@swishapp/sdk 0.105.1 → 0.107.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/dist/ajax-api/ajax-api-client.d.ts +1 -1
  2. package/dist/dom/create-placement.d.ts +114 -0
  3. package/dist/dom/dom-utils.d.ts +2 -1
  4. package/dist/intents/handlers/create-cart-line-handler.d.ts +21 -0
  5. package/dist/intents/handlers/edit-item-lists-handler.d.ts +2 -2
  6. package/dist/intents/handlers/edit-list-access-handler.d.ts +15 -0
  7. package/dist/intents/handlers/open-list-menu-handler.d.ts +6 -4
  8. package/dist/intents/handlers/share-list-handler.d.ts +16 -0
  9. package/dist/intents/handlers/show-toast-handler.d.ts +2 -0
  10. package/dist/intents/handlers/unsave-item-handler.d.ts +14 -0
  11. package/dist/intents/hooks/after-edit-list-access-hook.d.ts +5 -0
  12. package/dist/intents/hooks/after-share-list-hook.d.ts +5 -0
  13. package/dist/intents/intents.d.ts +12 -12
  14. package/dist/intents/types.d.ts +28 -19
  15. package/dist/options/swish-options.d.ts +7 -3
  16. package/dist/options/types.d.ts +92 -6
  17. package/dist/storefront-api/storefront-api-client.d.ts +33 -18
  18. package/dist/storefront-api/types/storefront.types.d.ts +33 -4
  19. package/dist/swish-api/swish-api-client.d.ts +4 -1
  20. package/dist/swish-ui/swish-ui-element.d.ts +1 -0
  21. package/dist/swish-ui/swish-ui.d.ts +14 -8
  22. package/dist/swish-ui/types.d.ts +21 -5
  23. package/dist/swish.d.ts +20 -1
  24. package/dist/swish.js +64 -64
  25. package/dist/utils/build-share-list-url.d.ts +4 -0
  26. package/dist/utils/copy-to-clipboard.d.ts +6 -0
  27. package/dist/utils/is-mobile-device.d.ts +1 -0
  28. package/dist/utils/shopify-id-schema.d.ts +2 -0
  29. package/package.json +1 -1
  30. package/dist/intents/handlers/delete-item-handler.d.ts +0 -13
