geno/wp-content/plugins/woocommerce/packages/woocommerce-blocks/build/mini-cart-component-frontend.js

4 lines
95 KiB
JavaScript
Raw Normal View History

2024-02-01 17:24:18 +05:30
(()=>{var e,t,r={4877:(e,t,r)=>{"use strict";r.d(t,{Z:()=>s});var n=r(9196),o=r(9685),i=r(4184),a=r.n(i),c=(r(5482),r(4705));const s=({className:e,showSpinner:t=!1,children:r,variant:i="contained",...s})=>{const l=a()("wc-block-components-button","wp-element-button",e,i,{"wc-block-components-button--loading":t});return(0,n.createElement)(o.Z,{className:l,...s},t&&(0,n.createElement)(c.Z,null),(0,n.createElement)("span",{className:"wc-block-components-button__text"},r))}},3340:(e,t,r)=>{"use strict";r.d(t,{Z:()=>u});var n=r(4617),o=r(5736),i=r(1478),a=r(2646),c=r(5271);const s=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,o.sprintf)(/* translators: %s Field label. */
(0,o.__)("%s (optional)","woocommerce"),e.label)),e.priority&&((0,i.h)(e.priority)&&(t.index=e.priority),(0,a.H)(e.priority)&&(t.index=parseInt(e.priority,10))),e.hidden&&(t.required=!1),t},l=Object.entries(c.vr).map((([e,t])=>[e,Object.entries(t).map((([e,t])=>[e,s(t)])).reduce(((e,[t,r])=>(e[t]=r,e)),{})])).reduce(((e,[t,r])=>(e[t]=r,e)),{}),u=(e,t,r="")=>{const o=r&&void 0!==l[r]?l[r]:{};return e.map((e=>({key:e,...n.defaultAddressFields[e]||{},...o[e]||{},...t[e]||{}}))).sort(((e,t)=>e.index-t.index))}},5577:(e,t,r)=>{"use strict";r.d(t,{m:()=>o});var n=r(9638);const o=(e,t)=>(r,o=10)=>{const i=n.Nw.addEventCallback(e,r,o);return t(i),()=>{t(n.Nw.removeEventCallback(e,i.id))}}},5017:(e,t,r)=>{"use strict";r.d(t,{P:()=>i});var n=r(6423),o=r(7755);const i=async(e,t,r)=>{const i=[],a=(0,n.Xj)(e,t);for(const e of a)try{const t=await Promise.resolve(e.callback(r));if(!(0,o.X)(t))continue;if(!t.hasOwnProperty("type"))throw new Error("Returned objects from event emitter observers must return an object with a type property");if((0,n.qm)(t)||(0,n.x$)(t))return i.push(t),i;i.push(t)}catch(e){return console.error(e),i.push({type:n.dO.ERROR}),i}return i}},9638:(e,t,r)=>{"use strict";r.d(t,{I6:()=>a,Nw:()=>o});var n=r(5400);const o={addEventCallback:(e,t,r=10)=>({id:Math.floor(Math.random()*Date.now()).toString(),type:n.o.ADD_EVENT_CALLBACK,eventType:e,callback:t,priority:r}),removeEventCallback:(e,t)=>({id:t,type:n.o.REMOVE_EVENT_CALLBACK,eventType:e})},i={},a=(e=i,{type:t,eventType:r,id:o,callback:a,priority:c})=>{const s=e.hasOwnProperty(r)?new Map(e[r]):new Map;switch(t){case n.o.ADD_EVENT_CALLBACK:return s.set(o,{priority:c,callback:a}),{...e,[r]:s};case n.o.REMOVE_EVENT_CALLBACK:return s.delete(o),{...e,[r]:s}}}},5400:(e,t,r)=>{"use strict";r.d(t,{o:()=>n});let n=function(e){return e.ADD_EVENT_CALLBACK="add_event_callback",e.REMOVE_EVENT_CALLBACK="remove_event_callback",e}({})},6423:(e,t,r)=>{"use strict";r.d(t,{Xj:()=>o,dO:()=>i,qm:()=>c,x$:()=>s});var n=r(7884);const o=(e,t)=>e[t]?Array.from(e[t].values()).sort(((e,t)=>e.priority-t.priority)):[];let i=function(e){return e.SUCCESS="success",e.FAIL="failure",e.ERROR="error",e}({});const a=(e,t)=>(0,n.Kn)(e)&&"type"in e&&e.type===t,c=e=>a(e,i.ERROR),s=e=>a(e,i.FAIL)},4055:(e,t,r)=>{"use strict";r.d(t,{b:()=>w});var n=r(2991),o=r.n(n),i=r(9307),a=r(4801),c=r(9818),s=r(2629),l=r(3881),u=r(8832);var d=r(9456);const p=e=>{const t=null==e?void 0:e.detail;t&&t.preserveCartData||(0,c.dispatch)(a.CART_STORE_KEY).invalidateResolutionForStore()},m=e=>{(null!=e&&e.persisted||"back_forward"===(window.performance&&window.performance.getEntriesByType("navigation").length?window.performance.getEntriesByType("navigation")[0].type:""))&&(0,c.dispatch)(a.CART_STORE_KEY).invalidateResolutionForStore()},f=()=>{1===window.wcBlocksStoreCartListeners.count&&window.wcBlocksStoreCartListeners.remove(),window.wcBlocksStoreCartListeners.count--},h={first_name:"",last_name:"",company:"",address_1:"",address_2:"",city:"",state:"",postcode:"",country:"",phone:""},g={...h,email:""},b={total_items:"",total_items_tax:"",total_fees:"",total_fees_tax:"",total_discount:"",total_discount_tax:"",total_shipping:"",total_shipping_tax:"",total_price:"",total_tax:"",tax_lines:a.EMPTY_TAX_LINES,currency_code:"",currency_symbol:"",currency_minor_unit:2,currency_decimal_separator:"",currency_thousand_separator:"",currency_prefix:"",currency_suffix:""},y=e=>Object.fromEntries(Object.entries(e).map((([e,t])=>[e,(0,s.decodeEntities)(t)]))),v={cartCoupons:a.EMPTY_CART_COUPONS,cartItems:a.EMPTY_CART_ITEMS,cartFees:a.EMPTY_CART_FEES,cartItemsCount:0,cartItemsWeight:0,crossSellsProducts:a.EMPTY_CART_CROSS_SELLS,cartNeedsPayment:!0,cartNeedsShipping:!0,cartItemErrors:a.EMPTY_CART_ITEM_ERRORS,cartTotals:b,cartIsLoading:!0,cartErrors:a.EMPTY_CART_ERRORS,billingAddress:g,shippingAddress:h,shippingRates:a.EMPTY_SHIPPING_RATES,isLoadingRates:!1,cartHasCalculatedShipping:!1,paymentMethods:a.EMPTY_PAYMENT_METHODS,paymentRequirements:a.EMPTY_PAYMENT_REQUIREMENTS,receiveCart:()=>{},receiveCartContents:()=>{},extensions:a.EMPTY_EXTENSI
(0,n._n)("%1$d item in cart","%1$d items in cart",Z,"woocommerce"),Z):(0,n.sprintf)(/* translators: %1$d is the number of products in the cart. %2$s is the cart total */
(0,n._n)("%1$d item in cart, total price of %2$s","%1$d items in cart, total price of %2$s",Z,"woocommerce"),Z,(0,B.formatPrice)(W,(0,B.getCurrencyFromPriceResponse)(z)));return(0,e.createElement)(e.Fragment,null,(0,e.createElement)("button",{className:`wc-block-mini-cart__button ${c}`,onClick:()=>{C||(_(!0),S(!1))},"aria-label":q},!m&&(0,e.createElement)("span",{className:"wc-block-mini-cart__amount",style:{color:f.color}},(0,B.formatPrice)(W,(0,B.getCurrencyFromPriceResponse)(z))),""!==V&&0!==W&&!m&&(0,e.createElement)("small",{className:"wc-block-mini-cart__tax-label",style:{color:f.color}},V),(0,e.createElement)(U,{count:Z,icon:l,iconColor:h,productCountColor:g})),(0,e.createElement)(P,{className:v()("wc-block-mini-cart__drawer","is-mobile",{"is-loading":w}),isOpen:C,onClose:()=>{_(!1)},slideIn:!x},(0,e.createElement)("div",{className:"wc-block-mini-cart__template-part",ref:R,dangerouslySetInnerHTML:{__html:s}})))};(()=>{let e=null;if(document.activeElement&&document.activeElement.classList.contains("wc-block-mini-cart__button")&&document.activeElement.parentNode instanceof HTMLElement&&(e=document.activeElement.parentNode),d({selector:".wc-block-mini-cart",Block:ue,getProps:e=>{var t,r;let n="";const o=e.querySelector(".wc-block-mini-cart__button");return o instanceof HTMLButtonElement&&(n=o.classList.toString().replace("wc-block-mini-cart__button","")),{initialCartTotals:e.dataset.cartTotals?JSON.parse(e.dataset.cartTotals):null,initialCartItemsCount:e.dataset.cartItemsCount?parseInt(e.dataset.cartItemsCount,10):0,isInitiallyOpen:"true"===e.dataset.isInitiallyOpen,colorClassNames:n,style:e.dataset.style?JSON.parse(e.dataset.style):{},miniCartIcon:e.dataset.miniCartIcon,addToCartBehaviour:e.dataset.addToCartBehaviour||"none",hasHiddenPrice:e.dataset.hasHiddenPrice,priceColor:e.dataset.priceColor?JSON.parse(e.dataset.priceColor):{},iconColor:e.dataset.iconColor?JSON.parse(e.dataset.iconColor):{},productCountColor:e.dataset.productCountColor?JSON.parse(e.dataset.productCountColor):{},contents:null!==(t=null===(r=e.querySelector(".wc-block-mini-cart__template-part"))||void 0===r?void 0:r.innerHTML)&&void 0!==t?t:""}}}),e instanceof HTMLElement&&!e.dataset.isInitiallyOpen){const t=e.querySelector(".wc-block-mini-cart__button");t instanceof HTMLElement&&t.focus()}})()})()})();