import{r as t,h as i,H as o,a}from"./p-e97fde0a.js";import{a as e,d as s,s as r}from"./p-6c74654a.js";import"./p-03631502.js";import"./p-9dbc54d6.js";import"./p-d3366af3.js";import"./p-401e165e.js";import"./p-830ab1a3.js";import"./p-ec182234.js";import"./p-3f6362a4.js";import"./p-95325ec5.js";import"./p-610295e2.js";const c=":host{display:inline-block;vertical-align:middle;line-height:1}::slotted(*){display:block !important;line-height:1}.cart__button{padding:0 4px;height:100%;display:grid;align-items:center}.cart__content{position:relative}.cart__count{box-sizing:border-box;position:absolute;inset:-12px -16px auto auto;text-align:center;font-size:10px;font-weight:bold;border-radius:var(--sc-cart-icon-counter-border-radius, 9999px);color:var(--sc-cart-icon-counter-color, var(--sc-color-primary-text, var(--sc-color-white)));background:var(--sc-cart-icon-counter-background, var(--sc-color-primary-500));box-shadow:var(--sc-cart-icon-box-shadow, var(--sc-shadow-x-large));padding:2px 6px;line-height:14px;min-width:14px;z-index:1}.cart__icon{font-size:var(--sc-cart-icon-size, 1.1em);cursor:pointer}.cart__icon sc-icon{display:block}";const n=c;const d=class{constructor(i){t(this,i);this.open=null;this.count=0;this.formId=undefined;this.mode="live";this.cartMenuAlwaysShown=true;this.showEmptyCount=false}getItemsCount(){var t,i;const o=(i=(t=r===null||r===void 0?void 0:r.checkout)===null||t===void 0?void 0:t.line_items)===null||i===void 0?void 0:i.data;let a=0;(o||[]).forEach((t=>{a=a+(t===null||t===void 0?void 0:t.quantity)}));return a}componentDidLoad(){this.link=this.el.closest("a");this.link.addEventListener("click",(t=>{t.preventDefault();t.stopImmediatePropagation();e.state.cart={...e.state.cart,open:!e.state.cart.open};return false}));this.handleParentLinkDisplay();s(this.mode,(()=>this.handleParentLinkDisplay()))}handleParentLinkDisplay(){this.link.style.display=!this.cartMenuAlwaysShown&&!this.getItemsCount()?"none":null}render(){return i(o,{key:"53e33ab9374f7a156bad2ae499013b73b694c512",tabindex:0,role:"button","aria-label":wp.i18n.sprintf(wp.i18n.__("Open Cart Menu Icon with %d items.","surecart"),this.getItemsCount()),onKeyDown:t=>{if("Enter"===(t===null||t===void 0?void 0:t.code)||"Space"===(t===null||t===void 0?void 0:t.code)){e.state.cart={...e.state.cart,open:!e.state.cart.open};t.preventDefault()}}},i("div",{key:"266a43d550aa48d941eece28659c80f5b01f8790",class:"cart__button",part:"base"},i("div",{key:"3ac90b3fb306c31bffce964b620d99ab1420d780",class:"cart__content"},(this.showEmptyCount||!!this.getItemsCount())&&i("span",{key:"6d18a4ec44abfd2ec7b9ef82b2b8624720739724",class:"cart__count",part:"count"},this.getItemsCount()),i("div",{key:"21c3a7bc7f8459780e9471c12618241172e78d5a",class:"cart__icon"},i("slot",{key:"2b79d0af8d8bd3054bce60f8e0819830ffdb2a19"})))))}get el(){return a(this)}};d.style=n;export{d as sc_cart_button};
//# sourceMappingURL=p-7de34d07.entry.js.map