package/dist/swish.js CHANGED
@@ -1,18 +1,18 @@
1
- var wr=Object.create;var ot=Object.defineProperty;var br=Object.getOwnPropertyDescriptor;var Sr=Object.getOwnPropertyNames;var Er=Object.getPrototypeOf,xr=Object.prototype.hasOwnProperty;var s=(n,e)=>ot(n,"name",{value:e,configurable:!0});var Cr=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var kr=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Sr(e))!xr.call(n,i)&&i!==t&&ot(n,i,{get:()=>e[i],enumerable:!(r=br(e,i))||r.enumerable});return n};var Rr=(n,e,t)=>(t=n!=null?wr(Er(n)):{},kr(e||!n||!n.__esModule?ot(t,"default",{value:n,enumerable:!0}):t,n));var mr=Cr((hc,hr)=>{"use strict";var ls=(function(){function n(t,r){if(typeof t!="function")throw new TypeError("DataLoader must be constructed with a function which accepts "+("Array<key> and returns Promise<Array<value>>, but got: "+t+"."));this._batchLoadFn=t,this._maxBatchSize=fs(r),this._batchScheduleFn=hs(r),this._cacheKeyFn=ms(r),this._cacheMap=ys(r),this._batch=null,this.name=vs(r)}s(n,"DataLoader");var e=n.prototype;return e.load=s(function(r){if(r==null)throw new TypeError("The loader.load() function must be called with a value, "+("but got: "+String(r)+"."));var i=ps(this),o=this._cacheMap,u;if(o){u=this._cacheKeyFn(r);var a=o.get(u);if(a){var l=i.cacheHits||(i.cacheHits=[]);return new Promise(function(p){l.push(function(){p(a)})})}}i.keys.push(r);var c=new Promise(function(p,h){i.callbacks.push({resolve:p,reject:h})});return o&&o.set(u,c),c},"load"),e.loadMany=s(function(r){if(!fr(r))throw new TypeError("The loader.loadMany() function must be called with Array<key> "+("but got: "+r+"."));for(var i=[],o=0;o<r.length;o++)i.push(this.load(r[o]).catch(function(u){return u}));return Promise.all(i)},"loadMany"),e.clear=s(function(r){var i=this._cacheMap;if(i){var o=this._cacheKeyFn(r);i.delete(o)}return this},"clear"),e.clearAll=s(function(){var r=this._cacheMap;return r&&r.clear(),this},"clearAll"),e.prime=s(function(r,i){var o=this._cacheMap;if(o){var u=this._cacheKeyFn(r);if(o.get(u)===void 0){var a;i instanceof Error?(a=Promise.reject(i),a.catch(function(){})):a=Promise.resolve(i),o.set(u,a)}}return this},"prime"),n})(),cs=typeof process=="object"&&typeof process.nextTick=="function"?function(n){Gt||(Gt=Promise.resolve()),Gt.then(function(){process.nextTick(n)})}:typeof setImmediate=="function"?function(n){setImmediate(n)}:function(n){setTimeout(n)},Gt;function ps(n){var e=n._batch;if(e!==null&&!e.hasDispatched&&e.keys.length<n._maxBatchSize)return e;var t={hasDispatched:!1,keys:[],callbacks:[]};return n._batch=t,n._batchScheduleFn(function(){ds(n,t)}),t}s(ps,"getCurrentBatch");function ds(n,e){if(e.hasDispatched=!0,e.keys.length===0){jt(e);return}var t;try{t=n._batchLoadFn(e.keys)}catch(r){return Ft(n,e,new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function "+("errored synchronously: "+String(r)+".")))}if(!t||typeof t.then!="function")return Ft(n,e,new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did "+("not return a Promise: "+String(t)+".")));t.then(function(r){if(!fr(r))throw new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did "+("not return a Promise of an Array: "+String(r)+"."));if(r.length!==e.keys.length)throw new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array of the same length as the Array of keys."+(`
1
+ var Nr=Object.create;var gt=Object.defineProperty;var Br=Object.getOwnPropertyDescriptor;var Ur=Object.getOwnPropertyNames;var Fr=Object.getPrototypeOf,jr=Object.prototype.hasOwnProperty;var i=(n,e)=>gt(n,"name",{value:e,configurable:!0});var Gr=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var Hr=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Ur(e))!jr.call(n,s)&&s!==t&&gt(n,s,{get:()=>e[s],enumerable:!(r=Br(e,s))||r.enumerable});return n};var Qr=(n,e,t)=>(t=n!=null?Nr(Fr(n)):{},Hr(e||!n||!n.__esModule?gt(t,"default",{value:n,enumerable:!0}):t,n));var Lr=Gr((Np,Or)=>{"use strict";var Wi=(function(){function n(t,r){if(typeof t!="function")throw new TypeError("DataLoader must be constructed with a function which accepts "+("Array<key> and returns Promise<Array<value>>, but got: "+t+"."));this._batchLoadFn=t,this._maxBatchSize=Ji(r),this._batchScheduleFn=Zi(r),this._cacheKeyFn=eo(r),this._cacheMap=to(r),this._batch=null,this.name=no(r)}i(n,"DataLoader");var e=n.prototype;return e.load=i(function(r){if(r==null)throw new TypeError("The loader.load() function must be called with a value, "+("but got: "+String(r)+"."));var s=Xi(this),o=this._cacheMap,a;if(o){a=this._cacheKeyFn(r);var u=o.get(a);if(u){var c=s.cacheHits||(s.cacheHits=[]);return new Promise(function(p){c.push(function(){p(u)})})}}s.keys.push(r);var l=new Promise(function(p,f){s.callbacks.push({resolve:p,reject:f})});return o&&o.set(a,l),l},"load"),e.loadMany=i(function(r){if(!_r(r))throw new TypeError("The loader.loadMany() function must be called with Array<key> "+("but got: "+r+"."));for(var s=[],o=0;o<r.length;o++)s.push(this.load(r[o]).catch(function(a){return a}));return Promise.all(s)},"loadMany"),e.clear=i(function(r){var s=this._cacheMap;if(s){var o=this._cacheKeyFn(r);s.delete(o)}return this},"clear"),e.clearAll=i(function(){var r=this._cacheMap;return r&&r.clear(),this},"clearAll"),e.prime=i(function(r,s){var o=this._cacheMap;if(o){var a=this._cacheKeyFn(r);if(o.get(a)===void 0){var u;s instanceof Error?(u=Promise.reject(s),u.catch(function(){})):u=Promise.resolve(s),o.set(a,u)}}return this},"prime"),n})(),Ki=typeof process=="object"&&typeof process.nextTick=="function"?function(n){en||(en=Promise.resolve()),en.then(function(){process.nextTick(n)})}:typeof setImmediate=="function"?function(n){setImmediate(n)}:function(n){setTimeout(n)},en;function Xi(n){var e=n._batch;if(e!==null&&!e.hasDispatched&&e.keys.length<n._maxBatchSize)return e;var t={hasDispatched:!1,keys:[],callbacks:[]};return n._batch=t,n._batchScheduleFn(function(){Yi(n,t)}),t}i(Xi,"getCurrentBatch");function Yi(n,e){if(e.hasDispatched=!0,e.keys.length===0){nn(e);return}var t;try{t=n._batchLoadFn(e.keys)}catch(r){return tn(n,e,new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function "+("errored synchronously: "+String(r)+".")))}if(!t||typeof t.then!="function")return tn(n,e,new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did "+("not return a Promise: "+String(t)+".")));t.then(function(r){if(!_r(r))throw new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did "+("not return a Promise of an Array: "+String(r)+"."));if(r.length!==e.keys.length)throw new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array of the same length as the Array of keys."+(`
2
2
 
3
3
  Keys:
4
4
  `+String(e.keys))+(`
5
5
 
6
6
  Values:
7
- `+String(r)));jt(e);for(var i=0;i<e.callbacks.length;i++){var o=r[i];o instanceof Error?e.callbacks[i].reject(o):e.callbacks[i].resolve(o)}}).catch(function(r){Ft(n,e,r)})}s(ds,"dispatchBatch");function Ft(n,e,t){jt(e);for(var r=0;r<e.keys.length;r++)n.clear(e.keys[r]),e.callbacks[r].reject(t)}s(Ft,"failedDispatch");function jt(n){if(n.cacheHits)for(var e=0;e<n.cacheHits.length;e++)n.cacheHits[e]()}s(jt,"resolveCacheHits");function fs(n){var e=!n||n.batch!==!1;if(!e)return 1;var t=n&&n.maxBatchSize;if(t===void 0)return 1/0;if(typeof t!="number"||t<1)throw new TypeError("maxBatchSize must be a positive number: "+t);return t}s(fs,"getValidMaxBatchSize");function hs(n){var e=n&&n.batchScheduleFn;if(e===void 0)return cs;if(typeof e!="function")throw new TypeError("batchScheduleFn must be a function: "+e);return e}s(hs,"getValidBatchScheduleFn");function ms(n){var e=n&&n.cacheKeyFn;if(e===void 0)return function(t){return t};if(typeof e!="function")throw new TypeError("cacheKeyFn must be a function: "+e);return e}s(ms,"getValidCacheKeyFn");function ys(n){var e=!n||n.cache!==!1;if(!e)return null;var t=n&&n.cacheMap;if(t===void 0)return new Map;if(t!==null){var r=["get","set","delete","clear"],i=r.filter(function(o){return t&&typeof t[o]!="function"});if(i.length!==0)throw new TypeError("Custom cacheMap missing methods: "+i.join(", "))}return t}s(ys,"getValidCacheMap");function vs(n){return n&&n.name?n.name:null}s(vs,"getValidName");function fr(n){return typeof n=="object"&&n!==null&&typeof n.length=="number"&&(n.length===0||n.length>0&&Object.prototype.hasOwnProperty.call(n,n.length-1))}s(fr,"isArrayLike");hr.exports=ls});var x=s(n=>n.split("/").pop()??"","shopifyGidToId"),E=s((n,e)=>`gid://shopify/${n}/${e}`,"shopifyIdToGid"),j=s(n=>n.toLowerCase().replace(".myshopify.com",""),"toShopName");var X=class{constructor(e,t,r=""){this.revalidationPromises=new Map;this.inFlightRequests=new Map;this.clearCachePromise=null;this.cacheName=e,this.defaultCacheControl=t,this.keyPrefix=r}static{s(this,"FetchCache")}async get(e){try{let t=await caches.open(this.cacheName),r=await t.match(e);if(r&&this.isExpired(r)){await t.delete(e);return}return r}catch(t){console.warn("Cache get error:",t);return}}async set(e,t,r){try{if(r?.includes("no-cache"))return;let i=this.createCacheableResponse(t,r);await(await caches.open(this.cacheName)).put(e,i)}catch(i){console.warn("Cache set error:",i)}}async fetchWithCache(e,t,r){let i=await this.getCacheKey(e,t);if(this.clearCachePromise&&await this.clearCachePromise,this.inFlightRequests.has(i))return this.inFlightRequests.get(i).then(u=>u.clone());let o=(async()=>{let u=await this.get(i);if(u)return this.isStaleButRevalidatable(u)&&this.revalidateInBackground(i,e,t,r),u.clone();let a=await fetch(e,t);return a.ok&&await this.set(i,a.clone(),r??this.defaultCacheControl),a})().finally(()=>{this.inFlightRequests.delete(i)});return this.inFlightRequests.set(i,o),o}async delete(e){try{return await(await caches.open(this.cacheName)).delete(e)}catch(t){return console.warn("Cache delete error:",t),!1}}async clear(){return this.clearCachePromise?this.clearCachePromise:(this.clearCachePromise=new Promise(async(e,t)=>{try{let r=await caches.open(this.cacheName),i=await r.keys();await Promise.all(i.map(o=>r.delete(o))),e()}catch(r){console.warn("Cache clear error:",r),t(r)}}),this.clearCachePromise.then(()=>{this.clearCachePromise=null}).catch(e=>{console.warn("Cache clear error:",e)}))}async keys(){try{return(await(await caches.open(this.cacheName)).keys()).map(r=>r.url)}catch(e){return console.warn("Cache keys error:",e),[]}}async has(e){try{let t=await caches.open(this.cacheName),r=await t.match(e);return r&&this.isExpired(r)?(await t.delete(e),!1):r!==void 0}catch(t){return console.warn("Cache has error:",t),!1}}async getStats(){try{return{total:(await(await caches.open(this.cacheName)).keys()).length}}catch(e){return console.warn("Cache stats error:",e),{total:0}}}async cleanupExpiredEntries(){try{let e=await caches.open(this.cacheName),t=await e.keys(),r=0;for(let o of t){let u=await e.match(o);u&&this.isExpired(u)&&(await e.delete(o),r++)}let i=t.length-r;return{removed:r,remaining:i}}catch(e){return console.warn("Cache cleanup error:",e),{removed:0,remaining:0}}}async getCacheKey(e,t){let r=this.getInputUrl(e),i=`${this.keyPrefix}${r}/${JSON.stringify(t)}`,u=new TextEncoder().encode(i),a=await crypto.subtle.digest("SHA-256",u);return`/${Array.from(new Uint8Array(a)).map(p=>p.toString(16).padStart(2,"0")).join("")}`}getInputUrl(e){return e instanceof URL?e.toString():typeof e=="string"?e:e.url}isExpired(e){let t=e.headers.get("Cache-Control");if(!t)return!1;let r=this.parseMaxAge(t),i=this.parseStaleWhileRevalidate(t);if(r===null)return!1;let o=e.headers.get("Date");if(!o)return!1;let u=new Date(o).getTime(),l=(Date.now()-u)/1e3,c=r+(i??0);return l>c}isStaleButRevalidatable(e){let t=e.headers.get("Cache-Control");if(!t)return!1;let r=this.parseMaxAge(t),i=this.parseStaleWhileRevalidate(t);if(r===null||i===null)return!1;let o=e.headers.get("Date");if(!o)return!1;let u=new Date(o).getTime(),l=(Date.now()-u)/1e3;return l>r&&l<=r+i}async revalidateInBackground(e,t,r,i){if(this.revalidationPromises.has(e))return;let o=(async()=>{try{let u=await fetch(t,r);u.ok&&await this.set(e,u.clone(),i??this.defaultCacheControl)}catch(u){console.warn("Background revalidation error:",u)}finally{this.revalidationPromises.delete(e)}})();this.revalidationPromises.set(e,o)}parseMaxAge(e){let t=new RegExp(/max-age=(\d+)/).exec(e);return t?parseInt(t[1],10):null}parseStaleWhileRevalidate(e){let t=new RegExp(/stale-while-revalidate=(\d+)/).exec(e);return t?parseInt(t[1],10):null}createCacheableResponse(e,t){let r=new Headers(e.headers);return r.set("Cache-Control",t),r.has("Date")||r.set("Date",new Date().toUTCString()),new Response(e.body,{status:e.status,statusText:e.statusText,headers:r})}};var he=class{static{s(this,"AjaxApiClient")}constructor(e){this.config=e;let t=j(e.storeDomain);this.cache=new X(`ajax-api-${t}`,"max-age=60, stale-while-revalidate=3600"),this.cache.cleanupExpiredEntries().catch(r=>{console.warn("Ajax API cache initialization cleanup error:",r)})}patchFetch(){if(!window.fetch||typeof window.fetch!="function")return;let e=window.fetch,t=this.config.responseInterceptor,r=this.getFetchRequest.bind(this);window.fetch=function(...i){let o=e.apply(this,i);if(typeof t=="function"){let u=r(i[0]);o.then(a=>t(a,u))}return o}}getFetchRequest(e){return e instanceof Request?e:new Request(e)}getBaseUrl(){if(!this.config?.storeDomain)throw new Error("Cart API client not initialized - missing store domain");return`https://${this.config.storeDomain}`}fetch(e,t){return(e instanceof Request?e.method:t?.method??"GET")==="GET"?this.cache.fetchWithCache(e,t):fetch(e,t)}async request(e,t={}){let r=`${this.getBaseUrl()}${e}`,i={"Content-Type":"application/json",Accept:"application/json"},o=await this.fetch(r,{...t,headers:{...i,...t.headers}});if(!o.ok){let u;try{u=await o.json()}catch{u={message:`HTTP ${o.status}: ${o.statusText}`,status:o.status.toString(),description:o.statusText}}throw new Error(u.message||u.description)}return o.json()}async fetchCart(){return this.request("/cart.js")}async addToCart(e){let t={...e,items:e.items.map(r=>{let i=x(r.id);if(!i)throw new Error(`Invalid Shopify GID format: ${r.id}`);let o=parseInt(i,10);if(isNaN(o))throw new Error(`Invalid numeric ID extracted from GID: ${r.id}`);return{...r,id:o}})};return this.request("/cart/add.js",{method:"POST",body:JSON.stringify(t)})}async clearCache(){await this.cache.clear()}};var me=class{constructor(e){this.eventMap={"/cart/add":"cart-add","/cart/update":"cart-update","/cart/change":"cart-change","/cart/clear":"cart-clear"};this.eventBus=e,this.processFetchResponse=this.processFetchResponse.bind(this)}static{s(this,"AjaxApiPublisher")}async processFetchResponse(e,t){try{let r=this.getEventName(t.url);if(r){let i=await e.clone().json();this.eventBus.publish(r,i)}}catch(r){console.warn(r)}}getEventName(e){for(let[t,r]of Object.entries(this.eventMap))if(e.includes(t))return r;return null}};function Ar(){let n=document.body||document.documentElement;return n?Promise.resolve(n):new Promise(e=>{window.addEventListener("DOMContentLoaded",()=>e(n))})}s(Ar,"waitForDOM");function ce({onElementFound:n,selector:e,observerOptions:t}){let r=new WeakSet,i=new MutationObserver(l=>{let c=!1;for(let p of l)if(p.addedNodes.length>0){c=!0;break}c&&o()}),o=s(()=>{document.querySelectorAll(e).forEach(l=>{r.has(l)||(u(l),r.add(l))})},"locateElements"),u=s(l=>{if(!t){n(l);return}let c=new IntersectionObserver(p=>{for(let h of p)h.isIntersecting&&(c.disconnect(),n(l))},t);c.observe(l)},"observeElement");return s(async()=>{let l=await Ar();o(),i.observe(l,{childList:!0,subtree:!0})},"locateAndObserveElements")(),i}s(ce,"createElementLocator");function ae({onLocationChange:n,fireOnInit:e=!1}){let t=s(()=>{n(window.location)},"handleChange");window.addEventListener("popstate",t);let r=history.pushState,i=history.replaceState;return history.pushState=function(...o){r.apply(this,o),t()},history.replaceState=function(...o){i.apply(this,o),t()},e&&t(),()=>{window.removeEventListener("popstate",t),history.pushState=r,history.replaceState=i}}s(ae,"createLocationObserver");function Yt({element:n,onHrefChange:e}){let t=s(()=>{e(n.href)},"handleChange"),r=new MutationObserver(()=>{t()});return r.observe(n,{attributes:!0,attributeFilter:["href"]}),()=>{r.disconnect()}}s(Yt,"createHrefObserver");var ye=class{constructor(){this.eventBus=new EventTarget}static{s(this,"EventBus")}subscribe(e,t,r){return Array.isArray(e)||(e=[e]),e.forEach(i=>{this.eventBus.addEventListener(i,t,r)}),()=>{e.forEach(i=>{this.eventBus.removeEventListener(i,t,r)})}}unsubscribe(e,t,r){this.eventBus.removeEventListener(e,t,r)}publish(e,t){this.eventBus.dispatchEvent(new CustomEvent(e,{detail:t}))}};var at;function Zt(n){return{lang:n?.lang??at?.lang,message:n?.message,abortEarly:n?.abortEarly??at?.abortEarly,abortPipeEarly:n?.abortPipeEarly??at?.abortPipeEarly}}s(Zt,"getGlobalConfig");var Dr;function Pr(n){return Dr?.get(n)}s(Pr,"getGlobalMessage");var Tr;function _r(n){return Tr?.get(n)}s(_r,"getSchemaMessage");var Or;function Lr(n,e){return Or?.get(n)?.get(e)}s(Lr,"getSpecificMessage");function ut(n){let e=typeof n;return e==="string"?`"${n}"`:e==="number"||e==="bigint"||e==="boolean"?`${n}`:e==="object"||e==="function"?(n&&Object.getPrototypeOf(n)?.constructor?.name)??"null":e}s(ut,"_stringify");function Y(n,e,t,r,i){let o=i&&"input"in i?i.input:t.value,u=i?.expected??n.expects??null,a=i?.received??ut(o),l={kind:n.kind,type:n.type,input:o,expected:u,received:a,message:`Invalid ${e}: ${u?`Expected ${u} but r`:"R"}eceived ${a}`,requirement:n.requirement,path:i?.path,issues:i?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},c=n.kind==="schema",p=i?.message??n.message??Lr(n.reference,l.lang)??(c?_r(l.lang):null)??r.message??Pr(l.lang);p!==void 0&&(l.message=typeof p=="function"?p(l):p),c&&(t.typed=!1),t.issues?t.issues.push(l):t.issues=[l]}s(Y,"_addIssue");function ne(n){return{version:1,vendor:"valibot",validate(e){return n["~run"]({value:e},Zt())}}}s(ne,"_getStandardProps");function qr(n,e){let t=[...new Set(n)];return t.length>1?`(${t.join(` ${e} `)})`:t[0]??"never"}s(qr,"_joinExpects");function lt(n,e){return{kind:"validation",type:"min_value",reference:lt,async:!1,expects:`>=${n instanceof Date?n.toJSON():ut(n)}`,requirement:n,message:e,"~run"(t,r){return t.typed&&!(t.value>=this.requirement)&&Y(this,"value",t,r,{received:t.value instanceof Date?t.value.toJSON():ut(t.value)}),t}}}s(lt,"minValue");function D(n){return{kind:"transformation",type:"transform",reference:D,async:!1,operation:n,"~run"(e){return e.value=this.operation(e.value),e}}}s(D,"transform");function $r(n,e,t){return typeof n.fallback=="function"?n.fallback(e,t):n.fallback}s($r,"getFallback");function en(n,e,t){return typeof n.default=="function"?n.default(e,t):n.default}s(en,"getDefault");function ct(n,e){return{kind:"schema",type:"array",reference:ct,expects:"Array",async:!1,item:n,message:e,get"~standard"(){return ne(this)},"~run"(t,r){let i=t.value;if(Array.isArray(i)){t.typed=!0,t.value=[];for(let o=0;o<i.length;o++){let u=i[o],a=this.item["~run"]({value:u},r);if(a.issues){let l={type:"array",origin:"value",input:i,key:o,value:u};for(let c of a.issues)c.path?c.path.unshift(l):c.path=[l],t.issues?.push(c);if(t.issues||(t.issues=a.issues),r.abortEarly){t.typed=!1;break}}a.typed||(t.typed=!1),t.value.push(a.value)}}else Y(this,"type",t,r);return t}}}s(ct,"array");function R(n){return{kind:"schema",type:"number",reference:R,expects:"number",async:!1,message:n,get"~standard"(){return ne(this)},"~run"(e,t){return typeof e.value=="number"&&!isNaN(e.value)?e.typed=!0:Y(this,"type",e,t),e}}}s(R,"number");function w(n,e){return{kind:"schema",type:"object",reference:w,expects:"Object",async:!1,entries:n,message:e,get"~standard"(){return ne(this)},"~run"(t,r){let i=t.value;if(i&&typeof i=="object"){t.typed=!0,t.value={};for(let o in this.entries){let u=this.entries[o];if(o in i||(u.type==="exact_optional"||u.type==="optional"||u.type==="nullish")&&u.default!==void 0){let a=o in i?i[o]:en(u),l=u["~run"]({value:a},r);if(l.issues){let c={type:"object",origin:"value",input:i,key:o,value:a};for(let p of l.issues)p.path?p.path.unshift(c):p.path=[c],t.issues?.push(p);if(t.issues||(t.issues=l.issues),r.abortEarly){t.typed=!1;break}}l.typed||(t.typed=!1),t.value[o]=l.value}else if(u.fallback!==void 0)t.value[o]=$r(u);else if(u.type!=="exact_optional"&&u.type!=="optional"&&u.type!=="nullish"&&(Y(this,"key",t,r,{input:void 0,expected:`"${o}"`,path:[{type:"object",origin:"key",input:i,key:o,value:i[o]}]}),r.abortEarly))break}}else Y(this,"type",t,r);return t}}}s(w,"object");function L(n,e){return{kind:"schema",type:"optional",reference:L,expects:`(${n.expects} | undefined)`,async:!1,wrapped:n,default:e,get"~standard"(){return ne(this)},"~run"(t,r){return t.value===void 0&&(this.default!==void 0&&(t.value=en(this,t,r)),t.value===void 0)?(t.typed=!0,t):this.wrapped["~run"](t,r)}}}s(L,"optional");function y(n){return{kind:"schema",type:"string",reference:y,expects:"string",async:!1,message:n,get"~standard"(){return ne(this)},"~run"(e,t){return typeof e.value=="string"?e.typed=!0:Y(this,"type",e,t),e}}}s(y,"string");function Jt(n){let e;if(n)for(let t of n)e?e.push(...t.issues):e=t.issues;return e}s(Jt,"_subIssues");function B(n,e){return{kind:"schema",type:"union",reference:B,expects:qr(n.map(t=>t.expects),"|"),async:!1,options:n,message:e,get"~standard"(){return ne(this)},"~run"(t,r){let i,o,u;for(let a of this.options){let l=a["~run"]({value:t.value},r);if(l.typed)if(l.issues)o?o.push(l):o=[l];else{i=l;break}else u?u.push(l):u=[l]}if(i)return i;if(o){if(o.length===1)return o[0];Y(this,"type",t,r,{issues:Jt(o)}),t.typed=!0}else{if(u?.length===1)return u[0];Y(this,"type",t,r,{issues:Jt(u)})}return t}}}s(B,"union");function A(...n){return{...n[0],pipe:n,get"~standard"(){return ne(this)},"~run"(e,t){for(let r of n)if(r.kind!=="metadata"){if(e.issues&&(r.kind==="schema"||r.kind==="transformation")){e.typed=!1;break}(!e.issues||!t.abortEarly&&!t.abortPipeEarly)&&(e=r["~run"](e,t))}return e}}}s(A,"pipe");function C(n,e,t){let r=n["~run"]({value:e},Zt(t));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}s(C,"safeParse");var m=class{constructor(e,t,r,i){this.swish=e;this.ui=t;this.eventBus=r;this.options=i}static{s(this,"IntentHandler")}};var Vr=w({productId:A(B([A(y(),D(x)),R()]),D(n=>Number(n)),R()),variantId:L(A(B([A(y(),D(x)),R()]),D(Number),R())),quantity:L(A(R(),lt(1))),tags:L(ct(y()))}),ve=class extends m{static{s(this,"SaveItemHandler")}async invoke(e){let t=C(Vr,e);if(!t.success)return{intent:"save:item",code:"error",message:"Invalid intent data",issues:t.issues.map(f=>f.message)};let{productId:r,variantId:i,quantity:o,tags:u}=t.output,a=await this.swish.storefront.loadSaveIntentData({productId:E("Product",r),variantId:i?E("ProductVariant",i):void 0});if(a.errors)return{intent:"save:item",code:"error",message:a.errors.message??"Failed to load save intent data",issues:a.errors.graphQLErrors?.map(f=>f.message)??[]};if(!a.data||!a.data.product)return{intent:"save:item",code:"error",message:"Failed to load save intent data",issues:["API response missing data"]};let{product:l}=a.data,c=l.variantsCount?.count&&l.variantsCount.count>1,p=!!i,h=!this.options.save.requireVariant||!this.options.save.requireVariantConfirmation&&p;if(!c||h){let f=s(()=>!c&&l.selectedOrFirstAvailableVariant?Number(x(l.selectedOrFirstAvailableVariant.id)):i,"variantIdToUse"),P=await this.swish.api.items.create({productId:r,variantId:f(),quantity:o,tags:u});if("error"in P)return{intent:"save:item",code:"error",message:"Failed to create item",issues:[P.error.message]};if(!P.data)return{intent:"save:item",code:"error",message:"Could not complete item creation",issues:["API response missing data"]};let v="variant"in a.data?a.data.variant:void 0;return{intent:"save:item",code:"ok",data:{item:P.data,product:l,variant:c?v:l.selectedOrFirstAvailableVariant}}}let g=await this.ui.showVariantSelect({productId:r,variantId:i});return g.code==="closed"?{intent:"save:item",code:"closed"}:{intent:"save:item",code:"ok",data:g.data}}};var ge=class extends m{static{s(this,"CreateListHandler")}async invoke(e){let t=await this.ui.showListEditor();if(t.code==="closed")return{intent:"create:list",code:"closed"};let{list:r}=t.data;return{intent:"create:list",code:"ok",data:{list:r}}}};var Br=w({itemId:y()}),Ie=class extends m{static{s(this,"DeleteItemHandler")}async invoke(e){let t=C(Br,e);if(!t.success)return{intent:"delete:item",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{itemId:r}=t.output;if(!this.options.unsave.requireConfirmation){let o=await this.swish.api.items.deleteById(r);return"error"in o?{intent:"delete:item",code:"error",message:"Failed to delete item",issues:[o.error.message]}:{intent:"delete:item",code:"ok",data:{itemId:r}}}return(await this.ui.showUnsaveAlert({itemId:r})).code==="closed"?{intent:"delete:item",code:"closed"}:{intent:"delete:item",code:"ok",data:{itemId:r}}}};var Nr=w({listId:y()}),we=class extends m{static{s(this,"DeleteListHandler")}async invoke(e){let t=C(Nr,e);if(!t.success)return{intent:"delete:list",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{listId:r}=t.output;return(await this.ui.showDeleteListAlert({listId:r})).code==="closed"?{intent:"delete:list",code:"closed"}:{intent:"delete:list",code:"ok",data:{listId:r}}}};var Ur=w({itemId:y()}),be=class extends m{static{s(this,"EditItemListsHandler")}async invoke(e){let t=C(Ur,e);if(!t.success)return{intent:"edit:item-lists",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{itemId:r}=t.output,i=await this.ui.showListSelect({itemId:r});if(i.code==="closed")return{intent:"edit:item-lists",code:"closed"};if(i.data.action==="submit"){let{item:o,product:u,variant:a}=i.data.data;return{intent:"edit:item-lists",code:"ok",data:{item:o,product:u,variant:a}}}return{intent:"delete:item",code:"ok",data:{itemId:i.data.data.itemId}}}};var Mr=w({itemId:A(y()),productId:A(B([A(y(),D(x)),R()]),D(n=>Number(n)),R()),variantId:L(A(B([A(y(),D(x)),R()]),D(n=>Number(n)),R()))}),Se=class extends m{static{s(this,"EditItemVariantHandler")}async invoke(e){let t=C(Mr,e);if(!t.success)return{intent:"edit:item-variant",code:"error",message:"Invalid intent data",issues:t.issues.map(g=>g.message)};let{itemId:r,productId:i,variantId:o}=t.output;if(!(!o||this.swish.options.swishUi.intents.edit.requireVariantConfirmation)){let g=await this.swish.api.items.updateById(r,{productId:i,variantId:o});if("error"in g)return{intent:"edit:item-variant",code:"error",message:"Failed to update variant",issues:[g.error.message]};if(!g.data)return{intent:"edit:item-variant",code:"error",message:"Failed to update variant",issues:["No item returned from API"]};let f=await this.swish.storefront.loadSaveIntentData({productId:E("Product",i),variantId:o?E("ProductVariant",o):void 0});if(!f.data?.product)return{intent:"edit:item-variant",code:"error",message:"Failed to load save intent data",issues:[f.errors?.message??"No product data returned from API"]};let P=f.data?.product,v="variant"in f.data?f.data.variant:void 0;return{intent:"edit:item-variant",code:"ok",data:{item:g.data,product:P,variant:v}}}let a=await this.ui.showVariantSelect({itemId:r,productId:i,variantId:o});if(a.code==="closed")return{intent:"edit:item-variant",code:"closed"};let{item:l,product:c,variant:p}=a.data;return{intent:"edit:item-variant",code:"ok",data:{item:l,product:c,variant:p}}}};var Gr=w({listId:y()}),Ee=class extends m{static{s(this,"EditListHandler")}async invoke(e){let t=C(Gr,e);if(!t.success)return{intent:"edit:list",code:"error",message:"Invalid intent data",issues:t.issues.map(u=>u.message)};let{listId:r}=t.output,i=await this.ui.showListEditor({listId:r});if(i.code==="closed")return{intent:"edit:list",code:"closed"};let{list:o}=i.data;return{intent:"edit:list",code:"ok",data:{list:o}}}};var xe=class extends m{static{s(this,"OpenHomeHandler")}async invoke(e){return{intent:"open:home",code:(await this.ui.showDrawer()).code,data:void 0}}};var Fr=w({listId:y()}),Ce=class extends m{static{s(this,"OpenListHandler")}async invoke(e){let t=C(Fr,e);if(!t.success)return{intent:"open:list",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{listId:r}=t.output;return{intent:"open:list",code:(await this.ui.showDrawer({view:"list",listId:r})).code,data:void 0}}};var ke=class extends m{static{s(this,"OpenListsHandler")}async invoke(e){return{intent:"open:lists",code:(await this.ui.showDrawer({view:"lists"})).code,data:void 0}}};var Re=class extends m{static{s(this,"OpenOrdersHandler")}async invoke(e){return{intent:"open:orders",code:(await this.ui.showDrawer({view:"orders"})).code,data:void 0}}};var Ae=class extends m{static{s(this,"OpenSavesHandler")}async invoke(e){return{intent:"open:saves",code:(await this.ui.showDrawer({view:"saves"})).code,data:void 0}}};var De=class extends m{static{s(this,"OpenNotificationsHandler")}async invoke(e){return{intent:"open:notifications",code:(await this.ui.showDrawer({view:"notifications"})).code,data:void 0}}};var Pe=class extends m{static{s(this,"OpenProfileHandler")}async invoke(e){return{intent:"open:profile",code:(await this.ui.showDrawer({view:"profile"})).code,data:void 0}}};var jr=w({productId:A(B([A(y(),D(x)),R()]),D(n=>Number(n)),R()),variantId:L(A(B([A(y(),D(x)),R()]),D(Number),R()))}),Te=class extends m{static{s(this,"OpenProductHandler")}async invoke(e){let t=C(jr,e);if(!t.success)return{intent:"open:product",code:"error",message:"Invalid intent data",issues:t.issues.map(u=>u.message)};let{productId:r,variantId:i}=t.output;return{intent:"open:product",code:(await this.ui.showDrawer({view:"product",productId:r.toString(),variantId:i?.toString()})).code,data:void 0}}};var Hr=w({listId:y()}),_e=class extends m{static{s(this,"OpenListMenuHandler")}async invoke(e){let t=C(Hr,e);if(!t.success)return{intent:"open:list-menu",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{listId:r}=t.output,i=await this.ui.showListMenu({listId:r});return i.code==="closed"?{intent:"open:list-menu",code:"closed"}:i.data.action==="edit"?{intent:"edit:list",code:"ok",data:i.data.data}:{intent:"delete:list",code:"ok",data:{listId:r}}}};var Qr=w({orderId:y()}),Oe=class extends m{static{s(this,"OpenOrderMenuHandler")}async invoke(e){let t=C(Qr,e);if(!t.success)return{intent:"open:order-menu",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{orderId:r}=t.output;return{intent:"open:order-menu",code:(await this.ui.showOrderMenu({orderId:r})).code,data:void 0}}};var Wr=w({listId:y()}),Le=class extends m{static{s(this,"OpenListDetailPageMenuHandler")}async invoke(e){let t=C(Wr,e);if(!t.success)return{intent:"open:list-detail-page-menu",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{listId:r}=t.output;return{intent:"open:list-detail-page-menu",code:(await this.ui.showListDetailPageMenu({listId:r})).code,data:void 0}}};var Go=w({returnTo:L(y())}),qe=class extends m{static{s(this,"OpenSignInHandler")}async invoke(e){return{intent:"open:sign-in",code:(await this.ui.showSignIn({returnTo:e?.returnTo})).code,data:void 0}}};var zr=w({productId:A(B([A(y(),D(x)),R()]),D(n=>Number(n)),R()),variantId:L(A(B([A(y(),D(x)),R()]),D(Number),R()))}),$e=class extends m{static{s(this,"OpenQuickBuyHandler")}async invoke(e){let t=C(zr,e);if(!t.success)return{intent:"open:quick-buy",code:"error",message:"Invalid intent data",issues:t.issues.map(u=>u.message)};let{productId:r,variantId:i}=t.output,o=await this.ui.showQuickBuy({productId:r,variantId:i});return o.code==="closed"?{intent:"open:quick-buy",code:"closed"}:{intent:"open:quick-buy",code:"ok",data:o.data}}};var J=class{constructor(e,t,r){this.swish=e;this.ui=t;this.options=r}static{s(this,"IntentHook")}};var Ve=class extends J{static{s(this,"AfterSaveItemHook")}async invoke(e){if(this.options.save.showToast&&e.code==="ok"){let{item:t,product:r,variant:i}=e.data;r&&(await(await this.swish.intents.invoke("show:toast",{title:"Saved",text:r.title,image:i?.image?.url??r.featuredImage?.url,action:{label:"Add to List"}})).complete).code==="ok"&&this.swish.intents.invoke("edit:item-lists",{itemId:t.id})}}};var Be=class extends J{static{s(this,"AfterEditItemListsHook")}async invoke(e){if(this.options.edit.showToast&&e.code==="ok"){if("itemId"in e.data)return;let{product:t,variant:r}=e.data;t&&(await(await this.swish.intents.invoke("show:toast",{title:"Saved",text:t.title,image:r?.image?.url??t.featuredImage?.url,action:{label:"View"}})).complete).code==="ok"&&this.swish.intents.invoke("open:home")}}};var Ne=class extends J{static{s(this,"AfterOpenHomeHook")}async invoke(e){if(e.code==="closed"){let t=new URL(window.location.href);(t.hash==="#swish-home"||t.hash==="#swish")&&(t.hash="",window.history.replaceState({},document.title,t.toString()))}}};var aa=w({title:L(y()),text:y(),image:L(y()),action:L(w({label:y(),url:L(y())}))}),Ue=class extends m{static{s(this,"ShowToastHandler")}async invoke(e){return{intent:"show:toast",code:(await this.ui.showToast(e)).code,data:void 0}}};var Xr=w({orderId:A(B([A(y(),D(x)),R()]),D(n=>Number(n)),R())}),Me=class extends m{static{s(this,"OpenOrderHandler")}async invoke(e){let t=C(Xr,e);if(!t.success)return{intent:"open:order",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{orderId:r}=t.output;return{intent:"open:order",code:(await this.ui.showDrawer({view:"order",orderId:r.toString()})).code,data:void 0}}};var Ge=class{static{s(this,"Intents")}constructor(e,t){this.swish=e,this.ui=t,this.eventBus=new EventTarget,this.options=e.options.swishUi.intents,this.handlers={"save:item":new ve(this.swish,this.ui,this.eventBus,this.options),"delete:item":new Ie(this.swish,this.ui,this.eventBus,this.options),"edit:item-variant":new Se(this.swish,this.ui,this.eventBus,this.options),"edit:item-lists":new be(this.swish,this.ui,this.eventBus,this.options),"create:list":new ge(this.swish,this.ui,this.eventBus,this.options),"edit:list":new Ee(this.swish,this.ui,this.eventBus,this.options),"delete:list":new we(this.swish,this.ui,this.eventBus,this.options),"open:home":new xe(this.swish,this.ui,this.eventBus,this.options),"open:list":new Ce(this.swish,this.ui,this.eventBus,this.options),"open:lists":new ke(this.swish,this.ui,this.eventBus,this.options),"open:orders":new Re(this.swish,this.ui,this.eventBus,this.options),"open:order":new Me(this.swish,this.ui,this.eventBus,this.options),"open:saves":new Ae(this.swish,this.ui,this.eventBus,this.options),"open:notifications":new De(this.swish,this.ui,this.eventBus,this.options),"open:profile":new Pe(this.swish,this.ui,this.eventBus,this.options),"open:product":new Te(this.swish,this.ui,this.eventBus,this.options),"open:list-menu":new _e(this.swish,this.ui,this.eventBus,this.options),"open:order-menu":new Oe(this.swish,this.ui,this.eventBus,this.options),"open:list-detail-page-menu":new Le(this.swish,this.ui,this.eventBus,this.options),"open:sign-in":new qe(this.swish,this.ui,this.eventBus,this.options),"open:quick-buy":new $e(this.swish,this.ui,this.eventBus,this.options),"show:toast":new Ue(this.swish,this.ui,this.eventBus,this.options)},this.initIntentHooks(),this.initIntentWatcher()}publishAnalyticsEvent(e,t){typeof window.Shopify?.analytics?.publish=="function"&&window.Shopify.analytics.publish(e,t)}async invoke(e,...t){let r=t[0],i={lifecycle:"before",intent:e,data:r};return this.publishAnalyticsEvent("swish-intent",i),this.publishAnalyticsEvent(`swish-intent=${e}`,i),{intent:e,data:r,complete:this.handleIntent(e,r).then(o=>{let u={lifecycle:"after",intent:e,data:r,response:o};return this.publishAnalyticsEvent("swish-intent",u),this.publishAnalyticsEvent(`swish-intent=${e}`,u),this.eventBus.dispatchEvent(new CustomEvent(e,{detail:o})),o})}}listen(e,t){let r=s(o=>{"detail"in o&&o.detail?t(o.detail):console.warn("Intent response event without detail",o)},"eventListener"),i=s(()=>{this.eventBus.removeEventListener(e,r)},"unsubscribe");return this.eventBus.addEventListener(e,r),i}parseIntentFromString(e){if(typeof e=="string"){let[t,...r]=e.split(","),i=r.reduce((o,u)=>{let[a,l]=u.split("=");return o[a]=l,o},{});return{intent:t,data:i}}return{intent:e,data:{}}}parseIntentFromHash(e){let t=e.startsWith("#")?e.slice(1):e;return{swish:"open:home","swish-home":"open:home","swish-lists":"open:lists","swish-orders":"open:orders","swish-saves":"open:saves","swish-notifications":"open:notifications","swish-profile":"open:profile"}[t]||null}async handleIntent(e,t){let r=this.handlers[e];return r?r.invoke(t):{intent:e,code:"error",message:"Invalid intent",issues:[`Intent ${e} not found`]}}initIntentHooks(){this.eventBus.addEventListener("save:item",e=>{new Ve(this.swish,this.ui,this.options).invoke(e.detail)}),this.eventBus.addEventListener("edit:item-lists",e=>{new Be(this.swish,this.ui,this.options).invoke(e.detail)}),this.eventBus.addEventListener("open:home",e=>{new Ne(this.swish,this.ui,this.options).invoke(e.detail)})}initIntentWatcher(){ce({selector:"[swish-intent]",onElementFound:s(e=>{let t=e.getAttribute("swish-intent");t&&e.addEventListener("click",()=>{let{intent:r,data:i}=this.parseIntentFromString(t);Object.keys(i).length>0?this.invoke(r,i):this.invoke(r)})},"onElementFound")}),ce({selector:"a[href*='swish-intent='],a[href*='#swish']",onElementFound:s(e=>{e instanceof HTMLAnchorElement&&e.addEventListener("click",t=>{if(!t.metaKey&&!t.ctrlKey&&!t.shiftKey&&!t.altKey){let r=new URL(e.href),i=r.hash,o=r.searchParams.get("swish-intent");if(o){let{intent:u,data:a}=this.parseIntentFromString(o);u&&(t.preventDefault(),t.stopPropagation(),Object.keys(a).length>0?this.invoke(u,a):this.invoke(u))}else if(i){let u=this.parseIntentFromHash(i);u&&(t.preventDefault(),t.stopPropagation(),this.invoke(u))}}})},"onElementFound")}),ae({fireOnInit:!0,onLocationChange:s(e=>{let t=new URL(e.href),r=t.hash,i=t.searchParams.get("swish-intent");if(i){let{intent:o,data:u}=this.parseIntentFromString(i);o&&(Object.keys(u).length>0?this.invoke(o,u):this.invoke(o))}else if(r){let o=this.parseIntentFromHash(r);o&&this.invoke(o)}},"onLocationChange")})}};var tn=s(n=>({storefrontApi:{storeDomain:n.storefrontApi?.storeDomain??"",accessToken:n.storefrontApi?.accessToken??""},storefrontContext:{...n.storefrontContext,localization:{country:n.storefrontContext.localization.country.toUpperCase(),language:n.storefrontContext.localization.language.toUpperCase(),market:n.storefrontContext.localization.market}},badges:{getBadges:n.badges?.getBadges??(({defaultBadges:e})=>e)},metafields:{product:n.metafields?.product??[],productVariant:n.metafields?.productVariant??[]},swishApi:{authProxy:n.swishApi?.authProxy??"/apps/wishlist/api",version:n.swishApi?.version??"2026-01"},swishUi:{baseUrl:n.swishUi?.baseUrl??"https://swish.app/cdn",version:n.swishUi?.version??Fe,components:{productRow:{showVariantTitle:n.swishUi?.components?.productRow?.showVariantTitle??!1},productDetail:{descriptionMaxLines:n.swishUi?.components?.productDetail?.descriptionMaxLines??4},variantSelect:{displayType:n.swishUi?.components?.variantSelect?.displayType??"pills"},icons:n.swishUi?.components?.icons??{},imageSlider:{flush:n.swishUi?.components?.imageSlider?.flush??!1,loop:n.swishUi?.components?.imageSlider?.loop??!1},images:{baseTint:n.swishUi?.components?.images?.baseTint??!1},buyButtons:{shopPay:n.swishUi?.components?.buyButtons?.shopPay??!1},listDetailPage:{desktopColumns:n.swishUi?.components?.listDetailPage?.desktopColumns??4,showBuyButton:n.swishUi?.components?.listDetailPage?.showBuyButton??!0,showVariantOptionNames:n.swishUi?.components?.listDetailPage?.showVariantOptionNames??!1,enableVariantChange:n.swishUi?.components?.listDetailPage?.enableVariantChange??!0},drawer:{title:n.swishUi?.components?.drawer?.title??"",logo:{url:n.swishUi?.components?.drawer?.logo?.url??"",altText:n.swishUi?.components?.drawer?.logo?.altText??""},navigation:{variant:n.swishUi?.components?.drawer?.navigation?.variant??"floating",items:n.swishUi?.components?.drawer?.navigation?.items??[{id:"home",enabled:!0,intent:"open:home"},{id:"saves",enabled:!0,intent:"open:saves"},{id:"lists",enabled:!0,intent:"open:lists"},{id:"orders",enabled:!0,intent:"open:orders"},{id:"profile",enabled:!0,intent:"open:profile"},{id:"notifications",enabled:!0,intent:"open:notifications"}]},miniMenu:{items:n.swishUi?.components?.drawer?.miniMenu?.items??[]},listDetailView:{enableVariantChange:n.swishUi?.components?.drawer?.listDetailView?.enableVariantChange??!1,showVariantOptionNames:n.swishUi?.components?.drawer?.listDetailView?.showVariantOptionNames??!1}}},css:n.swishUi?.css??[],intents:{save:{requireVariant:n.swishUi?.intents?.save?.requireVariant??!1,requireVariantConfirmation:n.swishUi?.intents?.save?.requireVariantConfirmation??!1,showToast:n.swishUi?.intents?.save?.showToast??!1},edit:{requireVariantConfirmation:n.swishUi?.intents?.edit?.requireVariantConfirmation??!1,showToast:n.swishUi?.intents?.edit?.showToast??!1},unsave:{requireConfirmation:n.swishUi?.intents?.unsave?.requireConfirmation??!1,openEditor:n.swishUi?.intents?.unsave?.openEditor??!1,showToast:n.swishUi?.intents?.unsave?.showToast??!1}},theme:n.swishUi?.theme??{}}}),"createSwishOptions");var Kr=Symbol.for("preact-signals");function He(){if(Z>1)Z--;else{for(var n,e=!1;pe!==void 0;){var t=pe;for(pe=void 0,pt++;t!==void 0;){var r=t.o;if(t.o=void 0,t.f&=-3,!(8&t.f)&&sn(t))try{t.c()}catch(i){e||(n=i,e=!0)}t=r}}if(pt=0,Z--,e)throw n}}s(He,"t");function ee(n){if(Z>0)return n();Z++;try{return n()}finally{He()}}s(ee,"r");var b=void 0;function nn(n){var e=b;b=void 0;try{return n()}finally{b=e}}s(nn,"n");var pe=void 0,Z=0,pt=0,je=0;function rn(n){if(b!==void 0){var e=n.n;if(e===void 0||e.t!==b)return e={i:0,S:n,p:b.s,n:void 0,t:b,e:void 0,x:void 0,r:e},b.s!==void 0&&(b.s.n=e),b.s=e,n.n=e,32&b.f&&n.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=b.s,e.n=void 0,b.s.n=e,b.s=e),e}}s(rn,"e");function U(n,e){this.v=n,this.i=0,this.n=void 0,this.t=void 0,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}s(U,"u");U.prototype.brand=Kr;U.prototype.h=function(){return!0};U.prototype.S=function(n){var e=this,t=this.t;t!==n&&n.e===void 0&&(n.x=t,this.t=n,t!==void 0?t.e=n:nn(function(){var r;(r=e.W)==null||r.call(e)}))};U.prototype.U=function(n){var e=this;if(this.t!==void 0){var t=n.e,r=n.x;t!==void 0&&(t.x=r,n.e=void 0),r!==void 0&&(r.e=t,n.x=void 0),n===this.t&&(this.t=r,r===void 0&&nn(function(){var i;(i=e.Z)==null||i.call(e)}))}};U.prototype.subscribe=function(n){var e=this;return H(function(){var t=e.value,r=b;b=void 0;try{n(t)}finally{b=r}},{name:"sub"})};U.prototype.valueOf=function(){return this.value};U.prototype.toString=function(){return this.value+""};U.prototype.toJSON=function(){return this.value};U.prototype.peek=function(){var n=b;b=void 0;try{return this.value}finally{b=n}};Object.defineProperty(U.prototype,"value",{get:s(function(){var n=rn(this);return n!==void 0&&(n.i=this.i),this.v},"get"),set:s(function(n){if(n!==this.v){if(pt>100)throw new Error("Cycle detected");this.v=n,this.i++,je++,Z++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{He()}}},"set")});function T(n,e){return new U(n,e)}s(T,"d");function sn(n){for(var e=n.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}s(sn,"c");function on(n){for(var e=n.s;e!==void 0;e=e.n){var t=e.S.n;if(t!==void 0&&(e.r=t),e.S.n=e,e.i=-1,e.n===void 0){n.s=e;break}}}s(on,"a");function an(n){for(var e=n.s,t=void 0;e!==void 0;){var r=e.p;e.i===-1?(e.S.U(e),r!==void 0&&(r.n=e.n),e.n!==void 0&&(e.n.p=r)):t=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=r}n.s=t}s(an,"l");function re(n,e){U.call(this,void 0),this.x=n,this.s=void 0,this.g=je-1,this.f=4,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}s(re,"y");re.prototype=new U;re.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===je))return!0;if(this.g=je,this.f|=1,this.i>0&&!sn(this))return this.f&=-2,!0;var n=b;try{on(this),b=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return b=n,an(this),this.f&=-2,!0};re.prototype.S=function(n){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}U.prototype.S.call(this,n)};re.prototype.U=function(n){if(this.t!==void 0&&(U.prototype.U.call(this,n),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}};re.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var n=this.t;n!==void 0;n=n.x)n.t.N()}};Object.defineProperty(re.prototype,"value",{get:s(function(){if(1&this.f)throw new Error("Cycle detected");var n=rn(this);if(this.h(),n!==void 0&&(n.i=this.i),16&this.f)throw this.v;return this.v},"get")});function G(n,e){return new re(n,e)}s(G,"w");function un(n){var e=n.u;if(n.u=void 0,typeof e=="function"){Z++;var t=b;b=void 0;try{e()}catch(r){throw n.f&=-2,n.f|=8,dt(n),r}finally{b=t,He()}}}s(un,"_");function dt(n){for(var e=n.s;e!==void 0;e=e.n)e.S.U(e);n.x=void 0,n.s=void 0,un(n)}s(dt,"b");function Yr(n){if(b!==this)throw new Error("Out-of-order effect");an(this),b=n,this.f&=-2,8&this.f&&dt(this),He()}s(Yr,"g");function ue(n,e){this.x=n,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=e?.name}s(ue,"p");ue.prototype.c=function(){var n=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.u=e)}finally{n()}};ue.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,un(this),on(this),Z++;var n=b;return b=this,Yr.bind(this,n)};ue.prototype.N=function(){2&this.f||(this.f|=2,this.o=pe,pe=this)};ue.prototype.d=function(){this.f|=8,1&this.f||dt(this)};ue.prototype.dispose=function(){this.d()};function H(n,e){var t=new ue(n,e);try{t.c()}catch(i){throw t.d(),i}var r=t.d.bind(t);return r[Symbol.dispose]=r,r}s(H,"E");var Jr=/\/products\/([^/?#]+)(?:\?(?:[^#]*?&)?variant=(\d+))?/,ft=s(n=>{let e=n.match(Jr);return e?{productHandle:e[1],variantId:e[2]}:null},"parseProductUrl"),ln=s(({source:n,onProductUrlChange:e})=>{let t=s(r=>{let i=ft(r);i?.productHandle&&e(i)},"handleChange");if(n instanceof HTMLAnchorElement)return Yt({element:n,onHrefChange:s(r=>t(r),"onHrefChange")});if(n instanceof Location)return ae({onLocationChange:s(r=>t(r.href),"onLocationChange")});throw new Error("Invalid source for observing product url")},"observeProductUrl");var cn=s(n=>e=>{let{productHandle:t,productId:r,variantId:i,itemId:o}=e?.dataset??{},l=!!(r||t)||!!o,c=T({loading:!1,productId:r,variantId:i,itemId:o});if(!l){let p=e instanceof HTMLAnchorElement?e:window.location,h=ft(p.href);h?.productHandle&&h.productHandle!==c.value.productHandle&&(c.value={...c.value,...h,productId:void 0},ln({source:p,onProductUrlChange:s(g=>{c.value={...c.value,...g,productId:g.productHandle!==c.value.productHandle?void 0:c.value.productId}},"onProductUrlChange")}))}return H(()=>{c.value.loading||!c.value.productId&&c.value.productHandle&&(c.value={...c.value,loading:!0},n.storefront.loadProductId({productHandle:c.value.productHandle}).then(p=>{p.errors&&console.error("Error loading product id",p.errors),c.value={...c.value,productId:p.data?.product?.id?x(p.data.product.id):void 0,loading:!1}}))}),c},"itemContextSignal");var pn=s(n=>e=>{let t=G(()=>{let{productId:k,variantId:I,loading:q}=e.value;return!k||q?null:I?`variant:${x(I)}`:`product:${x(k)}`}),r=G(()=>e.value.loading||!!e.value.itemId||!e.value.productId),i=G(()=>({limit:1,query:t.value??void 0})),o=T(!r.value),u=T(null),a=T(!1),l=T(!1),{data:c,loading:p,error:h,refetching:g}=n.state.swishQuery(k=>n.api.items.list(k),{refetch:["item-create","item-update","item-delete"],variables:i,skip:r}),f=T(e.value.itemId??null);H(()=>{ee(()=>{if(o.value=p.value,u.value=h.value,!e.value.itemId){let k=c.value?.[0]?.id??null;k!==f.value&&(f.value=k)}})});async function P(){if(!f.value)return;a.value=!0,(await(await n.intents.invoke("delete:item",{itemId:f.value})).complete).code==="ok"&&(f.value=null),a.value=!1}s(P,"unsave");async function v(){if(!f.value)return;a.value=!0;let I=await(await n.intents.invoke("edit:item-lists",{itemId:f.value})).complete;I.code==="ok"&&"itemId"in I.data&&(f.value=null),a.value=!1}s(v,"update");async function _(){let{productId:k,variantId:I}=e.value;if(!k)return;a.value=!0,l.value=!0;let $=await(await n.intents.invoke("save:item",{productId:k,variantId:I})).complete;if($.code==="ok"){let le=$.data;f.value=le.item.id,a.value=!1}else $.code==="error"&&console.warn("Failed to create item",$),ee(()=>{a.value=!1,l.value=!1})}s(_,"save");let V=G(()=>o.value||a.value||e.value.loading);H(()=>{l.value&&!a.value&&!g.value&&(l.value=!1)});let O=G(()=>{let k=g.value&&l.value,I=!!f.value,q=!I&&(a.value||k),$=I&&(a.value||k),le=G(()=>q?"saving":$?"unsaving":I?"saved":"unsaved");return{error:u.value,status:le.value,savedItemId:f.value,loading:V.value,submitting:a.value,saved:I,saving:q,unsaving:$}});async function W(){V.value||(O.value.saved&&O.value.savedItemId?v():O.value.saved||await _())}return s(W,"toggle"),Object.assign(O,{save:_,unsave:P,update:v,toggle:W})},"itemStateSignal");var dn=s(n=>()=>{let{data:e,loading:t,error:r}=n.state.swishQuery(()=>n.api.items.count(),{refetch:["item-create","item-delete"]}),i=T(0),o=T(!0),u=T(null);return H(()=>{ee(()=>{o.value=t.value,u.value=r.value,i.value=e.value?.count??0})}),G(()=>({count:i.value,loading:o.value,error:u.value}))},"itemCountSignal");var Zr="token-update",fn=s(n=>(e,t)=>{let r=T(null),i=T(null),o=T(null),u=T(!t?.skip),a=T(!1),l=G(()=>u.value&&a.value);async function c(){if(!t?.skip?.value)try{u.value=!0;let p=await e(t?.variables?.value);ee(()=>{o.value="error"in p?p.error:null,r.value="data"in p?p.data:null,i.value="pageInfo"in p?p.pageInfo:null,u.value=!1,a.value=!0})}catch(p){ee(()=>{o.value=p,u.value=!1,a.value=!0})}}return s(c,"executeFetch"),H(()=>{if(c(),t?.refetch?.length){let p=[...t.refetch,Zr];return n.events.subscribe(p,c)}}),{data:r,pageInfo:i,error:o,loading:u,refetching:l}},"swishQuerySignals");var ie="GraphQL Client";var ht="An error occurred while fetching from the API. Review 'graphQLErrors' for details.",mt="Response returned unexpected Content-Type:",yt="An unknown error has occurred. The API did not return a data object or any errors in its response.",Qe={json:"application/json",multipart:"multipart/mixed"},vt="X-SDK-Variant",gt="X-SDK-Version",mn="shopify-graphql-client",yn="1.4.1",We=1e3,vn=[429,503],It=/@(defer)\b/i,hn=`\r
8
- `,gn=/boundary="?([^=";]+)"?/i,wt=hn+hn;function z(n,e=ie){return n.startsWith(`${e}`)?n:`${e}: ${n}`}s(z,"formatErrorMessage");function K(n){return n instanceof Error?n.message:JSON.stringify(n)}s(K,"getErrorMessage");function bt(n){return n instanceof Error&&n.cause?n.cause:void 0}s(bt,"getErrorCause");function St(n){return n.flatMap(({errors:e})=>e??[])}s(St,"combineErrors");function ze({client:n,retries:e}){if(e!==void 0&&(typeof e!="number"||e<0||e>3))throw new Error(`${n}: The provided "retries" value (${e}) is invalid - it cannot be less than ${0} or greater than ${3}`)}s(ze,"validateRetries");function M(n,e){return e&&(typeof e!="object"||Array.isArray(e)||typeof e=="object"&&Object.keys(e).length>0)?{[n]:e}:{}}s(M,"getKeyValueIfValid");function Et(n,e){if(n.length===0)return e;let r={[n.pop()]:e};return n.length===0?r:Et(n,r)}s(Et,"buildDataObjectByPath");function bn(n,e){return Object.keys(e||{}).reduce((t,r)=>(typeof e[r]=="object"||Array.isArray(e[r]))&&n[r]?(t[r]=bn(n[r],e[r]),t):(t[r]=e[r],t),Array.isArray(n)?[...n]:{...n})}s(bn,"combineObjects");function xt([n,...e]){return e.reduce(bn,{...n})}s(xt,"buildCombinedDataObject");function Ct({clientLogger:n,customFetchApi:e=fetch,client:t=ie,defaultRetryWaitTime:r=We,retriableCodes:i=vn}){let o=s(async(u,a,l)=>{let c=a+1,p=l+1,h;try{if(h=await e(...u),n({type:"HTTP-Response",content:{requestParams:u,response:h}}),!h.ok&&i.includes(h.status)&&c<=p)throw new Error;let g=h?.headers.get("X-Shopify-API-Deprecated-Reason")||"";return g&&n({type:"HTTP-Response-GraphQL-Deprecation-Notice",content:{requestParams:u,deprecationNotice:g}}),h}catch(g){if(c<=p){let f=h?.headers.get("Retry-After");return await ei(f?parseInt(f,10):r),n({type:"HTTP-Retry",content:{requestParams:u,lastResponse:h,retryAttempt:a,maxRetries:l}}),o(u,c,l)}throw new Error(z(`${l>0?`Attempted maximum number of ${l} network retries. Last message - `:""}${K(g)}`,t))}},"httpFetch");return o}s(Ct,"generateHttpFetch");async function ei(n){return new Promise(e=>setTimeout(e,n))}s(ei,"sleep");function kt({headers:n,url:e,customFetchApi:t=fetch,retries:r=0,logger:i}){ze({client:ie,retries:r});let o={headers:n,url:e,retries:r},u=ti(i),a=Ct({customFetchApi:t,clientLogger:u,defaultRetryWaitTime:We}),l=ni(a,o),c=ri(l),p=ci(l);return{config:o,fetch:l,request:c,requestStream:p}}s(kt,"createGraphQLClient");function ti(n){return e=>{n&&n(e)}}s(ti,"generateClientLogger");async function Sn(n){let{errors:e,data:t,extensions:r}=await n.json();return{...M("data",t),...M("extensions",r),headers:n.headers,...e||!t?{errors:{networkStatusCode:n.status,message:z(e?ht:yt),...M("graphQLErrors",e),response:n}}:{}}}s(Sn,"processJSONResponse");function ni(n,{url:e,headers:t,retries:r}){return async(i,o={})=>{let{variables:u,headers:a,url:l,retries:c,keepalive:p,signal:h}=o,g=JSON.stringify({query:i,variables:u});ze({client:ie,retries:c});let f=Object.entries({...t,...a}).reduce((v,[_,V])=>(v[_]=Array.isArray(V)?V.join(", "):V.toString(),v),{});return!f[vt]&&!f[gt]&&(f[vt]=mn,f[gt]=yn),n([l??e,{method:"POST",headers:f,body:g,signal:h,keepalive:p}],1,c??r)}}s(ni,"generateFetch");function ri(n){return async(...e)=>{if(It.test(e[0]))throw new Error(z("This operation will result in a streamable response - use requestStream() instead."));let t=null;try{t=await n(...e);let{status:r,statusText:i}=t,o=t.headers.get("content-type")||"";return t.ok?o.includes(Qe.json)?await Sn(t):{errors:{networkStatusCode:r,message:z(`${mt} ${o}`),response:t}}:{errors:{networkStatusCode:r,message:z(i),response:t}}}catch(r){return{errors:{message:K(r),...t==null?{}:{networkStatusCode:t.status,response:t}}}}}}s(ri,"generateRequest");async function*ii(n){let e=new TextDecoder;if(n.body[Symbol.asyncIterator])for await(let t of n.body)yield e.decode(t);else{let t=n.body.getReader(),r;try{for(;!(r=await t.read()).done;)yield e.decode(r.value)}finally{t.cancel()}}}s(ii,"getStreamBodyIterator");function si(n,e){return{async*[Symbol.asyncIterator](){try{let t="";for await(let r of n)if(t+=r,t.indexOf(e)>-1){let i=t.lastIndexOf(e),u=t.slice(0,i).split(e).filter(a=>a.trim().length>0).map(a=>a.slice(a.indexOf(wt)+wt.length).trim());u.length>0&&(yield u),t=t.slice(i+e.length),t.trim()==="--"&&(t="")}}catch(t){throw new Error(`Error occured while processing stream payload - ${K(t)}`)}}}}s(si,"readStreamChunk");function oi(n){return{async*[Symbol.asyncIterator](){yield{...await Sn(n),hasNext:!1}}}}s(oi,"createJsonResponseAsyncIterator");function ai(n){return n.map(e=>{try{return JSON.parse(e)}catch(t){throw new Error(`Error in parsing multipart response - ${K(t)}`)}}).map(e=>{let{data:t,incremental:r,hasNext:i,extensions:o,errors:u}=e;if(!r)return{data:t||{},...M("errors",u),...M("extensions",o),hasNext:i};let a=r.map(({data:l,path:c,errors:p})=>({data:l&&c?Et(c,l):{},...M("errors",p)}));return{data:a.length===1?a[0].data:xt([...a.map(({data:l})=>l)]),...M("errors",St(a)),hasNext:i}})}s(ai,"getResponseDataFromChunkBodies");function ui(n,e){if(n.length>0)throw new Error(ht,{cause:{graphQLErrors:n}});if(Object.keys(e).length===0)throw new Error(yt)}s(ui,"validateResponseData");function li(n,e){let t=(e??"").match(gn),r=`--${t?t[1]:"-"}`;if(!n.body?.getReader&&!n.body?.[Symbol.asyncIterator])throw new Error("API multipart response did not return an iterable body",{cause:n});let i=ii(n),o={},u;return{async*[Symbol.asyncIterator](){try{let a=!0;for await(let l of si(i,r)){let c=ai(l);u=c.find(h=>h.extensions)?.extensions??u;let p=St(c);o=xt([o,...c.map(({data:h})=>h)]),a=c.slice(-1)[0].hasNext,ui(p,o),yield{...M("data",o),...M("extensions",u),hasNext:a}}if(a)throw new Error("Response stream terminated unexpectedly")}catch(a){let l=bt(a);yield{...M("data",o),...M("extensions",u),errors:{message:z(K(a)),networkStatusCode:n.status,...M("graphQLErrors",l?.graphQLErrors),response:n},hasNext:!1}}}}}s(li,"createMultipartResponseAsyncInterator");function ci(n){return async(...e)=>{if(!It.test(e[0]))throw new Error(z("This operation does not result in a streamable response - use request() instead."));try{let t=await n(...e),{statusText:r}=t;if(!t.ok)throw new Error(r,{cause:t});let i=t.headers.get("content-type")||"";switch(!0){case i.includes(Qe.json):return oi(t);case i.includes(Qe.multipart):return li(t,i);default:throw new Error(`${mt} ${i}`,{cause:t})}}catch(t){return{async*[Symbol.asyncIterator](){let r=bt(t);yield{errors:{message:z(K(t)),...M("networkStatusCode",r?.status),...M("response",r)},hasNext:!1}}}}}}s(ci,"generateRequestStream");function Rt({client:n,storeDomain:e}){try{if(!e||typeof e!="string")throw new Error;let t=e.trim(),r=t.match(/^https?:/)?t:`https://${t}`,i=new URL(r);return i.protocol="https",i.origin}catch(t){throw new Error(`${n}: a valid store domain ("${e}") must be provided`,{cause:t})}}s(Rt,"validateDomainAndGetStoreUrl");function Xe({client:n,currentSupportedApiVersions:e,apiVersion:t,logger:r}){let i=`${n}: the provided apiVersion ("${t}")`,o=`Currently supported API versions: ${e.join(", ")}`;if(!t||typeof t!="string")throw new Error(`${i} is invalid. ${o}`);let u=t.trim();e.includes(u)||(r?r({type:"Unsupported_Api_Version",content:{apiVersion:t,supportedApiVersions:e}}):console.warn(`${i} is likely deprecated or not supported. ${o}`))}s(Xe,"validateApiVersion");function Ke(n){let e=n*3-2;return e===10?e:`0${e}`}s(Ke,"getQuarterMonth");function At(n,e,t){let r=e-t;return r<=0?`${n-1}-${Ke(r+4)}`:`${n}-${Ke(r)}`}s(At,"getPrevousVersion");function En(){let n=new Date,e=n.getUTCMonth(),t=n.getUTCFullYear(),r=Math.floor(e/3+1);return{year:t,quarter:r,version:`${t}-${Ke(r)}`}}s(En,"getCurrentApiVersion");function Dt(){let{year:n,quarter:e,version:t}=En(),r=e===4?`${n+1}-01`:`${n}-${Ke(e+1)}`;return[At(n,e,3),At(n,e,2),At(n,e,1),t,r,"unstable"]}s(Dt,"getCurrentSupportedApiVersions");function Pt(n){return e=>({...e??{},...n.headers})}s(Pt,"generateGetHeaders");function Tt({getHeaders:n,getApiUrl:e}){return(t,r)=>{let i=[t];if(r&&Object.keys(r).length>0){let{variables:o,apiVersion:u,headers:a,retries:l,signal:c}=r;i.push({...o?{variables:o}:{},...a?{headers:n(a)}:{},...u?{url:e(u)}:{},...l?{retries:l}:{},...c?{signal:c}:{}})}return i}}s(Tt,"generateGetGQLClientParams");var _t="application/json",xn="storefront-api-client",Cn="1.0.9",kn="X-Shopify-Storefront-Access-Token",Rn="Shopify-Storefront-Private-Token",An="X-SDK-Variant",Dn="X-SDK-Version",Pn="X-SDK-Variant-Source",se="Storefront API Client";function Tn(n){if(n&&typeof window<"u")throw new Error(`${se}: private access tokens and headers should only be used in a server-to-server implementation. Use the public API access token in nonserver environments.`)}s(Tn,"validatePrivateAccessTokenUsage");function _n(n,e){if(!n&&!e)throw new Error(`${se}: a public or private access token must be provided`);if(n&&e)throw new Error(`${se}: only provide either a public or private access token`)}s(_n,"validateRequiredAccessTokens");function Ot({storeDomain:n,apiVersion:e,publicAccessToken:t,privateAccessToken:r,clientName:i,retries:o=0,customFetchApi:u,logger:a}){let l=Dt(),c=Rt({client:se,storeDomain:n}),p={client:se,currentSupportedApiVersions:l,logger:a};Xe({...p,apiVersion:e}),_n(t,r),Tn(r);let h=pi(c,e,p),g={storeDomain:c,apiVersion:e,...t?{publicAccessToken:t}:{privateAccessToken:r},headers:{"Content-Type":_t,Accept:_t,[An]:xn,[Dn]:Cn,...i?{[Pn]:i}:{},...t?{[kn]:t}:{[Rn]:r}},apiUrl:h(),clientName:i},f=kt({headers:g.headers,url:g.apiUrl,retries:o,customFetchApi:u,logger:a}),P=Pt(g),v=di(g,h),_=Tt({getHeaders:P,getApiUrl:v});return Object.freeze({config:g,getHeaders:P,getApiUrl:v,fetch:s((...O)=>f.fetch(..._(...O)),"fetch"),request:s((...O)=>f.request(..._(...O)),"request"),requestStream:s((...O)=>f.requestStream(..._(...O)),"requestStream")})}s(Ot,"createStorefrontApiClient");function pi(n,e,t){return r=>{r&&Xe({...t,apiVersion:r});let i=(r??e).trim();return`${n}/api/${i}/graphql.json`}}s(pi,"generateApiUrlFormatter");function di(n,e){return t=>t?e(t):n.apiUrl}s(di,"generateGetApiUrl");var F=`
7
+ `+String(r)));nn(e);for(var s=0;s<e.callbacks.length;s++){var o=r[s];o instanceof Error?e.callbacks[s].reject(o):e.callbacks[s].resolve(o)}}).catch(function(r){tn(n,e,r)})}i(Yi,"dispatchBatch");function tn(n,e,t){nn(e);for(var r=0;r<e.keys.length;r++)n.clear(e.keys[r]),e.callbacks[r].reject(t)}i(tn,"failedDispatch");function nn(n){if(n.cacheHits)for(var e=0;e<n.cacheHits.length;e++)n.cacheHits[e]()}i(nn,"resolveCacheHits");function Ji(n){var e=!n||n.batch!==!1;if(!e)return 1;var t=n&&n.maxBatchSize;if(t===void 0)return 1/0;if(typeof t!="number"||t<1)throw new TypeError("maxBatchSize must be a positive number: "+t);return t}i(Ji,"getValidMaxBatchSize");function Zi(n){var e=n&&n.batchScheduleFn;if(e===void 0)return Ki;if(typeof e!="function")throw new TypeError("batchScheduleFn must be a function: "+e);return e}i(Zi,"getValidBatchScheduleFn");function eo(n){var e=n&&n.cacheKeyFn;if(e===void 0)return function(t){return t};if(typeof e!="function")throw new TypeError("cacheKeyFn must be a function: "+e);return e}i(eo,"getValidCacheKeyFn");function to(n){var e=!n||n.cache!==!1;if(!e)return null;var t=n&&n.cacheMap;if(t===void 0)return new Map;if(t!==null){var r=["get","set","delete","clear"],s=r.filter(function(o){return t&&typeof t[o]!="function"});if(s.length!==0)throw new TypeError("Custom cacheMap missing methods: "+s.join(", "))}return t}i(to,"getValidCacheMap");function no(n){return n&&n.name?n.name:null}i(no,"getValidName");function _r(n){return typeof n=="object"&&n!==null&&typeof n.length=="number"&&(n.length===0||n.length>0&&Object.prototype.hasOwnProperty.call(n,n.length-1))}i(_r,"isArrayLike");Or.exports=Wi});var A=i(n=>n.split("/").pop()??"","shopifyGidToId"),D=i((n,e)=>`gid://shopify/${n}/${e}`,"shopifyIdToGid"),H=i(n=>n.toLowerCase().replace(".myshopify.com",""),"toShopName");var Y=class{constructor(e,t,r=""){this.revalidationPromises=new Map;this.inFlightRequests=new Map;this.clearCachePromise=null;this.cacheName=e,this.defaultCacheControl=t,this.keyPrefix=r}static{i(this,"FetchCache")}async get(e){try{let t=await caches.open(this.cacheName),r=await t.match(e);if(r&&this.isExpired(r)){await t.delete(e);return}return r}catch(t){console.warn("Cache get error:",t);return}}async set(e,t,r){try{if(r?.includes("no-cache"))return;let s=this.createCacheableResponse(t,r);await(await caches.open(this.cacheName)).put(e,s)}catch(s){console.warn("Cache set error:",s)}}async fetchWithCache(e,t,r){let s=await this.getCacheKey(e,t);if(this.clearCachePromise&&await this.clearCachePromise,this.inFlightRequests.has(s))return this.inFlightRequests.get(s).then(a=>a.clone());let o=(async()=>{let a=await this.get(s);if(a)return this.isStaleButRevalidatable(a)&&this.revalidateInBackground(s,e,t,r),a.clone();let u=await fetch(e,t);return u.ok&&await this.set(s,u.clone(),r??this.defaultCacheControl),u})().finally(()=>{this.inFlightRequests.delete(s)});return this.inFlightRequests.set(s,o),o}async delete(e){try{return await(await caches.open(this.cacheName)).delete(e)}catch(t){return console.warn("Cache delete error:",t),!1}}async clear(){return this.clearCachePromise?this.clearCachePromise:(this.clearCachePromise=new Promise(async(e,t)=>{try{let r=await caches.open(this.cacheName),s=await r.keys();await Promise.all(s.map(o=>r.delete(o))),e()}catch(r){console.warn("Cache clear error:",r),t(r)}}),this.clearCachePromise.then(()=>{this.clearCachePromise=null}).catch(e=>{console.warn("Cache clear error:",e)}))}async keys(){try{return(await(await caches.open(this.cacheName)).keys()).map(r=>r.url)}catch(e){return console.warn("Cache keys error:",e),[]}}async has(e){try{let t=await caches.open(this.cacheName),r=await t.match(e);return r&&this.isExpired(r)?(await t.delete(e),!1):r!==void 0}catch(t){return console.warn("Cache has error:",t),!1}}async getStats(){try{return{total:(await(await caches.open(this.cacheName)).keys()).length}}catch(e){return console.warn("Cache stats error:",e),{total:0}}}async cleanupExpiredEntries(){try{let e=await caches.open(this.cacheName),t=await e.keys(),r=0;for(let o of t){let a=await e.match(o);a&&this.isExpired(a)&&(await e.delete(o),r++)}let s=t.length-r;return{removed:r,remaining:s}}catch(e){return console.warn("Cache cleanup error:",e),{removed:0,remaining:0}}}async getCacheKey(e,t){let r=this.getInputUrl(e),s=`${this.keyPrefix}${r}/${JSON.stringify(t)}`,a=new TextEncoder().encode(s),u=await crypto.subtle.digest("SHA-256",a);return`/${Array.from(new Uint8Array(u)).map(p=>p.toString(16).padStart(2,"0")).join("")}`}getInputUrl(e){return e instanceof URL?e.toString():typeof e=="string"?e:e.url}isExpired(e){let t=e.headers.get("Cache-Control");if(!t)return!1;let r=this.parseMaxAge(t),s=this.parseStaleWhileRevalidate(t);if(r===null)return!1;let o=e.headers.get("Date");if(!o)return!1;let a=new Date(o).getTime(),c=(Date.now()-a)/1e3,l=r+(s??0);return c>l}isStaleButRevalidatable(e){let t=e.headers.get("Cache-Control");if(!t)return!1;let r=this.parseMaxAge(t),s=this.parseStaleWhileRevalidate(t);if(r===null||s===null)return!1;let o=e.headers.get("Date");if(!o)return!1;let a=new Date(o).getTime(),c=(Date.now()-a)/1e3;return c>r&&c<=r+s}async revalidateInBackground(e,t,r,s){if(this.revalidationPromises.has(e))return;let o=(async()=>{try{let a=await fetch(t,r);a.ok&&await this.set(e,a.clone(),s??this.defaultCacheControl)}catch(a){console.warn("Background revalidation error:",a)}finally{this.revalidationPromises.delete(e)}})();this.revalidationPromises.set(e,o)}parseMaxAge(e){let t=new RegExp(/max-age=(\d+)/).exec(e);return t?parseInt(t[1],10):null}parseStaleWhileRevalidate(e){let t=new RegExp(/stale-while-revalidate=(\d+)/).exec(e);return t?parseInt(t[1],10):null}createCacheableResponse(e,t){let r=new Headers(e.headers);return r.set("Cache-Control",t),r.has("Date")||r.set("Date",new Date().toUTCString()),new Response(e.body,{status:e.status,statusText:e.statusText,headers:r})}};var we=class{static{i(this,"AjaxApiClient")}constructor(e){this.config=e;let t=H(e.storeDomain);this.cache=new Y(`ajax-api-${t}`,"max-age=60, stale-while-revalidate=3600"),this.cache.cleanupExpiredEntries().catch(r=>{console.warn("Ajax API cache initialization cleanup error:",r)})}patchFetch(){if(!window.fetch||typeof window.fetch!="function")return;let e=window.fetch,t=this.config.responseInterceptor,r=this.getFetchRequest.bind(this);window.fetch=function(...s){let o=e.apply(this,s);if(typeof t=="function"){let a=r(s[0]);o.then(u=>t(u,a))}return o}}getFetchRequest(e){return e instanceof Request?e:new Request(e)}getBaseUrl(){if(!this.config?.storeDomain)throw new Error("Cart API client not initialized - missing store domain");return`https://${this.config.storeDomain}`}fetch(e,t){return(e instanceof Request?e.method:t?.method??"GET")==="GET"?this.cache.fetchWithCache(e,t):fetch(e,t)}async request(e,t={}){let r=`${this.getBaseUrl()}${e}`,s={"Content-Type":"application/json",Accept:"application/json"},o=await this.fetch(r,{...t,headers:{...s,...t.headers}});if(!o.ok){let a;try{a=await o.json()}catch{a={message:`HTTP ${o.status}: ${o.statusText}`,status:o.status.toString(),description:o.statusText}}throw new Error(a.message||a.description)}return o.json()}async fetchCart(){return this.request("/cart.js")}async addToCart(e){let t={...e,items:e.items.map(r=>{let s=Number(A(String(r.id)));if(!Number.isFinite(s)||s<=0)throw new Error(`Invalid Shopify ID: ${r.id}`);return{...r,id:s}})};return this.request("/cart/add.js",{method:"POST",body:JSON.stringify(t)})}async clearCache(){await this.cache.clear()}};var Ie=class{constructor(e){this.eventMap={"/cart/add":"cart-add","/cart/update":"cart-update","/cart/change":"cart-change","/cart/clear":"cart-clear"};this.eventBus=e,this.processFetchResponse=this.processFetchResponse.bind(this)}static{i(this,"AjaxApiPublisher")}async processFetchResponse(e,t){try{let r=this.getEventName(t.url);if(r){let s=await e.clone().json();this.eventBus.publish(r,s)}}catch(r){console.warn(r)}}getEventName(e){for(let[t,r]of Object.entries(this.eventMap))if(e.includes(t))return r;return null}};function zr(){let n=document.body||document.documentElement;return n?Promise.resolve(n):new Promise(e=>{window.addEventListener("DOMContentLoaded",()=>e(n))})}i(zr,"waitForDOM");function ie({onElementFound:n,selector:e,observerOptions:t,mustMatch:r}){let s=new WeakSet,o=new MutationObserver(l=>{let p=!1;for(let f of l)if(f.addedNodes.length>0){p=!0;break}p&&a()}),a=i(()=>{document.querySelectorAll(e).forEach(l=>{s.has(l)||(s.add(l),r?.(l)!==!1&&u(l))})},"locateElements"),u=i(l=>{if(!t){n(l);return}let p=new IntersectionObserver(f=>{for(let y of f)y.isIntersecting&&(p.disconnect(),n(l))},t);p.observe(l)},"observeElement");return i(async()=>{let l=await zr();a(),o.observe(l,{childList:!0,subtree:!0})},"locateAndObserveElements")(),o}i(ie,"createElementLocator");function le({onLocationChange:n,fireOnInit:e=!1}){let t=i(()=>{n(window.location)},"handleChange");window.addEventListener("popstate",t);let r=history.pushState,s=history.replaceState;return history.pushState=function(...o){r.apply(this,o),t()},history.replaceState=function(...o){s.apply(this,o),t()},e&&t(),()=>{window.removeEventListener("popstate",t),history.pushState=r,history.replaceState=s}}i(le,"createLocationObserver");function ln({element:n,onHrefChange:e}){let t=i(()=>{e(n.href)},"handleChange"),r=new MutationObserver(()=>{t()});return r.observe(n,{attributes:!0,attributeFilter:["href"]}),()=>{r.disconnect()}}i(ln,"createHrefObserver");function fn(n,e){if(!e.element)throw new Error("Element must be provided");let t=null,r=new Map,s=i(()=>{if(t){console.warn("Placement already mounted. Skipping mount.");return}Kr(e),t=ie({selector:e.target.selector,observerOptions:e.target.observerOptions,mustMatch:e.target.mustMatch,onElementFound:i(l=>o(l),"onElementFound")})},"mount"),o=i(l=>{r.has(l)||l.hasAttribute("swish-ignore")||l.getAttribute("swish-placement-target")===e.id||(l.setAttribute("swish-placement-target",e.id),a(l))},"evaluateAndMount"),a=i(async l=>{let p=[],f=e.mount.mode,y=is(l,e.mount.at);if(!y)return;let h=await(typeof e.element=="function"?e.element(e):ls(n,e.element));if(!h)return;if(h.setAttribute("swish-placement-element",e.id),typeof e.element!="function"){let k=e.element;k.props&&ps(h,k.props),k.classNames&&mn(h,k.classNames)}let b;e.container&&(b=cs(e.id,e.container),b.appendChild(h));let g,O=b??h;if(e.layout?.type==="overlay"){as(y);let k=e.layout.anchor??"bottom-right";O.setAttribute("swish-placement-overlay",e.id),O.setAttribute("swish-placement-anchor",k)}let N=!1,L;if(e.layout?.type==="inline"){let k=e.layout,ee=k.rowSelector?y.closest(k.rowSelector):null;ee?g=ee:(g=us(e.id,y,k),N=!0),L=g.getAttribute("swish-placement-inline-row"),g.setAttribute("swish-placement-inline-row",e.id)}let G=b??h;if(!os(y,G,f)){try{G.remove()}catch{}return}let I={targetEl:l,renderTargetEl:y,mountEl:h,containerEl:b,rowEl:g,rowWasCreated:N,rowInlineAttrPrevValue:L,cleanupFns:p,ownsNode:!0};r.set(l,I);let V={id:e.id,targetEl:l,renderTargetEl:y,mountEl:I.mountEl,containerEl:b,rowEl:g,cleanup:i(k=>p.push(k),"cleanup")};e.element?.name==="save-button"&&Wr(n,V),e.onMount?.(V)},"mountElement"),u=i(l=>{let p=r.get(l);if(p){if(e.onUnmount?.({id:e.id,targetEl:p.targetEl,renderTargetEl:p.renderTargetEl,mountEl:p.mountEl,containerEl:p.containerEl,rowEl:p.rowEl}),p.cleanupFns.forEach(f=>f()),p.targetEl.getAttribute("swish-placement-target")===e.id&&p.targetEl.removeAttribute("swish-placement-target"),p.ownsNode&&(p.containerEl||p.mountEl).remove(),p.rowEl){if(p.rowWasCreated){let f=p.rowEl.parentElement;f&&p.targetEl.parentElement===p.rowEl?p.rowEl.replaceWith(p.targetEl):f?f.removeChild(p.rowEl):p.rowEl.remove()}else if(p.rowInlineAttrPrevValue!==void 0){let f=p.rowInlineAttrPrevValue;f===null?p.rowEl.removeAttribute("swish-placement-inline-row"):p.rowEl.setAttribute("swish-placement-inline-row",f)}}r.delete(l)}},"unmountElement");return{mount:s,unmount:i(()=>{t&&(t.disconnect(),t=null),r.forEach((l,p)=>u(p)),r.clear()},"unmount")}}i(fn,"createPlacement");var Wr=i((n,{mountEl:e,targetEl:t,cleanup:r})=>{let s=n.state.itemContext(t),o=n.state.effect(()=>{let{loading:a,productId:u,variantId:c}=s.value;a||(e.setAttribute("product-id",u??""),e.setAttribute("variant-id",c??""))});r(()=>o?.())},"saveButtonMount");function Kr(n){let e=Xr(n.id),t=ss(n),r=document.getElementById(e);if(r){r.textContent=t;return}let s=document.createElement("style");s.id=e,s.setAttribute("swish-placement-style",n.id),s.textContent=t,document.head.appendChild(s)}i(Kr,"ensurePlacementStylesheet");function Xr(n){return`swish-placement-style-${Yr(n)}`}i(Xr,"getPlacementStyleId");function Yr(n){return n.replace(/[^a-zA-Z0-9\-_]/g,"_")}i(Yr,"cssEscapeId");function pn(n){return`--swish-placement-${Jr(String(n))}`}i(pn,"designKeyToCSSVar");function Jr(n){return n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase()}i(Jr,"toKebabCase");function Zr(n){return Object.entries(n??{sm:500,lg:700}).map(([r,s])=>({name:r,minWidth:s})).sort((r,s)=>r.minWidth-s.minWidth)}i(Zr,"getBreakpoints");function hn(n,e){if(n==null)return{};if(typeof n=="object"&&!Array.isArray(n)){if(e&&e.size){let t=Object.keys(n);return"base"in n||t.some(s=>e.has(s))?n:{base:n}}return n}return{base:n}}i(hn,"normalizeResponsiveValue");var es=new Set(["fontWeight","lineHeight","pressedScale","backgroundAlpha","pressedOpacity","pressedScale"]);function dn(n,e){if(e!=null)return typeof e=="number"&&!es.has(n)?`${e}px`:String(e)}i(dn,"formatDesignValue");function ts(n,e,t){if(!e)return"";let r=new Set(t.map(c=>c.name)),s=[],o={},a=Object.entries(e).map(([c,l])=>[c,l]);for(let[c,l]of a){let p=hn(l,r),f=dn(String(c),p.base);f!==void 0&&s.push(`${pn(c)}:${f};`);for(let y of t){let h=p[y.name],b=dn(String(c),h);b!==void 0&&(o[y.name]||(o[y.name]=[]),o[y.name].push(`${pn(c)}:${b};`))}}let u=[];s.length&&u.push(`[swish-placement-element="${n}"]{${s.join("")}}`);for(let c of t){let l=o[c.name];l?.length&&u.push(`@media(min-width:${c.minWidth}px){[swish-placement-element="${n}"]{${l.join("")}}}`)}return u.join("")}i(ts,"emitDesignCSS");function be(n){return n==null?"0px":typeof n=="number"?`${n}px`:n}i(be,"formatOffsetValue");function ns(n){return n==null?"":typeof n=="number"?`${n}`:n}i(ns,"formatZIndexValue");function rs(n,e,t){let r=new Set(t.map(l=>l.name)),s=hn(e,r),o=s.base??{},a=be(o.x),u=be(o.y),c=[];c.push(`[swish-placement-overlay="${n}"]{--swish-placement-offset-x:${a};--swish-placement-offset-y:${u};}`);for(let l of t){let p=s[l.name];if(!p)continue;let f=be(p.x),y=be(p.y);c.push(`@media(min-width:${l.minWidth}px){[swish-placement-overlay="${n}"]{--swish-placement-offset-x:${f};--swish-placement-offset-y:${y};}}`)}return c.join("")}i(rs,"emitOverlayOffsetCSS");function ss(n){let e=n.id,t=Zr(n.breakpoints),r=`[swish-placement-inline-row="${e}"]{display:flex;flex-direction:row;align-items:center;gap:var(--swish-placement-inline-gap,8px);width:100%}[swish-placement-inline-row="${e}"]>*:not([swish-placement-element="${e}"]){flex:1;min-width:0}`,s=`[swish-placement-overlay="${e}"]{position:absolute;z-index:var(--swish-placement-overlay-z,10);transform:translate(calc(var(--swish-placement-sign-x,1)*var(--swish-placement-offset-x,0px)),calc(var(--swish-placement-sign-y,1)*var(--swish-placement-offset-y,0px)));}[swish-placement-overlay="${e}"][swish-placement-anchor="top-left"]{top:0;left:0;}[swish-placement-overlay="${e}"][swish-placement-anchor="top-right"]{top:0;right:0;}[swish-placement-overlay="${e}"][swish-placement-anchor="bottom-left"]{bottom:0;left:0;}[swish-placement-overlay="${e}"][swish-placement-anchor="bottom-right"]{bottom:0;right:0;}[swish-placement-overlay="${e}"][swish-placement-anchor$="left"]{--swish-placement-sign-x:1;}[swish-placement-overlay="${e}"][swish-placement-anchor$="right"]{--swish-placement-sign-x:-1;}[swish-placement-overlay="${e}"][swish-placement-anchor^="top"]{--swish-placement-sign-y:1;}[swish-placement-overlay="${e}"][swish-placement-anchor^="bottom"]{--swish-placement-sign-y:-1;}`,o="";if(n.layout?.type==="overlay"){let a=rs(e,n.layout.offset,t),u=n.layout.zIndex?`[swish-placement-overlay="${e}"]{--swish-placement-overlay-z:${ns(n.layout.zIndex)};}`:"";o+=a+u+s}else n.layout?.type==="inline"&&(o+=r);if(n.design){let a=ts(e,n.design,t);a&&(o+=a)}return n.css&&(o+=n.css.trim()),o}i(ss,"buildPlacementCSS");function is(n,e){if(!e||e==="target")return n;if("closest"in e)return n.closest(e.closest);if("query"in e)return n.querySelector(e.query);if("withinClosest"in e){let t=n.closest(e.withinClosest.root);return t?t.querySelector(e.withinClosest.selector):null}return n}i(is,"resolveMountTarget");function os(n,e,t){switch(t){case"before":return n.parentElement?(n.before(e),!0):!1;case"after":{let r=n.parentElement;return r?(r.insertBefore(e,n.nextSibling),!0):!1}case"append":return n.appendChild(e),!0;case"prepend":return n.insertBefore(e,n.firstChild),!0;case"replace":return n.parentElement?(n.replaceWith(e),!0):!1}}i(os,"insertIntoDOM");function as(n){let e=n.parentElement;return e?(window.getComputedStyle(e).position==="static"&&(e.style.position="relative"),e):null}i(as,"ensureRelativeParent");function us(n,e,t){if(!e.parentElement)throw new Error("Cannot inline-wrap: refEl has no parentElement");let s=document.createElement("div");return s.setAttribute("swish-placement-inline-row",n),e.before(s),s.appendChild(e),s}i(us,"wrapWithFlexRow");function cs(n,e){let t=e.tag||"div",r=document.createElement(t);return r.setAttribute("swish-placement-container",n),e.classNames&&mn(r,e.classNames),r}i(cs,"createContainer");function ls(n,e){return n.ui.createElement(e.name,{})}i(ls,"createElement");function ps(n,e){for(let[t,r]of Object.entries(e)){let s=t.replace(/([A-Z])/g,"-$1").toLowerCase();r===!1||r===void 0||r===null||(r===!0?n.setAttribute(s,"true"):n.setAttribute(s,String(r)))}}i(ps,"applyProps");function mn(n,e){n.classList.add(...e)}i(mn,"applyClassNames");var Se=class{constructor(){this.eventBus=new EventTarget}static{i(this,"EventBus")}subscribe(e,t,r){return Array.isArray(e)||(e=[e]),e.forEach(s=>{this.eventBus.addEventListener(s,t,r)}),()=>{e.forEach(s=>{this.eventBus.removeEventListener(s,t,r)})}}unsubscribe(e,t,r){this.eventBus.removeEventListener(e,t,r)}publish(e,t){this.eventBus.dispatchEvent(new CustomEvent(e,{detail:t}))}};var m=class{constructor(e,t,r,s){this.swish=e;this.ui=t;this.eventBus=r;this.options=s}static{i(this,"IntentHandler")}};var Ee=class extends m{static{i(this,"CreateListHandler")}async invoke(e){let t=await this.ui.showListEditor();if(t.code==="closed")return{intent:"create:list",code:"closed"};let{list:r}=t.data;return{intent:"create:list",code:"ok",data:{list:r}}}};var wt;function vn(n){return{lang:n?.lang??wt?.lang,message:n?.message,abortEarly:n?.abortEarly??wt?.abortEarly,abortPipeEarly:n?.abortPipeEarly??wt?.abortPipeEarly}}i(vn,"getGlobalConfig");var ds;function fs(n){return ds?.get(n)}i(fs,"getGlobalMessage");var hs;function ms(n){return hs?.get(n)}i(ms,"getSchemaMessage");var ys;function vs(n,e){return ys?.get(n)?.get(e)}i(vs,"getSpecificMessage");function xe(n){let e=typeof n;return e==="string"?`"${n}"`:e==="number"||e==="bigint"||e==="boolean"?`${n}`:e==="object"||e==="function"?(n&&Object.getPrototypeOf(n)?.constructor?.name)??"null":e}i(xe,"_stringify");function K(n,e,t,r,s){let o=s&&"input"in s?s.input:t.value,a=s?.expected??n.expects??null,u=s?.received??xe(o),c={kind:n.kind,type:n.type,input:o,expected:a,received:u,message:`Invalid ${e}: ${a?`Expected ${a} but r`:"R"}eceived ${u}`,requirement:n.requirement,path:s?.path,issues:s?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},l=n.kind==="schema",p=s?.message??n.message??vs(n.reference,c.lang)??(l?ms(c.lang):null)??r.message??fs(c.lang);p!==void 0&&(c.message=typeof p=="function"?p(c):p),l&&(t.typed=!1),t.issues?t.issues.push(c):t.issues=[c]}i(K,"_addIssue");function J(n){return{version:1,vendor:"valibot",validate(e){return n["~run"]({value:e},vn())}}}i(J,"_getStandardProps");function gn(n,e){let t=[...new Set(n)];return t.length>1?`(${t.join(` ${e} `)})`:t[0]??"never"}i(gn,"_joinExpects");function It(n,e){return{kind:"validation",type:"min_length",reference:It,async:!1,expects:`>=${n}`,requirement:n,message:e,"~run"(t,r){return t.typed&&t.value.length<this.requirement&&K(this,"length",t,r,{received:`${t.value.length}`}),t}}}i(It,"minLength");function te(n,e){return{kind:"validation",type:"min_value",reference:te,async:!1,expects:`>=${n instanceof Date?n.toJSON():xe(n)}`,requirement:n,message:e,"~run"(t,r){return t.typed&&!(t.value>=this.requirement)&&K(this,"value",t,r,{received:t.value instanceof Date?t.value.toJSON():xe(t.value)}),t}}}i(te,"minValue");function P(n){return{kind:"transformation",type:"transform",reference:P,async:!1,operation:n,"~run"(e){return e.value=this.operation(e.value),e}}}i(P,"transform");function gs(n,e,t){return typeof n.fallback=="function"?n.fallback(e,t):n.fallback}i(gs,"getFallback");function wn(n,e,t){return typeof n.default=="function"?n.default(e,t):n.default}i(wn,"getDefault");function de(n,e){return{kind:"schema",type:"array",reference:de,expects:"Array",async:!1,item:n,message:e,get"~standard"(){return J(this)},"~run"(t,r){let s=t.value;if(Array.isArray(s)){t.typed=!0,t.value=[];for(let o=0;o<s.length;o++){let a=s[o],u=this.item["~run"]({value:a},r);if(u.issues){let c={type:"array",origin:"value",input:s,key:o,value:a};for(let l of u.issues)l.path?l.path.unshift(c):l.path=[c],t.issues?.push(l);if(t.issues||(t.issues=u.issues),r.abortEarly){t.typed=!1;break}}u.typed||(t.typed=!1),t.value.push(u.value)}}else K(this,"type",t,r);return t}}}i(de,"array");function bt(n){return{kind:"schema",type:"boolean",reference:bt,expects:"boolean",async:!1,message:n,get"~standard"(){return J(this)},"~run"(e,t){return typeof e.value=="boolean"?e.typed=!0:K(this,"type",e,t),e}}}i(bt,"boolean");function x(n){return{kind:"schema",type:"number",reference:x,expects:"number",async:!1,message:n,get"~standard"(){return J(this)},"~run"(e,t){return typeof e.value=="number"&&!isNaN(e.value)?e.typed=!0:K(this,"type",e,t),e}}}i(x,"number");function w(n,e){return{kind:"schema",type:"object",reference:w,expects:"Object",async:!1,entries:n,message:e,get"~standard"(){return J(this)},"~run"(t,r){let s=t.value;if(s&&typeof s=="object"){t.typed=!0,t.value={};for(let o in this.entries){let a=this.entries[o];if(o in s||(a.type==="exact_optional"||a.type==="optional"||a.type==="nullish")&&a.default!==void 0){let u=o in s?s[o]:wn(a),c=a["~run"]({value:u},r);if(c.issues){let l={type:"object",origin:"value",input:s,key:o,value:u};for(let p of c.issues)p.path?p.path.unshift(l):p.path=[l],t.issues?.push(p);if(t.issues||(t.issues=c.issues),r.abortEarly){t.typed=!1;break}}c.typed||(t.typed=!1),t.value[o]=c.value}else if(a.fallback!==void 0)t.value[o]=gs(a);else if(a.type!=="exact_optional"&&a.type!=="optional"&&a.type!=="nullish"&&(K(this,"key",t,r,{input:void 0,expected:`"${o}"`,path:[{type:"object",origin:"key",input:s,key:o,value:s[o]}]}),r.abortEarly))break}}else K(this,"type",t,r);return t}}}i(w,"object");function _(n,e){return{kind:"schema",type:"optional",reference:_,expects:`(${n.expects} | undefined)`,async:!1,wrapped:n,default:e,get"~standard"(){return J(this)},"~run"(t,r){return t.value===void 0&&(this.default!==void 0&&(t.value=wn(this,t,r)),t.value===void 0)?(t.typed=!0,t):this.wrapped["~run"](t,r)}}}i(_,"optional");function fe(n,e){return{kind:"schema",type:"picklist",reference:fe,expects:gn(n.map(xe),"|"),async:!1,options:n,message:e,get"~standard"(){return J(this)},"~run"(t,r){return this.options.includes(t.value)?t.typed=!0:K(this,"type",t,r),t}}}i(fe,"picklist");function v(n){return{kind:"schema",type:"string",reference:v,expects:"string",async:!1,message:n,get"~standard"(){return J(this)},"~run"(e,t){return typeof e.value=="string"?e.typed=!0:K(this,"type",e,t),e}}}i(v,"string");function yn(n){let e;if(n)for(let t of n)e?e.push(...t.issues):e=t.issues;return e}i(yn,"_subIssues");function M(n,e){return{kind:"schema",type:"union",reference:M,expects:gn(n.map(t=>t.expects),"|"),async:!1,options:n,message:e,get"~standard"(){return J(this)},"~run"(t,r){let s,o,a;for(let u of this.options){let c=u["~run"]({value:t.value},r);if(c.typed)if(c.issues)o?o.push(c):o=[c];else{s=c;break}else a?a.push(c):a=[c]}if(s)return s;if(o){if(o.length===1)return o[0];K(this,"type",t,r,{issues:yn(o)}),t.typed=!0}else{if(a?.length===1)return a[0];K(this,"type",t,r,{issues:yn(a)})}return t}}}i(M,"union");function S(...n){return{...n[0],pipe:n,get"~standard"(){return J(this)},"~run"(e,t){for(let r of n)if(r.kind!=="metadata"){if(e.issues&&(r.kind==="schema"||r.kind==="transformation")){e.typed=!1;break}(!e.issues||!t.abortEarly&&!t.abortPipeEarly)&&(e=r["~run"](e,t))}return e}}}i(S,"pipe");function E(n,e,t){let r=n["~run"]({value:e},vn(t));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}i(E,"safeParse");var ws=w({itemId:v(),delete:_(bt())}),Ce=class extends m{static{i(this,"UnsaveItemHandler")}async invoke(e){let t=E(ws,e);if(!t.success)return{intent:"unsave:item",code:"error",message:"Invalid intent data",issues:t.issues.map(a=>a.message)};let{itemId:r,delete:s}=t.output;if(this.options.unsaveProduct.selectList&&!s){let a=await this.ui.showListSelect({itemId:r});if(a.code==="closed")return{intent:"unsave:item",code:"closed"};if(a.data.action==="submit"){let{item:u,product:c,variant:l}=a.data.data;return{intent:"edit:item-lists",code:"ok",data:{item:u,product:c,variant:l}}}if(a.data.action==="unsave"){let{itemId:u}=a.data.data;return{intent:"unsave:item",code:"ok",data:{itemId:u}}}}if(!this.options.unsaveProduct.confirm){let a=await this.swish.api.items.deleteById(r);return"error"in a?{intent:"unsave:item",code:"error",message:"Failed to delete item",issues:[a.error.message]}:{intent:"unsave:item",code:"ok",data:{itemId:r}}}return(await this.ui.showUnsaveAlert({itemId:r})).code==="closed"?{intent:"unsave:item",code:"closed"}:{intent:"unsave:item",code:"ok",data:{itemId:r}}}};var Is=w({listId:v()}),ke=class extends m{static{i(this,"DeleteListHandler")}async invoke(e){let t=E(Is,e);if(!t.success)return{intent:"delete:list",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{listId:r}=t.output;return(await this.ui.showDeleteListAlert({listId:r})).code==="closed"?{intent:"delete:list",code:"closed"}:{intent:"delete:list",code:"ok",data:{listId:r}}}};var bs=w({itemId:v()}),Re=class extends m{static{i(this,"EditItemListsHandler")}async invoke(e){let t=E(bs,e);if(!t.success)return{intent:"edit:item-lists",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{itemId:r}=t.output,s=await this.ui.showListSelect({itemId:r});if(s.code==="closed")return{intent:"edit:item-lists",code:"closed"};if(s.data.action==="submit"){let{item:o,product:a,variant:u}=s.data.data;return{intent:"edit:item-lists",code:"ok",data:{item:o,product:a,variant:u}}}return{intent:"unsave:item",code:"ok",data:{itemId:s.data.data.itemId}}}};var Ss=w({itemId:S(v()),productId:S(M([S(v(),P(A)),x()]),P(n=>Number(n)),x()),variantId:_(S(M([S(v(),P(A)),x()]),P(n=>Number(n)),x()))}),Ae=class extends m{static{i(this,"EditItemVariantHandler")}async invoke(e){let t=E(Ss,e);if(!t.success)return{intent:"edit:item-variant",code:"error",message:"Invalid intent data",issues:t.issues.map(y=>y.message)};let{itemId:r,productId:s,variantId:o}=t.output;if(!(!o||this.swish.options.intents.editSavedProduct.promptVariantChange)){let y=await this.swish.api.items.updateById(r,{productId:s,variantId:o});if("error"in y)return{intent:"edit:item-variant",code:"error",message:"Failed to update variant",issues:[y.error.message]};if(!y.data)return{intent:"edit:item-variant",code:"error",message:"Failed to update variant",issues:["No item returned from API"]};let h=await this.swish.storefront.loadSaveIntentData({productId:D("Product",s),variantId:o?D("ProductVariant",o):void 0});if(!h.data?.product)return{intent:"edit:item-variant",code:"error",message:"Failed to load save intent data",issues:[h.errors?.message??"No product data returned from API"]};let b=h.data?.product,g="variant"in h.data?h.data.variant:void 0;return{intent:"edit:item-variant",code:"ok",data:{item:y.data,product:b,variant:g}}}let u=await this.ui.showVariantSelect({itemId:r,productId:s,variantId:o});if(u.code==="closed")return{intent:"edit:item-variant",code:"closed"};let{item:c,product:l,variant:p}=u.data;return{intent:"edit:item-variant",code:"ok",data:{item:c,product:l,variant:p}}}};var Es=w({listId:v()}),De=class extends m{static{i(this,"EditListHandler")}async invoke(e){let t=E(Es,e);if(!t.success)return{intent:"edit:list",code:"error",message:"Invalid intent data",issues:t.issues.map(a=>a.message)};let{listId:r}=t.output,s=await this.ui.showListEditor({listId:r});if(s.code==="closed")return{intent:"edit:list",code:"closed"};let{list:o}=s.data;return{intent:"edit:list",code:"ok",data:{list:o}}}};var xs=w({listId:v(),access:fe(["public","private"])}),Pe=class extends m{static{i(this,"EditListAccessHandler")}async invoke(e){let t=E(xs,e);if(!t.success)return{intent:"edit:list-access",code:"error",message:"Invalid intent data",issues:t.issues.map(u=>u.message)};let{listId:r,access:s}=t.output;if((await this.ui.showConfirmDialog({titleKey:s==="public"?"listMenu.public.title":"listMenu.private.title",descriptionKey:s==="public"?"listMenu.public.description":"listMenu.private.description",confirmLabelKey:s==="public"?"listMenu.public.text":"listMenu.private.text",cancelLabelKey:"listMenu.cancel",danger:!1})).code==="closed")return{intent:"edit:list-access",code:"closed"};let a=await this.swish.api.lists.updateById(r,{access:s});return"error"in a?{intent:"edit:list-access",code:"error",message:"Failed to update list access",issues:[a.error.message]}:a.data?{intent:"edit:list-access",code:"ok",data:{list:a.data}}:{intent:"edit:list-access",code:"error",message:"Failed to update list access",issues:["API response missing data"]}}};var Te=class extends m{static{i(this,"OpenHomeHandler")}async invoke(e){return{intent:"open:home",code:(await this.ui.showDrawer()).code,data:void 0}}};var Cs=w({listId:v()}),_e=class extends m{static{i(this,"OpenListDetailPageMenuHandler")}async invoke(e){let t=E(Cs,e);if(!t.success)return{intent:"open:list-detail-page-menu",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{listId:r}=t.output;return{intent:"open:list-detail-page-menu",code:(await this.ui.showListDetailPageMenu({listId:r})).code,data:void 0}}};var ks=w({listId:v()}),Oe=class extends m{static{i(this,"OpenListHandler")}async invoke(e){let t=E(ks,e);if(!t.success)return{intent:"open:list",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{listId:r}=t.output;return{intent:"open:list",code:(await this.ui.showDrawer({view:"list",listId:r})).code,data:void 0}}};var Rs=w({listId:v()}),Le=class extends m{static{i(this,"OpenListMenuHandler")}async invoke(e){let t=E(Rs,e);if(!t.success)return{intent:"open:list-menu",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{listId:r}=t.output,s=await this.ui.showListMenu({listId:r});if(s.code==="closed")return{intent:"open:list-menu",code:"closed"};if(s.data.action==="edit")return{intent:"edit:list",code:"ok",data:s.data.data};if(s.data.action==="delete")return{intent:"delete:list",code:"ok",data:{listId:r}};if(s.data.action==="edit-access"){let o=s.data.data?.currentListAccess,a=o==="public"?"private":o==="private"?"public":void 0;return a?(await this.swish.intents.invoke("edit:list-access",{listId:r,access:a})).complete:{intent:"open:list-menu",code:"error",message:"Missing list access from UI",issues:["List menu UI did not provide currentListAccess"]}}return s.data.action==="share"?(await this.swish.intents.invoke("share:list",{listId:r})).complete:{intent:"open:list-menu",code:"error",message:"Unknown list menu action",issues:["Unknown action returned from list menu UI"]}}};var $e=class extends m{static{i(this,"OpenListsHandler")}async invoke(e){return{intent:"open:lists",code:(await this.ui.showDrawer({view:"lists"})).code,data:void 0}}};var Ve=class extends m{static{i(this,"OpenNotificationsHandler")}async invoke(e){return{intent:"open:notifications",code:(await this.ui.showDrawer({view:"notifications"})).code,data:void 0}}};var As=w({orderId:S(M([S(v(),P(A)),x()]),P(n=>Number(n)),x())}),Me=class extends m{static{i(this,"OpenOrderHandler")}async invoke(e){let t=E(As,e);if(!t.success)return{intent:"open:order",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{orderId:r}=t.output;return{intent:"open:order",code:(await this.ui.showDrawer({view:"order",orderId:r.toString()})).code,data:void 0}}};var Ds=w({orderId:v()}),qe=class extends m{static{i(this,"OpenOrderMenuHandler")}async invoke(e){let t=E(Ds,e);if(!t.success)return{intent:"open:order-menu",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{orderId:r}=t.output;return{intent:"open:order-menu",code:(await this.ui.showOrderMenu({orderId:r})).code,data:void 0}}};var Ne=class extends m{static{i(this,"OpenOrdersHandler")}async invoke(e){return{intent:"open:orders",code:(await this.ui.showDrawer({view:"orders"})).code,data:void 0}}};var Ps=w({productId:S(M([S(v(),P(A)),x()]),P(n=>Number(n)),x()),variantId:_(S(M([S(v(),P(A)),x()]),P(Number),x()))}),Be=class extends m{static{i(this,"OpenProductHandler")}async invoke(e){let t=E(Ps,e);if(!t.success)return{intent:"open:product",code:"error",message:"Invalid intent data",issues:t.issues.map(a=>a.message)};let{productId:r,variantId:s}=t.output;return{intent:"open:product",code:(await this.ui.showDrawer({view:"product",productId:r.toString(),variantId:s?.toString()})).code,data:void 0}}};var Ue=class extends m{static{i(this,"OpenProfileHandler")}async invoke(e){return{intent:"open:profile",code:(await this.ui.showDrawer({view:"profile"})).code,data:void 0}}};var Ts=w({productId:S(M([S(v(),P(A)),x()]),P(n=>Number(n)),x()),variantId:_(S(M([S(v(),P(A)),x()]),P(Number),x()))}),Fe=class extends m{static{i(this,"OpenQuickBuyHandler")}async invoke(e){let t=E(Ts,e);if(!t.success)return{intent:"open:quick-buy",code:"error",message:"Invalid intent data",issues:t.issues.map(a=>a.message)};let{productId:r,variantId:s}=t.output,o=await this.ui.showQuickBuy({productId:r,variantId:s});return o.code==="closed"?{intent:"open:quick-buy",code:"closed"}:{intent:"open:quick-buy",code:"ok",data:o.data}}};var je=class extends m{static{i(this,"OpenSavesHandler")}async invoke(e){return{intent:"open:saves",code:(await this.ui.showDrawer({view:"saves"})).code,data:void 0}}};var Fa=w({returnTo:_(v())}),Ge=class extends m{static{i(this,"OpenSignInHandler")}async invoke(e){return{intent:"open:sign-in",code:(await this.ui.showSignIn({returnTo:e?.returnTo})).code,data:void 0}}};var _s=w({productId:S(M([S(v(),P(A)),x()]),P(n=>Number(n)),x()),variantId:_(S(M([S(v(),P(A)),x()]),P(Number),x())),quantity:_(S(x(),te(1))),tags:_(de(v()))}),He=class extends m{static{i(this,"SaveItemHandler")}async invoke(e){let t=E(_s,e);if(!t.success)return{intent:"save:item",code:"error",message:"Invalid intent data",issues:t.issues.map(h=>h.message)};let{productId:r,variantId:s,quantity:o,tags:a}=t.output,u=await this.swish.storefront.loadSaveIntentData({productId:D("Product",r),variantId:s?D("ProductVariant",s):void 0});if(u.errors)return{intent:"save:item",code:"error",message:u.errors.message??"Failed to load save intent data",issues:u.errors.graphQLErrors?.map(h=>h.message)??[]};if(!u.data||!u.data.product)return{intent:"save:item",code:"error",message:"Failed to load save intent data",issues:["API response missing data"]};let{product:c}=u.data,l=c.variantsCount?.count&&c.variantsCount.count>1,p=!!s,f=!this.options.saveProduct.promptVariantIfMissing||!this.options.saveProduct.promptVariantIfPresent&&p;if(!l||f){let h=i(()=>!l&&c.selectedOrFirstAvailableVariant?Number(A(c.selectedOrFirstAvailableVariant.id)):s,"variantIdToUse"),b=await this.swish.api.items.create({productId:r,variantId:h(),quantity:o,tags:a});if("error"in b)return{intent:"save:item",code:"error",message:"Failed to create item",issues:[b.error.message]};if(!b.data)return{intent:"save:item",code:"error",message:"Could not complete item creation",issues:["API response missing data"]};let g="variant"in u.data?u.data.variant:void 0;return{intent:"save:item",code:"ok",data:{item:b.data,product:c,variant:l?g:c.selectedOrFirstAvailableVariant}}}let y=await this.ui.showVariantSelect({productId:r,variantId:s});return y.code==="closed"?{intent:"save:item",code:"closed"}:{intent:"save:item",code:"ok",data:y.data}}};function he(n,e){let{storeDomain:t}=n.options.storefrontApi,{rootUrl:r,listDetailPagePath:s}=n.options.storefrontContext.routes,o=new URL(`https://${t}`),a=new URL(`${r==="/"?"":r}${s}`,o);return a.searchParams.set("public-list-id",e.publicListId),a}i(he,"buildShareListUrl");async function me(n){return typeof navigator?.clipboard?.writeText!="function"?{ok:!1,issues:["Clipboard API not available"]}:navigator.clipboard.writeText(n).then(()=>({ok:!0})).catch(e=>({ok:!1,issues:[e?.message??"Failed to copy to clipboard"]}))}i(me,"copyToClipboard");function In(){let n=navigator.userAgent.includes("Mac OS")&&navigator.maxTouchPoints>1;return/Android|Mobile/i.test(navigator.userAgent)||n}i(In,"isMobileDevice");var Os=w({listId:v()}),Qe=class extends m{static{i(this,"ShareListHandler")}async invoke(e){let t=E(Os,e);if(!t.success)return{intent:"share:list",code:"error",message:"Invalid intent data",issues:t.issues.map(u=>u.message)};let{listId:r}=t.output,s=he(this.swish,{publicListId:r}).toString();if(In()&&typeof navigator.share=="function"&&(await navigator.share({title:"Share list",url:s}).then(()=>({ok:!0})).catch(()=>({ok:!1}))).ok)return{intent:"share:list",code:"ok",data:{listId:r,url:s,method:"native"}};let a=await me(s);return a.ok?{intent:"share:list",code:"ok",data:{listId:r,url:s,method:"clipboard"}}:{intent:"share:list",code:"error",message:"Failed to share list",issues:a.issues}}};var uu=w({title:_(v()),text:v(),image:_(v()),action:_(w({label:v(),url:_(v())})),variant:_(fe(["compact","full"])),icon:_(v())}),ze=class extends m{static{i(this,"ShowToastHandler")}async invoke(e){return{intent:"show:toast",code:(await this.ui.showToast(e)).code,data:void 0}}};var St=S(M([S(v(),P(A)),x()]),P(n=>Number(n)),S(x(),te(1)));var Ls=M([w({variantId:St,quantity:_(S(x(),te(1)),1)}),w({items:S(de(w({variantId:St,quantity:_(S(x(),te(1)),1)})),It(1))})]),We=class extends m{static{i(this,"CreateCartLineHandler")}async invoke(e){let t=E(Ls,e);if(!t.success)return{intent:"create:cart-line",code:"error",message:"Invalid intent data",issues:t.issues.map(s=>s.message)};let r=t.output;try{let s="items"in r?r.items.map(a=>({id:a.variantId,quantity:a.quantity})):[{id:r.variantId,quantity:r.quantity}];return{intent:"create:cart-line",code:"ok",data:await this.swish.ajax.addToCart({items:s})}}catch(s){let o=[],a="Failed to add item to cart";return s instanceof Error?(s.message&&(a=s.message,o.push(s.message)),s.stack&&o.push(s.stack)):typeof s=="string"&&s.trim()?(a=s,o.push(s)):s!=null&&o.push(String(s)),{intent:"create:cart-line",code:"error",message:a,issues:o.length?o:["Cart request failed"]}}}};var z=class{constructor(e,t,r){this.swish=e;this.ui=t;this.options=r}static{i(this,"IntentHook")}};var Ke=class extends z{static{i(this,"AfterEditItemListsHook")}async invoke(e){if(this.options.editSavedProduct.showFeedback&&e.code==="ok"){if("itemId"in e.data)return;let{product:t,variant:r}=e.data;t&&(await(await this.swish.intents.invoke("show:toast",{title:"Saved",text:t.title,image:r?.image?.url??t.featuredImage?.url,action:{label:"View"}})).complete).code==="ok"&&this.swish.intents.invoke("open:home")}}};var Xe=class extends z{static{i(this,"AfterEditListAccessHook")}async invoke(e){if(e.code!=="ok")return;let t=e.data.list.access==="public"?"List is now public":"List is now private";await(await this.swish.intents.invoke("show:toast",{text:t,variant:"compact",icon:"check"})).complete}};var Ye=class extends z{static{i(this,"AfterOpenHomeHook")}async invoke(e){if(e.code==="closed"){let t=new URL(window.location.href);(t.hash==="#swish-home"||t.hash==="#swish")&&(t.hash="",window.history.replaceState({},document.title,t.toString()))}}};var Je=class extends z{static{i(this,"AfterSaveItemHook")}async invoke(e){if(this.options.saveProduct.showFeedback&&e.code==="ok"){let{item:t,product:r,variant:s}=e.data;r&&(await(await this.swish.intents.invoke("show:toast",{title:"Saved",text:r.title,image:s?.image?.url??r.featuredImage?.url,action:{label:"Add to List"}})).complete).code==="ok"&&this.swish.intents.invoke("edit:item-lists",{itemId:t.id})}}};var Ze=class extends z{static{i(this,"AfterShareListHook")}async invoke(e){if(e.code!=="ok")return;await(await this.swish.intents.invoke("show:toast",{variant:"compact",text:"Link shared",icon:"check"})).complete}};var et=class{static{i(this,"Intents")}constructor(e,t){this.swish=e,this.ui=t,this.eventBus=new EventTarget,this.options=e.options.intents,this.handlers={"create:cart-line":new We(this.swish,this.ui,this.eventBus,this.options),"save:item":new He(this.swish,this.ui,this.eventBus,this.options),"unsave:item":new Ce(this.swish,this.ui,this.eventBus,this.options),"edit:item-variant":new Ae(this.swish,this.ui,this.eventBus,this.options),"edit:item-lists":new Re(this.swish,this.ui,this.eventBus,this.options),"create:list":new Ee(this.swish,this.ui,this.eventBus,this.options),"edit:list":new De(this.swish,this.ui,this.eventBus,this.options),"edit:list-access":new Pe(this.swish,this.ui,this.eventBus,this.options),"delete:list":new ke(this.swish,this.ui,this.eventBus,this.options),"open:home":new Te(this.swish,this.ui,this.eventBus,this.options),"share:list":new Qe(this.swish,this.ui,this.eventBus,this.options),"open:list":new Oe(this.swish,this.ui,this.eventBus,this.options),"open:lists":new $e(this.swish,this.ui,this.eventBus,this.options),"open:orders":new Ne(this.swish,this.ui,this.eventBus,this.options),"open:order":new Me(this.swish,this.ui,this.eventBus,this.options),"open:saves":new je(this.swish,this.ui,this.eventBus,this.options),"open:notifications":new Ve(this.swish,this.ui,this.eventBus,this.options),"open:profile":new Ue(this.swish,this.ui,this.eventBus,this.options),"open:product":new Be(this.swish,this.ui,this.eventBus,this.options),"open:list-menu":new Le(this.swish,this.ui,this.eventBus,this.options),"open:order-menu":new qe(this.swish,this.ui,this.eventBus,this.options),"open:list-detail-page-menu":new _e(this.swish,this.ui,this.eventBus,this.options),"open:sign-in":new Ge(this.swish,this.ui,this.eventBus,this.options),"open:quick-buy":new Fe(this.swish,this.ui,this.eventBus,this.options),"show:toast":new ze(this.swish,this.ui,this.eventBus,this.options)},this.initIntentHooks(),this.initIntentWatcher()}publishAnalyticsEvent(e,t){typeof window.Shopify?.analytics?.publish=="function"&&window.Shopify.analytics.publish(e,t)}async invoke(e,...t){let r=t[0],s={lifecycle:"before",intent:e,data:r};return this.publishAnalyticsEvent("swish-intent",s),this.publishAnalyticsEvent(`swish-intent=${e}`,s),{intent:e,data:r,complete:this.handleIntent(e,r).then(o=>{let a={lifecycle:"after",intent:e,data:r,response:o};return this.publishAnalyticsEvent("swish-intent",a),this.publishAnalyticsEvent(`swish-intent=${e}`,a),this.eventBus.dispatchEvent(new CustomEvent(e,{detail:o})),o})}}listen(e,t){let r=i(o=>{"detail"in o&&o.detail?t(o.detail):console.warn("Intent response event without detail",o)},"eventListener"),s=i(()=>{this.eventBus.removeEventListener(e,r)},"unsubscribe");return this.eventBus.addEventListener(e,r),s}parseIntentFromString(e){if(typeof e=="string"){let[t,...r]=e.split(","),s=r.reduce((o,a)=>{let[u,c]=a.split("=");return o[u]=c,o},{});return{intent:t,data:s}}return{intent:e,data:{}}}parseIntentFromHash(e){let t=e.startsWith("#")?e.slice(1):e;return{swish:"open:home","swish-home":"open:home","swish-lists":"open:lists","swish-orders":"open:orders","swish-saves":"open:saves","swish-notifications":"open:notifications","swish-profile":"open:profile"}[t]||null}async handleIntent(e,t){let r=this.handlers[e];return r?r.invoke(t):{intent:e,code:"error",message:"Invalid intent",issues:[`Intent ${e} not found`]}}initIntentHooks(){this.eventBus.addEventListener("save:item",e=>{new Je(this.swish,this.ui,this.options).invoke(e.detail)}),this.eventBus.addEventListener("edit:item-lists",e=>{new Ke(this.swish,this.ui,this.options).invoke(e.detail)}),this.eventBus.addEventListener("open:home",e=>{new Ye(this.swish,this.ui,this.options).invoke(e.detail)}),this.eventBus.addEventListener("edit:list-access",e=>{new Xe(this.swish,this.ui,this.options).invoke(e.detail)}),this.eventBus.addEventListener("share:list",e=>{new Ze(this.swish,this.ui,this.options).invoke(e.detail)})}initIntentWatcher(){ie({selector:"[swish-intent]",onElementFound:i(e=>{let t=e.getAttribute("swish-intent");t&&e.addEventListener("click",()=>{let{intent:r,data:s}=this.parseIntentFromString(t);Object.keys(s).length>0?this.invoke(r,s):this.invoke(r)})},"onElementFound")}),ie({selector:"a[href*='swish-intent='],a[href*='#swish']",onElementFound:i(e=>{e instanceof HTMLAnchorElement&&e.addEventListener("click",t=>{if(!t.metaKey&&!t.ctrlKey&&!t.shiftKey&&!t.altKey){let r=new URL(e.href),s=r.hash,o=r.searchParams.get("swish-intent");if(o){let{intent:a,data:u}=this.parseIntentFromString(o);a&&(t.preventDefault(),t.stopPropagation(),Object.keys(u).length>0?this.invoke(a,u):this.invoke(a))}else if(s){let a=this.parseIntentFromHash(s);a&&(t.preventDefault(),t.stopPropagation(),this.invoke(a))}}})},"onElementFound")}),le({fireOnInit:!0,onLocationChange:i(e=>{let t=new URL(e.href),r=t.hash,s=t.searchParams.get("swish-intent");if(s){let{intent:o,data:a}=this.parseIntentFromString(s);o&&(Object.keys(a).length>0?this.invoke(o,a):this.invoke(o))}else if(r){let o=this.parseIntentFromHash(r);o&&this.invoke(o)}},"onLocationChange")})}};var bn=i(n=>({swishApi:{authProxy:n.swishApi?.authProxy??"/apps/wishlist/api",version:n.swishApi?.version??"2026-01"},storefrontApi:{storeDomain:n.storefrontApi?.storeDomain??"",accessToken:n.storefrontApi?.accessToken??""},storefrontContext:{...n.storefrontContext,routes:{...n.storefrontContext.routes,rootUrl:n.storefrontContext.routes?.rootUrl??"/",listDetailPagePath:n.storefrontContext.routes?.listDetailPagePath??"/apps/wishlist"},localization:{country:n.storefrontContext.localization.country.toUpperCase(),language:n.storefrontContext.localization.language.toUpperCase(),market:n.storefrontContext.localization.market}},badges:{getBadges:n.badges?.getBadges??(({defaultBadges:e})=>e)},productOptions:{sortValues:n.productOptions?.sortValues??(({optionValues:e})=>e)},metafields:{product:n.metafields?.product??[],productVariant:n.metafields?.productVariant??[]},features:{accounts:n?.features?.accounts??!0,lists:n?.features?.lists??!0,orders:n?.features?.orders??!0,notifications:n?.features?.notifications??!0},intents:{saveProduct:{promptVariantIfMissing:n?.intents?.saveProduct?.promptVariantIfMissing??!0,promptVariantIfPresent:n?.intents?.saveProduct?.promptVariantIfPresent??!0,showFeedback:n?.intents?.saveProduct?.showFeedback??!0},unsaveProduct:{selectList:n?.intents?.unsaveProduct?.selectList??!0,confirm:n?.intents?.unsaveProduct?.confirm??!0,showFeedback:n?.intents?.unsaveProduct?.showFeedback??!0},editSavedProduct:{promptVariantChange:n?.intents?.editSavedProduct?.promptVariantChange??!0,showFeedback:n?.intents?.editSavedProduct?.showFeedback??!0}},swishUi:{baseUrl:n.swishUi?.baseUrl??"https://swish.app/cdn",version:n.swishUi?.version??tt,components:{productRow:{showVariantTitle:n.swishUi?.components?.productRow?.showVariantTitle??!1},productDetail:{descriptionMaxLines:n.swishUi?.components?.productDetail?.descriptionMaxLines??4},variantSelect:{displayType:n.swishUi?.components?.variantSelect?.displayType??"pills"},icons:n.swishUi?.components?.icons??{},imageSlider:{flush:n.swishUi?.components?.imageSlider?.flush??!1,loop:n.swishUi?.components?.imageSlider?.loop??!1},images:{baseTint:n.swishUi?.components?.images?.baseTint??!1},buyButtons:{shopPay:n.swishUi?.components?.buyButtons?.shopPay??!1},listDetailPage:{desktopColumns:n.swishUi?.components?.listDetailPage?.desktopColumns??4,showBuyButton:n.swishUi?.components?.listDetailPage?.showBuyButton??!0,showVariantOptionNames:n.swishUi?.components?.listDetailPage?.showVariantOptionNames??!1,enableVariantChange:n.swishUi?.components?.listDetailPage?.enableVariantChange??!0},drawer:{title:n.swishUi?.components?.drawer?.title??"",logo:{url:n.swishUi?.components?.drawer?.logo?.url??"",altText:n.swishUi?.components?.drawer?.logo?.altText??""},navigation:{enabled:n.swishUi?.components?.drawer?.navigation?.enabled??!0,variant:n.swishUi?.components?.drawer?.navigation?.variant??"floating",items:n.swishUi?.components?.drawer?.navigation?.items??[]},emptyCallout:{enabled:n.swishUi?.components?.drawer?.emptyCallout?.enabled??!1,shoppingCalloutUrl:n.swishUi?.components?.drawer?.emptyCallout?.shoppingCalloutUrl??"/collections/all"},miniMenu:{enabled:n.swishUi?.components?.drawer?.miniMenu?.enabled??!0,items:n.swishUi?.components?.drawer?.miniMenu?.items??[]},listDetailView:{enableVariantChange:n.swishUi?.components?.drawer?.listDetailView?.enableVariantChange??!1,showVariantOptionNames:n.swishUi?.components?.drawer?.listDetailView?.showVariantOptionNames??!1}}},css:n.swishUi?.css??[],design:n.swishUi?.design??{}}}),"createSwishOptions");var $s=Symbol.for("preact-signals");function rt(){if(ne>1)ne--;else{for(var n,e=!1;ye!==void 0;){var t=ye;for(ye=void 0,Et++;t!==void 0;){var r=t.o;if(t.o=void 0,t.f&=-3,!(8&t.f)&&xn(t))try{t.c()}catch(s){e||(n=s,e=!0)}t=r}}if(Et=0,ne--,e)throw n}}i(rt,"t");function re(n){if(ne>0)return n();ne++;try{return n()}finally{rt()}}i(re,"r");var C=void 0;function Sn(n){var e=C;C=void 0;try{return n()}finally{C=e}}i(Sn,"n");var ye=void 0,ne=0,Et=0,nt=0;function En(n){if(C!==void 0){var e=n.n;if(e===void 0||e.t!==C)return e={i:0,S:n,p:C.s,n:void 0,t:C,e:void 0,x:void 0,r:e},C.s!==void 0&&(C.s.n=e),C.s=e,n.n=e,32&C.f&&n.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=C.s,e.n=void 0,C.s.n=e,C.s=e),e}}i(En,"e");function B(n,e){this.v=n,this.i=0,this.n=void 0,this.t=void 0,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}i(B,"u");B.prototype.brand=$s;B.prototype.h=function(){return!0};B.prototype.S=function(n){var e=this,t=this.t;t!==n&&n.e===void 0&&(n.x=t,this.t=n,t!==void 0?t.e=n:Sn(function(){var r;(r=e.W)==null||r.call(e)}))};B.prototype.U=function(n){var e=this;if(this.t!==void 0){var t=n.e,r=n.x;t!==void 0&&(t.x=r,n.e=void 0),r!==void 0&&(r.e=t,n.x=void 0),n===this.t&&(this.t=r,r===void 0&&Sn(function(){var s;(s=e.Z)==null||s.call(e)}))}};B.prototype.subscribe=function(n){var e=this;return Q(function(){var t=e.value,r=C;C=void 0;try{n(t)}finally{C=r}},{name:"sub"})};B.prototype.valueOf=function(){return this.value};B.prototype.toString=function(){return this.value+""};B.prototype.toJSON=function(){return this.value};B.prototype.peek=function(){var n=C;C=void 0;try{return this.value}finally{C=n}};Object.defineProperty(B.prototype,"value",{get:i(function(){var n=En(this);return n!==void 0&&(n.i=this.i),this.v},"get"),set:i(function(n){if(n!==this.v){if(Et>100)throw new Error("Cycle detected");this.v=n,this.i++,nt++,ne++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{rt()}}},"set")});function $(n,e){return new B(n,e)}i($,"d");function xn(n){for(var e=n.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}i(xn,"c");function Cn(n){for(var e=n.s;e!==void 0;e=e.n){var t=e.S.n;if(t!==void 0&&(e.r=t),e.S.n=e,e.i=-1,e.n===void 0){n.s=e;break}}}i(Cn,"a");function kn(n){for(var e=n.s,t=void 0;e!==void 0;){var r=e.p;e.i===-1?(e.S.U(e),r!==void 0&&(r.n=e.n),e.n!==void 0&&(e.n.p=r)):t=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=r}n.s=t}i(kn,"l");function oe(n,e){B.call(this,void 0),this.x=n,this.s=void 0,this.g=nt-1,this.f=4,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}i(oe,"y");oe.prototype=new B;oe.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===nt))return!0;if(this.g=nt,this.f|=1,this.i>0&&!xn(this))return this.f&=-2,!0;var n=C;try{Cn(this),C=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return C=n,kn(this),this.f&=-2,!0};oe.prototype.S=function(n){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}B.prototype.S.call(this,n)};oe.prototype.U=function(n){if(this.t!==void 0&&(B.prototype.U.call(this,n),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}};oe.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var n=this.t;n!==void 0;n=n.x)n.t.N()}};Object.defineProperty(oe.prototype,"value",{get:i(function(){if(1&this.f)throw new Error("Cycle detected");var n=En(this);if(this.h(),n!==void 0&&(n.i=this.i),16&this.f)throw this.v;return this.v},"get")});function F(n,e){return new oe(n,e)}i(F,"w");function Rn(n){var e=n.u;if(n.u=void 0,typeof e=="function"){ne++;var t=C;C=void 0;try{e()}catch(r){throw n.f&=-2,n.f|=8,xt(n),r}finally{C=t,rt()}}}i(Rn,"_");function xt(n){for(var e=n.s;e!==void 0;e=e.n)e.S.U(e);n.x=void 0,n.s=void 0,Rn(n)}i(xt,"b");function Vs(n){if(C!==this)throw new Error("Out-of-order effect");kn(this),C=n,this.f&=-2,8&this.f&&xt(this),rt()}i(Vs,"g");function pe(n,e){this.x=n,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=e?.name}i(pe,"p");pe.prototype.c=function(){var n=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.u=e)}finally{n()}};pe.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Rn(this),Cn(this),ne++;var n=C;return C=this,Vs.bind(this,n)};pe.prototype.N=function(){2&this.f||(this.f|=2,this.o=ye,ye=this)};pe.prototype.d=function(){this.f|=8,1&this.f||xt(this)};pe.prototype.dispose=function(){this.d()};function Q(n,e){var t=new pe(n,e);try{t.c()}catch(s){throw t.d(),s}var r=t.d.bind(t);return r[Symbol.dispose]=r,r}i(Q,"E");var Ms=/\/products\/([^/?#]+)(?:\?(?:[^#]*?&)?variant=(\d+))?/,Ct=i(n=>{let e=n.match(Ms);return e?{productHandle:e[1],variantId:e[2]}:null},"parseProductUrl"),An=i(({source:n,onProductUrlChange:e})=>{let t=i(r=>{let s=Ct(r);s?.productHandle&&e(s)},"handleChange");if(n instanceof HTMLAnchorElement)return ln({element:n,onHrefChange:i(r=>t(r),"onHrefChange")});if(n instanceof Location)return le({onLocationChange:i(r=>t(r.href),"onLocationChange")});throw new Error("Invalid source for observing product url")},"observeProductUrl");var Dn=i(n=>e=>{let{productHandle:t,productId:r,variantId:s,itemId:o}=e?.dataset??{},c=!!(r||t)||!!o,l=$({loading:!1,productId:r,variantId:s,itemId:o});if(!c){let p=e instanceof HTMLAnchorElement?e:window.location,f=Ct(p.href);f?.productHandle&&f.productHandle!==l.value.productHandle&&(l.value={...l.value,...f,productId:void 0},An({source:p,onProductUrlChange:i(y=>{l.value={...l.value,...y,productId:y.productHandle!==l.value.productHandle?void 0:l.value.productId}},"onProductUrlChange")}))}return Q(()=>{l.value.loading||!l.value.productId&&l.value.productHandle&&(l.value={...l.value,loading:!0},n.storefront.loadProductId({productHandle:l.value.productHandle}).then(p=>{p.errors&&console.error("Error loading product id",p.errors),l.value={...l.value,productId:p.data?.product?.id?A(p.data.product.id):void 0,loading:!1}}))}),l},"itemContextSignal");var Pn=i(n=>e=>{let t=F(()=>{let{productId:T,variantId:I,loading:V}=e.value;return!T||V?null:I?`variant:${A(I)}`:`product:${A(T)}`}),r=F(()=>e.value.loading||!!e.value.itemId||!e.value.productId),s=F(()=>({limit:1,query:t.value??void 0})),o=$(!r.value),a=$(null),u=$(!1),c=$(!1),{data:l,loading:p,error:f,refetching:y}=n.state.swishQuery(T=>n.api.items.list(T),{refetch:["item-create","item-update","item-delete"],variables:s,skip:r}),h=$(e.value.itemId??null);Q(()=>{re(()=>{if(o.value=p.value,a.value=f.value,!e.value.itemId){let T=l.value?.[0]?.id??null;T!==h.value&&(h.value=T)}})});async function b(){if(!h.value)return;u.value=!0;let I=await(await n.intents.invoke("unsave:item",{itemId:h.value})).complete;I.code==="ok"&&"itemId"in I.data&&(h.value=null),u.value=!1}i(b,"unsave");async function g(){if(!h.value)return;u.value=!0;let I=await(await n.intents.invoke("edit:item-lists",{itemId:h.value})).complete;I.code==="ok"&&"itemId"in I.data&&(h.value=null),u.value=!1}i(g,"update");async function O(){let{productId:T,variantId:I}=e.value;if(!T)return;u.value=!0,c.value=!0;let k=await(await n.intents.invoke("save:item",{productId:T,variantId:I})).complete;if(k.code==="ok"){let ee=k.data;h.value=ee.item.id,u.value=!1}else k.code==="error"&&console.warn("Failed to create item",k),re(()=>{u.value=!1,c.value=!1})}i(O,"save");let N=F(()=>o.value||u.value||e.value.loading);Q(()=>{c.value&&!u.value&&!y.value&&(c.value=!1)});let L=F(()=>{let T=y.value&&c.value,I=!!h.value,V=!I&&(u.value||T),k=I&&(u.value||T),ee=F(()=>V?"saving":k?"unsaving":I?"saved":"unsaved");return{error:a.value,status:ee.value,savedItemId:h.value,loading:N.value,submitting:u.value,saved:I,saving:V,unsaving:k}});async function G(){N.value||(L.value.saved&&L.value.savedItemId?b():L.value.saved||await O())}return i(G,"toggle"),Object.assign(L,{save:O,unsave:b,update:g,toggle:G})},"itemStateSignal");var Tn=i(n=>()=>{let{data:e,loading:t,error:r}=n.state.swishQuery(()=>n.api.items.count(),{refetch:["item-create","item-delete"]}),s=$(0),o=$(!0),a=$(null);return Q(()=>{re(()=>{o.value=t.value,a.value=r.value,s.value=e.value?.count??0})}),F(()=>({count:s.value,loading:o.value,error:a.value}))},"itemCountSignal");var qs="token-update",_n=i(n=>(e,t)=>{let r=$(null),s=$(null),o=$(null),a=$(!t?.skip),u=$(!1),c=F(()=>a.value&&u.value);async function l(){if(!t?.skip?.value)try{a.value=!0;let p=await e(t?.variables?.value);re(()=>{o.value="error"in p?p.error:null,r.value="data"in p?p.data:null,s.value="pageInfo"in p?p.pageInfo:null,a.value=!1,u.value=!0})}catch(p){re(()=>{o.value=p,a.value=!1,u.value=!0})}}return i(l,"executeFetch"),Q(()=>{if(l(),t?.refetch?.length){let p=[...t.refetch,qs];return n.events.subscribe(p,l)}}),{data:r,pageInfo:s,error:o,loading:a,refetching:c}},"swishQuerySignals");var ae="GraphQL Client";var kt="An error occurred while fetching from the API. Review 'graphQLErrors' for details.",Rt="Response returned unexpected Content-Type:",At="An unknown error has occurred. The API did not return a data object or any errors in its response.",st={json:"application/json",multipart:"multipart/mixed"},Dt="X-SDK-Variant",Pt="X-SDK-Version",Ln="shopify-graphql-client",$n="1.4.1",it=1e3,Vn=[429,503],Tt=/@(defer)\b/i,On=`\r
8
+ `,Mn=/boundary="?([^=";]+)"?/i,_t=On+On;function X(n,e=ae){return n.startsWith(`${e}`)?n:`${e}: ${n}`}i(X,"formatErrorMessage");function Z(n){return n instanceof Error?n.message:JSON.stringify(n)}i(Z,"getErrorMessage");function Ot(n){return n instanceof Error&&n.cause?n.cause:void 0}i(Ot,"getErrorCause");function Lt(n){return n.flatMap(({errors:e})=>e??[])}i(Lt,"combineErrors");function ot({client:n,retries:e}){if(e!==void 0&&(typeof e!="number"||e<0||e>3))throw new Error(`${n}: The provided "retries" value (${e}) is invalid - it cannot be less than ${0} or greater than ${3}`)}i(ot,"validateRetries");function U(n,e){return e&&(typeof e!="object"||Array.isArray(e)||typeof e=="object"&&Object.keys(e).length>0)?{[n]:e}:{}}i(U,"getKeyValueIfValid");function $t(n,e){if(n.length===0)return e;let r={[n.pop()]:e};return n.length===0?r:$t(n,r)}i($t,"buildDataObjectByPath");function Bn(n,e){return Object.keys(e||{}).reduce((t,r)=>(typeof e[r]=="object"||Array.isArray(e[r]))&&n[r]?(t[r]=Bn(n[r],e[r]),t):(t[r]=e[r],t),Array.isArray(n)?[...n]:{...n})}i(Bn,"combineObjects");function Vt([n,...e]){return e.reduce(Bn,{...n})}i(Vt,"buildCombinedDataObject");function Mt({clientLogger:n,customFetchApi:e=fetch,client:t=ae,defaultRetryWaitTime:r=it,retriableCodes:s=Vn}){let o=i(async(a,u,c)=>{let l=u+1,p=c+1,f;try{if(f=await e(...a),n({type:"HTTP-Response",content:{requestParams:a,response:f}}),!f.ok&&s.includes(f.status)&&l<=p)throw new Error;let y=f?.headers.get("X-Shopify-API-Deprecated-Reason")||"";return y&&n({type:"HTTP-Response-GraphQL-Deprecation-Notice",content:{requestParams:a,deprecationNotice:y}}),f}catch(y){if(l<=p){let h=f?.headers.get("Retry-After");return await Ns(h?parseInt(h,10):r),n({type:"HTTP-Retry",content:{requestParams:a,lastResponse:f,retryAttempt:u,maxRetries:c}}),o(a,l,c)}throw new Error(X(`${c>0?`Attempted maximum number of ${c} network retries. Last message - `:""}${Z(y)}`,t))}},"httpFetch");return o}i(Mt,"generateHttpFetch");async function Ns(n){return new Promise(e=>setTimeout(e,n))}i(Ns,"sleep");function qt({headers:n,url:e,customFetchApi:t=fetch,retries:r=0,logger:s}){ot({client:ae,retries:r});let o={headers:n,url:e,retries:r},a=Bs(s),u=Mt({customFetchApi:t,clientLogger:a,defaultRetryWaitTime:it}),c=Us(u,o),l=Fs(c),p=Ks(c);return{config:o,fetch:c,request:l,requestStream:p}}i(qt,"createGraphQLClient");function Bs(n){return e=>{n&&n(e)}}i(Bs,"generateClientLogger");async function Un(n){let{errors:e,data:t,extensions:r}=await n.json();return{...U("data",t),...U("extensions",r),headers:n.headers,...e||!t?{errors:{networkStatusCode:n.status,message:X(e?kt:At),...U("graphQLErrors",e),response:n}}:{}}}i(Un,"processJSONResponse");function Us(n,{url:e,headers:t,retries:r}){return async(s,o={})=>{let{variables:a,headers:u,url:c,retries:l,keepalive:p,signal:f}=o,y=JSON.stringify({query:s,variables:a});ot({client:ae,retries:l});let h=Object.entries({...t,...u}).reduce((g,[O,N])=>(g[O]=Array.isArray(N)?N.join(", "):N.toString(),g),{});return!h[Dt]&&!h[Pt]&&(h[Dt]=Ln,h[Pt]=$n),n([c??e,{method:"POST",headers:h,body:y,signal:f,keepalive:p}],1,l??r)}}i(Us,"generateFetch");function Fs(n){return async(...e)=>{if(Tt.test(e[0]))throw new Error(X("This operation will result in a streamable response - use requestStream() instead."));let t=null;try{t=await n(...e);let{status:r,statusText:s}=t,o=t.headers.get("content-type")||"";return t.ok?o.includes(st.json)?await Un(t):{errors:{networkStatusCode:r,message:X(`${Rt} ${o}`),response:t}}:{errors:{networkStatusCode:r,message:X(s),response:t}}}catch(r){return{errors:{message:Z(r),...t==null?{}:{networkStatusCode:t.status,response:t}}}}}}i(Fs,"generateRequest");async function*js(n){let e=new TextDecoder;if(n.body[Symbol.asyncIterator])for await(let t of n.body)yield e.decode(t);else{let t=n.body.getReader(),r;try{for(;!(r=await t.read()).done;)yield e.decode(r.value)}finally{t.cancel()}}}i(js,"getStreamBodyIterator");function Gs(n,e){return{async*[Symbol.asyncIterator](){try{let t="";for await(let r of n)if(t+=r,t.indexOf(e)>-1){let s=t.lastIndexOf(e),a=t.slice(0,s).split(e).filter(u=>u.trim().length>0).map(u=>u.slice(u.indexOf(_t)+_t.length).trim());a.length>0&&(yield a),t=t.slice(s+e.length),t.trim()==="--"&&(t="")}}catch(t){throw new Error(`Error occured while processing stream payload - ${Z(t)}`)}}}}i(Gs,"readStreamChunk");function Hs(n){return{async*[Symbol.asyncIterator](){yield{...await Un(n),hasNext:!1}}}}i(Hs,"createJsonResponseAsyncIterator");function Qs(n){return n.map(e=>{try{return JSON.parse(e)}catch(t){throw new Error(`Error in parsing multipart response - ${Z(t)}`)}}).map(e=>{let{data:t,incremental:r,hasNext:s,extensions:o,errors:a}=e;if(!r)return{data:t||{},...U("errors",a),...U("extensions",o),hasNext:s};let u=r.map(({data:c,path:l,errors:p})=>({data:c&&l?$t(l,c):{},...U("errors",p)}));return{data:u.length===1?u[0].data:Vt([...u.map(({data:c})=>c)]),...U("errors",Lt(u)),hasNext:s}})}i(Qs,"getResponseDataFromChunkBodies");function zs(n,e){if(n.length>0)throw new Error(kt,{cause:{graphQLErrors:n}});if(Object.keys(e).length===0)throw new Error(At)}i(zs,"validateResponseData");function Ws(n,e){let t=(e??"").match(Mn),r=`--${t?t[1]:"-"}`;if(!n.body?.getReader&&!n.body?.[Symbol.asyncIterator])throw new Error("API multipart response did not return an iterable body",{cause:n});let s=js(n),o={},a;return{async*[Symbol.asyncIterator](){try{let u=!0;for await(let c of Gs(s,r)){let l=Qs(c);a=l.find(f=>f.extensions)?.extensions??a;let p=Lt(l);o=Vt([o,...l.map(({data:f})=>f)]),u=l.slice(-1)[0].hasNext,zs(p,o),yield{...U("data",o),...U("extensions",a),hasNext:u}}if(u)throw new Error("Response stream terminated unexpectedly")}catch(u){let c=Ot(u);yield{...U("data",o),...U("extensions",a),errors:{message:X(Z(u)),networkStatusCode:n.status,...U("graphQLErrors",c?.graphQLErrors),response:n},hasNext:!1}}}}}i(Ws,"createMultipartResponseAsyncInterator");function Ks(n){return async(...e)=>{if(!Tt.test(e[0]))throw new Error(X("This operation does not result in a streamable response - use request() instead."));try{let t=await n(...e),{statusText:r}=t;if(!t.ok)throw new Error(r,{cause:t});let s=t.headers.get("content-type")||"";switch(!0){case s.includes(st.json):return Hs(t);case s.includes(st.multipart):return Ws(t,s);default:throw new Error(`${Rt} ${s}`,{cause:t})}}catch(t){return{async*[Symbol.asyncIterator](){let r=Ot(t);yield{errors:{message:X(Z(t)),...U("networkStatusCode",r?.status),...U("response",r)},hasNext:!1}}}}}}i(Ks,"generateRequestStream");function Nt({client:n,storeDomain:e}){try{if(!e||typeof e!="string")throw new Error;let t=e.trim(),r=t.match(/^https?:/)?t:`https://${t}`,s=new URL(r);return s.protocol="https",s.origin}catch(t){throw new Error(`${n}: a valid store domain ("${e}") must be provided`,{cause:t})}}i(Nt,"validateDomainAndGetStoreUrl");function at({client:n,currentSupportedApiVersions:e,apiVersion:t,logger:r}){let s=`${n}: the provided apiVersion ("${t}")`,o=`Currently supported API versions: ${e.join(", ")}`;if(!t||typeof t!="string")throw new Error(`${s} is invalid. ${o}`);let a=t.trim();e.includes(a)||(r?r({type:"Unsupported_Api_Version",content:{apiVersion:t,supportedApiVersions:e}}):console.warn(`${s} is likely deprecated or not supported. ${o}`))}i(at,"validateApiVersion");function ut(n){let e=n*3-2;return e===10?e:`0${e}`}i(ut,"getQuarterMonth");function Bt(n,e,t){let r=e-t;return r<=0?`${n-1}-${ut(r+4)}`:`${n}-${ut(r)}`}i(Bt,"getPrevousVersion");function Fn(){let n=new Date,e=n.getUTCMonth(),t=n.getUTCFullYear(),r=Math.floor(e/3+1);return{year:t,quarter:r,version:`${t}-${ut(r)}`}}i(Fn,"getCurrentApiVersion");function Ut(){let{year:n,quarter:e,version:t}=Fn(),r=e===4?`${n+1}-01`:`${n}-${ut(e+1)}`;return[Bt(n,e,3),Bt(n,e,2),Bt(n,e,1),t,r,"unstable"]}i(Ut,"getCurrentSupportedApiVersions");function Ft(n){return e=>({...e??{},...n.headers})}i(Ft,"generateGetHeaders");function jt({getHeaders:n,getApiUrl:e}){return(t,r)=>{let s=[t];if(r&&Object.keys(r).length>0){let{variables:o,apiVersion:a,headers:u,retries:c,signal:l}=r;s.push({...o?{variables:o}:{},...u?{headers:n(u)}:{},...a?{url:e(a)}:{},...c?{retries:c}:{},...l?{signal:l}:{}})}return s}}i(jt,"generateGetGQLClientParams");var Gt="application/json",jn="storefront-api-client",Gn="1.0.9",Hn="X-Shopify-Storefront-Access-Token",Qn="Shopify-Storefront-Private-Token",zn="X-SDK-Variant",Wn="X-SDK-Version",Kn="X-SDK-Variant-Source",ue="Storefront API Client";function Xn(n){if(n&&typeof window<"u")throw new Error(`${ue}: private access tokens and headers should only be used in a server-to-server implementation. Use the public API access token in nonserver environments.`)}i(Xn,"validatePrivateAccessTokenUsage");function Yn(n,e){if(!n&&!e)throw new Error(`${ue}: a public or private access token must be provided`);if(n&&e)throw new Error(`${ue}: only provide either a public or private access token`)}i(Yn,"validateRequiredAccessTokens");function Ht({storeDomain:n,apiVersion:e,publicAccessToken:t,privateAccessToken:r,clientName:s,retries:o=0,customFetchApi:a,logger:u}){let c=Ut(),l=Nt({client:ue,storeDomain:n}),p={client:ue,currentSupportedApiVersions:c,logger:u};at({...p,apiVersion:e}),Yn(t,r),Xn(r);let f=Xs(l,e,p),y={storeDomain:l,apiVersion:e,...t?{publicAccessToken:t}:{privateAccessToken:r},headers:{"Content-Type":Gt,Accept:Gt,[zn]:jn,[Wn]:Gn,...s?{[Kn]:s}:{},...t?{[Hn]:t}:{[Qn]:r}},apiUrl:f(),clientName:s},h=qt({headers:y.headers,url:y.apiUrl,retries:o,customFetchApi:a,logger:u}),b=Ft(y),g=Ys(y,f),O=jt({getHeaders:b,getApiUrl:g});return Object.freeze({config:y,getHeaders:b,getApiUrl:g,fetch:i((...L)=>h.fetch(...O(...L)),"fetch"),request:i((...L)=>h.request(...O(...L)),"request"),requestStream:i((...L)=>h.requestStream(...O(...L)),"requestStream")})}i(Ht,"createStorefrontApiClient");function Xs(n,e,t){return r=>{r&&at({...t,apiVersion:r});let s=(r??e).trim();return`${n}/api/${s}/graphql.json`}}i(Xs,"generateApiUrlFormatter");function Ys(n,e){return t=>t?e(t):n.apiUrl}i(Ys,"generateGetApiUrl");var j=`
9
9
  fragment productImageFields on Image {
10
10
  id
11
11
  altText
12
12
  url
13
13
  thumbhash
14
14
  }
15
- `,Lt=`
15
+ `,Qt=`
16
16
  fragment saveIntentProductFields on Product {
17
17
  id
18
18
  availableForSale
@@ -37,7 +37,7 @@ Values:
37
37
  }
38
38
  title
39
39
  }
40
- `,de=`
40
+ `,ve=`
41
41
  fragment productCardDataFields on Product {
42
42
  id
43
43
  availableForSale
@@ -90,7 +90,7 @@ Values:
90
90
  value
91
91
  }
92
92
  }
93
- `,qt=`
93
+ `,zt=`
94
94
  fragment productVariantDataFields on ProductVariant {
95
95
  id
96
96
  availableForSale
@@ -119,7 +119,7 @@ Values:
119
119
  value
120
120
  }
121
121
  }
122
- `,$t=`
122
+ `,Wt=`
123
123
  fragment productOptionsVariantFields on ProductVariant {
124
124
  id
125
125
  selectedOptions {
@@ -127,7 +127,7 @@ Values:
127
127
  value
128
128
  }
129
129
  }
130
- `,Vt=`
130
+ `,Kt=`
131
131
  fragment selectedVariantFields on Product {
132
132
  id
133
133
  availableForSale
@@ -158,7 +158,7 @@ Values:
158
158
  }
159
159
  }
160
160
  }
161
- `,oe=`
161
+ `,ce=`
162
162
  fragment productOptionsFields on Product {
163
163
  id
164
164
  availableForSale
@@ -194,7 +194,7 @@ Values:
194
194
  }
195
195
  }
