import*as e from"@wordpress/interactivity";var t,r,n={d:function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}},o=(t={getElement:function(){return e.getElement},store:function(){return e.store},withSyncEvent:function(){return e.withSyncEvent}},r={},n.d(r,t),r);let c=[];function a(e){return e.classList.contains("a11y-speak-region")||e.classList.contains("a11y-speak-intro-text")||e.querySelector("#a11y-speak-assertive, #a11y-speak-polite, #a11y-speak-intro-text")}const{actions:s}=(0,o.store)("surecart/product-quick-view"),{state:i,actions:l}=(0,o.store)("surecart/checkout"),{__}=wp.i18n,{state:u,actions:p}=(0,o.store)("surecart/cart",{state:{open:!1,get ariaLabel(){return u.label+" "+__("Review your cart.","surecart")},get dialog(){let e=document?.querySelector(".sc-cart-drawer")||null;if(!e){const{ref:t}=(0,o.getElement)();e=t.parentElement.querySelector(".sc-cart-drawer")||t.closest(".sc-cart-drawer")||null}return e}},actions:{open(){u.open=!0,requestAnimationFrame((()=>{u.dialog?.querySelector(".wp-block-surecart-cart-close-button")?.focus()})),u.label=__("Cart opened.","surecart"),l.fetch(),p.processCartViewEvent(i?.checkout),s?.close?.(),function(e){c=[];let t=e;for(;t&&t!==document.body;){const e=t.parentElement;if(!e)break;Array.from(e.children).forEach((e=>{e===t||e.hasAttribute("inert")||a(e)||(e.setAttribute("inert",""),c.push(e))})),t=e}}(document.querySelector(".sc-cart-wrapper"))},processCartViewEvent:function*(e){const{processCartViewEvent:t}=yield import("@surecart/checkout-events");t(i?.checkout)},close:()=>{u.open=!1,u.label=__("Cart closed.","surecart"),c.forEach((e=>{e.removeAttribute("inert")})),c=[]},toggle:(0,o.withSyncEvent)((e=>{e?.key&&" "!==e?.key&&"Enter"!==e?.key||(e?.preventDefault(),u?.open?p.close():p.open())})),closeOverlay:(0,o.withSyncEvent)((e=>{e.target===e.currentTarget&&p.close()})),handleKeydown:(0,o.withSyncEvent)((e=>{u.open&&"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),p.close())}))}});addEventListener("scToggleCart",p.toggle);