<?php
    /**
     * Frontpage shortcode one Section
     * 
     * @package Blog Bee
     * @since 1.0.0
     */
    namespace BBE\Customizer\Section;

    use BBE\Customizer\Section\Section as Section;
    use BBE\Customizer\Theme_Defaults as Theme_Defaults;
    use BBE\Helpers;

    use function esc_html__;
    use function get_template_directory_uri;

    if( ! class_exists( __NAMESPACE__ . '\\Frontpage_ShortCode_One' ) ) {
        /**
         * Web stories class
         */
        class Frontpage_ShortCode_One extends Section {
            /**
             * Section Id
             * 
             * @since 1.0.0
             * @var string
             */
            public static $id = 'bbe-frontpage-shortcode-one';

            /**
             * Register controls
             * 
             * @since 1.0.0
             */
            public function register_controls() {
                $this->tab = 'general';
                $this->add_section( 'frontpage_shortcode_one_section' );
                $this->add_control( 'frontpage_shortcode_one_field' );
            }

            /**
             * Settings
             * 
             * @since 1.0.0
             */
            public function get_settings( $id = '' ) {
                $settings = [
                    'frontpage_shortcode_one_field' =>  [
                        'sanitize_callback' =>  'sanitize_text_field',
                        'default'   =>  Theme_Defaults::get_defaults( $id )
                    ],
                ];
                return $id ? $settings[ $id ] : $settings;
            }

            /**
             * Controls
             * 
             * @since 1.0.0
             */
            public function get_controls( $id = '' ) {
                $controls = [
                    'frontpage_shortcode_one_section' =>  [
                        'title' =>  esc_html__( 'Shortcode 1', 'blog-bee' ),
                        'active_callback'   =>  function() {
                            return Helpers::get_reorder_value( 'section_reorder_fields', 'shortcode-one' );
                        },
                        'section_to_open' =>  'section_reorder_section'
                    ],
                    'frontpage_shortcode_one_field' =>  [
                        'label' =>  esc_html__( 'Shortcode', 'blog-bee' ),
                        'type'  =>  'bbe-text'
                    ],
                ];
                return $id ? $controls[ $id ] : $controls;
            }

            /**
             * Defaults
             * 
             * @since 1.0.0
             */
            public function set_defaults() {
                Theme_Defaults::update_theme_defaults( [
                    'frontpage_shortcode_one_field' =>  '',
                ] );
            }

            /**
             * Get dynamic css args
             * 
             * @since 1.0.0
             */
            public function get_dynamic_css_args(): array {
                $dynamic_args = [
                    
                ];
                return $dynamic_args;
            }

            /**
             * Render HTML
             * 
             * @since 1.0.0
             */
            public function render_html() {
                $shortcode = Theme_Defaults::get_theme_option( 'frontpage_shortcode_one_field' );
                if( ! $shortcode ) return;

                $block_class[] = self::$id;
                $block_class[] = 'shortcode-area';
                ?>
                    <section class="<?php echo esc_attr( implode( ' ', $block_class ) ); ?>" <?php Helpers::the_aos_data_attr(); ?>>
                        <div class="bbe-container">
                            <div class="row">
                                <?php
                                    echo do_shortcode( $shortcode ); 
                                ?>
                            </div>
                        </div>
                    </section>
                <?php
            }
        }
        Frontpage_ShortCode_One::get_instance();
    }