196
196
  }
197
- `,Bt=`
197
+ `,Xt=`
198
198
  fragment productImagesFields on Product {
199
199
  images(first: 20) {
200
200
  nodes {
@@ -202,7 +202,7 @@ Values:
202
202
  }
203
203
  }
204
204
  }
205
- `;var On=`
205
+ `;var Jn=`
206
206
  query GetSaveIntentData(
207
207
  $productId: ID!
208
208
  $country: CountryCode!
@@ -212,9 +212,9 @@ Values:
212
212
  ...saveIntentProductFields
213
213
  }
214
214
  }
215
- ${Lt}
216
- ${F}
217
- `,Ln=`
215
+ ${Qt}
216
+ ${j}
217
+ `,Zn=`
218
218
  query GetSaveIntentDataWithVariant(
219
219
  $productId: ID!
220
220
  $variantId: ID!
@@ -228,9 +228,9 @@ Values:
228
228
  ...saveIntentVariantFields
229
229
  }
230
230
  }
231
- ${Lt}
232
- ${F}
233
- `,qn=`
231
+ ${Qt}
232
+ ${j}
233
+ `,er=`
234
234
  query GetProductCardData(
235
235
  $productId: ID!
236
236
  $productMetafields: [HasMetafieldsIdentifier!]!
@@ -241,9 +241,9 @@ Values:
241
241
  ...productCardDataFields
242
242
  }
