function __vite__mapDeps(indexes) { if (!__vite__mapDeps.viteFileDeps) { __vite__mapDeps.viteFileDeps = ["./apps-startup.js","./vendor.js","./shared.js","./apps-js-api.js","./apps-tracker.js","./apps-add-to-bag.js","./apps-categories-v1.js","./apps-categories-v2.js","./apps-minicart-v1.js","./apps-minicart-v2.js","./apps-product-thumbnail.js","./apps-product-browser.js","./apps-product-browser-popup.js","./apps-search-panel.js","./apps-search-widget.js","./apps-single-product.js"] } return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) } const Ve="modulepreload",ke=function(t,e){return new URL(t,e).href},se={},f=function(e,r,n){let o=Promise.resolve();if(r&&r.length>0){const i=document.getElementsByTagName("link");o=Promise.all(r.map(s=>{if(s=ke(s,n),s in se)return;se[s]=!0;const u=s.endsWith(".css"),l=u?'[rel="stylesheet"]':"";if(!!n)for(let d=i.length-1;d>=0;d--){const p=i[d];if(p.href===s&&(!u||p.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${s}"]${l}`))return;const c=document.createElement("link");if(c.rel=u?"stylesheet":Ve,u||(c.as="script",c.crossOrigin=""),c.href=s,document.head.appendChild(c),u)return new Promise((d,p)=>{c.addEventListener("load",d),c.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${s}`)))})}))}return o.then(()=>e()).catch(i=>{const s=new Event("vite:preloadError",{cancelable:!0});if(s.payload=i,window.dispatchEvent(s),!s.defaultPrevented)throw i})};var Fe=Object.defineProperty,We=(t,e,r)=>e in t?Fe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ce=(t,e,r)=>(We(t,typeof e!="symbol"?e+"":e,r),r);const O={ALL:"ALL",PARTIAL:"PARTIAL",DEFAULT:"DEFAULT"},N={INFO:"INFO",WARNING:"WARNING",ERROR:"ERROR",LOG:"LOG"};function Be(t){switch(t){case N.INFO:return console.info;case N.WARNING:return console.warn;case N.ERROR:return console.error;case N.LOG:return console.info;default:throw new Error(`Unknown log level '${t}'`)}}const W="ALL";function Ge(t){return["%c%s",`background: ${t.background}; color: ${t.color}; padding: 1px 4px`,t.badgeName]}class He{constructor(e){ce(this,"localStorageKey"),ce(this,"isGreetingsPrinted",!1),this.localStorageKey=e}createDebugGreetingsData(e){const r="",n='font-family: "Monospace"; font-size: 1.1em';return[`%cTo enable all development logs please run in development console: %c localStorage.setItem("${this.localStorageKey}", "${W}") %cInstead of %c${W} %cyou can use comma separated event types list to partially enable logs. Available event types are: %O`,r,n,r,n,r,e]}printGreetingsIfNeeded(e){this.isGreetingsPrinted||(this.isGreetingsPrinted=!0,console.log(...this.createDebugGreetingsData(e)))}printLog(e,r,...n){const o=Ge(e);Be(r)(...o,...n)}getEventTypesToLog(){try{const e=window.localStorage.getItem(this.localStorageKey);return e===""||e===null?{type:O.DEFAULT}:e===W||e==="true"?{type:O.ALL}:{type:O.PARTIAL,events:e.split(",")}}catch{return{type:O.DEFAULT}}}}function L(t){for(var e=1;e"u")){s=L({},e,s),typeof s.expires=="number"&&(s.expires=new Date(Date.now()+s.expires*864e5)),s.expires&&(s.expires=s.expires.toUTCString()),o=encodeURIComponent(o).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var u="";for(var l in s)s[l]&&(u+="; "+l,s[l]!==!0&&(u+="="+s[l].split(";")[0]));return document.cookie=o+"="+t.write(i,o)+u}}function n(o){if(!(typeof document>"u"||arguments.length&&!o)){for(var i=document.cookie?document.cookie.split("; "):[],s={},u=0;u!t(e))}function V(t){I().push(t)}function Z(t){return I().find(e=>e.element===t)}function Ie(){return I().filter(t=>t.mountState===void 0||t.mountState===T.UNMOUNTED)}function ae(){return I().filter(t=>t.mountState===T.MOUNTED)}function hn(){$e(t=>t.widgetType===a.PRODUCT_BROWSER)}function qe(t){return I().find(e=>e.widgetType===t)}function Te(){return I().some(t=>t.widgetType===a.PRODUCT_BROWSER)}function je(){return I().some(t=>t.widgetType===a.PRODUCT||t.widgetType===a.SINGLE_PRODUCT)}function Se(){return I().some(t=>t.widgetType===a.MINICART_V1||t.widgetType===a.MINICART_V2)}function ye(){var r,n,o;const t=[a.PRODUCT_BROWSER,a.SINGLE_PRODUCT,a.PRODUCT,a.MINICART_V1,a.CATEGORIES_V2,a.VERTICAL_CATEGORIES_V1];for(const i of t){const s=(n=(r=I().filter(u=>u.widgetType===i))==null?void 0:r.reverse())==null?void 0:n[0];if(s!==void 0)return(o=s.element)==null?void 0:o.parentNode}const e=document.getElementsByClassName(Q);if(e.length>0){const i=e[e.length-1];return i==null?void 0:i.parentNode}}function q(t,e){var r;if(((r=document.defaultView)==null?void 0:r.getComputedStyle)!==void 0)return document.defaultView.getComputedStyle(t,null).getPropertyValue(e)}function Ye(){const t={},e=ye();if(e!==void 0){const r=q(e,"font-family");r!==void 0&&(t["font-family"]=r)}return t}function ze(t){var n;const e=document.createElement("a");e.href="",e.textContent="",t.appendChild(e);const r=((n=document.defaultView)==null?void 0:n.getComputedStyle(e,null).color)??"";return t.removeChild(e),r}function Ke(t){let e=t,r=q(e,"background-color");for(;r===void 0||r==="transparent"||r==="#000000"||r==="rgba(0, 0, 0, 0)";)e===document.documentElement?r="white":(e=e.parentNode,r=q(e,"background-color"));return r}function Xe(t,e){var n;let r;if(((n=e==null?void 0:e.chameleon)==null?void 0:n.font)!==void 0&&(r=e.chameleon.font),(r===void 0&&t||r==="auto")&&(r=Ye()),r!==void 0){const i=r["font-family"];if(i!==void 0){const s=i.split(/,\s*/);let u="",l="";for(const m of s){if(u.length+m.length+l.length>150)break;u+=l+m,l=","}return u}}}function Qe(t,e){var r,n;return t&&(((n=(r=e==null?void 0:e.chameleon)==null?void 0:r.gallery)==null?void 0:n.useExactColors)??!1)}function Ze(){var t;return((t=window.top)==null?void 0:t.location)!==window.location}function et(t,e){var m,c;let r;((m=e==null?void 0:e.chameleon)==null?void 0:m.colors)!==void 0&&(r=(c=e==null?void 0:e.chameleon)==null?void 0:c.colors);const n=document.styleSheets.length===0;if(r!==void 0&&r!=="auto"||!t||n)return r!=="auto"?r:{};const o={},i=ye();if(i===void 0)return o;const s=getComputedStyle(i,null).color;s.replace(/ /g,"")!=="rgba(0,0,0,0)"&&s!=="transparent"&&(o["color-foreground"]=s,o["color-price"]=o["color-foreground"]);const u=Ke(i);u.replace(/ /g,"")!=="rgba(0,0,0,0)"&&u!=="transparent"?o["color-background"]=u:o["color-background"]="white";const l=ze(i);return l.replace(/ /g,"")!=="rgba(0,0,0,0)"&&l!=="transparent"&&(o["color-link"]=l),o}function Ce(t,e){const r=t&&!Ze();return{isEnabled:t,colors:et(r,e),fontFamily:Xe(r,e),useExactColors:Qe(r,e)}}const tt="ecwid_body";function rt(){let t;const r=document.getElementsByTagName("body")[0];return r!==void 0&&(r.id===""&&(r.id=tt),t=r.id),t}const nt="ecwid_html";function ot(){let t;const r=document.getElementsByTagName("html")[0];return r!==void 0&&(r.id===""&&(r.id=nt),t=r.id),t}function _e(t,e){if(e===void 0)return t;let r;const n=Promise.race([t,new Promise((o,i)=>{r=setTimeout(()=>{i(new Error(`Timeout exceeded (${e} ms)`))},e)})]);return n.finally(()=>clearTimeout(r)),n}const P={SUCCESS:"success",DUPLICATE:"duplicate",FAILED:"failed"};var it=Object.defineProperty,st=(t,e,r)=>e in t?it(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,B=(t,e,r)=>(st(t,typeof e!="symbol"?e+"":e,r),r);const G={ALL:"ALL",PARTIAL:"PARTIAL",DEFAULT:"DEFAULT"},S={INFO:"INFO",WARNING:"WARNING",ERROR:"ERROR",LOG:"LOG"};class ct{constructor(e,r){B(this,"eventsLogSettings"),B(this,"loggerImpl"),B(this,"allowedEventTypes"),this.eventsLogSettings=e,this.loggerImpl=r,this.allowedEventTypes=Object.keys(this.eventsLogSettings).sort()}isNeedLogEvent(e,r,n){const o=n.type;switch(o){case G.ALL:return!0;case G.PARTIAL:return n.events.some(i=>i===e);case G.DEFAULT:return r.isDefault===!0;default:throw new Error(`Unknown event types to log '${o}'`)}}doLog(e,r,...n){this.loggerImpl.printGreetingsIfNeeded(this.allowedEventTypes);const o=this.eventsLogSettings[e];(r===S.WARNING||r===S.ERROR||this.isNeedLogEvent(e,o,this.loggerImpl.getEventTypesToLog()))&&this.loggerImpl.printLog(o,r,...n)}info(e,...r){this.doLog(e,S.INFO,...r)}warn(e,...r){this.doLog(e,S.WARNING,...r)}error(e,...r){this.doLog(e,S.ERROR,...r)}log(e,...r){this.doLog(e,S.LOG,...r)}}const g={APP_LIFECYCLE:"APP_LIFECYCLE",DEPRECATION:"DEPRECATION",JS_API:"JS_API",PERSISTENCE:"PERSISTENCE",RESOURCES:"RESOURCES",REST:"REST",ROUTER:"ROUTER",MUTATION:"MUTATION",SUSPENSE:"SUSPENSE",SSR:"SSR",TODO:"TODO",TRACKER:"TRACKER"},at={[g.APP_LIFECYCLE]:{badgeName:"app-lifecycle",background:"#006400",color:"#ffffff"},[g.DEPRECATION]:{badgeName:"deprecation",background:"#8b4513",color:"#ffffff",isDefault:!0},[g.JS_API]:{badgeName:"js-api",background:"#800080",color:"#ffffff"},[g.MUTATION]:{badgeName:"mutation",background:"#FFFF00",color:"#000000"},[g.PERSISTENCE]:{badgeName:"persistence",background:"#ff8c00",color:"#ffffff"},[g.RESOURCES]:{badgeName:"resources",background:"#20b2aa",color:"#ffffff"},[g.REST]:{badgeName:"rest",background:"#20b2aa",color:"#ffffff"},[g.ROUTER]:{badgeName:"router",background:"#1e90ff",color:"#ffffff"},[g.SUSPENSE]:{badgeName:"suspense",background:"#daa520",color:"#ffffff"},[g.SSR]:{badgeName:"ssr",background:"#191970",color:"#ffffff",isDefault:!0},[g.TODO]:{badgeName:"todo",background:"#8b0000",color:"#ffffff",isDefault:!0},[g.TRACKER]:{badgeName:"tracker",background:"#8a2be2",color:"#ffffff"}};class ut extends ct{constructor(e){super(at,e)}}function ee(t){return t!==void 0?[t]:[]}function Pe(t){return new Date().getTime()-t.getTime()}function we(t){const e=[`#${t.resourceLoadIndex}`,t.resourceType,"⮕",t.resourceUrl,...ee(t.attributes)];t.logger.info(g.RESOURCES,...e)}function Re(t){const e=Pe(t.requestStartTime),r=[`#${t.resourceLoadIndex}`,t.resourceType,"⬅",`[${e} ms]`,t.resourceUrl,...ee(t.attributes)];t.logger.info(g.RESOURCES,...r)}function M(t){const e=Pe(t.requestStartTime),r=[`#${t.resourceLoadIndex}`,t.resourceType,"⛌",`[${e} ms]`,t.resourceUrl,...ee(t.attributes),t.errorDetails];t.logger.warn(g.RESOURCES,...r)}function ue(t,e,r,n,o){const i=document.querySelectorAll(`script[src='${t}']`);if(i.length>0){const c={type:P.DUPLICATE,scriptElement:i[0]};return Promise.resolve(c)}const s=(r.resourceLoadIndex??0)+1;r.resourceLoadIndex=s;const u="🔨 JS",l=new Date;we({resourceLoadIndex:r.resourceLoadIndex,resourceType:u,resourceUrl:t,attributes:void 0,logger:n});const m=new Promise(c=>{var p;const d=document.createElement("script");d.type="text/javascript",d.src=t,d.async=e,d.onerror=()=>{M({resourceLoadIndex:s,resourceType:u,requestStartTime:l,resourceUrl:t,attributes:void 0,errorDetails:void 0,logger:n}),d.remove();const A={type:P.FAILED};c(A)},d.onload=()=>{Re({resourceLoadIndex:s,resourceType:u,requestStartTime:l,resourceUrl:t,attributes:void 0,logger:n});const A={type:P.SUCCESS,scriptElement:d};c(A)},(p=document.getElementsByTagName("head")[0])==null||p.appendChild(d)});return _e(m,o).catch(c=>(c instanceof Error&&M({resourceLoadIndex:s,resourceType:u,requestStartTime:l,resourceUrl:t,attributes:void 0,errorDetails:c.message,logger:n}),Promise.resolve({type:P.FAILED})))}const w={SUCCESS:"success",DUPLICATE:"duplicate",FAILED:"failed"},j="data-loading";function dt(t,e,r,n,o){const i=document.querySelectorAll(`link[href='${t}']`);if(i.length>0){const c={type:w.DUPLICATE,linkElement:i[0]};return Promise.resolve(c)}const s=(n.resourceLoadIndex??0)+1;n.resourceLoadIndex=s;const u="🎨 CSS",l=new Date;we({resourceLoadIndex:s,resourceType:u,resourceUrl:t,attributes:e,logger:o});const m=new Promise(c=>{var p;const d=document.createElement("link");d.rel="stylesheet",d.href=t,d.setAttribute(j,""),e!==void 0&&Object.entries(e).forEach(([A,xe])=>{d.setAttribute(A,xe)}),d.onerror=()=>{M({resourceLoadIndex:s,resourceType:u,requestStartTime:l,resourceUrl:t,attributes:e,errorDetails:void 0,logger:o}),d.remove();const A={type:w.FAILED};c(A)},d.onload=()=>{d.removeAttribute(j),Re({resourceLoadIndex:s,resourceType:u,requestStartTime:l,resourceUrl:t,attributes:e,logger:o});const A={type:w.SUCCESS,linkElement:d};c(A)},(p=document.getElementsByTagName("head")[0])==null||p.appendChild(d)});return _e(m,r).catch(c=>(M({resourceLoadIndex:s,resourceType:u,requestStartTime:l,resourceUrl:t,attributes:void 0,errorDetails:c instanceof Error?c.message:void 0,logger:o}),Promise.resolve({type:w.FAILED})))}function lt(t){return Object.entries(t).map(([e,r])=>`${encodeURIComponent(e)}=${encodeURIComponent(r.substring(0,150))}`).join("&")}function gt(t,e){const r={};return Object.entries(e.baseQueryParams).forEach(([n,o])=>{r[n]=o}),r.ownerid=e.storeId.toString(),e.cssSelectorsPrefix!==""&&(r["id-selector"]=e.cssSelectorsPrefix),e.isHoverDisabled&&(r.hover="disable"),e.chameleonParams.colors!==void 0&&Object.entries(e.chameleonParams.colors).forEach(([n,o])=>{r[n]=o}),e.chameleonParams.fontFamily!==void 0&&(r["font-family"]=e.chameleonParams.fontFamily),e.chameleonParams.useExactColors&&(r.useExactGalleryColors="true"),r.frontendV2="true",`${t}?${lt(r)}`}const ht=1e4;function mt(){return"ontouchstart"in window&&typeof window.matchMedia=="function"&&!window.matchMedia("(pointer: fine)").matches&&window.matchMedia("(hover: none)").matches}function pt(t,e){try{const r=new URL(e),n=new URL(t);return n.origin===r.origin&&n.pathname===r.pathname}catch{return!1}}function ft(t){return Array.from(document.getElementsByTagName("link")).filter(e=>!e.hasAttribute(j)).filter(e=>pt(e.href,t)).slice(0,-1)}function At(t,e,r,n,o){var l;const i={baseQueryParams:e.stylesheetsSettings.baseQueryParams,cssSelectorsPrefix:((l=r.stylesheet)==null?void 0:l.cssSelectorsPrefix)??"",chameleonParams:Ce(e.isChameleonEnabled,r.ecConfig),isHoverDisabled:mt(),storeId:t},s=m=>{const c=gt(m,i);return dt(c,{"data-ec-stylesheet":""},ht,n,o)},u=e.stylesheetsSettings.baseUrl;return s(u.primaryUrl).then(m=>(m.type===w.SUCCESS&&ft(u.primaryUrl).forEach(d=>{o.warn(g.RESOURCES,"Removing obsolete stylesheet link element",d),d.remove()}),m)).catch(()=>s(u.fallbackUrl))}function te(t,e){return{widgetType:t,id:e.id!==""?e.id:void 0,currentScript:void 0,element:e,arg:[],mountState:T.UNMOUNTED,unmountFn:void 0}}function Et(t){window.ec.config=window.ec.config??{},window.ec.config.chameleonDefaults=window.ec.config.chameleonDefaults??{},window.ec.config.chameleonDefaults.isEnabled=t.isEnabled,window.ec.config.chameleonDefaults.gallery=window.ec.config.chameleonDefaults.gallery??{},t.colors!==void 0&&(window.ec.config.chameleonDefaults.colors=t.colors),t.fontFamily!==void 0&&(window.ec.config.chameleonDefaults.font={"font-family":t.fontFamily})}function It(t){var e;window.css_selectors_prefix=((e=t.stylesheet)==null?void 0:e.cssSelectorsPrefix)??""}function Tt(t){t.then(e=>{window.ecwidMessages={...window.ecwidMessages,...e.translationsSettings.overrides}})}function St(t){if(t.cssSelectorsPrefix!==void 0)return t.cssSelectorsPrefix;let e="";return t.isCssSelectorsPrefixDisabled!==!0&&(t.htmlTagId!==void 0||t.bodyTagId!==void 0)&&(t.htmlTagId!==void 0&&(e+=`html#${t.htmlTagId}`),t.htmlTagId!==void 0&&t.bodyTagId!==void 0&&(e+=" "),t.bodyTagId!==void 0&&(e+=`body#${t.bodyTagId}`)),e}function yt(t){return JSON.parse(JSON.stringify(t))}function Ct(t){return t.chameleon!==void 0?{...t,chameleon:yt(t.chameleon)}:{...t}}const _t="ec-storefront-show-i18n-keys",Pt="ec-storefront-highlight-version";function wt(t){const e={...t};let r={};return e.queryState!==void 0&&(r=e.queryState,delete e.queryState),{queryState:r,piniaState:e}}function Rt(t,e,r,n,o){return e.then(i=>{It(r);const s=Ce(i.isChameleonEnabled,r.ecConfig);return Et(s),At(t,i,r,n,o)})}function Ot(t,e,r){return t.then(n=>{const o=n.translationsSettings.urls.map(i=>ue(i.primaryUrl,!0,e,r).then(s=>{s.type===P.FAILED&&ue(i.fallbackUrl,!0,e,r)}));return Promise.allSettled(o).then(()=>({locale:window.rosettaLanguageCode,messages:window.rosettaMessages}))})}function Nt(t,e){return{...t??{},...e.config??{}}}function Lt(t,e){return{...t??{},...e.order??{}}}function vt(t,e){return{...t??{},...e.storefront??{}}}function Dt(t){return{containerWidth:t==null?void 0:t.containerWidth}}function Ut(){var t;return((t=C.get(_t))==null?void 0:t.toString())==="true"?!0:void 0}function Mt(){var t;return((t=C.get(Pt))==null?void 0:t.toString())==="true"?!0:void 0}function bt(t){return{showI18nKeys:Ut()??(t==null?void 0:t.showI18nKeys),shouldHighlightVersion:Mt()??(t==null?void 0:t.shouldHighlightVersion)}}function xt(t,e){return{customHistoryStateHandler:(e==null?void 0:e.customHistoryStateHandler)??(t==null?void 0:t.customHistoryStateHandler)}}function Vt(t,e){const r={cssSelectorsPrefix:(e==null?void 0:e.css_selectors_prefix)??(t==null?void 0:t.cssSelectorsPrefix),isCssSelectorsPrefixDisabled:(e==null?void 0:e.ecwid_nocssrewrite)??(t==null?void 0:t.isCssSelectorsPrefixDisabled),htmlTagId:ot()??(t==null?void 0:t.htmlTagId),bodyTagId:rt()??(t==null?void 0:t.bodyTagId)};return{...r,cssSelectorsPrefix:St(r)}}function kt(t,e){return{signInProvider:t==null?void 0:t.signInProvider,signInUrls:t==null?void 0:t.signInUrls,ssoProfile:e.ecwid_sso_profile??(t==null?void 0:t.ssoProfile)}}function Ft(t){var r;const e=(r=t.globalOverrides)==null?void 0:r.globalOverrides;return{ecConfig:Ct(Nt(e==null?void 0:e.ecConfig,window.ec)),ecOrder:Lt(e==null?void 0:e.ecOrder,window.ec),ecStorefront:vt(e==null?void 0:e.ecStorefront,window.ec),browser:Dt(e==null?void 0:e.browser),debug:bt(e==null?void 0:e.debug),routing:xt(e==null?void 0:e.routing,window.Ecwid),stylesheet:Vt(e==null?void 0:e.stylesheet,window),sso:kt(e==null?void 0:e.sso,window)}}function Wt(t,e){const r=Z(t.containerElement);if(r!==void 0)return r;const n=te(e,t.containerElement);return V(n),n}function _(t){if(t.containerElement===void 0||t.containerElement===null)throw new Error("Cannot find containerElement, please sure that it is passed to the widget options correctly.");const{containerElement:e,rootProps:r,states:n}=t;return{containerElement:e,rootProps:r,states:n}}function de(){return document.createElement("div")}class Bt{constructor(e){this.options=e}getBootstrapPromise(){return this.options.bootstrapPromise}async createWidget(e,r){const n=r.states??{},{queryState:o,piniaState:i}=wt(n),s=Ft(i),u=this.widgetData??this.createWidgetData(s,this.options);Tt(this.options.bootstrapPromise),this.widgetData=u;const l={containerElement:r.containerElement,isHydrateExistingMarkup:Object.keys(n).length>0,queryState:o,piniaState:{...i,globalOverrides:{globalOverrides:s}},rootProps:r.rootProps??{},bootstrap:this.options.bootstrapPromise,widgetData:u,storefrontApiClient:this.options.storefrontApiClient,sessionStorageOptions:this.options.sessionStorageOptions,requestContext:this.options.requestContext,ecommerce:this.options.ecommerce,logger:this.options.logger};return await(await e).render(l)}createWidgetData(e,r){return{appMode:r.appMode,customizeStorefrontAppsResources:Promise.resolve(void 0),stylesheet:Rt(this.options.sessionStorageOptions.storeId,this.options.bootstrapPromise,e,this.options.requestContext,this.options.logger),translations:Ot(this.options.bootstrapPromise,this.options.requestContext,this.options.logger)}}getOrCreateConfigAndWidget(e,r,n){const o=_(r),i=Wt(o,n);return i.ecwidWidget!==void 0&&i.mountState!==T.UNMOUNTED||(i.mountState=T.MOUNTING,i.ecwidWidget=this.createWidget(e,o).then(s=>(i.mountState=T.MOUNTED,i.unmountFn=()=>{i.mountState=T.UNMOUNTED,i.unmountFn=void 0,s.unmountFn()},s))),i.ecwidWidget}createOrGetStartup(e){if(this.startupApp===void 0){const r=_({containerElement:de(),rootProps:{},states:e.states});this.startupApp=this.createWidget(f(()=>import("./apps-startup.js"),__vite__mapDeps([0,1,2]),import.meta.url),r)}return this.startupApp}createOrGetJsApi(){if(this.jsApi===void 0){const e=_({containerElement:de(),rootProps:{}});this.jsApi=this.createOrGetStartup(e).then(()=>this.createWidget(f(()=>import("./apps-js-api.js"),__vite__mapDeps([3,1,2]),import.meta.url),e))}return this.jsApi}createTracker(e){return this.createOrGetStartup(e).then(()=>this.createWidget(f(()=>import("./apps-tracker.js").then(r=>r.l),__vite__mapDeps([4,1,2]),import.meta.url),_(e)))}createAddToBag(e){return this.createOrGetStartup(e).then(()=>this.getOrCreateConfigAndWidget(f(()=>import("./apps-add-to-bag.js"),__vite__mapDeps([5,2,1]),import.meta.url),e,a.ADD_TO_BAG))}createCategoriesV1(e){var n;const r=((n=e.rootProps)==null?void 0:n.direction)===$.VERTICAL?a.VERTICAL_CATEGORIES_V1:a.HORIZONTAL_CATEGORIES_V1;return this.createOrGetStartup(e).then(()=>this.getOrCreateConfigAndWidget(f(()=>import("./apps-categories-v1.js"),__vite__mapDeps([6,1,2]),import.meta.url),e,r))}createCategoriesV2(e){return this.createOrGetStartup(e).then(()=>this.getOrCreateConfigAndWidget(f(()=>import("./apps-categories-v2.js"),__vite__mapDeps([7,1,2]),import.meta.url),e,a.CATEGORIES_V2))}createMinicartV1(e){return this.createOrGetStartup(e).then(()=>this.getOrCreateConfigAndWidget(f(()=>import("./apps-minicart-v1.js"),__vite__mapDeps([8,1,2]),import.meta.url),e,a.MINICART_V1))}createMinicartV2(e){return this.createOrGetStartup(e).then(()=>this.getOrCreateConfigAndWidget(f(()=>import("./apps-minicart-v2.js"),__vite__mapDeps([9,1,2]),import.meta.url),e,a.MINICART_V2))}createProductThumbnail(e){return this.createOrGetStartup(e).then(()=>this.getOrCreateConfigAndWidget(f(()=>import("./apps-product-thumbnail.js"),__vite__mapDeps([10,2,1]),import.meta.url),e,a.PRODUCT_THUMBNAIL))}createProductBrowser(e){return this.createOrGetStartup(e).then(()=>this.getOrCreateConfigAndWidget(f(()=>import("./apps-product-browser.js").then(r=>r.b1),__vite__mapDeps([11,1,2]),import.meta.url),e,a.PRODUCT_BROWSER))}createProductBrowserPopup(e){return this.createOrGetStartup(e).then(()=>this.createWidget(f(()=>import("./apps-product-browser-popup.js"),__vite__mapDeps([12,1,2]),import.meta.url),_(e)))}createSearchPanel(e){return this.createOrGetStartup(e).then(()=>this.getOrCreateConfigAndWidget(f(()=>import("./apps-search-panel.js"),__vite__mapDeps([13,1,2]),import.meta.url),e,a.SEARCH_PANEL))}createSearchWidget(e){return this.createOrGetStartup(e).then(()=>this.getOrCreateConfigAndWidget(f(()=>import("./apps-search-widget.js"),__vite__mapDeps([14,1,2]),import.meta.url),e,a.SEARCH_WIDGET))}createSingleProduct(e){return this.createOrGetStartup(e).then(()=>this.getOrCreateConfigAndWidget(f(()=>import("./apps-single-product.js"),__vite__mapDeps([15,2,1]),import.meta.url),e,a.SINGLE_PRODUCT))}}class Gt{constructor(e){this.legacyApiImpl=e}setInternalState(e){return this.legacyApiImpl.ensureJsApiSync().setRouterExternalState(e)}}const Oe={TOP_LEFT:"TOP_LEFT",TOP_RIGHT:"TOP_RIGHT",BOTTOM_LEFT:"BOTTOM_LEFT",BOTTOM_RIGHT:"BOTTOM_RIGHT"},k={RECT:"RECT",PILL:"PILL",NONE:"NONE"},Ne={BAG:"BAG",CART:"CART",BASKET:"BASKET"},Le={SMALL_ICON:"SMALL_ICON",SMALL_ICON_COUNTER:"SMALL_ICON_COUNTER",COUNTER_ONLY:"COUNTER_ONLY",TITLE_COUNTER:"TITLE_COUNTER",MEDIUM_ICON_COUNTER:"MEDIUM_ICON_COUNTER",MEDIUM_ICON_TITLE_COUNTER:"MEDIUM_ICON_TITLE_COUNTER",BIG_ICON_TITLE_SUBTOTAL:"BIG_ICON_TITLE_SUBTOTAL",BIG_ICON_DETAILS_SUBTOTAL:"BIG_ICON_DETAILS_SUBTOTAL"},h={DATA_LAYOUT:"data-layout",DATA_ICON:"data-icon",DATA_FIXED:"data-fixed",DATA_FIXED_POSITION:"data-fixed-position",DATA_FIXED_SHAPE:"data-fixed-shape",DATA_HORIZONTAL_INDENT:"data-horizontal-indent",DATA_VERTICAL_INDENT:"data-vertical-indent",DATA_RESPONSIVE:"data-responsive",DATA_CUSTOM_ICON_URL:"data-custom-icon-url",DATA_SHOW_EMPTY_CART:"data-show-empty-cart",DATA_SHOW_BUY_ANIMATION:"data-show-buy-animation"};function Ht(){const t=document.createElement("div");return t.setAttribute(h.DATA_FIXED,"true"),t.setAttribute(h.DATA_FIXED_SHAPE,k.PILL),t.setAttribute(h.DATA_SHOW_EMPTY_CART,"false"),t.className=Q,t}function ve(t){if(t!==void 0){const e=document.getElementById(t);if(e!==null)return e}}const le="autogenerated";function Jt(t){if(t===void 0)return document.body;const e=t.nextElementSibling;if(e instanceof HTMLElement&&e.dataset[le]!==void 0)return e;const r=document.createElement("div");return r.dataset[le]="true",t.insertAdjacentElement("afterend",r),r}function Y(t){const e=document.createElement("div");return e.id=t.id??`${t.widgetType}-${new Date().getTime()}`,Jt(t.currentScript).appendChild(e),e}function z(t){if(t.element!==void 0&&t.element!==null)return t.element;const e=ve(t.id);if(e!==void 0)return e}class $t{constructor(e,r,n){this.affiliateId=void 0,this.OnAPILoaded={add:o=>{this.legacyApiImpl.getJsApiAsync().then(i=>{i.onApiLoaded(o)})}},this.OnCartChanged={add:o=>{this.legacyApiImpl.getJsApiAsync().then(i=>{i.onCartChanged(o)})}},this.OnCartSynchronized={add:o=>{this.legacyApiImpl.getJsApiAsync().then(i=>{i.onCartSynchronized(o)})},clear:()=>{this.legacyApiImpl.getJsApiAsync().then(o=>{o.clearCartSynchronizedHandlers()})}},this.OnConsentChanged={add:o=>{this.legacyApiImpl.getJsApiAsync().then(i=>{i.onConsentChanged(o)})}},this.OnOrderPlaced={add:o=>{this.legacyApiImpl.getJsApiAsync().then(i=>{i.onOrderPlaced(o)})}},this.OnPageLoad={add:o=>{this.legacyApiImpl.getJsApiAsync().then(i=>{i.onPageLoad(o)})}},this.OnPageLoaded={add:o=>{this.legacyApiImpl.getJsApiAsync().then(i=>{i.onPageLoaded(o)})}},this.OnPageSwitch={add:o=>{this.legacyApiImpl.getJsApiAsync().then(i=>{i.onPageSwitch(o)})}},this.OnProductOptionsChanged={add:o=>{this.legacyApiImpl.getJsApiAsync().then(i=>{i.onProductOptionsChanged(o)})}},this.OnRouterExternalStateChanged={add:o=>{this.legacyApiImpl.getJsApiAsync().then(i=>{i.onRouterExternalStateChanged(o)})},clear:()=>{this.legacyApiImpl.getJsApiAsync().then(o=>{o.clearRouterExternalStateChangedHandlers()})}},this.OnSessionChanged={add:o=>{this.legacyApiImpl.getJsApiAsync().then(i=>{i.onSessionChanged(o)})}},this.OnSetProfile={add:o=>{this.legacyApiImpl.getJsApiAsync().then(i=>{i.onSetProfile(o)})}},this.legacyApiImpl=e,this.widgetRendererImpl=r,this.logger=n}customerSignOut(e){this.legacyApiImpl.getJsApiAsync().then(r=>{r.customerSignOut(e)})}createMinicartV2Config(e=void 0){let r=e;r===void 0&&(r=Ht(),document.body.appendChild(r));const n=te(a.MINICART_V2,r);return V(n),n}addMinicartV2Widgets(){const e=Array.from(document.getElementsByClassName(Q));if(e.length>0){const n=e.filter(o=>Z(o)===void 0).map(o=>this.createMinicartV2Config(o));return Promise.resolve(n)}if(je()&&!Te()&&!Se()){const n=this.createMinicartV2Config();return Promise.resolve([n])}return this.legacyApiImpl.getEcommerce().widgets.getBootstrapPromise().then(n=>{var o,i;return n.shouldInitMinicartForced&&((o=window.ec.storefront)==null?void 0:o.show_cart_widget)!==!1||((i=window.ec.storefront)==null?void 0:i.show_cart_widget)===!0?[this.createMinicartV2Config()]:[]})}_showPBLoader(){this.logger.warn(g.DEPRECATION,"Method Ecwid._showPBLoader() is a dummy in current implementation")}_onComplete(){this.logger.warn(g.DEPRECATION,"Method Ecwid._onComplete() is a dummy in current implementation")}destroy(){const e=ae().filter(r=>r.widgetType===a.PRODUCT_BROWSER);e.length>0&&(this.logger.info(g.JS_API,"Ecwid.destroy()"),e.forEach(r=>{r.unmountFn!==void 0&&r.unmountFn()}))}formatCurrency(e){return this.legacyApiImpl.ensureJsApiSync().formatCurrency(e)}init(){this.logger.info(g.JS_API,"Ecwid.init()"),setTimeout(()=>{Ie().forEach(e=>this.initWidget(e)),this.addMinicartV2Widgets().then(e=>{e.forEach(r=>this.initWidget(r))})},0)}initWidget(e){try{let r=z(e);if(e.id!==void 0&&r===void 0)throw new Error(`No such element: ${e.id}`);r=r??Y(e),e.element=r,e.id=r.id,this.widgetRendererImpl.renderWidget(e,r).then()}catch(r){this.logger.warn(g.APP_LIFECYCLE,"Cannot initialize widget",r)}}isCheckoutMutating(){return this.legacyApiImpl.ensureJsApiSync().isCheckoutMutating()}isStorefrontV3(){throw new Error("This method is implemented in entrypoint and should not be invoked")}getAppPublicConfig(e){return this.legacyApiImpl.ensureJsApiSync().getAppPublicConfig(e)}getAppPublicToken(e){return this.legacyApiImpl.ensureJsApiSync().getAppPublicToken(e)}getAndClearLegacyStorefrontNotice(){return this.legacyApiImpl.ensureJsApiSync().getAndClearLegacyStorefrontNotice()}getCheckoutInfo(){return this.legacyApiImpl.ensureJsApiSync().getCheckoutInfo()}getLegacyAuthToken(){return this.legacyApiImpl.ensureJsApiSync().getLegacyAuthToken()}getFeatureToggles(){return this.legacyApiImpl.ensureJsApiSync().getFeatureToggles()}getInitializedWidgets(){const e=ae().map(n=>n.widgetType),r=[...new Set(e)];return this.logger.info(g.JS_API,"Ecwid.getInitializedWidgets()",r),r}getPageSwitchCallbacks(){return this.legacyApiImpl.ensureJsApiSync().getPageSwitchCallbacks()}getStoreConfiguration(){return this.legacyApiImpl.ensureJsApiSync().getStoreConfiguration()}getStorefrontLang(){return this.legacyApiImpl.ensureJsApiSync().getStorefrontLang()}getOwnerId(){throw new Error("This method is implemented in entrypoint and should not be invoked")}getStaticBaseUrl(){return this.logger.warn(g.DEPRECATION,`Method Ecwid.getStaticBaseUrl() returns nothing in current implementation. If you use this method in your scripts, please contact us at https://support.ecwid.com/hc/en-us/requests/new`),""}scrollToContent(){return this.legacyApiImpl.ensureJsApiSync().scrollToContent()}getTrackingConsent(){return this.legacyApiImpl.ensureJsApiSync().getTrackingConsent()}getVisitorLocation(){return this.legacyApiImpl.ensureJsApiSync().getVisitorLocation()}onAllCheckoutMutationsCompleted(e){return this.legacyApiImpl.ensureJsApiSync().onAllCheckoutMutationsCompleted(e)}openCookiesSettingSidePanel(){return this.legacyApiImpl.ensureJsApiSync().openCookiesSettingSidePanel()}openPage(e,r){return this.legacyApiImpl.ensureJsApiSync().openPage(e,r)}refreshConfig(){this.legacyApiImpl.ensureJsApiSync().refreshConfig(window.ec)}resizeProductBrowser(){this.logger.warn(g.DEPRECATION,"Method Ecwid.resizeProductBrowser() is do nothing in current implementation and its call can be removed")}setSignInProvider(e){this.legacyApiImpl.getJsApiAsync().then(r=>{r.setSignInProvider(e)})}setSignInUrls(e){this.legacyApiImpl.getJsApiAsync().then(r=>{r.setSignInUrls(e)})}setSsoProfile(e){this.legacyApiImpl.getJsApiAsync().then(r=>{r.setSsoProfile(e)})}setCheckoutInfo(e){this.legacyApiImpl.ensureJsApiSync().setCheckoutInfo(e)}setLegacyAuthToken(e){this.legacyApiImpl.ensureJsApiSync().setLegacyAuthToken(e)}setSession(e){this.legacyApiImpl.ensureJsApiSync().setSession(e)}setStorefrontBaseUrl(e){this.legacyApiImpl.getJsApiAsync().then(r=>{r.setStorefrontBaseUrl(e)})}setTrackingConsent(e){this.legacyApiImpl.getJsApiAsync().then(r=>{r.setTrackingConsent(e)})}showProductFilters(){this.legacyApiImpl.ensureJsApiSync().showProductFilters()}}function De(t){const e={};return t.forEach(r=>{const n=r.split("=");if(n.length===2){const o=n[0],i=n[1];o!==void 0&&i!==void 0&&(e[o]=i)}}),e}const qt="id";function jt(t){return t.find(e=>e instanceof HTMLScriptElement)}const Yt=t=>t.filter(e=>typeof e=="string");function zt(t,e){const r=jt(e),n=Yt(e),i=De(n)[qt];return{widgetType:t,id:i,element:ve(i),currentScript:r,arg:n,mountState:T.UNMOUNTED,unmountFn:void 0}}function Kt(t){document.querySelectorAll("div[itemtype='http://schema.org/Product'], div[itemtype='https://schema.org/Product']").forEach(r=>{Z(r)===void 0&&V(te(t,r))})}class Xt{constructor(e,r){this.widgetRendererImpl=e,this.logger=r}xWidget(e,r){try{const n=this.getOrCreateWidgetConfig(e,r),o=z(n)??Y(n);n.element=o,n.id=o.id,this.widgetRendererImpl.renderWidget(n,o)}catch(n){this.logger.warn(g.APP_LIFECYCLE,"Cannot initialize widget",n)}}getOrCreateWidgetConfig(e,r){let n;if(e===a.PRODUCT_BROWSER&&(n=qe(a.PRODUCT_BROWSER)),n!==void 0)return n;const o=zt(e,r);return V(o),o}addMinicartIfNeeded(){!Te()&&!Se()&&this.xWidget(a.MINICART_V2,[`${h.DATA_FIXED}=true`,`${h.DATA_FIXED_SHAPE}=${k.PILL}`,`${h.DATA_SHOW_EMPTY_CART}=false`])}xSingleProductWidgets(e){Kt(e),Ie().filter(r=>r.widgetType===e).forEach(r=>{try{const n=z(r)??Y(r);r.element=n,r.id=n.id,this.widgetRendererImpl.renderWidget(r,n).then(()=>this.addMinicartIfNeeded())}catch(n){this.logger.warn(g.APP_LIFECYCLE,"Cannot initialize widget",n)}})}xProductBrowser(...e){window.getEcwidV3Object().destroy(),setTimeout(()=>this.xWidget(a.PRODUCT_BROWSER,e),0)}xMinicart(...e){this.xWidget(a.MINICART_V1,e)}xSearchPanel(...e){this.xWidget(a.SEARCH_PANEL,e)}xSearch(...e){this.xWidget(a.SEARCH_WIDGET,e)}xCategories(...e){this.xWidget(a.HORIZONTAL_CATEGORIES_V1,e)}xCategoriesV2(...e){this.xWidget(a.CATEGORIES_V2,e)}xVCategories(...e){this.xWidget(a.VERTICAL_CATEGORIES_V1,e)}ecwid_onBodyDone(){this.logger.warn(g.DEPRECATION,"Function window.ecwid_onBodyDone() is deprecated. Use window.Ecwid.init() instead"),window.getEcwidV3Object().init()}xAddToBag(...e){this.xWidget(a.ADD_TO_BAG,e)}xProductThumbnail(...e){this.xWidget(a.PRODUCT_THUMBNAIL,e)}xSingleProduct(){this.xSingleProductWidgets(a.SINGLE_PRODUCT)}xProduct(){this.xSingleProductWidgets(a.PRODUCT)}}class Qt{constructor(e){this.legacyApiImpl=e}addProduct(e,r){this.legacyApiImpl.getJsApiAsync().then(n=>{typeof e=="object"?n.addProductToCart(e):n.addProductToCart({id:parseInt(e.toString(),10),callback:r??(()=>{})})})}removeProduct(e,r){this.legacyApiImpl.getJsApiAsync().then(n=>{typeof e>"u"?n.removeFromCart(void 0,!1,r):n.removeFromCart([e],!1,r)})}removeProducts(e,r){this.legacyApiImpl.getJsApiAsync().then(n=>{n.removeFromCart(e,!0,r)})}clear(e){this.legacyApiImpl.getJsApiAsync().then(r=>{r.clearCart(e)})}get(e){this.legacyApiImpl.getJsApiAsync().then(r=>{r.getCart(e)})}calculateTotal(e){this.legacyApiImpl.getJsApiAsync().then(r=>{r.calculateTotal(e)})}gotoCheckout(e){this.legacyApiImpl.getJsApiAsync().then(r=>{r.goToCheckout(e)})}canGotoCheckout(e){return this.legacyApiImpl.getJsApiAsync().then(r=>{r.canGoToCheckout(e)}),!0}setCustomerEmail(e,r,n){if(this.isEmptyString(e))return;const o="Ecwid.Cart.setCustomerEmail()";this.legacyApiImpl.getJsApiAsync().then(i=>{i.updateCart({email:e},r,n,o)})}setOrderComments(e,r,n){if(this.isEmptyString(e))return;const o="Ecwid.Cart.setOrderComments()";this.legacyApiImpl.getJsApiAsync().then(i=>{i.updateCart({orderComments:e},r,n,o)})}setAddress(e,r,n){const o="Ecwid.Cart.setAddress()";this.legacyApiImpl.getJsApiAsync().then(i=>{i.updateCart({shippingPerson:e},r,n,o)})}setBillingAddress(e,r,n){const o="Ecwid.Cart.setBillingAddress()";this.legacyApiImpl.getJsApiAsync().then(i=>{i.updateCart({billingPerson:e},r,n,o)})}refreshCartInfo(e){this.legacyApiImpl.getJsApiAsync().then(r=>{r.refreshCartInfo(e)})}isEmptyString(e){return e===void 0||e.trim()===""}}const v={STANDARD:"STANDARD",MINI:"MINI",FLOATING:"FLOATING",UNSUPPORTED:"UNSUPPORTED"};function R(t){var e;switch((e=t==null?void 0:t.toString())==null?void 0:e.toLowerCase()){case"true":case"1":return!0;case"false":case"0":return!1;default:return}}function b(t){if(t!==void 0){const e=parseInt(t==null?void 0:t.toString(),10);if(!Number.isNaN(e))return e}}function mn(t){if(t!==void 0){const e=parseFloat(t);if(!Number.isNaN(e))return e}}function y(t,e){for(const r of Object.keys(t)){const n=t[r];if(n!==void 0&&n.toString()===e)return t[r]}}function re(t,e){const r=t.getAttribute(e);if(r!==null)return r}function K(t,e){const r=re(t,e);return b(r)}function D(t,e){const r=re(t,e);return R(r)}function U(t,e,r){return y(r,t.getAttribute(e))}const ge="productid",Zt="layout",er="defaultCategoryId",tr="defaultProductId",rr=/grid\((?\d+), *(?\d+)\)/,nr="views",he="productid",me="data-single-product-id";function or(t){const e=t[nr];if(e!==void 0){const r=e.match(rr);if(r!==null&&r.groups!==void 0&&r.groups.rows!==void 0&&r.groups.cols!==void 0){const n=Math.max(1,parseInt(r.groups.rows,10)),o=Math.max(1,parseInt(r.groups.cols,10));return n*o}}}function ir(t){const e=t[er],r=e!==void 0?parseInt(e,10):NaN;return!Number.isNaN(r)&&r>0?r:void 0}function sr(t){const e=t[tr],r=e!==void 0?parseInt(e,10):NaN;return!Number.isNaN(r)&&r>0?r:void 0}function cr(t,e){const r=e[Zt]??"";return r.toLowerCase().includes("attach")?v.UNSUPPORTED:r==="floating"?v.FLOATING:r==="Mini"?v.MINI:v.STANDARD}function ar(t){const e=b(t[ge]);if(e===void 0)throw new Error(`Parameter '${ge}' is missing or invalid`);return e}function ur(t,e,r){return{productId:e,pageProductIdsPromise:r}}function dr(t,e){return{layout:cr(t,e)}}function lr(t){return{isMobileViewNotAllowed:t.hasAttribute("data-mobile-no"),isChildrenNotAllowed:t.hasAttribute("data-children-no")}}function gr(t){return{layout:U(t,h.DATA_LAYOUT,Le),icon:U(t,h.DATA_ICON,Ne),isFixed:D(t,h.DATA_FIXED),fixedPosition:U(t,h.DATA_FIXED_POSITION,Oe),fixedShape:U(t,h.DATA_FIXED_SHAPE,k),horizontalIndent:K(t,h.DATA_HORIZONTAL_INDENT),verticalIndent:K(t,h.DATA_VERTICAL_INDENT),isResponsive:D(t,h.DATA_RESPONSIVE),customIconUrl:re(t,h.DATA_CUSTOM_ICON_URL),showEmptyCart:D(t,h.DATA_SHOW_EMPTY_CART),showBuyAnimation:D(t,h.DATA_SHOW_BUY_ANIMATION)}}function hr(t){return{layout:y(Le,t[h.DATA_LAYOUT]),icon:y(Ne,t[h.DATA_ICON]),isFixed:R(t[h.DATA_FIXED]),fixedPosition:y(Oe,t[h.DATA_FIXED_POSITION]),fixedShape:y(k,t[h.DATA_FIXED_SHAPE]),horizontalIndent:b(t[h.DATA_HORIZONTAL_INDENT]),verticalIndent:b(t[h.DATA_VERTICAL_INDENT]),isResponsive:R(t[h.DATA_RESPONSIVE]),customIconUrl:t[h.DATA_CUSTOM_ICON_URL],showEmptyCart:R(t[h.DATA_SHOW_EMPTY_CART]),showBuyAnimation:R(t[h.DATA_SHOW_BUY_ANIMATION])}}function mr(t,e){const r=gr(t),n=hr(e);return{layout:n.layout??r.layout,icon:n.icon??r.icon,isFixed:n.isFixed??r.isFixed,fixedPosition:n.fixedPosition??r.fixedPosition,fixedShape:n.fixedShape??r.fixedShape,horizontalIndent:n.horizontalIndent??r.horizontalIndent,verticalIndent:n.verticalIndent??r.verticalIndent,isResponsive:n.isResponsive??r.isResponsive,customIconUrl:n.customIconUrl??r.customIconUrl,showEmptyCart:n.showEmptyCart??r.showEmptyCart,showBuyAnimation:n.showBuyAnimation??r.showBuyAnimation}}function pr(t){return{defaultCategoryId:ir(t),defaultProductId:sr(t),productsPerPage:or(t),timeZoneOffset:void 0}}function fr(t){const e=t[he],r=e!==void 0?parseInt(e,10):NaN;if(Number.isNaN(r))throw new Error(`Parameter '${he}' is missing or invalid`);return r}function Ar(t,e){return{productId:t,pageProductIdsPromise:e}}function pe(t){const e=K(t,me);if(e===void 0)throw new Error(`Attribute '${me}' is missing or invalid`);return e}function fe(t,e,r){return{productId:t,pageProductIdsPromise:e,isNewLookAndFeel:r}}class Er{constructor(e){this.pageProductIds=new Set,this.ecommerce=e}collectPageProductId(e){return this.pageProductIds.add(e),new Promise(r=>{setTimeout(()=>{const n=[...this.pageProductIds].sort();r(n)},0)})}renderWidget(e,r){const n=De(e.arg??[]);switch(e.widgetType){case a.ADD_TO_BAG:{const o=ar(n),i=this.collectPageProductId(o);return this.ecommerce.widgets.createAddToBag({containerElement:r,rootProps:ur(r,o,i)})}case a.HORIZONTAL_CATEGORIES_V1:return this.ecommerce.widgets.createCategoriesV1({containerElement:r,rootProps:{direction:$.HORIZONTAL}});case a.CATEGORIES_V2:return this.ecommerce.widgets.createCategoriesV2({containerElement:r,rootProps:lr(r)});case a.MINICART_V1:return this.ecommerce.widgets.createMinicartV1({containerElement:r,rootProps:dr(r,n)});case a.MINICART_V2:return this.ecommerce.widgets.createMinicartV2({containerElement:r,rootProps:mr(r,n)});case a.PRODUCT:{const o=pe(r),i=this.collectPageProductId(o);return this.ecommerce.widgets.createSingleProduct({containerElement:r,rootProps:fe(o,i,!0)})}case a.PRODUCT_BROWSER:return this.ecommerce.widgets.createProductBrowser({containerElement:r,rootProps:pr(n)});case a.PRODUCT_THUMBNAIL:{const o=fr(n),i=this.collectPageProductId(o);return this.ecommerce.widgets.createProductThumbnail({containerElement:r,rootProps:Ar(o,i)})}case a.SEARCH_PANEL:return this.ecommerce.widgets.createSearchPanel({containerElement:r,rootProps:{}});case a.SEARCH_WIDGET:return this.ecommerce.widgets.createSearchWidget({containerElement:r,rootProps:{}});case a.SINGLE_PRODUCT:{const o=pe(r),i=this.collectPageProductId(o);return this.ecommerce.widgets.createSingleProduct({containerElement:r,rootProps:fe(o,i,!1)})}case a.VERTICAL_CATEGORIES_V1:return this.ecommerce.widgets.createCategoriesV1({containerElement:r,rootProps:{direction:$.VERTICAL}});default:throw new Error(`Unknown widget type '${e.widgetType}'`)}}}class Ir{constructor(e,r,n){this.ecommerce=e;const o=new Er(this.ecommerce);this.ecImpl=new Gt(this),this.ecwidImpl=new $t(this,o,n),this.ecwidCartImpl=new Qt(this),this.windowImpl=new Xt(o,n)}getEcImpl(){return this.ecImpl}getEcwidImpl(){return this.ecwidImpl}getEcwidCartImpl(){return this.ecwidCartImpl}getWindowImpl(){return this.windowImpl}getEcommerce(){return this.ecommerce}ensureJsApiSync(){if(this.jsApiSync===void 0)throw Error(`Ecwid JS API is not initialized! Please make sure your code is wrapped in an Ecwid.OnAPILoaded.add callback. See the documentation for more details: https://api-docs.ecwid.com/reference/ecwidonapiloaded#ecwidonapiloaded`);return this.jsApiSync}getJsApiAsync(){const r=this.getEcommerce().widgets.createOrGetJsApi();return r.then(n=>{this.jsApiSync=n}),r}getTrackerAsync(){if(this.trackerAsync===void 0){const e=this.getEcommerce(),r=document.createElement("div");this.trackerAsync=e.widgets.createTracker({containerElement:r,rootProps:{}})}return this.trackerAsync}}class Tr extends EventTarget{addEventListener(e,r,n){super.addEventListener(e,r,n)}removeEventListener(e,r,n){super.removeEventListener(e,r,n)}dispatchTypedEvent(e,r){return super.dispatchEvent(r)}}function Sr(t){return typeof t!="function"||!t.toString().includes("[native code]")}function yr(t,e,r,n){const o=e;Sr(o[r])&&(t.warn(g.APP_LIFECYCLE,`Restoring patched browser function '${r}'. Old value:`,o[r]),o[r]=n)}function Cr(){const t=document.createElement("iframe");document.body.appendChild(t);const e=t.contentWindow;try{return e===null?[]:[{target:window.Array,property:"from",iframeCorrectFunc:e.Array.from},{target:Function.prototype,property:"bind",iframeCorrectFunc:e.window.Function.prototype.bind},{target:String.prototype,property:"replaceAll",iframeCorrectFunc:e.window.String.prototype.replaceAll},{target:String.prototype,property:"trim",iframeCorrectFunc:e.window.String.prototype.trim},{target:String.prototype,property:"trimLeft",iframeCorrectFunc:e.window.String.prototype.trimLeft},{target:String.prototype,property:"trimRight",iframeCorrectFunc:e.window.String.prototype.trimRight},{target:window.Promise,property:"allSettled",iframeCorrectFunc:e.window.Promise.allSettled}]}finally{t.remove()}}function _r(t){try{Cr().forEach(({target:r,property:n,iframeCorrectFunc:o})=>{yr(t,r,n,o)})}catch(e){t.error(g.APP_LIFECYCLE,"Failed to restore patched browser functions:",e)}}class Ue{constructor(e){this.keyNamePlaceholder=e}buildKeyName(e){return this.keyNamePlaceholder.replaceAll("{storeId}",e.toString())}getValue(e){try{return window.localStorage.getItem(this.buildKeyName(e))??void 0}catch{return}}setValue(e,r){try{r===void 0?window.localStorage.removeItem(this.buildKeyName(e)):window.localStorage.setItem(this.buildKeyName(e),r)}catch{}}}function Pr(t){const e=t;return typeof t=="object"&&t!==null&&(e.id===void 0||typeof e.id=="string")&&typeof e.itemsCount=="number"}class wr{constructor(){this.checkoutInfoStorage=new Ue("ec-{storeId}-checkout")}getValue(e){const r=this.checkoutInfoStorage.getValue(e);if(r!==void 0)try{const n=JSON.parse(r);if(Pr(n))return n}catch{}}setValue(e,r){const n=r===void 0?void 0:JSON.stringify(r);this.checkoutInfoStorage.setValue(e,n)}}class Rr{constructor(e,r){this.cookieName=e,this.expiresDays=r}buildCookieName(e){return this.cookieName.replaceAll("{storeId}",e.toString())}getValue(e){return C.get(this.buildCookieName(e))}setValue(e,r){if(r===void 0)C.remove(this.buildCookieName(e));else{const n=window.location.protocol==="https:";C.set(this.buildCookieName(e),r,{sameSite:n?"None":"Lax",secure:n,expires:this.expiresDays})}}}class ne{constructor(e){this.storeIdToValueMap={},this.afterSetFn=e}getValue(e){return this.storeIdToValueMap[e]}setValue(e,r){this.storeIdToValueMap[e]!==r&&(this.storeIdToValueMap[e]=r,this.afterSetFn(e,r))}}const oe={ON_SESSION_TOKEN_CHANGED:"ON_SESSION_TOKEN_CHANGED",ON_CHECKOUT_INFO_CHANGED:"ON_CART_ID_CHANGED",ON_LEGACY_AUTH_TOKEN_CHANGED:"ON_LEGACY_AUTH_TOKEN_CHANGED"};class Or extends ne{constructor(e){super((r,n)=>{e.publish(oe.ON_SESSION_TOKEN_CHANGED,n)})}}class Nr extends ne{constructor(e){super((r,n)=>{e.publish(oe.ON_CHECKOUT_INFO_CHANGED,n)})}}class Lr extends ne{constructor(e){super((r,n)=>{e.publish(oe.ON_LEGACY_AUTH_TOKEN_CHANGED,n)})}}class H{constructor(e){this.options=e}getValue(e){var r;return this.options.inMemoryStorage.getValue(e)??((r=this.options.externalStorage)==null?void 0:r.getValue(e))}setValue(e,r){var n;(n=this.options.externalStorage)==null||n.setValue(e,r),this.options.inMemoryStorage.setValue(e,r)}}const Ae="PS",vr=3*30;function X(t){var e,r;if(((r=(e=window.ec)==null?void 0:e.config)==null?void 0:r.disable_all_cookies)!==!0)return t()}function Dr(){return X(()=>new Rr("ec-{storeId}-session",vr))}function Ur(t,e,r){const n=new Or(r),o=new H({inMemoryStorage:n,externalStorage:e??Dr()}),i=new Nr(r),s=new H({inMemoryStorage:i,externalStorage:X(()=>new wr)}),u=new Lr(r),l=new H({inMemoryStorage:u,externalStorage:X(()=>new Ue(`${Ae}ecwid__{storeId}${Ae}token`))});return{storeId:t,sessionToken:o,checkoutInfo:s,legacyAuthToken:l,sessionStorageEventBus:r}}function Mr(t){return new Promise(e=>{setTimeout(()=>e(t()))})}function br(t){const e=t.storeId,r=t.sessionToken.getValue(e);return r!==void 0?{Authorization:`Bearer ${r}`}:{}}function xr(t){return JSON.stringify(t)}function Vr(t,e){return new Headers({"Content-Type":"application/json",...br(t),...e})}async function kr(t,e,r,n){return Mr(()=>({method:t,mode:"cors",headers:Vr(r,n),body:xr(e)}))}async function Fr(t,e,r){const n=new AbortController,o={...e,signal:n.signal},i=setTimeout(()=>{const s=new DOMException("The user aborted a request.","AbortError");n.abort(s)},r);try{return await fetch(t,o)}finally{clearTimeout(i)}}const Me="StorefrontApiBusinessError";class Wr extends Error{constructor(e,r){super(e.statusText),this.type=Me,this.response=e;try{this.data=JSON.parse(r)}catch{this.data=void 0}this.text=r}isBadRequestError(){return this.response.status===400}isUnauthorizedError(){return this.response.status===401}isNotFoundError(){return this.response.status===404}getData(){return this.data}getText(){return this.text}getResponse(){return this.response}}function x(t){return"type"in t&&t.type===Me}const Br=8,Gr=3e4;function Hr(t,e,r){if((e==null?void 0:e.isRetryable)===!1||t>=Br)return!1;if(x(r)){const n=r.getResponse().status;return n>=500&&n<=599}return!0}function be(t){return new Date().getTime()-t.getTime()}function F(t){return t>1?[`(x${t})`]:[]}function Jr(t){var o;const e=be(t.requestStartDate),r=t.error.getResponse(),n=[`#${t.currentRequestIndex}`,...F(t.retryNumber),"⛌",`[${e} ms]`,`[${r.status} ${r.statusText}]`,(o=t.requestMethod)==null?void 0:o.toUpperCase(),t.url,t.error.getData()??t.error.getText()];t.logger.warn(g.REST,...n)}function $r(t){const e=[];let r=t;for(;r!==void 0;)e.push(r.stack??r.message??String(r)),r=r.cause;return e.join(` Caused by: `)}function qr(t){var r;const e=[`#${t.currentRequestIndex}`,...F(t.retryNumber),"⛌",(r=t.requestMethod)==null?void 0:r.toUpperCase(),t.url,$r(t.error)];t.logger.warn(g.REST,...e)}function jr(t){x(t.error)?Jr({logger:t.logger,requestStartDate:t.requestStartDate,currentRequestIndex:t.currentRequestIndex,retryNumber:t.retryNumber,requestMethod:t.requestMethod,url:t.url,error:t.error}):qr({logger:t.logger,url:t.url,currentRequestIndex:t.currentRequestIndex,retryNumber:t.retryNumber,requestMethod:t.requestMethod,error:t.error.getError()})}function Yr(t){const e=[`#${t.currentRequestIndex}`,...F(t.retryNumber),"⮕",t.requestMethod.toUpperCase(),t.url,t.data];t.logger.info(g.REST,...e)}function zr(t){var o;const e=be(t.requestStartDate),r=`${t.responseStatus} ${t.responseStatusText}`.trim(),n=[`#${t.currentRequestIndex}`,...F(t.retryNumber),"⬅",`[${e} ms]`,`[${r}]`,(o=t.requestMethod)==null?void 0:o.toUpperCase(),t.url,t.responseData];t.logger.info(g.REST,...n)}const Kr="StorefrontApiFatalError";class Xr extends Error{constructor(e){super(e.message),this.type=Kr,this.error=e}getError(){return this.error}}function Qr(t){const e=2**t*100,r=e*.2*Math.random();return e+r}function Zr(t){return new Promise(e=>{setTimeout(e,Qr(t))})}class en{constructor(e,r,n,o){this.requestIndex=0,this.sessionStorageOptions=e,this.apiBaseUrl=r,this.additionalHeaders=n,this.logger=o}createRequestUrl(e){return`${this.apiBaseUrl}/${this.sessionStorageOptions.storeId}${e}`}async makeRequest(e,r,n){let o=1;this.requestIndex+=1;const i="post",s=this.requestIndex,u=async()=>{const l=new Date;try{Yr({logger:this.logger,url:e,data:r,currentRequestIndex:s,retryNumber:o,requestMethod:i});const m=await kr(i,r,this.sessionStorageOptions,this.additionalHeaders),c=await Fr(this.createRequestUrl(e),m,Gr);if(!c.ok){const p=await c.text();throw new Wr(c,p)}const d=await c.json();return zr({logger:this.logger,url:e,currentRequestIndex:s,retryNumber:o,requestStartDate:l,requestMethod:i,responseStatus:c.status,responseStatusText:c.statusText,responseData:d}),{data:d}}catch(m){const c=m,d=x(c)?c:new Xr(c);if(jr({logger:this.logger,url:e,currentRequestIndex:s,retryNumber:o,requestStartDate:l,requestMethod:i,error:d}),x(c)&&c.isUnauthorizedError())throw this.resetInvalidSession(),c;if(Hr(o,n,d))return await Zr(o),o+=1,u();throw c}};return u()}resetInvalidSession(){const e=this.sessionStorageOptions.storeId;this.sessionStorageOptions.sessionToken.setValue(e,void 0),this.sessionStorageOptions.checkoutInfo.setValue(e,void 0),this.sessionStorageOptions.legacyAuthToken.setValue(e,void 0)}}const Ee={NORMAL:"NORMAL",PREVIEW:"PREVIEW"};class tn{constructor(){this.eventListeners=new Map}ensureListeners(e){const r=this.eventListeners.get(e);if(r!==void 0)return r;const n=new Set;return this.eventListeners.set(e,n),n}publish(e,...r){const n=this.eventListeners.get(e);n!==void 0&&n.forEach(o=>{o(...r)})}subscribe(e,r){const n=this.ensureListeners(e);return n.add(r),()=>{n.has(r)&&(n.delete(r),n.size===0&&this.eventListeners.delete(e))}}}function rn(){return!1}function pn(){var t;return((t=window.top)==null?void 0:t.location)!==window.location}class nn{constructor(e){this.pubChannels=new Map,this.subChannels=new Map,this.channelsNamePrefix=`ec-${e}-`,window.addEventListener("beforeunload",()=>{this.pubChannels.forEach(r=>r.close()),this.pubChannels.clear(),this.subChannels.forEach(r=>r.close()),this.subChannels.clear()})}publish(e,r){var n;(n=this.getChannel(e,this.pubChannels))==null||n.postMessage(r)}subscribe(e,r){const n=i=>r(i.data),o=()=>{var i;(i=this.getChannel(e,this.subChannels))==null||i.addEventListener("message",n)};return o(),window.addEventListener("pageshow",o),()=>{var i;(i=this.subChannels.get(e))==null||i.removeEventListener("message",n)}}getChannel(e,r){let n=r.get(e);return n===void 0&&!rn()&&(n=new BroadcastChannel(this.createChannelName(e.toString())),r.set(e,n)),n}createChannelName(e){return`${this.channelsNamePrefix}-${e}`}}const on="ec-storefront-forced-tracing-enabled",sn="X-Ec-Forced-Tracing-Enabled";function cn(){return new ut(new He("show_ec_logs"))}function an(t,e,r){if(t!==void 0)return Promise.resolve(t);const n={lang:e};return r.makeRequest("/bootstrap",n).then(o=>o.data)}function un(t){const e=Math.random()import("./vendor-datadog-browser-rum.js"),__vite__mapDeps([]),import.meta.url).then(n=>{var i,s;const o=n.datadogRum;return o.init({applicationId:t.applicationId,clientToken:t.clientToken,site:t.site,service:t.service,env:t.env,version:t.version,allowedTracingUrls:[{match:e,propagatorTypes:["tracecontext"]}],sessionSampleRate:100,sessionReplaySampleRate:0,trackingConsent:((s=(i=window.ec)==null?void 0:i.config)==null?void 0:s.disable_all_cookies)===!0?"not-granted":"granted",trackUserInteractions:!0,trackResources:!0,trackLongTasks:!0}),o})}class ie extends Tr{static updateGlobalEcommerceInstance(e){window.Ecwid.ecommerceInstance===void 0&&(window.Ecwid.ecommerceInstance=e)}constructor(e){super(),ie.updateGlobalEcommerceInstance(this);const r=cn();_r(r);const n=E.getEntryPointQueryParams(),o=(e==null?void 0:e.storeId)??n.storeId,i=(e==null?void 0:e.apiBaseUrl)??E.getEcommerceJsParams().apiBaseUrl,s=(e==null?void 0:e.lang)??n.lang,u=y(Ee,e==null?void 0:e.appMode)??Ee.NORMAL,l=C.get(on)==="true",m=gn(E.getEcommerceJsParams().datadogRum,i,l),c={ecommerceEventTarget:this,sessionStorageEventBus:new nn(o),apiEventBus:new tn,datadogRumPromise:m,widgetLang:s},d=Ur(o,e==null?void 0:e.externalSessionTokenStorage,c.sessionStorageEventBus);this.legacyApiImpl=new Ir(this,c,r);const p=new en(d,i,dn(l),r),A=an(e==null?void 0:e.bootstrap,s,p);this.widgets=new Bt({appMode:u,bootstrapPromise:A,ecommerce:this,logger:r,requestContext:c,sessionStorageOptions:d,storefrontApiClient:p})}addEventListener(e,r,n){this.legacyApiImpl.getJsApiAsync().then(()=>{super.addEventListener(e,r,n)})}}window.ec=window.ec??{};window.ec.config=window.ec.config??{};window.ec.order=window.ec.order??{};window.ec.storefront=window.ec.storefront??{};window._xnext_initialization_scripts=window._xnext_initialization_scripts??[];window.Ecommerce=ie;window.EcommerceGlobals=E;window.rtCommonProps!==void 0&&(delete window.rtCommonProps["new.store.fix.ecwid.back.bug"],delete window.rtCommonProps["new.store.accountPage.ecwid.signIn.fix"]);(()=>{const t=new CustomEvent("ecommerce.ready");document.dispatchEvent(t)})();export{Ee as A,$ as C,a as D,ie as E,g as L,v as M,oe as S,f as _,y as a,Le as b,Oe as c,yt as d,k as e,Ne as f,pn as g,ue as h,x as i,P as j,rn as k,At as l,dt as m,C as n,mn as o,b as p,R as q,hn as r,I as s,V as t,Ct as u,zt as v,Z as w,Te as x}; //# sourceMappingURL=https://storefront.local.ecwid.com:16088/static/ecommerce.js.map