OwlCyberSecurity - MANAGER
Edit File: product-button.js
(globalThis.webpackChunkwebpackWcBlocksMainJsonp=globalThis.webpackChunkwebpackWcBlocksMainJsonp||[]).push([[7409],{595:(t,e,r)=>{"use strict";r.r(e),r.d(e,{Block:()=>f,default:()=>w});var s=r(6087),o=r(4921),n=r(7723),c=r(7052),a=r(1057),i=r(371),d=r(8537),l=r(8331),u=r(5703),p=r(415),m=r(1616),_=(r(7316),r(2281)),y=r(790);const g=({product:t,isDescendantOfAddToCartWithOptions:e,className:r,style:s})=>{const{id:i,permalink:p,add_to_cart:m,has_options:_,is_purchasable:g,is_in_stock:b}=t,{dispatchStoreEvent:h}=(0,c.y)(),{cartQuantity:f,addingToCart:w,addToCart:T}=(0,a.R)(i),C=Number.isFinite(f)&&f>0,E=!_&&g&&b,S=(0,d.decodeEntities)(m?.description||""),k=(({cartQuantity:t,productCartDetails:e,isDescendantOfAddToCartWithOptions:r})=>Number.isFinite(t)&&t>0?(0,n.sprintf)(/* translators: %s number of products in cart. */ /* translators: %s number of products in cart. */ (0,n._n)("%d in cart","%d in cart",t,"woocommerce"),t):r&&e?.single_text?e?.single_text:e?.text||(0,n.__)("Add to cart","woocommerce"))({cartQuantity:f,productCartDetails:m,isDescendantOfAddToCartWithOptions:e}),v=E?"button":"a",R={};return E?R.onClick=async()=>{await T(),h("cart-add-item",{product:t});const{cartRedirectAfterAdd:e}=(0,u.getSetting)("productsSettings");e&&(window.location.href=l.Vo)}:(R.href=p,R.rel="nofollow",R.onClick=()=>{h("product-view-link",{product:t})}),(0,y.jsx)(v,{...R,"aria-label":S,disabled:w,className:(0,o.A)(r,"wp-block-button__link","wp-element-button","add_to_cart_button","wc-block-components-product-button__button",{loading:w,added:C}),style:s,children:k})},b=({className:t,style:e})=>(0,y.jsx)("button",{className:(0,o.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,n.__)("Add to cart","woocommerce")}),h=({className:t,style:e,blockClientId:r})=>{const{current:c,registerListener:a,unregisterListener:i}=(0,_.A)();(0,s.useEffect)((()=>{if(r)return a(r),()=>{i(r)}}),[r,a,i]);const d="external"===c?.slug?(0,n.__)("Buy product","woocommerce"):(0,n.__)("Add to cart","woocommerce");return(0,y.jsx)("button",{className:(0,o.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,n=(0,i.p)(t),{parentClassName:c}=(0,p.useInnerBlockLayoutContext)(),{isLoading:a,product:d}=(0,p.useProductDataContext)();return(0,y.jsx)("div",{className:(0,o.A)(e,"wp-block-button","wc-block-components-product-button",{[`${c}__product-add-to-cart`]:c,[`align-${r}`]:r}),children:a?(0,y.jsx)(b,{className:n.className,style:n.style}):(0,y.jsx)(y.Fragment,{children:d.id?(0,y.jsx)(g,{product:d,style:n.style,className:n.className,isDescendantOfAddToCartWithOptions:t["woocommerce/isDescendantOfAddToCartWithOptions"]}):(0,y.jsx)(h,{style:n.style,className:n.className,isLoading:a,blockClientId:s})})})},w=(0,m.withProductDataContext)(f)},2e3:(t,e,r)=>{"use strict";r.d(e,{A:()=>a});var s=r(8331),o=r(3993),n=r(7723);const c=Object.entries(s.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,n.sprintf)(/* translators: %s Field label. */ /* translators: %s Field label. */ (0,n.__)("%s (optional)","woocommerce"),t.label)),t.index&&((0,o.isNumber)(t.index)&&(e.index=t.index),(0,o.isString)(t.index)&&(e.index=parseInt(t.index,10))),t.hidden&&(e.required=!1),e})(r),t)),{}),t)),{}),a=(t,e,r="")=>{const s=r&&void 0!==c[r]?c[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))}},6037:(t,e,r)=>{"use strict";r.d(e,{U:()=>u});var s=r(6087),o=r(7594),n=r(7143),c=r(1174),a=r(3757);const i=t=>{const e=t?.detail;e&&e.preserveCartData||(0,n.dispatch)(o.cartStore).invalidateResolutionForStore()},d=t=>{(t?.persisted||"back_forward"===(0,c.F)())&&(0,n.dispatch)(o.cartStore).invalidateResolutionForStore()},l=()=>{1===window.wcBlocksStoreCartListeners.count&&window.wcBlocksStoreCartListeners.remove(),window.wcBlocksStoreCartListeners.count--},u=()=>{(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",i),document.body.addEventListener("wc-blocks_removed_from_cart",i),window.addEventListener("pageshow",d);const t=(0,a.f2)("added_to_cart","wc-blocks_added_to_cart"),e=(0,a.f2)("removed_from_cart","wc-blocks_removed_from_cart");window.wcBlocksStoreCartListeners.count=1,window.wcBlocksStoreCartListeners.remove=()=>{document.body.removeEventListener("wc-blocks_added_to_cart",i),document.body.removeEventListener("wc-blocks_removed_from_cart",i),window.removeEventListener("pageshow",d),t(),e()}})(),l)),[])}},5460:(t,e,r)=>{"use strict";r.d(e,{V:()=>g});var s=r(1824),o=r.n(s),n=r(6087),c=r(7594),a=r(7143),i=r(8537),d=r(4982),l=r(6037);const u={first_name:"",last_name:"",company:"",address_1:"",address_2:"",city:"",state:"",postcode:"",country:"",phone:""},p={...u,email:""},m={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:c.EMPTY_TAX_LINES,currency_code:"",currency_symbol:"",currency_minor_unit:2,currency_decimal_separator:"",currency_thousand_separator:"",currency_prefix:"",currency_suffix:""},_=t=>Object.fromEntries(Object.entries(t).map((([t,e])=>[t,(0,i.decodeEntities)(e)]))),y={cartCoupons:c.EMPTY_CART_COUPONS,cartItems:c.EMPTY_CART_ITEMS,cartFees:c.EMPTY_CART_FEES,cartItemsCount:0,cartItemsWeight:0,crossSellsProducts:c.EMPTY_CART_CROSS_SELLS,cartNeedsPayment:!0,cartNeedsShipping:!0,cartItemErrors:c.EMPTY_CART_ITEM_ERRORS,cartTotals:m,cartIsLoading:!0,cartErrors:c.EMPTY_CART_ERRORS,billingData:p,billingAddress:p,shippingAddress:u,shippingRates:c.EMPTY_SHIPPING_RATES,isLoadingRates:!1,cartHasCalculatedShipping:!1,paymentMethods:c.EMPTY_PAYMENT_METHODS,paymentRequirements:c.EMPTY_PAYMENT_REQUIREMENTS,receiveCart:()=>{},receiveCartContents:()=>{},extensions:c.EMPTY_EXTENSIONS},g=(t={shouldSelect:!0})=>{const{shouldSelect:e}=t,r=(0,n.useRef)(),s=(0,n.useRef)(p),m=(0,n.useRef)(u);(0,l.U)();const{receiveCart:g,receiveCartContents:b}=(0,a.useDispatch)(c.cartStore),{cartData:h,cartErrors:f,cartTotals:w,cartIsLoading:T,isLoadingRates:C}=(0,a.useSelect)((t=>{const e=t(c.cartStore);return{cartData:e.getCartData(),cartErrors:e.getCartErrors(),cartTotals:e.getCartTotals(),cartIsLoading:!e.hasFinishedResolution("getCartData"),isLoadingRates:e.isAddressFieldsForShippingRatesUpdating()}}),[]);if(!e)return y;const E=(0,d.TU)(_(h.billingAddress));o()(s.current,E)||(s.current=E);const S=s.current,k=h.needsShipping?(0,d.TU)(_(h.shippingAddress)):S;o()(m.current,k)||(m.current=k);const v=m.current,R={cartCoupons:h.coupons.length>0?h.coupons.map((t=>({...t,label:(0,i.decodeEntities)(t.code)}))):c.EMPTY_CART_COUPONS,cartItems:h.items,crossSellsProducts:h.crossSells,cartFees:h.fees.length>0?h.fees.map((t=>_(t))):c.EMPTY_CART_FEES,cartItemsCount:h.itemsCount,cartItemsWeight:h.itemsWeight,cartNeedsPayment:h.needsPayment,cartNeedsShipping:h.needsShipping,cartItemErrors:h.errors,cartTotals:w,cartIsLoading:T,cartErrors:f,billingData:S,billingAddress:S,shippingAddress:v,extensions:h.extensions,shippingRates:h.shippingRates,isLoadingRates:C,cartHasCalculatedShipping:h.hasCalculatedShipping,paymentRequirements:h.paymentRequirements,paymentMethods:h.paymentMethods,receiveCart:g,receiveCartContents:b};return r.current&&o()(r.current,R)||(r.current=R),r.current}},1057:(t,e,r)=>{"use strict";r.d(e,{R:()=>d});var s=r(6087),o=r(7143),n=r(7594),c=r(8537),a=r(5460);const i=(t,e)=>{const r=t.find((({id:t})=>t===e));return r?r.quantity:0},d=t=>{const{addItemToCart:e}=(0,o.useDispatch)(n.cartStore),{cartItems:r,cartIsLoading:d}=(0,a.V)(),{createErrorNotice:l,removeNotice:u}=(0,o.useDispatch)("core/notices"),[p,m]=(0,s.useState)(!1),_=(0,s.useRef)(i(r,t));return(0,s.useEffect)((()=>{const e=i(r,t);e!==_.current&&(_.current=e)}),[r,t]),{cartQuantity:Number.isFinite(_.current)?_.current:0,addingToCart:p,cartIsLoading:d,addToCart:(r=1)=>(m(!0),e(t,r).then((()=>{u("add-to-cart")})).catch((t=>{l((0,c.decodeEntities)(t.message),{id:"add-to-cart",context:"wc/all-products",isDismissible:!0})})).finally((()=>{m(!1)})))}}},7052:(t,e,r)=>{"use strict";r.d(e,{y:()=>c});var s=r(2619),o=r(7143),n=r(6087);const c=()=>({dispatchStoreEvent:(0,n.useCallback)(((t,e={})=>{try{(0,s.doAction)(`experimental__woocommerce_blocks-${t}`,e)}catch(t){console.error(t)}}),[]),dispatchCheckoutEvent:(0,n.useCallback)(((t,e={})=>{try{(0,s.doAction)(`experimental__woocommerce_blocks-checkout-${t}`,{...e,storeCart:(0,o.select)("wc/store/cart").getCartData()})}catch(t){console.error(t)}}),[])})},371:(t,e,r)=>{"use strict";r.d(e,{p:()=>a});var s=r(4921),o=r(3993),n=r(219),c=r(17);const a=t=>{const e=(t=>{const e=(0,o.isObject)(t)?t:{style:{}};let r=e.style;return(0,o.isString)(r)&&(r=JSON.parse(r)||{}),(0,o.isObject)(r)||(r={}),{...e,style:r}})(t),r=(0,c.BK)(e),a=(0,c.aR)(e),i=(0,c.fo)(e),d=(0,n.x)(e);return{className:(0,s.A)(d.className,r.className,a.className,i.className),style:{...d.style,...r.style,...a.style,...i.style}}}},219:(t,e,r)=>{"use strict";r.d(e,{x:()=>o});var s=r(3993);const o=t=>{const e=(0,s.isObject)(t.style.typography)?t.style.typography:{},r=(0,s.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}}}},4982:(t,e,r)=>{"use strict";r.d(e,{TU:()=>c});var s=r(2e3),o=r(8331),n=r(5703);r(3993),r(8537);const c=t=>{const e=(0,s.A)(o.Hw,n.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}},17:(t,e,r)=>{"use strict";r.d(e,{BK:()=>d,aR:()=>l,fo:()=>u});var s=r(4921),o=r(7356),n=r(9786),c=r(3993);function a(t={}){const e={};return(0,n.getCSSRules)(t,{selector:""}).forEach((t=>{e[t.key]=t.value})),e}function i(t,e){return t&&e?`has-${(0,o.c)(e)}-${t}`:""}function d(t){const{backgroundColor:e,textColor:r,gradient:o,style:n}=t,d=i("background-color",e),l=i("color",r),u=function(t){if(t)return`has-${t}-gradient-background`}(o),p=u||n?.color?.gradient;return{className:(0,s.A)(l,u,{[d]:!p&&!!d,"has-text-color":r||n?.color?.text,"has-background":e||n?.color?.background||o||n?.color?.gradient,"has-link-color":(0,c.isObject)(n?.elements?.link)?n?.elements?.link?.color:void 0}),style:a({color:n?.color||{}})}}function l(t){const e=t.style?.border||{};return{className:function(t){const{borderColor:e,style:r}=t,o=e?i("border-color",e):"";return(0,s.A)({"has-border-color":!!e||!!r?.border?.color,[o]:!!o})}(t),style:a({border:e})}}function u(t){return{className:void 0,style:a({spacing:t.style?.spacing||{}})}}},1174:(t,e,r)=>{"use strict";r.d(e,{F:()=>s});const s=()=>window.performance&&window.performance.getEntriesByType("navigation").length?window.performance.getEntriesByType("navigation")[0].type:""},3757:(t,e,r)=>{"use strict";r.d(e,{f2:()=>o});const s=window.CustomEvent||null,o=(t,e,r=!1,o=!1)=>{if("function"!=typeof jQuery)return()=>{};const n=()=>{((t,{bubbles:e=!1,cancelable:r=!1,element:o,detail:n={}})=>{if(!s)return;o||(o=document.body);const c=new s(t,{bubbles:e,cancelable:r,detail:n});o.dispatchEvent(c)})(e,{bubbles:r,cancelable:o})};return jQuery(document).on(t,n),()=>jQuery(document).off(t,n)}},2266:(t,e,r)=>{"use strict";r.d(e,{EF:()=>s,Ie:()=>c,UI:()=>n,ht:()=>a,j9:()=>o});const s="woocommerce/product-type-template-state",o="SWITCH_PRODUCT_TYPE",n="SET_PRODUCT_TYPES",c="REGISTER_LISTENER",a="UNREGISTER_LISTENER"},8207:(t,e,r)=>{"use strict";r.d(e,{M:()=>i});var s=r(7143),o=r(2266);const n=(0,r(7254).c)(),c={productTypes:{list:n,current:n[0]?.slug},listeners:[]},a={switchProductType:t=>({type:o.j9,current:t}),setProductTypes:t=>({type:o.UI,productTypes:t}),registerListener:t=>({type:o.Ie,listener:t}),unregisterListener:t=>({type:o.ht,listener:t})},i=(0,s.createReduxStore)(o.EF,{reducer:(t=c,e)=>{switch(e.type){case o.UI:return{...t,productTypes:{...t.productTypes,list:e.productTypes||[]}};case o.j9:return{...t,productTypes:{...t.productTypes,current:e.current}};case o.Ie:return{...t,listeners:[...t.listeners,e.listener||""]};case o.ht:return{...t,listeners:t.listeners.filter((t=>t!==e.listener))};default:return t}},actions:a,selectors:{getProductTypes:t=>t.productTypes.list,getCurrentProductType:t=>t.productTypes.list.find((e=>e.slug===t.productTypes.current)),getRegisteredListeners:t=>t.listeners}});(0,s.select)(o.EF)||(0,s.register)(i)},2281:(t,e,r)=>{"use strict";r.d(e,{A:()=>n});var s=r(7143),o=r(8207);function n(){const{productTypes:t,current:e,registeredListeners:r}=(0,s.useSelect)((t=>{const{getProductTypes:e,getCurrentProductType:r,getRegisteredListeners:s}=t(o.M);return{productTypes:e(),current:r(),registeredListeners:s()}}),[]),{switchProductType:n,registerListener:c,unregisterListener:a}=(0,s.useDispatch)(o.M);return{productTypes:t,current:e,set:n,registeredListeners:r,registerListener:c,unregisterListener:a}}},7254:(t,e,r)=>{"use strict";r.d(e,{c:()=>o});const s=(0,r(5703).getSetting)("productTypes",{});function o(){return Object.keys(s).map((t=>({slug:t,label:s[t]})))}},7316:()=>{}}]);