// source --> https://giftstoinspire.us/wp-content/plugins/woocommerce/assets/js/frontend/woocommerce.min.js?ver=10.7.0 
function on_keydown_remove_from_cart(e){" "===e.key&&(e.preventDefault(),e.currentTarget.click())}function focus_populate_live_region(){var e=["woocommerce-message","woocommerce-error","wc-block-components-notice-banner"].map(function(e){return"."+e+'[role="alert"]'}).join(", "),o=document.querySelectorAll(e);if(0!==o.length){var t=o[0];t.setAttribute("tabindex","-1");var n=setTimeout(function(){t.focus(),clearTimeout(n)},500)}}function refresh_sorted_by_live_region(){var e=document.querySelector(".woocommerce-result-count");if(e){var o=e.innerHTML;e.setAttribute("aria-hidden","true");var t=setTimeout(function(){e.setAttribute("aria-hidden","false"),e.innerHTML="",e.innerHTML=o,clearTimeout(t)},2e3)}}function on_document_ready(){focus_populate_live_region(),refresh_sorted_by_live_region()}jQuery(function(e){e(".woocommerce-ordering").on("change","select.orderby",function(){e(this).closest("form").trigger("submit")}),e("input.qty:not(.product-quantity input.qty)").each(function(){var o=parseFloat(e(this).attr("min"));o>=0&&parseFloat(e(this).val())<o&&e(this).val(o)});var o="store_notice"+(e(".woocommerce-store-notice").data("noticeId")||"");if("hidden"===Cookies.get(o))e(".woocommerce-store-notice").hide();else{function t(o){["Enter"," "].includes(o.key)&&(o.preventDefault(),e(".woocommerce-store-notice__dismiss-link").click())}e(".woocommerce-store-notice").show(),e(".woocommerce-store-notice__dismiss-link").on("click",function n(r){Cookies.set(o,"hidden",{path:"/"}),e(".woocommerce-store-notice").hide(),r.preventDefault(),e(".woocommerce-store-notice__dismiss-link").off("click",n).off("keydown",t)}).on("keydown",t)}e(".woocommerce-input-wrapper span.description").length&&e(document.body).on("click",function(){e(".woocommerce-input-wrapper span.description:visible").prop("aria-hidden",!0).slideUp(250)}),e(".woocommerce-input-wrapper").on("click",function(e){e.stopPropagation()}),e(".woocommerce-input-wrapper :input").on("keydown",function(o){var t=e(this).parent().find("span.description");if(27===o.which&&t.length&&t.is(":visible"))return t.prop("aria-hidden",!0).slideUp(250),o.preventDefault(),!1}).on("click focus",function(){var o=e(this).parent(),t=o.find("span.description");o.addClass("currentTarget"),e(".woocommerce-input-wrapper:not(.currentTarget) span.description:visible").prop("aria-hidden",!0).slideUp(250),t.length&&t.is(":hidden")&&t.prop("aria-hidden",!1).slideDown(250),o.removeClass("currentTarget")}),e.scroll_to_notices=function(o){o.length&&e("html, body").animate({scrollTop:o.offset().top-100},1e3)},e('.woocommerce form .woocommerce-Input[type="password"]').wrap('<span class="password-input"></span>'),e(".woocommerce form input").filter(":password").parent("span").addClass("password-input"),e(".password-input").each(function(){const o=e(this).find("input").attr("id");e(this).append('<button type="button" class="show-password-input" aria-label="'+woocommerce_params.i18n_password_show+'" aria-describedBy="'+o+'"></button>')}),e(".show-password-input").on("click",function(o){o.preventDefault(),e(this).hasClass("display-password")?(e(this).removeClass("display-password"),e(this).attr("aria-label",woocommerce_params.i18n_password_show)):(e(this).addClass("display-password"),e(this).attr("aria-label",woocommerce_params.i18n_password_hide)),e(this).hasClass("display-password")?e(this).siblings(['input[type="password"]']).prop("type","text"):e(this).siblings('input[type="text"]').prop("type","password"),e(this).siblings("input").focus()}),e("a.coming-soon-footer-banner-dismiss").on("click",function(o){var t=e(o.target);e.ajax({type:"post",url:t.data("rest-url"),data:{woocommerce_meta:{coming_soon_banner_dismissed:"yes"}},beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",t.data("rest-nonce"))},complete:function(){e("#coming-soon-footer-banner").hide()}})}),"undefined"==typeof wc_add_to_cart_params&&e(document.body).on("keydown",".remove_from_cart_button",on_keydown_remove_from_cart),e(document.body).on("item_removed_from_classic_cart updated_wc_div",focus_populate_live_region)}),document.addEventListener("DOMContentLoaded",on_document_ready);
// source --> https://giftstoinspire.us/wp-content/plugins/woocommerce-custom-fields/assets/js/general.js?ver=1.2.1 
/**
 * WooCommerce Custom Fields Plugin General Scripts
 */
jQuery(document).ready(function() {

    /**
     * Datepicker
     */
    jQuery('.wccf_date').each(function() {
        jQuery(this).datepicker(rp_wccf_datepicker_config);
    });

    /**
     * Check frontend conditions
     */
    function check_conditions(form)
    {
        // Iterate over all custom fields in this form
        form.find('.wccf').each(function() {

            // Get element id and conditions variable name
            var id = jQuery(this).prop('id');
            var conditions = 'wccf_conditions_' + id;

            // Check if we have any conditions for this field
            if (typeof window[conditions] !== 'undefined') {

                // Track if all conditions match
                var conditions_match = true;

                // Reference context
                var context = window[conditions]['context'];

                // Iterate over conditions
                for (var i = 0; i < window[conditions]['conditions'].length; i++) {

                    // Reference current condition and context
                    var condition = window[conditions]['conditions'][i];

                    // Check if condition is matched
                    if (!check_condition(form, condition, context)) {
                        conditions_match = false;
                    }
                }

                // Make field visible
                if (conditions_match && !form.find('#' + id).is(':visible')) {
                    jQuery('#' + id).closest('.wccf_meta_box_field_container, .wccf_field_container').each(function() {

                        // Enable fields so they are submitted
                        jQuery(this).find('input, select, textarea').removeAttr('disabled');

                        // Show field
                        jQuery(this).show();
                    });
                }
                // Make field hidden
                else if (!conditions_match && form.find('#' + id).is(':visible')) {
                    jQuery('#' + id).closest('.wccf_meta_box_field_container, .wccf_field_container').each(function() {

                        // Hide field
                        jQuery(this).hide();

                        // Disable fields so they are not submitted
                        jQuery(this).find('input, select, textarea').attr('disabled', 'disabled');

                        // TBD: currently this does not support chained conditions
                    });
                }
            }
        });
    }

    /**
     * Check single frontend condition
     */
    function check_condition(form, condition, context)
    {
        if (condition.type === 'custom_field_other_custom_field') {
            return check_condition_other_custom_field(form, condition, context);
        }

        return false;
    }

    /**
     * Check other custom field condition
     */
    function check_condition_other_custom_field(form, condition, context)
    {
        // Reference field that we are checking against
        var other_field = form.find('#wccf_' + context + '_' + condition.other_field_key);

        // Reference method
        var method = condition.custom_field_other_custom_field_method;

        // Is Empty
        if (method === 'is_empty') {
            return is_empty(form, other_field);
        }

        // Is Not Empty
        else if (method === 'is_not_empty') {
            return !is_empty(form, other_field);
        }

        // Contains
        else if (method === 'contains') {
            return contains(form, other_field, condition.text);
        }

        // Does Not Contain
        else if (method === 'does_not_contain') {
            return !contains(form, other_field, condition.text);
        }

        // Equals
        else if (method === 'equals') {
            return equals(form, other_field, condition.text);
        }

        // Does Not Equal
        else if (method === 'does_not_equal') {
            return !equals(form, other_field, condition.text);
        }

        // Less Than
        else if (method === 'less_than') {
            return less_than(form, other_field, condition.text);
        }

        // Less Or Equal To
        else if (method === 'less_or_equal_to') {
            return !more_than(form, other_field, condition.text);
        }

        // More Than
        else if (method === 'more_than') {
            return more_than(form, other_field, condition.text);
        }

        // More Or Equal
        else if (method === 'more_or_equal') {
            return !less_than(form, other_field, condition.text);
        }

        // Is Checked
        else if (method === 'is_checked') {
            return is_checked(form, other_field);
        }

        // Is Not Checked
        else if (method === 'is_not_checked') {
            return !is_checked(form, other_field);
        }
    }

    /**
     * Check if field element is empty
     */
    function is_empty(form, field)
    {
        // Get value of field that we are checking against
        var field_value = get_value(form, field);

        // Check if value is empty
        return (field_value === '' || field_value === null || field_value.length === 0);
    }

    /**
     * Check if field element contains string
     */
    function contains(form, field, value)
    {
        // Get value of field that we are checking against
        var field_value = get_value(form, field);

        // Will check subscring in string and whole array value in array (for select fields)
        if (field_value !== null && field_value.indexOf(value) > -1) {
            return true;
        }

        return false;
    }

    /**
     * Check if field element equals string
     */
    function equals(form, field, value)
    {
        // Get value of field that we are checking against
        var field_value = get_string_value(get_value(form, field));

        // Check if it equals given string
        if (field_value !== false && field_value === value) {
            return true;
        }

        return false;
    }

    /**
     * Check if field element is less than value
     */
    function less_than(form, field, value)
    {
        // Get value of field that we are checking against
        var field_value = get_string_value(get_value(form, field));

        // Check if value is less than given value
        if (field_value !== false && field_value < value) {
            return true;
        }

        return false;
    }

    /**
     * Check if field element is more than value
     */
    function more_than(form, field, value)
    {
        // Get value of field that we are checking against
        var field_value = get_string_value(get_value(form, field));

        // Check if value is less than given value
        if (field_value !== false && field_value > value) {
            return true;
        }

        return false;
    }

    /**
     * Check if field element is checked
     */
    function is_checked(form, field)
    {
        // In case of radio or checkbox
        if (field.is(':checkbox') || field.is(':radio')) {
            if (field.is(':checked')) {
                return true;
            }
        }

        // In case of other fields - make sure it's not empty
        else {
            if (!is_empty(form, field)) {
                return true;
            }
        }

        return false;
    }

    /**
     * Get value depending on field type
     */
    function get_value(form, field)
    {
        // No field? This must be a condition dependant on checkbox or radio fields
        if (field.length === 0) {

            // Get beginning of potential field id
            var id = field.selector;
            id = id.replace('#', '');

            // Store values
            var values = [];

            // Iterate over all checkbox and radio elements in a given form
            form.find('input:radio, input:checkbox').each(function() {

                // Check if id of current element matches beginning of selector id and is checked
                if (jQuery(this).prop('id').indexOf(id) > -1 && jQuery(this).is(':checked')) {

                    // Also make sure it's not some other field which id begins with the same string
                    if (id + '_' + jQuery(this).val() === jQuery(this).prop('id')) {
                        values.push(jQuery(this).val());
                    }
                }
            });

            // Return values
            return values.length > 0 ? values : '';
        }

        // Field selected successfully - return value
        else {
            return (typeof field.val() === 'string' ? field.val().trim() : field.val());
        }
    }

    /**
     * Get string value from any value
     */
    function get_string_value(value)
    {
        // In case of string
        if (typeof value === 'string') {
            return value.trim();
        }

        // In case of array with single element
        if (value !== null && typeof value === 'object' && value.length === 1 && typeof value[0] === 'string') {
            return value[0].trim();
        }

        return false;
    }

    /**
     * Initialize frontend condition checks
     */
    jQuery('form:has(.wccf)').each(function() {

        // Get reference
        var form = jQuery(this);

        // Check conditions on page load
        check_conditions(form);

        // Check conditions on interaction with elements
        form.find('.wccf').each(function() {

            // Key up
            jQuery(this).keyup(function() {
                check_conditions(form);
            });

            // Value change
            jQuery(this).change(function() {
                check_conditions(form);
            });
        });
    });

});