import{r as t,h as i,H as a,a as o}from"./p-9add63ef.js";import{a as c,d as e,s}from"./p-b28405ea.js";import"./p-2b28ea49.js";import"./p-dd24e53c.js";import"./p-d3366af3.js";import"./p-401e165e.js";import"./p-830ab1a3.js";import"./p-ec182234.js";import"./p-3f6362a4.js";import"./p-31faf2b8.js";import"./p-610295e2.js";const r=":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=r;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 a=(i=(t=s===null||s===void 0?void 0:s.checkout)===null||t===void 0?void 0:t.line_items)===null||i===void 0?void 0:i.data;let o=0;(a||[]).forEach((t=>{o=o+(t===null||t===void 0?void 0:t.quantity)}));return o}componentDidLoad(){this.link=this.el.closest("a");this.link.addEventListener("click",(t=>{t.preventDefault();t.stopImmediatePropagation();c.state.cart={...c.state.cart,open:!c.state.cart.open};return false}));this.handleParentLinkDisplay();e(this.mode,(()=>this.handleParentLinkDisplay()))}handleParentLinkDisplay(){this.link.style.display=!this.cartMenuAlwaysShown&&!this.getItemsCount()?"none":null}render(){return i(a,{key:"4e610fc9c65a7693e1db849c0f1faca166d23e4f",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)){c.state.cart={...c.state.cart,open:!c.state.cart.open};t.preventDefault()}}},i("div",{key:"bbb7bab70b0a9b5fc91632425c868f4aba957aff",class:"cart__button",part:"base"},i("div",{key:"80640d42812e56ae2599c95de82c087a76717266",class:"cart__content"},(this.showEmptyCount||!!this.getItemsCount())&&i("span",{key:"0f8cbbcbc701f48bc67e5a3581af1d7dfea0cb47",class:"cart__count",part:"count"},this.getItemsCount()),i("div",{key:"e430dd789c822c5c661c6c660ec3102e10c06d9d",class:"cart__icon"},i("slot",{key:"f7af649ff152bad7d389c3d42cb25c4ea527c37f"})))))}get el(){return o(this)}};d.style=n;export{d as sc_cart_button};
//# sourceMappingURL=p-d251d6ec.entry.js.map