<?php
/**
 * Havenlytics DefaultTabSectionsData
 *
 * @package HvnlyNab\Api\Type\Builders
 * @since 2.0.0
 */


namespace HvnlyNab\Api\Type\Builders;

// Exit if accessed directly.
if (!defined('ABSPATH')) {
    exit;
}
class DefaultTabSectionsData
{
    private static $instance = null;

    public static function get_instance()
    {
        if (null === self::$instance) {
            self::$instance = new self();
        }
        return self::$instance;
    }

    /**
     * Get default sections in DnDSections format
     */
    public static function get_default_sections_for_dnd()
    {
        $metabox_tabs = self::hvnly_metabox_tabs_builder();
        $dnd_sections = [];

        foreach ($metabox_tabs as $index => $tab) {
            $section_id = $tab['id'] ?? 'sec_' . uniqid();

            // Mark required tabs
            $is_required_tab = ($tab['hvnly__sectiontitle'] ?? '') === 'Basic Info';

            $dnd_sections[$section_id] = [
                'id' => $section_id,
                'title' => sanitize_text_field($tab['hvnly__sectiontitle'] ?? 'Untitled Section'),
                'icon' => sanitize_text_field($tab['icon'] ?? 'fas fa-home'),
                'order' => $index,
                'collapsed' => false,
                'required' => $is_required_tab,
                'fields' => self::convert_fields_to_dnd_format_with_groups($tab['fields'] ?? [], $is_required_tab)
            ];
        }

        return $dnd_sections;
    }

