import{E as n}from"./events.js";import{e as r}from"./emitEvent.js";const a={"data-heading":"heading","data-heading-plural":"headingPlural","data-view-text":"viewText"};class s extends HTMLElement{constructor(){super(),this.onViewButtonKeyDown=e=>{(e.code==="Enter"||e.code==="NumpadEnter"||e.code==="Space")&&(e.preventDefault(),e.target.dispatchEvent(new Event("click")))},this.heading=this.dataset.heading,this.headingPlural=this.dataset.headingPlural,this.viewText=this.dataset.viewText,this.count=window.eight.bundleBuilder.storefront.cartEngine.bundles.length,this.totalPrice=window.eight.bundleBuilder.storefront.cartEngine.bundlesTotalPrice,this.totalCompareAtPrice=window.eight.bundleBuilder.storefront.cartEngine.prices.bundles_original_price,this.showCompareAtPrice=window.eight.bundleBuilder.storefront.cartEngine.boxSettings.show_compare_at,this.changeSet=a}connectedCallback(){this.init(),document.addEventListener(n["UPDATE:BOX"],()=>{this.updateBox()})}static get observedAttributes(){return[...Object.keys(a)]}attributeChangedCallback(e,i,t){Object.keys(this.changeSet).includes(e)&&i!==t&&(this[this.changeSet[e]]=t,this.init())}updateBox(){this.count=window.eight.bundleBuilder.storefront.cartEngine.bundles.length,this.totalPrice=window.eight.bundleBuilder.storefront.cartEngine.bundlesTotalPrice,this.init()}compileTitle(){let e=this.count>1?this.headingPlural:this.heading;return e=(e||"").replace(/{{\s*count\s*}}/,`${this.count}`),e}compileCost(){return window.eight.bundleBuilder.storefront.cartEngine.formatMoney(this.totalPrice)}compileCompareAtPrice(){return!this.showCompareAtPrice||this.totalCompareAtPrice<=this.totalPrice?"":window.eight.bundleBuilder.storefront.cartEngine.formatMoney(this.totalCompareAtPrice)}init(){const e=this.compileTitle(),i=this.compileCost(),t=this.compileCompareAtPrice();this.innerHTML=`