<?php

namespace Unlockafe_addons\Widgets;

use Unlockafe_addons\Traits\Utils as UnlockafeUtils;
use Unlockafe_addons\Traits\Widget_helper;
use Elementor\Element_Section;
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use \Elementor\Utils;
use \Elementor\Control_Media;
use \Elementor\Repeater;
use \Elementor\Group_Control_Border;
use \Elementor\Group_Control_Box_Shadow;
use \Elementor\Group_Control_Text_Shadow;
use \Elementor\Group_Control_Typography;
use \Elementor\Group_Control_Background;

if (!defined('ABSPATH'))
	exit; // Exit if accessed directly

/**
 * Awards Widget
 *
 * @since 1.0.0
 */
class Awards extends Widget_Base
{

	use Widget_helper, UnlockafeUtils;

	/**
	 * Retrieve the widget name.
	 *
	 * @since 1.0.0
	 *
	 * @access public
	 *
	 * @return string Widget name.
	 */
	public function get_name()
	{
		return 'unlockafe-awards';
	}

	/**
	 * Retrieve the widget title.
	 *
	 * @since 1.0.0
	 *
	 * @access public
	 *
	 * @return string Widget title.
	 */
	public function get_title()
	{
		return __('WPRealizer - Awards', 'unlock-addons-for-elementor');
	}

	/**
	 * Retrieve the widget icon.
	 *
	 * @since 1.0.0
	 *
	 * @access public
	 *
	 * @return string Widget icon.
	 */
	public function get_icon()
	{
		return 'eicon-trophy ulicon';
	}

	/**
	 * Retrieve the list of categories the widget belongs to.
	 *
	 * Used to determine where to display the widget in the editor.
	 *
	 * Note that currently Elementor supports only one category.
	 * When multiple categories passed, Elementor uses the first one.
	 *
	 * @since 1.0.0
	 *
	 * @access public
	 *
	 * @return array Widget categories.
	 */
	public function get_categories()
	{
		return ['unlockafe-addons'];
	}

	/**
	 * Retrieve the list of scripts the widget depended on.
	 *
	 * Used to set scripts dependencies required to run the widget.
	 *
	 * @since 1.0.0
	 *
	 * @access public
	 *
	 * @return array Widget scripts dependencies.
	 */
	public function get_script_depends()
	{
		return [];
	}

	public function get_style_depends()
	{
		return ['unlockafe-global'];
	}

	/**
	 * Register the widget controls.
	 *
	 * Adds different input fields to allow the user to change and customize the widget settings.
	 *
	 * @since 1.0.0
	 *
	 * @access protected
	 */

	protected function register_controls()
	{
		$this->register_controls_section();
		$this->style_tab_content();
	}

