whoami7 - Manager
:
/
home
/
ezdajrnh
/
www
/
wp-content
/
plugins
/
woocommerce
/
assets
/
client
/
blocks
/
Upload File:
files >> //home/ezdajrnh/www/wp-content/plugins/woocommerce/assets/client/blocks/product-button-frontend.js
(globalThis.webpackChunkwebpackWcBlocksFrontendJsonp=globalThis.webpackChunkwebpackWcBlocksFrontendJsonp||[]).push([[409],{3867:(t,e,r)=>{"use strict";r.r(e),r.d(e,{Block:()=>F,default:()=>Y});var s=r(6087),n=r(4921),o=r(7723),c=r(1509),a=r(7143),i=r(7594),d=r(8537),l=r(1824),u=r.n(l),p=r(8331),m=r(3993);const _=Object.entries(p.iI).reduce(((t,[e,r])=>(t[e]=Object.entries(r).reduce(((t,[e,r])=>(t[e]=(t=>{const e={};return void 0!==t.label&&(e.label=t.label),void 0!==t.required&&(e.required=t.required),void 0!==t.hidden&&(e.hidden=t.hidden),void 0===t.label||t.optionalLabel||(e.optionalLabel=(0,o.sprintf)(/* translators: %s Field label. */ /* translators: %s Field label. */ (0,o.__)("%s (optional)","woocommerce"),t.label)),void 0!==t.optionalLabel&&(e.optionalLabel=t.optionalLabel),t.index&&((0,m.isNumber)(t.index)&&(e.index=t.index),(0,m.isString)(t.index)&&(e.index=parseInt(t.index,10))),t.hidden&&(e.required=!1),e})(r),t)),{}),t)),{});var g=r(5703);const b=window.CustomEvent||null,y=(t,e,r=!1,s=!1)=>{if("function"!=typeof jQuery)return()=>{};const n=()=>{((t,{bubbles:e=!1,cancelable:r=!1,element:s,detail:n={}})=>{if(!b)return;s||(s=document.body);const o=new b(t,{bubbles:e,cancelable:r,detail:n});s.dispatchEvent(o)})(e,{bubbles:r,cancelable:s})};return jQuery(document).on(t,n),()=>jQuery(document).off(t,n)},h=t=>{const e=t?.detail;e&&e.preserveCartData||(0,a.dispatch)(i.cartStore).invalidateResolutionForStore()},w=t=>{(t?.persisted||"back_forward"===(window.performance&&window.performance.getEntriesByType("navigation").length?window.performance.getEntriesByType("navigation")[0].type:""))&&(0,a.dispatch)(i.cartStore).invalidateResolutionForStore()},T=()=>{1===window.wcBlocksStoreCartListeners.count&&window.wcBlocksStoreCartListeners.remove(),window.wcBlocksStoreCartListeners.count--},f={first_name:"",last_name:"",company:"",address_1:"",address_2:"",city:"",state:"",postcode:"",country:"",phone:""},C={...f,email:""},S={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:i.EMPTY_TAX_LINES,currency_code:"",currency_symbol:"",currency_minor_unit:2,currency_decimal_separator:"",currency_thousand_separator:"",currency_prefix:"",currency_suffix:""},E=t=>Object.fromEntries(Object.entries(t).map((([t,e])=>[t,(0,d.decodeEntities)(e)]))),k=(t,e)=>{const r=(t=>{const e=((t,e,r="")=>{const s=r&&void 0!==_[r]?_[r]:{};return t.map((t=>({key:t,...e&&t in e?e[t]:{},...s&&t in s?s[t]:{}}))).sort(((t,e)=>t.index-e.index))})(p.Hw,g.defaultFields,t.country),r=Object.assign({},t);return e.forEach((({key:e,hidden:s})=>{!0===s&&((t,e)=>t in e)(e,t)&&(r[e]="")})),r})(E(t));return u()(e.current,r)||(e.current=r),e.current},x={billingAddress:C,billingData:C,cartCoupons:i.EMPTY_CART_COUPONS,cartErrors:i.EMPTY_CART_ERRORS,cartFees:i.EMPTY_CART_FEES,cartHasCalculatedShipping:!1,cartIsLoading:!0,cartItemErrors:i.EMPTY_CART_ITEM_ERRORS,cartItems:i.EMPTY_CART_ITEMS,cartItemsCount:0,cartItemsWeight:0,cartNeedsPayment:!0,cartNeedsShipping:!0,cartTotals:S,crossSellsProducts:i.EMPTY_CART_CROSS_SELLS,extensions:i.EMPTY_EXTENSIONS,hasPendingItemsOperations:!1,isLoadingRates:!1,paymentMethods:i.EMPTY_PAYMENT_METHODS,paymentRequirements:i.EMPTY_PAYMENT_REQUIREMENTS,receiveCart:()=>{},receiveCartContents:()=>{},shippingAddress:f,shippingRates:i.EMPTY_SHIPPING_RATES},L=(t={shouldSelect:!0})=>{const{shouldSelect:e}=t,r=(0,s.useRef)(),n=(0,s.useRef)(C),o=(0,s.useRef)(f);(0,s.useEffect)((()=>((()=>{if(window.wcBlocksStoreCartListeners||(window.wcBlocksStoreCartListeners={count:0,remove:()=>{}}),window.wcBlocksStoreCartListeners?.count>0)return void window.wcBlocksStoreCartListeners.count++;document.body.addEventListener("wc-blocks_added_to_cart",h),document.body.addEventListener("wc-blocks_removed_from_cart",h),window.addEventListener("pageshow",w);const t=y("added_to_cart","wc-blocks_added_to_cart"),e=y("removed_from_cart","wc-blocks_removed_from_cart");window.wcBlocksStoreCartListeners.count=1,window.wcBlocksStoreCartListeners.remove=()=>{document.body.removeEventListener("wc-blocks_added_to_cart",h),document.body.removeEventListener("wc-blocks_removed_from_cart",h),window.removeEventListener("pageshow",w),t(),e()}})(),T)),[]);const{receiveCart:c,receiveCartContents:l}=(0,a.useDispatch)(i.cartStore),{cartData:p,cartErrors:m,cartTotals:_,cartIsLoading:g,isLoadingRates:b,hasPendingItemsOperations:S}=(0,a.useSelect)((t=>{const e=t(i.cartStore),r=!e.hasFinishedResolution("getCartData",[]);return{cartData:e.getCartData(),cartErrors:e.getCartErrors(),cartTotals:e.getCartTotals(),cartIsLoading:r,isLoadingRates:e.isAddressFieldsForShippingRatesUpdating(),hasPendingItemsOperations:e.hasPendingItemsOperations()}}),[]);if(!e)return x;const L=k(p.billingAddress,n),v=p.needsShipping?k(p.shippingAddress,o):L,A={billingAddress:L,billingData:L,cartCoupons:(O=p.coupons,O.length>0?O.map((t=>({...t,label:(0,d.decodeEntities)(t.code)}))):i.EMPTY_CART_COUPONS),cartErrors:m,cartFees:(N=p.fees,N.length>0?N.map((t=>E(t))):i.EMPTY_CART_FEES),cartHasCalculatedShipping:p.hasCalculatedShipping,cartIsLoading:g,cartItemErrors:p.errors,cartItems:p.items,cartItemsCount:p.itemsCount,cartItemsWeight:p.itemsWeight,cartNeedsPayment:p.needsPayment,cartNeedsShipping:p.needsShipping,cartTotals:_,crossSellsProducts:p.crossSells,extensions:p.extensions,hasPendingItemsOperations:S,isLoadingRates:b,paymentMethods:p.paymentMethods,paymentRequirements:p.paymentRequirements,receiveCart:c,receiveCartContents:l,shippingAddress:v,shippingRates:(R=p.shippingRates,R.length>0?R.map((t=>({...t,shipping_rates:t.shipping_rates.length>0?t.shipping_rates.map((t=>E(t))):[]}))):[])};var R,N,O;return r.current&&u()(r.current,A)||(r.current=A),r.current},v=(t,e)=>{const r=t.find((({id:t})=>t===e));return r?r.quantity:0};var A=r(41),R=r(2796),N=r(1616),O=(r(7316),r(4179)),P=r(790);const I=({product:t,isDescendantOfAddToCartWithOptions:e})=>{const r="external"===t.type,s=r?t.button_text:t.add_to_cart?.single_text,c=e?s:t.add_to_cart?.text;return(0,P.jsx)("button",{disabled:!1,className:(0,n.A)("wp-block-button__link","wp-element-button","add_to_cart_button","wc-block-components-product-button__button"),style:{},children:r?t.button_text:c||(0,o.__)("Add to cart","woocommerce")})},D=({product:t,isDescendantOfAddToCartWithOptions:e,className:r,style:l})=>{const{id:u,permalink:m,add_to_cart:_,has_options:b,is_purchasable:y,is_in_stock:h}=t,{dispatchStoreEvent:w}=(0,c.y)(),{cartQuantity:T,addingToCart:f,addToCart:C}=(t=>{const{addItemToCart:e}=(0,a.useDispatch)(i.cartStore),{cartItems:r,cartIsLoading:n}=L(),{createErrorNotice:o,removeNotice:c}=(0,a.useDispatch)("core/notices"),[l,u]=(0,s.useState)(!1),p=(0,s.useRef)(v(r,t));return(0,s.useEffect)((()=>{const e=v(r,t);e!==p.current&&(p.current=e)}),[r,t]),{cartQuantity:Number.isFinite(p.current)?p.current:0,addingToCart:l,cartIsLoading:n,addToCart:(r=1)=>(u(!0),e(t,r).then((()=>{c("add-to-cart")})).catch((t=>{o((0,d.decodeEntities)(t.message),{id:"add-to-cart",context:"wc/all-products",isDismissible:!0})})).finally((()=>{u(!1)})))}})(u),S=Number.isFinite(T)&&T>0,E=!b&&y&&h,k=(0,d.decodeEntities)(_?.description||""),x=(({cartQuantity:t,productCartDetails:e,isDescendantOfAddToCartWithOptions:r})=>Number.isFinite(t)&&t>0?(0,o.sprintf)(/* translators: %s number of products in cart. */ /* translators: %s number of products in cart. */ (0,o._n)("%d in cart","%d in cart",t,"woocommerce"),t):r&&e?.single_text?e?.single_text:e?.text||(0,o.__)("Add to cart","woocommerce"))({cartQuantity:T,productCartDetails:_,isDescendantOfAddToCartWithOptions:e}),A=E?"button":"a",R={};return E?R.onClick=async()=>{await C(),w("cart-add-item",{product:t});const{cartRedirectAfterAdd:e}=(0,g.getSetting)("productsSettings");e&&(window.location.href=p.Vo)}:(R.href=m,R.rel="nofollow",R.onClick=()=>{w("product-view-link",{product:t})}),(0,P.jsx)(A,{...R,"aria-label":k,disabled:f,className:(0,n.A)(r,"wp-block-button__link","wp-element-button","add_to_cart_button","wc-block-components-product-button__button",{loading:f,added:S}),style:l,children:x})},j=({className:t,style:e})=>(0,P.jsx)("button",{className:(0,n.A)("wp-block-button__link","wp-element-button","add_to_cart_button","wc-block-components-product-button__button","wc-block-components-product-button__button--placeholder",t),style:e,disabled:!0,children:(0,o.__)("Add to cart","woocommerce")}),M=({className:t,style:e,blockClientId:r})=>{const{current:c,registerListener:a,unregisterListener:i}=(0,O.A)();(0,s.useEffect)((()=>{if(r)return a(r),()=>{i(r)}}),[r,a,i]);const d="external"===c?.slug?(0,o.__)("Buy product","woocommerce"):(0,o.__)("Add to cart","woocommerce");return(0,P.jsx)("button",{className:(0,n.A)("wp-block-button__link","wp-element-button","add_to_cart_button","wc-block-components-product-button__button",t),style:e,disabled:!0,children:d})},F=t=>{const{className:e,textAlign:r,blockClientId:s}=t,o=(0,A.p)(t),{parentClassName:c}=(0,R.useInnerBlockLayoutContext)(),{product:a,isLoading:i}=(0,R.useProductDataContext)({product:t.product,isAdmin:t.isAdmin}),d=a?.id&&t.isAdmin&&(0,p.Sc)();return(0,P.jsx)("div",{className:(0,n.A)(e,"wp-block-button","wc-block-components-product-button",{[`${c}__product-add-to-cart`]:c,[`align-${r}`]:r}),children:i?(0,P.jsx)(j,{className:o.className,style:o.style}):(0,P.jsxs)(P.Fragment,{children:[d&&(0,P.jsx)(I,{product:a,isDescendantOfAddToCartWithOptions:t["woocommerce/isDescendantOfAddToCartWithOptions"]}),!d&&(a&&a?.id?(0,P.jsx)(D,{product:a,style:o.style,className:o.className,isAdmin:t.isAdmin,isDescendantOfAddToCartWithOptions:t["woocommerce/isDescendantOfAddToCartWithOptions"],productEntity:t.product}):(0,P.jsx)(M,{style:o.style,className:o.className,isLoading:null!=i&&i,blockClientId:s}))]})})},Y=(0,N.withProductDataContext)(F)},41:(t,e,r)=>{"use strict";r.d(e,{p:()=>d});var s=r(4921),n=r(3993),o=r(7356),c=r(9786);function a(t={}){const e={};return(0,c.getCSSRules)(t,{selector:""}).forEach((t=>{e[t.key]=t.value})),e}function i(t,e){return t&&e?`has-${(0,o.c)(e)}-${t}`:""}const d=t=>{const e=(t=>{const e=(0,n.isObject)(t)?t:{style:{}};let r=e.style;return(0,n.isString)(r)&&(r=JSON.parse(r)||{}),(0,n.isObject)(r)||(r={}),{...e,style:r}})(t),r=function(t){const{backgroundColor:e,textColor:r,gradient:o,style:c}=t,d=i("background-color",e),l=i("color",r),u=function(t){if(t)return`has-${t}-gradient-background`}(o),p=u||c?.color?.gradient;return{className:(0,s.A)(l,u,{[d]:!p&&!!d,"has-text-color":r||c?.color?.text,"has-background":e||c?.color?.background||o||c?.color?.gradient,"has-link-color":(0,n.isObject)(c?.elements?.link)?c?.elements?.link?.color:void 0}),style:a({color:c?.color||{}})}}(e),o=function(t){const e=t.style?.border||{};return{className:function(t){const{borderColor:e,style:r}=t,n=e?i("border-color",e):"";return(0,s.A)({"has-border-color":!!e||!!r?.border?.color,[n]:!!n})}(t),style:a({border:e})}}(e),c=function(t){return{className:void 0,style:a({spacing:t.style?.spacing||{}})}}(e),d=(t=>{const e=(0,n.isObject)(t.style.typography)?t.style.typography:{},r=(0,n.isString)(e.fontFamily)?e.fontFamily:"";return{className:t.fontFamily?`has-${t.fontFamily}-font-family`:r,style:{fontSize:t.fontSize?`var(--wp--preset--font-size--${t.fontSize})`:e.fontSize,fontStyle:e.fontStyle,fontWeight:e.fontWeight,letterSpacing:e.letterSpacing,lineHeight:e.lineHeight,textDecoration:e.textDecoration,textTransform:e.textTransform}}})(e);return{className:(0,s.A)(d.className,r.className,o.className,c.className),style:{...d.style,...r.style,...o.style,...c.style}}}},4179:(t,e,r)=>{"use strict";r.d(e,{A:()=>_});var s=r(7143);const n="woocommerce/product-type-template-state",o="SWITCH_PRODUCT_TYPE",c="SET_PRODUCT_TYPES",a="REGISTER_LISTENER",i="UNREGISTER_LISTENER",d=(0,r(5703).getSetting)("productTypes",{}),l=Object.keys(d).map((t=>({slug:t,label:d[t]}))),u={productTypes:{list:l,current:l[0]?.slug},listeners:[]},p={switchProductType:t=>({type:o,current:t}),setProductTypes:t=>({type:c,productTypes:t}),registerListener:t=>({type:a,listener:t}),unregisterListener:t=>({type:i,listener:t})},m=(0,s.createReduxStore)(n,{reducer:(t=u,e)=>{switch(e.type){case c:return{...t,productTypes:{...t.productTypes,list:e.productTypes||[]}};case o:return{...t,productTypes:{...t.productTypes,current:e.current}};case a:return{...t,listeners:[...t.listeners,e.listener||""]};case i:return{...t,listeners:t.listeners.filter((t=>t!==e.listener))};default:return t}},actions:p,selectors:{getProductTypes:t=>t.productTypes.list,getCurrentProductType:t=>t.productTypes.list.find((e=>e.slug===t.productTypes.current)),getRegisteredListeners:t=>t.listeners}});function _(){const{productTypes:t,current:e,registeredListeners:r}=(0,s.useSelect)((t=>{const{getProductTypes:e,getCurrentProductType:r,getRegisteredListeners:s}=t(m);return{productTypes:e(),current:r(),registeredListeners:s()}}),[]),{switchProductType:n,registerListener:o,unregisterListener:c}=(0,s.useDispatch)(m);return{productTypes:t,current:e,set:n,registeredListeners:r,registerListener:o,unregisterListener:c}}(0,s.select)(n)||(0,s.register)(m)},7316:()=>{}}]);
Copyright ©2021 || Defacer Indonesia