var R=Object.defineProperty;var q=n=>{throw TypeError(n)};var j=(n,t,e)=>t in n?R(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var E=(n,t,e)=>j(n,typeof t!="symbol"?t+"":t,e),b=(n,t,e)=>t.has(n)||q("Cannot "+e);var l=(n,t,e)=>(b(n,t,"read from private field"),e?e.call(n):t.get(n)),u=(n,t,e)=>t.has(n)?q("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,e),d=(n,t,e,o)=>(b(n,t,"write to private field"),o?o.call(n,e):t.set(n,e),e),p=(n,t,e)=>(b(n,t,"access private method"),e);class H{static init(){document.addEventListener("click",function(t){const e=window.FluentCartSingleProductModal;if(!e)return;const o=t.target.closest("[data-fluent-cart-product-details-button]");if(o){t.preventDefault();const c=o.getAttribute("data-product-id");e.openModal(c,o)}})}}var f,C,S,y,r,s,U,B,N,O,P,$,x,D;const i=class i{constructor(){u(this,s);u(this,f,!1);u(this,C,window.fluentCartRestVars.rest.url);u(this,S,"/public/single-product-views");u(this,y,700);u(this,r,null);p(this,s,B).call(this),p(this,s,$).call(this),p(this,s,N).call(this)}async openModal(t,e){var V,T;const o=this;if(l(o,f))return;d(o,f,!0),e&&e.classList.add("loading");let c=document.createElement("div"),a=document.createElement("div");a.className="fluent-cart-shop-app-single-product-modal",a.setAttribute("data-fluent-cart-shop-app-single-product-modal","");const h=document.createElement("div");h.className="fluent-cart-shop-app-single-product-modal-overlay",h.setAttribute("data-fluent-cart-shop-app-single-product-modal-overlay",""),a.appendChild(h);const v=document.createElement("div");v.className="fluent-cart-shop-app-single-product-modal-body";const g=document.createElement("div");g.className="fct-loader-wrap show",g.setAttribute("data-fluent-cart-cart-drawer-loader","");const k=document.createElement("div");k.className="fct-loader-spinner",g.appendChild(k),v.appendChild(g),a.appendChild(v),c.style.opacity="1",c.style.pointerEvents="auto",c.appendChild(a),document.body.appendChild(c),d(o,r,a);const A=await p(V=o,s,P).call(V,t);A&&(a.innerHTML=A,d(o,r,a),p(this,s,x).call(this,a,l(o,y)),p(T=o,s,O).call(T,a),window.dispatchEvent(new CustomEvent("fluentCartSingleProductModalOpened",{detail:{productId:t}}))),document.body.style.overflow="hidden"}closeModal(t){p(this,s,D).call(this,t,l(this,y),()=>{t.remove(),document.body.style.overflow="",d(this,r,null)})}};f=new WeakMap,C=new WeakMap,S=new WeakMap,y=new WeakMap,r=new WeakMap,s=new WeakSet,U=function(){const t=document.querySelector("[data-fluent-cart-shop-app-single-product-modal-close]"),e=document.querySelector(".fluent-cart-shop-app-single-product-modal-body");if(t&&e){const o=()=>{const c=e.getBoundingClientRect(),a=e.scrollTop;t.style.right=`${window.innerWidth-c.right+5}px`,t.style.top=`${c.top+5}px`,a>=100?t.classList.add("hovered"):t.classList.remove("hovered")};o(),e.addEventListener("scroll",o),window.addEventListener("resize",o),window.addEventListener("scroll",o)}},B=function(){const t=this;document.addEventListener("click",async function(e){const o=e.target.closest("[data-fluent-cart-single-product-card-view-button]");if(!o)return;o.classList.add("fct-loading");const c=o.dataset.productId;await t.openModal(c,o),o.classList.remove("fct-loading")})},N=function(){const t=this;document.addEventListener("keydown",function(e){e.key==="Escape"&&l(t,r)&&l(t,r).querySelector("[data-fluent-cart-shop-app-single-product-modal]")&&t.closeModal(l(t,r))})},O=function(t){t.querySelectorAll("[data-fluent-cart-single-product-page]").forEach(o=>{new window.FluentCartSingleProduct().init(o,0)})},P=async function(t){if(i.cachedView[t])return d(this,f,!1),i.cachedView[t];d(this,f,!0);const{request:e,controller:o}=window.fluentCartAjax.get({action:"fluent_cart_checkout_routes",fc_checkout_action:"get_product_modal_view",product_id:t},!0),a=(await e).view;i.cachedView[t]=a;const h=Object.keys(i.cachedView);return h.length>i.cacheThreshold&&delete i.cachedView[h[0]],d(this,f,!1),a},$=function(){const t=this;document.addEventListener("click",function(e){const o=document.querySelector("[data-fluent-cart-shop-app-single-product-modal-overlay]"),c=document.querySelector("[data-fluent-cart-shop-app-single-product-modal-close]"),a=e.target.closest("[data-fluent-cart-shop-app-single-product-modal]");o&&o.contains(e.target)&&t.closeModal(a.parentElement),c&&c.contains(e.target)&&t.closeModal(a.parentElement)})},x=function(t,e){t.style.opacity="0",t.style.transition=`opacity ${e}ms ease-in-out`,t.offsetHeight,t.style.opacity="1",setTimeout(()=>{t.style.pointerEvents="auto"},e)},D=function(t,e,o){t.style.transition=`opacity ${e}ms ease-in-out`,t.style.opacity="0",setTimeout(()=>{o&&o()},e)},E(i,"cachedView",{}),E(i,"cacheThreshold",10);let L=i;var w;const m=class m{static init(){return l(m,w)!==null?l(m,w):(H.init(),d(m,w,this),this)}};w=new WeakMap,u(m,w,null);let M=m;window.addEventListener("load",function(){M.init(),window.FluentCartSingleProductModal=new L});