	protected function register_controls_section()
	{

		// layout Panel
		$this->start_controls_section(
			'wpr_layout',
			[
				'label' => esc_html__('Design Layout', 'unlock-addons-for-elementor'),
			]
		);

		$this->add_control(
			'wpr_design_style',
			[
				'label' => esc_html__('Select Layout', 'unlock-addons-for-elementor'),
				'type' => Controls_Manager::SELECT,
				'options' => [
					'layout-1' => esc_html__('Layout 1', 'unlock-addons-for-elementor'),
					'layout-2' => esc_html__('Layout 2', 'unlock-addons-for-elementor'),

				],
				'default' => 'layout-1',
			]
		);

		$this->add_control(
			'wpr_awards_arrow_switcher',
			[
				'label' => esc_html__('Arrow SWITCHER', 'unlock-addons-for-elementor'),
				'type' => \Elementor\Controls_Manager::SWITCHER,
				'label_on' => esc_html__('Yes', 'unlock-addons-for-elementor'),
				'label_off' => esc_html__('No', 'unlock-addons-for-elementor'),
				'return_value' => 'yes',
				'default' => 'yes',
				'separator' => 'before',
				'condition' => [
					'wpr_design_style' => ['layout-4']
				]
			]
		);

		$this->end_controls_section();

		// Awards Sections
		$this->start_controls_section(
			'awardsContentSec',
			[
				'label' => esc_html__('Awards Content', 'unlock-addons-for-elementor'),
				'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
				'condition' => [
					'wpr_design_style' => ['layout-10']
				]
			]
		);

		$this->add_control(
			'wpr_title',
			[
				'label' => esc_html__('Title', 'unlock-addons-for-elementor'),
				'description' => $this->tp_get_allowed_html_desc('intermediate'),
				'type' => Controls_Manager::TEXT,
				'default' => esc_html__('WPR Title Here', 'unlock-addons-for-elementor'),
				'placeholder' => esc_html__('Type Heading Text', 'unlock-addons-for-elementor'),
				'label_block' => true,
			]
		);

		$this->add_control(
			'wpr_title_tag',
			[
				'label' => esc_html__('Title HTML Tag', 'unlock-addons-for-elementor'),
				'type' => Controls_Manager::CHOOSE,
				'options' => [
					'h1' => [
						'title' => esc_html__('H1', 'unlock-addons-for-elementor'),
						'icon' => 'eicon-editor-h1'
					],
					'h2' => [
						'title' => esc_html__('H2', 'unlock-addons-for-elementor'),
						'icon' => 'eicon-editor-h2'
					],
					'h3' => [
						'title' => esc_html__('H3', 'unlock-addons-for-elementor'),
						'icon' => 'eicon-editor-h3'
					],
					'h4' => [
						'title' => esc_html__('H4', 'unlock-addons-for-elementor'),
						'icon' => 'eicon-editor-h4'
					],
					'h5' => [
						'title' => esc_html__('H5', 'unlock-addons-for-elementor'),
						'icon' => 'eicon-editor-h5'
					],
					'h6' => [
						'title' => esc_html__('H6', 'unlock-addons-for-elementor'),
						'icon' => 'eicon-editor-h6'
					]
				],
				'default' => 'h2',
				'toggle' => false,
			]
		);

		$this->add_responsive_control(
			'wpr_align',
			[
				'label' => esc_html__('Alignment', 'unlock-addons-for-elementor'),
				'type' => Controls_Manager::CHOOSE,
				'options' => [
					'left' => [
						'title' => esc_html__('Left', 'unlock-addons-for-elementor'),
						'icon' => 'eicon-text-align-left',
					],
					'center' => [
						'title' => esc_html__('Center', 'unlock-addons-for-elementor'),
						'icon' => 'eicon-text-align-center',
					],
					'right' => [
						'title' => esc_html__('Right', 'unlock-addons-for-elementor'),
						'icon' => 'eicon-text-align-right',
					],
				],
				'toggle' => false,
				'selectors' => [
					'{{WRAPPER}} .tp-align' => 'text-align: {{VALUE}};'
				]
			]
		);

		$this->add_control(
			'wpr_description',
			[
				'label' => esc_html__('Description', 'unlock-addons-for-elementor'),
				'description' => $this->tp_get_allowed_html_desc('intermediate'),
				'type' => Controls_Manager::TEXTAREA,
				'default' => esc_html__('This is description text here.', 'unlock-addons-for-elementor'),
				'placeholder' => esc_html__('Type section description here', 'unlock-addons-for-elementor'),
				'label_block' => true,
			]
		);

		$this->end_controls_section();

		// award section
		$this->start_controls_section(
			'wpr_award_section',
			[
				'label' => __('Awards Repeater Item', 'unlock-addons-for-elementor'),
				'tab' => Controls_Manager::TAB_CONTENT,
			]
		);

		$repeater = new Repeater();

		$repeater->add_control(
			'repeater_condition',
			[
				'label' => __('Field condition', 'unlock-addons-for-elementor'),
				'type' => Controls_Manager::SELECT,
				'options' => [
					'style_1' => __('Style 1', 'unlock-addons-for-elementor'),
					'style_2' => __('Style 2', 'unlock-addons-for-elementor'),
					// 'style_3' => __('Style 3', 'unlock-addons-for-elementor'),
				],
				'default' => 'style_1',
				'frontend_available' => true,
				'style_transfer' => true,
			]
		);

		$repeater->add_control(
			'award_border_color',
			[
				'label' => __('Border Hover Color', 'unlock-addons-for-elementor'),
				'type' => Controls_Manager::COLOR,
				'default' => '#FD5D39',
				'selectors' => [
					'{{WRAPPER}} .award-box-2:hover' => 'border-color: {{VALUE}};',
				],
				'condition' => [
					'repeater_condition' => ['style_1']
				]
			]
		);

		$repeater->add_control(
			'award_animation_delay',
			[
				'label' => esc_html__('Animation Delay', 'unlock-addons-for-elementor'),
				'type' => Controls_Manager::TEXT,
				'default' => esc_html__('.2', 'unlock-addons-for-elementor'),
				'description' => $this->tp_get_allowed_html_desc('intermediate'),
				'label_block' => true,
				'condition' => [
					'repeater_condition' => ['style_11']
				]
			]
		);

		$repeater->add_control(
			'award_image',
			[
				'label' => esc_html__('Award Image', 'unlock-addons-for-elementor'),
				'type' => Controls_Manager::MEDIA,
				'default' => [
					'url' => Utils::get_placeholder_image_src(),
				],
				'condition' => [
					'repeater_condition' => ['style_2']
				]
			]
		);

		$repeater->add_control(
			'award_year',
			[
				'label' => esc_html__('Award Year', 'unlock-addons-for-elementor'),
				'type' => Controls_Manager::TEXT,
				'default' => esc_html__('2024', 'unlock-addons-for-elementor'),
				'description' => $this->tp_get_allowed_html_desc('intermediate'),
				'label_block' => true,
				'condition' => [
					'repeater_condition' => ['style_2']
				]
			]
		);

		$repeater->add_control(
			'award_title',
			[
				'label' => esc_html__('Award Title', 'unlock-addons-for-elementor'),
				'type' => Controls_Manager::TEXT,
				'default' => esc_html__('Black book', 'unlock-addons-for-elementor'),
				'description' => $this->tp_get_allowed_html_desc('intermediate'),
				'label_block' => true,
				'condition' => [
					'repeater_condition' => ['style_1', 'style_2']
				]
			]
		);

		$repeater->add_control(
			'award_desc',
			[
				'label' => esc_html__('Award Description', 'unlock-addons-for-elementor'),
				'type' => Controls_Manager::TEXTAREA,
				'default' => esc_html__('Award Description', 'unlock-addons-for-elementor'),
				'description' => $this->tp_get_allowed_html_desc('intermediate'),
				'label_block' => true,
				'condition' => [
					'repeater_condition' => ['style_10']
				]
			]
		);

		$repeater->add_control(
			'award_shape_img',
			[
				'label' => esc_html__('Shape Image 1', 'unlock-addons-for-elementor'),
				'type' => Controls_Manager::MEDIA,
				'default' => [
					'url' => Utils::get_placeholder_image_src(),
				],
				'condition' => [
					'repeater_condition' => ['style_20']
				]
			]
		);

		$repeater->add_control(
			'award_cat',
			[
				'label' => esc_html__('Award Category', 'unlock-addons-for-elementor'),
				'type' => Controls_Manager::TEXTAREA,
				'default' => esc_html__('Clutch', 'unlock-addons-for-elementor'),
				'description' => $this->tp_get_allowed_html_desc('intermediate'),
				'label_block' => true,
				'condition' => [
					'repeater_condition' => ['style_2']
				]
			]
		);

		$repeater->add_control(
			'wpr_btn_link_switcher',
			[
				'label' => esc_html__('Button', 'unlock-addons-for-elementor'),
				'type' => \Elementor\Controls_Manager::SWITCHER,
				'label_on' => esc_html__('Yes', 'unlock-addons-for-elementor'),
				'label_off' => esc_html__('No', 'unlock-addons-for-elementor'),
				'return_value' => 'yes',
				'default' => 'no',
				'separator' => 'before',
				'condition' => [
					'repeater_condition' => ['style_10']
				]
			]
		);

		$repeater->add_control(
			'wpr_btn_text',
			[
				'label' => esc_html__('Button Text', 'unlock-addons-for-elementor'),
				'type' => Controls_Manager::TEXT,
				'default' => esc_html__('Button Text', 'unlock-addons-for-elementor'),
				'title' => esc_html__('Enter button text', 'unlock-addons-for-elementor'),
				'label_block' => false,
				'condition' => [
					'wpr_btn_link_switcher' => 'yes',
					'repeater_condition' => ['style_10']
				],
			]
		);

		$repeater->add_control(
			'wpr_btn_link_type',
			[
				'label' => esc_html__('Button Link Type', 'unlock-addons-for-elementor'),
				'type' => \Elementor\Controls_Manager::SELECT,
				'options' => [
					'1' => 'Custom Link',
					'2' => 'Internal Page',
				],
				'default' => '1',
				'condition' => [
					'wpr_btn_link_switcher' => 'yes',
				]
			]
		);
		$repeater->add_control(
			'wpr_btn_link',
			[
				'label' => esc_html__('Button Link', 'unlock-addons-for-elementor'),
				'type' => \Elementor\Controls_Manager::URL,
				'dynamic' => [
					'active' => true,
				],
				'placeholder' => esc_html__('https://your-link.com', 'unlock-addons-for-elementor'),
				'show_external' => true,
				'default' => [
					'url' => '#',
					'is_external' => false,
					'nofollow' => false,
				],
				'condition' => [
					'wpr_btn_link_type' => '1',
					'wpr_btn_link_switcher' => 'yes',
				]
			]
		);
		$repeater->add_control(
			'wpr_btn_page_link',
			[
				'label' => esc_html__('Select Button Link Page', 'unlock-addons-for-elementor'),
				'type' => \Elementor\Controls_Manager::SELECT2,
				'label_block' => true,
				'options' => $this->tp_get_all_pages(),
				'condition' => [
					'wpr_btn_link_type' => '2',
					'wpr_btn_link_switcher' => 'yes',
				]
			]
		);

		$nested_repeater = new \Elementor\Repeater();

		$nested_repeater->add_control(
			'nested_award_image',
			[
				'label' => esc_html__('Award Image', 'unlock-addons-for-elementor'),
				'type' => Controls_Manager::MEDIA,
				'default' => [
					'url' => Utils::get_placeholder_image_src(),
				]
			]
		);

		// Add controls to the nested repeater
		$nested_repeater->add_control(
			'nested_award_title',
			[
				'label' => esc_html__('Nested Title', 'unlock-addons-for-elementor'),
				'type' => \Elementor\Controls_Manager::TEXT,
				'default' => esc_html__('Nested Item Title', 'unlock-addons-for-elementor'),
				'label_block' => true,
			]
		);

		$nested_repeater->add_control(
			'nested_award_cat',
			[
				'label' => esc_html__('Award Category', 'unlock-addons-for-elementor'),
				'type' => Controls_Manager::TEXTAREA,
				'default' => esc_html__('Site of The Day', 'unlock-addons-for-elementor'),
				'description' => $this->tp_get_allowed_html_desc('intermediate'),
				'label_block' => true,
			]
		);

		$nested_repeater->add_control(
			'nested_award_date',
			[
				'label' => esc_html__('Award Date', 'unlock-addons-for-elementor'),
				'type' => Controls_Manager::TEXTAREA,
				'default' => esc_html__('February 2024', 'unlock-addons-for-elementor'),
				'description' => $this->tp_get_allowed_html_desc('intermediate'),
				'label_block' => true,
			]
		);

		// Add the nested repeater to the main repeater
		$repeater->add_control(
			'nested_items',
			[
				'label' => esc_html__('Body Items', 'unlock-addons-for-elementor'),
				'type' => \Elementor\Controls_Manager::REPEATER,
				'fields' => $nested_repeater->get_controls(),
				'default' => [
					[
						'nested_award_title' => esc_html__('abstract design', 'unlock-addons-for-elementor'),
					],
					[
						'nested_award_title' => esc_html__('abstract design', 'unlock-addons-for-elementor'),
					],
				],
				'title_field' => '{{{ nested_award_title }}}',
				// Optional: Add condition if you want this to appear only for specific styles
				'condition' => [
					'repeater_condition' => ['style_1'] // or whatever style you want
				]
			]
		);
		// End controls to the nested repeater

		$repeater->end_controls_tab();
		$repeater->end_controls_tab();


		$this->add_control(
			'wpr_award_slides',
			[
				'show_label' => false,
				'type' => Controls_Manager::REPEATER,
				'fields' => $repeater->get_controls(),
				'title_field' => esc_html__('Awards Item', 'unlock-addons-for-elementor'),
				'default' => [
					[
						'award_title' => __('Influencer Marketing', 'unlock-addons-for-elementor')
					],
					[
						'award_title' => __('Others Award', 'unlock-addons-for-elementor')
					],
				]
			]
		);

		$this->end_controls_section();
	}

