﻿// source --> https://mfrash.com/wp-content/plugins/woocommerce/assets/client/blocks/wc-blocks-registry.js?ver=bb54b6869c8b2a477616 
(()=>{"use strict";var e={n:t=>{var o=t&&t.__esModule?()=>t.default:()=>t;return e.d(o,{a:o}),o},d:(t,o)=>{for(var r in o)e.o(o,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:o[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{__experimentalDeRegisterExpressPaymentMethod:()=>P,__experimentalDeRegisterPaymentMethod:()=>k,__experimentalRegisterProductCollection:()=>z,getExpressPaymentMethods:()=>S,getPaymentMethods:()=>I,getRegisteredBlockComponents:()=>A,getRegisteredInnerBlocks:()=>T,registerBlockComponent:()=>x,registerExpressPaymentMethod:()=>g,registerInnerBlock:()=>R,registerPaymentMethod:()=>h,registerPaymentMethodExtensionCallbacks:()=>v});const o=window.wp.deprecated;var r=e.n(o);const n=window.wp.data,a={},i=a,s=(e,t,o)=>{const r=((e,t)=>o=>(o?.paymentRequirements||[]).every(e=>t.includes(e))&&e(o))(e,t);return Object.values(i).some(e=>o in e)?((e,t,o)=>r=>{let n=e(r);if(n){const e={};Object.entries(t).forEach(([t,r])=>{o in r&&"function"==typeof r[o]&&(e[t]=r[o])}),n=Object.keys(e).every(t=>{try{return e[t](r)}catch(e){return console.error(`Error when executing callback for ${o} in ${t}`,e),!0}})}return n})(r,i,o):r},c=window.wp.element,l=(e,t)=>{if(null!==e&&!(0,c.isValidElement)(e))throw new TypeError(`The ${t} property for the payment method must be a React element or null.`)},u=(e,t=[])=>{const o=t.reduce((t,o)=>(e.hasOwnProperty(o)||t.push(o),t),[]);if(o.length>0)throw new TypeError("The payment method configuration object is missing the following properties:"+o.join(", "))},p=window.ReactJSXRuntime,d=()=>null;class m{constructor(e){m.assertValidConfig(e),this.name=e.name,this.label=e.label,this.placeOrderButtonLabel=e.placeOrderButtonLabel,this.placeOrderButton=e.placeOrderButton,this.ariaLabel=e.ariaLabel,this.content=e.content,this.savedTokenComponent=e.savedTokenComponent,this.icons=e.icons||null,this.edit=e.edit,this.paymentMethodId=e.paymentMethodId||this.name,this.supports={showSavedCards:e?.supports?.showSavedCards||e?.supports?.savePaymentInfo||!1,showSaveOption:e?.supports?.showSaveOption||!1,features:e?.supports?.features||["products"]},this.canMakePaymentFromConfig=e.canMakePayment}get canMakePayment(){return s(this.canMakePaymentFromConfig,this.supports.features,this.name)}static assertValidConfig=e=>{if(e.savedTokenComponent=e.savedTokenComponent||(0,p.jsx)(d,{}),u(e,["name","label","ariaLabel","content","edit","canMakePayment"]),"string"!=typeof e.name)throw new Error("The name property for the payment method must be a string");if(void 0!==e.icons&&!Array.isArray(e.icons)&&null!==e.icons)throw new Error("The icons property for the payment method must be an array or null.");if("string"!=typeof e.paymentMethodId&&void 0!==e.paymentMethodId)throw new Error("The paymentMethodId property for the payment method must be a string or undefined (in which case it will be the value of the name property).");if("string"!=typeof e.placeOrderButtonLabel&&void 0!==e.placeOrderButtonLabel)throw new TypeError("The placeOrderButtonLabel property for the payment method must be a string");if(e.placeOrderButton&&"function"!=typeof e.placeOrderButton)throw new TypeError("The placeOrderButton property for the payment method must be a React component (function)");if(e.placeOrderButton&&e.placeOrderButtonLabel&&console.warn(`Payment method "${e.name}" provided both placeOrderButton and placeOrderButtonLabel. Using placeOrderButton.`),(e=>{if(null!==e&&!(0,c.isValidElement)(e)&&"string"!=typeof e)throw new TypeError("The label property for the payment method must be a React element, a string, or null.")})(e.label),l(e.content,"content"),l(e.edit,"edit"),l(e.savedTokenComponent,"savedTokenComponent"),"string"!=typeof e.ariaLabel)throw new TypeError("The ariaLabel property for the payment method must be a string");if("function"!=typeof e.canMakePayment)throw new TypeError("The canMakePayment property for the payment method must be a function.");if(void 0!==e.supports?.showSavedCards&&"boolean"!=typeof e.supports?.showSavedCards)throw new TypeError("If the payment method includes the `supports.showSavedCards` property, it must be a boolean");if(void 0!==e.supports?.savePaymentInfo&&r()("Passing savePaymentInfo when registering a payment method.",{alternative:"Pass showSavedCards and showSaveOption",plugin:"woocommerce-gutenberg-products-block",link:"https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3686"}),void 0!==e.supports?.features&&!Array.isArray(e.supports?.features))throw new Error("The features property for the payment method must be an array or undefined.");if(void 0!==e.supports?.showSaveOption&&"boolean"!=typeof e.supports?.showSaveOption)throw new TypeError("If the payment method includes the `supports.showSaveOption` property, it must be a boolean")}}class y{constructor(e){const t="string"==typeof e.name?e.name.replace(/[_-]/g," "):e.name,o="string"==typeof e?.description&&e.description.length>130?e.description.slice(0,130)+"...":e.description;y.assertValidConfig(e),this.name=e.name,this.title=e.title||t,this.description=o||"",this.gatewayId=e.gatewayId||"",this.content=e.content,this.edit=e.edit,this.paymentMethodId=e.paymentMethodId||this.name,this.supports={features:e?.supports?.features||["products"],style:e?.supports?.style||[]},this.canMakePaymentFromConfig=e.canMakePayment}get canMakePayment(){return s(this.canMakePaymentFromConfig,this.supports.features,this.name)}static assertValidConfig=e=>{if(u(e,["name","content","edit"]),"string"!=typeof e.name)throw new TypeError("The name property for the express payment method must be a string");if("string"!=typeof e.paymentMethodId&&void 0!==e.paymentMethodId)throw new Error("The paymentMethodId property for the payment method must be a string or undefined (in which case it will be the value of the name property).");if(void 0!==e.supports?.features&&!Array.isArray(e.supports?.features))throw new Error("The features property for the payment method must be an array or undefined.");if(l(e.content,"content"),l(e.edit,"edit"),"function"!=typeof e.canMakePayment)throw new TypeError("The canMakePayment property for the express payment method must be a function.")}}const b="wc/store/payment",w={},f={},h=e=>{let t;"function"==typeof e?(t=e(m),r()("Passing a callback to registerPaymentMethod()",{alternative:"a config options object",plugin:"woocommerce-gutenberg-products-block",link:"https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3404"})):t=new m(e),t instanceof m&&(w[t.name]=t)},g=e=>{let t;"function"==typeof e?(t=e(y),r()("Passing a callback to registerExpressPaymentMethod()",{alternative:"a config options object",plugin:"woocommerce-gutenberg-products-block",link:"https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3404"})):t=new y(e),t instanceof y&&(f[t.name]=t)},v=(e,t)=>{a[e]?console.error(`The namespace provided to registerPaymentMethodExtensionCallbacks must be unique. Callbacks have already been registered for the ${e} namespace.`):(a[e]={},Object.entries(t).forEach(([t,o])=>{"function"==typeof o?a[e][t]=o:console.error(`All callbacks provided to registerPaymentMethodExtensionCallbacks must be functions. The callback for the ${t} payment method in the ${e} namespace was not a function.`)}))},k=e=>{delete w[e];const{__internalRemoveAvailablePaymentMethod:t}=(0,n.dispatch)(b);t(e)},P=e=>{delete f[e];const{__internalRemoveAvailableExpressPaymentMethod:t}=(0,n.dispatch)(b);t(e)},I=()=>w,S=()=>f,E={};function A(e){return{..."object"==typeof E[e]&&Object.keys(E[e]).length>0?E[e]:{},...E.any}}function T(e){return r()("getRegisteredInnerBlocks",{version:"2.8.0",alternative:"getRegisteredBlockComponents",plugin:"WooCommerce Blocks"}),A(e)}const O=(e,t,o)=>{const r=typeof e[t];if(r!==o)throw new Error(`Incorrect value for the ${t} argument when registering a block component. It was a ${r}, but must be a ${o}.`)},C=(e,t)=>{if(e[t]){if("function"==typeof e[t])return;if(e[t].$$typeof&&e[t].$$typeof===Symbol.for("react.lazy"))return}throw new Error(`Incorrect value for the ${t} argument when registering a block component. Component must be a valid React Element or Lazy callback.`)};function x(e){e.context||(e.context="any"),O(e,"context","string"),O(e,"blockName","string"),C(e,"component");const{context:t,blockName:o,component:r}=e;E[t]||(E[t]={}),E[t][o]=r}function R(e){r()("registerInnerBlock",{version:"2.8.0",alternative:"registerBlockComponent",plugin:"WooCommerce Blocks",hint:'"main" has been replaced with "context" and is now optional.'}),O(e,"main","string"),x({...e,context:e.main})}const B=window.wp.hooks;let q=function(e){return e.GRID="flex",e.STACK="list",e.CAROUSEL="carousel",e}({}),M=function(e){return e.FILL="fill",e.FIXED="fixed",e}({}),j=function(e){return e.ATTRIBUTES="attributes",e.CREATED="created",e.FEATURED="featured",e.HAND_PICKED="hand-picked",e.INHERIT="inherit",e.KEYWORD="keyword",e.ON_SALE="on-sale",e.ORDER="order",e.DEFAULT_ORDER="default-order",e.STOCK_STATUS="stock-status",e.TAXONOMY="taxonomy",e.PRICE_RANGE="price-range",e.FILTERABLE="filterable",e.PRODUCTS_PER_PAGE="products-per-page",e.MAX_PAGES_TO_SHOW="max-pages-to-show",e.OFFSET="offset",e.RELATED_BY="related-by",e}({});const L=window.wc.wcSettings,_=JSON.parse('{"UU":"woocommerce/product-collection"}');let F=function(e){return e.SINGLE="single",e.THUMBNAIL="thumbnail",e}({});const $=_.UU,D=`${$}/product-title`,H=(0,L.getSetting)("stockStatusOptions",[]),N={perPage:9,pages:0,offset:0,postType:"product",order:"asc",orderBy:"title",search:"",exclude:[],inherit:!1,taxQuery:{},isProductCollectionBlock:!0,featured:!1,woocommerceOnSale:!1,woocommerceStockStatus:(0,L.getSetting)("hideOutOfStockItems",!1)?Object.keys(function(e,t){const{[t]:o,...r}=e;return r}(H,"outofstock")):Object.keys(H),woocommerceAttributes:[],woocommerceHandPickedProducts:[],timeFrame:void 0,priceRange:void 0,filterable:!1,relatedBy:{categories:!0,tags:!0}},U={query:N,tagName:"div",displayLayout:{type:q.GRID,columns:3,shrinkColumns:!0},dimensions:{widthType:M.FILL},queryContextIncludes:["collection"],forcePageReload:!1},V=[["woocommerce/product-template",{},[["woocommerce/product-image",{imageSizing:F.THUMBNAIL,showSaleBadge:!1},[["woocommerce/product-sale-badge",{align:"right"}]]],["core/post-title",{textAlign:"center",level:2,fontSize:"medium",style:{spacing:{margin:{bottom:"0.75rem",top:"0"}},typography:{lineHeight:"1.4"}},isLink:!0,__woocommerceNamespace:D}],["woocommerce/product-price",{textAlign:"center",fontSize:"small"}],["woocommerce/product-button",{textAlign:"center",fontSize:"small"}]]],["core/query-pagination",{layout:{type:"flex",justifyContent:"center"}}],["woocommerce/product-collection-no-results"]],z=e=>{if(!(e=>"object"!=typeof e||null===e?(console.error("Invalid arguments: You must pass an object to __experimentalRegisterProductCollection."),!1):"string"!=typeof e.name||0===e.name.length?(console.error("Invalid name: name must be a non-empty string."),!1):(e.name.match(/^[a-zA-Z0-9-]+\/product-collection\/[a-zA-Z0-9-]+$/)||console.warn('To prevent conflicts with other collections, please use a unique name following the pattern: "<plugin-name>/product-collection/<collection-name>". Ensure "<plugin-name>" is your plugin name and "<collection-name>" is your collection name. Both should consist only of alphanumeric characters and hyphens (e.g., "my-plugin/product-collection/my-collection").'),"string"!=typeof e.title||0===e.title.length?(console.error("Invalid title: title must be a non-empty string."),!1):(void 0!==e.description&&"string"!=typeof e.description&&console.warn("Invalid description: description must be a string."),void 0!==e.category&&"string"!=typeof e.category&&console.warn("Invalid category: category must be a string."),void 0===e.keywords||Array.isArray(e.keywords)||console.warn("Invalid keywords: keywords must be an array of strings."),void 0!==e.icon&&"string"!=typeof e.icon&&"object"!=typeof e.icon&&console.warn("Invalid icon: icon must be a string or an object."),void 0!==e.example&&"object"!=typeof e.example&&console.warn("Invalid example: example must be an object."),void 0===e.scope||Array.isArray(e.scope)||console.warn("Invalid scope: scope must be an array of type WPBlockVariationScope."),void 0!==e.attributes&&"object"!=typeof e.attributes&&console.warn("Invalid attributes: attributes must be an object."),void 0!==e.attributes?.query&&"object"!=typeof e.attributes.query&&console.warn("Invalid query: query must be an object."),void 0!==e.attributes?.query?.offset&&"number"!=typeof e.attributes.query.offset&&console.warn("Invalid offset: offset must be a number."),void 0!==e.attributes?.query?.order&&"string"!=typeof e.attributes.query.order&&console.warn("Invalid order: order must be a string."),void 0!==e.attributes?.query?.orderBy&&"string"!=typeof e.attributes.query.orderBy&&console.warn("Invalid orderBy: orderBy must be a string."),void 0!==e.attributes?.query?.pages&&"number"!=typeof e.attributes.query.pages&&console.warn("Invalid pages: pages must be a number."),void 0!==e.attributes?.query?.perPage&&"number"!=typeof e.attributes.query.perPage&&console.warn("Invalid perPage: perPage must be a number."),void 0!==e.attributes?.query?.search&&"string"!=typeof e.attributes.query.search&&console.warn("Invalid search: search must be a string."),void 0!==e.attributes?.query?.taxQuery&&"object"!=typeof e.attributes.query.taxQuery&&console.warn("Invalid taxQuery: taxQuery must be an object."),void 0!==e.attributes?.query?.featured&&"boolean"!=typeof e.attributes.query.featured&&console.warn("Invalid featured: featured must be a boolean."),void 0!==e.attributes?.query?.timeFrame&&"object"!=typeof e.attributes.query.timeFrame&&console.warn("Invalid timeFrame: timeFrame must be an object."),void 0!==e.attributes?.query?.woocommerceOnSale&&"boolean"!=typeof e.attributes.query.woocommerceOnSale&&console.warn("Invalid woocommerceOnSale: woocommerceOnSale must be a boolean."),void 0===e.attributes?.query?.woocommerceStockStatus||Array.isArray(e.attributes.query.woocommerceStockStatus)||console.warn("Invalid woocommerceStockStatus: woocommerceStockStatus must be an array."),void 0===e.attributes?.query?.woocommerceAttributes||Array.isArray(e.attributes.query.woocommerceAttributes)||console.warn("Invalid woocommerceAttributes: woocommerceAttributes must be an array."),void 0===e.attributes?.query?.woocommerceHandPickedProducts||Array.isArray(e.attributes.query.woocommerceHandPickedProducts)||console.warn("Invalid woocommerceHandPickedProducts: woocommerceHandPickedProducts must be an array."),void 0!==e.attributes?.query?.priceRange&&"object"!=typeof e.attributes.query.priceRange&&console.warn("Invalid priceRange: priceRange must be an object."),void 0!==e.attributes?.displayLayout&&"object"!=typeof e.attributes.displayLayout&&console.warn("Invalid displayLayout: displayLayout must be an object."),void 0!==e.attributes?.dimensions&&"object"!=typeof e.attributes.dimensions&&console.warn("Invalid dimensions: dimensions must be an object."),void 0===e.attributes?.hideControls||Array.isArray(e.attributes.hideControls)||console.warn("Invalid hideControls: hideControls must be an array of strings."),void 0===e.attributes?.queryContextIncludes||Array.isArray(e.attributes.queryContextIncludes)||console.warn("Invalid queryContextIncludes: queryContextIncludes must be an array of strings."),void 0!==e.preview&&("object"==typeof e.preview&&null!==e.preview||console.warn("Invalid preview: preview must be an object."),void 0!==e.preview.setPreviewState&&"function"!=typeof e.preview.setPreviewState&&console.warn("Invalid preview: setPreviewState must be a function."),void 0!==e.preview.initialPreviewState&&("object"!=typeof e.preview.initialPreviewState&&console.warn("Invalid preview: initialPreviewState must be an object."),"boolean"!=typeof e.preview.initialPreviewState.isPreview&&console.warn("Invalid preview: preview.isPreview must be a boolean."),"string"!=typeof e.preview.initialPreviewState.previewMessage&&console.warn("Invalid preview: preview.previewMessage must be a string."))),!(void 0!==e.usesReference&&!Array.isArray(e.usesReference)&&(console.error("Invalid usesReference: usesReference must be an array of strings."),1)))))(e))return void console.error("Collection could not be registered due to invalid configuration.");const{preview:{setPreviewState:t,initialPreviewState:o}={},usesReference:r}=e,n=e.attributes?.query||{},a=[...new Set([j.INHERIT,...e.attributes?.hideControls||[]])],i={name:e.name,title:e.title,description:e.description,category:e.category,keywords:e.keywords,icon:e.icon,example:e.example,scope:e.scope,attributes:{...e.attributes,query:{...N,...void 0!==n.offset&&{offset:n.offset},...void 0!==n.order&&{order:n.order},...void 0!==n.orderBy&&{orderBy:n.orderBy},...void 0!==n.pages&&{pages:n.pages},...void 0!==n.perPage&&{perPage:n.perPage},...void 0!==n.search&&{search:n.search},...void 0!==n.taxQuery&&{taxQuery:n.taxQuery},...void 0!==n.featured&&{featured:n.featured},...void 0!==n.timeFrame&&{timeFrame:n.timeFrame},...void 0!==n.woocommerceOnSale&&{woocommerceOnSale:n.woocommerceOnSale},...void 0!==n.woocommerceStockStatus&&{woocommerceStockStatus:n.woocommerceStockStatus},...void 0!==n.woocommerceAttributes&&{woocommerceAttributes:n.woocommerceAttributes},...void 0!==n.woocommerceHandPickedProducts&&{woocommerceHandPickedProducts:n.woocommerceHandPickedProducts},...void 0!==n.priceRange&&{priceRange:n.priceRange}},hideControls:a,collection:e.name,inherit:!1},innerBlocks:e.innerBlocks||V,isActive:(e,t)=>e.collection===t.collection,isDefault:!1};if(t||o||Array.isArray(r)&&r.length>0){const e=e=>n=>n.attributes.collection!==i.name?(0,p.jsx)(e,{...n}):(0,p.jsx)(e,{...n,...o||t?{preview:{setPreviewState:t,initialPreviewState:o}}:{},usesReference:r});(0,B.addFilter)("editor.BlockEdit",i.name,e)}wp?.blocks?.registerBlockVariation&&wp.blocks.registerBlockVariation($,{...i,attributes:{...U,...i.attributes,query:{...N,...i.attributes?.query},displayLayout:{...U.displayLayout,...i.attributes?.displayLayout}}})};(this.wc=this.wc||{}).wcBlocksRegistry=t})();
// source --> https://mfrash.com/wp-includes/js/dist/html-entities.min.js?ver=8c6fa5b869dfeadc4af2 
"use strict";var wp;(wp||={}).htmlEntities=(()=>{var r=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var u=(e,t)=>{for(var i in t)r(e,i,{get:t[i],enumerable:!0})},f=(e,t,i,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of d(t))!m.call(e,o)&&o!==i&&r(e,o,{get:()=>t[o],enumerable:!(c=a(t,o))||c.enumerable});return e};var x=e=>f(r({},"__esModule",{value:!0}),e);var T={};u(T,{decodeEntities:()=>p});var n;function p(e){if(typeof e!="string"||e.indexOf("&")===-1)return e;n===void 0&&(document.implementation&&document.implementation.createHTMLDocument?n=document.implementation.createHTMLDocument("").createElement("textarea"):n=document.createElement("textarea")),n.innerHTML=e;let t=n.textContent??"";return n.innerHTML="",t}return x(T);})();
// source --> https://mfrash.com/wp-content/plugins/tabby-checkout/assets/blocks/tabby-installments/index.js?ver=5.11.1 
/**
 * External dependencies
 */
const registerPaymentMethod = window.wc.wcBlocksRegistry.registerPaymentMethod;
const getPaymentMethodData = window.wc.wcSettings.getPaymentMethodData;

const settings = getPaymentMethodData( 'tabby_installments', {} );
const defaultLabel = 'Pay in 4. No interest, no fees.';
const title = settings?.title || '';


/**
 * Icon component
 */

const TabbyIcon = () => {
    return React.createElement('img', {
        src: settings?.icon_src,
        style: {marginRight:'10px'},
        alt: title
    }, null);
}

const Label = () => {
    return [window.wp.element.createElement(TabbyIcon), React.createElement('span', null, title)];
}

const InitTabbyCard = (className, classParams) => {
    if (eval('typeof ' + className) == 'function') {
        eval('new ' + className + '(' + classParams + ');');
        return true;
    }
    return false;
};

const TabbyPromotionCard = () => {
    React.useEffect(() => {
        // init Tabby Promo Card
        if (!InitTabbyCard(settings?.config?.jsClass, settings?.config?.jsConf)) {
            let timerId = setInterval(function () {
                if (InitTabbyCard(settings?.config?.jsClass, settings?.config?.jsConf)) {
                    clearInterval(timerId);
                }
            }, 300);
        }
    });
    return React.createElement('div', {id: settings?.config?.id}, '');    
}

const TabbyInstallmentsMethodName = 'tabby_installments';
/**
 * Content component
 */
const Content = () => {
    switch (settings?.config?.class) {
        case 'empty':
            return null;
        case 'tabbyDesc':
            return React.createElement('span', null, settings?.config?.html || '');
        default: 
            return window.wp.element.createElement(TabbyPromotionCard);
    }
};

/**
 * Tabby installments payment method config object.
 */

const tabbyInstallmentsPaymentMethod = {
    name: TabbyInstallmentsMethodName,
    label: Object( window.wp.element.createElement ) (Label, null),
    content: Object( window.wp.element.createElement ) (Content, null),
    edit: Object( window.wp.element.createElement ) (Content, null),
    canMakePayment: (props) => {
        return true;
    },
    ariaLabel: title,
    placeOrderButtonLabel: window.wp.i18n.__(
        'Proceed to Tabby',
        'tabby-checkout'
    ),
    supports: {
        features: settings?.supports ?? []
    }
};

registerPaymentMethod( tabbyInstallmentsPaymentMethod );
// source --> https://mfrash.com/wp-content/uploads/wpcode/assets/66e8217a2c8c491a60eeed9f5a167db3.js?ver=1776102692 
jQuery(document).ready(function($){
    // $("#billing_city option:first").remove();
    // $(document).on('change', '#billing_state', function(){
    //     var thisVal = $(this).val();
    //     var thisText = $( "#billing_state option:selected" ).text();
        
    //     console.log(thisVal, thisText);
    //     // Search on 
    //     /*
    //     billing_state
    //     billing_city
    //     */
    //     $('#billing_city').val(thisText);
    //     $("#billing_city option:first").remove();
    // });
    
    $(document).on('change', "#shipping_state",function(){
        $("#shipping_city").val($(this).val());
    });
    $(document).on('change', "#billing_state",function(){
        $("#billing_city").val($(this).val());
    });
    
});
// source --> https://mfrash.com/wp-content/uploads/wpcode/assets/213a33e8cc9cae6743c2c50386bb2826.js?ver=1776102692 
document.addEventListener("DOMContentLoaded", function () {
  const products = document.querySelectorAll('.mfrash-slider-wrapper');

  products.forEach(function (wrapper) {
    const productId = wrapper.dataset.productId;
    const viewsKey = 'mfrash_views_' + productId;
    const cartKey = 'mfrash_cart_' + productId;

    // عدد المشاهدات
    let views = parseInt(localStorage.getItem(viewsKey) || '0') + 1;
    localStorage.setItem(viewsKey, views);
    const viewsEl = wrapper.querySelector('.mfrash-views-count');
    if (viewsEl) viewsEl.textContent = views;

    // عدد إضافات السلة (عند الضغط على الزر)
    let cartCount = parseInt(localStorage.getItem(cartKey) || '0');
    const cartEls = wrapper.querySelectorAll('.mfrash-cart-count');
    cartEls.forEach(el => el.textContent = cartCount);

    // استهداف زر "اختر التصميم" أو أي زر بداخل المنتج
    const productBox = wrapper.closest('.product');
    if (productBox) {
      const designBtn = productBox.querySelector('a.button, a.choose-button, .choose-style');
      if (designBtn) {
        designBtn.addEventListener('click', function () {
          cartCount++;
          localStorage.setItem(cartKey, cartCount);
          cartEls.forEach(el => el.textContent = cartCount);
        });
      }
    }
  });
});
// source --> https://mfrash.com/wp-content/themes/porto/js/advanced-button.min.js?ver=7.9.0 
!function(o,r){r(".porto-btn[data-hover]").on("mouseenter",(function(){var o=r(this).data("hover"),s=r(this).data("border-hover");o&&(r(this).data("originalColor",r(this).css("color")),r(this).css("color",o)),s&&(r(this).data("originalBorderColor",r(this).css("border-color")),r(this).css("border-color",s))})).on("mouseleave",(function(){var o=r(this).data("originalColor"),s=r(this).data("originalBorderColor");o&&r(this).css("color",o),s&&r(this).css("border-color",s)}))}(window.theme,jQuery);
// source --> https://mfrash.com/wp-content/plugins/wc-customer-photo-reviews/assets/wcpr.js?ver=2.4.32 
(function () {
	'use strict';

	function qs(selector, root) {
		return (root || document).querySelector(selector);
	}

	function qsa(selector, root) {
		return Array.prototype.slice.call((root || document).querySelectorAll(selector));
	}

	function postForm(formData) {
		return fetch(wcprConfig.ajaxUrl, {
			method: 'POST',
			credentials: 'same-origin',
			body: formData
		}).then(function (response) {
			return response.json();
		});
	}

	function getFormNonce(form) {
		var field = qs('input[name="nonce"]', form);
		return field && field.value ? field.value : wcprConfig.nonce;
	}

	function setMessage(element, message, type) {
		if (!element) {
			return;
		}
		element.textContent = message || '';
		element.classList.remove('is-error', 'is-success');
		if (type) {
			element.classList.add('is-' + type);
		}
	}

	function handlePreview(input) {
		var container = input.closest('.wcpr-form') || input.closest('.wcpr-order-product-review') || input.closest('.wcpr-upload');
		var preview = container ? qs('.wcpr-preview', container) : null;
		if (!preview) {
			return;
		}

		preview.innerHTML = '';
		Array.prototype.slice.call(input.files || []).forEach(function (file) {
			if (!file.type || file.type.indexOf('image/') !== 0) {
				return;
			}

			var img = document.createElement('img');
			img.alt = file.name;
			img.src = URL.createObjectURL(file);
			img.onload = function () {
				URL.revokeObjectURL(img.src);
			};
			preview.appendChild(img);
		});
	}

	function refreshReviews(section, html) {
		var wrap = qs('.wcpr-reviews-wrap', section);
		if (wrap && html) {
			wrap.innerHTML = html;
		}
	}

	function openModal(modal) {
		if (!modal) {
			return;
		}
		modal.hidden = false;
		document.documentElement.classList.add('wcpr-modal-open');
		var firstField = qs('input[name="rating"]', modal) || qs('textarea, input, button', modal);
		if (firstField) {
			setTimeout(function () {
				firstField.focus({ preventScroll: true });
			}, 30);
		}
	}

	function closeModal(modal) {
		if (!modal) {
			return;
		}
		modal.hidden = true;
		document.documentElement.classList.remove('wcpr-modal-open');
	}

	function shouldScrollToReviews() {
		if (window.location.hash === '#wcpr-reviews') {
			return true;
		}

		try {
			return new URLSearchParams(window.location.search).get('wcpr_after_login') === '1';
		} catch (error) {
			return window.location.search.indexOf('wcpr_after_login=1') !== -1;
		}
	}

	function scrollToReviewsAfterLogin() {
		if (!shouldScrollToReviews()) {
			return;
		}

		var section = document.getElementById('wcpr-reviews') || qs('.wcpr[data-product-id]');
		if (!section) {
			return;
		}

		setTimeout(function () {
			section.scrollIntoView({ behavior: 'smooth', block: 'start' });

			if (!window.history || !window.history.replaceState || window.location.search.indexOf('wcpr_after_login=1') === -1) {
				return;
			}

			try {
				var url = new URL(window.location.href);
				url.searchParams.delete('wcpr_after_login');
				url.hash = 'wcpr-reviews';
				window.history.replaceState(null, '', url.pathname + url.search + url.hash);
			} catch (error) {
				// Keep the original URL when older browsers cannot parse it.
			}
		}, 250);
	}

	function refreshReviewFormsForCache() {
		qsa('.wcpr-form-card[data-product-id]').forEach(function (card) {
			var productId = card.getAttribute('data-product-id');
			if (!productId || card.getAttribute('data-wcpr-refreshing') === '1') {
				return;
			}

			var formData = new FormData();
			formData.append('action', 'wcpr_refresh_form');
			formData.append('product_id', productId);
			card.setAttribute('data-wcpr-refreshing', '1');

			postForm(formData).then(function (json) {
				if (!json || !json.success || !json.data || !json.data.html) {
					return;
				}

				if (json.data.nonce) {
					wcprConfig.nonce = json.data.nonce;
				}

				var wrapper = document.createElement('div');
				wrapper.innerHTML = json.data.html;
				var freshCard = qs('.wcpr-form-card', wrapper);
				if (freshCard) {
					card.replaceWith(freshCard);
				}
			}).finally(function () {
				card.removeAttribute('data-wcpr-refreshing');
			});
		});
	}

	function handleSubmit(form) {
		var section = form.closest('.wcpr');
		var message = qs('.wcpr-message', form);
		var button = qs('.wcpr-submit', form);
		var rating = qs('input[name="rating"]:checked', form);

		if (!rating) {
			setMessage(message, wcprConfig.i18n.choose_rating, 'error');
			return;
		}

		var formData = new FormData(form);
		formData.set('nonce', getFormNonce(form));
		button.disabled = true;
		button.textContent = wcprConfig.i18n.sending;
		setMessage(message, '', null);

		postForm(formData).then(function (json) {
			if (json && json.success) {
				var modal = form.closest('.wcpr-modal');
				form.reset();
				var preview = qs('.wcpr-preview', form);
				if (preview) {
					preview.innerHTML = '';
				}
				setMessage(message, json.data.message, 'success');
				refreshReviews(section, json.data.html);
				if (modal) {
					setTimeout(function () {
						closeModal(modal);
						setMessage(message, '', null);
					}, 900);
				}
			} else {
				setMessage(message, json && json.data ? json.data.message : 'حدث خطأ', 'error');
			}
		}).catch(function () {
			setMessage(message, 'حدث خطأ', 'error');
		}).finally(function () {
			button.disabled = false;
			button.textContent = wcprConfig.i18n.submit;
		});
	}

	function handleHelpful(button) {
		if (!button || button.disabled || button.getAttribute('data-wcpr-busy') === '1') {
			return;
		}

		var formData = new FormData();
		var count = qs('.wcpr-helpful-count', button);

		formData.append('action', 'wcpr_helpful');
		formData.append('nonce', wcprConfig.nonce);
		formData.append('comment_id', button.getAttribute('data-comment-id'));
		button.setAttribute('data-wcpr-busy', '1');
		button.disabled = true;

		postForm(formData).then(function (json) {
			if (json && json.success && count) {
				count.textContent = json.data.count;
				button.classList.add('is-voted');
				button.setAttribute('aria-label', json.data.message || button.textContent);
				button.setAttribute('title', json.data.message || button.textContent);
			} else if (json && json.data && json.data.message) {
				button.classList.add('is-voted');
				button.setAttribute('aria-label', json.data.message);
				button.setAttribute('title', json.data.message);
			}
		}).finally(function () {
			button.disabled = false;
			button.removeAttribute('data-wcpr-busy');
		});
	}

	function handleHelpfulTap(event) {
		var helpful = event.target.closest('.wcpr-helpful');
		if (!helpful) {
			return false;
		}

		event.preventDefault();

		if (event.type === 'click' && helpful.getAttribute('data-wcpr-touch-handled') === '1') {
			return true;
		}

		if (event.type === 'touchend') {
			helpful.setAttribute('data-wcpr-touch-handled', '1');
			window.setTimeout(function () {
				helpful.removeAttribute('data-wcpr-touch-handled');
			}, 700);
		}

		handleHelpful(helpful);
		return true;
	}

	function handleLoadMore(button) {
		var section = button.closest('.wcpr');
		var list = qs('.wcpr-list', section);
		var formData = new FormData();
		var isAllReviews = button.getAttribute('data-scope') === 'all';

		formData.append('action', isAllReviews ? 'wcpr_load_all_reviews' : 'wcpr_load_reviews');
		formData.append('nonce', wcprConfig.nonce);
		formData.append('page', button.getAttribute('data-next-page'));
		if (isAllReviews) {
			formData.append('per_page', button.getAttribute('data-per-page') || '20');
			formData.append('limit', button.getAttribute('data-limit') || '0');
			formData.append('rating', button.getAttribute('data-rating') || '0');
			formData.append('photos', button.getAttribute('data-photos') || '0');
			formData.append('comments', button.getAttribute('data-comments') || '0');
			formData.append('review_order', button.getAttribute('data-review-order') || 'latest');
		} else {
			formData.append('product_id', section.getAttribute('data-product-id'));
			formData.append('rating', button.getAttribute('data-rating') || '0');
			formData.append('photos', button.getAttribute('data-photos') || '0');
			formData.append('comments', button.getAttribute('data-comments') || '0');
			formData.append('review_order', button.getAttribute('data-review-order') || 'rating_high');
		}
		button.disabled = true;
		button.textContent = wcprConfig.i18n.loading;

		postForm(formData).then(function (json) {
			if (!json || !json.success || !list) {
				return;
			}

			var holder = document.createElement('div');
			holder.innerHTML = json.data.html;
			var nextList = qs('.wcpr-list', holder);
			if (nextList) {
				qsa('.wcpr-review', nextList).forEach(function (review) {
					list.appendChild(review);
				});
			}

			var nextButton = qs('.wcpr-load-more', holder);
			if (nextButton) {
				button.setAttribute('data-next-page', nextButton.getAttribute('data-next-page'));
				if (nextButton.getAttribute('data-per-page')) {
					button.setAttribute('data-per-page', nextButton.getAttribute('data-per-page'));
				}
				if (nextButton.getAttribute('data-limit')) {
					button.setAttribute('data-limit', nextButton.getAttribute('data-limit'));
				}
				button.setAttribute('data-rating', nextButton.getAttribute('data-rating') || '0');
				button.setAttribute('data-photos', nextButton.getAttribute('data-photos') || '0');
				button.setAttribute('data-comments', nextButton.getAttribute('data-comments') || '0');
				button.setAttribute('data-review-order', nextButton.getAttribute('data-review-order') || (isAllReviews ? 'latest' : 'rating_high'));
				button.disabled = false;
				button.textContent = nextButton.textContent;
			} else {
				button.remove();
			}
		}).catch(function () {
			button.disabled = false;
		});
	}

	function handleAllReviewsFilter(form) {
		var section = form.closest('.wcpr-all-reviews');
		var wrap = qs('.wcpr-reviews-wrap', section);
		var formData = new FormData();
		var button = qs('.wcpr-load-more', wrap);

		formData.append('action', 'wcpr_load_all_reviews');
		formData.append('nonce', wcprConfig.nonce);
		formData.append('page', '1');
		formData.append('per_page', button ? button.getAttribute('data-per-page') || '20' : form.getAttribute('data-per-page') || '20');
		formData.append('limit', button ? button.getAttribute('data-limit') || '0' : form.getAttribute('data-limit') || '0');
		formData.append('rating', qs('[name="rating"]', form).value || '0');
		formData.append('photos', qs('[name="photos"]', form).value || '0');
		formData.append('comments', qs('[name="comments"]', form) ? qs('[name="comments"]', form).value || '0' : '0');
		formData.append('review_order', qs('[name="order"]', form).value || 'latest');

		form.setAttribute('data-loading', '1');
		postForm(formData).then(function (json) {
			if (json && json.success && wrap) {
				wrap.innerHTML = json.data.html;
			}
		}).finally(function () {
			form.removeAttribute('data-loading');
		});
	}

	function handleProductReviewsFilter(form) {
		var section = form.closest('.wcpr');
		var wrap = qs('.wcpr-reviews-wrap', section);
		var formData = new FormData();

		if (!section || !wrap) {
			return;
		}

		formData.append('action', 'wcpr_load_reviews');
		formData.append('nonce', wcprConfig.nonce);
		formData.append('page', '1');
		formData.append('product_id', section.getAttribute('data-product-id'));
		formData.append('rating', qs('[name="rating"]', form).value || '0');
		var orderValue = qs('[name="order"]', form).value || 'rating_high';
		var photosField = qs('[name="photos"]', form);
		var commentsField = qs('[name="comments"]', form);
		formData.append('photos', orderValue === 'photos' ? '1' : (photosField ? photosField.value || '0' : '0'));
		formData.append('comments', orderValue === 'comments' ? '1' : (commentsField ? commentsField.value || '0' : '0'));
		formData.append('review_order', orderValue);

		form.setAttribute('data-loading', '1');
		postForm(formData).then(function (json) {
			if (json && json.success) {
				wrap.innerHTML = json.data.html;
			}
		}).finally(function () {
			form.removeAttribute('data-loading');
		});
	}

	function handlePhotoSliderNav(button) {
		var slider = button.closest('.wcpr-photo-slider');
		var track = slider ? qs('.wcpr-photo-slider-track', slider) : null;
		if (!track) {
			return;
		}

		var amount = Math.max(180, Math.round(track.clientWidth * 0.75));
		var direction = button.getAttribute('data-direction') === 'prev' ? -1 : 1;
		track.scrollBy({ left: amount * direction, behavior: 'smooth' });
	}

	function ensureLightbox() {
		var box = qs('.wcpr-lightbox');
		if (box) {
			return box;
		}

		box = document.createElement('div');
		box.className = 'wcpr-lightbox';
		box.hidden = true;
		box.innerHTML = '<button type="button" aria-label="إغلاق">×</button><img alt="">';
		document.body.appendChild(box);
		box.addEventListener('click', function (event) {
			if (event.target === box || event.target.tagName === 'BUTTON') {
				box.hidden = true;
			}
		});
		document.addEventListener('keydown', function (event) {
			if (event.key === 'Escape') {
				box.hidden = true;
				qsa('.wcpr-modal:not([hidden])').forEach(closeModal);
			}
		});
		return box;
	}

	function initReviewSliders() {
		var reduceMotion = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
		if (reduceMotion) {
			return;
		}

		qsa('.wcpr-slider-track').forEach(function (track) {
			if (track.getAttribute('data-wcpr-ready') === '1') {
				return;
			}

			var originalCount = parseInt(track.getAttribute('data-wcpr-count'), 10) || 0;
			var cards = qsa('.wcpr-slider-card', track);
			var viewport = track.closest('.wcpr-slider-viewport');
			var index = 0;
			var timer = null;
			var step = 0;

			if (!viewport || originalCount < 2 || cards.length < 2) {
				return;
			}

			track.setAttribute('data-wcpr-ready', '1');

			function getInterval() {
				var isMobile = window.matchMedia && window.matchMedia('(max-width: 720px)').matches;
				var totalSeconds = parseInt(track.getAttribute(isMobile ? 'data-wcpr-mobile-speed' : 'data-wcpr-speed'), 10) || (isMobile ? 70 : 42);
				return Math.max(isMobile ? 4200 : 3200, Math.round((totalSeconds * 1000) / originalCount));
			}

			function measureStep() {
				var first = cards[0];
				var styles = window.getComputedStyle(track);
				var gap = parseFloat(styles.columnGap || styles.gap || '0') || 0;
				step = first.getBoundingClientRect().width + gap;
			}

			function applyPosition(animate) {
				track.style.transition = animate ? 'transform 0.62s ease' : 'none';
				track.style.transform = 'translateX(' + (index * step) + 'px)';
			}

			function moveNext() {
				measureStep();
				index += 1;
				applyPosition(true);

				if (index >= originalCount) {
					window.setTimeout(function () {
						index = 0;
						applyPosition(false);
					}, 680);
				}
			}

			function stop() {
				if (timer) {
					window.clearInterval(timer);
					timer = null;
				}
			}

			function start() {
				stop();
				timer = window.setInterval(moveNext, getInterval());
			}

			measureStep();
			applyPosition(false);
			start();

			viewport.addEventListener('mouseenter', stop);
			viewport.addEventListener('mouseleave', start);
			viewport.addEventListener('focusin', stop);
			viewport.addEventListener('focusout', start);
			window.addEventListener('resize', function () {
				measureStep();
				applyPosition(false);
				start();
			});
			document.addEventListener('visibilitychange', function () {
				if (document.hidden) {
					stop();
				} else {
					start();
				}
			});
		});
	}

	function initOrderReviewForm() {
		var ratingLabels = {
			1: 'ضعيف',
			2: 'مقبول',
			3: 'جيد',
			4: 'جيد جدًا',
			5: 'ممتاز'
		};

		qsa('.wcpr-order-comment textarea').forEach(function (textarea) {
			var counter = qs('.wcpr-order-count', textarea.closest('.wcpr-order-comment'));
			var max = parseInt(textarea.getAttribute('maxlength'), 10) || 500;

			function updateCounter() {
				if (counter) {
					counter.textContent = textarea.value.length + '/' + max;
				}
			}

			textarea.addEventListener('input', updateCounter);
			updateCounter();
		});

		qsa('.wcpr-order-rating-row input[type="radio"]').forEach(function (input) {
			input.addEventListener('change', function () {
				var row = input.closest('.wcpr-order-rating-row');
				var text = qs('.wcpr-order-rating-text', row);
				if (text) {
					text.textContent = ratingLabels[input.value] || '';
				}
			});
		});
	}

	function copyCouponCode(button) {
		var text = button.getAttribute('data-wcpr-copy') || '';
		var copiedLabel = button.getAttribute('data-copied') || 'تم النسخ';
		var originalLabel = button.getAttribute('data-label') || button.textContent;

		function markCopied() {
			button.textContent = copiedLabel;
			button.classList.add('is-copied');
			window.setTimeout(function () {
				button.textContent = originalLabel;
				button.classList.remove('is-copied');
			}, 1800);
		}

		if (navigator.clipboard && navigator.clipboard.writeText) {
			navigator.clipboard.writeText(text).then(markCopied).catch(function () {
				copyCouponCodeFallback(text, markCopied);
			});
			return;
		}

		copyCouponCodeFallback(text, markCopied);
	}

	function copyCouponCodeFallback(text, done) {
		var textarea = document.createElement('textarea');
		textarea.value = text;
		textarea.setAttribute('readonly', 'readonly');
		textarea.style.position = 'fixed';
		textarea.style.top = '-1000px';
		document.body.appendChild(textarea);
		textarea.select();

		try {
			document.execCommand('copy');
			done();
		} catch (error) {
			// Keep the code visible if browser copy permissions are blocked.
		}

		document.body.removeChild(textarea);
	}

	function applyAutomatedDiscountDisplay() {
		var discount = wcprConfig && wcprConfig.automatedDiscount ? wcprConfig.automatedDiscount : null;
		if (!discount || !discount.priceHtml) {
			return;
		}

		var applyCount = 0;
		var customPriceWrap = document.getElementById('mfrash-price-wrap');
		var isCurrentDiscount = isAutomatedDiscountCurrentSelection(discount);
		var selectors = [
			'.summary .price',
			'.entry-summary .price',
			'.product .summary p.price',
			'.single-product .price',
			'.woocommerce-variation-price .price',
			'[class*="price"]',
			'[class*="Price"]'
		];
		var nodes = [];

		selectors.forEach(function (selector) {
			qsa(selector).forEach(function (node) {
				if (nodes.indexOf(node) === -1) {
					nodes.push(node);
				}
			});
		});

		if (!customPriceWrap) {
			nodes.forEach(function (node) {
				if (node.closest('.wcpr') || node.closest('del') || node.closest('.woocommerce-mini-cart')) {
					return;
				}
				if (node.innerHTML !== discount.priceHtml) {
					node.innerHTML = discount.priceHtml;
				}
				node.setAttribute('data-mfrash-gad-applied', '1');
				applyCount += 1;
			});
		}

		if (!customPriceWrap && !applyCount) {
			qsa('.summary, .entry-summary, form.cart, .product').some(function (scope) {
				var amounts = qsa('.amount, bdi', scope);
				if (!amounts.length) {
					return false;
				}

				if (amounts[0].textContent !== (discount.priceText || '')) {
					amounts[0].textContent = discount.priceText || '';
				}
				amounts[0].setAttribute('data-mfrash-gad-applied', '1');
				return true;
			});
		}

		applyAutomatedDiscountNotice(discount);

		if (document.body.getAttribute('data-mfrash-gad-listener') !== '1') {
			document.body.setAttribute('data-mfrash-gad-listener', '1');
			document.body.addEventListener('found_variation', function (event) {
				if (!event.detail || !event.detail.variation_id || parseInt(event.detail.variation_id, 10) !== parseInt(discount.productId, 10)) {
					return;
				}

				window.setTimeout(applyAutomatedDiscountDisplay, 20);
				window.setTimeout(applyAutomatedDiscountDisplay, 250);
				window.setTimeout(function () {
					applyAutomatedDiscountInlineNote(document.getElementById('mfrash-price-wrap'), isAutomatedDiscountCurrentSelection(discount));
				}, 450);
			});
		}

		if (!document.body.getAttribute('data-mfrash-gad-observer')) {
			document.body.setAttribute('data-mfrash-gad-observer', '1');
			var target = customPriceWrap ? (qs('form.variations_form') || qs('.summary') || qs('.entry-summary')) : (qs('.summary') || qs('.entry-summary') || qs('form.cart'));
			if (target && window.MutationObserver) {
				var observer = new MutationObserver(function () {
					window.clearTimeout(target._mfrashGadTimer);
					target._mfrashGadTimer = window.setTimeout(applyAutomatedDiscountDisplay, 80);
				});
				observer.observe(target, { childList: true, subtree: true, characterData: true });
			}
		}

		if (window.jQuery && document.body.getAttribute('data-mfrash-gad-jquery') !== '1') {
			document.body.setAttribute('data-mfrash-gad-jquery', '1');
			window.jQuery(document.body).on('found_variation show_variation reset_data hide_variation', function () {
				var refreshInlineNote = function () {
					applyAutomatedDiscountInlineNote(document.getElementById('mfrash-price-wrap'), isAutomatedDiscountCurrentSelection(discount));
				};

				refreshInlineNote();
				window.setTimeout(refreshInlineNote, 60);
				window.setTimeout(refreshInlineNote, 220);
			});
		}
	}

	function applyAutomatedDiscountNotice(discount) {
		var customPriceWrap = document.getElementById('mfrash-price-wrap');
		if (customPriceWrap) {
			applyAutomatedDiscountInlineNote(customPriceWrap, isAutomatedDiscountCurrentSelection(discount));
		}
	}

	function isAutomatedDiscountCurrentSelection(discount) {
		if (!discount || !discount.parentId || !discount.productId) {
			return true;
		}

		var visiblePrice = qs('#mfrash-price-wrap #mfrash-final-price');
		var visibleAmount = visiblePrice ? parseLocalizedNumber(visiblePrice.getAttribute('data-price') || visiblePrice.textContent) : 0;
		if (visibleAmount > 0 && Math.abs(visibleAmount - parseFloat(discount.price || 0)) < 0.02) {
			return true;
		}

		var variationInput = qs('form.variations_form input.variation_id');
		var variationId = variationInput && variationInput.value ? parseInt(variationInput.value, 10) : 0;
		return variationId > 0 && variationId === parseInt(discount.productId, 10);
	}

	function parseLocalizedNumber(value) {
		value = String(value || '').replace(/[^\d.,]/g, '');
		if (!value) {
			return 0;
		}

		if (value.indexOf(',') !== -1 && value.indexOf('.') !== -1) {
			value = value.replace(/,/g, '');
		} else if (value.indexOf(',') !== -1) {
			value = value.replace(',', '.');
		}

		var number = parseFloat(value);
		return Number.isFinite(number) ? number : 0;
	}

	function applyAutomatedDiscountInlineNote(priceWrap, isActive) {
		if (!priceWrap) {
			return;
		}

		var existing = qs('.mfrash-gad-inline-note-wrap', priceWrap);
		var text = getAutomatedDiscountBadgeText();
		if (existing) {
			existing.remove();
		}

		if (!isActive || !text) {
			priceWrap.classList.remove('mfrash-gad-active-wrap');
			priceWrap.style.removeProperty('--mfrash-gad-badge-text');
			return;
		}

		priceWrap.style.setProperty('--mfrash-gad-badge-text', JSON.stringify(text));
		priceWrap.classList.add('mfrash-gad-active-wrap');
	}

	function getAutomatedDiscountBadgeText() {
		if (wcprConfig && typeof wcprConfig.automatedDiscountBadgeText === 'string') {
			return wcprConfig.automatedDiscountBadgeText.trim();
		}

		var discountText = wcprConfig && wcprConfig.automatedDiscount && typeof wcprConfig.automatedDiscount.badgeText === 'string' ? wcprConfig.automatedDiscount.badgeText.trim() : '';
		var fallbackText = wcprConfig && wcprConfig.i18n && typeof wcprConfig.i18n.discount_badge === 'string' ? wcprConfig.i18n.discount_badge.trim() : '';
		return discountText || fallbackText || 'عرض خاص لفترة محدودة';
	}

	document.addEventListener('keydown', function (event) {
		if (event.key === 'Escape') {
			qsa('.wcpr-modal:not([hidden])').forEach(closeModal);
		}
	});

	if (document.readyState === 'loading') {
		document.addEventListener('DOMContentLoaded', function () {
			scrollToReviewsAfterLogin();
			refreshReviewFormsForCache();
			applyAutomatedDiscountDisplay();
			initReviewSliders();
			initOrderReviewForm();
		});
	} else {
		scrollToReviewsAfterLogin();
		refreshReviewFormsForCache();
		applyAutomatedDiscountDisplay();
		initReviewSliders();
		initOrderReviewForm();
	}

	document.addEventListener('change', function (event) {
		if (event.target.matches('.wcpr-upload input[type="file"]')) {
			handlePreview(event.target);
		}

		if (event.target.closest('[data-wcpr-all-filters]')) {
			handleAllReviewsFilter(event.target.closest('[data-wcpr-all-filters]'));
		}

		if (event.target.closest('[data-wcpr-product-filters]')) {
			handleProductReviewsFilter(event.target.closest('[data-wcpr-product-filters]'));
		}
	});

	document.addEventListener('submit', function (event) {
		if (event.target.matches('.wcpr-form')) {
			event.preventDefault();
			handleSubmit(event.target);
		}

		if (event.target.matches('[data-wcpr-product-filters], [data-wcpr-all-filters]')) {
			event.preventDefault();
		}
	});

	document.addEventListener('click', function (event) {
		var loadMore = event.target.closest('.wcpr-load-more');
		var imageButton = event.target.closest('.wcpr-image-button');
		var openButton = event.target.closest('.wcpr-open-modal');
		var closeButton = event.target.closest('[data-wcpr-close]');
		var copyButton = event.target.closest('.wcpr-copy-coupon');
		var photoNav = event.target.closest('.wcpr-photo-nav');

		if (handleHelpfulTap(event)) {
			return;
		}

		if (loadMore) {
			handleLoadMore(loadMore);
		}

		if (photoNav) {
			handlePhotoSliderNav(photoNav);
		}

		if (imageButton) {
			var box = ensureLightbox();
			var img = qs('img', box);
			img.src = imageButton.getAttribute('data-full');
			box.hidden = false;
		}

		if (openButton) {
			openModal(qs('.wcpr-modal', openButton.closest('.wcpr-form-card')));
		}

		if (closeButton) {
			closeModal(closeButton.closest('.wcpr-modal'));
		}

		if (copyButton) {
			event.preventDefault();
			copyCouponCode(copyButton);
		}
	});

	document.addEventListener('touchend', function (event) {
		handleHelpfulTap(event);
	}, { passive: false });
}());
// source --> https://mfrash.com/wp-content/themes/porto/js/sidebar-menu.min.js?ver=7.9.0 
(function(e,i){"use strict";e=e||{},i.extend(e,{SidebarMenu:{defaults:{menu:i(".sidebar-menu:not(.side-menu-accordion)"),toggle:i(".widget_sidebar_menu .widget-title .toggle"),menu_toggle:i("#main-toggle-menu .menu-title")},rtl:e.rtl,initialize:function(e,t,s){return this.$menu&&this.$menu.length&&e&&e.length?(this.$menu=i.uniqueSort(i.merge(this.$menu,e)),this.build(),this):(this.$menu=e||this.defaults.menu,this.$menu.length?(this.$toggle=t||this.defaults.toggle,this.$menu_toggle=s||this.defaults.menu_toggle,this.events(),this):this)},isRightSidebar:function(e){var t=!1;t=this.rtl?!(i("#main").hasClass("column2-right-sidebar")||i("#main").hasClass("column2-wide-right-sidebar")):i("#main").hasClass("column2-right-sidebar")||i("#main").hasClass("column2-wide-right-sidebar"),e.closest("#main-toggle-menu").length&&(t=!!this.rtl);var s=e.closest(".header-wrapper");return s.length&&s.hasClass("header-side-nav")&&(t=!!this.rtl,i(".page-wrapper").hasClass("side-nav-right")&&(t=!this.rtl)),t},popupWidth:function(){var t=window.innerWidth,s=e.bodyWidth-2*e.grid_gutter_width;return i("body").hasClass("wide")||(t>=1140+e.grid_gutter_width&&t<=e.container_width+2*e.grid_gutter_width-1&&e.container_width>=1360?s=1140-e.grid_gutter_width:t>=e.container_width+e.grid_gutter_width-1?s=e.container_width-e.grid_gutter_width:t>=992?s=960-e.grid_gutter_width:t>=768&&(s=720-e.grid_gutter_width)),s},build:function(t){var s=this;if(t||(t=s.$menu),t.length){t.find(".menu-item-has-children").each((function(){var e=i(this);e.find(">.popup").length>0&&0==e.find(">.popup>.inner>.sub-menu > li:not(.hidden-item)").length&&e.addClass("hidden-item")}));var n=t.parent(".toggle-menu-wrap"),a=null;if(n.length&&n.is(":hidden")&&((a=n.get(0)).style.display="block",a.style.visibility="hidden"),t.each((function(){var n,a=this,o=i(this);if(!a.classList.contains("side-menu-slide")){if(window.innerWidth<992)n=s.popupWidth();else{var l=this.offsetWidth?this.offsetWidth:o.width();n=s.popupWidth()-l-45}var d=s.isRightSidebar(o),h=o.children("li");h.each((function(){var s=i(this),l=s.children(".popup");if(l.length){var r=l.get(0),u=!1;if(l.is(":visible")?u=!0:r.style.display="block",s.hasClass("wide")){o.hasClass("side-menu-columns")||(r.style.left=0);var c=4;s.hasClass("col-1")&&(c=1),s.hasClass("col-2")&&(c=2),s.hasClass("col-3")&&(c=3),s.hasClass("col-4")&&(c=4),s.hasClass("col-5")&&(c=5),s.hasClass("col-6")&&(c=6),window.innerWidth<992&&(c=1);var m=0;l.find("> .inner > ul > li").each((function(){var e=parseFloat(i(this).data("cols"));(!e||e<=0)&&(e=1),e>c&&(e=c),m+=e})),m>c&&(m=c);var p=l.data("popup-mw")?l.data("popup-mw"):l.find(".inner").css("max-width"),f=n/c;"none"!==p&&parseInt(p)<n&&(f=parseInt(p)/c),l.find("> .inner > ul > li").each((function(){var e=parseFloat(i(this).data("cols"));e<=0&&(e=1),e>c&&(e=c),s.hasClass("pos-center")||s.hasClass("pos-left")||s.hasClass("pos-right")?this.style.width=100/m*e+"%":this.style.width=100/c*e+"%"})),r.children[0].children[0].style.width=f*m+1+"px",o.hasClass("side-menu-columns")||(d?(r.style.left="auto",r.style.right=(this.offsetWidth?this.offsetWidth:i(this).width())+"px"):(r.style.left=(this.offsetWidth?this.offsetWidth:i(this).width())+"px",r.style.right="auto"))}u||(r.style.display="none"),a.classList.contains("side-menu-accordion")||a.classList.contains("side-menu-slide")||s.hasClass("sub-ready")||(!("ontouchstart"in document)&&window.innerWidth>991?s.on("mouseenter",(function(){if(h.find(".popup").hide(),l.show(),l.parent().addClass("open"),!o.hasClass("side-menu-columns")&&"static"!==l.parent().css("position")){let i=this.getBoundingClientRect().top;if(this.offsetParent&&i+r.offsetHeight>e.innerHeight){let t=i+r.offsetHeight-e.innerHeight,s=i-this.parentNode.getBoundingClientRect().top;s<t&&(t=s),r.style.top=-1*t+"px",r.style.setProperty("--porto-sd-menu-popup-top",-1*t+"px")}else r.style.top="",r.style.setProperty("--porto-sd-menu-popup-top","")}l.find(".owl-carousel").length&&l.find(".owl-carousel").each((function(){var e,t=i(this);if(!t.hasClass("owl-loaded")){var s=t.data("plugin-options");s&&(e=s),t.themeCarousel(e)}}))})).on("mouseleave",(function(){l.hide(),l.parent().removeClass("open")})):s.on("click",".arrow",(function(){!o.hasClass("side-menu-columns")&&!l.parent().hasClass("open")&&window.innerWidth>991&&t.children("li.has-sub").removeClass("open").children(".popup").hide(),l.slideToggle(),l.parent().toggleClass("open")})),s.addClass("sub-ready"))}}))}})),t.hasClass("side-menu-slide")){var o={$mainNav:t,$mainNavItem:t.find("li"),build:function(){this.menuNav()},initSub:function(e){var i=e.closest("ul"),t=e.parent().find("ul").first();t.children(".menu-item").children(".go-back").length<1&&t.prepend('<li class="menu-item"><a class="go-back" href="#">'+js_porto_vars.submenu_back+"</a></li>"),i.addClass("next-menu"),t.addClass("visible"),i.css({overflow:"visible","overflow-y":"visible"}),t.outerHeight()<t.closest(".header-main").outerHeight()-100&&t.css({height:t.outerHeight()+t.find("> li").outerHeight()});var s=t.find("> li").length*t.find("> li").outerHeight()-t.outerHeight();s>0&&t.css({overflow:"hidden","overflow-y":"scroll"}),t.css({"padding-top":s+"px"})},menuNav:function(){var e=this;e.$mainNav.find(".menu-item-has-children > a.nolink").removeClass("nolink").attr("href",""),e.$mainNav.find(".menu-item-has-children > a:not(.go-back)").off("click").on("click",(function(t){t.stopImmediatePropagation(),t.preventDefault();var s=i(this);js_porto_vars.lazyload_menu&&!e.$mainNav.hasClass("sub-ready")?(e.initSub(s),e.$mainNav.on("sub-loaded",(function(){e.initSub(s)}))):e.initSub(s)}))}};o.build()}return a&&(a.style.display="",a.style.visibility=""),s}},events:function(){var e,t=this;(t.$toggle.on("click",(function(){var e=i(this).parent().parent(),s=i(this);s.hasClass("closed")?(s.removeClass("closed"),e.removeClass("closed"),e.find(".sidebar-menu-wrap").stop().slideDown(400,(function(){i(this).attr("style","").show(),t.build()}))):(s.addClass("closed"),e.addClass("closed"),e.find(".sidebar-menu-wrap").stop().slideUp(400,(function(){i(this).attr("style","").hide()})))})),this.$menu_toggle.on("click",(function(){var e=i(this).parent();if(!e.hasClass("show-always")&&!e.hasClass("show-hover")){var s=i(this);s.hasClass("closed")?(s.removeClass("closed"),e.removeClass("closed"),e.find(".toggle-menu-wrap").stop().slideDown(400,(function(){i(this).attr("style","").show()})),t.build()):(s.addClass("closed"),e.addClass("closed"),e.find(".toggle-menu-wrap").stop().slideUp(400,(function(){i(this).attr("style","").hide()})))}})),t.$menu.hasClass("side-menu-slide")&&t.$menu.on("click",".go-back",(function(e){e.preventDefault();var t=i(this).closest(".next-menu"),s=0;t.length&&t.find("> li").length&&(s=t.find("> li").length*t.find("> li").outerHeight()-t.outerHeight()),t.removeClass("next-menu"),i(this).closest("ul").removeClass("visible"),s>0&&t.css({overflow:"hidden","overflow-y":"scroll"})})),i(".sidebar-menu:not(.side-menu-accordion)").closest("[data-plugin-sticky]").length)?i(window).smartresize((function(){e&&clearTimeout(e),e=setTimeout((function(){t.build()}),800)})):i(window).smartresize((function(e){e.originalEvent&&t.build()}));return setTimeout((function(){t.build()}),400),"ontouchstart"in document&&i(document.body).on("click",(function(e){window.innerWidth>991&&(i(e.target).closest("li.has-sub.open").length||t.$menu.each((function(){var e=i(this);e.hasClass("side-menu-accordion")||e.hasClass("side-menu-slide")||e.hasClass("side-menu-columns")||e.children("li.has-sub").removeClass("open").children(".popup").hide()})))})),t}}})}).apply(this,[window.theme,jQuery]),jQuery(document).ready((function(e){void 0!==theme.SidebarMenu&&(theme.bodyWidth||(theme.bodyWidth=theme.bodyWidth||document.body.offsetWidth),theme.SidebarMenu.initialize(),e.fn.themeAccordionMenu&&e(".sidebar-menu.side-menu-accordion").themeAccordionMenu({open_one:!0}))}));