<?php

namespace iwbvel\classes\repositories\meta_field;

defined('ABSPATH') || exit();

class Meta_Field_Main
{
    protected $meta_fields_option_name;

    const TEXTINPUT = "textinput";
    const TEXT = "text";
    const TEXTAREA = "textarea";
    const CHECKBOX = "checkbox";
    const RADIO = "radio";
    const ARRAY_TYPE = "array";
    const CALENDAR = "calendar";
    const EMAIL = "email";
    const PASSWORD = "password";
    const URL = "url";
    const IMAGE = "image";
    const FILE = "file";
    const EDITOR = "editor";
    const SELECT = "select";
    const MULTI_SELECT = "multi_select";
    const TAXONOMY = "taxonomy";
    const COLOR = "color_picker";
    const DATE = "date_picker";
    const DATE_TIME = "date_time_picker";
    const TIME = "time_picker";

    const STRING_TYPE = "string";
    const NUMBER = "number";

    public static function get_fields_name_have_operator()
    {
        return [
            // self::TEXTAREA,
            self::EDITOR,
            self::EMAIL,
            self::PASSWORD,
            self::URL,
            self::ARRAY_TYPE,
        ];
    }

    public static function get_main_types()
    {
        return [
            self::TEXTINPUT => esc_html__('TextInput', 'ithemeland-bulk-variation-editing-for-woocommerce'),
            self::TEXTAREA => esc_html__('TextArea', 'ithemeland-bulk-variation-editing-for-woocommerce'),
            self::CHECKBOX => esc_html__('Checkbox', 'ithemeland-bulk-variation-editing-for-woocommerce'),
            self::RADIO => esc_html__('Radio', 'ithemeland-bulk-variation-editing-for-woocommerce'),
            self::ARRAY_TYPE => esc_html__('Array', 'ithemeland-bulk-variation-editing-for-woocommerce'),
            self::CALENDAR => esc_html__('Calendar', 'ithemeland-bulk-variation-editing-for-woocommerce'),
            self::EMAIL => esc_html__('Email', 'ithemeland-bulk-variation-editing-for-woocommerce'),
            self::PASSWORD => esc_html__('Password', 'ithemeland-bulk-variation-editing-for-woocommerce'),
            self::URL => esc_html__('Url', 'ithemeland-bulk-variation-editing-for-woocommerce'),
            self::IMAGE => esc_html__('Image', 'ithemeland-bulk-variation-editing-for-woocommerce'),
            self::FILE => esc_html__('File', 'ithemeland-bulk-variation-editing-for-woocommerce'),
            self::EDITOR => esc_html__('Editor', 'ithemeland-bulk-variation-editing-for-woocommerce'),
            self::SELECT => esc_html__('Select', 'ithemeland-bulk-variation-editing-for-woocommerce'),
        ];
    }

    public static function get_supported_acf_field_types()
    {
        return [
            'text',
            'textarea',
            'number',
            'checkbox',
            'radio',
            'email',
            'image',
            'file',
            'select',
            'multi_select',
            'wysiwyg',
            'password',
            'url',
            'taxonomy',
            'date_picker',
            'date_time_picker',
            'time_picker',
            'color_picker',
        ];
    }

    public static function get_sub_types()
    {
        return [
            self::STRING_TYPE => esc_html__('String', 'ithemeland-bulk-variation-editing-for-woocommerce'),
            self::NUMBER => esc_html__('Number', 'ithemeland-bulk-variation-editing-for-woocommerce'),
        ];
    }

    public function update(array $meta_fields)
    {
        return update_option($this->meta_fields_option_name, $meta_fields);
    }

    public function get()
    {
        $meta_fields = get_option($this->meta_fields_option_name);
        return !empty($meta_fields) ? $meta_fields : [];
    }
}
