const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./layers-widget-Cx0UmG7s.js","./layers-widget-CouLIq29.js","./layers-widget-EsaJEcap.js","./layers-widget-CglxezVK.js","./layers-widget-98ks9uNH.js","./layers-widget.js","./layers-widget-DeqaJRh1.js","./layers-widget-BRgAlcSu.js"])))=>i.map(i=>d[i]); import{_ as s}from"./layers-widget.js";import{F as o}from"./layers-widget-98ks9uNH.js";import{c as l,b as a}from"./layers-widget-DeqaJRh1.js";class c extends HTMLElement{modal=null;productId=null;filterGroups=void 0;filterOptions=void 0;facetCode=null;referenceImageSrc=null;connectedCallback(){this.childElementCount===0&&this.appendChild(l(a)),this.productId=this.getAttribute("product-id")||null,this.referenceImageSrc=this.getAttribute("reference-image-src")||null,this.facetCode=this.getAttribute("data-facet-code")||null;const t=this.querySelector('script[type="layers/filter-groups"]');if(t&&t.textContent)try{const e=JSON.parse(t.textContent.trim()),i=o.safeParse(e);i.success?this.filterGroups=i.data:console.error("Invalid filter groups JSON structure:",i.error)}catch(e){console.error("Failed to parse filter groups JSON:",e)}const r=this.getAttribute("data-filter-options");if(r)try{this.filterOptions=JSON.parse(r)}catch(e){console.error("Failed to parse filter options JSON:",e)}this.addEventListener("click",this.handleClick)}disconnectedCallback(){this.removeEventListener("click",this.handleClick)}handleClick=async()=>{try{this.modal?(this.modal.reset(),this.modal.open()):(await s(()=>import("./layers-widget-Cx0UmG7s.js"),__vite__mapDeps([0,1,2,3,4,5,6,7]),import.meta.url),this.modal=document.createElement("layers-similar-products-modal"),this.productId&&this.modal.setAttribute("product-id",this.productId),this.referenceImageSrc&&this.modal.setAttribute("reference-image-src",this.referenceImageSrc),this.filterGroups&&this.modal.setAttribute("filter-groups",JSON.stringify(this.filterGroups)),this.filterOptions&&this.modal.setAttribute("filter-options",JSON.stringify(this.filterOptions)),this.facetCode&&this.modal.setAttribute("facet-code",this.facetCode),document.body.appendChild(this.modal))}catch(t){console.error("Failed to initialize similar products modal:",t)}}}customElements.get("layers-similar-products-toggle")||customElements.define("layers-similar-products-toggle",c);export{c as LayersSimilarProductsToggle};