	protected function style_tab_content()
	{

		// $this->tp_section_style_controls(
		//     'awards_section',
		//     'Section - Style',
		//     '.wpr-el-section'
		// );

		// $this->tp_basic_style_controls(
		//     'awards_title',
		//     'Heading Title',
		//     '.wpr-el-title'
		// );

		// $this->tp_basic_style_controls(
		//     'awards_desc',
		//     'Heading Description',
		//     '.wpr-el-desc'
		// );

		$this->tp_basic_style_controls('award_main_title', 'Awards Main Title', '.wpr-el-title', ['layout-1']);
		$this->tp_box_controls_style('wpr_rep_box_style', 'Box - Style', '.wpr-el-box', ['layout-2']);
		$this->tp_basic_style_controls('award_title', 'Awards Title', '.wpr-el-rep-title', ['layout-1', 'layout-2']);
		// $this->tp_basic_style_controls('award_desc', 'Awards Description', '.wpr-el-rep-desc');
		$this->tp_basic_style_controls('awards_year', 'Awards Year', '.wpr-el-rep-year');
		$this->tp_basic_style_controls('award_cat', 'Awards Category', '.wpr-el-rep-cat');
		// $this->tp_link_controls_style('', 'award_btn_style', 'Award Button', '.wpr-el-rep-btn', ['layout-11', 'layout-22']);

		// Image -Icon 
		$this->start_controls_section(
			'wpr_awards_btn_section',
			[
				'label' => esc_html__('Image - Icon - SVG', 'unlock-addons-for-elementor'),
				'tab'   => \Elementor\Controls_Manager::TAB_STYLE,
			]
		);

		// icon 
		$this->start_controls_tabs(
			'wpr_awards_btn_tabs'
		);

		$this->start_controls_tab(
			'wpr_awards_btn_tab',
			[
				'label' => esc_html__('Icon', 'unlock-addons-for-elementor'),
			]
		);

		$this->add_responsive_control(
			'wpr_awards_btn_icon_color',
			[
				'label' => esc_html__('Icon Color', 'unlock-addons-for-elementor'),
				'type' => \Elementor\Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .wpr-el-award-btn span i' => 'color: {{VALUE}}',
				],
			]
		);


