<?php
namespace EcafeAddons\Widgets;

use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Utils;
use Elementor\Group_Control_Typography;
use Elementor\Core\Schemes\Typography;
use Elementor\Scheme_Color;
use Elementor\Group_Control_Background;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Box_Shadow;

use EcafeAddons\EcafeElementLoad;

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

class Ecafe_Toolset_Embeddedmedia extends Widget_Base {

	public function get_name() {
		return 'ecafe-toolset-embedded-media';
	}

	public function get_title() {
		return esc_html__( 'Toolset : Embedded Media', 'essential-classy-addons-for-elementor' );
	}

	public function get_icon() {
		return 'ecafe-ele-back-icon ecafe-toolset-icon';
	}

	public function get_categories() {
		return array( 'ectoolset' );
	}

	public function get_keywords() {
		return array( 'toolset', 'toolset embedded', 'embedded', 'embedded media', 'media' );
	}
	public function get_custom_help_url() {
		return 'https://store.kapasias.com/helpdesk/';
	}
	public function has_widget_inner_wrapper(): bool {
		return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
	}
	protected function register_controls() {

		$this->start_controls_section(
			'contentSection',
			array(
				'label' => esc_html__( 'Toolset : Embedded Media', 'essential-classy-addons-for-elementor' ),
				'tab'   => Controls_Manager::TAB_CONTENT,
			)
		);
		$this->add_control(
			'toolsetEmbedded',
			array(
				'label'       => esc_html__( 'Select Field', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::SELECT,
				'label_block' => true,
				'multiple'    => false,
				'groups'      => \EcafeHelper::ecGetToolsetFields( 'embed' ),
			)
		);
		$this->end_controls_section();

		/*Notice panel*/
		$ecwidgetdoclink = esc_url( 'https://ecaddons.com/docs/toolset-widget-tutorial/' );
		include ECAFE_PATH . 'element/widgets/ecafe-widgetpanel-help.php';
	}

	protected function render() {

		$settings = $this->get_settings_for_display();
		if ( defined( 'WPCF_VERSION' ) ) {
			$toolsetEmbedded = ! empty( $settings['toolsetEmbedded'] ) ? $settings['toolsetEmbedded'] : '';
			if ( ( types_render_field( $toolsetEmbedded ) ) ) {
				echo '<div class="eca-toolset-embedded">';
					echo ( types_render_field( $toolsetEmbedded ) );
				echo '</div>';
			}
		}
	}
}
