var Be=Object.defineProperty,Ie=Object.defineProperties;var Oe=Object.getOwnPropertyDescriptors;var Yt=Object.getOwnPropertySymbols;var _e=Object.prototype.hasOwnProperty,Le=Object.prototype.propertyIsEnumerable;var wt=(k,C,p)=>C in k?Be(k,C,{enumerable:!0,configurable:!0,writable:!0,value:p}):k[C]=p,b=(k,C)=>{for(var p in C||(C={}))_e.call(C,p)&&wt(k,p,C[p]);if(Yt)for(var p of Yt(C))Le.call(C,p)&&wt(k,p,C[p]);return k},L=(k,C)=>Ie(k,Oe(C));var g=(k,C,p)=>(wt(k,typeof C!="symbol"?C+"":C,p),p);var y=(k,C,p)=>new Promise((q,N)=>{var K=D=>{try{M(p.next(D))}catch(R){N(R)}},J=D=>{try{M(p.throw(D))}catch(R){N(R)}},M=D=>D.done?q(D.value):Promise.resolve(D.value).then(K,J);M((p=p.apply(k,C)).next())});(function(){var z,Gt,Kt;"use strict";const k=()=>{window.magpieBridge||(window.magpieBridge={})};function C(){var t;return((t=window.Shopline)==null?void 0:t.themeTypeVersion)>=2.1}function p(){var t;const i=(t=window.Shopline)==null?void 0:t.themeTypeVersion;return i>=3&&i<4}function q(){var t;const i=(t=window.Shopline)==null?void 0:t.themeTypeVersion;return i>=2.1&&i<3}function N(){var i;return(i=window.Shopline)==null?void 0:i.url_customization}const K=(i,t)=>{const e=[];for(let o=0;o<i.length;o+=t)e.push(i.slice(o,o+t));return e},J=(i,t)=>{const e=[];let o=[],n=0;for(let r=0;r<i.length;r++)n+i[r].length>t&&(e.push(o),o=[],n=0),o.push(i[r]),n+=i[r].length;return o.length>0&&e.push(o),e},M=i=>{try{return decodeURI(i)}catch(t){return console.error(t),i}},D=i=>{try{return encodeURI(i)}catch(t){return console.error(t),i}},R="/api/product/product/handle/query?paramsList=",Zt=i=>new Promise((t,e)=>{fetch(R+i.join(",")).then(o=>{o.status===200?o.json().then(n=>{t((n==null?void 0:n.data)||[])}):e(o)},o=>{e(o)})}),Vt=i=>y(this,null,function*(){if(k(),window.magpieBridge.productHandleCacheData||(window.magpieBridge.productHandleCacheData={}),!i||!i.length)return console.error("not input handle"),Promise.resolve([]);const t=[],e=[];if(i.forEach(s=>{var c,d,u,h;s&&((d=(c=window.magpieBridge)==null?void 0:c.productHandleCacheData)!=null&&d[s]?t.push((h=(u=window.magpieBridge)==null?void 0:u.productHandleCacheData)==null?void 0:h[s]):e.includes(s)||e.push(s))}),!e.length)return Promise.resolve(t);const o=K(e,50);let n=[];o.forEach(s=>{n=[...n,...J(s,3500)]});let r=[];try{r=yield Promise.all(n.map(s=>Zt(s)))}catch(s){return console.error(s),Promise.reject(s)}const a=r==null?void 0:r.reduce((s,c)=>Array.isArray(c)?s.concat(c):s,[]);return a.forEach(s=>{(s==null?void 0:s.handle)&&window.magpieBridge.productHandleCacheData&&(window.magpieBridge.productHandleCacheData[s.handle]=s)}),t.concat(a)}),te="/api/custom-url/resources.json",ee=(i,t)=>y(this,null,function*(){const e=i.filter(n=>!n.hit_route&&!!n.handle).map(n=>encodeURI(n.handle));(yield Vt(e)).forEach(n=>{const r=i.findIndex(a=>decodeURI(a.handle)===decodeURI(n.handle));i[r]&&(i[r]=b(b({},i[r]),n))}),t(i.filter(n=>!!n.id))}),U=i=>new Promise((t,e)=>{fetch(te,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({custom_urls:i})}).then(o=>{o.status===200?o.json().then(n=>{n.data.resources.some(r=>!r.hit_route)?ee(n.data.resources,t):t((n==null?void 0:n.data.resources)||[])}):e(o)},o=>{e(o)})}),B=(i="")=>{var o,n;let t=i;(o=i==null?void 0:i.startsWith)!=null&&o.call(i,"http")||(t=location.origin+i);try{t=(n=new URL(t))==null?void 0:n.pathname}catch(r){console.error(r)}const e=t==null?void 0:t.split("/products/");if((e==null?void 0:e.length)>1){let r=e==null?void 0:e[(e==null?void 0:e.length)-1];for(;r.endsWith("/");)r=r.substring(0,r.length-1);return r}},I={Home:"Home",About:"About",AboutPolicy:"AboutPolicy",AboutTerms:"AboutTerms",ContactUs:"ContactUs",PrivacyPolicy:"PrivacyPolicy",ShippingPolicy:"ShippingPolicy",PaymentMethod:"PaymentMethod",Faq:"Faq",ProductsSearch:"ProductsSearch",Custom:"Custom",OneShop:"OneShop",Page:"Page",ProductsDetail:"ProductsDetail",PreviewProductsDetail:"PreviewProductsDetail",Activity:"Activity",Products:"Products",BlogsDetail:"BlogsDetail",BlogsList:"BlogsList",AllCollections:"AllCollections",Proofing:"Proofing",NotFound:"404",Checkout:"Checkout",Center:"Center",OrderList:"OrderList",OrderDetail:"OrderDetail",OrderComment:"OrderComment",ReOrderList:"ReOrderList",ReOrderDetail:"ReOrderDetail",ReOrderConfirm:"ReOrderConfirm",SignIn:"SignIn",SignOut:"SignOut",SignUp:"SignUp",Bind:"Bind",AddressNew:"AddressNew",AddressEdit:"AddressEdit",Cart:"Cart",CheckoutError:"CheckoutError",RePay:"RePay",Processing:"Processing",Orders:"Orders",Thankyou:"Thankyou",ExpressCallback:"ExpressCallback",StockProblems:"StockProblems",PaymentMethods:"PaymentMethods",Password:"Password",Policy:"Policy",TransitPage:"TransitPage",PasswordNew:"PasswordNew",Message:"Message",PasswordReset:"PasswordReset",PointList:"PointList",Unsub:"Unsub",UnsubFeedback:"UnsubFeedback",GiftCard:"GiftCard",ActivateAccount:"ActivateAccount",Blank:"Blank"},l={skuChanged:"Product::SkuChanged",updateCollectionSection:"Product::UpdateSection::Filter",scrollUpdateCollection:"Product::UpdateSection::Scroll",miniCartOpen:"Cart::MiniCart::Open",miniCartClose:"Cart::MiniCart::Close",miniCartUpdate:"Cart::MiniCart::Update",recommendUpdate:"Product::Recommend::Update",quickAddClose:"Product::CloseQuickAdd::AddToCart",quickAddOpen:"Product::OpenQuickAdd::AddToCart",stageHeaderSticky:"Stage::Header::Sticky",bannerMiniCartClose:"Cart::BannerMiniCart::Close",bannerMiniCartOpen:"Cart::BannerMiniCart::Open",cartPageUpdate:"Cart::CartPage::Update",openQuickAddModal:"Product::OpenQuickAddModal",updateSearchSection:"Product::UpdateSearchPageSection::Filter",productItemsUpdated:"Product::ProductItems::Updated",productDetailSkuChanged:"ProductDetail::SkuChanged"},ie=()=>q()?document.querySelector("#MainProduct-main-product-info, #MainProduct-main"):p()?document.querySelector('theme-product-detail[data-section-type="main-product"]'):null,mt=i=>{var o,n,r,a,s;let t=null;i?t=i:q()?t=document.querySelector("#MainProduct-main-product-info, #MainProduct-main"):p()&&(t=document.querySelector('theme-product-detail[data-section-type="main-product"]'));let e=(o=t==null?void 0:t.querySelector(p()?"theme-product-form":"product-form"))==null?void 0:o.querySelector("form");if(e||(e=t==null?void 0:t.querySelector("form[action='/api/carts/ajax-cart/addSingle.js']"),e&&((r=(n=window.__SL_Track__)==null?void 0:n.error)==null||r.call(n,"magpieBridgeSdkLog",{error:{message:"[getProductData], Merchant custom form"}}))),e){const c=new FormData(e),d=c.get("id"),u=c.get("quantity");return{productFormData:c,skuId:d,quantity:u,form:e,root:t}}else return(s=(a=window.__SL_Track__)==null?void 0:a.error)==null||s.call(a,"magpieBridgeSdkLog",{error:{message:"[getProductData], not find form"}}),null},S=(i,t)=>function(...e){var n,r;const o=(n=i==null?void 0:i.apply)==null?void 0:n.call(i,this,e);try{(r=t==null?void 0:t.apply)==null||r.call(t,this,e)}catch(a){console.error(a)}return o},oe="/api/product/products.json?handle=",re=(i,t,e)=>(k(),window.magpieBridge.productCacheData||(window.magpieBridge.productCacheData={}),fetch(oe+i).then(o=>{o.status===200?o.json().then(n=>{n.products&&n.products.length&&(t==null||t(n.products[0])),t==null||t(null)}):e==null||e()},()=>{e==null||e()})),x=i=>{var e,o,n;if(!i)return console.error("not input handle"),Promise.resolve(null);if(i=D(M(i)),(o=(e=window.magpieBridge)==null?void 0:e.productCacheData)!=null&&o[i])return(n=window.magpieBridge.productCacheData)==null?void 0:n[i].promise;const t=new Promise(r=>{const a=function(){re(i,s=>{r(s)},()=>{var s,c,d,u;((s=window.magpieBridge.productCacheData)==null?void 0:s[i])&&((d=(c=window.magpieBridge.productCacheData)==null?void 0:c[i])==null?void 0:d.retryCount)<3?(window.magpieBridge.productCacheData[i].retryCount++,setTimeout(()=>{a()},500)):((u=window.magpieBridge.productCacheData)==null||delete u[i],r(null))})};a()});return window.magpieBridge.productCacheData[i]={promise:t,retryCount:0},t},ne=()=>{var i,t;return((t=(i=window==null?void 0:window.Shopline)==null?void 0:i.uri)==null?void 0:t.alias)===I.Cart};k();const gt=()=>{window.magpieBridge||(window.magpieBridge={})};class ae{constructor(){g(this,"_events");g(this,"_caches");this._events={},this._caches={}}addEventListener(t,e,o=!1){this._events[t]||(this._events[t]=[]),e.once=o,this._events[t].push(e)}emit(t,...e){const o=this._events[t];this._caches[t]||(this._caches[t]=[]),this._caches[t].push(e),Array.isArray(o)&&(this._events[t]=o.filter(n=>{try{n(...e)}catch(r){console.error(r)}return!n.once}))}on(t,e){this._caches[t]&&this._caches[t].forEach(o=>{try{e(...o)}catch(n){console.error(n)}}),this.addEventListener(t,e)}once(t,e){if(this._caches[t]){const o=this._caches[t][0];try{e(...o)}catch(n){console.error(n)}return}this.addEventListener(t,e,!0)}off(t,e){this._events[t]=this._events[t].filter(o=>e!==o)}}const se=()=>{var i;gt(),(i=window==null?void 0:window.magpieBridge)!=null&&i.event||(window.magpieBridge.event=new ae)};gt();let yt=!1;function vt(i){return y(this,null,function*(){var n,r,a,s,c,d,u,h,f;let t=(r=(n=i.querySelector("variant-selects, variant-radios"))==null?void 0:n.dataset)==null?void 0:r.url;if(!t&&i&&(t=(a=i.dataset)==null?void 0:a.productUrl),!t&&(i==null?void 0:i.id)){const w=document.querySelector(`modal-opener[data-modal="#${i.id}"]`),m=w==null?void 0:w.querySelector('button[type="submit"]');m&&((s=m.dataset)==null?void 0:s.productUrl)&&(t=(c=m.dataset)==null?void 0:c.productUrl)}if(!t){const w=i==null?void 0:i.querySelector('a[href*="/products/"]');t=w==null?void 0:w.href}if(!t)return;let e="";if(window.Shopline.url_customization){let w=t;(d=t==null?void 0:t.startsWith)!=null&&d.call(t,"http")||(w=location.origin+t);try{w=(u=new URL(w))==null?void 0:u.pathname}catch(v){console.error(v)}const m=(h=yield U([w]))==null?void 0:h[0];m&&(e=m.handle)}else e=B(t)||"";const o=i==null?void 0:i.modalContent;e&&(window.magpieBridge.event&&(window.magpieBridge.event._caches[l.quickAddClose]=[]),(f=window.magpieBridge.event)==null||f.emit(l.quickAddOpen,{data:{modal:i,productUrl:t,handle:e,id:o.id||i.id,modalContent:o},onSuccess:()=>{},onError:()=>{}}))})}function ce(i,t){var o,n,r;const e=t==null?void 0:t.dataset.handle;if(e){const a=(o=t==null?void 0:t.dataset)==null?void 0:o.url,s="QuickAddInfo-"+((n=t==null?void 0:t.dataset)==null?void 0:n.id);window.magpieBridge.event&&(window.magpieBridge.event._caches[l.quickAddClose]=[]),(r=window.magpieBridge.event)==null||r.emit(l.quickAddOpen,{data:{modal:i,productUrl:a,handle:e,id:s,modalContent:t},onSuccess:()=>{},onError:()=>{}})}}let A;const T=()=>y(this,null,function*(){var i;if(!yt){if(yt=!0,p())(i=window.themeEventCenter)==null||i.addListener("product:viewed",t=>{const e=t==null?void 0:t.target,o=e==null?void 0:e.closest("details");o&&ce(o,e)});else if(yield Promise.race([customElements.whenDefined("quick-add-modal"),customElements.whenDefined("product-quick-view-modal")]),A=window.QuickAddModal?"QuickAddModal":"ProductQuickViewModal",window[A]&&window[A].prototype&&window[A].prototype.setInnerHTML){const t=document.querySelector("quick-add-modal details[open='true'], product-quick-view-modal details[open='true']");t&&vt(t.parentElement),window[A].prototype.setInnerHTML=S(window[A].prototype.setInnerHTML,function(){vt(this)})}}});T.key=l.quickAddOpen;let St=!1;const $=()=>{var i;St||(T(),(i=window.magpieBridge.event)==null||i.on(l.quickAddOpen,t=>{const{modal:e,productUrl:o,handle:n,modalContent:r,id:a}=t.data;if(p()){const s=e;if(s){const c=new MutationObserver(()=>{var d;s!=null&&s.hasAttribute("open")||(c.disconnect(),window.magpieBridge.event&&(window.magpieBridge.event._caches[l.quickAddOpen]=[]),(d=window.magpieBridge.event)==null||d.emit(l.quickAddClose,{data:{modal:e,productUrl:o,handle:n,id:a,modalContent:r},onSuccess:()=>{},onError:()=>{}}))});c.observe(s,{subtree:!1,attributes:!0,childList:!1})}}else{let s=e.querySelector("details");if(e.hasAttribute("load-feature-modal")&&(s=e),s){const c=new MutationObserver(()=>{var d;s!=null&&s.hasAttribute("open")||(c.disconnect(),window.magpieBridge.event&&(window.magpieBridge.event._caches[l.quickAddOpen]=[]),(d=window.magpieBridge.event)==null||d.emit(l.quickAddClose,{data:{modal:e,productUrl:o,handle:n,id:a,modalContent:r},onSuccess:()=>{},onError:()=>{}}))});c.observe(s,{subtree:!1,attributes:!0,childList:!1})}}}),St=!0)};$.key=l.quickAddClose;class de{constructor(){g(this,"$watcher");g(this,"$afterWatcher");g(this,"$data");g(this,"watch");g(this,"watchAfter");Object.defineProperty(this,"$watcher",{value:{},configurable:!0}),Object.defineProperty(this,"$afterWatcher",{value:{},configurable:!0}),Object.defineProperty(this,"$data",{value:{},configurable:!0});const t=e=>(o,n)=>{const r={};o.forEach(a=>{this.$watcher[a]||(this.$watcher[a]=[]),this.$afterWatcher[a]||(this.$afterWatcher[a]=[]),e==="watch"?this.$watcher[a].push(n):e==="watchAfter"&&this.$afterWatcher[a].push(n),!Object.prototype.hasOwnProperty.call(this.$data,a)&&(this.$data[a]=this[a],delete this[a],r[a]={set:s=>{this.$data[a]=s,this.$watcher[a].forEach(c=>{try{c&&c(s,a)}catch(d){console.error(d)}}),this.$afterWatcher[a].forEach(c=>{try{c&&c(s,a)}catch(d){console.error(d)}})},get:()=>this.$data[a],configurable:!0})}),Object.defineProperties(this,r)};Object.defineProperty(this,"watch",{value:t("watch"),configurable:!0}),Object.defineProperty(this,"watchAfter",{value:t("watchAfter"),configurable:!0})}empty(){this.$afterWatcher={},this.$data={},this.$watcher={}}}const Ct=()=>new de;class ue{constructor({root:t,max:e,value:o,min:n,onChange:r,productHasQuantityRule:a}){g(this,"root");g(this,"data");g(this,"onChange");g(this,"input");g(this,"minus");g(this,"plus");g(this,"productHasQuantityRule");var s,c,d,u,h,f,w,m,v,P;this.root=t,this.input=((s=this.root)==null?void 0:s.querySelector('input[name="quantity"]'))||null,this.minus=null,this.plus=null,p()?(this.minus=(c=this.root)==null?void 0:c.querySelector('button[name="minus"]'),this.plus=(d=this.root)==null?void 0:d.querySelector('button[name="plus"]')):(this.minus=(u=this.root)==null?void 0:u.querySelector('.quantity__button[name="minus"]'),this.plus=(h=this.root)==null?void 0:h.querySelector('.quantity__button[name="plus"]')),this.productHasQuantityRule=a,this.data={min:(f=this.input)!=null&&f.min?Number(this.input.min):n,max:(w=this.input)!=null&&w.max?Number(this.input.max):e,step:(m=this.input)!=null&&m.step?Number(this.input.step):1,value:(v=this.input)!=null&&v.value?Number((P=this.input)==null?void 0:P.value):o},this.onChange=r,this.initEvent()}initEvent(){var t,e,o,n;if((t=this.minus)==null||t.addEventListener("click",()=>{this.data.min<this.data.value&&(this.data.value-=this.data.step,this.data.value<this.data.min&&(this.data.value=this.data.min),this.render())}),(e=this.plus)==null||e.addEventListener("click",()=>{this.data.value<this.data.max&&(this.data.value+=this.data.step,this.data.value>this.data.max&&(this.data.value=this.data.max),this.render())}),(o=this.input)==null||o.addEventListener("input",r=>{var c,d;const a=(d=(c=r.target)==null?void 0:c.value)==null?void 0:d.replace(/[^\d]/g,""),s=a&&Number(a);this.data.value=+s,this.render()}),(n=this.input)==null||n.addEventListener("blur",r=>{var s,c;const a=+((s=r.target)==null?void 0:s.value);this.data.value=+a,a>this.data.max?this.data.value=this.data.max:this.data.min>a&&(this.data.value=this.data.min),(c=window.magpieBridge.event)==null||c.emit("product:quantity:modify",[this.data.value,this.root]),this.render()}),this.input){const r=new MutationObserver(s=>{var c,d,u;for(const h of s)if(this.productHasQuantityRule){if(h.attributeName==="min"){const f=Number((c=this.input)==null?void 0:c.min);this.setStepperData({min:f,value:f})}else if(h.attributeName==="max"){const f=Number((d=this.input)==null?void 0:d.max);this.setStepperData({max:f})}else if(h.attributeName==="step"){const f=Number((u=this.input)==null?void 0:u.step);this.setStepperData({step:f})}}else this.render()}),a={attributes:!0};r.observe(this.input,a)}}setSingleDisabled(t,e){var o,n,r,a;e?p()?(o=this.root.querySelector(`button[name="${t}"]`))==null||o.setAttribute("disabled",""):(n=this.root.querySelector(`.quantity__button[name="${t}"]`))==null||n.classList.add("disabled"):p()?(r=this.root.querySelector(`button[name="${t}"]`))==null||r.removeAttribute("disabled"):(a=this.root.querySelector(`.quantity__button[name="${t}"]`))==null||a.classList.remove("disabled")}setStepperData(t){this.data=b(b({},this.data),t),this.render()}render(){var t;!this.root||(this.data.value&&(this.setSingleDisabled("minus",this.data.min>=this.data.value),this.setSingleDisabled("plus",this.data.max<=this.data.value)),setTimeout(()=>{this.input&&(this.input.value=String(this.data.value))}),(t=this.onChange)==null||t.call(this,this.data.value))}}const kt=1;class le{constructor(t,e,o,n){g(this,"root");g(this,"product");g(this,"productHasQuantityRule");g(this,"dataPool");g(this,"fixedMax");g(this,"skuStepper");g(this,"onChange");var r,a;this.dataPool=Ct(),this.root=null,p()?this.root=t==null?void 0:t.querySelector("theme-input-number"):this.root=t==null?void 0:t.querySelector("quantity-input"),this.product=e,this.productHasQuantityRule=(a=(r=this.product)==null?void 0:r.variants)==null?void 0:a.some(s=>s.quantity_rule&&(s.quantity_rule.min>1||s.quantity_rule.increment>1||s.quantity_rule.max)),this.fixedMax=o!=null?o:0,this.onChange=n,this.skuStepper=new ue({root:this.root,max:this.getMax(),value:kt,min:1,onChange:s=>{var c;!this.dataPool||isNaN(s)||(s!==this.dataPool.quantity&&(this.dataPool.quantity=s),(c=this.onChange)==null||c.call(this,s))},productHasQuantityRule:this.productHasQuantityRule}),this.init()}init(){var t,e;!this.dataPool||(this.dataPool.quantity=((e=(t=this.skuStepper)==null?void 0:t.data)==null?void 0:e.value)||kt,this.dataPool.watch(["quantity"],()=>{this.dataPool&&this.setCurrentNum(this.dataPool.quantity)}))}setCurrentNum(t){if(!this.skuStepper)return;const e=L(b({},this.skuStepper.data),{value:t});this.skuStepper.setStepperData(e)}getMax(){return this.fixedMax?this.fixedMax:99999}destory(){var t;(t=this.dataPool)==null||t.empty(),delete this.dataPool,delete this.root,delete this.fixedMax,delete this.onChange,delete this.skuStepper}}const pe=i=>i!=null&&i.length?i.map(t=>{var n;const e=t.name,o=(n=t.values)==null?void 0:n.map(r=>({name:r,imgUrl:t.values_images[r],disabled:!1}));return{specName:e,specAttrList:o}}):[],he=(i,t)=>i.reduce((e,o)=>(Object.keys(e).forEach(n=>{if(o[n]===null)return;let r=e[n].find(u=>u.value===o[n]);typeof r=="undefined"&&(r={value:o[n],soldOut:!0},e[n].push(r));const a=t==null?void 0:t.find(u=>u.index==="option1"),s=t==null?void 0:t.find(u=>u.index==="option2"),c=t==null?void 0:t.find(u=>u.index==="option3"),d=t==null?void 0:t.find(u=>u.index==="option4");switch(n){case"option1":r.soldOut=r.soldOut&&o.available?!1:r.soldOut;break;case"option2":a&&o.option1===a.value&&(r.soldOut=r.soldOut&&o.available?!1:r.soldOut);break;case"option3":a&&o.option1===a.value&&s&&o.option2===s.value&&(r.soldOut=r.soldOut&&o.available?!1:r.soldOut);break;case"option4":a&&o.option1===a.value&&s&&o.option2===s.value&&c&&o.option3===c.value&&(r.soldOut=r.soldOut&&o.available?!1:r.soldOut);break;case"option5":a&&o.option1===a.value&&s&&o.option2===s.value&&c&&o.option3===c.value&&d&&o.option4===d.value&&(r.soldOut=r.soldOut&&o.available?!1:r.soldOut);break}}),e),{option1:[],option2:[],option3:[],option4:[],option5:[]});class fe{constructor(t,e,o){g(this,"root");g(this,"dataPool");g(this,"form");g(this,"skuType");g(this,"productData");g(this,"currentSkuId");var n,r,a,s;this.dataPool=Ct(),this.root=null,p()?this.root=(t==null?void 0:t.querySelector("theme-variant-radio-picker"))||(t==null?void 0:t.querySelector("theme-variant-select-picker"))||null:this.root=(t==null?void 0:t.querySelector("variant-radios"))||(t==null?void 0:t.querySelector("variant-selects"))||null,this.skuType=((n=this.root)==null?void 0:n.tagName)==="VARIANT-RADIOS"||((r=this.root)==null?void 0:r.tagName)==="THEME-VARIANT-RADIO-PICKER"?"flatten":"select",this.form=o,this.productData=e,this.currentSkuId=((s=(a=this.form)==null?void 0:a.querySelector('[name="id"]'))==null?void 0:s.value)||"",this.init()}init(){var t;this.bindEvent(),this.dataPool&&(this.dataPool.attrArray=pe(this.productData.options),this.dataPool.activeSku=((t=this.productData.variants)==null?void 0:t.find(({id:e})=>e===this.currentSkuId))||{},p()||this.updateOptionsDisabled(),this.updateCurrentSpecIndex())}clickAttr(t,e){var o,n,r,a,s,c,d,u,h;if(!(!this.dataPool||!this.form)){if(!this.root){const f=[...this.dataPool.currentSpecIndex];f[t]=e;const w=f.map((P,_)=>{var H;return(H=this.productData.options)==null?void 0:H[_].values[P]}).join(" \xB7 "),m=(n=(o=this.productData.variants)==null?void 0:o.find(P=>P.title===w))==null?void 0:n.id,v=(r=this.form)==null?void 0:r.querySelector('[name="id"]');v&&m&&(v.value=m,v.dispatchEvent(new Event("change",{bubbles:!0})));return}if(this.skuType==="flatten"){(a=this.root)==null||a.querySelectorAll("fieldset")[t].querySelectorAll("input")[e].click();return}if(this.skuType==="select"){const f=(c=(s=this.root)==null?void 0:s.querySelectorAll("select"))==null?void 0:c[t],w=(h=(u=(d=this.productData.options)==null?void 0:d[t])==null?void 0:u.values)==null?void 0:h[e];if(f&&w&&(f.value=w,f.dispatchEvent(new Event("change",{bubbles:!0})),p())){const m=f.closest("theme-select");m&&Array.from(m.querySelectorAll(".theme-select__option")).forEach((P,_)=>{_===e?P.setAttribute("selected","true"):P.removeAttribute("selected")})}}}}bindEvent(){var t,e;(t=this.form)==null||t.addEventListener("change",o=>{var r,a,s;if(!this.dataPool)return;const n=o.target;n.name==="id"&&(this.currentSkuId=n.value,this.dataPool.activeSku=((r=this.productData.variants)==null?void 0:r.find(({id:c})=>c===this.currentSkuId))||{},this.root||(this.dataPool.currentSpecIndex=((s=(a=this.dataPool.activeSku)==null?void 0:a.options)==null?void 0:s.map((c,d)=>{var u;return(u=this.productData.options)==null?void 0:u[d].values.findIndex(h=>h===c)}))||[]))}),(e=this.root)==null||e.addEventListener("change",()=>{p()||this.updateOptionsDisabled(),this.updateCurrentSpecIndex()})}updateOptionsDisabled(){var o,n,r,a,s,c;let t=(a=(r=(n=(o=this.dataPool)==null?void 0:o.activeSku)==null?void 0:n.options)==null?void 0:r.map)==null?void 0:a.call(r,(d,u)=>({index:`option${u+1}`,value:d}));if(!t&&this.root)if(this.skuType==="select")t=(s=Array.from(this.root.querySelectorAll("select")))==null?void 0:s.map((d,u)=>({index:`option${u+1}`,value:d==null?void 0:d.value}));else{const d=Array.from(this.root.querySelectorAll("fieldset"));t=d==null?void 0:d.map((u,h)=>{var f,w;return{index:`option${h+1}`,value:(w=(f=Array.from(u.querySelectorAll("input")))==null?void 0:f.find(m=>m.checked))==null?void 0:w.value}})}if(!t)return;const e=he(this.productData.variants,t);(c=this.dataPool)==null||c.attrArray.forEach((d,u)=>{d.specAttrList.forEach((h,f)=>{var v,P;const w=`option${u+1}`,m=(P=(v=e==null?void 0:e[w])==null?void 0:v[f])==null?void 0:P.soldOut;h.disabled=m})})}updateCurrentSpecIndex(){var e,o,n;if(!this.dataPool)return;if(!this.root){(e=this.dataPool)!=null&&e.activeSku&&(this.dataPool.currentSpecIndex=((o=this.dataPool.activeSku.options)==null?void 0:o.map((r,a)=>{var s;return(s=this.productData.options)==null?void 0:s[a].values.findIndex(c=>c===r)}))||[]);return}let t=[];if(this.skuType==="select")t=(n=Array.from(this.root.querySelectorAll("select")))==null?void 0:n.map(r=>r==null?void 0:r.value);else{const r=Array.from(this.root.querySelectorAll("fieldset"));t=r==null?void 0:r.map(a=>{var s,c;return(c=(s=Array.from(a.querySelectorAll("input")))==null?void 0:s.find(d=>d.checked))==null?void 0:c.value})}this.dataPool.currentSpecIndex=(t==null?void 0:t.map((r,a)=>{var s;return(s=this.productData.options)==null?void 0:s[a].values.findIndex(c=>c===r)}))||[]}destory(){var t;(t=this.dataPool)==null||t.empty(),delete this.dataPool,delete this.root,delete this.form}}const X=()=>{var i,t,e,o;return((t=(i=window==null?void 0:window.Shopline)==null?void 0:i.uri)==null?void 0:t.alias)===I.ProductsDetail||((o=(e=window==null?void 0:window.Shopline)==null?void 0:e.uri)==null?void 0:o.alias)===I.PreviewProductsDetail};let Pt=!1,F;function bt(i,t){var a,s,c;const e=new FormData(i),o=(a=e.get("id"))!=null?a:null,n=e.get("quantity"),r=(c=(s=t==null?void 0:t.variants)==null?void 0:s.find(d=>(d==null?void 0:d.id)===o))!=null?c:null;return{skuId:o,quantity:n,activeSku:r}}const Q=(i,t,e,o)=>y(this,null,function*(){var f;const n=yield x(t);if(!n)return;const r=mt(o);if(!r)return;const{form:a,root:s}=r;if(!s||!a)return;const c=new fe(s,n,a),d=new le(s,n);let u;switch(i){case"featureProduct":u={module:"featuredProduct"};break;case"productDetail":u={module:"pdp"};break;case"quickAdd":u={modalType:"quickAddToCart",module:"quickAddToCartModal",modalContainerElement:s};break;case"quickAddWithoutPic":u={modalType:"quickAddWithoutPicToCart",module:"quickAddWithoutPicToCartModal",modalContainerElement:s};break}const h=w=>{var v;w.target.name==="id"&&((v=window.magpieBridge.event)==null||v.emit(l.skuChanged,{data:L(b(b(b({type:"change"},r),bt(a,n)),u),{product:n,id:e!=null?e:"productDetail",handle:t,skuTrade:c,quantityStepper:d}),onSuccess:()=>{},onError:()=>{}}))};return a.addEventListener("change",h),(f=window.magpieBridge.event)==null||f.emit(l.skuChanged,{data:L(b(b(b({type:"init"},r),bt(a,n)),u),{product:n,id:e!=null?e:"productDetail",handle:t,skuTrade:c,quantityStepper:d}),onSuccess:()=>{},onError:()=>{}}),()=>{var w,m,v;(w=a==null?void 0:a.removeEventListener)==null||w.call(a,"change",h),(m=c==null?void 0:c.destory)==null||m.call(c),(v=d==null?void 0:d.destory)==null||v.call(d)}}),we=()=>{document.querySelectorAll("[class^='featured-product']").forEach(i=>y(this,null,function*(){var o,n,r,a,s,c;let t=(o=i.querySelector("variant-radios[data-url],variant-selects[data-url]"))==null?void 0:o.dataset.url;if(t||(t=(n=i.querySelector("a[href*='/products/']"))==null?void 0:n.getAttribute("href")),!t&&window.Shopline.url_customization&&(t=(r=i.querySelector(".product__view-details"))==null?void 0:r.getAttribute("href"),(s=(a=window.__SL_Track__)==null?void 0:a.error)==null||s.call(a,"magpieBridgeSdkLog",{error:{message:"[bindFeatureProduct], customization url get product__view-details"}})),!t)return;let e="";if(window.Shopline.url_customization){const d=(c=yield U([t]))==null?void 0:c[0];d&&(e=d.handle)}else e=B(t)||"";!e||Q("featureProduct",e,i.id,i)}))},me=()=>{document.querySelectorAll('theme-product-detail[data-section-type="featured-product"]').forEach(i=>y(this,null,function*(){var o,n,r;const t=(o=i==null?void 0:i.dataset)==null?void 0:o.url;if(!t)return;let e="";if(window.Shopline.url_customization){const a=(n=yield U([t]))==null?void 0:n[0];a&&(e=a.handle)}else e=B(t)||"";!e||Q("featureProduct",e,(r=i==null?void 0:i.dataset)==null?void 0:r.sectionId,i)}))},ge=()=>{var i,t;$(),T(),p()||window[A]&&window[A].prototype&&window[A].prototype.open&&(window[A].prototype.open=S(window[A].prototype.open,function(){return y(this,null,function*(){var r,a,s,c;const e=this;let o=(a=(r=e.querySelector("[data-product-url]"))==null?void 0:r.dataset)==null?void 0:a.productUrl;if(!o&&(e==null?void 0:e.id)){const d=document.querySelector(`modal-opener[data-modal="#${e.id}"]`),u=d==null?void 0:d.querySelector('button[type="submit"]');u&&((s=u.dataset)==null?void 0:s.productUrl)&&(o=(c=u.dataset)==null?void 0:c.productUrl)}const n=B(o);n&&x(n)})})),(i=window.magpieBridge.event)==null||i.on(l.quickAddOpen,e=>y(this,null,function*(){const{handle:o,modalContent:n,modal:r,id:a}=(e==null?void 0:e.data)||{};let s=(r==null?void 0:r.tagName)==="PRODUCT-QUICK-ADD-MODAL"?"quickAddWithoutPic":"quickAdd";p()&&(s="quickAdd"),F=yield Q(s,o,a,n)})),(t=window.magpieBridge.event)==null||t.on(l.quickAddClose,()=>{F==null||F(),F=void 0})},Y=()=>y(this,null,function*(){var i,t;if(!Pt){if(Pt=!0,ge(),p()?yield customElements.whenDefined("theme-product-form"):yield customElements.whenDefined("product-form"),X()){let e="";if(window.Shopline.url_customization){if(p()){const o=document.querySelector('theme-product-detail[data-section-type="main-product"]');e=(i=o==null?void 0:o.dataset)==null?void 0:i.handle}if(!e){const o=(t=yield U([location.pathname]))==null?void 0:t[0];o&&(e=o.handle)}}else e=B(location.href)||"";Q("productDetail",e)}p()?me():we()}});Y.key=l.skuChanged;const ye=()=>{var i,t;return((t=(i=window==null?void 0:window.Shopline)==null?void 0:i.uri)==null?void 0:t.alias)===I.Products};let qt=!1;const Z=()=>y(this,null,function*(){if(!qt&&(qt=!0,ye()))if(p()){const i=document.querySelector("theme-facets-form");if(i){yield customElements.whenDefined("theme-facets-form");const t=Object.getPrototypeOf(i);t.updateResults&&(t.updateResults=S(t==null?void 0:t.updateResults,function(){var e;(e=window.magpieBridge.event)==null||e.emit(l.updateCollectionSection,{data:{content:document.getElementById("ResultsContainer")},onSuccess:()=>{},onError:()=>{}})}))}}else yield customElements.whenDefined("facet-filters-form"),window.FacetFiltersForm&&window.FacetFiltersForm.renderProductGridContainer&&(window.FacetFiltersForm.renderProductGridContainer=S(window.FacetFiltersForm.renderProductGridContainer,function(){var i;(i=window.magpieBridge.event)==null||i.emit(l.updateCollectionSection,{data:{content:document.getElementById("ProductListContainer")},onSuccess:()=>{},onError:()=>{}})}))});Z.key=l.updateCollectionSection;const ve=()=>{var i,t;return((t=(i=window==null?void 0:window.Shopline)==null?void 0:i.uri)==null?void 0:t.alias)===I.Products},At=i=>{var t;(t=window.magpieBridge.event)==null||t.emit(l.scrollUpdateCollection,{data:{content:i},onSuccess:()=>{},onError:()=>{}})};let Dt=!1;const V=()=>y(this,null,function*(){if(!Dt&&(Dt=!0,ve()))if(p()){yield customElements.whenDefined("theme-infinite-scroll");const i=document.querySelector("theme-infinite-scroll");if(!i)return;const t=Object.getPrototypeOf(i);t!=null&&t.handleLoading&&(t.handleLoading=S(t.handleLoading,function(e){e===!1&&At(i)}))}else yield customElements.whenDefined("infinite-scroll"),window.InfiniteScroll&&window.InfiniteScroll.prototype&&window.InfiniteScroll.prototype.handleLoading&&(window.InfiniteScroll.prototype.handleLoading=S(window.InfiniteScroll.prototype.handleLoading,function(i){i===!1&&At(document.querySelector("ul.product-list-content"))}))});V.key=l.scrollUpdateCollection;let Et=!1;const Bt=i=>{var t;(t=window.magpieBridge.event)==null||t.emit(l.recommendUpdate,{data:{content:i},onSuccess:()=>{},onError:()=>{}})},tt=()=>{if(Et)return;const i=p()?".section-recommended-product":"product-recommendations",t=p()?".block-product-card":".product-card-wrapper",e=document.querySelector(i);if(X()&&e){if(e.querySelector(t)){Bt(e);return}const o={childList:!0,attributes:!1,subtree:!0},n=new MutationObserver(()=>{!e.querySelector(t)||(n.disconnect(),Bt(e))});n.observe(e,o)}Et=!0};tt.key=l.recommendUpdate;const Se=(i,t)=>{const e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),o=[];let n;if(t=t||e.length,i)for(n=0;n<i;n++)o[n]=e[0|Math.random()*t];else{let r;for(o[8]=o[13]=o[18]=o[23]="-",o[14]="4",n=0;n<36;n++)o[n]||(r=0|Math.random()*16,o[n]=e[n==19?r&3|8:r])}return o.join("")};let It=!1;function Ce(i,t,e,o){var r,a,s,c,d;const n=i==null?void 0:i.querySelector("#"+((c=(s=(a=(r=window.Shopline)==null?void 0:r.utils)==null?void 0:a.quickAddModal)==null?void 0:s.contentId)!=null?c:"lf-quick-add-modal-content"));o&&n&&(window.magpieBridge.event&&(window.magpieBridge.event._caches[l.quickAddClose]=[]),(d=window.magpieBridge.event)==null||d.emit(l.quickAddOpen,{data:{modal:i,productUrl:t,handle:o,id:e,modalContent:n},onSuccess:()=>{},onError:()=>{}}))}const et=()=>y(this,null,function*(){var i;It||($(),(i=window.magpieBridge.event)==null||i.on(l.openQuickAddModal,t=>{const{handle:e,url:o}=(t==null?void 0:t.data)||{};if(!e){console.error("openQuickAddModalRun: handle is required");return}window.Shopline.loadFeatures([{name:"component-quick-add-modal",version:"0.1"}],function(n){return y(this,null,function*(){var a,s,c,d,u,h,f,w,m,v,P,_,H,Jt,Xt;if(n)throw n;let r;if(N())r=o;else{const G=`/products/${e}`;r=(a=window==null?void 0:window.Shopline)!=null&&a.redirectTo?(c=(s=window==null?void 0:window.Shopline)==null?void 0:s.redirectTo)==null?void 0:c.call(s,G):G}if(yield(f=(h=(u=(d=window.Shopline)==null?void 0:d.utils)==null?void 0:u.quickAddModal)==null?void 0:h.open)==null?void 0:f.call(h,r),!p()){const G="component-quick-add-modal-"+Se(20);(P=(v=(m=(w=window.Shopline)==null?void 0:w.utils)==null?void 0:m.quickAddModal)==null?void 0:v.modal)!=null&&P.container&&Ce((Xt=(Jt=(H=(_=window.Shopline)==null?void 0:_.utils)==null?void 0:H.quickAddModal)==null?void 0:Jt.modal)==null?void 0:Xt.container,r,G,e)}})})}),It=!0)});et.key=l.openQuickAddModal;const ke=()=>{var i,t;return((t=(i=window==null?void 0:window.Shopline)==null?void 0:i.uri)==null?void 0:t.alias)===I.ProductsSearch};let Ot=!1;const it=()=>y(this,null,function*(){if(!Ot&&(Ot=!0,ke()))if(p()){const i=document.querySelector("theme-facets-form");if(i){yield customElements.whenDefined("theme-facets-form");const t=Object.getPrototypeOf(i);t.updateResults&&(t.updateResults=S(t==null?void 0:t.updateResults,function(){var e;(e=window.magpieBridge.event)==null||e.emit(l.updateSearchSection,{data:{content:document.getElementById("ResultsContainer")},onSuccess:()=>{},onError:()=>{}})}))}}else yield customElements.whenDefined("facet-filters-form"),window.FacetFiltersForm&&window.FacetFiltersForm.renderProductGridContainer&&(window.FacetFiltersForm.renderProductGridContainer=S(window.FacetFiltersForm.renderProductGridContainer,function(){var i;(i=window.magpieBridge.event)==null||i.emit(l.updateSearchSection,{data:{content:document.getElementById("ProductListContainer")},onSuccess:()=>{},onError:()=>{}})}))});it.key=l.updateSearchSection;let _t=!1;const Pe=()=>{var i;(i=window.magpieBridge.event)==null||i.emit(l.productItemsUpdated,{onSuccess:()=>{},onError:()=>{}})},ot=()=>{if(_t)return;_t=!0;const i=document.querySelectorAll("theme-featured-collection-tabs");i.length&&i.forEach(t=>{new MutationObserver(o=>{o.forEach(n=>{var a,s;const r=(a=Array.from(n.addedNodes))==null?void 0:a.some(c=>{var d;return((d=c.tagName)==null?void 0:d.toLocaleLowerCase())==="theme-carousel"});n.type==="childList"&&((s=n.addedNodes)==null?void 0:s.length)>0&&r&&Pe()})}).observe(t,{subtree:!0,attributes:!1,childList:!0})})};ot.key=l.productItemsUpdated;let Lt=!1;function Mt(i,t){var r,a,s;const o=(r=new FormData(i).get("id"))!=null?r:null,n=(s=(a=t==null?void 0:t.variants)==null?void 0:a.find(c=>(c==null?void 0:c.id)===o))!=null?s:null;return{skuId:o,activeSku:n}}const be=(i,t,e)=>y(this,null,function*(){var r;const o=yield x(i);if(!o||!t||!e)return;const n=a=>{var c;a.target.name==="id"&&((c=window.magpieBridge.event)==null||c.emit(l.productDetailSkuChanged,{data:L(b({type:"change",root:t},Mt(e,o)),{module:"pdp",product:o,id:"productDetail",handle:i}),onSuccess:()=>{},onError:()=>{}}))};e.addEventListener("change",n),(r=window.magpieBridge.event)==null||r.emit(l.productDetailSkuChanged,{data:L(b({type:"init",root:t},Mt(e,o)),{module:"pdp",product:o,id:"productDetail",handle:i}),onSuccess:()=>{},onError:()=>{}})}),Rt=(i,t,e,o)=>{const n=o||e;let r=null;if(q()){let a=null;const s=t.variants;e?a=Array.from(i.querySelectorAll("select"),c=>c.value):a=Array.from(i.querySelectorAll("fieldset")).map(d=>{const h=Array.from(d.querySelectorAll("input")).find(f=>f.checked);return h?h.value:""}),r=s==null?void 0:s.find(c=>{var d;return!((d=c==null?void 0:c.options)!=null&&d.map((u,h)=>a[h]===u).includes(!1))})}else p()&&(r=n.currentVariant);return r==null?void 0:r.id},Ut=(i,t)=>{var e,o;return(o=(e=i==null?void 0:i.variants)==null?void 0:e.find(n=>(n==null?void 0:n.id)===t))!=null?o:null},qe=(i,t)=>y(this,null,function*(){var c,d,u,h,f;const e=yield x(i);if(!e)return;let o=null,n=null;if(q()?(o=t.querySelector("variant-selects"),n=t.querySelector("variant-radios")):p()&&(o=t.querySelector("theme-variant-select-picker"),n=t.querySelector("theme-variant-radio-picker")),!o&&!n){((c=e==null?void 0:e.variants)==null?void 0:c.length)===1&&((h=window.magpieBridge.event)==null||h.emit(l.productDetailSkuChanged,{data:{type:"init",root:t,skuId:(d=e==null?void 0:e.variants)==null?void 0:d[0].id,activeSku:(u=e==null?void 0:e.variants)==null?void 0:u[0],module:"pdp",product:e,id:"productDetail",handle:i},onSuccess:()=>{},onError:()=>{}}));return}const r=Rt(t,e,o,n),a=Ut(e,r);(f=window.magpieBridge.event)==null||f.emit(l.productDetailSkuChanged,{data:{type:"init",root:t,skuId:r,activeSku:a,module:"pdp",product:e,id:"productDetail",handle:i},onSuccess:()=>{},onError:()=>{}});const s=n||o;s==null||s.addEventListener("change",()=>{var v;const w=Rt(t,e,o,n),m=Ut(e,w);(v=window.magpieBridge.event)==null||v.emit(l.productDetailSkuChanged,{data:{type:"change",root:t,skuId:w,activeSku:m,module:"pdp",product:e,id:"productDetail",handle:i},onSuccess:()=>{},onError:()=>{}})})}),rt=()=>y(this,null,function*(){var i,t;if(!Lt&&(Lt=!0,X())){const e=mt(),o=ie();if(!o)return;const n=e&&(e==null?void 0:e.form);p()?n?yield customElements.whenDefined("theme-product-form"):yield Promise.race([customElements.whenDefined("theme-variant-select-picker"),customElements.whenDefined("theme-variant-radio-picker")]):n?yield customElements.whenDefined("product-form"):yield Promise.race([customElements.whenDefined("variant-radios"),customElements.whenDefined("variant-selects")]);let r="";if(window.Shopline.url_customization){if(p()){const a=document.querySelector('theme-product-detail[data-section-type="main-product"]');r=(i=a==null?void 0:a.dataset)==null?void 0:i.handle}if(!r){const a=(t=yield U([location.pathname]))==null?void 0:t[0];a&&(r=a.handle)}}else r=B(location.href)||"";n?be(r,o,e==null?void 0:e.form):qe(r,o)}});rt.key=l.productDetailSkuChanged;let Tt=!1;const nt=()=>{var i;window.magpieBridge.event&&(window.magpieBridge.event._caches[l.miniCartOpen]=[]),(i=window.magpieBridge.event)==null||i.emit(l.miniCartClose,{onSuccess:()=>{},onError:()=>{}})},at=()=>y(this,null,function*(){var i,t;if(!Tt){if(Tt=!0,p()){const e=(i=window.themeEventCenter)==null?void 0:i.getCurrentDetail("cart:closed");(e==null?void 0:e.type)==="drawer"&&nt(),(t=window.themeEventCenter)==null||t.addListener("cart:closed",o=>{const{detail:n}=o;n.type==="drawer"&&nt()})}q()&&document.querySelector("cart-drawer-entry")&&(yield customElements.whenDefined("cart-drawer-entry"),window.CartDrawerEntry&&window.CartDrawerEntry.prototype&&window.CartDrawerEntry.prototype.close&&(window.CartDrawerEntry.prototype.close=S(window.CartDrawerEntry.prototype.close,function(){nt()})))}});at.key=l.miniCartClose;let $t=!1;const j=()=>{var i;window.magpieBridge.event&&(window.magpieBridge.event._caches[l.miniCartClose]=[]),(i=window.magpieBridge.event)==null||i.emit(l.miniCartOpen,{onSuccess:()=>{},onError:()=>{}})},st=()=>y(this,null,function*(){var i,t,e,o;if(!$t){if($t=!0,p()){const n=(i=window.themeEventCenter)==null?void 0:i.getCurrentDetail("cart:opened");(n==null?void 0:n.type)==="drawer"&&j(),(t=window.themeEventCenter)==null||t.addListener("cart:opened",r=>{const{detail:a}=r;a.type==="drawer"&&j()})}if(q()){const n=document.querySelector("cart-drawer-entry");n&&(yield customElements.whenDefined("cart-drawer-entry"),window.CartDrawerEntry&&window.CartDrawerEntry.prototype&&window.CartDrawerEntry.prototype.open&&((o=(e=n.querySelector("cart-drawer"))==null?void 0:e.classList)!=null&&o.contains("active")&&j(),window.CartDrawerEntry.prototype.open=S(window.CartDrawerEntry.prototype.open,function(){j()})))}}});st.key=l.miniCartOpen;let Ft=!1;const Ht=()=>{var i;(i=window.magpieBridge.event)==null||i.emit(l.miniCartUpdate,{onSuccess:()=>{},onError:()=>{}})},ct=()=>y(this,null,function*(){if(!Ft){if(Ft=!0,p()){const i=document.querySelector("theme-cart-drawer");i&&(yield customElements.whenDefined("theme-cart-drawer"),i.replaceElement&&(i.replaceElement=S(i==null?void 0:i.replaceElement,Ht)))}q()&&document.querySelector("cart-drawer-entry")&&(yield customElements.whenDefined("cart-drawer-entry"),window.CartItems&&window.CartItems.prototype&&window.CartItems.prototype.disableLoading&&(window.CartItems.prototype.disableLoading=S(window.CartItems.prototype.disableLoading,function(){(this==null?void 0:this.constructor)===(window==null?void 0:window.CartDrawerItems)&&Ht()})))}});ct.key=l.miniCartUpdate;let Nt=!1;const dt=()=>{var i;window.magpieBridge.event&&(window.magpieBridge.event._caches[l.bannerMiniCartOpen]=[]),(i=window.magpieBridge.event)==null||i.emit(l.bannerMiniCartClose,{onSuccess:()=>{},onError:()=>{}})},ut=()=>y(this,null,function*(){var i,t;if(!Nt){if(Nt=!0,p()){const e=(i=window.themeEventCenter)==null?void 0:i.getCurrentDetail("cart:closed");(e==null?void 0:e.type)==="notification"&&dt(),(t=window.themeEventCenter)==null||t.addListener("cart:closed",o=>{const{detail:n}=o;n.type==="notification"&&dt()})}q()&&document.querySelector("cart-notification")&&(yield customElements.whenDefined("cart-notification"),window.CartNotification&&window.CartNotification.prototype&&window.CartNotification.prototype.close&&(window.CartNotification.prototype.close=S(window.CartNotification.prototype.close,function(){dt()})))}});ut.key=l.bannerMiniCartClose;let xt=!1;const W=()=>{var i;window.magpieBridge.event&&(window.magpieBridge.event._caches[l.bannerMiniCartClose]=[]),(i=window.magpieBridge.event)==null||i.emit(l.bannerMiniCartOpen,{onSuccess:()=>{},onError:()=>{}})},lt=()=>y(this,null,function*(){var i,t,e;if(!xt){if(xt=!0,p()){const o=(i=window.themeEventCenter)==null?void 0:i.getCurrentDetail("cart:opened");(o==null?void 0:o.type)==="notification"&&W(),(t=window.themeEventCenter)==null||t.addListener("cart:opened",n=>{const{detail:r}=n;r.type==="notification"&&W()})}if(q()){const o=document.querySelector("cart-notification");o&&(yield customElements.whenDefined("cart-notification"),window.CartNotification&&window.CartNotification.prototype&&window.CartNotification.prototype.open&&((e=o==null?void 0:o.classList)!=null&&e.contains("active")&&W(),window.CartNotification.prototype.open=S(window.CartNotification.prototype.open,function(){W()})))}}});lt.key=l.bannerMiniCartOpen;let Qt=!1;const jt=()=>{var i;(i=window.magpieBridge.event)==null||i.emit(l.cartPageUpdate,{onSuccess:()=>{},onError:()=>{}})},pt=()=>y(this,null,function*(){if(Qt)return;if(Qt=!0,ne()){if(p()){const t=document.querySelector("theme-main-cart-items");if(t){yield customElements.whenDefined("theme-main-cart-items");const e=Object.getPrototypeOf(t);e.replaceElement&&(e.replaceElement=S(e==null?void 0:e.replaceElement,jt))}}q()&&(yield customElements.whenDefined("cart-items"),window.CartItems&&window.CartItems.prototype&&window.CartItems.prototype.disableLoading&&(window.CartItems.prototype.disableLoading=S(window.CartItems.prototype.disableLoading,function(){(this==null?void 0:this.constructor)===(window==null?void 0:window.CartItems)&&jt()})))}});pt.key=l.cartPageUpdate;let Wt=!1;const E=i=>{var t,e,o,n;(o=(e=(t=window.magpieBridge.event)==null?void 0:t._caches)==null?void 0:e[l.stageHeaderSticky])!=null&&o.length&&(window.magpieBridge.event._caches[l.stageHeaderSticky]=[]),(n=window.magpieBridge.event)==null||n.emit(l.stageHeaderSticky,{data:{stickyActive:i},onError(){},onSuccess(){}})},zt=()=>{const i=document.querySelector('[data-settings-id="shopline-section-header"]'),t=i==null?void 0:i.classList;t!=null&&t.contains("theme-sticky-header--sticky")?t!=null&&t.contains("theme-sticky-header--sticky-collapse")?E(!1):E(!0):E(!1)},Ae=()=>{zt(),window.addEventListener("scroll",()=>{zt()})},ht=()=>y(this,null,function*(){var i,t,e,o,n;if(!Wt)if(Wt=!0,p())Ae();else{yield Promise.race([customElements.whenDefined("sticky-header"),customElements.whenDefined("header-layout")]);const r=window.StickyHeader||window.HeaderLayout,a=document.querySelector("#shopline-section-header");a&&(a.classList.contains("shopline-section-header-sticky")&&!a.classList.contains("shopline-section-header-hidden")||a.classList.contains("shopline-section-header-sticky--always"))&&E(!0),(i=r==null?void 0:r.prototype)!=null&&i.reveal&&(r.prototype.reveal=S(r.prototype.reveal,function(){E(!0)})),(t=r==null?void 0:r.prototype)!=null&&t.hide&&(r.prototype.hide=S(r.prototype.hide,function(){E(!1)})),(e=r==null?void 0:r.prototype)!=null&&e.reset&&(r.prototype.reset=S(r.prototype.reset,function(){E(!1)})),(o=r==null?void 0:r.prototype)!=null&&o.addStickyClass&&(r.prototype.addStickyClass=S(r.prototype.addStickyClass,function(){E(!0)})),(n=r==null?void 0:r.prototype)!=null&&n.removeSticyClass&&(r.prototype.removeSticyClass=S(r.prototype.removeSticyClass,function(){E(!1)}))}});ht.key=l.stageHeaderSticky;const O={[Y.key]:Y,[Z.key]:Z,[V.key]:V,[at.key]:at,[st.key]:st,[ct.key]:ct,[tt.key]:tt,[$.key]:$,[T.key]:T,[ht.key]:ht,[ut.key]:ut,[lt.key]:lt,[pt.key]:pt,[et.key]:et,[it.key]:it,[ot.key]:ot,[rt.key]:rt},ft=new Map;window.magpieBridge&&(window.magpieBridge.registeredListMap=ft);const De=i=>{i.forEach(t=>{var e;ft.get(t)||O[t]&&(ft.set(t,!0),(e=O==null?void 0:O[t])==null||e.call(O))})};function Ee(){var e;const i="_magpie_bridge_sdk";if((e=window.magpieBridge)!=null&&e[i])return;window.magpieBridge[i]=!0;function t(){var o,n,r;se(),window.magpieBridge&&(window.magpieBridge.registerEventName=De,(n=(o=window.magpieBridge)==null?void 0:o._resolve_)==null||n.call(o),(r=window.magpieBridge)==null||delete r._resolve_)}t()}C()?Ee():window.magpieBridge&&(window.magpieBridge.registerEventName=function(){},(Gt=(z=window.magpieBridge)==null?void 0:z._resolve_)==null||Gt.call(z),(Kt=window.magpieBridge)==null||delete Kt._resolve_)})();