		$this->add_responsive_control(
			'wpr_awards_btn_icon_font-size',
			[
				'label' => esc_html__('Font Size', 'unlock-addons-for-elementor'),
				'type' => \Elementor\Controls_Manager::SLIDER,
				'size_units' => ['px', '%', 'em', 'rem', 'custom'],
				'range' => [
					'px' => [
						'min' => 0,
						'max' => 300,
						'step' => 5,
					],
					'%' => [
						'min' => 0,
						'max' => 100,
					],
				],
				'selectors' => [
					'{{WRAPPER}} .wpr-el-award-btn span i' => 'font-size: {{SIZE}}{{UNIT}};',
				],
			]
		);

		$this->end_controls_tab();

		// image 
		$this->start_controls_tab(
			'wpr_awards_btn_image_tab',
			[
				'label' => esc_html__('Image', 'unlock-addons-for-elementor'),
			]
		);

		$this->add_responsive_control(
			'wpr_awards_image_w',
			[
				'type' => \Elementor\Controls_Manager::SLIDER,
				'label' => esc_html__('Image Width', 'unlock-addons-for-elementor'),
				'size_units' => ['px', '%'],
				'range' => [
					'px' => [
						'min' => 1,
						'max' => 2000,
					],
				],
				'selectors' => [
					'{{WRAPPER}} .wpr-el-award-img img' => 'min-width: {{SIZE}}{{UNIT}};',
				],
			]
		);
		$this->add_responsive_control(
			'wpr_awards_image_h',
			[
				'type' => \Elementor\Controls_Manager::SLIDER,
				'label' => esc_html__('Image Height', 'unlock-addons-for-elementor'),
				'size_units' => ['px', '%'],
				'range' => [
					'px' => [
						'min' => 1,
						'max' => 2000,
					],
				],
				'selectors' => [
					'{{WRAPPER}} .wpr-el-award-img img' => 'height: {{SIZE}}{{UNIT}};',
				],
			]
		);