    /**
     * Convert metabox fields to DnDSections format with groups
     */
    private static function convert_fields_to_dnd_format_with_groups($fields, $is_required_tab = false)
    {
        if (!is_array($fields)) {
            return [];
        }

        $dnd_fields = [];
        $current_group_id = null;
        $group_type = null;
        $group_position = 0;
        $group_base_id = null;

        foreach ($fields as $index => $field) {
            $field_id = $field['fieldid'] ?? 'fld_' . uniqid();
            $is_locked_field = $is_required_tab && $index < 3;
            $meta_key = $field['metaKey'] ?? '';

            // Check if this is a video group
            if (isset($field['group_type']) && $field['group_type'] === 'video') {
                if (!$current_group_id || $group_type !== 'video') {
                    $current_group_id = 'grp_video_' . uniqid();
                    $group_type = 'video';
                    $group_position = 0;
                    $group_base_id = 'video_' . time() . '_' . substr(uniqid(), -8);
                }
                
                $dnd_field = [
                    'id' => $field_id,
                    'name' => $field['name'] ?? $field_id,
                    'type' => self::map_field_type($field['input_type'] ?? 'text'),
                    'label' => sanitize_text_field($field['label'] ?? ''),
                    'placeholder' => sanitize_text_field($field['placeholder'] ?? ''),
                    'required' => !empty($field['is_required']),
                    'locked' => $is_locked_field,
                    'adminOnly' => false,
                    'enabled' => true,
                    'order' => $index,
                    'group_id' => $current_group_id,
                    'group_type' => 'video',
                    'group_name' => 'Video Information',
                    'group_position' => $group_position,
                    'group_total' => 3,
                    'group_base_id' => $group_base_id,
                    'metaKey' => $meta_key,
                    'hidden' => false
                ];
                $group_position++;
                
            } 
            // Check if this is a gallery group
            elseif (isset($field['group_type']) && $field['group_type'] === 'gallery') {
                if (!$current_group_id || $group_type !== 'gallery') {
                    $current_group_id = 'grp_gallery_' . uniqid();
                    $group_type = 'gallery';
                    $group_position = 0;
                    $group_base_id = 'gallery_' . time() . '_' . substr(uniqid(), -8);
                }
                
                $dnd_field = [
                    'id' => $field_id,
                    'name' => $field['name'] ?? $field_id,
                    'type' => self::map_field_type($field['input_type'] ?? 'text'),
                    'label' => sanitize_text_field($field['label'] ?? ''),
                    'placeholder' => sanitize_text_field($field['placeholder'] ?? ''),
                    'required' => !empty($field['is_required']),
                    'locked' => $is_locked_field,
                    'adminOnly' => false,
                    'enabled' => true,
                    'order' => $index,
                    'group_id' => $current_group_id,
                    'group_type' => 'gallery',
                    'group_name' => 'Property Gallery',
                    'group_position' => $group_position,
                    'group_total' => 2,
                    'group_base_id' => $group_base_id,
                    'metaKey' => $meta_key,
                    'hidden' => false
                ];
                $group_position++;
                
            } 
            // Check if this is a map group
            elseif (isset($field['group_type']) && $field['group_type'] === 'map') {
                if (!$current_group_id || $group_type !== 'map') {
                    $current_group_id = 'grp_map_' . uniqid();
                    $group_type = 'map';
                    $group_position = 0;
                    $group_base_id = 'map_' . time() . '_' . substr(uniqid(), -8);
                }
                
                // Explicitly set hidden flag for latitude and longitude fields
                $is_hidden_field = in_array($meta_key, ['latitude', 'longitude']);
                
                $dnd_field = [
                    'id' => $field_id,
                    'name' => $field['name'] ?? $field_id,
                    'type' => self::map_field_type($field['input_type'] ?? 'text'),
                    'label' => sanitize_text_field($field['label'] ?? ''),
                    'placeholder' => sanitize_text_field($field['placeholder'] ?? ''),
                    'required' => !empty($field['is_required']),
                    'locked' => $is_locked_field,
                    'adminOnly' => false,
                    'enabled' => true,
                    'order' => $index,
                    'group_id' => $current_group_id,
                    'group_type' => 'map',
                    'group_name' => 'Map Location',
                    'group_position' => $group_position,
                    'group_total' => 4,
                    'group_base_id' => $group_base_id,
                    'metaKey' => $meta_key,
                    'hidden' => $is_hidden_field
                ];
                
                // Add relationship fields for map
                if ($meta_key === 'preview') {
                    $dnd_field['address_field_name'] = $group_base_id . '_address';
                    $dnd_field['lat_field_name'] = $group_base_id . '_latitude';
                    $dnd_field['lng_field_name'] = $group_base_id . '_longitude';
                    $dnd_field['map_field_name'] = $group_base_id . '_preview';
                }
                
                $group_position++;
            }
            // Check if this is a property_docs group
            elseif (isset($field['group_type']) && $field['group_type'] === 'property_docs') {
                if (!$current_group_id || $group_type !== 'property_docs') {
                    $current_group_id = 'grp_property_docs_' . uniqid();
                    $group_type = 'property_docs';
                    $group_position = 0;
                    $group_base_id = 'property_docs_' . time() . '_' . substr(uniqid(), -8);
                }
                
                $field_type = self::map_field_type($field['input_type'] ?? 'text');
                
                $dnd_field = [
                    'id' => $field_id,
                    'name' => $field['name'] ?? $field_id,
                    'type' => $field_type,
                    'label' => sanitize_text_field($field['label'] ?? ''),
                    'placeholder' => sanitize_text_field($field['placeholder'] ?? ''),
                    'required' => !empty($field['is_required']),
                    'locked' => $is_locked_field,
                    'adminOnly' => false,
                    'enabled' => true,
                    'order' => $index,
                    'group_id' => $current_group_id,
                    'group_type' => 'property_docs',
                    'group_name' => 'Property Documents',
                    'group_position' => $group_position,
                    'group_total' => 3,
                    'group_base_id' => $group_base_id,
                    'metaKey' => $meta_key,
                    'hidden' => false,
                    // Add show_in_sidebar ONLY for property_docs group
                    'show_in_sidebar' => isset($field['show_in_sidebar']) ? (bool)$field['show_in_sidebar'] : true
                ];
                
                $group_position++;
            } else {
                // Regular field (not in a group) - NO show_in_sidebar here
                $current_group_id = null;
                $group_type = null;
                $group_position = 0;
                
                $dnd_field = [
                    'id' => $field_id,
                    'name' => sanitize_text_field($field['name'] ?? $field_id),
                    'type' => self::map_field_type($field['input_type'] ?? 'text'),
                    'label' => sanitize_text_field($field['label'] ?? ''),
                    'placeholder' => sanitize_text_field($field['placeholder'] ?? ''),
                    'required' => !empty($field['is_required']),
                    'locked' => $is_locked_field,
                    'adminOnly' => false,
                    'enabled' => true,
                    'order' => $index,
                    'hidden' => false
                ];
            }

            // Add conditional fields
            if (!empty($field['condition'])) {
                $dnd_field['condition'] = [
                    'field' => sanitize_text_field($field['condition']['field'] ?? ''),
                    'value' => sanitize_text_field($field['condition']['value'] ?? '')
                ];
            }

            // Add options for select fields
            if (!empty($field['options']) && is_array($field['options'])) {
                $dnd_field['options'] = $field['options'];
            }

            // Add file type for file uploads
            if (!empty($field['file_type'])) {
                $dnd_field['fileType'] = sanitize_text_field($field['file_type']);
            }

            // Add description/userguide
            if (!empty($field['description'])) {
                $dnd_field['description'] = sanitize_text_field($field['description']);
            }

            if (!empty($field['userguide'])) {
                $dnd_field['userguide'] = sanitize_text_field($field['userguide']);
            }

            $dnd_fields[] = $dnd_field;
        }

        return $dnd_fields;
    }

