8 lines
72 KiB
JavaScript
8 lines
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))}
|
||
|
(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;ret
|
||
|
(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
|
||
|
(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,regi
|