		$this->add_control(
			'wpr_image_object_style',
			[
				'label' => esc_html__('Object Fit', 'unlock-addons-for-elementor'),
				'type' => \Elementor\Controls_Manager::SELECT,
				'default' => 'cover',
				'options' => [
					'none' => esc_html__('None', 'unlock-addons-for-elementor'),
					'contain'  => esc_html__('Contain', 'unlock-addons-for-elementor'),
					'cover' => esc_html__('Cover', 'unlock-addons-for-elementor'),
					'fill' => esc_html__('fill', 'unlock-addons-for-elementor'),
				],
				'selectors' => [
					'{{WRAPPER}} .wpr-el-award-img img' => 'object-fit: {{VALUE}};',
				],
			]
		);

		$this->end_controls_tab();

		// svg
		$this->start_controls_tab(
			'wpr_awards_btn_svg_tab',
			[
				'label' => esc_html__('SVG', 'unlock-addons-for-elementor'),
			]
		);
		$this->add_responsive_control(
			'wpr_awards_btn_svg_w',
			[
				'type' => \Elementor\Controls_Manager::SLIDER,
				'label' => esc_html__('SVG Width', 'unlock-addons-for-elementor'),
				'size_units' => ['px', '%'],
				'range' => [
					'px' => [
						'min' => 1,
						'max' => 300,
					],
				],
				'selectors' => [
					'{{WRAPPER}} .wpr-el-award-btn span svg' => 'height: {{SIZE}}{{UNIT}};',
				],
			]
		);

