@swishapp/sdk 0.133.0 → 0.134.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.
package/dist/swish.js CHANGED
@@ -1,18 +1,18 @@
1
- var zo=Object.create;var Wn=Object.defineProperty;var Go=Object.getOwnPropertyDescriptor;var Wo=Object.getOwnPropertyNames;var Ko=Object.getPrototypeOf,Xo=Object.prototype.hasOwnProperty;var r=(e,t)=>Wn(e,"name",{value:t,configurable:!0});var Jo=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Yo=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Wo(t))!Xo.call(e,s)&&s!==n&&Wn(e,s,{get:()=>t[s],enumerable:!(i=Go(t,s))||i.enumerable});return e};var Zo=(e,t,n)=>(n=e!=null?zo(Ko(e)):{},Yo(t||!e||!e.__esModule?Wn(n,"default",{value:e,enumerable:!0}):n,e));var Oo=Jo((aS,Lo)=>{"use strict";var bd=(function(){function e(n,i){if(typeof n!="function")throw new TypeError("DataLoader must be constructed with a function which accepts "+("Array<key> and returns Promise<Array<value>>, but got: "+n+"."));this._batchLoadFn=n,this._maxBatchSize=Ed(i),this._batchScheduleFn=Cd(i),this._cacheKeyFn=Rd(i),this._cacheMap=kd(i),this._batch=null,this.name=Ad(i)}r(e,"DataLoader");var t=e.prototype;return t.load=r(function(i){if(i==null)throw new TypeError("The loader.load() function must be called with a value, "+("but got: "+String(i)+"."));var s=Sd(this),o=this._cacheMap,a;if(o){a=this._cacheKeyFn(i);var l=o.get(a);if(l){var c=s.cacheHits||(s.cacheHits=[]);return new Promise(function(u){c.push(function(){u(l)})})}}s.keys.push(i);var d=new Promise(function(u,p){s.callbacks.push({resolve:u,reject:p})});return o&&o.set(a,d),d},"load"),t.loadMany=r(function(i){if(!Do(i))throw new TypeError("The loader.loadMany() function must be called with Array<key> "+("but got: "+i+"."));for(var s=[],o=0;o<i.length;o++)s.push(this.load(i[o]).catch(function(a){return a}));return Promise.all(s)},"loadMany"),t.clear=r(function(i){var s=this._cacheMap;if(s){var o=this._cacheKeyFn(i);s.delete(o)}return this},"clear"),t.clearAll=r(function(){var i=this._cacheMap;return i&&i.clear(),this},"clearAll"),t.prime=r(function(i,s){var o=this._cacheMap;if(o){var a=this._cacheKeyFn(i);if(o.get(a)===void 0){var l;s instanceof Error?(l=Promise.reject(s),l.catch(function(){})):l=Promise.resolve(s),o.set(a,l)}}return this},"prime"),e})(),Id=typeof process=="object"&&typeof process.nextTick=="function"?function(e){Ki||(Ki=Promise.resolve()),Ki.then(function(){process.nextTick(e)})}:typeof setImmediate=="function"?function(e){setImmediate(e)}:function(e){setTimeout(e)},Ki;function Sd(e){var t=e._batch;if(t!==null&&!t.hasDispatched&&t.keys.length<e._maxBatchSize)return t;var n={hasDispatched:!1,keys:[],callbacks:[]};return e._batch=n,e._batchScheduleFn(function(){xd(e,n)}),n}r(Sd,"getCurrentBatch");function xd(e,t){if(t.hasDispatched=!0,t.keys.length===0){Ji(t);return}var n;try{n=e._batchLoadFn(t.keys)}catch(i){return Xi(e,t,new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function "+("errored synchronously: "+String(i)+".")))}if(!n||typeof n.then!="function")return Xi(e,t,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(n)+".")));n.then(function(i){if(!Do(i))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(i)+"."));if(i.length!==t.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 ma=Object.create;var Yn=Object.defineProperty;var ya=Object.getOwnPropertyDescriptor;var va=Object.getOwnPropertyNames;var ga=Object.getPrototypeOf,wa=Object.prototype.hasOwnProperty;var r=(e,t)=>Yn(e,"name",{value:t,configurable:!0});var ba=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ia=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of va(t))!wa.call(e,s)&&s!==n&&Yn(e,s,{get:()=>t[s],enumerable:!(i=ya(t,s))||i.enumerable});return e};var Sa=(e,t,n)=>(n=e!=null?ma(ga(e)):{},Ia(t||!e||!e.__esModule?Yn(n,"default",{value:e,enumerable:!0}):n,e));var ta=ba((ix,ea)=>{"use strict";var tp=(function(){function e(n,i){if(typeof n!="function")throw new TypeError("DataLoader must be constructed with a function which accepts "+("Array<key> and returns Promise<Array<value>>, but got: "+n+"."));this._batchLoadFn=n,this._maxBatchSize=rp(i),this._batchScheduleFn=op(i),this._cacheKeyFn=ap(i),this._cacheMap=lp(i),this._batch=null,this.name=cp(i)}r(e,"DataLoader");var t=e.prototype;return t.load=r(function(i){if(i==null)throw new TypeError("The loader.load() function must be called with a value, "+("but got: "+String(i)+"."));var s=ip(this),o=this._cacheMap,a;if(o){a=this._cacheKeyFn(i);var l=o.get(a);if(l){var c=s.cacheHits||(s.cacheHits=[]);return new Promise(function(u){c.push(function(){u(l)})})}}s.keys.push(i);var d=new Promise(function(u,p){s.callbacks.push({resolve:u,reject:p})});return o&&o.set(a,d),d},"load"),t.loadMany=r(function(i){if(!Zo(i))throw new TypeError("The loader.loadMany() function must be called with Array<key> "+("but got: "+i+"."));for(var s=[],o=0;o<i.length;o++)s.push(this.load(i[o]).catch(function(a){return a}));return Promise.all(s)},"loadMany"),t.clear=r(function(i){var s=this._cacheMap;if(s){var o=this._cacheKeyFn(i);s.delete(o)}return this},"clear"),t.clearAll=r(function(){var i=this._cacheMap;return i&&i.clear(),this},"clearAll"),t.prime=r(function(i,s){var o=this._cacheMap;if(o){var a=this._cacheKeyFn(i);if(o.get(a)===void 0){var l;s instanceof Error?(l=Promise.reject(s),l.catch(function(){})):l=Promise.resolve(s),o.set(a,l)}}return this},"prime"),e})(),np=typeof process=="object"&&typeof process.nextTick=="function"?function(e){ss||(ss=Promise.resolve()),ss.then(function(){process.nextTick(e)})}:typeof setImmediate=="function"?function(e){setImmediate(e)}:function(e){setTimeout(e)},ss;function ip(e){var t=e._batch;if(t!==null&&!t.hasDispatched&&t.keys.length<e._maxBatchSize)return t;var n={hasDispatched:!1,keys:[],callbacks:[]};return e._batch=n,e._batchScheduleFn(function(){sp(e,n)}),n}r(ip,"getCurrentBatch");function sp(e,t){if(t.hasDispatched=!0,t.keys.length===0){os(t);return}var n;try{n=e._batchLoadFn(t.keys)}catch(i){return rs(e,t,new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function "+("errored synchronously: "+String(i)+".")))}if(!n||typeof n.then!="function")return rs(e,t,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(n)+".")));n.then(function(i){if(!Zo(i))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(i)+"."));if(i.length!==t.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(t.keys))+(`
5
5
 
6
6
  Values:
7
- `+String(i)));Ji(t);for(var s=0;s<t.callbacks.length;s++){var o=i[s];o instanceof Error?t.callbacks[s].reject(o):t.callbacks[s].resolve(o)}}).catch(function(i){Xi(e,t,i)})}r(xd,"dispatchBatch");function Xi(e,t,n){Ji(t);for(var i=0;i<t.keys.length;i++)e.clear(t.keys[i]),t.callbacks[i].reject(n)}r(Xi,"failedDispatch");function Ji(e){if(e.cacheHits)for(var t=0;t<e.cacheHits.length;t++)e.cacheHits[t]()}r(Ji,"resolveCacheHits");function Ed(e){var t=!e||e.batch!==!1;if(!t)return 1;var n=e&&e.maxBatchSize;if(n===void 0)return 1/0;if(typeof n!="number"||n<1)throw new TypeError("maxBatchSize must be a positive number: "+n);return n}r(Ed,"getValidMaxBatchSize");function Cd(e){var t=e&&e.batchScheduleFn;if(t===void 0)return Id;if(typeof t!="function")throw new TypeError("batchScheduleFn must be a function: "+t);return t}r(Cd,"getValidBatchScheduleFn");function Rd(e){var t=e&&e.cacheKeyFn;if(t===void 0)return function(n){return n};if(typeof t!="function")throw new TypeError("cacheKeyFn must be a function: "+t);return t}r(Rd,"getValidCacheKeyFn");function kd(e){var t=!e||e.cache!==!1;if(!t)return null;var n=e&&e.cacheMap;if(n===void 0)return new Map;if(n!==null){var i=["get","set","delete","clear"],s=i.filter(function(o){return n&&typeof n[o]!="function"});if(s.length!==0)throw new TypeError("Custom cacheMap missing methods: "+s.join(", "))}return n}r(kd,"getValidCacheMap");function Ad(e){return e&&e.name?e.name:null}r(Ad,"getValidName");function Do(e){return typeof e=="object"&&e!==null&&typeof e.length=="number"&&(e.length===0||e.length>0&&Object.prototype.hasOwnProperty.call(e,e.length-1))}r(Do,"isArrayLike");Lo.exports=bd});function rs(e,t="",n=new Map){for(let[i,s]of Object.entries(e)){let o=t?`${t}.${i}`:i;typeof s=="object"&&s!==null?rs(s,o,n):typeof s=="string"&&n.set(o,s)}return n}r(rs,"c");var ea=new Set(["en"]),at="en";function os(e,t){return t?.count===void 0?e:t.count===1?`${e}One`:`${e}Other`}r(os,"d");function ss(e,t,n){t=os(t,n);let i=e.get(t)??t;return n&&(n.count!==void 0&&(i=i.replace("{{count}}",n.count.toString())),Object.entries(n).forEach(([s,o])=>{s!=="count"&&typeof o=="string"&&(i=i.replace(`{{${s}}}`,o))})),i}r(ss,"f");function as(e,t){let n=null;async function i(o){let a=await import(`${e}/locales/${o.toLowerCase()}.js`);return rs(a.default)}r(i,"a");function s(o,a){return n?n.has(os(o,a))?{status:"ready",value:ss(n,o,a),key:o}:{status:"missing",value:ss(n,o,a),key:o}:{status:"pending",value:o,key:o}}return r(s,"r"),{t(o,a){return s(o,a).value},resolveTranslation:s,async loadLocale(o){let a=o;ea.has(o)||(console.warn(`[swish] Unsupported language "${o}", falling back to "${at}".`),a=at);let l;try{l=await i(a)}catch(c){if(console.warn(`[swish-i18n] Failed to load locale "${a}".`,c),a!==at)try{l=await i(at)}catch{console.warn(`[swish] Failed to load fallback locale "${at}".`);return}else return}if(t?.[a])for(let[c,d]of Object.entries(t[a]))d!==void 0&&l.set(c,d);n=l}}}r(as,"L");var N=r(e=>e.split("/").pop()??"","shopifyGidToId"),Le=r((e,t)=>`gid://shopify/${e}/${t}`,"shopifyIdToGid"),me=r(e=>e.toLowerCase().replace(".myshopify.com",""),"toShopName");var Oe=class{constructor(t,n,i=""){this.revalidationPromises=new Map;this.inFlightRequests=new Map;this.clearCachePromise=null;this.cacheName=t,this.defaultCacheControl=n,this.keyPrefix=i}static{r(this,"FetchCache")}async get(t){try{let n=await caches.open(this.cacheName),i=await n.match(t);if(i&&this.isExpired(i)){await n.delete(t);return}return i}catch(n){console.warn("Cache get error:",n);return}}async set(t,n,i){try{if(i?.includes("no-cache"))return;let s=this.createCacheableResponse(n,i);await(await caches.open(this.cacheName)).put(t,s)}catch(s){console.warn("Cache set error:",s)}}async fetchWithCache(t,n,i){let s=await this.getCacheKey(t,n);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,t,n,i),a.clone();let l=await fetch(t,n);return l.ok&&await this.set(s,l.clone(),i??this.defaultCacheControl),l})().finally(()=>{this.inFlightRequests.delete(s)});return this.inFlightRequests.set(s,o),o}async delete(t){try{return await(await caches.open(this.cacheName)).delete(t)}catch(n){return console.warn("Cache delete error:",n),!1}}async clear(){return this.clearCachePromise?this.clearCachePromise:(this.clearCachePromise=new Promise(async(t,n)=>{try{let i=await caches.open(this.cacheName),s=await i.keys();await Promise.all(s.map(o=>i.delete(o))),t()}catch(i){console.warn("Cache clear error:",i),n(i)}}),this.clearCachePromise.then(()=>{this.clearCachePromise=null}).catch(t=>{console.warn("Cache clear error:",t)}))}async keys(){try{return(await(await caches.open(this.cacheName)).keys()).map(i=>i.url)}catch(t){return console.warn("Cache keys error:",t),[]}}async has(t){try{let n=await caches.open(this.cacheName),i=await n.match(t);return i&&this.isExpired(i)?(await n.delete(t),!1):i!==void 0}catch(n){return console.warn("Cache has error:",n),!1}}async getStats(){try{return{total:(await(await caches.open(this.cacheName)).keys()).length}}catch(t){return console.warn("Cache stats error:",t),{total:0}}}async cleanupExpiredEntries(){try{let t=await caches.open(this.cacheName),n=await t.keys(),i=0;for(let o of n){let a=await t.match(o);a&&this.isExpired(a)&&(await t.delete(o),i++)}let s=n.length-i;return{removed:i,remaining:s}}catch(t){return console.warn("Cache cleanup error:",t),{removed:0,remaining:0}}}async getCacheKey(t,n){let i=this.getInputUrl(t),s=`${this.keyPrefix}${i}/${JSON.stringify(n)}`,a=new TextEncoder().encode(s),l=await crypto.subtle.digest("SHA-256",a);return`/${Array.from(new Uint8Array(l)).map(u=>u.toString(16).padStart(2,"0")).join("")}`}getInputUrl(t){return t instanceof URL?t.toString():typeof t=="string"?t:t.url}isExpired(t){let n=t.headers.get("Cache-Control");if(!n)return!1;let i=this.parseMaxAge(n),s=this.parseStaleWhileRevalidate(n);if(i===null)return!1;let o=t.headers.get("Date");if(!o)return!1;let a=new Date(o).getTime(),c=(Date.now()-a)/1e3,d=i+(s??0);return c>d}isStaleButRevalidatable(t){let n=t.headers.get("Cache-Control");if(!n)return!1;let i=this.parseMaxAge(n),s=this.parseStaleWhileRevalidate(n);if(i===null||s===null)return!1;let o=t.headers.get("Date");if(!o)return!1;let a=new Date(o).getTime(),c=(Date.now()-a)/1e3;return c>i&&c<=i+s}async revalidateInBackground(t,n,i,s){if(this.revalidationPromises.has(t))return;let o=(async()=>{try{let a=await fetch(n,i);a.ok&&await this.set(t,a.clone(),s??this.defaultCacheControl)}catch(a){console.warn("Background revalidation error:",a)}finally{this.revalidationPromises.delete(t)}})();this.revalidationPromises.set(t,o)}parseMaxAge(t){let n=new RegExp(/max-age=(\d+)/).exec(t);return n?parseInt(n[1],10):null}parseStaleWhileRevalidate(t){let n=new RegExp(/stale-while-revalidate=(\d+)/).exec(t);return n?parseInt(n[1],10):null}createCacheableResponse(t,n){let i=new Headers(t.headers);return i.set("Cache-Control",n),i.has("Date")||i.set("Date",new Date().toUTCString()),new Response(t.body,{status:t.status,statusText:t.statusText,headers:i})}};var At=class{static{r(this,"AjaxApiClient")}constructor(t){this.config=t;let n=me(t.storeDomain);this.cache=new Oe(`ajax-api-${n}`,"max-age=60, stale-while-revalidate=3600"),this.cache.cleanupExpiredEntries().catch(i=>{console.warn("Ajax API cache initialization cleanup error:",i)})}patchFetch(){if(!window.fetch||typeof window.fetch!="function")return;let t=window.fetch,n=this.config.responseInterceptor,i=this.getFetchRequest.bind(this);window.fetch=function(...s){let o=t.apply(this,s);if(typeof n=="function"){let a=i(s[0]);o.then(l=>n(l,a))}return o}}getFetchRequest(t){return t instanceof Request?t:new Request(t)}fetch(t,n){return(t instanceof Request?t.method:n?.method??"GET")==="GET"?this.cache.fetchWithCache(t,n):fetch(t,n)}async request(t,n={}){let i=`${window.location.origin}${t}`,s={"Content-Type":"application/json",Accept:"application/json"},o=await this.fetch(i,{...n,headers:{...s,...n.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(t){let n={...t,items:t.items.map(i=>{let s=Number(N(String(i.id)));if(!Number.isFinite(s)||s<=0)throw new Error(`Invalid Shopify ID: ${i.id}`);return{...i,id:s}})};return this.request("/cart/add.js",{method:"POST",body:JSON.stringify(n)})}async clearCache(){await this.cache.clear()}};var Pt=class{constructor(t){this.eventMap={"/cart/add":"cart-add","/cart/update":"cart-update","/cart/change":"cart-change","/cart/clear":"cart-clear"};this.previousCart=null;this.eventBus=t,this.processFetchResponse=this.processFetchResponse.bind(this)}static{r(this,"AjaxApiPublisher")}async processFetchResponse(t,n){try{let i=this.getEventName(n.url);if(!(i||n.url.includes("/cart.js")))return;let o=await t.clone().json();if(i==="cart-update"&&!o.items_removed){let a=this.diffRemovedItems(o);this.snapshotCart(o),this.eventBus.publish(i,{...o,items_removed:a})}else this.snapshotCart(o),i&&this.eventBus.publish(i,o)}catch(i){console.warn(i)}}getEventName(t){for(let[n,i]of Object.entries(this.eventMap))if(t.includes(n))return i;return null}snapshotCart(t){typeof t=="object"&&t!==null&&"token"in t&&"items"in t&&(this.previousCart=t)}diffRemovedItems(t){let n=this.previousCart;if(!n)return[];let i=new Set(t.items.map(o=>o.key)),s=[];for(let o of n.items)i.has(o.key)||s.push(this.toCartChangeItem(o));return s}toCartChangeItem(t){return{product_id:t.product_id,variant_id:t.variant_id,id:String(t.id),image:t.image,price:String(t.price),presentment_price:t.price,quantity:t.quantity,title:t.title,product_title:t.product_title,variant_title:t.variant_title,vendor:t.vendor,product_type:t.product_type,sku:t.sku,url:t.url,untranslated_product_title:t.product_title,untranslated_variant_title:t.variant_title,view_key:""}}};var lt=Math.min,Be=Math.max,ct=Math.round,ut=Math.floor,be=r(e=>({x:e,y:e}),"createCoords");function Kn(e,t){return typeof e=="function"?e(t):e}r(Kn,"evaluate");function Xn(e){return e.split("-")[0]}r(Xn,"getSide");function Jn(e){return e.split("-")[1]}r(Jn,"getAlignment");function cs(e){return e==="x"?"y":"x"}r(cs,"getOppositeAxis");function us(e){return e==="y"?"height":"width"}r(us,"getAxisLength");function Tt(e){let t=e[0];return t==="t"||t==="b"?"y":"x"}r(Tt,"getSideAxis");function ds(e){return cs(Tt(e))}r(ds,"getAlignmentAxis");function ta(e){return{top:0,right:0,bottom:0,left:0,...e}}r(ta,"expandPaddingObject");function ps(e){return typeof e!="number"?ta(e):{top:e,right:e,bottom:e,left:e}}r(ps,"getPaddingObject");function je(e){let{x:t,y:n,width:i,height:s}=e;return{width:i,height:s,top:n,left:t,right:t+i,bottom:n+s,x:t,y:n}}r(je,"rectToClientRect");function hs(e,t,n){let{reference:i,floating:s}=e,o=Tt(t),a=ds(t),l=us(a),c=Xn(t),d=o==="y",u=i.x+i.width/2-s.width/2,p=i.y+i.height/2-s.height/2,f=i[l]/2-s[l]/2,h;switch(c){case"top":h={x:u,y:i.y-s.height};break;case"bottom":h={x:u,y:i.y+i.height};break;case"right":h={x:i.x+i.width,y:p};break;case"left":h={x:i.x-s.width,y:p};break;default:h={x:i.x,y:i.y}}switch(Jn(t)){case"start":h[a]-=f*(n&&d?-1:1);break;case"end":h[a]+=f*(n&&d?-1:1);break}return h}r(hs,"computeCoordsFromPlacement");async function fs(e,t){var n;t===void 0&&(t={});let{x:i,y:s,platform:o,rects:a,elements:l,strategy:c}=e,{boundary:d="clippingAncestors",rootBoundary:u="viewport",elementContext:p="floating",altBoundary:f=!1,padding:h=0}=Kn(t,e),w=ps(h),b=l[f?p==="floating"?"reference":"floating":p],S=je(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(b)))==null||n?b:b.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(l.floating)),boundary:d,rootBoundary:u,strategy:c})),k=p==="floating"?{x:i,y:s,width:a.floating.width,height:a.floating.height}:a.reference,P=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l.floating)),D=await(o.isElement==null?void 0:o.isElement(P))?await(o.getScale==null?void 0:o.getScale(P))||{x:1,y:1}:{x:1,y:1},E=je(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:k,offsetParent:P,strategy:c}):k);return{top:(S.top-E.top+w.top)/D.y,bottom:(E.bottom-S.bottom+w.bottom)/D.y,left:(S.left-E.left+w.left)/D.x,right:(E.right-S.right+w.right)/D.x}}r(fs,"detectOverflow");var na=50,ms=r(async(e,t,n)=>{let{placement:i="bottom",strategy:s="absolute",middleware:o=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:fs},c=await(a.isRTL==null?void 0:a.isRTL(t)),d=await a.getElementRects({reference:e,floating:t,strategy:s}),{x:u,y:p}=hs(d,i,c),f=i,h=0,w={};for(let m=0;m<o.length;m++){let b=o[m];if(!b)continue;let{name:S,fn:k}=b,{x:P,y:D,data:E,reset:A}=await k({x:u,y:p,initialPlacement:i,placement:f,strategy:s,middlewareData:w,rects:d,platform:l,elements:{reference:e,floating:t}});u=P??u,p=D??p,w[S]={...w[S],...E},A&&h<na&&(h++,typeof A=="object"&&(A.placement&&(f=A.placement),A.rects&&(d=A.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:s}):A.rects),{x:u,y:p}=hs(d,f,c)),m=-1)}return{x:u,y:p,placement:f,strategy:s,middlewareData:w}},"computePosition");var ia=new Set(["left","top"]);async function sa(e,t){let{placement:n,platform:i,elements:s}=e,o=await(i.isRTL==null?void 0:i.isRTL(s.floating)),a=Xn(n),l=Jn(n),c=Tt(n)==="y",d=ia.has(a)?-1:1,u=o&&c?-1:1,p=Kn(t,e),{mainAxis:f,crossAxis:h,alignmentAxis:w}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return l&&typeof w=="number"&&(h=l==="end"?w*-1:w),c?{x:h*u,y:f*d}:{x:f*d,y:h*u}}r(sa,"convertValueToCoords");var ys=r(function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,i;let{x:s,y:o,placement:a,middlewareData:l}=t,c=await sa(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(i=l.arrow)!=null&&i.alignmentOffset?{}:{x:s+c.x,y:o+c.y,data:{...c,placement:a}}}}},"offset");function Dt(){return typeof window<"u"}r(Dt,"hasWindow");function Ue(e){return gs(e)?(e.nodeName||"").toLowerCase():"#document"}r(Ue,"getNodeName");function ue(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}r(ue,"getWindow");function Ie(e){var t;return(t=(gs(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}r(Ie,"getDocumentElement");function gs(e){return Dt()?e instanceof Node||e instanceof ue(e).Node:!1}r(gs,"isNode");function ve(e){return Dt()?e instanceof Element||e instanceof ue(e).Element:!1}r(ve,"isElement");function Re(e){return Dt()?e instanceof HTMLElement||e instanceof ue(e).HTMLElement:!1}r(Re,"isHTMLElement");function vs(e){return!Dt()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ue(e).ShadowRoot}r(vs,"isShadowRoot");function Je(e){let{overflow:t,overflowX:n,overflowY:i,display:s}=ge(e);return/auto|scroll|overlay|hidden|clip/.test(t+i+n)&&s!=="inline"&&s!=="contents"}r(Je,"isOverflowElement");function ws(e){return/^(table|td|th)$/.test(Ue(e))}r(ws,"isTableElement");function dt(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}r(dt,"isTopLayer");var ra=/transform|translate|scale|rotate|perspective|filter/,oa=/paint|layout|strict|content/,Ne=r(e=>!!e&&e!=="none","isNotNone"),Yn;function Lt(e){let t=ve(e)?ge(e):e;return Ne(t.transform)||Ne(t.translate)||Ne(t.scale)||Ne(t.rotate)||Ne(t.perspective)||!Ot()&&(Ne(t.backdropFilter)||Ne(t.filter))||ra.test(t.willChange||"")||oa.test(t.contain||"")}r(Lt,"isContainingBlock");function bs(e){let t=_e(e);for(;Re(t)&&!Ve(t);){if(Lt(t))return t;if(dt(t))return null;t=_e(t)}return null}r(bs,"getContainingBlock");function Ot(){return Yn==null&&(Yn=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Yn}r(Ot,"isWebKit");function Ve(e){return/^(html|body|#document)$/.test(Ue(e))}r(Ve,"isLastTraversableNode");function ge(e){return ue(e).getComputedStyle(e)}r(ge,"getComputedStyle");function pt(e){return ve(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}r(pt,"getNodeScroll");function _e(e){if(Ue(e)==="html")return e;let t=e.assignedSlot||e.parentNode||vs(e)&&e.host||Ie(e);return vs(t)?t.host:t}r(_e,"getParentNode");function Is(e){let t=_e(e);return Ve(t)?e.ownerDocument?e.ownerDocument.body:e.body:Re(t)&&Je(t)?t:Is(t)}r(Is,"getNearestOverflowAncestor");function Xe(e,t,n){var i;t===void 0&&(t=[]),n===void 0&&(n=!0);let s=Is(e),o=s===((i=e.ownerDocument)==null?void 0:i.body),a=ue(s);if(o){let l=_t(a);return t.concat(a,a.visualViewport||[],Je(s)?s:[],l&&n?Xe(l):[])}else return t.concat(s,Xe(s,[],n))}r(Xe,"getOverflowAncestors");function _t(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}r(_t,"getFrameElement");function Cs(e){let t=ge(e),n=parseFloat(t.width)||0,i=parseFloat(t.height)||0,s=Re(e),o=s?e.offsetWidth:n,a=s?e.offsetHeight:i,l=ct(n)!==o||ct(i)!==a;return l&&(n=o,i=a),{width:n,height:i,$:l}}r(Cs,"getCssDimensions");function ei(e){return ve(e)?e:e.contextElement}r(ei,"unwrapElement");function Ye(e){let t=ei(e);if(!Re(t))return be(1);let n=t.getBoundingClientRect(),{width:i,height:s,$:o}=Cs(t),a=(o?ct(n.width):n.width)/i,l=(o?ct(n.height):n.height)/s;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}r(Ye,"getScale");var aa=be(0);function Rs(e){let t=ue(e);return!Ot()||!t.visualViewport?aa:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}r(Rs,"getVisualOffsets");function la(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ue(e)?!1:t}r(la,"shouldAddVisualOffsets");function $e(e,t,n,i){t===void 0&&(t=!1),n===void 0&&(n=!1);let s=e.getBoundingClientRect(),o=ei(e),a=be(1);t&&(i?ve(i)&&(a=Ye(i)):a=Ye(e));let l=la(o,n,i)?Rs(o):be(0),c=(s.left+l.x)/a.x,d=(s.top+l.y)/a.y,u=s.width/a.x,p=s.height/a.y;if(o){let f=ue(o),h=i&&ve(i)?ue(i):i,w=f,m=_t(w);for(;m&&i&&h!==w;){let b=Ye(m),S=m.getBoundingClientRect(),k=ge(m),P=S.left+(m.clientLeft+parseFloat(k.paddingLeft))*b.x,D=S.top+(m.clientTop+parseFloat(k.paddingTop))*b.y;c*=b.x,d*=b.y,u*=b.x,p*=b.y,c+=P,d+=D,w=ue(m),m=_t(w)}}return je({width:u,height:p,x:c,y:d})}r($e,"getBoundingClientRect");function Mt(e,t){let n=pt(e).scrollLeft;return t?t.left+n:$e(Ie(e)).left+n}r(Mt,"getWindowScrollBarX");function ks(e,t){let n=e.getBoundingClientRect(),i=n.left+t.scrollLeft-Mt(e,n),s=n.top+t.scrollTop;return{x:i,y:s}}r(ks,"getHTMLOffset");function ca(e){let{elements:t,rect:n,offsetParent:i,strategy:s}=e,o=s==="fixed",a=Ie(i),l=t?dt(t.floating):!1;if(i===a||l&&o)return n;let c={scrollLeft:0,scrollTop:0},d=be(1),u=be(0),p=Re(i);if((p||!p&&!o)&&((Ue(i)!=="body"||Je(a))&&(c=pt(i)),p)){let h=$e(i);d=Ye(i),u.x=h.x+i.clientLeft,u.y=h.y+i.clientTop}let f=a&&!p&&!o?ks(a,c):be(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-c.scrollLeft*d.x+u.x+f.x,y:n.y*d.y-c.scrollTop*d.y+u.y+f.y}}r(ca,"convertOffsetParentRelativeRectToViewportRelativeRect");function ua(e){return Array.from(e.getClientRects())}r(ua,"getClientRects");function da(e){let t=Ie(e),n=pt(e),i=e.ownerDocument.body,s=Be(t.scrollWidth,t.clientWidth,i.scrollWidth,i.clientWidth),o=Be(t.scrollHeight,t.clientHeight,i.scrollHeight,i.clientHeight),a=-n.scrollLeft+Mt(e),l=-n.scrollTop;return ge(i).direction==="rtl"&&(a+=Be(t.clientWidth,i.clientWidth)-s),{width:s,height:o,x:a,y:l}}r(da,"getDocumentRect");var Ss=25;function pa(e,t){let n=ue(e),i=Ie(e),s=n.visualViewport,o=i.clientWidth,a=i.clientHeight,l=0,c=0;if(s){o=s.width,a=s.height;let u=Ot();(!u||u&&t==="fixed")&&(l=s.offsetLeft,c=s.offsetTop)}let d=Mt(i);if(d<=0){let u=i.ownerDocument,p=u.body,f=getComputedStyle(p),h=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,w=Math.abs(i.clientWidth-p.clientWidth-h);w<=Ss&&(o-=w)}else d<=Ss&&(o+=d);return{width:o,height:a,x:l,y:c}}r(pa,"getViewportRect");function ha(e,t){let n=$e(e,!0,t==="fixed"),i=n.top+e.clientTop,s=n.left+e.clientLeft,o=Re(e)?Ye(e):be(1),a=e.clientWidth*o.x,l=e.clientHeight*o.y,c=s*o.x,d=i*o.y;return{width:a,height:l,x:c,y:d}}r(ha,"getInnerBoundingClientRect");function xs(e,t,n){let i;if(t==="viewport")i=pa(e,n);else if(t==="document")i=da(Ie(e));else if(ve(t))i=ha(t,n);else{let s=Rs(e);i={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return je(i)}r(xs,"getClientRectFromClippingAncestor");function As(e,t){let n=_e(e);return n===t||!ve(n)||Ve(n)?!1:ge(n).position==="fixed"||As(n,t)}r(As,"hasFixedPositionAncestor");function fa(e,t){let n=t.get(e);if(n)return n;let i=Xe(e,[],!1).filter(l=>ve(l)&&Ue(l)!=="body"),s=null,o=ge(e).position==="fixed",a=o?_e(e):e;for(;ve(a)&&!Ve(a);){let l=ge(a),c=Lt(a);!c&&l.position==="fixed"&&(s=null),(o?!c&&!s:!c&&l.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||Je(a)&&!c&&As(e,a))?i=i.filter(u=>u!==a):s=l,a=_e(a)}return t.set(e,i),i}r(fa,"getClippingElementAncestors");function ma(e){let{element:t,boundary:n,rootBoundary:i,strategy:s}=e,a=[...n==="clippingAncestors"?dt(t)?[]:fa(t,this._c):[].concat(n),i],l=xs(t,a[0],s),c=l.top,d=l.right,u=l.bottom,p=l.left;for(let f=1;f<a.length;f++){let h=xs(t,a[f],s);c=Be(h.top,c),d=lt(h.right,d),u=lt(h.bottom,u),p=Be(h.left,p)}return{width:d-p,height:u-c,x:p,y:c}}r(ma,"getClippingRect");function ya(e){let{width:t,height:n}=Cs(e);return{width:t,height:n}}r(ya,"getDimensions");function va(e,t,n){let i=Re(t),s=Ie(t),o=n==="fixed",a=$e(e,!0,o,t),l={scrollLeft:0,scrollTop:0},c=be(0);function d(){c.x=Mt(s)}if(r(d,"setLeftRTLScrollbarOffset"),i||!i&&!o)if((Ue(t)!=="body"||Je(s))&&(l=pt(t)),i){let h=$e(t,!0,o,t);c.x=h.x+t.clientLeft,c.y=h.y+t.clientTop}else s&&d();o&&!i&&s&&d();let u=s&&!i&&!o?ks(s,l):be(0),p=a.left+l.scrollLeft-c.x-u.x,f=a.top+l.scrollTop-c.y-u.y;return{x:p,y:f,width:a.width,height:a.height}}r(va,"getRectRelativeToOffsetParent");function Zn(e){return ge(e).position==="static"}r(Zn,"isStaticPositioned");function Es(e,t){if(!Re(e)||ge(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ie(e)===n&&(n=n.ownerDocument.body),n}r(Es,"getTrueOffsetParent");function Ps(e,t){let n=ue(e);if(dt(e))return n;if(!Re(e)){let s=_e(e);for(;s&&!Ve(s);){if(ve(s)&&!Zn(s))return s;s=_e(s)}return n}let i=Es(e,t);for(;i&&ws(i)&&Zn(i);)i=Es(i,t);return i&&Ve(i)&&Zn(i)&&!Lt(i)?n:i||bs(e)||n}r(Ps,"getOffsetParent");var ga=r(async function(e){let t=this.getOffsetParent||Ps,n=this.getDimensions,i=await n(e.floating);return{reference:va(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}},"getElementRects");function wa(e){return ge(e).direction==="rtl"}r(wa,"isRTL");var ba={convertOffsetParentRelativeRectToViewportRelativeRect:ca,getDocumentElement:Ie,getClippingRect:ma,getOffsetParent:Ps,getElementRects:ga,getClientRects:ua,getDimensions:ya,getScale:Ye,isElement:ve,isRTL:wa};function Ts(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}r(Ts,"rectsAreEqual");function Ia(e,t){let n=null,i,s=Ie(e);function o(){var l;clearTimeout(i),(l=n)==null||l.disconnect(),n=null}r(o,"cleanup");function a(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),o();let d=e.getBoundingClientRect(),{left:u,top:p,width:f,height:h}=d;if(l||t(),!f||!h)return;let w=ut(p),m=ut(s.clientWidth-(u+f)),b=ut(s.clientHeight-(p+h)),S=ut(u),P={rootMargin:-w+"px "+-m+"px "+-b+"px "+-S+"px",threshold:Be(0,lt(1,c))||1},D=!0;function E(A){let C=A[0].intersectionRatio;if(C!==c){if(!D)return a();C?a(!1,C):i=setTimeout(()=>{a(!1,1e-7)},1e3)}C===1&&!Ts(d,e.getBoundingClientRect())&&a(),D=!1}r(E,"handleObserve");try{n=new IntersectionObserver(E,{...P,root:s.ownerDocument})}catch{n=new IntersectionObserver(E,P)}n.observe(e)}return r(a,"refresh"),a(!0),o}r(Ia,"observeMove");function Ds(e,t,n,i){i===void 0&&(i={});let{ancestorScroll:s=!0,ancestorResize:o=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=i,d=ei(e),u=s||o?[...d?Xe(d):[],...t?Xe(t):[]]:[];u.forEach(S=>{s&&S.addEventListener("scroll",n,{passive:!0}),o&&S.addEventListener("resize",n)});let p=d&&l?Ia(d,n):null,f=-1,h=null;a&&(h=new ResizeObserver(S=>{let[k]=S;k&&k.target===d&&h&&t&&(h.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var P;(P=h)==null||P.observe(t)})),n()}),d&&!c&&h.observe(d),t&&h.observe(t));let w,m=c?$e(e):null;c&&b();function b(){let S=$e(e);m&&!Ts(m,S)&&n(),m=S,w=requestAnimationFrame(b)}return r(b,"frameLoop"),n(),()=>{var S;u.forEach(k=>{s&&k.removeEventListener("scroll",n),o&&k.removeEventListener("resize",n)}),p?.(),(S=h)==null||S.disconnect(),h=null,c&&cancelAnimationFrame(w)}}r(Ds,"autoUpdate");var Ls=ys;var Os=r((e,t,n)=>{let i=new Map,s={platform:ba,...n},o={...s.platform,_c:i};return ms(e,t,{...s,platform:o})},"computePosition");function Sa(){let e=document.body||document.documentElement;return e?Promise.resolve(e):new Promise(t=>{window.addEventListener("DOMContentLoaded",()=>t(e))})}r(Sa,"waitForDOM");function ht({onElementFound:e,selector:t,observerOptions:n,mustMatch:i}){let s=new WeakSet,o=new MutationObserver(d=>{let u=!1;for(let p of d)if(p.addedNodes.length>0){u=!0;break}u&&a()}),a=r(()=>{document.querySelectorAll(t).forEach(d=>{s.has(d)||(s.add(d),i?.(d)!==!1&&l(d))})},"locateElements"),l=r(d=>{if(!n){e(d);return}let u=new IntersectionObserver(p=>{for(let f of p)f.isIntersecting&&(u.disconnect(),e(d))},n);u.observe(d)},"observeElement");return r(async()=>{let d=await Sa();a(),o.observe(d,{childList:!0,subtree:!0})},"locateAndObserveElements")(),o}r(ht,"createElementLocator");function Ze({onLocationChange:e,fireOnInit:t=!1}){let n=r(()=>{e(window.location)},"handleChange");window.addEventListener("popstate",n);let i=history.pushState,s=history.replaceState;return history.pushState=function(...o){i.apply(this,o),n()},history.replaceState=function(...o){s.apply(this,o),n()},t&&n(),()=>{window.removeEventListener("popstate",n),history.pushState=i,history.replaceState=s}}r(Ze,"createLocationObserver");function et(e,t){let n=e.parentElement;for(;n;){let i=n.querySelector(t);if(i&&i!==e)return i;n=n.parentElement}return null}r(et,"findNearestElement");function _s({element:e,onHrefChange:t}){let n=r(()=>{t(e.href)},"handleChange"),i=new MutationObserver(()=>{n()});return i.observe(e,{attributes:!0,attributeFilter:["href"]}),()=>{i.disconnect()}}r(_s,"createHrefObserver");function xa(e){let t=e.getAttribute("swish-item-context");return t?t==="location"?globalThis.window?.location??e:et(e,t)??e:e}r(xa,"resolveItemContextSource");function Ms(e,t){return e.getAttribute("swish-item-context")?xa(e):t}r(Ms,"resolvePlacementItemContextSource");function ti(e,t){if(!t.element)throw new Error("Element must be provided");let n=null,i=new Map,s=r(()=>{if(n){console.warn("Placement already mounted. Skipping mount.");return}Ca(t),n=ht({selector:t.target.selector,observerOptions:t.target.observerOptions,mustMatch:t.target.mustMatch,onElementFound:r(d=>o(d),"onElementFound")})},"mount"),o=r(d=>{i.has(d)||d.hasAttribute("swish-ignore")||d.getAttribute("swish-placement-target")===t.id||(d.setAttribute("swish-placement-target",t.id),a(d))},"evaluateAndMount"),a=r(async d=>{let u=[],p=t.mount.mode,f=js(d,t.mount.at);if(!f)return;let h=await(typeof t.element=="function"?t.element(t):Na(e,t.element));if(!h)return;if(h.setAttribute("swish-placement-element",t.id),typeof t.element!="function"){let C=t.element;C.props&&Ua(h,C.props),C.classNames&&Us(h,C.classNames)}let w;t.container&&(w=ja(t.id,t.container),w.appendChild(h));let m,b=w??h;if(t.layout?.type==="overlay"){Ma(f);let C=t.layout.anchor??"bottom-right";b.setAttribute("swish-placement-overlay",t.id),b.setAttribute("swish-placement-anchor",C)}else t.layout?.type==="anchored"&&b.setAttribute("swish-placement-anchored",t.id);let S=!1,k;if(t.layout?.type==="inline"){let C=t.layout,B=C.rowSelector?f.closest(C.rowSelector):null;B?m=B:(m=Fa(t.id,f,C),S=!0),k=m.getAttribute("swish-placement-inline-row"),m.setAttribute("swish-placement-inline-row",t.id)}let P=w??h;if(!_a(f,P,p)){try{P.remove()}catch{}return}if(t.layout?.type==="anchored"){let C=js(d,t.layout.to)??f,B=qa(C,b,t.layout);u.push(B)}let E={targetEl:d,renderTargetEl:f,mountEl:h,containerEl:w,rowEl:m,rowWasCreated:S,rowInlineAttrPrevValue:k,cleanupFns:u,ownsNode:!0};i.set(d,E);let A={id:t.id,targetEl:d,renderTargetEl:f,mountEl:E.mountEl,containerEl:w,rowEl:m,cleanup:r(C=>u.push(C),"cleanup")};t.element?.name==="save-button"&&Ea(e,A),t.onMount?.(A)},"mountElement"),l=r(d=>{let u=i.get(d);if(u){if(t.onUnmount?.({id:t.id,targetEl:u.targetEl,renderTargetEl:u.renderTargetEl,mountEl:u.mountEl,containerEl:u.containerEl,rowEl:u.rowEl}),u.cleanupFns.forEach(p=>p()),u.targetEl.getAttribute("swish-placement-target")===t.id&&u.targetEl.removeAttribute("swish-placement-target"),u.ownsNode&&(u.containerEl||u.mountEl).remove(),u.rowEl){if(u.rowWasCreated){let p=u.rowEl.parentElement;p&&u.targetEl.parentElement===u.rowEl?u.rowEl.replaceWith(u.targetEl):p?p.removeChild(u.rowEl):u.rowEl.remove()}else if(u.rowInlineAttrPrevValue!==void 0){let p=u.rowInlineAttrPrevValue;p===null?u.rowEl.removeAttribute("swish-placement-inline-row"):u.rowEl.setAttribute("swish-placement-inline-row",p)}}i.delete(d)}},"unmountElement");return{mount:s,unmount:r(()=>{n&&(n.disconnect(),n=null),i.forEach((d,u)=>l(u)),i.clear()},"unmount")}}r(ti,"createPlacement");var Ea=r((e,{mountEl:t,targetEl:n,cleanup:i})=>{let s=Ms(t,n),o=e.state.itemContext(s),a=e.state.effect(()=>{let{loading:l,productId:c,variantId:d}=o.value;l||(t.setAttribute("product-id",c??""),t.setAttribute("variant-id",d??""))});i(()=>a?.())},"saveButtonMount");function Ca(e){let t=Ra(e.id),n=Oa(e),i=document.getElementById(t);if(i){i.textContent=n;return}let s=document.createElement("style");s.id=t,s.setAttribute("swish-placement-style",e.id),s.textContent=n,document.head.appendChild(s)}r(Ca,"ensurePlacementStylesheet");function Ra(e){return`swish-placement-style-${ka(e)}`}r(Ra,"getPlacementStyleId");function ka(e){return e.replace(/[^a-zA-Z0-9\-_]/g,"_")}r(ka,"cssEscapeId");function qs(e){return`--swish-placement-${Aa(String(e))}`}r(qs,"designKeyToCSSVar");function Aa(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase()}r(Aa,"toKebabCase");function Pa(e){return Object.entries(e??{sm:500,lg:700}).map(([i,s])=>({name:i,minWidth:s})).sort((i,s)=>i.minWidth-s.minWidth)}r(Pa,"getBreakpoints");function Ns(e,t){if(e==null)return{};if(typeof e=="object"&&!Array.isArray(e)){if(t&&t.size){let n=Object.keys(e);return"base"in e||n.some(s=>t.has(s))?e:{base:e}}return e}return{base:e}}r(Ns,"normalizeResponsiveValue");var Ta=new Set(["fontWeight","lineHeight","pressedScale","backgroundAlpha","pressedOpacity","pressedScale"]);function Bs(e,t){if(t!=null)return typeof t=="number"&&!Ta.has(e)?`${t}px`:String(t)}r(Bs,"formatDesignValue");function Da(e,t,n){if(!t)return"";let i=new Set(n.map(c=>c.name)),s=[],o={},a=Object.entries(t).map(([c,d])=>[c,d]);for(let[c,d]of a){let u=Ns(d,i),p=Bs(String(c),u.base);p!==void 0&&s.push(`${qs(c)}:${p};`);for(let f of n){let h=u[f.name],w=Bs(String(c),h);w!==void 0&&(o[f.name]||(o[f.name]=[]),o[f.name].push(`${qs(c)}:${w};`))}}let l=[];s.length&&l.push(`[swish-placement-element="${e}"]{${s.join("")}}`);for(let c of n){let d=o[c.name];d?.length&&l.push(`@media(min-width:${c.minWidth}px){[swish-placement-element="${e}"]{${d.join("")}}}`)}return l.join("")}r(Da,"emitDesignCSS");function qt(e){return e==null?"0px":typeof e=="number"?`${e}px`:e}r(qt,"formatOffsetValue");function Fs(e){return e==null?"":typeof e=="number"?`${e}`:e}r(Fs,"formatZIndexValue");function La(e,t,n){let i=new Set(n.map(d=>d.name)),s=Ns(t,i),o=s.base??{},a=qt(o.x),l=qt(o.y),c=[];c.push(`[swish-placement-overlay="${e}"]{--swish-placement-offset-x:${a};--swish-placement-offset-y:${l};}`);for(let d of n){let u=s[d.name];if(!u)continue;let p=qt(u.x),f=qt(u.y);c.push(`@media(min-width:${d.minWidth}px){[swish-placement-overlay="${e}"]{--swish-placement-offset-x:${p};--swish-placement-offset-y:${f};}}`)}return c.join("")}r(La,"emitOverlayOffsetCSS");function Oa(e){let t=e.id,n=Pa(e.breakpoints),i=`[swish-placement-inline-row="${t}"]{display:flex;flex-direction:row;align-items:center;gap:var(--swish-placement-inline-gap,8px);width:100%}[swish-placement-inline-row="${t}"]>*:not([swish-placement-element="${t}"]){flex:1;min-width:0}`,s=`[swish-placement-overlay="${t}"]{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="${t}"][swish-placement-anchor="top-left"]{top:0;left:0;}[swish-placement-overlay="${t}"][swish-placement-anchor="top-right"]{top:0;right:0;}[swish-placement-overlay="${t}"][swish-placement-anchor="bottom-left"]{bottom:0;left:0;}[swish-placement-overlay="${t}"][swish-placement-anchor="bottom-right"]{bottom:0;right:0;}[swish-placement-overlay="${t}"][swish-placement-anchor$="left"]{--swish-placement-sign-x:1;}[swish-placement-overlay="${t}"][swish-placement-anchor$="right"]{--swish-placement-sign-x:-1;}[swish-placement-overlay="${t}"][swish-placement-anchor^="top"]{--swish-placement-sign-y:1;}[swish-placement-overlay="${t}"][swish-placement-anchor^="bottom"]{--swish-placement-sign-y:-1;}`,o="";if(e.layout?.type==="overlay"){let a=La(t,e.layout.offset,n),l=e.layout.zIndex?`[swish-placement-overlay="${t}"]{--swish-placement-overlay-z:${Fs(e.layout.zIndex)};}`:"";o+=a+l+s}else if(e.layout?.type==="anchored"){let a=e.layout.zIndex?Fs(e.layout.zIndex):"10";o+=`[swish-placement-anchored="${t}"]{position:absolute;width:max-content;top:0;left:0;z-index:${a};}`}else e.layout?.type==="inline"&&(o+=i);if(e.design){let a=Da(t,e.design,n);a&&(o+=a)}return e.css&&(o+=e.css.trim()),o}r(Oa,"buildPlacementCSS");function js(e,t){if(!t||t==="target")return e;if(typeof t=="string"&&(t={nearest:t}),"nearest"in t)return et(e,t.nearest);if("closest"in t)return e.closest(t.closest);if("query"in t)return e.querySelector(t.query);if("withinClosest"in t){let n=e.closest(t.withinClosest.root);return n?n.querySelector(t.withinClosest.selector):null}return e}r(js,"resolveMountTarget");function _a(e,t,n){switch(n){case"before":return e.parentElement?(e.before(t),!0):!1;case"after":{let i=e.parentElement;return i?(i.insertBefore(t,e.nextSibling),!0):!1}case"append":return e.appendChild(t),!0;case"prepend":return e.insertBefore(t,e.firstChild),!0;case"replace":return e.parentElement?(e.replaceWith(t),!0):!1}}r(_a,"insertIntoDOM");function Ma(e){let t=e.parentElement;return t?(window.getComputedStyle(t).position==="static"&&(t.style.position="relative"),t):null}r(Ma,"ensureRelativeParent");function qa(e,t,n){let i=[];return n.inside?i.push(Ba(n.offset??0)):n.offset&&i.push(Ls(n.offset)),Ds(e,t,r(()=>{Os(e,t,{placement:n.placement??"bottom-end",middleware:i}).then(({x:o,y:a})=>{Object.assign(t.style,{left:`${o}px`,top:`${a}px`})})},"update"))}r(qa,"setupAnchoredPosition");function Ba(e){return{name:"anchoredInside",fn({x:t,y:n,rects:i,placement:s}){let[o,a]=s.split("-"),l=0,c=0,d=o==="top"||o==="bottom";return o==="top"?c=i.floating.height+e:o==="bottom"?c=-(i.floating.height+e):o==="left"?l=i.floating.width+e:o==="right"&&(l=-(i.floating.width+e)),d&&a==="start"?l=e:d&&a==="end"?l=-e:!d&&a==="start"?c=e:!d&&a==="end"&&(c=-e),{x:t+l,y:n+c}}}}r(Ba,"anchoredInsideMiddleware");function Fa(e,t,n){if(!t.parentElement)throw new Error("Cannot inline-wrap: refEl has no parentElement");let s=document.createElement("div");return s.setAttribute("swish-placement-inline-row",e),t.before(s),s.appendChild(t),s}r(Fa,"wrapWithFlexRow");function ja(e,t){let n=t.tag||"div",i=document.createElement(n);return i.setAttribute("swish-placement-container",e),t.classNames&&Us(i,t.classNames),i}r(ja,"createContainer");function Na(e,t){return e.ui.createElement(t.name,{})}r(Na,"createElement");function Ua(e,t){for(let[n,i]of Object.entries(t)){let s=n.replace(/([A-Z])/g,"-$1").toLowerCase();i===!1||i===void 0||i===null||(i===!0?e.setAttribute(s,"true"):e.setAttribute(s,String(i)))}}r(Ua,"applyProps");function Us(e,t){e.classList.add(...t)}r(Us,"applyClassNames");var Va=Symbol.for("preact-signals");function Ft(){if(Fe>1)Fe--;else{for(var e,t=!1;ft!==void 0;){var n=ft;for(ft=void 0,ni++;n!==void 0;){var i=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&Qs(n))try{n.c()}catch(s){t||(e=s,t=!0)}n=i}}if(ni=0,Fe--,t)throw e}}r(Ft,"t");function ie(e){if(Fe>0)return e();Fe++;try{return e()}finally{Ft()}}r(ie,"n");var j=void 0;function $s(e){var t=j;j=void 0;try{return e()}finally{j=t}}r($s,"o");var Vs,ft=void 0,Fe=0,ni=0,Bt=0;function Hs(e){if(j!==void 0){var t=e.n;if(t===void 0||t.t!==j)return t={i:0,S:e,p:j.s,n:void 0,t:j,e:void 0,x:void 0,r:t},j.s!==void 0&&(j.s.n=t),j.s=t,e.n=t,32&j.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=j.s,t.n=void 0,j.s.n=t,j.s=t),t}}r(Hs,"e");function re(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}r(re,"d");re.prototype.brand=Va;re.prototype.h=function(){return!0};re.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n!==void 0?n.e=e:$s(function(){var i;(i=t.W)==null||i.call(t)}))};re.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,i=e.x;n!==void 0&&(n.x=i,e.e=void 0),i!==void 0&&(i.e=n,e.x=void 0),e===this.t&&(this.t=i,i===void 0&&$s(function(){var s;(s=t.Z)==null||s.call(t)}))}};re.prototype.subscribe=function(e){var t=this;return Z(function(){var n=t.value,i=j;j=void 0;try{e(n)}finally{j=i}},{name:"sub"})};re.prototype.valueOf=function(){return this.value};re.prototype.toString=function(){return this.value+""};re.prototype.toJSON=function(){return this.value};re.prototype.peek=function(){var e=j;j=void 0;try{return this.value}finally{j=e}};Object.defineProperty(re.prototype,"value",{get:r(function(){var e=Hs(this);return e!==void 0&&(e.i=this.i),this.v},"get"),set:r(function(e){if(e!==this.v){if(ni>100)throw new Error("Cycle detected");this.v=e,this.i++,Bt++,Fe++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Ft()}}},"set")});function F(e,t){return new re(e,t)}r(F,"c");function Qs(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}r(Qs,"a");function zs(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}r(zs,"l");function Gs(e){for(var t=e.s,n=void 0;t!==void 0;){var i=t.p;t.i===-1?(t.S.U(t),i!==void 0&&(i.n=t.n),t.n!==void 0&&(t.n.p=i)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=i}e.s=n}r(Gs,"y");function He(e,t){re.call(this,void 0),this.x=e,this.s=void 0,this.g=Bt-1,this.f=4,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}r(He,"w");He.prototype=new re;He.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Bt))return!0;if(this.g=Bt,this.f|=1,this.i>0&&!Qs(this))return this.f&=-2,!0;var e=j;try{zs(this),j=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return j=e,Gs(this),this.f&=-2,!0};He.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}re.prototype.S.call(this,e)};He.prototype.U=function(e){if(this.t!==void 0&&(re.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}};He.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty(He.prototype,"value",{get:r(function(){if(1&this.f)throw new Error("Cycle detected");var e=Hs(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v},"get")});function de(e,t){return new He(e,t)}r(de,"b");function Ws(e){var t=e.u;if(e.u=void 0,typeof t=="function"){Fe++;var n=j;j=void 0;try{t()}catch(i){throw e.f&=-2,e.f|=8,ii(e),i}finally{j=n,Ft()}}}r(Ws,"_");function ii(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Ws(e)}r(ii,"p");function $a(e){if(j!==this)throw new Error("Out-of-order effect");Gs(this),j=e,this.f&=-2,8&this.f&&ii(this),Ft()}r($a,"g");function tt(e,t){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=t?.name,Vs&&Vs.push(this)}r(tt,"S");tt.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.u=t)}finally{e()}};tt.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Ws(this),zs(this),Fe++;var e=j;return j=this,$a.bind(this,e)};tt.prototype.N=function(){2&this.f||(this.f|=2,this.o=ft,ft=this)};tt.prototype.d=function(){this.f|=8,1&this.f||ii(this)};tt.prototype.dispose=function(){this.d()};function Z(e,t){var n=new tt(e,t);try{n.c()}catch(s){throw n.d(),s}var i=n.d.bind(n);return i[Symbol.dispose]=i,i}r(Z,"m");var Ha="swish-save, swish-drawer";function Ks(e,t){return e.closest(Ha)===t}r(Ks,"belongsToHost");function jt(e,t){return Z(()=>{let n=t();e.querySelectorAll("[data-swish-when]").forEach(s=>{if(!Ks(s,e))return;let a=!(s.dataset.swishWhen??"").split(",").map(l=>l.trim()).includes(n);s.hidden!==a&&(s.hidden=a)})})}r(jt,"bindWhen");function Xs(e,t,n){e.hidden&&(e.hidden=!1);let i=`[data-swish-bind="${t}"]`;return Z(()=>{let s=n(),o=String(s);e.querySelectorAll(i).forEach(l=>{Ks(l,e)&&l.textContent!==o&&(l.textContent=o)})})}r(Xs,"bindValue");var Qa=["home","saves","lists","orders","notifications","profile"],za=["view"],Ga=typeof HTMLElement<"u"?HTMLElement:class{},mt=class extends Ga{constructor(){super(...arguments);this.disposers=[];this.deferredReady=null;this.clickHandler=r(()=>{let n=Qe();if(!n)return;let i=this.resolveView();n.intents.invoke(`view:${i}`)},"clickHandler")}static{r(this,"SwishDrawerElement")}static get observedAttributes(){return[...za]}connectedCallback(){if(!this.isConnected)return;let n=Qe();if(!n){if(this.deferredReady)return;let i=r(()=>{this.deferredReady=null,this.connectedCallback()},"handler");this.deferredReady=i,document.addEventListener("swish-ready",i,{once:!0});return}this.bind(n),this.addEventListener("click",this.clickHandler)}disconnectedCallback(){this.deferredReady&&(document.removeEventListener("swish-ready",this.deferredReady),this.deferredReady=null),this.removeEventListener("click",this.clickHandler),this.dispose()}bind(n){let i=n.state.itemCount(),s=n.state.effect(()=>{let{count:l,loading:c}=i.value;this.setAttribute("state",l>0?"has-saves":"empty"),!c&&!this.hasAttribute("ready")&&this.toggleAttribute("ready",!0)}),o=Xs(this,"count",()=>i.value.count),a=jt(this,()=>i.value.count>0?"has-saves":"empty");this.disposers.push(s,o,a)}dispose(){for(;this.disposers.length;)this.disposers.pop()?.()}resolveView(){let n=this.getAttribute("view");return n&&Qa.includes(n)?n:(n&&console.warn(`[swish] <swish-drawer> view="${n}" is not a recognized view. Falling back to "home".`),"home")}};var Wa=["product","variant","context","match"],Ka="a[href*='/products/']";function Xa(e){if(e==="variant"||e==="product"||e==="auto")return e}r(Xa,"parseMatch");function Ja(e){return e==="product-card"?"product":"auto"}r(Ja,"defaultMatchForContext");var Ya=typeof HTMLElement<"u"?HTMLElement:class{},yt=class extends Ya{constructor(){super(...arguments);this.disposers=[];this.state=null;this.deferredReady=null;this.clickHandler=r(n=>{n.stopPropagation(),this.state?.toggle()},"clickHandler")}static{r(this,"SwishSaveElement")}static get observedAttributes(){return[...Wa]}connectedCallback(){if(!this.isConnected)return;let n=Qe();if(!n){if(this.deferredReady)return;let i=r(()=>{this.deferredReady=null,this.connectedCallback()},"handler");this.deferredReady=i,document.addEventListener("swish-ready",i,{once:!0});return}this.bind(n),this.addEventListener("click",this.clickHandler)}attributeChangedCallback(n,i,s){i===s||!this.isConnected||!this.state||this.rebind()}disconnectedCallback(){this.deferredReady&&(document.removeEventListener("swish-ready",this.deferredReady),this.deferredReady=null),this.removeEventListener("click",this.clickHandler),this.dispose()}bind(n){let i=this.resolveContext(n),s=Xa(this.getAttribute("match"))??Ja(this.getAttribute("context"));this.state=n.state.itemState(i,{match:s});let o=n.state.effect(()=>{let l=this.state?.value;l&&(this.setAttribute("state",l.status),this.setAttribute("aria-pressed",String(l.saved)),!l.loading&&!this.hasAttribute("ready")&&this.toggleAttribute("ready",!0))}),a=jt(this,()=>this.state?.value.status??"unsaved");this.disposers.push(()=>this.state?.dispose()),this.disposers.push(o),this.disposers.push(a)}rebind(){let n=Qe();n&&(this.dispose(),this.bind(n))}dispose(){for(;this.disposers.length;)this.disposers.pop()?.();this.state=null}resolveContext(n){let i=this.getAttribute("product"),s=this.getAttribute("variant");if(i)return n.state.itemContextFromIds({productId:i,variantId:s});let o=this.getAttribute("context");if(o==="pdp")return n.state.itemContext(window.location);if(o==="product-card"){let a=et(this,Ka);if(a)return n.state.itemContext(a)}return n.state.itemContext(this)}};var Js=null;function si(e){Js=e,!(typeof customElements>"u")&&(customElements.get("swish-save")||customElements.define("swish-save",yt),customElements.get("swish-drawer")||customElements.define("swish-drawer",mt))}r(si,"initElements");function Qe(){return Js}r(Qe,"getSwish");var Nt=class{constructor(){this.eventBus=new EventTarget}static{r(this,"EventBus")}subscribe(t,n,i){return Array.isArray(t)||(t=[t]),t.forEach(s=>{this.eventBus.addEventListener(s,n,i)}),()=>{t.forEach(s=>{this.eventBus.removeEventListener(s,n,i)})}}unsubscribe(t,n,i){this.eventBus.removeEventListener(t,n,i)}publish(t,n){this.eventBus.dispatchEvent(new CustomEvent(t,{detail:n}))}};var Za=/\/products\/([^/?#]+)(?:\?(?:[^#]*?&)?variant=(\d+))?/,vt=r(e=>{let t=e.match(Za);return t?{productHandle:decodeURIComponent(t[1]),variantId:t[2]}:null},"parseProductUrl"),Ys=r(({source:e,onProductUrlChange:t})=>{let n=r(i=>{let s=vt(i);s?.productHandle&&t(s)},"handleChange");if(e instanceof HTMLAnchorElement)return _s({element:e,onHrefChange:r(i=>n(i),"onHrefChange")});if(e instanceof Location)return Ze({onLocationChange:r(i=>n(i.href),"onLocationChange")});throw new Error("Invalid source for observing product url")},"observeProductUrl");var ri;function oi(e){return{lang:e?.lang??ri?.lang,message:e?.message,abortEarly:e?.abortEarly??ri?.abortEarly,abortPipeEarly:e?.abortPipeEarly??ri?.abortPipeEarly}}r(oi,"getGlobalConfig");var el;function tl(e){return el?.get(e)}r(tl,"getGlobalMessage");var nl;function il(e){return nl?.get(e)}r(il,"getSchemaMessage");var sl;function rl(e,t){return sl?.get(e)?.get(t)}r(rl,"getSpecificMessage");function gt(e){let t=typeof e;return t==="string"?`"${e}"`:t==="number"||t==="bigint"||t==="boolean"?`${e}`:t==="object"||t==="function"?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":t}r(gt,"_stringify");function se(e,t,n,i,s){let o=s&&"input"in s?s.input:n.value,a=s?.expected??e.expects??null,l=s?.received??gt(o),c={kind:e.kind,type:e.type,input:o,expected:a,received:l,message:`Invalid ${t}: ${a?`Expected ${a} but r`:"R"}eceived ${l}`,requirement:e.requirement,path:s?.path,issues:s?.issues,lang:i.lang,abortEarly:i.abortEarly,abortPipeEarly:i.abortPipeEarly},d=e.kind==="schema",u=s?.message??e.message??rl(e.reference,c.lang)??(d?il(c.lang):null)??i.message??tl(c.lang);u!==void 0&&(c.message=typeof u=="function"?u(c):u),d&&(n.typed=!1),n.issues?n.issues.push(c):n.issues=[c]}r(se,"_addIssue");function pe(e){return{version:1,vendor:"valibot",validate(t){return e["~run"]({value:t},oi())}}}r(pe,"_getStandardProps");function ol(e,t){return Object.hasOwn(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}r(ol,"_isValidObjectKey");function ai(e,t){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??"never"}r(ai,"_joinExpects");var al=class extends Error{static{r(this,"ValiError")}constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function wt(e,t){return{kind:"validation",type:"min_length",reference:wt,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(n,i){return n.typed&&n.value.length<this.requirement&&se(this,"length",n,i,{received:`${n.value.length}`}),n}}}r(wt,"minLength");function Se(e,t){return{kind:"validation",type:"min_value",reference:Se,async:!1,expects:`>=${e instanceof Date?e.toJSON():gt(e)}`,requirement:e,message:t,"~run"(n,i){return n.typed&&!(n.value>=this.requirement)&&se(this,"value",n,i,{received:n.value instanceof Date?n.value.toJSON():gt(n.value)}),n}}}r(Se,"minValue");function U(e){return{kind:"transformation",type:"transform",reference:U,async:!1,operation:e,"~run"(t){return t.value=this.operation(t.value),t}}}r(U,"transform");function ll(e,t,n){return typeof e.fallback=="function"?e.fallback(t,n):e.fallback}r(ll,"getFallback");function er(e,t,n){return typeof e.default=="function"?e.default(t,n):e.default}r(er,"getDefault");function z(e,t){return{kind:"schema",type:"array",reference:z,expects:"Array",async:!1,item:e,message:t,get"~standard"(){return pe(this)},"~run"(n,i){let s=n.value;if(Array.isArray(s)){n.typed=!0,n.value=[];for(let o=0;o<s.length;o++){let a=s[o],l=this.item["~run"]({value:a},i);if(l.issues){let c={type:"array",origin:"value",input:s,key:o,value:a};for(let d of l.issues)d.path?d.path.unshift(c):d.path=[c],n.issues?.push(d);if(n.issues||(n.issues=l.issues),i.abortEarly){n.typed=!1;break}}l.typed||(n.typed=!1),n.value.push(l.value)}}else se(this,"type",n,i);return n}}}r(z,"array");function T(e){return{kind:"schema",type:"boolean",reference:T,expects:"boolean",async:!1,message:e,get"~standard"(){return pe(this)},"~run"(t,n){return typeof t.value=="boolean"?t.typed=!0:se(this,"type",t,n),t}}}r(T,"boolean");function li(e,t){return{kind:"schema",type:"instance",reference:li,expects:e.name,async:!1,class:e,message:t,get"~standard"(){return pe(this)},"~run"(n,i){return n.value instanceof this.class?n.typed=!0:se(this,"type",n,i),n}}}r(li,"instance");function H(e,t){return{kind:"schema",type:"literal",reference:H,expects:gt(e),async:!1,literal:e,message:t,get"~standard"(){return pe(this)},"~run"(n,i){return n.value===this.literal?n.typed=!0:se(this,"type",n,i),n}}}r(H,"literal");function _(e){return{kind:"schema",type:"number",reference:_,expects:"number",async:!1,message:e,get"~standard"(){return pe(this)},"~run"(t,n){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:se(this,"type",t,n),t}}}r(_,"number");function I(e,t){return{kind:"schema",type:"object",reference:I,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return pe(this)},"~run"(n,i){let s=n.value;if(s&&typeof s=="object"){n.typed=!0,n.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 l=o in s?s[o]:er(a),c=a["~run"]({value:l},i);if(c.issues){let d={type:"object",origin:"value",input:s,key:o,value:l};for(let u of c.issues)u.path?u.path.unshift(d):u.path=[d],n.issues?.push(u);if(n.issues||(n.issues=c.issues),i.abortEarly){n.typed=!1;break}}c.typed||(n.typed=!1),n.value[o]=c.value}else if(a.fallback!==void 0)n.value[o]=ll(a);else if(a.type!=="exact_optional"&&a.type!=="optional"&&a.type!=="nullish"&&(se(this,"key",n,i,{input:void 0,expected:`"${o}"`,path:[{type:"object",origin:"key",input:s,key:o,value:s[o]}]}),i.abortEarly))break}}else se(this,"type",n,i);return n}}}r(I,"object");function y(e,t){return{kind:"schema",type:"optional",reference:y,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return pe(this)},"~run"(n,i){return n.value===void 0&&(this.default!==void 0&&(n.value=er(this,n,i)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,i)}}}r(y,"optional");function oe(e,t){return{kind:"schema",type:"picklist",reference:oe,expects:ai(e.map(gt),"|"),async:!1,options:e,message:t,get"~standard"(){return pe(this)},"~run"(n,i){return this.options.includes(n.value)?n.typed=!0:se(this,"type",n,i),n}}}r(oe,"picklist");function ne(e,t,n){return{kind:"schema",type:"record",reference:ne,expects:"Object",async:!1,key:e,value:t,message:n,get"~standard"(){return pe(this)},"~run"(i,s){let o=i.value;if(o&&typeof o=="object"){i.typed=!0,i.value={};for(let a in o)if(ol(o,a)){let l=o[a],c=this.key["~run"]({value:a},s);if(c.issues){let u={type:"object",origin:"key",input:o,key:a,value:l};for(let p of c.issues)p.path=[u],i.issues?.push(p);if(i.issues||(i.issues=c.issues),s.abortEarly){i.typed=!1;break}}let d=this.value["~run"]({value:l},s);if(d.issues){let u={type:"object",origin:"value",input:o,key:a,value:l};for(let p of d.issues)p.path?p.path.unshift(u):p.path=[u],i.issues?.push(p);if(i.issues||(i.issues=d.issues),s.abortEarly){i.typed=!1;break}}(!c.typed||!d.typed)&&(i.typed=!1),c.typed&&(i.value[c.value]=d.value)}}else se(this,"type",i,s);return i}}}r(ne,"record");function x(e){return{kind:"schema",type:"string",reference:x,expects:"string",async:!1,message:e,get"~standard"(){return pe(this)},"~run"(t,n){return typeof t.value=="string"?t.typed=!0:se(this,"type",t,n),t}}}r(x,"string");function Zs(e){let t;if(e)for(let n of e)t?t.push(...n.issues):t=n.issues;return t}r(Zs,"_subIssues");function $(e,t){return{kind:"schema",type:"union",reference:$,expects:ai(e.map(n=>n.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return pe(this)},"~run"(n,i){let s,o,a;for(let l of this.options){let c=l["~run"]({value:n.value},i);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];se(this,"type",n,i,{issues:Zs(o)}),n.typed=!0}else{if(a?.length===1)return a[0];se(this,"type",n,i,{issues:Zs(a)})}return n}}}r($,"union");function ae(){return{kind:"schema",type:"unknown",reference:ae,expects:"unknown",async:!1,get"~standard"(){return pe(this)},"~run"(e){return e.typed=!0,e}}}r(ae,"unknown");function ze(e,t,n){return{kind:"schema",type:"variant",reference:ze,expects:"Object",async:!1,key:e,options:t,message:n,get"~standard"(){return pe(this)},"~run"(i,s){let o=i.value;if(o&&typeof o=="object"){let a,l=0,c=this.key,d=[],u=r((p,f)=>{for(let h of p.options){if(h.type==="variant")u(h,new Set(f).add(h.key));else{let w=!0,m=0;for(let b of f){let S=h.entries[b];if(b in o?S["~run"]({typed:!1,value:o[b]},{abortEarly:!0}).issues:S.type!=="exact_optional"&&S.type!=="optional"&&S.type!=="nullish"){w=!1,c!==b&&(l<m||l===m&&b in o&&!(c in o))&&(l=m,c=b,d=[]),c===b&&d.push(h.entries[b].expects);break}m++}if(w){let b=h["~run"]({value:o},s);(!a||!a.typed&&b.typed)&&(a=b)}}if(a&&!a.issues)break}},"parseOptions");if(u(this,new Set([this.key])),a)return a;se(this,"type",i,s,{input:o[c],expected:ai(d,"|"),path:[{type:"object",origin:"value",input:o,key:c,value:o[c]}]})}else se(this,"type",i,s);return i}}}r(ze,"variant");function tr(e,t,n){let i=e["~run"]({value:t},oi(n));if(i.issues)throw new al(i.issues);return i.value}r(tr,"parse");function M(...e){return{...e[0],pipe:e,get"~standard"(){return pe(this)},"~run"(t,n){for(let i of e)if(i.kind!=="metadata"){if(t.issues&&(i.kind==="schema"||i.kind==="transformation")){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=i["~run"](t,n))}return t}}}r(M,"pipe");function q(e,t,n){let i=e["~run"]({value:t},oi(n));return{typed:i.typed,success:!i.issues,output:i.value,issues:i.issues}}r(q,"safeParse");var nt=M($([M(x(),U(N)),_()]),U(e=>Number(e)),M(_(),Se(1)));var R=class{constructor(t,n,i,s){this.swish=t;this.ui=n;this.eventBus=i;this.options=s}static{r(this,"IntentHandler")}};var cl=$([I({variantId:nt,quantity:y(M(_(),Se(1)),1)}),I({items:M(z(I({variantId:nt,quantity:y(M(_(),Se(1)),1)})),wt(1))})]),Ut=class extends R{static{r(this,"CreateCartLineHandler")}async invoke(t){let n=q(cl,t);if(!n.success)return{intent:"create:cart-line",code:"error",message:"Invalid intent data",issues:n.issues.map(s=>s.message)};let i=n.output;try{let s="items"in i?i.items.map(a=>({id:a.variantId,quantity:a.quantity})):[{id:i.variantId,quantity:i.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 Vt=class extends R{static{r(this,"CreateListHandler")}async invoke(t){let n=await this.ui.showListEditor();if(n.code==="closed")return{intent:"create:list",code:"closed"};let{list:i}=n.data;return{intent:"create:list",code:"ok",data:{list:i}}}};var ul=I({listId:x()}),$t=class extends R{static{r(this,"DeleteListHandler")}async invoke(t){let n=q(ul,t);if(!n.success)return{intent:"delete:list",code:"error",message:"Invalid intent data",issues:n.issues.map(o=>o.message)};let{listId:i}=n.output;return(await this.ui.showDeleteListAlert({listId:i})).code==="closed"?{intent:"delete:list",code:"closed"}:{intent:"delete:list",code:"ok",data:{listId:i}}}};var dl=I({itemId:x()}),Ht=class extends R{static{r(this,"EditItemListsHandler")}async invoke(t){let n=q(dl,t);if(!n.success)return{intent:"edit:item-lists",code:"error",message:"Invalid intent data",issues:n.issues.map(o=>o.message)};let{itemId:i}=n.output,s=await this.ui.showListSelect({itemId:i});if(s.code==="closed")return{intent:"edit:item-lists",code:"closed"};if(s.data.action==="submit"){let{item:o,product:a,variant:l}=s.data.data;return{intent:"edit:item-lists",code:"ok",data:{item:o,product:a,variant:l}}}return{intent:"unsave:item",code:"ok",data:{itemId:s.data.data.itemId}}}};var pl=I({itemId:M(x()),productId:M($([M(x(),U(N)),_()]),U(e=>Number(e)),_()),variantId:y(M($([M(x(),U(N)),_()]),U(e=>Number(e)),_()))}),Qt=class extends R{static{r(this,"EditItemVariantHandler")}async invoke(t){let n=q(pl,t);if(!n.success)return{intent:"edit:item-variant",code:"error",message:"Invalid intent data",issues:n.issues.map(f=>f.message)};let{itemId:i,productId:s,variantId:o}=n.output;if(!(!o||this.swish.options.intents.editSavedProduct.promptVariantChange)){let f=await this.swish.api.items.updateById(i,{productId:s,variantId:o});if("error"in f)return{intent:"edit:item-variant",code:"error",message:"Failed to update variant",issues:[f.error.message]};if(!f.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.loadProduct({productId:String(s),variantId:o?String(o):void 0});if(!h.data?.product)return{intent:"edit:item-variant",code:"error",message:"Failed to load product data",issues:[h.errors?.message??"No product data returned from API"]};let w=h.data.product,m=h.data.variant;return{intent:"edit:item-variant",code:"ok",data:{item:f.data,product:w,variant:m}}}let l=await this.ui.showVariantSelect({itemId:i,productId:s,variantId:o});if(l.code==="closed")return{intent:"edit:item-variant",code:"closed"};let{item:c,product:d,variant:u}=l.data;return{intent:"edit:item-variant",code:"ok",data:{item:c,product:d,variant:u}}}};var hl=I({listId:x(),access:oe(["public","private"])}),zt=class extends R{static{r(this,"EditListAccessHandler")}async invoke(t){let n=q(hl,t);if(!n.success)return{intent:"edit:list-access",code:"error",message:"Invalid intent data",issues:n.issues.map(l=>l.message)};let{listId:i,access:s}=n.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(i,{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 fl=I({listId:x()}),Gt=class extends R{static{r(this,"EditListHandler")}async invoke(t){let n=q(fl,t);if(!n.success)return{intent:"edit:list",code:"error",message:"Invalid intent data",issues:n.issues.map(a=>a.message)};let{listId:i}=n.output,s=await this.ui.showListEditor({listId:i});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 ml=I({variantId:nt,quantity:y(M(_(),Se(1)),1)}),yl=150,vl=$([I({variantId:nt,quantity:y(M(_(),Se(1)),1)}),I({items:M(z(ml),wt(1))})]),Wt=class extends R{static{r(this,"InitiateCheckoutHandler")}async invoke(t){let n=q(vl,t);if(!n.success)return{intent:"initiate:checkout",code:"error",message:"Invalid intent data",issues:n.issues.map(l=>l.message)};let i=n.output,o=("items"in i?i.items:[{variantId:i.variantId,quantity:i.quantity}]).map(l=>`${l.variantId}:${l.quantity}`).join(","),a=new URL(`/cart/${o}`,this.swish.shopUrl);return a.searchParams.set("checkout","1"),typeof window<"u"&&window.setTimeout(()=>window.location.assign(a.href),yl),{intent:"initiate:checkout",code:"ok",data:{checkoutUrl:a.href}}}};var gl=I({productId:M($([M(x(),U(N)),_()]),U(e=>Number(e)),_()),variantId:y(M($([M(x(),U(N)),_()]),U(Number),_()))}),Kt=class extends R{static{r(this,"InitiateQuickBuyHandler")}async invoke(t){let n=q(gl,t);if(!n.success)return{intent:"initiate:quick-buy",code:"error",message:"Invalid intent data",issues:n.issues.map(a=>a.message)};let{productId:i,variantId:s}=n.output,o=await this.ui.showQuickBuy({productId:i,variantId:s});return o.code==="closed"?{intent:"initiate:quick-buy",code:"closed"}:{intent:"initiate:quick-buy",code:"ok",data:o.data}}};var wl=150,bl=I({returnTo:x()}),Xt=class extends R{static{r(this,"InitiateSignInHandler")}async invoke(t){let n=q(bl,t);if(!n.success)return{intent:"initiate:sign-in",code:"error",message:"Invalid intent data",issues:n.issues.map(o=>o.message)};let i=n.output.returnTo;return(await this.ui.showConfirmDialog({titleKey:"signIn.title",descriptionKey:"signIn.description",confirmLabelKey:"signIn.continue",danger:!1})).code==="closed"?{intent:"initiate:sign-in",code:"closed"}:(this.scheduleRedirect(i),{intent:"initiate:sign-in",code:"ok",data:void 0})}scheduleRedirect(t){window.setTimeout(()=>this.redirectToSignIn(t),wl)}redirectToSignIn(t){let{routes:n,newCustomerAccounts:i}=this.swish.storefrontContext,s=i?"/customer_identity/login":n.accountUrl,o=new URL(s,window.location.origin);o.searchParams.set("return_to",t),window.location.assign(o.toString())}};var Il=150,Jt=class extends R{static{r(this,"InitiateSignOutHandler")}async invoke(){return this.scheduleRedirect(),{intent:"initiate:sign-out",code:"ok",data:void 0}}scheduleRedirect(){window.setTimeout(()=>this.redirectToSignOut(),Il)}redirectToSignOut(){let{accountUrl:t,rootUrl:n}=this.swish.storefrontContext.routes,{newCustomerAccounts:i}=this.swish.storefrontContext,s;if(i){let o=new URL(t,window.location.origin);o.pathname=o.pathname.replace(/\/$/,"")+"/logout",s=o.toString()}else s=new URL("/account/logout",window.location.origin).toString();s+=`?return_url=${encodeURIComponent(n)}`,window.location.assign(s)}};var Yt=class extends R{static{r(this,"SaveCartLineHandler")}async invoke(t){if(!t?.items?.length)return{intent:"save:cart-line",code:"error",message:"No items to save",issues:["items array is empty or missing"]};let{confirm:n,showFeedback:i}=this.options.saveCartLine,s=t.items[0];if(n&&(await this.ui.showToast({title:"Save this for later?",text:s.title??"",image:s.image,action:{label:"Save for later"},variant:"full"})).code!=="ok")return{intent:"save:cart-line",code:"closed"};for(let o of t.items){let a=await this.swish.api.items.create({productId:o.productId,variantId:o.variantId,quantity:o.quantity,source:"cart"});if("error"in a)return{intent:"save:cart-line",code:"error",message:"Failed to save item from cart",issues:[a.error.message]}}return i&&await this.ui.showToast({title:"We've saved this for you",text:s.title??"",image:s.image,variant:"full"}),{intent:"save:cart-line",code:"ok",data:t.items}}};var Sl=I({productId:M($([M(x(),U(N)),_()]),U(e=>Number(e)),_()),variantId:y(M($([M(x(),U(N)),_()]),U(Number),_())),quantity:y(M(_(),Se(1))),tags:y(z(x()))}),Zt=class extends R{static{r(this,"SaveItemHandler")}async invoke(t){let n=q(Sl,t);if(!n.success)return{intent:"save:item",code:"error",message:"Invalid intent data",issues:n.issues.map(b=>b.message)};let{productId:i,variantId:s,quantity:o,tags:a}=n.output,l=await this.swish.storefront.loadProduct({productId:String(i),variantId:s?String(s):void 0});if(l.errors)return{intent:"save:item",code:"error",message:l.errors.message??"Failed to load product data",issues:l.errors.graphQLErrors?.map(b=>b.message)??[]};if(!l.data||!l.data.product)return{intent:"save:item",code:"error",message:"Failed to load product data",issues:["API response missing data"]};let{product:c,variant:d}=l.data,u=c.variantsCount?.count&&c.variantsCount.count>1,p=!!s,h=!(typeof this.options.saveProduct.promptVariantIfMissing=="function"?this.options.saveProduct.promptVariantIfMissing({product:c,variant:d}):this.options.saveProduct.promptVariantIfMissing)||!this.options.saveProduct.promptVariantIfPresent&&p;if(!u||h){let b=r(()=>!u&&c.selectedOrFirstAvailableVariant?Number(N(c.selectedOrFirstAvailableVariant.id)):s,"variantIdToUse"),S=await this.swish.api.items.create({productId:i,variantId:b(),quantity:o,tags:a});return"error"in S?{intent:"save:item",code:"error",message:"Failed to create item",issues:[S.error.message]}:S.data?{intent:"save:item",code:"ok",data:{item:S.data,product:c,variant:u?d:c.selectedOrFirstAvailableVariant}}:{intent:"save:item",code:"error",message:"Could not complete item creation",issues:["API response missing data"]}}let w;if(this.options.saveProduct.saveBeforeVariantPrompt){let b=await this.swish.api.items.create({productId:i,quantity:o,tags:a});"data"in b&&b.data&&(w=b.data)}let m=await this.ui.showVariantSelect({productId:i,variantId:s,itemId:w?.id});return m.code==="closed"?w?{intent:"save:item",code:"ok",data:{item:w,product:c,variant:d}}:{intent:"save:item",code:"closed"}:{intent:"save:item",code:"ok",data:m.data}}};function bt(e,t){let{storeDomain:n}=e.options.storefront,{rootUrl:i,listDetailPagePath:s}=e.options.context.routes,o=new URL(`https://${n}`),a=new URL(`${i==="/"?"":i}${s}`,o);return a.searchParams.set("public-list-id",t.publicListId),a}r(bt,"buildShareListUrl");async function It(e){return typeof navigator?.clipboard?.writeText!="function"?{ok:!1,issues:["Clipboard API not available"]}:navigator.clipboard.writeText(e).then(()=>({ok:!0})).catch(t=>({ok:!1,issues:[t?.message??"Failed to copy to clipboard"]}))}r(It,"copyToClipboard");function nr(){let e=navigator.userAgent.includes("Mac OS")&&navigator.maxTouchPoints>1;return/Android|Mobile/i.test(navigator.userAgent)||e}r(nr,"isMobileDevice");var xl=I({listId:x()}),en=class extends R{static{r(this,"ShareListHandler")}async invoke(t){let n=q(xl,t);if(!n.success)return{intent:"initiate:share",code:"error",message:"Invalid intent data",issues:n.issues.map(c=>c.message)};let{listId:i}=n.output,s=await this.swish.api.lists.findById(i);if("error"in s)return{intent:"initiate:share",code:"error",message:"Failed to fetch list",issues:[s.error.message]};if(!s.data)return{intent:"initiate:share",code:"error",message:"List not found",issues:[]};if(s.data.access!=="public"){let d=await(await this.swish.intents.invoke("edit:list-access",{listId:i,access:"public"})).complete;if(d.code!=="ok")return{...d,intent:"initiate:share"}}let o=bt(this.swish,{publicListId:i}).toString();if(nr()&&typeof navigator.share=="function"&&(await navigator.share({title:"Share list",url:o}).then(()=>({ok:!0})).catch(()=>({ok:!1}))).ok)return{intent:"initiate:share",code:"ok",data:{listId:i,url:o,method:"native"}};let l=await It(o);return l.ok?{intent:"initiate:share",code:"ok",data:{listId:i,url:o,method:"clipboard"}}:{intent:"initiate:share",code:"error",message:"Failed to share list",issues:l.issues}}};var Am=I({title:y(x()),text:x(),image:y(x()),action:y(I({label:x(),url:y(x())})),variant:y(oe(["compact","full"])),icon:y(x())}),tn=class extends R{static{r(this,"ShowToastHandler")}async invoke(t){return{intent:"show:toast",code:(await this.ui.showToast(t)).code,data:void 0}}};var El=I({itemId:x(),delete:y(T())}),nn=class extends R{static{r(this,"UnsaveItemHandler")}async invoke(t){let n=q(El,t);if(!n.success)return{intent:"unsave:item",code:"error",message:"Invalid intent data",issues:n.issues.map(a=>a.message)};let{itemId:i,delete:s}=n.output;if(this.options.unsaveProduct.selectList&&!s){let a=await this.ui.showListSelect({itemId:i});if(a.code==="closed")return{intent:"unsave:item",code:"closed"};if(a.data.action==="submit"){let{item:l,product:c,variant:d}=a.data.data;return{intent:"edit:item-lists",code:"ok",data:{item:l,product:c,variant:d}}}if(a.data.action==="unsave"){let{itemId:l}=a.data.data;return{intent:"unsave:item",code:"ok",data:{itemId:l}}}}if(!this.options.unsaveProduct.confirm){let a=await this.swish.api.items.deleteById(i);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:i}}}return(await this.ui.showUnsaveAlert({itemId:i})).code==="closed"?{intent:"unsave:item",code:"closed"}:{intent:"unsave:item",code:"ok",data:{itemId:i}}}};var sn=class extends R{static{r(this,"ViewHomeHandler")}async invoke(t){return{intent:"view:home",code:(await this.ui.showDrawer()).code,data:void 0}}};var Cl=I({listId:x()}),rn=class extends R{static{r(this,"ViewListDetailPageMenuHandler")}async invoke(t){let n=q(Cl,t);if(!n.success)return{intent:"view:list-detail-page-menu",code:"error",message:"Invalid intent data",issues:n.issues.map(o=>o.message)};let{listId:i}=n.output;return{intent:"view:list-detail-page-menu",code:(await this.ui.showListDetailPageMenu({listId:i})).code,data:void 0}}};var Rl=I({listId:x(),listType:y(oe(["user","smart","shared"]),"user")}),on=class extends R{static{r(this,"ViewListHandler")}async invoke(t){let n=q(Rl,t);if(!n.success)return{intent:"view:list",code:"error",message:"Invalid intent data",issues:n.issues.map(a=>a.message)};let{listId:i,listType:s}=n.output;return{intent:"view:list",code:(await this.ui.showDrawer({view:"list",listId:i,listType:s})).code,data:void 0}}};var kl=I({listId:x()}),an=class extends R{static{r(this,"ViewListMenuHandler")}async invoke(t){let n=q(kl,t);if(!n.success)return{intent:"view:list-menu",code:"error",message:"Invalid intent data",issues:n.issues.map(o=>o.message)};let{listId:i}=n.output,s=await this.ui.showListMenu({listId:i});if(s.code==="closed")return{intent:"view: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:i}};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:i,access:a})).complete:{intent:"view: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("initiate:share",{listId:i})).complete:s.data.action==="add-items"?{intent:"view:list-menu",code:"ok",data:{listId:i}}:{intent:"view:list-menu",code:"error",message:"Unknown list menu action",issues:["Unknown action returned from list menu UI"]}}};var ln=class extends R{static{r(this,"ViewListsHandler")}async invoke(t){return{intent:"view:lists",code:(await this.ui.showDrawer({view:"lists"})).code,data:void 0}}};var cn=class extends R{static{r(this,"ViewNotificationsHandler")}async invoke(t){return{intent:"view:notifications",code:(await this.ui.showDrawer({view:"notifications"})).code,data:void 0}}};var Al=I({orderId:M($([M(x(),U(N)),_()]),U(e=>Number(e)),_())}),un=class extends R{static{r(this,"ViewOrderHandler")}async invoke(t){let n=q(Al,t);if(!n.success)return{intent:"view:order",code:"error",message:"Invalid intent data",issues:n.issues.map(o=>o.message)};let{orderId:i}=n.output;return{intent:"view:order",code:(await this.ui.showDrawer({view:"order",orderId:i.toString()})).code,data:void 0}}};var Pl=I({orderId:x()}),dn=class extends R{static{r(this,"ViewOrderMenuHandler")}async invoke(t){let n=q(Pl,t);if(!n.success)return{intent:"view:order-menu",code:"error",message:"Invalid intent data",issues:n.issues.map(o=>o.message)};let{orderId:i}=n.output;return{intent:"view:order-menu",code:(await this.ui.showOrderMenu({orderId:i})).code,data:void 0}}};var pn=class extends R{static{r(this,"ViewOrdersHandler")}async invoke(t){return{intent:"view:orders",code:(await this.ui.showDrawer({view:"orders"})).code,data:void 0}}};var Tl=I({productId:M($([M(x(),U(N)),_()]),U(e=>Number(e)),_()),variantId:y(M($([M(x(),U(N)),_()]),U(Number),_()))}),hn=class extends R{static{r(this,"ViewProductHandler")}async invoke(t){let n=q(Tl,t);if(!n.success)return{intent:"view:product",code:"error",message:"Invalid intent data",issues:n.issues.map(a=>a.message)};let{productId:i,variantId:s}=n.output;return{intent:"view:product",code:(await this.ui.showDrawer({view:"product",productId:i.toString(),variantId:s?.toString()})).code,data:void 0}}};var fn=class extends R{static{r(this,"ViewProfileHandler")}async invoke(t){return{intent:"view:profile",code:(await this.ui.showDrawer({view:"profile"})).code,data:void 0}}};var mn=class extends R{static{r(this,"ViewSavesHandler")}async invoke(t){return{intent:"view:saves",code:(await this.ui.showDrawer({view:"saves"})).code,data:void 0}}};var ee=class{constructor(t,n,i){this.swish=t;this.ui=n;this.options=i}static{r(this,"IntentHook")}};var yn=class extends ee{static{r(this,"AfterCreateCartLineHook")}async invoke(t){this.options.createCartLine.afterComplete?.(t)}};var vn=class extends ee{static{r(this,"AfterEditItemListsHook")}async invoke(t){if(this.options.editSavedProduct.showFeedback&&t.code==="ok"){if("itemId"in t.data)return;let{product:n,variant:i}=t.data;n&&(await(await this.swish.intents.invoke("show:toast",{title:"Saved",text:n.title,image:i?.image?.url??n.featuredImage?.url,action:{label:"View"}})).complete).code==="ok"&&this.swish.intents.invoke("view:saves")}}};var gn=class extends ee{static{r(this,"AfterEditListAccessHook")}async invoke(t){if(t.code!=="ok")return;let n=t.data.list.access==="public"?"List is now public":"List is now private";await(await this.swish.intents.invoke("show:toast",{text:n,variant:"compact",icon:"check"})).complete}};var wn=class extends ee{static{r(this,"AfterSaveCartLineHook")}async invoke(t){this.options.saveCartLine.afterComplete?.(t)}};var bn=class extends ee{static{r(this,"AfterSaveItemHook")}async invoke(t){if(this.options.saveProduct.showFeedback&&t.code==="ok"){let{item:n,product:i,variant:s}=t.data;i&&(await(await this.swish.intents.invoke("show:toast",{title:"Saved",text:i.title,image:s?.image?.url??i.featuredImage?.url,action:{label:"Add to List"}})).complete).code==="ok"&&this.swish.intents.invoke("edit:item-lists",{itemId:n.id})}}};var In=class extends ee{static{r(this,"AfterShareListHook")}async invoke(t){if(t.code!=="ok")return;await(await this.swish.intents.invoke("show:toast",{variant:"compact",text:"Link copied",icon:"check"})).complete}};var Sn=class extends ee{static{r(this,"AfterViewHomeHook")}async invoke(t){if(t.code==="closed"){let n=new URL(window.location.href);(n.hash==="#swish-home"||n.hash==="#swish")&&(n.hash="",window.history.replaceState({},document.title,n.toString()))}}};function ir(e){let t=e.startsWith("#")?e.slice(1):e;return t==="swish"||t.startsWith("swish-")}r(ir,"isSwishHash");var xn=class extends ee{static{r(this,"BeforeViewHomeHook")}async invoke(){ir(window.location.hash)||window.history.replaceState(window.history.state,"",window.location.pathname+window.location.search+"#swish")}};var En=class{constructor(t,n){this._invoking=!1;this.swish=t,this.ui=n,this.eventBus=new EventTarget,this.options=t.options.intents,this.handlers={"create:cart-line":new Ut(this.swish,this.ui,this.eventBus,this.options),"initiate:checkout":new Wt(this.swish,this.ui,this.eventBus,this.options),"save:item":new Zt(this.swish,this.ui,this.eventBus,this.options),"save:cart-line":new Yt(this.swish,this.ui,this.eventBus,this.options),"unsave:item":new nn(this.swish,this.ui,this.eventBus,this.options),"edit:item-variant":new Qt(this.swish,this.ui,this.eventBus,this.options),"edit:item-lists":new Ht(this.swish,this.ui,this.eventBus,this.options),"create:list":new Vt(this.swish,this.ui,this.eventBus,this.options),"edit:list":new Gt(this.swish,this.ui,this.eventBus,this.options),"edit:list-access":new zt(this.swish,this.ui,this.eventBus,this.options),"delete:list":new $t(this.swish,this.ui,this.eventBus,this.options),"view:home":new sn(this.swish,this.ui,this.eventBus,this.options),"initiate:share":new en(this.swish,this.ui,this.eventBus,this.options),"view:list":new on(this.swish,this.ui,this.eventBus,this.options),"view:lists":new ln(this.swish,this.ui,this.eventBus,this.options),"view:orders":new pn(this.swish,this.ui,this.eventBus,this.options),"view:order":new un(this.swish,this.ui,this.eventBus,this.options),"view:saves":new mn(this.swish,this.ui,this.eventBus,this.options),"view:notifications":new cn(this.swish,this.ui,this.eventBus,this.options),"view:profile":new fn(this.swish,this.ui,this.eventBus,this.options),"view:product":new hn(this.swish,this.ui,this.eventBus,this.options),"view:list-menu":new an(this.swish,this.ui,this.eventBus,this.options),"view:order-menu":new dn(this.swish,this.ui,this.eventBus,this.options),"view:list-detail-page-menu":new rn(this.swish,this.ui,this.eventBus,this.options),"initiate:sign-in":new Xt(this.swish,this.ui,this.eventBus,this.options),"initiate:sign-out":new Jt(this.swish,this.ui,this.eventBus,this.options),"initiate:quick-buy":new Kt(this.swish,this.ui,this.eventBus,this.options),"show:toast":new tn(this.swish,this.ui,this.eventBus,this.options)},this.initIntentHooks(),this.initIntentWatcher(),this.initCartChangeListener()}static{r(this,"Intents")}publishAnalyticsEvent(t,n){typeof window.Shopify?.analytics?.publish=="function"&&window.Shopify.analytics.publish(t,n)}async invoke(t,...n){let i=n[0],s={lifecycle:"before",intent:t,data:i,response:null};return this.publishAnalyticsEvent("swish-intent",s),this.publishAnalyticsEvent(`swish-intent=${t}`,s),this._invoking=!0,this.eventBus.dispatchEvent(new CustomEvent(`before:${t}`,{detail:s})),this._invoking=!1,{intent:t,data:i,complete:this.handleIntent(t,i).then(o=>{let a={lifecycle:"after",intent:t,data:i,response:o};if(this.publishAnalyticsEvent("swish-intent",a),this.publishAnalyticsEvent(`swish-intent=${t}`,a),this.eventBus.dispatchEvent(new CustomEvent(t,{detail:a})),o.code==="ok"&&o.intent!==t){let l={lifecycle:"after",intent:o.intent,data:i,response:o};this.eventBus.dispatchEvent(new CustomEvent(o.intent,{detail:l}))}return o})}}listen(t,n){let i=r(o=>{"detail"in o&&o.detail?n(o.detail.response):console.warn("Intent response event without detail",o)},"eventListener"),s=r(()=>{this.eventBus.removeEventListener(`${t}`,i)},"unsubscribe");return this.eventBus.addEventListener(`${t}`,i),s}parseIntentFromString(t){let n=String(t),i=n.indexOf("?");if(i===-1)return{intent:n,data:{}};let s=n.slice(0,i),o=new URLSearchParams(n.slice(i+1)),a={};return o.forEach((l,c)=>{a[c]=l}),{intent:s,data:a}}parseIntentFromUrl(t){let n=t.searchParams.get("swish-intent");if(!n)return null;let i=n,s={};t.searchParams.forEach((a,l)=>{l!=="swish-intent"&&(s[l]=a)});let o=vt(t.pathname);return o&&(!s.product&&!s.productId&&(s.product=o.productHandle),!s.variant&&!s.variantId&&o.variantId&&(s.variant=o.variantId)),{intent:i,data:s}}mapParamNames(t){let n={product:"productId",variant:"variantId",list:"listId",order:"orderId",item:"itemId"},i={};for(let[s,o]of Object.entries(t))i[n[s]??s]=o;return i}async resolveIntentData(t){let{productId:n}=t;if(!n||/^\d+$/.test(n)||n.startsWith("gid://"))return t;let i=await this.swish.storefront.loadProductId({productHandle:n});return i.data?.product?.id?{...t,productId:N(i.data.product.id)}:t}async invokeFromParsed(t,n){let i=this.mapParamNames(n),s=await this.resolveIntentData(i);Object.keys(s).length>0?this.invoke(t,s):this.invoke(t)}parseIntentFromHash(t){let n=t.startsWith("#")?t.slice(1):t;return{swish:"view:home","swish-home":"view:home","swish-lists":"view:lists","swish-orders":"view:orders","swish-saves":"view:saves","swish-notifications":"view:notifications","swish-profile":"view:profile"}[n]||null}async handleIntent(t,n){let i=this.handlers[t];return i?i.invoke(n):{intent:t,code:"error",message:"Invalid intent",issues:[`Intent ${t} not found`]}}initIntentHooks(){this.eventBus.addEventListener("before:view:home",()=>{new xn(this.swish,this.ui,this.options).invoke()}),this.eventBus.addEventListener("create:cart-line",t=>{new yn(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("save:item",t=>{new bn(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("edit:item-lists",t=>{new vn(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("view:home",t=>{new Sn(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("edit:list-access",t=>{new gn(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("initiate:share",t=>{new In(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("save:cart-line",t=>{new wn(this.swish,this.ui,this.options).invoke(t.detail.response)})}initCartChangeListener(){this.swish.events.subscribe(["cart-change","cart-update"],t=>{if(!this.options.removeCartLine.saveCartLine)return;let i=t.detail?.items_removed;if(!i?.length)return;let s=i.map(o=>({productId:o.product_id,variantId:o.variant_id,quantity:o.quantity,title:o.product_title,image:o.image,variantTitle:o.variant_title}));this.invoke("save:cart-line",{items:s})})}initIntentWatcher(){ht({selector:"[swish-intent]",onElementFound:r(t=>{let n=t.getAttribute("swish-intent");if(!n)return;let{intent:i,data:s}=this.parseIntentFromString(n);t.addEventListener("click",()=>{this.invokeFromParsed(i,s)})},"onElementFound")}),ht({selector:"a[href*='swish-intent='],a[href*='#swish']",onElementFound:r(t=>{t instanceof HTMLAnchorElement&&t.addEventListener("click",n=>{if(!n.metaKey&&!n.ctrlKey&&!n.shiftKey&&!n.altKey){let i=new URL(t.href),s=this.parseIntentFromUrl(i);if(s)n.preventDefault(),n.stopPropagation(),this.invokeFromParsed(s.intent,s.data);else if(i.hash){let o=this.parseIntentFromHash(i.hash);o&&(n.preventDefault(),n.stopPropagation(),this.invoke(o))}}})},"onElementFound")}),Ze({fireOnInit:!0,onLocationChange:r(t=>{if(this._invoking)return;let n=new URL(t.href),i=this.parseIntentFromUrl(n);if(i)n.searchParams.delete("swish-intent"),history.replaceState(history.state,"",n.toString()),this.invokeFromParsed(i.intent,i.data);else if(n.hash){let s=this.parseIntentFromHash(n.hash);s&&this.invoke(s)}},"onLocationChange")})}};var W=y(ne(x(),$([x(),_()])),{}),Dl=I({url:y(x(),""),altText:y(x(),"")}),Ll=I({id:x(),enabled:T(),intent:x()}),Ol=I({type:H("drawer-header"),hidden:y(T(),!1),design:W,options:y(I({title:y(x(),""),logo:y(Dl,{url:"",altText:""}),useCloseButton:y(T(),!1),accountButton:y(T(),!0),notificationButton:y(T(),!0)}),{title:"",logo:{url:"",altText:""},useCloseButton:!1,accountButton:!0,notificationButton:!0})}),_l=I({type:H("drawer-footer"),hidden:y(T(),!1),design:W,options:y(I({displayType:y(oe(["floating","docked"]),"docked"),showIcons:y(T(),!1),showText:y(T(),!0),items:y(z(Ll),[{id:"home",enabled:!0,intent:"view:home"},{id:"saves",enabled:!0,intent:"view:saves"},{id:"lists",enabled:!1,intent:"view:lists"},{id:"notifications",enabled:!0,intent:"view:notifications"},{id:"orders",enabled:!0,intent:"view:orders"},{id:"profile",enabled:!0,intent:"view:profile"}])}),{displayType:"docked",showIcons:!1,showText:!0,items:[{id:"home",enabled:!0,intent:"view:home"},{id:"saves",enabled:!0,intent:"view:saves"},{id:"lists",enabled:!1,intent:"view:lists"},{id:"notifications",enabled:!0,intent:"view:notifications"},{id:"orders",enabled:!0,intent:"view:orders"},{id:"profile",enabled:!0,intent:"view:profile"}]})}),Ml=ze("type",[Ol,_l]),ql=I({type:oe(["sign-in","notifications","recently-viewed","saved-from-cart","saved-items","lists"]),hidden:y(T(),!1),design:W,options:y(ne(x(),ae()),{})}),Bl=I({title:x(),url:x()}),Fl=I({type:H("mini-menu"),hidden:y(T(),!1),design:W,options:y(ne(x(),ae()),{}),items:y(z(Bl),[])}),jl=I({type:H("content-block"),hidden:y(T(),!1),design:W,options:y(ne(x(),ae()),{}),title:y(x()),body:y(x()),image:y(I({url:x(),width:y(_()),height:y(_())})),link:y(I({url:x(),target:y(oe(["_self","_blank"]))}))}),Nl=I({type:H("featured-collection"),hidden:y(T(),!1),design:W,options:y(ne(x(),ae()),{}),handle:x()}),Ul=ze("type",[ql,Fl,jl,Nl]),Vl=I({type:H("lists-section"),hidden:y(T(),!1),design:W,options:y(I({display:y(oe(["myLists","forYouLists"]),"myLists"),layout:y(oe(["list","slider"]),"slider")}),{display:"myLists",layout:"slider"})}),$l=I({type:H("all-items-grid"),hidden:y(T(),!1),design:W,options:y(I({showSaveButton:y(T(),!0),showQuickBuyButton:y(T(),!0),showVariantTitle:y(T(),!0),enableVariantChange:y(T(),!1),showVariantOptionNames:y(T(),!0)}),{showSaveButton:!0,showQuickBuyButton:!0,showVariantTitle:!0,enableVariantChange:!1,showVariantOptionNames:!0})}),Hl=ze("type",[Vl,$l]),Ql=I({type:H("lists-grid"),hidden:y(T(),!1),design:W,options:y(I({displayType:y(oe(["list","slider"]),"slider")}),{displayType:"slider"})}),zl=Ql,Gl=I({type:H("list-items-grid"),hidden:y(T(),!1),design:W,options:y(I({desktopColumns:y(_(),4),showBuyButton:y(T(),!0),showVariantOptionNames:y(T(),!1),enableVariantChange:y(T(),!0)}),{desktopColumns:4,showBuyButton:!0,showVariantOptionNames:!1,enableVariantChange:!0})}),Wl=Gl,Kl=I({type:H("list-items-grid"),hidden:y(T(),!1),design:W,options:y(I({showVariantOptionNames:y(T(),!1),enableVariantChange:y(T(),!1)}),{showVariantOptionNames:!1,enableVariantChange:!1})}),Xl=Kl,Jl=I({type:H("orders-list"),hidden:y(T(),!1),design:W,options:y(ne(x(),ae()),{})}),Yl=Jl,Zl=I({type:H("order-info"),hidden:y(T(),!1),design:W,options:y(ne(x(),ae()),{})}),ec=I({type:H("order-items"),hidden:y(T(),!1),design:W,options:y(ne(x(),ae()),{})}),tc=I({type:H("order-actions"),hidden:y(T(),!1),design:W,options:y(ne(x(),ae()),{})}),nc=ze("type",[Zl,ec,tc]),ic=I({type:H("image-slider"),hidden:y(T(),!1),design:W,options:y(I({flush:y(T(),!0),loop:y(T(),!1)}),{flush:!0,loop:!1})}),sc=I({type:H("product-info"),hidden:y(T(),!1),design:W,options:y(I({descriptionMaxLines:y(_(),4),variantSelectDisplayType:y(oe(["pills","rows"]),"pills"),hideSingleValueOptions:y(T(),!0),images:y(I({baseTint:y(T(),!0)}),{baseTint:!0})}),{descriptionMaxLines:4,variantSelectDisplayType:"pills",hideSingleValueOptions:!0,images:{baseTint:!0}})}),rc=I({type:H("buy-buttons"),hidden:y(T(),!1),design:W,options:y(I({shopPay:y(T(),!1)}),{shopPay:!1})}),oc=I({type:H("complementary-products"),hidden:y(T(),!1),design:W,options:y(ne(x(),ae()),{})}),ac=I({type:H("related-products"),hidden:y(T(),!1),design:W,options:y(ne(x(),ae()),{})}),lc=ze("type",[ic,sc,rc,oc,ac]),cc=I({type:H("profile-form"),hidden:y(T(),!1),design:W,options:y(ne(x(),ae()),{})}),uc=cc,dc=I({type:H("notifications-list"),hidden:y(T(),!1),design:W,options:y(ne(x(),ae()),{})}),pc=dc,hc=I({sections:y(z(Ml),[{type:"drawer-header",options:{title:"",logo:{url:"",altText:""},useCloseButton:!1,accountButton:!0,notificationButton:!0}},{type:"drawer-footer",options:{displayType:"docked",showIcons:!1,showText:!0,items:[{id:"home",enabled:!0,intent:"view:home"},{id:"saves",enabled:!0,intent:"view:saves"},{id:"lists",enabled:!1,intent:"view:lists"},{id:"notifications",enabled:!0,intent:"view:notifications"},{id:"orders",enabled:!0,intent:"view:orders"},{id:"profile",enabled:!0,intent:"view:profile"}]}}])}),fc=I({sections:y(z(Ul),[{type:"sign-in"},{type:"notifications"},{type:"recently-viewed"},{type:"saved-from-cart"},{type:"saved-items"},{type:"lists"},{type:"mini-menu",hidden:!0,items:[{title:"Shipping",url:"/policies/shipping-policy"},{title:"Returns",url:"/policies/refund-policy"},{title:"Contact Us",url:"/pages/contact"}]}])}),mc=I({sections:y(z(Hl),[{type:"lists-section",options:{display:"myLists"}},{type:"lists-section",options:{display:"forYouLists"}},{type:"all-items-grid"}])}),yc=I({sections:y(z(zl),[{type:"lists-grid"}])}),vc=I({sections:y(z(Wl),[{type:"list-items-grid"}])}),gc=I({sections:y(z(Xl),[{type:"list-items-grid"}])}),wc=I({sections:y(z(Yl),[{type:"orders-list"}])}),bc=I({sections:y(z(nc),[{type:"order-info"},{type:"order-items"},{type:"order-actions"}])}),Ic=I({sections:y(z(lc),[{type:"image-slider"},{type:"product-info"},{type:"buy-buttons"},{type:"complementary-products"},{type:"related-products"}])}),Sc=I({sections:y(z(uc),[{type:"profile-form"}])}),xc=I({sections:y(z(pc),[{type:"notifications-list"}])}),sr=I({baseUrl:y(x(),"https://swish.app/cdn"),css:y(z($([x(),li(URL)])),[]),design:y(ne(x(),ae()),{}),icons:y(ne(x(),x()),{}),images:y(I({baseTint:y(T(),!0)}),{baseTint:!0}),drawer:y(hc,{}),home:y(fc,{}),saves:y(mc,{}),lists:y(yc,{}),listDetail:y(gc,{}),listDetailPage:y(vc,{}),orders:y(wc,{}),orderDetail:y(bc,{}),productDetail:y(Ic,{}),profile:y(Sc,{}),notifications:y(xc,{})});var rr=r(e=>({auth:{tokenUrl:e.auth?.tokenUrl??"/apps/wishlist/api/profiles/token"},storefront:{storeDomain:e.storefront?.storeDomain??"",accessToken:e.storefront?.accessToken??""},context:{...e.context,routes:{...e.context.routes,rootUrl:e.context.routes?.rootUrl??"/",listDetailPagePath:e.context.routes?.listDetailPagePath??"/apps/wishlist"},localization:{country:e.context.localization.country.toUpperCase(),language:e.context.localization.language.toUpperCase(),market:e.context.localization.market}},metafields:{product:e.metafields?.product??[],productVariant:e.metafields?.productVariant??[]},transforms:{productTitle:e.transforms?.productTitle??(({product:t})=>t?.title??""),productDescription:e.transforms?.productDescription??(({product:t})=>t?.descriptionHtml??""),productBadges:e.transforms?.productBadges??(({defaultBadges:t})=>t),productPrice:e.transforms?.productPrice??(()=>{}),addToCartButton:e.transforms?.addToCartButton??(()=>!0),variantTitle:e.transforms?.variantTitle??(({variant:t})=>t?.title??""),optionValues:e.transforms?.optionValues??(({optionValues:t})=>t)},intents:{saveProduct:{promptVariantIfMissing:e?.intents?.saveProduct?.promptVariantIfMissing??!0,promptVariantIfPresent:e?.intents?.saveProduct?.promptVariantIfPresent??!1,saveBeforeVariantPrompt:e?.intents?.saveProduct?.saveBeforeVariantPrompt??!0,showFeedback:e?.intents?.saveProduct?.showFeedback??!0},unsaveProduct:{selectList:e?.intents?.unsaveProduct?.selectList??!0,confirm:e?.intents?.unsaveProduct?.confirm??!0,showFeedback:e?.intents?.unsaveProduct?.showFeedback??!0},editSavedProduct:{promptVariantChange:e?.intents?.editSavedProduct?.promptVariantChange??!0,showFeedback:e?.intents?.editSavedProduct?.showFeedback??!0},initiateQuickBuy:{promptVariantIfPresent:e?.intents?.initiateQuickBuy?.promptVariantIfPresent??!0},createCartLine:{afterComplete:e?.intents?.createCartLine?.afterComplete},removeCartLine:{saveCartLine:e?.intents?.removeCartLine?.saveCartLine??!0},saveCartLine:{confirm:e?.intents?.saveCartLine?.confirm??!1,showFeedback:e?.intents?.saveCartLine?.showFeedback??!0,afterComplete:e?.intents?.saveCartLine?.afterComplete}},placements:e.placements??[],translations:e.translations,ui:tr(sr,e.ui??{})}),"createSwishOptions");function or(e){return N(String(e).trim())}r(or,"normalizeSwishQueryId");function Cn(e){let t=e.productId?or(e.productId):"",n=e.variantId?or(e.variantId):"";return n?["swish","items",t,n]:["swish","items",t]}r(Cn,"swishItemsQueryKey");var Ec=["item-create","item-update","item-delete"],ar="auth-cache-clear",lr="token-update";function cr({events:e,queryClient:t}){return e.subscribe([...Ec,ar,lr],n=>{if(!(n instanceof CustomEvent))return;if(n.type===ar){t.clear();return}if(n.type===lr){t.invalidateQueries({queryKey:["swish"]});return}if(!n.detail?.productId)return;let i=Cn({productId:n.detail.productId});t.invalidateQueries({queryKey:i})})}r(cr,"bindSwishItemQueryInvalidation");var ke=class{static{r(this,"Subscribable")}constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};var Cc=class extends ke{static{r(this,"FocusManager")}#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<"u"&&window.addEventListener){let t=r(()=>e(),"listener");return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},it=new Cc;var Rc={setTimeout:r((e,t)=>setTimeout(e,t),"setTimeout"),clearTimeout:r(e=>clearTimeout(e),"clearTimeout"),setInterval:r((e,t)=>setInterval(e,t),"setInterval"),clearInterval:r(e=>clearInterval(e),"clearInterval")},kc=class{static{r(this,"TimeoutManager")}#e=Rc;#t=!1;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}},Ae=new kc;function ur(e){setTimeout(e,0)}r(ur,"systemSetTimeoutZero");var hr=typeof window>"u"||"Deno"in globalThis;function K(){}r(K,"noop");function fr(e,t){return typeof e=="function"?e(t):e}r(fr,"functionalUpdate");function St(e){return typeof e=="number"&&e>=0&&e!==1/0}r(St,"isValidTimeout");function Rn(e,t){return Math.max(e+(t||0)-Date.now(),0)}r(Rn,"timeUntilStale");function xe(e,t){return typeof e=="function"?e(t):e}r(xe,"resolveStaleTime");function he(e,t){return typeof e=="function"?e(t):e}r(he,"resolveEnabled");function ui(e,t){let{type:n="all",exact:i,fetchStatus:s,predicate:o,queryKey:a,stale:l}=e;if(a){if(i){if(t.queryHash!==xt(a,t.options))return!1}else if(!rt(t.queryKey,a))return!1}if(n!=="all"){let c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof l=="boolean"&&t.isStale()!==l||s&&s!==t.state.fetchStatus||o&&!o(t))}r(ui,"matchQuery");function di(e,t){let{exact:n,status:i,predicate:s,mutationKey:o}=e;if(o){if(!t.options.mutationKey)return!1;if(n){if(st(t.options.mutationKey)!==st(o))return!1}else if(!rt(t.options.mutationKey,o))return!1}return!(i&&t.state.status!==i||s&&!s(t))}r(di,"matchMutation");function xt(e,t){return(t?.queryKeyHashFn||st)(e)}r(xt,"hashQueryKeyByOptions");function st(e){return JSON.stringify(e,(t,n)=>ci(n)?Object.keys(n).sort().reduce((i,s)=>(i[s]=n[s],i),{}):n)}r(st,"hashKey");function rt(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>rt(e[n],t[n])):!1}r(rt,"partialMatchKey");var Ac=Object.prototype.hasOwnProperty;function mr(e,t,n=0){if(e===t)return e;if(n>500)return t;let i=dr(e)&&dr(t);if(!i&&!(ci(e)&&ci(t)))return t;let o=(i?e:Object.keys(e)).length,a=i?t:Object.keys(t),l=a.length,c=i?new Array(l):{},d=0;for(let u=0;u<l;u++){let p=i?u:a[u],f=e[p],h=t[p];if(f===h){c[p]=f,(i?u<o:Ac.call(e,p))&&d++;continue}if(f===null||h===null||typeof f!="object"||typeof h!="object"){c[p]=h;continue}let w=mr(f,h,n+1);c[p]=w,w===f&&d++}return o===l&&d===o?e:c}r(mr,"replaceEqualDeep");function kn(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}r(kn,"shallowEqualObjects");function dr(e){return Array.isArray(e)&&e.length===Object.keys(e).length}r(dr,"isPlainArray");function ci(e){if(!pr(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!pr(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}r(ci,"isPlainObject");function pr(e){return Object.prototype.toString.call(e)==="[object Object]"}r(pr,"hasObjectPrototype");function yr(e){return new Promise(t=>{Ae.setTimeout(t,e)})}r(yr,"sleep");function Et(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?mr(e,t):t}r(Et,"replaceData");function vr(e,t,n=0){let i=[...e,t];return n&&i.length>n?i.slice(1):i}r(vr,"addToEnd");function gr(e,t,n=0){let i=[t,...e];return n&&i.length>n?i.slice(0,-1):i}r(gr,"addToStart");var Ct=Symbol();function An(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Ct?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}r(An,"ensureQueryFn");function wr(e,t,n){let i=!1,s;return Object.defineProperty(e,"signal",{enumerable:!0,get:r(()=>(s??=t(),i||(i=!0,s.aborted?n():s.addEventListener("abort",n,{once:!0})),s),"get")}),e}r(wr,"addConsumeAwareSignal");var Ge=(()=>{let e=r(()=>hr,"isServerFn");return{isServer(){return e()},setIsServer(t){e=t}}})();function Rt(){let e,t,n=new Promise((s,o)=>{e=s,t=o});n.status="pending",n.catch(()=>{});function i(s){Object.assign(n,s),delete n.resolve,delete n.reject}return r(i,"finalize"),n.resolve=s=>{i({status:"fulfilled",value:s}),e(s)},n.reject=s=>{i({status:"rejected",reason:s}),t(s)},n}r(Rt,"pendingThenable");function br(e){let t;if(e.then(n=>(t=n,n),K)?.catch(K),t!==void 0)return{data:t}}r(br,"tryResolveSync");function Ir(e){return e}r(Ir,"defaultTransformerFn");function Pc(e){return{mutationKey:e.options.mutationKey,state:e.state,...e.options.scope&&{scope:e.options.scope},...e.meta&&{meta:e.meta}}}r(Pc,"dehydrateMutation");function Tc(e,t,n){let i=r(()=>{let s=e.promise?.then(t).catch(o=>n(o)?Promise.reject(new Error("redacted")):Promise.reject(o));return s?.catch(K),s},"dehydratePromise");return{dehydratedAt:Date.now(),state:{...e.state,...e.state.data!==void 0&&{data:t(e.state.data)}},queryKey:e.queryKey,queryHash:e.queryHash,...e.state.status==="pending"&&{promise:i()},...e.meta&&{meta:e.meta}}}r(Tc,"dehydrateQuery");function Sr(e){return e.state.isPaused}r(Sr,"defaultShouldDehydrateMutation");function xr(e){return e.state.status==="success"}r(xr,"defaultShouldDehydrateQuery");function Dc(e){return!0}r(Dc,"defaultShouldRedactErrors");function pi(e,t={}){let n=t.shouldDehydrateMutation??e.getDefaultOptions().dehydrate?.shouldDehydrateMutation??Sr,i=e.getMutationCache().getAll().flatMap(c=>n(c)?[Pc(c)]:[]),s=t.shouldDehydrateQuery??e.getDefaultOptions().dehydrate?.shouldDehydrateQuery??xr,o=t.shouldRedactErrors??e.getDefaultOptions().dehydrate?.shouldRedactErrors??Dc,a=t.serializeData??e.getDefaultOptions().dehydrate?.serializeData??Ir,l=e.getQueryCache().getAll().flatMap(c=>s(c)?[Tc(c,a,o)]:[]);return{mutations:i,queries:l}}r(pi,"dehydrate");function hi(e,t,n){if(typeof t!="object"||t===null)return;let i=e.getMutationCache(),s=e.getQueryCache(),o=n?.defaultOptions?.deserializeData??e.getDefaultOptions().hydrate?.deserializeData??Ir,a=t.mutations||[],l=t.queries||[];a.forEach(({state:c,...d})=>{i.build(e,{...e.getDefaultOptions().hydrate?.mutations,...n?.defaultOptions?.mutations,...d},c)}),l.forEach(({queryKey:c,state:d,queryHash:u,meta:p,promise:f,dehydratedAt:h})=>{let w=f?br(f):void 0,m=d.data===void 0?w?.data:d.data,b=m===void 0?m:o(m),S=s.get(u),k=S?.state.status==="pending",P=S?.state.fetchStatus==="fetching";if(S){let D=w&&h!==void 0&&h>S.state.dataUpdatedAt;if(d.dataUpdatedAt>S.state.dataUpdatedAt||D){let{fetchStatus:E,...A}=d;S.setState({...A,data:b})}}else S=s.build(e,{...e.getDefaultOptions().hydrate?.queries,...n?.defaultOptions?.queries,queryKey:c,queryHash:u,meta:p},{...d,data:b,fetchStatus:"idle",status:b!==void 0?"success":d.status});f&&!k&&!P&&(h===void 0||h>S.state.dataUpdatedAt)&&S.fetch(void 0,{initialPromise:Promise.resolve(f).then(o)}).catch(K)})}r(hi,"hydrate");var Lc=ur;function Oc(){let e=[],t=0,n=r(l=>{l()},"notifyFn"),i=r(l=>{l()},"batchNotifyFn"),s=Lc,o=r(l=>{t?e.push(l):s(()=>{n(l)})},"schedule"),a=r(()=>{let l=e;e=[],l.length&&s(()=>{i(()=>{l.forEach(c=>{n(c)})})})},"flush");return{batch:r(l=>{let c;t++;try{c=l()}finally{t--,t||a()}return c},"batch"),batchCalls:r(l=>(...c)=>{o(()=>{l(...c)})},"batchCalls"),schedule:o,setNotifyFunction:r(l=>{n=l},"setNotifyFunction"),setBatchNotifyFunction:r(l=>{i=l},"setBatchNotifyFunction"),setScheduler:r(l=>{s=l},"setScheduler")}}r(Oc,"createNotifyManager");var X=Oc();var _c=class extends ke{static{r(this,"OnlineManager")}#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<"u"&&window.addEventListener){let t=r(()=>e(!0),"onlineListener"),n=r(()=>e(!1),"offlineListener");return window.addEventListener("online",t,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(n=>{n(e)}))}isOnline(){return this.#e}},ot=new _c;function Mc(e){return Math.min(1e3*2**e,3e4)}r(Mc,"defaultRetryDelay");function fi(e){return(e??"online")==="online"?ot.isOnline():!0}r(fi,"canFetch");var Pn=class extends Error{static{r(this,"CancelledError")}constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function Tn(e){let t=!1,n=0,i,s=Rt(),o=r(()=>s.status!=="pending","isResolved"),a=r(m=>{if(!o()){let b=new Pn(m);f(b),e.onCancel?.(b)}},"cancel"),l=r(()=>{t=!0},"cancelRetry"),c=r(()=>{t=!1},"continueRetry"),d=r(()=>it.isFocused()&&(e.networkMode==="always"||ot.isOnline())&&e.canRun(),"canContinue"),u=r(()=>fi(e.networkMode)&&e.canRun(),"canStart"),p=r(m=>{o()||(i?.(),s.resolve(m))},"resolve"),f=r(m=>{o()||(i?.(),s.reject(m))},"reject"),h=r(()=>new Promise(m=>{i=r(b=>{(o()||d())&&m(b)},"continueFn"),e.onPause?.()}).then(()=>{i=void 0,o()||e.onContinue?.()}),"pause"),w=r(()=>{if(o())return;let m,b=n===0?e.initialPromise:void 0;try{m=b??e.fn()}catch(S){m=Promise.reject(S)}Promise.resolve(m).then(p).catch(S=>{if(o())return;let k=e.retry??(Ge.isServer()?0:3),P=e.retryDelay??Mc,D=typeof P=="function"?P(n,S):P,E=k===!0||typeof k=="number"&&n<k||typeof k=="function"&&k(n,S);if(t||!E){f(S);return}n++,e.onFail?.(n,S),yr(D).then(()=>d()?void 0:h()).then(()=>{t?f(S):w()})})},"run");return{promise:s,status:r(()=>s.status,"status"),cancel:a,continue:r(()=>(i?.(),s),"continue"),cancelRetry:l,continueRetry:c,canStart:u,start:r(()=>(u()?w():h().then(w),s),"start")}}r(Tn,"createRetryer");var Dn=class{static{r(this,"Removable")}#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),St(this.gcTime)&&(this.#e=Ae.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Ge.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e&&(Ae.clearTimeout(this.#e),this.#e=void 0)}};var Rr=class extends Dn{static{r(this,"Query")}#e;#t;#n;#s;#i;#o;#r;constructor(e){super(),this.#r=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#s=e.client,this.#n=this.#s.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=Cr(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#i?.promise}setOptions(e){if(this.options={...this.#o,...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let t=Cr(this.options);t.data!==void 0&&(this.setState(Er(t.data,t.dataUpdatedAt)),this.#e=t)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(e,t){let n=Et(this.state.data,e,this.options);return this.#l({data:n,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#l({type:"setState",state:e,setStateOptions:t})}cancel(e){let t=this.#i?.promise;return this.#i?.cancel(e),t?t.then(K).catch(K):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#e}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>he(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Ct||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>xe(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!Rn(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#i&&(this.#r||this.#a()?this.#i.cancel({revert:!0}):this.#i.cancelRetry()),this.scheduleGc()),this.#n.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}#a(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"}invalidate(){this.state.isInvalidated||this.#l({type:"invalidate"})}async fetch(e,t){if(this.state.fetchStatus!=="idle"&&this.#i?.status()!=="rejected"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.promise}if(e&&this.setOptions(e),!this.options.queryFn){let l=this.observers.find(c=>c.options.queryFn);l&&this.setOptions(l.options)}let n=new AbortController,i=r(l=>{Object.defineProperty(l,"signal",{enumerable:!0,get:r(()=>(this.#r=!0,n.signal),"get")})},"addSignalProperty"),s=r(()=>{let l=An(this.options,t),d=r(()=>{let u={client:this.#s,queryKey:this.queryKey,meta:this.meta};return i(u),u},"createQueryFnContext")();return this.#r=!1,this.options.persister?this.options.persister(l,d,this):l(d)},"fetchFn"),a=r(()=>{let l={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#s,state:this.state,fetchFn:s};return i(l),l},"createFetchContext")();this.options.behavior?.onFetch(a,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#l({type:"fetch",meta:a.fetchOptions?.meta}),this.#i=Tn({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:r(l=>{l instanceof Pn&&l.revert&&this.setState({...this.#t,fetchStatus:"idle"}),n.abort()},"onCancel"),onFail:r((l,c)=>{this.#l({type:"failed",failureCount:l,error:c})},"onFail"),onPause:r(()=>{this.#l({type:"pause"})},"onPause"),onContinue:r(()=>{this.#l({type:"continue"})},"onContinue"),retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:r(()=>!0,"canRun")});try{let l=await this.#i.start();if(l===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(l),this.#n.config.onSuccess?.(l,this),this.#n.config.onSettled?.(l,this.state.error,this),l}catch(l){if(l instanceof Pn){if(l.silent)return this.#i.promise;if(l.revert){if(this.state.data===void 0)throw l;return this.state.data}}throw this.#l({type:"error",error:l}),this.#n.config.onError?.(l,this),this.#n.config.onSettled?.(this.state.data,l,this),l}finally{this.scheduleGc()}}#l(e){let t=r(n=>{switch(e.type){case"failed":return{...n,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...mi(n.data,this.options),fetchMeta:e.meta??null};case"success":let i={...n,...Er(e.data,e.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#t=e.manual?i:void 0,i;case"error":let s=e.error;return{...n,error:s,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...e.state}}},"reducer");this.state=t(this.state),X.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:e})})}};function mi(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:fi(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}r(mi,"fetchState");function Er(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}r(Er,"successState");function Cr(e){let t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,i=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?i??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}r(Cr,"getDefaultState");var vi=class extends ke{static{r(this,"QueryObserver")}constructor(e,t){super(),this.options=t,this.#e=e,this.#a=null,this.#r=Rt(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#s=void 0;#i;#o;#r;#a;#l;#h;#f;#u;#d;#c;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),kr(this.#t,this.options)?this.#p():this.updateResult(),this.#w())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return yi(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return yi(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#I(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof he(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#S(),this.#t.setOptions(this.options),t._defaulted&&!kn(this.options,t)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});let i=this.hasListeners();i&&Ar(this.#t,n,this.options,t)&&this.#p(),this.updateResult(),i&&(this.#t!==n||he(this.options.enabled,this.#t)!==he(t.enabled,this.#t)||xe(this.options.staleTime,this.#t)!==xe(t.staleTime,this.#t))&&this.#y();let s=this.#v();i&&(this.#t!==n||he(this.options.enabled,this.#t)!==he(t.enabled,this.#t)||s!==this.#c)&&this.#g(s)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return Bc(this,n)&&(this.#s=n,this.#o=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#s}trackResult(e,t){return new Proxy(e,{get:r((n,i)=>(this.trackProp(i),t?.(i),i==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#r.status==="pending"&&this.#r.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,i)),"get")})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#p({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#s))}#p(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(K)),t}#y(){this.#b();let e=xe(this.options.staleTime,this.#t);if(Ge.isServer()||this.#s.isStale||!St(e))return;let n=Rn(this.#s.dataUpdatedAt,e)+1;this.#u=Ae.setTimeout(()=>{this.#s.isStale||this.updateResult()},n)}#v(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#g(e){this.#I(),this.#c=e,!(Ge.isServer()||he(this.options.enabled,this.#t)===!1||!St(this.#c)||this.#c===0)&&(this.#d=Ae.setInterval(()=>{(this.options.refetchIntervalInBackground||it.isFocused())&&this.#p()},this.#c))}#w(){this.#y(),this.#g(this.#v())}#b(){this.#u&&(Ae.clearTimeout(this.#u),this.#u=void 0)}#I(){this.#d&&(Ae.clearInterval(this.#d),this.#d=void 0)}createResult(e,t){let n=this.#t,i=this.options,s=this.#s,o=this.#i,a=this.#o,c=e!==n?e.state:this.#n,{state:d}=e,u={...d},p=!1,f;if(t._optimisticResults){let B=this.hasListeners(),ce=!B&&kr(e,t),Ee=B&&Ar(e,n,t,i);(ce||Ee)&&(u={...u,...mi(d.data,e.options)}),t._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:h,errorUpdatedAt:w,status:m}=u;f=u.data;let b=!1;if(t.placeholderData!==void 0&&f===void 0&&m==="pending"){let B;s?.isPlaceholderData&&t.placeholderData===a?.placeholderData?(B=s.data,b=!0):B=typeof t.placeholderData=="function"?t.placeholderData(this.#f?.state.data,this.#f):t.placeholderData,B!==void 0&&(m="success",f=Et(s?.data,B,t),p=!0)}if(t.select&&f!==void 0&&!b)if(s&&f===o?.data&&t.select===this.#l)f=this.#h;else try{this.#l=t.select,f=t.select(f),f=Et(s?.data,f,t),this.#h=f,this.#a=null}catch(B){this.#a=B}this.#a&&(h=this.#a,f=this.#h,w=Date.now(),m="error");let S=u.fetchStatus==="fetching",k=m==="pending",P=m==="error",D=k&&S,E=f!==void 0,C={status:m,fetchStatus:u.fetchStatus,isPending:k,isSuccess:m==="success",isError:P,isInitialLoading:D,isLoading:D,data:f,dataUpdatedAt:u.dataUpdatedAt,error:h,errorUpdatedAt:w,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:u.dataUpdateCount>c.dataUpdateCount||u.errorUpdateCount>c.errorUpdateCount,isFetching:S,isRefetching:S&&!k,isLoadingError:P&&!E,isPaused:u.fetchStatus==="paused",isPlaceholderData:p,isRefetchError:P&&E,isStale:gi(e,t),refetch:this.refetch,promise:this.#r,isEnabled:he(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let B=C.data!==void 0,ce=C.status==="error"&&!B,Ee=r(ye=>{ce?ye.reject(C.error):B&&ye.resolve(C.data)},"finalizeThenableIfPossible"),De=r(()=>{let ye=this.#r=C.promise=Rt();Ee(ye)},"recreateThenable"),te=this.#r;switch(te.status){case"pending":e.queryHash===n.queryHash&&Ee(te);break;case"fulfilled":(ce||C.data!==te.value)&&De();break;case"rejected":(!ce||C.error!==te.reason)&&De();break}}return C}updateResult(){let e=this.#s,t=this.createResult(this.#t,this.options);if(this.#i=this.#t.state,this.#o=this.options,this.#i.data!==void 0&&(this.#f=this.#t),kn(t,e))return;this.#s=t;let n=r(()=>{if(!e)return!0;let{notifyOnChangeProps:i}=this.options,s=typeof i=="function"?i():i;if(s==="all"||!s&&!this.#m.size)return!0;let o=new Set(s??this.#m);return this.options.throwOnError&&o.add("error"),Object.keys(this.#s).some(a=>{let l=a;return this.#s[l]!==e[l]&&o.has(l)})},"shouldNotifyListeners");this.#x({listeners:n()})}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#w()}#x(e){X.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#s)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function qc(e,t){return he(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}r(qc,"shouldLoadOnMount");function kr(e,t){return qc(e,t)||e.state.data!==void 0&&yi(e,t,t.refetchOnMount)}r(kr,"shouldFetchOnMount");function yi(e,t,n){if(he(t.enabled,e)!==!1&&xe(t.staleTime,e)!=="static"){let i=typeof n=="function"?n(e):n;return i==="always"||i!==!1&&gi(e,t)}return!1}r(yi,"shouldFetchOn");function Ar(e,t,n,i){return(e!==t||he(i.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&gi(e,n)}r(Ar,"shouldFetchOptionally");function gi(e,t){return he(t.enabled,e)!==!1&&e.isStaleByTime(xe(t.staleTime,e))}r(gi,"isStale");function Bc(e,t){return!kn(e.getCurrentResult(),t)}r(Bc,"shouldAssignObserverCurrentProperties");function wi(e){return{onFetch:r((t,n)=>{let i=t.options,s=t.fetchOptions?.meta?.fetchMore?.direction,o=t.state.data?.pages||[],a=t.state.data?.pageParams||[],l={pages:[],pageParams:[]},c=0,d=r(async()=>{let u=!1,p=r(w=>{wr(w,()=>t.signal,()=>u=!0)},"addSignalProperty"),f=An(t.options,t.fetchOptions),h=r(async(w,m,b)=>{if(u)return Promise.reject();if(m==null&&w.pages.length)return Promise.resolve(w);let k=r(()=>{let A={client:t.client,queryKey:t.queryKey,pageParam:m,direction:b?"backward":"forward",meta:t.options.meta};return p(A),A},"createQueryFnContext")(),P=await f(k),{maxPages:D}=t.options,E=b?gr:vr;return{pages:E(w.pages,P,D),pageParams:E(w.pageParams,m,D)}},"fetchPage");if(s&&o.length){let w=s==="backward",m=w?Fc:Pr,b={pages:o,pageParams:a},S=m(i,b);l=await h(b,S,w)}else{let w=e??o.length;do{let m=c===0?a[0]??i.initialPageParam:Pr(i,l);if(c>0&&m==null)break;l=await h(l,m),c++}while(c<w)}return l},"fetchFn");t.options.persister?t.fetchFn=()=>t.options.persister?.(d,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=d},"onFetch")}}r(wi,"infiniteQueryBehavior");function Pr(e,{pages:t,pageParams:n}){let i=t.length-1;return t.length>0?e.getNextPageParam(t[i],t,n[i],n):void 0}r(Pr,"getNextPageParam");function Fc(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}r(Fc,"getPreviousPageParam");var Tr=class extends Dn{static{r(this,"Mutation")}#e;#t;#n;#s;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||jc(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#n.remove(this))}continue(){return this.#s?.continue()??this.execute(this.state.variables)}async execute(e){let t=r(()=>{this.#i({type:"continue"})},"onContinue"),n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#s=Tn({fn:r(()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(new Error("No mutationFn found")),"fn"),onFail:r((o,a)=>{this.#i({type:"failed",failureCount:o,error:a})},"onFail"),onPause:r(()=>{this.#i({type:"pause"})},"onPause"),onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:r(()=>this.#n.canRun(this),"canRun")});let i=this.state.status==="pending",s=!this.#s.canStart();try{if(i)t();else{this.#i({type:"pending",variables:e,isPaused:s}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let a=await this.options.onMutate?.(e,n);a!==this.state.context&&this.#i({type:"pending",context:a,variables:e,isPaused:s})}let o=await this.#s.start();return await this.#n.config.onSuccess?.(o,e,this.state.context,this,n),await this.options.onSuccess?.(o,e,this.state.context,n),await this.#n.config.onSettled?.(o,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(o,null,e,this.state.context,n),this.#i({type:"success",data:o}),o}catch(o){try{await this.#n.config.onError?.(o,e,this.state.context,this,n)}catch(a){Promise.reject(a)}try{await this.options.onError?.(o,e,this.state.context,n)}catch(a){Promise.reject(a)}try{await this.#n.config.onSettled?.(void 0,o,this.state.variables,this.state.context,this,n)}catch(a){Promise.reject(a)}try{await this.options.onSettled?.(void 0,o,e,this.state.context,n)}catch(a){Promise.reject(a)}throw this.#i({type:"error",error:o}),o}finally{this.#n.runNext(this)}}#i(e){let t=r(n=>{switch(e.type){case"failed":return{...n,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...n,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:e.error,failureCount:n.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}},"reducer");this.state=t(this.state),X.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:"updated",action:e})})}};function jc(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}r(jc,"getDefaultState");var Dr=class extends ke{static{r(this,"MutationCache")}constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let i=new Tr({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(i),i}add(e){this.#e.add(e);let t=Ln(e);if(typeof t=="string"){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){let t=Ln(e);if(typeof t=="string"){let n=this.#t.get(t);if(n)if(n.length>1){let i=n.indexOf(e);i!==-1&&n.splice(i,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){let t=Ln(e);if(typeof t=="string"){let i=this.#t.get(t)?.find(s=>s.state.status==="pending");return!i||i===e}else return!0}runNext(e){let t=Ln(e);return typeof t=="string"?this.#t.get(t)?.find(i=>i!==e&&i.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){X.batch(()=>{this.#e.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(n=>di(t,n))}findAll(e={}){return this.getAll().filter(t=>di(e,t))}notify(e){X.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(t=>t.state.isPaused);return X.batch(()=>Promise.all(e.map(t=>t.continue().catch(K))))}};function Ln(e){return e.options.scope?.id}r(Ln,"scopeFor");var Lr=class extends ke{static{r(this,"QueryCache")}constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let i=t.queryKey,s=t.queryHash??xt(i,t),o=this.get(s);return o||(o=new Rr({client:e,queryKey:i,queryHash:s,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(i)}),this.add(o)),o}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){X.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(n=>ui(t,n))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(n=>ui(e,n)):t}notify(e){X.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){X.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){X.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}};var bi=class{static{r(this,"QueryClient")}#e;#t;#n;#s;#i;#o;#r;#a;constructor(e={}){this.#e=e.queryCache||new Lr,this.#t=e.mutationCache||new Dr,this.#n=e.defaultOptions||{},this.#s=new Map,this.#i=new Map,this.#o=0}mount(){this.#o++,this.#o===1&&(this.#r=it.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=ot.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#o--,this.#o===0&&(this.#r?.(),this.#r=void 0,this.#a?.(),this.#a=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),i=n.state.data;return i===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(xe(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(i))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:n})=>{let i=n.data;return[t,i]})}setQueryData(e,t,n){let i=this.defaultQueryOptions({queryKey:e}),o=this.#e.get(i.queryHash)?.state.data,a=fr(t,o);if(a!==void 0)return this.#e.build(this,i).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return X.batch(()=>this.#e.findAll(e).map(({queryKey:i})=>[i,this.setQueryData(i,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;X.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){let n=this.#e;return X.batch(()=>(n.findAll(e).forEach(i=>{i.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},i=X.batch(()=>this.#e.findAll(e).map(s=>s.cancel(n)));return Promise.all(i).then(K).catch(K)}invalidateQueries(e,t={}){return X.batch(()=>(this.#e.findAll(e).forEach(n=>{n.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},i=X.batch(()=>this.#e.findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let o=s.fetch(void 0,n);return n.throwOnError||(o=o.catch(K)),s.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(i).then(K)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(xe(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(K).catch(K)}fetchInfiniteQuery(e){return e.behavior=wi(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(K).catch(K)}ensureInfiniteQueryData(e){return e.behavior=wi(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return ot.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#s.set(st(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#s.values()],n={};return t.forEach(i=>{rt(e,i.queryKey)&&Object.assign(n,i.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(st(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(i=>{rt(e,i.mutationKey)&&Object.assign(n,i.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=xt(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Ct&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}};function Or(){return new bi({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1,gcTime:1e3*60*60*1,staleTime:1e3*60*10}}})}r(Or,"createSwishQueryClient");var Nc="swish-query-cache";function Uc(e){return e.replace(/\.myshopify\.com$/,"")||"unknown-store"}r(Uc,"normalizeStoreKeyPart");function On({customerId:e,storeDomain:t}){let n=e??"guest",i=Uc(t??"");return`${Nc}:${i}:${n}`}r(On,"getSwishQueryStorageKey");var Vc=1e3*60*60*24,$c=1e3;function Ii(){return!!globalThis.window?.localStorage}r(Ii,"canUseLocalStorage");function Hc(e){if(!Ii())return null;let t=globalThis.window.localStorage.getItem(e);if(!t)return null;try{return JSON.parse(t)}catch{return globalThis.window.localStorage.removeItem(e),null}}r(Hc,"readPersistedState");function Qc(e,t){if(Ii())try{globalThis.window.localStorage.setItem(e,JSON.stringify(t))}catch{}}r(Qc,"writePersistedState");function zc(e){if(Ii())try{globalThis.window.localStorage.removeItem(e)}catch{}}r(zc,"removePersistedState");function Gc(e,t){return Number.isFinite(e.timestamp)?Date.now()-e.timestamp>t:!0}r(Gc,"isPersistedStateExpired");function _r({queryClient:e,cacheBuster:t,customerId:n,storeDomain:i,maxAgeMs:s=Vc,throttleMs:o=$c}){let a=On({customerId:n,storeDomain:i}),l=F(!1),c=Hc(a);c?.buster===t&&!Gc(c,s)?hi(e,c.clientState):c&&zc(a),l.value=!0;let d=null,u=!1,p=r(()=>{Qc(a,{buster:t,timestamp:Date.now(),clientState:pi(e)})},"persistNow"),f=r(()=>{u=!0,!d&&(d=setTimeout(()=>{d=null,u&&(u=!1,p())},Math.max(o,0)))},"schedulePersist"),h=r(()=>{u&&(u=!1,d&&(clearTimeout(d),d=null),p())},"flushPersist"),w=e.getQueryCache().subscribe(b=>{l.value&&f()}),m=r(()=>{h()},"onPageHide");return globalThis.window?.addEventListener("pagehide",m),{restored:l,storageKey:a,dispose:r(()=>{globalThis.window?.removeEventListener("pagehide",m),w(),h()},"dispose")}}r(_r,"initSwishQueryPersistence");function Mr({events:e,cacheBuster:t,customerId:n,storeDomain:i}){let s=Or(),o=_r({queryClient:s,cacheBuster:t,customerId:n,storeDomain:i});return cr({events:e,queryClient:s}),{client:s,cacheBuster:t,restored:o.restored,storageKey:o.storageKey,keys:{items:Cn}}}r(Mr,"createSwishQuery");var qr=r(e=>F({loading:!1,productId:e.productId==null?void 0:String(e.productId),variantId:e.variantId==null?void 0:String(e.variantId),itemId:e.itemId??void 0}),"itemContextFromIds"),Br=r(e=>t=>{let n=t instanceof Location,i=t instanceof HTMLAnchorElement,s=t instanceof HTMLElement;if(!n&&!i&&!s)throw new Error("Invalid source");let{productHandle:o,productId:a,variantId:l,itemId:c}=s?t.dataset:{},p=!!(a||o)||!!c,f=F({loading:!1,productHandle:o,productId:a,variantId:l,itemId:c});if(!p&&(n||i)){let h=t.href,w=vt(h);w?.productHandle&&w.productHandle!==f.value.productHandle&&(f.value={...f.value,...w,productId:void 0},Ys({source:t,onProductUrlChange:r(m=>{f.value={...f.value,...m,productId:m.productHandle===f.value.productHandle?f.value.productId:void 0}},"onProductUrlChange")}))}return Z(()=>{f.value.loading||!f.value.productId&&f.value.productHandle&&(f.value={...f.value,loading:!0},e.storefront.loadProductId({productHandle:f.value.productHandle}).then(h=>{h.errors&&console.error("Error loading product id",h.errors);let w=h.data?.product?.id?N(h.data.product.id):void 0;f.value={...f.value,productId:w,loading:!w}}))}),f},"itemContextSignal");function Fr({queryClient:e,options:t,restored:n}){let i=F(null),s=F(!1),o=F(null),a=F(!1),l=r(w=>{let m=n?.value??!0,b=w.enabled??!0;return{...w,enabled:!!(b&&m)}},"getObserverOptions"),c=new vi(e,l(t.value)),d=r(w=>{ie(()=>{i.value=w.data??null,s.value=w.isLoading,a.value=w.isRefetching,o.value=w.error??null})},"syncResult"),u=c.subscribe(d);d(c.getCurrentResult());let p=Z(()=>{c.setOptions(l(t.value))}),f=!1;return{data:i,loading:s,error:o,refetching:a,refetch:r(()=>c.refetch(),"refetch"),dispose:r(()=>{f||(f=!0,p(),u(),c.destroy())},"dispose")}}r(Fr,"createTanstackQuerySignal");var Si=50;function jr(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}r(jr,"arraysShallowEqual");function Wc(e,t,n){if(n==="variant"||n==="auto"&&!!t){if(!t)return null;let s=N(t);return e.find(o=>String(o.variantId)===s)??null}return e[0]??null}r(Wc,"pickSavedItem");function Kc(e){ie(()=>{if(e.savedItemsLoading.value=e.apiLoading,e.savedItemsError.value=e.apiError,e.forcedItemId){let o=[e.forcedItemId];jr(e.savedItemIds.value,o)||(e.savedItemIds.value=o),e.savedItemId.value!==e.forcedItemId&&(e.savedItemId.value=e.forcedItemId);return}let t=e.apiData?.data??[];t.length>=Si&&console.warn(`[swish] item-state query hit the per-product limit (${Si}). Some saved items may be missing.`);let n=t.map(o=>o.id);jr(e.savedItemIds.value,n)||(e.savedItemIds.value=n);let s=Wc(t,e.variantId,e.policy)?.id??null;s!==e.savedItemId.value&&(e.savedItemId.value=s)})}r(Kc,"syncFromApi");var Nr=r(e=>(t,n={})=>{let i=[],s={onSave:n.onSave,onUnsave:n.onUnsave,onListsUpdate:n.onListsUpdate,onVariantUpdate:n.onVariantUpdate},o=F(n.match??"auto"),a=r(Q=>{s.onSave=Q.onSave,s.onUnsave=Q.onUnsave,s.onListsUpdate=Q.onListsUpdate,s.onVariantUpdate=Q.onVariantUpdate;let J=Q.match??"auto";o.value!==J&&(o.value=J)},"setOptions"),l=de(()=>{let{productId:Q,loading:J}=t.value;return!Q||J?null:`product:${N(Q)}`}),c=de(()=>t.value.loading||!!t.value.itemId||!t.value.productId),d=F(!c.value),u=F(null),p=F(!1),f=F(!1),h=F(!1),w=de(()=>p.value||f.value||h.value),m=F(!1),b=F(!1),S=de(()=>{let Q=l.value,J=c.value,{productId:fe}=t.value;return{queryKey:e.query.keys.items({productId:fe}),queryFn:r(async()=>{let we=await e.api.items.list({limit:Si,query:Q??void 0},{batch:!0});if("error"in we)throw we.error;return we},"queryFn"),enabled:!J}}),{data:k,loading:P,error:D,refetching:E,dispose:A}=Fr({queryClient:e.query.client,options:S,restored:e.query.restored});i.push(A);let C=t.value.itemId??null,B=F(C),ce=F(C?[C]:[]),Ee=Z(()=>Kc({apiData:k.value,apiLoading:P.value,apiError:D.value,forcedItemId:t.value.itemId,variantId:t.value.variantId,policy:o.value,savedItemId:B,savedItemIds:ce,savedItemsLoading:d,savedItemsError:u}));i.push(Ee);async function De(){if(!B.value)return;ie(()=>{f.value=!0,b.value=!0});let J=await(await e.intents.invoke("unsave:item",{itemId:B.value})).complete;if(J.code==="ok"){let fe=J.data;"itemId"in fe?(ie(()=>{B.value=null,f.value=!1}),s.onUnsave?.(fe)):f.value=!1}else ie(()=>{f.value=!1,b.value=!1})}r(De,"unsave");async function te(){if(!B.value)return;h.value=!0;let J=await(await e.intents.invoke("edit:item-lists",{itemId:B.value})).complete;if(J.code==="ok"){let fe=J.data;"itemId"in fe?(B.value=null,s.onUnsave?.(fe)):s.onListsUpdate?.(fe)}h.value=!1}r(te,"updateLists");async function ye(){if(!B.value)return;let{productId:Q,variantId:J}=t.value;if(!Q)return;h.value=!0;let we=await(await e.intents.invoke("edit:item-variant",{itemId:B.value,productId:Q,variantId:J})).complete;we.code==="ok"&&s.onVariantUpdate?.(we.data),h.value=!1}r(ye,"updateVariant");async function Y(){let{productId:Q,variantId:J}=t.value;if(!Q)return;let fe=o.value==="product"?void 0:J;ie(()=>{p.value=!0,m.value=!0});let kt=await(await e.intents.invoke("save:item",{productId:Q,variantId:fe})).complete;if(kt.code==="ok"){let is=kt.data;ie(()=>{B.value=is.item.id,p.value=!1}),s.onSave?.(is)}else kt.code==="error"&&console.warn("Failed to create item",kt),ie(()=>{p.value=!1,m.value=!1})}r(Y,"save");let qe=de(()=>d.value||w.value||t.value.loading),V=Z(()=>{(m.value||b.value)&&!w.value&&!E.value&&ie(()=>{m.value=!1,b.value=!1})});i.push(V);let Ce=de(()=>{let Q=!!B.value,J=p.value||E.value&&m.value,fe=f.value||E.value&&b.value,we="unsaved";return Q?we="saved":J&&(we="saving"),{error:u.value,status:we,savedItemId:B.value,savedItemIds:ce.value,loading:qe.value,submitting:w.value,saved:Q,saving:J,unsaving:fe}});async function Qo(){qe.value||(Ce.value.saved&&Ce.value.savedItemId?await De():Ce.value.saved||await Y())}return r(Qo,"toggle"),Object.assign(Ce,{save:Y,unsave:De,updateLists:te,updateVariant:ye,update:te,toggle:Qo,setOptions:a,setCallbacks:a,dispose:r(()=>{for(;i.length;)i.pop()?.()},"dispose")})},"itemStateSignal");var Ur=r(e=>()=>{let{data:t,loading:n,error:i}=e.state.swishQuery(()=>e.api.items.count(),{refetch:["item-create","item-delete"]}),s=F(0),o=F(!0),a=F(null);return Z(()=>{ie(()=>{o.value=n.value,a.value=i.value,s.value=t.value?.count??0})}),de(()=>({count:s.value,loading:o.value,error:a.value}))},"itemCountSignal");var Xc="token-update",Vr=r(e=>(t,n)=>{let i=F(null),s=F(null),o=F(null),a=F(!n?.skip),l=F(!1),c=de(()=>a.value&&l.value);async function d(){if(!n?.skip?.value)try{a.value=!0;let u=await t(n?.variables?.value);ie(()=>{o.value="error"in u?u.error:null,i.value="data"in u?u.data:null,s.value="pageInfo"in u?u.pageInfo:null,a.value=!1,l.value=!0})}catch(u){ie(()=>{o.value=u,a.value=!1,l.value=!0})}}return r(d,"executeFetch"),Z(()=>{if(d(),n?.refetch?.length){let u=[...n.refetch,Xc];return e.events.subscribe(u,d)}}),{data:i,pageInfo:s,error:o,loading:a,refetching:c}},"swishQuerySignals");var We="GraphQL Client";var xi="An error occurred while fetching from the API. Review 'graphQLErrors' for details.",Ei="Response returned unexpected Content-Type:",Ci="An unknown error has occurred. The API did not return a data object or any errors in its response.",_n={json:"application/json",multipart:"multipart/mixed"},Ri="X-SDK-Variant",ki="X-SDK-Version",Hr="shopify-graphql-client",Qr="1.4.1",Mn=1e3,zr=[429,503],Ai=/@(defer)\b/i,$r=`\r
8
- `,Gr=/boundary="?([^=";]+)"?/i,Pi=$r+$r;function Pe(e,t=We){return e.startsWith(`${t}`)?e:`${t}: ${e}`}r(Pe,"formatErrorMessage");function Me(e){return e instanceof Error?e.message:JSON.stringify(e)}r(Me,"getErrorMessage");function Ti(e){return e instanceof Error&&e.cause?e.cause:void 0}r(Ti,"getErrorCause");function Di(e){return e.flatMap(({errors:t})=>t??[])}r(Di,"combineErrors");function qn({client:e,retries:t}){if(t!==void 0&&(typeof t!="number"||t<0||t>3))throw new Error(`${e}: The provided "retries" value (${t}) is invalid - it cannot be less than ${0} or greater than ${3}`)}r(qn,"validateRetries");function le(e,t){return t&&(typeof t!="object"||Array.isArray(t)||typeof t=="object"&&Object.keys(t).length>0)?{[e]:t}:{}}r(le,"getKeyValueIfValid");function Li(e,t){if(e.length===0)return t;let i={[e.pop()]:t};return e.length===0?i:Li(e,i)}r(Li,"buildDataObjectByPath");function Xr(e,t){return Object.keys(t||{}).reduce((n,i)=>(typeof t[i]=="object"||Array.isArray(t[i]))&&e[i]?(n[i]=Xr(e[i],t[i]),n):(n[i]=t[i],n),Array.isArray(e)?[...e]:{...e})}r(Xr,"combineObjects");function Oi([e,...t]){return t.reduce(Xr,{...e})}r(Oi,"buildCombinedDataObject");function _i({clientLogger:e,customFetchApi:t=fetch,client:n=We,defaultRetryWaitTime:i=Mn,retriableCodes:s=zr}){let o=r(async(a,l,c)=>{let d=l+1,u=c+1,p;try{if(p=await t(...a),e({type:"HTTP-Response",content:{requestParams:a,response:p}}),!p.ok&&s.includes(p.status)&&d<=u)throw new Error;let f=p?.headers.get("X-Shopify-API-Deprecated-Reason")||"";return f&&e({type:"HTTP-Response-GraphQL-Deprecation-Notice",content:{requestParams:a,deprecationNotice:f}}),p}catch(f){if(d<=u){let h=p?.headers.get("Retry-After");return await Jc(h?parseInt(h,10):i),e({type:"HTTP-Retry",content:{requestParams:a,lastResponse:p,retryAttempt:l,maxRetries:c}}),o(a,d,c)}throw new Error(Pe(`${c>0?`Attempted maximum number of ${c} network retries. Last message - `:""}${Me(f)}`,n))}},"httpFetch");return o}r(_i,"generateHttpFetch");async function Jc(e){return new Promise(t=>setTimeout(t,e))}r(Jc,"sleep");function Mi({headers:e,url:t,customFetchApi:n=fetch,retries:i=0,logger:s}){qn({client:We,retries:i});let o={headers:e,url:t,retries:i},a=Yc(s),l=_i({customFetchApi:n,clientLogger:a,defaultRetryWaitTime:Mn}),c=Zc(l,o),d=eu(c),u=au(c);return{config:o,fetch:c,request:d,requestStream:u}}r(Mi,"createGraphQLClient");function Yc(e){return t=>{e&&e(t)}}r(Yc,"generateClientLogger");async function Jr(e){let{errors:t,data:n,extensions:i}=await e.json();return{...le("data",n),...le("extensions",i),headers:e.headers,...t||!n?{errors:{networkStatusCode:e.status,message:Pe(t?xi:Ci),...le("graphQLErrors",t),response:e}}:{}}}r(Jr,"processJSONResponse");function Zc(e,{url:t,headers:n,retries:i}){return async(s,o={})=>{let{variables:a,headers:l,url:c,retries:d,keepalive:u,signal:p}=o,f=JSON.stringify({query:s,variables:a});qn({client:We,retries:d});let h=Object.entries({...n,...l}).reduce((m,[b,S])=>(m[b]=Array.isArray(S)?S.join(", "):S.toString(),m),{});return!h[Ri]&&!h[ki]&&(h[Ri]=Hr,h[ki]=Qr),e([c??t,{method:"POST",headers:h,body:f,signal:p,keepalive:u}],1,d??i)}}r(Zc,"generateFetch");function eu(e){return async(...t)=>{if(Ai.test(t[0]))throw new Error(Pe("This operation will result in a streamable response - use requestStream() instead."));let n=null;try{n=await e(...t);let{status:i,statusText:s}=n,o=n.headers.get("content-type")||"";return n.ok?o.includes(_n.json)?await Jr(n):{errors:{networkStatusCode:i,message:Pe(`${Ei} ${o}`),response:n}}:{errors:{networkStatusCode:i,message:Pe(s),response:n}}}catch(i){return{errors:{message:Me(i),...n==null?{}:{networkStatusCode:n.status,response:n}}}}}}r(eu,"generateRequest");async function*tu(e){let t=new TextDecoder;if(e.body[Symbol.asyncIterator])for await(let n of e.body)yield t.decode(n);else{let n=e.body.getReader(),i;try{for(;!(i=await n.read()).done;)yield t.decode(i.value)}finally{n.cancel()}}}r(tu,"getStreamBodyIterator");function nu(e,t){return{async*[Symbol.asyncIterator](){try{let n="";for await(let i of e)if(n+=i,n.indexOf(t)>-1){let s=n.lastIndexOf(t),a=n.slice(0,s).split(t).filter(l=>l.trim().length>0).map(l=>l.slice(l.indexOf(Pi)+Pi.length).trim());a.length>0&&(yield a),n=n.slice(s+t.length),n.trim()==="--"&&(n="")}}catch(n){throw new Error(`Error occured while processing stream payload - ${Me(n)}`)}}}}r(nu,"readStreamChunk");function iu(e){return{async*[Symbol.asyncIterator](){yield{...await Jr(e),hasNext:!1}}}}r(iu,"createJsonResponseAsyncIterator");function su(e){return e.map(t=>{try{return JSON.parse(t)}catch(n){throw new Error(`Error in parsing multipart response - ${Me(n)}`)}}).map(t=>{let{data:n,incremental:i,hasNext:s,extensions:o,errors:a}=t;if(!i)return{data:n||{},...le("errors",a),...le("extensions",o),hasNext:s};let l=i.map(({data:c,path:d,errors:u})=>({data:c&&d?Li(d,c):{},...le("errors",u)}));return{data:l.length===1?l[0].data:Oi([...l.map(({data:c})=>c)]),...le("errors",Di(l)),hasNext:s}})}r(su,"getResponseDataFromChunkBodies");function ru(e,t){if(e.length>0)throw new Error(xi,{cause:{graphQLErrors:e}});if(Object.keys(t).length===0)throw new Error(Ci)}r(ru,"validateResponseData");function ou(e,t){let n=(t??"").match(Gr),i=`--${n?n[1]:"-"}`;if(!e.body?.getReader&&!e.body?.[Symbol.asyncIterator])throw new Error("API multipart response did not return an iterable body",{cause:e});let s=tu(e),o={},a;return{async*[Symbol.asyncIterator](){try{let l=!0;for await(let c of nu(s,i)){let d=su(c);a=d.find(p=>p.extensions)?.extensions??a;let u=Di(d);o=Oi([o,...d.map(({data:p})=>p)]),l=d.slice(-1)[0].hasNext,ru(u,o),yield{...le("data",o),...le("extensions",a),hasNext:l}}if(l)throw new Error("Response stream terminated unexpectedly")}catch(l){let c=Ti(l);yield{...le("data",o),...le("extensions",a),errors:{message:Pe(Me(l)),networkStatusCode:e.status,...le("graphQLErrors",c?.graphQLErrors),response:e},hasNext:!1}}}}}r(ou,"createMultipartResponseAsyncInterator");function au(e){return async(...t)=>{if(!Ai.test(t[0]))throw new Error(Pe("This operation does not result in a streamable response - use request() instead."));try{let n=await e(...t),{statusText:i}=n;if(!n.ok)throw new Error(i,{cause:n});let s=n.headers.get("content-type")||"";switch(!0){case s.includes(_n.json):return iu(n);case s.includes(_n.multipart):return ou(n,s);default:throw new Error(`${Ei} ${s}`,{cause:n})}}catch(n){return{async*[Symbol.asyncIterator](){let i=Ti(n);yield{errors:{message:Pe(Me(n)),...le("networkStatusCode",i?.status),...le("response",i)},hasNext:!1}}}}}}r(au,"generateRequestStream");function qi({client:e,storeDomain:t}){try{if(!t||typeof t!="string")throw new Error;let n=t.trim(),i=n.match(/^https?:/)?n:`https://${n}`,s=new URL(i);return s.protocol="https",s.origin}catch(n){throw new Error(`${e}: a valid store domain ("${t}") must be provided`,{cause:n})}}r(qi,"validateDomainAndGetStoreUrl");function Bn({client:e,currentSupportedApiVersions:t,apiVersion:n,logger:i}){let s=`${e}: the provided apiVersion ("${n}")`,o=`Currently supported API versions: ${t.join(", ")}`;if(!n||typeof n!="string")throw new Error(`${s} is invalid. ${o}`);let a=n.trim();t.includes(a)||(i?i({type:"Unsupported_Api_Version",content:{apiVersion:n,supportedApiVersions:t}}):console.warn(`${s} is likely deprecated or not supported. ${o}`))}r(Bn,"validateApiVersion");function Fn(e){let t=e*3-2;return t===10?t:`0${t}`}r(Fn,"getQuarterMonth");function Bi(e,t,n){let i=t-n;return i<=0?`${e-1}-${Fn(i+4)}`:`${e}-${Fn(i)}`}r(Bi,"getPrevousVersion");function Yr(){let e=new Date,t=e.getUTCMonth(),n=e.getUTCFullYear(),i=Math.floor(t/3+1);return{year:n,quarter:i,version:`${n}-${Fn(i)}`}}r(Yr,"getCurrentApiVersion");function Fi(){let{year:e,quarter:t,version:n}=Yr(),i=t===4?`${e+1}-01`:`${e}-${Fn(t+1)}`;return[Bi(e,t,3),Bi(e,t,2),Bi(e,t,1),n,i,"unstable"]}r(Fi,"getCurrentSupportedApiVersions");function ji(e){return t=>({...t??{},...e.headers})}r(ji,"generateGetHeaders");function Ni({getHeaders:e,getApiUrl:t}){return(n,i)=>{let s=[n];if(i&&Object.keys(i).length>0){let{variables:o,apiVersion:a,headers:l,retries:c,signal:d}=i;s.push({...o?{variables:o}:{},...l?{headers:e(l)}:{},...a?{url:t(a)}:{},...c?{retries:c}:{},...d?{signal:d}:{}})}return s}}r(Ni,"generateGetGQLClientParams");var Ui="application/json",Zr="storefront-api-client",eo="1.0.9",to="X-Shopify-Storefront-Access-Token",no="Shopify-Storefront-Private-Token",io="X-SDK-Variant",so="X-SDK-Version",ro="X-SDK-Variant-Source",Ke="Storefront API Client";function oo(e){if(e&&typeof window<"u")throw new Error(`${Ke}: private access tokens and headers should only be used in a server-to-server implementation. Use the public API access token in nonserver environments.`)}r(oo,"validatePrivateAccessTokenUsage");function ao(e,t){if(!e&&!t)throw new Error(`${Ke}: a public or private access token must be provided`);if(e&&t)throw new Error(`${Ke}: only provide either a public or private access token`)}r(ao,"validateRequiredAccessTokens");function Vi({storeDomain:e,apiVersion:t,publicAccessToken:n,privateAccessToken:i,clientName:s,retries:o=0,customFetchApi:a,logger:l}){let c=Fi(),d=qi({client:Ke,storeDomain:e}),u={client:Ke,currentSupportedApiVersions:c,logger:l};Bn({...u,apiVersion:t}),ao(n,i),oo(i);let p=lu(d,t,u),f={storeDomain:d,apiVersion:t,...n?{publicAccessToken:n}:{privateAccessToken:i},headers:{"Content-Type":Ui,Accept:Ui,[io]:Zr,[so]:eo,...s?{[ro]:s}:{},...n?{[to]:n}:{[no]:i}},apiUrl:p(),clientName:s},h=Mi({headers:f.headers,url:f.apiUrl,retries:o,customFetchApi:a,logger:l}),w=ji(f),m=cu(f,p),b=Ni({getHeaders:w,getApiUrl:m});return Object.freeze({config:f,getHeaders:w,getApiUrl:m,fetch:r((...k)=>h.fetch(...b(...k)),"fetch"),request:r((...k)=>h.request(...b(...k)),"request"),requestStream:r((...k)=>h.requestStream(...b(...k)),"requestStream")})}r(Vi,"createStorefrontApiClient");function lu(e,t,n){return i=>{i&&Bn({...n,apiVersion:i});let s=(i??t).trim();return`${e}/api/${s}/graphql.json`}}r(lu,"generateApiUrlFormatter");function cu(e,t){return n=>n?t(n):e.apiUrl}r(cu,"generateGetApiUrl");var jn=`
7
+ `+String(i)));os(t);for(var s=0;s<t.callbacks.length;s++){var o=i[s];o instanceof Error?t.callbacks[s].reject(o):t.callbacks[s].resolve(o)}}).catch(function(i){rs(e,t,i)})}r(sp,"dispatchBatch");function rs(e,t,n){os(t);for(var i=0;i<t.keys.length;i++)e.clear(t.keys[i]),t.callbacks[i].reject(n)}r(rs,"failedDispatch");function os(e){if(e.cacheHits)for(var t=0;t<e.cacheHits.length;t++)e.cacheHits[t]()}r(os,"resolveCacheHits");function rp(e){var t=!e||e.batch!==!1;if(!t)return 1;var n=e&&e.maxBatchSize;if(n===void 0)return 1/0;if(typeof n!="number"||n<1)throw new TypeError("maxBatchSize must be a positive number: "+n);return n}r(rp,"getValidMaxBatchSize");function op(e){var t=e&&e.batchScheduleFn;if(t===void 0)return np;if(typeof t!="function")throw new TypeError("batchScheduleFn must be a function: "+t);return t}r(op,"getValidBatchScheduleFn");function ap(e){var t=e&&e.cacheKeyFn;if(t===void 0)return function(n){return n};if(typeof t!="function")throw new TypeError("cacheKeyFn must be a function: "+t);return t}r(ap,"getValidCacheKeyFn");function lp(e){var t=!e||e.cache!==!1;if(!t)return null;var n=e&&e.cacheMap;if(n===void 0)return new Map;if(n!==null){var i=["get","set","delete","clear"],s=i.filter(function(o){return n&&typeof n[o]!="function"});if(s.length!==0)throw new TypeError("Custom cacheMap missing methods: "+s.join(", "))}return n}r(lp,"getValidCacheMap");function cp(e){return e&&e.name?e.name:null}r(cp,"getValidName");function Zo(e){return typeof e=="object"&&e!==null&&typeof e.length=="number"&&(e.length===0||e.length>0&&Object.prototype.hasOwnProperty.call(e,e.length-1))}r(Zo,"isArrayLike");ea.exports=tp});function fs(e,t="",n=new Map){for(let[i,s]of Object.entries(e)){let o=t?`${t}.${i}`:i;typeof s=="object"&&s!==null?fs(s,o,n):typeof s=="string"&&n.set(o,s)}return n}r(fs,"c");var xa=new Set(["en"]),ct="en";function ms(e,t){return t?.count===void 0?e:t.count===1?`${e}One`:`${e}Other`}r(ms,"d");function hs(e,t,n){t=ms(t,n);let i=e.get(t)??t;return n&&(n.count!==void 0&&(i=i.replace("{{count}}",n.count.toString())),Object.entries(n).forEach(([s,o])=>{s!=="count"&&typeof o=="string"&&(i=i.replace(`{{${s}}}`,o))})),i}r(hs,"f");function ys(e,t){let n=null;async function i(o){let a=await import(`${e}/locales/${o.toLowerCase()}.js`);return fs(a.default)}r(i,"a");function s(o,a){return n?n.has(ms(o,a))?{status:"ready",value:hs(n,o,a),key:o}:{status:"missing",value:hs(n,o,a),key:o}:{status:"pending",value:o,key:o}}return r(s,"r"),{t(o,a){return s(o,a).value},resolveTranslation:s,async loadLocale(o){let a=o;xa.has(o)||(console.warn(`[swish] Unsupported language "${o}", falling back to "${ct}".`),a=ct);let l;try{l=await i(a)}catch(c){if(console.warn(`[swish-i18n] Failed to load locale "${a}".`,c),a!==ct)try{l=await i(ct)}catch{console.warn(`[swish] Failed to load fallback locale "${ct}".`);return}else return}if(t?.[a])for(let[c,d]of Object.entries(t[a]))d!==void 0&&l.set(c,d);n=l}}}r(ys,"L");var U=r(e=>e.split("/").pop()??"","shopifyGidToId"),Se=r((e,t)=>typeof t=="string"&&t.startsWith("gid://shopify/")?t:`gid://shopify/${e}/${t}`,"shopifyIdToGid"),ye=r(e=>e.toLowerCase().replace(".myshopify.com",""),"toShopName");var Me=class{constructor(t,n,i=""){this.revalidationPromises=new Map;this.inFlightRequests=new Map;this.clearCachePromise=null;this.cacheName=t,this.defaultCacheControl=n,this.keyPrefix=i}static{r(this,"FetchCache")}async get(t){try{let n=await caches.open(this.cacheName),i=await n.match(t);if(i&&this.isExpired(i)){await n.delete(t);return}return i}catch(n){console.warn("Cache get error:",n);return}}async set(t,n,i){try{if(i?.includes("no-cache"))return;let s=this.createCacheableResponse(n,i);await(await caches.open(this.cacheName)).put(t,s)}catch(s){console.warn("Cache set error:",s)}}async fetchWithCache(t,n,i){let s=await this.getCacheKey(t,n);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,t,n,i),a.clone();let l=await fetch(t,n);return l.ok&&await this.set(s,l.clone(),i??this.defaultCacheControl),l})().finally(()=>{this.inFlightRequests.delete(s)});return this.inFlightRequests.set(s,o),o}async delete(t){try{return await(await caches.open(this.cacheName)).delete(t)}catch(n){return console.warn("Cache delete error:",n),!1}}async clear(){return this.clearCachePromise?this.clearCachePromise:(this.clearCachePromise=new Promise(async(t,n)=>{try{let i=await caches.open(this.cacheName),s=await i.keys();await Promise.all(s.map(o=>i.delete(o))),t()}catch(i){console.warn("Cache clear error:",i),n(i)}}),this.clearCachePromise.then(()=>{this.clearCachePromise=null}).catch(t=>{console.warn("Cache clear error:",t)}))}async keys(){try{return(await(await caches.open(this.cacheName)).keys()).map(i=>i.url)}catch(t){return console.warn("Cache keys error:",t),[]}}async has(t){try{let n=await caches.open(this.cacheName),i=await n.match(t);return i&&this.isExpired(i)?(await n.delete(t),!1):i!==void 0}catch(n){return console.warn("Cache has error:",n),!1}}async getStats(){try{return{total:(await(await caches.open(this.cacheName)).keys()).length}}catch(t){return console.warn("Cache stats error:",t),{total:0}}}async cleanupExpiredEntries(){try{let t=await caches.open(this.cacheName),n=await t.keys(),i=0;for(let o of n){let a=await t.match(o);a&&this.isExpired(a)&&(await t.delete(o),i++)}let s=n.length-i;return{removed:i,remaining:s}}catch(t){return console.warn("Cache cleanup error:",t),{removed:0,remaining:0}}}async getCacheKey(t,n){let i=this.getInputUrl(t),s=`${this.keyPrefix}${i}/${JSON.stringify(n)}`,a=new TextEncoder().encode(s),l=await crypto.subtle.digest("SHA-256",a);return`/${Array.from(new Uint8Array(l)).map(u=>u.toString(16).padStart(2,"0")).join("")}`}getInputUrl(t){return t instanceof URL?t.toString():typeof t=="string"?t:t.url}isExpired(t){let n=t.headers.get("Cache-Control");if(!n)return!1;let i=this.parseMaxAge(n),s=this.parseStaleWhileRevalidate(n);if(i===null)return!1;let o=t.headers.get("Date");if(!o)return!1;let a=new Date(o).getTime(),c=(Date.now()-a)/1e3,d=i+(s??0);return c>d}isStaleButRevalidatable(t){let n=t.headers.get("Cache-Control");if(!n)return!1;let i=this.parseMaxAge(n),s=this.parseStaleWhileRevalidate(n);if(i===null||s===null)return!1;let o=t.headers.get("Date");if(!o)return!1;let a=new Date(o).getTime(),c=(Date.now()-a)/1e3;return c>i&&c<=i+s}async revalidateInBackground(t,n,i,s){if(this.revalidationPromises.has(t))return;let o=(async()=>{try{let a=await fetch(n,i);a.ok&&await this.set(t,a.clone(),s??this.defaultCacheControl)}catch(a){console.warn("Background revalidation error:",a)}finally{this.revalidationPromises.delete(t)}})();this.revalidationPromises.set(t,o)}parseMaxAge(t){let n=new RegExp(/max-age=(\d+)/).exec(t);return n?parseInt(n[1],10):null}parseStaleWhileRevalidate(t){let n=new RegExp(/stale-while-revalidate=(\d+)/).exec(t);return n?parseInt(n[1],10):null}createCacheableResponse(t,n){let i=new Headers(t.headers);return i.set("Cache-Control",n),i.has("Date")||i.set("Date",new Date().toUTCString()),new Response(t.body,{status:t.status,statusText:t.statusText,headers:i})}};var At=class{static{r(this,"AjaxApiClient")}constructor(t){this.config=t;let n=ye(t.storeDomain);this.cache=new Me(`ajax-api-${n}`,"max-age=60, stale-while-revalidate=3600"),this.cache.cleanupExpiredEntries().catch(i=>{console.warn("Ajax API cache initialization cleanup error:",i)})}patchFetch(){if(!window.fetch||typeof window.fetch!="function")return;let t=window.fetch,n=this.config.responseInterceptor,i=this.getFetchRequest.bind(this);window.fetch=function(...s){let o=t.apply(this,s);if(typeof n=="function"){let a=i(s[0]);o.then(l=>n(l,a))}return o}}getFetchRequest(t){return t instanceof Request?t:new Request(t)}fetch(t,n){return(t instanceof Request?t.method:n?.method??"GET")==="GET"?this.cache.fetchWithCache(t,n):fetch(t,n)}async request(t,n={}){let i=`${window.location.origin}${t}`,s={"Content-Type":"application/json",Accept:"application/json"},o=await this.fetch(i,{...n,headers:{...s,...n.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 fetchProduct(t){return this.request(`/products/${t}.js`)}async addToCart(t){let n={...t,items:t.items.map(i=>{let s=Number(U(String(i.id)));if(!Number.isFinite(s)||s<=0)throw new Error(`Invalid Shopify ID: ${i.id}`);return{...i,id:s}})};return this.request("/cart/add.js",{method:"POST",body:JSON.stringify(n)})}async clearCache(){await this.cache.clear()}};var Tt=class{constructor(t){this.eventMap={"/cart/add":"cart-add","/cart/update":"cart-update","/cart/change":"cart-change","/cart/clear":"cart-clear"};this.previousCart=null;this.eventBus=t,this.processFetchResponse=this.processFetchResponse.bind(this)}static{r(this,"AjaxApiPublisher")}async processFetchResponse(t,n){try{let i=this.getEventName(n.url);if(!(i||n.url.includes("/cart.js")))return;let o=await t.clone().json();if(i==="cart-update"&&!o.items_removed){let a=this.diffRemovedItems(o);this.snapshotCart(o),this.eventBus.publish(i,{...o,items_removed:a})}else this.snapshotCart(o),i&&this.eventBus.publish(i,o)}catch(i){console.warn(i)}}getEventName(t){for(let[n,i]of Object.entries(this.eventMap))if(t.includes(n))return i;return null}snapshotCart(t){typeof t=="object"&&t!==null&&"token"in t&&"items"in t&&(this.previousCart=t)}diffRemovedItems(t){let n=this.previousCart;if(!n)return[];let i=new Set(t.items.map(o=>o.key)),s=[];for(let o of n.items)i.has(o.key)||s.push(this.toCartChangeItem(o));return s}toCartChangeItem(t){return{product_id:t.product_id,variant_id:t.variant_id,id:String(t.id),image:t.image,price:String(t.price),presentment_price:t.price,quantity:t.quantity,title:t.title,product_title:t.product_title,variant_title:t.variant_title,vendor:t.vendor,product_type:t.product_type,sku:t.sku,url:t.url,untranslated_product_title:t.product_title,untranslated_variant_title:t.variant_title,view_key:""}}};function Ca(){let e=document.body||document.documentElement;return e?Promise.resolve(e):new Promise(t=>{window.addEventListener("DOMContentLoaded",()=>t(e))})}r(Ca,"waitForDOM");function ut({onElementFound:e,selector:t,observerOptions:n,mustMatch:i}){let s=new WeakSet,o=new MutationObserver(d=>{let u=!1;for(let p of d)if(p.addedNodes.length>0){u=!0;break}u&&a()}),a=r(()=>{document.querySelectorAll(t).forEach(d=>{s.has(d)||(s.add(d),i?.(d)!==!1&&l(d))})},"locateElements"),l=r(d=>{if(!n){e(d);return}let u=new IntersectionObserver(p=>{for(let h of p)h.isIntersecting&&(u.disconnect(),e(d))},n);u.observe(d)},"observeElement");return r(async()=>{let d=await Ca();a(),o.observe(d,{childList:!0,subtree:!0})},"locateAndObserveElements")(),o}r(ut,"createElementLocator");function Ye({onLocationChange:e,fireOnInit:t=!1}){let n=r(()=>{e(window.location)},"handleChange");window.addEventListener("popstate",n);let i=history.pushState,s=history.replaceState;return history.pushState=function(...o){i.apply(this,o),n()},history.replaceState=function(...o){s.apply(this,o),n()},t&&n(),()=>{window.removeEventListener("popstate",n),history.pushState=i,history.replaceState=s}}r(Ye,"createLocationObserver");function Ze(e,t){let n=e.parentElement;for(;n;){let i=n.querySelector(t);if(i&&i!==e)return i;n=n.parentElement}return null}r(Ze,"findNearestElement");function gs({element:e,onHrefChange:t}){let n=r(()=>{t(e.href)},"handleChange"),i=new MutationObserver(()=>{n()});return i.observe(e,{attributes:!0,attributeFilter:["href"]}),()=>{i.disconnect()}}r(gs,"createHrefObserver");var Ea=/\/products\/([^/?#]+)(?:\?(?:[^#]*?&)?variant=(\d+))?/,Ne=r(e=>{let t=e.match(Ea);return t?{productHandle:decodeURIComponent(t[1]),variantId:t[2]}:null},"parseProductUrl"),ws=r(({source:e,onProductUrlChange:t})=>{let n=r(i=>{let s=Ne(i);s?.productHandle&&t(s)},"handleChange");if(e instanceof HTMLAnchorElement)return gs({element:e,onHrefChange:r(i=>n(i),"onHrefChange")});if(e instanceof Location)return Ye({onLocationChange:r(i=>n(i.href),"onLocationChange")});throw new Error("Invalid source for observing product url")},"observeProductUrl");var Ra=/^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i,ka=/^\/collections\/([^/?#]+)(?:\/|$)/,Pa=r(e=>e instanceof URL?e:typeof e=="string"?new URL(e,"http://placeholder.local"):new URL(e.href),"toUrl"),bs=r((e=window.location)=>{let n=Pa(e).pathname.replace(Ra,"")||"/",i=Ne(n);if(i?.productHandle)return{type:"pdp",productHandle:i.productHandle};let s=n.match(ka);return s?{type:"collection",collectionHandle:decodeURIComponent(s[1])}:n==="/cart"||n==="/cart/"?{type:"cart"}:n==="/"?{type:"home"}:{type:"other"}},"getPageInfo");var Is="swish:customiser:mounted",Ss="swish:customiser:minimized",Dt="swish-customiser",Aa="https://swish.app/cdn",Ta="swish-customiser-frame",xs="400px",Da="40px",xe=null,Cs=r(e=>{try{return window.sessionStorage?.getItem(e)==="1"}catch{return!1}},"readFlag"),Es=r((e,t)=>{try{t?window.sessionStorage?.setItem(e,"1"):window.sessionStorage?.removeItem(e)}catch{}},"writeFlag"),Rs=r(()=>Cs(Is),"readSticky"),ks=r(e=>Es(Is,e),"writeSticky"),La=r(()=>Cs(Ss),"readMinimized"),ei=r(e=>Es(Ss,e),"writeMinimized"),Oa=r(()=>{let e=new URLSearchParams(window.location.search);if(!e.has(Dt))return;e.delete(Dt);let t=e.toString(),n=window.location.pathname+(t?`?${t}`:"")+window.location.hash;window.history.replaceState(null,"",n)},"scrubLaunchParam"),Ma=r(()=>{let e=window.Shopify?.theme?.id;return e===void 0?void 0:String(e)},"readThemeId"),_a=r(e=>`${e.endsWith("/")?e.slice(0,-1):e}/customiser@${ge}/`,"buildCustomiserUrl"),ti=r(()=>typeof window>"u"?!1:new URLSearchParams(window.location.search).has(Dt)||Rs(),"isCustomiserRequested"),Lt=r((e={})=>{if(typeof window>"u")return;let t=e.baseUrl??Aa,i=new URLSearchParams(window.location.search).has(Dt),s=Rs();!i&&!s||(i&&(Oa(),ks(!0)),ni(_a(t),e.shop,Ma()))},"mountCustomiserIfRequested"),Zn=r((e,t)=>{e.style.width=t?Da:xs},"applyMinimized"),qa=r(e=>{try{let t=new URL(e,window.location.href);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}},"isSafeNavigateUrl"),ni=r((e,t,n)=>{if(xe)return;let i=new URL(e).origin,s=window.location.origin,o=document.createElement("div");o.id=Ta,Object.assign(o.style,{position:"fixed",top:"0",left:"0",width:xs,height:"100vh",background:"#fff",boxShadow:"2px 0 24px rgba(0, 0, 0, 0.12)",zIndex:"2147483647",transition:"width 220ms ease"});let a=La();a&&Zn(o,!0);let l=document.createElement("iframe");l.src=e,l.title="Swish Customiser",Object.assign(l.style,{width:"100%",height:"100%",border:"0",display:"block"}),o.appendChild(l);let c=new Set,d=!1,u=[],p=r(E=>{l.contentWindow?.postMessage(E,i)},"post"),h=r(E=>{d?p(E):u.push(E)},"pushOrQueue"),f=r((E,R,x)=>{p({type:`swish-customiser:${x}.result`,requestId:E,...R})},"respond"),w=[],y=r(()=>{let E=window.swish;if(!E?.events)return;let R=r(A=>{let P=A.detail;p({type:"swish-customiser:drawer.state",open:P.open})},"onDrawer"),x=r(A=>{let P=A.detail,F=`${P.placementId??""}:${P.code}`;c.has(F)||(c.add(F),h({type:"swish-customiser:warning",placementId:P.placementId,code:P.code,message:P.message}))},"onWarning");w.push(E.events.subscribe("drawer-state-change",R)),w.push(E.events.subscribe("placement-warning",x))},"subscribeToSdkEvents"),b=r((E,R)=>{switch(E){case"swish-customiser:customiser.close":ii(),window.location.reload();return;case"swish-customiser:customiser.minimize":xe&&(a=!0,ei(!0),Zn(xe.drawer,!0),h({type:"swish-customiser:customiser.state",minimized:!0}));return;case"swish-customiser:customiser.maximize":xe&&(a=!1,ei(!1),Zn(xe.drawer,!1),h({type:"swish-customiser:customiser.state",minimized:!1}));return;case"swish-customiser:drawer.open":window.swish?.ui.showDrawer?.();return;case"swish-customiser:drawer.close":window.swish?.ui.hideDrawer?.();return;case"swish-customiser:storefront.navigate":{let x=R.url;if(typeof x!="string"||!qa(x)){console.warn("[swish] storefront.navigate rejected unsafe URL:",x);return}window.location.assign(x);return}case"swish-customiser:preview.update":console.log("swish-customiser:preview.update",R.options),c.clear(),window.swish?.applyPreview?.(R.options);return}},"handleCommand"),S=r((E,R)=>{let x=R.requestId;if(typeof x=="string")switch(E){case"swish-customiser:storefront.page":{f(x,{ok:!0,result:bs()},"storefront.page");return}case"swish-customiser:dom.matches":{let A=R.selector;if(typeof A!="string"){f(x,{ok:!1,error:{code:"bad-params",message:"selector required"}},"dom.matches");return}try{let P=document.querySelectorAll(A).length;f(x,{ok:!0,result:{count:P}},"dom.matches")}catch(P){f(x,{ok:!1,error:{code:"invalid-selector",message:P instanceof Error?P.message:"Invalid selector"}},"dom.matches")}return}}},"handleQuery"),k=r(E=>{if(E.source!==l.contentWindow)return;let R=E.data;if(!(!R||typeof R.type!="string")){if(R.type==="swish-customiser:ready"){for(t&&p({type:"swish-customiser:context",shop:t,themeId:n,parentOrigin:s}),y(),h({type:"swish-customiser:customiser.state",minimized:a}),d=!0;u.length>0;){let x=u.shift();p(x)}return}if(!R.type.endsWith(".result")){if(R.type==="swish-customiser:storefront.page"||R.type==="swish-customiser:dom.matches"){S(R.type,R);return}b(R.type,R)}}},"onMessage");window.addEventListener("message",k),document.body.appendChild(o),xe={drawer:o,iframe:l,detach:r(()=>{window.removeEventListener("message",k),w.forEach(E=>E()),w.length=0},"detach")}},"mountCustomiser"),ii=r(()=>{xe&&(xe.detach(),xe.drawer.remove(),xe=null,ks(!1),ei(!1))},"unmountCustomiser"),Ps=r(()=>xe!==null,"isCustomiserMounted");var dt=Math.min,Fe=Math.max,pt=Math.round,ht=Math.floor,Ce=r(e=>({x:e,y:e}),"createCoords");function si(e,t){return typeof e=="function"?e(t):e}r(si,"evaluate");function ri(e){return e.split("-")[0]}r(ri,"getSide");function oi(e){return e.split("-")[1]}r(oi,"getAlignment");function As(e){return e==="x"?"y":"x"}r(As,"getOppositeAxis");function Ts(e){return e==="y"?"height":"width"}r(Ts,"getAxisLength");function Ot(e){let t=e[0];return t==="t"||t==="b"?"y":"x"}r(Ot,"getSideAxis");function Ds(e){return As(Ot(e))}r(Ds,"getAlignmentAxis");function Ba(e){return{top:0,right:0,bottom:0,left:0,...e}}r(Ba,"expandPaddingObject");function Ls(e){return typeof e!="number"?Ba(e):{top:e,right:e,bottom:e,left:e}}r(Ls,"getPaddingObject");function Ue(e){let{x:t,y:n,width:i,height:s}=e;return{width:i,height:s,top:n,left:t,right:t+i,bottom:n+s,x:t,y:n}}r(Ue,"rectToClientRect");function Os(e,t,n){let{reference:i,floating:s}=e,o=Ot(t),a=Ds(t),l=Ts(a),c=ri(t),d=o==="y",u=i.x+i.width/2-s.width/2,p=i.y+i.height/2-s.height/2,h=i[l]/2-s[l]/2,f;switch(c){case"top":f={x:u,y:i.y-s.height};break;case"bottom":f={x:u,y:i.y+i.height};break;case"right":f={x:i.x+i.width,y:p};break;case"left":f={x:i.x-s.width,y:p};break;default:f={x:i.x,y:i.y}}switch(oi(t)){case"start":f[a]-=h*(n&&d?-1:1);break;case"end":f[a]+=h*(n&&d?-1:1);break}return f}r(Os,"computeCoordsFromPlacement");async function Ms(e,t){var n;t===void 0&&(t={});let{x:i,y:s,platform:o,rects:a,elements:l,strategy:c}=e,{boundary:d="clippingAncestors",rootBoundary:u="viewport",elementContext:p="floating",altBoundary:h=!1,padding:f=0}=si(t,e),w=Ls(f),b=l[h?p==="floating"?"reference":"floating":p],S=Ue(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(b)))==null||n?b:b.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(l.floating)),boundary:d,rootBoundary:u,strategy:c})),k=p==="floating"?{x:i,y:s,width:a.floating.width,height:a.floating.height}:a.reference,E=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l.floating)),R=await(o.isElement==null?void 0:o.isElement(E))?await(o.getScale==null?void 0:o.getScale(E))||{x:1,y:1}:{x:1,y:1},x=Ue(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:k,offsetParent:E,strategy:c}):k);return{top:(S.top-x.top+w.top)/R.y,bottom:(x.bottom-S.bottom+w.bottom)/R.y,left:(S.left-x.left+w.left)/R.x,right:(x.right-S.right+w.right)/R.x}}r(Ms,"detectOverflow");var Fa=50,_s=r(async(e,t,n)=>{let{placement:i="bottom",strategy:s="absolute",middleware:o=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:Ms},c=await(a.isRTL==null?void 0:a.isRTL(t)),d=await a.getElementRects({reference:e,floating:t,strategy:s}),{x:u,y:p}=Os(d,i,c),h=i,f=0,w={};for(let y=0;y<o.length;y++){let b=o[y];if(!b)continue;let{name:S,fn:k}=b,{x:E,y:R,data:x,reset:A}=await k({x:u,y:p,initialPlacement:i,placement:h,strategy:s,middlewareData:w,rects:d,platform:l,elements:{reference:e,floating:t}});u=E??u,p=R??p,w[S]={...w[S],...x},A&&f<Fa&&(f++,typeof A=="object"&&(A.placement&&(h=A.placement),A.rects&&(d=A.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:s}):A.rects),{x:u,y:p}=Os(d,h,c)),y=-1)}return{x:u,y:p,placement:h,strategy:s,middlewareData:w}},"computePosition");var ja=new Set(["left","top"]);async function Na(e,t){let{placement:n,platform:i,elements:s}=e,o=await(i.isRTL==null?void 0:i.isRTL(s.floating)),a=ri(n),l=oi(n),c=Ot(n)==="y",d=ja.has(a)?-1:1,u=o&&c?-1:1,p=si(t,e),{mainAxis:h,crossAxis:f,alignmentAxis:w}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return l&&typeof w=="number"&&(f=l==="end"?w*-1:w),c?{x:f*u,y:h*d}:{x:h*d,y:f*u}}r(Na,"convertValueToCoords");var qs=r(function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,i;let{x:s,y:o,placement:a,middlewareData:l}=t,c=await Na(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(i=l.arrow)!=null&&i.alignmentOffset?{}:{x:s+c.x,y:o+c.y,data:{...c,placement:a}}}}},"offset");function Mt(){return typeof window<"u"}r(Mt,"hasWindow");function $e(e){return Fs(e)?(e.nodeName||"").toLowerCase():"#document"}r($e,"getNodeName");function de(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}r(de,"getWindow");function Ee(e){var t;return(t=(Fs(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}r(Ee,"getDocumentElement");function Fs(e){return Mt()?e instanceof Node||e instanceof de(e).Node:!1}r(Fs,"isNode");function we(e){return Mt()?e instanceof Element||e instanceof de(e).Element:!1}r(we,"isElement");function Ae(e){return Mt()?e instanceof HTMLElement||e instanceof de(e).HTMLElement:!1}r(Ae,"isHTMLElement");function Bs(e){return!Mt()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof de(e).ShadowRoot}r(Bs,"isShadowRoot");function tt(e){let{overflow:t,overflowX:n,overflowY:i,display:s}=be(e);return/auto|scroll|overlay|hidden|clip/.test(t+i+n)&&s!=="inline"&&s!=="contents"}r(tt,"isOverflowElement");function js(e){return/^(table|td|th)$/.test($e(e))}r(js,"isTableElement");function ft(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}r(ft,"isTopLayer");var Ua=/transform|translate|scale|rotate|perspective|filter/,Va=/paint|layout|strict|content/,Ve=r(e=>!!e&&e!=="none","isNotNone"),ai;function _t(e){let t=we(e)?be(e):e;return Ve(t.transform)||Ve(t.translate)||Ve(t.scale)||Ve(t.rotate)||Ve(t.perspective)||!qt()&&(Ve(t.backdropFilter)||Ve(t.filter))||Ua.test(t.willChange||"")||Va.test(t.contain||"")}r(_t,"isContainingBlock");function Ns(e){let t=_e(e);for(;Ae(t)&&!He(t);){if(_t(t))return t;if(ft(t))return null;t=_e(t)}return null}r(Ns,"getContainingBlock");function qt(){return ai==null&&(ai=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),ai}r(qt,"isWebKit");function He(e){return/^(html|body|#document)$/.test($e(e))}r(He,"isLastTraversableNode");function be(e){return de(e).getComputedStyle(e)}r(be,"getComputedStyle");function mt(e){return we(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}r(mt,"getNodeScroll");function _e(e){if($e(e)==="html")return e;let t=e.assignedSlot||e.parentNode||Bs(e)&&e.host||Ee(e);return Bs(t)?t.host:t}r(_e,"getParentNode");function Us(e){let t=_e(e);return He(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ae(t)&&tt(t)?t:Us(t)}r(Us,"getNearestOverflowAncestor");function et(e,t,n){var i;t===void 0&&(t=[]),n===void 0&&(n=!0);let s=Us(e),o=s===((i=e.ownerDocument)==null?void 0:i.body),a=de(s);if(o){let l=Bt(a);return t.concat(a,a.visualViewport||[],tt(s)?s:[],l&&n?et(l):[])}else return t.concat(s,et(s,[],n))}r(et,"getOverflowAncestors");function Bt(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}r(Bt,"getFrameElement");function Qs(e){let t=be(e),n=parseFloat(t.width)||0,i=parseFloat(t.height)||0,s=Ae(e),o=s?e.offsetWidth:n,a=s?e.offsetHeight:i,l=pt(n)!==o||pt(i)!==a;return l&&(n=o,i=a),{width:n,height:i,$:l}}r(Qs,"getCssDimensions");function ci(e){return we(e)?e:e.contextElement}r(ci,"unwrapElement");function nt(e){let t=ci(e);if(!Ae(t))return Ce(1);let n=t.getBoundingClientRect(),{width:i,height:s,$:o}=Qs(t),a=(o?pt(n.width):n.width)/i,l=(o?pt(n.height):n.height)/s;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}r(nt,"getScale");var $a=Ce(0);function zs(e){let t=de(e);return!qt()||!t.visualViewport?$a:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}r(zs,"getVisualOffsets");function Ha(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==de(e)?!1:t}r(Ha,"shouldAddVisualOffsets");function Qe(e,t,n,i){t===void 0&&(t=!1),n===void 0&&(n=!1);let s=e.getBoundingClientRect(),o=ci(e),a=Ce(1);t&&(i?we(i)&&(a=nt(i)):a=nt(e));let l=Ha(o,n,i)?zs(o):Ce(0),c=(s.left+l.x)/a.x,d=(s.top+l.y)/a.y,u=s.width/a.x,p=s.height/a.y;if(o){let h=de(o),f=i&&we(i)?de(i):i,w=h,y=Bt(w);for(;y&&i&&f!==w;){let b=nt(y),S=y.getBoundingClientRect(),k=be(y),E=S.left+(y.clientLeft+parseFloat(k.paddingLeft))*b.x,R=S.top+(y.clientTop+parseFloat(k.paddingTop))*b.y;c*=b.x,d*=b.y,u*=b.x,p*=b.y,c+=E,d+=R,w=de(y),y=Bt(w)}}return Ue({width:u,height:p,x:c,y:d})}r(Qe,"getBoundingClientRect");function Ft(e,t){let n=mt(e).scrollLeft;return t?t.left+n:Qe(Ee(e)).left+n}r(Ft,"getWindowScrollBarX");function Gs(e,t){let n=e.getBoundingClientRect(),i=n.left+t.scrollLeft-Ft(e,n),s=n.top+t.scrollTop;return{x:i,y:s}}r(Gs,"getHTMLOffset");function Qa(e){let{elements:t,rect:n,offsetParent:i,strategy:s}=e,o=s==="fixed",a=Ee(i),l=t?ft(t.floating):!1;if(i===a||l&&o)return n;let c={scrollLeft:0,scrollTop:0},d=Ce(1),u=Ce(0),p=Ae(i);if((p||!p&&!o)&&(($e(i)!=="body"||tt(a))&&(c=mt(i)),p)){let f=Qe(i);d=nt(i),u.x=f.x+i.clientLeft,u.y=f.y+i.clientTop}let h=a&&!p&&!o?Gs(a,c):Ce(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-c.scrollLeft*d.x+u.x+h.x,y:n.y*d.y-c.scrollTop*d.y+u.y+h.y}}r(Qa,"convertOffsetParentRelativeRectToViewportRelativeRect");function za(e){return Array.from(e.getClientRects())}r(za,"getClientRects");function Ga(e){let t=Ee(e),n=mt(e),i=e.ownerDocument.body,s=Fe(t.scrollWidth,t.clientWidth,i.scrollWidth,i.clientWidth),o=Fe(t.scrollHeight,t.clientHeight,i.scrollHeight,i.clientHeight),a=-n.scrollLeft+Ft(e),l=-n.scrollTop;return be(i).direction==="rtl"&&(a+=Fe(t.clientWidth,i.clientWidth)-s),{width:s,height:o,x:a,y:l}}r(Ga,"getDocumentRect");var Vs=25;function Wa(e,t){let n=de(e),i=Ee(e),s=n.visualViewport,o=i.clientWidth,a=i.clientHeight,l=0,c=0;if(s){o=s.width,a=s.height;let u=qt();(!u||u&&t==="fixed")&&(l=s.offsetLeft,c=s.offsetTop)}let d=Ft(i);if(d<=0){let u=i.ownerDocument,p=u.body,h=getComputedStyle(p),f=u.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,w=Math.abs(i.clientWidth-p.clientWidth-f);w<=Vs&&(o-=w)}else d<=Vs&&(o+=d);return{width:o,height:a,x:l,y:c}}r(Wa,"getViewportRect");function Ka(e,t){let n=Qe(e,!0,t==="fixed"),i=n.top+e.clientTop,s=n.left+e.clientLeft,o=Ae(e)?nt(e):Ce(1),a=e.clientWidth*o.x,l=e.clientHeight*o.y,c=s*o.x,d=i*o.y;return{width:a,height:l,x:c,y:d}}r(Ka,"getInnerBoundingClientRect");function $s(e,t,n){let i;if(t==="viewport")i=Wa(e,n);else if(t==="document")i=Ga(Ee(e));else if(we(t))i=Ka(t,n);else{let s=zs(e);i={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return Ue(i)}r($s,"getClientRectFromClippingAncestor");function Ws(e,t){let n=_e(e);return n===t||!we(n)||He(n)?!1:be(n).position==="fixed"||Ws(n,t)}r(Ws,"hasFixedPositionAncestor");function Xa(e,t){let n=t.get(e);if(n)return n;let i=et(e,[],!1).filter(l=>we(l)&&$e(l)!=="body"),s=null,o=be(e).position==="fixed",a=o?_e(e):e;for(;we(a)&&!He(a);){let l=be(a),c=_t(a);!c&&l.position==="fixed"&&(s=null),(o?!c&&!s:!c&&l.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||tt(a)&&!c&&Ws(e,a))?i=i.filter(u=>u!==a):s=l,a=_e(a)}return t.set(e,i),i}r(Xa,"getClippingElementAncestors");function Ja(e){let{element:t,boundary:n,rootBoundary:i,strategy:s}=e,a=[...n==="clippingAncestors"?ft(t)?[]:Xa(t,this._c):[].concat(n),i],l=$s(t,a[0],s),c=l.top,d=l.right,u=l.bottom,p=l.left;for(let h=1;h<a.length;h++){let f=$s(t,a[h],s);c=Fe(f.top,c),d=dt(f.right,d),u=dt(f.bottom,u),p=Fe(f.left,p)}return{width:d-p,height:u-c,x:p,y:c}}r(Ja,"getClippingRect");function Ya(e){let{width:t,height:n}=Qs(e);return{width:t,height:n}}r(Ya,"getDimensions");function Za(e,t,n){let i=Ae(t),s=Ee(t),o=n==="fixed",a=Qe(e,!0,o,t),l={scrollLeft:0,scrollTop:0},c=Ce(0);function d(){c.x=Ft(s)}if(r(d,"setLeftRTLScrollbarOffset"),i||!i&&!o)if(($e(t)!=="body"||tt(s))&&(l=mt(t)),i){let f=Qe(t,!0,o,t);c.x=f.x+t.clientLeft,c.y=f.y+t.clientTop}else s&&d();o&&!i&&s&&d();let u=s&&!i&&!o?Gs(s,l):Ce(0),p=a.left+l.scrollLeft-c.x-u.x,h=a.top+l.scrollTop-c.y-u.y;return{x:p,y:h,width:a.width,height:a.height}}r(Za,"getRectRelativeToOffsetParent");function li(e){return be(e).position==="static"}r(li,"isStaticPositioned");function Hs(e,t){if(!Ae(e)||be(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ee(e)===n&&(n=n.ownerDocument.body),n}r(Hs,"getTrueOffsetParent");function Ks(e,t){let n=de(e);if(ft(e))return n;if(!Ae(e)){let s=_e(e);for(;s&&!He(s);){if(we(s)&&!li(s))return s;s=_e(s)}return n}let i=Hs(e,t);for(;i&&js(i)&&li(i);)i=Hs(i,t);return i&&He(i)&&li(i)&&!_t(i)?n:i||Ns(e)||n}r(Ks,"getOffsetParent");var el=r(async function(e){let t=this.getOffsetParent||Ks,n=this.getDimensions,i=await n(e.floating);return{reference:Za(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}},"getElementRects");function tl(e){return be(e).direction==="rtl"}r(tl,"isRTL");var nl={convertOffsetParentRelativeRectToViewportRelativeRect:Qa,getDocumentElement:Ee,getClippingRect:Ja,getOffsetParent:Ks,getElementRects:el,getClientRects:za,getDimensions:Ya,getScale:nt,isElement:we,isRTL:tl};function Xs(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}r(Xs,"rectsAreEqual");function il(e,t){let n=null,i,s=Ee(e);function o(){var l;clearTimeout(i),(l=n)==null||l.disconnect(),n=null}r(o,"cleanup");function a(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),o();let d=e.getBoundingClientRect(),{left:u,top:p,width:h,height:f}=d;if(l||t(),!h||!f)return;let w=ht(p),y=ht(s.clientWidth-(u+h)),b=ht(s.clientHeight-(p+f)),S=ht(u),E={rootMargin:-w+"px "+-y+"px "+-b+"px "+-S+"px",threshold:Fe(0,dt(1,c))||1},R=!0;function x(A){let P=A[0].intersectionRatio;if(P!==c){if(!R)return a();P?a(!1,P):i=setTimeout(()=>{a(!1,1e-7)},1e3)}P===1&&!Xs(d,e.getBoundingClientRect())&&a(),R=!1}r(x,"handleObserve");try{n=new IntersectionObserver(x,{...E,root:s.ownerDocument})}catch{n=new IntersectionObserver(x,E)}n.observe(e)}return r(a,"refresh"),a(!0),o}r(il,"observeMove");function Js(e,t,n,i){i===void 0&&(i={});let{ancestorScroll:s=!0,ancestorResize:o=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=i,d=ci(e),u=s||o?[...d?et(d):[],...t?et(t):[]]:[];u.forEach(S=>{s&&S.addEventListener("scroll",n,{passive:!0}),o&&S.addEventListener("resize",n)});let p=d&&l?il(d,n):null,h=-1,f=null;a&&(f=new ResizeObserver(S=>{let[k]=S;k&&k.target===d&&f&&t&&(f.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var E;(E=f)==null||E.observe(t)})),n()}),d&&!c&&f.observe(d),t&&f.observe(t));let w,y=c?Qe(e):null;c&&b();function b(){let S=Qe(e);y&&!Xs(y,S)&&n(),y=S,w=requestAnimationFrame(b)}return r(b,"frameLoop"),n(),()=>{var S;u.forEach(k=>{s&&k.removeEventListener("scroll",n),o&&k.removeEventListener("resize",n)}),p?.(),(S=f)==null||S.disconnect(),f=null,c&&cancelAnimationFrame(w)}}r(Js,"autoUpdate");var Ys=qs;var Zs=r((e,t,n)=>{let i=new Map,s={platform:nl,...n},o={...s.platform,_c:i};return _s(e,t,{...s,platform:o})},"computePosition");function sl(e){let t=e.getAttribute("swish-item-context");return t?t==="location"?globalThis.window?.location??e:Ze(e,t)??e:e}r(sl,"resolveItemContextSource");function er(e,t){return e.getAttribute("swish-item-context")?sl(e):t}r(er,"resolvePlacementItemContextSource");function Nt(e,t){if(!t.element)throw new Error("Element must be provided");let n=null,i=null,s=new Map,o=r((p,h)=>{e.events.publish("placement-warning",{placementId:t.id,code:p,message:h})},"warn"),a=r(()=>{if(n){console.warn("Placement already mounted. Skipping mount.");return}ol(t);try{document.querySelectorAll(t.target.selector)}catch(p){o("invalid-selector",p instanceof Error?p.message:"Invalid CSS selector");return}n=ut({selector:t.target.selector,observerOptions:t.target.observerOptions,mustMatch:t.target.mustMatch,onElementFound:r(p=>l(p),"onElementFound")}),i=setTimeout(()=>{s.size===0&&o("no-matches",`No elements match selector "${t.target.selector}"`),i=null},2e3)},"mount"),l=r(p=>{s.has(p)||p.hasAttribute("swish-ignore")||p.getAttribute("swish-placement-target")===t.id||(p.setAttribute("swish-placement-target",t.id),c(p))},"evaluateAndMount"),c=r(async p=>{let h=[],f=t.mount.mode,w=sr(p,t.mount.at);if(!w){o("mount-target-not-found","Could not resolve a mount target relative to the matched element.");return}let y=await(typeof t.element=="function"?t.element(t):Il(e,t.element));if(!y){o("element-factory-empty","Element factory returned no element to mount.");return}if(y.setAttribute("swish-placement-element",t.id),typeof t.element!="function"){let N=t.element;N.props&&Sl(y,N.props),N.classNames&&or(y,N.classNames)}let b;t.container&&(b=bl(t.id,t.container),b.appendChild(y));let S,k=b??y;if(t.layout?.type==="overlay"){yl(w);let N=t.layout.anchor??"bottom-right";k.setAttribute("swish-placement-overlay",t.id),k.setAttribute("swish-placement-anchor",N)}else t.layout?.type==="anchored"&&k.setAttribute("swish-placement-anchored",t.id);let E=!1,R;if(t.layout?.type==="inline"){let N=t.layout,oe=N.rowSelector?w.closest(N.rowSelector):null;oe?S=oe:(S=wl(t.id,w,N),E=!0),R=S.getAttribute("swish-placement-inline-row"),S.setAttribute("swish-placement-inline-row",t.id)}let x=b??y;if(!ml(w,x,f)){try{x.remove()}catch{}o("insert-failed",`Could not insert element with mode "${f}" \u2014 target has no parent.`);return}if(t.layout?.type==="anchored"){let N=sr(p,t.layout.to)??w,oe=vl(N,k,t.layout);h.push(oe)}let P={targetEl:p,renderTargetEl:w,mountEl:y,containerEl:b,rowEl:S,rowWasCreated:E,rowInlineAttrPrevValue:R,cleanupFns:h,ownsNode:!0};s.set(p,P),i&&(clearTimeout(i),i=null);let F={id:t.id,targetEl:p,renderTargetEl:w,mountEl:P.mountEl,containerEl:b,rowEl:S,cleanup:r(N=>h.push(N),"cleanup")};t.element?.name==="save-button"&&rl(e,F),t.onMount?.(F)},"mountElement"),d=r(p=>{let h=s.get(p);if(h){if(t.onUnmount?.({id:t.id,targetEl:h.targetEl,renderTargetEl:h.renderTargetEl,mountEl:h.mountEl,containerEl:h.containerEl,rowEl:h.rowEl}),h.cleanupFns.forEach(f=>f()),h.targetEl.getAttribute("swish-placement-target")===t.id&&h.targetEl.removeAttribute("swish-placement-target"),h.ownsNode&&(h.containerEl||h.mountEl).remove(),h.rowEl){if(h.rowWasCreated){let f=h.rowEl.parentElement;f&&h.targetEl.parentElement===h.rowEl?h.rowEl.replaceWith(h.targetEl):f?f.removeChild(h.rowEl):h.rowEl.remove()}else if(h.rowInlineAttrPrevValue!==void 0){let f=h.rowInlineAttrPrevValue;f===null?h.rowEl.removeAttribute("swish-placement-inline-row"):h.rowEl.setAttribute("swish-placement-inline-row",f)}}s.delete(p)}},"unmountElement");return{mount:a,unmount:r(()=>{n&&(n.disconnect(),n=null),i&&(clearTimeout(i),i=null),s.forEach((p,h)=>d(h)),s.clear()},"unmount")}}r(Nt,"createPlacement");var rl=r((e,{mountEl:t,targetEl:n,cleanup:i})=>{let s=er(t,n),o=e.state.itemContext(s),a=e.state.effect(()=>{let{loading:l,productId:c,variantId:d}=o.value;l||(t.setAttribute("product-id",c??""),t.setAttribute("variant-id",d??""))});i(()=>a?.())},"saveButtonMount");function ol(e){let t=al(e.id),n=fl(e),i=document.getElementById(t);if(i){i.textContent=n;return}let s=document.createElement("style");s.id=t,s.setAttribute("swish-placement-style",e.id),s.textContent=n,document.head.appendChild(s)}r(ol,"ensurePlacementStylesheet");function al(e){return`swish-placement-style-${ll(e)}`}r(al,"getPlacementStyleId");function ll(e){return e.replace(/[^a-zA-Z0-9\-_]/g,"_")}r(ll,"cssEscapeId");function tr(e){return`--swish-placement-${cl(String(e))}`}r(tr,"designKeyToCSSVar");function cl(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase()}r(cl,"toKebabCase");function ul(e){return Object.entries(e??{sm:500,lg:700}).map(([i,s])=>({name:i,minWidth:s})).sort((i,s)=>i.minWidth-s.minWidth)}r(ul,"getBreakpoints");function rr(e,t){if(e==null)return{};if(typeof e=="object"&&!Array.isArray(e)){if(t&&t.size){let n=Object.keys(e);return"base"in e||n.some(s=>t.has(s))?e:{base:e}}return e}return{base:e}}r(rr,"normalizeResponsiveValue");var dl=new Set(["fontWeight","lineHeight","pressedScale","backgroundAlpha","pressedOpacity","pressedScale"]);function nr(e,t){if(t!=null)return typeof t=="number"&&!dl.has(e)?`${t}px`:String(t)}r(nr,"formatDesignValue");function pl(e,t,n){if(!t)return"";let i=new Set(n.map(c=>c.name)),s=[],o={},a=Object.entries(t).map(([c,d])=>[c,d]);for(let[c,d]of a){let u=rr(d,i),p=nr(String(c),u.base);p!==void 0&&s.push(`${tr(c)}:${p};`);for(let h of n){let f=u[h.name],w=nr(String(c),f);w!==void 0&&(o[h.name]||(o[h.name]=[]),o[h.name].push(`${tr(c)}:${w};`))}}let l=[];s.length&&l.push(`[swish-placement-element="${e}"]{${s.join("")}}`);for(let c of n){let d=o[c.name];d?.length&&l.push(`@media(min-width:${c.minWidth}px){[swish-placement-element="${e}"]{${d.join("")}}}`)}return l.join("")}r(pl,"emitDesignCSS");function jt(e){return e==null?"0px":typeof e=="number"?`${e}px`:e}r(jt,"formatOffsetValue");function ir(e){return e==null?"":typeof e=="number"?`${e}`:e}r(ir,"formatZIndexValue");function hl(e,t,n){let i=new Set(n.map(d=>d.name)),s=rr(t,i),o=s.base??{},a=jt(o.x),l=jt(o.y),c=[];c.push(`[swish-placement-overlay="${e}"]{--swish-placement-offset-x:${a};--swish-placement-offset-y:${l};}`);for(let d of n){let u=s[d.name];if(!u)continue;let p=jt(u.x),h=jt(u.y);c.push(`@media(min-width:${d.minWidth}px){[swish-placement-overlay="${e}"]{--swish-placement-offset-x:${p};--swish-placement-offset-y:${h};}}`)}return c.join("")}r(hl,"emitOverlayOffsetCSS");function fl(e){let t=e.id,n=ul(e.breakpoints),i=`[swish-placement-inline-row="${t}"]{display:flex;flex-direction:row;align-items:center;gap:var(--swish-placement-inline-gap,8px);width:100%}[swish-placement-inline-row="${t}"]>*:not([swish-placement-element="${t}"]){flex:1;min-width:0}`,s=`[swish-placement-overlay="${t}"]{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="${t}"][swish-placement-anchor="top-left"]{top:0;left:0;}[swish-placement-overlay="${t}"][swish-placement-anchor="top-right"]{top:0;right:0;}[swish-placement-overlay="${t}"][swish-placement-anchor="bottom-left"]{bottom:0;left:0;}[swish-placement-overlay="${t}"][swish-placement-anchor="bottom-right"]{bottom:0;right:0;}[swish-placement-overlay="${t}"][swish-placement-anchor$="left"]{--swish-placement-sign-x:1;}[swish-placement-overlay="${t}"][swish-placement-anchor$="right"]{--swish-placement-sign-x:-1;}[swish-placement-overlay="${t}"][swish-placement-anchor^="top"]{--swish-placement-sign-y:1;}[swish-placement-overlay="${t}"][swish-placement-anchor^="bottom"]{--swish-placement-sign-y:-1;}`,o="";if(e.layout?.type==="overlay"){let a=hl(t,e.layout.offset,n),l=e.layout.zIndex?`[swish-placement-overlay="${t}"]{--swish-placement-overlay-z:${ir(e.layout.zIndex)};}`:"";o+=a+l+s}else if(e.layout?.type==="anchored"){let a=e.layout.zIndex?ir(e.layout.zIndex):"10";o+=`[swish-placement-anchored="${t}"]{position:absolute;width:max-content;top:0;left:0;z-index:${a};}`}else e.layout?.type==="inline"&&(o+=i);if(e.design){let a=pl(t,e.design,n);a&&(o+=a)}return e.css&&(o+=e.css.trim()),o}r(fl,"buildPlacementCSS");function sr(e,t){if(!t||t==="target")return e;if(typeof t=="string"&&(t={nearest:t}),"nearest"in t)return Ze(e,t.nearest);if("closest"in t)return e.closest(t.closest);if("query"in t)return e.querySelector(t.query);if("withinClosest"in t){let n=e.closest(t.withinClosest.root);return n?n.querySelector(t.withinClosest.selector):null}return e}r(sr,"resolveMountTarget");function ml(e,t,n){switch(n){case"before":return e.parentElement?(e.before(t),!0):!1;case"after":{let i=e.parentElement;return i?(i.insertBefore(t,e.nextSibling),!0):!1}case"append":return e.appendChild(t),!0;case"prepend":return e.insertBefore(t,e.firstChild),!0;case"replace":return e.parentElement?(e.replaceWith(t),!0):!1}}r(ml,"insertIntoDOM");function yl(e){let t=e.parentElement;return t?(window.getComputedStyle(t).position==="static"&&(t.style.position="relative"),t):null}r(yl,"ensureRelativeParent");function vl(e,t,n){let i=[];return n.inside?i.push(gl(n.offset??0)):n.offset&&i.push(Ys(n.offset)),Js(e,t,r(()=>{Zs(e,t,{placement:n.placement??"bottom-end",middleware:i}).then(({x:o,y:a})=>{Object.assign(t.style,{left:`${o}px`,top:`${a}px`})})},"update"))}r(vl,"setupAnchoredPosition");function gl(e){return{name:"anchoredInside",fn({x:t,y:n,rects:i,placement:s}){let[o,a]=s.split("-"),l=0,c=0,d=o==="top"||o==="bottom";return o==="top"?c=i.floating.height+e:o==="bottom"?c=-(i.floating.height+e):o==="left"?l=i.floating.width+e:o==="right"&&(l=-(i.floating.width+e)),d&&a==="start"?l=e:d&&a==="end"?l=-e:!d&&a==="start"?c=e:!d&&a==="end"&&(c=-e),{x:t+l,y:n+c}}}}r(gl,"anchoredInsideMiddleware");function wl(e,t,n){if(!t.parentElement)throw new Error("Cannot inline-wrap: refEl has no parentElement");let s=document.createElement("div");return s.setAttribute("swish-placement-inline-row",e),t.before(s),s.appendChild(t),s}r(wl,"wrapWithFlexRow");function bl(e,t){let n=t.tag||"div",i=document.createElement(n);return i.setAttribute("swish-placement-container",e),t.classNames&&or(i,t.classNames),i}r(bl,"createContainer");function Il(e,t){return e.ui.createElement(t.name,{})}r(Il,"createElement");function Sl(e,t){for(let[n,i]of Object.entries(t)){let s=n.replace(/([A-Z])/g,"-$1").toLowerCase();i===!1||i===void 0||i===null||(i===!0?e.setAttribute(s,"true"):e.setAttribute(s,String(i)))}}r(Sl,"applyProps");function or(e,t){e.classList.add(...t)}r(or,"applyClassNames");var xl=Symbol.for("preact-signals");function Vt(){if(je>1)je--;else{for(var e,t=!1;yt!==void 0;){var n=yt;for(yt=void 0,ui++;n!==void 0;){var i=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&ur(n))try{n.c()}catch(s){t||(e=s,t=!0)}n=i}}if(ui=0,je--,t)throw e}}r(Vt,"t");function se(e){if(je>0)return e();je++;try{return e()}finally{Vt()}}r(se,"n");var j=void 0;function lr(e){var t=j;j=void 0;try{return e()}finally{j=t}}r(lr,"o");var ar,yt=void 0,je=0,ui=0,Ut=0;function cr(e){if(j!==void 0){var t=e.n;if(t===void 0||t.t!==j)return t={i:0,S:e,p:j.s,n:void 0,t:j,e:void 0,x:void 0,r:t},j.s!==void 0&&(j.s.n=t),j.s=t,e.n=t,32&j.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=j.s,t.n=void 0,j.s.n=t,j.s=t),t}}r(cr,"e");function ae(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}r(ae,"d");ae.prototype.brand=xl;ae.prototype.h=function(){return!0};ae.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n!==void 0?n.e=e:lr(function(){var i;(i=t.W)==null||i.call(t)}))};ae.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,i=e.x;n!==void 0&&(n.x=i,e.e=void 0),i!==void 0&&(i.e=n,e.x=void 0),e===this.t&&(this.t=i,i===void 0&&lr(function(){var s;(s=t.Z)==null||s.call(t)}))}};ae.prototype.subscribe=function(e){var t=this;return ee(function(){var n=t.value,i=j;j=void 0;try{e(n)}finally{j=i}},{name:"sub"})};ae.prototype.valueOf=function(){return this.value};ae.prototype.toString=function(){return this.value+""};ae.prototype.toJSON=function(){return this.value};ae.prototype.peek=function(){var e=j;j=void 0;try{return this.value}finally{j=e}};Object.defineProperty(ae.prototype,"value",{get:r(function(){var e=cr(this);return e!==void 0&&(e.i=this.i),this.v},"get"),set:r(function(e){if(e!==this.v){if(ui>100)throw new Error("Cycle detected");this.v=e,this.i++,Ut++,je++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Vt()}}},"set")});function q(e,t){return new ae(e,t)}r(q,"c");function ur(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}r(ur,"a");function dr(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}r(dr,"l");function pr(e){for(var t=e.s,n=void 0;t!==void 0;){var i=t.p;t.i===-1?(t.S.U(t),i!==void 0&&(i.n=t.n),t.n!==void 0&&(t.n.p=i)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=i}e.s=n}r(pr,"y");function ze(e,t){ae.call(this,void 0),this.x=e,this.s=void 0,this.g=Ut-1,this.f=4,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}r(ze,"w");ze.prototype=new ae;ze.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Ut))return!0;if(this.g=Ut,this.f|=1,this.i>0&&!ur(this))return this.f&=-2,!0;var e=j;try{dr(this),j=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return j=e,pr(this),this.f&=-2,!0};ze.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}ae.prototype.S.call(this,e)};ze.prototype.U=function(e){if(this.t!==void 0&&(ae.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}};ze.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty(ze.prototype,"value",{get:r(function(){if(1&this.f)throw new Error("Cycle detected");var e=cr(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v},"get")});function pe(e,t){return new ze(e,t)}r(pe,"b");function hr(e){var t=e.u;if(e.u=void 0,typeof t=="function"){je++;var n=j;j=void 0;try{t()}catch(i){throw e.f&=-2,e.f|=8,di(e),i}finally{j=n,Vt()}}}r(hr,"_");function di(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,hr(e)}r(di,"p");function Cl(e){if(j!==this)throw new Error("Out-of-order effect");pr(this),j=e,this.f&=-2,8&this.f&&di(this),Vt()}r(Cl,"g");function it(e,t){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=t?.name,ar&&ar.push(this)}r(it,"S");it.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.u=t)}finally{e()}};it.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,hr(this),dr(this),je++;var e=j;return j=this,Cl.bind(this,e)};it.prototype.N=function(){2&this.f||(this.f|=2,this.o=yt,yt=this)};it.prototype.d=function(){this.f|=8,1&this.f||di(this)};it.prototype.dispose=function(){this.d()};function ee(e,t){var n=new it(e,t);try{n.c()}catch(s){throw n.d(),s}var i=n.d.bind(n);return i[Symbol.dispose]=i,i}r(ee,"m");var El="swish-save, swish-drawer";function fr(e,t){return e.closest(El)===t}r(fr,"belongsToHost");function $t(e,t){return ee(()=>{let n=t();e.querySelectorAll("[data-swish-when]").forEach(s=>{if(!fr(s,e))return;let a=!(s.dataset.swishWhen??"").split(",").map(l=>l.trim()).includes(n);s.hidden!==a&&(s.hidden=a)})})}r($t,"bindWhen");function mr(e,t,n){e.hidden&&(e.hidden=!1);let i=`[data-swish-bind="${t}"]`;return ee(()=>{let s=n(),o=String(s);e.querySelectorAll(i).forEach(l=>{fr(l,e)&&l.textContent!==o&&(l.textContent=o)})})}r(mr,"bindValue");var Rl=["home","saves","lists","orders","notifications","profile"],kl=["view"],Pl=typeof HTMLElement<"u"?HTMLElement:class{},vt=class extends Pl{constructor(){super(...arguments);this.disposers=[];this.deferredReady=null;this.clickHandler=r(()=>{let n=Ge();if(!n)return;let i=this.resolveView();n.intents.invoke(`view:${i}`)},"clickHandler")}static{r(this,"SwishDrawerElement")}static get observedAttributes(){return[...kl]}connectedCallback(){if(!this.isConnected)return;let n=Ge();if(!n){if(this.deferredReady)return;let i=r(()=>{this.deferredReady=null,this.connectedCallback()},"handler");this.deferredReady=i,document.addEventListener("swish-ready",i,{once:!0});return}this.bind(n),this.addEventListener("click",this.clickHandler)}disconnectedCallback(){this.deferredReady&&(document.removeEventListener("swish-ready",this.deferredReady),this.deferredReady=null),this.removeEventListener("click",this.clickHandler),this.dispose()}bind(n){let i=n.state.itemCount(),s=n.state.effect(()=>{let{count:l,loading:c}=i.value;this.setAttribute("state",l>0?"has-saves":"empty"),!c&&!this.hasAttribute("ready")&&this.toggleAttribute("ready",!0)}),o=mr(this,"count",()=>i.value.count),a=$t(this,()=>i.value.count>0?"has-saves":"empty");this.disposers.push(s,o,a)}dispose(){for(;this.disposers.length;)this.disposers.pop()?.()}resolveView(){let n=this.getAttribute("view");return n&&Rl.includes(n)?n:(n&&console.warn(`[swish] <swish-drawer> view="${n}" is not a recognized view. Falling back to "home".`),"home")}};var Al=["product","variant","context","match"],Tl="a[href*='/products/']";function Dl(e){if(e==="variant"||e==="product"||e==="auto")return e}r(Dl,"parseMatch");function Ll(e){return e==="product-card"?"product":"auto"}r(Ll,"defaultMatchForContext");var Ol=typeof HTMLElement<"u"?HTMLElement:class{},gt=class extends Ol{constructor(){super(...arguments);this.disposers=[];this.state=null;this.deferredReady=null;this.clickHandler=r(n=>{n.stopPropagation(),this.state?.toggle()},"clickHandler")}static{r(this,"SwishSaveElement")}static get observedAttributes(){return[...Al]}connectedCallback(){if(!this.isConnected)return;let n=Ge();if(!n){if(this.deferredReady)return;let i=r(()=>{this.deferredReady=null,this.connectedCallback()},"handler");this.deferredReady=i,document.addEventListener("swish-ready",i,{once:!0});return}this.bind(n),this.addEventListener("click",this.clickHandler)}attributeChangedCallback(n,i,s){i===s||!this.isConnected||!this.state||this.rebind()}disconnectedCallback(){this.deferredReady&&(document.removeEventListener("swish-ready",this.deferredReady),this.deferredReady=null),this.removeEventListener("click",this.clickHandler),this.dispose()}bind(n){let i=this.resolveContext(n),s=Dl(this.getAttribute("match"))??Ll(this.getAttribute("context"));this.state=n.state.itemState(i,{match:s});let o=n.state.effect(()=>{let l=this.state?.value;l&&(this.setAttribute("state",l.status),this.setAttribute("aria-pressed",String(l.saved)),!l.loading&&!this.hasAttribute("ready")&&this.toggleAttribute("ready",!0))}),a=$t(this,()=>this.state?.value.status??"unsaved");this.disposers.push(()=>this.state?.dispose()),this.disposers.push(o),this.disposers.push(a)}rebind(){let n=Ge();n&&(this.dispose(),this.bind(n))}dispose(){for(;this.disposers.length;)this.disposers.pop()?.();this.state=null}resolveContext(n){let i=this.getAttribute("product"),s=this.getAttribute("variant");if(i)return n.state.itemContextFromIds({productId:i,variantId:s});let o=this.getAttribute("context");if(o==="pdp")return n.state.itemContext(window.location);if(o==="product-card"){let a=Ze(this,Tl);if(a)return n.state.itemContext(a)}return n.state.itemContext(this)}};var yr=null;function pi(e){yr=e,!(typeof customElements>"u")&&(customElements.get("swish-save")||customElements.define("swish-save",gt),customElements.get("swish-drawer")||customElements.define("swish-drawer",vt))}r(pi,"initElements");function Ge(){return yr}r(Ge,"getSwish");var Ht=class{constructor(){this.eventBus=new EventTarget}static{r(this,"EventBus")}subscribe(t,n,i){return Array.isArray(t)||(t=[t]),t.forEach(s=>{this.eventBus.addEventListener(s,n,i)}),()=>{t.forEach(s=>{this.eventBus.removeEventListener(s,n,i)})}}unsubscribe(t,n,i){this.eventBus.removeEventListener(t,n,i)}publish(t,n){this.eventBus.dispatchEvent(new CustomEvent(t,{detail:n}))}};var hi;function fi(e){return{lang:e?.lang??hi?.lang,message:e?.message,abortEarly:e?.abortEarly??hi?.abortEarly,abortPipeEarly:e?.abortPipeEarly??hi?.abortPipeEarly}}r(fi,"getGlobalConfig");var Ml;function _l(e){return Ml?.get(e)}r(_l,"getGlobalMessage");var ql;function Bl(e){return ql?.get(e)}r(Bl,"getSchemaMessage");var Fl;function jl(e,t){return Fl?.get(e)?.get(t)}r(jl,"getSpecificMessage");function wt(e){let t=typeof e;return t==="string"?`"${e}"`:t==="number"||t==="bigint"||t==="boolean"?`${e}`:t==="object"||t==="function"?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":t}r(wt,"_stringify");function re(e,t,n,i,s){let o=s&&"input"in s?s.input:n.value,a=s?.expected??e.expects??null,l=s?.received??wt(o),c={kind:e.kind,type:e.type,input:o,expected:a,received:l,message:`Invalid ${t}: ${a?`Expected ${a} but r`:"R"}eceived ${l}`,requirement:e.requirement,path:s?.path,issues:s?.issues,lang:i.lang,abortEarly:i.abortEarly,abortPipeEarly:i.abortPipeEarly},d=e.kind==="schema",u=s?.message??e.message??jl(e.reference,c.lang)??(d?Bl(c.lang):null)??i.message??_l(c.lang);u!==void 0&&(c.message=typeof u=="function"?u(c):u),d&&(n.typed=!1),n.issues?n.issues.push(c):n.issues=[c]}r(re,"_addIssue");function he(e){return{version:1,vendor:"valibot",validate(t){return e["~run"]({value:t},fi())}}}r(he,"_getStandardProps");function Nl(e,t){return Object.hasOwn(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}r(Nl,"_isValidObjectKey");function mi(e,t){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??"never"}r(mi,"_joinExpects");var Ul=class extends Error{static{r(this,"ValiError")}constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function bt(e,t){return{kind:"validation",type:"min_length",reference:bt,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(n,i){return n.typed&&n.value.length<this.requirement&&re(this,"length",n,i,{received:`${n.value.length}`}),n}}}r(bt,"minLength");function Re(e,t){return{kind:"validation",type:"min_value",reference:Re,async:!1,expects:`>=${e instanceof Date?e.toJSON():wt(e)}`,requirement:e,message:t,"~run"(n,i){return n.typed&&!(n.value>=this.requirement)&&re(this,"value",n,i,{received:n.value instanceof Date?n.value.toJSON():wt(n.value)}),n}}}r(Re,"minValue");function V(e){return{kind:"transformation",type:"transform",reference:V,async:!1,operation:e,"~run"(t){return t.value=this.operation(t.value),t}}}r(V,"transform");function Vl(e,t,n){return typeof e.fallback=="function"?e.fallback(t,n):e.fallback}r(Vl,"getFallback");function gr(e,t,n){return typeof e.default=="function"?e.default(t,n):e.default}r(gr,"getDefault");function G(e,t){return{kind:"schema",type:"array",reference:G,expects:"Array",async:!1,item:e,message:t,get"~standard"(){return he(this)},"~run"(n,i){let s=n.value;if(Array.isArray(s)){n.typed=!0,n.value=[];for(let o=0;o<s.length;o++){let a=s[o],l=this.item["~run"]({value:a},i);if(l.issues){let c={type:"array",origin:"value",input:s,key:o,value:a};for(let d of l.issues)d.path?d.path.unshift(c):d.path=[c],n.issues?.push(d);if(n.issues||(n.issues=l.issues),i.abortEarly){n.typed=!1;break}}l.typed||(n.typed=!1),n.value.push(l.value)}}else re(this,"type",n,i);return n}}}r(G,"array");function T(e){return{kind:"schema",type:"boolean",reference:T,expects:"boolean",async:!1,message:e,get"~standard"(){return he(this)},"~run"(t,n){return typeof t.value=="boolean"?t.typed=!0:re(this,"type",t,n),t}}}r(T,"boolean");function yi(e,t){return{kind:"schema",type:"instance",reference:yi,expects:e.name,async:!1,class:e,message:t,get"~standard"(){return he(this)},"~run"(n,i){return n.value instanceof this.class?n.typed=!0:re(this,"type",n,i),n}}}r(yi,"instance");function Q(e,t){return{kind:"schema",type:"literal",reference:Q,expects:wt(e),async:!1,literal:e,message:t,get"~standard"(){return he(this)},"~run"(n,i){return n.value===this.literal?n.typed=!0:re(this,"type",n,i),n}}}r(Q,"literal");function M(e){return{kind:"schema",type:"number",reference:M,expects:"number",async:!1,message:e,get"~standard"(){return he(this)},"~run"(t,n){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:re(this,"type",t,n),t}}}r(M,"number");function I(e,t){return{kind:"schema",type:"object",reference:I,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return he(this)},"~run"(n,i){let s=n.value;if(s&&typeof s=="object"){n.typed=!0,n.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 l=o in s?s[o]:gr(a),c=a["~run"]({value:l},i);if(c.issues){let d={type:"object",origin:"value",input:s,key:o,value:l};for(let u of c.issues)u.path?u.path.unshift(d):u.path=[d],n.issues?.push(u);if(n.issues||(n.issues=c.issues),i.abortEarly){n.typed=!1;break}}c.typed||(n.typed=!1),n.value[o]=c.value}else if(a.fallback!==void 0)n.value[o]=Vl(a);else if(a.type!=="exact_optional"&&a.type!=="optional"&&a.type!=="nullish"&&(re(this,"key",n,i,{input:void 0,expected:`"${o}"`,path:[{type:"object",origin:"key",input:s,key:o,value:s[o]}]}),i.abortEarly))break}}else re(this,"type",n,i);return n}}}r(I,"object");function m(e,t){return{kind:"schema",type:"optional",reference:m,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return he(this)},"~run"(n,i){return n.value===void 0&&(this.default!==void 0&&(n.value=gr(this,n,i)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,i)}}}r(m,"optional");function le(e,t){return{kind:"schema",type:"picklist",reference:le,expects:mi(e.map(wt),"|"),async:!1,options:e,message:t,get"~standard"(){return he(this)},"~run"(n,i){return this.options.includes(n.value)?n.typed=!0:re(this,"type",n,i),n}}}r(le,"picklist");function ie(e,t,n){return{kind:"schema",type:"record",reference:ie,expects:"Object",async:!1,key:e,value:t,message:n,get"~standard"(){return he(this)},"~run"(i,s){let o=i.value;if(o&&typeof o=="object"){i.typed=!0,i.value={};for(let a in o)if(Nl(o,a)){let l=o[a],c=this.key["~run"]({value:a},s);if(c.issues){let u={type:"object",origin:"key",input:o,key:a,value:l};for(let p of c.issues)p.path=[u],i.issues?.push(p);if(i.issues||(i.issues=c.issues),s.abortEarly){i.typed=!1;break}}let d=this.value["~run"]({value:l},s);if(d.issues){let u={type:"object",origin:"value",input:o,key:a,value:l};for(let p of d.issues)p.path?p.path.unshift(u):p.path=[u],i.issues?.push(p);if(i.issues||(i.issues=d.issues),s.abortEarly){i.typed=!1;break}}(!c.typed||!d.typed)&&(i.typed=!1),c.typed&&(i.value[c.value]=d.value)}}else re(this,"type",i,s);return i}}}r(ie,"record");function C(e){return{kind:"schema",type:"string",reference:C,expects:"string",async:!1,message:e,get"~standard"(){return he(this)},"~run"(t,n){return typeof t.value=="string"?t.typed=!0:re(this,"type",t,n),t}}}r(C,"string");function vr(e){let t;if(e)for(let n of e)t?t.push(...n.issues):t=n.issues;return t}r(vr,"_subIssues");function H(e,t){return{kind:"schema",type:"union",reference:H,expects:mi(e.map(n=>n.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return he(this)},"~run"(n,i){let s,o,a;for(let l of this.options){let c=l["~run"]({value:n.value},i);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];re(this,"type",n,i,{issues:vr(o)}),n.typed=!0}else{if(a?.length===1)return a[0];re(this,"type",n,i,{issues:vr(a)})}return n}}}r(H,"union");function ce(){return{kind:"schema",type:"unknown",reference:ce,expects:"unknown",async:!1,get"~standard"(){return he(this)},"~run"(e){return e.typed=!0,e}}}r(ce,"unknown");function We(e,t,n){return{kind:"schema",type:"variant",reference:We,expects:"Object",async:!1,key:e,options:t,message:n,get"~standard"(){return he(this)},"~run"(i,s){let o=i.value;if(o&&typeof o=="object"){let a,l=0,c=this.key,d=[],u=r((p,h)=>{for(let f of p.options){if(f.type==="variant")u(f,new Set(h).add(f.key));else{let w=!0,y=0;for(let b of h){let S=f.entries[b];if(b in o?S["~run"]({typed:!1,value:o[b]},{abortEarly:!0}).issues:S.type!=="exact_optional"&&S.type!=="optional"&&S.type!=="nullish"){w=!1,c!==b&&(l<y||l===y&&b in o&&!(c in o))&&(l=y,c=b,d=[]),c===b&&d.push(f.entries[b].expects);break}y++}if(w){let b=f["~run"]({value:o},s);(!a||!a.typed&&b.typed)&&(a=b)}}if(a&&!a.issues)break}},"parseOptions");if(u(this,new Set([this.key])),a)return a;re(this,"type",i,s,{input:o[c],expected:mi(d,"|"),path:[{type:"object",origin:"value",input:o,key:c,value:o[c]}]})}else re(this,"type",i,s);return i}}}r(We,"variant");function wr(e,t,n){let i=e["~run"]({value:t},fi(n));if(i.issues)throw new Ul(i.issues);return i.value}r(wr,"parse");function _(...e){return{...e[0],pipe:e,get"~standard"(){return he(this)},"~run"(t,n){for(let i of e)if(i.kind!=="metadata"){if(t.issues&&(i.kind==="schema"||i.kind==="transformation")){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=i["~run"](t,n))}return t}}}r(_,"pipe");function B(e,t,n){let i=e["~run"]({value:t},fi(n));return{typed:i.typed,success:!i.issues,output:i.value,issues:i.issues}}r(B,"safeParse");var st=_(H([_(C(),V(U)),M()]),V(e=>Number(e)),_(M(),Re(1)));var D=class{constructor(t,n,i,s){this.swish=t;this.ui=n;this.eventBus=i;this.options=s}static{r(this,"IntentHandler")}};var $l=H([I({variantId:st,quantity:m(_(M(),Re(1)),1)}),I({items:_(G(I({variantId:st,quantity:m(_(M(),Re(1)),1)})),bt(1))})]),Qt=class extends D{static{r(this,"CreateCartLineHandler")}async invoke(t){let n=B($l,t);if(!n.success)return{intent:"create:cart-line",code:"error",message:"Invalid intent data",issues:n.issues.map(s=>s.message)};let i=n.output;try{let s="items"in i?i.items.map(a=>({id:a.variantId,quantity:a.quantity})):[{id:i.variantId,quantity:i.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 zt=class extends D{static{r(this,"CreateListHandler")}async invoke(t){let n=await this.ui.showListEditor();if(n.code==="closed")return{intent:"create:list",code:"closed"};let{list:i}=n.data;return{intent:"create:list",code:"ok",data:{list:i}}}};var Hl=I({listId:C()}),Gt=class extends D{static{r(this,"DeleteListHandler")}async invoke(t){let n=B(Hl,t);if(!n.success)return{intent:"delete:list",code:"error",message:"Invalid intent data",issues:n.issues.map(o=>o.message)};let{listId:i}=n.output;return(await this.ui.showDeleteListAlert({listId:i})).code==="closed"?{intent:"delete:list",code:"closed"}:{intent:"delete:list",code:"ok",data:{listId:i}}}};var Ql=I({itemId:C()}),Wt=class extends D{static{r(this,"EditItemListsHandler")}async invoke(t){let n=B(Ql,t);if(!n.success)return{intent:"edit:item-lists",code:"error",message:"Invalid intent data",issues:n.issues.map(o=>o.message)};let{itemId:i}=n.output,s=await this.ui.showListSelect({itemId:i});if(s.code==="closed")return{intent:"edit:item-lists",code:"closed"};if(s.data.action==="submit"){let{item:o,product:a,variant:l}=s.data.data;return{intent:"edit:item-lists",code:"ok",data:{item:o,product:a,variant:l}}}return{intent:"unsave:item",code:"ok",data:{itemId:s.data.data.itemId}}}};var zl=I({itemId:_(C()),productId:_(H([_(C(),V(U)),M()]),V(e=>Number(e)),M()),variantId:m(_(H([_(C(),V(U)),M()]),V(e=>Number(e)),M()))}),Kt=class extends D{static{r(this,"EditItemVariantHandler")}async invoke(t){let n=B(zl,t);if(!n.success)return{intent:"edit:item-variant",code:"error",message:"Invalid intent data",issues:n.issues.map(h=>h.message)};let{itemId:i,productId:s,variantId:o}=n.output;if(!(!o||this.swish.options.intents.editSavedProduct.promptVariantChange)){let h=await this.swish.api.items.updateById(i,{productId:s,variantId:o});if("error"in h)return{intent:"edit:item-variant",code:"error",message:"Failed to update variant",issues:[h.error.message]};if(!h.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.loadProduct({productId:String(s),variantId:o?String(o):void 0});if(!f.data?.product)return{intent:"edit:item-variant",code:"error",message:"Failed to load product data",issues:[f.errors?.message??"No product data returned from API"]};let w=f.data.product,y=f.data.variant;return{intent:"edit:item-variant",code:"ok",data:{item:h.data,product:w,variant:y}}}let l=await this.ui.showVariantSelect({itemId:i,productId:s,variantId:o});if(l.code==="closed")return{intent:"edit:item-variant",code:"closed"};let{item:c,product:d,variant:u}=l.data;return{intent:"edit:item-variant",code:"ok",data:{item:c,product:d,variant:u}}}};var Gl=I({listId:C(),access:le(["public","private"])}),Xt=class extends D{static{r(this,"EditListAccessHandler")}async invoke(t){let n=B(Gl,t);if(!n.success)return{intent:"edit:list-access",code:"error",message:"Invalid intent data",issues:n.issues.map(l=>l.message)};let{listId:i,access:s}=n.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(i,{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 Wl=I({listId:C()}),Jt=class extends D{static{r(this,"EditListHandler")}async invoke(t){let n=B(Wl,t);if(!n.success)return{intent:"edit:list",code:"error",message:"Invalid intent data",issues:n.issues.map(a=>a.message)};let{listId:i}=n.output,s=await this.ui.showListEditor({listId:i});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 Kl=I({variantId:st,quantity:m(_(M(),Re(1)),1)}),Xl=150,Jl=H([I({variantId:st,quantity:m(_(M(),Re(1)),1)}),I({items:_(G(Kl),bt(1))})]),Yt=class extends D{static{r(this,"InitiateCheckoutHandler")}async invoke(t){let n=B(Jl,t);if(!n.success)return{intent:"initiate:checkout",code:"error",message:"Invalid intent data",issues:n.issues.map(l=>l.message)};let i=n.output,o=("items"in i?i.items:[{variantId:i.variantId,quantity:i.quantity}]).map(l=>`${l.variantId}:${l.quantity}`).join(","),a=new URL(`/cart/${o}`,this.swish.shopUrl);return a.searchParams.set("checkout","1"),typeof window<"u"&&window.setTimeout(()=>window.location.assign(a.href),Xl),{intent:"initiate:checkout",code:"ok",data:{checkoutUrl:a.href}}}};var Yl=I({productId:_(H([_(C(),V(U)),M()]),V(e=>Number(e)),M()),variantId:m(_(H([_(C(),V(U)),M()]),V(Number),M()))}),Zt=class extends D{static{r(this,"InitiateQuickBuyHandler")}async invoke(t){let n=B(Yl,t);if(!n.success)return{intent:"initiate:quick-buy",code:"error",message:"Invalid intent data",issues:n.issues.map(a=>a.message)};let{productId:i,variantId:s}=n.output,o=await this.ui.showQuickBuy({productId:i,variantId:s});return o.code==="closed"?{intent:"initiate:quick-buy",code:"closed"}:{intent:"initiate:quick-buy",code:"ok",data:o.data}}};var Zl=150,ec=I({returnTo:C()}),en=class extends D{static{r(this,"InitiateSignInHandler")}async invoke(t){let n=B(ec,t);if(!n.success)return{intent:"initiate:sign-in",code:"error",message:"Invalid intent data",issues:n.issues.map(o=>o.message)};let i=n.output.returnTo;return(await this.ui.showConfirmDialog({titleKey:"signIn.title",descriptionKey:"signIn.description",confirmLabelKey:"signIn.continue",danger:!1})).code==="closed"?{intent:"initiate:sign-in",code:"closed"}:(this.scheduleRedirect(i),{intent:"initiate:sign-in",code:"ok",data:void 0})}scheduleRedirect(t){window.setTimeout(()=>this.redirectToSignIn(t),Zl)}redirectToSignIn(t){let{routes:n,newCustomerAccounts:i}=this.swish.storefrontContext,s=i?"/customer_identity/login":n.accountUrl,o=new URL(s,window.location.origin);o.searchParams.set("return_to",t),window.location.assign(o.toString())}};var tc=150,tn=class extends D{static{r(this,"InitiateSignOutHandler")}async invoke(){return this.scheduleRedirect(),{intent:"initiate:sign-out",code:"ok",data:void 0}}scheduleRedirect(){window.setTimeout(()=>this.redirectToSignOut(),tc)}redirectToSignOut(){let{accountUrl:t,rootUrl:n}=this.swish.storefrontContext.routes,{newCustomerAccounts:i}=this.swish.storefrontContext,s;if(i){let o=new URL(t,window.location.origin);o.pathname=o.pathname.replace(/\/$/,"")+"/logout",s=o.toString()}else s=new URL("/account/logout",window.location.origin).toString();s+=`?return_url=${encodeURIComponent(n)}`,window.location.assign(s)}};var nn=class extends D{static{r(this,"SaveCartLineHandler")}async invoke(t){if(!t?.items?.length)return{intent:"save:cart-line",code:"error",message:"No items to save",issues:["items array is empty or missing"]};let{confirm:n,showFeedback:i}=this.options.saveCartLine,s=t.items[0];if(n&&(await this.ui.showToast({title:"Save this for later?",text:s.title??"",image:s.image,action:{label:"Save for later"},variant:"full"})).code!=="ok")return{intent:"save:cart-line",code:"closed"};for(let o of t.items){let a=await this.swish.api.items.create({productId:o.productId,variantId:o.variantId,quantity:o.quantity,source:"cart"});if("error"in a)return{intent:"save:cart-line",code:"error",message:"Failed to save item from cart",issues:[a.error.message]}}return i&&await this.ui.showToast({title:"We've saved this for you",text:s.title??"",image:s.image,variant:"full"}),{intent:"save:cart-line",code:"ok",data:t.items}}};var nc=I({productId:_(H([_(C(),V(U)),M()]),V(e=>Number(e)),M()),variantId:m(_(H([_(C(),V(U)),M()]),V(Number),M())),quantity:m(_(M(),Re(1))),tags:m(G(C()))}),sn=class extends D{static{r(this,"SaveItemHandler")}async invoke(t){let n=B(nc,t);if(!n.success)return{intent:"save:item",code:"error",message:"Invalid intent data",issues:n.issues.map(b=>b.message)};let{productId:i,variantId:s,quantity:o,tags:a}=n.output,l=await this.swish.storefront.loadProduct({productId:String(i),variantId:s?String(s):void 0});if(l.errors)return{intent:"save:item",code:"error",message:l.errors.message??"Failed to load product data",issues:l.errors.graphQLErrors?.map(b=>b.message)??[]};if(!l.data||!l.data.product)return{intent:"save:item",code:"error",message:"Failed to load product data",issues:["API response missing data"]};let{product:c,variant:d}=l.data,u=c.variantsCount?.count&&c.variantsCount.count>1,p=!!s,f=!(typeof this.options.saveProduct.promptVariantIfMissing=="function"?this.options.saveProduct.promptVariantIfMissing({product:c,variant:d}):this.options.saveProduct.promptVariantIfMissing)||!this.options.saveProduct.promptVariantIfPresent&&p;if(!u||f){let b=r(()=>!u&&c.selectedOrFirstAvailableVariant?Number(U(c.selectedOrFirstAvailableVariant.id)):s,"variantIdToUse"),S=await this.swish.api.items.create({productId:i,variantId:b(),quantity:o,tags:a});return"error"in S?{intent:"save:item",code:"error",message:"Failed to create item",issues:[S.error.message]}:S.data?{intent:"save:item",code:"ok",data:{item:S.data,product:c,variant:u?d:c.selectedOrFirstAvailableVariant}}:{intent:"save:item",code:"error",message:"Could not complete item creation",issues:["API response missing data"]}}let w;if(this.options.saveProduct.saveBeforeVariantPrompt){let b=await this.swish.api.items.create({productId:i,quantity:o,tags:a});"data"in b&&b.data&&(w=b.data)}let y=await this.ui.showVariantSelect({productId:i,variantId:s,itemId:w?.id});return y.code==="closed"?w?{intent:"save:item",code:"ok",data:{item:w,product:c,variant:d}}:{intent:"save:item",code:"closed"}:{intent:"save:item",code:"ok",data:y.data}}};function It(e,t){let{storeDomain:n}=e.options.storefront,{rootUrl:i,listDetailPagePath:s}=e.options.context.routes,o=new URL(`https://${n}`),a=new URL(`${i==="/"?"":i}${s}`,o);return a.searchParams.set("public-list-id",t.publicListId),a}r(It,"buildShareListUrl");async function St(e){return typeof navigator?.clipboard?.writeText!="function"?{ok:!1,issues:["Clipboard API not available"]}:navigator.clipboard.writeText(e).then(()=>({ok:!0})).catch(t=>({ok:!1,issues:[t?.message??"Failed to copy to clipboard"]}))}r(St,"copyToClipboard");function br(){let e=navigator.userAgent.includes("Mac OS")&&navigator.maxTouchPoints>1;return/Android|Mobile/i.test(navigator.userAgent)||e}r(br,"isMobileDevice");var ic=I({listId:C()}),rn=class extends D{static{r(this,"ShareListHandler")}async invoke(t){let n=B(ic,t);if(!n.success)return{intent:"initiate:share",code:"error",message:"Invalid intent data",issues:n.issues.map(c=>c.message)};let{listId:i}=n.output,s=await this.swish.api.lists.findById(i);if("error"in s)return{intent:"initiate:share",code:"error",message:"Failed to fetch list",issues:[s.error.message]};if(!s.data)return{intent:"initiate:share",code:"error",message:"List not found",issues:[]};if(s.data.access!=="public"){let d=await(await this.swish.intents.invoke("edit:list-access",{listId:i,access:"public"})).complete;if(d.code!=="ok")return{...d,intent:"initiate:share"}}let o=It(this.swish,{publicListId:i}).toString();if(br()&&typeof navigator.share=="function"&&(await navigator.share({title:"Share list",url:o}).then(()=>({ok:!0})).catch(()=>({ok:!1}))).ok)return{intent:"initiate:share",code:"ok",data:{listId:i,url:o,method:"native"}};let l=await St(o);return l.ok?{intent:"initiate:share",code:"ok",data:{listId:i,url:o,method:"clipboard"}}:{intent:"initiate:share",code:"error",message:"Failed to share list",issues:l.issues}}};var gy=I({title:m(C()),text:C(),image:m(C()),action:m(I({label:C(),url:m(C())})),variant:m(le(["compact","full"])),icon:m(C())}),on=class extends D{static{r(this,"ShowToastHandler")}async invoke(t){return{intent:"show:toast",code:(await this.ui.showToast(t)).code,data:void 0}}};var sc=I({itemId:C(),delete:m(T())}),an=class extends D{static{r(this,"UnsaveItemHandler")}async invoke(t){let n=B(sc,t);if(!n.success)return{intent:"unsave:item",code:"error",message:"Invalid intent data",issues:n.issues.map(a=>a.message)};let{itemId:i,delete:s}=n.output;if(this.options.unsaveProduct.selectList&&!s){let a=await this.ui.showListSelect({itemId:i});if(a.code==="closed")return{intent:"unsave:item",code:"closed"};if(a.data.action==="submit"){let{item:l,product:c,variant:d}=a.data.data;return{intent:"edit:item-lists",code:"ok",data:{item:l,product:c,variant:d}}}if(a.data.action==="unsave"){let{itemId:l}=a.data.data;return{intent:"unsave:item",code:"ok",data:{itemId:l}}}}if(!this.options.unsaveProduct.confirm){let a=await this.swish.api.items.deleteById(i);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:i}}}return(await this.ui.showUnsaveAlert({itemId:i})).code==="closed"?{intent:"unsave:item",code:"closed"}:{intent:"unsave:item",code:"ok",data:{itemId:i}}}};var ln=class extends D{static{r(this,"ViewHomeHandler")}async invoke(t){return{intent:"view:home",code:(await this.ui.showDrawer()).code,data:void 0}}};var rc=I({listId:C()}),cn=class extends D{static{r(this,"ViewListDetailPageMenuHandler")}async invoke(t){let n=B(rc,t);if(!n.success)return{intent:"view:list-detail-page-menu",code:"error",message:"Invalid intent data",issues:n.issues.map(o=>o.message)};let{listId:i}=n.output;return{intent:"view:list-detail-page-menu",code:(await this.ui.showListDetailPageMenu({listId:i})).code,data:void 0}}};var oc=I({listId:C(),listType:m(le(["user","smart","shared"]),"user")}),un=class extends D{static{r(this,"ViewListHandler")}async invoke(t){let n=B(oc,t);if(!n.success)return{intent:"view:list",code:"error",message:"Invalid intent data",issues:n.issues.map(a=>a.message)};let{listId:i,listType:s}=n.output;return{intent:"view:list",code:(await this.ui.showDrawer({view:"list",listId:i,listType:s})).code,data:void 0}}};var ac=I({listId:C()}),dn=class extends D{static{r(this,"ViewListMenuHandler")}async invoke(t){let n=B(ac,t);if(!n.success)return{intent:"view:list-menu",code:"error",message:"Invalid intent data",issues:n.issues.map(o=>o.message)};let{listId:i}=n.output,s=await this.ui.showListMenu({listId:i});if(s.code==="closed")return{intent:"view: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:i}};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:i,access:a})).complete:{intent:"view: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("initiate:share",{listId:i})).complete:s.data.action==="add-items"?{intent:"view:list-menu",code:"ok",data:{listId:i}}:{intent:"view:list-menu",code:"error",message:"Unknown list menu action",issues:["Unknown action returned from list menu UI"]}}};var pn=class extends D{static{r(this,"ViewListsHandler")}async invoke(t){return{intent:"view:lists",code:(await this.ui.showDrawer({view:"lists"})).code,data:void 0}}};var hn=class extends D{static{r(this,"ViewNotificationsHandler")}async invoke(t){return{intent:"view:notifications",code:(await this.ui.showDrawer({view:"notifications"})).code,data:void 0}}};var lc=I({orderId:_(H([_(C(),V(U)),M()]),V(e=>Number(e)),M())}),fn=class extends D{static{r(this,"ViewOrderHandler")}async invoke(t){let n=B(lc,t);if(!n.success)return{intent:"view:order",code:"error",message:"Invalid intent data",issues:n.issues.map(o=>o.message)};let{orderId:i}=n.output;return{intent:"view:order",code:(await this.ui.showDrawer({view:"order",orderId:i.toString()})).code,data:void 0}}};var cc=I({orderId:C()}),mn=class extends D{static{r(this,"ViewOrderMenuHandler")}async invoke(t){let n=B(cc,t);if(!n.success)return{intent:"view:order-menu",code:"error",message:"Invalid intent data",issues:n.issues.map(o=>o.message)};let{orderId:i}=n.output;return{intent:"view:order-menu",code:(await this.ui.showOrderMenu({orderId:i})).code,data:void 0}}};var yn=class extends D{static{r(this,"ViewOrdersHandler")}async invoke(t){return{intent:"view:orders",code:(await this.ui.showDrawer({view:"orders"})).code,data:void 0}}};var uc=I({productId:_(H([_(C(),V(U)),M()]),V(e=>Number(e)),M()),variantId:m(_(H([_(C(),V(U)),M()]),V(Number),M()))}),vn=class extends D{static{r(this,"ViewProductHandler")}async invoke(t){let n=B(uc,t);if(!n.success)return{intent:"view:product",code:"error",message:"Invalid intent data",issues:n.issues.map(a=>a.message)};let{productId:i,variantId:s}=n.output;return{intent:"view:product",code:(await this.ui.showDrawer({view:"product",productId:i.toString(),variantId:s?.toString()})).code,data:void 0}}};var gn=class extends D{static{r(this,"ViewProfileHandler")}async invoke(t){return{intent:"view:profile",code:(await this.ui.showDrawer({view:"profile"})).code,data:void 0}}};var wn=class extends D{static{r(this,"ViewSavesHandler")}async invoke(t){return{intent:"view:saves",code:(await this.ui.showDrawer({view:"saves"})).code,data:void 0}}};var te=class{constructor(t,n,i){this.swish=t;this.ui=n;this.options=i}static{r(this,"IntentHook")}};var bn=class extends te{static{r(this,"AfterCreateCartLineHook")}async invoke(t){this.options.createCartLine.afterComplete?.(t)}};var In=class extends te{static{r(this,"AfterEditItemListsHook")}async invoke(t){if(this.options.editSavedProduct.showFeedback&&t.code==="ok"){if("itemId"in t.data)return;let{product:n,variant:i}=t.data;n&&(await(await this.swish.intents.invoke("show:toast",{title:"Saved",text:n.title,image:i?.image?.url??n.featuredImage?.url,action:{label:"View"}})).complete).code==="ok"&&this.swish.intents.invoke("view:saves")}}};var Sn=class extends te{static{r(this,"AfterEditListAccessHook")}async invoke(t){if(t.code!=="ok")return;let n=t.data.list.access==="public"?"List is now public":"List is now private";await(await this.swish.intents.invoke("show:toast",{text:n,variant:"compact",icon:"check"})).complete}};var xn=class extends te{static{r(this,"AfterSaveCartLineHook")}async invoke(t){this.options.saveCartLine.afterComplete?.(t)}};var Cn=class extends te{static{r(this,"AfterSaveItemHook")}async invoke(t){if(this.options.saveProduct.showFeedback&&t.code==="ok"){let{item:n,product:i,variant:s}=t.data;i&&(await(await this.swish.intents.invoke("show:toast",{title:"Saved",text:i.title,image:s?.image?.url??i.featuredImage?.url,action:{label:"Add to List"}})).complete).code==="ok"&&this.swish.intents.invoke("edit:item-lists",{itemId:n.id})}}};var En=class extends te{static{r(this,"AfterShareListHook")}async invoke(t){if(t.code!=="ok")return;await(await this.swish.intents.invoke("show:toast",{variant:"compact",text:"Link copied",icon:"check"})).complete}};var Rn=class extends te{static{r(this,"AfterViewHomeHook")}async invoke(t){if(t.code==="closed"){let n=new URL(window.location.href);(n.hash==="#swish-home"||n.hash==="#swish")&&(n.hash="",window.history.replaceState({},document.title,n.toString()))}}};function Ir(e){let t=e.startsWith("#")?e.slice(1):e;return t==="swish"||t.startsWith("swish-")}r(Ir,"isSwishHash");var kn=class extends te{static{r(this,"BeforeViewHomeHook")}async invoke(){Ir(window.location.hash)||window.history.replaceState(window.history.state,"",window.location.pathname+window.location.search+"#swish")}};var Pn=class{constructor(t,n){this._invoking=!1;this.swish=t,this.ui=n,this.eventBus=new EventTarget,this.options=t.options.intents,this.handlers=this.initHandlers(),this.initIntentHooks(),this.initIntentWatcher(),this.initCartChangeListener()}static{r(this,"Intents")}applyPreview(t){this.options=t,this.handlers=this.initHandlers()}initHandlers(){return{"create:cart-line":new Qt(this.swish,this.ui,this.eventBus,this.options),"initiate:checkout":new Yt(this.swish,this.ui,this.eventBus,this.options),"save:item":new sn(this.swish,this.ui,this.eventBus,this.options),"save:cart-line":new nn(this.swish,this.ui,this.eventBus,this.options),"unsave:item":new an(this.swish,this.ui,this.eventBus,this.options),"edit:item-variant":new Kt(this.swish,this.ui,this.eventBus,this.options),"edit:item-lists":new Wt(this.swish,this.ui,this.eventBus,this.options),"create:list":new zt(this.swish,this.ui,this.eventBus,this.options),"edit:list":new Jt(this.swish,this.ui,this.eventBus,this.options),"edit:list-access":new Xt(this.swish,this.ui,this.eventBus,this.options),"delete:list":new Gt(this.swish,this.ui,this.eventBus,this.options),"view:home":new ln(this.swish,this.ui,this.eventBus,this.options),"initiate:share":new rn(this.swish,this.ui,this.eventBus,this.options),"view:list":new un(this.swish,this.ui,this.eventBus,this.options),"view:lists":new pn(this.swish,this.ui,this.eventBus,this.options),"view:orders":new yn(this.swish,this.ui,this.eventBus,this.options),"view:order":new fn(this.swish,this.ui,this.eventBus,this.options),"view:saves":new wn(this.swish,this.ui,this.eventBus,this.options),"view:notifications":new hn(this.swish,this.ui,this.eventBus,this.options),"view:profile":new gn(this.swish,this.ui,this.eventBus,this.options),"view:product":new vn(this.swish,this.ui,this.eventBus,this.options),"view:list-menu":new dn(this.swish,this.ui,this.eventBus,this.options),"view:order-menu":new mn(this.swish,this.ui,this.eventBus,this.options),"view:list-detail-page-menu":new cn(this.swish,this.ui,this.eventBus,this.options),"initiate:sign-in":new en(this.swish,this.ui,this.eventBus,this.options),"initiate:sign-out":new tn(this.swish,this.ui,this.eventBus,this.options),"initiate:quick-buy":new Zt(this.swish,this.ui,this.eventBus,this.options),"show:toast":new on(this.swish,this.ui,this.eventBus,this.options)}}publishAnalyticsEvent(t,n){typeof window.Shopify?.analytics?.publish=="function"&&window.Shopify.analytics.publish(t,n)}async invoke(t,...n){let i=n[0],s={lifecycle:"before",intent:t,data:i,response:null};return this.publishAnalyticsEvent("swish-intent",s),this.publishAnalyticsEvent(`swish-intent=${t}`,s),this._invoking=!0,this.eventBus.dispatchEvent(new CustomEvent(`before:${t}`,{detail:s})),this._invoking=!1,{intent:t,data:i,complete:this.handleIntent(t,i).then(o=>{let a={lifecycle:"after",intent:t,data:i,response:o};if(this.publishAnalyticsEvent("swish-intent",a),this.publishAnalyticsEvent(`swish-intent=${t}`,a),this.eventBus.dispatchEvent(new CustomEvent(t,{detail:a})),o.code==="ok"&&o.intent!==t){let l={lifecycle:"after",intent:o.intent,data:i,response:o};this.eventBus.dispatchEvent(new CustomEvent(o.intent,{detail:l}))}return o})}}listen(t,n){let i=r(o=>{"detail"in o&&o.detail?n(o.detail.response):console.warn("Intent response event without detail",o)},"eventListener"),s=r(()=>{this.eventBus.removeEventListener(`${t}`,i)},"unsubscribe");return this.eventBus.addEventListener(`${t}`,i),s}parseIntentFromString(t){let n=String(t),i=n.indexOf("?");if(i===-1)return{intent:n,data:{}};let s=n.slice(0,i),o=new URLSearchParams(n.slice(i+1)),a={};return o.forEach((l,c)=>{a[c]=l}),{intent:s,data:a}}parseIntentFromUrl(t){let n=t.searchParams.get("swish-intent");if(!n)return null;let i=n,s={};t.searchParams.forEach((a,l)=>{l!=="swish-intent"&&(s[l]=a)});let o=Ne(t.pathname);return o&&(!s.product&&!s.productId&&(s.product=o.productHandle),!s.variant&&!s.variantId&&o.variantId&&(s.variant=o.variantId)),{intent:i,data:s}}mapParamNames(t){let n={product:"productId",variant:"variantId",list:"listId",order:"orderId",item:"itemId"},i={};for(let[s,o]of Object.entries(t))i[n[s]??s]=o;return i}async resolveIntentData(t){let{productId:n}=t;if(!n||/^\d+$/.test(n)||n.startsWith("gid://"))return t;let i=await this.swish.storefront.loadProductId({productHandle:n});return i.data?.product?.id?{...t,productId:U(i.data.product.id)}:t}async invokeFromParsed(t,n){let i=this.mapParamNames(n),s=await this.resolveIntentData(i);Object.keys(s).length>0?this.invoke(t,s):this.invoke(t)}parseIntentFromHash(t){let n=t.startsWith("#")?t.slice(1):t;return{swish:"view:home","swish-home":"view:home","swish-lists":"view:lists","swish-orders":"view:orders","swish-saves":"view:saves","swish-notifications":"view:notifications","swish-profile":"view:profile"}[n]||null}async handleIntent(t,n){let i=this.handlers[t];return i?i.invoke(n):{intent:t,code:"error",message:"Invalid intent",issues:[`Intent ${t} not found`]}}initIntentHooks(){this.eventBus.addEventListener("before:view:home",()=>{new kn(this.swish,this.ui,this.options).invoke()}),this.eventBus.addEventListener("create:cart-line",t=>{new bn(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("save:item",t=>{new Cn(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("edit:item-lists",t=>{new In(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("view:home",t=>{new Rn(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("edit:list-access",t=>{new Sn(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("initiate:share",t=>{new En(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("save:cart-line",t=>{new xn(this.swish,this.ui,this.options).invoke(t.detail.response)})}initCartChangeListener(){this.swish.events.subscribe(["cart-change","cart-update"],t=>{if(!this.options.removeCartLine.saveCartLine)return;let i=t.detail?.items_removed;if(!i?.length)return;let s=i.map(o=>({productId:o.product_id,variantId:o.variant_id,quantity:o.quantity,title:o.product_title,image:o.image,variantTitle:o.variant_title}));this.invoke("save:cart-line",{items:s})})}initIntentWatcher(){ut({selector:"[swish-intent]",onElementFound:r(t=>{let n=t.getAttribute("swish-intent");if(!n)return;let{intent:i,data:s}=this.parseIntentFromString(n);t.addEventListener("click",()=>{this.invokeFromParsed(i,s)})},"onElementFound")}),ut({selector:"a[href*='swish-intent='],a[href*='#swish']",onElementFound:r(t=>{t instanceof HTMLAnchorElement&&t.addEventListener("click",n=>{if(!n.metaKey&&!n.ctrlKey&&!n.shiftKey&&!n.altKey){let i=new URL(t.href),s=this.parseIntentFromUrl(i);if(s)n.preventDefault(),n.stopPropagation(),this.invokeFromParsed(s.intent,s.data);else if(i.hash){let o=this.parseIntentFromHash(i.hash);o&&(n.preventDefault(),n.stopPropagation(),this.invoke(o))}}})},"onElementFound")}),Ye({fireOnInit:!0,onLocationChange:r(t=>{if(this._invoking)return;let n=new URL(t.href),i=this.parseIntentFromUrl(n);if(i)n.searchParams.delete("swish-intent"),history.replaceState(history.state,"",n.toString()),this.invokeFromParsed(i.intent,i.data);else if(n.hash){let s=this.parseIntentFromHash(n.hash);s&&this.invoke(s)}},"onLocationChange")})}};var K=m(ie(C(),H([C(),M()])),{}),dc=I({url:m(C(),""),altText:m(C(),"")}),pc=I({id:C(),enabled:T(),intent:C()}),hc=I({type:Q("drawer-header"),hidden:m(T(),!1),design:K,options:m(I({title:m(C(),""),logo:m(dc,{url:"",altText:""}),useCloseButton:m(T(),!1),accountButton:m(T(),!0),notificationButton:m(T(),!0)}),{title:"",logo:{url:"",altText:""},useCloseButton:!1,accountButton:!0,notificationButton:!0})}),fc=I({type:Q("drawer-footer"),hidden:m(T(),!1),design:K,options:m(I({displayType:m(le(["floating","docked"]),"docked"),showIcons:m(T(),!1),showText:m(T(),!0),items:m(G(pc),[{id:"home",enabled:!0,intent:"view:home"},{id:"saves",enabled:!0,intent:"view:saves"},{id:"lists",enabled:!1,intent:"view:lists"},{id:"notifications",enabled:!0,intent:"view:notifications"},{id:"orders",enabled:!0,intent:"view:orders"},{id:"profile",enabled:!0,intent:"view:profile"}])}),{displayType:"docked",showIcons:!1,showText:!0,items:[{id:"home",enabled:!0,intent:"view:home"},{id:"saves",enabled:!0,intent:"view:saves"},{id:"lists",enabled:!1,intent:"view:lists"},{id:"notifications",enabled:!0,intent:"view:notifications"},{id:"orders",enabled:!0,intent:"view:orders"},{id:"profile",enabled:!0,intent:"view:profile"}]})}),mc=We("type",[hc,fc]),yc=I({type:le(["sign-in","notifications","recently-viewed","saved-from-cart","saved-items","lists"]),hidden:m(T(),!1),design:K,options:m(ie(C(),ce()),{})}),vc=I({title:C(),url:C()}),gc=I({type:Q("mini-menu"),hidden:m(T(),!1),design:K,options:m(ie(C(),ce()),{}),items:m(G(vc),[])}),wc=I({type:Q("content-block"),hidden:m(T(),!1),design:K,options:m(ie(C(),ce()),{}),title:m(C()),body:m(C()),image:m(I({url:C(),width:m(M()),height:m(M())})),link:m(I({url:C(),target:m(le(["_self","_blank"]))}))}),bc=I({type:Q("featured-collection"),hidden:m(T(),!1),design:K,options:m(ie(C(),ce()),{}),handle:C()}),Ic=We("type",[yc,gc,wc,bc]),Sc=I({type:Q("lists-section"),hidden:m(T(),!1),design:K,options:m(I({display:m(le(["myLists","forYouLists"]),"myLists"),layout:m(le(["list","slider"]),"slider")}),{display:"myLists",layout:"slider"})}),xc=I({type:Q("all-items-grid"),hidden:m(T(),!1),design:K,options:m(I({showSaveButton:m(T(),!0),showQuickBuyButton:m(T(),!0),showBuyButton:m(T(),!1),showVariantTitle:m(T(),!0),enableVariantChange:m(T(),!1),showVariantOptionNames:m(T(),!0),hideCompareAtPrice:m(T(),!1),linkToProductPage:m(T(),!1)}),{showSaveButton:!0,showQuickBuyButton:!0,showBuyButton:!1,showVariantTitle:!0,enableVariantChange:!1,showVariantOptionNames:!0,hideCompareAtPrice:!1,linkToProductPage:!1})}),Cc=We("type",[Sc,xc]),Ec=I({type:Q("lists-grid"),hidden:m(T(),!1),design:K,options:m(I({displayType:m(le(["list","slider"]),"slider")}),{displayType:"slider"})}),Rc=Ec,kc=I({type:Q("list-items-grid"),hidden:m(T(),!1),design:K,options:m(I({desktopColumns:m(M(),4),showBuyButton:m(T(),!0),showVariantTitle:m(T(),!0),showVariantOptionNames:m(T(),!1),enableVariantChange:m(T(),!0),hideCompareAtPrice:m(T(),!1),linkToProductPage:m(T(),!0)}),{desktopColumns:4,showBuyButton:!0,showVariantTitle:!0,showVariantOptionNames:!1,enableVariantChange:!0,hideCompareAtPrice:!1,linkToProductPage:!0})}),Pc=kc,Ac=I({type:Q("list-items-grid"),hidden:m(T(),!1),design:K,options:m(I({showBuyButton:m(T(),!1),showVariantTitle:m(T(),!0),showVariantOptionNames:m(T(),!1),enableVariantChange:m(T(),!1),hideCompareAtPrice:m(T(),!1),linkToProductPage:m(T(),!1)}),{showBuyButton:!1,showVariantTitle:!0,showVariantOptionNames:!1,enableVariantChange:!1,hideCompareAtPrice:!1,linkToProductPage:!1})}),Tc=Ac,Dc=I({type:Q("orders-list"),hidden:m(T(),!1),design:K,options:m(ie(C(),ce()),{})}),Lc=Dc,Oc=I({type:Q("order-info"),hidden:m(T(),!1),design:K,options:m(ie(C(),ce()),{})}),Mc=I({type:Q("order-items"),hidden:m(T(),!1),design:K,options:m(ie(C(),ce()),{})}),_c=I({type:Q("order-actions"),hidden:m(T(),!1),design:K,options:m(ie(C(),ce()),{})}),qc=We("type",[Oc,Mc,_c]),Bc=I({type:Q("image-slider"),hidden:m(T(),!1),design:K,options:m(I({flush:m(T(),!0),loop:m(T(),!1)}),{flush:!0,loop:!1})}),Fc=I({type:Q("product-info"),hidden:m(T(),!1),design:K,options:m(I({descriptionMaxLines:m(M(),4),variantSelectDisplayType:m(le(["pills","rows"]),"pills"),hideSingleValueOptions:m(T(),!0),images:m(I({baseTint:m(T(),!0)}),{baseTint:!0})}),{descriptionMaxLines:4,variantSelectDisplayType:"pills",hideSingleValueOptions:!0,images:{baseTint:!0}})}),jc=I({type:Q("buy-buttons"),hidden:m(T(),!1),design:K,options:m(I({shopPay:m(T(),!1)}),{shopPay:!1})}),Nc=I({type:Q("complementary-products"),hidden:m(T(),!1),design:K,options:m(ie(C(),ce()),{})}),Uc=I({type:Q("related-products"),hidden:m(T(),!1),design:K,options:m(ie(C(),ce()),{})}),Vc=We("type",[Bc,Fc,jc,Nc,Uc]),$c=I({type:Q("profile-form"),hidden:m(T(),!1),design:K,options:m(ie(C(),ce()),{})}),Hc=$c,Qc=I({type:Q("notifications-list"),hidden:m(T(),!1),design:K,options:m(ie(C(),ce()),{})}),zc=Qc,Gc=I({sections:m(G(mc),[{type:"drawer-header",options:{title:"",logo:{url:"",altText:""},useCloseButton:!1,accountButton:!0,notificationButton:!0}},{type:"drawer-footer",options:{displayType:"docked",showIcons:!1,showText:!0,items:[{id:"home",enabled:!0,intent:"view:home"},{id:"saves",enabled:!0,intent:"view:saves"},{id:"lists",enabled:!1,intent:"view:lists"},{id:"notifications",enabled:!0,intent:"view:notifications"},{id:"orders",enabled:!0,intent:"view:orders"},{id:"profile",enabled:!0,intent:"view:profile"}]}}])}),Wc=I({sections:m(G(Ic),[{type:"sign-in"},{type:"notifications"},{type:"recently-viewed"},{type:"saved-from-cart"},{type:"saved-items"},{type:"lists"},{type:"mini-menu",hidden:!0,items:[{title:"Shipping",url:"/policies/shipping-policy"},{title:"Returns",url:"/policies/refund-policy"},{title:"Contact Us",url:"/pages/contact"}]}])}),Kc=I({sections:m(G(Cc),[{type:"lists-section",options:{display:"myLists"}},{type:"lists-section",options:{display:"forYouLists"}},{type:"all-items-grid"}])}),Xc=I({sections:m(G(Rc),[{type:"lists-grid"}])}),Jc=I({sections:m(G(Pc),[{type:"list-items-grid"}])}),Yc=I({sections:m(G(Tc),[{type:"list-items-grid"}])}),Zc=I({sections:m(G(Lc),[{type:"orders-list"}])}),eu=I({sections:m(G(qc),[{type:"order-info"},{type:"order-items"},{type:"order-actions"}])}),tu=I({sections:m(G(Vc),[{type:"image-slider"},{type:"product-info"},{type:"buy-buttons"},{type:"complementary-products"},{type:"related-products"}])}),nu=I({sections:m(G(Hc),[{type:"profile-form"}])}),iu=I({sections:m(G(zc),[{type:"notifications-list"}])}),Sr=I({baseUrl:m(C(),"https://swish.app/cdn"),css:m(G(H([C(),yi(URL)])),[]),design:m(ie(C(),ce()),{}),icons:m(ie(C(),C()),{}),images:m(I({baseTint:m(T(),!0)}),{baseTint:!0}),drawer:m(Gc,{}),home:m(Wc,{}),saves:m(Kc,{}),lists:m(Xc,{}),listDetail:m(Yc,{}),listDetailPage:m(Jc,{}),orders:m(Zc,{}),orderDetail:m(eu,{}),productDetail:m(tu,{}),profile:m(nu,{}),notifications:m(iu,{})});var xr=r(e=>({auth:{tokenUrl:e.auth?.tokenUrl??"/apps/wishlist/api/profiles/token"},storefront:{storeDomain:e.storefront?.storeDomain??"",accessToken:e.storefront?.accessToken??""},context:{...e.context,routes:{...e.context.routes,rootUrl:e.context.routes?.rootUrl??"/",listDetailPagePath:e.context.routes?.listDetailPagePath??"/apps/wishlist"},localization:{country:e.context.localization.country.toUpperCase(),language:e.context.localization.language.toUpperCase(),market:e.context.localization.market}},metafields:{product:e.metafields?.product??[],productVariant:e.metafields?.productVariant??[]},transforms:{productTitle:e.transforms?.productTitle??(({product:t})=>t?.title??""),productDescription:e.transforms?.productDescription??(({product:t})=>t?.descriptionHtml??""),productBadges:e.transforms?.productBadges??(({defaultBadges:t})=>t),productPrice:e.transforms?.productPrice??(()=>{}),addToCartButton:e.transforms?.addToCartButton??(()=>!0),variantTitle:e.transforms?.variantTitle??(({variant:t})=>t?.title??""),optionValues:e.transforms?.optionValues??(({optionValues:t})=>t),combinedListingParent:e.transforms?.combinedListingParent??(()=>!1),hideOption:e.transforms?.hideOption??(()=>!1)},intents:{saveProduct:{promptVariantIfMissing:e?.intents?.saveProduct?.promptVariantIfMissing??!0,promptVariantIfPresent:e?.intents?.saveProduct?.promptVariantIfPresent??!1,saveBeforeVariantPrompt:e?.intents?.saveProduct?.saveBeforeVariantPrompt??!0,showFeedback:e?.intents?.saveProduct?.showFeedback??!0},unsaveProduct:{selectList:e?.intents?.unsaveProduct?.selectList??!0,confirm:e?.intents?.unsaveProduct?.confirm??!0,showFeedback:e?.intents?.unsaveProduct?.showFeedback??!0},editSavedProduct:{promptVariantChange:e?.intents?.editSavedProduct?.promptVariantChange??!0,showFeedback:e?.intents?.editSavedProduct?.showFeedback??!0},initiateQuickBuy:{promptVariantIfPresent:e?.intents?.initiateQuickBuy?.promptVariantIfPresent??!0},createCartLine:{afterComplete:e?.intents?.createCartLine?.afterComplete},removeCartLine:{saveCartLine:e?.intents?.removeCartLine?.saveCartLine??!0},saveCartLine:{confirm:e?.intents?.saveCartLine?.confirm??!1,showFeedback:e?.intents?.saveCartLine?.showFeedback??!0,afterComplete:e?.intents?.saveCartLine?.afterComplete}},placements:e.placements??[],translations:e.translations,ui:wr(Sr,e.ui??{})}),"createSwishOptions");function Cr(e){return U(String(e).trim())}r(Cr,"normalizeSwishQueryId");function An(e){let t=e.productId?Cr(e.productId):"",n=e.variantId?Cr(e.variantId):"";return n?["swish","items",t,n]:["swish","items",t]}r(An,"swishItemsQueryKey");var su=["item-create","item-update","item-delete"],Er="auth-cache-clear",Rr="token-update";function kr({events:e,queryClient:t}){return e.subscribe([...su,Er,Rr],n=>{if(!(n instanceof CustomEvent))return;if(n.type===Er){t.clear();return}if(n.type===Rr){t.invalidateQueries({queryKey:["swish"]});return}if(!n.detail?.productId)return;let i=An({productId:n.detail.productId});t.invalidateQueries({queryKey:i})})}r(kr,"bindSwishItemQueryInvalidation");var Te=class{static{r(this,"Subscribable")}constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};var ru=class extends Te{static{r(this,"FocusManager")}#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<"u"&&window.addEventListener){let t=r(()=>e(),"listener");return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},rt=new ru;var ou={setTimeout:r((e,t)=>setTimeout(e,t),"setTimeout"),clearTimeout:r(e=>clearTimeout(e),"clearTimeout"),setInterval:r((e,t)=>setInterval(e,t),"setInterval"),clearInterval:r(e=>clearInterval(e),"clearInterval")},au=class{static{r(this,"TimeoutManager")}#e=ou;#t=!1;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}},De=new au;function Pr(e){setTimeout(e,0)}r(Pr,"systemSetTimeoutZero");var Dr=typeof window>"u"||"Deno"in globalThis;function X(){}r(X,"noop");function Lr(e,t){return typeof e=="function"?e(t):e}r(Lr,"functionalUpdate");function xt(e){return typeof e=="number"&&e>=0&&e!==1/0}r(xt,"isValidTimeout");function Tn(e,t){return Math.max(e+(t||0)-Date.now(),0)}r(Tn,"timeUntilStale");function ke(e,t){return typeof e=="function"?e(t):e}r(ke,"resolveStaleTime");function fe(e,t){return typeof e=="function"?e(t):e}r(fe,"resolveEnabled");function gi(e,t){let{type:n="all",exact:i,fetchStatus:s,predicate:o,queryKey:a,stale:l}=e;if(a){if(i){if(t.queryHash!==Ct(a,t.options))return!1}else if(!at(t.queryKey,a))return!1}if(n!=="all"){let c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof l=="boolean"&&t.isStale()!==l||s&&s!==t.state.fetchStatus||o&&!o(t))}r(gi,"matchQuery");function wi(e,t){let{exact:n,status:i,predicate:s,mutationKey:o}=e;if(o){if(!t.options.mutationKey)return!1;if(n){if(ot(t.options.mutationKey)!==ot(o))return!1}else if(!at(t.options.mutationKey,o))return!1}return!(i&&t.state.status!==i||s&&!s(t))}r(wi,"matchMutation");function Ct(e,t){return(t?.queryKeyHashFn||ot)(e)}r(Ct,"hashQueryKeyByOptions");function ot(e){return JSON.stringify(e,(t,n)=>vi(n)?Object.keys(n).sort().reduce((i,s)=>(i[s]=n[s],i),{}):n)}r(ot,"hashKey");function at(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>at(e[n],t[n])):!1}r(at,"partialMatchKey");var lu=Object.prototype.hasOwnProperty;function Or(e,t,n=0){if(e===t)return e;if(n>500)return t;let i=Ar(e)&&Ar(t);if(!i&&!(vi(e)&&vi(t)))return t;let o=(i?e:Object.keys(e)).length,a=i?t:Object.keys(t),l=a.length,c=i?new Array(l):{},d=0;for(let u=0;u<l;u++){let p=i?u:a[u],h=e[p],f=t[p];if(h===f){c[p]=h,(i?u<o:lu.call(e,p))&&d++;continue}if(h===null||f===null||typeof h!="object"||typeof f!="object"){c[p]=f;continue}let w=Or(h,f,n+1);c[p]=w,w===h&&d++}return o===l&&d===o?e:c}r(Or,"replaceEqualDeep");function Dn(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}r(Dn,"shallowEqualObjects");function Ar(e){return Array.isArray(e)&&e.length===Object.keys(e).length}r(Ar,"isPlainArray");function vi(e){if(!Tr(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!Tr(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}r(vi,"isPlainObject");function Tr(e){return Object.prototype.toString.call(e)==="[object Object]"}r(Tr,"hasObjectPrototype");function Mr(e){return new Promise(t=>{De.setTimeout(t,e)})}r(Mr,"sleep");function Et(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?Or(e,t):t}r(Et,"replaceData");function _r(e,t,n=0){let i=[...e,t];return n&&i.length>n?i.slice(1):i}r(_r,"addToEnd");function qr(e,t,n=0){let i=[t,...e];return n&&i.length>n?i.slice(0,-1):i}r(qr,"addToStart");var Rt=Symbol();function Ln(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Rt?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}r(Ln,"ensureQueryFn");function Br(e,t,n){let i=!1,s;return Object.defineProperty(e,"signal",{enumerable:!0,get:r(()=>(s??=t(),i||(i=!0,s.aborted?n():s.addEventListener("abort",n,{once:!0})),s),"get")}),e}r(Br,"addConsumeAwareSignal");var Ke=(()=>{let e=r(()=>Dr,"isServerFn");return{isServer(){return e()},setIsServer(t){e=t}}})();function kt(){let e,t,n=new Promise((s,o)=>{e=s,t=o});n.status="pending",n.catch(()=>{});function i(s){Object.assign(n,s),delete n.resolve,delete n.reject}return r(i,"finalize"),n.resolve=s=>{i({status:"fulfilled",value:s}),e(s)},n.reject=s=>{i({status:"rejected",reason:s}),t(s)},n}r(kt,"pendingThenable");function Fr(e){let t;if(e.then(n=>(t=n,n),X)?.catch(X),t!==void 0)return{data:t}}r(Fr,"tryResolveSync");function jr(e){return e}r(jr,"defaultTransformerFn");function cu(e){return{mutationKey:e.options.mutationKey,state:e.state,...e.options.scope&&{scope:e.options.scope},...e.meta&&{meta:e.meta}}}r(cu,"dehydrateMutation");function uu(e,t,n){let i=r(()=>{let s=e.promise?.then(t).catch(o=>n(o)?Promise.reject(new Error("redacted")):Promise.reject(o));return s?.catch(X),s},"dehydratePromise");return{dehydratedAt:Date.now(),state:{...e.state,...e.state.data!==void 0&&{data:t(e.state.data)}},queryKey:e.queryKey,queryHash:e.queryHash,...e.state.status==="pending"&&{promise:i()},...e.meta&&{meta:e.meta}}}r(uu,"dehydrateQuery");function Nr(e){return e.state.isPaused}r(Nr,"defaultShouldDehydrateMutation");function Ur(e){return e.state.status==="success"}r(Ur,"defaultShouldDehydrateQuery");function du(e){return!0}r(du,"defaultShouldRedactErrors");function bi(e,t={}){let n=t.shouldDehydrateMutation??e.getDefaultOptions().dehydrate?.shouldDehydrateMutation??Nr,i=e.getMutationCache().getAll().flatMap(c=>n(c)?[cu(c)]:[]),s=t.shouldDehydrateQuery??e.getDefaultOptions().dehydrate?.shouldDehydrateQuery??Ur,o=t.shouldRedactErrors??e.getDefaultOptions().dehydrate?.shouldRedactErrors??du,a=t.serializeData??e.getDefaultOptions().dehydrate?.serializeData??jr,l=e.getQueryCache().getAll().flatMap(c=>s(c)?[uu(c,a,o)]:[]);return{mutations:i,queries:l}}r(bi,"dehydrate");function Ii(e,t,n){if(typeof t!="object"||t===null)return;let i=e.getMutationCache(),s=e.getQueryCache(),o=n?.defaultOptions?.deserializeData??e.getDefaultOptions().hydrate?.deserializeData??jr,a=t.mutations||[],l=t.queries||[];a.forEach(({state:c,...d})=>{i.build(e,{...e.getDefaultOptions().hydrate?.mutations,...n?.defaultOptions?.mutations,...d},c)}),l.forEach(({queryKey:c,state:d,queryHash:u,meta:p,promise:h,dehydratedAt:f})=>{let w=h?Fr(h):void 0,y=d.data===void 0?w?.data:d.data,b=y===void 0?y:o(y),S=s.get(u),k=S?.state.status==="pending",E=S?.state.fetchStatus==="fetching";if(S){let R=w&&f!==void 0&&f>S.state.dataUpdatedAt;if(d.dataUpdatedAt>S.state.dataUpdatedAt||R){let{fetchStatus:x,...A}=d;S.setState({...A,data:b})}}else S=s.build(e,{...e.getDefaultOptions().hydrate?.queries,...n?.defaultOptions?.queries,queryKey:c,queryHash:u,meta:p},{...d,data:b,fetchStatus:"idle",status:b!==void 0?"success":d.status});h&&!k&&!E&&(f===void 0||f>S.state.dataUpdatedAt)&&S.fetch(void 0,{initialPromise:Promise.resolve(h).then(o)}).catch(X)})}r(Ii,"hydrate");var pu=Pr;function hu(){let e=[],t=0,n=r(l=>{l()},"notifyFn"),i=r(l=>{l()},"batchNotifyFn"),s=pu,o=r(l=>{t?e.push(l):s(()=>{n(l)})},"schedule"),a=r(()=>{let l=e;e=[],l.length&&s(()=>{i(()=>{l.forEach(c=>{n(c)})})})},"flush");return{batch:r(l=>{let c;t++;try{c=l()}finally{t--,t||a()}return c},"batch"),batchCalls:r(l=>(...c)=>{o(()=>{l(...c)})},"batchCalls"),schedule:o,setNotifyFunction:r(l=>{n=l},"setNotifyFunction"),setBatchNotifyFunction:r(l=>{i=l},"setBatchNotifyFunction"),setScheduler:r(l=>{s=l},"setScheduler")}}r(hu,"createNotifyManager");var J=hu();var fu=class extends Te{static{r(this,"OnlineManager")}#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<"u"&&window.addEventListener){let t=r(()=>e(!0),"onlineListener"),n=r(()=>e(!1),"offlineListener");return window.addEventListener("online",t,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(n=>{n(e)}))}isOnline(){return this.#e}},lt=new fu;function mu(e){return Math.min(1e3*2**e,3e4)}r(mu,"defaultRetryDelay");function Si(e){return(e??"online")==="online"?lt.isOnline():!0}r(Si,"canFetch");var On=class extends Error{static{r(this,"CancelledError")}constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function Mn(e){let t=!1,n=0,i,s=kt(),o=r(()=>s.status!=="pending","isResolved"),a=r(y=>{if(!o()){let b=new On(y);h(b),e.onCancel?.(b)}},"cancel"),l=r(()=>{t=!0},"cancelRetry"),c=r(()=>{t=!1},"continueRetry"),d=r(()=>rt.isFocused()&&(e.networkMode==="always"||lt.isOnline())&&e.canRun(),"canContinue"),u=r(()=>Si(e.networkMode)&&e.canRun(),"canStart"),p=r(y=>{o()||(i?.(),s.resolve(y))},"resolve"),h=r(y=>{o()||(i?.(),s.reject(y))},"reject"),f=r(()=>new Promise(y=>{i=r(b=>{(o()||d())&&y(b)},"continueFn"),e.onPause?.()}).then(()=>{i=void 0,o()||e.onContinue?.()}),"pause"),w=r(()=>{if(o())return;let y,b=n===0?e.initialPromise:void 0;try{y=b??e.fn()}catch(S){y=Promise.reject(S)}Promise.resolve(y).then(p).catch(S=>{if(o())return;let k=e.retry??(Ke.isServer()?0:3),E=e.retryDelay??mu,R=typeof E=="function"?E(n,S):E,x=k===!0||typeof k=="number"&&n<k||typeof k=="function"&&k(n,S);if(t||!x){h(S);return}n++,e.onFail?.(n,S),Mr(R).then(()=>d()?void 0:f()).then(()=>{t?h(S):w()})})},"run");return{promise:s,status:r(()=>s.status,"status"),cancel:a,continue:r(()=>(i?.(),s),"continue"),cancelRetry:l,continueRetry:c,canStart:u,start:r(()=>(u()?w():f().then(w),s),"start")}}r(Mn,"createRetryer");var _n=class{static{r(this,"Removable")}#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),xt(this.gcTime)&&(this.#e=De.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Ke.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e&&(De.clearTimeout(this.#e),this.#e=void 0)}};var Hr=class extends _n{static{r(this,"Query")}#e;#t;#n;#s;#i;#o;#r;constructor(e){super(),this.#r=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#s=e.client,this.#n=this.#s.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=$r(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#i?.promise}setOptions(e){if(this.options={...this.#o,...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let t=$r(this.options);t.data!==void 0&&(this.setState(Vr(t.data,t.dataUpdatedAt)),this.#e=t)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(e,t){let n=Et(this.state.data,e,this.options);return this.#l({data:n,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#l({type:"setState",state:e,setStateOptions:t})}cancel(e){let t=this.#i?.promise;return this.#i?.cancel(e),t?t.then(X).catch(X):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#e}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>fe(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Rt||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>ke(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!Tn(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#i&&(this.#r||this.#a()?this.#i.cancel({revert:!0}):this.#i.cancelRetry()),this.scheduleGc()),this.#n.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}#a(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"}invalidate(){this.state.isInvalidated||this.#l({type:"invalidate"})}async fetch(e,t){if(this.state.fetchStatus!=="idle"&&this.#i?.status()!=="rejected"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.promise}if(e&&this.setOptions(e),!this.options.queryFn){let l=this.observers.find(c=>c.options.queryFn);l&&this.setOptions(l.options)}let n=new AbortController,i=r(l=>{Object.defineProperty(l,"signal",{enumerable:!0,get:r(()=>(this.#r=!0,n.signal),"get")})},"addSignalProperty"),s=r(()=>{let l=Ln(this.options,t),d=r(()=>{let u={client:this.#s,queryKey:this.queryKey,meta:this.meta};return i(u),u},"createQueryFnContext")();return this.#r=!1,this.options.persister?this.options.persister(l,d,this):l(d)},"fetchFn"),a=r(()=>{let l={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#s,state:this.state,fetchFn:s};return i(l),l},"createFetchContext")();this.options.behavior?.onFetch(a,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#l({type:"fetch",meta:a.fetchOptions?.meta}),this.#i=Mn({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:r(l=>{l instanceof On&&l.revert&&this.setState({...this.#t,fetchStatus:"idle"}),n.abort()},"onCancel"),onFail:r((l,c)=>{this.#l({type:"failed",failureCount:l,error:c})},"onFail"),onPause:r(()=>{this.#l({type:"pause"})},"onPause"),onContinue:r(()=>{this.#l({type:"continue"})},"onContinue"),retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:r(()=>!0,"canRun")});try{let l=await this.#i.start();if(l===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(l),this.#n.config.onSuccess?.(l,this),this.#n.config.onSettled?.(l,this.state.error,this),l}catch(l){if(l instanceof On){if(l.silent)return this.#i.promise;if(l.revert){if(this.state.data===void 0)throw l;return this.state.data}}throw this.#l({type:"error",error:l}),this.#n.config.onError?.(l,this),this.#n.config.onSettled?.(this.state.data,l,this),l}finally{this.scheduleGc()}}#l(e){let t=r(n=>{switch(e.type){case"failed":return{...n,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...xi(n.data,this.options),fetchMeta:e.meta??null};case"success":let i={...n,...Vr(e.data,e.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#t=e.manual?i:void 0,i;case"error":let s=e.error;return{...n,error:s,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...e.state}}},"reducer");this.state=t(this.state),J.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:e})})}};function xi(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Si(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}r(xi,"fetchState");function Vr(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}r(Vr,"successState");function $r(e){let t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,i=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?i??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}r($r,"getDefaultState");var Ei=class extends Te{static{r(this,"QueryObserver")}constructor(e,t){super(),this.options=t,this.#e=e,this.#a=null,this.#r=kt(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#s=void 0;#i;#o;#r;#a;#l;#h;#f;#u;#d;#c;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Qr(this.#t,this.options)?this.#p():this.updateResult(),this.#w())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ci(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ci(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#I(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof fe(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#S(),this.#t.setOptions(this.options),t._defaulted&&!Dn(this.options,t)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});let i=this.hasListeners();i&&zr(this.#t,n,this.options,t)&&this.#p(),this.updateResult(),i&&(this.#t!==n||fe(this.options.enabled,this.#t)!==fe(t.enabled,this.#t)||ke(this.options.staleTime,this.#t)!==ke(t.staleTime,this.#t))&&this.#y();let s=this.#v();i&&(this.#t!==n||fe(this.options.enabled,this.#t)!==fe(t.enabled,this.#t)||s!==this.#c)&&this.#g(s)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return vu(this,n)&&(this.#s=n,this.#o=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#s}trackResult(e,t){return new Proxy(e,{get:r((n,i)=>(this.trackProp(i),t?.(i),i==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#r.status==="pending"&&this.#r.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,i)),"get")})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#p({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#s))}#p(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(X)),t}#y(){this.#b();let e=ke(this.options.staleTime,this.#t);if(Ke.isServer()||this.#s.isStale||!xt(e))return;let n=Tn(this.#s.dataUpdatedAt,e)+1;this.#u=De.setTimeout(()=>{this.#s.isStale||this.updateResult()},n)}#v(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#g(e){this.#I(),this.#c=e,!(Ke.isServer()||fe(this.options.enabled,this.#t)===!1||!xt(this.#c)||this.#c===0)&&(this.#d=De.setInterval(()=>{(this.options.refetchIntervalInBackground||rt.isFocused())&&this.#p()},this.#c))}#w(){this.#y(),this.#g(this.#v())}#b(){this.#u&&(De.clearTimeout(this.#u),this.#u=void 0)}#I(){this.#d&&(De.clearInterval(this.#d),this.#d=void 0)}createResult(e,t){let n=this.#t,i=this.options,s=this.#s,o=this.#i,a=this.#o,c=e!==n?e.state:this.#n,{state:d}=e,u={...d},p=!1,h;if(t._optimisticResults){let F=this.hasListeners(),N=!F&&Qr(e,t),oe=F&&zr(e,n,t,i);(N||oe)&&(u={...u,...xi(d.data,e.options)}),t._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:f,errorUpdatedAt:w,status:y}=u;h=u.data;let b=!1;if(t.placeholderData!==void 0&&h===void 0&&y==="pending"){let F;s?.isPlaceholderData&&t.placeholderData===a?.placeholderData?(F=s.data,b=!0):F=typeof t.placeholderData=="function"?t.placeholderData(this.#f?.state.data,this.#f):t.placeholderData,F!==void 0&&(y="success",h=Et(s?.data,F,t),p=!0)}if(t.select&&h!==void 0&&!b)if(s&&h===o?.data&&t.select===this.#l)h=this.#h;else try{this.#l=t.select,h=t.select(h),h=Et(s?.data,h,t),this.#h=h,this.#a=null}catch(F){this.#a=F}this.#a&&(f=this.#a,h=this.#h,w=Date.now(),y="error");let S=u.fetchStatus==="fetching",k=y==="pending",E=y==="error",R=k&&S,x=h!==void 0,P={status:y,fetchStatus:u.fetchStatus,isPending:k,isSuccess:y==="success",isError:E,isInitialLoading:R,isLoading:R,data:h,dataUpdatedAt:u.dataUpdatedAt,error:f,errorUpdatedAt:w,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:u.dataUpdateCount>c.dataUpdateCount||u.errorUpdateCount>c.errorUpdateCount,isFetching:S,isRefetching:S&&!k,isLoadingError:E&&!x,isPaused:u.fetchStatus==="paused",isPlaceholderData:p,isRefetchError:E&&x,isStale:Ri(e,t),refetch:this.refetch,promise:this.#r,isEnabled:fe(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let F=P.data!==void 0,N=P.status==="error"&&!F,oe=r(ve=>{N?ve.reject(P.error):F&&ve.resolve(P.data)},"finalizeThenableIfPossible"),Oe=r(()=>{let ve=this.#r=P.promise=kt();oe(ve)},"recreateThenable"),ne=this.#r;switch(ne.status){case"pending":e.queryHash===n.queryHash&&oe(ne);break;case"fulfilled":(N||P.data!==ne.value)&&Oe();break;case"rejected":(!N||P.error!==ne.reason)&&Oe();break}}return P}updateResult(){let e=this.#s,t=this.createResult(this.#t,this.options);if(this.#i=this.#t.state,this.#o=this.options,this.#i.data!==void 0&&(this.#f=this.#t),Dn(t,e))return;this.#s=t;let n=r(()=>{if(!e)return!0;let{notifyOnChangeProps:i}=this.options,s=typeof i=="function"?i():i;if(s==="all"||!s&&!this.#m.size)return!0;let o=new Set(s??this.#m);return this.options.throwOnError&&o.add("error"),Object.keys(this.#s).some(a=>{let l=a;return this.#s[l]!==e[l]&&o.has(l)})},"shouldNotifyListeners");this.#x({listeners:n()})}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#w()}#x(e){J.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#s)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function yu(e,t){return fe(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}r(yu,"shouldLoadOnMount");function Qr(e,t){return yu(e,t)||e.state.data!==void 0&&Ci(e,t,t.refetchOnMount)}r(Qr,"shouldFetchOnMount");function Ci(e,t,n){if(fe(t.enabled,e)!==!1&&ke(t.staleTime,e)!=="static"){let i=typeof n=="function"?n(e):n;return i==="always"||i!==!1&&Ri(e,t)}return!1}r(Ci,"shouldFetchOn");function zr(e,t,n,i){return(e!==t||fe(i.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Ri(e,n)}r(zr,"shouldFetchOptionally");function Ri(e,t){return fe(t.enabled,e)!==!1&&e.isStaleByTime(ke(t.staleTime,e))}r(Ri,"isStale");function vu(e,t){return!Dn(e.getCurrentResult(),t)}r(vu,"shouldAssignObserverCurrentProperties");function ki(e){return{onFetch:r((t,n)=>{let i=t.options,s=t.fetchOptions?.meta?.fetchMore?.direction,o=t.state.data?.pages||[],a=t.state.data?.pageParams||[],l={pages:[],pageParams:[]},c=0,d=r(async()=>{let u=!1,p=r(w=>{Br(w,()=>t.signal,()=>u=!0)},"addSignalProperty"),h=Ln(t.options,t.fetchOptions),f=r(async(w,y,b)=>{if(u)return Promise.reject();if(y==null&&w.pages.length)return Promise.resolve(w);let k=r(()=>{let A={client:t.client,queryKey:t.queryKey,pageParam:y,direction:b?"backward":"forward",meta:t.options.meta};return p(A),A},"createQueryFnContext")(),E=await h(k),{maxPages:R}=t.options,x=b?qr:_r;return{pages:x(w.pages,E,R),pageParams:x(w.pageParams,y,R)}},"fetchPage");if(s&&o.length){let w=s==="backward",y=w?gu:Gr,b={pages:o,pageParams:a},S=y(i,b);l=await f(b,S,w)}else{let w=e??o.length;do{let y=c===0?a[0]??i.initialPageParam:Gr(i,l);if(c>0&&y==null)break;l=await f(l,y),c++}while(c<w)}return l},"fetchFn");t.options.persister?t.fetchFn=()=>t.options.persister?.(d,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=d},"onFetch")}}r(ki,"infiniteQueryBehavior");function Gr(e,{pages:t,pageParams:n}){let i=t.length-1;return t.length>0?e.getNextPageParam(t[i],t,n[i],n):void 0}r(Gr,"getNextPageParam");function gu(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}r(gu,"getPreviousPageParam");var Wr=class extends _n{static{r(this,"Mutation")}#e;#t;#n;#s;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||wu(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#n.remove(this))}continue(){return this.#s?.continue()??this.execute(this.state.variables)}async execute(e){let t=r(()=>{this.#i({type:"continue"})},"onContinue"),n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#s=Mn({fn:r(()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(new Error("No mutationFn found")),"fn"),onFail:r((o,a)=>{this.#i({type:"failed",failureCount:o,error:a})},"onFail"),onPause:r(()=>{this.#i({type:"pause"})},"onPause"),onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:r(()=>this.#n.canRun(this),"canRun")});let i=this.state.status==="pending",s=!this.#s.canStart();try{if(i)t();else{this.#i({type:"pending",variables:e,isPaused:s}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let a=await this.options.onMutate?.(e,n);a!==this.state.context&&this.#i({type:"pending",context:a,variables:e,isPaused:s})}let o=await this.#s.start();return await this.#n.config.onSuccess?.(o,e,this.state.context,this,n),await this.options.onSuccess?.(o,e,this.state.context,n),await this.#n.config.onSettled?.(o,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(o,null,e,this.state.context,n),this.#i({type:"success",data:o}),o}catch(o){try{await this.#n.config.onError?.(o,e,this.state.context,this,n)}catch(a){Promise.reject(a)}try{await this.options.onError?.(o,e,this.state.context,n)}catch(a){Promise.reject(a)}try{await this.#n.config.onSettled?.(void 0,o,this.state.variables,this.state.context,this,n)}catch(a){Promise.reject(a)}try{await this.options.onSettled?.(void 0,o,e,this.state.context,n)}catch(a){Promise.reject(a)}throw this.#i({type:"error",error:o}),o}finally{this.#n.runNext(this)}}#i(e){let t=r(n=>{switch(e.type){case"failed":return{...n,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...n,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:e.error,failureCount:n.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}},"reducer");this.state=t(this.state),J.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:"updated",action:e})})}};function wu(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}r(wu,"getDefaultState");var Kr=class extends Te{static{r(this,"MutationCache")}constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let i=new Wr({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(i),i}add(e){this.#e.add(e);let t=qn(e);if(typeof t=="string"){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){let t=qn(e);if(typeof t=="string"){let n=this.#t.get(t);if(n)if(n.length>1){let i=n.indexOf(e);i!==-1&&n.splice(i,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){let t=qn(e);if(typeof t=="string"){let i=this.#t.get(t)?.find(s=>s.state.status==="pending");return!i||i===e}else return!0}runNext(e){let t=qn(e);return typeof t=="string"?this.#t.get(t)?.find(i=>i!==e&&i.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){J.batch(()=>{this.#e.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(n=>wi(t,n))}findAll(e={}){return this.getAll().filter(t=>wi(e,t))}notify(e){J.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(t=>t.state.isPaused);return J.batch(()=>Promise.all(e.map(t=>t.continue().catch(X))))}};function qn(e){return e.options.scope?.id}r(qn,"scopeFor");var Xr=class extends Te{static{r(this,"QueryCache")}constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let i=t.queryKey,s=t.queryHash??Ct(i,t),o=this.get(s);return o||(o=new Hr({client:e,queryKey:i,queryHash:s,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(i)}),this.add(o)),o}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){J.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(n=>gi(t,n))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(n=>gi(e,n)):t}notify(e){J.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){J.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){J.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}};var Pi=class{static{r(this,"QueryClient")}#e;#t;#n;#s;#i;#o;#r;#a;constructor(e={}){this.#e=e.queryCache||new Xr,this.#t=e.mutationCache||new Kr,this.#n=e.defaultOptions||{},this.#s=new Map,this.#i=new Map,this.#o=0}mount(){this.#o++,this.#o===1&&(this.#r=rt.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=lt.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#o--,this.#o===0&&(this.#r?.(),this.#r=void 0,this.#a?.(),this.#a=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),i=n.state.data;return i===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(ke(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(i))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:n})=>{let i=n.data;return[t,i]})}setQueryData(e,t,n){let i=this.defaultQueryOptions({queryKey:e}),o=this.#e.get(i.queryHash)?.state.data,a=Lr(t,o);if(a!==void 0)return this.#e.build(this,i).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return J.batch(()=>this.#e.findAll(e).map(({queryKey:i})=>[i,this.setQueryData(i,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;J.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){let n=this.#e;return J.batch(()=>(n.findAll(e).forEach(i=>{i.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},i=J.batch(()=>this.#e.findAll(e).map(s=>s.cancel(n)));return Promise.all(i).then(X).catch(X)}invalidateQueries(e,t={}){return J.batch(()=>(this.#e.findAll(e).forEach(n=>{n.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},i=J.batch(()=>this.#e.findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let o=s.fetch(void 0,n);return n.throwOnError||(o=o.catch(X)),s.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(i).then(X)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(ke(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(X).catch(X)}fetchInfiniteQuery(e){return e.behavior=ki(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(X).catch(X)}ensureInfiniteQueryData(e){return e.behavior=ki(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return lt.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#s.set(ot(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#s.values()],n={};return t.forEach(i=>{at(e,i.queryKey)&&Object.assign(n,i.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(ot(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(i=>{at(e,i.mutationKey)&&Object.assign(n,i.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Ct(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Rt&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}};function Jr(){return new Pi({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1,gcTime:1e3*60*60*1,staleTime:1e3*60*10}}})}r(Jr,"createSwishQueryClient");var bu="swish-query-cache";function Iu(e){return e.replace(/\.myshopify\.com$/,"")||"unknown-store"}r(Iu,"normalizeStoreKeyPart");function Bn({customerId:e,storeDomain:t}){let n=e??"guest",i=Iu(t??"");return`${bu}:${i}:${n}`}r(Bn,"getSwishQueryStorageKey");var Su=1e3*60*60*24,xu=1e3;function Ai(){return!!globalThis.window?.localStorage}r(Ai,"canUseLocalStorage");function Cu(e){if(!Ai())return null;let t=globalThis.window.localStorage.getItem(e);if(!t)return null;try{return JSON.parse(t)}catch{return globalThis.window.localStorage.removeItem(e),null}}r(Cu,"readPersistedState");function Eu(e,t){if(Ai())try{globalThis.window.localStorage.setItem(e,JSON.stringify(t))}catch{}}r(Eu,"writePersistedState");function Ru(e){if(Ai())try{globalThis.window.localStorage.removeItem(e)}catch{}}r(Ru,"removePersistedState");function ku(e,t){return Number.isFinite(e.timestamp)?Date.now()-e.timestamp>t:!0}r(ku,"isPersistedStateExpired");function Yr({queryClient:e,cacheBuster:t,customerId:n,storeDomain:i,maxAgeMs:s=Su,throttleMs:o=xu}){let a=Bn({customerId:n,storeDomain:i}),l=q(!1),c=Cu(a);c?.buster===t&&!ku(c,s)?Ii(e,c.clientState):c&&Ru(a),l.value=!0;let d=null,u=!1,p=r(()=>{Eu(a,{buster:t,timestamp:Date.now(),clientState:bi(e)})},"persistNow"),h=r(()=>{u=!0,!d&&(d=setTimeout(()=>{d=null,u&&(u=!1,p())},Math.max(o,0)))},"schedulePersist"),f=r(()=>{u&&(u=!1,d&&(clearTimeout(d),d=null),p())},"flushPersist"),w=e.getQueryCache().subscribe(b=>{l.value&&h()}),y=r(()=>{f()},"onPageHide");return globalThis.window?.addEventListener("pagehide",y),{restored:l,storageKey:a,dispose:r(()=>{globalThis.window?.removeEventListener("pagehide",y),w(),f()},"dispose")}}r(Yr,"initSwishQueryPersistence");function Zr({events:e,cacheBuster:t,customerId:n,storeDomain:i}){let s=Jr(),o=Yr({queryClient:s,cacheBuster:t,customerId:n,storeDomain:i});return kr({events:e,queryClient:s}),{client:s,cacheBuster:t,restored:o.restored,storageKey:o.storageKey,keys:{items:An}}}r(Zr,"createSwishQuery");var eo=r(e=>q({loading:!1,productId:e.productId==null?void 0:String(e.productId),variantId:e.variantId==null?void 0:String(e.variantId),itemId:e.itemId??void 0}),"itemContextFromIds"),to=r(e=>t=>{let n=t instanceof Location,i=t instanceof HTMLAnchorElement,s=t instanceof HTMLElement;if(!n&&!i&&!s)throw new Error("Invalid source");let{productHandle:o,productId:a,variantId:l,itemId:c}=s?t.dataset:{},p=!!(a||o)||!!c,h=q({loading:!1,productHandle:o,productId:a,variantId:l,itemId:c});if(!p&&(n||i)){let f=t.href,w=Ne(f);w?.productHandle&&w.productHandle!==h.value.productHandle&&(h.value={...h.value,...w,productId:void 0},ws({source:t,onProductUrlChange:r(y=>{h.value={...h.value,...y,productId:y.productHandle===h.value.productHandle?h.value.productId:void 0}},"onProductUrlChange")}))}return ee(()=>{h.value.loading||!h.value.productId&&h.value.productHandle&&(h.value={...h.value,loading:!0},e.storefront.loadProductId({productHandle:h.value.productHandle}).then(f=>{f.errors&&console.error("Error loading product id",f.errors);let w=f.data?.product?.id?U(f.data.product.id):void 0;h.value={...h.value,productId:w,loading:!w}}))}),h},"itemContextSignal");function no({queryClient:e,options:t,restored:n}){let i=q(null),s=q(!1),o=q(null),a=q(!1),l=r(w=>{let y=n?.value??!0,b=w.enabled??!0;return{...w,enabled:!!(b&&y)}},"getObserverOptions"),c=new Ei(e,l(t.value)),d=r(w=>{se(()=>{i.value=w.data??null,s.value=w.isLoading,a.value=w.isRefetching,o.value=w.error??null})},"syncResult"),u=c.subscribe(d);d(c.getCurrentResult());let p=ee(()=>{c.setOptions(l(t.value))}),h=!1;return{data:i,loading:s,error:o,refetching:a,refetch:r(()=>c.refetch(),"refetch"),dispose:r(()=>{h||(h=!0,p(),u(),c.destroy())},"dispose")}}r(no,"createTanstackQuerySignal");var Ti=50;function io(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}r(io,"arraysShallowEqual");function Pu(e,t,n){if(n==="variant"||n==="auto"&&!!t){if(!t)return null;let s=U(t);return e.find(o=>String(o.variantId)===s)??null}return e[0]??null}r(Pu,"pickSavedItem");function Au(e){se(()=>{if(e.savedItemsLoading.value=e.apiLoading,e.savedItemsError.value=e.apiError,e.forcedItemId){let o=[e.forcedItemId];io(e.savedItemIds.value,o)||(e.savedItemIds.value=o),e.savedItemId.value!==e.forcedItemId&&(e.savedItemId.value=e.forcedItemId);return}let t=e.apiData?.data??[];t.length>=Ti&&console.warn(`[swish] item-state query hit the per-product limit (${Ti}). Some saved items may be missing.`);let n=t.map(o=>o.id);io(e.savedItemIds.value,n)||(e.savedItemIds.value=n);let s=Pu(t,e.variantId,e.policy)?.id??null;s!==e.savedItemId.value&&(e.savedItemId.value=s)})}r(Au,"syncFromApi");var so=r(e=>(t,n={})=>{let i=[],s={onSave:n.onSave,onUnsave:n.onUnsave,onListsUpdate:n.onListsUpdate,onVariantUpdate:n.onVariantUpdate},o=q(n.match??"auto"),a=r(z=>{s.onSave=z.onSave,s.onUnsave=z.onUnsave,s.onListsUpdate=z.onListsUpdate,s.onVariantUpdate=z.onVariantUpdate;let Y=z.match??"auto";o.value!==Y&&(o.value=Y)},"setOptions"),l=pe(()=>{let{productId:z,loading:Y}=t.value;return!z||Y?null:`product:${U(z)}`}),c=pe(()=>t.value.loading||!!t.value.itemId||!t.value.productId),d=q(!c.value),u=q(null),p=q(!1),h=q(!1),f=q(!1),w=pe(()=>p.value||h.value||f.value),y=q(!1),b=q(!1),S=pe(()=>{let z=l.value,Y=c.value,{productId:me}=t.value;return{queryKey:e.query.keys.items({productId:me}),queryFn:r(async()=>{let Ie=await e.api.items.list({limit:Ti,query:z??void 0},{batch:!0});if("error"in Ie)throw Ie.error;return Ie},"queryFn"),enabled:!Y}}),{data:k,loading:E,error:R,refetching:x,dispose:A}=no({queryClient:e.query.client,options:S,restored:e.query.restored});i.push(A);let P=t.value.itemId??null,F=q(P),N=q(P?[P]:[]),oe=ee(()=>Au({apiData:k.value,apiLoading:E.value,apiError:R.value,forcedItemId:t.value.itemId,variantId:t.value.variantId,policy:o.value,savedItemId:F,savedItemIds:N,savedItemsLoading:d,savedItemsError:u}));i.push(oe);async function Oe(){if(!F.value)return;se(()=>{h.value=!0,b.value=!0});let Y=await(await e.intents.invoke("unsave:item",{itemId:F.value})).complete;if(Y.code==="ok"){let me=Y.data;"itemId"in me?(se(()=>{F.value=null,h.value=!1}),s.onUnsave?.(me)):h.value=!1}else se(()=>{h.value=!1,b.value=!1})}r(Oe,"unsave");async function ne(){if(!F.value)return;f.value=!0;let Y=await(await e.intents.invoke("edit:item-lists",{itemId:F.value})).complete;if(Y.code==="ok"){let me=Y.data;"itemId"in me?(F.value=null,s.onUnsave?.(me)):s.onListsUpdate?.(me)}f.value=!1}r(ne,"updateLists");async function ve(){if(!F.value)return;let{productId:z,variantId:Y}=t.value;if(!z)return;f.value=!0;let Ie=await(await e.intents.invoke("edit:item-variant",{itemId:F.value,productId:z,variantId:Y})).complete;Ie.code==="ok"&&s.onVariantUpdate?.(Ie.data),f.value=!1}r(ve,"updateVariant");async function Z(){let{productId:z,variantId:Y}=t.value;if(!z)return;let me=o.value==="product"?void 0:Y;se(()=>{p.value=!0,y.value=!0});let Pt=await(await e.intents.invoke("save:item",{productId:z,variantId:me})).complete;if(Pt.code==="ok"){let ps=Pt.data;se(()=>{F.value=ps.item.id,p.value=!1}),s.onSave?.(ps)}else Pt.code==="error"&&console.warn("Failed to create item",Pt),se(()=>{p.value=!1,y.value=!1})}r(Z,"save");let Be=pe(()=>d.value||w.value||t.value.loading),$=ee(()=>{(y.value||b.value)&&!w.value&&!x.value&&se(()=>{y.value=!1,b.value=!1})});i.push($);let Pe=pe(()=>{let z=!!F.value,Y=p.value||x.value&&y.value,me=h.value||x.value&&b.value,Ie="unsaved";return z?Ie="saved":Y&&(Ie="saving"),{error:u.value,status:Ie,savedItemId:F.value,savedItemIds:N.value,loading:Be.value,submitting:w.value,saved:z,saving:Y,unsaving:me}});async function fa(){Be.value||(Pe.value.saved&&Pe.value.savedItemId?await Oe():Pe.value.saved||await Z())}return r(fa,"toggle"),Object.assign(Pe,{save:Z,unsave:Oe,updateLists:ne,updateVariant:ve,update:ne,toggle:fa,setOptions:a,setCallbacks:a,dispose:r(()=>{for(;i.length;)i.pop()?.()},"dispose")})},"itemStateSignal");var ro=r(e=>()=>{let{data:t,loading:n,error:i}=e.state.swishQuery(()=>e.api.items.count(),{refetch:["item-create","item-delete"]}),s=q(0),o=q(!0),a=q(null);return ee(()=>{se(()=>{o.value=n.value,a.value=i.value,s.value=t.value?.count??0})}),pe(()=>({count:s.value,loading:o.value,error:a.value}))},"itemCountSignal");var Tu="token-update",oo=r(e=>(t,n)=>{let i=q(null),s=q(null),o=q(null),a=q(!n?.skip),l=q(!1),c=pe(()=>a.value&&l.value);async function d(){if(!n?.skip?.value)try{a.value=!0;let u=await t(n?.variables?.value);se(()=>{o.value="error"in u?u.error:null,i.value="data"in u?u.data:null,s.value="pageInfo"in u?u.pageInfo:null,a.value=!1,l.value=!0})}catch(u){se(()=>{o.value=u,a.value=!1,l.value=!0})}}return r(d,"executeFetch"),ee(()=>{if(d(),n?.refetch?.length){let u=[...n.refetch,Tu];return e.events.subscribe(u,d)}}),{data:i,pageInfo:s,error:o,loading:a,refetching:c}},"swishQuerySignals");var Xe="GraphQL Client";var Di="An error occurred while fetching from the API. Review 'graphQLErrors' for details.",Li="Response returned unexpected Content-Type:",Oi="An unknown error has occurred. The API did not return a data object or any errors in its response.",Fn={json:"application/json",multipart:"multipart/mixed"},Mi="X-SDK-Variant",_i="X-SDK-Version",lo="shopify-graphql-client",co="1.4.1",jn=1e3,uo=[429,503],qi=/@(defer)\b/i,ao=`\r
8
+ `,po=/boundary="?([^=";]+)"?/i,Bi=ao+ao;function Le(e,t=Xe){return e.startsWith(`${t}`)?e:`${t}: ${e}`}r(Le,"formatErrorMessage");function qe(e){return e instanceof Error?e.message:JSON.stringify(e)}r(qe,"getErrorMessage");function Fi(e){return e instanceof Error&&e.cause?e.cause:void 0}r(Fi,"getErrorCause");function ji(e){return e.flatMap(({errors:t})=>t??[])}r(ji,"combineErrors");function Nn({client:e,retries:t}){if(t!==void 0&&(typeof t!="number"||t<0||t>3))throw new Error(`${e}: The provided "retries" value (${t}) is invalid - it cannot be less than ${0} or greater than ${3}`)}r(Nn,"validateRetries");function ue(e,t){return t&&(typeof t!="object"||Array.isArray(t)||typeof t=="object"&&Object.keys(t).length>0)?{[e]:t}:{}}r(ue,"getKeyValueIfValid");function Ni(e,t){if(e.length===0)return t;let i={[e.pop()]:t};return e.length===0?i:Ni(e,i)}r(Ni,"buildDataObjectByPath");function mo(e,t){return Object.keys(t||{}).reduce((n,i)=>(typeof t[i]=="object"||Array.isArray(t[i]))&&e[i]?(n[i]=mo(e[i],t[i]),n):(n[i]=t[i],n),Array.isArray(e)?[...e]:{...e})}r(mo,"combineObjects");function Ui([e,...t]){return t.reduce(mo,{...e})}r(Ui,"buildCombinedDataObject");function Vi({clientLogger:e,customFetchApi:t=fetch,client:n=Xe,defaultRetryWaitTime:i=jn,retriableCodes:s=uo}){let o=r(async(a,l,c)=>{let d=l+1,u=c+1,p;try{if(p=await t(...a),e({type:"HTTP-Response",content:{requestParams:a,response:p}}),!p.ok&&s.includes(p.status)&&d<=u)throw new Error;let h=p?.headers.get("X-Shopify-API-Deprecated-Reason")||"";return h&&e({type:"HTTP-Response-GraphQL-Deprecation-Notice",content:{requestParams:a,deprecationNotice:h}}),p}catch(h){if(d<=u){let f=p?.headers.get("Retry-After");return await Du(f?parseInt(f,10):i),e({type:"HTTP-Retry",content:{requestParams:a,lastResponse:p,retryAttempt:l,maxRetries:c}}),o(a,d,c)}throw new Error(Le(`${c>0?`Attempted maximum number of ${c} network retries. Last message - `:""}${qe(h)}`,n))}},"httpFetch");return o}r(Vi,"generateHttpFetch");async function Du(e){return new Promise(t=>setTimeout(t,e))}r(Du,"sleep");function $i({headers:e,url:t,customFetchApi:n=fetch,retries:i=0,logger:s}){Nn({client:Xe,retries:i});let o={headers:e,url:t,retries:i},a=Lu(s),l=Vi({customFetchApi:n,clientLogger:a,defaultRetryWaitTime:jn}),c=Ou(l,o),d=Mu(c),u=Uu(c);return{config:o,fetch:c,request:d,requestStream:u}}r($i,"createGraphQLClient");function Lu(e){return t=>{e&&e(t)}}r(Lu,"generateClientLogger");async function yo(e){let{errors:t,data:n,extensions:i}=await e.json();return{...ue("data",n),...ue("extensions",i),headers:e.headers,...t||!n?{errors:{networkStatusCode:e.status,message:Le(t?Di:Oi),...ue("graphQLErrors",t),response:e}}:{}}}r(yo,"processJSONResponse");function Ou(e,{url:t,headers:n,retries:i}){return async(s,o={})=>{let{variables:a,headers:l,url:c,retries:d,keepalive:u,signal:p}=o,h=JSON.stringify({query:s,variables:a});Nn({client:Xe,retries:d});let f=Object.entries({...n,...l}).reduce((y,[b,S])=>(y[b]=Array.isArray(S)?S.join(", "):S.toString(),y),{});return!f[Mi]&&!f[_i]&&(f[Mi]=lo,f[_i]=co),e([c??t,{method:"POST",headers:f,body:h,signal:p,keepalive:u}],1,d??i)}}r(Ou,"generateFetch");function Mu(e){return async(...t)=>{if(qi.test(t[0]))throw new Error(Le("This operation will result in a streamable response - use requestStream() instead."));let n=null;try{n=await e(...t);let{status:i,statusText:s}=n,o=n.headers.get("content-type")||"";return n.ok?o.includes(Fn.json)?await yo(n):{errors:{networkStatusCode:i,message:Le(`${Li} ${o}`),response:n}}:{errors:{networkStatusCode:i,message:Le(s),response:n}}}catch(i){return{errors:{message:qe(i),...n==null?{}:{networkStatusCode:n.status,response:n}}}}}}r(Mu,"generateRequest");async function*_u(e){let t=new TextDecoder;if(e.body[Symbol.asyncIterator])for await(let n of e.body)yield t.decode(n);else{let n=e.body.getReader(),i;try{for(;!(i=await n.read()).done;)yield t.decode(i.value)}finally{n.cancel()}}}r(_u,"getStreamBodyIterator");function qu(e,t){return{async*[Symbol.asyncIterator](){try{let n="";for await(let i of e)if(n+=i,n.indexOf(t)>-1){let s=n.lastIndexOf(t),a=n.slice(0,s).split(t).filter(l=>l.trim().length>0).map(l=>l.slice(l.indexOf(Bi)+Bi.length).trim());a.length>0&&(yield a),n=n.slice(s+t.length),n.trim()==="--"&&(n="")}}catch(n){throw new Error(`Error occured while processing stream payload - ${qe(n)}`)}}}}r(qu,"readStreamChunk");function Bu(e){return{async*[Symbol.asyncIterator](){yield{...await yo(e),hasNext:!1}}}}r(Bu,"createJsonResponseAsyncIterator");function Fu(e){return e.map(t=>{try{return JSON.parse(t)}catch(n){throw new Error(`Error in parsing multipart response - ${qe(n)}`)}}).map(t=>{let{data:n,incremental:i,hasNext:s,extensions:o,errors:a}=t;if(!i)return{data:n||{},...ue("errors",a),...ue("extensions",o),hasNext:s};let l=i.map(({data:c,path:d,errors:u})=>({data:c&&d?Ni(d,c):{},...ue("errors",u)}));return{data:l.length===1?l[0].data:Ui([...l.map(({data:c})=>c)]),...ue("errors",ji(l)),hasNext:s}})}r(Fu,"getResponseDataFromChunkBodies");function ju(e,t){if(e.length>0)throw new Error(Di,{cause:{graphQLErrors:e}});if(Object.keys(t).length===0)throw new Error(Oi)}r(ju,"validateResponseData");function Nu(e,t){let n=(t??"").match(po),i=`--${n?n[1]:"-"}`;if(!e.body?.getReader&&!e.body?.[Symbol.asyncIterator])throw new Error("API multipart response did not return an iterable body",{cause:e});let s=_u(e),o={},a;return{async*[Symbol.asyncIterator](){try{let l=!0;for await(let c of qu(s,i)){let d=Fu(c);a=d.find(p=>p.extensions)?.extensions??a;let u=ji(d);o=Ui([o,...d.map(({data:p})=>p)]),l=d.slice(-1)[0].hasNext,ju(u,o),yield{...ue("data",o),...ue("extensions",a),hasNext:l}}if(l)throw new Error("Response stream terminated unexpectedly")}catch(l){let c=Fi(l);yield{...ue("data",o),...ue("extensions",a),errors:{message:Le(qe(l)),networkStatusCode:e.status,...ue("graphQLErrors",c?.graphQLErrors),response:e},hasNext:!1}}}}}r(Nu,"createMultipartResponseAsyncInterator");function Uu(e){return async(...t)=>{if(!qi.test(t[0]))throw new Error(Le("This operation does not result in a streamable response - use request() instead."));try{let n=await e(...t),{statusText:i}=n;if(!n.ok)throw new Error(i,{cause:n});let s=n.headers.get("content-type")||"";switch(!0){case s.includes(Fn.json):return Bu(n);case s.includes(Fn.multipart):return Nu(n,s);default:throw new Error(`${Li} ${s}`,{cause:n})}}catch(n){return{async*[Symbol.asyncIterator](){let i=Fi(n);yield{errors:{message:Le(qe(n)),...ue("networkStatusCode",i?.status),...ue("response",i)},hasNext:!1}}}}}}r(Uu,"generateRequestStream");function Hi({client:e,storeDomain:t}){try{if(!t||typeof t!="string")throw new Error;let n=t.trim(),i=n.match(/^https?:/)?n:`https://${n}`,s=new URL(i);return s.protocol="https",s.origin}catch(n){throw new Error(`${e}: a valid store domain ("${t}") must be provided`,{cause:n})}}r(Hi,"validateDomainAndGetStoreUrl");function Un({client:e,currentSupportedApiVersions:t,apiVersion:n,logger:i}){let s=`${e}: the provided apiVersion ("${n}")`,o=`Currently supported API versions: ${t.join(", ")}`;if(!n||typeof n!="string")throw new Error(`${s} is invalid. ${o}`);let a=n.trim();t.includes(a)||(i?i({type:"Unsupported_Api_Version",content:{apiVersion:n,supportedApiVersions:t}}):console.warn(`${s} is likely deprecated or not supported. ${o}`))}r(Un,"validateApiVersion");function Vn(e){let t=e*3-2;return t===10?t:`0${t}`}r(Vn,"getQuarterMonth");function Qi(e,t,n){let i=t-n;return i<=0?`${e-1}-${Vn(i+4)}`:`${e}-${Vn(i)}`}r(Qi,"getPrevousVersion");function vo(){let e=new Date,t=e.getUTCMonth(),n=e.getUTCFullYear(),i=Math.floor(t/3+1);return{year:n,quarter:i,version:`${n}-${Vn(i)}`}}r(vo,"getCurrentApiVersion");function zi(){let{year:e,quarter:t,version:n}=vo(),i=t===4?`${e+1}-01`:`${e}-${Vn(t+1)}`;return[Qi(e,t,3),Qi(e,t,2),Qi(e,t,1),n,i,"unstable"]}r(zi,"getCurrentSupportedApiVersions");function Gi(e){return t=>({...t??{},...e.headers})}r(Gi,"generateGetHeaders");function Wi({getHeaders:e,getApiUrl:t}){return(n,i)=>{let s=[n];if(i&&Object.keys(i).length>0){let{variables:o,apiVersion:a,headers:l,retries:c,signal:d}=i;s.push({...o?{variables:o}:{},...l?{headers:e(l)}:{},...a?{url:t(a)}:{},...c?{retries:c}:{},...d?{signal:d}:{}})}return s}}r(Wi,"generateGetGQLClientParams");var Ki="application/json",go="storefront-api-client",wo="1.0.9",bo="X-Shopify-Storefront-Access-Token",Io="Shopify-Storefront-Private-Token",So="X-SDK-Variant",xo="X-SDK-Version",Co="X-SDK-Variant-Source",Je="Storefront API Client";function Eo(e){if(e&&typeof window<"u")throw new Error(`${Je}: private access tokens and headers should only be used in a server-to-server implementation. Use the public API access token in nonserver environments.`)}r(Eo,"validatePrivateAccessTokenUsage");function Ro(e,t){if(!e&&!t)throw new Error(`${Je}: a public or private access token must be provided`);if(e&&t)throw new Error(`${Je}: only provide either a public or private access token`)}r(Ro,"validateRequiredAccessTokens");function Xi({storeDomain:e,apiVersion:t,publicAccessToken:n,privateAccessToken:i,clientName:s,retries:o=0,customFetchApi:a,logger:l}){let c=zi(),d=Hi({client:Je,storeDomain:e}),u={client:Je,currentSupportedApiVersions:c,logger:l};Un({...u,apiVersion:t}),Ro(n,i),Eo(i);let p=Vu(d,t,u),h={storeDomain:d,apiVersion:t,...n?{publicAccessToken:n}:{privateAccessToken:i},headers:{"Content-Type":Ki,Accept:Ki,[So]:go,[xo]:wo,...s?{[Co]:s}:{},...n?{[bo]:n}:{[Io]:i}},apiUrl:p(),clientName:s},f=$i({headers:h.headers,url:h.apiUrl,retries:o,customFetchApi:a,logger:l}),w=Gi(h),y=$u(h,p),b=Wi({getHeaders:w,getApiUrl:y});return Object.freeze({config:h,getHeaders:w,getApiUrl:y,fetch:r((...k)=>f.fetch(...b(...k)),"fetch"),request:r((...k)=>f.request(...b(...k)),"request"),requestStream:r((...k)=>f.requestStream(...b(...k)),"requestStream")})}r(Xi,"createStorefrontApiClient");function Vu(e,t,n){return i=>{i&&Un({...n,apiVersion:i});let s=(i??t).trim();return`${e}/api/${s}/graphql.json`}}r(Vu,"generateApiUrlFormatter");function $u(e,t){return n=>n?t(n):e.apiUrl}r($u,"generateGetApiUrl");var $n=`
9
9
  fragment productImageFields on Image {
10
10
  id
11
11
  altText
12
12
  url
13
13
  thumbhash
14
14
  }
15
- `,$i=`
15
+ `,Ji=`
16
16
  fragment productFields on Product {
17
17
  id
18
18
  availableForSale
@@ -93,7 +93,7 @@ Values:
93
93
  }
94
94
  # totalInventory
95
95
  }
96
- `,Hi=`
96
+ `,Yi=`
97
97
  fragment productVariantDataFields on ProductVariant {
98
98
  id
99
99
  availableForSale
@@ -109,6 +109,9 @@ Values:
109
109
  amount
110
110
  currencyCode
111
111
  }
112
+ product {
113
+ id
114
+ }
112
115
  # quantityAvailable
113
116
  selectedOptions {
114
117
  name
@@ -122,7 +125,7 @@ Values:
122
125
  value
123
126
  }
124
127
  }
125
- `;var lo=`
128
+ `;var ko=`
126
129
  query GetProduct(
127
130
  $productId: ID!
128
131
  $variantId: ID!
@@ -147,10 +150,10 @@ Values:
147
150
  }
148
151
  }
149
152
  }
150
- ${$i}
151
- ${Hi}
152
- ${jn}
153
- `,co=`
153
+ ${Ji}
154
+ ${Yi}
155
+ ${$n}
156
+ `,Po=`
154
157
  query GetProductByHandle(
155
158
  $handle: String!
156
159
  $variantId: ID!
@@ -175,10 +178,10 @@ Values:
175
178
  }
176
179
  }
177
180
  }
178
- ${$i}
179
- ${Hi}
180
- ${jn}
181
- `,uo=`
181
+ ${Ji}
182
+ ${Yi}
183
+ ${$n}
184
+ `,Ao=`
182
185
  query GetProductImagesById(
183
186
  $ids: [ID!]!
184
187
  $country: CountryCode!
@@ -202,8 +205,8 @@ Values:
202
205
  }
203
206
  }
204
207
  }
205
- ${jn}
206
- `,po=`
208
+ ${$n}
209
+ `,To=`
207
210
  query GetProductRecommendationsById(
208
211
  $productId: ID!
209
212
  $intent: ProductRecommendationIntent
@@ -214,7 +217,7 @@ Values:
214
217
  id
215
218
  }
216
219
  }
217
- `,ho=`
220
+ `,Do=`
218
221
  query GetProductRecommendationsByHandle(
219
222
  $handle: String!
220
223
  $intent: ProductRecommendationIntent
@@ -225,13 +228,19 @@ Values:
225
228
  id
226
229
  }
227
230
  }
228
- `,fo=`
231
+ `,Lo=`
229
232
  query GetProductIdByHandle($handle: String!) {
230
233
  product(handle: $handle) {
231
234
  id
232
235
  }
233
236
  }
234
- `,mo=`
237
+ `,Oo=`
238
+ query GetProductHandleById($productId: ID!) {
239
+ product(id: $productId) {
240
+ handle
241
+ }
242
+ }
243
+ `,Mo=`
235
244
  query GetCollectionProducts(
236
245
  $handle: String!
237
246
  $first: Int!
@@ -254,19 +263,23 @@ Values:
254
263
  }
255
264
  }
256
265
  }
257
- `;var yo=r(async(e,{productId:t,productHandle:n,variantId:i,selectedOptions:s,productMetafields:o=[],variantMetafields:a=[],country:l,language:c})=>{if(!t&&!n)throw new Error("Either productId or productHandle must be provided");let d=!!i,u=!!s?.length,p=t?lo:co,f=t?{productId:Le("Product",t),variantId:i?Le("ProductVariant",i):"gid://shopify/ProductVariant/0",selectedOptions:u?s:[],productMetafields:o,variantMetafields:a,includeVariantById:d,includeVariantBySelectedOptions:u,country:l,language:c}:{handle:n,variantId:i?Le("ProductVariant",i):"gid://shopify/ProductVariant/0",selectedOptions:u?s:[],productMetafields:o,variantMetafields:a,includeVariantById:d,includeVariantBySelectedOptions:u,country:l,language:c},h=await e.query(p,f),w=h.data?.product??null,m=h.data?.variantNode??w?.variant??null;return{data:{product:w,variant:m},errors:h.errors}},"loadProduct");var vo=r(async(e,{productHandle:t})=>{if(!t)throw new Error("A product handle must be provided");return e.query(fo,{handle:t})},"loadProductId");var go=r(async(e,{items:t,country:n,language:i})=>{if(!t?.length)throw new Error("A list of items must be provided");let s={ids:t.map(o=>o.variantId?Le("ProductVariant",o.variantId.toString()):Le("Product",o.productId.toString())),country:n,language:i};try{return{data:(await e.query(uo,s)).data?.nodes.map(l=>l===null?null:"image"in l?l.image:"featuredImage"in l?l.featuredImage:null).filter(l=>l!==null)??[],errors:null}}catch(o){return console.error(o),{data:null,errors:o}}},"loadProductImages");var wo=r(async(e,{productId:t,productHandle:n,intent:i,country:s,language:o})=>{if(!t&&!n)throw new Error("Either productId or productHandle must be provided");if(t){let l={productId:Le("Product",t),intent:i,country:s,language:o};return e.query(po,l)}let a={handle:n,intent:i,country:s,language:o};return e.query(ho,a)},"loadProductRecommendations");var bo=r(async(e,{handle:t,first:n,after:i,country:s,language:o})=>{if(!t)throw new Error("A collection handle must be provided");return e.query(mo,{handle:t,first:n,after:i??void 0,country:s,language:o})},"loadCollectionProducts");var uu="2026-04",du=["GetProductIdByHandle"],Nn=class{constructor(t,n,i){this.client=null;this.query=r(async(t,n)=>{if(!this.client)throw new Error("Storefront API client not initialized");let i=await this.client.request(t,{variables:n});return{data:i.data,errors:i.errors??null}},"query");this.loadProduct=r(async t=>yo(this,{...t,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}),"loadProduct");this.loadProductImages=r(async t=>go(this,{...t,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}),"loadProductImages");this.loadProductRecommendations=r(async t=>wo(this,{...t,country:this.context.localization.country,language:this.context.localization.language}),"loadProductRecommendations");this.loadProductId=r(async t=>vo(this,t),"loadProductId");this.loadCollectionProducts=r(async t=>bo(this,{...t,country:this.context.localization.country,language:this.context.localization.language}),"loadCollectionProducts");this.options=t,this.context=n,this.metafields={productMetafields:i?.product.map(o=>({namespace:o.split(".")[0],key:o.split(".")[1]}))??[],variantMetafields:i?.productVariant.map(o=>({namespace:o.split(".")[0],key:o.split(".")[1]}))??[]};let s=me(n.myshopifyDomain);this.shortCache=new Oe(`storefront-api-short-${s}`,"max-age=60, stale-while-revalidate=3600"),this.longCache=new Oe(`storefront-api-long-${s}`,"max-age=3600, stale-while-revalidate=86400"),this.shortCache.cleanupExpiredEntries().catch(o=>{console.warn("Storefront API cache initialization cleanup error:",o)}),this.longCache.cleanupExpiredEntries().catch(o=>{console.warn("Storefront API cache initialization cleanup error:",o)}),this.client=Vi({apiVersion:uu,customFetchApi:r((o,a)=>a?.method==="OPTIONS"?this.fetch(o,a):du.some(l=>a?.body?.toString().includes(`query ${l}`))?this.longCache.fetchWithCache(o,a):this.shortCache.fetchWithCache(o,a),"customFetchApi"),publicAccessToken:this.options.accessToken,storeDomain:this.options.storeDomain})}static{r(this,"StorefrontApiClient")}fetch(t,n){return n?.method==="OPTIONS"?fetch(t,n):this.shortCache.fetchWithCache(t,n)}async clearCache(){await this.shortCache.clear()}};var pu=Object.defineProperty,v=r((e,t)=>pu(e,"name",{value:t,configurable:!0}),"t"),hu={bodySerializer:v(e=>JSON.stringify(e,(t,n)=>typeof n=="bigint"?n.toString():n),"bodySerializer")},fu=v(({onRequest:e,onSseError:t,onSseEvent:n,responseTransformer:i,responseValidator:s,sseDefaultRetryDelay:o,sseMaxRetryAttempts:a,sseMaxRetryDelay:l,sseSleepFn:c,url:d,...u})=>{let p,f=c??(h=>new Promise(w=>setTimeout(w,h)));return{stream:v(async function*(){let h=o??3e3,w=0,m=u.signal??new AbortController().signal;for(;!m.aborted;){w++;let b=u.headers instanceof Headers?u.headers:new Headers(u.headers);p!==void 0&&b.set("Last-Event-ID",p);try{let S={redirect:"follow",...u,body:u.serializedBody,headers:b,signal:m},k=new Request(d,S);e&&(k=await e(d,S));let P=await(u.fetch??globalThis.fetch)(k);if(!P.ok)throw new Error(`SSE failed: ${P.status} ${P.statusText}`);if(!P.body)throw new Error("No body in SSE response");let D=P.body.pipeThrough(new TextDecoderStream).getReader(),E="",A=v(()=>{try{D.cancel()}catch{}},"abortHandler");m.addEventListener("abort",A);try{for(;;){let{done:C,value:B}=await D.read();if(C)break;E+=B,E=E.replace(/\r\n/g,`
266
+ `;var _o=r(async(e,{handle:t,first:n,after:i,country:s,language:o})=>{if(!t)throw new Error("A collection handle must be provided");return e.query(Mo,{handle:t,first:n,after:i??void 0,country:s,language:o})},"loadCollectionProducts");var Bo=r(async(e,{productId:t,productHandle:n,variantId:i,selectedOptions:s,productMetafields:o=[],variantMetafields:a=[],country:l,language:c})=>{if(!t&&!n)throw new Error("Either productId or productHandle must be provided");let d=!!i,u=!!s?.length,p=t?ko:Po,h=t?{productId:Se("Product",t),variantId:i?Se("ProductVariant",i):"gid://shopify/ProductVariant/0",selectedOptions:u?s:[],productMetafields:o,variantMetafields:a,includeVariantById:d,includeVariantBySelectedOptions:u,country:l,language:c}:{handle:n,variantId:i?Se("ProductVariant",i):"gid://shopify/ProductVariant/0",selectedOptions:u?s:[],productMetafields:o,variantMetafields:a,includeVariantById:d,includeVariantBySelectedOptions:u,country:l,language:c},f=await e.query(p,h),w=qo(o),y=qo(a),b=Hu(f.data?.product??null,w,y),S=f.data?.variantNode??null,k=(S?Zi(S,y):null)??b?.variant??null;return{data:{product:b,variant:k},errors:f.errors}},"loadProduct"),qo=r(e=>{let t=new Set;for(let{namespace:n}of e)n&&t.add(n);return Array.from(t)},"uniqueNamespaces"),Fo=r((e,t)=>{let n={};for(let i of t)n[i]={};for(let i of e??[])i&&((n[i.namespace]??={})[i.key]=i.value);return n},"normalizeMetafields"),Zi=r((e,t)=>({...e,metafields:Fo(e.metafields,t)}),"withNormalizedVariantMetafields"),Hu=r((e,t,n)=>e?{...e,metafields:Fo(e.metafields,t),selectedOrFirstAvailableVariant:e.selectedOrFirstAvailableVariant?Zi(e.selectedOrFirstAvailableVariant,n):null,variant:e.variant?Zi(e.variant,n):e.variant}:null,"withNormalizedMetafields");var jo=r(async(e,{productHandle:t})=>{if(!t)throw new Error("A product handle must be provided");return e.query(Lo,{handle:t})},"loadProductId");var No=r(async(e,{items:t,country:n,language:i})=>{if(!t?.length)throw new Error("A list of items must be provided");let s={ids:t.map(o=>o.variantId?Se("ProductVariant",o.variantId.toString()):Se("Product",o.productId.toString())),country:n,language:i};try{return{data:(await e.query(Ao,s)).data?.nodes.map(l=>l===null?null:"image"in l?l.image:"featuredImage"in l?l.featuredImage:null).filter(l=>l!==null)??[],errors:null}}catch(o){return console.error(o),{data:null,errors:o}}},"loadProductImages");var Uo=r(async(e,{productId:t,productHandle:n,intent:i,country:s,language:o})=>{if(!t&&!n)throw new Error("Either productId or productHandle must be provided");if(t){let l={productId:Se("Product",t),intent:i,country:s,language:o};return e.query(To,l)}let a={handle:n,intent:i,country:s,language:o};return e.query(Do,a)},"loadProductRecommendations");var Vo=r(async(e,{productId:t})=>{if(!t)throw new Error("A product ID must be provided");return e.query(Oo,{productId:Se("Product",t)})},"loadProductHandle");var Qu="2026-04",zu=["GetProductIdByHandle"],Hn=class{constructor(t,n,i){this.client=null;this.query=r(async(t,n)=>{if(!this.client)throw new Error("Storefront API client not initialized");let i=await this.client.request(t,{variables:n});return{data:i.data,errors:i.errors??null}},"query");this.loadProduct=r(async t=>Bo(this,{...t,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}),"loadProduct");this.loadProductImages=r(async t=>No(this,{...t,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}),"loadProductImages");this.loadProductRecommendations=r(async t=>Uo(this,{...t,country:this.context.localization.country,language:this.context.localization.language}),"loadProductRecommendations");this.loadProductId=r(async t=>jo(this,t),"loadProductId");this.loadProductHandle=r(async t=>Vo(this,t),"loadProductHandle");this.loadCollectionProducts=r(async t=>_o(this,{...t,country:this.context.localization.country,language:this.context.localization.language}),"loadCollectionProducts");this.options=t,this.context=n,this.metafields={productMetafields:i?.product.map(o=>({namespace:o.split(".")[0],key:o.split(".")[1]}))??[],variantMetafields:i?.productVariant.map(o=>({namespace:o.split(".")[0],key:o.split(".")[1]}))??[]};let s=ye(n.myshopifyDomain);this.shortCache=new Me(`storefront-api-short-${s}`,"max-age=60, stale-while-revalidate=3600"),this.longCache=new Me(`storefront-api-long-${s}`,"max-age=3600, stale-while-revalidate=86400"),this.shortCache.cleanupExpiredEntries().catch(o=>{console.warn("Storefront API cache initialization cleanup error:",o)}),this.longCache.cleanupExpiredEntries().catch(o=>{console.warn("Storefront API cache initialization cleanup error:",o)}),this.client=Xi({apiVersion:Qu,customFetchApi:r((o,a)=>a?.method==="OPTIONS"?this.fetch(o,a):zu.some(l=>a?.body?.toString().includes(`query ${l}`))?this.longCache.fetchWithCache(o,a):this.shortCache.fetchWithCache(o,a),"customFetchApi"),publicAccessToken:this.options.accessToken,storeDomain:this.options.storeDomain})}static{r(this,"StorefrontApiClient")}fetch(t,n){return n?.method==="OPTIONS"?fetch(t,n):this.shortCache.fetchWithCache(t,n)}async clearCache(){await this.shortCache.clear()}};var Gu=Object.defineProperty,v=r((e,t)=>Gu(e,"name",{value:t,configurable:!0}),"t"),Wu={bodySerializer:v(e=>JSON.stringify(e,(t,n)=>typeof n=="bigint"?n.toString():n),"bodySerializer")},Ku=v(({onRequest:e,onSseError:t,onSseEvent:n,responseTransformer:i,responseValidator:s,sseDefaultRetryDelay:o,sseMaxRetryAttempts:a,sseMaxRetryDelay:l,sseSleepFn:c,url:d,...u})=>{let p,h=c??(f=>new Promise(w=>setTimeout(w,f)));return{stream:v(async function*(){let f=o??3e3,w=0,y=u.signal??new AbortController().signal;for(;!y.aborted;){w++;let b=u.headers instanceof Headers?u.headers:new Headers(u.headers);p!==void 0&&b.set("Last-Event-ID",p);try{let S={redirect:"follow",...u,body:u.serializedBody,headers:b,signal:y},k=new Request(d,S);e&&(k=await e(d,S));let E=await(u.fetch??globalThis.fetch)(k);if(!E.ok)throw new Error(`SSE failed: ${E.status} ${E.statusText}`);if(!E.body)throw new Error("No body in SSE response");let R=E.body.pipeThrough(new TextDecoderStream).getReader(),x="",A=v(()=>{try{R.cancel()}catch{}},"abortHandler");y.addEventListener("abort",A);try{for(;;){let{done:P,value:F}=await R.read();if(P)break;x+=F,x=x.replace(/\r\n/g,`
258
267
  `).replace(/\r/g,`
259
- `);let ce=E.split(`
268
+ `);let N=x.split(`
260
269
 
261
- `);E=ce.pop()??"";for(let Ee of ce){let De=Ee.split(`
262
- `),te=[],ye;for(let V of De)if(V.startsWith("data:"))te.push(V.replace(/^data:\s*/,""));else if(V.startsWith("event:"))ye=V.replace(/^event:\s*/,"");else if(V.startsWith("id:"))p=V.replace(/^id:\s*/,"");else if(V.startsWith("retry:")){let Ce=Number.parseInt(V.replace(/^retry:\s*/,""),10);Number.isNaN(Ce)||(h=Ce)}let Y,qe=!1;if(te.length){let V=te.join(`
263
- `);try{Y=JSON.parse(V),qe=!0}catch{Y=V}}qe&&(s&&await s(Y),i&&(Y=await i(Y))),n?.({data:Y,event:ye,id:p,retry:h}),te.length&&(yield Y)}}}finally{m.removeEventListener("abort",A),D.releaseLock()}break}catch(S){if(t?.(S),a!==void 0&&w>=a)break;let k=Math.min(h*2**(w-1),l??3e4);await f(k)}}},"createStream")()}},"createSseClient"),mu=v(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorArrayExplode"),yu=v(e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},"separatorArrayNoExplode"),vu=v(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorObjectExplode"),xo=v(({allowReserved:e,explode:t,name:n,style:i,value:s})=>{if(!t){let l=(e?s:s.map(c=>encodeURIComponent(c))).join(yu(i));switch(i){case"label":return`.${l}`;case"matrix":return`;${n}=${l}`;case"simple":return l;default:return`${n}=${l}`}}let o=mu(i),a=s.map(l=>i==="label"||i==="simple"?e?l:encodeURIComponent(l):Un({allowReserved:e,name:n,value:l})).join(o);return i==="label"||i==="matrix"?o+a:a},"serializeArrayParam"),Un=v(({allowReserved:e,name:t,value:n})=>{if(n==null)return"";if(typeof n=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?n:encodeURIComponent(n)}`},"serializePrimitiveParam"),Eo=v(({allowReserved:e,explode:t,name:n,style:i,value:s,valueOnly:o})=>{if(s instanceof Date)return o?s.toISOString():`${n}=${s.toISOString()}`;if(i!=="deepObject"&&!t){let c=[];Object.entries(s).forEach(([u,p])=>{c=[...c,u,e?p:encodeURIComponent(p)]});let d=c.join(",");switch(i){case"form":return`${n}=${d}`;case"label":return`.${d}`;case"matrix":return`;${n}=${d}`;default:return d}}let a=vu(i),l=Object.entries(s).map(([c,d])=>Un({allowReserved:e,name:i==="deepObject"?`${n}[${c}]`:c,value:d})).join(a);return i==="label"||i==="matrix"?a+l:l},"serializeObjectParam"),gu=/\{[^{}]+\}/g,wu=v(({path:e,url:t})=>{let n=t,i=t.match(gu);if(i)for(let s of i){let o=!1,a=s.substring(1,s.length-1),l="simple";a.endsWith("*")&&(o=!0,a=a.substring(0,a.length-1)),a.startsWith(".")?(a=a.substring(1),l="label"):a.startsWith(";")&&(a=a.substring(1),l="matrix");let c=e[a];if(c==null)continue;if(Array.isArray(c)){n=n.replace(s,xo({explode:o,name:a,style:l,value:c}));continue}if(typeof c=="object"){n=n.replace(s,Eo({explode:o,name:a,style:l,value:c,valueOnly:!0}));continue}if(l==="matrix"){n=n.replace(s,`;${Un({name:a,value:c})}`);continue}let d=encodeURIComponent(l==="label"?`.${c}`:c);n=n.replace(s,d)}return n},"defaultPathSerializer"),bu=v(({baseUrl:e,path:t,query:n,querySerializer:i,url:s})=>{let o=s.startsWith("/")?s:`/${s}`,a=(e??"")+o;t&&(a=wu({path:t,url:a}));let l=n?i(n):"";return l.startsWith("?")&&(l=l.substring(1)),l&&(a+=`?${l}`),a},"getUrl");function zi(e){let t=e.body!==void 0;if(t&&e.bodySerializer)return"serializedBody"in e?e.serializedBody!==void 0&&e.serializedBody!==""?e.serializedBody:null:e.body!==""?e.body:null;if(t)return e.body}r(zi,"N");v(zi,"getValidRequestBody");var Iu=v(async(e,t)=>{let n=typeof t=="function"?await t(e):t;if(n)return e.scheme==="bearer"?`Bearer ${n}`:e.scheme==="basic"?`Basic ${btoa(n)}`:n},"getAuthToken"),Co=v(({parameters:e={},...t}={})=>v(n=>{let i=[];if(n&&typeof n=="object")for(let s in n){let o=n[s];if(o==null)continue;let a=e[s]||t;if(Array.isArray(o)){let l=xo({allowReserved:a.allowReserved,explode:!0,name:s,style:"form",value:o,...a.array});l&&i.push(l)}else if(typeof o=="object"){let l=Eo({allowReserved:a.allowReserved,explode:!0,name:s,style:"deepObject",value:o,...a.object});l&&i.push(l)}else{let l=Un({allowReserved:a.allowReserved,name:s,value:o});l&&i.push(l)}}return i.join("&")},"querySerializer"),"createQuerySerializer"),Su=v(e=>{var t;if(!e)return"stream";let n=(t=e.split(";")[0])==null?void 0:t.trim();if(n){if(n.startsWith("application/json")||n.endsWith("+json"))return"json";if(n==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some(i=>n.startsWith(i)))return"blob";if(n.startsWith("text/"))return"text"}},"getParseAs"),xu=v((e,t)=>{var n,i;return t?!!(e.headers.has(t)||(n=e.query)!=null&&n[t]||(i=e.headers.get("Cookie"))!=null&&i.includes(`${t}=`)):!1},"checkForExistence"),Eu=v(async({security:e,...t})=>{for(let n of e){if(xu(t,n.name))continue;let i=await Iu(n,t.auth);if(!i)continue;let s=n.name??"Authorization";switch(n.in){case"query":t.query||(t.query={}),t.query[s]=i;break;case"cookie":t.headers.append("Cookie",`${s}=${i}`);break;default:t.headers.set(s,i);break}}},"setAuthParams"),Io=v(e=>bu({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:Co(e.querySerializer),url:e.url}),"buildUrl"),So=v((e,t)=>{var n;let i={...e,...t};return(n=i.baseUrl)!=null&&n.endsWith("/")&&(i.baseUrl=i.baseUrl.substring(0,i.baseUrl.length-1)),i.headers=Ro(e.headers,t.headers),i},"mergeConfigs"),Cu=v(e=>{let t=[];return e.forEach((n,i)=>{t.push([i,n])}),t},"headersEntries"),Ro=v((...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let i=n instanceof Headers?Cu(n):Object.entries(n);for(let[s,o]of i)if(o===null)t.delete(s);else if(Array.isArray(o))for(let a of o)t.append(s,a);else o!==void 0&&t.set(s,typeof o=="object"?JSON.stringify(o):o)}return t},"mergeHeaders"),ko=class{static{r(this,"j")}constructor(){this.fns=[]}clear(){this.fns=[]}eject(t){let n=this.getInterceptorIndex(t);this.fns[n]&&(this.fns[n]=null)}exists(t){let n=this.getInterceptorIndex(t);return!!this.fns[n]}getInterceptorIndex(t){return typeof t=="number"?this.fns[t]?t:-1:this.fns.indexOf(t)}update(t,n){let i=this.getInterceptorIndex(t);return this.fns[i]?(this.fns[i]=n,t):!1}use(t){return this.fns.push(t),this.fns.length-1}};v(ko,"Interceptors");var Qi=ko,Ru=v(()=>({error:new Qi,request:new Qi,response:new Qi}),"createInterceptors"),ku=Co({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),Au={"Content-Type":"application/json"},Gi=v((e={})=>({...hu,headers:Au,parseAs:"auto",querySerializer:ku,...e}),"createConfig"),Ao=v((e={})=>{let t=So(Gi(),e),n=v(()=>({...t}),"getConfig"),i=v(d=>(t=So(t,d),n()),"setConfig"),s=Ru(),o=v(async d=>{let u={...t,...d,fetch:d.fetch??t.fetch??globalThis.fetch,headers:Ro(t.headers,d.headers),serializedBody:void 0};u.security&&await Eu({...u,security:u.security}),u.requestValidator&&await u.requestValidator(u),u.body!==void 0&&u.bodySerializer&&(u.serializedBody=u.bodySerializer(u.body)),(u.body===void 0||u.serializedBody==="")&&u.headers.delete("Content-Type");let p=Io(u);return{opts:u,url:p}},"beforeRequest"),a=v(async d=>{let{opts:u,url:p}=await o(d),f={redirect:"follow",...u,body:zi(u)},h=new Request(p,f);for(let E of s.request.fns)E&&(h=await E(h,u));let w=u.fetch,m;try{m=await w(h)}catch(E){let A=E;for(let C of s.error.fns)C&&(A=await C(E,void 0,h,u));if(A=A||{},u.throwOnError)throw A;return u.responseStyle==="data"?void 0:{error:A,request:h,response:void 0}}for(let E of s.response.fns)E&&(m=await E(m,h,u));let b={request:h,response:m};if(m.ok){let E=(u.parseAs==="auto"?Su(m.headers.get("Content-Type")):u.parseAs)??"json";if(m.status===204||m.headers.get("Content-Length")==="0"){let C;switch(E){case"arrayBuffer":case"blob":case"text":C=await m[E]();break;case"formData":C=new FormData;break;case"stream":C=m.body;break;default:C={};break}return u.responseStyle==="data"?C:{data:C,...b}}let A;switch(E){case"arrayBuffer":case"blob":case"formData":case"text":A=await m[E]();break;case"json":{let C=await m.text();A=C?JSON.parse(C):{};break}case"stream":return u.responseStyle==="data"?m.body:{data:m.body,...b}}return E==="json"&&(u.responseValidator&&await u.responseValidator(A),u.responseTransformer&&(A=await u.responseTransformer(A))),u.responseStyle==="data"?A:{data:A,...b}}let S=await m.text(),k;try{k=JSON.parse(S)}catch{}let P=k??S,D=P;for(let E of s.error.fns)E&&(D=await E(P,m,h,u));if(D=D||{},u.throwOnError)throw D;return u.responseStyle==="data"?void 0:{error:D,...b}},"request"),l=v(d=>u=>a({...u,method:d}),"makeMethodFn"),c=v(d=>async u=>{let{opts:p,url:f}=await o(u);return fu({...p,body:p.body,headers:p.headers,method:d,onRequest:v(async(h,w)=>{let m=new Request(h,w);for(let b of s.request.fns)b&&(m=await b(m,p));return m},"onRequest"),serializedBody:zi(p),url:f})},"makeSseFn");return{buildUrl:Io,connect:l("CONNECT"),delete:l("DELETE"),get:l("GET"),getConfig:n,head:l("HEAD"),interceptors:s,options:l("OPTIONS"),patch:l("PATCH"),post:l("POST"),put:l("PUT"),request:a,setConfig:i,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:l("TRACE")}},"createClient"),L=Ao(Gi({baseUrl:"https://swish.app/api/2026-04"})),Pu=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/lists",...e}),"listControllerFind"),Tu=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerCreate"),Du=v(e=>(e.client??L).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e}),"listControllerDeleteById"),Lu=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e}),"listControllerFindById"),Ou=v(e=>(e.client??L).patch({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerUpdateById"),_u=v(e=>(e.client??L).put({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/order",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerSetListItemsOrder"),Mu=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerAddItemsToList"),qu=v(e=>(e.client??L).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/{itemId}",...e}),"listControllerRemoveItemFromList"),Bu=v(e=>(e.client??L).delete({security:[{scheme:"bearer",type:"http"}],url:"/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerDelete"),Fu=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/items",...e}),"itemControllerFind"),ju=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerCreate"),Nu=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/items/count",...e}),"itemControllerCount"),Uu=v(e=>(e.client??L).delete({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e}),"itemControllerDeleteById"),Vu=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e}),"itemControllerFindById"),$u=v(e=>(e.client??L).patch({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerUpdateById"),Hu=v(e=>(e.client??L).put({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerSetListsById"),Qu=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/identify",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerIdentify"),zu=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/token",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerCreateToken"),Gu=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/profiles",...e}),"profileControllerGetProfile"),Wu=v(e=>(e.client??L).patch({security:[{scheme:"bearer",type:"http"}],url:"/profiles/profile",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerUpdateProfile"),Ku=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/saved-items",...e}),"analyticsControllerLoadSavedItems"),Xu=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/sessions",...e}),"analyticsControllerLoadSessions"),Ju=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/new-lists",...e}),"analyticsControllerLoadNewLists"),Yu=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/collect",...e,headers:{"Content-Type":"application/json",...e.headers}}),"trackingControllerCollect"),Zu=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/orders",...e}),"ordersControllerFind"),ed=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/orders/{orderId}",...e}),"ordersControllerFindOne"),td=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists",...e}),"sharedListsControllerFindAll"),nd=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"sharedListsControllerSave"),id=v(e=>(e.client??L).delete({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}",...e}),"sharedListsControllerDeleteById"),sd=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}",...e}),"sharedListsControllerFindById"),rd=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}/items",...e}),"sharedListsControllerFindItems"),od=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/notifications",...e}),"notificationsControllerFind"),ad=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/notifications/unread/count",...e}),"notificationsControllerGetUnreadCount"),ld=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/notifications/read",...e,headers:{"Content-Type":"application/json",...e.headers}}),"notificationsControllerMarkAsRead"),cd=v(e=>(e?.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/notifications/read/all",...e}),"notificationsControllerMarkAllAsRead"),ud=v(e=>(e.client??L).delete({security:[{scheme:"bearer",type:"http"}],url:"/notifications/{id}",...e}),"notificationsControllerDeleteById"),dd=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions",...e}),"subscriptionsControllerFind"),pd=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions",...e,headers:{"Content-Type":"application/json",...e.headers}}),"subscriptionsControllerCreate"),hd=v(e=>(e.client??L).delete({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e}),"subscriptionsControllerDelete"),fd=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e}),"subscriptionsControllerFindById"),md=v(e=>(e.client??L).patch({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"subscriptionsControllerUpdate"),yd=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists",...e}),"smartListsControllerFindAll"),vd=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists/{smartListId}",...e}),"smartListsControllerFindById"),gd=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists/{smartListId}/items",...e}),"smartListsControllerFindItems"),Wi="2026-04",Po=v(e=>new wd(e),"createApiClient"),To=class{static{r(this,"xe")}constructor(t){this.version=Wi,this.items={list:v(n=>this.handlePaginatedRequest(Fu({query:n,client:this.client})),"list"),create:v(n=>this.handleRequest(ju({body:n,client:this.client})),"create"),delete:v(n=>this.handleRequest(Bu({body:{itemIds:n},client:this.client})),"delete"),findById:v(n=>this.handleRequest(Vu({path:{itemId:n},client:this.client})),"findById"),updateById:v((n,i)=>this.handleRequest($u({body:i,path:{itemId:n},client:this.client})),"updateById"),deleteById:v(n=>this.handleRequest(Uu({path:{itemId:n},client:this.client})),"deleteById"),setListsById:v((n,i)=>this.handleRequest(Hu({body:{listIds:i},path:{itemId:n},client:this.client})),"setListsById"),count:v(()=>this.handleRequest(Nu({client:this.client})),"count")},this.lists={list:v(n=>this.handlePaginatedRequest(Pu({query:n,client:this.client})),"list"),create:v(n=>this.handleRequest(Tu({body:n,client:this.client})),"create"),findById:v(n=>this.handleRequest(Lu({path:{listId:n},client:this.client})),"findById"),updateById:v((n,i)=>this.handleRequest(Ou({body:i,path:{listId:n},client:this.client})),"updateById"),deleteById:v(n=>this.handleRequest(Du({path:{listId:n},client:this.client})),"deleteById"),orderItems:v((n,i)=>this.handleRequest(_u({body:{itemIds:i},path:{listId:n},client:this.client})),"orderItems"),addItemsToList:v((n,i)=>this.handleRequest(Mu({body:{itemIds:i},path:{listId:n},client:this.client})),"addItemsToList"),removeItemFromList:v((n,i)=>this.handleRequest(qu({path:{listId:n,itemId:i},client:this.client})),"removeItemFromList")},this.profiles={createToken:v((n={})=>this.handleRequest(zu({body:n,client:this.client})),"createToken"),identify:v(n=>this.handleRequest(Qu({body:n,client:this.client})),"identify"),getProfile:v(()=>this.handleRequest(Gu({client:this.client})),"getProfile"),updateProfile:v(n=>this.handleRequest(Wu({body:n,client:this.client})),"updateProfile")},this.orders={list:v(n=>this.handlePaginatedRequest(Zu({query:n,client:this.client})),"list"),findById:v(n=>this.handleRequest(ed({path:{orderId:n},client:this.client})),"findById")},this.sharedLists={list:v(n=>this.handlePaginatedRequest(td({query:n,client:this.client})),"list"),save:v(n=>this.handleRequest(nd({body:{listId:n},client:this.client})),"save"),findById:v(n=>this.handleRequest(sd({path:{sharedListId:n},client:this.client})),"findById"),deleteById:v(n=>this.handleRequest(id({path:{sharedListId:n},client:this.client})),"deleteById"),findItems:v((n,i)=>this.handlePaginatedRequest(rd({path:{sharedListId:n},query:i,client:this.client})),"findItems")},this.analytics={savedItems:v(n=>this.handleRequest(Ku({query:n,client:this.client})),"savedItems"),sessions:v(n=>this.handleRequest(Xu({query:n,client:this.client})),"sessions"),newLists:v(n=>this.handleRequest(Ju({query:n,client:this.client})),"newLists")},this.tracking={track:v(n=>this.handleRequest(Yu({body:n,client:this.client})),"track")},this.notifications={list:v(n=>this.handlePaginatedRequest(od({query:n,client:this.client})),"list"),getUnreadCount:v(()=>this.handleRequest(ad({client:this.client})),"getUnreadCount"),markAsRead:v(n=>this.handleRequest(ld({body:{notificationIds:n},client:this.client})),"markAsRead"),markAllAsRead:v(()=>this.handleRequest(cd({client:this.client})),"markAllAsRead"),deleteById:v(n=>this.handleRequest(ud({path:{id:n},client:this.client})),"deleteById")},this.subscriptions={list:v(n=>this.handlePaginatedRequest(dd({query:n,client:this.client})),"list"),create:v(n=>this.handleRequest(pd({body:n,client:this.client})),"create"),findById:v(n=>this.handleRequest(fd({path:{id:n},client:this.client})),"findById"),updateById:v((n,i)=>this.handleRequest(md({body:i,path:{id:n},client:this.client})),"updateById"),deleteById:v(n=>this.handleRequest(hd({path:{id:n},client:this.client})),"deleteById")},this.smartLists={list:v(()=>this.handleRequest(yd({client:this.client})),"list"),findById:v(n=>this.handleRequest(vd({path:{smartListId:n},client:this.client})),"findById"),findItems:v((n,i)=>this.handlePaginatedRequest(gd({path:{smartListId:n},query:i,client:this.client})),"findItems")},this.handleRequest=v(async n=>{let{data:i,error:s}=await n;return s!=null&&s.error?{error:s.error}:{data:i?.data}},"handleRequest"),this.handlePaginatedRequest=v(async n=>{var i;let{data:s,error:o}=await n;return o!=null&&o.error?{error:o.error}:{data:s?.data??[],pageInfo:s?.pageInfo??{next:null,previous:null,totalCount:((i=s?.data)==null?void 0:i.length)??0}}},"handlePaginatedRequest"),this.client=Ao(Gi({baseUrl:`https://swish.app/api/${this.version}`,...t.config})),t.authToken&&(this.authToken=t.authToken),t.requestInterceptor&&this.client.interceptors.request.use(t.requestInterceptor),t.responseInterceptor&&this.client.interceptors.response.use(t.responseInterceptor),this.client.interceptors.request.use(this.directRequestInterceptor.bind(this))}setAuthToken(t){this.authToken=t}directRequestInterceptor(t){return this.authToken&&t.headers.set("Authorization",`Bearer ${this.authToken}`),t}};v(To,"SwishClient");var wd=To;var _o=Zo(Oo(),1);var Mo=r(e=>new _o.default(async t=>{let n=[...new Set(t)].sort((s,o)=>s.localeCompare(o)),i=await e.items.list({query:n.join(" "),limit:200});if("error"in i){let s=new Error(i.error.message);return t.map(()=>s)}return t.map(s=>{let o=i.data.filter(a=>s===`variant:${a.variantId}`||s===`product:${a.productId}`);return{data:o,pageInfo:{next:null,previous:null,totalCount:o.length}}})},{batchScheduleFn:r(t=>setTimeout(t,50),"batchScheduleFn"),cache:!1,maxBatchSize:200}),"createItemsBatchLoader");var Pd=Object.defineProperty,g=r((e,t)=>Pd(e,"name",{value:t,configurable:!0}),"t"),Td={bodySerializer:g(e=>JSON.stringify(e,(t,n)=>typeof n=="bigint"?n.toString():n),"bodySerializer")},Dd=g(({onRequest:e,onSseError:t,onSseEvent:n,responseTransformer:i,responseValidator:s,sseDefaultRetryDelay:o,sseMaxRetryAttempts:a,sseMaxRetryDelay:l,sseSleepFn:c,url:d,...u})=>{let p,f=c??(h=>new Promise(w=>setTimeout(w,h)));return{stream:g(async function*(){let h=o??3e3,w=0,m=u.signal??new AbortController().signal;for(;!m.aborted;){w++;let b=u.headers instanceof Headers?u.headers:new Headers(u.headers);p!==void 0&&b.set("Last-Event-ID",p);try{let S={redirect:"follow",...u,body:u.serializedBody,headers:b,signal:m},k=new Request(d,S);e&&(k=await e(d,S));let P=await(u.fetch??globalThis.fetch)(k);if(!P.ok)throw new Error(`SSE failed: ${P.status} ${P.statusText}`);if(!P.body)throw new Error("No body in SSE response");let D=P.body.pipeThrough(new TextDecoderStream).getReader(),E="",A=g(()=>{try{D.cancel()}catch{}},"abortHandler");m.addEventListener("abort",A);try{for(;;){let{done:C,value:B}=await D.read();if(C)break;E+=B,E=E.replace(/\r\n/g,`
270
+ `);x=N.pop()??"";for(let oe of N){let Oe=oe.split(`
271
+ `),ne=[],ve;for(let $ of Oe)if($.startsWith("data:"))ne.push($.replace(/^data:\s*/,""));else if($.startsWith("event:"))ve=$.replace(/^event:\s*/,"");else if($.startsWith("id:"))p=$.replace(/^id:\s*/,"");else if($.startsWith("retry:")){let Pe=Number.parseInt($.replace(/^retry:\s*/,""),10);Number.isNaN(Pe)||(f=Pe)}let Z,Be=!1;if(ne.length){let $=ne.join(`
272
+ `);try{Z=JSON.parse($),Be=!0}catch{Z=$}}Be&&(s&&await s(Z),i&&(Z=await i(Z))),n?.({data:Z,event:ve,id:p,retry:f}),ne.length&&(yield Z)}}}finally{y.removeEventListener("abort",A),R.releaseLock()}break}catch(S){if(t?.(S),a!==void 0&&w>=a)break;let k=Math.min(f*2**(w-1),l??3e4);await h(k)}}},"createStream")()}},"createSseClient"),Xu=v(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorArrayExplode"),Ju=v(e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},"separatorArrayNoExplode"),Yu=v(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorObjectExplode"),Qo=v(({allowReserved:e,explode:t,name:n,style:i,value:s})=>{if(!t){let l=(e?s:s.map(c=>encodeURIComponent(c))).join(Ju(i));switch(i){case"label":return`.${l}`;case"matrix":return`;${n}=${l}`;case"simple":return l;default:return`${n}=${l}`}}let o=Xu(i),a=s.map(l=>i==="label"||i==="simple"?e?l:encodeURIComponent(l):Qn({allowReserved:e,name:n,value:l})).join(o);return i==="label"||i==="matrix"?o+a:a},"serializeArrayParam"),Qn=v(({allowReserved:e,name:t,value:n})=>{if(n==null)return"";if(typeof n=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?n:encodeURIComponent(n)}`},"serializePrimitiveParam"),zo=v(({allowReserved:e,explode:t,name:n,style:i,value:s,valueOnly:o})=>{if(s instanceof Date)return o?s.toISOString():`${n}=${s.toISOString()}`;if(i!=="deepObject"&&!t){let c=[];Object.entries(s).forEach(([u,p])=>{c=[...c,u,e?p:encodeURIComponent(p)]});let d=c.join(",");switch(i){case"form":return`${n}=${d}`;case"label":return`.${d}`;case"matrix":return`;${n}=${d}`;default:return d}}let a=Yu(i),l=Object.entries(s).map(([c,d])=>Qn({allowReserved:e,name:i==="deepObject"?`${n}[${c}]`:c,value:d})).join(a);return i==="label"||i==="matrix"?a+l:l},"serializeObjectParam"),Zu=/\{[^{}]+\}/g,ed=v(({path:e,url:t})=>{let n=t,i=t.match(Zu);if(i)for(let s of i){let o=!1,a=s.substring(1,s.length-1),l="simple";a.endsWith("*")&&(o=!0,a=a.substring(0,a.length-1)),a.startsWith(".")?(a=a.substring(1),l="label"):a.startsWith(";")&&(a=a.substring(1),l="matrix");let c=e[a];if(c==null)continue;if(Array.isArray(c)){n=n.replace(s,Qo({explode:o,name:a,style:l,value:c}));continue}if(typeof c=="object"){n=n.replace(s,zo({explode:o,name:a,style:l,value:c,valueOnly:!0}));continue}if(l==="matrix"){n=n.replace(s,`;${Qn({name:a,value:c})}`);continue}let d=encodeURIComponent(l==="label"?`.${c}`:c);n=n.replace(s,d)}return n},"defaultPathSerializer"),td=v(({baseUrl:e,path:t,query:n,querySerializer:i,url:s})=>{let o=s.startsWith("/")?s:`/${s}`,a=(e??"")+o;t&&(a=ed({path:t,url:a}));let l=n?i(n):"";return l.startsWith("?")&&(l=l.substring(1)),l&&(a+=`?${l}`),a},"getUrl");function ts(e){let t=e.body!==void 0;if(t&&e.bodySerializer)return"serializedBody"in e?e.serializedBody!==void 0&&e.serializedBody!==""?e.serializedBody:null:e.body!==""?e.body:null;if(t)return e.body}r(ts,"N");v(ts,"getValidRequestBody");var nd=v(async(e,t)=>{let n=typeof t=="function"?await t(e):t;if(n)return e.scheme==="bearer"?`Bearer ${n}`:e.scheme==="basic"?`Basic ${btoa(n)}`:n},"getAuthToken"),Go=v(({parameters:e={},...t}={})=>v(n=>{let i=[];if(n&&typeof n=="object")for(let s in n){let o=n[s];if(o==null)continue;let a=e[s]||t;if(Array.isArray(o)){let l=Qo({allowReserved:a.allowReserved,explode:!0,name:s,style:"form",value:o,...a.array});l&&i.push(l)}else if(typeof o=="object"){let l=zo({allowReserved:a.allowReserved,explode:!0,name:s,style:"deepObject",value:o,...a.object});l&&i.push(l)}else{let l=Qn({allowReserved:a.allowReserved,name:s,value:o});l&&i.push(l)}}return i.join("&")},"querySerializer"),"createQuerySerializer"),id=v(e=>{var t;if(!e)return"stream";let n=(t=e.split(";")[0])==null?void 0:t.trim();if(n){if(n.startsWith("application/json")||n.endsWith("+json"))return"json";if(n==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some(i=>n.startsWith(i)))return"blob";if(n.startsWith("text/"))return"text"}},"getParseAs"),sd=v((e,t)=>{var n,i;return t?!!(e.headers.has(t)||(n=e.query)!=null&&n[t]||(i=e.headers.get("Cookie"))!=null&&i.includes(`${t}=`)):!1},"checkForExistence"),rd=v(async({security:e,...t})=>{for(let n of e){if(sd(t,n.name))continue;let i=await nd(n,t.auth);if(!i)continue;let s=n.name??"Authorization";switch(n.in){case"query":t.query||(t.query={}),t.query[s]=i;break;case"cookie":t.headers.append("Cookie",`${s}=${i}`);break;default:t.headers.set(s,i);break}}},"setAuthParams"),$o=v(e=>td({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:Go(e.querySerializer),url:e.url}),"buildUrl"),Ho=v((e,t)=>{var n;let i={...e,...t};return(n=i.baseUrl)!=null&&n.endsWith("/")&&(i.baseUrl=i.baseUrl.substring(0,i.baseUrl.length-1)),i.headers=Wo(e.headers,t.headers),i},"mergeConfigs"),od=v(e=>{let t=[];return e.forEach((n,i)=>{t.push([i,n])}),t},"headersEntries"),Wo=v((...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let i=n instanceof Headers?od(n):Object.entries(n);for(let[s,o]of i)if(o===null)t.delete(s);else if(Array.isArray(o))for(let a of o)t.append(s,a);else o!==void 0&&t.set(s,typeof o=="object"?JSON.stringify(o):o)}return t},"mergeHeaders"),Ko=class{static{r(this,"j")}constructor(){this.fns=[]}clear(){this.fns=[]}eject(t){let n=this.getInterceptorIndex(t);this.fns[n]&&(this.fns[n]=null)}exists(t){let n=this.getInterceptorIndex(t);return!!this.fns[n]}getInterceptorIndex(t){return typeof t=="number"?this.fns[t]?t:-1:this.fns.indexOf(t)}update(t,n){let i=this.getInterceptorIndex(t);return this.fns[i]?(this.fns[i]=n,t):!1}use(t){return this.fns.push(t),this.fns.length-1}};v(Ko,"Interceptors");var es=Ko,ad=v(()=>({error:new es,request:new es,response:new es}),"createInterceptors"),ld=Go({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),cd={"Content-Type":"application/json"},ns=v((e={})=>({...Wu,headers:cd,parseAs:"auto",querySerializer:ld,...e}),"createConfig"),Xo=v((e={})=>{let t=Ho(ns(),e),n=v(()=>({...t}),"getConfig"),i=v(d=>(t=Ho(t,d),n()),"setConfig"),s=ad(),o=v(async d=>{let u={...t,...d,fetch:d.fetch??t.fetch??globalThis.fetch,headers:Wo(t.headers,d.headers),serializedBody:void 0};u.security&&await rd({...u,security:u.security}),u.requestValidator&&await u.requestValidator(u),u.body!==void 0&&u.bodySerializer&&(u.serializedBody=u.bodySerializer(u.body)),(u.body===void 0||u.serializedBody==="")&&u.headers.delete("Content-Type");let p=$o(u);return{opts:u,url:p}},"beforeRequest"),a=v(async d=>{let{opts:u,url:p}=await o(d),h={redirect:"follow",...u,body:ts(u)},f=new Request(p,h);for(let x of s.request.fns)x&&(f=await x(f,u));let w=u.fetch,y;try{y=await w(f)}catch(x){let A=x;for(let P of s.error.fns)P&&(A=await P(x,void 0,f,u));if(A=A||{},u.throwOnError)throw A;return u.responseStyle==="data"?void 0:{error:A,request:f,response:void 0}}for(let x of s.response.fns)x&&(y=await x(y,f,u));let b={request:f,response:y};if(y.ok){let x=(u.parseAs==="auto"?id(y.headers.get("Content-Type")):u.parseAs)??"json";if(y.status===204||y.headers.get("Content-Length")==="0"){let P;switch(x){case"arrayBuffer":case"blob":case"text":P=await y[x]();break;case"formData":P=new FormData;break;case"stream":P=y.body;break;default:P={};break}return u.responseStyle==="data"?P:{data:P,...b}}let A;switch(x){case"arrayBuffer":case"blob":case"formData":case"text":A=await y[x]();break;case"json":{let P=await y.text();A=P?JSON.parse(P):{};break}case"stream":return u.responseStyle==="data"?y.body:{data:y.body,...b}}return x==="json"&&(u.responseValidator&&await u.responseValidator(A),u.responseTransformer&&(A=await u.responseTransformer(A))),u.responseStyle==="data"?A:{data:A,...b}}let S=await y.text(),k;try{k=JSON.parse(S)}catch{}let E=k??S,R=E;for(let x of s.error.fns)x&&(R=await x(E,y,f,u));if(R=R||{},u.throwOnError)throw R;return u.responseStyle==="data"?void 0:{error:R,...b}},"request"),l=v(d=>u=>a({...u,method:d}),"makeMethodFn"),c=v(d=>async u=>{let{opts:p,url:h}=await o(u);return Ku({...p,body:p.body,headers:p.headers,method:d,onRequest:v(async(f,w)=>{let y=new Request(f,w);for(let b of s.request.fns)b&&(y=await b(y,p));return y},"onRequest"),serializedBody:ts(p),url:h})},"makeSseFn");return{buildUrl:$o,connect:l("CONNECT"),delete:l("DELETE"),get:l("GET"),getConfig:n,head:l("HEAD"),interceptors:s,options:l("OPTIONS"),patch:l("PATCH"),post:l("POST"),put:l("PUT"),request:a,setConfig:i,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:l("TRACE")}},"createClient"),L=Xo(ns({baseUrl:"https://swish.app/api/2026-04"})),ud=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/lists",...e}),"listControllerFind"),dd=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerCreate"),pd=v(e=>(e.client??L).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e}),"listControllerDeleteById"),hd=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e}),"listControllerFindById"),fd=v(e=>(e.client??L).patch({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerUpdateById"),md=v(e=>(e.client??L).put({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/order",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerSetListItemsOrder"),yd=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerAddItemsToList"),vd=v(e=>(e.client??L).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/{itemId}",...e}),"listControllerRemoveItemFromList"),gd=v(e=>(e.client??L).delete({security:[{scheme:"bearer",type:"http"}],url:"/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerDelete"),wd=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/items",...e}),"itemControllerFind"),bd=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerCreate"),Id=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/items/count",...e}),"itemControllerCount"),Sd=v(e=>(e.client??L).delete({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e}),"itemControllerDeleteById"),xd=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e}),"itemControllerFindById"),Cd=v(e=>(e.client??L).patch({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerUpdateById"),Ed=v(e=>(e.client??L).put({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerSetListsById"),Rd=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/identify",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerIdentify"),kd=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/token",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerCreateToken"),Pd=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/profiles",...e}),"profileControllerGetProfile"),Ad=v(e=>(e.client??L).patch({security:[{scheme:"bearer",type:"http"}],url:"/profiles/profile",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerUpdateProfile"),Td=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/saved-items",...e}),"analyticsControllerLoadSavedItems"),Dd=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/sessions",...e}),"analyticsControllerLoadSessions"),Ld=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/new-lists",...e}),"analyticsControllerLoadNewLists"),Od=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/collect",...e,headers:{"Content-Type":"application/json",...e.headers}}),"trackingControllerCollect"),Md=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/orders",...e}),"ordersControllerFind"),_d=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/orders/{orderId}",...e}),"ordersControllerFindOne"),qd=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists",...e}),"sharedListsControllerFindAll"),Bd=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"sharedListsControllerSave"),Fd=v(e=>(e.client??L).delete({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}",...e}),"sharedListsControllerDeleteById"),jd=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}",...e}),"sharedListsControllerFindById"),Nd=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}/items",...e}),"sharedListsControllerFindItems"),Ud=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/notifications",...e}),"notificationsControllerFind"),Vd=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/notifications/unread/count",...e}),"notificationsControllerGetUnreadCount"),$d=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/notifications/read",...e,headers:{"Content-Type":"application/json",...e.headers}}),"notificationsControllerMarkAsRead"),Hd=v(e=>(e?.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/notifications/read/all",...e}),"notificationsControllerMarkAllAsRead"),Qd=v(e=>(e.client??L).delete({security:[{scheme:"bearer",type:"http"}],url:"/notifications/{id}",...e}),"notificationsControllerDeleteById"),zd=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions",...e}),"subscriptionsControllerFind"),Gd=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions",...e,headers:{"Content-Type":"application/json",...e.headers}}),"subscriptionsControllerCreate"),Wd=v(e=>(e.client??L).delete({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e}),"subscriptionsControllerDelete"),Kd=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e}),"subscriptionsControllerFindById"),Xd=v(e=>(e.client??L).patch({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"subscriptionsControllerUpdate"),Jd=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists",...e}),"smartListsControllerFindAll"),Yd=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists/{smartListId}",...e}),"smartListsControllerFindById"),Zd=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists/{smartListId}/items",...e}),"smartListsControllerFindItems"),is="2026-04",Jo=v(e=>new ep(e),"createApiClient"),Yo=class{static{r(this,"xe")}constructor(t){this.version=is,this.items={list:v(n=>this.handlePaginatedRequest(wd({query:n,client:this.client})),"list"),create:v(n=>this.handleRequest(bd({body:n,client:this.client})),"create"),delete:v(n=>this.handleRequest(gd({body:{itemIds:n},client:this.client})),"delete"),findById:v(n=>this.handleRequest(xd({path:{itemId:n},client:this.client})),"findById"),updateById:v((n,i)=>this.handleRequest(Cd({body:i,path:{itemId:n},client:this.client})),"updateById"),deleteById:v(n=>this.handleRequest(Sd({path:{itemId:n},client:this.client})),"deleteById"),setListsById:v((n,i)=>this.handleRequest(Ed({body:{listIds:i},path:{itemId:n},client:this.client})),"setListsById"),count:v(()=>this.handleRequest(Id({client:this.client})),"count")},this.lists={list:v(n=>this.handlePaginatedRequest(ud({query:n,client:this.client})),"list"),create:v(n=>this.handleRequest(dd({body:n,client:this.client})),"create"),findById:v(n=>this.handleRequest(hd({path:{listId:n},client:this.client})),"findById"),updateById:v((n,i)=>this.handleRequest(fd({body:i,path:{listId:n},client:this.client})),"updateById"),deleteById:v(n=>this.handleRequest(pd({path:{listId:n},client:this.client})),"deleteById"),orderItems:v((n,i)=>this.handleRequest(md({body:{itemIds:i},path:{listId:n},client:this.client})),"orderItems"),addItemsToList:v((n,i)=>this.handleRequest(yd({body:{itemIds:i},path:{listId:n},client:this.client})),"addItemsToList"),removeItemFromList:v((n,i)=>this.handleRequest(vd({path:{listId:n,itemId:i},client:this.client})),"removeItemFromList")},this.profiles={createToken:v((n={})=>this.handleRequest(kd({body:n,client:this.client})),"createToken"),identify:v(n=>this.handleRequest(Rd({body:n,client:this.client})),"identify"),getProfile:v(()=>this.handleRequest(Pd({client:this.client})),"getProfile"),updateProfile:v(n=>this.handleRequest(Ad({body:n,client:this.client})),"updateProfile")},this.orders={list:v(n=>this.handlePaginatedRequest(Md({query:n,client:this.client})),"list"),findById:v(n=>this.handleRequest(_d({path:{orderId:n},client:this.client})),"findById")},this.sharedLists={list:v(n=>this.handlePaginatedRequest(qd({query:n,client:this.client})),"list"),save:v(n=>this.handleRequest(Bd({body:{listId:n},client:this.client})),"save"),findById:v(n=>this.handleRequest(jd({path:{sharedListId:n},client:this.client})),"findById"),deleteById:v(n=>this.handleRequest(Fd({path:{sharedListId:n},client:this.client})),"deleteById"),findItems:v((n,i)=>this.handlePaginatedRequest(Nd({path:{sharedListId:n},query:i,client:this.client})),"findItems")},this.analytics={savedItems:v(n=>this.handleRequest(Td({query:n,client:this.client})),"savedItems"),sessions:v(n=>this.handleRequest(Dd({query:n,client:this.client})),"sessions"),newLists:v(n=>this.handleRequest(Ld({query:n,client:this.client})),"newLists")},this.tracking={track:v(n=>this.handleRequest(Od({body:n,client:this.client})),"track")},this.notifications={list:v(n=>this.handlePaginatedRequest(Ud({query:n,client:this.client})),"list"),getUnreadCount:v(()=>this.handleRequest(Vd({client:this.client})),"getUnreadCount"),markAsRead:v(n=>this.handleRequest($d({body:{notificationIds:n},client:this.client})),"markAsRead"),markAllAsRead:v(()=>this.handleRequest(Hd({client:this.client})),"markAllAsRead"),deleteById:v(n=>this.handleRequest(Qd({path:{id:n},client:this.client})),"deleteById")},this.subscriptions={list:v(n=>this.handlePaginatedRequest(zd({query:n,client:this.client})),"list"),create:v(n=>this.handleRequest(Gd({body:n,client:this.client})),"create"),findById:v(n=>this.handleRequest(Kd({path:{id:n},client:this.client})),"findById"),updateById:v((n,i)=>this.handleRequest(Xd({body:i,path:{id:n},client:this.client})),"updateById"),deleteById:v(n=>this.handleRequest(Wd({path:{id:n},client:this.client})),"deleteById")},this.smartLists={list:v(()=>this.handleRequest(Jd({client:this.client})),"list"),findById:v(n=>this.handleRequest(Yd({path:{smartListId:n},client:this.client})),"findById"),findItems:v((n,i)=>this.handlePaginatedRequest(Zd({path:{smartListId:n},query:i,client:this.client})),"findItems")},this.handleRequest=v(async n=>{let{data:i,error:s}=await n;return s!=null&&s.error?{error:s.error}:{data:i?.data}},"handleRequest"),this.handlePaginatedRequest=v(async n=>{var i;let{data:s,error:o}=await n;return o!=null&&o.error?{error:o.error}:{data:s?.data??[],pageInfo:s?.pageInfo??{next:null,previous:null,totalCount:((i=s?.data)==null?void 0:i.length)??0}}},"handlePaginatedRequest"),this.client=Xo(ns({baseUrl:`https://swish.app/api/${this.version}`,...t.config})),t.authToken&&(this.authToken=t.authToken),t.requestInterceptor&&this.client.interceptors.request.use(t.requestInterceptor),t.responseInterceptor&&this.client.interceptors.response.use(t.responseInterceptor),this.client.interceptors.request.use(this.directRequestInterceptor.bind(this))}setAuthToken(t){this.authToken=t}directRequestInterceptor(t){return this.authToken&&t.headers.set("Authorization",`Bearer ${this.authToken}`),t}};v(Yo,"SwishClient");var ep=Yo;var na=Sa(ta(),1);var ia=r(e=>new na.default(async t=>{let n=[...new Set(t)].sort((s,o)=>s.localeCompare(o)),i=await e.items.list({query:n.join(" "),limit:200});if("error"in i){let s=new Error(i.error.message);return t.map(()=>s)}return t.map(s=>{let o=i.data.filter(a=>s===`variant:${a.variantId}`||s===`product:${a.productId}`);return{data:o,pageInfo:{next:null,previous:null,totalCount:o.length}}})},{batchScheduleFn:r(t=>setTimeout(t,50),"batchScheduleFn"),cache:!1,maxBatchSize:200}),"createItemsBatchLoader");var up=Object.defineProperty,g=r((e,t)=>up(e,"name",{value:t,configurable:!0}),"t"),dp={bodySerializer:g(e=>JSON.stringify(e,(t,n)=>typeof n=="bigint"?n.toString():n),"bodySerializer")},pp=g(({onRequest:e,onSseError:t,onSseEvent:n,responseTransformer:i,responseValidator:s,sseDefaultRetryDelay:o,sseMaxRetryAttempts:a,sseMaxRetryDelay:l,sseSleepFn:c,url:d,...u})=>{let p,h=c??(f=>new Promise(w=>setTimeout(w,f)));return{stream:g(async function*(){let f=o??3e3,w=0,y=u.signal??new AbortController().signal;for(;!y.aborted;){w++;let b=u.headers instanceof Headers?u.headers:new Headers(u.headers);p!==void 0&&b.set("Last-Event-ID",p);try{let S={redirect:"follow",...u,body:u.serializedBody,headers:b,signal:y},k=new Request(d,S);e&&(k=await e(d,S));let E=await(u.fetch??globalThis.fetch)(k);if(!E.ok)throw new Error(`SSE failed: ${E.status} ${E.statusText}`);if(!E.body)throw new Error("No body in SSE response");let R=E.body.pipeThrough(new TextDecoderStream).getReader(),x="",A=g(()=>{try{R.cancel()}catch{}},"abortHandler");y.addEventListener("abort",A);try{for(;;){let{done:P,value:F}=await R.read();if(P)break;x+=F,x=x.replace(/\r\n/g,`
264
273
  `).replace(/\r/g,`
265
- `);let ce=E.split(`
274
+ `);let N=x.split(`
266
275
 
267
- `);E=ce.pop()??"";for(let Ee of ce){let De=Ee.split(`
268
- `),te=[],ye;for(let V of De)if(V.startsWith("data:"))te.push(V.replace(/^data:\s*/,""));else if(V.startsWith("event:"))ye=V.replace(/^event:\s*/,"");else if(V.startsWith("id:"))p=V.replace(/^id:\s*/,"");else if(V.startsWith("retry:")){let Ce=Number.parseInt(V.replace(/^retry:\s*/,""),10);Number.isNaN(Ce)||(h=Ce)}let Y,qe=!1;if(te.length){let V=te.join(`
269
- `);try{Y=JSON.parse(V),qe=!0}catch{Y=V}}qe&&(s&&await s(Y),i&&(Y=await i(Y))),n?.({data:Y,event:ye,id:p,retry:h}),te.length&&(yield Y)}}}finally{m.removeEventListener("abort",A),D.releaseLock()}break}catch(S){if(t?.(S),a!==void 0&&w>=a)break;let k=Math.min(h*2**(w-1),l??3e4);await f(k)}}},"createStream")()}},"createSseClient"),Ld=g(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorArrayExplode"),Od=g(e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},"separatorArrayNoExplode"),_d=g(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorObjectExplode"),Fo=g(({allowReserved:e,explode:t,name:n,style:i,value:s})=>{if(!t){let l=(e?s:s.map(c=>encodeURIComponent(c))).join(Od(i));switch(i){case"label":return`.${l}`;case"matrix":return`;${n}=${l}`;case"simple":return l;default:return`${n}=${l}`}}let o=Ld(i),a=s.map(l=>i==="label"||i==="simple"?e?l:encodeURIComponent(l):Vn({allowReserved:e,name:n,value:l})).join(o);return i==="label"||i==="matrix"?o+a:a},"serializeArrayParam"),Vn=g(({allowReserved:e,name:t,value:n})=>{if(n==null)return"";if(typeof n=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?n:encodeURIComponent(n)}`},"serializePrimitiveParam"),jo=g(({allowReserved:e,explode:t,name:n,style:i,value:s,valueOnly:o})=>{if(s instanceof Date)return o?s.toISOString():`${n}=${s.toISOString()}`;if(i!=="deepObject"&&!t){let c=[];Object.entries(s).forEach(([u,p])=>{c=[...c,u,e?p:encodeURIComponent(p)]});let d=c.join(",");switch(i){case"form":return`${n}=${d}`;case"label":return`.${d}`;case"matrix":return`;${n}=${d}`;default:return d}}let a=_d(i),l=Object.entries(s).map(([c,d])=>Vn({allowReserved:e,name:i==="deepObject"?`${n}[${c}]`:c,value:d})).join(a);return i==="label"||i==="matrix"?a+l:l},"serializeObjectParam"),Md=/\{[^{}]+\}/g,qd=g(({path:e,url:t})=>{let n=t,i=t.match(Md);if(i)for(let s of i){let o=!1,a=s.substring(1,s.length-1),l="simple";a.endsWith("*")&&(o=!0,a=a.substring(0,a.length-1)),a.startsWith(".")?(a=a.substring(1),l="label"):a.startsWith(";")&&(a=a.substring(1),l="matrix");let c=e[a];if(c==null)continue;if(Array.isArray(c)){n=n.replace(s,Fo({explode:o,name:a,style:l,value:c}));continue}if(typeof c=="object"){n=n.replace(s,jo({explode:o,name:a,style:l,value:c,valueOnly:!0}));continue}if(l==="matrix"){n=n.replace(s,`;${Vn({name:a,value:c})}`);continue}let d=encodeURIComponent(l==="label"?`.${c}`:c);n=n.replace(s,d)}return n},"defaultPathSerializer"),Bd=g(({baseUrl:e,path:t,query:n,querySerializer:i,url:s})=>{let o=s.startsWith("/")?s:`/${s}`,a=(e??"")+o;t&&(a=qd({path:t,url:a}));let l=n?i(n):"";return l.startsWith("?")&&(l=l.substring(1)),l&&(a+=`?${l}`),a},"getUrl");function Zi(e){let t=e.body!==void 0;if(t&&e.bodySerializer)return"serializedBody"in e?e.serializedBody!==void 0&&e.serializedBody!==""?e.serializedBody:null:e.body!==""?e.body:null;if(t)return e.body}r(Zi,"N");g(Zi,"getValidRequestBody");var Fd=g(async(e,t)=>{let n=typeof t=="function"?await t(e):t;if(n)return e.scheme==="bearer"?`Bearer ${n}`:e.scheme==="basic"?`Basic ${btoa(n)}`:n},"getAuthToken"),No=g(({parameters:e={},...t}={})=>g(n=>{let i=[];if(n&&typeof n=="object")for(let s in n){let o=n[s];if(o==null)continue;let a=e[s]||t;if(Array.isArray(o)){let l=Fo({allowReserved:a.allowReserved,explode:!0,name:s,style:"form",value:o,...a.array});l&&i.push(l)}else if(typeof o=="object"){let l=jo({allowReserved:a.allowReserved,explode:!0,name:s,style:"deepObject",value:o,...a.object});l&&i.push(l)}else{let l=Vn({allowReserved:a.allowReserved,name:s,value:o});l&&i.push(l)}}return i.join("&")},"querySerializer"),"createQuerySerializer"),jd=g(e=>{var t;if(!e)return"stream";let n=(t=e.split(";")[0])==null?void 0:t.trim();if(n){if(n.startsWith("application/json")||n.endsWith("+json"))return"json";if(n==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some(i=>n.startsWith(i)))return"blob";if(n.startsWith("text/"))return"text"}},"getParseAs"),Nd=g((e,t)=>{var n,i;return t?!!(e.headers.has(t)||(n=e.query)!=null&&n[t]||(i=e.headers.get("Cookie"))!=null&&i.includes(`${t}=`)):!1},"checkForExistence"),Ud=g(async({security:e,...t})=>{for(let n of e){if(Nd(t,n.name))continue;let i=await Fd(n,t.auth);if(!i)continue;let s=n.name??"Authorization";switch(n.in){case"query":t.query||(t.query={}),t.query[s]=i;break;case"cookie":t.headers.append("Cookie",`${s}=${i}`);break;default:t.headers.set(s,i);break}}},"setAuthParams"),qo=g(e=>Bd({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:No(e.querySerializer),url:e.url}),"buildUrl"),Bo=g((e,t)=>{var n;let i={...e,...t};return(n=i.baseUrl)!=null&&n.endsWith("/")&&(i.baseUrl=i.baseUrl.substring(0,i.baseUrl.length-1)),i.headers=Uo(e.headers,t.headers),i},"mergeConfigs"),Vd=g(e=>{let t=[];return e.forEach((n,i)=>{t.push([i,n])}),t},"headersEntries"),Uo=g((...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let i=n instanceof Headers?Vd(n):Object.entries(n);for(let[s,o]of i)if(o===null)t.delete(s);else if(Array.isArray(o))for(let a of o)t.append(s,a);else o!==void 0&&t.set(s,typeof o=="object"?JSON.stringify(o):o)}return t},"mergeHeaders"),Vo=class{static{r(this,"j")}constructor(){this.fns=[]}clear(){this.fns=[]}eject(t){let n=this.getInterceptorIndex(t);this.fns[n]&&(this.fns[n]=null)}exists(t){let n=this.getInterceptorIndex(t);return!!this.fns[n]}getInterceptorIndex(t){return typeof t=="number"?this.fns[t]?t:-1:this.fns.indexOf(t)}update(t,n){let i=this.getInterceptorIndex(t);return this.fns[i]?(this.fns[i]=n,t):!1}use(t){return this.fns.push(t),this.fns.length-1}};g(Vo,"Interceptors");var Yi=Vo,$d=g(()=>({error:new Yi,request:new Yi,response:new Yi}),"createInterceptors"),Hd=No({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),Qd={"Content-Type":"application/json"},es=g((e={})=>({...Td,headers:Qd,parseAs:"auto",querySerializer:Hd,...e}),"createConfig"),$o=g((e={})=>{let t=Bo(es(),e),n=g(()=>({...t}),"getConfig"),i=g(d=>(t=Bo(t,d),n()),"setConfig"),s=$d(),o=g(async d=>{let u={...t,...d,fetch:d.fetch??t.fetch??globalThis.fetch,headers:Uo(t.headers,d.headers),serializedBody:void 0};u.security&&await Ud({...u,security:u.security}),u.requestValidator&&await u.requestValidator(u),u.body!==void 0&&u.bodySerializer&&(u.serializedBody=u.bodySerializer(u.body)),(u.body===void 0||u.serializedBody==="")&&u.headers.delete("Content-Type");let p=qo(u);return{opts:u,url:p}},"beforeRequest"),a=g(async d=>{let{opts:u,url:p}=await o(d),f={redirect:"follow",...u,body:Zi(u)},h=new Request(p,f);for(let E of s.request.fns)E&&(h=await E(h,u));let w=u.fetch,m;try{m=await w(h)}catch(E){let A=E;for(let C of s.error.fns)C&&(A=await C(E,void 0,h,u));if(A=A||{},u.throwOnError)throw A;return u.responseStyle==="data"?void 0:{error:A,request:h,response:void 0}}for(let E of s.response.fns)E&&(m=await E(m,h,u));let b={request:h,response:m};if(m.ok){let E=(u.parseAs==="auto"?jd(m.headers.get("Content-Type")):u.parseAs)??"json";if(m.status===204||m.headers.get("Content-Length")==="0"){let C;switch(E){case"arrayBuffer":case"blob":case"text":C=await m[E]();break;case"formData":C=new FormData;break;case"stream":C=m.body;break;default:C={};break}return u.responseStyle==="data"?C:{data:C,...b}}let A;switch(E){case"arrayBuffer":case"blob":case"formData":case"text":A=await m[E]();break;case"json":{let C=await m.text();A=C?JSON.parse(C):{};break}case"stream":return u.responseStyle==="data"?m.body:{data:m.body,...b}}return E==="json"&&(u.responseValidator&&await u.responseValidator(A),u.responseTransformer&&(A=await u.responseTransformer(A))),u.responseStyle==="data"?A:{data:A,...b}}let S=await m.text(),k;try{k=JSON.parse(S)}catch{}let P=k??S,D=P;for(let E of s.error.fns)E&&(D=await E(P,m,h,u));if(D=D||{},u.throwOnError)throw D;return u.responseStyle==="data"?void 0:{error:D,...b}},"request"),l=g(d=>u=>a({...u,method:d}),"makeMethodFn"),c=g(d=>async u=>{let{opts:p,url:f}=await o(u);return Dd({...p,body:p.body,headers:p.headers,method:d,onRequest:g(async(h,w)=>{let m=new Request(h,w);for(let b of s.request.fns)b&&(m=await b(m,p));return m},"onRequest"),serializedBody:Zi(p),url:f})},"makeSseFn");return{buildUrl:qo,connect:l("CONNECT"),delete:l("DELETE"),get:l("GET"),getConfig:n,head:l("HEAD"),interceptors:s,options:l("OPTIONS"),patch:l("PATCH"),post:l("POST"),put:l("PUT"),request:a,setConfig:i,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:l("TRACE")}},"createClient"),O=$o(es({baseUrl:"https://swish.app/api/2026-04"})),zd=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/lists",...e}),"listControllerFind"),Gd=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerCreate"),Wd=g(e=>(e.client??O).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e}),"listControllerDeleteById"),Kd=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e}),"listControllerFindById"),Xd=g(e=>(e.client??O).patch({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerUpdateById"),Jd=g(e=>(e.client??O).put({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/order",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerSetListItemsOrder"),Yd=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerAddItemsToList"),Zd=g(e=>(e.client??O).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/{itemId}",...e}),"listControllerRemoveItemFromList"),ep=g(e=>(e.client??O).delete({security:[{scheme:"bearer",type:"http"}],url:"/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerDelete"),tp=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/items",...e}),"itemControllerFind"),np=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerCreate"),ip=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/items/count",...e}),"itemControllerCount"),sp=g(e=>(e.client??O).delete({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e}),"itemControllerDeleteById"),rp=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e}),"itemControllerFindById"),op=g(e=>(e.client??O).patch({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerUpdateById"),ap=g(e=>(e.client??O).put({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerSetListsById"),lp=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/identify",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerIdentify"),cp=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/token",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerCreateToken"),up=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/profiles",...e}),"profileControllerGetProfile"),dp=g(e=>(e.client??O).patch({security:[{scheme:"bearer",type:"http"}],url:"/profiles/profile",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerUpdateProfile"),pp=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/saved-items",...e}),"analyticsControllerLoadSavedItems"),hp=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/sessions",...e}),"analyticsControllerLoadSessions"),fp=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/new-lists",...e}),"analyticsControllerLoadNewLists"),mp=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/collect",...e,headers:{"Content-Type":"application/json",...e.headers}}),"trackingControllerCollect"),yp=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/orders",...e}),"ordersControllerFind"),vp=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/orders/{orderId}",...e}),"ordersControllerFindOne"),gp=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists",...e}),"sharedListsControllerFindAll"),wp=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"sharedListsControllerSave"),bp=g(e=>(e.client??O).delete({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}",...e}),"sharedListsControllerDeleteById"),Ip=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}",...e}),"sharedListsControllerFindById"),Sp=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}/items",...e}),"sharedListsControllerFindItems"),xp=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/notifications",...e}),"notificationsControllerFind"),Ep=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/notifications/unread/count",...e}),"notificationsControllerGetUnreadCount"),Cp=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/notifications/read",...e,headers:{"Content-Type":"application/json",...e.headers}}),"notificationsControllerMarkAsRead"),Rp=g(e=>(e?.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/notifications/read/all",...e}),"notificationsControllerMarkAllAsRead"),kp=g(e=>(e.client??O).delete({security:[{scheme:"bearer",type:"http"}],url:"/notifications/{id}",...e}),"notificationsControllerDeleteById"),Ap=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions",...e}),"subscriptionsControllerFind"),Pp=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions",...e,headers:{"Content-Type":"application/json",...e.headers}}),"subscriptionsControllerCreate"),Tp=g(e=>(e.client??O).delete({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e}),"subscriptionsControllerDelete"),Dp=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e}),"subscriptionsControllerFindById"),Lp=g(e=>(e.client??O).patch({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"subscriptionsControllerUpdate"),Op=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists",...e}),"smartListsControllerFindAll"),_p=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists/{smartListId}",...e}),"smartListsControllerFindById"),Mp=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists/{smartListId}/items",...e}),"smartListsControllerFindItems"),ts="2026-04",pS=g(e=>new qp(e),"createApiClient"),Ho=class{static{r(this,"xe")}constructor(t){this.version=ts,this.items={list:g(n=>this.handlePaginatedRequest(tp({query:n,client:this.client})),"list"),create:g(n=>this.handleRequest(np({body:n,client:this.client})),"create"),delete:g(n=>this.handleRequest(ep({body:{itemIds:n},client:this.client})),"delete"),findById:g(n=>this.handleRequest(rp({path:{itemId:n},client:this.client})),"findById"),updateById:g((n,i)=>this.handleRequest(op({body:i,path:{itemId:n},client:this.client})),"updateById"),deleteById:g(n=>this.handleRequest(sp({path:{itemId:n},client:this.client})),"deleteById"),setListsById:g((n,i)=>this.handleRequest(ap({body:{listIds:i},path:{itemId:n},client:this.client})),"setListsById"),count:g(()=>this.handleRequest(ip({client:this.client})),"count")},this.lists={list:g(n=>this.handlePaginatedRequest(zd({query:n,client:this.client})),"list"),create:g(n=>this.handleRequest(Gd({body:n,client:this.client})),"create"),findById:g(n=>this.handleRequest(Kd({path:{listId:n},client:this.client})),"findById"),updateById:g((n,i)=>this.handleRequest(Xd({body:i,path:{listId:n},client:this.client})),"updateById"),deleteById:g(n=>this.handleRequest(Wd({path:{listId:n},client:this.client})),"deleteById"),orderItems:g((n,i)=>this.handleRequest(Jd({body:{itemIds:i},path:{listId:n},client:this.client})),"orderItems"),addItemsToList:g((n,i)=>this.handleRequest(Yd({body:{itemIds:i},path:{listId:n},client:this.client})),"addItemsToList"),removeItemFromList:g((n,i)=>this.handleRequest(Zd({path:{listId:n,itemId:i},client:this.client})),"removeItemFromList")},this.profiles={createToken:g((n={})=>this.handleRequest(cp({body:n,client:this.client})),"createToken"),identify:g(n=>this.handleRequest(lp({body:n,client:this.client})),"identify"),getProfile:g(()=>this.handleRequest(up({client:this.client})),"getProfile"),updateProfile:g(n=>this.handleRequest(dp({body:n,client:this.client})),"updateProfile")},this.orders={list:g(n=>this.handlePaginatedRequest(yp({query:n,client:this.client})),"list"),findById:g(n=>this.handleRequest(vp({path:{orderId:n},client:this.client})),"findById")},this.sharedLists={list:g(n=>this.handlePaginatedRequest(gp({query:n,client:this.client})),"list"),save:g(n=>this.handleRequest(wp({body:{listId:n},client:this.client})),"save"),findById:g(n=>this.handleRequest(Ip({path:{sharedListId:n},client:this.client})),"findById"),deleteById:g(n=>this.handleRequest(bp({path:{sharedListId:n},client:this.client})),"deleteById"),findItems:g((n,i)=>this.handlePaginatedRequest(Sp({path:{sharedListId:n},query:i,client:this.client})),"findItems")},this.analytics={savedItems:g(n=>this.handleRequest(pp({query:n,client:this.client})),"savedItems"),sessions:g(n=>this.handleRequest(hp({query:n,client:this.client})),"sessions"),newLists:g(n=>this.handleRequest(fp({query:n,client:this.client})),"newLists")},this.tracking={track:g(n=>this.handleRequest(mp({body:n,client:this.client})),"track")},this.notifications={list:g(n=>this.handlePaginatedRequest(xp({query:n,client:this.client})),"list"),getUnreadCount:g(()=>this.handleRequest(Ep({client:this.client})),"getUnreadCount"),markAsRead:g(n=>this.handleRequest(Cp({body:{notificationIds:n},client:this.client})),"markAsRead"),markAllAsRead:g(()=>this.handleRequest(Rp({client:this.client})),"markAllAsRead"),deleteById:g(n=>this.handleRequest(kp({path:{id:n},client:this.client})),"deleteById")},this.subscriptions={list:g(n=>this.handlePaginatedRequest(Ap({query:n,client:this.client})),"list"),create:g(n=>this.handleRequest(Pp({body:n,client:this.client})),"create"),findById:g(n=>this.handleRequest(Dp({path:{id:n},client:this.client})),"findById"),updateById:g((n,i)=>this.handleRequest(Lp({body:i,path:{id:n},client:this.client})),"updateById"),deleteById:g(n=>this.handleRequest(Tp({path:{id:n},client:this.client})),"deleteById")},this.smartLists={list:g(()=>this.handleRequest(Op({client:this.client})),"list"),findById:g(n=>this.handleRequest(_p({path:{smartListId:n},client:this.client})),"findById"),findItems:g((n,i)=>this.handlePaginatedRequest(Mp({path:{smartListId:n},query:i,client:this.client})),"findItems")},this.handleRequest=g(async n=>{let{data:i,error:s}=await n;return s!=null&&s.error?{error:s.error}:{data:i?.data}},"handleRequest"),this.handlePaginatedRequest=g(async n=>{var i;let{data:s,error:o}=await n;return o!=null&&o.error?{error:o.error}:{data:s?.data??[],pageInfo:s?.pageInfo??{next:null,previous:null,totalCount:((i=s?.data)==null?void 0:i.length)??0}}},"handlePaginatedRequest"),this.client=$o(es({baseUrl:`https://swish.app/api/${this.version}`,...t.config})),t.authToken&&(this.authToken=t.authToken),t.requestInterceptor&&this.client.interceptors.request.use(t.requestInterceptor),t.responseInterceptor&&this.client.interceptors.response.use(t.responseInterceptor),this.client.interceptors.request.use(this.directRequestInterceptor.bind(this))}setAuthToken(t){this.authToken=t}directRequestInterceptor(t){return this.authToken&&t.headers.set("Authorization",`Bearer ${this.authToken}`),t}};g(Ho,"SwishClient");var qp=Ho;var $n=class{constructor(t,n,i,s){this.tokenHasProfile=!1;this.api=t,this.context=n,this.eventBus=i,this.tokenUrl=s}static{r(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()=>{let t=this.getSwishToken();this.migrateLegacySession();let n=this.context.customer.id;n?(this.hasSessionToken()&&(this.eventBus.publish("auth-cache-clear",null),await this.api.clearCache()),await this.initCustomer(n)):(this.hasCustomerToken()&&await this.resetSession(),await this.initSession());let i=this.getSwishToken();i&&i!==t&&this.eventBus.publish("token-update",null)})(),this._initPromise)}async initCustomer(t){let n=`gid://shopify/Customer/${t}`,i=this.getTokenBySub(n);if(i){this.initToken(i);return}let s=this.getSessionId();await this.acquireToken(s,n)}async initSession(){let t=this.getSessionId(),n=t?this.getTokenBySub(t):null;if(n){this.initToken(n);return}await this.acquireToken(t)}initToken(t){let n=this.getTokenData(t);if(!n)throw new Error("Invalid Swish token.");this.tokenHasProfile=n.has_profile!==!1,this.api.setAuthToken(t)}async acquireToken(t,n){let i={};n&&(i.customer=n),t&&(i.session=t);let s=await fetch(this.tokenUrl,{method:"POST",headers:{"Content-Type":"application/json","Swish-Api-Version":ts},body:JSON.stringify(i)});if(!s.ok)throw console.error("Failed to create customer token",s.status),new Error("Failed to create customer token");let a=(await s.json()).data;if(!a?.token)throw console.error("Failed to create customer token empty response"),new Error("Failed to create customer token");a.profile.startsWith("gid://swish/Session/")&&this.setSessionId(a.profile),this.setSwishToken(a.token),this.initToken(a.token)}async resetSession(){this.deleteSessionId(),this.deleteSwishToken(),await this.api.clearCache(),this.eventBus.publish("auth-cache-clear",null)}getTokenData(t){try{return JSON.parse(atob(t.split(".")[1]))}catch(n){return console.error("Failed to parse Swish token",{cause:n}),null}}willTokenExpire(t,n=60){let i=this.getTokenData(t);return!!(i&&i.exp&&i.exp<Date.now()/1e3+n)}hasCustomerToken(){let t=this.getSwishToken();return t?this.getTokenData(t)?.sub?.startsWith("gid://shopify/Customer/")??!1:!1}hasSessionToken(){let t=this.getSwishToken();return t?this.getTokenData(t)?.sub?.startsWith("gid://swish/Session/")??!1:!1}getTokenBySub(t){if(!t)return null;let n=this.getSwishToken();if(!n)return null;let i=this.getTokenData(n);return!i||i.sub!==t||this.willTokenExpire(n,60)?null:n}getSessionId(){let t=me(this.context.myshopifyDomain);return localStorage.getItem(`swish-session-${t}`)??void 0}setSessionId(t){let n=me(this.context.myshopifyDomain);localStorage.setItem(`swish-session-${n}`,t)}deleteSessionId(){let t=me(this.context.myshopifyDomain);localStorage.removeItem(`swish-session-${t}`)}getSwishToken(){let t=me(this.context.myshopifyDomain);return sessionStorage.getItem(`swish-token-${t}`)??void 0}setSwishToken(t){let n=me(this.context.myshopifyDomain);sessionStorage.setItem(`swish-token-${n}`,t)}deleteSwishToken(){let t=me(this.context.myshopifyDomain);sessionStorage.removeItem(`swish-token-${t}`)}migrateLegacySession(){try{let t=localStorage.getItem("wk_session_id")??localStorage.getItem("swish-profile")?.split("/").pop()??localStorage.getItem("swish-session")?.split("/").pop();t&&(this.setSessionId(`gid://swish/Session/${t}`),localStorage.removeItem("wk_session_id"),localStorage.removeItem("swish-profile"),localStorage.removeItem("swish-session"))}catch(t){console.warn("Failed to migrate legacy session id to Swish session",{cause:t})}}};var Hn=class{static{r(this,"SwishApi")}constructor(t,n,i,s,o){this.config=t,this.storefrontContext=n;let a=me(n.myshopifyDomain);this.cache=new Oe(`swish-api-${a}`,"max-age=60, stale-while-revalidate=3600",s+Wi),this.cache.cleanupExpiredEntries().catch(c=>{console.warn("Swish API cache initialization cleanup error:",c)}),this.auth=new $n(this,n,i,o);let l={authToken:this.auth.getSwishToken(),config:{...t,fetch:this.fetchFunction.bind(this)},requestInterceptor:this.requestInterceptor.bind(this),responseInterceptor:this.responseInterceptor.bind(this)};this.apiClient=Po(l),this.itemsLoader=Mo(this)}async fetchFunction(t,n){let i=t instanceof Request?t.method:n?.method??"GET",s=t instanceof Request?t.url:typeof t=="string"?t:t.toString();if(s.includes("/smart-lists"))return fetch(t,n);let a=s.includes("/orders"),l=s.includes("/profiles");return i==="GET"&&!a&&!l?this.cache.fetchWithCache(t,n):fetch(t,n)}async requestInterceptor(t){await this.initAuth();try{t.headers.set("Market-Context-Type","country"),t.headers.set("Market-Context-Value",this.storefrontContext.localization.country),t.headers.set("Country",this.storefrontContext.localization.country),t.headers.set("Language",this.storefrontContext.localization.language),t.headers.set("Market",this.storefrontContext.localization.market)}catch(n){console.warn("Failed to set storefront context headers:",n)}return this.config.requestInterceptor&&(t=await this.config.requestInterceptor(t)),t}async responseInterceptor(t,n){let i=n.method!=="GET",s=n.url.includes("/profiles/token");if(i&&!s){let o=this.auth.hasToken(),a=!this.auth.hasProfile(),l=t.ok;await this.cache.clear(),o&&a&&l&&await this.auth.renewToken()}return await this.config.responseInterceptor?.(t,n),t}setAuthToken(t){this.apiClient.setAuthToken(t)}initAuth(){return this.auth.init()}async withFallback(t,n){return await this.initAuth(),this.auth.hasProfile()?t():Promise.resolve(n)}async withSignedInCustomerFallback(t,n){return await this.initAuth(),!!this.storefrontContext.customer.id&&this.auth.hasProfile()?t():Promise.resolve(n)}get items(){return{...this.apiClient.items,count:r(async()=>this.withFallback(()=>this.apiClient.items.count(),{data:{count:0}}),"count"),list:r(async(t,n)=>{let i=r(()=>{if(n?.batch&&t?.query){let s=t.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(t)},"execute");return n?.shared?i():this.withFallback(i,{data:[],pageInfo:{next:null,previous:null,totalCount:0}})},"list"),findById:r(async t=>this.withFallback(()=>this.apiClient.items.findById(t),{data:null}),"findById")}}get lists(){return{...this.apiClient.lists,list:r(async t=>this.withFallback(()=>this.apiClient.lists.list(t),{data:[],pageInfo:{next:null,previous:null,totalCount:0}}),"list"),findById:r(async(t,n)=>{let i=r(()=>this.apiClient.lists.findById(t),"execute");return n?.shared?i():this.withFallback(()=>this.apiClient.lists.findById(t),{data:null})},"findById")}}get orders(){return{...this.apiClient.orders,list:r(async t=>this.withFallback(()=>this.apiClient.orders.list(t),{data:[],pageInfo:{next:null,previous:null,totalCount:0}}),"list"),findById:r(async t=>this.withFallback(()=>(typeof t=="string"&&(t=parseInt(t.split("/").pop()??t)),this.apiClient.orders.findById(t)),{data:null}),"findById")}}get notifications(){return{...this.apiClient.notifications,list:r(async t=>this.withSignedInCustomerFallback(()=>this.apiClient.notifications.list(t),{data:[],pageInfo:{next:null,previous:null,totalCount:0}}),"list"),getUnreadCount:r(async()=>this.withSignedInCustomerFallback(()=>this.apiClient.notifications.getUnreadCount(),{data:{count:0}}),"getUnreadCount"),markAsRead:r(t=>this.apiClient.notifications.markAsRead(t),"markAsRead"),markAllAsRead:r(()=>this.apiClient.notifications.markAllAsRead(),"markAllAsRead"),deleteById:r(t=>this.apiClient.notifications.deleteById(t),"deleteById")}}get smartLists(){return{...this.apiClient.smartLists,list:r(async()=>this.withFallback(()=>this.apiClient.smartLists.list(),{data:null}),"list"),findById:r(async t=>t==="recently-viewed"?this.apiClient.smartLists.findById(t):this.withFallback(()=>this.apiClient.smartLists.findById(t),{data:null}),"findById"),findItems:r(async(t,n)=>t==="recently-viewed"?this.apiClient.smartLists.findItems(t,n):this.withFallback(()=>this.apiClient.smartLists.findItems(t,n),{data:[],pageInfo:{next:null,previous:null,totalCount:0}}),"findItems")}}get profiles(){return{...this.apiClient.profiles,getProfile:r(async()=>this.withSignedInCustomerFallback(()=>this.apiClient.profiles.getProfile(),{data:null}),"getProfile"),updateProfile:r(async t=>this.apiClient.profiles.updateProfile(t),"updateProfile")}}async clearCache(){await this.cache.clear()}};var Qn=class{constructor(t){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","POST /notifications\\/read\\/all\\/?$":"notification-update","POST /notifications\\/read\\/?$":"notification-update","PATCH /notifications\\/([^/]+)\\/?$":"notification-update","DELETE /notifications\\/([^/]+)\\/?$":"notification-delete"};this.eventBus=t,this.processFetchResponse=this.processFetchResponse.bind(this)}static{r(this,"SwishApiPublisher")}async processFetchResponse(t,n){try{let i=this.getEventName(n.method,t.status,n.url);if(!i)return;let s=await t.clone().text();if(t.headers.get("Content-Type")?.includes("application/json"))try{s=JSON.parse(s).data}catch(o){console.warn(o)}this.eventBus.publish(i,s)}catch(i){console.warn(i)}}getEventName(t,n,i){t=t.toUpperCase();let s=new URL(i).pathname;return t==="GET"||n<200||n>=300?void 0:Object.entries(this.eventMap).find(([a])=>{let[l,c]=a.split(" ");return l!==t?!1:new RegExp(c).test(s)})?.[1]}};var zn=class{constructor(t){this.inflightModals=new Map;this.modalsWithScrollLock=new Set;this.scrollLockRefCount=0;this.scrollPositionBeforeLock=0;this.elementId=0;this._templatePromises=new Map;this._importPromises=new Map;this._lockScroll=r(()=>this.lockScroll(),"_lockScroll");this._unlockScroll=r(()=>this.unlockScroll(),"_unlockScroll");this.swishApp=t}static{r(this,"SwishUi")}async showModal(t){if(this.inflightModals.has(t))return this.inflightModals.get(t);let n=(async()=>{typeof t=="string"&&(t=await this.requireUiComponent(t)),!(!t||t.getAttribute("open")==="true")&&(this.lockScroll(),this.modalsWithScrollLock.add(t),t.setAttribute("open","true"))})().finally(()=>{this.inflightModals.delete(t)});return this.inflightModals.set(t,n),n}async hideModal(t){if(this.inflightModals.has(t))return this.inflightModals.get(t);let n=(async()=>{try{if(typeof t=="string"&&(t=await this.requireUiComponent(t)),t?.getAttribute("open")!=="true")return;t.setAttribute("open","false"),t.hasAttribute("swish-singleton")||t.addEventListener("closed",()=>{t.remove()},{once:!0})}finally{t&&typeof t!="string"&&this.modalsWithScrollLock.has(t)&&(this.modalsWithScrollLock.delete(t),this.unlockScroll())}})().finally(()=>{this.inflightModals.delete(t)});return this.inflightModals.set(t,n),n}waitForEvent(t,n){return new Promise(i=>{let s=[],o=r(()=>{s.forEach(({event:a,listener:l})=>{t.removeEventListener(a,l)})},"cleanup");Object.entries(n).forEach(([a,l])=>{let c=r(d=>{let u=l(d);o(),i(u)},"listener");s.push({event:a,listener:c}),t.addEventListener(a,c)})})}async showSignIn(t){let n=await this.requireUiComponent("sign-in");n.setAttribute("return-to",t?.returnTo??window.location.pathname),await this.showModal(n);let i=await this.waitForEvent(n,{submit:r(()=>({code:"ok",data:void 0}),"submit"),close:r(()=>({code:"closed"}),"close")});return await this.hideModal(n),i}async showUnsaveAlert(t){if(!t.itemId)throw new Error("An itemId is required to show the unsave alert");await this.hideAllToasts();let n=await this.requireUiComponent("unsave-alert");n.setAttribute("item-id",t.itemId),await this.showModal(n);let i=await this.waitForEvent(n,{submit:r(s=>s instanceof CustomEvent?{code:"ok",data:s.detail}:(console.warn("Unsave alert submitted without detail",s),{code:"closed"}),"submit"),close:r(()=>({code:"closed"}),"close")});return await this.hideModal(n),i}async showDeleteListAlert(t){if(!t.listId)throw new Error("A listId is required to show the delete list alert");await this.hideAllToasts();let n=await this.requireUiComponent("delete-list-alert");n.setAttribute("list-id",t.listId),await this.showModal(n);let i=await this.waitForEvent(n,{submit:r(()=>({code:"ok",data:void 0}),"submit"),close:r(()=>({code:"closed"}),"close")});return await this.hideModal(n),i}async showConfirmDialog(t){await this.hideAllToasts();let n=await this.requireUiComponent("confirm-dialog");t.titleKey?n.setAttribute("title-key",t.titleKey):n.removeAttribute("title-key"),t.descriptionKey?n.setAttribute("description-key",t.descriptionKey):n.removeAttribute("description-key"),t.confirmLabelKey?n.setAttribute("confirm-label-key",t.confirmLabelKey):n.removeAttribute("confirm-label-key"),t.cancelLabelKey?n.setAttribute("cancel-label-key",t.cancelLabelKey):n.removeAttribute("cancel-label-key"),t.danger?n.setAttribute("danger",""):n.removeAttribute("danger"),await this.showModal(n);let i=await this.waitForEvent(n,{submit:r(()=>({code:"ok",data:void 0}),"submit"),close:r(()=>({code:"closed"}),"close")});return await this.hideModal(n),i}async showDrawer(t){await this.hideAllToasts();let n=await this.requireUiComponent("drawer",{singleInstance:!0});n.setAttribute("account-url",this.swishApp.storefrontContext.routes.accountUrl),this.swishApp.storefrontContext.customer.id&&n.setAttribute("customer-id",this.swishApp.storefrontContext.customer.id),n.setAttribute("view",t?.view??"home"),t?.listId&&n.setAttribute("list-id",t.listId),t?.listType&&n.setAttribute("list-type",t.listType),t?.productId&&n.setAttribute("product-id",t.productId),t?.variantId&&n.setAttribute("variant-id",t.variantId),t?.orderId&&n.setAttribute("order-id",t.orderId),await this.showModal(n);let i=await this.waitForEvent(n,{close:r(()=>({code:"closed"}),"close")});return await this.hideModal(n),i}async showListMenu(t){if(!t.listId)throw new Error("listId is required");await this.hideAllToasts();let n=await this.requireUiComponent("list-menu");n.setAttribute("list-id",t.listId),await this.showModal(n);let i=await this.waitForEvent(n,{close:r(()=>({code:"closed"}),"close"),edit:r(s=>s instanceof CustomEvent?{code:"ok",data:{action:"edit",data:s.detail}}:(console.warn("List menu edit without detail",s),{code:"closed"}),"edit"),delete:r(()=>({code:"ok",data:{action:"delete"}}),"delete"),"add-items":r(()=>({code:"ok",data:{action:"add-items"}}),"add-items"),share:r(()=>({code:"ok",data:{action:"share"}}),"share"),"edit-access":r(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(n),i}async showOrderMenu(t){if(!t.orderId)throw new Error("orderId is required");await this.hideAllToasts();let n=await this.requireUiComponent("order-menu");n.setAttribute("order-id",t.orderId),await this.showModal(n);let i=await this.waitForEvent(n,{close:r(()=>({code:"closed"}),"close")});return await this.hideModal(n),i}async showListDetailPageMenu(t){await this.hideAllToasts();let n=await this.requireUiComponent("list-detail-page-menu");n.setAttribute("list-id",t.listId),await this.showModal(n);let i=await this.waitForEvent(n,{close:r(()=>({code:"closed"}),"close")});return await this.hideModal(n),i}async showListSelect(t){if(!t.itemId)throw new Error("itemId is required");await this.hideAllToasts();let n=await this.requireUiComponent("list-select");n.setAttribute("item-id",t.itemId),await this.showModal(n);let i=await this.waitForEvent(n,{close:r(()=>({code:"closed"}),"close"),submit:r(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:r(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(n),i}async initListDetailPage(t,n){let i=await this.requireUiComponent("list-detail-page",{refElement:n});t.listId&&i.setAttribute("list-id",t.listId)}async showToast(t){let n=Date.now(),i=await this.requireUiComponent("toast-manager",{singleInstance:!0,onHydrated:r(s=>{s.current.show(t,n)},"onHydrated")});return this.waitForEvent(i,{[`close-${n}`]:()=>({code:"closed"}),[`submit-${n}`]:()=>({code:"ok",data:void 0})})}async hideAllToasts(){this.queryComponent("toast-manager")&&await this.requireUiComponent("toast-manager",{singleInstance:!0,onHydrated:r(t=>{t.current.clear()},"onHydrated")})}async showVariantSelect(t){await this.hideAllToasts();let n=await this.requireUiComponent("variant-select");if(t?.itemId&&n.setAttribute("item-id",t.itemId),t?.productId)n.setAttribute("product-id",t.productId.toString());else if(t?.productHandle)n.setAttribute("product-handle",t.productHandle);else throw new Error("Either productId or productHandle must be provided");t?.variantId&&n.setAttribute("variant-id",t.variantId.toString()),await this.showModal(n);let i=await this.waitForEvent(n,{close:r(()=>({code:"closed"}),"close"),submit:r(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(n),i}async showQuickBuy(t){await this.hideAllToasts();let n=await this.requireUiComponent("quick-buy");if(t?.productId)n.setAttribute("product-id",t.productId.toString());else if(t?.productHandle)n.setAttribute("product-handle",t.productHandle);else throw new Error("ProductId or productHandle must be provided");t?.variantId&&n.setAttribute("variant-id",t.variantId.toString()),await this.showModal(n);let i=await this.waitForEvent(n,{close:r(()=>({code:"closed"}),"close"),submit:r(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(n),i}async showListEditor(t){let n=await this.requireUiComponent("list-editor");t?.listId&&n.setAttribute("list-id",t.listId),await this.showModal(n);let i=await this.waitForEvent(n,{close:r(()=>({code:"closed"}),"close"),submit:r(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(n),i}async createElement(t,n){let[i,{themeVariablesStylesheet:s}]=await Promise.all([this.loadTemplate(t),this.loadCricalResources()]),o=document.createElement("template");o.innerHTML=i.replace(' shadowrootmode="open"',"");let a=o.content.firstElementChild;return a.addEventListener("connected",()=>{a.shadowRoot&&(a.shadowRoot.adoptedStyleSheets=[s],this.hydrateElement(t,a,n?.onHydrated))},{once:!0}),a}async hydrateElement(t,n,i){if(n.hasAttribute("hydrated")){i?.(n.getComponentRef());return}await Promise.all([this.loadNonCriticalResources(),this.loadLocale(),this.importScript(t)]).then(([{bundleCssStylesheet:s,customCssStylesheets:o},,{hydrate:a}])=>{n.shadowRoot&&s&&(n.shadowRoot.adoptedStyleSheets=[...n.shadowRoot.adoptedStyleSheets,...o,s],n.shadowRoot?.querySelector(":host > style")?.remove()),a(n),n.setAttribute("hydrated","")}),i?.(n.getComponentRef())}async requireUiComponent(t,n){this.loadCricalResources();let i=await this.loadTemplate(t),s=await this.insertComponent({name:t,template:i,refElement:n?.refElement??document.body,position:"beforeend",singleInstance:n?.singleInstance??!1});return s.shadowRoot&&!s.hasAttribute("hydrated")?Promise.all([this.loadNonCriticalResources(),this.loadLocale(),this.importScript(t)]).then(([{bundleCssStylesheet:o,customCssStylesheets:a},,{hydrate:l}])=>{s.shadowRoot&&o&&(s.shadowRoot.adoptedStyleSheets=[...s.shadowRoot.adoptedStyleSheets,...a,o],s.shadowRoot?.querySelector(":host > style")?.remove()),l(s),s.setAttribute("hydrated",""),n?.onHydrated?.(s.getComponentRef())}):s.hasAttribute("hydrated")&&n?.onHydrated?.(s.getComponentRef()),s}async loadTemplate(t){let n=`${this.swishApp.options.ui.baseUrl}/ui@${Te}/${t}.html`;if(this._templatePromises.has(n))return this._templatePromises.get(n);let i=fetch(n).then(s=>s.text());return this._templatePromises.set(n,i),i}async importScript(t){let n=`${this.swishApp.options.ui.baseUrl}/ui@${Te}/${t}.js`;if(this._importPromises.has(n))return this._importPromises.get(n);let i=import(n);return this._importPromises.set(n,i),i}async loadLocale(){if(this._loadLocalePromise)return this._loadLocalePromise;let t=this.swishApp.storefrontContext.localization.language.toLowerCase();return this._loadLocalePromise=this.swishApp.i18n.loadLocale(t),this._loadLocalePromise}async loadCricalResources(){return this._loadCricalResourcesPromise?this._loadCricalResourcesPromise:(this._loadCricalResourcesPromise=(async()=>{let t=`${this.swishApp.options.ui.baseUrl}/ui@${Te}/theme.css`,n=await fetch(t).then(o=>o.text()),i=new CSSStyleSheet;i.replaceSync(n);let s=Bp(this.swishApp.options.ui.design);return Object.entries(s).forEach(([o,a])=>{i.cssRules[0].cssRules[0].style.setProperty(o,a)}),{themeVariablesStylesheet:i}})(),this._loadCricalResourcesPromise)}async loadNonCriticalResources(){return this._loadNonCriticalResourcesPromise?this._loadNonCriticalResourcesPromise:(this._loadNonCriticalResourcesPromise=(async()=>{let t=`${this.swishApp.options.ui.baseUrl}/ui@${Te}/bundle.css`,n=r(o=>{let a=new CSSStyleSheet;return a.replaceSync(o),a},"createCssStylesheet"),[i,...s]=await Promise.all([fetch(t).then(o=>o.text()).then(n),...this.swishApp.options.ui.css.map(async o=>o instanceof URL?n(await fetch(o).then(a=>a.text())):n(o))]);return{bundleCssStylesheet:i,customCssStylesheets:s}})(),this._loadNonCriticalResourcesPromise)}async insertComponent({name:t,template:n,position:i,refElement:s,singleInstance:o}){if(o&&this.queryComponent(t))return this.queryComponent(t);let{themeVariablesStylesheet:a}=await this.loadCricalResources(),l=o?0:++this.elementId;s.insertAdjacentHTML(i,n.replace(' shadowrootmode="open"',"").replace(`ref="${t}"`,`ref="${t}" instance="${l}"`));let c=this.queryComponent(t,l);if(!c)throw new Error(`Element ${t} not found in DOM`);return o&&c.setAttribute("swish-singleton",""),c.shadowRoot&&(c.shadowRoot.adoptedStyleSheets=[a]),c}queryComponent(t,n=0){let i=`swish-ui[ref="${t}"][instance="${n}"]`;return document.querySelector(i)}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(`
276
+ `);x=N.pop()??"";for(let oe of N){let Oe=oe.split(`
277
+ `),ne=[],ve;for(let $ of Oe)if($.startsWith("data:"))ne.push($.replace(/^data:\s*/,""));else if($.startsWith("event:"))ve=$.replace(/^event:\s*/,"");else if($.startsWith("id:"))p=$.replace(/^id:\s*/,"");else if($.startsWith("retry:")){let Pe=Number.parseInt($.replace(/^retry:\s*/,""),10);Number.isNaN(Pe)||(f=Pe)}let Z,Be=!1;if(ne.length){let $=ne.join(`
278
+ `);try{Z=JSON.parse($),Be=!0}catch{Z=$}}Be&&(s&&await s(Z),i&&(Z=await i(Z))),n?.({data:Z,event:ve,id:p,retry:f}),ne.length&&(yield Z)}}}finally{y.removeEventListener("abort",A),R.releaseLock()}break}catch(S){if(t?.(S),a!==void 0&&w>=a)break;let k=Math.min(f*2**(w-1),l??3e4);await h(k)}}},"createStream")()}},"createSseClient"),hp=g(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorArrayExplode"),fp=g(e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},"separatorArrayNoExplode"),mp=g(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorObjectExplode"),oa=g(({allowReserved:e,explode:t,name:n,style:i,value:s})=>{if(!t){let l=(e?s:s.map(c=>encodeURIComponent(c))).join(fp(i));switch(i){case"label":return`.${l}`;case"matrix":return`;${n}=${l}`;case"simple":return l;default:return`${n}=${l}`}}let o=hp(i),a=s.map(l=>i==="label"||i==="simple"?e?l:encodeURIComponent(l):zn({allowReserved:e,name:n,value:l})).join(o);return i==="label"||i==="matrix"?o+a:a},"serializeArrayParam"),zn=g(({allowReserved:e,name:t,value:n})=>{if(n==null)return"";if(typeof n=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?n:encodeURIComponent(n)}`},"serializePrimitiveParam"),aa=g(({allowReserved:e,explode:t,name:n,style:i,value:s,valueOnly:o})=>{if(s instanceof Date)return o?s.toISOString():`${n}=${s.toISOString()}`;if(i!=="deepObject"&&!t){let c=[];Object.entries(s).forEach(([u,p])=>{c=[...c,u,e?p:encodeURIComponent(p)]});let d=c.join(",");switch(i){case"form":return`${n}=${d}`;case"label":return`.${d}`;case"matrix":return`;${n}=${d}`;default:return d}}let a=mp(i),l=Object.entries(s).map(([c,d])=>zn({allowReserved:e,name:i==="deepObject"?`${n}[${c}]`:c,value:d})).join(a);return i==="label"||i==="matrix"?a+l:l},"serializeObjectParam"),yp=/\{[^{}]+\}/g,vp=g(({path:e,url:t})=>{let n=t,i=t.match(yp);if(i)for(let s of i){let o=!1,a=s.substring(1,s.length-1),l="simple";a.endsWith("*")&&(o=!0,a=a.substring(0,a.length-1)),a.startsWith(".")?(a=a.substring(1),l="label"):a.startsWith(";")&&(a=a.substring(1),l="matrix");let c=e[a];if(c==null)continue;if(Array.isArray(c)){n=n.replace(s,oa({explode:o,name:a,style:l,value:c}));continue}if(typeof c=="object"){n=n.replace(s,aa({explode:o,name:a,style:l,value:c,valueOnly:!0}));continue}if(l==="matrix"){n=n.replace(s,`;${zn({name:a,value:c})}`);continue}let d=encodeURIComponent(l==="label"?`.${c}`:c);n=n.replace(s,d)}return n},"defaultPathSerializer"),gp=g(({baseUrl:e,path:t,query:n,querySerializer:i,url:s})=>{let o=s.startsWith("/")?s:`/${s}`,a=(e??"")+o;t&&(a=vp({path:t,url:a}));let l=n?i(n):"";return l.startsWith("?")&&(l=l.substring(1)),l&&(a+=`?${l}`),a},"getUrl");function ls(e){let t=e.body!==void 0;if(t&&e.bodySerializer)return"serializedBody"in e?e.serializedBody!==void 0&&e.serializedBody!==""?e.serializedBody:null:e.body!==""?e.body:null;if(t)return e.body}r(ls,"N");g(ls,"getValidRequestBody");var wp=g(async(e,t)=>{let n=typeof t=="function"?await t(e):t;if(n)return e.scheme==="bearer"?`Bearer ${n}`:e.scheme==="basic"?`Basic ${btoa(n)}`:n},"getAuthToken"),la=g(({parameters:e={},...t}={})=>g(n=>{let i=[];if(n&&typeof n=="object")for(let s in n){let o=n[s];if(o==null)continue;let a=e[s]||t;if(Array.isArray(o)){let l=oa({allowReserved:a.allowReserved,explode:!0,name:s,style:"form",value:o,...a.array});l&&i.push(l)}else if(typeof o=="object"){let l=aa({allowReserved:a.allowReserved,explode:!0,name:s,style:"deepObject",value:o,...a.object});l&&i.push(l)}else{let l=zn({allowReserved:a.allowReserved,name:s,value:o});l&&i.push(l)}}return i.join("&")},"querySerializer"),"createQuerySerializer"),bp=g(e=>{var t;if(!e)return"stream";let n=(t=e.split(";")[0])==null?void 0:t.trim();if(n){if(n.startsWith("application/json")||n.endsWith("+json"))return"json";if(n==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some(i=>n.startsWith(i)))return"blob";if(n.startsWith("text/"))return"text"}},"getParseAs"),Ip=g((e,t)=>{var n,i;return t?!!(e.headers.has(t)||(n=e.query)!=null&&n[t]||(i=e.headers.get("Cookie"))!=null&&i.includes(`${t}=`)):!1},"checkForExistence"),Sp=g(async({security:e,...t})=>{for(let n of e){if(Ip(t,n.name))continue;let i=await wp(n,t.auth);if(!i)continue;let s=n.name??"Authorization";switch(n.in){case"query":t.query||(t.query={}),t.query[s]=i;break;case"cookie":t.headers.append("Cookie",`${s}=${i}`);break;default:t.headers.set(s,i);break}}},"setAuthParams"),sa=g(e=>gp({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:la(e.querySerializer),url:e.url}),"buildUrl"),ra=g((e,t)=>{var n;let i={...e,...t};return(n=i.baseUrl)!=null&&n.endsWith("/")&&(i.baseUrl=i.baseUrl.substring(0,i.baseUrl.length-1)),i.headers=ca(e.headers,t.headers),i},"mergeConfigs"),xp=g(e=>{let t=[];return e.forEach((n,i)=>{t.push([i,n])}),t},"headersEntries"),ca=g((...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let i=n instanceof Headers?xp(n):Object.entries(n);for(let[s,o]of i)if(o===null)t.delete(s);else if(Array.isArray(o))for(let a of o)t.append(s,a);else o!==void 0&&t.set(s,typeof o=="object"?JSON.stringify(o):o)}return t},"mergeHeaders"),ua=class{static{r(this,"j")}constructor(){this.fns=[]}clear(){this.fns=[]}eject(t){let n=this.getInterceptorIndex(t);this.fns[n]&&(this.fns[n]=null)}exists(t){let n=this.getInterceptorIndex(t);return!!this.fns[n]}getInterceptorIndex(t){return typeof t=="number"?this.fns[t]?t:-1:this.fns.indexOf(t)}update(t,n){let i=this.getInterceptorIndex(t);return this.fns[i]?(this.fns[i]=n,t):!1}use(t){return this.fns.push(t),this.fns.length-1}};g(ua,"Interceptors");var as=ua,Cp=g(()=>({error:new as,request:new as,response:new as}),"createInterceptors"),Ep=la({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),Rp={"Content-Type":"application/json"},cs=g((e={})=>({...dp,headers:Rp,parseAs:"auto",querySerializer:Ep,...e}),"createConfig"),da=g((e={})=>{let t=ra(cs(),e),n=g(()=>({...t}),"getConfig"),i=g(d=>(t=ra(t,d),n()),"setConfig"),s=Cp(),o=g(async d=>{let u={...t,...d,fetch:d.fetch??t.fetch??globalThis.fetch,headers:ca(t.headers,d.headers),serializedBody:void 0};u.security&&await Sp({...u,security:u.security}),u.requestValidator&&await u.requestValidator(u),u.body!==void 0&&u.bodySerializer&&(u.serializedBody=u.bodySerializer(u.body)),(u.body===void 0||u.serializedBody==="")&&u.headers.delete("Content-Type");let p=sa(u);return{opts:u,url:p}},"beforeRequest"),a=g(async d=>{let{opts:u,url:p}=await o(d),h={redirect:"follow",...u,body:ls(u)},f=new Request(p,h);for(let x of s.request.fns)x&&(f=await x(f,u));let w=u.fetch,y;try{y=await w(f)}catch(x){let A=x;for(let P of s.error.fns)P&&(A=await P(x,void 0,f,u));if(A=A||{},u.throwOnError)throw A;return u.responseStyle==="data"?void 0:{error:A,request:f,response:void 0}}for(let x of s.response.fns)x&&(y=await x(y,f,u));let b={request:f,response:y};if(y.ok){let x=(u.parseAs==="auto"?bp(y.headers.get("Content-Type")):u.parseAs)??"json";if(y.status===204||y.headers.get("Content-Length")==="0"){let P;switch(x){case"arrayBuffer":case"blob":case"text":P=await y[x]();break;case"formData":P=new FormData;break;case"stream":P=y.body;break;default:P={};break}return u.responseStyle==="data"?P:{data:P,...b}}let A;switch(x){case"arrayBuffer":case"blob":case"formData":case"text":A=await y[x]();break;case"json":{let P=await y.text();A=P?JSON.parse(P):{};break}case"stream":return u.responseStyle==="data"?y.body:{data:y.body,...b}}return x==="json"&&(u.responseValidator&&await u.responseValidator(A),u.responseTransformer&&(A=await u.responseTransformer(A))),u.responseStyle==="data"?A:{data:A,...b}}let S=await y.text(),k;try{k=JSON.parse(S)}catch{}let E=k??S,R=E;for(let x of s.error.fns)x&&(R=await x(E,y,f,u));if(R=R||{},u.throwOnError)throw R;return u.responseStyle==="data"?void 0:{error:R,...b}},"request"),l=g(d=>u=>a({...u,method:d}),"makeMethodFn"),c=g(d=>async u=>{let{opts:p,url:h}=await o(u);return pp({...p,body:p.body,headers:p.headers,method:d,onRequest:g(async(f,w)=>{let y=new Request(f,w);for(let b of s.request.fns)b&&(y=await b(y,p));return y},"onRequest"),serializedBody:ls(p),url:h})},"makeSseFn");return{buildUrl:sa,connect:l("CONNECT"),delete:l("DELETE"),get:l("GET"),getConfig:n,head:l("HEAD"),interceptors:s,options:l("OPTIONS"),patch:l("PATCH"),post:l("POST"),put:l("PUT"),request:a,setConfig:i,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:l("TRACE")}},"createClient"),O=da(cs({baseUrl:"https://swish.app/api/2026-04"})),kp=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/lists",...e}),"listControllerFind"),Pp=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerCreate"),Ap=g(e=>(e.client??O).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e}),"listControllerDeleteById"),Tp=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e}),"listControllerFindById"),Dp=g(e=>(e.client??O).patch({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerUpdateById"),Lp=g(e=>(e.client??O).put({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/order",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerSetListItemsOrder"),Op=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerAddItemsToList"),Mp=g(e=>(e.client??O).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/{itemId}",...e}),"listControllerRemoveItemFromList"),_p=g(e=>(e.client??O).delete({security:[{scheme:"bearer",type:"http"}],url:"/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerDelete"),qp=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/items",...e}),"itemControllerFind"),Bp=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerCreate"),Fp=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/items/count",...e}),"itemControllerCount"),jp=g(e=>(e.client??O).delete({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e}),"itemControllerDeleteById"),Np=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e}),"itemControllerFindById"),Up=g(e=>(e.client??O).patch({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerUpdateById"),Vp=g(e=>(e.client??O).put({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerSetListsById"),$p=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/identify",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerIdentify"),Hp=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/token",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerCreateToken"),Qp=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/profiles",...e}),"profileControllerGetProfile"),zp=g(e=>(e.client??O).patch({security:[{scheme:"bearer",type:"http"}],url:"/profiles/profile",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerUpdateProfile"),Gp=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/saved-items",...e}),"analyticsControllerLoadSavedItems"),Wp=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/sessions",...e}),"analyticsControllerLoadSessions"),Kp=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/new-lists",...e}),"analyticsControllerLoadNewLists"),Xp=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/collect",...e,headers:{"Content-Type":"application/json",...e.headers}}),"trackingControllerCollect"),Jp=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/orders",...e}),"ordersControllerFind"),Yp=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/orders/{orderId}",...e}),"ordersControllerFindOne"),Zp=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists",...e}),"sharedListsControllerFindAll"),eh=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"sharedListsControllerSave"),th=g(e=>(e.client??O).delete({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}",...e}),"sharedListsControllerDeleteById"),nh=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}",...e}),"sharedListsControllerFindById"),ih=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}/items",...e}),"sharedListsControllerFindItems"),sh=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/notifications",...e}),"notificationsControllerFind"),rh=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/notifications/unread/count",...e}),"notificationsControllerGetUnreadCount"),oh=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/notifications/read",...e,headers:{"Content-Type":"application/json",...e.headers}}),"notificationsControllerMarkAsRead"),ah=g(e=>(e?.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/notifications/read/all",...e}),"notificationsControllerMarkAllAsRead"),lh=g(e=>(e.client??O).delete({security:[{scheme:"bearer",type:"http"}],url:"/notifications/{id}",...e}),"notificationsControllerDeleteById"),ch=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions",...e}),"subscriptionsControllerFind"),uh=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions",...e,headers:{"Content-Type":"application/json",...e.headers}}),"subscriptionsControllerCreate"),dh=g(e=>(e.client??O).delete({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e}),"subscriptionsControllerDelete"),ph=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e}),"subscriptionsControllerFindById"),hh=g(e=>(e.client??O).patch({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"subscriptionsControllerUpdate"),fh=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists",...e}),"smartListsControllerFindAll"),mh=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists/{smartListId}",...e}),"smartListsControllerFindById"),yh=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists/{smartListId}/items",...e}),"smartListsControllerFindItems"),us="2026-04",lx=g(e=>new vh(e),"createApiClient"),pa=class{static{r(this,"xe")}constructor(t){this.version=us,this.items={list:g(n=>this.handlePaginatedRequest(qp({query:n,client:this.client})),"list"),create:g(n=>this.handleRequest(Bp({body:n,client:this.client})),"create"),delete:g(n=>this.handleRequest(_p({body:{itemIds:n},client:this.client})),"delete"),findById:g(n=>this.handleRequest(Np({path:{itemId:n},client:this.client})),"findById"),updateById:g((n,i)=>this.handleRequest(Up({body:i,path:{itemId:n},client:this.client})),"updateById"),deleteById:g(n=>this.handleRequest(jp({path:{itemId:n},client:this.client})),"deleteById"),setListsById:g((n,i)=>this.handleRequest(Vp({body:{listIds:i},path:{itemId:n},client:this.client})),"setListsById"),count:g(()=>this.handleRequest(Fp({client:this.client})),"count")},this.lists={list:g(n=>this.handlePaginatedRequest(kp({query:n,client:this.client})),"list"),create:g(n=>this.handleRequest(Pp({body:n,client:this.client})),"create"),findById:g(n=>this.handleRequest(Tp({path:{listId:n},client:this.client})),"findById"),updateById:g((n,i)=>this.handleRequest(Dp({body:i,path:{listId:n},client:this.client})),"updateById"),deleteById:g(n=>this.handleRequest(Ap({path:{listId:n},client:this.client})),"deleteById"),orderItems:g((n,i)=>this.handleRequest(Lp({body:{itemIds:i},path:{listId:n},client:this.client})),"orderItems"),addItemsToList:g((n,i)=>this.handleRequest(Op({body:{itemIds:i},path:{listId:n},client:this.client})),"addItemsToList"),removeItemFromList:g((n,i)=>this.handleRequest(Mp({path:{listId:n,itemId:i},client:this.client})),"removeItemFromList")},this.profiles={createToken:g((n={})=>this.handleRequest(Hp({body:n,client:this.client})),"createToken"),identify:g(n=>this.handleRequest($p({body:n,client:this.client})),"identify"),getProfile:g(()=>this.handleRequest(Qp({client:this.client})),"getProfile"),updateProfile:g(n=>this.handleRequest(zp({body:n,client:this.client})),"updateProfile")},this.orders={list:g(n=>this.handlePaginatedRequest(Jp({query:n,client:this.client})),"list"),findById:g(n=>this.handleRequest(Yp({path:{orderId:n},client:this.client})),"findById")},this.sharedLists={list:g(n=>this.handlePaginatedRequest(Zp({query:n,client:this.client})),"list"),save:g(n=>this.handleRequest(eh({body:{listId:n},client:this.client})),"save"),findById:g(n=>this.handleRequest(nh({path:{sharedListId:n},client:this.client})),"findById"),deleteById:g(n=>this.handleRequest(th({path:{sharedListId:n},client:this.client})),"deleteById"),findItems:g((n,i)=>this.handlePaginatedRequest(ih({path:{sharedListId:n},query:i,client:this.client})),"findItems")},this.analytics={savedItems:g(n=>this.handleRequest(Gp({query:n,client:this.client})),"savedItems"),sessions:g(n=>this.handleRequest(Wp({query:n,client:this.client})),"sessions"),newLists:g(n=>this.handleRequest(Kp({query:n,client:this.client})),"newLists")},this.tracking={track:g(n=>this.handleRequest(Xp({body:n,client:this.client})),"track")},this.notifications={list:g(n=>this.handlePaginatedRequest(sh({query:n,client:this.client})),"list"),getUnreadCount:g(()=>this.handleRequest(rh({client:this.client})),"getUnreadCount"),markAsRead:g(n=>this.handleRequest(oh({body:{notificationIds:n},client:this.client})),"markAsRead"),markAllAsRead:g(()=>this.handleRequest(ah({client:this.client})),"markAllAsRead"),deleteById:g(n=>this.handleRequest(lh({path:{id:n},client:this.client})),"deleteById")},this.subscriptions={list:g(n=>this.handlePaginatedRequest(ch({query:n,client:this.client})),"list"),create:g(n=>this.handleRequest(uh({body:n,client:this.client})),"create"),findById:g(n=>this.handleRequest(ph({path:{id:n},client:this.client})),"findById"),updateById:g((n,i)=>this.handleRequest(hh({body:i,path:{id:n},client:this.client})),"updateById"),deleteById:g(n=>this.handleRequest(dh({path:{id:n},client:this.client})),"deleteById")},this.smartLists={list:g(()=>this.handleRequest(fh({client:this.client})),"list"),findById:g(n=>this.handleRequest(mh({path:{smartListId:n},client:this.client})),"findById"),findItems:g((n,i)=>this.handlePaginatedRequest(yh({path:{smartListId:n},query:i,client:this.client})),"findItems")},this.handleRequest=g(async n=>{let{data:i,error:s}=await n;return s!=null&&s.error?{error:s.error}:{data:i?.data}},"handleRequest"),this.handlePaginatedRequest=g(async n=>{var i;let{data:s,error:o}=await n;return o!=null&&o.error?{error:o.error}:{data:s?.data??[],pageInfo:s?.pageInfo??{next:null,previous:null,totalCount:((i=s?.data)==null?void 0:i.length)??0}}},"handlePaginatedRequest"),this.client=da(cs({baseUrl:`https://swish.app/api/${this.version}`,...t.config})),t.authToken&&(this.authToken=t.authToken),t.requestInterceptor&&this.client.interceptors.request.use(t.requestInterceptor),t.responseInterceptor&&this.client.interceptors.response.use(t.responseInterceptor),this.client.interceptors.request.use(this.directRequestInterceptor.bind(this))}setAuthToken(t){this.authToken=t}directRequestInterceptor(t){return this.authToken&&t.headers.set("Authorization",`Bearer ${this.authToken}`),t}};g(pa,"SwishClient");var vh=pa;var Gn=class{constructor(t,n,i,s){this.tokenHasProfile=!1;this.api=t,this.context=n,this.eventBus=i,this.tokenUrl=s}static{r(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()=>{let t=this.getSwishToken();this.migrateLegacySession();let n=this.context.customer.id;n?(this.hasSessionToken()&&(this.eventBus.publish("auth-cache-clear",null),await this.api.clearCache()),await this.initCustomer(n)):(this.hasCustomerToken()&&await this.resetSession(),await this.initSession());let i=this.getSwishToken();i&&i!==t&&this.eventBus.publish("token-update",null)})(),this._initPromise)}async initCustomer(t){let n=`gid://shopify/Customer/${t}`,i=this.getTokenBySub(n);if(i){this.initToken(i);return}let s=this.getSessionId();await this.acquireToken(s,n)}async initSession(){let t=this.getSessionId(),n=t?this.getTokenBySub(t):null;if(n){this.initToken(n);return}await this.acquireToken(t)}initToken(t){let n=this.getTokenData(t);if(!n)throw new Error("Invalid Swish token.");this.tokenHasProfile=n.has_profile!==!1,this.api.setAuthToken(t)}async acquireToken(t,n){let i={};n&&(i.customer=n),t&&(i.session=t);let s=await fetch(this.tokenUrl,{method:"POST",headers:{"Content-Type":"application/json","Swish-Api-Version":us},body:JSON.stringify(i)});if(!s.ok)throw console.error("Failed to create customer token",s.status),new Error("Failed to create customer token");let a=(await s.json()).data;if(!a?.token)throw console.error("Failed to create customer token empty response"),new Error("Failed to create customer token");a.profile.startsWith("gid://swish/Session/")&&this.setSessionId(a.profile),this.setSwishToken(a.token),this.initToken(a.token)}async resetSession(){this.deleteSessionId(),this.deleteSwishToken(),await this.api.clearCache(),this.eventBus.publish("auth-cache-clear",null)}getTokenData(t){try{return JSON.parse(atob(t.split(".")[1]))}catch(n){return console.error("Failed to parse Swish token",{cause:n}),null}}willTokenExpire(t,n=60){let i=this.getTokenData(t);return!!(i&&i.exp&&i.exp<Date.now()/1e3+n)}hasCustomerToken(){let t=this.getSwishToken();return t?this.getTokenData(t)?.sub?.startsWith("gid://shopify/Customer/")??!1:!1}hasSessionToken(){let t=this.getSwishToken();return t?this.getTokenData(t)?.sub?.startsWith("gid://swish/Session/")??!1:!1}getTokenBySub(t){if(!t)return null;let n=this.getSwishToken();if(!n)return null;let i=this.getTokenData(n);return!i||i.sub!==t||this.willTokenExpire(n,60)?null:n}getSessionId(){let t=ye(this.context.myshopifyDomain);return localStorage.getItem(`swish-session-${t}`)??void 0}setSessionId(t){let n=ye(this.context.myshopifyDomain);localStorage.setItem(`swish-session-${n}`,t)}deleteSessionId(){let t=ye(this.context.myshopifyDomain);localStorage.removeItem(`swish-session-${t}`)}getSwishToken(){let t=ye(this.context.myshopifyDomain);return sessionStorage.getItem(`swish-token-${t}`)??void 0}setSwishToken(t){let n=ye(this.context.myshopifyDomain);sessionStorage.setItem(`swish-token-${n}`,t)}deleteSwishToken(){let t=ye(this.context.myshopifyDomain);sessionStorage.removeItem(`swish-token-${t}`)}migrateLegacySession(){try{let t=localStorage.getItem("wk_session_id")??localStorage.getItem("swish-profile")?.split("/").pop()??localStorage.getItem("swish-session")?.split("/").pop();t&&(this.setSessionId(`gid://swish/Session/${t}`),localStorage.removeItem("wk_session_id"),localStorage.removeItem("swish-profile"),localStorage.removeItem("swish-session"))}catch(t){console.warn("Failed to migrate legacy session id to Swish session",{cause:t})}}};var Wn=class{static{r(this,"SwishApi")}constructor(t,n,i,s,o){this.config=t,this.storefrontContext=n;let a=ye(n.myshopifyDomain);this.cache=new Me(`swish-api-${a}`,"max-age=60, stale-while-revalidate=3600",s+is),this.cache.cleanupExpiredEntries().catch(c=>{console.warn("Swish API cache initialization cleanup error:",c)}),this.auth=new Gn(this,n,i,o);let l={authToken:this.auth.getSwishToken(),config:{...t,fetch:this.fetchFunction.bind(this)},requestInterceptor:this.requestInterceptor.bind(this),responseInterceptor:this.responseInterceptor.bind(this)};this.apiClient=Jo(l),this.itemsLoader=ia(this)}async fetchFunction(t,n){let i=t instanceof Request?t.method:n?.method??"GET",s=t instanceof Request?t.url:typeof t=="string"?t:t.toString();if(s.includes("/smart-lists"))return fetch(t,n);let a=s.includes("/orders"),l=s.includes("/profiles");return i==="GET"&&!a&&!l?this.cache.fetchWithCache(t,n):fetch(t,n)}async requestInterceptor(t){await this.initAuth();try{t.headers.set("Market-Context-Type","country"),t.headers.set("Market-Context-Value",this.storefrontContext.localization.country),t.headers.set("Country",this.storefrontContext.localization.country),t.headers.set("Language",this.storefrontContext.localization.language),t.headers.set("Market",this.storefrontContext.localization.market)}catch(n){console.warn("Failed to set storefront context headers:",n)}return this.config.requestInterceptor&&(t=await this.config.requestInterceptor(t)),t}async responseInterceptor(t,n){let i=n.method!=="GET",s=n.url.includes("/profiles/token");if(i&&!s){let o=this.auth.hasToken(),a=!this.auth.hasProfile(),l=t.ok;await this.cache.clear(),o&&a&&l&&await this.auth.renewToken()}return await this.config.responseInterceptor?.(t,n),t}setAuthToken(t){this.apiClient.setAuthToken(t)}initAuth(){return this.auth.init()}async withFallback(t,n){return await this.initAuth(),this.auth.hasProfile()?t():Promise.resolve(n)}async withSignedInCustomerFallback(t,n){return await this.initAuth(),!!this.storefrontContext.customer.id&&this.auth.hasProfile()?t():Promise.resolve(n)}get items(){return{...this.apiClient.items,count:r(async()=>this.withFallback(()=>this.apiClient.items.count(),{data:{count:0}}),"count"),list:r(async(t,n)=>{let i=r(()=>{if(n?.batch&&t?.query){let s=t.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(t)},"execute");return n?.shared?i():this.withFallback(i,{data:[],pageInfo:{next:null,previous:null,totalCount:0}})},"list"),findById:r(async t=>this.withFallback(()=>this.apiClient.items.findById(t),{data:null}),"findById")}}get lists(){return{...this.apiClient.lists,list:r(async t=>this.withFallback(()=>this.apiClient.lists.list(t),{data:[],pageInfo:{next:null,previous:null,totalCount:0}}),"list"),findById:r(async(t,n)=>{let i=r(()=>this.apiClient.lists.findById(t),"execute");return n?.shared?i():this.withFallback(()=>this.apiClient.lists.findById(t),{data:null})},"findById")}}get orders(){return{...this.apiClient.orders,list:r(async t=>this.withFallback(()=>this.apiClient.orders.list(t),{data:[],pageInfo:{next:null,previous:null,totalCount:0}}),"list"),findById:r(async t=>this.withFallback(()=>(typeof t=="string"&&(t=parseInt(t.split("/").pop()??t)),this.apiClient.orders.findById(t)),{data:null}),"findById")}}get notifications(){return{...this.apiClient.notifications,list:r(async t=>this.withSignedInCustomerFallback(()=>this.apiClient.notifications.list(t),{data:[],pageInfo:{next:null,previous:null,totalCount:0}}),"list"),getUnreadCount:r(async()=>this.withSignedInCustomerFallback(()=>this.apiClient.notifications.getUnreadCount(),{data:{count:0}}),"getUnreadCount"),markAsRead:r(t=>this.apiClient.notifications.markAsRead(t),"markAsRead"),markAllAsRead:r(()=>this.apiClient.notifications.markAllAsRead(),"markAllAsRead"),deleteById:r(t=>this.apiClient.notifications.deleteById(t),"deleteById")}}get smartLists(){return{...this.apiClient.smartLists,list:r(async()=>this.withFallback(()=>this.apiClient.smartLists.list(),{data:null}),"list"),findById:r(async t=>t==="recently-viewed"?this.apiClient.smartLists.findById(t):this.withFallback(()=>this.apiClient.smartLists.findById(t),{data:null}),"findById"),findItems:r(async(t,n)=>t==="recently-viewed"?this.apiClient.smartLists.findItems(t,n):this.withFallback(()=>this.apiClient.smartLists.findItems(t,n),{data:[],pageInfo:{next:null,previous:null,totalCount:0}}),"findItems")}}get profiles(){return{...this.apiClient.profiles,getProfile:r(async()=>this.withSignedInCustomerFallback(()=>this.apiClient.profiles.getProfile(),{data:null}),"getProfile"),updateProfile:r(async t=>this.apiClient.profiles.updateProfile(t),"updateProfile")}}async clearCache(){await this.cache.clear()}};var Kn=class{constructor(t){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","POST /notifications\\/read\\/all\\/?$":"notification-update","POST /notifications\\/read\\/?$":"notification-update","PATCH /notifications\\/([^/]+)\\/?$":"notification-update","DELETE /notifications\\/([^/]+)\\/?$":"notification-delete"};this.eventBus=t,this.processFetchResponse=this.processFetchResponse.bind(this)}static{r(this,"SwishApiPublisher")}async processFetchResponse(t,n){try{let i=this.getEventName(n.method,t.status,n.url);if(!i)return;let s=await t.clone().text();if(t.headers.get("Content-Type")?.includes("application/json"))try{s=JSON.parse(s).data}catch(o){console.warn(o)}this.eventBus.publish(i,s)}catch(i){console.warn(i)}}getEventName(t,n,i){t=t.toUpperCase();let s=new URL(i).pathname;return t==="GET"||n<200||n>=300?void 0:Object.entries(this.eventMap).find(([a])=>{let[l,c]=a.split(" ");return l!==t?!1:new RegExp(c).test(s)})?.[1]}};var Xn=class{constructor(t,n){this.inflightModals=new Map;this.modalsWithScrollLock=new Set;this.scrollLockRefCount=0;this.scrollPositionBeforeLock=0;this.elementId=0;this._templatePromises=new Map;this._importPromises=new Map;this._lockScroll=r(()=>this.lockScroll(),"_lockScroll");this._unlockScroll=r(()=>this.unlockScroll(),"_unlockScroll");this.swishApp=t,this.isPreview=n,this.previewCssStylesheet=n?new CSSStyleSheet:void 0,this.themeVariablesStylesheet=new CSSStyleSheet,this.icons=q(n?{}:t.options.ui.icons??{})}static{r(this,"SwishUi")}async showModal(t){if(this.inflightModals.has(t))return this.inflightModals.get(t);let n=(async()=>{typeof t=="string"&&(t=await this.requireUiComponent(t)),!(!t||t.getAttribute("open")==="true")&&(this.lockScroll(),this.modalsWithScrollLock.add(t),t.setAttribute("open","true"),t.getAttribute("ref")==="drawer"&&this.swishApp.events.publish("drawer-state-change",{open:!0}))})().finally(()=>{this.inflightModals.delete(t)});return this.inflightModals.set(t,n),n}async hideModal(t){if(this.inflightModals.has(t))return this.inflightModals.get(t);let n=(async()=>{try{if(typeof t=="string"&&(t=await this.requireUiComponent(t)),t?.getAttribute("open")!=="true")return;t.setAttribute("open","false"),t.getAttribute("ref")==="drawer"&&this.swishApp.events.publish("drawer-state-change",{open:!1}),t.hasAttribute("swish-singleton")||t.addEventListener("closed",()=>{t.remove()},{once:!0})}finally{t&&typeof t!="string"&&this.modalsWithScrollLock.has(t)&&(this.modalsWithScrollLock.delete(t),this.unlockScroll())}})().finally(()=>{this.inflightModals.delete(t)});return this.inflightModals.set(t,n),n}waitForEvent(t,n){return new Promise(i=>{let s=[],o=r(()=>{s.forEach(({event:a,listener:l})=>{t.removeEventListener(a,l)})},"cleanup");Object.entries(n).forEach(([a,l])=>{let c=r(d=>{let u=l(d);o(),i(u)},"listener");s.push({event:a,listener:c}),t.addEventListener(a,c)})})}async showSignIn(t){let n=await this.requireUiComponent("sign-in");n.setAttribute("return-to",t?.returnTo??window.location.pathname),await this.showModal(n);let i=await this.waitForEvent(n,{submit:r(()=>({code:"ok",data:void 0}),"submit"),close:r(()=>({code:"closed"}),"close")});return await this.hideModal(n),i}async showUnsaveAlert(t){if(!t.itemId)throw new Error("An itemId is required to show the unsave alert");await this.hideAllToasts();let n=await this.requireUiComponent("unsave-alert");n.setAttribute("item-id",t.itemId),await this.showModal(n);let i=await this.waitForEvent(n,{submit:r(s=>s instanceof CustomEvent?{code:"ok",data:s.detail}:(console.warn("Unsave alert submitted without detail",s),{code:"closed"}),"submit"),close:r(()=>({code:"closed"}),"close")});return await this.hideModal(n),i}async showDeleteListAlert(t){if(!t.listId)throw new Error("A listId is required to show the delete list alert");await this.hideAllToasts();let n=await this.requireUiComponent("delete-list-alert");n.setAttribute("list-id",t.listId),await this.showModal(n);let i=await this.waitForEvent(n,{submit:r(()=>({code:"ok",data:void 0}),"submit"),close:r(()=>({code:"closed"}),"close")});return await this.hideModal(n),i}async showConfirmDialog(t){await this.hideAllToasts();let n=await this.requireUiComponent("confirm-dialog");t.titleKey?n.setAttribute("title-key",t.titleKey):n.removeAttribute("title-key"),t.descriptionKey?n.setAttribute("description-key",t.descriptionKey):n.removeAttribute("description-key"),t.confirmLabelKey?n.setAttribute("confirm-label-key",t.confirmLabelKey):n.removeAttribute("confirm-label-key"),t.cancelLabelKey?n.setAttribute("cancel-label-key",t.cancelLabelKey):n.removeAttribute("cancel-label-key"),t.danger?n.setAttribute("danger",""):n.removeAttribute("danger"),await this.showModal(n);let i=await this.waitForEvent(n,{submit:r(()=>({code:"ok",data:void 0}),"submit"),close:r(()=>({code:"closed"}),"close")});return await this.hideModal(n),i}hideDrawer(){let t=this.queryComponent("drawer");!t||t.getAttribute("open")!=="true"||t.dispatchEvent(new CustomEvent("close"))}async showDrawer(t){await this.hideAllToasts();let n=await this.requireUiComponent("drawer",{singleInstance:!0});n.setAttribute("account-url",this.swishApp.storefrontContext.routes.accountUrl),this.swishApp.storefrontContext.customer.id&&n.setAttribute("customer-id",this.swishApp.storefrontContext.customer.id),n.setAttribute("view",t?.view??"home"),t?.listId&&n.setAttribute("list-id",t.listId),t?.listType&&n.setAttribute("list-type",t.listType),t?.productId&&n.setAttribute("product-id",t.productId),t?.variantId&&n.setAttribute("variant-id",t.variantId),t?.orderId&&n.setAttribute("order-id",t.orderId),await this.showModal(n);let i=await this.waitForEvent(n,{close:r(()=>({code:"closed"}),"close")});return await this.hideModal(n),i}async showListMenu(t){if(!t.listId)throw new Error("listId is required");await this.hideAllToasts();let n=await this.requireUiComponent("list-menu");n.setAttribute("list-id",t.listId),await this.showModal(n);let i=await this.waitForEvent(n,{close:r(()=>({code:"closed"}),"close"),edit:r(s=>s instanceof CustomEvent?{code:"ok",data:{action:"edit",data:s.detail}}:(console.warn("List menu edit without detail",s),{code:"closed"}),"edit"),delete:r(()=>({code:"ok",data:{action:"delete"}}),"delete"),"add-items":r(()=>({code:"ok",data:{action:"add-items"}}),"add-items"),share:r(()=>({code:"ok",data:{action:"share"}}),"share"),"edit-access":r(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(n),i}async showOrderMenu(t){if(!t.orderId)throw new Error("orderId is required");await this.hideAllToasts();let n=await this.requireUiComponent("order-menu");n.setAttribute("order-id",t.orderId),await this.showModal(n);let i=await this.waitForEvent(n,{close:r(()=>({code:"closed"}),"close")});return await this.hideModal(n),i}async showListDetailPageMenu(t){await this.hideAllToasts();let n=await this.requireUiComponent("list-detail-page-menu");n.setAttribute("list-id",t.listId),await this.showModal(n);let i=await this.waitForEvent(n,{close:r(()=>({code:"closed"}),"close")});return await this.hideModal(n),i}async showListSelect(t){if(!t.itemId)throw new Error("itemId is required");await this.hideAllToasts();let n=await this.requireUiComponent("list-select");n.setAttribute("item-id",t.itemId),await this.showModal(n);let i=await this.waitForEvent(n,{close:r(()=>({code:"closed"}),"close"),submit:r(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:r(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(n),i}async initListDetailPage(t,n){let i=await this.requireUiComponent("list-detail-page",{refElement:n});t.listId&&i.setAttribute("list-id",t.listId)}async showToast(t){let n=Date.now(),i=await this.requireUiComponent("toast-manager",{singleInstance:!0,onHydrated:r(s=>{s.current.show(t,n)},"onHydrated")});return this.waitForEvent(i,{[`close-${n}`]:()=>({code:"closed"}),[`submit-${n}`]:()=>({code:"ok",data:void 0})})}async hideAllToasts(){this.queryComponent("toast-manager")&&await this.requireUiComponent("toast-manager",{singleInstance:!0,onHydrated:r(t=>{t.current.clear()},"onHydrated")})}async showVariantSelect(t){await this.hideAllToasts();let n=await this.requireUiComponent("variant-select");if(t?.itemId&&n.setAttribute("item-id",t.itemId),t?.productId)n.setAttribute("product-id",t.productId.toString());else if(t?.productHandle)n.setAttribute("product-handle",t.productHandle);else throw new Error("Either productId or productHandle must be provided");t?.variantId&&n.setAttribute("variant-id",t.variantId.toString()),await this.showModal(n);let i=await this.waitForEvent(n,{close:r(()=>({code:"closed"}),"close"),submit:r(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(n),i}async showQuickBuy(t){await this.hideAllToasts();let n=await this.requireUiComponent("quick-buy");if(t?.productId)n.setAttribute("product-id",t.productId.toString());else if(t?.productHandle)n.setAttribute("product-handle",t.productHandle);else throw new Error("ProductId or productHandle must be provided");t?.variantId&&n.setAttribute("variant-id",t.variantId.toString()),await this.showModal(n);let i=await this.waitForEvent(n,{close:r(()=>({code:"closed"}),"close"),submit:r(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(n),i}async showListEditor(t){let n=await this.requireUiComponent("list-editor");t?.listId&&n.setAttribute("list-id",t.listId),await this.showModal(n);let i=await this.waitForEvent(n,{close:r(()=>({code:"closed"}),"close"),submit:r(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(n),i}async createElement(t,n){let[i]=await Promise.all([this.loadTemplate(t),this.loadCricalResources()]),s=document.createElement("template");s.innerHTML=i.replace(' shadowrootmode="open"',"");let o=s.content.firstElementChild;return o.addEventListener("connected",()=>{o.shadowRoot&&(o.shadowRoot.adoptedStyleSheets=[this.themeVariablesStylesheet],this.hydrateElement(t,o,n?.onHydrated))},{once:!0}),o}async hydrateElement(t,n,i){if(n.hasAttribute("hydrated")){i?.(n.getComponentRef());return}await Promise.all([this.loadNonCriticalResources(),this.loadLocale(),this.importScript(t)]).then(([{bundleCssStylesheet:s,customCssStylesheets:o},,{hydrate:a}])=>{n.shadowRoot&&s&&(n.shadowRoot.adoptedStyleSheets=[...n.shadowRoot.adoptedStyleSheets,...o,s],n.shadowRoot?.querySelector(":host > style")?.remove()),a(n),n.setAttribute("hydrated","")}),i?.(n.getComponentRef())}async requireUiComponent(t,n){this.loadCricalResources();let i=await this.loadTemplate(t),s=await this.insertComponent({name:t,template:i,refElement:n?.refElement??document.body,position:"beforeend",singleInstance:n?.singleInstance??!1});return s.shadowRoot&&!s.hasAttribute("hydrated")?Promise.all([this.loadNonCriticalResources(),this.loadLocale(),this.importScript(t)]).then(([{bundleCssStylesheet:o,customCssStylesheets:a},,{hydrate:l}])=>{s.shadowRoot&&o&&(s.shadowRoot.adoptedStyleSheets=[...s.shadowRoot.adoptedStyleSheets,...a,o],s.shadowRoot?.querySelector(":host > style")?.remove()),l(s),s.setAttribute("hydrated",""),n?.onHydrated?.(s.getComponentRef())}):s.hasAttribute("hydrated")&&n?.onHydrated?.(s.getComponentRef()),s}async loadTemplate(t){let n=`${this.swishApp.options.ui.baseUrl}/ui@${ge}/${t}.html`;if(this._templatePromises.has(n))return this._templatePromises.get(n);let i=fetch(n).then(s=>s.text());return this._templatePromises.set(n,i),i}async importScript(t){let n=`${this.swishApp.options.ui.baseUrl}/ui@${ge}/${t}.js`;if(this._importPromises.has(n))return this._importPromises.get(n);let i=import(n);return this._importPromises.set(n,i),i}async loadLocale(){if(this._loadLocalePromise)return this._loadLocalePromise;let t=this.swishApp.storefrontContext.localization.language.toLowerCase();return this._loadLocalePromise=this.swishApp.i18n.loadLocale(t),this._loadLocalePromise}async loadCricalResources(){return this._loadCricalResourcesPromise?this._loadCricalResourcesPromise:(this._loadCricalResourcesPromise=(async()=>{let t=`${this.swishApp.options.ui.baseUrl}/ui@${ge}/theme.css`,n=await fetch(t).then(s=>s.text());this.themeVariablesStylesheet.replaceSync(n);let i=ha(this.swishApp.options.ui.design);Object.entries(i).forEach(([s,o])=>{this.themeVariablesStylesheet.cssRules[0].cssRules[0].style.setProperty(s,o)})})(),this._loadCricalResourcesPromise)}applyPreview({design:t,css:n,icons:i}){if(!this.previewCssStylesheet)return;let s=n?.filter(l=>typeof l=="string").map(l=>l.toString()).join(`
279
+ `)??"",o=t?ha(t):{},a=`@layer theme { :host {
280
+ ${Object.entries(o).map(([l,c])=>`${l}: ${c};`).join(`
281
+ `)}
282
+ }} ${s??""}`;this.previewCssStylesheet.replaceSync(a),Ih(this.icons.peek(),i??{})||(this.icons.value=i??{})}async loadNonCriticalResources(){return this._loadNonCriticalResourcesPromise?this._loadNonCriticalResourcesPromise:(this._loadNonCriticalResourcesPromise=(async()=>{let t=`${this.swishApp.options.ui.baseUrl}/ui@${ge}/bundle.css`,n=r(a=>{let l=new CSSStyleSheet;return l.replaceSync(a),l},"createCssStylesheet"),i=this.isPreview?[]:this.swishApp.options.ui.css,[s,...o]=await Promise.all([fetch(t).then(a=>a.text()).then(n),...i.map(async a=>a instanceof URL?n(await fetch(a).then(l=>l.text())):n(a))]);return this.previewCssStylesheet&&o.push(this.previewCssStylesheet),{bundleCssStylesheet:s,customCssStylesheets:o}})(),this._loadNonCriticalResourcesPromise)}async insertComponent({name:t,template:n,position:i,refElement:s,singleInstance:o}){if(o&&this.queryComponent(t))return this.queryComponent(t);let a=o?0:++this.elementId;s.insertAdjacentHTML(i,n.replace(' shadowrootmode="open"',"").replace(`ref="${t}"`,`ref="${t}" instance="${a}"`));let l=this.queryComponent(t,a);if(!l)throw new Error(`Element ${t} not found in DOM`);return o&&l.setAttribute("swish-singleton",""),l.shadowRoot&&(l.shadowRoot.adoptedStyleSheets=[this.themeVariablesStylesheet]),l}queryComponent(t,n=0){let i=`swish-ui[ref="${t}"][instance="${n}"]`;return document.querySelector(i)}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(`
270
283
  html[swish-locked] body {
271
284
  overflow: hidden;
272
285
  position: fixed;
@@ -274,4 +287,4 @@ Values:
274
287
  left: 0px;
275
288
  right: 0px;
276
289
  }
277
- `),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 Bp(e){if(!e)return{};let t={},n=r(i=>{Object.entries(i).forEach(([s,o])=>{if(o!=null){if(typeof o=="object"&&!Array.isArray(o)){n(o);return}if(typeof o=="string"||typeof o=="number"){let a=s.startsWith("--")?s:`--swish-theme-${Fp(s)}`;t[a]=jp(s,o)}}})},"walk");return n(e),t}r(Bp,"flattenDesignTokens");function Fp(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase()}r(Fp,"toKebabCase");function jp(e,t){return typeof t=="number"&&!Np(e)?`${t}px`:String(t)}r(jp,"formatDesignValue");function Np(e){let t=e.toLowerCase();return t.includes("fontweight")||t.includes("scale")||t.includes("letterspacing")||t.includes("lineheight")}r(Np,"isNonPxValue");var Up=typeof HTMLElement<"u"?HTMLElement:class{},Gn=class extends Up{constructor(){super();this.getComponentRef=r(()=>this.componentRef,"getComponentRef");this.setComponentRef=r(n=>{this.componentRef=n},"setComponentRef");this.shadowRoot||this.attachShadow({mode:"open"});let n=this.querySelector("template");n&&this.shadowRoot&&(this.shadowRoot.appendChild(n.content),n.remove())}static{r(this,"SwishUiElement")}connectedCallback(){this.dispatchEvent(new CustomEvent("connected"))}};var Te="0.133.0",bx=`https://swish.app/cdn/sdk@${Te}/swish.js`,Ix=r(async e=>{if(globalThis.window===void 0)throw new Error("Swish is not supported in this environment");if(globalThis.window.swish)return globalThis.window.swish;let t=rr(e),n=new ns(t);return globalThis.window.swish=n,document.dispatchEvent(new Event("swish-ready")),n.api.initAuth().then(()=>{typeof globalThis.window.Shopify?.analytics?.publish=="function"&&globalThis.window.Shopify.analytics.publish("swish-ready",{market:t.context.localization.market,country:t.context.localization.country,language:t.context.localization.language,rootUrl:t.context.routes.rootUrl,preRelease:Te==="unstable"})}),n},"createSwish"),ns=class{constructor(t){this._mountedPlacements=[];this.ui={createElement:r((t,n)=>this.swishUi.createElement(t,n),"createElement")};this.utils={copyToClipboard:It,createShareUrl:r(t=>bt(this,t),"createShareUrl")};this.state={itemContext:Br(this),itemContextFromIds:qr,itemState:Nr(this),itemCount:Ur(this),swishQuery:Vr(this),effect:Z,signal:F,computed:de};this.swishOptions=t,this.events=new Nt,this._i18n=as(`${t.ui.baseUrl}/i18n@${Te}`,t.translations),this.swishApiPublisher=new Qn(this.events);let n=Te;this.swishApi=new Hn({responseInterceptor:this.swishApiPublisher.processFetchResponse},this.swishOptions.context,this.events,n,this.swishOptions.auth.tokenUrl),this.ajaxApiPublisher=new Pt(this.events),this.ajaxApi=new At({storeDomain:this.swishOptions.storefront.storeDomain,responseInterceptor:this.ajaxApiPublisher.processFetchResponse}),this.ajaxApi.patchFetch(),this.storefrontApi=new Nn(this.swishOptions.storefront,this.swishOptions.context,this.swishOptions.metafields),this.swishUi=new zn(this),this.query=Mr({events:this.events,cacheBuster:Te,customerId:this.swishOptions.context.customer.id,storeDomain:this.swishOptions.context.myshopifyDomain}),this.events.subscribe(["cart-add","cart-update","cart-change","cart-clear"],()=>{this.ajaxApi.clearCache()}),customElements.get("swish-ui")||customElements.define("swish-ui",Gn),this.intents=new En(this,this.swishUi),si(this),this._mountedPlacements=this.swishOptions.placements.map(i=>{let s=ti(this,i);return s.mount(),{spec:i,...s}})}static{r(this,"SwishApp")}get options(){return this.swishOptions}get storefrontContext(){return this.swishOptions.context}get api(){return this.swishApi}get storefront(){return this.storefrontApi}get ajax(){return this.ajaxApi}get i18n(){return this._i18n}get shopUrl(){return`https://${this.swishOptions.storefront.storeDomain}`}get dom(){return{createLocationObserver:Ze,createPlacement:r(t=>ti(this,t),"createPlacement"),placements:this._mountedPlacements}}};export{Te as VERSION,bt as buildShareListUrl,It as copyToClipboard,Ix as createSwish,On as getSwishQueryStorageKey,bx as swishSdkUrl};
290
+ `),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 ha(e){if(!e)return{};let t={},n=r(i=>{Object.entries(i).forEach(([s,o])=>{if(o!=null){if(typeof o=="object"&&!Array.isArray(o)){n(o);return}if(typeof o=="string"||typeof o=="number"){let a=s.startsWith("--")?s:`--swish-theme-${gh(s)}`;t[a]=wh(s,o)}}})},"walk");return n(e),t}r(ha,"flattenDesignTokens");function gh(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase()}r(gh,"toKebabCase");function wh(e,t){return typeof t=="number"&&!bh(e)?`${t}px`:String(t)}r(wh,"formatDesignValue");function bh(e){let t=e.toLowerCase();return t.includes("fontweight")||t.includes("scale")||t.includes("letterspacing")||t.includes("lineheight")}r(bh,"isNonPxValue");function Ih(e,t){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let i of n)if(e[i]!==t[i])return!1;return!0}r(Ih,"shallowEqualStringMap");var Sh=typeof HTMLElement<"u"?HTMLElement:class{},Jn=class extends Sh{constructor(){super();this.getComponentRef=r(()=>this.componentRef,"getComponentRef");this.setComponentRef=r(n=>{this.componentRef=n},"setComponentRef");this.shadowRoot||this.attachShadow({mode:"open"});let n=this.querySelector("template");n&&this.shadowRoot&&(this.shadowRoot.appendChild(n.content),n.remove())}static{r(this,"SwishUiElement")}connectedCallback(){this.dispatchEvent(new CustomEvent("connected"))}};var ge="0.134.0",wC=`https://swish.app/cdn/sdk@${ge}/swish.js`,bC=r(async e=>{if(globalThis.window===void 0)throw new Error("Swish is not supported in this environment");if(globalThis.window.swish)return globalThis.window.swish;let t=ti(),n=xr(e),i=new ds(n,t);return globalThis.window.swish=i,Lt({baseUrl:e.customiser?.baseUrl,shop:n.context.myshopifyDomain}),document.dispatchEvent(new Event("swish-ready")),i.api.initAuth().then(()=>{typeof globalThis.window.Shopify?.analytics?.publish=="function"&&globalThis.window.Shopify.analytics.publish("swish-ready",{market:n.context.localization.market,country:n.context.localization.country,language:n.context.localization.language,rootUrl:n.context.routes.rootUrl,preRelease:ge==="unstable"})}),i},"createSwish"),ds=class{constructor(t,n){this._mountedPlacements=[];this.ui={createElement:r((t,n)=>this.swishUi.createElement(t,n),"createElement"),showDrawer:r(t=>this.swishUi.showDrawer(t),"showDrawer"),hideDrawer:r(()=>this.swishUi.hideDrawer(),"hideDrawer")};this.utils={copyToClipboard:St,createShareUrl:r(t=>It(this,t),"createShareUrl")};this.state={itemContext:to(this),itemContextFromIds:eo,itemState:so(this),itemCount:ro(this),swishQuery:oo(this),effect:ee,signal:q,computed:pe};this.swishOptions=t,this.isPreview=n,this.events=new Ht,this._i18n=ys(`${t.ui.baseUrl}/i18n@${ge}`,t.translations),this.swishApiPublisher=new Kn(this.events);let i=ge;this.swishApi=new Wn({responseInterceptor:this.swishApiPublisher.processFetchResponse},this.swishOptions.context,this.events,i,this.swishOptions.auth.tokenUrl),this.ajaxApiPublisher=new Tt(this.events),this.ajaxApi=new At({storeDomain:this.swishOptions.storefront.storeDomain,responseInterceptor:this.ajaxApiPublisher.processFetchResponse}),this.ajaxApi.patchFetch(),this.storefrontApi=new Hn(this.swishOptions.storefront,this.swishOptions.context,this.swishOptions.metafields),this.swishUi=new Xn(this,n),this.query=Zr({events:this.events,cacheBuster:ge,customerId:this.swishOptions.context.customer.id,storeDomain:this.swishOptions.context.myshopifyDomain}),this.events.subscribe(["cart-add","cart-update","cart-change","cart-clear"],()=>{this.ajaxApi.clearCache()}),customElements.get("swish-ui")||customElements.define("swish-ui",Jn),this.intents=new Pn(this,this.swishUi),pi(this),n||(this._mountedPlacements=this.swishOptions.placements.map(s=>{let o=Nt(this,s);return o.mount(),{spec:s,...o}}))}static{r(this,"SwishApp")}get options(){return this.swishOptions}get storefrontContext(){return this.swishOptions.context}get api(){return this.swishApi}get storefront(){return this.storefrontApi}get ajax(){return this.ajaxApi}get i18n(){return this._i18n}get shopUrl(){return`https://${this.swishOptions.storefront.storeDomain}`}get dom(){return{createLocationObserver:Ye,createPlacement:r(t=>Nt(this,t),"createPlacement"),placements:this._mountedPlacements}}applyPreview(t){this.swishUi.applyPreview(t.ui),this.intents.applyPreview(t.intents),this._mountedPlacements.forEach(n=>{n.unmount()}),this._mountedPlacements=(t.placements??[]).map(n=>{let i=Nt(this,n);return i.mount(),{spec:n,...i}})}get iconsSignal(){return this.swishUi.icons}};export{ge as VERSION,It as buildShareListUrl,St as copyToClipboard,bC as createSwish,Bn as getSwishQueryStorageKey,Ps as isCustomiserMounted,ni as mountCustomiser,Lt as mountCustomiserIfRequested,wC as swishSdkUrl,ii as unmountCustomiser};