243
243
  }
244
- ${de}
245
- ${F}
246
- `,$n=`
244
+ ${ve}
245
+ ${j}
246
+ `,tr=`
247
247
  query GetProductCardDataWithVariant(
248
248
  $productId: ID!
249
249
  $variantId: ID!
@@ -259,10 +259,10 @@ Values:
259
259
  ...productVariantDataFields
260
260
  }
261
261
  }
262
- ${de}
263
- ${qt}
264
- ${F}
265
- `,Vn=`
262
+ ${ve}
263
+ ${zt}
264
+ ${j}
265
+ `,nr=`
266
266
  query GetProductOptions(
267
267
  $productId: ID!
268
268
  $country: CountryCode!
@@ -272,9 +272,9 @@ Values:
272
272
  ...productOptionsFields
273
273
  }
274
274
  }
275
- ${oe}
276
- ${F}
277
- `,Bn=`
275
+ ${ce}
276
+ ${j}
277
+ `,rr=`
278
278
  query GetProductOptionsByHandle(
279
279
  $handle: String!
280
280
  $country: CountryCode!
@@ -284,9 +284,9 @@ Values:
284
284
  ...productOptionsFields
285
285
  }
286
286
  }
287
- ${oe}
288
- ${F}
289
- `,Nn=`
287
+ ${ce}
288
+ ${j}
289
+ `,sr=`
290
290
  query GetProductOptionsWithVariant(
291
291
  $productId: ID!
292
292
  $variantId: ID!
@@ -300,10 +300,10 @@ Values:
300
300
  ...productOptionsVariantFields
301
301
  }