		$this->end_controls_tab();

		$this->end_controls_tabs();
		//  end tab 

		$this->add_responsive_control(
			'wpr_awards_btn_bg',
			[
				'label' => esc_html__('Background Color', 'unlock-addons-for-elementor'),
				'type' => \Elementor\Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .wpr-el-award-btn span::before' => 'background: {{VALUE}}',
				],
			]
		);

		$this->add_group_control(
			Group_Control_Border::get_type(),
			[
				'name' => 'tp_my_awards_btn_normal_border_style',
				'selector' => '{{WRAPPER}} .wpr-el-award-btn span::before',
			]
		);

		$this->add_responsive_control(
			'wpr_awards_btn_bg_margin',
			[
				'label' => esc_html__('Margin', 'unlock-addons-for-elementor'),
				'type' => Controls_Manager::DIMENSIONS,
				'size_units' => ['px', '%', 'em', 'rem', 'custom'],
				'selectors' => [
					'{{WRAPPER}} .wpr-el-award-btn span i, {{WRAPPER}} .wpr-el-award-img img , {{WRAPPER}} .wpr-el-award-btn span svg' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				],
			]
		);

		$this->add_responsive_control(
			'wpr_awards_btn_bg_padding',
			[
				'label' => esc_html__('Padding', 'unlock-addons-for-elementor'),
				'type' => \Elementor\Controls_Manager::DIMENSIONS,
				'size_units' => ['px', '%', 'em', 'rem', 'custom'],
				'selectors' => [
					'{{WRAPPER}} .wpr-el-award-btn span i, {{WRAPPER}} .wpr-el-award-btn span img , {{WRAPPER}} .wpr-el-award-btn span svg' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				],
			]
		);

		$this->end_controls_section();
	}

	/**
	 * Render the widget output on the frontend.
	 *
	 * Written in PHP and used to generate the final HTML.
	 *
	 * @since 1.0.0
	 *
	 * @access protected
	 */
	protected function render()
	{
		$settings = $this->get_settings_for_display();
		$btn_id = 'theme_btn';
?>

		<?php if ($settings['wpr_design_style'] == 'layout-2'): ?>

			<!-- awards area start  -->
			<div id="awards" class="awards-area">
				<div class="awards-area-inner">
					<div class="awards-wrapper-box fade-anim">
						<div class="awards-wrapper">
							<?php foreach ($settings['wpr_award_slides'] as $key => $item):

								$award_image = $this->tp_get_img($item, 'award_image', 'full', false);
								$award_image_alt = get_post_meta($item["award_image"]["id"], "_wp_attachment_image_alt", true);
							?>
								<div class="wpr-el-box award-box-1 fade-anim">
									<?php if (!empty($item['award_title'])): ?>
										<h3 class="title wpr-el-rep-title"><?php echo $this->tp_kses($item['award_title']); ?></h3>
									<?php endif; ?>
									<?php if (!empty($item['award_year'])): ?>
										<span class="year wpr-el-rep-year"><?php echo $this->tp_kses($item['award_year']); ?></span>
									<?php endif; ?>
									<?php if (!empty($item['award_image'])): ?>
										<div class="thumb wpr-el-award-img">
											<img src="<?php echo esc_url($award_image['award_image']); ?>"
												alt="<?php echo esc_attr($award_image_alt); ?>" />
										</div>
									<?php endif; ?>
									<?php if (!empty($item['award_cat'])): ?>
										<span class="category wpr-el-rep-cat"><?php echo $this->tp_kses($item['award_cat']); ?></span>
									<?php endif; ?>
								</div>
							<?php endforeach; ?>
						</div>
					</div>
				</div>
			</div>
			<!-- awards area end  -->

		<?php else: ?>

			<!-- awards area start  -->
			<section class="awards-area-2">
				<div class="awards-area-2-inner">
					<div class="awards-wrapper-box fade-anim">
						<div class="container">
							<div class="awards-wrapper">
								<?php foreach ($settings['wpr_award_slides'] as $key => $item):

								?>
									<div class="site-group fade-anim">
										<?php if (!empty($item['award_title'])): ?>
											<h2 class="group-title wpr-el-title">
												<?php echo $this->tp_kses($item['award_title']); ?>
											</h2>
										<?php endif; ?>
										<div class="group-wrapper">
											<?php
											if (!empty($item['nested_items']) && is_array($item['nested_items'])) :

												foreach ($item['nested_items'] as $nested_item) :

													// Use $nested_item instead of $item
													$award_image = $this->tp_get_img($nested_item, 'nested_award_image', 'full', false);

													// Ensure 'nested_award_image' exists and has an 'id' key
													$award_image_alt = isset($nested_item["nested_award_image"]["id"])
														? get_post_meta($nested_item["nested_award_image"]["id"], "_wp_attachment_image_alt", true)
														: '';
											?>
													<div class="award-box-2">
														<?php if (!empty($nested_item['nested_award_image'])): ?>
															<div class="thumb wpr-el-award-img">
																<img src="<?php echo esc_url($award_image['nested_award_image']); ?>"
																	alt="<?php echo esc_attr($award_image_alt); ?>" />
															</div>
														<?php endif; ?>

														<div class="award-title-wrapper">
															<?php if (!empty($nested_item['nested_award_title'])): ?>
																<h3 class="title wpr-el-rep-title">
																	<?php echo $this->tp_kses($nested_item['nested_award_title']); ?>
																</h3>
															<?php endif; ?>

															<?php if (!empty($nested_item['nested_award_cat'])): ?>
																<span class="category wpr-el-rep-cat">
																	<?php echo $this->tp_kses($nested_item['nested_award_cat']); ?>
																</span>
															<?php endif; ?>
														</div>

														<?php if (!empty($nested_item['nested_award_date'])): ?>
															<span class="year wpr-el-rep-year">
																<?php echo $this->tp_kses($nested_item['nested_award_date']); ?>
															</span>
														<?php endif; ?>
													</div>
											<?php
												endforeach;
											endif;
											?>
										</div>
									</div>
								<?php endforeach; ?>
							</div>
						</div>
					</div>
				</div>
			</section>
			<!-- awards area end  -->

<?php endif;
	}
}


