<?php
/**
 * Customer Qr Block.
 *
 * @package Noesia_Commerce_Suite
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- View templates receive local variables from their renderer.
$settings      = isset( $settings ) && is_array( $settings ) ? $settings : Noesia_CS_Settings::get_all();
$access_title  = ! empty( $settings['order_care_access_card_title'] ) ? $settings['order_care_access_card_title'] : __( 'Your Order Care Hub', 'noesia-commerce-suite' );
$qr_label      = ! empty( $settings['order_care_access_card_text'] ) ? $settings['order_care_access_card_text'] : Noesia_CS_Settings::get( 'qr_label_text', __( 'Open your secure Order Care Hub for review, reorder and support.', 'noesia-commerce-suite' ) );
if ( 'Scan for order care' === $qr_label ) {
	$qr_label = __( 'Open your secure Order Care Hub for review, reorder and support.', 'noesia-commerce-suite' );
}
$access_button_label  = ! empty( $settings['order_care_access_button_label'] ) ? $settings['order_care_access_button_label'] : __( 'Open Order Care Hub', 'noesia-commerce-suite' );
$layout_style         = in_array( $settings['qr_card_layout_style'] ?? 'clean', array( 'clean', 'compact' ), true ) ? $settings['qr_card_layout_style'] : 'clean';
$button_style         = in_array( $settings['button_style'] ?? 'rounded', array( 'rounded', 'pill', 'minimal' ), true ) ? $settings['button_style'] : 'rounded';
?>
<div class="noesia-cs-public-passport-card noesia-cs-public-passport-card--<?php echo esc_attr( $layout_style ); ?> noesia-cs-button-style--<?php echo esc_attr( $button_style ); ?>">
	<div>
		<span class="noesia-cs-public-passport-card__eyebrow"><?php esc_html_e( 'After-sales access', 'noesia-commerce-suite' ); ?></span>
		<strong><?php echo esc_html( $access_title ); ?></strong>
		<p><?php echo esc_html( $qr_label ); ?></p>
		<a class="noesia-cs-public-button" href="<?php echo esc_url( $url ); ?>" rel="nofollow noindex"><?php echo esc_html( $access_button_label ); ?></a>
	</div>
	<div class="noesia-cs-public-qr" data-noesia-cs-qr="<?php echo esc_url( $url ); ?>" data-noesia-cs-qr-size="<?php echo esc_attr( max( 80, min( 420, absint( Noesia_CS_Settings::get( 'qr_size', 160 ) ) ) ) ); ?>" data-noesia-cs-qr-foreground="<?php echo esc_attr( Noesia_CS_Settings::get( 'qr_foreground_color', '#111827' ) ); ?>" data-noesia-cs-qr-background="<?php echo esc_attr( Noesia_CS_Settings::get( 'qr_background_color', '#ffffff' ) ); ?>"></div>
</div>