    /**
     * Map old field types to new standardized types
     */
    private static function map_field_type($old_type)
    {
        $type_mapping = [
            'text' => 'text',
            'number' => 'number',
            'select' => 'select',
            'checkbox' => 'checkbox',
            'file' => 'file',
            'gallery' => 'gallery',
            'map' => 'map',
            'textarea' => 'textarea',
            'image' => 'file',
            'price_label' => 'price_label', 
        ];

        return $type_mapping[$old_type] ?? 'text';
    }

    /**
     * Get property documents group fields with group metadata
     * ONLY includes show_in_sidebar for this group type
     */
    private static function get_property_docs_group_fields()
    {
        $group_id = 'grp_property_docs_' . uniqid();
        $timestamp = time();
        $group_base_id = 'property_docs_' . $timestamp . '_' . substr(uniqid(), -8);
        
        return array(
            array(
                'fieldid'     => $group_base_id . '_icon',
                'input_type'  => 'text',
                'label'       => __('Document Icon', 'havenlytics'),
                'name'        => $group_base_id . '_icon',
                'placeholder' => __('e.g., file-pdf, print, video', 'havenlytics'),
                'group_type'  => 'property_docs',
                'group_id'    => $group_id,
                'group_base_id' => $group_base_id,
                'metaKey'     => 'icon',
                'show_in_sidebar' => true
            ),
            array(
                'fieldid'     => $group_base_id . '_label',
                'input_type'  => 'text',
                'label'       => __('Document Label', 'havenlytics'),
                'name'        => $group_base_id . '_label',
                'placeholder' => __('e.g., Floor Plan, Brochure, EPC', 'havenlytics'),
                'is_required' => true,
                'group_type'  => 'property_docs',
                'group_id'    => $group_id,
                'group_base_id' => $group_base_id,
                'metaKey'     => 'label',
                'show_in_sidebar' => true
            ),
            array(
                'fieldid'     => $group_base_id . '_url',
                'input_type'  => 'text',
                'label'       => __('Document URL', 'havenlytics'),
                'name'        => $group_base_id . '_url',
                'placeholder' => __('Enter document URL or file path', 'havenlytics'),
                'is_required' => true,
                'group_type'  => 'property_docs',
                'group_id'    => $group_id,
                'group_base_id' => $group_base_id,
                'metaKey'     => 'url',
                'show_in_sidebar' => true
            ),
        );
    }

    /**
     * Get video group fields with group metadata
     */
    private static function get_video_group_fields()
    {
        $group_id = 'grp_video_' . uniqid();
        $timestamp = time();
        $group_base_id = 'video_' . $timestamp . '_' . substr(uniqid(), -8);
        
        return array(
            array(
                'fieldid'     => $group_base_id . '_title',
                'input_type'  => 'text',
                'label'       => __('Video Title', 'havenlytics'),
                'name'        => $group_base_id . '_title',
                'placeholder' => __('Enter video title', 'havenlytics'),
                'group_type'  => 'video',
                'group_id'    => $group_id,
                'group_base_id' => $group_base_id,
                'metaKey'     => 'title',
            ),
            array(
                'fieldid'     => $group_base_id . '_url',
                'input_type'  => 'text',
                'label'       => __('Video URL', 'havenlytics'),
                'name'        => $group_base_id . '_url',
                'placeholder' => __('Enter video URL', 'havenlytics'),
                'group_type'  => 'video',
                'group_id'    => $group_id,
                'group_base_id' => $group_base_id,
                'metaKey'     => 'url',
            ),
            array(
                'fieldid'     => $group_base_id . '_thumbnail',
                'input_type'  => 'file',
                'label'       => __('Video Thumbnail', 'havenlytics'),
                'name'        => $group_base_id . '_thumbnail',
                'placeholder' => __('Upload video thumbnail', 'havenlytics'),
                'file_type'   => 'image',
                'group_type'  => 'video',
                'group_id'    => $group_id,
                'group_base_id' => $group_base_id,
                'metaKey'     => 'thumbnail',
            ),
        );
    }

