8 lines
No EOL
72 KiB
JavaScript
8 lines
No EOL
72 KiB
JavaScript
(()=>{"use strict";var e={933:e=>{var t,r=function(){function e(e,t){if("function"!=typeof e)throw new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but got: "+e+".");this._batchLoadFn=e,this._maxBatchSize=function(e){if(!(!e||!1!==e.batch))return 1;var t=e&&e.maxBatchSize;if(void 0===t)return 1/0;if("number"!=typeof t||t<1)throw new TypeError("maxBatchSize must be a positive number: "+t);return t}(t),this._batchScheduleFn=function(e){var t=e&&e.batchScheduleFn;if(void 0===t)return a;if("function"!=typeof t)throw new TypeError("batchScheduleFn must be a function: "+t);return t}(t),this._cacheKeyFn=function(e){var t=e&&e.cacheKeyFn;if(void 0===t)return function(e){return e};if("function"!=typeof t)throw new TypeError("cacheKeyFn must be a function: "+t);return t}(t),this._cacheMap=function(e){if(!(!e||!1!==e.cache))return null;var t=e&&e.cacheMap;if(void 0===t)return new Map;if(null!==t){var r=["get","set","delete","clear"].filter((function(e){return t&&"function"!=typeof t[e]}));if(0!==r.length)throw new TypeError("Custom cacheMap missing methods: "+r.join(", "))}return t}(t),this._batch=null}var t=e.prototype;return t.load=function(e){if(null==e)throw new TypeError("The loader.load() function must be called with a value, but got: "+String(e)+".");var t=function(e){var t=e._batch;if(null!==t&&!t.hasDispatched&&t.keys.length<e._maxBatchSize&&(!t.cacheHits||t.cacheHits.length<e._maxBatchSize))return t;var r={hasDispatched:!1,keys:[],callbacks:[]};return e._batch=r,e._batchScheduleFn((function(){!function(e,t){if(t.hasDispatched=!0,0!==t.keys.length){var r=e._batchLoadFn(t.keys);if(!r||"function"!=typeof r.then)return s(e,t,new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise: "+String(r)+"."));r.then((function(e){if(!n(e))throw new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array: "+String(e)+".");if(e.length!==t.keys.length)throw new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array of the same length as the Array of keys.\n\nKeys:\n"+String(t.keys)+"\n\nValues:\n"+String(e));i(t);for(var r=0;r<t.callbacks.length;r++){var a=e[r];a instanceof Error?t.callbacks[r].reject(a):t.callbacks[r].resolve(a)}})).catch((function(r){s(e,t,r)}))}else i(t)}(e,r)})),r}(this),r=this._cacheMap,a=this._cacheKeyFn(e);if(r){var o=r.get(a);if(o){var c=t.cacheHits||(t.cacheHits=[]);return new Promise((function(e){c.push((function(){e(o)}))}))}}t.keys.push(e);var l=new Promise((function(e,r){t.callbacks.push({resolve:e,reject:r})}));return r&&r.set(a,l),l},t.loadMany=function(e){if(!n(e))throw new TypeError("The loader.loadMany() function must be called with Array<key> but got: "+e+".");for(var t=[],r=0;r<e.length;r++)t.push(this.load(e[r]).catch((function(e){return e})));return Promise.all(t)},t.clear=function(e){var t=this._cacheMap;if(t){var r=this._cacheKeyFn(e);t.delete(r)}return this},t.clearAll=function(){var e=this._cacheMap;return e&&e.clear(),this},t.prime=function(e,t){var r=this._cacheMap;if(r){var a,s=this._cacheKeyFn(e);void 0===r.get(s)&&(t instanceof Error?(a=Promise.reject(t)).catch((function(){})):a=Promise.resolve(t),r.set(s,a))}return this},e}(),a="object"==typeof process&&"function"==typeof process.nextTick?function(e){t||(t=Promise.resolve()),t.then((function(){process.nextTick(e)}))}:"function"==typeof setImmediate?function(e){setImmediate(e)}:function(e){setTimeout(e)};function s(e,t,r){i(t);for(var a=0;a<t.keys.length;a++)e.clear(t.keys[a]),t.callbacks[a].reject(r)}function i(e){if(e.cacheHits)for(var t=0;t<e.cacheHits.length;t++)e.cacheHits[t]()}function n(e){return"object"==typeof e&&null!==e&&"number"==typeof e.length&&(0===e.length||e.length>0&&Object.prototype.hasOwnProperty.call(e,e.length-1))}e.exports=r}},t={};function r(a){var s=t[a];if(void 0!==s)return s.exports;var i=t[a]={exports:{}};return e[a](i,i.exports,r),i.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var a in t)r.o(t,a)&&!r.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};(()=>{r.r(a),r.d(a,{API_BLOCK_NAMESPACE:()=>w,CART_STORE_KEY:()=>Kt,CHECKOUT_STORE_KEY:()=>Aa,COLLECTIONS_STORE_KEY:()=>$a,EMPTY_CART_COUPONS:()=>C,EMPTY_CART_CROSS_SELLS:()=>k,EMPTY_CART_ERRORS:()=>M,EMPTY_CART_FEES:()=>D,EMPTY_CART_ITEMS:()=>I,EMPTY_CART_ITEM_ERRORS:()=>O,EMPTY_EXTENSIONS:()=>Y,EMPTY_PAYMENT_METHODS:()=>x,EMPTY_PAYMENT_REQUIREMENTS:()=>L,EMPTY_SHIPPING_RATES:()=>N,EMPTY_TAX_LINES:()=>U,PAYMENT_STORE_KEY:()=>Ws,QUERY_STATE_STORE_KEY:()=>oi,SCHEMA_STORE_KEY:()=>Ei,STORE_NOTICES_STORE_KEY:()=>wi,VALIDATION_STORE_KEY:()=>Gi,getErrorDetails:()=>Dt,hasInState:()=>Ca,processErrorResponse:()=>Nt,updateState:()=>Ba});var e={};r.r(e),r.d(e,{getCartData:()=>H,getCartErrors:()=>z,getCartItem:()=>J,getCartMeta:()=>G,getCartTotals:()=>$,getCouponBeingApplied:()=>Q,getCouponBeingRemoved:()=>Z,getCustomerData:()=>V,getHasCalculatedShipping:()=>F,getItemsPendingDelete:()=>ie,getItemsPendingQuantityUpdate:()=>se,getNeedsShipping:()=>B,getShippingRates:()=>q,isApplyingCoupon:()=>K,isCartDataStale:()=>X,isCustomerDataUpdating:()=>re,isItemPendingDelete:()=>te,isItemPendingQuantity:()=>ee,isRemovingCoupon:()=>W,isShippingRateBeingSelected:()=>ae});var t={};r.r(t),r.d(t,{addItemToCart:()=>lt,applyCoupon:()=>ot,applyExtensionCartUpdate:()=>nt,changeCartItemQuantity:()=>ut,itemIsPendingDelete:()=>rt,itemIsPendingQuantity:()=>tt,receiveApplyingCoupon:()=>Ze,receiveCart:()=>ze,receiveCartContents:()=>We,receiveCartItem:()=>et,receiveError:()=>Ke,receiveRemovingCoupon:()=>Je,removeCoupon:()=>ct,removeItemFromCart:()=>dt,selectShippingRate:()=>pt,setBillingAddress:()=>_t,setCartData:()=>Xe,setErrorData:()=>Qe,setIsCartDataStale:()=>at,setShippingAddress:()=>mt,shippingRatesBeingSelected:()=>it,updateCustomerData:()=>ht,updatingCustomerData:()=>st});var s={};r.r(s),r.d(s,{getCartData:()=>gt,getCartTotals:()=>yt});var i={};r.r(i),r.d(i,{getCheckoutStatus:()=>Ar,getCustomerId:()=>yr,getExtensionData:()=>vr,getOrderId:()=>Er,getOrderNotes:()=>Sr,getRedirectUrl:()=>br,getShouldCreateAccount:()=>Tr,getUseShippingAsBilling:()=>fr,hasError:()=>Pr,hasOrder:()=>Rr,isAfterProcessing:()=>kr,isBeforeProcessing:()=>Ir,isCalculating:()=>Or,isComplete:()=>wr,isIdle:()=>Cr,isProcessing:()=>Dr,prefersCollection:()=>Mr});var n={};r.r(n),r.d(n,{__internalDecrementCalculating:()=>la,__internalEmitAfterProcessingEvents:()=>ea,__internalEmitValidateEvent:()=>Jr,__internalIncrementCalculating:()=>ca,__internalProcessCheckoutResponse:()=>Zr,__internalSetAfterProcessing:()=>sa,__internalSetBeforeProcessing:()=>ra,__internalSetComplete:()=>ia,__internalSetCustomerId:()=>da,__internalSetExtensionData:()=>ha,__internalSetHasError:()=>oa,__internalSetIdle:()=>ta,__internalSetOrderNotes:()=>_a,__internalSetProcessing:()=>aa,__internalSetRedirectUrl:()=>na,__internalSetShouldCreateAccount:()=>pa,__internalSetUseShippingAsBilling:()=>ua,setPrefersCollection:()=>ma});var o={};r.r(o),r.d(o,{getCollection:()=>ka,getCollectionError:()=>Da,getCollectionHeader:()=>Oa,getCollectionLastModified:()=>Ma});var c={};r.r(c),r.d(c,{receiveCollection:()=>La,receiveCollectionError:()=>Ya,receiveLastModified:()=>Ua});var l={};r.r(l),r.d(l,{getCollection:()=>Ha,getCollectionHeader:()=>Va});var d={};r.r(d),r.d(d,{__internalEmitPaymentProcessingEvent:()=>os,__internalRemoveAvailableExpressPaymentMethod:()=>vs,__internalRemoveAvailablePaymentMethod:()=>fs,__internalSetActivePaymentMethod:()=>gs,__internalSetAvailableExpressPaymentMethods:()=>bs,__internalSetAvailablePaymentMethods:()=>Ss,__internalSetExpressPaymentError:()=>ns,__internalSetExpressPaymentMethodsInitialized:()=>ms,__internalSetExpressPaymentStarted:()=>ls,__internalSetPaymentError:()=>us,__internalSetPaymentIdle:()=>cs,__internalSetPaymentMethodData:()=>ys,__internalSetPaymentMethodsInitialized:()=>_s,__internalSetPaymentProcessing:()=>ds,__internalSetPaymentReady:()=>ps,__internalSetPaymentResult:()=>Es,__internalSetShouldSavePaymentMethod:()=>hs,__internalUpdateAvailablePaymentMethods:()=>Ts});var u={};r.r(u),r.d(u,{expressPaymentMethodsInitialized:()=>Fs,getActivePaymentMethod:()=>Ls,getActiveSavedPaymentMethods:()=>qs,getActiveSavedToken:()=>xs,getAvailableExpressPaymentMethods:()=>Us,getAvailablePaymentMethods:()=>Ys,getCurrentStatus:()=>$s,getIncompatiblePaymentMethods:()=>Hs,getPaymentMethodData:()=>js,getPaymentResult:()=>zs,getSavedPaymentMethods:()=>Vs,getShouldSavePaymentMethod:()=>Gs,getState:()=>Ks,hasPaymentError:()=>Os,isExpressPaymentMethodActive:()=>Ns,isExpressPaymentStarted:()=>Cs,isPaymentFailed:()=>Ms,isPaymentIdle:()=>Rs,isPaymentPristine:()=>Ps,isPaymentProcessing:()=>Is,isPaymentReady:()=>ks,isPaymentStarted:()=>ws,isPaymentSuccess:()=>Ds,paymentMethodsInitialized:()=>Bs});var p={};r.r(p),r.d(p,{getValueForQueryContext:()=>ti,getValueForQueryKey:()=>ei});var _={};r.r(_),r.d(_,{setQueryValue:()=>si,setValueForQueryContext:()=>ii});var m={};r.r(m),r.d(m,{getRoute:()=>ci,getRoutes:()=>li});var h={};r.r(h),r.d(h,{receiveRoutes:()=>_i});var g={};r.r(g),r.d(g,{getRoute:()=>mi,getRoutes:()=>hi});var y={};r.r(y),r.d(y,{registerContainer:()=>bi,unregisterContainer:()=>fi});var E={};r.r(E),r.d(E,{getRegisteredContainers:()=>vi});var S={};r.r(S),r.d(S,{clearAllValidationErrors:()=>Li,clearValidationError:()=>Yi,clearValidationErrors:()=>xi,hideValidationError:()=>Ui,setValidationErrors:()=>Ni,showAllValidationErrors:()=>Hi,showValidationError:()=>ji});var b={};r.r(b),r.d(b,{getValidationError:()=>Vi,getValidationErrorId:()=>qi,hasValidationErrors:()=>Bi});const f=window.wp.notices,v=window.wp.data,T=window.wp.dataControls,A=window.wp.i18n,P="wc/store/cart",R={code:"cart_api_error",message:(0,A.__)("Unable to get cart data from the API.","woocommerce"),data:{status:500}},w="wc/blocks",C=[],I=[],k=[],D=[],O=[],M=[],N=[],x=[],L=[],Y={},U=[],j={cartItemsPendingQuantity:[],cartItemsPendingDelete:[],cartData:{coupons:C,shippingRates:N,shippingAddress:{first_name:"",last_name:"",company:"",address_1:"",address_2:"",city:"",state:"",postcode:"",country:"",phone:""},billingAddress:{first_name:"",last_name:"",company:"",address_1:"",address_2:"",city:"",state:"",postcode:"",country:"",phone:"",email:""},items:I,itemsCount:0,itemsWeight:0,crossSells:k,needsShipping:!0,needsPayment:!1,hasCalculatedShipping:!0,fees:D,totals:{currency_code:"",currency_symbol:"",currency_minor_unit:2,currency_decimal_separator:".",currency_thousand_separator:",",currency_prefix:"",currency_suffix:"",total_items:"0",total_items_tax:"0",total_fees:"0",total_fees_tax:"0",total_discount:"0",total_discount_tax:"0",total_shipping:"0",total_shipping_tax:"0",total_price:"0",total_tax:"0",tax_lines:U},errors:O,paymentMethods:x,paymentRequirements:L,extensions:Y},metaData:{updatingCustomerData:!1,updatingSelectedRate:!1,applyingCoupon:"",removingCoupon:"",isCartDataStale:!1},errors:M},H=e=>e.cartData,V=e=>({shippingAddress:e.cartData.shippingAddress,billingAddress:e.cartData.billingAddress}),q=e=>e.cartData.shippingRates,B=e=>e.cartData.needsShipping,F=e=>e.cartData.hasCalculatedShipping,$=e=>e.cartData.totals||j.cartData.totals,G=e=>e.metaData||j.metaData,z=e=>e.errors,K=e=>!!e.metaData.applyingCoupon,X=e=>e.metaData.isCartDataStale,Q=e=>e.metaData.applyingCoupon||"",W=e=>!!e.metaData.removingCoupon,Z=e=>e.metaData.removingCoupon||"",J=(e,t)=>e.cartData.items.find((e=>e.key===t)),ee=(e,t)=>e.cartItemsPendingQuantity.includes(t),te=(e,t)=>e.cartItemsPendingDelete.includes(t),re=e=>!!e.metaData.updatingCustomerData,ae=e=>!!e.metaData.updatingSelectedRate,se=e=>e.cartItemsPendingQuantity,ie=e=>e.cartItemsPendingDelete;var ne=function(){return ne=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var s in t=arguments[r])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},ne.apply(this,arguments)};function oe(e){return e.toLowerCase()}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var ce=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],le=/[^A-Z0-9]+/gi;function de(e,t,r){return t instanceof RegExp?e.replace(t,r):t.reduce((function(e,t){return e.replace(t,r)}),e)}function ue(e,t){var r=e.charAt(0),a=e.substr(1).toLowerCase();return t>0&&r>="0"&&r<="9"?"_"+r+a:""+r.toUpperCase()+a}function pe(e,t){return 0===t?e.toLowerCase():ue(e,t)}const _e=e=>((e,t)=>Object.entries(e).reduce(((e,[r,a])=>({...e,[t(0,r)]:a})),{}))(e,((e,t)=>{return void 0===r&&(r={}),function(e,t){return void 0===t&&(t={}),function(e,t){void 0===t&&(t={});for(var r=t.splitRegexp,a=void 0===r?ce:r,s=t.stripRegexp,i=void 0===s?le:s,n=t.transform,o=void 0===n?oe:n,c=t.delimiter,l=void 0===c?" ":c,d=de(de(e,a,"$1\0$2"),i,"\0"),u=0,p=d.length;"\0"===d.charAt(u);)u++;for(;"\0"===d.charAt(p-1);)p--;return d.slice(u,p).split("\0").map(o).join(l)}(e,ne({delimiter:"",transform:ue},t))}(t,ne({transform:pe},r));var r})),me=window.CustomEvent||null,he=(e,{bubbles:t=!1,cancelable:r=!1,element:a,detail:s={}})=>{if(!me)return;a||(a=document.body);const i=new me(e,{bubbles:t,cancelable:r,detail:s});a.dispatchEvent(i)},ge="SET_CART_DATA",ye="SET_ERROR_DATA",Ee="APPLYING_COUPON",Se="REMOVING_COUPON",be="RECEIVE_CART_ITEM",fe="ITEM_PENDING_QUANTITY",ve="SET_IS_CART_DATA_STALE",Te="RECEIVE_REMOVED_ITEM",Ae="UPDATING_CUSTOMER_DATA",Pe="SET_BILLING_ADDRESS",Re="SET_SHIPPING_ADDRESS",we="UPDATING_SELECTED_SHIPPING_RATE",Ce=window.wp.apiFetch;var Ie=r.n(Ce),ke=r(933),De=r.n(ke);const Oe={},Me={code:"invalid_json",message:(0,A.__)("The response is not a valid JSON response.","woocommerce")},Ne=e=>{Ie().setNonce&&"function"==typeof Ie().setNonce?Ie().setNonce(e):console.error('The monkey patched function on APIFetch, "setNonce", is not present, likely another plugin or some other code has removed this augmentation')},xe=new(De())((e=>Ie()({path:"/wc/store/v1/batch",method:"POST",data:{requests:e.map((e=>({...e,body:null==e?void 0:e.data})))}}).then((t=>(function(e){if("object"!=typeof e||null===e||!e.hasOwnProperty("responses"))throw new Error("Response not valid")}(t),e.map(((e,r)=>t.responses[r]||Oe)))))),{batchScheduleFn:e=>setTimeout(e,300),cache:!1,maxBatchSize:25}),Le=e=>({type:"API_FETCH_WITH_HEADERS",options:e}),Ye=e=>new Promise(((t,r)=>{e.method&&"GET"!==e.method?(async e=>await xe.load(e))(e).then((e=>{throw function(e){if("object"!=typeof e||null===e||!("body"in e)||!("headers"in e))throw new Error("Response not valid")}(e),e.status>=200&&e.status<300&&(t({response:e.body,headers:e.headers}),Ne(e.headers)),e})).catch((e=>{e.headers&&Ne(e.headers),e.body?r(e.body):r(e)})):Ie()({...e,parse:!1}).then((e=>{e.json().then((r=>{t({response:r,headers:e.headers}),Ne(e.headers)})).catch((()=>{r(Me)}))})).catch((e=>{Ne(e.headers),"function"==typeof e.json?e.json().then((e=>{r(e)})).catch((()=>{r(Me)})):r(e.message)}))})),Ue=e=>Ye(e),je={API_FETCH_WITH_HEADERS:({options:e})=>Ye(e)},He=e=>!(e=>null===e)(e)&&e instanceof Object&&e.constructor===Object;function Ve(e,t){return He(e)&&t in e}const qe=e=>He(e)&&Ve(e,"code")&&Ve(e,"message"),Be=e=>e.quantity>=e.quantity_limits.minimum&&e.quantity<=e.quantity_limits.maximum&&e.quantity%e.quantity_limits.multiple_of==0,Fe=(0,A.__)("Something went wrong. Please contact us to get assistance.","woocommerce"),$e=(e,t,r)=>{const a=null==r?void 0:r.context;(0,v.select)("wc/store/payment").isExpressPaymentMethodActive()||void 0===a||(0,v.dispatch)("core/notices").createNotice(e,t,{isDismissible:!0,...r,context:a})},Ge=window.wp.htmlEntities,ze=e=>({dispatch:t,select:r})=>{const a=_e(e),s=r.getCartData();((e=null,t=null)=>{t&&t.forEach((e=>{(0,v.dispatch)("core/notices").removeNotice(e.code,"wc/cart")})),null!==e&&e.forEach((e=>{qe(e)&&$e("error",(0,Ge.decodeEntities)(e.message),{id:e.code,context:"wc/cart",isDismissible:!1})}))})(a.errors,s.errors),(({oldCart:e,newCart:t,cartItemsPendingQuantity:r=[],cartItemsPendingDelete:a=[]})=>{(0,v.select)(P).hasFinishedResolution("getCartData")&&(((e,t,r)=>{e.items.forEach((e=>{r.includes(e.key)||t.items.find((t=>t&&t.key===e.key))||(0,v.dispatch)("core/notices").createInfoNotice((0,A.sprintf)(/* translators: %s is the name of the item. */
|
|
(0,A.__)('"%s" was removed from your cart.',"woocommerce"),e.name),{context:"wc/cart",speak:!0,type:"snackbar",id:`${e.key}-removed`})}))})(e,t,a),((e,t)=>{t.items.forEach((t=>{const r=e.items.find((e=>e&&e.key===t.key)),a=0===e.items.length;if(!r&&!a)return;if(Be(t))return;const s=t.quantity>t.quantity_limits.maximum,i=t.quantity<t.quantity_limits.minimum,n=t.quantity%t.quantity_limits.multiple_of!=0;(s||i||n)&&(n?(0,v.dispatch)("core/notices").createInfoNotice((0,A.sprintf)(/* translators: %1$s is the name of the item, %2$d is the quantity of the item. %3$d is a number that the quantity must be a multiple of. */
|
|
(0,A.__)('The quantity of "%1$s" was changed to %2$d. You must purchase this product in groups of %3$d.',"woocommerce"),t.name,Math.floor(t.quantity/t.quantity_limits.multiple_of)*t.quantity_limits.multiple_of,t.quantity_limits.multiple_of),{context:"wc/cart",speak:!0,type:"snackbar",id:`${t.key}-quantity-update`}):i?(0,v.dispatch)("core/notices").createInfoNotice((0,A.sprintf)(/* translators: %1$s is the name of the item, %2$d is the quantity of the item. */
|
|
(0,A.__)('The quantity of "%1$s" was increased to %2$d. This is the minimum required quantity.',"woocommerce"),t.name,t.quantity_limits.minimum),{context:"wc/cart",speak:!0,type:"snackbar",id:`${t.key}-quantity-update`}):(0,v.dispatch)("core/notices").createInfoNotice((0,A.sprintf)(/* translators: %1$s is the name of the item, %2$d is the quantity of the item. */
|
|
(0,A.__)('The quantity of "%1$s" was decreased to %2$d. This is the maximum allowed quantity.',"woocommerce"),t.name,t.quantity_limits.maximum),{context:"wc/cart",speak:!0,type:"snackbar",id:`${t.key}-quantity-update`}))}))})(e,t),((e,t,r)=>{t.items.forEach((t=>{if(r.includes(t.key))return;const a=e.items.find((e=>e&&e.key===t.key));return a&&t.key===a.key?(t.quantity!==a.quantity&&Be(t)&&(0,v.dispatch)("core/notices").createInfoNotice((0,A.sprintf)(/* translators: %1$s is the name of the item, %2$d is the quantity of the item. */
|
|
(0,A.__)('The quantity of "%1$s" was changed to %2$d.',"woocommerce"),t.name,t.quantity),{context:"wc/cart",speak:!0,type:"snackbar",id:`${t.key}-quantity-update`}),t):void 0}))})(e,t,r))})({oldCart:s,newCart:a,cartItemsPendingQuantity:r.getItemsPendingQuantityUpdate(),cartItemsPendingDelete:r.getItemsPendingDelete()}),t.setCartData(a)},Ke=(e=null)=>({dispatch:t})=>{var r,a;qe(e)&&(t.setErrorData(e),null!==(r=e.data)&&void 0!==r&&r.cart&&t.receiveCart(null==e||null===(a=e.data)||void 0===a?void 0:a.cart))},Xe=e=>({type:ge,response:e}),Qe=e=>({type:ye,error:e}),We=e=>{const t=_e(e),{shippingAddress:r,billingAddress:a,...s}=t;return{type:ge,response:s}},Ze=e=>({type:Ee,couponCode:e}),Je=e=>({type:Se,couponCode:e}),et=(e=null)=>({type:be,cartItem:e}),tt=(e,t=!0)=>({type:fe,cartItemKey:e,isPendingQuantity:t}),rt=(e,t=!0)=>({type:Te,cartItemKey:e,isPendingDelete:t}),at=(e=!0)=>({type:ve,isCartDataStale:e}),st=e=>({type:Ae,isResolving:e}),it=e=>({type:we,isResolving:e}),nt=e=>async({dispatch:t})=>{try{const{response:r}=await Ue({path:"/wc/store/v1/cart/extensions",method:"POST",data:{namespace:e.namespace,data:e.data},cache:"no-store"});return t.receiveCart(r),r}catch(e){return t.receiveError(e),Promise.reject(e)}},ot=e=>async({dispatch:t})=>{try{t.receiveApplyingCoupon(e);const{response:r}=await Ue({path:"/wc/store/v1/cart/apply-coupon",method:"POST",data:{code:e},cache:"no-store"});return t.receiveCart(r),r}catch(e){return t.receiveError(e),Promise.reject(e)}finally{t.receiveApplyingCoupon("")}},ct=e=>async({dispatch:t})=>{try{t.receiveRemovingCoupon(e);const{response:r}=await Ue({path:"/wc/store/v1/cart/remove-coupon",method:"POST",data:{code:e},cache:"no-store"});return t.receiveCart(r),r}catch(e){return t.receiveError(e),Promise.reject(e)}finally{t.receiveRemovingCoupon("")}},lt=(e,t=1)=>async({dispatch:r})=>{try{he("wc-blocks_adding_to_cart",{bubbles:!0,cancelable:!0});const{response:a}=await Ue({path:"/wc/store/v1/cart/add-item",method:"POST",data:{id:e,quantity:t},cache:"no-store"});return r.receiveCart(a),(({preserveCartData:e=!1})=>{he("wc-blocks_added_to_cart",{bubbles:!0,cancelable:!0,detail:{preserveCartData:e}})})({preserveCartData:!0}),a}catch(e){return r.receiveError(e),Promise.reject(e)}},dt=e=>async({dispatch:t})=>{try{t.itemIsPendingDelete(e);const{response:r}=await Ue({path:"/wc/store/v1/cart/remove-item",data:{key:e},method:"POST",cache:"no-store"});return t.receiveCart(r),r}catch(e){return t.receiveError(e),Promise.reject(e)}finally{t.itemIsPendingDelete(e,!1)}},ut=(e,t)=>async({dispatch:r,select:a})=>{const s=a.getCartItem(e);if((null==s?void 0:s.quantity)!==t)try{r.itemIsPendingQuantity(e);const{response:a}=await Ue({path:"/wc/store/v1/cart/update-item",method:"POST",data:{key:e,quantity:t},cache:"no-store"});return r.receiveCart(a),a}catch(e){return r.receiveError(e),Promise.reject(e)}finally{r.itemIsPendingQuantity(e,!1)}},pt=(e,t=null)=>async({dispatch:r,select:a})=>{var s;const i=null===(s=a.getShippingRates().find((e=>e.package_id===t)))||void 0===s?void 0:s.shipping_rates.find((e=>!0===e.selected));if((null==i?void 0:i.rate_id)!==e)try{r.shippingRatesBeingSelected(!0);const{response:a}=await Ue({path:"/wc/store/v1/cart/select-shipping-rate",method:"POST",data:{package_id:t,rate_id:e},cache:"no-store"}),{shipping_address:s,billing_address:i,...n}=a;return r.receiveCart(n),a}catch(e){return r.receiveError(e),Promise.reject(e)}finally{r.shippingRatesBeingSelected(!1)}},_t=e=>({type:Pe,billingAddress:e}),mt=e=>({type:Re,shippingAddress:e}),ht=(e,t=!0)=>async({dispatch:r})=>{try{r.updatingCustomerData(!0);const{response:a}=await Ue({path:"/wc/store/v1/cart/update-customer",method:"POST",data:e,cache:"no-store"});return t?r.receiveCartContents(a):r.receiveCart(a),a}catch(e){return r.receiveError(e),Promise.reject(e)}finally{r.updatingCustomerData(!1)}},gt=()=>async({dispatch:e})=>{const t=await Ie()({path:"/wc/store/v1/cart",method:"GET",cache:"no-store"}),{receiveCart:r,receiveError:a}=e;t?r(t):a(R)},yt=()=>async({resolveSelect:e})=>{await e.getCartData()},Et=(e=[],t)=>t.type===be?e.map((e=>{var r;return e.key===(null===(r=t.cartItem)||void 0===r?void 0:r.key)?t.cartItem:e})):e,St=(e,t)=>t.reduce(((t,r)=>(e&&e.hasOwnProperty(r)&&(t[r]=e[r]),t)),{}),bt=(e,t,r)=>{let a,s=null;const i=(...i)=>{s=i,a&&clearTimeout(a),a=setTimeout((()=>{a=null,!r&&s&&e(...s)}),t),r&&!a&&e(...i)};return i.flush=()=>{a&&s&&(e(...s),clearTimeout(a),a=null)},i},ft=window.wp.isShallowEqual;var vt=r.n(ft);const Tt=(e,t)=>e[t]?Array.from(e[t].values()).sort(((e,t)=>e.priority-t.priority)):[];let At=function(e){return e.SUCCESS="success",e.FAIL="failure",e.ERROR="error",e}({}),Pt=function(e){return e.CART="wc/cart",e.CHECKOUT="wc/checkout",e.PAYMENTS="wc/checkout/payments",e.EXPRESS_PAYMENTS="wc/checkout/express-payments",e.CONTACT_INFORMATION="wc/checkout/contact-information",e.SHIPPING_ADDRESS="wc/checkout/shipping-address",e.BILLING_ADDRESS="wc/checkout/billing-address",e.SHIPPING_METHODS="wc/checkout/shipping-methods",e.CHECKOUT_ACTIONS="wc/checkout/checkout-actions",e}({});const Rt=(e,t)=>He(e)&&"type"in e&&e.type===t,wt=e=>Rt(e,At.SUCCESS),Ct=e=>Rt(e,At.ERROR),It=e=>Rt(e,At.FAIL),kt=e=>!He(e)||void 0===e.retry||!0===e.retry,Dt=e=>{const t=Ve(e.data,"details")?Object.entries(e.data.details):null;return t?t.reduce(((e,[t,{code:r,message:a,additional_errors:s=[]}])=>[...e,{param:t,id:`${t}_${r}`,code:r,message:(0,Ge.decodeEntities)(a)},...Array.isArray(s)?s.flatMap((e=>Ve(e,"code")&&Ve(e,"message")?[{param:t,id:`${t}_${e.code}`,code:e.code,message:(0,Ge.decodeEntities)(e.message)}]:[])):[]]),[]):[]},Ot=e=>{switch(e){case"woocommerce_rest_missing_email_address":case"woocommerce_rest_invalid_email_address":return Pt.CONTACT_INFORMATION;default:return Pt.CART}},Mt=e=>{switch(e){case"invalid_email":return Pt.CONTACT_INFORMATION;case"billing_address":return Pt.BILLING_ADDRESS;case"shipping_address":return Pt.SHIPPING_ADDRESS;default:return}},Nt=(e,t)=>{if(!qe(e))return;if("rest_invalid_param"===e.code)return((e,t)=>{Dt(e).forEach((({code:e,message:r,id:a,param:s})=>{$e("error",r,{id:a,context:t||Mt(s)||Ot(e)})}))})(e,t);let r=(0,Ge.decodeEntities)(e.message)||Fe;"invalid_json"===e.code&&(r=Fe),$e("error",r,{id:e.code,context:t||Ot(e.code)})},xt=window.wp.url,Lt="wc/store/validation",Yt=(e,t)=>"string"!=typeof t?t:"email"===e?(0,xt.isEmail)(t)?t.trim():"":"postcode"===e?t.replace(" ","").toUpperCase():t.trim(),Ut=(e,t)=>Object.keys(e).filter((r=>Yt(r,e[r])!==Yt(r,t[r]))),jt={customerDataIsInitialized:!1,doingPush:!1,customerData:{billingAddress:{},shippingAddress:{}},dirtyProps:{billingAddress:[],shippingAddress:[]}},Ht=()=>{if(jt.doingPush)return;if(jt.doingPush=!0,(()=>{const e=(0,v.select)(P).getCustomerData();jt.dirtyProps.billingAddress=[...jt.dirtyProps.billingAddress,...Ut(jt.customerData.billingAddress,e.billingAddress)],jt.dirtyProps.shippingAddress=[...jt.dirtyProps.shippingAddress,...Ut(jt.customerData.shippingAddress,e.shippingAddress)],jt.customerData=e})(),!(jt.dirtyProps.billingAddress.length>0||jt.dirtyProps.shippingAddress.length>0))return void(jt.doingPush=!1);if(!(e=>{const t=(0,v.select)(Lt);return 0===[...e.billingAddress.filter((e=>void 0!==t.getValidationError("billing_"+e))),...e.shippingAddress.filter((e=>void 0!==t.getValidationError("shipping_"+e)))].filter(Boolean).length})(jt.dirtyProps))return void(jt.doingPush=!1);const e={};jt.dirtyProps.billingAddress.length&&(e.billing_address=St(jt.customerData.billingAddress,jt.dirtyProps.billingAddress)),jt.dirtyProps.shippingAddress.length&&(e.shipping_address=St(jt.customerData.shippingAddress,jt.dirtyProps.shippingAddress)),(0,v.dispatch)(P).updateCustomerData(e).then((()=>{jt.dirtyProps.billingAddress=[],jt.dirtyProps.shippingAddress=[],jt.doingPush=!1,(()=>{const e=(0,v.select)("wc/store/store-notices").getRegisteredContainers(),{removeNotice:t}=(0,v.dispatch)("core/notices"),{getNotices:r}=(0,v.select)("core/notices");e.forEach((e=>{r(e).forEach((r=>{t(r.id,e)}))}))})()})).catch((e=>{jt.doingPush=!1,Nt(e)}))},Vt=bt((()=>{jt.doingPush?Vt():Ht()}),1500),qt="wc/store/payment";let Bt=function(e){return e.IDLE="idle",e.EXPRESS_STARTED="express_started",e.PROCESSING="processing",e.READY="ready",e.ERROR="has_error",e}({});const Ft=async()=>!!(0,v.select)(P).hasFinishedResolution("getCartData")&&(await(0,v.dispatch)(qt).__internalUpdateAvailablePaymentMethods(),!0),$t=bt(Ft,1e3),Gt=(0,v.registerStore)(P,{reducer:(e=j,t)=>{switch(t.type){case ye:t.error&&(e={...e,errors:[t.error]});break;case ge:t.response&&(e={...e,errors:M,cartData:{...e.cartData,...t.response}});break;case Ee:(t.couponCode||""===t.couponCode)&&(e={...e,metaData:{...e.metaData,applyingCoupon:t.couponCode}});break;case Pe:e={...e,cartData:{...e.cartData,billingAddress:{...e.cartData.billingAddress,...t.billingAddress}}};break;case Re:e={...e,cartData:{...e.cartData,shippingAddress:{...e.cartData.shippingAddress,...t.shippingAddress}}};break;case Se:(t.couponCode||""===t.couponCode)&&(e={...e,metaData:{...e.metaData,removingCoupon:t.couponCode}});break;case fe:const r=e.cartItemsPendingQuantity.filter((e=>e!==t.cartItemKey));t.isPendingQuantity&&t.cartItemKey&&r.push(t.cartItemKey),e={...e,cartItemsPendingQuantity:r};break;case Te:const a=e.cartItemsPendingDelete.filter((e=>e!==t.cartItemKey));t.isPendingDelete&&t.cartItemKey&&a.push(t.cartItemKey),e={...e,cartItemsPendingDelete:a};break;case be:e={...e,errors:M,cartData:{...e.cartData,items:Et(e.cartData.items,t)}};break;case Ae:e={...e,metaData:{...e.metaData,updatingCustomerData:!!t.isResolving}};break;case we:e={...e,metaData:{...e.metaData,updatingSelectedRate:!!t.isResolving}};break;case ve:e={...e,metaData:{...e.metaData,isCartDataStale:t.isCartDataStale}}}return e},actions:t,controls:T.controls,selectors:e,resolvers:s,__experimentalUseThunks:!0});Gt.subscribe(((e=!0)=>{if((0,v.select)(P).hasFinishedResolution("getCartData"))return jt.customerDataIsInitialized?void(vt()(jt.customerData,(0,v.select)(P).getCustomerData())||(e?Vt():Ht())):(jt.customerData=(0,v.select)(P).getCustomerData(),void(jt.customerDataIsInitialized=!0))})),document.body.addEventListener("focusout",(e=>{e.target&&e.target instanceof Element&&"input"===e.target.tagName.toLowerCase()&&Vt.flush()}));const zt=Gt.subscribe((async()=>{await Ft()&&(zt(),Gt.subscribe($t))})),Kt=P,Xt=window.wc.wcSettings,Qt="wc/store/checkout";let Wt=function(e){return e.IDLE="idle",e.COMPLETE="complete",e.BEFORE_PROCESSING="before_processing",e.PROCESSING="processing",e.AFTER_PROCESSING="after_processing",e}({});const Zt={order_id:0,customer_id:0,billing_address:{},shipping_address:{},...(0,Xt.getSetting)("checkoutData",{})||{}};var Jt,er,tr,rr,ar,sr,ir,nr,or,cr;const lr=(0,Xt.getSetting)("wcBlocksConfig",{buildPhase:1,pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),dr=lr.pluginUrl+"images/",ur=(lr.pluginUrl,lr.buildPhase,null===(Jt=Xt.STORE_PAGES.shop)||void 0===Jt||Jt.permalink,null===(er=Xt.STORE_PAGES.checkout)||void 0===er||er.id,null===(tr=Xt.STORE_PAGES.checkout)||void 0===tr||tr.permalink,null===(rr=Xt.STORE_PAGES.privacy)||void 0===rr||rr.permalink,null===(ar=Xt.STORE_PAGES.privacy)||void 0===ar||ar.title,null===(sr=Xt.STORE_PAGES.terms)||void 0===sr||sr.permalink,null===(ir=Xt.STORE_PAGES.terms)||void 0===ir||ir.title,null===(nr=Xt.STORE_PAGES.cart)||void 0===nr||nr.id,null===(or=Xt.STORE_PAGES.cart)||void 0===or||or.permalink,null!==(cr=Xt.STORE_PAGES.myaccount)&&void 0!==cr&&cr.permalink?Xt.STORE_PAGES.myaccount.permalink:(0,Xt.getSetting)("wpLoginUrl","/wp-login.php"),(0,Xt.getSetting)("localPickupEnabled",!1)),pr=(0,Xt.getSetting)("countries",{}),_r=(0,Xt.getSetting)("countryData",{}),mr=(Object.fromEntries(Object.keys(_r).filter((e=>!0===_r[e].allowBilling)).map((e=>[e,pr[e]||""]))),Object.fromEntries(Object.keys(_r).filter((e=>!0===_r[e].allowBilling)).map((e=>[e,_r[e].states||[]]))),Object.fromEntries(Object.keys(_r).filter((e=>!0===_r[e].allowShipping)).map((e=>[e,pr[e]||""]))),Object.fromEntries(Object.keys(_r).filter((e=>!0===_r[e].allowShipping)).map((e=>[e,_r[e].states||[]]))),Object.fromEntries(Object.keys(_r).map((e=>[e,_r[e].locale||[]])))),hr=(0,Xt.getSetting)("collectableMethodIds",[]),gr=e=>"string"==typeof e,yr=e=>e.customerId,Er=e=>e.orderId,Sr=e=>e.orderNotes,br=e=>e.redirectUrl,fr=e=>e.useShippingAsBilling,vr=e=>e.extensionData,Tr=e=>e.shouldCreateAccount,Ar=e=>e.status,Pr=e=>e.hasError,Rr=e=>!!e.orderId,wr=e=>e.status===Wt.COMPLETE,Cr=e=>e.status===Wt.IDLE,Ir=e=>e.status===Wt.BEFORE_PROCESSING,kr=e=>e.status===Wt.AFTER_PROCESSING,Dr=e=>e.status===Wt.PROCESSING,Or=e=>e.calculatingCount>0,Mr=e=>{if(void 0===e.prefersCollection){const e=(0,v.select)(P).getShippingRates();if(!e||!e.length)return!1;const r=e[0].shipping_rates.find((e=>e.selected));if(Ve(r,"method_id")&&gr(r.method_id))return t=null==r?void 0:r.method_id,!!ur&&(Array.isArray(t)?!!t.find((e=>hr.includes(e))):hr.includes(t))}var t;return e.prefersCollection},Nr="SET_IDLE",xr="SET_REDIRECT_URL",Lr="SET_CHECKOUT_COMPLETE",Yr="SET_BEFORE_PROCESSING",Ur="SET_AFTER_PROCESSING",jr="SET_CHECKOUT_IS_PROCESSING",Hr="SET_CHECKOUT_HAS_ERROR",Vr="SET_CHECKOUT_CUSTOMER_ID",qr="SET_CHECKOUT_ORDER_NOTES",Br="INCREMENT_CALCULATING",Fr="DECREMENT_CALCULATING",$r="SET_USE_SHIPPING_AS_BILLING",Gr="SET_SHOULD_CREATE_ACCOUNT",zr="SET_PREFERS_COLLECTION",Kr="SET_EXTENSION_DATA",Xr=e=>He(e)&&Ve(e,"type"),Qr=async(e,t,r)=>{const a=[],s=Tt(e,t);for(const e of s)try{const t=await Promise.resolve(e.callback(r));if(!Xr(t))continue;if(!t.hasOwnProperty("type"))throw new Error("Returned objects from event emitter observers must return an object with a type property");if(Ct(t)||It(t))return a.push(t),a;a.push(t)}catch(e){return console.error(e),a.push({type:At.ERROR}),a}return a},Wr=(window.wp.element,"checkout_success"),Zr=e=>({dispatch:t})=>{const r=(e=>{const t={message:"",paymentStatus:"not set",redirectUrl:"",paymentDetails:{}};return"payment_result"in e&&(t.paymentStatus=e.payment_result.payment_status,t.redirectUrl=e.payment_result.redirect_url,e.payment_result.hasOwnProperty("payment_details")&&Array.isArray(e.payment_result.payment_details)&&e.payment_result.payment_details.forEach((({key:e,value:r})=>{t.paymentDetails[e]=(0,Ge.decodeEntities)(r)}))),"message"in e&&(t.message=(0,Ge.decodeEntities)(e.message)),!t.message&&"data"in e&&"status"in e.data&&e.data.status>299&&(t.message=(0,A.__)("Something went wrong. Please contact us to get assistance.","woocommerce")),t})(e);t.__internalSetRedirectUrl((null==r?void 0:r.redirectUrl)||""),(0,v.dispatch)(qt).__internalSetPaymentResult(r),t.__internalSetAfterProcessing()},Jr=({observers:e,setValidationErrors:t})=>({dispatch:r,registry:a})=>{const{createErrorNotice:s}=a.dispatch(f.store);((e,t)=>{const r=(0,v.select)("core/notices").getNotices(t),{removeNotice:a}=(0,v.dispatch)("core/notices");r.filter((e=>"error"===e.status)).forEach((e=>a(e.id,t)))})(),(async(e,t,r)=>{const a=Tt(e,t),s=[];for(const e of a)try{const t=await Promise.resolve(e.callback(r));"object"==typeof t&&s.push(t)}catch(e){console.error(e)}return!s.length||s})(e,"checkout_validation",{}).then((e=>{!0!==e?(Array.isArray(e)&&e.forEach((({errorMessage:e,validationErrors:r,context:a="wc/checkout"})=>{s(e,{context:a}),t(r)})),r.__internalSetIdle(),r.__internalSetHasError()):r.__internalSetProcessing()}))},ea=({observers:e,notices:t})=>({select:r,dispatch:a,registry:s})=>{const{createErrorNotice:i}=s.dispatch(f.store),n={redirectUrl:r.getRedirectUrl(),orderId:r.getOrderId(),customerId:r.getCustomerId(),orderNotes:r.getOrderNotes(),processingResponse:(0,v.select)(qt).getPaymentResult()};r.hasError()?Qr(e,"checkout_fail",n).then((e=>{(({observerResponses:e,notices:t,dispatch:r,createErrorNotice:a,data:s})=>{const i=(({observerResponses:e,createErrorNotice:t})=>{let r=null;return e.forEach((e=>{if((Ct(e)||It(e))&&e.message&&gr(e.message)){const a=e.messageContext&&gr(e.messageContext)?{context:e.messageContext}:void 0;r=e,t(e.message,a)}})),r})({observerResponses:e,createErrorNotice:a});if(null!==i)kt(i)?r.__internalSetIdle():r.__internalSetComplete(i);else{var n;t.checkoutNotices.some((e=>"error"===e.status))||t.expressPaymentNotices.some((e=>"error"===e.status))||t.paymentNotices.some((e=>"error"===e.status))||a((null===(n=s.processingResponse)||void 0===n?void 0:n.message)||(0,A.__)("Something went wrong. Please contact us to get assistance.","woocommerce"),{id:"checkout",context:"wc/checkout"}),r.__internalSetIdle()}})({observerResponses:e,notices:t,dispatch:a,createErrorNotice:i,data:n})})):Qr(e,Wr,n).then((e=>{(({observerResponses:e,dispatch:t,createErrorNotice:r})=>{let a=null,s=null;if(e.forEach((e=>{wt(e)&&(a=e),(Ct(e)||It(e))&&(s=e)})),a&&!s)t.__internalSetComplete(a);else if(He(s)){if(s.message&&gr(s.message)){const e=s.messageContext&&gr(s.messageContext)?{context:s.messageContext}:void 0;r(s.message,e)}kt(s)?t.__internalSetHasError(!0):t.__internalSetComplete(s)}else t.__internalSetComplete()})({observerResponses:e,dispatch:a,createErrorNotice:i})}))},ta=()=>({type:Nr}),ra=()=>({type:Yr}),aa=()=>({type:jr}),sa=()=>({type:Ur}),ia=(e={})=>({type:Lr,data:e}),na=e=>({type:xr,redirectUrl:e}),oa=(e=!0)=>({type:Hr,hasError:e}),ca=()=>({type:Br}),la=()=>({type:Fr}),da=e=>({type:Vr,customerId:e}),ua=e=>({type:$r,useShippingAsBilling:e}),pa=e=>({type:Gr,shouldCreateAccount:e}),_a=e=>({type:qr,orderNotes:e}),ma=e=>({type:zr,prefersCollection:e}),ha=(e,t,r=!1)=>({type:Kr,extensionData:t,namespace:e,replace:r}),ga=e=>{const t={};return void 0!==e.label&&(t.label=e.label),void 0!==e.required&&(t.required=e.required),void 0!==e.hidden&&(t.hidden=e.hidden),void 0===e.label||e.optionalLabel||(t.optionalLabel=(0,A.sprintf)(/* translators: %s Field label. */
|
|
(0,A.__)("%s (optional)","woocommerce"),e.label)),e.priority&&("number"==typeof e.priority&&(t.index=e.priority),gr(e.priority)&&(t.index=parseInt(e.priority,10))),e.hidden&&(t.required=!1),t},ya=Object.entries(mr).map((([e,t])=>[e,Object.entries(t).map((([e,t])=>[e,ga(t)])).reduce(((e,[t,r])=>(e[t]=r,e)),{})])).reduce(((e,[t,r])=>(e[t]=r,e)),{}),Ea=e=>{const t=((e,t,r="")=>{const a=r&&void 0!==ya[r]?ya[r]:{};return e.map((e=>({key:e,...Xt.defaultAddressFields[e]||{},...a[e]||{},...t[e]||{}}))).sort(((e,t)=>e.index-t.index))})(Object.keys(Xt.defaultAddressFields),{},e.country),r=Object.assign({},e);return t.forEach((({key:t="",hidden:a=!1})=>{a&&((e,t)=>e in t)(t,e)&&(r[t]="")})),r},Sa={redirectUrl:"",status:Wt.PRISTINE,hasError:!1,orderId:Zt.order_id,customerId:Zt.customer_id,calculatingCount:0,orderNotes:"",useShippingAsBilling:(ba=Zt.billing_address,fa=Zt.shipping_address,Object.keys(Xt.defaultAddressFields).every((e=>ba[e]===fa[e]))),shouldCreateAccount:!1,prefersCollection:void 0,extensionData:{}};var ba,fa;const va={reducer:(e=Sa,t)=>{var r;let a=e;switch(t.type){case Nr:a=e.status!==Wt.IDLE?{...e,status:Wt.IDLE}:e;break;case xr:a=void 0!==t.redirectUrl&&t.redirectUrl!==e.redirectUrl?{...e,redirectUrl:t.redirectUrl}:e;break;case Lr:a={...e,status:Wt.COMPLETE,redirectUrl:"string"==typeof(null===(r=t.data)||void 0===r?void 0:r.redirectUrl)?t.data.redirectUrl:e.redirectUrl};break;case jr:a={...e,status:Wt.PROCESSING,hasError:!1};break;case Yr:a={...e,status:Wt.BEFORE_PROCESSING,hasError:!1};break;case Ur:a={...e,status:Wt.AFTER_PROCESSING};break;case Hr:a={...e,hasError:t.hasError,status:e.status===Wt.PROCESSING||e.status===Wt.BEFORE_PROCESSING?Wt.IDLE:e.status};break;case Br:a={...e,calculatingCount:e.calculatingCount+1};break;case Fr:a={...e,calculatingCount:Math.max(0,e.calculatingCount-1)};break;case Vr:void 0!==t.customerId&&(a={...e,customerId:t.customerId});break;case $r:void 0!==t.useShippingAsBilling&&t.useShippingAsBilling!==e.useShippingAsBilling&&(a={...e,useShippingAsBilling:t.useShippingAsBilling});break;case Gr:void 0!==t.shouldCreateAccount&&t.shouldCreateAccount!==e.shouldCreateAccount&&(a={...e,shouldCreateAccount:t.shouldCreateAccount});break;case zr:void 0!==t.prefersCollection&&t.prefersCollection!==e.prefersCollection&&(a={...e,prefersCollection:t.prefersCollection});break;case qr:void 0!==t.orderNotes&&e.orderNotes!==t.orderNotes&&(a={...e,orderNotes:t.orderNotes});break;case Kr:void 0!==t.extensionData&&void 0!==t.namespace&&(a={...e,extensionData:{...e.extensionData,[t.namespace]:t.replace?t.extensionData:{...e.extensionData[t.namespace],...t.extensionData}}})}return a},selectors:i,actions:n,__experimentalUseThunks:!0},Ta=(0,v.createReduxStore)(Qt,va);(0,v.register)(Ta);const Aa=Qt,Pa="wc/store/collections",Ra=[],wa=(e,t)=>!!t&&!!t.reduce(((e,t)=>"object"==typeof e&&null!==e?e[t]:void 0),e);function Ca(e,t){return wa(e,t)}const Ia=({state:e,namespace:t,resourceName:r,query:a,ids:s,type:i="items",fallback:n=Ra})=>Ca(e,[t,r,s=JSON.stringify(s),a=null!==a?(0,xt.addQueryArgs)("",a):"",i])?e[t][r][s][a][i]:n,ka=(e,t,r,a=null,s=Ra)=>Ia({state:e,namespace:t,resourceName:r,query:a,ids:s}),Da=(e,t,r,a=null,s=Ra)=>Ia({state:e,namespace:t,resourceName:r,query:a,ids:s,type:"error",fallback:null}),Oa=(e,t,r,a,s=null,i=Ra)=>{const n=((e,t,r,a=null,s=Ra)=>Ia({state:e,namespace:t,resourceName:r,query:a,ids:s,type:"headers",fallback:void 0}))(e,r,a,s,i);return n&&n.get?n.has(t)?n.get(t):void 0:null},Ma=e=>e.lastModified||0,Na={RECEIVE_COLLECTION:"RECEIVE_COLLECTION",RESET_COLLECTION:"RESET_COLLECTION",ERROR:"ERROR",RECEIVE_LAST_MODIFIED:"RECEIVE_LAST_MODIFIED",INVALIDATE_RESOLUTION_FOR_STORE:"INVALIDATE_RESOLUTION_FOR_STORE"};let xa=window.Headers||null;function La(e,t,r="",a=[],s={items:[],headers:xa},i=!1){return{type:i?Na.RESET_COLLECTION:Na.RECEIVE_COLLECTION,namespace:e,resourceName:t,queryString:r,ids:a,response:s}}function Ya(e,t,r,a,s){return{type:"ERROR",namespace:e,resourceName:t,queryString:r,ids:a,response:{items:[],headers:xa,error:s}}}function Ua(e){return{type:Na.RECEIVE_LAST_MODIFIED,timestamp:e}}xa=xa?new xa:{get:()=>{},has:()=>{}};const ja="wc/store/schema";function*Ha(e,t,r,a){const s=yield v.controls.resolveSelect(ja,"getRoute",e,t,a),i=(0,xt.addQueryArgs)("",r);if(s)try{const{response:r=Ra,headers:n}=yield Le({path:s+i});n&&n.get&&n.has("last-modified")&&(yield function*(e){const t=yield v.controls.resolveSelect(Pa,"getCollectionLastModified");t?e>t&&(yield v.controls.dispatch(Pa,"invalidateResolutionForStore"),yield v.controls.dispatch(Pa,"receiveLastModified",e)):yield v.controls.dispatch(Pa,"receiveLastModified",e)}(parseInt(n.get("last-modified"),10))),yield La(e,t,i,a,{items:r,headers:n})}catch(r){yield Ya(e,t,i,a,r)}else yield La(e,t,i,a)}function*Va(e,t,r,a,s){const i=[t,r,a,s].filter((e=>void 0!==e));yield v.controls.resolveSelect(Pa,"getCollection",...i)}function qa(e,t,r,a=0){const s=t[a];if(a===t.length-1)return{...e,[s]:r};const i=e[s]||{};return{...e,[s]:qa(i,t,r,a+1)}}function Ba(e,t,r){return qa(e,t,r)}const Fa=(0,v.createReduxStore)(Pa,{reducer:(e={},t)=>{if(t.type===Na.RECEIVE_LAST_MODIFIED)return t.timestamp===e.lastModified?e:{...e,lastModified:t.timestamp};if(t.type===Na.INVALIDATE_RESOLUTION_FOR_STORE)return{};const{type:r,namespace:a,resourceName:s,queryString:i,response:n}=t,o=t.ids?JSON.stringify(t.ids):"[]";switch(r){case Na.RECEIVE_COLLECTION:if(Ca(e,[a,s,o,i]))return e;e=Ba(e,[a,s,o,i],n);break;case Na.RESET_COLLECTION:case Na.ERROR:e=Ba(e,[a,s,o,i],n)}return e},actions:c,controls:{...T.controls,...je},selectors:o,resolvers:l});(0,v.register)(Fa);const $a=Pa,Ga={status:Bt.IDLE,activePaymentMethod:"",activeSavedToken:"",availablePaymentMethods:{},availableExpressPaymentMethods:{},savedPaymentMethods:(0,Xt.getSetting)("customerPaymentMethods",{}),paymentMethodData:{},paymentResult:null,paymentMethodsInitialized:!1,expressPaymentMethodsInitialized:!1,shouldSavePaymentMethod:!1};let za=function(e){return e.SET_PAYMENT_IDLE="SET_PAYMENT_IDLE",e.SET_EXPRESS_PAYMENT_STARTED="SET_EXPRESS_PAYMENT_STARTED",e.SET_PAYMENT_READY="SET_PAYMENT_READY",e.SET_PAYMENT_PROCESSING="SET_PAYMENT_PROCESSING",e.SET_PAYMENT_ERROR="SET_PAYMENT_ERROR",e.SET_PAYMENT_METHODS_INITIALIZED="SET_PAYMENT_METHODS_INITIALIZED",e.SET_EXPRESS_PAYMENT_METHODS_INITIALIZED="SET_EXPRESS_PAYMENT_METHODS_INITIALIZED",e.SET_ACTIVE_PAYMENT_METHOD="SET_ACTIVE_PAYMENT_METHOD",e.SET_SHOULD_SAVE_PAYMENT_METHOD="SET_SHOULD_SAVE_PAYMENT_METHOD",e.SET_AVAILABLE_PAYMENT_METHODS="SET_AVAILABLE_PAYMENT_METHODS",e.SET_AVAILABLE_EXPRESS_PAYMENT_METHODS="SET_AVAILABLE_EXPRESS_PAYMENT_METHODS",e.REMOVE_AVAILABLE_PAYMENT_METHOD="REMOVE_AVAILABLE_PAYMENT_METHOD",e.REMOVE_AVAILABLE_EXPRESS_PAYMENT_METHOD="REMOVE_AVAILABLE_EXPRESS_PAYMENT_METHOD",e.INITIALIZE_PAYMENT_METHODS="INITIALIZE_PAYMENT_METHODS",e.SET_PAYMENT_METHOD_DATA="SET_PAYMENT_METHOD_DATA",e.SET_PAYMENT_RESULT="SET_PAYMENT_RESULT",e}({});const Ka=e=>Object.fromEntries(e.map((({package_id:e,shipping_rates:t})=>{var r;return[e,(null===(r=t.find((e=>e.selected)))||void 0===r?void 0:r.rate_id)||""]}))),Xa=window.wc.wcBlocksRegistry,Qa=[{destination:{address_1:"",address_2:"",city:"",state:"",postcode:"",country:""},package_id:0,name:(0,A.__)("Shipping","woocommerce"),items:[{key:"33e75ff09dd601bbe69f351039152189",name:(0,A._x)("Beanie with Logo","example product in Cart Block","woocommerce"),quantity:2},{key:"6512bd43d9caa6e02c990b0a82652dca",name:(0,A._x)("Beanie","example product in Cart Block","woocommerce"),quantity:1}],shipping_rates:[{currency_code:"USD",currency_symbol:"$",currency_minor_unit:2,currency_decimal_separator:".",currency_thousand_separator:",",currency_prefix:"$",currency_suffix:"",name:(0,A.__)("Flat rate shipping","woocommerce"),description:"",delivery_time:"",price:"500",taxes:"0",rate_id:"flat_rate:0",instance_id:0,meta_data:[],method_id:"flat_rate",selected:!0},{currency_code:"USD",currency_symbol:"$",currency_minor_unit:2,currency_decimal_separator:".",currency_thousand_separator:",",currency_prefix:"$",currency_suffix:"",name:(0,A.__)("Free shipping","woocommerce"),description:"",delivery_time:"",price:"0",taxes:"0",rate_id:"free_shipping:1",instance_id:0,meta_data:[],method_id:"flat_rate",selected:!1},{currency_code:"USD",currency_symbol:"$",currency_minor_unit:2,currency_decimal_separator:".",currency_thousand_separator:",",currency_prefix:"$",currency_suffix:"",name:(0,A.__)("Local pickup","woocommerce"),description:"",delivery_time:"",price:"0",taxes:"0",rate_id:"pickup_location:1",instance_id:1,meta_data:[{key:"pickup_location",value:"New York"},{key:"pickup_address",value:"123 Easy Street, New York, 12345"}],method_id:"pickup_location",selected:!1},{currency_code:"USD",currency_symbol:"$",currency_minor_unit:2,currency_decimal_separator:".",currency_thousand_separator:",",currency_prefix:"$",currency_suffix:"",name:(0,A.__)("Local pickup","woocommerce"),description:"",delivery_time:"",price:"0",taxes:"0",rate_id:"pickup_location:2",instance_id:1,meta_data:[{key:"pickup_location",value:"Los Angeles"},{key:"pickup_address",value:"123 Easy Street, Los Angeles, California, 90210"}],method_id:"pickup_location",selected:!1}]}],Wa=(0,Xt.getSetting)("displayCartPricesIncludingTax",!1),Za={coupons:[],shipping_rates:(0,Xt.getSetting)("shippingMethodsExist",!1)||(0,Xt.getSetting)("localPickupEnabled",!1)?Qa:[],items:[{key:"1",id:1,type:"simple",quantity:2,catalog_visibility:"visible",name:(0,A.__)("Beanie","woocommerce"),summary:(0,A.__)("Beanie","woocommerce"),short_description:(0,A.__)("Warm hat for winter","woocommerce"),description:"Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",sku:"woo-beanie",permalink:"https://example.org",low_stock_remaining:2,backorders_allowed:!1,show_backorder_badge:!1,sold_individually:!1,quantity_limits:{minimum:1,maximum:99,multiple_of:1,editable:!0},images:[{id:10,src:dr+"previews/beanie.jpg",thumbnail:dr+"previews/beanie.jpg",srcset:"",sizes:"",name:"",alt:""}],variation:[{attribute:(0,A.__)("Color","woocommerce"),value:(0,A.__)("Yellow","woocommerce")},{attribute:(0,A.__)("Size","woocommerce"),value:(0,A.__)("Small","woocommerce")}],prices:{currency_code:"USD",currency_symbol:"$",currency_minor_unit:2,currency_decimal_separator:".",currency_thousand_separator:",",currency_prefix:"$",currency_suffix:"",price:Wa?"12000":"10000",regular_price:Wa?"12000":"10000",sale_price:Wa?"12000":"10000",price_range:null,raw_prices:{precision:6,price:Wa?"12000000":"10000000",regular_price:Wa?"12000000":"10000000",sale_price:Wa?"12000000":"10000000"}},totals:{currency_code:"USD",currency_symbol:"$",currency_minor_unit:2,currency_decimal_separator:".",currency_thousand_separator:",",currency_prefix:"$",currency_suffix:"",line_subtotal:"2000",line_subtotal_tax:"400",line_total:"2000",line_total_tax:"400"},extensions:{},item_data:[]},{key:"2",id:2,type:"simple",quantity:1,catalog_visibility:"visible",name:(0,A.__)("Cap","woocommerce"),summary:(0,A.__)("Cap","woocommerce"),short_description:(0,A.__)("Lightweight baseball cap","woocommerce"),description:"Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",sku:"woo-cap",low_stock_remaining:null,permalink:"https://example.org",backorders_allowed:!1,show_backorder_badge:!1,sold_individually:!1,quantity_limits:{minimum:1,maximum:99,multiple_of:1,editable:!0},images:[{id:11,src:dr+"previews/cap.jpg",thumbnail:dr+"previews/cap.jpg",srcset:"",sizes:"",name:"",alt:""}],variation:[{attribute:(0,A.__)("Color","woocommerce"),value:(0,A.__)("Orange","woocommerce")}],prices:{currency_code:"USD",currency_symbol:"$",currency_minor_unit:2,currency_decimal_separator:".",currency_thousand_separator:",",currency_prefix:"$",currency_suffix:"",price:Wa?"2400":"2000",regular_price:Wa?"2400":"2000",sale_price:Wa?"2400":"2000",price_range:null,raw_prices:{precision:6,price:Wa?"24000000":"20000000",regular_price:Wa?"24000000":"20000000",sale_price:Wa?"24000000":"20000000"}},totals:{currency_code:"USD",currency_symbol:"$",currency_minor_unit:2,currency_decimal_separator:".",currency_thousand_separator:",",currency_prefix:"$",currency_suffix:"",line_subtotal:"2000",line_subtotal_tax:"400",line_total:"2000",line_total_tax:"400"},extensions:{},item_data:[]}],cross_sells:[{id:1,name:(0,A.__)("Polo","woocommerce"),parent:0,type:"simple",variation:"",permalink:"https://example.org",sku:"woo-polo",short_description:(0,A.__)("Polo","woocommerce"),description:(0,A.__)("Polo","woocommerce"),on_sale:!1,prices:{currency_code:"USD",currency_symbol:"$",currency_minor_unit:2,currency_decimal_separator:".",currency_thousand_separator:",",currency_prefix:"$",currency_suffix:"",price:Wa?"24000":"20000",regular_price:Wa?"24000":"20000",sale_price:Wa?"12000":"10000",price_range:null},price_html:"",average_rating:"4.5",review_count:2,images:[{id:17,src:dr+"previews/polo.jpg",thumbnail:dr+"previews/polo.jpg",srcset:"",sizes:"",name:"",alt:""}],categories:[],tags:[],attributes:[],variations:[],has_options:!1,is_purchasable:!0,is_in_stock:!0,is_on_backorder:!1,low_stock_remaining:null,sold_individually:!1,add_to_cart:{text:"",description:"",url:"",minimum:1,maximum:99,multiple_of:1}},{id:2,name:(0,A.__)("Long Sleeve Tee","woocommerce"),parent:0,type:"simple",variation:"",permalink:"https://example.org",sku:"woo-long-sleeve-tee",short_description:(0,A.__)("Long Sleeve Tee","woocommerce"),description:(0,A.__)("Long Sleeve Tee","woocommerce"),on_sale:!1,prices:{currency_code:"USD",currency_symbol:"$",currency_minor_unit:2,currency_decimal_separator:".",currency_thousand_separator:",",currency_prefix:"$",currency_suffix:"",price:Wa?"30000":"25000",regular_price:Wa?"30000":"25000",sale_price:Wa?"30000":"25000",price_range:null},price_html:"",average_rating:"4",review_count:2,images:[{id:17,src:dr+"previews/long-sleeve-tee.jpg",thumbnail:dr+"previews/long-sleeve-tee.jpg",srcset:"",sizes:"",name:"",alt:""}],categories:[],tags:[],attributes:[],variations:[],has_options:!1,is_purchasable:!0,is_in_stock:!0,is_on_backorder:!1,low_stock_remaining:null,sold_individually:!1,add_to_cart:{text:"",description:"",url:"",minimum:1,maximum:99,multiple_of:1}},{id:3,name:(0,A.__)("Hoodie with Zipper","woocommerce"),parent:0,type:"simple",variation:"",permalink:"https://example.org",sku:"woo-hoodie-with-zipper",short_description:(0,A.__)("Hoodie with Zipper","woocommerce"),description:(0,A.__)("Hoodie with Zipper","woocommerce"),on_sale:!0,prices:{currency_code:"USD",currency_symbol:"$",currency_minor_unit:2,currency_decimal_separator:".",currency_thousand_separator:",",currency_prefix:"$",currency_suffix:"",price:Wa?"15000":"12500",regular_price:Wa?"30000":"25000",sale_price:Wa?"15000":"12500",price_range:null},price_html:"",average_rating:"1",review_count:2,images:[{id:17,src:dr+"previews/hoodie-with-zipper.jpg",thumbnail:dr+"previews/hoodie-with-zipper.jpg",srcset:"",sizes:"",name:"",alt:""}],categories:[],tags:[],attributes:[],variations:[],has_options:!1,is_purchasable:!0,is_in_stock:!0,is_on_backorder:!1,low_stock_remaining:null,sold_individually:!1,add_to_cart:{text:"",description:"",url:"",minimum:1,maximum:99,multiple_of:1}},{id:4,name:(0,A.__)("Hoodie with Logo","woocommerce"),parent:0,type:"simple",variation:"",permalink:"https://example.org",sku:"woo-hoodie-with-logo",short_description:(0,A.__)("Polo","woocommerce"),description:(0,A.__)("Polo","woocommerce"),on_sale:!1,prices:{currency_code:"USD",currency_symbol:"$",currency_minor_unit:2,currency_decimal_separator:".",currency_thousand_separator:",",currency_prefix:"$",currency_suffix:"",price:Wa?"4500":"4250",regular_price:Wa?"4500":"4250",sale_price:Wa?"4500":"4250",price_range:null},price_html:"",average_rating:"5",review_count:2,images:[{id:17,src:dr+"previews/hoodie-with-logo.jpg",thumbnail:dr+"previews/hoodie-with-logo.jpg",srcset:"",sizes:"",name:"",alt:""}],categories:[],tags:[],attributes:[],variations:[],has_options:!1,is_purchasable:!0,is_in_stock:!0,is_on_backorder:!1,low_stock_remaining:null,sold_individually:!1,add_to_cart:{text:"",description:"",url:"",minimum:1,maximum:99,multiple_of:1}},{id:5,name:(0,A.__)("Hoodie with Pocket","woocommerce"),parent:0,type:"simple",variation:"",permalink:"https://example.org",sku:"woo-hoodie-with-pocket",short_description:(0,A.__)("Hoodie with Pocket","woocommerce"),description:(0,A.__)("Hoodie with Pocket","woocommerce"),on_sale:!0,prices:{currency_code:"USD",currency_symbol:"$",currency_minor_unit:2,currency_decimal_separator:".",currency_thousand_separator:",",currency_prefix:"$",currency_suffix:"",price:Wa?"3500":"3250",regular_price:Wa?"4500":"4250",sale_price:Wa?"3500":"3250",price_range:null},price_html:"",average_rating:"3.75",review_count:4,images:[{id:17,src:dr+"previews/hoodie-with-pocket.jpg",thumbnail:dr+"previews/hoodie-with-pocket.jpg",srcset:"",sizes:"",name:"",alt:""}],categories:[],tags:[],attributes:[],variations:[],has_options:!1,is_purchasable:!0,is_in_stock:!0,is_on_backorder:!1,low_stock_remaining:null,sold_individually:!1,add_to_cart:{text:"",description:"",url:"",minimum:1,maximum:99,multiple_of:1}},{id:6,name:(0,A.__)("T-Shirt","woocommerce"),parent:0,type:"simple",variation:"",permalink:"https://example.org",sku:"woo-t-shirt",short_description:(0,A.__)("T-Shirt","woocommerce"),description:(0,A.__)("T-Shirt","woocommerce"),on_sale:!1,prices:{currency_code:"USD",currency_symbol:"$",currency_minor_unit:2,currency_decimal_separator:".",currency_thousand_separator:",",currency_prefix:"$",currency_suffix:"",price:Wa?"1800":"1500",regular_price:Wa?"1800":"1500",sale_price:Wa?"1800":"1500",price_range:null},price_html:"",average_rating:"3",review_count:2,images:[{id:17,src:dr+"previews/tshirt.jpg",thumbnail:dr+"previews/tshirt.jpg",srcset:"",sizes:"",name:"",alt:""}],categories:[],tags:[],attributes:[],variations:[],has_options:!1,is_purchasable:!0,is_in_stock:!0,is_on_backorder:!1,low_stock_remaining:null,sold_individually:!1,add_to_cart:{text:"",description:"",url:"",minimum:1,maximum:99,multiple_of:1}}],fees:[{id:"fee",name:(0,A.__)("Fee","woocommerce"),totals:{currency_code:"USD",currency_symbol:"$",currency_minor_unit:2,currency_decimal_separator:".",currency_thousand_separator:",",currency_prefix:"$",currency_suffix:"",total:"100",total_tax:"20"}}],items_count:3,items_weight:0,needs_payment:!0,needs_shipping:(0,Xt.getSetting)("shippingEnabled",!0),has_calculated_shipping:!0,shipping_address:{first_name:"",last_name:"",company:"",address_1:"",address_2:"",city:"",state:"",postcode:"",country:"",phone:""},billing_address:{first_name:"",last_name:"",company:"",address_1:"",address_2:"",city:"",state:"",postcode:"",country:"",email:"",phone:""},totals:{currency_code:"USD",currency_symbol:"$",currency_minor_unit:2,currency_decimal_separator:".",currency_thousand_separator:",",currency_prefix:"$",currency_suffix:"",total_items:"4000",total_items_tax:"800",total_fees:"100",total_fees_tax:"20",total_discount:"0",total_discount_tax:"0",total_shipping:"0",total_shipping_tax:"0",total_tax:"820",total_price:"4920",tax_lines:[{name:(0,A.__)("Sales tax","woocommerce"),rate:"20%",price:"820"}]},errors:[],payment_methods:["cod","bacs","cheque"],payment_requirements:["products"],extensions:{}},Ja=(e,t,r=!1)=>{const{createErrorNotice:a}=(0,v.dispatch)("core/notices"),s=r?Pt.EXPRESS_PAYMENTS:Pt.PAYMENTS;a(`${(0,A.sprintf)(/* translators: %s the id of the payment method being registered (bank transfer, cheque...) */
|
|
(0,A.__)("There was an error registering the payment method with id '%s': ","woocommerce"),e.paymentMethodId)} ${t}`,{context:s,id:`wc-${e.paymentMethodId}-registration-error`})},es=async(e=!1)=>{let t={};const r=e?(0,Xa.getExpressPaymentMethods)():(0,Xa.getPaymentMethods)(),a=e=>{const{name:r}=e;t={...t,[e.name]:{name:r}}},s=e?Object.keys(r):Array.from(new Set([...(0,Xt.getSetting)("paymentMethodSortOrder",[]),...Object.keys(r)])),i=(()=>{let e;if((0,v.select)("core/editor")){const t={cartCoupons:Za.coupons,cartItems:Za.items,crossSellsProducts:Za.cross_sells,cartFees:Za.fees,cartItemsCount:Za.items_count,cartItemsWeight:Za.items_weight,cartNeedsPayment:Za.needs_payment,cartNeedsShipping:Za.needs_shipping,cartItemErrors:O,cartTotals:Za.totals,cartIsLoading:!1,cartErrors:M,billingData:j.cartData.billingAddress,billingAddress:j.cartData.billingAddress,shippingAddress:j.cartData.shippingAddress,extensions:Y,shippingRates:Za.shipping_rates,isLoadingRates:!1,cartHasCalculatedShipping:Za.has_calculated_shipping,paymentRequirements:Za.payment_requirements,receiveCart:()=>{}};e={cart:t,cartTotals:t.cartTotals,cartNeedsShipping:t.cartNeedsShipping,billingData:t.billingAddress,billingAddress:t.billingAddress,shippingAddress:t.shippingAddress,selectedShippingMethods:Ka(t.shippingRates),paymentMethods:Za.payment_methods,paymentRequirements:t.paymentRequirements}}else{const t=(0,v.select)(P),r=t.getCartData(),a=t.getCartErrors(),s=t.getCartTotals(),i=!t.hasFinishedResolution("getCartData"),n=t.isCustomerDataUpdating(),o=Ka(r.shippingRates);e={cart:{cartCoupons:r.coupons,cartItems:r.items,crossSellsProducts:r.crossSells,cartFees:r.fees,cartItemsCount:r.itemsCount,cartItemsWeight:r.itemsWeight,cartNeedsPayment:r.needsPayment,cartNeedsShipping:r.needsShipping,cartItemErrors:r.errors,cartTotals:s,cartIsLoading:i,cartErrors:a,billingData:Ea(r.billingAddress),billingAddress:Ea(r.billingAddress),shippingAddress:Ea(r.shippingAddress),extensions:r.extensions,shippingRates:r.shippingRates,isLoadingRates:n,cartHasCalculatedShipping:r.hasCalculatedShipping,paymentRequirements:r.paymentRequirements,receiveCart:(0,v.dispatch)(P).receiveCart},cartTotals:r.totals,cartNeedsShipping:r.needsShipping,billingData:r.billingAddress,billingAddress:r.billingAddress,shippingAddress:r.shippingAddress,selectedShippingMethods:o,paymentMethods:r.paymentMethods,paymentRequirements:r.paymentRequirements}}return e})(),n=i.paymentMethods,o=!!(0,v.select)("core/editor");for(let t=0;t<s.length;t++){const c=s[t],l=r[c];if(l)try{const t=!(!o&&!e)||n.includes(c),r=!!o||t&&await Promise.resolve(l.canMakePayment(i));if(r){if("object"==typeof r&&r.error)throw new Error(r.error.message);a(l)}}catch(t){(Xt.CURRENT_USER_IS_ADMIN||o)&&Ja(l,t,e)}}const c=Object.keys(t),l=e?(0,v.select)(qt).getAvailableExpressPaymentMethods():(0,v.select)(qt).getAvailablePaymentMethods();if(Object.keys(l).length===c.length&&Object.keys(l).every((e=>c.includes(e))))return!0;const{__internalSetAvailablePaymentMethods:d,__internalSetAvailableExpressPaymentMethods:u}=(0,v.dispatch)(qt);return(e?u:d)(t),!0},ts=async e=>{const t=Object.keys(e),r=Object.keys((0,v.select)(qt).getAvailableExpressPaymentMethods()),a=[...t,...r],s=(0,v.select)(qt).getSavedPaymentMethods(),i=Object.keys(s).flatMap((e=>s[e]))[0]||void 0;if(i){const e=i.tokenId.toString(),t=i.method.gateway,r=`wc-${t}-payment-token`;return void(0,v.dispatch)(qt).__internalSetActivePaymentMethod(t,{token:e,payment_method:t,[r]:e,isSavedToken:!0})}const n=(0,v.select)(qt).getActivePaymentMethod();n&&a.includes(n)||((0,v.dispatch)(qt).__internalSetPaymentIdle(),(0,v.dispatch)(qt).__internalSetActivePaymentMethod(t[0]))},rs=window.wp.deprecated;var as=r.n(rs);const ss=e=>["first_name","last_name","company","address_1","address_2","city","state","postcode","country","phone"].every((t=>Ve(e,t))),is=e=>ss(e)&&Ve(e,"email"),ns=e=>({registry:t})=>{const{createErrorNotice:r,removeNotice:a}=t.dispatch(f.store);e?r(e,{id:"wc-express-payment-error",context:Pt.EXPRESS_PAYMENTS}):a("wc-express-payment-error",Pt.EXPRESS_PAYMENTS)},os=(e,t)=>({dispatch:r,registry:a})=>{const{createErrorNotice:s,removeNotice:i}=a.dispatch("core/notices");return i("wc-payment-error",Pt.PAYMENTS),Qr(e,"payment_setup",{}).then((e=>{let i,n,o,c;e.forEach((e=>{wt(e)&&(i=e),(Ct(e)||It(e))&&(n=e);const{billingAddress:t,billingData:r,shippingAddress:a,shippingData:s}=(null==e?void 0:e.meta)||{};o=t,c=a,r&&(o=r,as()("returning billingData from an onPaymentProcessing observer in WooCommerce Blocks",{version:"9.5.0",alternative:"billingAddress",link:"https://github.com/woocommerce/woocommerce-blocks/pull/6369"})),Ve(s,"address")&&s.address&&(c=s.address,as()("returning shippingData from an onPaymentProcessing observer in WooCommerce Blocks",{version:"9.5.0",alternative:"shippingAddress",link:"https://github.com/woocommerce/woocommerce-blocks/pull/8163"}))}));const{setBillingAddress:l,setShippingAddress:d}=a.dispatch(Kt);if(Xr(i)&&!n){var u;const{paymentMethodData:e}=(null===(u=i)||void 0===u?void 0:u.meta)||{};is(o)&&l(o),ss(c)&&d(c),r.__internalSetPaymentMethodData(He(e)?e:{}),r.__internalSetPaymentReady()}else if(It(n)){var p;const{paymentMethodData:e}=(null===(p=n)||void 0===p?void 0:p.meta)||{};if(Ve(n,"message")&&gr(n.message)&&n.message.length){let e=Pt.PAYMENTS;Ve(n,"messageContext")&&gr(n.messageContext)&&n.messageContext.length&&(e=n.messageContext),s(n.message,{id:"wc-payment-error",isDismissible:!1,context:e})}is(o)&&l(o),r.__internalSetPaymentMethodData(He(e)?e:{}),r.__internalSetPaymentError()}else if(Ct(n)){if(Ve(n,"message")&&gr(n.message)&&n.message.length){let e=Pt.PAYMENTS;Ve(n,"messageContext")&&gr(n.messageContext)&&n.messageContext.length&&(e=n.messageContext),s(n.message,{id:"wc-payment-error",isDismissible:!1,context:e})}r.__internalSetPaymentError(),_=n.validationErrors,He(_)&&Object.entries(_).every((([e,t])=>{return gr(e)&&He(r=t)&&Ve(r,"message")&&Ve(r,"hidden")&&gr(r.message)&&"boolean"==typeof r.hidden;var r}))&&t(n.validationErrors)}else r.__internalSetPaymentReady();var _}))},cs=()=>({type:za.SET_PAYMENT_IDLE}),ls=()=>({type:za.SET_EXPRESS_PAYMENT_STARTED}),ds=()=>({type:za.SET_PAYMENT_PROCESSING}),us=()=>({type:za.SET_PAYMENT_ERROR}),ps=()=>({type:za.SET_PAYMENT_READY}),_s=e=>async({select:t,dispatch:r})=>{const a=t.getAvailablePaymentMethods();e&&await ts(a),r({type:za.SET_PAYMENT_METHODS_INITIALIZED,initialized:e})},ms=e=>({type:za.SET_EXPRESS_PAYMENT_METHODS_INITIALIZED,initialized:e}),hs=e=>({type:za.SET_SHOULD_SAVE_PAYMENT_METHOD,shouldSavePaymentMethod:e}),gs=(e,t={})=>({type:za.SET_ACTIVE_PAYMENT_METHOD,activePaymentMethod:e,paymentMethodData:t}),ys=(e={})=>({type:za.SET_PAYMENT_METHOD_DATA,paymentMethodData:e}),Es=e=>({type:za.SET_PAYMENT_RESULT,data:e}),Ss=e=>async({dispatch:t,select:r})=>{r.getActivePaymentMethod()in e||await ts(e),t({type:za.SET_AVAILABLE_PAYMENT_METHODS,paymentMethods:e})},bs=e=>({type:za.SET_AVAILABLE_EXPRESS_PAYMENT_METHODS,paymentMethods:e}),fs=e=>({type:za.REMOVE_AVAILABLE_PAYMENT_METHOD,name:e}),vs=e=>({type:za.REMOVE_AVAILABLE_EXPRESS_PAYMENT_METHOD,name:e});function Ts(){return async({select:e,dispatch:t})=>{const r=await es(!0),a=await es(!1),{paymentMethodsInitialized:s,expressPaymentMethodsInitialized:i}=e;a&&!s()&&t(_s(!0)),r&&!i()&&t(ms(!0))}}const As={};(0,Xt.getSetting)("globalPaymentMethods")&&(0,Xt.getSetting)("globalPaymentMethods").forEach((e=>{As[e.id]=e.title}));const Ps=e=>(as()("isPaymentPristine",{since:"9.6.0",alternative:"isPaymentIdle",plugin:"WooCommerce Blocks",link:"https://github.com/woocommerce/woocommerce-blocks/pull/8110"}),e.status===Bt.IDLE),Rs=e=>e.status===Bt.IDLE,ws=e=>(as()("isPaymentStarted",{since:"9.6.0",alternative:"isExpressPaymentStarted",plugin:"WooCommerce Blocks",link:"https://github.com/woocommerce/woocommerce-blocks/pull/8110"}),e.status===Bt.EXPRESS_STARTED),Cs=e=>e.status===Bt.EXPRESS_STARTED,Is=e=>e.status===Bt.PROCESSING,ks=e=>e.status===Bt.READY,Ds=e=>(as()("isPaymentSuccess",{since:"9.6.0",alternative:"isPaymentReady",plugin:"WooCommerce Blocks",link:"https://github.com/woocommerce/woocommerce-blocks/pull/8110"}),e.status===Bt.READY),Os=e=>e.status===Bt.ERROR,Ms=e=>(as()("isPaymentFailed",{since:"9.6.0",plugin:"WooCommerce Blocks",link:"https://github.com/woocommerce/woocommerce-blocks/pull/8110"}),e.status===Bt.ERROR),Ns=e=>Object.keys(e.availableExpressPaymentMethods).includes(e.activePaymentMethod),xs=e=>"object"==typeof e.paymentMethodData&&Ve(e.paymentMethodData,"token")?e.paymentMethodData.token+"":"",Ls=e=>e.activePaymentMethod,Ys=e=>e.availablePaymentMethods,Us=e=>e.availableExpressPaymentMethods,js=e=>e.paymentMethodData,Hs=e=>{const{availablePaymentMethods:t,availableExpressPaymentMethods:r,paymentMethodsInitialized:a,expressPaymentMethodsInitialized:s}=e;return a&&s?Object.fromEntries(Object.entries(As).filter((([e])=>!(e in{...t,...r})))):{}},Vs=e=>e.savedPaymentMethods,qs=e=>((e=[],t)=>{if(0===e.length)return{};const r=(0,Xa.getPaymentMethods)(),a=Object.fromEntries(e.map((e=>[e,r[e]]))),s=Object.keys(t),i={};return s.forEach((e=>{const r=t[e].filter((({method:{gateway:e}})=>{var t;return e in a&&(null===(t=a[e].supports)||void 0===t?void 0:t.showSavedCards)}));r.length&&(i[e]=r)})),i})(Object.keys(e.availablePaymentMethods),e.savedPaymentMethods),Bs=e=>e.paymentMethodsInitialized,Fs=e=>e.expressPaymentMethodsInitialized,$s=e=>(as()("getCurrentStatus",{since:"8.9.0",alternative:"isPaymentIdle, isPaymentProcessing, hasPaymentError",plugin:"WooCommerce Blocks",link:"https://github.com/woocommerce/woocommerce-blocks/pull/7666"}),{get isPristine(){return as()("isPristine",{since:"9.6.0",alternative:"isIdle",plugin:"WooCommerce Blocks"}),Rs(e)},isIdle:Rs(e),isStarted:Cs(e),isProcessing:Is(e),get isFinished(){return as()("isFinished",{since:"9.6.0",plugin:"WooCommerce Blocks",link:"https://github.com/woocommerce/woocommerce-blocks/pull/8110"}),Os(e)||ks(e)},hasError:Os(e),get hasFailed(){return as()("hasFailed",{since:"9.6.0",plugin:"WooCommerce Blocks",link:"https://github.com/woocommerce/woocommerce-blocks/pull/8110"}),Os(e)},get isSuccessful(){return as()("isSuccessful",{since:"9.6.0",plugin:"WooCommerce Blocks",link:"https://github.com/woocommerce/woocommerce-blocks/pull/8110"}),ks(e)},isDoingExpressPayment:Ns(e)}),Gs=e=>e.shouldSavePaymentMethod,zs=e=>e.paymentResult,Ks=e=>e,Xs={reducer:(e=Ga,t)=>{let r=e;switch(t.type){case za.SET_PAYMENT_IDLE:r={...e,status:Bt.IDLE};break;case za.SET_EXPRESS_PAYMENT_STARTED:r={...e,status:Bt.EXPRESS_STARTED};break;case za.SET_PAYMENT_PROCESSING:r={...e,status:Bt.PROCESSING};break;case za.SET_PAYMENT_READY:r={...e,status:Bt.READY};break;case za.SET_PAYMENT_ERROR:r={...e,status:Bt.ERROR};break;case za.SET_SHOULD_SAVE_PAYMENT_METHOD:r={...e,shouldSavePaymentMethod:t.shouldSavePaymentMethod};break;case za.SET_PAYMENT_METHOD_DATA:r={...e,paymentMethodData:t.paymentMethodData};break;case za.SET_PAYMENT_RESULT:r={...e,paymentResult:t.data};break;case za.REMOVE_AVAILABLE_PAYMENT_METHOD:const a={...e.availablePaymentMethods};delete a[t.name],r={...e,availablePaymentMethods:{...a}};break;case za.REMOVE_AVAILABLE_EXPRESS_PAYMENT_METHOD:const s={...e.availablePaymentMethods};delete s[t.name],r={...e,availableExpressPaymentMethods:{...s}};break;case za.SET_PAYMENT_METHODS_INITIALIZED:r={...e,paymentMethodsInitialized:t.initialized};break;case za.SET_EXPRESS_PAYMENT_METHODS_INITIALIZED:r={...e,expressPaymentMethodsInitialized:t.initialized};break;case za.SET_AVAILABLE_PAYMENT_METHODS:r={...e,availablePaymentMethods:t.paymentMethods};break;case za.SET_AVAILABLE_EXPRESS_PAYMENT_METHODS:r={...e,availableExpressPaymentMethods:t.paymentMethods};break;case za.SET_ACTIVE_PAYMENT_METHOD:const i="object"==typeof e.paymentMethodData&&Ve(t.paymentMethodData,"token")?t.paymentMethodData.token+"":"";r={...e,activeSavedToken:i,activePaymentMethod:t.activePaymentMethod,paymentMethodData:t.paymentMethodData||e.paymentMethodData};break;default:return r}return r},selectors:u,actions:d,controls:{...T.controls,...je},__experimentalUseThunks:!0},Qs=(0,v.createReduxStore)(qt,Xs);(0,v.register)(Qs);const Ws=qt,Zs="wc/store/query-state",Js=(e,t)=>void 0===e[t]?null:e[t],ei=(e,t,r,a={})=>{let s=Js(e,t);return null===s?a:(s=JSON.parse(s),void 0!==s[r]?s[r]:a)},ti=(e,t,r={})=>{const a=Js(e,t);return null===a?r:JSON.parse(a)},ri="SET_QUERY_KEY_VALUE",ai="SET_QUERY_CONTEXT_VALUE",si=(e,t,r)=>({type:ri,context:e,queryKey:t,value:r}),ii=(e,t)=>({type:ai,context:e,value:t}),ni=(0,v.createReduxStore)(Zs,{reducer:(e={},t)=>{const{type:r,context:a,queryKey:s,value:i}=t,n=Js(e,a);let o;switch(r){case ri:const t=null!==n?JSON.parse(n):{};t[s]=i,o=JSON.stringify(t),n!==o&&(e={...e,[a]:o});break;case ai:o=JSON.stringify(i),n!==o&&(e={...e,[a]:o})}return e},actions:_,selectors:p});(0,v.register)(ni);const oi=Zs,ci=(0,v.createRegistrySelector)((e=>(t,r,a,s=[])=>{const i=e(ja).hasFinishedResolution("getRoutes",[r]);let n="";if((t=t.routes)[r]?t[r][a]||(n=(0,A.sprintf)("There is no route for the given resource name (%s) in the store",a)):n=(0,A.sprintf)("There is no route for the given namespace (%s) in the store",r),""!==n){if(i)throw new Error(n);return""}const o=di(t[r][a],s);if(""===o&&i)throw new Error((0,A.sprintf)("While there is a route for the given namespace (%1$s) and resource name (%2$s), there is no route utilizing the number of ids you included in the select arguments. The available routes are: (%3$s)",r,a,JSON.stringify(t[r][a])));return o})),li=(0,v.createRegistrySelector)((e=>(t,r)=>{const a=e(ja).hasFinishedResolution("getRoutes",[r]),s=t.routes[r];if(!s){if(a)throw new Error((0,A.sprintf)("There is no route for the given namespace (%s) in the store",r));return[]}let i=[];for(const e in s)i=[...i,...Object.keys(s[e])];return i})),di=(e,t=[])=>{const r=(e=Object.entries(e)).find((([,e])=>t.length===e.length)),[a,s]=r||[];return a?0===t.length?a:ui(a,s,t):""},ui=(e,t,r)=>(t.forEach(((t,a)=>{e=e.replace(`{${t}}`,r[a])})),e),pi={RECEIVE_MODEL_ROUTES:"RECEIVE_MODEL_ROUTES"};function _i(e,t=w){return{type:pi.RECEIVE_MODEL_ROUTES,routes:e,namespace:t}}function*mi(e){yield v.controls.resolveSelect(ja,"getRoutes",e)}function*hi(e){const t=yield(0,T.apiFetch)({path:e}),r=t&&t.routes?Object.keys(t.routes):[];yield _i(r,e)}const gi=(0,v.combineReducers)({routes:(e={},t)=>{const{type:r,routes:a,namespace:s}=t;return r===pi.RECEIVE_MODEL_ROUTES&&a.forEach((t=>{const r=((e,t)=>(t=t.replace(`${e}/`,"")).replace(/\/\(\?P\<[a-z_]*\>\[\\*[a-z]\]\+\)/g,""))(s,t);if(r&&r!==s){const a=(e=>{const t=e.match(/\<[a-z_]*\>/g);return Array.isArray(t)&&0!==t.length?t.map((e=>e.replace(/<|>/g,""))):[]})(t),i=((e,t)=>Array.isArray(t)&&0!==t.length?(t.forEach((t=>{const r=`\\(\\?P<${t}>.*?\\)`;e=e.replace(new RegExp(r),`{${t}}`)})),e):e)(t,a);Ca(e,[s,r,i])||(e=Ba(e,[s,r,i],a))}})),e}}),yi=(0,v.createReduxStore)(ja,{reducer:gi,actions:h,controls:T.controls,selectors:m,resolvers:g});(0,v.register)(yi);const Ei=ja;let Si=function(e){return e.REGISTER_CONTAINER="REGISTER_CONTAINER",e.UNREGISTER_CONTAINER="UNREGISTER_CONTAINER",e}({});const bi=e=>({type:Si.REGISTER_CONTAINER,containerContext:e}),fi=e=>({type:Si.UNREGISTER_CONTAINER,containerContext:e}),vi=e=>e.containers,Ti={containers:[]},Ai="wc/store/store-notices",Pi={reducer:(e=Ti,t)=>{switch(t.type){case Si.REGISTER_CONTAINER:return{...e,containers:[...e.containers,t.containerContext]};case Si.UNREGISTER_CONTAINER:const r=e.containers.filter((e=>e!==t.containerContext));return{...e,containers:r}}return e},actions:y,selectors:E},Ri=(0,v.createReduxStore)(Ai,Pi);(0,v.register)(Ri);const wi=Ai,Ci="SET_VALIDATION_ERRORS",Ii="CLEAR_VALIDATION_ERROR",ki="CLEAR_VALIDATION_ERRORS",Di="HIDE_VALIDATION_ERROR",Oi="SHOW_VALIDATION_ERROR",Mi="SHOW_ALL_VALIDATION_ERRORS",Ni=e=>({type:Ci,errors:e}),xi=e=>({type:ki,errors:e}),Li=()=>(as()("clearAllValidationErrors",{version:"9.0.0",alternative:"clearValidationErrors",plugin:"WooCommerce Blocks",link:"https://github.com/woocommerce/woocommerce-blocks/pull/7601",hint:"Calling `clearValidationErrors` with no arguments will clear all validation errors."}),xi()),Yi=e=>({type:Ii,error:e}),Ui=e=>({type:Di,error:e}),ji=e=>({type:Oi,error:e}),Hi=()=>({type:Mi}),Vi=(e,t)=>e[t],qi=(e,t)=>{if(e.hasOwnProperty(t)&&!e[t].hidden)return`validate-error-${t}`},Bi=e=>Object.keys(e).length>0,Fi={reducer:(e={},t)=>{const r={...e};switch(t.type){case Ci:return t.errors&&Object.entries(t.errors).some((([t,r])=>!("string"!=typeof(null==r?void 0:r.message)||e.hasOwnProperty(t)&&vt()(e[t],r))))?{...e,...t.errors}:e;case Ii:return gr(t.error)&&r.hasOwnProperty(t.error)?(delete r[t.error],r):r;case ki:const{errors:a}=t;return void 0===a?{}:Array.isArray(a)?(a.forEach((e=>{r.hasOwnProperty(e)&&delete r[e]})),r):r;case Di:return gr(t.error)&&r.hasOwnProperty(t.error)?(r[t.error].hidden=!0,r):r;case Oi:return gr(t.error)&&r.hasOwnProperty(t.error)?(r[t.error].hidden=!1,r):r;case Mi:return Object.keys(r).forEach((e=>{r[e].hidden&&(r[e].hidden=!1)})),{...r};default:return e}},selectors:b,actions:S},$i=(0,v.createReduxStore)(Lt,Fi);(0,v.register)($i);const Gi=Lt})(),(this.wc=this.wc||{}).wcBlocksData=a})(); |