<?php

namespace Layerdrops\Ostech\Widgets;


class SidebarNavmenu extends \Elementor\Widget_Base
{
    public function get_name()
    {
        return 'sidebar-nav';
    }

    public function get_title()
    {
        return __('Sidebar Nav Menus', 'ostech-addon');
    }

    public function get_icon()
    {
        return 'eicon-cogs';
    }

    public function get_categories()
    {
        return ['ostech-category'];
    }

    protected function register_controls()
    {

        $this->start_controls_section(
            'layout_section',
            [
                'label' => __('Layout', 'ostech-addon'),
                'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
            ]
        );

        $this->add_control(
            'layout_type',
            [
                'label' => __('Select Layout', 'ostech-addon'),
                'type' => \Elementor\Controls_Manager::SELECT2,
                'default' => 'layout_one',
                'options' => [
                    'layout_one' => __('Layout One', 'ostech-addon'),
                    // 'layout_two' => __('Layout Two', 'ostech-addon'),
                ]
            ]
        );

        $this->end_controls_section();


        $this->start_controls_section(
            'content_section',
            [
                'label' => __('Content', 'ostech-addon'),
                'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
            ]
        );

        $this->add_control(
            'title',
            [
                'label' => __('Widget Title', 'ostech-addon'),
                'type' => \Elementor\Controls_Manager::TEXT,
                'default' => __('ALL SERVICES', 'ostech-addon'),
                'label_block' => true
            ]
        );

        ostech_elementor_heading_option($this, 'Widget Title', 'h3', 'layout_one');

        $nav_menus = new \Elementor\Repeater();

        $nav_menus->add_control(
            'nav_menu',
            [
                'label' => __('Select Nav Menu', 'ogency-addon'),
                'type' => \Elementor\Controls_Manager::SELECT2,
                'options' => ostech_get_nav_menu(),
                'label_block' => true,
            ]
        );


        $this->add_control(
            'nav_menus',
            [
                'label' => __('Nav Menus', 'ogency-addon'),
                'type' => \Elementor\Controls_Manager::REPEATER,
                'prevent_empty' => false,
                'fields' => $nav_menus->get_controls(),
            ]
        );

        $this->end_controls_section();

        //General style
        $this->start_controls_section(
            'general_style',
            [
                'label' => esc_html__('Style Options', 'ostech-addon'),
                'tab' => \Elementor\Controls_Manager::TAB_STYLE,
            ]
        );

        ostech_elementor_general_style_options($this, 'Title', '{{WRAPPER}} .service-sidebar__title.background-base', ['layout_one']);
        ostech_elementor_general_style_options($this, 'Active Nav Menu', '{{WRAPPER}} .services-details__services li.current a', ['layout_one']);
        ostech_elementor_general_style_options($this, 'Nav Menu', '{{WRAPPER}} .service-sidebar__nav li a', ['layout_one']);

        ostech_elementor_general_style_options($this, 'Background Color', '{{WRAPPER}}  .background-base', ['layout_one'], 'background-color', false);

        $this->end_controls_section();
    }

    protected function render()
    {
        $settings = $this->get_settings_for_display();
        include ostech_get_template('sidebar-nav-menu-one.php');
        // include ostech_get_template('sidebar-nav-menu-two.php');
    }
}