    /**
     * Get gallery group fields with group metadata
     */
    private static function get_gallery_group_fields()
    {
        $group_id = 'grp_gallery_' . uniqid();
        $timestamp = time();
        $group_base_id = 'gallery_' . $timestamp . '_' . substr(uniqid(), -8);
        
        return array(
            array(
                'fieldid'     => $group_base_id . '_title',
                'input_type'  => 'text',
                'label'       => __('Gallery Title', 'havenlytics'),
                'name'        => $group_base_id . '_title',
                'placeholder' => __('Enter gallery title', 'havenlytics'),
                'group_type'  => 'gallery',
                'group_id'    => $group_id,
                'group_base_id' => $group_base_id,
                'metaKey'     => 'title',
            ),
            array(
                'fieldid'     => $group_base_id . '_images',
                'input_type'  => 'gallery',
                'label'       => __('Gallery Images', 'havenlytics'),
                'name'        => $group_base_id . '_images',
                'placeholder' => __('Upload gallery images', 'havenlytics'),
                'group_type'  => 'gallery',
                'group_id'    => $group_id,
                'group_base_id' => $group_base_id,
                'metaKey'     => 'images',
            ),
        );
    }

    /**
     * Get map group fields with group metadata
     */
    private static function get_map_group_fields()
    {
        $group_id = 'grp_map_' . uniqid();
        $timestamp = time();
        $unique_suffix = substr(uniqid(), -8);
        $group_base_id = 'map_' . $timestamp . '_' . $unique_suffix;
        
        // Pre-calculate field names for consistency
        $address_field_name = $group_base_id . '_address';
        $latitude_field_name = $group_base_id . '_latitude';
        $longitude_field_name = $group_base_id . '_longitude';
        $preview_field_name = $group_base_id . '_preview';
        
        return array(
            // Address field
            array(
                'fieldid'     => $address_field_name,
                'input_type'  => 'text',
                'label'       => __('Property Map Address', 'havenlytics'),
                'name'        => $address_field_name,
                'placeholder' => __('Enter property map address', 'havenlytics'),
                'is_required' => true,
                'group_type'  => 'map',
                'group_id'    => $group_id,
                'group_base_id' => $group_base_id,
                'metaKey'     => 'address',
            ),
            // Latitude field - hidden
            array(
                'fieldid'     => $latitude_field_name,
                'input_type'  => 'text',
                'label'       => __('Property Latitude', 'havenlytics'),
                'name'        => $latitude_field_name,
                'placeholder' => __('Enter property latitude', 'havenlytics'),
                'userguide'   => __('Get the property latitude by clicking on Google Maps or visiting https://www.maps.ie/coordinates.html', 'havenlytics'),
                'group_type'  => 'map',
                'group_id'    => $group_id,
                'group_base_id' => $group_base_id,
                'metaKey'     => 'latitude',
                'hidden'      => true,
            ),
            // Longitude field - hidden
            array(
                'fieldid'     => $longitude_field_name,
                'input_type'  => 'text',
                'label'       => __('Property Longitude', 'havenlytics'),
                'name'        => $longitude_field_name,
                'placeholder' => __('Enter property longitude', 'havenlytics'),
                'userguide'   => __('Get the property longitude by clicking on Google Maps or visiting https://www.maps.ie/coordinates.html', 'havenlytics'),
                'group_type'  => 'map',
                'group_id'    => $group_id,
                'group_base_id' => $group_base_id,
                'metaKey'     => 'longitude',
                'hidden'      => true,
            ),
            // Preview map field - using pre-calculated field names
            array(
                'fieldid'     => $preview_field_name,
                'input_type'  => 'map',
                'label'       => __('Property Location Map', 'havenlytics'),
                'name'        => $preview_field_name,
                'group_type'  => 'map',
                'group_id'    => $group_id,
                'group_base_id' => $group_base_id,
                'metaKey'     => 'preview',
                // IMPORTANT: These must match EXACTLY the field names above
                'address_field_name' => $address_field_name,
                'lat_field_name' => $latitude_field_name,
                'lng_field_name' => $longitude_field_name,
                'map_field_name' => $preview_field_name,
            ),
        );
    }

