1 line
2.1 KiB
JavaScript
1 line
2.1 KiB
JavaScript
"use strict";(self.webpackChunkwebpackWcBlocksStylingJsonp=self.webpackChunkwebpackWcBlocksStylingJsonp||[]).push([[9936],{12854:(e,t,n)=>{n.r(t),n.d(t,{default:()=>h});var c=n(41616),o=n(51609),r=n(70851),a=n(86087),s=n(74845),l=n(40812);const u={bottom:0,left:0,opacity:0,pointerEvents:"none",position:"absolute",right:0,top:0,zIndex:-1};var i=n(15703),b=n(47143),d=n(47594),p=n(71e3),k=n(72379),m=n(68939),f=n(46170);var g=n(59726);const h=(0,c.withFilteredAttributes)(g.A)((({checkoutPageId:e,className:t,buttonLabel:c})=>{const g=(0,i.getSetting)("page-"+e,!1),h=(0,b.useSelect)((e=>e(d.CHECKOUT_STORE_KEY).isCalculating())),[v,C]=(()=>{const[e,t]=(0,a.useState)(""),n=(0,a.useRef)(null),c=(0,a.useRef)(new IntersectionObserver((e=>{e[0].isIntersecting?t("visible"):t(e[0].boundingClientRect.top>0?"below":"above")}),{threshold:1}));return(0,a.useLayoutEffect)((()=>{const e=n.current,t=c.current;return e&&t.observe(e),()=>{t.unobserve(e)}}),[]),[(0,o.createElement)("div",{"aria-hidden":!0,ref:n,style:u}),e]})(),[E,w]=(0,a.useState)(!1);(0,a.useEffect)((()=>{if("function"!=typeof n.g.addEventListener||"function"!=typeof n.g.removeEventListener)return;const e=()=>{w(!1)};return n.g.addEventListener("pageshow",e),()=>{n.g.removeEventListener("pageshow",e)}}),[]);const _=(0,b.useSelect)((e=>e(d.CART_STORE_KEY).getCartData())),y=(0,p.applyCheckoutFilter)({filterName:"proceedToCheckoutButtonLabel",defaultValue:c||f.G,arg:{cart:_}}),S=(0,p.applyCheckoutFilter)({filterName:"proceedToCheckoutButtonLink",defaultValue:g||l.tn,arg:{cart:_}}),{dispatchOnProceedToCheckout:L}=(0,m.e)(),N=(0,o.createElement)(s.A,{className:"wc-block-cart__submit-button",href:S,disabled:h,onClick:e=>{L().then((t=>{t.some(k.CR)?e.preventDefault():w(!0)}))},showSpinner:E},y),R=(0,a.useMemo)((()=>getComputedStyle(document.body).backgroundColor),[]);return(0,o.createElement)("div",{className:(0,r.A)("wc-block-cart__submit",t)},v,(0,o.createElement)("div",{className:"wc-block-cart__submit-container"},N),"below"===C&&(0,o.createElement)("div",{className:"wc-block-cart__submit-container wc-block-cart__submit-container--sticky",style:{backgroundColor:R}},N))}))}}]); |