<?php

/**
 * Handle field imports with comprehensive demo content.
 *
 * @package    Extra_Product_Options_For_WooCommerce
 * @subpackage Extra_Product_Options_For_WooCommerce/includes
 * @since      3.0.9
 * @since      4.4.0 Added multiple demo addons with all field types.
 */
if ( !defined( 'ABSPATH' ) ) {
    exit;
}
/**
 * Import functionality for Extra Product Options for WooCommerce
 *
 * This class handles the import of predefined fields into the plugin.
 * It provides functionality to import demo addons showcasing all field types.
 *
 * @since 3.0.9
 */
class EPOFW_Import {
    /**
     * Initialize the import functionality
     */
    public static function init() {
        add_action( 'admin_post_epofw_import_all_fields', array(__CLASS__, 'import_all_fields') );
        add_action( 'wp_ajax_epofw_import_all_fields_ajax', array(__CLASS__, 'import_all_fields_ajax') );
        // Check for pending demo import (set during activation).
        add_action( 'admin_init', array(__CLASS__, 'maybe_import_demo_addons_on_activation'), 20 );
    }

    /**
     * Import demo addons on first activation
     *
     * This runs on admin_init to ensure custom tables are ready.
     * Only imports if pending flag is set and demos haven't been imported yet.
     *
     * @since 4.4.5
     */
    public static function maybe_import_demo_addons_on_activation() {
        // Check if pending import flag is set.
        if ( 'yes' !== get_option( 'epofw_pending_demo_import' ) ) {
            return;
        }
        // Check if demos already imported.
        if ( get_option( 'epofw_demo_addons_imported' ) ) {
            delete_option( 'epofw_pending_demo_import' );
            return;
        }
        // Check if custom tables are enabled and ready.
        if ( !class_exists( 'EPOFW_Custom_Tables' ) || !EPOFW_Custom_Tables::is_enabled() ) {
            return;
        }
        // Import demo addons silently.
        self::import_demo_addons_silently();
        // Mark as imported and remove pending flag.
        update_option( 'epofw_demo_addons_imported', 'yes' );
        delete_option( 'epofw_pending_demo_import' );
    }

    /**
     * Import demo addons silently (without redirect)
     *
     * Used for automatic import on first activation.
     *
     * @since 4.4.5
     * @return int Number of addons imported.
     */
    public static function import_demo_addons_silently() {
        $fields = self::get_all_demo_addons();
        $imported_count = 0;
        // Register post type if it doesn't exist.
        if ( !post_type_exists( EPOFW_DFT_POST_TYPE ) ) {
            register_post_type( EPOFW_DFT_POST_TYPE, array(
                'labels' => array(
                    'name'          => esc_html__( 'Extra Product Option', 'extra-product-options-for-woocommerce' ),
                    'singular_name' => esc_html__( 'Extra Product Option', 'extra-product-options-for-woocommerce' ),
                ),
            ) );
        }
        // Save each addon, but never override existing ones.
        foreach ( $fields as $field_group ) {
            $addon_name = ( isset( $field_group['epofw_addon_name'] ) ? $field_group['epofw_addon_name'] : 'Demo Addon' );
            // If an addon with the same title already exists, skip creating another.
            if ( self::get_existing_addon_id_by_title( $addon_name ) ) {
                continue;
            }
            $post_data = array(
                'post_title'  => $addon_name,
                'post_status' => 'draft',
                'post_type'   => EPOFW_DFT_POST_TYPE,
            );
            $post_id = wp_insert_post( $post_data, true );
            if ( is_wp_error( $post_id ) || !$post_id ) {
                continue;
            }
            // Transform demo data structure to match custom tables format.
            $transformed_data = self::transform_demo_data_for_custom_tables( $field_group );
            // Save to custom tables.
            EPOFW_Custom_Tables::save_addon( $post_id, $transformed_data );
            ++$imported_count;
        }
        return $imported_count;
    }

    /**
     * Check if demo addons have been imported
     *
     * @since 4.4.5
     * @return bool True if demos already imported.
     */
    public static function is_demo_imported() {
        return (bool) get_option( 'epofw_demo_addons_imported' );
    }