    /**
     * Original metabox tabs data with groups
     */
    public static function hvnly_metabox_tabs_builder()
    {
        return array(
            array(
                'hvnly__sectiontitle' => __('Basic Info', 'havenlytics'),
                'id'           => 'hvnly__dyamic_metabox_tab__' . uniqid(),
                'icon'         => 'fas fa-home',
                'fields'       => array(
                    array(
                        'fieldid'     => '_hvnly_property_price',
                        'input_type'  => 'price_label',
                        'label'       => __('Property Price', 'havenlytics'),
                        'name'        => '_hvnly_property_price',
                        'placeholder' => __('Enter property price', 'havenlytics'),
                        'is_required' => true,
                    ),
                    array(
                        'fieldid'     => '_hvnly_property_reception_rooms',
                        'input_type'  => 'number',
                        'label'       => __('Property Reception Rooms', 'havenlytics'),
                        'name'        => '_hvnly_property_reception_rooms',
                        'placeholder' => __('Enter reception rooms', 'havenlytics'),
                        'is_required' => true,
                    ),
                    array(
                        'fieldid'     => '_hvnly_property_bedrooms',
                        'input_type'  => 'number',
                        'label'       => __('Property Bedrooms', 'havenlytics'),
                        'name'        => '_hvnly_property_bedrooms',
                        'placeholder' => __('Enter property bedrooms', 'havenlytics'),
                        'is_required' => true,
                    ),
                    array(
                        'fieldid'     => '_hvnly_property_bathrooms',
                        'input_type'  => 'number',
                        'label'       => __('Property Bathrooms', 'havenlytics'),
                        'name'        => '_hvnly_property_bathrooms',
                        'placeholder' => __('Enter property bathrooms', 'havenlytics'),
                        'is_required' => true,
                    ),
                    array(
                        'fieldid'     => '_hvnly_property_half_bathrooms',
                        'input_type'  => 'number',
                        'label'       => __('Property Half Baths', 'havenlytics'),
                        'name'        => '_hvnly_property_half_bathrooms',
                        'placeholder' => __('Enter property half baths', 'havenlytics'),
                        'is_required' => true,
                    ),
                    array(
                        'fieldid'     => '_hvnly_property_kitchens',
                        'input_type'  => 'number',
                        'label'       => __('Property Kitchen', 'havenlytics'),
                        'name'        => '_hvnly_property_kitchens',
                        'placeholder' => __('Enter property kitchen', 'havenlytics'),
                    ),
                    array(
                        'fieldid'     => '_hvnly_property_total_rooms',
                        'input_type'  => 'number',
                        'label'       => __('Property Total Rooms', 'havenlytics'),
                        'name'        => '_hvnly_property_total_rooms',
                        'placeholder' => __('Enter property total rooms', 'havenlytics'),
                        'is_required' => true,
                    ),
                    array(
                        'fieldid'     => '_hvnly_property_floors',
                        'input_type'  => 'number',
                        'label'       => __('Property Floors', 'havenlytics'),
                        'name'        => '_hvnly_property_floors',
                        'placeholder' => __('Enter property floors', 'havenlytics'),
                    ),
                    array(
                        'fieldid'     => '_hvnly_property_year_built',
                        'input_type'  => 'number',
                        'label'       => __('Property Year Built', 'havenlytics'),
                        'name'        => '_hvnly_property_year_built',
                        'placeholder' => __('Enter property year built', 'havenlytics'),
                    ),
                    array(
                        'fieldid'     => '_hvnly_property_mls_number',
                        'input_type'  => 'text',
                        'label'       => __('Property MLS Number', 'havenlytics'),
                        'name'        => '_hvnly_property_mls_number',
                        'placeholder' => __('Enter property MLS number', 'havenlytics'),
                    ),
                    array(
                        'fieldid'     => '_hvnly_property_garage_sqft',
                        'input_type'  => 'number',
                        'label'       => __('Property Garage Square Footage', 'havenlytics'),
                        'name'        => '_hvnly_property_garage_sqft',
                        'placeholder' => __('Enter property garage square footage', 'havenlytics'),
                        'is_required' => true,
                    ),
                ),
            ),
            array(
                'hvnly__sectiontitle' => __('Additional Information', 'havenlytics'),
                'id'           => 'hvnly__dyamic_metabox_tab__' . uniqid(),
                'icon'         => 'fas fa-info-circle',
                'fields'       => array(
                    array(
                        'fieldid'     => '_hvnly_property_sqft',
                        'input_type'  => 'number',
                        'label'       => __('Property Area, sq ft', 'havenlytics'),
                        'name'        => '_hvnly_property_sqft',
                        'placeholder' => __('Enter property area in square feet', 'havenlytics'),
                        'is_required' => true,
                    ),
                    array(
                        'fieldid'     => '_hvnly_property_lot_size',
                        'input_type'  => 'text',
                        'label'       => __('Property Lot size, sq ft', 'havenlytics'),
                        'name'        => '_hvnly_property_lot_size',
                        'placeholder' => __('Enter property lot size', 'havenlytics'),
                        'is_required' => true,
                    ),
                    array(
                        'fieldid'     => '_hvnly_property_hoa_fee',
                        'input_type'  => 'text',
                        'label'       => __('Property HOA Fee', 'havenlytics'),
                        'name'        => '_hvnly_property_hoa_fee',
                        'placeholder' => __('Enter property HOA fee', 'havenlytics'),
                    ),
                    array(
                        'fieldid'     => '_hvnly_property_annual_tax_amount',
                        'input_type'  => 'number',
                        'label'       => __('Property Annual Tax Amount', 'havenlytics'),
                        'name'        => '_hvnly_property_annual_tax_amount',
                        'placeholder' => __('Enter property annual tax amount', 'havenlytics'),
                    ),
                    array(
                        'fieldid'     => '_hvnly_property_heating',
                        'input_type'  => 'select',
                        'label'       => __('Heating', 'havenlytics'),
                        'name'        => '_hvnly_property_heating',
                        'options'     => array(
                            'forced_air' => __('Forced Air', 'havenlytics'),
                            'radiator' => __('Radiator', 'havenlytics'),
                            'heat_pump' => __('Heat Pump', 'havenlytics'),
                            'baseboard' => __('Baseboard', 'havenlytics'),
                            'none' => __('None', 'havenlytics'),
                        ),
                    ),
                    array(
                        'fieldid'     => '_hvnly_property_cooling',
                        'input_type'  => 'select',
                        'label'       => __('Cooling', 'havenlytics'),
                        'name'        => '_hvnly_property_cooling',
                        'options'     => array(
                            'central' => __('Central Air', 'havenlytics'),
                            'window' => __('Window Units', 'havenlytics'),
                            'heat_pump' => __('Heat Pump', 'havenlytics'),
                            'baseboard' => __('Baseboard', 'havenlytics'),
                            'none' => __('None', 'havenlytics'),
                        ),
                    ),
                    array(
                        'fieldid'     => '_hvnly_property_water',
                        'input_type'  => 'select',
                        'label'       => __('Water Source', 'havenlytics'),
                        'name'        => '_hvnly_property_water',
                        'options'     => array(
                            'city' => __('City', 'havenlytics'),
                            'well' => __('Well', 'havenlytics'),
                            'shared_well' => __('Shared Well', 'havenlytics'),
                            'none' => __('None', 'havenlytics'),
                        ),
                    ),
                ),
            ),
            array(
                'hvnly__sectiontitle' => __('Address & Neighborhood', 'havenlytics'),
                'id'           => 'hvnly__dyamic_metabox_tab__' . uniqid(),
                'icon'         => 'fas fa-building',
                'fields'       => array(
                    array(
                        'fieldid'     => '_hvnly_property_reference_number',
                        'input_type'  => 'text',
                        'label'       => __('Property Reference Number', 'havenlytics'),
                        'name'        => '_hvnly_property_reference_number',
                        'placeholder' => __('Enter property reference number', 'havenlytics'),
                    ),
                    array(
                        'fieldid'     => '_hvnly_property_building_number',
                        'input_type'  => 'text',
                        'label'       => __('Property Building Number', 'havenlytics'),
                        'name'        => '_hvnly_property_building_number',
                        'placeholder' => __('Enter property building number', 'havenlytics'),
                    ),
                    array(
                        'fieldid'     => '_hvnly_property_street',
                        'input_type'  => 'text',
                        'label'       => __('Property Street', 'havenlytics'),
                        'name'        => '_hvnly_property_street',
                        'placeholder' => __('Enter property street', 'havenlytics'),
                    ),
                    array(
                        'fieldid'     => '_hvnly_property_address_line_1',
                        'input_type'  => 'text',
                        'label'       => __('Property Address Line 1', 'havenlytics'),
                        'name'        => '_hvnly_property_address_line_1',
                        'placeholder' => __('Enter property address line 1', 'havenlytics'),
                    ),
                    array(
                        'fieldid'     => '_hvnly_property_address_line_2',
                        'input_type'  => 'text',
                        'label'       => __('Property Address Line 2', 'havenlytics'),
                        'name'        => '_hvnly_property_address_line_2',
                        'placeholder' => __('Enter property address line 2', 'havenlytics'),
                    ),
                    array(
                        'fieldid'     => '_hvnly_property_town_city',
                        'input_type'  => 'text',
                        'label'       => __('Property Town/City', 'havenlytics'),
                        'name'        => '_hvnly_property_town_city',
                        'placeholder' => __('Enter property town/city', 'havenlytics'),
                    ),
                    array(
                        'fieldid'     => '_hvnly_property_country_state',
                        'input_type'  => 'text',
                        'label'       => __('Property Country/State', 'havenlytics'),
                        'name'        => '_hvnly_property_country_state',
                        'placeholder' => __('Enter property country/state', 'havenlytics'),
                    ),
                    array(
                        'fieldid'     => '_hvnly_property_zip_code',
                        'input_type'  => 'text',
                        'label'       => __('Property Zip Code', 'havenlytics'),
                        'name'        => '_hvnly_property_zip_code',
                        'placeholder' => __('Enter property zip code', 'havenlytics'),
                    ),
                    array(
                        'fieldid'     => '_hvnly_property_location',
                        'input_type'  => 'select',
                        'label'       => __('Property Location', 'havenlytics'),
                        'name'        => '_hvnly_property_location',
                        'options'     => self::hvnly_get_property_locations(),
                    ),
                    array(
                        'fieldid'     => '_hvnly_property_country_location',
                        'input_type'  => 'select',
                        'label'       => __('Property Country', 'havenlytics'),
                        'name'        => '_hvnly_property_country_location',
                        'options'     => self::hvnly_get_property_countries(),
                    ),
                ),
            ),
            array(
                'hvnly__sectiontitle' => __('Property Video', 'havenlytics'),
                'id'           => 'hvnly__dyamic_metabox_tab__' . uniqid(),
                'icon'         => 'fas fa-video',
                'fields'       => self::get_video_group_fields(),
            ),
            array(
                'hvnly__sectiontitle' => __('Property Gallery', 'havenlytics'),
                'id'           => 'hvnly__dyamic_metabox_tab__' . uniqid(),
                'icon'         => 'fas fa-images',
                'fields'       => self::get_gallery_group_fields(),
            ),
            array(
                'hvnly__sectiontitle' => __('Property Location', 'havenlytics'),
                'id'           => 'hvnly__dyamic_metabox_tab__' . uniqid(),
                'icon'         => 'fas fa-map-marker-alt',
                'fields'       => self::get_map_group_fields(),
            ),
            array(
                'hvnly__sectiontitle' => __('Property Documents', 'havenlytics'),
                'id'           => 'hvnly__dyamic_metabox_tab__' . uniqid(),
                'icon'         => 'fas fa-file-pdf',
                'fields'       => self::get_property_docs_group_fields(),
            )
        );
    }

    /**
     * Utility methods for options data
     */
    public static function hvnly_get_property_locations()
    {
        return array(
            'urban' => __('Urban', 'havenlytics'),
            'suburban' => __('Suburban', 'havenlytics'),
            'rural' => __('Rural', 'havenlytics'),
            'coastal' => __('Coastal', 'havenlytics'),
        );
    }

    public static function hvnly_get_property_countries()
    {
        return array(
            'us' => __('United States', 'havenlytics'),
            'uk' => __('United Kingdom', 'havenlytics'),
            'ca' => __('Canada', 'havenlytics'),
            'au' => __('Australia', 'havenlytics'),
        );
    }

    public static function get_cf7_forms()
    {
        return array(
            '' => __('Select a Form', 'havenlytics'),
            'form1' => __('Contact Form 1', 'havenlytics'),
            'form2' => __('Contact Form 2', 'havenlytics'),
        );
    }
}