302
302
  }
303
- ${oe}
304
- ${$t}
305
- ${F}
306
- `,Un=`
303
+ ${ce}
304
+ ${Wt}
305
+ ${j}
306
+ `,ir=`
307
307
  query GetProductOptionsByHandleWithVariant(
308
308
  $handle: String!
309
309
  $variantId: ID!
@@ -317,10 +317,10 @@ Values:
317
317
  ...productOptionsVariantFields
318
318
  }
319
319
  }
320
- ${oe}
321
- ${$t}
322
- ${F}
323
- `,Mn=`
320
+ ${ce}
321
+ ${Wt}
322
+ ${j}
323
+ `,or=`
324
324
  query GetSelectedVariant(
325
325
  $productId: ID!
326
326
  $selectedOptions: [SelectedOptionInput!]!
@@ -331,9 +331,9 @@ Values:
331
331
  ...selectedVariantFields
332
332
  }
333
333
  }
334
- ${Vt}
335
- ${F}
336
- `,Gn=`
334
+ ${Kt}
335
+ ${j}
336
+ `,ar=`
337
337
  query GetSelectedVariantByHandle(
338
338
  $handle: String!
339
339
  $selectedOptions: [SelectedOptionInput!]!
@@ -344,9 +344,9 @@ Values:
344
344
  ...selectedVariantFields
345
345
  }
346
346
  }
347
- ${Vt}
348
- ${F}
349
- `,Fn=`
347
+ ${Kt}
348
+ ${j}
349
+ `,ur=`
350
350
  query GetProductDetailData(
351
351
  $productId: ID!
352
352
  $productMetafields: [HasMetafieldsIdentifier!]!
@@ -359,11 +359,11 @@ Values:
359
359
  ...productImagesFields
360
360
  }
361
361
  }
362
- ${de}
363
- ${oe}
364
- ${Bt}
365
- ${F}
366
- `,jn=`
362
+ ${ve}
363
+ ${ce}
364
+ ${Xt}
365
+ ${j}
366
+ `,cr=`
367
367
  query GetProductDetailDataWithVariant(
368
368
  $productId: ID!
369
369
  $variantId: ID!
@@ -381,12 +381,12 @@ Values:
381
381
  ...productVariantDataFields
382
382
  }
383
383
  }
384
- ${de}
385
- ${oe}
386
- ${qt}
387
- ${Bt}
388
- ${F}
389
- `,Hn=`
384
+ ${ve}
385
+ ${ce}
386
+ ${zt}
387
+ ${Xt}
388
+ ${j}
389
+ `,lr=`
390
390
  query GetProductImagesById(
391
391
  $ids: [ID!]!
392
392
  $country: CountryCode!
@@ -410,8 +410,8 @@ Values:
410
410
  }
411
411
  }
412
412
  }
413
- ${F}
414
- `,Qn=`
413
+ ${j}
414
+ `,pr=`
415
415
  query GetProductRecommendationsById(
416
416
  $productId: ID!
417
417
  $intent: ProductRecommendationIntent
@@ -422,7 +422,7 @@ Values:
422
422
  id
423
423
  }
424
424
  }
425
- `,Wn=`
425
+ `,dr=`
426
426
  query GetProductRecommendationsByHandle(
427
427
  $handle: String!
428
428
  $intent: ProductRecommendationIntent
@@ -433,17 +433,17 @@ Values:
433
433
  id
434
434
  }
435
435
  }
436
- `,zn=`
436
+ `,fr=`
437
437
  query GetProductIdByHandle($handle: String!) {
438
438
  product(handle: $handle) {
439
439
  id
440
440
  }
441
441
  }
442
- `;var Xn=s(async(n,{productId:e,variantId:t,productMetafields:r=[],variantMetafields:i=[],country:o,language:u})=>{if(!e)throw new Error("A productId must be provided");let a=s(()=>{if(e&&!t)return qn;if(e&&t)return $n},"getProductOptionsQuery"),l=s(()=>{if(e&&!t)return{productId:E("Product",e),productMetafields:r,country:o,language:u};if(e&&t)return{productId:E("Product",e),variantId:E("ProductVariant",t),productMetafields:r,variantMetafields:i,country:o,language:u}},"getVariables"),c=a(),p=l();if(!p||!c)throw new Error("Invalid query arguments");return n.query(c,p)},"loadProductCardData");var Kn=s(async(n,{productId:e,variantId:t,productMetafields:r=[],variantMetafields:i=[],country:o,language:u})=>{if(!e)throw new Error("A productId must be provided");let a=s(()=>{if(e&&!t)return Fn;if(e&&t)return jn},"getProductOptionsQuery"),l=s(()=>{if(e&&!t)return{productId:E("Product",e),productMetafields:r,country:o,language:u};if(e&&t)return{productId:E("Product",e),variantId:E("ProductVariant",t),productMetafields:r,variantMetafields:i,country:o,language:u}},"getVariables"),c=a(),p=l();if(!p||!c)throw new Error("Invalid query arguments");return n.query(c,p)},"loadProductDetailData");var Yn=s(async(n,{productHandle:e})=>{if(!e)throw new Error("A product handle must be provided");return n.query(zn,{handle:e})},"loadProductId");var Jn=s(async(n,{items:e,country:t,language:r})=>{if(!e?.length)throw new Error("A list of items must be provided");let i={ids:e.map(o=>o.variantId?E("ProductVariant",o.variantId.toString()):E("Product",o.productId.toString())),country:t,language:r};try{return{data:(await n.query(Hn,i)).data?.nodes.map(a=>a===null?null:"image"in a?a.image:"featuredImage"in a?a.featuredImage:null).filter(a=>a!==null)??[],error:null}}catch(o){return console.error(o),{data:null,error:o}}},"loadProductImages");var Zn=s(async(n,{productId:e,productHandle:t,variantId:r,country:i,language:o})=>{if(!e&&!t)throw new Error("Either productId or handle must be provided");let u=s(()=>{if(e&&!r)return Vn;if(t&&!r)return Bn;if(e&&r)return Nn;if(t&&r)return Un},"getProductOptionsQuery"),a=s(()=>{if(e&&!r)return{productId:E("Product",e),country:i,language:o};if(t&&!r)return{handle:t,country:i,language:o};if(e&&r)return{productId:E("Product",e),variantId:E("ProductVariant",r),country:i,language:o};if(t&&r)return{handle:t,variantId:E("ProductVariant",r),country:i,language:o}},"getVariables"),l=u(),c=a();if(!c||!l)throw new Error("Invalid query arguments");return n.query(l,c)},"loadProductOptions");var er=s(async(n,{productId:e,productHandle:t,intent:r,country:i,language:o})=>{if(!e&&!t)throw new Error("Either productId or productHandle must be provided");if(e){let a={productId:E("Product",e),intent:r,country:i,language:o};return n.query(Qn,a)}let u={handle:t,intent:r,country:i,language:o};return n.query(Wn,u)},"loadProductRecommendations");var tr=s(async(n,{productId:e,variantId:t,country:r,language:i})=>{let o=s(()=>{if(e&&!t)return On;if(e&&t)return Ln},"getProductOptionsQuery"),u=s(()=>{if(e&&!t)return{productId:E("Product",x(e)),country:r,language:i};if(e&&t)return{productId:E("Product",x(e)),variantId:E("ProductVariant",x(t)),country:r,language:i}},"getVariables"),a=o(),l=u();if(!l||!a)throw new Error("Invalid query arguments");return n.query(a,l)},"loadSaveIntentData");var nr=s(async(n,{productId:e,productHandle:t,selectedOptions:r,country:i,language:o})=>{if(!e&&!t)throw new Error("Either productId or handle must be provided");let u=e?Mn:Gn,a=e?{productId:`gid://shopify/Product/${e}`,selectedOptions:r,country:i,language:o}:{handle:t,selectedOptions:r,country:i,language:o};return n.query(u,a)},"loadSelectedVariant");var fi="2025-10",hi=["GetProductIdByHandle"],Ye=class{constructor(e,t,r,i){this.client=null;this.query=s(async(e,t)=>{if(!this.client)throw new Error("Storefront API client not initialized");let r=await this.client.request(e,{variables:t});return{data:r.data,errors:r.errors??null}},"query");this.loadProductOptions=s(async e=>Zn(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}),"loadProductOptions");this.loadSelectedVariant=s(async e=>nr(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}),"loadSelectedVariant");this.loadProductCardData=s(async e=>Xn(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}).then(t=>t.data?"variant"in t.data?{...t,data:{...t.data,badges:this.badges.getBadges({product:t.data.product,variant:t.data.variant})}}:{...t,data:{...t.data,badges:this.badges.getBadges({product:t.data.product})}}:t),"loadProductCardData");this.loadProductDetailData=s(async e=>Kn(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}).then(t=>t.data?"variant"in t.data?{...t,data:{...t.data,badges:this.badges.getBadges({product:t.data.product,variant:t.data.variant})}}:{...t,data:{...t.data,badges:this.badges.getBadges({product:t.data.product})}}:t),"loadProductDetailData");this.loadProductImages=s(async e=>Jn(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}),"loadProductImages");this.loadProductRecommendations=s(async e=>er(this,{...e,country:this.context.localization.country,language:this.context.localization.language}),"loadProductRecommendations");this.loadProductId=s(async e=>Yn(this,e),"loadProductId");this.loadSaveIntentData=s(async e=>tr(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}),"loadSaveIntentData");this.options=e,this.context=t,this.badges=r,this.metafields={productMetafields:i?.product.map(u=>({namespace:u.split(".")[0],key:u.split(".")[1]}))??[],variantMetafields:i?.productVariant.map(u=>({namespace:u.split(".")[0],key:u.split(".")[1]}))??[]};let o=j(t.myshopifyDomain);this.shortCache=new X(`storefront-api-short-${o}`,"max-age=60, stale-while-revalidate=3600"),this.longCache=new X(`storefront-api-long-${o}`,"max-age=3600, stale-while-revalidate=86400"),this.shortCache.cleanupExpiredEntries().catch(u=>{console.warn("Storefront API cache initialization cleanup error:",u)}),this.longCache.cleanupExpiredEntries().catch(u=>{console.warn("Storefront API cache initialization cleanup error:",u)}),this.client=Ot({apiVersion:fi,customFetchApi:s((u,a)=>a?.method==="OPTIONS"?this.fetch(u,a):hi.some(l=>a?.body?.toString().includes(`query ${l}`))?this.longCache.fetchWithCache(u,a):this.shortCache.fetchWithCache(u,a),"customFetchApi"),publicAccessToken:this.options.accessToken,storeDomain:this.options.storeDomain})}static{s(this,"StorefrontApiClient")}fetch(e,t){return t?.method==="OPTIONS"?fetch(e,t):this.shortCache.fetchWithCache(e,t)}async clearCache(){await this.shortCache.clear()}};var mi=Object.defineProperty,d=s((n,e)=>mi(n,"name",{value:e,configurable:!0}),"n"),yi={bodySerializer:d(n=>JSON.stringify(n,(e,t)=>typeof t=="bigint"?t.toString():t),"bodySerializer")},vi={$body_:"body",$headers_:"headers",$path_:"path",$query_:"query"},lc=Object.entries(vi),gi=d(({onRequest:n,onSseError:e,onSseEvent:t,responseTransformer:r,responseValidator:i,sseDefaultRetryDelay:o,sseMaxRetryAttempts:u,sseMaxRetryDelay:a,sseSleepFn:l,url:c,...p})=>{let h,g=l??(f=>new Promise(P=>setTimeout(P,f)));return{stream:d(async function*(){let f=o??3e3,P=0,v=p.signal??new AbortController().signal;for(;!v.aborted;){P++;let _=p.headers instanceof Headers?p.headers:new Headers(p.headers);h!==void 0&&_.set("Last-Event-ID",h);try{let V={redirect:"follow",...p,body:p.serializedBody,headers:_,signal:v},O=new Request(c,V);n&&(O=await n(c,V));let W=await(p.fetch??globalThis.fetch)(O);if(!W.ok)throw new Error(`SSE failed: ${W.status} ${W.statusText}`);if(!W.body)throw new Error("No body in SSE response");let k=W.body.pipeThrough(new TextDecoderStream).getReader(),I="",q=d(()=>{try{k.cancel()}catch{}},"abortHandler");v.addEventListener("abort",q);try{for(;;){let{done:$,value:le}=await k.read();if($)break;I+=le;let Qt=I.split(`
442
+ `;var hr=i(async(n,{productId:e,variantId:t,productMetafields:r=[],variantMetafields:s=[],country:o,language:a})=>{if(!e)throw new Error("A productId must be provided");let u=i(()=>{if(e&&!t)return er;if(e&&t)return tr},"getProductOptionsQuery"),c=i(()=>{if(e&&!t)return{productId:D("Product",e),productMetafields:r,country:o,language:a};if(e&&t)return{productId:D("Product",e),variantId:D("ProductVariant",t),productMetafields:r,variantMetafields:s,country:o,language:a}},"getVariables"),l=u(),p=c();if(!p||!l)throw new Error("Invalid query arguments");return n.query(l,p)},"loadProductCardData");var mr=i(async(n,{productId:e,variantId:t,productMetafields:r=[],variantMetafields:s=[],country:o,language:a})=>{if(!e)throw new Error("A productId must be provided");let u=i(()=>{if(e&&!t)return ur;if(e&&t)return cr},"getProductDetailDataQuery"),c=i(()=>{if(e&&!t)return{productId:D("Product",e),productMetafields:r,country:o,language:a};if(e&&t)return{productId:D("Product",e),variantId:D("ProductVariant",t),productMetafields:r,variantMetafields:s,country:o,language:a}},"getVariables"),l=u(),p=c();if(!p||!l)throw new Error("Invalid query arguments");return n.query(l,p)},"loadProductDetailData");var yr=i(async(n,{productHandle:e})=>{if(!e)throw new Error("A product handle must be provided");return n.query(fr,{handle:e})},"loadProductId");var vr=i(async(n,{items:e,country:t,language:r})=>{if(!e?.length)throw new Error("A list of items must be provided");let s={ids:e.map(o=>o.variantId?D("ProductVariant",o.variantId.toString()):D("Product",o.productId.toString())),country:t,language:r};try{return{data:(await n.query(lr,s)).data?.nodes.map(u=>u===null?null:"image"in u?u.image:"featuredImage"in u?u.featuredImage:null).filter(u=>u!==null)??[],error:null}}catch(o){return console.error(o),{data:null,error:o}}},"loadProductImages");var gr=i(async(n,{productId:e,productHandle:t,variantId:r,country:s,language:o})=>{if(!e&&!t)throw new Error("Either productId or handle must be provided");let a=i(()=>{if(e&&!r)return nr;if(t&&!r)return rr;if(e&&r)return sr;if(t&&r)return ir},"getProductOptionsQuery"),u=i(()=>{if(e&&!r)return{productId:D("Product",e),country:s,language:o};if(t&&!r)return{handle:t,country:s,language:o};if(e&&r)return{productId:D("Product",e),variantId:D("ProductVariant",r),country:s,language:o};if(t&&r)return{handle:t,variantId:D("ProductVariant",r),country:s,language:o}},"getVariables"),c=a(),l=u();if(!l||!c)throw new Error("Invalid query arguments");return n.query(c,l)},"loadProductOptions");var wr=i(async(n,{productId:e,productHandle:t,intent:r,country:s,language:o})=>{if(!e&&!t)throw new Error("Either productId or productHandle must be provided");if(e){let u={productId:D("Product",e),intent:r,country:s,language:o};return n.query(pr,u)}let a={handle:t,intent:r,country:s,language:o};return n.query(dr,a)},"loadProductRecommendations");var Ir=i(async(n,{productId:e,variantId:t,country:r,language:s})=>{let o=i(()=>{if(e&&!t)return Jn;if(e&&t)return Zn},"getProductOptionsQuery"),a=i(()=>{if(e&&!t)return{productId:D("Product",A(e)),country:r,language:s};if(e&&t)return{productId:D("Product",A(e)),variantId:D("ProductVariant",A(t)),country:r,language:s}},"getVariables"),u=o(),c=a();if(!c||!u)throw new Error("Invalid query arguments");return n.query(u,c)},"loadSaveIntentData");var br=i(async(n,{productId:e,productHandle:t,selectedOptions:r,country:s,language:o})=>{if(!e&&!t)throw new Error("Either productId or handle must be provided");let a=e?or:ar,u=e?{productId:`gid://shopify/Product/${e}`,selectedOptions:r,country:s,language:o}:{handle:t,selectedOptions:r,country:s,language:o};return n.query(a,u)},"loadSelectedVariant");var Js="2026-01",Zs=["GetProductIdByHandle"],ct=class{constructor(e,t,r,s,o){this.client=null;this.query=i(async(e,t)=>{if(!this.client)throw new Error("Storefront API client not initialized");let r=await this.client.request(e,{variables:t});return{data:r.data,errors:r.errors??null}},"query");this.loadProductOptions=i(async e=>gr(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}).then(t=>t.data?{...t,data:{...t.data,product:t.data.product?{...t.data.product,options:t.data.product.options.map(r=>({...r,optionValues:this.productOptions.sortValues({optionValues:r.optionValues.slice()})}))}:void 0}}:t),"loadProductOptions");this.loadSelectedVariant=i(async e=>br(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}),"loadSelectedVariant");this.loadProductCardData=i(async e=>hr(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}).then(t=>t.data?"variant"in t.data?{...t,data:{...t.data,badges:this.badges.getBadges({product:t.data.product,variant:t.data.variant})}}:{...t,data:{...t.data,badges:this.badges.getBadges({product:t.data.product})}}:t),"loadProductCardData");this.loadProductDetailData=i(async e=>mr(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}).then(t=>{if(!t.data)return t;let r=t.data.product?{...t.data.product,options:t.data.product.options.map(s=>({...s,optionValues:this.productOptions.sortValues({optionValues:s.optionValues.slice()})}))}:void 0;return"variant"in t.data?{...t,data:{...t.data,product:r,badges:this.badges.getBadges({product:r,variant:t.data.variant})}}:{...t,data:{...t.data,product:r,badges:this.badges.getBadges({product:r})}}}),"loadProductDetailData");this.loadProductImages=i(async e=>vr(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}),"loadProductImages");this.loadProductRecommendations=i(async e=>wr(this,{...e,country:this.context.localization.country,language:this.context.localization.language}),"loadProductRecommendations");this.loadProductId=i(async e=>yr(this,e),"loadProductId");this.loadSaveIntentData=i(async e=>Ir(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}),"loadSaveIntentData");this.options=e,this.context=t,this.badges=r,this.productOptions=s,this.metafields={productMetafields:o?.product.map(u=>({namespace:u.split(".")[0],key:u.split(".")[1]}))??[],variantMetafields:o?.productVariant.map(u=>({namespace:u.split(".")[0],key:u.split(".")[1]}))??[]};let a=H(t.myshopifyDomain);this.shortCache=new Y(`storefront-api-short-${a}`,"max-age=60, stale-while-revalidate=3600"),this.longCache=new Y(`storefront-api-long-${a}`,"max-age=3600, stale-while-revalidate=86400"),this.shortCache.cleanupExpiredEntries().catch(u=>{console.warn("Storefront API cache initialization cleanup error:",u)}),this.longCache.cleanupExpiredEntries().catch(u=>{console.warn("Storefront API cache initialization cleanup error:",u)}),this.client=Ht({apiVersion:Js,customFetchApi:i((u,c)=>c?.method==="OPTIONS"?this.fetch(u,c):Zs.some(l=>c?.body?.toString().includes(`query ${l}`))?this.longCache.fetchWithCache(u,c):this.shortCache.fetchWithCache(u,c),"customFetchApi"),publicAccessToken:this.options.accessToken,storeDomain:this.options.storeDomain})}static{i(this,"StorefrontApiClient")}fetch(e,t){return t?.method==="OPTIONS"?fetch(e,t):this.shortCache.fetchWithCache(e,t)}async clearCache(){await this.shortCache.clear()}};var ei=Object.defineProperty,d=i((n,e)=>ei(n,"name",{value:e,configurable:!0}),"n"),ti={bodySerializer:d(n=>JSON.stringify(n,(e,t)=>typeof t=="bigint"?t.toString():t),"bodySerializer")},ni={$body_:"body",$headers_:"headers",$path_:"path",$query_:"query"},Lp=Object.entries(ni),ri=d(({onRequest:n,onSseError:e,onSseEvent:t,responseTransformer:r,responseValidator:s,sseDefaultRetryDelay:o,sseMaxRetryAttempts:a,sseMaxRetryDelay:u,sseSleepFn:c,url:l,...p})=>{let f,y=c??(h=>new Promise(b=>setTimeout(b,h)));return{stream:d(async function*(){let h=o??3e3,b=0,g=p.signal??new AbortController().signal;for(;!g.aborted;){b++;let O=p.headers instanceof Headers?p.headers:new Headers(p.headers);f!==void 0&&O.set("Last-Event-ID",f);try{let N={redirect:"follow",...p,body:p.serializedBody,headers:O,signal:g},L=new Request(l,N);n&&(L=await n(l,N));let G=await(p.fetch??globalThis.fetch)(L);if(!G.ok)throw new Error(`SSE failed: ${G.status} ${G.statusText}`);if(!G.body)throw new Error("No body in SSE response");let T=G.body.pipeThrough(new TextDecoderStream).getReader(),I="",V=d(()=>{try{T.cancel()}catch{}},"abortHandler");g.addEventListener("abort",V);try{for(;;){let{done:k,value:ee}=await T.read();if(k)break;I+=ee;let sn=I.split(`
443
443
 