    /**
     * Handle importing all predefined fields with new section-based structure
     */
    public static function import_all_fields() {
        if ( !current_user_can( 'manage_woocommerce' ) ) {
            wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'extra-product-options-for-woocommerce' ) );
        }
        check_admin_referer( 'epofw_import_fields_nonce' );
        $fields = self::get_all_demo_addons();
        // Save each addon but never override existing ones.
        foreach ( $fields as $field_group ) {
            $addon_name = ( isset( $field_group['epofw_addon_name'] ) ? $field_group['epofw_addon_name'] : '' );
            if ( '' === $addon_name ) {
                continue;
            }
            if ( self::get_existing_addon_id_by_title( $addon_name ) ) {
                continue;
            }
            $post_data = array(
                'post_title'  => $addon_name,
                'post_status' => 'draft',
                'post_type'   => EPOFW_DFT_POST_TYPE,
            );
            $post_id = wp_insert_post( $post_data );
            if ( $post_id ) {
                // Transform demo data structure to match custom tables format.
                $transformed_data = self::transform_demo_data_for_custom_tables( $field_group );
                // Save to custom tables.
                EPOFW_Custom_Tables::save_addon( $post_id, $transformed_data );
            }
        }
        // Mark demos as imported so button gets disabled.
        update_option( 'epofw_demo_addons_imported', 'yes' );
        wp_safe_redirect( add_query_arg( array(
            'page'    => 'epofw-main',
            'tab'     => 'field-section',
            'message' => 'imported',
        ), admin_url( 'admin.php' ) ) );
        exit;
    }

    /**
     * Handle AJAX import request
     */
    public static function import_all_fields_ajax() {
        // Check permissions.
        if ( !current_user_can( 'manage_woocommerce' ) ) {
            wp_send_json_error( array(
                'message' => esc_html__( 'You do not have sufficient permissions to perform this action.', 'extra-product-options-for-woocommerce' ),
            ) );
        }
        // Verify nonce.
        if ( !isset( $_POST['nonce'] ) ) {
            wp_send_json_error( array(
                'message' => esc_html__( 'Security check failed. Nonce not provided.', 'extra-product-options-for-woocommerce' ),
            ) );
        }
        if ( !wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce'] ) ), 'epofw_import_fields_nonce' ) ) {
            wp_send_json_error( array(
                'message' => esc_html__( 'Security check failed. Please refresh the page and try again.', 'extra-product-options-for-woocommerce' ),
            ) );
        }
        $fields = self::get_all_demo_addons();
        $imported_count = 0;
        $errors = array();
        $total_count = count( $fields );
        // Register post type if it doesn't exist (AJAX timing issue fix).
        if ( !post_type_exists( EPOFW_DFT_POST_TYPE ) ) {
            register_post_type( EPOFW_DFT_POST_TYPE, array(
                'labels' => array(
                    'name'          => esc_html__( 'Extra Product Option', 'extra-product-options-for-woocommerce' ),
                    'singular_name' => esc_html__( 'Extra Product Option', 'extra-product-options-for-woocommerce' ),
                ),
            ) );
        }
        // Save each addon but never override existing ones.
        foreach ( $fields as $index => $field_group ) {
            $addon_name = ( isset( $field_group['epofw_addon_name'] ) ? $field_group['epofw_addon_name'] : 'Unknown Addon' );
            if ( '' === $addon_name ) {
                continue;
            }
            if ( self::get_existing_addon_id_by_title( $addon_name ) ) {
                continue;
            }
            $post_data = array(
                'post_title'  => $addon_name,
                'post_status' => 'draft',
                'post_type'   => EPOFW_DFT_POST_TYPE,
            );
            $post_id = wp_insert_post( $post_data, true );
            if ( is_wp_error( $post_id ) ) {
                $errors[] = 'Failed to create addon "' . $addon_name . '": ' . $post_id->get_error_message();
                continue;
            }
            if ( !$post_id ) {
                $errors[] = 'Failed to create addon "' . $addon_name . '": Unknown error';
                continue;
            }
            // Transform demo data structure to match custom tables format.
            $transformed_data = self::transform_demo_data_for_custom_tables( $field_group );
            // Save to custom tables.
            EPOFW_Custom_Tables::save_addon( $post_id, $transformed_data );
            ++$imported_count;
        }
        if ( $imported_count > 0 ) {
            // Mark demos as imported so button gets disabled.
            update_option( 'epofw_demo_addons_imported', 'yes' );
            wp_send_json_success( array(
                'message'        => sprintf( 
                    /* translators: %d: number of imported addons */
                    esc_html__( 'Successfully imported %d demo addon(s)!', 'extra-product-options-for-woocommerce' ),
                    $imported_count
                 ),
                'imported_count' => $imported_count,
                'total_count'    => $total_count,
                'errors'         => $errors,
                'redirect_url'   => add_query_arg( array(
                    'page'    => 'epofw-main',
                    'tab'     => 'field-section',
                    'message' => 'imported',
                ), admin_url( 'admin.php' ) ),
            ) );
        } else {
            wp_send_json_error( array(
                'message' => esc_html__( 'Failed to import demo addons.', 'extra-product-options-for-woocommerce' ),
                'errors'  => $errors,
            ) );
        }
    }

    /**
     * Get all demo addons
     *
     * @since 4.4.0
     *
     * @return array Array of demo addon configurations.
     */
    private static function get_all_demo_addons() {
        $base_time = time();
        $product_ids = self::get_simple_product_ids( 4 );
        // Assign different products to each demo (or fallback to first product if not enough).
        $product_id_1 = ( isset( $product_ids[0] ) ? $product_ids[0] : '0' );
        $product_id_2 = ( isset( $product_ids[1] ) ? $product_ids[1] : $product_id_1 );
        $product_id_3 = ( isset( $product_ids[2] ) ? $product_ids[2] : $product_id_1 );
        $product_id_4 = ( isset( $product_ids[3] ) ? $product_ids[3] : $product_id_1 );
        $addons = array();
        // Demo 1: T-Shirt Customization (Text, Textarea, Radio, Checkbox, Color Picker, Heading, Hidden/Password).
        $addons[] = self::get_tshirt_customization_demo( $base_time, $product_id_1 );
        // Demo 2: Pizza Order (Select, Checkbox Group, Radio Group, Number, Textarea).
        $addons[] = self::get_pizza_order_demo( $base_time + 1000, $product_id_2 );
        // Demo 3: Event Registration (Date Picker, Time Picker, File Upload, Text, Select, Paragraph).
        $event_demo = self::get_event_registration_demo( $base_time + 2000, $product_id_3 );
        // Free version: Filter out premium fields by default.
        $event_demo = self::filter_premium_fields_from_addon( $event_demo );
        if ( !empty( $event_demo['general'] ) ) {
            $addons[] = $event_demo;
        }
        return $addons;
    }

    /**
     * Filter premium fields from a demo addon for free users.
     *
     * Removes premium field types (file, colorswitcher, textswitcher, imageswitcher, repeater)
     * from the addon configuration. Also removes empty sections after filtering.
     *
     * @since 4.4.5
     *
     * @param array $addon The addon configuration.
     *
     * @return array Filtered addon configuration.
     */
    private static function filter_premium_fields_from_addon( $addon ) {
        if ( empty( $addon['general'] ) ) {
            return $addon;
        }
        $premium_types = epofw_get_premium_field_types();
        foreach ( $addon['general'] as $section_id => &$section ) {
            if ( empty( $section['fields'] ) ) {
                continue;
            }
            // Filter out premium fields.
            foreach ( $section['fields'] as $field_id => $field ) {
                $field_type = ( isset( $field['field']['type'] ) ? $field['field']['type'] : '' );
                if ( in_array( $field_type, $premium_types, true ) ) {
                    unset($section['fields'][$field_id]);
                }
            }
            // Remove section if no fields left.
            if ( empty( $section['fields'] ) ) {
                unset($addon['general'][$section_id]);
            }
        }
        return $addon;
    }

    /**
     * Get existing addon ID by exact title to prevent duplicate demos.
     *
     * @since 4.4.7
     *
     * @param string $title Addon post title.
     * @return int Addon ID if found, 0 otherwise.
     */
    private static function get_existing_addon_id_by_title( $title ) {
        if ( '' === $title ) {
            return 0;
        }
        $existing = get_page_by_title( $title, OBJECT, EPOFW_DFT_POST_TYPE );
        if ( $existing && !is_wp_error( $existing ) ) {
            return (int) $existing->ID;
        }
        return 0;
    }

    /**
     * Demo 1: T-Shirt Customization
     * Showcases: Text, Textarea, Radio Group, Checkbox, Color Picker
     *
     * @since 4.4.0
     *
     * @param int    $base_time  Base timestamp for unique IDs.
     * @param string $product_id Product ID.
     *
     * @return array Addon configuration.
     */
    private static function get_tshirt_customization_demo( $base_time, $product_id ) {
        return array(
            'epofw_addon_name'     => 'T-Shirt Customization (Demo)',
            'epofw_addon_status'   => 'off',
            'epofw_addon_position' => 'before_add_to_cart',
            'additional_rule_data' => array(
                $base_time + 1 => array(
                    'condition' => 'product',
                    'operator'  => 'is_equal_to',
                    'value'     => array(
                        '0' => $product_id,
                    ),
                ),
            ),
            'general'              => array(
                $base_time + 10 => array(
                    'section_id'       => 'section_' . ($base_time + 10),
                    'section_title'    => 'Size & Style',
                    'section_status'   => 'on',
                    'section_order'    => 1,
                    'section_settings' => array(
                        'show_label'  => 'on',
                        'enabled'     => '',
                        'description' => 'Choose your preferred size and style',
                    ),
                    'row_groups'       => array(
                        'group_' . ($base_time + 10) => array(
                            'row_group_settings' => array(
                                'enabled' => '',
                                'gap'     => '16',
                            ),
                            'rows'               => array(
                                'row_' . ($base_time + 10) . '_1' => array(
                                    'column_settings' => array(
                                        'enabled' => '',
                                    ),
                                ),
                                'row_' . ($base_time + 10) . '_2' => array(
                                    'column_settings' => array(
                                        'enabled' => '',
                                    ),
                                ),
                            ),
                        ),
                    ),
                    'fields'           => array(
                        $base_time + 90  => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'  => 'heading',
                                'name'  => 'epofw_field_tshirt_intro',
                                'id'    => 'tshirt_intro',
                                'class' => 'epofw_fields_heading',
                            ),
                            'label'                    => array(
                                'title'         => 'Customize Your T-Shirt',
                                'subtitle'      => 'Step 1: Choose size and color',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 10) . '_1',
                                'group_id' => 'group_' . ($base_time + 10),
                                'layout'   => 'single',
                                'columns'  => '1',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(),
                            'field_order'              => 0,
                            'field_id'                 => $base_time + 90,
                        ),
                        $base_time + 101 => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'     => 'radiogroup',
                                'required' => 'on',
                                'name'     => 'epofw_field_tshirt_size',
                                'id'       => 'tshirt_size',
                                'class'    => 'epofw_fields_tag_class',
                            ),
                            'label'                    => array(
                                'title'         => 'Select Size',
                                'subtitle'      => 'Choose your size',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 10) . '_1',
                                'group_id' => 'group_' . ($base_time + 10),
                                'layout'   => 'multiple',
                                'columns'  => '2',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(
                                'addon_price_type' => 'per_option',
                                'options'          => array(
                                    array(
                                        'label'      => 'Small (S)',
                                        'price'      => '0',
                                        'price_type' => 'fixed',
                                    ),
                                    array(
                                        'label'      => 'Medium (M)',
                                        'price'      => '0',
                                        'price_type' => 'fixed',
                                    ),
                                    array(
                                        'label'      => 'Large (L)',
                                        'price'      => '2',
                                        'price_type' => 'fixed',
                                    ),
                                    array(
                                        'label'      => 'X-Large (XL)',
                                        'price'      => '4',
                                        'price_type' => 'fixed',
                                    ),
                                    array(
                                        'label'      => '2X-Large (2XL)',
                                        'price'      => '6',
                                        'price_type' => 'fixed',
                                    )
                                ),
                            ),
                            'field_order'              => 1,
                            'field_id'                 => $base_time + 101,
                        ),
                        $base_time + 102 => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'  => 'colorpicker',
                                'value' => '#ffffff',
                                'name'  => 'epofw_field_tshirt_color',
                                'id'    => 'tshirt_color',
                                'class' => 'epofw_color_picker',
                            ),
                            'label'                    => array(
                                'title'         => 'T-Shirt Color',
                                'subtitle'      => 'Pick your favorite color',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 10) . '_2',
                                'group_id' => 'group_' . ($base_time + 10),
                                'layout'   => 'multiple',
                                'columns'  => '2',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(
                                'addon_price_type' => 'fixed',
                                'addon_price'      => '',
                            ),
                            'field_order'              => 2,
                            'field_id'                 => $base_time + 102,
                        ),
                    ),
                ),
                $base_time + 20 => array(
                    'section_id'       => 'section_' . ($base_time + 20),
                    'section_title'    => 'Personalization',
                    'section_status'   => 'on',
                    'section_order'    => 2,
                    'section_settings' => array(
                        'show_label'  => 'on',
                        'enabled'     => '',
                        'description' => 'Add your personal touch',
                    ),
                    'row_groups'       => array(
                        'group_' . ($base_time + 20) => array(
                            'row_group_settings' => array(
                                'enabled' => '',
                                'gap'     => '16',
                            ),
                            'rows'               => array(
                                'row_' . ($base_time + 20) . '_1' => array(
                                    'column_settings' => array(
                                        'enabled' => '',
                                    ),
                                ),
                                'row_' . ($base_time + 20) . '_2' => array(
                                    'column_settings' => array(
                                        'enabled' => '',
                                    ),
                                ),
                            ),
                        ),
                    ),
                    'fields'           => array(
                        $base_time + 201 => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'        => 'text',
                                'placeholder' => 'Enter your custom text (max 20 chars)',
                                'name'        => 'epofw_field_custom_text',
                                'id'          => 'custom_text',
                                'class'       => 'epofw_fields_tag_class',
                            ),
                            'label'                    => array(
                                'title'         => 'Custom Text',
                                'subtitle'      => 'Add text to your t-shirt',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 20) . '_1',
                                'group_id' => 'group_' . ($base_time + 20),
                                'layout'   => 'single',
                                'columns'  => '1',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(
                                'addon_price_type' => 'fixed',
                                'addon_price'      => '5',
                            ),
                            'field_order'              => 1,
                            'field_id'                 => $base_time + 201,
                        ),
                        $base_time + 202 => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'        => 'textarea',
                                'placeholder' => 'Any special instructions for printing...',
                                'name'        => 'epofw_field_special_instructions',
                                'id'          => 'special_instructions',
                                'class'       => 'epofw_fields_tag_class',
                            ),
                            'label'                    => array(
                                'title'         => 'Special Instructions',
                                'subtitle'      => 'Tell us about placement, font preferences, etc.',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 20) . '_2',
                                'group_id' => 'group_' . ($base_time + 20),
                                'layout'   => 'single',
                                'columns'  => '1',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(
                                'addon_price_type' => 'fixed',
                                'addon_price'      => '',
                            ),
                            'field_order'              => 2,
                            'field_id'                 => $base_time + 202,
                        ),
                        $base_time + 203 => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'  => 'hidden',
                                'value' => 'tshirt_demo_personalization',
                                'name'  => 'epofw_field_tshirt_meta',
                                'id'    => 'tshirt_meta',
                                'class' => '',
                            ),
                            'label'                    => array(
                                'title'         => '',
                                'subtitle'      => '',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 20) . '_2',
                                'group_id' => 'group_' . ($base_time + 20),
                                'layout'   => 'single',
                                'columns'  => '1',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(
                                'addon_price_type' => 'fixed',
                                'addon_price'      => '',
                            ),
                            'field_order'              => 3,
                            'field_id'                 => $base_time + 203,
                        ),
                    ),
                ),
                $base_time + 30 => array(
                    'section_id'       => 'section_' . ($base_time + 30),
                    'section_title'    => 'Optional Add-ons',
                    'section_status'   => 'on',
                    'section_order'    => 3,
                    'section_settings' => array(
                        'show_label'  => 'on',
                        'enabled'     => '',
                        'description' => 'Enhance your order with these extras',
                    ),
                    'row_groups'       => array(
                        'group_' . ($base_time + 30) => array(
                            'row_group_settings' => array(
                                'enabled' => '',
                                'gap'     => '16',
                            ),
                            'rows'               => array(
                                'row_' . ($base_time + 30) . '_1' => array(
                                    'column_settings' => array(
                                        'enabled' => '',
                                    ),
                                ),
                                'row_' . ($base_time + 30) . '_2' => array(
                                    'column_settings' => array(
                                        'enabled' => '',
                                    ),
                                ),
                                'row_' . ($base_time + 30) . '_3' => array(
                                    'column_settings' => array(
                                        'enabled' => '',
                                    ),
                                ),
                            ),
                        ),
                    ),
                    'fields'           => array(
                        $base_time + 301 => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'  => 'checkbox',
                                'name'  => 'epofw_field_gift_wrap',
                                'id'    => 'gift_wrap',
                                'class' => 'epofw_fields_tag_class',
                            ),
                            'label'                    => array(
                                'title'         => 'Gift Wrap',
                                'subtitle'      => 'Wrap it beautifully',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 30) . '_1',
                                'group_id' => 'group_' . ($base_time + 30),
                                'layout'   => 'multiple',
                                'columns'  => '2',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(
                                'addon_price_type' => 'per_option',
                                'options'          => array(array(
                                    'label'      => 'Add Gift Wrap',
                                    'price'      => '3',
                                    'price_type' => 'fixed',
                                )),
                            ),
                            'field_order'              => 1,
                            'field_id'                 => $base_time + 301,
                        ),
                        $base_time + 302 => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'  => 'checkbox',
                                'name'  => 'epofw_field_express_shipping',
                                'id'    => 'express_shipping',
                                'class' => 'epofw_fields_tag_class',
                            ),
                            'label'                    => array(
                                'title'         => 'Express Shipping',
                                'subtitle'      => 'Get it in 2-3 days',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 30) . '_2',
                                'group_id' => 'group_' . ($base_time + 30),
                                'layout'   => 'multiple',
                                'columns'  => '2',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(
                                'addon_price_type' => 'per_option',
                                'options'          => array(array(
                                    'label'      => 'Express Shipping',
                                    'price'      => '10',
                                    'price_type' => 'fixed',
                                )),
                            ),
                            'field_order'              => 2,
                            'field_id'                 => $base_time + 302,
                        ),
                        $base_time + 303 => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'  => 'switch',
                                'name'  => 'epofw_field_priority_production',
                                'id'    => 'priority_production',
                                'class' => 'epofw_fields_tag_class',
                            ),
                            'label'                    => array(
                                'title'         => 'Priority Production',
                                'subtitle'      => 'Move to front of queue',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 30) . '_3',
                                'group_id' => 'group_' . ($base_time + 30),
                                'layout'   => 'single',
                                'columns'  => '1',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(
                                'addon_price_type' => 'per_option',
                                'options'          => array(array(
                                    'label'      => 'Yes, prioritize my order',
                                    'price'      => '5',
                                    'price_type' => 'fixed',
                                )),
                            ),
                            'field_order'              => 3,
                            'field_id'                 => $base_time + 303,
                        ),
                    ),
                ),
            ),
        );
    }

    /**
     * Demo 2: Pizza Order
     * Showcases: Select, Checkbox Group, Radio Group, Number, Textarea
     *
     * @since 4.4.0
     *
     * @param int    $base_time  Base timestamp for unique IDs.
     * @param string $product_id Product ID.
     *
     * @return array Addon configuration.
     */
    private static function get_pizza_order_demo( $base_time, $product_id ) {
        return array(
            'epofw_addon_name'     => 'Pizza Order Customization (Demo)',
            'epofw_addon_status'   => 'off',
            'epofw_addon_position' => 'before_add_to_cart',
            'additional_rule_data' => array(
                $base_time + 1 => array(
                    'condition' => 'product',
                    'operator'  => 'is_equal_to',
                    'value'     => array(
                        '0' => $product_id,
                    ),
                ),
            ),
            'general'              => array(
                $base_time + 10 => array(
                    'section_id'       => 'section_' . ($base_time + 10),
                    'section_title'    => 'Size & Crust',
                    'section_status'   => 'on',
                    'section_order'    => 1,
                    'section_settings' => array(
                        'show_label'  => 'on',
                        'enabled'     => '',
                        'description' => 'Select your pizza size and crust type',
                    ),
                    'row_groups'       => array(
                        'group_' . ($base_time + 10) => array(
                            'row_group_settings' => array(
                                'enabled' => '',
                                'gap'     => '16',
                            ),
                            'rows'               => array(
                                'row_' . ($base_time + 10) . '_1' => array(
                                    'column_settings' => array(
                                        'enabled' => '',
                                    ),
                                ),
                                'row_' . ($base_time + 10) . '_2' => array(
                                    'column_settings' => array(
                                        'enabled' => '',
                                    ),
                                ),
                            ),
                        ),
                    ),
                    'fields'           => array(
                        $base_time + 101 => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'     => 'select',
                                'required' => 'on',
                                'name'     => 'epofw_field_pizza_size',
                                'id'       => 'pizza_size',
                                'class'    => 'epofw_fields_tag_class',
                            ),
                            'label'                    => array(
                                'title'         => 'Pizza Size',
                                'subtitle'      => 'How hungry are you?',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 10) . '_1',
                                'group_id' => 'group_' . ($base_time + 10),
                                'layout'   => 'multiple',
                                'columns'  => '2',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(
                                'addon_price_type' => 'per_option',
                                'options'          => array(
                                    array(
                                        'label'      => 'Personal (8 inch)',
                                        'price'      => '0',
                                        'price_type' => 'fixed',
                                    ),
                                    array(
                                        'label'      => 'Medium (12 inch)',
                                        'price'      => '4',
                                        'price_type' => 'fixed',
                                    ),
                                    array(
                                        'label'      => 'Large (14 inch)',
                                        'price'      => '7',
                                        'price_type' => 'fixed',
                                    ),
                                    array(
                                        'label'      => 'Family (18 inch)',
                                        'price'      => '12',
                                        'price_type' => 'fixed',
                                    )
                                ),
                            ),
                            'field_order'              => 1,
                            'field_id'                 => $base_time + 101,
                        ),
                        $base_time + 102 => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'     => 'radiogroup',
                                'required' => 'on',
                                'name'     => 'epofw_field_crust_type',
                                'id'       => 'crust_type',
                                'class'    => 'epofw_fields_tag_class',
                            ),
                            'label'                    => array(
                                'title'         => 'Crust Type',
                                'subtitle'      => 'Choose your preferred crust',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 10) . '_2',
                                'group_id' => 'group_' . ($base_time + 10),
                                'layout'   => 'multiple',
                                'columns'  => '2',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(
                                'addon_price_type' => 'per_option',
                                'options'          => array(
                                    array(
                                        'label'      => 'Classic Hand-Tossed',
                                        'price'      => '0',
                                        'price_type' => 'fixed',
                                    ),
                                    array(
                                        'label'      => 'Thin & Crispy',
                                        'price'      => '0',
                                        'price_type' => 'fixed',
                                    ),
                                    array(
                                        'label'      => 'Stuffed Crust',
                                        'price'      => '3',
                                        'price_type' => 'fixed',
                                    ),
                                    array(
                                        'label'      => 'Gluten-Free',
                                        'price'      => '4',
                                        'price_type' => 'fixed',
                                    )
                                ),
                            ),
                            'field_order'              => 2,
                            'field_id'                 => $base_time + 102,
                        ),
                    ),
                ),
                $base_time + 20 => array(
                    'section_id'       => 'section_' . ($base_time + 20),
                    'section_title'    => 'Toppings',
                    'section_status'   => 'on',
                    'section_order'    => 2,
                    'section_settings' => array(
                        'show_label'  => 'on',
                        'enabled'     => '',
                        'description' => 'Add your favorite toppings',
                    ),
                    'row_groups'       => array(
                        'group_' . ($base_time + 20) => array(
                            'row_group_settings' => array(
                                'enabled' => '',
                                'gap'     => '16',
                            ),
                            'rows'               => array(
                                'row_' . ($base_time + 20) . '_1' => array(
                                    'column_settings' => array(
                                        'enabled' => '',
                                    ),
                                ),
                                'row_' . ($base_time + 20) . '_2' => array(
                                    'column_settings' => array(
                                        'enabled' => '',
                                    ),
                                ),
                            ),
                        ),
                    ),
                    'fields'           => array(
                        $base_time + 201 => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'  => 'checkboxgroup',
                                'name'  => 'epofw_field_extra_toppings',
                                'id'    => 'extra_toppings',
                                'class' => 'epofw_fields_tag_class',
                            ),
                            'label'                    => array(
                                'title'         => 'Extra Toppings',
                                'subtitle'      => 'Select as many as you like',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 20) . '_1',
                                'group_id' => 'group_' . ($base_time + 20),
                                'layout'   => 'single',
                                'columns'  => '1',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(
                                'addon_price_type' => 'per_option',
                                'options'          => array(
                                    array(
                                        'label'      => 'Extra Cheese',
                                        'price'      => '2',
                                        'price_type' => 'fixed',
                                    ),
                                    array(
                                        'label'      => 'Pepperoni',
                                        'price'      => '1.50',
                                        'price_type' => 'fixed',
                                    ),
                                    array(
                                        'label'      => 'Mushrooms',
                                        'price'      => '1',
                                        'price_type' => 'fixed',
                                    ),
                                    array(
                                        'label'      => 'Bell Peppers',
                                        'price'      => '1',
                                        'price_type' => 'fixed',
                                    ),
                                    array(
                                        'label'      => 'Olives',
                                        'price'      => '1',
                                        'price_type' => 'fixed',
                                    ),
                                    array(
                                        'label'      => 'Jalapeños',
                                        'price'      => '0.75',
                                        'price_type' => 'fixed',
                                    )
                                ),
                            ),
                            'field_order'              => 1,
                            'field_id'                 => $base_time + 201,
                        ),
                        $base_time + 202 => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'        => 'number',
                                'placeholder' => '8',
                                'name'        => 'epofw_field_num_slices',
                                'id'          => 'num_slices',
                                'class'       => 'epofw_fields_tag_class',
                                'min'         => '4',
                                'max'         => '16',
                                'step'        => '2',
                            ),
                            'label'                    => array(
                                'title'         => 'Number of Slices',
                                'subtitle'      => 'How many slices? (4-16)',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 20) . '_2',
                                'group_id' => 'group_' . ($base_time + 20),
                                'layout'   => 'single',
                                'columns'  => '1',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(
                                'addon_price_type' => 'fixed',
                                'addon_price'      => '',
                            ),
                            'field_order'              => 2,
                            'field_id'                 => $base_time + 202,
                        ),
                    ),
                ),
                $base_time + 30 => array(
                    'section_id'       => 'section_' . ($base_time + 30),
                    'section_title'    => 'Special Requests',
                    'section_status'   => 'on',
                    'section_order'    => 3,
                    'section_settings' => array(
                        'show_label'  => 'on',
                        'enabled'     => '',
                        'description' => 'Any special requests?',
                    ),
                    'row_groups'       => array(
                        'group_' . ($base_time + 30) => array(
                            'row_group_settings' => array(
                                'enabled' => '',
                                'gap'     => '16',
                            ),
                            'rows'               => array(
                                'row_' . ($base_time + 30) . '_1' => array(
                                    'column_settings' => array(
                                        'enabled' => '',
                                    ),
                                ),
                                'row_' . ($base_time + 30) . '_2' => array(
                                    'column_settings' => array(
                                        'enabled' => '',
                                    ),
                                ),
                            ),
                        ),
                    ),
                    'fields'           => array(
                        $base_time + 301 => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'  => 'multiselect',
                                'name'  => 'epofw_field_dipping_sauces',
                                'id'    => 'dipping_sauces',
                                'class' => 'multiselect2',
                            ),
                            'label'                    => array(
                                'title'         => 'Dipping Sauces',
                                'subtitle'      => 'Select multiple sauces',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 30) . '_1',
                                'group_id' => 'group_' . ($base_time + 30),
                                'layout'   => 'single',
                                'columns'  => '1',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(
                                'addon_price_type' => 'per_option',
                                'options'          => array(
                                    array(
                                        'label'      => 'Marinara',
                                        'price'      => '0.50',
                                        'price_type' => 'fixed',
                                    ),
                                    array(
                                        'label'      => 'Ranch',
                                        'price'      => '0.50',
                                        'price_type' => 'fixed',
                                    ),
                                    array(
                                        'label'      => 'BBQ',
                                        'price'      => '0.50',
                                        'price_type' => 'fixed',
                                    ),
                                    array(
                                        'label'      => 'Garlic Butter',
                                        'price'      => '0.75',
                                        'price_type' => 'fixed',
                                    )
                                ),
                            ),
                            'field_order'              => 1,
                            'field_id'                 => $base_time + 301,
                        ),
                        $base_time + 302 => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'        => 'textarea',
                                'placeholder' => 'E.g., extra sauce, well-done, cut into squares...',
                                'name'        => 'epofw_field_pizza_instructions',
                                'id'          => 'pizza_instructions',
                                'class'       => 'epofw_fields_tag_class',
                            ),
                            'label'                    => array(
                                'title'         => 'Special Instructions',
                                'subtitle'      => 'Tell us how you want it',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 30) . '_2',
                                'group_id' => 'group_' . ($base_time + 30),
                                'layout'   => 'single',
                                'columns'  => '1',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(
                                'addon_price_type' => 'fixed',
                                'addon_price'      => '',
                            ),
                            'field_order'              => 2,
                            'field_id'                 => $base_time + 302,
                        ),
                    ),
                ),
            ),
        );
    }

    /**
     * Demo 3: Event Registration
     * Showcases: Date Picker, Time Picker, File Upload, Text, Select, Slider, Separator
     *
     * @since 4.4.0
     *
     * @param int    $base_time  Base timestamp for unique IDs.
     * @param string $product_id Product ID.
     *
     * @return array Addon configuration.
     */
    private static function get_event_registration_demo( $base_time, $product_id ) {
        return array(
            'epofw_addon_name'     => 'Event Registration (Demo)',
            'epofw_addon_status'   => 'off',
            'epofw_addon_position' => 'before_add_to_cart',
            'additional_rule_data' => array(
                $base_time + 1 => array(
                    'condition' => 'product',
                    'operator'  => 'is_equal_to',
                    'value'     => array(
                        '0' => $product_id,
                    ),
                ),
            ),
            'general'              => array(
                $base_time + 10 => array(
                    'section_id'       => 'section_' . ($base_time + 10),
                    'section_title'    => 'Attendee Information',
                    'section_status'   => 'on',
                    'section_order'    => 1,
                    'section_settings' => array(
                        'show_label'  => 'on',
                        'enabled'     => '',
                        'description' => 'Please provide your details',
                    ),
                    'row_groups'       => array(
                        'group_' . ($base_time + 10) => array(
                            'row_group_settings' => array(
                                'enabled' => '',
                                'gap'     => '16',
                            ),
                            'rows'               => array(
                                'row_' . ($base_time + 10) . '_1' => array(
                                    'column_settings' => array(
                                        'enabled' => '',
                                    ),
                                ),
                                'row_' . ($base_time + 10) . '_2' => array(
                                    'column_settings' => array(
                                        'enabled' => '',
                                    ),
                                ),
                                'row_' . ($base_time + 10) . '_3' => array(
                                    'column_settings' => array(
                                        'enabled' => '',
                                    ),
                                ),
                                'row_' . ($base_time + 10) . '_4' => array(
                                    'column_settings' => array(
                                        'enabled' => '',
                                    ),
                                ),
                            ),
                        ),
                    ),
                    'fields'           => array(
                        $base_time + 90  => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'  => 'paragraph',
                                'name'  => 'epofw_field_event_intro',
                                'id'    => 'event_intro',
                                'class' => 'epofw_fields_paragraph',
                            ),
                            'label'                    => array(
                                'title'         => 'Register for the Event',
                                'subtitle'      => 'Step 1: Tell us about yourself',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 10) . '_1',
                                'group_id' => 'group_' . ($base_time + 10),
                                'layout'   => 'single',
                                'columns'  => '1',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(),
                            'field_order'              => 0,
                            'field_id'                 => $base_time + 90,
                        ),
                        $base_time + 101 => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'        => 'text',
                                'required'    => 'on',
                                'placeholder' => 'Enter your full name',
                                'name'        => 'epofw_field_attendee_name',
                                'id'          => 'attendee_name',
                                'class'       => 'epofw_fields_tag_class',
                            ),
                            'label'                    => array(
                                'title'         => 'Full Name',
                                'subtitle'      => 'As it should appear on the badge',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 10) . '_1',
                                'group_id' => 'group_' . ($base_time + 10),
                                'layout'   => 'multiple',
                                'columns'  => '2',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(
                                'addon_price_type' => 'fixed',
                                'addon_price'      => '',
                            ),
                            'field_order'              => 1,
                            'field_id'                 => $base_time + 101,
                        ),
                        $base_time + 102 => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'        => 'text',
                                'placeholder' => 'Company or organization',
                                'name'        => 'epofw_field_organization',
                                'id'          => 'organization',
                                'class'       => 'epofw_fields_tag_class',
                            ),
                            'label'                    => array(
                                'title'         => 'Organization',
                                'subtitle'      => 'Optional',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 10) . '_2',
                                'group_id' => 'group_' . ($base_time + 10),
                                'layout'   => 'multiple',
                                'columns'  => '2',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(
                                'addon_price_type' => 'fixed',
                                'addon_price'      => '',
                            ),
                            'field_order'              => 2,
                            'field_id'                 => $base_time + 102,
                        ),
                        $base_time + 103 => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'  => 'slider',
                                'name'  => 'epofw_field_num_guests',
                                'id'    => 'num_guests',
                                'class' => 'epofw_fields_tag_class',
                                'min'   => '1',
                                'max'   => '10',
                                'step'  => '1',
                                'value' => '1',
                            ),
                            'label'                    => array(
                                'title'         => 'Number of Guests',
                                'subtitle'      => 'How many people will attend with you?',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 10) . '_3',
                                'group_id' => 'group_' . ($base_time + 10),
                                'layout'   => 'single',
                                'columns'  => '1',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(
                                'addon_price_type' => 'quantity_based',
                                'addon_price'      => '25',
                            ),
                            'field_order'              => 3,
                            'field_id'                 => $base_time + 103,
                        ),
                        $base_time + 104 => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'  => 'separator',
                                'name'  => 'epofw_field_separator_1',
                                'id'    => 'separator_1',
                                'class' => 'epofw_fields_tag_class',
                            ),
                            'label'                    => array(
                                'title'         => '',
                                'subtitle'      => '',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 10) . '_4',
                                'group_id' => 'group_' . ($base_time + 10),
                                'layout'   => 'single',
                                'columns'  => '1',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(
                                'addon_price_type' => 'fixed',
                                'addon_price'      => '',
                            ),
                            'field_order'              => 4,
                            'field_id'                 => $base_time + 104,
                        ),
                    ),
                ),
                $base_time + 20 => array(
                    'section_id'       => 'section_' . ($base_time + 20),
                    'section_title'    => 'Schedule Preferences',
                    'section_status'   => 'on',
                    'section_order'    => 2,
                    'section_settings' => array(
                        'show_label'  => 'on',
                        'enabled'     => '',
                        'description' => 'Select your preferred date and time',
                    ),
                    'row_groups'       => array(
                        'group_' . ($base_time + 20) => array(
                            'row_group_settings' => array(
                                'enabled' => '',
                                'gap'     => '16',
                            ),
                            'rows'               => array(
                                'row_' . ($base_time + 20) . '_1' => array(
                                    'column_settings' => array(
                                        'enabled' => '',
                                    ),
                                ),
                                'row_' . ($base_time + 20) . '_2' => array(
                                    'column_settings' => array(
                                        'enabled' => '',
                                    ),
                                ),
                                'row_' . ($base_time + 20) . '_3' => array(
                                    'column_settings' => array(
                                        'enabled' => '',
                                    ),
                                ),
                            ),
                        ),
                    ),
                    'fields'           => array(
                        $base_time + 201 => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'     => 'datepicker',
                                'required' => 'on',
                                'name'     => 'epofw_field_event_date',
                                'id'       => 'event_date',
                                'class'    => 'epofw_datepicker',
                            ),
                            'label'                    => array(
                                'title'         => 'Preferred Date',
                                'subtitle'      => 'Choose the event date',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 20) . '_1',
                                'group_id' => 'group_' . ($base_time + 20),
                                'layout'   => 'multiple',
                                'columns'  => '3',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(
                                'addon_price_type' => 'fixed',
                                'addon_price'      => '',
                            ),
                            'field_order'              => 1,
                            'field_id'                 => $base_time + 201,
                        ),
                        $base_time + 202 => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'  => 'timepicker',
                                'name'  => 'epofw_field_event_time',
                                'id'    => 'event_time',
                                'class' => 'epofw_timepicker',
                            ),
                            'label'                    => array(
                                'title'         => 'Preferred Time',
                                'subtitle'      => 'Select arrival time',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 20) . '_2',
                                'group_id' => 'group_' . ($base_time + 20),
                                'layout'   => 'multiple',
                                'columns'  => '3',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(
                                'addon_price_type' => 'fixed',
                                'addon_price'      => '',
                            ),
                            'field_order'              => 2,
                            'field_id'                 => $base_time + 202,
                        ),
                        $base_time + 203 => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'  => 'select',
                                'name'  => 'epofw_field_session_type',
                                'id'    => 'session_type',
                                'class' => 'epofw_fields_tag_class',
                            ),
                            'label'                    => array(
                                'title'         => 'Session Type',
                                'subtitle'      => 'Which track interests you?',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 20) . '_3',
                                'group_id' => 'group_' . ($base_time + 20),
                                'layout'   => 'multiple',
                                'columns'  => '3',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(
                                'addon_price_type' => 'per_option',
                                'options'          => array(array(
                                    'label'      => 'General Session',
                                    'price'      => '0',
                                    'price_type' => 'fixed',
                                ), array(
                                    'label'      => 'Workshop Track',
                                    'price'      => '25',
                                    'price_type' => 'fixed',
                                ), array(
                                    'label'      => 'VIP Experience',
                                    'price'      => '100',
                                    'price_type' => 'fixed',
                                )),
                            ),
                            'field_order'              => 3,
                            'field_id'                 => $base_time + 203,
                        ),
                    ),
                ),
                $base_time + 30 => array(
                    'section_id'       => 'section_' . ($base_time + 30),
                    'section_title'    => 'Upload Documents',
                    'section_status'   => 'on',
                    'section_order'    => 3,
                    'section_settings' => array(
                        'show_label'  => 'on',
                        'enabled'     => '',
                        'description' => 'Upload any required documents',
                    ),
                    'row_groups'       => array(
                        'group_' . ($base_time + 30) => array(
                            'row_group_settings' => array(
                                'enabled' => '',
                                'gap'     => '16',
                            ),
                            'rows'               => array(
                                'row_' . ($base_time + 30) . '_1' => array(
                                    'column_settings' => array(
                                        'enabled' => '',
                                    ),
                                ),
                            ),
                        ),
                    ),
                    'fields'           => array(
                        $base_time + 301 => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'  => 'file',
                                'name'  => 'epofw_field_id_photo',
                                'id'    => 'id_photo',
                                'class' => 'epofw_fields_tag_class',
                            ),
                            'label'                    => array(
                                'title'         => 'Photo ID',
                                'subtitle'      => 'Upload a photo for your badge (JPG, PNG)',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 30) . '_1',
                                'group_id' => 'group_' . ($base_time + 30),
                                'layout'   => 'single',
                                'columns'  => '1',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(
                                'addon_price_type' => 'fixed',
                                'addon_price'      => '',
                            ),
                            'field_order'              => 1,
                            'field_id'                 => $base_time + 301,
                        ),
                        $base_time + 302 => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'        => 'password',
                                'placeholder' => 'Enter your access code (if any)',
                                'name'        => 'epofw_field_event_access_code',
                                'id'          => 'event_access_code',
                                'class'       => 'epofw_fields_tag_class',
                            ),
                            'label'                    => array(
                                'title'         => 'Access Code',
                                'subtitle'      => 'Optional password field demo',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 30) . '_1',
                                'group_id' => 'group_' . ($base_time + 30),
                                'layout'   => 'single',
                                'columns'  => '1',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(
                                'addon_price_type' => 'fixed',
                                'addon_price'      => '',
                            ),
                            'field_order'              => 2,
                            'field_id'                 => $base_time + 302,
                        ),
                    ),
                ),
            ),
        );
    }

    /**
     * Demo 4: Premium Features Demo (Premium Only)
     * Showcases: Color Switcher, Text Switcher, Image Switcher, Multi-select
     *
     * @since 4.4.0
     *
     * @param int    $base_time  Base timestamp for unique IDs.
     * @param string $product_id Product ID.
     *
     * @return array Addon configuration.
     */
    private static function get_premium_features_demo( $base_time, $product_id ) {
        return array(
            'epofw_addon_name'     => 'Premium Features Showcase (Demo)',
            'epofw_addon_status'   => 'off',
            'epofw_addon_position' => 'before_add_to_cart',
            'additional_rule_data' => array(
                $base_time + 1 => array(
                    'condition' => 'product',
                    'operator'  => 'is_equal_to',
                    'value'     => array(
                        '0' => $product_id,
                    ),
                ),
            ),
            'general'              => array(
                $base_time + 10 => array(
                    'section_id'       => 'section_' . ($base_time + 10),
                    'section_title'    => 'Visual Selectors',
                    'section_status'   => 'on',
                    'section_order'    => 1,
                    'section_settings' => array(
                        'show_label'  => 'on',
                        'enabled'     => '',
                        'description' => 'Click to select your preferred options',
                    ),
                    'row_groups'       => array(
                        'group_' . ($base_time + 10) => array(
                            'row_group_settings' => array(
                                'enabled' => '',
                                'gap'     => '20',
                            ),
                            'rows'               => array(
                                'row_' . ($base_time + 10) . '_1' => array(
                                    'column_settings' => array(
                                        'enabled' => '',
                                    ),
                                ),
                                'row_' . ($base_time + 10) . '_2' => array(
                                    'column_settings' => array(
                                        'enabled' => '',
                                    ),
                                ),
                            ),
                        ),
                    ),
                    'fields'           => array(
                        $base_time + 101 => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'  => 'colorswitcher',
                                'name'  => 'epofw_field_product_color',
                                'id'    => 'product_color',
                                'class' => 'epofw_fields_tag_class',
                            ),
                            'label'                    => array(
                                'title'         => 'Product Color',
                                'subtitle'      => 'Click a color to select',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 10) . '_1',
                                'group_id' => 'group_' . ($base_time + 10),
                                'layout'   => 'multiple',
                                'columns'  => '2',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(
                                'addon_price_type' => 'per_option',
                                'options'          => array(
                                    array(
                                        'label'      => 'Red',
                                        'swticher'   => '#e74c3c',
                                        'price'      => '0',
                                        'price_type' => 'fixed',
                                    ),
                                    array(
                                        'label'      => 'Blue',
                                        'swticher'   => '#3498db',
                                        'price'      => '0',
                                        'price_type' => 'fixed',
                                    ),
                                    array(
                                        'label'      => 'Green',
                                        'swticher'   => '#27ae60',
                                        'price'      => '0',
                                        'price_type' => 'fixed',
                                    ),
                                    array(
                                        'label'      => 'Gold',
                                        'swticher'   => '#f1c40f',
                                        'price'      => '5',
                                        'price_type' => 'fixed',
                                    ),
                                    array(
                                        'label'      => 'Purple',
                                        'swticher'   => '#9b59b6',
                                        'price'      => '3',
                                        'price_type' => 'fixed',
                                    )
                                ),
                            ),
                            'field_order'              => 1,
                            'field_id'                 => $base_time + 101,
                        ),
                        $base_time + 102 => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'  => 'textswitcher',
                                'name'  => 'epofw_field_premium_material',
                                'id'    => 'premium_material',
                                'class' => 'epofw_fields_tag_class',
                            ),
                            'label'                    => array(
                                'title'         => 'Premium Material',
                                'subtitle'      => 'Available only for Gold color',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 10) . '_2',
                                'group_id' => 'group_' . ($base_time + 10),
                                'layout'   => 'multiple',
                                'columns'  => '2',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(
                                'addon_price_type' => 'per_option',
                                'options'          => array(array(
                                    'label'      => 'Standard Fabric',
                                    'price'      => '0',
                                    'price_type' => 'fixed',
                                ), array(
                                    'label'      => 'Ultra Premium Fabric',
                                    'price'      => '40',
                                    'price_type' => 'fixed',
                                )),
                            ),
                            'logical_operation'        => array(
                                $base_time + 1020 => array(
                                    'epofw_conditional_logic_options'  => 'product_color',
                                    'epofw_conditional_logic_operator' => 'equal_to',
                                    'epofw_conditional_logic_fields'   => 'Gold',
                                    'epofw_cnd_logic_type'             => 'show',
                                ),
                            ),
                            'field_order'              => 2,
                            'field_id'                 => $base_time + 102,
                        ),
                        $base_time + 102 => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'  => 'textswitcher',
                                'name'  => 'epofw_field_material_type',
                                'id'    => 'material_type',
                                'class' => 'epofw_fields_tag_class',
                            ),
                            'label'                    => array(
                                'title'         => 'Premium Material',
                                'subtitle'      => 'Available for Gold color selection (Conditional Logic Demo)',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 10) . '_2',
                                'group_id' => 'group_' . ($base_time + 10),
                                'layout'   => 'multiple',
                                'columns'  => '2',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(
                                'addon_price_type' => 'per_option',
                                'options'          => array(
                                    array(
                                        'label'      => 'Cotton',
                                        'price'      => '0',
                                        'price_type' => 'fixed',
                                    ),
                                    array(
                                        'label'      => 'Polyester',
                                        'price'      => '2',
                                        'price_type' => 'fixed',
                                    ),
                                    array(
                                        'label'      => 'Silk',
                                        'price'      => '15',
                                        'price_type' => 'fixed',
                                    ),
                                    array(
                                        'label'      => 'Linen',
                                        'price'      => '8',
                                        'price_type' => 'fixed',
                                    )
                                ),
                            ),
                            'field_order'              => 2,
                            'field_id'                 => $base_time + 102,
                        ),
                    ),
                ),
                $base_time + 20 => array(
                    'section_id'       => 'section_' . ($base_time + 20),
                    'section_title'    => 'Design Options',
                    'section_status'   => 'on',
                    'section_order'    => 2,
                    'section_settings' => array(
                        'show_label'  => 'on',
                        'enabled'     => '',
                        'description' => 'Choose your design and features',
                    ),
                    'row_groups'       => array(
                        'group_' . ($base_time + 20) => array(
                            'row_group_settings' => array(
                                'enabled' => '',
                                'gap'     => '20',
                            ),
                            'rows'               => array(
                                'row_' . ($base_time + 20) . '_1' => array(
                                    'column_settings' => array(
                                        'enabled' => '',
                                    ),
                                ),
                                'row_' . ($base_time + 20) . '_2' => array(
                                    'column_settings' => array(
                                        'enabled' => '',
                                    ),
                                ),
                            ),
                        ),
                    ),
                    'fields'           => array(
                        $base_time + 201 => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'  => 'imageswitcher',
                                'name'  => 'epofw_field_design_pattern',
                                'id'    => 'design_pattern',
                                'class' => 'epofw_fields_tag_class',
                            ),
                            'label'                    => array(
                                'title'         => 'Design Pattern',
                                'subtitle'      => 'Click an image to select',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 20) . '_1',
                                'group_id' => 'group_' . ($base_time + 20),
                                'layout'   => 'single',
                                'columns'  => '1',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(
                                'addon_price_type' => 'per_option',
                                'options'          => array(
                                    array(
                                        'label'      => 'Solid',
                                        'swticher'   => EPOFW_PLUGIN_URL . 'assets/demo-images/image-1.png',
                                        'price'      => '0',
                                        'price_type' => 'fixed',
                                    ),
                                    array(
                                        'label'      => 'Stripes',
                                        'swticher'   => EPOFW_PLUGIN_URL . 'assets/demo-images/image-2.png',
                                        'price'      => '3',
                                        'price_type' => 'fixed',
                                    ),
                                    array(
                                        'label'      => 'Dots',
                                        'swticher'   => EPOFW_PLUGIN_URL . 'assets/demo-images/image-3.png',
                                        'price'      => '3',
                                        'price_type' => 'fixed',
                                    ),
                                    array(
                                        'label'      => 'Abstract',
                                        'swticher'   => EPOFW_PLUGIN_URL . 'assets/demo-images/image-4.png',
                                        'price'      => '5',
                                        'price_type' => 'fixed',
                                    )
                                ),
                            ),
                            'field_order'              => 1,
                            'field_id'                 => $base_time + 201,
                        ),
                        $base_time + 202 => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'  => 'multiselect',
                                'name'  => 'epofw_field_extra_features',
                                'id'    => 'extra_features',
                                'class' => 'multiselect2',
                            ),
                            'label'                    => array(
                                'title'         => 'Extra Features',
                                'subtitle'      => 'Hold Ctrl/Cmd to select multiple',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 20) . '_2',
                                'group_id' => 'group_' . ($base_time + 20),
                                'layout'   => 'single',
                                'columns'  => '1',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(
                                'addon_price_type' => 'per_option',
                                'options'          => array(
                                    array(
                                        'label'      => 'Water Resistant',
                                        'price'      => '10',
                                        'price_type' => 'fixed',
                                    ),
                                    array(
                                        'label'      => 'UV Protection',
                                        'price'      => '8',
                                        'price_type' => 'fixed',
                                    ),
                                    array(
                                        'label'      => 'Anti-Wrinkle',
                                        'price'      => '5',
                                        'price_type' => 'fixed',
                                    ),
                                    array(
                                        'label'      => 'Stain Guard',
                                        'price'      => '7',
                                        'price_type' => 'fixed',
                                    ),
                                    array(
                                        'label'      => 'Extended Warranty',
                                        'price'      => '15',
                                        'price_type' => 'fixed',
                                    )
                                ),
                            ),
                            'field_order'              => 2,
                            'field_id'                 => $base_time + 202,
                        ),
                    ),
                ),
            ),
        );
    }

    /**
     * Generate a unique option ID.
     *
     * Format: opt_{field_id}{index}_{random}
     *
     * @since 4.4.5
     *
     * @param int $field_id Field ID for uniqueness.
     * @param int $index    Option index.
     * @return string Unique option ID.
     */
    private static function generate_option_id( $field_id, $index ) {
        return 'opt_' . $field_id . ($index + 1) . '_' . wp_rand( 1000, 9999 );
    }

    /**
     * Add option IDs to field settings options.
     *
     * This ensures options have unique IDs like when saved through admin UI.
     *
     * @since 4.4.5
     *
     * @param array $field_data Field data array.
     * @param int   $field_id   Field ID.
     * @return array Modified field data with option IDs.
     */
    private static function add_option_ids_to_field( $field_data, $field_id ) {
        if ( empty( $field_data['epofw_field_settings']['options'] ) || !is_array( $field_data['epofw_field_settings']['options'] ) ) {
            return $field_data;
        }
        foreach ( $field_data['epofw_field_settings']['options'] as $index => &$option ) {
            if ( is_array( $option ) && !isset( $option['id'] ) ) {
                $option['id'] = self::generate_option_id( $field_id, $index );
            }
        }
        return $field_data;
    }

    /**
     * Transform demo data structure for custom tables format
     *
     * The custom tables expect fields to be inside rows, not directly in sections.
     * This method reorganizes the demo data structure to match that format.
     *
     * @since 4.4.0
     *
     * @param array $demo_data Original demo addon data.
     * @return array Transformed data for custom tables.
     */
    private static function transform_demo_data_for_custom_tables( $demo_data ) {
        if ( empty( $demo_data['general'] ) || !is_array( $demo_data['general'] ) ) {
            return $demo_data;
        }
        $transformed = $demo_data;
        foreach ( $transformed['general'] as $section_id => &$section_data ) {
            if ( empty( $section_data['row_groups'] ) || empty( $section_data['fields'] ) ) {
                continue;
            }
            // Get all fields from section level and add option IDs.
            $fields = $section_data['fields'];
            foreach ( $fields as $field_id => &$field_data ) {
                $field_data = self::add_option_ids_to_field( $field_data, $field_id );
            }
            unset($field_data);
            // Break reference.
            $section_data['fields'] = $fields;
            // Transform row_groups to use columns_groups structure.
            foreach ( $section_data['row_groups'] as $group_id => &$group_data ) {
                if ( empty( $group_data['rows'] ) ) {
                    continue;
                }
                // Create columns_groups from rows.
                $columns_groups = array();
                $columns_order = 1;
                foreach ( $group_data['rows'] as $row_id => $row_data ) {
                    // Generate columns_id for this row.
                    $columns_id = 'columns_' . $row_id;
                    // Get layout info from field's row_association (if any field is assigned to this row).
                    $layout_type = 'single';
                    $columns_count = 1;
                    foreach ( $fields as $field_id => $field_data ) {
                        if ( !empty( $field_data['row_association'] ) ) {
                            $assoc_row_id = ( isset( $field_data['row_association']['row_id'] ) ? $field_data['row_association']['row_id'] : '' );
                            $assoc_group_id = ( isset( $field_data['row_association']['group_id'] ) ? $field_data['row_association']['group_id'] : '' );
                            if ( $assoc_row_id === $row_id && $assoc_group_id === $group_id ) {
                                // Get layout from row_association.
                                if ( isset( $field_data['row_association']['layout'] ) && 'multiple' === $field_data['row_association']['layout'] ) {
                                    $layout_type = 'multiple';
                                    $columns_count = ( isset( $field_data['row_association']['columns'] ) ? (int) $field_data['row_association']['columns'] : 2 );
                                }
                                break;
                            }
                        }
                    }
                    // Initialize columns_group structure.
                    // Note: layout_type at root level for save_addon compatibility.
                    $columns_groups[$columns_id] = array(
                        'layout_type'            => $layout_type,
                        'columns_order'          => $columns_order,
                        'columns_group_settings' => array(
                            'layout_type'   => $layout_type,
                            'columns_count' => $columns_count,
                        ),
                        'rows'                   => array(
                            $row_id => array(
                                'column_settings' => ( isset( $row_data['column_settings'] ) ? $row_data['column_settings'] : array(
                                    'enabled' => '',
                                ) ),
                                'row_number'      => 1,
                                'fields'          => array(),
                            ),
                        ),
                    );
                    // Find and assign fields that belong to this row.
                    foreach ( $fields as $field_id => $field_data ) {
                        if ( !empty( $field_data['row_association'] ) ) {
                            $assoc_row_id = ( isset( $field_data['row_association']['row_id'] ) ? $field_data['row_association']['row_id'] : '' );
                            $assoc_group_id = ( isset( $field_data['row_association']['group_id'] ) ? $field_data['row_association']['group_id'] : '' );
                            // Match field to row.
                            if ( $assoc_row_id === $row_id && $assoc_group_id === $group_id ) {
                                $columns_groups[$columns_id]['rows'][$row_id]['fields'][$field_id] = $field_data;
                            }
                        }
                    }
                    ++$columns_order;
                }
                // Replace rows with columns_groups.
                $group_data['columns_groups'] = $columns_groups;
                unset($group_data['rows']);
            }
            // Remove fields from section level (they're now in columns_groups > rows).
            unset($section_data['fields']);
        }
        return $transformed;
    }

    /**
     * Get multiple simple product IDs for demo addons
     *
     * Each demo addon gets assigned to a different product for better showcase.
     *
     * @since 4.4.5
     *
     * @param int $count Number of product IDs to retrieve.
     * @return array Array of product IDs (strings). Returns array with '0' if no products found.
     */
    private static function get_simple_product_ids( $count = 4 ) {
        $args = array(
            'post_type'      => 'product',
            'post_status'    => 'publish',
            'posts_per_page' => $count,
            'orderby'        => 'date',
            'order'          => 'DESC',
            'tax_query'      => array(array(
                'taxonomy' => 'product_type',
                'field'    => 'slug',
                'terms'    => 'simple',
            )),
        );
        $products = get_posts( $args );
        if ( !empty( $products ) ) {
            $product_ids = array();
            foreach ( $products as $product ) {
                $product_ids[] = (string) $product->ID;
            }
            return $product_ids;
        }
        return array('0');
        // Return array with '0' if no simple product found.
    }

    /**
     * Get the first available simple product ID (backward compatibility)
     *
     * @return string Product ID or '0' if no simple product found
     */
    private static function get_first_simple_product_id() {
        $product_ids = self::get_simple_product_ids( 1 );
        return ( !empty( $product_ids ) ? $product_ids[0] : '0' );
    }

    /**
     * Demo 5: Conditional Logic Showcase (Premium Only)
     *
     * Demonstrates conditional logic between different field types.
     *
     * Note: Current server-side conditional logic evaluator uses AND between rules.
     * This demo includes multiple rules and "not_equal_to" patterns to approximate
     * common AND/OR scenarios.
     *
     * @since 4.4.7
     *
     * @param int    $base_time  Base timestamp for unique IDs.
     * @param string $product_id Product ID.
     *
     * @return array Addon configuration.
     */
    private static function get_conditional_logic_showcase_demo( $base_time, $product_id ) {
        return array(
            'epofw_addon_name'     => 'Conditional Logic Showcase (Demo)',
            'epofw_addon_status'   => 'off',
            'epofw_addon_position' => 'before_add_to_cart',
            'additional_rule_data' => array(
                $base_time + 1 => array(
                    'condition' => 'product',
                    'operator'  => 'is_equal_to',
                    'value'     => array(
                        '0' => $product_id,
                    ),
                ),
            ),
            'general'              => array(
                $base_time + 10 => array(
                    'section_id'       => 'section_' . ($base_time + 10),
                    'section_title'    => 'Conditional Logic',
                    'section_status'   => 'on',
                    'section_order'    => 1,
                    'section_settings' => array(
                        'show_label'  => 'on',
                        'enabled'     => '',
                        'description' => 'These fields show/hide based on earlier selections.',
                    ),
                    'row_groups'       => array(
                        'group_' . ($base_time + 10) => array(
                            'row_group_settings' => array(
                                'enabled' => '',
                                'gap'     => '16',
                            ),
                            'rows'               => array(
                                'row_' . ($base_time + 10) . '_1' => array(
                                    'column_settings' => array(
                                        'enabled' => '',
                                    ),
                                ),
                                'row_' . ($base_time + 10) . '_2' => array(
                                    'column_settings' => array(
                                        'enabled' => '',
                                    ),
                                ),
                                'row_' . ($base_time + 10) . '_3' => array(
                                    'column_settings' => array(
                                        'enabled' => '',
                                    ),
                                ),
                                'row_' . ($base_time + 10) . '_4' => array(
                                    'column_settings' => array(
                                        'enabled' => '',
                                    ),
                                ),
                            ),
                        ),
                    ),
                    'fields'           => array(
                        $base_time + 101 => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'     => 'radiogroup',
                                'required' => 'on',
                                'name'     => 'epofw_field_training_type',
                                'id'       => 'training_type',
                                'class'    => 'epofw_fields_tag_class',
                            ),
                            'label'                    => array(
                                'title'         => 'Training Type',
                                'subtitle'      => 'Choose a track',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 10) . '_1',
                                'group_id' => 'group_' . ($base_time + 10),
                                'layout'   => 'single',
                                'columns'  => '1',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(
                                'addon_price_type' => 'per_option',
                                'options'          => array(array(
                                    'label'      => 'Online',
                                    'price'      => '0',
                                    'price_type' => 'fixed',
                                ), array(
                                    'label'      => 'In-person',
                                    'price'      => '20',
                                    'price_type' => 'fixed',
                                )),
                            ),
                            'field_order'              => 1,
                            'field_id'                 => $base_time + 101,
                        ),
                        $base_time + 102 => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'        => 'number',
                                'required'    => '',
                                'placeholder' => '1',
                                'name'        => 'epofw_field_seats',
                                'id'          => 'seats',
                                'class'       => 'epofw_fields_tag_class',
                                'min'         => '1',
                                'max'         => '10',
                                'step'        => '1',
                                'value'       => '1',
                            ),
                            'label'                    => array(
                                'title'         => 'Number of Seats',
                                'subtitle'      => 'Used by conditional logic below',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 10) . '_2',
                                'group_id' => 'group_' . ($base_time + 10),
                                'layout'   => 'single',
                                'columns'  => '1',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(
                                'addon_price_type' => 'fixed',
                                'addon_price'      => '',
                            ),
                            'field_order'              => 2,
                            'field_id'                 => $base_time + 102,
                        ),
                        $base_time + 103 => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'  => 'select',
                                'name'  => 'epofw_field_venue_pref',
                                'id'    => 'venue_pref',
                                'class' => 'epofw_fields_tag_class',
                            ),
                            'label'                    => array(
                                'title'         => 'Venue Preference',
                                'subtitle'      => 'Shown only for In-person',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 10) . '_3',
                                'group_id' => 'group_' . ($base_time + 10),
                                'layout'   => 'single',
                                'columns'  => '1',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(
                                'addon_price_type' => 'per_option',
                                'options'          => array(array(
                                    'label'      => 'Front rows',
                                    'price'      => '10',
                                    'price_type' => 'fixed',
                                ), array(
                                    'label'      => 'Near exit',
                                    'price'      => '0',
                                    'price_type' => 'fixed',
                                )),
                            ),
                            'logical_operation'        => array(
                                $base_time + 1030 => array(
                                    'epofw_conditional_logic_options'  => 'training_type',
                                    'epofw_conditional_logic_operator' => 'equal_to',
                                    'epofw_conditional_logic_fields'   => 'In-person',
                                    'epofw_cnd_logic_type'             => 'show',
                                ),
                            ),
                            'field_order'              => 3,
                            'field_id'                 => $base_time + 103,
                        ),
                        $base_time + 104 => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'  => 'switch',
                                'name'  => 'epofw_field_group_discount',
                                'id'    => 'group_discount',
                                'class' => 'epofw_fields_tag_class',
                            ),
                            'label'                    => array(
                                'title'         => 'Apply Group Discount',
                                'subtitle'      => 'Shown when 5+ seats and not Online',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 10) . '_4',
                                'group_id' => 'group_' . ($base_time + 10),
                                'layout'   => 'single',
                                'columns'  => '1',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(
                                'addon_price_type' => 'fixed',
                                'addon_price'      => '-10',
                            ),
                            'logical_operation'        => array(
                                $base_time + 1040 => array(
                                    'epofw_conditional_logic_options'  => 'seats',
                                    'epofw_conditional_logic_operator' => 'greater_equal_to',
                                    'epofw_conditional_logic_fields'   => '5',
                                    'epofw_cnd_logic_type'             => 'show',
                                ),
                                $base_time + 1041 => array(
                                    'epofw_conditional_logic_options'  => 'training_type',
                                    'epofw_conditional_logic_operator' => 'not_equal_to',
                                    'epofw_conditional_logic_fields'   => 'Online',
                                    'epofw_cnd_logic_type'             => 'show',
                                ),
                            ),
                            'field_order'              => 4,
                            'field_id'                 => $base_time + 104,
                        ),
                    ),
                ),
            ),
        );
    }

    /**
     * Demo 6: Product Group & Repeater (Premium Only)
     *
     * Demonstrates productgroup and repeater storage and rendering.
     *
     * @since 4.4.7
     *
     * @param int    $base_time  Base timestamp for unique IDs.
     * @param string $product_id Product ID.
     *
     * @return array Addon configuration.
     */
    private static function get_product_group_repeater_demo( $base_time, $product_id ) {
        return array(
            'epofw_addon_name'     => 'Product Group & Repeater (Demo)',
            'epofw_addon_status'   => 'off',
            'epofw_addon_position' => 'before_add_to_cart',
            'additional_rule_data' => array(
                $base_time + 1 => array(
                    'condition' => 'product',
                    'operator'  => 'is_equal_to',
                    'value'     => array(
                        '0' => $product_id,
                    ),
                ),
            ),
            'general'              => array(
                $base_time + 10 => array(
                    'section_id'       => 'section_' . ($base_time + 10),
                    'section_title'    => 'Premium Nested Fields',
                    'section_status'   => 'on',
                    'section_order'    => 1,
                    'section_settings' => array(
                        'show_label'  => 'on',
                        'enabled'     => '',
                        'description' => 'Product group selection and repeater entries.',
                    ),
                    'row_groups'       => array(
                        'group_' . ($base_time + 10) => array(
                            'row_group_settings' => array(
                                'enabled' => '',
                                'gap'     => '16',
                            ),
                            'rows'               => array(
                                'row_' . ($base_time + 10) . '_1' => array(
                                    'column_settings' => array(
                                        'enabled' => '',
                                    ),
                                ),
                                'row_' . ($base_time + 10) . '_2' => array(
                                    'column_settings' => array(
                                        'enabled' => '',
                                    ),
                                ),
                            ),
                        ),
                    ),
                    'fields'           => array(
                        $base_time + 101 => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'  => 'productgroup',
                                'name'  => 'epofw_field_bundle',
                                'id'    => 'bundle',
                                'class' => 'epofw_fields_tag_class',
                            ),
                            'label'                    => array(
                                'title'         => 'Bundle Products',
                                'subtitle'      => 'Choose extra products for bundling',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 10) . '_1',
                                'group_id' => 'group_' . ($base_time + 10),
                                'layout'   => 'single',
                                'columns'  => '1',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(
                                'addon_price_type'            => 'fixed',
                                'addon_price'                 => '',
                                'min_selections'              => 1,
                                'max_selections'              => 5,
                                'allow_multiple_productgroup' => 'on',
                                'product_quantity_enabled'    => 'on',
                                'disable_addon_product_stock' => '',
                                'options'                     => array(array(
                                    'id'         => 'opt_bundle_1_' . $base_time,
                                    'label'      => '',
                                    'price'      => '0',
                                    'price_type' => 'fixed',
                                    'product_id' => $product_id,
                                )),
                            ),
                            'field_order'              => 1,
                            'field_id'                 => $base_time + 101,
                        ),
                        $base_time + 102 => array(
                            'field_status'             => 'on',
                            'field'                    => array(
                                'type'  => 'repeater',
                                'name'  => 'epofw_field_guests',
                                'id'    => 'guests',
                                'class' => 'epofw_fields_tag_class',
                            ),
                            'label'                    => array(
                                'title'         => 'Guest List',
                                'subtitle'      => 'Add multiple guests (repeater)',
                                'label_styling' => array(
                                    'enabled' => '',
                                ),
                            ),
                            'row_association'          => array(
                                'row_id'   => 'row_' . ($base_time + 10) . '_2',
                                'group_id' => 'group_' . ($base_time + 10),
                                'layout'   => 'single',
                                'columns'  => '1',
                            ),
                            'field_container_settings' => array(
                                'enabled' => '',
                            ),
                            'input_container_settings' => array(
                                'enabled' => '',
                            ),
                            'epofw_field_settings'     => array(
                                'addon_price_type' => 'quantity_based',
                                'addon_price'      => '15',
                            ),
                            'field_order'              => 2,
                            'field_id'                 => $base_time + 102,
                        ),
                    ),
                ),
            ),
        );
    }

}

EPOFW_Import::init();