444
- `);I=Qt.pop()??"";for(let gr of Qt){let Ir=gr.split(`
445
- `),fe=[],Wt;for(let Q of Ir)if(Q.startsWith("data:"))fe.push(Q.replace(/^data:\s*/,""));else if(Q.startsWith("event:"))Wt=Q.replace(/^event:\s*/,"");else if(Q.startsWith("id:"))h=Q.replace(/^id:\s*/,"");else if(Q.startsWith("retry:")){let Xt=Number.parseInt(Q.replace(/^retry:\s*/,""),10);Number.isNaN(Xt)||(f=Xt)}let te,zt=!1;if(fe.length){let Q=fe.join(`
446
- `);try{te=JSON.parse(Q),zt=!0}catch{te=Q}}zt&&(i&&await i(te),r&&(te=await r(te))),t?.({data:te,event:Wt,id:h,retry:f}),fe.length&&(yield te)}}}finally{v.removeEventListener("abort",q),k.releaseLock()}break}catch(V){if(e?.(V),u!==void 0&&P>=u)break;let O=Math.min(f*2**(P-1),a??3e4);await g(O)}}},"createStream")()}},"createSseClient"),Ii=d(n=>{switch(n){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorArrayExplode"),wi=d(n=>{switch(n){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},"separatorArrayNoExplode"),bi=d(n=>{switch(n){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorObjectExplode"),sr=d(({allowReserved:n,explode:e,name:t,style:r,value:i})=>{if(!e){let a=(n?i:i.map(l=>encodeURIComponent(l))).join(wi(r));switch(r){case"label":return`.${a}`;case"matrix":return`;${t}=${a}`;case"simple":return a;default:return`${t}=${a}`}}let o=Ii(r),u=i.map(a=>r==="label"||r==="simple"?n?a:encodeURIComponent(a):Ze({allowReserved:n,name:t,value:a})).join(o);return r==="label"||r==="matrix"?o+u:u},"serializeArrayParam"),Ze=d(({allowReserved:n,name:e,value:t})=>{if(t==null)return"";if(typeof t=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${e}=${n?t:encodeURIComponent(t)}`},"serializePrimitiveParam"),or=d(({allowReserved:n,explode:e,name:t,style:r,value:i,valueOnly:o})=>{if(i instanceof Date)return o?i.toISOString():`${t}=${i.toISOString()}`;if(r!=="deepObject"&&!e){let l=[];Object.entries(i).forEach(([p,h])=>{l=[...l,p,n?h:encodeURIComponent(h)]});let c=l.join(",");switch(r){case"form":return`${t}=${c}`;case"label":return`.${c}`;case"matrix":return`;${t}=${c}`;default:return c}}let u=bi(r),a=Object.entries(i).map(([l,c])=>Ze({allowReserved:n,name:r==="deepObject"?`${t}[${l}]`:l,value:c})).join(u);return r==="label"||r==="matrix"?u+a:a},"serializeObjectParam"),Si=/\{[^{}]+\}/g,Ei=d(({path:n,url:e})=>{let t=e,r=e.match(Si);if(r)for(let i of r){let o=!1,u=i.substring(1,i.length-1),a="simple";u.endsWith("*")&&(o=!0,u=u.substring(0,u.length-1)),u.startsWith(".")?(u=u.substring(1),a="label"):u.startsWith(";")&&(u=u.substring(1),a="matrix");let l=n[u];if(l==null)continue;if(Array.isArray(l)){t=t.replace(i,sr({explode:o,name:u,style:a,value:l}));continue}if(typeof l=="object"){t=t.replace(i,or({explode:o,name:u,style:a,value:l,valueOnly:!0}));continue}if(a==="matrix"){t=t.replace(i,`;${Ze({name:u,value:l})}`);continue}let c=encodeURIComponent(a==="label"?`.${l}`:l);t=t.replace(i,c)}return t},"defaultPathSerializer"),xi=d(({baseUrl:n,path:e,query:t,querySerializer:r,url:i})=>{let o=i.startsWith("/")?i:`/${i}`,u=(n??"")+o;e&&(u=Ei({path:e,url:u}));let a=t?r(t):"";return a.startsWith("?")&&(a=a.substring(1)),a&&(u+=`?${a}`),u},"getUrl");function ar(n){let e=n.body!==void 0;if(e&&n.bodySerializer)return"serializedBody"in n?n.serializedBody!==void 0&&n.serializedBody!==""?n.serializedBody:null:n.body!==""?n.body:null;if(e)return n.body}s(ar,"K");d(ar,"getValidRequestBody");var Ci=d(async(n,e)=>{let t=typeof e=="function"?await e(n):e;if(t)return n.scheme==="bearer"?`Bearer ${t}`:n.scheme==="basic"?`Basic ${btoa(t)}`:t},"getAuthToken"),ur=d(({allowReserved:n,array:e,object:t}={})=>d(r=>{let i=[];if(r&&typeof r=="object")for(let o in r){let u=r[o];if(u!=null)if(Array.isArray(u)){let a=sr({allowReserved:n,explode:!0,name:o,style:"form",value:u,...e});a&&i.push(a)}else if(typeof u=="object"){let a=or({allowReserved:n,explode:!0,name:o,style:"deepObject",value:u,...t});a&&i.push(a)}else{let a=Ze({allowReserved:n,name:o,value:u});a&&i.push(a)}}return i.join("&")},"querySerializer"),"createQuerySerializer"),ki=d(n=>{var e;if(!n)return"stream";let t=(e=n.split(";")[0])==null?void 0:e.trim();if(t){if(t.startsWith("application/json")||t.endsWith("+json"))return"json";if(t==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some(r=>t.startsWith(r)))return"blob";if(t.startsWith("text/"))return"text"}},"getParseAs"),Ri=d((n,e)=>{var t,r;return e?!!(n.headers.has(e)||(t=n.query)!=null&&t[e]||(r=n.headers.get("Cookie"))!=null&&r.includes(`${e}=`)):!1},"checkForExistence"),Ai=d(async({security:n,...e})=>{for(let t of n){if(Ri(e,t.name))continue;let r=await Ci(t,e.auth);if(!r)continue;let i=t.name??"Authorization";switch(t.in){case"query":e.query||(e.query={}),e.query[i]=r;break;case"cookie":e.headers.append("Cookie",`${i}=${r}`);break;case"header":default:e.headers.set(i,r);break}}},"setAuthParams"),rr=d(n=>xi({baseUrl:n.baseUrl,path:n.path,query:n.query,querySerializer:typeof n.querySerializer=="function"?n.querySerializer:ur(n.querySerializer),url:n.url}),"buildUrl"),ir=d((n,e)=>{var t;let r={...n,...e};return(t=r.baseUrl)!=null&&t.endsWith("/")&&(r.baseUrl=r.baseUrl.substring(0,r.baseUrl.length-1)),r.headers=lr(n.headers,e.headers),r},"mergeConfigs"),Di=d(n=>{let e=[];return n.forEach((t,r)=>{e.push([r,t])}),e},"headersEntries"),lr=d((...n)=>{let e=new Headers;for(let t of n){if(!t)continue;let r=t instanceof Headers?Di(t):Object.entries(t);for(let[i,o]of r)if(o===null)e.delete(i);else if(Array.isArray(o))for(let u of o)e.append(i,u);else o!==void 0&&e.set(i,typeof o=="object"?JSON.stringify(o):o)}return e},"mergeHeaders"),cr=class{static{s(this,"$")}constructor(){this.fns=[]}clear(){this.fns=[]}eject(e){let t=this.getInterceptorIndex(e);this.fns[t]&&(this.fns[t]=null)}exists(e){let t=this.getInterceptorIndex(e);return!!this.fns[t]}getInterceptorIndex(e){return typeof e=="number"?this.fns[e]?e:-1:this.fns.indexOf(e)}update(e,t){let r=this.getInterceptorIndex(e);return this.fns[r]?(this.fns[r]=t,e):!1}use(e){return this.fns.push(e),this.fns.length-1}};d(cr,"Interceptors");var Nt=cr,Pi=d(()=>({error:new Nt,request:new Nt,response:new Nt}),"createInterceptors"),Ti=ur({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),_i={"Content-Type":"application/json"},Je=d((n={})=>({...yi,headers:_i,parseAs:"auto",querySerializer:Ti,...n}),"createConfig"),Ut=d((n={})=>{let e=ir(Je(),n),t=d(()=>({...e}),"getConfig"),r=d(c=>(e=ir(e,c),t()),"setConfig"),i=Pi(),o=d(async c=>{let p={...e,...c,fetch:c.fetch??e.fetch??globalThis.fetch,headers:lr(e.headers,c.headers),serializedBody:void 0};p.security&&await Ai({...p,security:p.security}),p.requestValidator&&await p.requestValidator(p),p.body!==void 0&&p.bodySerializer&&(p.serializedBody=p.bodySerializer(p.body)),(p.body===void 0||p.serializedBody==="")&&p.headers.delete("Content-Type");let h=rr(p);return{opts:p,url:h}},"beforeRequest"),u=d(async c=>{let{opts:p,url:h}=await o(c),g={redirect:"follow",...p,body:ar(p)},f=new Request(h,g);for(let I of i.request.fns)I&&(f=await I(f,p));let P=p.fetch,v=await P(f);for(let I of i.response.fns)I&&(v=await I(v,f,p));let _={request:f,response:v};if(v.ok){let I=(p.parseAs==="auto"?ki(v.headers.get("Content-Type")):p.parseAs)??"json";if(v.status===204||v.headers.get("Content-Length")==="0"){let $;switch(I){case"arrayBuffer":case"blob":case"text":$=await v[I]();break;case"formData":$=new FormData;break;case"stream":$=v.body;break;case"json":default:$={};break}return p.responseStyle==="data"?$:{data:$,..._}}let q;switch(I){case"arrayBuffer":case"blob":case"formData":case"json":case"text":q=await v[I]();break;case"stream":return p.responseStyle==="data"?v.body:{data:v.body,..._}}return I==="json"&&(p.responseValidator&&await p.responseValidator(q),p.responseTransformer&&(q=await p.responseTransformer(q))),p.responseStyle==="data"?q:{data:q,..._}}let V=await v.text(),O;try{O=JSON.parse(V)}catch{}let W=O??V,k=W;for(let I of i.error.fns)I&&(k=await I(W,v,f,p));if(k=k||{},p.throwOnError)throw k;return p.responseStyle==="data"?void 0:{error:k,..._}},"request"),a=d(c=>p=>u({...p,method:c}),"makeMethodFn"),l=d(c=>async p=>{let{opts:h,url:g}=await o(p);return gi({...h,body:h.body,headers:h.headers,method:c,onRequest:d(async(f,P)=>{let v=new Request(f,P);for(let _ of i.request.fns)_&&(v=await _(v,h));return v},"onRequest"),url:g})},"makeSseFn");return{buildUrl:rr,connect:a("CONNECT"),delete:a("DELETE"),get:a("GET"),getConfig:t,head:a("HEAD"),interceptors:i,options:a("OPTIONS"),patch:a("PATCH"),post:a("POST"),put:a("PUT"),request:u,setConfig:r,sse:{connect:l("CONNECT"),delete:l("DELETE"),get:l("GET"),head:l("HEAD"),options:l("OPTIONS"),patch:l("PATCH"),post:l("POST"),put:l("PUT"),trace:l("TRACE")},trace:a("TRACE")}},"createClient"),S=Ut(Je({baseUrl:"https://swish.app/api/2026-01"})),Oi=d(n=>(n?.client??S).get({security:[{scheme:"bearer",type:"http"}],url:"/lists",...n}),"listControllerFind"),Li=d(n=>(n.client??S).post({security:[{scheme:"bearer",type:"http"}],url:"/lists",...n,headers:{"Content-Type":"application/json",...n.headers}}),"listControllerCreate"),qi=d(n=>(n.client??S).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...n}),"listControllerDeleteById"),$i=d(n=>(n.client??S).get({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...n}),"listControllerFindById"),Vi=d(n=>(n.client??S).patch({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...n,headers:{"Content-Type":"application/json",...n.headers}}),"listControllerUpdateById"),Bi=d(n=>(n.client??S).put({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/order",...n,headers:{"Content-Type":"application/json",...n.headers}}),"listControllerSetListItemsOrder"),Ni=d(n=>(n.client??S).post({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items",...n,headers:{"Content-Type":"application/json",...n.headers}}),"listControllerAddItemsToList"),Ui=d(n=>(n.client??S).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/{itemId}",...n}),"listControllerRemoveItemFromList"),Mi=d(n=>(n.client??S).delete({security:[{scheme:"bearer",type:"http"}],url:"/items",...n,headers:{"Content-Type":"application/json",...n.headers}}),"itemControllerDelete"),Gi=d(n=>(n?.client??S).get({security:[{scheme:"bearer",type:"http"}],url:"/items",...n}),"itemControllerFind"),Fi=d(n=>(n.client??S).post({security:[{scheme:"bearer",type:"http"}],url:"/items",...n,headers:{"Content-Type":"application/json",...n.headers}}),"itemControllerCreate"),ji=d(n=>(n?.client??S).get({security:[{scheme:"bearer",type:"http"}],url:"/items/count",...n}),"itemControllerCount"),Hi=d(n=>(n.client??S).delete({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...n}),"itemControllerDeleteById"),Qi=d(n=>(n.client??S).get({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...n}),"itemControllerFindById"),Wi=d(n=>(n.client??S).patch({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...n,headers:{"Content-Type":"application/json",...n.headers}}),"itemControllerUpdateById"),zi=d(n=>(n.client??S).put({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}/lists",...n,headers:{"Content-Type":"application/json",...n.headers}}),"itemControllerSetListsById"),Xi=d(n=>(n.client??S).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/identify",...n,headers:{"Content-Type":"application/json",...n.headers}}),"profileControllerIdentify"),Ki=d(n=>(n.client??S).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/token",...n,headers:{"Content-Type":"application/json",...n.headers}}),"profileControllerCreateToken"),Yi=d(n=>(n?.client??S).get({security:[{scheme:"bearer",type:"http"}],url:"/profiles",...n}),"profileControllerGetProfile"),Ji=d(n=>(n.client??S).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/saved-items",...n}),"analyticsControllerLoadSavedItems"),Zi=d(n=>(n.client??S).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/sessions",...n}),"analyticsControllerLoadSessions"),es=d(n=>(n.client??S).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/new-lists",...n}),"analyticsControllerLoadNewLists"),ts=d(n=>(n.client??S).post({security:[{scheme:"bearer",type:"http"}],url:"/tracking",...n,headers:{"Content-Type":"application/json",...n.headers}}),"trackingControllerTrack"),ns=d(n=>(n?.client??S).get({security:[{scheme:"bearer",type:"http"}],url:"/orders",...n}),"ordersControllerFind"),rs=d(n=>(n.client??S).get({security:[{scheme:"bearer",type:"http"}],url:"/orders/{orderId}",...n}),"ordersControllerFindOne"),is=d(n=>(n.client??S).post({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{listId}/save",...n}),"sharedListsControllerSave"),ss=d(n=>(n.client??S).delete({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{listId}",...n}),"sharedListsControllerDeleteById"),os=d(n=>(n.client??S).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{listId}",...n}),"sharedListsControllerFindById"),as=d(n=>(n?.client??S).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists",...n}),"sharedListsControllerFindAll"),Mt="2026-01",pr=d(n=>new us(n),"createApiClient"),dr=class{static{s(this,"H")}constructor(e){this.version=Mt,this.items={list:d(a=>this.handlePaginatedRequest(Gi({query:a,client:this.directClient})),"list"),create:d(a=>this.handleRequest(Fi({body:a,client:this.directClient})),"create"),delete:d(a=>this.handleRequest(Mi({body:{itemIds:a},client:this.directClient})),"delete"),findById:d(a=>this.handleRequest(Qi({path:{itemId:a},client:this.directClient})),"findById"),updateById:d((a,l)=>this.handleRequest(Wi({body:l,path:{itemId:a},client:this.directClient})),"updateById"),deleteById:d(a=>this.handleRequest(Hi({path:{itemId:a},client:this.directClient})),"deleteById"),setListsById:d((a,l)=>this.handleRequest(zi({body:{listIds:l},path:{itemId:a},client:this.directClient})),"setListsById"),count:d(()=>this.handleRequest(ji({client:this.directClient})),"count")},this.lists={list:d(a=>this.handlePaginatedRequest(Oi({query:a,client:this.directClient})),"list"),create:d(a=>this.handleRequest(Li({body:a,client:this.directClient})),"create"),findById:d(a=>this.handleRequest($i({path:{listId:a},client:this.directClient})),"findById"),updateById:d((a,l)=>this.handleRequest(Vi({body:l,path:{listId:a},client:this.directClient})),"updateById"),deleteById:d(a=>this.handleRequest(qi({path:{listId:a},client:this.directClient})),"deleteById"),orderItems:d((a,l)=>this.handleRequest(Bi({body:{itemIds:l},path:{listId:a},client:this.directClient})),"orderItems"),addItemsToList:d((a,l)=>this.handleRequest(Ni({body:{itemIds:l},path:{listId:a},client:this.directClient})),"addItemsToList"),removeItemFromList:d((a,l)=>this.handleRequest(Ui({path:{listId:a,itemId:l},client:this.directClient})),"removeItemFromList")},this.profiles={createToken:d((a={})=>this.handleRequest(Ki({body:a,client:this.proxyClient??this.directClient})),"createToken"),identify:d(a=>this.handleRequest(Xi({body:a,client:this.directClient})),"identify"),getProfile:d(()=>this.handleRequest(Yi({client:this.directClient})),"getProfile")},this.orders={list:d(a=>this.handlePaginatedRequest(ns({query:a,client:this.directClient})),"list"),findById:d(a=>this.handleRequest(rs({path:{orderId:a},client:this.directClient})),"findById")},this.sharedLists={list:d(a=>this.handlePaginatedRequest(as({query:a,client:this.directClient})),"list"),save:d(a=>this.handleRequest(is({path:{listId:a},client:this.directClient})),"save"),findById:d(a=>this.handleRequest(os({path:{listId:a},client:this.directClient})),"findById"),deleteById:d(a=>this.handleRequest(ss({path:{listId:a},client:this.directClient})),"deleteById")},this.analytics={savedItems:d(a=>this.handleRequest(Ji({query:a,client:this.directClient})),"savedItems"),sessions:d(a=>this.handleRequest(Zi({query:a,client:this.directClient})),"sessions"),newLists:d(a=>this.handleRequest(es({query:a,client:this.directClient})),"newLists")},this.tracking={track:d((a,l)=>this.handleRequest(ts({body:a,headers:l,client:this.directClient})),"track")},this.handleRequest=d(async a=>{let{data:l,error:c}=await a;return c!=null&&c.error?{error:c.error}:{data:l?.data}},"handleRequest"),this.handlePaginatedRequest=d(async a=>{var l;let{data:c,error:p}=await a;return p!=null&&p.error?{error:p.error}:{data:c?.data??[],pageInfo:c?.pageInfo??{next:null,previous:null,totalCount:((l=c?.data)==null?void 0:l.length)??0}}},"handlePaginatedRequest");var t,r,i,o,u;(t=e.config)!=null&&t.version&&(this.version=e.config.version),this.directClient=Ut(Je({baseUrl:`https://swish.app/api/${this.version}`,...e.config})),(r=e.config)!=null&&r.authProxy&&(this.proxyClient=Ut(Je({...e.config,baseUrl:e.config.authProxy}))),e.authToken&&(this.authToken=e.authToken),e.requestInterceptor&&((i=this.proxyClient)==null||i.interceptors.request.use(e.requestInterceptor),this.directClient.interceptors.request.use(e.requestInterceptor)),e.responseInterceptor&&((o=this.proxyClient)==null||o.interceptors.response.use(e.responseInterceptor),this.directClient.interceptors.response.use(e.responseInterceptor)),(u=this.proxyClient)==null||u.interceptors.request.use(this.proxyRequestInterceptor.bind(this)),this.directClient.interceptors.request.use(this.directRequestInterceptor.bind(this))}setAuthToken(e){this.authToken=e}proxyRequestInterceptor(e){return this.version&&e.headers.set("Swish-Api-Version",this.version),e}directRequestInterceptor(e){return this.authToken&&e.headers.set("Authorization",`Bearer ${this.authToken}`),e}};d(dr,"SwishClient");var us=dr;var yr=Rr(mr(),1);var vr=s(n=>new yr.default(async e=>{let t=[...new Set(e)].sort((i,o)=>i.localeCompare(o)),r=await n.items.list({query:t.join(" "),limit:200});return"error"in r?(console.error("Failed to load items",r.error),e.map(()=>({data:[],pageInfo:{next:null,previous:null,totalCount:0}}))):e.map(i=>{let o=r.data.find(u=>i===`variant:${u.variantId}`||i===`product:${u.productId}`);return{data:o?[o]:[],pageInfo:{next:null,previous:null,totalCount:o?1:0}}})},{batchScheduleFn:s(e=>setTimeout(e,50),"batchScheduleFn"),cache:!1,maxBatchSize:200}),"createItemsBatchLoader");var et=class{constructor(e,t,r){this.tokenHasProfile=!1;this.api=e,this.context=t,this.eventBus=r}static{s(this,"SwishApiAuth")}hasProfile(){return this.tokenHasProfile}hasToken(){return!!this.getSwishToken()}async renewToken(){return this._renewPromise?this._renewPromise:(this._renewPromise=(async()=>{this._initPromise=void 0,this.deleteSwishToken(),await this.init(),this._renewPromise=void 0})(),this._renewPromise)}async init(){return this._initPromise?this._initPromise:(this._initPromise=(async()=>{this.migrateLegacySession();let e=this.context.customer.id;e?(this.hasSessionToken()&&await this.api.clearCache(),await this.initCustomer(e)):(this.hasCustomerToken()&&await this.resetSession(),await this.initSession()),this.eventBus.publish("token-update",null)})(),this._initPromise)}async initCustomer(e){let t=`gid://shopify/Customer/${e}`,r=this.getTokenBySub(t);if(r){this.initToken(r);return}let i=this.getSessionId();await this.acquireToken(i,t)}async initSession(){let e=this.getSessionId(),t=e?this.getTokenBySub(e):null;if(t){this.initToken(t);return}await this.acquireToken(e)}initToken(e){let t=this.getTokenData(e);if(!t)throw new Error("Invalid Swish token.");this.tokenHasProfile=t.has_profile!==!1,this.api.setAuthToken(e)}async acquireToken(e,t){let r=await this.api.profiles.createToken({customer:t,session:e});if("error"in r)throw console.error("Failed to create customer token",r.error),new Error("Failed to create customer token");if(!r.data?.token)throw console.error("Failed to create customer token empty response"),new Error("Failed to create customer token");r.data.profile.startsWith("gid://swish/Session/")&&this.setSessionId(r.data.profile),this.setSwishToken(r.data.token),this.initToken(r.data.token)}async resetSession(){this.deleteSessionId(),this.deleteSwishToken(),await this.api.clearCache()}getTokenData(e){try{return JSON.parse(atob(e.split(".")[1]))}catch(t){return console.error("Failed to parse Swish token",{cause:t}),null}}willTokenExpire(e,t=60){let r=this.getTokenData(e);return!!(r&&r.exp&&r.exp<Date.now()/1e3+t)}hasCustomerToken(){let e=this.getSwishToken();return e?this.getTokenData(e)?.sub?.startsWith("gid://shopify/Customer/")??!1:!1}hasSessionToken(){let e=this.getSwishToken();return e?this.getTokenData(e)?.sub?.startsWith("gid://swish/Session/")??!1:!1}getTokenBySub(e){if(!e)return null;let t=this.getSwishToken();if(!t)return null;let r=this.getTokenData(t);return!r||r.sub!==e||this.willTokenExpire(t,60)?null:t}getSessionId(){let e=j(this.context.myshopifyDomain);return localStorage.getItem(`swish-session-${e}`)??void 0}setSessionId(e){let t=j(this.context.myshopifyDomain);localStorage.setItem(`swish-session-${t}`,e)}deleteSessionId(){let e=j(this.context.myshopifyDomain);localStorage.removeItem(`swish-session-${e}`)}getSwishToken(){let e=j(this.context.myshopifyDomain);return sessionStorage.getItem(`swish-token-${e}`)??void 0}setSwishToken(e){let t=j(this.context.myshopifyDomain);sessionStorage.setItem(`swish-token-${t}`,e)}deleteSwishToken(){let e=j(this.context.myshopifyDomain);sessionStorage.removeItem(`swish-token-${e}`)}migrateLegacySession(){try{let e=localStorage.getItem("wk_session_id")??localStorage.getItem("swish-profile")?.split("/").pop()??localStorage.getItem("swish-session")?.split("/").pop();e&&(this.setSessionId(`gid://swish/Session/${e}`),localStorage.removeItem("wk_session_id"),localStorage.removeItem("swish-profile"),localStorage.removeItem("swish-session"))}catch(e){console.warn("Failed to migrate legacy session id to Swish session",{cause:e})}}};var tt=class{static{s(this,"SwishApi")}constructor(e,t,r,i){this.config=e,this.storefrontContext=t;let o=j(t.myshopifyDomain);this.cache=new X(`swish-api-${o}`,"max-age=60, stale-while-revalidate=3600",i+(e.version??Mt)),this.cache.cleanupExpiredEntries().catch(u=>{console.warn("Swish API cache initialization cleanup error:",u)}),this.auth=new et(this,t,r),this.apiClient=pr({authToken:this.auth.getSwishToken(),config:{...e,fetch:this.fetchFunction.bind(this)},requestInterceptor:this.requestInterceptor.bind(this),responseInterceptor:this.responseInterceptor.bind(this)}),this.itemsLoader=vr(this)}async fetchFunction(e,t){let r=e instanceof Request?e.method:t?.method??"GET",o=(e instanceof Request?e.url:typeof e=="string"?e:e.toString()).includes("/orders");return r==="GET"&&!o?this.cache.fetchWithCache(e,t):fetch(e,t)}async requestInterceptor(e){let t=new URL(e.url,window.location.origin);!!this.config.authProxy&&t.pathname.startsWith(this.config.authProxy)||await this.auth.init();try{e.headers.set("Country",this.storefrontContext.localization.country),e.headers.set("Language",this.storefrontContext.localization.language),e.headers.set("Market",this.storefrontContext.localization.market)}catch(i){console.warn("Failed to set storefront context headers:",i)}return this.config.requestInterceptor&&(e=await this.config.requestInterceptor(e)),e}async responseInterceptor(e,t){let r=t.method!=="GET",i=t.url.includes("/profiles/token");if(r&&!i){let o=this.auth.hasToken(),u=!this.auth.hasProfile(),a=e.ok;await this.cache.clear(),o&&u&&a&&await this.auth.renewToken()}return await this.config.responseInterceptor?.(e,t),e}setAuthToken(e){this.apiClient.setAuthToken(e)}initAuth(){return this.auth.init()}withFallback(e,t){return this.auth.hasProfile()?e():Promise.resolve(t)}get items(){return{...this.apiClient.items,count:s(async()=>this.withFallback(()=>this.apiClient.items.count(),{data:{count:0}}),"count"),list:s(async(e,t)=>this.withFallback(()=>{if(t?.batch&&e?.query){e.limit!==1&&console.warn("Batching will always limit to 1 item");let r=e.query.split(" ");r.length>1&&console.warn("Batching will only support one query parameter");let i=r[0];if(!i.match(/^product:\d+$/)&&!i.match(/^variant:\d+$/))console.warn("Batching will only support product:<id> or variant:<id>");else return this.itemsLoader?.load(i)}return this.apiClient.items.list(e)},{data:[],pageInfo:{next:null,previous:null,totalCount:0}}),"list"),findById:s(async e=>this.withFallback(()=>this.apiClient.items.findById(e),{data:null}),"findById")}}get lists(){return{...this.apiClient.lists,list:s(async e=>this.withFallback(()=>this.apiClient.lists.list(e),{data:[],pageInfo:{next:null,previous:null,totalCount:0}}),"list"),findById:s(async e=>this.withFallback(()=>this.apiClient.lists.findById(e),{data:null}),"findById")}}get orders(){return{...this.apiClient.orders,list:s(async e=>this.withFallback(()=>this.apiClient.orders.list(e),{data:[],pageInfo:{next:null,previous:null,totalCount:0}}),"list"),findById:s(async e=>this.withFallback(()=>(typeof e=="string"&&(e=parseInt(e.split("/").pop()??e)),this.apiClient.orders.findById(e)),{data:null}),"findById")}}get profiles(){return this.apiClient.profiles}async clearCache(){await this.cache.clear()}};var nt=class{constructor(e){this.eventMap={"POST /items\\/?$":"item-create","DELETE /items\\/?$":"item-delete","PATCH /items\\/([^/]+)\\/?$":"item-update","DELETE /items\\/([^/]+)\\/?$":"item-delete","PUT /items\\/([^/]+)\\/lists\\/?$":"item-lists-update","POST /lists\\/?$":"list-create","DELETE /lists\\/?$":"list-delete","PATCH /lists\\/([^/]+)\\/?$":"list-update","DELETE /lists\\/([^/]+)\\/?$":"list-delete"};this.eventBus=e,this.processFetchResponse=this.processFetchResponse.bind(this)}static{s(this,"SwishApiPublisher")}async processFetchResponse(e,t){try{let r=this.getEventName(t.method,e.status,t.url);if(!r)return;let i=await e.clone().text();if(e.headers.get("Content-Type")?.includes("application/json"))try{i=JSON.parse(i).data}catch(o){console.warn(o)}this.eventBus.publish(r,i)}catch(r){console.warn(r)}}getEventName(e,t,r){e=e.toUpperCase();let i=new URL(r).pathname;return e==="GET"||t<200||t>=300?void 0:Object.entries(this.eventMap).find(([u])=>{let[a,l]=u.split(" ");return a!==e?!1:new RegExp(l).test(i)})?.[1]}};var rt=class{constructor(e,t){this.inflightModals=new Map;this.modalsWithScrollLock=new Set;this.scrollLockRefCount=0;this.scrollPositionBeforeLock=0;this._lockScroll=s(()=>this.lockScroll(),"_lockScroll");this._unlockScroll=s(()=>this.unlockScroll(),"_unlockScroll");this.swishUiOptions=e,this.storefrontContext=t}static{s(this,"SwishUi")}async hideModal(e){if(this.inflightModals.has(e))return this.inflightModals.get(e);let t=(async()=>{try{if(typeof e=="string"&&(e=await this.requireUiComponent(e)),!e||e.getAttribute("open")!=="true")return;e.setAttribute("open","false")}finally{e&&typeof e!="string"&&this.modalsWithScrollLock.has(e)&&(this.modalsWithScrollLock.delete(e),this.unlockScroll())}})().finally(()=>{this.inflightModals.delete(e)});return this.inflightModals.set(e,t),t}async showModal(e){if(this.inflightModals.has(e))return this.inflightModals.get(e);let t=(async()=>{typeof e=="string"&&(e=await this.requireUiComponent(e)),!(!e||e.getAttribute("open")==="true")&&(this.lockScroll(),this.modalsWithScrollLock.add(e),e.setAttribute("open","true"))})().finally(()=>{this.inflightModals.delete(e)});return this.inflightModals.set(e,t),t}waitForEvent(e,t){return new Promise(r=>{let i=[],o=s(()=>{i.forEach(({event:u,listener:a})=>{e.removeEventListener(u,a)})},"cleanup");Object.entries(t).forEach(([u,a])=>{let l=s(c=>{let p=a(c);o(),r(p)},"listener");i.push({event:u,listener:l}),e.addEventListener(u,l)})})}async showSignIn(e){let t=await this.requireUiComponent("sign-in");t.setAttribute("return-to",e?.returnTo??window.location.pathname),await this.showModal(t);let r=await this.waitForEvent(t,{close:s(()=>({code:"closed"}),"close")});return await this.hideModal(t),r}async showUnsaveAlert(e){if(!e.itemId)throw new Error("An itemId is required to show the unsave alert");await this.hideAllToasts();let t=await this.requireUiComponent("unsave-alert");t.setAttribute("item-id",e.itemId),await this.showModal(t);let r=await this.waitForEvent(t,{submit:s(i=>i instanceof CustomEvent?{code:"ok",data:i.detail}:(console.warn("Unsave alert submitted without detail",i),{code:"closed"}),"submit"),close:s(()=>({code:"closed"}),"close")});return await this.hideModal(t),r}async showDeleteListAlert(e){if(!e.listId)throw new Error("A listId is required to show the delete list alert");await this.hideAllToasts();let t=await this.requireUiComponent("delete-list-alert");t.setAttribute("list-id",e.listId),await this.showModal(t);let r=await this.waitForEvent(t,{submit:s(()=>({code:"ok",data:void 0}),"submit"),close:s(()=>({code:"closed"}),"close")});return await this.hideModal(t),r}async showDrawer(e){await this.hideAllToasts();let t=await this.requireUiComponent("drawer");t.setAttribute("account-url",this.storefrontContext.routes.accountUrl),this.storefrontContext.customer.id&&t.setAttribute("customer-id",this.storefrontContext.customer.id),t.setAttribute("view",e?.view??"home"),e?.listId&&t.setAttribute("list-id",e.listId),e?.productId&&t.setAttribute("product-id",e.productId),e?.variantId&&t.setAttribute("variant-id",e.variantId),e?.orderId&&t.setAttribute("order-id",e.orderId),await this.showModal(t);let r=await this.waitForEvent(t,{close:s(()=>({code:"closed"}),"close")});return await this.hideModal(t),r}async showListMenu(e){if(!e.listId)throw new Error("listId is required");await this.hideAllToasts();let t=await this.requireUiComponent("list-menu");t.setAttribute("list-id",e.listId),await this.showModal(t);let r=await this.waitForEvent(t,{close:s(()=>({code:"closed"}),"close"),edit:s(i=>i instanceof CustomEvent?{code:"ok",data:{action:"edit",data:i.detail}}:(console.warn("List menu edit without detail",i),{code:"closed"}),"edit"),delete:s(()=>({code:"ok",data:{action:"delete"}}),"delete")});return await this.hideModal(t),r}async showOrderMenu(e){if(!e.orderId)throw new Error("orderId is required");await this.hideAllToasts();let t=await this.requireUiComponent("order-menu");t.setAttribute("order-id",e.orderId),await this.showModal(t);let r=await this.waitForEvent(t,{close:s(()=>({code:"closed"}),"close")});return await this.hideModal(t),r}async showListDetailPageMenu(e){await this.hideAllToasts();let t=await this.requireUiComponent("list-detail-page-menu");t.setAttribute("list-id",e.listId),await this.showModal(t);let r=await this.waitForEvent(t,{close:s(()=>({code:"closed"}),"close")});return await this.hideModal(t),r}async showListSelect(e){if(!e.itemId)throw new Error("itemId is required");await this.hideAllToasts();let t=await this.requireUiComponent("list-select");t.setAttribute("item-id",e.itemId),await this.showModal(t);let r=await this.waitForEvent(t,{close:s(()=>({code:"closed"}),"close"),submit:s(i=>"detail"in i&&i.detail?{code:"ok",data:{action:"submit",data:i.detail}}:(console.warn("List select submit without detail",i),{code:"closed"}),"submit"),unsave:s(i=>i instanceof CustomEvent?{code:"ok",data:{action:"unsave",data:i.detail}}:(console.warn("List select unsave without detail",i),{code:"closed"}),"unsave")});return await this.hideModal(t),r}async initListDetailPage(e,t){let r=await this.requireUiComponent("list-detail-page",{refElement:t});e.listId&&r.setAttribute("list-id",e.listId)}async showToast(e){let t=Date.now(),r=await this.requireUiComponent("toast-manager",{onHydrated:s(i=>{i.current.show(e,t)},"onHydrated")});return this.waitForEvent(r,{[`close-${t}`]:()=>({code:"closed"}),[`submit-${t}`]:()=>({code:"ok",data:void 0})})}async hideAllToasts(){this.queryComponent("toast-manager")&&await this.requireUiComponent("toast-manager",{onHydrated:s(e=>{e.current.clear()},"onHydrated")})}async showVariantSelect(e){await this.hideAllToasts();let t=await this.requireUiComponent("variant-select");if(e?.itemId&&t.setAttribute("item-id",e.itemId),e?.productId)t.setAttribute("product-id",e.productId.toString());else if(e?.productHandle)t.setAttribute("product-handle",e.productHandle);else throw new Error("Either productId or productHandle must be provided");e?.variantId&&t.setAttribute("variant-id",e.variantId.toString()),await this.showModal(t);let r=await this.waitForEvent(t,{close:s(()=>({code:"closed"}),"close"),submit:s(i=>"detail"in i&&i.detail?{code:"ok",data:i.detail}:(console.warn("Variant select submit without detail",i),{code:"closed"}),"submit")});return await this.hideModal(t),r}async showQuickBuy(e){await this.hideAllToasts();let t=await this.requireUiComponent("quick-buy");if(e?.productId)t.setAttribute("product-id",e.productId.toString());else if(e?.productHandle)t.setAttribute("product-handle",e.productHandle);else throw new Error("ProductId or productHandle must be provided");e?.variantId&&t.setAttribute("variant-id",e.variantId.toString()),await this.showModal(t);let r=await this.waitForEvent(t,{close:s(()=>({code:"closed"}),"close"),submit:s(i=>"detail"in i&&i.detail?{code:"ok",data:i.detail}:(console.warn("Quick buy submit without detail",i),{code:"closed"}),"submit")});return await this.hideModal(t),r}async showListEditor(e){let t=await this.requireUiComponent("list-editor");e?.listId&&t.setAttribute("list-id",e.listId),await this.showModal(t);let r=await this.waitForEvent(t,{close:s(()=>({code:"closed"}),"close"),submit:s(i=>"detail"in i&&i.detail?{code:"ok",data:i.detail}:(console.warn("List editor submit without detail",i),{code:"closed"}),"submit")});return await this.hideModal(t),r}async requireUiComponent(e,t){this.loadCricalResources();let r=`${this.swishUiOptions.baseUrl}/ui@${this.swishUiOptions.version}/${e}.html`,i=await fetch(r).then(a=>a.text()),o=t?.instance,u=this.queryComponent(e,o)??await this.insertComponent({name:e,template:i,refElement:t?.refElement??document.body,position:"beforeend",instance:o});if(u.shadowRoot&&!u.hasAttribute("hydrated")){let a=`${this.swishUiOptions.baseUrl}/ui@${this.swishUiOptions.version}/${e}.js`;Promise.all([this.loadNonCriticalResources(),import(a)]).then(([{bundleCssStylesheet:l,customCssStylesheets:c},{hydrate:p}])=>{u.shadowRoot&&l&&(u.shadowRoot.adoptedStyleSheets=[...u.shadowRoot.adoptedStyleSheets,...c,l],u.shadowRoot?.querySelector(":host > style")?.remove()),p(u),u.setAttribute("hydrated",""),t?.onHydrated?.(u.getComponentRef())})}else u.hasAttribute("hydrated")&&t?.onHydrated?.(u.getComponentRef());return u}async loadCricalResources(){return this._loadCricalResourcesPromise?this._loadCricalResourcesPromise:(this._loadCricalResourcesPromise=(async()=>{let e=`${this.swishUiOptions.baseUrl}/ui@${this.swishUiOptions.version}/theme.css`,t=await fetch(e).then(i=>i.text()),r=new CSSStyleSheet;return r.replaceSync(t),this.swishUiOptions.theme&&Object.entries(this.swishUiOptions.theme).forEach(([i,o])=>{r.cssRules[0].cssRules[0].style.setProperty(i,o)}),{themeVariablesStylesheet:r}})(),this._loadCricalResourcesPromise)}async loadNonCriticalResources(){return this._loadNonCriticalResourcesPromise?this._loadNonCriticalResourcesPromise:(this._loadNonCriticalResourcesPromise=(async()=>{let e=`${this.swishUiOptions.baseUrl}/ui@${this.swishUiOptions.version}/bundle.css`,t=s(o=>{let u=new CSSStyleSheet;return u.replaceSync(o),u},"createCssStylesheet"),[r,...i]=await Promise.all([fetch(e).then(o=>o.text()).then(t),...this.swishUiOptions.css.map(async o=>o instanceof URL?t(await fetch(o).then(u=>u.text())):t(o))]);return{bundleCssStylesheet:r,customCssStylesheets:i}})(),this._loadNonCriticalResourcesPromise)}async insertComponent({name:e,instance:t,template:r,position:i,refElement:o}){let{themeVariablesStylesheet:u}=await this.loadCricalResources();o.insertAdjacentHTML(i,r.replace(' shadowrootmode="open"',""));let a=this.queryComponent(e,t);if(!a)throw new Error(`Element ${e} not found in DOM`);return a.shadowRoot&&(a.shadowRoot.adoptedStyleSheets=[u]),a}queryComponent(e,t){let r=`swish-ui[ref="${e}${t?`-${t}`:""}"]`;return document.querySelector(r)}lockScroll(){this.scrollLockRefCount++,this.scrollLockRefCount===1&&(this.scrollPositionBeforeLock=window.scrollY,this.scrollLockStyleSheet||(this.scrollLockStyleSheet=new CSSStyleSheet,document.adoptedStyleSheets=[...document.adoptedStyleSheets,this.scrollLockStyleSheet]),this.scrollLockStyleSheet.replaceSync(`
444
+ `);I=sn.pop()??"";for(let Mr of sn){let qr=Mr.split(`
445
+ `),ge=[],on;for(let W of qr)if(W.startsWith("data:"))ge.push(W.replace(/^data:\s*/,""));else if(W.startsWith("event:"))on=W.replace(/^event:\s*/,"");else if(W.startsWith("id:"))f=W.replace(/^id:\s*/,"");else if(W.startsWith("retry:")){let un=Number.parseInt(W.replace(/^retry:\s*/,""),10);Number.isNaN(un)||(h=un)}let se,an=!1;if(ge.length){let W=ge.join(`
446
+ `);try{se=JSON.parse(W),an=!0}catch{se=W}}an&&(s&&await s(se),r&&(se=await r(se))),t?.({data:se,event:on,id:f,retry:h}),ge.length&&(yield se)}}}finally{g.removeEventListener("abort",V),T.releaseLock()}break}catch(N){if(e?.(N),a!==void 0&&b>=a)break;let L=Math.min(h*2**(b-1),u??3e4);await y(L)}}},"createStream")()}},"createSseClient"),si=d(n=>{switch(n){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorArrayExplode"),ii=d(n=>{switch(n){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},"separatorArrayNoExplode"),oi=d(n=>{switch(n){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorObjectExplode"),xr=d(({allowReserved:n,explode:e,name:t,style:r,value:s})=>{if(!e){let u=(n?s:s.map(c=>encodeURIComponent(c))).join(ii(r));switch(r){case"label":return`.${u}`;case"matrix":return`;${t}=${u}`;case"simple":return u;default:return`${t}=${u}`}}let o=si(r),a=s.map(u=>r==="label"||r==="simple"?n?u:encodeURIComponent(u):pt({allowReserved:n,name:t,value:u})).join(o);return r==="label"||r==="matrix"?o+a:a},"serializeArrayParam"),pt=d(({allowReserved:n,name:e,value:t})=>{if(t==null)return"";if(typeof t=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${e}=${n?t:encodeURIComponent(t)}`},"serializePrimitiveParam"),Cr=d(({allowReserved:n,explode:e,name:t,style:r,value:s,valueOnly:o})=>{if(s instanceof Date)return o?s.toISOString():`${t}=${s.toISOString()}`;if(r!=="deepObject"&&!e){let c=[];Object.entries(s).forEach(([p,f])=>{c=[...c,p,n?f:encodeURIComponent(f)]});let l=c.join(",");switch(r){case"form":return`${t}=${l}`;case"label":return`.${l}`;case"matrix":return`;${t}=${l}`;default:return l}}let a=oi(r),u=Object.entries(s).map(([c,l])=>pt({allowReserved:n,name:r==="deepObject"?`${t}[${c}]`:c,value:l})).join(a);return r==="label"||r==="matrix"?a+u:u},"serializeObjectParam"),ai=/\{[^{}]+\}/g,ui=d(({path:n,url:e})=>{let t=e,r=e.match(ai);if(r)for(let s of r){let o=!1,a=s.substring(1,s.length-1),u="simple";a.endsWith("*")&&(o=!0,a=a.substring(0,a.length-1)),a.startsWith(".")?(a=a.substring(1),u="label"):a.startsWith(";")&&(a=a.substring(1),u="matrix");let c=n[a];if(c==null)continue;if(Array.isArray(c)){t=t.replace(s,xr({explode:o,name:a,style:u,value:c}));continue}if(typeof c=="object"){t=t.replace(s,Cr({explode:o,name:a,style:u,value:c,valueOnly:!0}));continue}if(u==="matrix"){t=t.replace(s,`;${pt({name:a,value:c})}`);continue}let l=encodeURIComponent(u==="label"?`.${c}`:c);t=t.replace(s,l)}return t},"defaultPathSerializer"),ci=d(({baseUrl:n,path:e,query:t,querySerializer:r,url:s})=>{let o=s.startsWith("/")?s:`/${s}`,a=(n??"")+o;e&&(a=ui({path:e,url:a}));let u=t?r(t):"";return u.startsWith("?")&&(u=u.substring(1)),u&&(a+=`?${u}`),a},"getUrl");function kr(n){let e=n.body!==void 0;if(e&&n.bodySerializer)return"serializedBody"in n?n.serializedBody!==void 0&&n.serializedBody!==""?n.serializedBody:null:n.body!==""?n.body:null;if(e)return n.body}i(kr,"K");d(kr,"getValidRequestBody");var li=d(async(n,e)=>{let t=typeof e=="function"?await e(n):e;if(t)return n.scheme==="bearer"?`Bearer ${t}`:n.scheme==="basic"?`Basic ${btoa(t)}`:t},"getAuthToken"),Rr=d(({allowReserved:n,array:e,object:t}={})=>d(r=>{let s=[];if(r&&typeof r=="object")for(let o in r){let a=r[o];if(a!=null)if(Array.isArray(a)){let u=xr({allowReserved:n,explode:!0,name:o,style:"form",value:a,...e});u&&s.push(u)}else if(typeof a=="object"){let u=Cr({allowReserved:n,explode:!0,name:o,style:"deepObject",value:a,...t});u&&s.push(u)}else{let u=pt({allowReserved:n,name:o,value:a});u&&s.push(u)}}return s.join("&")},"querySerializer"),"createQuerySerializer"),pi=d(n=>{var e;if(!n)return"stream";let t=(e=n.split(";")[0])==null?void 0:e.trim();if(t){if(t.startsWith("application/json")||t.endsWith("+json"))return"json";if(t==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some(r=>t.startsWith(r)))return"blob";if(t.startsWith("text/"))return"text"}},"getParseAs"),di=d((n,e)=>{var t,r;return e?!!(n.headers.has(e)||(t=n.query)!=null&&t[e]||(r=n.headers.get("Cookie"))!=null&&r.includes(`${e}=`)):!1},"checkForExistence"),fi=d(async({security:n,...e})=>{for(let t of n){if(di(e,t.name))continue;let r=await li(t,e.auth);if(!r)continue;let s=t.name??"Authorization";switch(t.in){case"query":e.query||(e.query={}),e.query[s]=r;break;case"cookie":e.headers.append("Cookie",`${s}=${r}`);break;case"header":default:e.headers.set(s,r);break}}},"setAuthParams"),Sr=d(n=>ci({baseUrl:n.baseUrl,path:n.path,query:n.query,querySerializer:typeof n.querySerializer=="function"?n.querySerializer:Rr(n.querySerializer),url:n.url}),"buildUrl"),Er=d((n,e)=>{var t;let r={...n,...e};return(t=r.baseUrl)!=null&&t.endsWith("/")&&(r.baseUrl=r.baseUrl.substring(0,r.baseUrl.length-1)),r.headers=Ar(n.headers,e.headers),r},"mergeConfigs"),hi=d(n=>{let e=[];return n.forEach((t,r)=>{e.push([r,t])}),e},"headersEntries"),Ar=d((...n)=>{let e=new Headers;for(let t of n){if(!t)continue;let r=t instanceof Headers?hi(t):Object.entries(t);for(let[s,o]of r)if(o===null)e.delete(s);else if(Array.isArray(o))for(let a of o)e.append(s,a);else o!==void 0&&e.set(s,typeof o=="object"?JSON.stringify(o):o)}return e},"mergeHeaders"),Dr=class{static{i(this,"$")}constructor(){this.fns=[]}clear(){this.fns=[]}eject(e){let t=this.getInterceptorIndex(e);this.fns[t]&&(this.fns[t]=null)}exists(e){let t=this.getInterceptorIndex(e);return!!this.fns[t]}getInterceptorIndex(e){return typeof e=="number"?this.fns[e]?e:-1:this.fns.indexOf(e)}update(e,t){let r=this.getInterceptorIndex(e);return this.fns[r]?(this.fns[r]=t,e):!1}use(e){return this.fns.push(e),this.fns.length-1}};d(Dr,"Interceptors");var Yt=Dr,mi=d(()=>({error:new Yt,request:new Yt,response:new Yt}),"createInterceptors"),yi=Rr({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),vi={"Content-Type":"application/json"},lt=d((n={})=>({...ti,headers:vi,parseAs:"auto",querySerializer:yi,...n}),"createConfig"),Jt=d((n={})=>{let e=Er(lt(),n),t=d(()=>({...e}),"getConfig"),r=d(l=>(e=Er(e,l),t()),"setConfig"),s=mi(),o=d(async l=>{let p={...e,...l,fetch:l.fetch??e.fetch??globalThis.fetch,headers:Ar(e.headers,l.headers),serializedBody:void 0};p.security&&await fi({...p,security:p.security}),p.requestValidator&&await p.requestValidator(p),p.body!==void 0&&p.bodySerializer&&(p.serializedBody=p.bodySerializer(p.body)),(p.body===void 0||p.serializedBody==="")&&p.headers.delete("Content-Type");let f=Sr(p);return{opts:p,url:f}},"beforeRequest"),a=d(async l=>{let{opts:p,url:f}=await o(l),y={redirect:"follow",...p,body:kr(p)},h=new Request(f,y);for(let I of s.request.fns)I&&(h=await I(h,p));let b=p.fetch,g=await b(h);for(let I of s.response.fns)I&&(g=await I(g,h,p));let O={request:h,response:g};if(g.ok){let I=(p.parseAs==="auto"?pi(g.headers.get("Content-Type")):p.parseAs)??"json";if(g.status===204||g.headers.get("Content-Length")==="0"){let k;switch(I){case"arrayBuffer":case"blob":case"text":k=await g[I]();break;case"formData":k=new FormData;break;case"stream":k=g.body;break;case"json":default:k={};break}return p.responseStyle==="data"?k:{data:k,...O}}let V;switch(I){case"arrayBuffer":case"blob":case"formData":case"json":case"text":V=await g[I]();break;case"stream":return p.responseStyle==="data"?g.body:{data:g.body,...O}}return I==="json"&&(p.responseValidator&&await p.responseValidator(V),p.responseTransformer&&(V=await p.responseTransformer(V))),p.responseStyle==="data"?V:{data:V,...O}}let N=await g.text(),L;try{L=JSON.parse(N)}catch{}let G=L??N,T=G;for(let I of s.error.fns)I&&(T=await I(G,g,h,p));if(T=T||{},p.throwOnError)throw T;return p.responseStyle==="data"?void 0:{error:T,...O}},"request"),u=d(l=>p=>a({...p,method:l}),"makeMethodFn"),c=d(l=>async p=>{let{opts:f,url:y}=await o(p);return ri({...f,body:f.body,headers:f.headers,method:l,onRequest:d(async(h,b)=>{let g=new Request(h,b);for(let O of s.request.fns)O&&(g=await O(g,f));return g},"onRequest"),url:y})},"makeSseFn");return{buildUrl:Sr,connect:u("CONNECT"),delete:u("DELETE"),get:u("GET"),getConfig:t,head:u("HEAD"),interceptors:s,options:u("OPTIONS"),patch:u("PATCH"),post:u("POST"),put:u("PUT"),request:a,setConfig:r,sse:{connect:c("CONNECT"),delete:c("DELETE"),get:c("GET"),head:c("HEAD"),options:c("OPTIONS"),patch:c("PATCH"),post:c("POST"),put:c("PUT"),trace:c("TRACE")},trace:u("TRACE")}},"createClient"),R=Jt(lt({baseUrl:"https://swish.app/api/2026-01"})),gi=d(n=>(n?.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/lists",...n}),"listControllerFind"),wi=d(n=>(n.client??R).post({security:[{scheme:"bearer",type:"http"}],url:"/lists",...n,headers:{"Content-Type":"application/json",...n.headers}}),"listControllerCreate"),Ii=d(n=>(n.client??R).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...n}),"listControllerDeleteById"),bi=d(n=>(n.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...n}),"listControllerFindById"),Si=d(n=>(n.client??R).patch({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...n,headers:{"Content-Type":"application/json",...n.headers}}),"listControllerUpdateById"),Ei=d(n=>(n.client??R).put({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/order",...n,headers:{"Content-Type":"application/json",...n.headers}}),"listControllerSetListItemsOrder"),xi=d(n=>(n.client??R).post({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items",...n,headers:{"Content-Type":"application/json",...n.headers}}),"listControllerAddItemsToList"),Ci=d(n=>(n.client??R).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/{itemId}",...n}),"listControllerRemoveItemFromList"),ki=d(n=>(n.client??R).delete({security:[{scheme:"bearer",type:"http"}],url:"/items",...n,headers:{"Content-Type":"application/json",...n.headers}}),"itemControllerDelete"),Ri=d(n=>(n?.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/items",...n}),"itemControllerFind"),Ai=d(n=>(n.client??R).post({security:[{scheme:"bearer",type:"http"}],url:"/items",...n,headers:{"Content-Type":"application/json",...n.headers}}),"itemControllerCreate"),Di=d(n=>(n?.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/items/count",...n}),"itemControllerCount"),Pi=d(n=>(n.client??R).delete({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...n}),"itemControllerDeleteById"),Ti=d(n=>(n.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...n}),"itemControllerFindById"),_i=d(n=>(n.client??R).patch({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...n,headers:{"Content-Type":"application/json",...n.headers}}),"itemControllerUpdateById"),Oi=d(n=>(n.client??R).put({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}/lists",...n,headers:{"Content-Type":"application/json",...n.headers}}),"itemControllerSetListsById"),Li=d(n=>(n.client??R).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/identify",...n,headers:{"Content-Type":"application/json",...n.headers}}),"profileControllerIdentify"),$i=d(n=>(n.client??R).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/token",...n,headers:{"Content-Type":"application/json",...n.headers}}),"profileControllerCreateToken"),Vi=d(n=>(n?.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/profiles",...n}),"profileControllerGetProfile"),Mi=d(n=>(n.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/saved-items",...n}),"analyticsControllerLoadSavedItems"),qi=d(n=>(n.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/sessions",...n}),"analyticsControllerLoadSessions"),Ni=d(n=>(n.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/new-lists",...n}),"analyticsControllerLoadNewLists"),Bi=d(n=>(n.client??R).post({security:[{scheme:"bearer",type:"http"}],url:"/tracking",...n,headers:{"Content-Type":"application/json",...n.headers}}),"trackingControllerTrack"),Ui=d(n=>(n?.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/orders",...n}),"ordersControllerFind"),Fi=d(n=>(n.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/orders/{orderId}",...n}),"ordersControllerFindOne"),ji=d(n=>(n.client??R).post({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{listId}/save",...n}),"sharedListsControllerSave"),Gi=d(n=>(n.client??R).delete({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{listId}",...n}),"sharedListsControllerDeleteById"),Hi=d(n=>(n.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{listId}",...n}),"sharedListsControllerFindById"),Qi=d(n=>(n?.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists",...n}),"sharedListsControllerFindAll"),Zt="2026-01",Pr=d(n=>new zi(n),"createApiClient"),Tr=class{static{i(this,"H")}constructor(e){this.version=Zt,this.items={list:d(u=>this.handlePaginatedRequest(Ri({query:u,client:this.directClient})),"list"),create:d(u=>this.handleRequest(Ai({body:u,client:this.directClient})),"create"),delete:d(u=>this.handleRequest(ki({body:{itemIds:u},client:this.directClient})),"delete"),findById:d(u=>this.handleRequest(Ti({path:{itemId:u},client:this.directClient})),"findById"),updateById:d((u,c)=>this.handleRequest(_i({body:c,path:{itemId:u},client:this.directClient})),"updateById"),deleteById:d(u=>this.handleRequest(Pi({path:{itemId:u},client:this.directClient})),"deleteById"),setListsById:d((u,c)=>this.handleRequest(Oi({body:{listIds:c},path:{itemId:u},client:this.directClient})),"setListsById"),count:d(()=>this.handleRequest(Di({client:this.directClient})),"count")},this.lists={list:d(u=>this.handlePaginatedRequest(gi({query:u,client:this.directClient})),"list"),create:d(u=>this.handleRequest(wi({body:u,client:this.directClient})),"create"),findById:d(u=>this.handleRequest(bi({path:{listId:u},client:this.directClient})),"findById"),updateById:d((u,c)=>this.handleRequest(Si({body:c,path:{listId:u},client:this.directClient})),"updateById"),deleteById:d(u=>this.handleRequest(Ii({path:{listId:u},client:this.directClient})),"deleteById"),orderItems:d((u,c)=>this.handleRequest(Ei({body:{itemIds:c},path:{listId:u},client:this.directClient})),"orderItems"),addItemsToList:d((u,c)=>this.handleRequest(xi({body:{itemIds:c},path:{listId:u},client:this.directClient})),"addItemsToList"),removeItemFromList:d((u,c)=>this.handleRequest(Ci({path:{listId:u,itemId:c},client:this.directClient})),"removeItemFromList")},this.profiles={createToken:d((u={})=>this.handleRequest($i({body:u,client:this.proxyClient??this.directClient})),"createToken"),identify:d(u=>this.handleRequest(Li({body:u,client:this.directClient})),"identify"),getProfile:d(()=>this.handleRequest(Vi({client:this.directClient})),"getProfile")},this.orders={list:d(u=>this.handlePaginatedRequest(Ui({query:u,client:this.directClient})),"list"),findById:d(u=>this.handleRequest(Fi({path:{orderId:u},client:this.directClient})),"findById")},this.sharedLists={list:d(u=>this.handlePaginatedRequest(Qi({query:u,client:this.directClient})),"list"),save:d(u=>this.handleRequest(ji({path:{listId:u},client:this.directClient})),"save"),findById:d(u=>this.handleRequest(Hi({path:{listId:u},client:this.directClient})),"findById"),deleteById:d(u=>this.handleRequest(Gi({path:{listId:u},client:this.directClient})),"deleteById")},this.analytics={savedItems:d(u=>this.handleRequest(Mi({query:u,client:this.directClient})),"savedItems"),sessions:d(u=>this.handleRequest(qi({query:u,client:this.directClient})),"sessions"),newLists:d(u=>this.handleRequest(Ni({query:u,client:this.directClient})),"newLists")},this.tracking={track:d((u,c)=>this.handleRequest(Bi({body:u,headers:c,client:this.directClient})),"track")},this.handleRequest=d(async u=>{let{data:c,error:l}=await u;return l!=null&&l.error?{error:l.error}:{data:c?.data}},"handleRequest"),this.handlePaginatedRequest=d(async u=>{var c;let{data:l,error:p}=await u;return p!=null&&p.error?{error:p.error}:{data:l?.data??[],pageInfo:l?.pageInfo??{next:null,previous:null,totalCount:((c=l?.data)==null?void 0:c.length)??0}}},"handlePaginatedRequest");var t,r,s,o,a;(t=e.config)!=null&&t.version&&(this.version=e.config.version),this.directClient=Jt(lt({baseUrl:`https://swish.app/api/${this.version}`,...e.config})),(r=e.config)!=null&&r.authProxy&&(this.proxyClient=Jt(lt({...e.config,baseUrl:e.config.authProxy}))),e.authToken&&(this.authToken=e.authToken),e.requestInterceptor&&((s=this.proxyClient)==null||s.interceptors.request.use(e.requestInterceptor),this.directClient.interceptors.request.use(e.requestInterceptor)),e.responseInterceptor&&((o=this.proxyClient)==null||o.interceptors.response.use(e.responseInterceptor),this.directClient.interceptors.response.use(e.responseInterceptor)),(a=this.proxyClient)==null||a.interceptors.request.use(this.proxyRequestInterceptor.bind(this)),this.directClient.interceptors.request.use(this.directRequestInterceptor.bind(this))}setAuthToken(e){this.authToken=e}proxyRequestInterceptor(e){return this.version&&e.headers.set("Swish-Api-Version",this.version),e}directRequestInterceptor(e){return this.authToken&&e.headers.set("Authorization",`Bearer ${this.authToken}`),e}};d(Tr,"SwishClient");var zi=Tr;var $r=Qr(Lr(),1);var Vr=i(n=>new $r.default(async e=>{let t=[...new Set(e)].sort((s,o)=>s.localeCompare(o)),r=await n.items.list({query:t.join(" "),limit:200});return"error"in r?(console.error("Failed to load items",r.error),e.map(()=>({data:[],pageInfo:{next:null,previous:null,totalCount:0}}))):e.map(s=>{let o=r.data.find(a=>s===`variant:${a.variantId}`||s===`product:${a.productId}`);return{data:o?[o]:[],pageInfo:{next:null,previous:null,totalCount:o?1:0}}})},{batchScheduleFn:i(e=>setTimeout(e,50),"batchScheduleFn"),cache:!1,maxBatchSize:200}),"createItemsBatchLoader");var dt=class{constructor(e,t,r){this.tokenHasProfile=!1;this.api=e,this.context=t,this.eventBus=r}static{i(this,"SwishApiAuth")}hasProfile(){return this.tokenHasProfile}hasToken(){return!!this.getSwishToken()}async renewToken(){return this._renewPromise?this._renewPromise:(this._renewPromise=(async()=>{this._initPromise=void 0,this.deleteSwishToken(),await this.init(),this._renewPromise=void 0})(),this._renewPromise)}async init(){return this._initPromise?this._initPromise:(this._initPromise=(async()=>{this.migrateLegacySession();let e=this.context.customer.id;e?(this.hasSessionToken()&&await this.api.clearCache(),await this.initCustomer(e)):(this.hasCustomerToken()&&await this.resetSession(),await this.initSession()),this.eventBus.publish("token-update",null)})(),this._initPromise)}async initCustomer(e){let t=`gid://shopify/Customer/${e}`,r=this.getTokenBySub(t);if(r){this.initToken(r);return}let s=this.getSessionId();await this.acquireToken(s,t)}async initSession(){let e=this.getSessionId(),t=e?this.getTokenBySub(e):null;if(t){this.initToken(t);return}await this.acquireToken(e)}initToken(e){let t=this.getTokenData(e);if(!t)throw new Error("Invalid Swish token.");this.tokenHasProfile=t.has_profile!==!1,this.api.setAuthToken(e)}async acquireToken(e,t){let r=await this.api.profiles.createToken({customer:t,session:e});if("error"in r)throw console.error("Failed to create customer token",r.error),new Error("Failed to create customer token");if(!r.data?.token)throw console.error("Failed to create customer token empty response"),new Error("Failed to create customer token");r.data.profile.startsWith("gid://swish/Session/")&&this.setSessionId(r.data.profile),this.setSwishToken(r.data.token),this.initToken(r.data.token)}async resetSession(){this.deleteSessionId(),this.deleteSwishToken(),await this.api.clearCache()}getTokenData(e){try{return JSON.parse(atob(e.split(".")[1]))}catch(t){return console.error("Failed to parse Swish token",{cause:t}),null}}willTokenExpire(e,t=60){let r=this.getTokenData(e);return!!(r&&r.exp&&r.exp<Date.now()/1e3+t)}hasCustomerToken(){let e=this.getSwishToken();return e?this.getTokenData(e)?.sub?.startsWith("gid://shopify/Customer/")??!1:!1}hasSessionToken(){let e=this.getSwishToken();return e?this.getTokenData(e)?.sub?.startsWith("gid://swish/Session/")??!1:!1}getTokenBySub(e){if(!e)return null;let t=this.getSwishToken();if(!t)return null;let r=this.getTokenData(t);return!r||r.sub!==e||this.willTokenExpire(t,60)?null:t}getSessionId(){let e=H(this.context.myshopifyDomain);return localStorage.getItem(`swish-session-${e}`)??void 0}setSessionId(e){let t=H(this.context.myshopifyDomain);localStorage.setItem(`swish-session-${t}`,e)}deleteSessionId(){let e=H(this.context.myshopifyDomain);localStorage.removeItem(`swish-session-${e}`)}getSwishToken(){let e=H(this.context.myshopifyDomain);return sessionStorage.getItem(`swish-token-${e}`)??void 0}setSwishToken(e){let t=H(this.context.myshopifyDomain);sessionStorage.setItem(`swish-token-${t}`,e)}deleteSwishToken(){let e=H(this.context.myshopifyDomain);sessionStorage.removeItem(`swish-token-${e}`)}migrateLegacySession(){try{let e=localStorage.getItem("wk_session_id")??localStorage.getItem("swish-profile")?.split("/").pop()??localStorage.getItem("swish-session")?.split("/").pop();e&&(this.setSessionId(`gid://swish/Session/${e}`),localStorage.removeItem("wk_session_id"),localStorage.removeItem("swish-profile"),localStorage.removeItem("swish-session"))}catch(e){console.warn("Failed to migrate legacy session id to Swish session",{cause:e})}}};var ft=class{static{i(this,"SwishApi")}constructor(e,t,r,s){this.config=e,this.storefrontContext=t;let o=H(t.myshopifyDomain);this.cache=new Y(`swish-api-${o}`,"max-age=60, stale-while-revalidate=3600",s+(e.version??Zt)),this.cache.cleanupExpiredEntries().catch(a=>{console.warn("Swish API cache initialization cleanup error:",a)}),this.auth=new dt(this,t,r),this.apiClient=Pr({authToken:this.auth.getSwishToken(),config:{...e,fetch:this.fetchFunction.bind(this)},requestInterceptor:this.requestInterceptor.bind(this),responseInterceptor:this.responseInterceptor.bind(this)}),this.itemsLoader=Vr(this)}async fetchFunction(e,t){let r=e instanceof Request?e.method:t?.method??"GET",o=(e instanceof Request?e.url:typeof e=="string"?e:e.toString()).includes("/orders");return r==="GET"&&!o?this.cache.fetchWithCache(e,t):fetch(e,t)}async requestInterceptor(e){let t=new URL(e.url,window.location.origin);!!this.config.authProxy&&t.pathname.startsWith(this.config.authProxy)||await this.initAuth();try{e.headers.set("Country",this.storefrontContext.localization.country),e.headers.set("Language",this.storefrontContext.localization.language),e.headers.set("Market",this.storefrontContext.localization.market)}catch(s){console.warn("Failed to set storefront context headers:",s)}return this.config.requestInterceptor&&(e=await this.config.requestInterceptor(e)),e}async responseInterceptor(e,t){let r=t.method!=="GET",s=t.url.includes("/profiles/token");if(r&&!s){let o=this.auth.hasToken(),a=!this.auth.hasProfile(),u=e.ok;await this.cache.clear(),o&&a&&u&&await this.auth.renewToken()}return await this.config.responseInterceptor?.(e,t),e}setAuthToken(e){this.apiClient.setAuthToken(e)}initAuth(){return this.auth.init()}async withFallback(e,t){return await this.initAuth(),this.auth.hasProfile()?e():Promise.resolve(t)}get items(){return{...this.apiClient.items,count:i(async()=>this.withFallback(()=>this.apiClient.items.count(),{data:{count:0}}),"count"),list:i(async(e,t)=>{let r=i(()=>{if(t?.batch&&e?.query){e.limit!==1&&console.warn("Batching will always limit to 1 item");let s=e.query.split(" ");s.length>1&&console.warn("Batching will only support one query parameter");let o=s[0];if(!o.match(/^product:\d+$/)&&!o.match(/^variant:\d+$/))console.warn("Batching will only support product:<id> or variant:<id>");else return this.itemsLoader?.load(o)}return this.apiClient.items.list(e)},"execute");return t?.shared?r():this.withFallback(r,{data:[],pageInfo:{next:null,previous:null,totalCount:0}})},"list"),findById:i(async e=>this.withFallback(()=>this.apiClient.items.findById(e),{data:null}),"findById")}}get lists(){return{...this.apiClient.lists,list:i(async e=>this.withFallback(()=>this.apiClient.lists.list(e),{data:[],pageInfo:{next:null,previous:null,totalCount:0}}),"list"),findById:i(async(e,t)=>{let r=i(()=>this.apiClient.lists.findById(e),"execute");return t?.shared?r():this.withFallback(()=>this.apiClient.lists.findById(e),{data:null})},"findById")}}get orders(){return{...this.apiClient.orders,list:i(async e=>this.withFallback(()=>this.apiClient.orders.list(e),{data:[],pageInfo:{next:null,previous:null,totalCount:0}}),"list"),findById:i(async e=>this.withFallback(()=>(typeof e=="string"&&(e=parseInt(e.split("/").pop()??e)),this.apiClient.orders.findById(e)),{data:null}),"findById")}}get profiles(){return this.apiClient.profiles}async clearCache(){await this.cache.clear()}};var ht=class{constructor(e){this.eventMap={"POST /items\\/?$":"item-create","DELETE /items\\/?$":"item-delete","PATCH /items\\/([^/]+)\\/?$":"item-update","DELETE /items\\/([^/]+)\\/?$":"item-delete","PUT /items\\/([^/]+)\\/lists\\/?$":"item-lists-update","POST /lists\\/?$":"list-create","DELETE /lists\\/?$":"list-delete","PATCH /lists\\/([^/]+)\\/?$":"list-update","DELETE /lists\\/([^/]+)\\/?$":"list-delete"};this.eventBus=e,this.processFetchResponse=this.processFetchResponse.bind(this)}static{i(this,"SwishApiPublisher")}async processFetchResponse(e,t){try{let r=this.getEventName(t.method,e.status,t.url);if(!r)return;let s=await e.clone().text();if(e.headers.get("Content-Type")?.includes("application/json"))try{s=JSON.parse(s).data}catch(o){console.warn(o)}this.eventBus.publish(r,s)}catch(r){console.warn(r)}}getEventName(e,t,r){e=e.toUpperCase();let s=new URL(r).pathname;return e==="GET"||t<200||t>=300?void 0:Object.entries(this.eventMap).find(([a])=>{let[u,c]=a.split(" ");return u!==e?!1:new RegExp(c).test(s)})?.[1]}};var mt=class{constructor(e,t){this.inflightModals=new Map;this.modalsWithScrollLock=new Set;this.scrollLockRefCount=0;this.scrollPositionBeforeLock=0;this._templatePromises=new Map;this._importPromises=new Map;this._lockScroll=i(()=>this.lockScroll(),"_lockScroll");this._unlockScroll=i(()=>this.unlockScroll(),"_unlockScroll");this.swishUiOptions=e,this.storefrontContext=t}static{i(this,"SwishUi")}async hideModal(e){if(this.inflightModals.has(e))return this.inflightModals.get(e);let t=(async()=>{try{if(typeof e=="string"&&(e=await this.requireUiComponent(e)),!e||e.getAttribute("open")!=="true")return;e.setAttribute("open","false")}finally{e&&typeof e!="string"&&this.modalsWithScrollLock.has(e)&&(this.modalsWithScrollLock.delete(e),this.unlockScroll())}})().finally(()=>{this.inflightModals.delete(e)});return this.inflightModals.set(e,t),t}async showModal(e){if(this.inflightModals.has(e))return this.inflightModals.get(e);let t=(async()=>{typeof e=="string"&&(e=await this.requireUiComponent(e)),!(!e||e.getAttribute("open")==="true")&&(this.lockScroll(),this.modalsWithScrollLock.add(e),e.setAttribute("open","true"))})().finally(()=>{this.inflightModals.delete(e)});return this.inflightModals.set(e,t),t}waitForEvent(e,t){return new Promise(r=>{let s=[],o=i(()=>{s.forEach(({event:a,listener:u})=>{e.removeEventListener(a,u)})},"cleanup");Object.entries(t).forEach(([a,u])=>{let c=i(l=>{let p=u(l);o(),r(p)},"listener");s.push({event:a,listener:c}),e.addEventListener(a,c)})})}async showSignIn(e){let t=await this.requireUiComponent("sign-in");t.setAttribute("return-to",e?.returnTo??window.location.pathname),await this.showModal(t);let r=await this.waitForEvent(t,{close:i(()=>({code:"closed"}),"close")});return await this.hideModal(t),r}async showUnsaveAlert(e){if(!e.itemId)throw new Error("An itemId is required to show the unsave alert");await this.hideAllToasts();let t=await this.requireUiComponent("unsave-alert");t.setAttribute("item-id",e.itemId),await this.showModal(t);let r=await this.waitForEvent(t,{submit:i(s=>s instanceof CustomEvent?{code:"ok",data:s.detail}:(console.warn("Unsave alert submitted without detail",s),{code:"closed"}),"submit"),close:i(()=>({code:"closed"}),"close")});return await this.hideModal(t),r}async showDeleteListAlert(e){if(!e.listId)throw new Error("A listId is required to show the delete list alert");await this.hideAllToasts();let t=await this.requireUiComponent("delete-list-alert");t.setAttribute("list-id",e.listId),await this.showModal(t);let r=await this.waitForEvent(t,{submit:i(()=>({code:"ok",data:void 0}),"submit"),close:i(()=>({code:"closed"}),"close")});return await this.hideModal(t),r}async showConfirmDialog(e){await this.hideAllToasts();let t=await this.requireUiComponent("confirm-dialog");e.titleKey?t.setAttribute("title-key",e.titleKey):t.removeAttribute("title-key"),e.descriptionKey?t.setAttribute("description-key",e.descriptionKey):t.removeAttribute("description-key"),e.confirmLabelKey?t.setAttribute("confirm-label-key",e.confirmLabelKey):t.removeAttribute("confirm-label-key"),e.cancelLabelKey?t.setAttribute("cancel-label-key",e.cancelLabelKey):t.removeAttribute("cancel-label-key"),e.danger?t.setAttribute("danger",""):t.removeAttribute("danger"),await this.showModal(t);let r=await this.waitForEvent(t,{submit:i(()=>({code:"ok",data:void 0}),"submit"),close:i(()=>({code:"closed"}),"close")});return await this.hideModal(t),r}async showDrawer(e){await this.hideAllToasts();let t=await this.requireUiComponent("drawer");t.setAttribute("account-url",this.storefrontContext.routes.accountUrl),this.storefrontContext.customer.id&&t.setAttribute("customer-id",this.storefrontContext.customer.id),t.setAttribute("view",e?.view??"home"),e?.listId&&t.setAttribute("list-id",e.listId),e?.productId&&t.setAttribute("product-id",e.productId),e?.variantId&&t.setAttribute("variant-id",e.variantId),e?.orderId&&t.setAttribute("order-id",e.orderId),await this.showModal(t);let r=await this.waitForEvent(t,{close:i(()=>({code:"closed"}),"close")});return await this.hideModal(t),r}async showListMenu(e){if(!e.listId)throw new Error("listId is required");await this.hideAllToasts();let t=await this.requireUiComponent("list-menu");t.setAttribute("list-id",e.listId),await this.showModal(t);let r=await this.waitForEvent(t,{close:i(()=>({code:"closed"}),"close"),edit:i(s=>s instanceof CustomEvent?{code:"ok",data:{action:"edit",data:s.detail}}:(console.warn("List menu edit without detail",s),{code:"closed"}),"edit"),delete:i(()=>({code:"ok",data:{action:"delete"}}),"delete"),share:i(()=>({code:"ok",data:{action:"share"}}),"share"),"edit-access":i(s=>{if(s instanceof CustomEvent){let a=s.detail?.currentListAccess;if(a==="public"||a==="private")return{code:"ok",data:{action:"edit-access",data:{currentListAccess:a}}}}return{code:"ok",data:{action:"edit-access"}}},"edit-access")});return await this.hideModal(t),r}async showOrderMenu(e){if(!e.orderId)throw new Error("orderId is required");await this.hideAllToasts();let t=await this.requireUiComponent("order-menu");t.setAttribute("order-id",e.orderId),await this.showModal(t);let r=await this.waitForEvent(t,{close:i(()=>({code:"closed"}),"close")});return await this.hideModal(t),r}async showListDetailPageMenu(e){await this.hideAllToasts();let t=await this.requireUiComponent("list-detail-page-menu");t.setAttribute("list-id",e.listId),await this.showModal(t);let r=await this.waitForEvent(t,{close:i(()=>({code:"closed"}),"close")});return await this.hideModal(t),r}async showListSelect(e){if(!e.itemId)throw new Error("itemId is required");await this.hideAllToasts();let t=await this.requireUiComponent("list-select");t.setAttribute("item-id",e.itemId),await this.showModal(t);let r=await this.waitForEvent(t,{close:i(()=>({code:"closed"}),"close"),submit:i(s=>"detail"in s&&s.detail?{code:"ok",data:{action:"submit",data:s.detail}}:(console.warn("List select submit without detail",s),{code:"closed"}),"submit"),unsave:i(s=>s instanceof CustomEvent?{code:"ok",data:{action:"unsave",data:s.detail}}:(console.warn("List select unsave without detail",s),{code:"closed"}),"unsave")});return await this.hideModal(t),r}async initListDetailPage(e,t){let r=await this.requireUiComponent("list-detail-page",{refElement:t});e.listId&&r.setAttribute("list-id",e.listId)}async showToast(e){let t=Date.now(),r=await this.requireUiComponent("toast-manager",{onHydrated:i(s=>{s.current.show(e,t)},"onHydrated")});return this.waitForEvent(r,{[`close-${t}`]:()=>({code:"closed"}),[`submit-${t}`]:()=>({code:"ok",data:void 0})})}async hideAllToasts(){this.queryComponent("toast-manager")&&await this.requireUiComponent("toast-manager",{onHydrated:i(e=>{e.current.clear()},"onHydrated")})}async showVariantSelect(e){await this.hideAllToasts();let t=await this.requireUiComponent("variant-select");if(e?.itemId&&t.setAttribute("item-id",e.itemId),e?.productId)t.setAttribute("product-id",e.productId.toString());else if(e?.productHandle)t.setAttribute("product-handle",e.productHandle);else throw new Error("Either productId or productHandle must be provided");e?.variantId&&t.setAttribute("variant-id",e.variantId.toString()),await this.showModal(t);let r=await this.waitForEvent(t,{close:i(()=>({code:"closed"}),"close"),submit:i(s=>"detail"in s&&s.detail?{code:"ok",data:s.detail}:(console.warn("Variant select submit without detail",s),{code:"closed"}),"submit")});return await this.hideModal(t),r}async showQuickBuy(e){await this.hideAllToasts();let t=await this.requireUiComponent("quick-buy");if(e?.productId)t.setAttribute("product-id",e.productId.toString());else if(e?.productHandle)t.setAttribute("product-handle",e.productHandle);else throw new Error("ProductId or productHandle must be provided");e?.variantId&&t.setAttribute("variant-id",e.variantId.toString()),await this.showModal(t);let r=await this.waitForEvent(t,{close:i(()=>({code:"closed"}),"close"),submit:i(s=>"detail"in s&&s.detail?{code:"ok",data:s.detail}:(console.warn("Quick buy submit without detail",s),{code:"closed"}),"submit")});return await this.hideModal(t),r}async showListEditor(e){let t=await this.requireUiComponent("list-editor");e?.listId&&t.setAttribute("list-id",e.listId),await this.showModal(t);let r=await this.waitForEvent(t,{close:i(()=>({code:"closed"}),"close"),submit:i(s=>"detail"in s&&s.detail?{code:"ok",data:s.detail}:(console.warn("List editor submit without detail",s),{code:"closed"}),"submit")});return await this.hideModal(t),r}async createElement(e,t){let[r,{themeVariablesStylesheet:s}]=await Promise.all([this.loadTemplate(e),this.loadCricalResources()]),o=document.createElement("template");o.innerHTML=r.replace(' shadowrootmode="open"',"");let a=o.content.firstElementChild;return a.addEventListener("connected",()=>{a.shadowRoot&&(a.shadowRoot.adoptedStyleSheets=[s],this.hydrateElement(e,a,t?.onHydrated))},{once:!0}),a}async hydrateElement(e,t,r){if(t.hasAttribute("hydrated")){r?.(t.getComponentRef());return}await Promise.all([this.loadNonCriticalResources(),this.importScript(e)]).then(([{bundleCssStylesheet:s,customCssStylesheets:o},{hydrate:a}])=>{t.shadowRoot&&s&&(t.shadowRoot.adoptedStyleSheets=[...t.shadowRoot.adoptedStyleSheets,...o,s],t.shadowRoot?.querySelector(":host > style")?.remove()),a(t),t.setAttribute("hydrated","")}),r?.(t.getComponentRef())}async requireUiComponent(e,t){this.loadCricalResources();let r=await this.loadTemplate(e),s=this.queryComponent(e)??await this.insertComponent({name:e,template:r,refElement:t?.refElement??document.body,position:"beforeend"});return s.shadowRoot&&!s.hasAttribute("hydrated")?Promise.all([this.loadNonCriticalResources(),this.importScript(e)]).then(([{bundleCssStylesheet:o,customCssStylesheets:a},{hydrate:u}])=>{s.shadowRoot&&o&&(s.shadowRoot.adoptedStyleSheets=[...s.shadowRoot.adoptedStyleSheets,...a,o],s.shadowRoot?.querySelector(":host > style")?.remove()),u(s),s.setAttribute("hydrated",""),t?.onHydrated?.(s.getComponentRef())}):s.hasAttribute("hydrated")&&t?.onHydrated?.(s.getComponentRef()),s}async loadTemplate(e){let t=`${this.swishUiOptions.baseUrl}/ui@${this.swishUiOptions.version}/${e}.html`;if(this._templatePromises.has(t))return this._templatePromises.get(t);let r=fetch(t).then(s=>s.text());return this._templatePromises.set(t,r),r}async importScript(e){let t=`${this.swishUiOptions.baseUrl}/ui@${this.swishUiOptions.version}/${e}.js`;if(this._importPromises.has(t))return this._importPromises.get(t);let r=import(t);return this._importPromises.set(t,r),r}async loadCricalResources(){return this._loadCricalResourcesPromise?this._loadCricalResourcesPromise:(this._loadCricalResourcesPromise=(async()=>{let e=`${this.swishUiOptions.baseUrl}/ui@${this.swishUiOptions.version}/theme.css`,t=await fetch(e).then(o=>o.text()),r=new CSSStyleSheet;r.replaceSync(t);let s=ro(this.swishUiOptions.design);return Object.entries(s).forEach(([o,a])=>{r.cssRules[0].cssRules[0].style.setProperty(o,a)}),{themeVariablesStylesheet:r}})(),this._loadCricalResourcesPromise)}async loadNonCriticalResources(){return this._loadNonCriticalResourcesPromise?this._loadNonCriticalResourcesPromise:(this._loadNonCriticalResourcesPromise=(async()=>{let e=`${this.swishUiOptions.baseUrl}/ui@${this.swishUiOptions.version}/bundle.css`,t=i(o=>{let a=new CSSStyleSheet;return a.replaceSync(o),a},"createCssStylesheet"),[r,...s]=await Promise.all([fetch(e).then(o=>o.text()).then(t),...this.swishUiOptions.css.map(async o=>o instanceof URL?t(await fetch(o).then(a=>a.text())):t(o))]);return{bundleCssStylesheet:r,customCssStylesheets:s}})(),this._loadNonCriticalResourcesPromise)}async insertComponent({name:e,template:t,position:r,refElement:s}){let{themeVariablesStylesheet:o}=await this.loadCricalResources();s.insertAdjacentHTML(r,t.replace(' shadowrootmode="open"',""));let a=this.queryComponent(e);if(!a)throw new Error(`Element ${e} not found in DOM`);return a.shadowRoot&&(a.shadowRoot.adoptedStyleSheets=[o]),a}queryComponent(e,t){let r=`swish-ui[ref="${e}${t?`-${t}`:""}"]`;return document.querySelector(r)}lockScroll(){this.scrollLockRefCount++,this.scrollLockRefCount===1&&(this.scrollPositionBeforeLock=window.scrollY,this.scrollLockStyleSheet||(this.scrollLockStyleSheet=new CSSStyleSheet,document.adoptedStyleSheets=[...document.adoptedStyleSheets,this.scrollLockStyleSheet]),this.scrollLockStyleSheet.replaceSync(`
447
447
  html[swish-locked] body {
448
448
  overflow: hidden;
449
449
  position: fixed;
@@ -451,4 +451,4 @@ Values:
451
451
  left: 0px;
452
452
  right: 0px;
453
453
  }
454
- `),document.documentElement.setAttribute("swish-locked",""))}unlockScroll(){this.scrollLockRefCount>0&&this.scrollLockRefCount--,this.scrollLockRefCount===0&&(this.scrollLockStyleSheet&&this.scrollLockStyleSheet.replaceSync(""),window.scrollTo({top:this.scrollPositionBeforeLock,behavior:"instant"}),this.scrollPositionBeforeLock=0,document.documentElement.removeAttribute("swish-locked"))}};var gs=typeof HTMLElement<"u"?HTMLElement:class{},it=class extends gs{constructor(){super();this.getComponentRef=s(()=>this.componentRef,"getComponentRef");this.setComponentRef=s(t=>{this.componentRef=t},"setComponentRef");this.shadowRoot||this.attachShadow({mode:"open"});let t=this.querySelector("template");t&&this.shadowRoot&&(this.shadowRoot.appendChild(t.content),t.remove())}static{s(this,"SwishUiElement")}};var st=class{static{s(this,"ShopifyBadgesUtils")}#e;constructor({getBadges:e}){this.#e=e?.bind(this)}getBadges({product:e,variant:t}){try{let r=this.getDefaultBadges({product:e,variant:t});return this.#e?this.mapBadges(this.#e({product:e,variant:t,defaultBadges:r})??[]):this.mapBadges(r)}catch(r){return console.error("Error getting badges",r),[]}}getDefaultBadges({product:e,variant:t}){let r=[];if(e?.availableForSale===!1||t?.availableForSale===!1)return r.push("Sold out"),r;let i=t?t.price.amount:e?.priceRange?.minVariantPrice.amount,o=t?t.compareAtPrice?.amount:e?.compareAtPriceRange?.minVariantPrice.amount;return o&&parseFloat(o)>parseFloat(i)&&r.push("Sale"),r}mapBadges(e){return e.map(t=>typeof t=="string"?{id:t.toLowerCase().replace(/[^a-z0-9]/g,"_"),label:t}:t)}};var Fe="0.105.1",lp=`https://swish.app/cdn/sdk@${Fe}/swish.js`,cp=s(async n=>{if(typeof window>"u")throw new Error("Swish is not supported in this environment");if(window.swish)return window.swish;let e=tn(n),t=new Ht(e);return window.swish=t,document.dispatchEvent(new Event("swish-ready")),t.api.initAuth().then(()=>{typeof window.Shopify?.analytics?.publish=="function"&&window.Shopify.analytics.publish("swish-ready",{market:e.storefrontContext.localization.market,country:e.storefrontContext.localization.country,language:e.storefrontContext.localization.language,rootUrl:e.storefrontContext.routes.rootUrl})}),t},"createSwish"),Ht=class{constructor(e){this.dom={createElementLocator:ce,createQueryParamsObserver:ae};this.state={itemContext:cn(this),itemState:pn(this),itemCount:dn(this),swishQuery:fn(this),effect:H,signal:T,computed:G};this.swishOptions=e,this.events=new ye,this.swishBadges=new st({getBadges:this.swishOptions.badges?.getBadges}),this.swishApiPublisher=new nt(this.events);let t=[Fe,e.swishUi?.version].join("-");this.swishApi=new tt({...this.swishOptions.swishApi,responseInterceptor:this.swishApiPublisher.processFetchResponse},this.swishOptions.storefrontContext,this.events,t),this.ajaxApiPublisher=new me(this.events),this.ajaxApi=new he({storeDomain:this.swishOptions.storefrontApi.storeDomain,responseInterceptor:this.ajaxApiPublisher.processFetchResponse}),this.ajaxApi.patchFetch(),this.storefrontApi=new Ye(this.swishOptions.storefrontApi,this.swishOptions.storefrontContext,this.swishBadges,this.swishOptions.metafields),this.swishUi=new rt(this.swishOptions.swishUi,this.swishOptions.storefrontContext),this.events.subscribe(["cart-add","cart-update","cart-change","cart-clear"],()=>{this.ajaxApi.clearCache()}),customElements.get("swish-ui")||customElements.define("swish-ui",it),this.intents=new Ge(this,this.swishUi)}static{s(this,"SwishApp")}get options(){return this.swishOptions}get storefrontContext(){return this.swishOptions.storefrontContext}get badges(){return this.swishBadges}get api(){return this.swishApi}get storefront(){return this.storefrontApi}get ajax(){return this.ajaxApi}get shopUrl(){return`https://${this.swishOptions.storefrontApi.storeDomain}`}};export{Fe as VERSION,cp as createSwish,lp as swishSdkUrl};
454
+ `),document.documentElement.setAttribute("swish-locked",""))}unlockScroll(){this.scrollLockRefCount>0&&this.scrollLockRefCount--,this.scrollLockRefCount===0&&(this.scrollLockStyleSheet&&this.scrollLockStyleSheet.replaceSync(""),window.scrollTo({top:this.scrollPositionBeforeLock,behavior:"instant"}),this.scrollPositionBeforeLock=0,document.documentElement.removeAttribute("swish-locked"))}};function ro(n){if(!n)return{};let e={},t=i(r=>{Object.entries(r).forEach(([s,o])=>{if(o!=null){if(typeof o=="object"&&!Array.isArray(o)){t(o);return}if(typeof o=="string"||typeof o=="number"){let a=s.startsWith("--")?s:`--swish-theme-${so(s)}`;e[a]=io(s,o)}}})},"walk");return t(n),e}i(ro,"flattenDesignTokens");function so(n){return n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase()}i(so,"toKebabCase");function io(n,e){return typeof e=="number"&&!oo(n)?`${e}px`:String(e)}i(io,"formatDesignValue");function oo(n){let e=n.toLowerCase();return e.includes("fontweight")||e.includes("scale")||e.includes("letterspacing")||e.includes("lineheight")}i(oo,"isNonPxValue");var ao=typeof HTMLElement<"u"?HTMLElement:class{},yt=class extends ao{constructor(){super();this.getComponentRef=i(()=>this.componentRef,"getComponentRef");this.setComponentRef=i(t=>{this.componentRef=t},"setComponentRef");this.shadowRoot||this.attachShadow({mode:"open"});let t=this.querySelector("template");t&&this.shadowRoot&&(this.shadowRoot.appendChild(t.content),t.remove())}static{i(this,"SwishUiElement")}connectedCallback(){this.dispatchEvent(new CustomEvent("connected"))}};var vt=class{static{i(this,"ShopifyBadgesUtils")}#e;constructor({getBadges:e}){this.#e=e?.bind(this)}getBadges({product:e,variant:t}){try{let r=this.getDefaultBadges({product:e,variant:t});return this.#e?this.mapBadges(this.#e({product:e,variant:t,defaultBadges:r})??[]):this.mapBadges(r)}catch(r){return console.error("Error getting badges",r),[]}}getDefaultBadges({product:e,variant:t}){let r=[];if(e?.availableForSale===!1||t?.availableForSale===!1)return r.push("Sold out"),r;let s=t?t.price.amount:e?.priceRange?.minVariantPrice.amount,o=t?t.compareAtPrice?.amount:e?.compareAtPriceRange?.minVariantPrice.amount;return o&&parseFloat(o)>parseFloat(s)&&r.push("Sale"),r}mapBadges(e){return e.map(t=>typeof t=="string"?{id:t.toLowerCase().replace(/[^a-z0-9]/g,"_"),label:t}:t)}};var tt="0.107.0",qd=`https://swish.app/cdn/sdk@${tt}/swish.js`,Nd=i(async n=>{if(typeof window>"u")throw new Error("Swish is not supported in this environment");if(window.swish)return window.swish;let e=bn(n),t=new rn(e);return window.swish=t,document.dispatchEvent(new Event("swish-ready")),t.api.initAuth().then(()=>{typeof window.Shopify?.analytics?.publish=="function"&&window.Shopify.analytics.publish("swish-ready",{market:e.storefrontContext.localization.market,country:e.storefrontContext.localization.country,language:e.storefrontContext.localization.language,rootUrl:e.storefrontContext.routes.rootUrl})}),t},"createSwish"),rn=class{constructor(e){this.dom={createElementLocator:ie,createLocationObserver:le,createPlacement:i(e=>fn(this,e),"createPlacement")};this.ui={createElement:i((e,t)=>this.swishUi.createElement(e,t),"createElement")};this.utils={copyToClipboard:me,createShareUrl:i(e=>he(this,e),"createShareUrl")};this.state={itemContext:Dn(this),itemState:Pn(this),itemCount:Tn(this),swishQuery:_n(this),effect:Q,signal:$,computed:F};this.swishOptions=e,this.events=new Se,this.swishBadges=new vt({getBadges:this.swishOptions.badges?.getBadges}),this.swishApiPublisher=new ht(this.events);let t=[tt,e.swishUi?.version].join("-");this.swishApi=new ft({...this.swishOptions.swishApi,responseInterceptor:this.swishApiPublisher.processFetchResponse},this.swishOptions.storefrontContext,this.events,t),this.ajaxApiPublisher=new Ie(this.events),this.ajaxApi=new we({storeDomain:this.swishOptions.storefrontApi.storeDomain,responseInterceptor:this.ajaxApiPublisher.processFetchResponse}),this.ajaxApi.patchFetch(),this.storefrontApi=new ct(this.swishOptions.storefrontApi,this.swishOptions.storefrontContext,this.swishBadges,this.swishOptions.productOptions,this.swishOptions.metafields),this.swishUi=new mt(this.swishOptions.swishUi,this.swishOptions.storefrontContext),this.events.subscribe(["cart-add","cart-update","cart-change","cart-clear"],()=>{this.ajaxApi.clearCache()}),customElements.get("swish-ui")||customElements.define("swish-ui",yt),this.intents=new et(this,this.swishUi)}static{i(this,"SwishApp")}get options(){return this.swishOptions}get storefrontContext(){return this.swishOptions.storefrontContext}get badges(){return this.swishBadges}get api(){return this.swishApi}get storefront(){return this.storefrontApi}get ajax(){return this.ajaxApi}get shopUrl(){return`https://${this.swishOptions.storefrontApi.storeDomain}`}};export{tt as VERSION,he as buildShareListUrl,me as copyToClipboard,Nd as createSwish,qd as swishSdkUrl};