@swishapp/sdk 0.132.0 → 0.133.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/elements/bindings.d.ts +13 -0
- package/dist/elements/index.d.ts +3 -0
- package/dist/elements/init.d.ts +3 -0
- package/dist/elements/swish-drawer-element.d.ts +13 -0
- package/dist/elements/swish-save-element.d.ts +16 -0
- package/dist/storefront-api/load-product-images.d.ts +1 -1
- package/dist/storefront-api/load-product.d.ts +1 -1
- package/dist/storefront-api/storefront-api-client.d.ts +2 -2
- package/dist/swish.d.ts +1 -2
- package/dist/swish.js +29 -29
- package/package.json +1 -1
- package/dist/state/declarative-state.d.ts +0 -2
package/dist/swish.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
var
|
|
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."+(`
|
|
2
2
|
|
|
3
3
|
Keys:
|
|
4
4
|
`+String(t.keys))+(`
|
|
5
5
|
|
|
6
6
|
Values:
|
|
7
|
-
`+String(i)));Gi(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){zi(e,t,i)})}r(dd,"dispatchBatch");function zi(e,t,n){Gi(t);for(var i=0;i<t.keys.length;i++)e.clear(t.keys[i]),t.callbacks[i].reject(n)}r(zi,"failedDispatch");function Gi(e){if(e.cacheHits)for(var t=0;t<e.cacheHits.length;t++)e.cacheHits[t]()}r(Gi,"resolveCacheHits");function pd(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(pd,"getValidMaxBatchSize");function hd(e){var t=e&&e.batchScheduleFn;if(t===void 0)return cd;if(typeof t!="function")throw new TypeError("batchScheduleFn must be a function: "+t);return t}r(hd,"getValidBatchScheduleFn");function fd(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(fd,"getValidCacheKeyFn");function md(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(md,"getValidCacheMap");function yd(e){return e&&e.name?e.name:null}r(yd,"getValidName");function Eo(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(Eo,"isArrayLike");Ro.exports=ld});function ts(e,t="",n=new Map){for(let[i,s]of Object.entries(e)){let o=t?`${t}.${i}`:i;typeof s=="object"&&s!==null?ts(s,o,n):typeof s=="string"&&n.set(o,s)}return n}r(ts,"c");var Ko=new Set(["en"]),ot="en";function ns(e,t){return t?.count===void 0?e:t.count===1?`${e}One`:`${e}Other`}r(ns,"d");function es(e,t,n){t=ns(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(es,"f");function is(e,t){let n=null;async function i(o){let a=await import(`${e}/locales/${o.toLowerCase()}.js`);return ts(a.default)}r(i,"a");function s(o,a){return n?n.has(ns(o,a))?{status:"ready",value:es(n,o,a),key:o}:{status:"missing",value:es(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;Ko.has(o)||(console.warn(`[swish] Unsupported language "${o}", falling back to "${ot}".`),a=ot);let l;try{l=await i(a)}catch(c){if(console.warn(`[swish-i18n] Failed to load locale "${a}".`,c),a!==ot)try{l=await i(ot)}catch{console.warn(`[swish] Failed to load fallback locale "${ot}".`);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(is,"L");var N=r(e=>e.split("/").pop()??"","shopifyGidToId"),Oe=r((e,t)=>`gid://shopify/${e}/${t}`,"shopifyIdToGid"),me=r(e=>e.toLowerCase().replace(".myshopify.com",""),"toShopName");var _e=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 Ct=class{static{r(this,"AjaxApiClient")}constructor(t){this.config=t;let n=me(t.storeDomain);this.cache=new _e(`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 Et=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 at=Math.min,Fe=Math.max,lt=Math.round,ct=Math.floor,be=r(e=>({x:e,y:e}),"createCoords");function Qn(e,t){return typeof e=="function"?e(t):e}r(Qn,"evaluate");function zn(e){return e.split("-")[0]}r(zn,"getSide");function Gn(e){return e.split("-")[1]}r(Gn,"getAlignment");function rs(e){return e==="x"?"y":"x"}r(rs,"getOppositeAxis");function os(e){return e==="y"?"height":"width"}r(os,"getAxisLength");function Rt(e){let t=e[0];return t==="t"||t==="b"?"y":"x"}r(Rt,"getSideAxis");function as(e){return rs(Rt(e))}r(as,"getAlignmentAxis");function Wo(e){return{top:0,right:0,bottom:0,left:0,...e}}r(Wo,"expandPaddingObject");function ls(e){return typeof e!="number"?Wo(e):{top:e,right:e,bottom:e,left:e}}r(ls,"getPaddingObject");function Ne(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(Ne,"rectToClientRect");function cs(e,t,n){let{reference:i,floating:s}=e,o=Rt(t),a=as(t),l=os(a),c=zn(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(Gn(t)){case"start":h[a]-=f*(n&&d?-1:1);break;case"end":h[a]+=f*(n&&d?-1:1);break}return h}r(cs,"computeCoordsFromPlacement");async function us(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}=Qn(t,e),w=ls(h),b=l[f?p==="floating"?"reference":"floating":p],S=Ne(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,A=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l.floating)),D=await(o.isElement==null?void 0:o.isElement(A))?await(o.getScale==null?void 0:o.getScale(A))||{x:1,y:1}:{x:1,y:1},C=Ne(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:k,offsetParent:A,strategy:c}):k);return{top:(S.top-C.top+w.top)/D.y,bottom:(C.bottom-S.bottom+w.bottom)/D.y,left:(S.left-C.left+w.left)/D.x,right:(C.right-S.right+w.right)/D.x}}r(us,"detectOverflow");var Xo=50,ds=r(async(e,t,n)=>{let{placement:i="bottom",strategy:s="absolute",middleware:o=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:us},c=await(a.isRTL==null?void 0:a.isRTL(t)),d=await a.getElementRects({reference:e,floating:t,strategy:s}),{x:u,y:p}=cs(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:A,y:D,data:C,reset:P}=await k({x:u,y:p,initialPlacement:i,placement:f,strategy:s,middlewareData:w,rects:d,platform:l,elements:{reference:e,floating:t}});u=A??u,p=D??p,w[S]={...w[S],...C},P&&h<Xo&&(h++,typeof P=="object"&&(P.placement&&(f=P.placement),P.rects&&(d=P.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:s}):P.rects),{x:u,y:p}=cs(d,f,c)),m=-1)}return{x:u,y:p,placement:f,strategy:s,middlewareData:w}},"computePosition");var Jo=new Set(["left","top"]);async function Yo(e,t){let{placement:n,platform:i,elements:s}=e,o=await(i.isRTL==null?void 0:i.isRTL(s.floating)),a=zn(n),l=Gn(n),c=Rt(n)==="y",d=Jo.has(a)?-1:1,u=o&&c?-1:1,p=Qn(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(Yo,"convertValueToCoords");var ps=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 Yo(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 kt(){return typeof window<"u"}r(kt,"hasWindow");function $e(e){return fs(e)?(e.nodeName||"").toLowerCase():"#document"}r($e,"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=(fs(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}r(Ie,"getDocumentElement");function fs(e){return kt()?e instanceof Node||e instanceof ue(e).Node:!1}r(fs,"isNode");function ve(e){return kt()?e instanceof Element||e instanceof ue(e).Element:!1}r(ve,"isElement");function Re(e){return kt()?e instanceof HTMLElement||e instanceof ue(e).HTMLElement:!1}r(Re,"isHTMLElement");function hs(e){return!kt()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ue(e).ShadowRoot}r(hs,"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 ms(e){return/^(table|td|th)$/.test($e(e))}r(ms,"isTableElement");function ut(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}r(ut,"isTopLayer");var Zo=/transform|translate|scale|rotate|perspective|filter/,ea=/paint|layout|strict|content/,Ue=r(e=>!!e&&e!=="none","isNotNone"),Kn;function Pt(e){let t=ve(e)?ge(e):e;return Ue(t.transform)||Ue(t.translate)||Ue(t.scale)||Ue(t.rotate)||Ue(t.perspective)||!At()&&(Ue(t.backdropFilter)||Ue(t.filter))||Zo.test(t.willChange||"")||ea.test(t.contain||"")}r(Pt,"isContainingBlock");function ys(e){let t=Me(e);for(;Re(t)&&!Ve(t);){if(Pt(t))return t;if(ut(t))return null;t=Me(t)}return null}r(ys,"getContainingBlock");function At(){return Kn==null&&(Kn=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Kn}r(At,"isWebKit");function Ve(e){return/^(html|body|#document)$/.test($e(e))}r(Ve,"isLastTraversableNode");function ge(e){return ue(e).getComputedStyle(e)}r(ge,"getComputedStyle");function dt(e){return ve(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}r(dt,"getNodeScroll");function Me(e){if($e(e)==="html")return e;let t=e.assignedSlot||e.parentNode||hs(e)&&e.host||Ie(e);return hs(t)?t.host:t}r(Me,"getParentNode");function vs(e){let t=Me(e);return Ve(t)?e.ownerDocument?e.ownerDocument.body:e.body:Re(t)&&Je(t)?t:vs(t)}r(vs,"getNearestOverflowAncestor");function Xe(e,t,n){var i;t===void 0&&(t=[]),n===void 0&&(n=!0);let s=vs(e),o=s===((i=e.ownerDocument)==null?void 0:i.body),a=ue(s);if(o){let l=Tt(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 Tt(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}r(Tt,"getFrameElement");function Is(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=lt(n)!==o||lt(i)!==a;return l&&(n=o,i=a),{width:n,height:i,$:l}}r(Is,"getCssDimensions");function Xn(e){return ve(e)?e:e.contextElement}r(Xn,"unwrapElement");function Ye(e){let t=Xn(e);if(!Re(t))return be(1);let n=t.getBoundingClientRect(),{width:i,height:s,$:o}=Is(t),a=(o?lt(n.width):n.width)/i,l=(o?lt(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 ta=be(0);function Ss(e){let t=ue(e);return!At()||!t.visualViewport?ta:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}r(Ss,"getVisualOffsets");function na(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ue(e)?!1:t}r(na,"shouldAddVisualOffsets");function He(e,t,n,i){t===void 0&&(t=!1),n===void 0&&(n=!1);let s=e.getBoundingClientRect(),o=Xn(e),a=be(1);t&&(i?ve(i)&&(a=Ye(i)):a=Ye(e));let l=na(o,n,i)?Ss(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=Tt(w);for(;m&&i&&h!==w;){let b=Ye(m),S=m.getBoundingClientRect(),k=ge(m),A=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+=A,d+=D,w=ue(m),m=Tt(w)}}return Ne({width:u,height:p,x:c,y:d})}r(He,"getBoundingClientRect");function Dt(e,t){let n=dt(e).scrollLeft;return t?t.left+n:He(Ie(e)).left+n}r(Dt,"getWindowScrollBarX");function xs(e,t){let n=e.getBoundingClientRect(),i=n.left+t.scrollLeft-Dt(e,n),s=n.top+t.scrollTop;return{x:i,y:s}}r(xs,"getHTMLOffset");function ia(e){let{elements:t,rect:n,offsetParent:i,strategy:s}=e,o=s==="fixed",a=Ie(i),l=t?ut(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)&&(($e(i)!=="body"||Je(a))&&(c=dt(i)),p)){let h=He(i);d=Ye(i),u.x=h.x+i.clientLeft,u.y=h.y+i.clientTop}let f=a&&!p&&!o?xs(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(ia,"convertOffsetParentRelativeRectToViewportRelativeRect");function sa(e){return Array.from(e.getClientRects())}r(sa,"getClientRects");function ra(e){let t=Ie(e),n=dt(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+Dt(e),l=-n.scrollTop;return ge(i).direction==="rtl"&&(a+=Fe(t.clientWidth,i.clientWidth)-s),{width:s,height:o,x:a,y:l}}r(ra,"getDocumentRect");var gs=25;function oa(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=At();(!u||u&&t==="fixed")&&(l=s.offsetLeft,c=s.offsetTop)}let d=Dt(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<=gs&&(o-=w)}else d<=gs&&(o+=d);return{width:o,height:a,x:l,y:c}}r(oa,"getViewportRect");function aa(e,t){let n=He(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(aa,"getInnerBoundingClientRect");function ws(e,t,n){let i;if(t==="viewport")i=oa(e,n);else if(t==="document")i=ra(Ie(e));else if(ve(t))i=aa(t,n);else{let s=Ss(e);i={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return Ne(i)}r(ws,"getClientRectFromClippingAncestor");function Cs(e,t){let n=Me(e);return n===t||!ve(n)||Ve(n)?!1:ge(n).position==="fixed"||Cs(n,t)}r(Cs,"hasFixedPositionAncestor");function la(e,t){let n=t.get(e);if(n)return n;let i=Xe(e,[],!1).filter(l=>ve(l)&&$e(l)!=="body"),s=null,o=ge(e).position==="fixed",a=o?Me(e):e;for(;ve(a)&&!Ve(a);){let l=ge(a),c=Pt(a);!c&&l.position==="fixed"&&(s=null),(o?!c&&!s:!c&&l.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||Je(a)&&!c&&Cs(e,a))?i=i.filter(u=>u!==a):s=l,a=Me(a)}return t.set(e,i),i}r(la,"getClippingElementAncestors");function ca(e){let{element:t,boundary:n,rootBoundary:i,strategy:s}=e,a=[...n==="clippingAncestors"?ut(t)?[]:la(t,this._c):[].concat(n),i],l=ws(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=ws(t,a[f],s);c=Fe(h.top,c),d=at(h.right,d),u=at(h.bottom,u),p=Fe(h.left,p)}return{width:d-p,height:u-c,x:p,y:c}}r(ca,"getClippingRect");function ua(e){let{width:t,height:n}=Is(e);return{width:t,height:n}}r(ua,"getDimensions");function da(e,t,n){let i=Re(t),s=Ie(t),o=n==="fixed",a=He(e,!0,o,t),l={scrollLeft:0,scrollTop:0},c=be(0);function d(){c.x=Dt(s)}if(r(d,"setLeftRTLScrollbarOffset"),i||!i&&!o)if(($e(t)!=="body"||Je(s))&&(l=dt(t)),i){let h=He(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?xs(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(da,"getRectRelativeToOffsetParent");function Wn(e){return ge(e).position==="static"}r(Wn,"isStaticPositioned");function bs(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(bs,"getTrueOffsetParent");function Es(e,t){let n=ue(e);if(ut(e))return n;if(!Re(e)){let s=Me(e);for(;s&&!Ve(s);){if(ve(s)&&!Wn(s))return s;s=Me(s)}return n}let i=bs(e,t);for(;i&&ms(i)&&Wn(i);)i=bs(i,t);return i&&Ve(i)&&Wn(i)&&!Pt(i)?n:i||ys(e)||n}r(Es,"getOffsetParent");var pa=r(async function(e){let t=this.getOffsetParent||Es,n=this.getDimensions,i=await n(e.floating);return{reference:da(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}},"getElementRects");function ha(e){return ge(e).direction==="rtl"}r(ha,"isRTL");var fa={convertOffsetParentRelativeRectToViewportRelativeRect:ia,getDocumentElement:Ie,getClippingRect:ca,getOffsetParent:Es,getElementRects:pa,getClientRects:sa,getDimensions:ua,getScale:Ye,isElement:ve,isRTL:ha};function Rs(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}r(Rs,"rectsAreEqual");function ma(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=ct(p),m=ct(s.clientWidth-(u+f)),b=ct(s.clientHeight-(p+h)),S=ct(u),A={rootMargin:-w+"px "+-m+"px "+-b+"px "+-S+"px",threshold:Fe(0,at(1,c))||1},D=!0;function C(P){let E=P[0].intersectionRatio;if(E!==c){if(!D)return a();E?a(!1,E):i=setTimeout(()=>{a(!1,1e-7)},1e3)}E===1&&!Rs(d,e.getBoundingClientRect())&&a(),D=!1}r(C,"handleObserve");try{n=new IntersectionObserver(C,{...A,root:s.ownerDocument})}catch{n=new IntersectionObserver(C,A)}n.observe(e)}return r(a,"refresh"),a(!0),o}r(ma,"observeMove");function ks(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=Xn(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?ma(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 A;(A=h)==null||A.observe(t)})),n()}),d&&!c&&h.observe(d),t&&h.observe(t));let w,m=c?He(e):null;c&&b();function b(){let S=He(e);m&&!Rs(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(ks,"autoUpdate");var Ps=ps;var As=r((e,t,n)=>{let i=new Map,s={platform:fa,...n},o={...s.platform,_c:i};return ds(e,t,{...s,platform:o})},"computePosition");function ya(){let e=document.body||document.documentElement;return e?Promise.resolve(e):new Promise(t=>{window.addEventListener("DOMContentLoaded",()=>t(e))})}r(ya,"waitForDOM");function ke({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 ya();a(),o.observe(d,{childList:!0,subtree:!0})},"locateAndObserveElements")(),o}r(ke,"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 Lt(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(Lt,"findNearestElement");function Ts({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(Ts,"createHrefObserver");function Jn(e){let t=e.getAttribute("swish-item-context");return t?t==="location"?globalThis.window?.location??e:Lt(e,t)??e:e}r(Jn,"resolveItemContextSource");function Ds(e,t){return e.getAttribute("swish-item-context")?Jn(e):t}r(Ds,"resolvePlacementItemContextSource");function Yn(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}ga(t),n=ke({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=Ms(d,t.mount.at);if(!f)return;let h=await(typeof t.element=="function"?t.element(t):Oa(e,t.element));if(!h)return;if(h.setAttribute("swish-placement-element",t.id),typeof t.element!="function"){let E=t.element;E.props&&_a(h,E.props),E.classNames&&Bs(h,E.classNames)}let w;t.container&&(w=La(t.id,t.container),w.appendChild(h));let m,b=w??h;if(t.layout?.type==="overlay"){Pa(f);let E=t.layout.anchor??"bottom-right";b.setAttribute("swish-placement-overlay",t.id),b.setAttribute("swish-placement-anchor",E)}else t.layout?.type==="anchored"&&b.setAttribute("swish-placement-anchored",t.id);let S=!1,k;if(t.layout?.type==="inline"){let E=t.layout,B=E.rowSelector?f.closest(E.rowSelector):null;B?m=B:(m=Da(t.id,f,E),S=!0),k=m.getAttribute("swish-placement-inline-row"),m.setAttribute("swish-placement-inline-row",t.id)}let A=w??h;if(!ka(f,A,p)){try{A.remove()}catch{}return}if(t.layout?.type==="anchored"){let E=Ms(d,t.layout.to)??f,B=Aa(E,b,t.layout);u.push(B)}let C={targetEl:d,renderTargetEl:f,mountEl:h,containerEl:w,rowEl:m,rowWasCreated:S,rowInlineAttrPrevValue:k,cleanupFns:u,ownsNode:!0};i.set(d,C);let P={id:t.id,targetEl:d,renderTargetEl:f,mountEl:C.mountEl,containerEl:w,rowEl:m,cleanup:r(E=>u.push(E),"cleanup")};t.element?.name==="save-button"&&va(e,P),t.onMount?.(P)},"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(Yn,"createPlacement");var va=r((e,{mountEl:t,targetEl:n,cleanup:i})=>{let s=Ds(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 ga(e){let t=wa(e.id),n=Ra(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(ga,"ensurePlacementStylesheet");function wa(e){return`swish-placement-style-${ba(e)}`}r(wa,"getPlacementStyleId");function ba(e){return e.replace(/[^a-zA-Z0-9\-_]/g,"_")}r(ba,"cssEscapeId");function Ls(e){return`--swish-placement-${Ia(String(e))}`}r(Ls,"designKeyToCSSVar");function Ia(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase()}r(Ia,"toKebabCase");function Sa(e){return Object.entries(e??{sm:500,lg:700}).map(([i,s])=>({name:i,minWidth:s})).sort((i,s)=>i.minWidth-s.minWidth)}r(Sa,"getBreakpoints");function qs(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(qs,"normalizeResponsiveValue");var xa=new Set(["fontWeight","lineHeight","pressedScale","backgroundAlpha","pressedOpacity","pressedScale"]);function Os(e,t){if(t!=null)return typeof t=="number"&&!xa.has(e)?`${t}px`:String(t)}r(Os,"formatDesignValue");function Ca(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=qs(d,i),p=Os(String(c),u.base);p!==void 0&&s.push(`${Ls(c)}:${p};`);for(let f of n){let h=u[f.name],w=Os(String(c),h);w!==void 0&&(o[f.name]||(o[f.name]=[]),o[f.name].push(`${Ls(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(Ca,"emitDesignCSS");function Ot(e){return e==null?"0px":typeof e=="number"?`${e}px`:e}r(Ot,"formatOffsetValue");function _s(e){return e==null?"":typeof e=="number"?`${e}`:e}r(_s,"formatZIndexValue");function Ea(e,t,n){let i=new Set(n.map(d=>d.name)),s=qs(t,i),o=s.base??{},a=Ot(o.x),l=Ot(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=Ot(u.x),f=Ot(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(Ea,"emitOverlayOffsetCSS");function Ra(e){let t=e.id,n=Sa(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=Ea(t,e.layout.offset,n),l=e.layout.zIndex?`[swish-placement-overlay="${t}"]{--swish-placement-overlay-z:${_s(e.layout.zIndex)};}`:"";o+=a+l+s}else if(e.layout?.type==="anchored"){let a=e.layout.zIndex?_s(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=Ca(t,e.design,n);a&&(o+=a)}return e.css&&(o+=e.css.trim()),o}r(Ra,"buildPlacementCSS");function Ms(e,t){if(!t||t==="target")return e;if(typeof t=="string"&&(t={nearest:t}),"nearest"in t)return Lt(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(Ms,"resolveMountTarget");function ka(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(ka,"insertIntoDOM");function Pa(e){let t=e.parentElement;return t?(window.getComputedStyle(t).position==="static"&&(t.style.position="relative"),t):null}r(Pa,"ensureRelativeParent");function Aa(e,t,n){let i=[];return n.inside?i.push(Ta(n.offset??0)):n.offset&&i.push(Ps(n.offset)),ks(e,t,r(()=>{As(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(Aa,"setupAnchoredPosition");function Ta(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(Ta,"anchoredInsideMiddleware");function Da(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(Da,"wrapWithFlexRow");function La(e,t){let n=t.tag||"div",i=document.createElement(n);return i.setAttribute("swish-placement-container",e),t.classNames&&Bs(i,t.classNames),i}r(La,"createContainer");function Oa(e,t){return e.ui.createElement(t.name,{})}r(Oa,"createElement");function _a(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(_a,"applyProps");function Bs(e,t){e.classList.add(...t)}r(Bs,"applyClassNames");var _t=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 Ma=/\/products\/([^/?#]+)(?:\?(?:[^#]*?&)?variant=(\d+))?/,pt=r(e=>{let t=e.match(Ma);return t?{productHandle:decodeURIComponent(t[1]),variantId:t[2]}:null},"parseProductUrl"),Fs=r(({source:e,onProductUrlChange:t})=>{let n=r(i=>{let s=pt(i);s?.productHandle&&t(s)},"handleChange");if(e instanceof HTMLAnchorElement)return Ts({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 Zn;function ei(e){return{lang:e?.lang??Zn?.lang,message:e?.message,abortEarly:e?.abortEarly??Zn?.abortEarly,abortPipeEarly:e?.abortPipeEarly??Zn?.abortPipeEarly}}r(ei,"getGlobalConfig");var qa;function Ba(e){return qa?.get(e)}r(Ba,"getGlobalMessage");var Fa;function ja(e){return Fa?.get(e)}r(ja,"getSchemaMessage");var Na;function Ua(e,t){return Na?.get(e)?.get(t)}r(Ua,"getSpecificMessage");function ht(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(ht,"_stringify");function ne(e,t,n,i,s){let o=s&&"input"in s?s.input:n.value,a=s?.expected??e.expects??null,l=s?.received??ht(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??Ua(e.reference,c.lang)??(d?ja(c.lang):null)??i.message??Ba(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(ne,"_addIssue");function de(e){return{version:1,vendor:"valibot",validate(t){return e["~run"]({value:t},ei())}}}r(de,"_getStandardProps");function $a(e,t){return Object.hasOwn(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}r($a,"_isValidObjectKey");function ti(e,t){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??"never"}r(ti,"_joinExpects");var Va=class extends Error{static{r(this,"ValiError")}constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function ft(e,t){return{kind:"validation",type:"min_length",reference:ft,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(n,i){return n.typed&&n.value.length<this.requirement&&ne(this,"length",n,i,{received:`${n.value.length}`}),n}}}r(ft,"minLength");function Se(e,t){return{kind:"validation",type:"min_value",reference:Se,async:!1,expects:`>=${e instanceof Date?e.toJSON():ht(e)}`,requirement:e,message:t,"~run"(n,i){return n.typed&&!(n.value>=this.requirement)&&ne(this,"value",n,i,{received:n.value instanceof Date?n.value.toJSON():ht(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 Ha(e,t,n){return typeof e.fallback=="function"?e.fallback(t,n):e.fallback}r(Ha,"getFallback");function Ns(e,t,n){return typeof e.default=="function"?e.default(t,n):e.default}r(Ns,"getDefault");function z(e,t){return{kind:"schema",type:"array",reference:z,expects:"Array",async:!1,item:e,message:t,get"~standard"(){return de(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 ne(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 de(this)},"~run"(t,n){return typeof t.value=="boolean"?t.typed=!0:ne(this,"type",t,n),t}}}r(T,"boolean");function ni(e,t){return{kind:"schema",type:"instance",reference:ni,expects:e.name,async:!1,class:e,message:t,get"~standard"(){return de(this)},"~run"(n,i){return n.value instanceof this.class?n.typed=!0:ne(this,"type",n,i),n}}}r(ni,"instance");function H(e,t){return{kind:"schema",type:"literal",reference:H,expects:ht(e),async:!1,literal:e,message:t,get"~standard"(){return de(this)},"~run"(n,i){return n.value===this.literal?n.typed=!0:ne(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 de(this)},"~run"(t,n){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:ne(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 de(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]:Ns(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]=Ha(a);else if(a.type!=="exact_optional"&&a.type!=="optional"&&a.type!=="nullish"&&(ne(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 ne(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 de(this)},"~run"(n,i){return n.value===void 0&&(this.default!==void 0&&(n.value=Ns(this,n,i)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,i)}}}r(y,"optional");function se(e,t){return{kind:"schema",type:"picklist",reference:se,expects:ti(e.map(ht),"|"),async:!1,options:e,message:t,get"~standard"(){return de(this)},"~run"(n,i){return this.options.includes(n.value)?n.typed=!0:ne(this,"type",n,i),n}}}r(se,"picklist");function te(e,t,n){return{kind:"schema",type:"record",reference:te,expects:"Object",async:!1,key:e,value:t,message:n,get"~standard"(){return de(this)},"~run"(i,s){let o=i.value;if(o&&typeof o=="object"){i.typed=!0,i.value={};for(let a in o)if($a(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 ne(this,"type",i,s);return i}}}r(te,"record");function x(e){return{kind:"schema",type:"string",reference:x,expects:"string",async:!1,message:e,get"~standard"(){return de(this)},"~run"(t,n){return typeof t.value=="string"?t.typed=!0:ne(this,"type",t,n),t}}}r(x,"string");function js(e){let t;if(e)for(let n of e)t?t.push(...n.issues):t=n.issues;return t}r(js,"_subIssues");function V(e,t){return{kind:"schema",type:"union",reference:V,expects:ti(e.map(n=>n.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return de(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];ne(this,"type",n,i,{issues:js(o)}),n.typed=!0}else{if(a?.length===1)return a[0];ne(this,"type",n,i,{issues:js(a)})}return n}}}r(V,"union");function re(){return{kind:"schema",type:"unknown",reference:re,expects:"unknown",async:!1,get"~standard"(){return de(this)},"~run"(e){return e.typed=!0,e}}}r(re,"unknown");function Qe(e,t,n){return{kind:"schema",type:"variant",reference:Qe,expects:"Object",async:!1,key:e,options:t,message:n,get"~standard"(){return de(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;ne(this,"type",i,s,{input:o[c],expected:ti(d,"|"),path:[{type:"object",origin:"value",input:o,key:c,value:o[c]}]})}else ne(this,"type",i,s);return i}}}r(Qe,"variant");function Us(e,t,n){let i=e["~run"]({value:t},ei(n));if(i.issues)throw new Va(i.issues);return i.value}r(Us,"parse");function M(...e){return{...e[0],pipe:e,get"~standard"(){return de(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},ei(n));return{typed:i.typed,success:!i.issues,output:i.value,issues:i.issues}}r(q,"safeParse");var et=M(V([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 Qa=V([I({variantId:et,quantity:y(M(_(),Se(1)),1)}),I({items:M(z(I({variantId:et,quantity:y(M(_(),Se(1)),1)})),ft(1))})]),Mt=class extends R{static{r(this,"CreateCartLineHandler")}async invoke(t){let n=q(Qa,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 qt=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 za=I({listId:x()}),Bt=class extends R{static{r(this,"DeleteListHandler")}async invoke(t){let n=q(za,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 Ga=I({itemId:x()}),Ft=class extends R{static{r(this,"EditItemListsHandler")}async invoke(t){let n=q(Ga,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 Ka=I({itemId:M(x()),productId:M(V([M(x(),U(N)),_()]),U(e=>Number(e)),_()),variantId:y(M(V([M(x(),U(N)),_()]),U(e=>Number(e)),_()))}),jt=class extends R{static{r(this,"EditItemVariantHandler")}async invoke(t){let n=q(Ka,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 Wa=I({listId:x(),access:se(["public","private"])}),Nt=class extends R{static{r(this,"EditListAccessHandler")}async invoke(t){let n=q(Wa,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 Xa=I({listId:x()}),Ut=class extends R{static{r(this,"EditListHandler")}async invoke(t){let n=q(Xa,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 Ja=I({variantId:et,quantity:y(M(_(),Se(1)),1)}),Ya=150,Za=V([I({variantId:et,quantity:y(M(_(),Se(1)),1)}),I({items:M(z(Ja),ft(1))})]),$t=class extends R{static{r(this,"InitiateCheckoutHandler")}async invoke(t){let n=q(Za,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),Ya),{intent:"initiate:checkout",code:"ok",data:{checkoutUrl:a.href}}}};var el=I({productId:M(V([M(x(),U(N)),_()]),U(e=>Number(e)),_()),variantId:y(M(V([M(x(),U(N)),_()]),U(Number),_()))}),Vt=class extends R{static{r(this,"InitiateQuickBuyHandler")}async invoke(t){let n=q(el,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 tl=150,nl=I({returnTo:x()}),Ht=class extends R{static{r(this,"InitiateSignInHandler")}async invoke(t){let n=q(nl,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),tl)}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,Qt=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 zt=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(V([M(x(),U(N)),_()]),U(e=>Number(e)),_()),variantId:y(M(V([M(x(),U(N)),_()]),U(Number),_())),quantity:y(M(_(),Se(1))),tags:y(z(x()))}),Gt=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 mt(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(mt,"buildShareListUrl");async function yt(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(yt,"copyToClipboard");function $s(){let e=navigator.userAgent.includes("Mac OS")&&navigator.maxTouchPoints>1;return/Android|Mobile/i.test(navigator.userAgent)||e}r($s,"isMobileDevice");var rl=I({listId:x()}),Kt=class extends R{static{r(this,"ShareListHandler")}async invoke(t){let n=q(rl,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=mt(this.swish,{publicListId:i}).toString();if($s()&&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 yt(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 zf=I({title:y(x()),text:x(),image:y(x()),action:y(I({label:x(),url:y(x())})),variant:y(se(["compact","full"])),icon:y(x())}),Wt=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 ol=I({itemId:x(),delete:y(T())}),Xt=class extends R{static{r(this,"UnsaveItemHandler")}async invoke(t){let n=q(ol,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 Jt=class extends R{static{r(this,"ViewHomeHandler")}async invoke(t){return{intent:"view:home",code:(await this.ui.showDrawer()).code,data:void 0}}};var al=I({listId:x()}),Yt=class extends R{static{r(this,"ViewListDetailPageMenuHandler")}async invoke(t){let n=q(al,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 ll=I({listId:x(),listType:y(se(["user","smart","shared"]),"user")}),Zt=class extends R{static{r(this,"ViewListHandler")}async invoke(t){let n=q(ll,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 cl=I({listId:x()}),en=class extends R{static{r(this,"ViewListMenuHandler")}async invoke(t){let n=q(cl,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 tn=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 nn=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 ul=I({orderId:M(V([M(x(),U(N)),_()]),U(e=>Number(e)),_())}),sn=class extends R{static{r(this,"ViewOrderHandler")}async invoke(t){let n=q(ul,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 dl=I({orderId:x()}),rn=class extends R{static{r(this,"ViewOrderMenuHandler")}async invoke(t){let n=q(dl,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 on=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 pl=I({productId:M(V([M(x(),U(N)),_()]),U(e=>Number(e)),_()),variantId:y(M(V([M(x(),U(N)),_()]),U(Number),_()))}),an=class extends R{static{r(this,"ViewProductHandler")}async invoke(t){let n=q(pl,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 ln=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 cn=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 Z=class{constructor(t,n,i){this.swish=t;this.ui=n;this.options=i}static{r(this,"IntentHook")}};var un=class extends Z{static{r(this,"AfterCreateCartLineHook")}async invoke(t){this.options.createCartLine.afterComplete?.(t)}};var dn=class extends Z{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 pn=class extends Z{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 hn=class extends Z{static{r(this,"AfterSaveCartLineHook")}async invoke(t){this.options.saveCartLine.afterComplete?.(t)}};var fn=class extends Z{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 mn=class extends Z{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 yn=class extends Z{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 Vs(e){let t=e.startsWith("#")?e.slice(1):e;return t==="swish"||t.startsWith("swish-")}r(Vs,"isSwishHash");var vn=class extends Z{static{r(this,"BeforeViewHomeHook")}async invoke(){Vs(window.location.hash)||window.history.replaceState(window.history.state,"",window.location.pathname+window.location.search+"#swish")}};var gn=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 Mt(this.swish,this.ui,this.eventBus,this.options),"initiate:checkout":new $t(this.swish,this.ui,this.eventBus,this.options),"save:item":new Gt(this.swish,this.ui,this.eventBus,this.options),"save:cart-line":new zt(this.swish,this.ui,this.eventBus,this.options),"unsave:item":new Xt(this.swish,this.ui,this.eventBus,this.options),"edit:item-variant":new jt(this.swish,this.ui,this.eventBus,this.options),"edit:item-lists":new Ft(this.swish,this.ui,this.eventBus,this.options),"create:list":new qt(this.swish,this.ui,this.eventBus,this.options),"edit:list":new Ut(this.swish,this.ui,this.eventBus,this.options),"edit:list-access":new Nt(this.swish,this.ui,this.eventBus,this.options),"delete:list":new Bt(this.swish,this.ui,this.eventBus,this.options),"view:home":new Jt(this.swish,this.ui,this.eventBus,this.options),"initiate:share":new Kt(this.swish,this.ui,this.eventBus,this.options),"view:list":new Zt(this.swish,this.ui,this.eventBus,this.options),"view:lists":new tn(this.swish,this.ui,this.eventBus,this.options),"view:orders":new on(this.swish,this.ui,this.eventBus,this.options),"view:order":new sn(this.swish,this.ui,this.eventBus,this.options),"view:saves":new cn(this.swish,this.ui,this.eventBus,this.options),"view:notifications":new nn(this.swish,this.ui,this.eventBus,this.options),"view:profile":new ln(this.swish,this.ui,this.eventBus,this.options),"view:product":new an(this.swish,this.ui,this.eventBus,this.options),"view:list-menu":new en(this.swish,this.ui,this.eventBus,this.options),"view:order-menu":new rn(this.swish,this.ui,this.eventBus,this.options),"view:list-detail-page-menu":new Yt(this.swish,this.ui,this.eventBus,this.options),"initiate:sign-in":new Ht(this.swish,this.ui,this.eventBus,this.options),"initiate:sign-out":new Qt(this.swish,this.ui,this.eventBus,this.options),"initiate:quick-buy":new Vt(this.swish,this.ui,this.eventBus,this.options),"show:toast":new Wt(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=pt(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 vn(this.swish,this.ui,this.options).invoke()}),this.eventBus.addEventListener("create:cart-line",t=>{new un(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("save:item",t=>{new fn(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("edit:item-lists",t=>{new dn(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("view:home",t=>{new yn(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("edit:list-access",t=>{new pn(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("initiate:share",t=>{new mn(this.swish,this.ui,this.options).invoke(t.detail.response)}),this.eventBus.addEventListener("save:cart-line",t=>{new hn(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(){ke({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")}),ke({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 K=y(te(x(),V([x(),_()])),{}),hl=I({url:y(x(),""),altText:y(x(),"")}),fl=I({id:x(),enabled:T(),intent:x()}),ml=I({type:H("drawer-header"),hidden:y(T(),!1),design:K,options:y(I({title:y(x(),""),logo:y(hl,{url:"",altText:""}),useCloseButton:y(T(),!1),accountButton:y(T(),!0),notificationButton:y(T(),!0)}),{title:"",logo:{url:"",altText:""},useCloseButton:!1,accountButton:!0,notificationButton:!0})}),yl=I({type:H("drawer-footer"),hidden:y(T(),!1),design:K,options:y(I({displayType:y(se(["floating","docked"]),"docked"),showIcons:y(T(),!1),showText:y(T(),!0),items:y(z(fl),[{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"}]})}),vl=Qe("type",[ml,yl]),gl=I({type:se(["sign-in","notifications","recently-viewed","saved-from-cart","saved-items","lists"]),hidden:y(T(),!1),design:K,options:y(te(x(),re()),{})}),wl=I({title:x(),url:x()}),bl=I({type:H("mini-menu"),hidden:y(T(),!1),design:K,options:y(te(x(),re()),{}),items:y(z(wl),[])}),Il=I({type:H("content-block"),hidden:y(T(),!1),design:K,options:y(te(x(),re()),{}),title:y(x()),body:y(x()),image:y(I({url:x(),width:y(_()),height:y(_())})),link:y(I({url:x(),target:y(se(["_self","_blank"]))}))}),Sl=I({type:H("featured-collection"),hidden:y(T(),!1),design:K,options:y(te(x(),re()),{}),handle:x()}),xl=Qe("type",[gl,bl,Il,Sl]),Cl=I({type:H("lists-section"),hidden:y(T(),!1),design:K,options:y(I({display:y(se(["myLists","forYouLists"]),"myLists"),layout:y(se(["list","slider"]),"slider")}),{display:"myLists",layout:"slider"})}),El=I({type:H("all-items-grid"),hidden:y(T(),!1),design:K,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})}),Rl=Qe("type",[Cl,El]),kl=I({type:H("lists-grid"),hidden:y(T(),!1),design:K,options:y(I({displayType:y(se(["list","slider"]),"slider")}),{displayType:"slider"})}),Pl=kl,Al=I({type:H("list-items-grid"),hidden:y(T(),!1),design:K,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})}),Tl=Al,Dl=I({type:H("list-items-grid"),hidden:y(T(),!1),design:K,options:y(I({showVariantOptionNames:y(T(),!1),enableVariantChange:y(T(),!1)}),{showVariantOptionNames:!1,enableVariantChange:!1})}),Ll=Dl,Ol=I({type:H("orders-list"),hidden:y(T(),!1),design:K,options:y(te(x(),re()),{})}),_l=Ol,Ml=I({type:H("order-info"),hidden:y(T(),!1),design:K,options:y(te(x(),re()),{})}),ql=I({type:H("order-items"),hidden:y(T(),!1),design:K,options:y(te(x(),re()),{})}),Bl=I({type:H("order-actions"),hidden:y(T(),!1),design:K,options:y(te(x(),re()),{})}),Fl=Qe("type",[Ml,ql,Bl]),jl=I({type:H("image-slider"),hidden:y(T(),!1),design:K,options:y(I({flush:y(T(),!0),loop:y(T(),!1)}),{flush:!0,loop:!1})}),Nl=I({type:H("product-info"),hidden:y(T(),!1),design:K,options:y(I({descriptionMaxLines:y(_(),4),variantSelectDisplayType:y(se(["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}})}),Ul=I({type:H("buy-buttons"),hidden:y(T(),!1),design:K,options:y(I({shopPay:y(T(),!1)}),{shopPay:!1})}),$l=I({type:H("complementary-products"),hidden:y(T(),!1),design:K,options:y(te(x(),re()),{})}),Vl=I({type:H("related-products"),hidden:y(T(),!1),design:K,options:y(te(x(),re()),{})}),Hl=Qe("type",[jl,Nl,Ul,$l,Vl]),Ql=I({type:H("profile-form"),hidden:y(T(),!1),design:K,options:y(te(x(),re()),{})}),zl=Ql,Gl=I({type:H("notifications-list"),hidden:y(T(),!1),design:K,options:y(te(x(),re()),{})}),Kl=Gl,Wl=I({sections:y(z(vl),[{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"}]}}])}),Xl=I({sections:y(z(xl),[{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"}]}])}),Jl=I({sections:y(z(Rl),[{type:"lists-section",options:{display:"myLists"}},{type:"lists-section",options:{display:"forYouLists"}},{type:"all-items-grid"}])}),Yl=I({sections:y(z(Pl),[{type:"lists-grid"}])}),Zl=I({sections:y(z(Tl),[{type:"list-items-grid"}])}),ec=I({sections:y(z(Ll),[{type:"list-items-grid"}])}),tc=I({sections:y(z(_l),[{type:"orders-list"}])}),nc=I({sections:y(z(Fl),[{type:"order-info"},{type:"order-items"},{type:"order-actions"}])}),ic=I({sections:y(z(Hl),[{type:"image-slider"},{type:"product-info"},{type:"buy-buttons"},{type:"complementary-products"},{type:"related-products"}])}),sc=I({sections:y(z(zl),[{type:"profile-form"}])}),rc=I({sections:y(z(Kl),[{type:"notifications-list"}])}),Hs=I({baseUrl:y(x(),"https://swish.app/cdn"),css:y(z(V([x(),ni(URL)])),[]),design:y(te(x(),re()),{}),icons:y(te(x(),x()),{}),images:y(I({baseTint:y(T(),!0)}),{baseTint:!0}),drawer:y(Wl,{}),home:y(Xl,{}),saves:y(Jl,{}),lists:y(Yl,{}),listDetail:y(ec,{}),listDetailPage:y(Zl,{}),orders:y(tc,{}),orderDetail:y(nc,{}),productDetail:y(ic,{}),profile:y(sc,{}),notifications:y(rc,{})});var Qs=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:Us(Hs,e.ui??{})}),"createSwishOptions");function zs(e){return N(String(e).trim())}r(zs,"normalizeSwishQueryId");function wn(e){let t=e.productId?zs(e.productId):"",n=e.variantId?zs(e.variantId):"";return n?["swish","items",t,n]:["swish","items",t]}r(wn,"swishItemsQueryKey");var oc=["item-create","item-update","item-delete"],Gs="auth-cache-clear",Ks="token-update";function Ws({events:e,queryClient:t}){return e.subscribe([...oc,Gs,Ks],n=>{if(!(n instanceof CustomEvent))return;if(n.type===Gs){t.clear();return}if(n.type===Ks){t.invalidateQueries({queryKey:["swish"]});return}if(!n.detail?.productId)return;let i=wn({productId:n.detail.productId});t.invalidateQueries({queryKey:i})})}r(Ws,"bindSwishItemQueryInvalidation");var Pe=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 ac=class extends Pe{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"}},tt=new ac;var lc={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")},cc=class{static{r(this,"TimeoutManager")}#e=lc;#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 cc;function Xs(e){setTimeout(e,0)}r(Xs,"systemSetTimeoutZero");var Zs=typeof window>"u"||"Deno"in globalThis;function W(){}r(W,"noop");function er(e,t){return typeof e=="function"?e(t):e}r(er,"functionalUpdate");function vt(e){return typeof e=="number"&&e>=0&&e!==1/0}r(vt,"isValidTimeout");function bn(e,t){return Math.max(e+(t||0)-Date.now(),0)}r(bn,"timeUntilStale");function xe(e,t){return typeof e=="function"?e(t):e}r(xe,"resolveStaleTime");function pe(e,t){return typeof e=="function"?e(t):e}r(pe,"resolveEnabled");function si(e,t){let{type:n="all",exact:i,fetchStatus:s,predicate:o,queryKey:a,stale:l}=e;if(a){if(i){if(t.queryHash!==gt(a,t.options))return!1}else if(!it(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(si,"matchQuery");function ri(e,t){let{exact:n,status:i,predicate:s,mutationKey:o}=e;if(o){if(!t.options.mutationKey)return!1;if(n){if(nt(t.options.mutationKey)!==nt(o))return!1}else if(!it(t.options.mutationKey,o))return!1}return!(i&&t.state.status!==i||s&&!s(t))}r(ri,"matchMutation");function gt(e,t){return(t?.queryKeyHashFn||nt)(e)}r(gt,"hashQueryKeyByOptions");function nt(e){return JSON.stringify(e,(t,n)=>ii(n)?Object.keys(n).sort().reduce((i,s)=>(i[s]=n[s],i),{}):n)}r(nt,"hashKey");function it(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>it(e[n],t[n])):!1}r(it,"partialMatchKey");var uc=Object.prototype.hasOwnProperty;function tr(e,t,n=0){if(e===t)return e;if(n>500)return t;let i=Js(e)&&Js(t);if(!i&&!(ii(e)&&ii(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:uc.call(e,p))&&d++;continue}if(f===null||h===null||typeof f!="object"||typeof h!="object"){c[p]=h;continue}let w=tr(f,h,n+1);c[p]=w,w===f&&d++}return o===l&&d===o?e:c}r(tr,"replaceEqualDeep");function In(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(In,"shallowEqualObjects");function Js(e){return Array.isArray(e)&&e.length===Object.keys(e).length}r(Js,"isPlainArray");function ii(e){if(!Ys(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!Ys(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}r(ii,"isPlainObject");function Ys(e){return Object.prototype.toString.call(e)==="[object Object]"}r(Ys,"hasObjectPrototype");function nr(e){return new Promise(t=>{Ae.setTimeout(t,e)})}r(nr,"sleep");function wt(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?tr(e,t):t}r(wt,"replaceData");function ir(e,t,n=0){let i=[...e,t];return n&&i.length>n?i.slice(1):i}r(ir,"addToEnd");function sr(e,t,n=0){let i=[t,...e];return n&&i.length>n?i.slice(0,-1):i}r(sr,"addToStart");var bt=Symbol();function Sn(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===bt?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}r(Sn,"ensureQueryFn");function rr(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(rr,"addConsumeAwareSignal");var ze=(()=>{let e=r(()=>Zs,"isServerFn");return{isServer(){return e()},setIsServer(t){e=t}}})();function It(){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(It,"pendingThenable");function or(e){let t;if(e.then(n=>(t=n,n),W)?.catch(W),t!==void 0)return{data:t}}r(or,"tryResolveSync");function ar(e){return e}r(ar,"defaultTransformerFn");function dc(e){return{mutationKey:e.options.mutationKey,state:e.state,...e.options.scope&&{scope:e.options.scope},...e.meta&&{meta:e.meta}}}r(dc,"dehydrateMutation");function pc(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(W),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(pc,"dehydrateQuery");function lr(e){return e.state.isPaused}r(lr,"defaultShouldDehydrateMutation");function cr(e){return e.state.status==="success"}r(cr,"defaultShouldDehydrateQuery");function hc(e){return!0}r(hc,"defaultShouldRedactErrors");function oi(e,t={}){let n=t.shouldDehydrateMutation??e.getDefaultOptions().dehydrate?.shouldDehydrateMutation??lr,i=e.getMutationCache().getAll().flatMap(c=>n(c)?[dc(c)]:[]),s=t.shouldDehydrateQuery??e.getDefaultOptions().dehydrate?.shouldDehydrateQuery??cr,o=t.shouldRedactErrors??e.getDefaultOptions().dehydrate?.shouldRedactErrors??hc,a=t.serializeData??e.getDefaultOptions().dehydrate?.serializeData??ar,l=e.getQueryCache().getAll().flatMap(c=>s(c)?[pc(c,a,o)]:[]);return{mutations:i,queries:l}}r(oi,"dehydrate");function ai(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??ar,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?or(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",A=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:C,...P}=d;S.setState({...P,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&&!A&&(h===void 0||h>S.state.dataUpdatedAt)&&S.fetch(void 0,{initialPromise:Promise.resolve(f).then(o)}).catch(W)})}r(ai,"hydrate");var fc=Xs;function mc(){let e=[],t=0,n=r(l=>{l()},"notifyFn"),i=r(l=>{l()},"batchNotifyFn"),s=fc,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(mc,"createNotifyManager");var X=mc();var yc=class extends Pe{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}},st=new yc;function vc(e){return Math.min(1e3*2**e,3e4)}r(vc,"defaultRetryDelay");function li(e){return(e??"online")==="online"?st.isOnline():!0}r(li,"canFetch");var xn=class extends Error{static{r(this,"CancelledError")}constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function Cn(e){let t=!1,n=0,i,s=It(),o=r(()=>s.status!=="pending","isResolved"),a=r(m=>{if(!o()){let b=new xn(m);f(b),e.onCancel?.(b)}},"cancel"),l=r(()=>{t=!0},"cancelRetry"),c=r(()=>{t=!1},"continueRetry"),d=r(()=>tt.isFocused()&&(e.networkMode==="always"||st.isOnline())&&e.canRun(),"canContinue"),u=r(()=>li(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??(ze.isServer()?0:3),A=e.retryDelay??vc,D=typeof A=="function"?A(n,S):A,C=k===!0||typeof k=="number"&&n<k||typeof k=="function"&&k(n,S);if(t||!C){f(S);return}n++,e.onFail?.(n,S),nr(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(Cn,"createRetryer");var En=class{static{r(this,"Removable")}#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),vt(this.gcTime)&&(this.#e=Ae.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(ze.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e&&(Ae.clearTimeout(this.#e),this.#e=void 0)}};var pr=class extends En{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=dr(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=dr(this.options);t.data!==void 0&&(this.setState(ur(t.data,t.dataUpdatedAt)),this.#e=t)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(e,t){let n=wt(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(W).catch(W):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=>pe(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===bt||!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:!bn(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=Sn(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=Cn({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:r(l=>{l instanceof xn&&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 xn){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,...ci(n.data,this.options),fetchMeta:e.meta??null};case"success":let i={...n,...ur(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 ci(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:li(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}r(ci,"fetchState");function ur(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}r(ur,"successState");function dr(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(dr,"getDefaultState");var di=class extends Pe{static{r(this,"QueryObserver")}constructor(e,t){super(),this.options=t,this.#e=e,this.#a=null,this.#r=It(),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),hr(this.#t,this.options)?this.#p():this.updateResult(),this.#w())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ui(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ui(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 pe(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&&!In(this.options,t)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});let i=this.hasListeners();i&&fr(this.#t,n,this.options,t)&&this.#p(),this.updateResult(),i&&(this.#t!==n||pe(this.options.enabled,this.#t)!==pe(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||pe(this.options.enabled,this.#t)!==pe(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 wc(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(W)),t}#y(){this.#b();let e=xe(this.options.staleTime,this.#t);if(ze.isServer()||this.#s.isStale||!vt(e))return;let n=bn(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,!(ze.isServer()||pe(this.options.enabled,this.#t)===!1||!vt(this.#c)||this.#c===0)&&(this.#d=Ae.setInterval(()=>{(this.options.refetchIntervalInBackground||tt.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&&hr(e,t),Ce=B&&fr(e,n,t,i);(ce||Ce)&&(u={...u,...ci(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=wt(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=wt(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",A=m==="error",D=k&&S,C=f!==void 0,E={status:m,fetchStatus:u.fetchStatus,isPending:k,isSuccess:m==="success",isError:A,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:A&&!C,isPaused:u.fetchStatus==="paused",isPlaceholderData:p,isRefetchError:A&&C,isStale:pi(e,t),refetch:this.refetch,promise:this.#r,isEnabled:pe(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let B=E.data!==void 0,ce=E.status==="error"&&!B,Ce=r(ye=>{ce?ye.reject(E.error):B&&ye.resolve(E.data)},"finalizeThenableIfPossible"),Le=r(()=>{let ye=this.#r=E.promise=It();Ce(ye)},"recreateThenable"),ee=this.#r;switch(ee.status){case"pending":e.queryHash===n.queryHash&&Ce(ee);break;case"fulfilled":(ce||E.data!==ee.value)&&Le();break;case"rejected":(!ce||E.error!==ee.reason)&&Le();break}}return E}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),In(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 gc(e,t){return pe(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}r(gc,"shouldLoadOnMount");function hr(e,t){return gc(e,t)||e.state.data!==void 0&&ui(e,t,t.refetchOnMount)}r(hr,"shouldFetchOnMount");function ui(e,t,n){if(pe(t.enabled,e)!==!1&&xe(t.staleTime,e)!=="static"){let i=typeof n=="function"?n(e):n;return i==="always"||i!==!1&&pi(e,t)}return!1}r(ui,"shouldFetchOn");function fr(e,t,n,i){return(e!==t||pe(i.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&pi(e,n)}r(fr,"shouldFetchOptionally");function pi(e,t){return pe(t.enabled,e)!==!1&&e.isStaleByTime(xe(t.staleTime,e))}r(pi,"isStale");function wc(e,t){return!In(e.getCurrentResult(),t)}r(wc,"shouldAssignObserverCurrentProperties");function hi(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=>{rr(w,()=>t.signal,()=>u=!0)},"addSignalProperty"),f=Sn(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 P={client:t.client,queryKey:t.queryKey,pageParam:m,direction:b?"backward":"forward",meta:t.options.meta};return p(P),P},"createQueryFnContext")(),A=await f(k),{maxPages:D}=t.options,C=b?sr:ir;return{pages:C(w.pages,A,D),pageParams:C(w.pageParams,m,D)}},"fetchPage");if(s&&o.length){let w=s==="backward",m=w?bc:mr,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:mr(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(hi,"infiniteQueryBehavior");function mr(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(mr,"getNextPageParam");function bc(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}r(bc,"getPreviousPageParam");var yr=class extends En{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||Ic(),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=Cn({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 Ic(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}r(Ic,"getDefaultState");var vr=class extends Pe{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 yr({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=Rn(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=Rn(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=Rn(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=Rn(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=>ri(t,n))}findAll(e={}){return this.getAll().filter(t=>ri(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(W))))}};function Rn(e){return e.options.scope?.id}r(Rn,"scopeFor");var gr=class extends Pe{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??gt(i,t),o=this.get(s);return o||(o=new pr({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=>si(t,n))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(n=>si(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 fi=class{static{r(this,"QueryClient")}#e;#t;#n;#s;#i;#o;#r;#a;constructor(e={}){this.#e=e.queryCache||new gr,this.#t=e.mutationCache||new vr,this.#n=e.defaultOptions||{},this.#s=new Map,this.#i=new Map,this.#o=0}mount(){this.#o++,this.#o===1&&(this.#r=tt.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=st.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=er(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(W).catch(W)}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(W)),s.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(i).then(W)}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(W).catch(W)}fetchInfiniteQuery(e){return e.behavior=hi(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(W).catch(W)}ensureInfiniteQueryData(e){return e.behavior=hi(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return st.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(nt(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#s.values()],n={};return t.forEach(i=>{it(e,i.queryKey)&&Object.assign(n,i.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(nt(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(i=>{it(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=gt(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===bt&&(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 wr(){return new fi({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1,gcTime:1e3*60*60*1,staleTime:1e3*60*10}}})}r(wr,"createSwishQueryClient");var Sc=Symbol.for("preact-signals");function Pn(){if(je>1)je--;else{for(var e,t=!1;St!==void 0;){var n=St;for(St=void 0,mi++;n!==void 0;){var i=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&xr(n))try{n.c()}catch(s){t||(e=s,t=!0)}n=i}}if(mi=0,je--,t)throw e}}r(Pn,"t");function ie(e){if(je>0)return e();je++;try{return e()}finally{Pn()}}r(ie,"n");var j=void 0;function Ir(e){var t=j;j=void 0;try{return e()}finally{j=t}}r(Ir,"o");var br,St=void 0,je=0,mi=0,kn=0;function Sr(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(Sr,"e");function oe(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(oe,"d");oe.prototype.brand=Sc;oe.prototype.h=function(){return!0};oe.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:Ir(function(){var i;(i=t.W)==null||i.call(t)}))};oe.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&&Ir(function(){var s;(s=t.Z)==null||s.call(t)}))}};oe.prototype.subscribe=function(e){var t=this;return ae(function(){var n=t.value,i=j;j=void 0;try{e(n)}finally{j=i}},{name:"sub"})};oe.prototype.valueOf=function(){return this.value};oe.prototype.toString=function(){return this.value+""};oe.prototype.toJSON=function(){return this.value};oe.prototype.peek=function(){var e=j;j=void 0;try{return this.value}finally{j=e}};Object.defineProperty(oe.prototype,"value",{get:r(function(){var e=Sr(this);return e!==void 0&&(e.i=this.i),this.v},"get"),set:r(function(e){if(e!==this.v){if(mi>100)throw new Error("Cycle detected");this.v=e,this.i++,kn++,je++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Pn()}}},"set")});function F(e,t){return new oe(e,t)}r(F,"c");function xr(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(xr,"a");function Cr(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(Cr,"l");function Er(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(Er,"y");function Ge(e,t){oe.call(this,void 0),this.x=e,this.s=void 0,this.g=kn-1,this.f=4,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}r(Ge,"w");Ge.prototype=new oe;Ge.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===kn))return!0;if(this.g=kn,this.f|=1,this.i>0&&!xr(this))return this.f&=-2,!0;var e=j;try{Cr(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,Er(this),this.f&=-2,!0};Ge.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)}oe.prototype.S.call(this,e)};Ge.prototype.U=function(e){if(this.t!==void 0&&(oe.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)}};Ge.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(Ge.prototype,"value",{get:r(function(){if(1&this.f)throw new Error("Cycle detected");var e=Sr(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v},"get")});function he(e,t){return new Ge(e,t)}r(he,"b");function Rr(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,yi(e),i}finally{j=n,Pn()}}}r(Rr,"_");function yi(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Rr(e)}r(yi,"p");function xc(e){if(j!==this)throw new Error("Out-of-order effect");Er(this),j=e,this.f&=-2,8&this.f&&yi(this),Pn()}r(xc,"g");function rt(e,t){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=t?.name,br&&br.push(this)}r(rt,"S");rt.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()}};rt.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Rr(this),Cr(this),je++;var e=j;return j=this,xc.bind(this,e)};rt.prototype.N=function(){2&this.f||(this.f|=2,this.o=St,St=this)};rt.prototype.d=function(){this.f|=8,1&this.f||yi(this)};rt.prototype.dispose=function(){this.d()};function ae(e,t){var n=new rt(e,t);try{n.c()}catch(s){throw n.d(),s}var i=n.d.bind(n);return i[Symbol.dispose]=i,i}r(ae,"m");var Cc="swish-query-cache";function Ec(e){return e.replace(/\.myshopify\.com$/,"")||"unknown-store"}r(Ec,"normalizeStoreKeyPart");function An({customerId:e,storeDomain:t}){let n=e??"guest",i=Ec(t??"");return`${Cc}:${i}:${n}`}r(An,"getSwishQueryStorageKey");var Rc=1e3*60*60*24,kc=1e3;function vi(){return!!globalThis.window?.localStorage}r(vi,"canUseLocalStorage");function Pc(e){if(!vi())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(Pc,"readPersistedState");function Ac(e,t){if(vi())try{globalThis.window.localStorage.setItem(e,JSON.stringify(t))}catch{}}r(Ac,"writePersistedState");function Tc(e){if(vi())try{globalThis.window.localStorage.removeItem(e)}catch{}}r(Tc,"removePersistedState");function Dc(e,t){return Number.isFinite(e.timestamp)?Date.now()-e.timestamp>t:!0}r(Dc,"isPersistedStateExpired");function kr({queryClient:e,cacheBuster:t,customerId:n,storeDomain:i,maxAgeMs:s=Rc,throttleMs:o=kc}){let a=An({customerId:n,storeDomain:i}),l=F(!1),c=Pc(a);c?.buster===t&&!Dc(c,s)?ai(e,c.clientState):c&&Tc(a),l.value=!0;let d=null,u=!1,p=r(()=>{Ac(a,{buster:t,timestamp:Date.now(),clientState:oi(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(kr,"initSwishQueryPersistence");function Pr({events:e,cacheBuster:t,customerId:n,storeDomain:i}){let s=wr(),o=kr({queryClient:s,cacheBuster:t,customerId:n,storeDomain:i});return Ws({events:e,queryClient:s}),{client:s,cacheBuster:t,restored:o.restored,storageKey:o.storageKey,keys:{items:wn}}}r(Pr,"createSwishQuery");var Ar=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"),Tr=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=pt(h);w?.productHandle&&w.productHandle!==f.value.productHandle&&(f.value={...f.value,...w,productId:void 0},Fs({source:t,onProductUrlChange:r(m=>{f.value={...f.value,...m,productId:m.productHandle===f.value.productHandle?f.value.productId:void 0}},"onProductUrlChange")}))}return ae(()=>{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 Dr({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 di(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=ae(()=>{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(Dr,"createTanstackQuerySignal");var gi=50;function Lr(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(Lr,"arraysShallowEqual");function Lc(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(Lc,"pickSavedItem");function Oc(e){ie(()=>{if(e.savedItemsLoading.value=e.apiLoading,e.savedItemsError.value=e.apiError,e.forcedItemId){let o=[e.forcedItemId];Lr(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>=gi&&console.warn(`[swish] item-state query hit the per-product limit (${gi}). Some saved items may be missing.`);let n=t.map(o=>o.id);Lr(e.savedItemIds.value,n)||(e.savedItemIds.value=n);let s=Lc(t,e.variantId,e.policy)?.id??null;s!==e.savedItemId.value&&(e.savedItemId.value=s)})}r(Oc,"syncFromApi");var Or=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=he(()=>{let{productId:Q,loading:J}=t.value;return!Q||J?null:`product:${N(Q)}`}),c=he(()=>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=he(()=>p.value||f.value||h.value),m=F(!1),b=F(!1),S=he(()=>{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:gi,query:Q??void 0},{batch:!0});if("error"in we)throw we.error;return we},"queryFn"),enabled:!J}}),{data:k,loading:A,error:D,refetching:C,dispose:P}=Dr({queryClient:e.query.client,options:S,restored:e.query.restored});i.push(P);let E=t.value.itemId??null,B=F(E),ce=F(E?[E]:[]),Ce=ae(()=>Oc({apiData:k.value,apiLoading:A.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(Ce);async function Le(){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(Le,"unsave");async function ee(){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(ee,"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 xt=await(await e.intents.invoke("save:item",{productId:Q,variantId:fe})).complete;if(xt.code==="ok"){let Zi=xt.data;ie(()=>{B.value=Zi.item.id,p.value=!1}),s.onSave?.(Zi)}else xt.code==="error"&&console.warn("Failed to create item",xt),ie(()=>{p.value=!1,m.value=!1})}r(Y,"save");let Be=he(()=>d.value||w.value||t.value.loading),$=ae(()=>{(m.value||b.value)&&!w.value&&!C.value&&ie(()=>{m.value=!1,b.value=!1})});i.push($);let Ee=he(()=>{let Q=!!B.value,J=p.value||C.value&&m.value,fe=f.value||C.value&&b.value,we="unsaved";return Q?we="saved":J&&(we="saving"),{error:u.value,status:we,savedItemId:B.value,savedItemIds:ce.value,loading:Be.value,submitting:w.value,saved:Q,saving:J,unsaving:fe}});async function jo(){Be.value||(Ee.value.saved&&Ee.value.savedItemId?await Le():Ee.value.saved||await Y())}return r(jo,"toggle"),Object.assign(Ee,{save:Y,unsave:Le,updateLists:ee,updateVariant:ye,update:ee,toggle:jo,setOptions:a,setCallbacks:a,dispose:r(()=>{for(;i.length;)i.pop()?.()},"dispose")})},"itemStateSignal");var _r=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 ae(()=>{ie(()=>{o.value=n.value,a.value=i.value,s.value=t.value?.count??0})}),he(()=>({count:s.value,loading:o.value,error:a.value}))},"itemCountSignal");var _c="token-update",Mr=r(e=>(t,n)=>{let i=F(null),s=F(null),o=F(null),a=F(!n?.skip),l=F(!1),c=he(()=>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"),ae(()=>{if(d(),n?.refetch?.length){let u=[...n.refetch,_c];return e.events.subscribe(u,d)}}),{data:i,pageInfo:s,error:o,loading:a,refetching:c}},"swishQuerySignals");function Mc(e){if(e==="variant"||e==="product"||e==="auto")return e}r(Mc,"parseMatch");function qc(e,t){let n=Jn(t),i=e.state.itemContext(n),s=Mc(t.getAttribute("swish-item-match")),o=e.state.itemState(i,{match:s});e.state.effect(()=>{let{status:l,saved:c}=o.value;t.setAttribute("swish-item-state",l),t.setAttribute("aria-pressed",String(c))}),t.querySelectorAll("[swish-item-label]").forEach(l=>{Bc(e,l,o)});let a=r(()=>{o.toggle()},"onClick");t.addEventListener("click",a)}r(qc,"bindItemState");function Bc(e,t,n){let i=t.textContent??"",s=t.getAttribute("swish-item-label-unsaved")??"Save",o=t.getAttribute("swish-item-label-saved")??"Saved",a={unsaved:s,saved:o,saving:t.getAttribute("swish-item-label-saving")??o};e.state.effect(()=>{t.textContent=a[n.value.status]??i})}r(Bc,"bindItemLabel");function Fc(e,t){let n=e.state.itemCount();e.state.effect(()=>{let{count:i,loading:s}=n.value,o=s?"":String(i);t.setAttribute("swish-item-count",o),t.textContent=o})}r(Fc,"bindItemCount");function qr(e){ke({selector:"[swish-item-state]",onElementFound:r(t=>{qc(e,t)},"onElementFound")}),ke({selector:"[swish-item-count]",onElementFound:r(t=>{Fc(e,t)},"onElementFound")})}r(qr,"initDeclarativeState");var Ke="GraphQL Client";var wi="An error occurred while fetching from the API. Review 'graphQLErrors' for details.",bi="Response returned unexpected Content-Type:",Ii="An unknown error has occurred. The API did not return a data object or any errors in its response.",Tn={json:"application/json",multipart:"multipart/mixed"},Si="X-SDK-Variant",xi="X-SDK-Version",Fr="shopify-graphql-client",jr="1.4.1",Dn=1e3,Nr=[429,503],Ci=/@(defer)\b/i,Br=`\r
|
|
8
|
-
`,Ur=/boundary="?([^=";]+)"?/i,Ei=Br+Br;function Te(e,t=Ke){return e.startsWith(`${t}`)?e:`${t}: ${e}`}r(Te,"formatErrorMessage");function qe(e){return e instanceof Error?e.message:JSON.stringify(e)}r(qe,"getErrorMessage");function Ri(e){return e instanceof Error&&e.cause?e.cause:void 0}r(Ri,"getErrorCause");function ki(e){return e.flatMap(({errors:t})=>t??[])}r(ki,"combineErrors");function Ln({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(Ln,"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 Pi(e,t){if(e.length===0)return t;let i={[e.pop()]:t};return e.length===0?i:Pi(e,i)}r(Pi,"buildDataObjectByPath");function Hr(e,t){return Object.keys(t||{}).reduce((n,i)=>(typeof t[i]=="object"||Array.isArray(t[i]))&&e[i]?(n[i]=Hr(e[i],t[i]),n):(n[i]=t[i],n),Array.isArray(e)?[...e]:{...e})}r(Hr,"combineObjects");function Ai([e,...t]){return t.reduce(Hr,{...e})}r(Ai,"buildCombinedDataObject");function Ti({clientLogger:e,customFetchApi:t=fetch,client:n=Ke,defaultRetryWaitTime:i=Dn,retriableCodes:s=Nr}){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(Te(`${c>0?`Attempted maximum number of ${c} network retries. Last message - `:""}${qe(f)}`,n))}},"httpFetch");return o}r(Ti,"generateHttpFetch");async function jc(e){return new Promise(t=>setTimeout(t,e))}r(jc,"sleep");function Di({headers:e,url:t,customFetchApi:n=fetch,retries:i=0,logger:s}){Ln({client:Ke,retries:i});let o={headers:e,url:t,retries:i},a=Nc(s),l=Ti({customFetchApi:n,clientLogger:a,defaultRetryWaitTime:Dn}),c=Uc(l,o),d=$c(c),u=Wc(c);return{config:o,fetch:c,request:d,requestStream:u}}r(Di,"createGraphQLClient");function Nc(e){return t=>{e&&e(t)}}r(Nc,"generateClientLogger");async function Qr(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:Te(t?wi:Ii),...le("graphQLErrors",t),response:e}}:{}}}r(Qr,"processJSONResponse");function Uc(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});Ln({client:Ke,retries:d});let h=Object.entries({...n,...l}).reduce((m,[b,S])=>(m[b]=Array.isArray(S)?S.join(", "):S.toString(),m),{});return!h[Si]&&!h[xi]&&(h[Si]=Fr,h[xi]=jr),e([c??t,{method:"POST",headers:h,body:f,signal:p,keepalive:u}],1,d??i)}}r(Uc,"generateFetch");function $c(e){return async(...t)=>{if(Ci.test(t[0]))throw new Error(Te("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(Tn.json)?await Qr(n):{errors:{networkStatusCode:i,message:Te(`${bi} ${o}`),response:n}}:{errors:{networkStatusCode:i,message:Te(s),response:n}}}catch(i){return{errors:{message:qe(i),...n==null?{}:{networkStatusCode:n.status,response:n}}}}}}r($c,"generateRequest");async function*Vc(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(Vc,"getStreamBodyIterator");function Hc(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(Ei)+Ei.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(Hc,"readStreamChunk");function Qc(e){return{async*[Symbol.asyncIterator](){yield{...await Qr(e),hasNext:!1}}}}r(Qc,"createJsonResponseAsyncIterator");function zc(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||{},...le("errors",a),...le("extensions",o),hasNext:s};let l=i.map(({data:c,path:d,errors:u})=>({data:c&&d?Pi(d,c):{},...le("errors",u)}));return{data:l.length===1?l[0].data:Ai([...l.map(({data:c})=>c)]),...le("errors",ki(l)),hasNext:s}})}r(zc,"getResponseDataFromChunkBodies");function Gc(e,t){if(e.length>0)throw new Error(wi,{cause:{graphQLErrors:e}});if(Object.keys(t).length===0)throw new Error(Ii)}r(Gc,"validateResponseData");function Kc(e,t){let n=(t??"").match(Ur),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=Vc(e),o={},a;return{async*[Symbol.asyncIterator](){try{let l=!0;for await(let c of Hc(s,i)){let d=zc(c);a=d.find(p=>p.extensions)?.extensions??a;let u=ki(d);o=Ai([o,...d.map(({data:p})=>p)]),l=d.slice(-1)[0].hasNext,Gc(u,o),yield{...le("data",o),...le("extensions",a),hasNext:l}}if(l)throw new Error("Response stream terminated unexpectedly")}catch(l){let c=Ri(l);yield{...le("data",o),...le("extensions",a),errors:{message:Te(qe(l)),networkStatusCode:e.status,...le("graphQLErrors",c?.graphQLErrors),response:e},hasNext:!1}}}}}r(Kc,"createMultipartResponseAsyncInterator");function Wc(e){return async(...t)=>{if(!Ci.test(t[0]))throw new Error(Te("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(Tn.json):return Qc(n);case s.includes(Tn.multipart):return Kc(n,s);default:throw new Error(`${bi} ${s}`,{cause:n})}}catch(n){return{async*[Symbol.asyncIterator](){let i=Ri(n);yield{errors:{message:Te(qe(n)),...le("networkStatusCode",i?.status),...le("response",i)},hasNext:!1}}}}}}r(Wc,"generateRequestStream");function Li({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(Li,"validateDomainAndGetStoreUrl");function On({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(On,"validateApiVersion");function _n(e){let t=e*3-2;return t===10?t:`0${t}`}r(_n,"getQuarterMonth");function Oi(e,t,n){let i=t-n;return i<=0?`${e-1}-${_n(i+4)}`:`${e}-${_n(i)}`}r(Oi,"getPrevousVersion");function zr(){let e=new Date,t=e.getUTCMonth(),n=e.getUTCFullYear(),i=Math.floor(t/3+1);return{year:n,quarter:i,version:`${n}-${_n(i)}`}}r(zr,"getCurrentApiVersion");function _i(){let{year:e,quarter:t,version:n}=zr(),i=t===4?`${e+1}-01`:`${e}-${_n(t+1)}`;return[Oi(e,t,3),Oi(e,t,2),Oi(e,t,1),n,i,"unstable"]}r(_i,"getCurrentSupportedApiVersions");function Mi(e){return t=>({...t??{},...e.headers})}r(Mi,"generateGetHeaders");function qi({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(qi,"generateGetGQLClientParams");var Bi="application/json",Gr="storefront-api-client",Kr="1.0.9",Wr="X-Shopify-Storefront-Access-Token",Xr="Shopify-Storefront-Private-Token",Jr="X-SDK-Variant",Yr="X-SDK-Version",Zr="X-SDK-Variant-Source",We="Storefront API Client";function eo(e){if(e&&typeof window<"u")throw new Error(`${We}: 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 to(e,t){if(!e&&!t)throw new Error(`${We}: a public or private access token must be provided`);if(e&&t)throw new Error(`${We}: only provide either a public or private access token`)}r(to,"validateRequiredAccessTokens");function Fi({storeDomain:e,apiVersion:t,publicAccessToken:n,privateAccessToken:i,clientName:s,retries:o=0,customFetchApi:a,logger:l}){let c=_i(),d=Li({client:We,storeDomain:e}),u={client:We,currentSupportedApiVersions:c,logger:l};On({...u,apiVersion:t}),to(n,i),eo(i);let p=Xc(d,t,u),f={storeDomain:d,apiVersion:t,...n?{publicAccessToken:n}:{privateAccessToken:i},headers:{"Content-Type":Bi,Accept:Bi,[Jr]:Gr,[Yr]:Kr,...s?{[Zr]:s}:{},...n?{[Wr]:n}:{[Xr]:i}},apiUrl:p(),clientName:s},h=Di({headers:f.headers,url:f.apiUrl,retries:o,customFetchApi:a,logger:l}),w=Mi(f),m=Jc(f,p),b=qi({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(Fi,"createStorefrontApiClient");function Xc(e,t,n){return i=>{i&&On({...n,apiVersion:i});let s=(i??t).trim();return`${e}/api/${s}/graphql.json`}}r(Xc,"generateApiUrlFormatter");function Jc(e,t){return n=>n?t(n):e.apiUrl}r(Jc,"generateGetApiUrl");var Mn=`
|
|
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=`
|
|
9
9
|
fragment productImageFields on Image {
|
|
10
10
|
id
|
|
11
11
|
altText
|
|
12
12
|
url
|
|
13
13
|
thumbhash
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
`,$i=`
|
|
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
|
-
`,
|
|
96
|
+
`,Hi=`
|
|
97
97
|
fragment productVariantDataFields on ProductVariant {
|
|
98
98
|
id
|
|
99
99
|
availableForSale
|
|
@@ -122,7 +122,7 @@ Values:
|
|
|
122
122
|
value
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
`;var
|
|
125
|
+
`;var lo=`
|
|
126
126
|
query GetProduct(
|
|
127
127
|
$productId: ID!
|
|
128
128
|
$variantId: ID!
|
|
@@ -147,10 +147,10 @@ Values:
|
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
|
-
${
|
|
151
|
-
${
|
|
152
|
-
${
|
|
153
|
-
`,
|
|
150
|
+
${$i}
|
|
151
|
+
${Hi}
|
|
152
|
+
${jn}
|
|
153
|
+
`,co=`
|
|
154
154
|
query GetProductByHandle(
|
|
155
155
|
$handle: String!
|
|
156
156
|
$variantId: ID!
|
|
@@ -175,10 +175,10 @@ Values:
|
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
|
-
${
|
|
179
|
-
${
|
|
180
|
-
${
|
|
181
|
-
`,
|
|
178
|
+
${$i}
|
|
179
|
+
${Hi}
|
|
180
|
+
${jn}
|
|
181
|
+
`,uo=`
|
|
182
182
|
query GetProductImagesById(
|
|
183
183
|
$ids: [ID!]!
|
|
184
184
|
$country: CountryCode!
|
|
@@ -202,8 +202,8 @@ Values:
|
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
|
-
${
|
|
206
|
-
`,
|
|
205
|
+
${jn}
|
|
206
|
+
`,po=`
|
|
207
207
|
query GetProductRecommendationsById(
|
|
208
208
|
$productId: ID!
|
|
209
209
|
$intent: ProductRecommendationIntent
|
|
@@ -214,7 +214,7 @@ Values:
|
|
|
214
214
|
id
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
`,
|
|
217
|
+
`,ho=`
|
|
218
218
|
query GetProductRecommendationsByHandle(
|
|
219
219
|
$handle: String!
|
|
220
220
|
$intent: ProductRecommendationIntent
|
|
@@ -225,13 +225,13 @@ Values:
|
|
|
225
225
|
id
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
|
-
`,
|
|
228
|
+
`,fo=`
|
|
229
229
|
query GetProductIdByHandle($handle: String!) {
|
|
230
230
|
product(handle: $handle) {
|
|
231
231
|
id
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
|
-
`,
|
|
234
|
+
`,mo=`
|
|
235
235
|
query GetCollectionProducts(
|
|
236
236
|
$handle: String!
|
|
237
237
|
$first: Int!
|
|
@@ -254,19 +254,19 @@ Values:
|
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
|
-
`;var
|
|
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,`
|
|
258
258
|
`).replace(/\r/g,`
|
|
259
|
-
`);let ce=
|
|
259
|
+
`);let ce=E.split(`
|
|
260
260
|
|
|
261
|
-
`);
|
|
262
|
-
`),
|
|
263
|
-
`);try{Y=JSON.parse($),Be=!0}catch{Y=$}}Be&&(s&&await s(Y),i&&(Y=await i(Y))),n?.({data:Y,event:ye,id:p,retry:h}),ee.length&&(yield Y)}}}finally{m.removeEventListener("abort",P),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"),iu=v(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorArrayExplode"),su=v(e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},"separatorArrayNoExplode"),ru=v(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorObjectExplode"),vo=v(({allowReserved:e,explode:t,name:n,style:i,value:s})=>{if(!t){let l=(e?s:s.map(c=>encodeURIComponent(c))).join(su(i));switch(i){case"label":return`.${l}`;case"matrix":return`;${n}=${l}`;case"simple":return l;default:return`${n}=${l}`}}let o=iu(i),a=s.map(l=>i==="label"||i==="simple"?e?l:encodeURIComponent(l):Bn({allowReserved:e,name:n,value:l})).join(o);return i==="label"||i==="matrix"?o+a:a},"serializeArrayParam"),Bn=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"),go=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=ru(i),l=Object.entries(s).map(([c,d])=>Bn({allowReserved:e,name:i==="deepObject"?`${n}[${c}]`:c,value:d})).join(a);return i==="label"||i==="matrix"?a+l:l},"serializeObjectParam"),ou=/\{[^{}]+\}/g,au=v(({path:e,url:t})=>{let n=t,i=t.match(ou);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,vo({explode:o,name:a,style:l,value:c}));continue}if(typeof c=="object"){n=n.replace(s,go({explode:o,name:a,style:l,value:c,valueOnly:!0}));continue}if(l==="matrix"){n=n.replace(s,`;${Bn({name:a,value:c})}`);continue}let d=encodeURIComponent(l==="label"?`.${c}`:c);n=n.replace(s,d)}return n},"defaultPathSerializer"),lu=v(({baseUrl:e,path:t,query:n,querySerializer:i,url:s})=>{let o=s.startsWith("/")?s:`/${s}`,a=(e??"")+o;t&&(a=au({path:t,url:a}));let l=n?i(n):"";return l.startsWith("?")&&(l=l.substring(1)),l&&(a+=`?${l}`),a},"getUrl");function $i(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($i,"N");v($i,"getValidRequestBody");var cu=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"),wo=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=vo({allowReserved:a.allowReserved,explode:!0,name:s,style:"form",value:o,...a.array});l&&i.push(l)}else if(typeof o=="object"){let l=go({allowReserved:a.allowReserved,explode:!0,name:s,style:"deepObject",value:o,...a.object});l&&i.push(l)}else{let l=Bn({allowReserved:a.allowReserved,name:s,value:o});l&&i.push(l)}}return i.join("&")},"querySerializer"),"createQuerySerializer"),uu=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"),du=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"),pu=v(async({security:e,...t})=>{for(let n of e){if(du(t,n.name))continue;let i=await cu(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"),mo=v(e=>lu({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:wo(e.querySerializer),url:e.url}),"buildUrl"),yo=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=bo(e.headers,t.headers),i},"mergeConfigs"),hu=v(e=>{let t=[];return e.forEach((n,i)=>{t.push([i,n])}),t},"headersEntries"),bo=v((...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let i=n instanceof Headers?hu(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"),Io=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(Io,"Interceptors");var Ui=Io,fu=v(()=>({error:new Ui,request:new Ui,response:new Ui}),"createInterceptors"),mu=wo({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),yu={"Content-Type":"application/json"},Vi=v((e={})=>({...tu,headers:yu,parseAs:"auto",querySerializer:mu,...e}),"createConfig"),So=v((e={})=>{let t=yo(Vi(),e),n=v(()=>({...t}),"getConfig"),i=v(d=>(t=yo(t,d),n()),"setConfig"),s=fu(),o=v(async d=>{let u={...t,...d,fetch:d.fetch??t.fetch??globalThis.fetch,headers:bo(t.headers,d.headers),serializedBody:void 0};u.security&&await pu({...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=mo(u);return{opts:u,url:p}},"beforeRequest"),a=v(async d=>{let{opts:u,url:p}=await o(d),f={redirect:"follow",...u,body:$i(u)},h=new Request(p,f);for(let C of s.request.fns)C&&(h=await C(h,u));let w=u.fetch,m;try{m=await w(h)}catch(C){let P=C;for(let E of s.error.fns)E&&(P=await E(C,void 0,h,u));if(P=P||{},u.throwOnError)throw P;return u.responseStyle==="data"?void 0:{error:P,request:h,response:void 0}}for(let C of s.response.fns)C&&(m=await C(m,h,u));let b={request:h,response:m};if(m.ok){let C=(u.parseAs==="auto"?uu(m.headers.get("Content-Type")):u.parseAs)??"json";if(m.status===204||m.headers.get("Content-Length")==="0"){let E;switch(C){case"arrayBuffer":case"blob":case"text":E=await m[C]();break;case"formData":E=new FormData;break;case"stream":E=m.body;break;default:E={};break}return u.responseStyle==="data"?E:{data:E,...b}}let P;switch(C){case"arrayBuffer":case"blob":case"formData":case"text":P=await m[C]();break;case"json":{let E=await m.text();P=E?JSON.parse(E):{};break}case"stream":return u.responseStyle==="data"?m.body:{data:m.body,...b}}return C==="json"&&(u.responseValidator&&await u.responseValidator(P),u.responseTransformer&&(P=await u.responseTransformer(P))),u.responseStyle==="data"?P:{data:P,...b}}let S=await m.text(),k;try{k=JSON.parse(S)}catch{}let A=k??S,D=A;for(let C of s.error.fns)C&&(D=await C(A,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 nu({...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:$i(p),url:f})},"makeSseFn");return{buildUrl:mo,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=So(Vi({baseUrl:"https://swish.app/api/2026-04"})),vu=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/lists",...e}),"listControllerFind"),gu=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerCreate"),wu=v(e=>(e.client??L).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e}),"listControllerDeleteById"),bu=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e}),"listControllerFindById"),Iu=v(e=>(e.client??L).patch({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerUpdateById"),Su=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"),xu=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerAddItemsToList"),Cu=v(e=>(e.client??L).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/{itemId}",...e}),"listControllerRemoveItemFromList"),Eu=v(e=>(e.client??L).delete({security:[{scheme:"bearer",type:"http"}],url:"/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerDelete"),Ru=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/items",...e}),"itemControllerFind"),ku=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerCreate"),Pu=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/items/count",...e}),"itemControllerCount"),Au=v(e=>(e.client??L).delete({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e}),"itemControllerDeleteById"),Tu=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e}),"itemControllerFindById"),Du=v(e=>(e.client??L).patch({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerUpdateById"),Lu=v(e=>(e.client??L).put({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerSetListsById"),Ou=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/identify",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerIdentify"),_u=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/token",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerCreateToken"),Mu=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/profiles",...e}),"profileControllerGetProfile"),qu=v(e=>(e.client??L).patch({security:[{scheme:"bearer",type:"http"}],url:"/profiles/profile",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerUpdateProfile"),Bu=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/saved-items",...e}),"analyticsControllerLoadSavedItems"),Fu=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"),Nu=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/collect",...e,headers:{"Content-Type":"application/json",...e.headers}}),"trackingControllerCollect"),Uu=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/orders",...e}),"ordersControllerFind"),$u=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/orders/{orderId}",...e}),"ordersControllerFindOne"),Vu=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists",...e}),"sharedListsControllerFindAll"),Hu=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"sharedListsControllerSave"),Qu=v(e=>(e.client??L).delete({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}",...e}),"sharedListsControllerDeleteById"),zu=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}",...e}),"sharedListsControllerFindById"),Gu=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}/items",...e}),"sharedListsControllerFindItems"),Ku=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/notifications",...e}),"notificationsControllerFind"),Wu=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/notifications/unread/count",...e}),"notificationsControllerGetUnreadCount"),Xu=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/notifications/read",...e,headers:{"Content-Type":"application/json",...e.headers}}),"notificationsControllerMarkAsRead"),Ju=v(e=>(e?.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/notifications/read/all",...e}),"notificationsControllerMarkAllAsRead"),Yu=v(e=>(e.client??L).delete({security:[{scheme:"bearer",type:"http"}],url:"/notifications/{id}",...e}),"notificationsControllerDeleteById"),Zu=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions",...e}),"subscriptionsControllerFind"),ed=v(e=>(e.client??L).post({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions",...e,headers:{"Content-Type":"application/json",...e.headers}}),"subscriptionsControllerCreate"),td=v(e=>(e.client??L).delete({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e}),"subscriptionsControllerDelete"),nd=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e}),"subscriptionsControllerFindById"),id=v(e=>(e.client??L).patch({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"subscriptionsControllerUpdate"),sd=v(e=>(e?.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists",...e}),"smartListsControllerFindAll"),rd=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists/{smartListId}",...e}),"smartListsControllerFindById"),od=v(e=>(e.client??L).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists/{smartListId}/items",...e}),"smartListsControllerFindItems"),Hi="2026-04",xo=v(e=>new ad(e),"createApiClient"),Co=class{static{r(this,"xe")}constructor(t){this.version=Hi,this.items={list:v(n=>this.handlePaginatedRequest(Ru({query:n,client:this.client})),"list"),create:v(n=>this.handleRequest(ku({body:n,client:this.client})),"create"),delete:v(n=>this.handleRequest(Eu({body:{itemIds:n},client:this.client})),"delete"),findById:v(n=>this.handleRequest(Tu({path:{itemId:n},client:this.client})),"findById"),updateById:v((n,i)=>this.handleRequest(Du({body:i,path:{itemId:n},client:this.client})),"updateById"),deleteById:v(n=>this.handleRequest(Au({path:{itemId:n},client:this.client})),"deleteById"),setListsById:v((n,i)=>this.handleRequest(Lu({body:{listIds:i},path:{itemId:n},client:this.client})),"setListsById"),count:v(()=>this.handleRequest(Pu({client:this.client})),"count")},this.lists={list:v(n=>this.handlePaginatedRequest(vu({query:n,client:this.client})),"list"),create:v(n=>this.handleRequest(gu({body:n,client:this.client})),"create"),findById:v(n=>this.handleRequest(bu({path:{listId:n},client:this.client})),"findById"),updateById:v((n,i)=>this.handleRequest(Iu({body:i,path:{listId:n},client:this.client})),"updateById"),deleteById:v(n=>this.handleRequest(wu({path:{listId:n},client:this.client})),"deleteById"),orderItems:v((n,i)=>this.handleRequest(Su({body:{itemIds:i},path:{listId:n},client:this.client})),"orderItems"),addItemsToList:v((n,i)=>this.handleRequest(xu({body:{itemIds:i},path:{listId:n},client:this.client})),"addItemsToList"),removeItemFromList:v((n,i)=>this.handleRequest(Cu({path:{listId:n,itemId:i},client:this.client})),"removeItemFromList")},this.profiles={createToken:v((n={})=>this.handleRequest(_u({body:n,client:this.client})),"createToken"),identify:v(n=>this.handleRequest(Ou({body:n,client:this.client})),"identify"),getProfile:v(()=>this.handleRequest(Mu({client:this.client})),"getProfile"),updateProfile:v(n=>this.handleRequest(qu({body:n,client:this.client})),"updateProfile")},this.orders={list:v(n=>this.handlePaginatedRequest(Uu({query:n,client:this.client})),"list"),findById:v(n=>this.handleRequest($u({path:{orderId:n},client:this.client})),"findById")},this.sharedLists={list:v(n=>this.handlePaginatedRequest(Vu({query:n,client:this.client})),"list"),save:v(n=>this.handleRequest(Hu({body:{listId:n},client:this.client})),"save"),findById:v(n=>this.handleRequest(zu({path:{sharedListId:n},client:this.client})),"findById"),deleteById:v(n=>this.handleRequest(Qu({path:{sharedListId:n},client:this.client})),"deleteById"),findItems:v((n,i)=>this.handlePaginatedRequest(Gu({path:{sharedListId:n},query:i,client:this.client})),"findItems")},this.analytics={savedItems:v(n=>this.handleRequest(Bu({query:n,client:this.client})),"savedItems"),sessions:v(n=>this.handleRequest(Fu({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(Nu({body:n,client:this.client})),"track")},this.notifications={list:v(n=>this.handlePaginatedRequest(Ku({query:n,client:this.client})),"list"),getUnreadCount:v(()=>this.handleRequest(Wu({client:this.client})),"getUnreadCount"),markAsRead:v(n=>this.handleRequest(Xu({body:{notificationIds:n},client:this.client})),"markAsRead"),markAllAsRead:v(()=>this.handleRequest(Ju({client:this.client})),"markAllAsRead"),deleteById:v(n=>this.handleRequest(Yu({path:{id:n},client:this.client})),"deleteById")},this.subscriptions={list:v(n=>this.handlePaginatedRequest(Zu({query:n,client:this.client})),"list"),create:v(n=>this.handleRequest(ed({body:n,client:this.client})),"create"),findById:v(n=>this.handleRequest(nd({path:{id:n},client:this.client})),"findById"),updateById:v((n,i)=>this.handleRequest(id({body:i,path:{id:n},client:this.client})),"updateById"),deleteById:v(n=>this.handleRequest(td({path:{id:n},client:this.client})),"deleteById")},this.smartLists={list:v(()=>this.handleRequest(sd({client:this.client})),"list"),findById:v(n=>this.handleRequest(rd({path:{smartListId:n},client:this.client})),"findById"),findItems:v((n,i)=>this.handlePaginatedRequest(od({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=So(Vi({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(Co,"SwishClient");var ad=Co;var Po=Go(ko(),1);var Ao=r(e=>new Po.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 vd=Object.defineProperty,g=r((e,t)=>vd(e,"name",{value:t,configurable:!0}),"t"),gd={bodySerializer:g(e=>JSON.stringify(e,(t,n)=>typeof n=="bigint"?n.toString():n),"bodySerializer")},wd=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 A=await(u.fetch??globalThis.fetch)(k);if(!A.ok)throw new Error(`SSE failed: ${A.status} ${A.statusText}`);if(!A.body)throw new Error("No body in SSE response");let D=A.body.pipeThrough(new TextDecoderStream).getReader(),C="",P=g(()=>{try{D.cancel()}catch{}},"abortHandler");m.addEventListener("abort",P);try{for(;;){let{done:E,value:B}=await D.read();if(E)break;C+=B,C=C.replace(/\r\n/g,`
|
|
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,`
|
|
264
264
|
`).replace(/\r/g,`
|
|
265
|
-
`);let ce=
|
|
265
|
+
`);let ce=E.split(`
|
|
266
266
|
|
|
267
|
-
`);
|
|
268
|
-
`),
|
|
269
|
-
`);try{Y=JSON.parse($),Be=!0}catch{Y=$}}Be&&(s&&await s(Y),i&&(Y=await i(Y))),n?.({data:Y,event:ye,id:p,retry:h}),ee.length&&(yield Y)}}}finally{m.removeEventListener("abort",P),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"),bd=g(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorArrayExplode"),Id=g(e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},"separatorArrayNoExplode"),Sd=g(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorObjectExplode"),Lo=g(({allowReserved:e,explode:t,name:n,style:i,value:s})=>{if(!t){let l=(e?s:s.map(c=>encodeURIComponent(c))).join(Id(i));switch(i){case"label":return`.${l}`;case"matrix":return`;${n}=${l}`;case"simple":return l;default:return`${n}=${l}`}}let o=bd(i),a=s.map(l=>i==="label"||i==="simple"?e?l:encodeURIComponent(l):Fn({allowReserved:e,name:n,value:l})).join(o);return i==="label"||i==="matrix"?o+a:a},"serializeArrayParam"),Fn=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"),Oo=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=Sd(i),l=Object.entries(s).map(([c,d])=>Fn({allowReserved:e,name:i==="deepObject"?`${n}[${c}]`:c,value:d})).join(a);return i==="label"||i==="matrix"?a+l:l},"serializeObjectParam"),xd=/\{[^{}]+\}/g,Cd=g(({path:e,url:t})=>{let n=t,i=t.match(xd);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,Lo({explode:o,name:a,style:l,value:c}));continue}if(typeof c=="object"){n=n.replace(s,Oo({explode:o,name:a,style:l,value:c,valueOnly:!0}));continue}if(l==="matrix"){n=n.replace(s,`;${Fn({name:a,value:c})}`);continue}let d=encodeURIComponent(l==="label"?`.${c}`:c);n=n.replace(s,d)}return n},"defaultPathSerializer"),Ed=g(({baseUrl:e,path:t,query:n,querySerializer:i,url:s})=>{let o=s.startsWith("/")?s:`/${s}`,a=(e??"")+o;t&&(a=Cd({path:t,url:a}));let l=n?i(n):"";return l.startsWith("?")&&(l=l.substring(1)),l&&(a+=`?${l}`),a},"getUrl");function Wi(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(Wi,"N");g(Wi,"getValidRequestBody");var Rd=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"),_o=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=Lo({allowReserved:a.allowReserved,explode:!0,name:s,style:"form",value:o,...a.array});l&&i.push(l)}else if(typeof o=="object"){let l=Oo({allowReserved:a.allowReserved,explode:!0,name:s,style:"deepObject",value:o,...a.object});l&&i.push(l)}else{let l=Fn({allowReserved:a.allowReserved,name:s,value:o});l&&i.push(l)}}return i.join("&")},"querySerializer"),"createQuerySerializer"),kd=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"),Pd=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"),Ad=g(async({security:e,...t})=>{for(let n of e){if(Pd(t,n.name))continue;let i=await Rd(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"),To=g(e=>Ed({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:_o(e.querySerializer),url:e.url}),"buildUrl"),Do=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=Mo(e.headers,t.headers),i},"mergeConfigs"),Td=g(e=>{let t=[];return e.forEach((n,i)=>{t.push([i,n])}),t},"headersEntries"),Mo=g((...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let i=n instanceof Headers?Td(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"),qo=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(qo,"Interceptors");var Ki=qo,Dd=g(()=>({error:new Ki,request:new Ki,response:new Ki}),"createInterceptors"),Ld=_o({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),Od={"Content-Type":"application/json"},Xi=g((e={})=>({...gd,headers:Od,parseAs:"auto",querySerializer:Ld,...e}),"createConfig"),Bo=g((e={})=>{let t=Do(Xi(),e),n=g(()=>({...t}),"getConfig"),i=g(d=>(t=Do(t,d),n()),"setConfig"),s=Dd(),o=g(async d=>{let u={...t,...d,fetch:d.fetch??t.fetch??globalThis.fetch,headers:Mo(t.headers,d.headers),serializedBody:void 0};u.security&&await Ad({...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=To(u);return{opts:u,url:p}},"beforeRequest"),a=g(async d=>{let{opts:u,url:p}=await o(d),f={redirect:"follow",...u,body:Wi(u)},h=new Request(p,f);for(let C of s.request.fns)C&&(h=await C(h,u));let w=u.fetch,m;try{m=await w(h)}catch(C){let P=C;for(let E of s.error.fns)E&&(P=await E(C,void 0,h,u));if(P=P||{},u.throwOnError)throw P;return u.responseStyle==="data"?void 0:{error:P,request:h,response:void 0}}for(let C of s.response.fns)C&&(m=await C(m,h,u));let b={request:h,response:m};if(m.ok){let C=(u.parseAs==="auto"?kd(m.headers.get("Content-Type")):u.parseAs)??"json";if(m.status===204||m.headers.get("Content-Length")==="0"){let E;switch(C){case"arrayBuffer":case"blob":case"text":E=await m[C]();break;case"formData":E=new FormData;break;case"stream":E=m.body;break;default:E={};break}return u.responseStyle==="data"?E:{data:E,...b}}let P;switch(C){case"arrayBuffer":case"blob":case"formData":case"text":P=await m[C]();break;case"json":{let E=await m.text();P=E?JSON.parse(E):{};break}case"stream":return u.responseStyle==="data"?m.body:{data:m.body,...b}}return C==="json"&&(u.responseValidator&&await u.responseValidator(P),u.responseTransformer&&(P=await u.responseTransformer(P))),u.responseStyle==="data"?P:{data:P,...b}}let S=await m.text(),k;try{k=JSON.parse(S)}catch{}let A=k??S,D=A;for(let C of s.error.fns)C&&(D=await C(A,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 wd({...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:Wi(p),url:f})},"makeSseFn");return{buildUrl:To,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=Bo(Xi({baseUrl:"https://swish.app/api/2026-04"})),_d=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/lists",...e}),"listControllerFind"),Md=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerCreate"),qd=g(e=>(e.client??O).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e}),"listControllerDeleteById"),Bd=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e}),"listControllerFindById"),Fd=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"),Nd=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerAddItemsToList"),Ud=g(e=>(e.client??O).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/{itemId}",...e}),"listControllerRemoveItemFromList"),$d=g(e=>(e.client??O).delete({security:[{scheme:"bearer",type:"http"}],url:"/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerDelete"),Vd=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/items",...e}),"itemControllerFind"),Hd=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerCreate"),Qd=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/items/count",...e}),"itemControllerCount"),zd=g(e=>(e.client??O).delete({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e}),"itemControllerDeleteById"),Gd=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e}),"itemControllerFindById"),Kd=g(e=>(e.client??O).patch({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerUpdateById"),Wd=g(e=>(e.client??O).put({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerSetListsById"),Xd=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/identify",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerIdentify"),Jd=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/token",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerCreateToken"),Yd=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/profiles",...e}),"profileControllerGetProfile"),Zd=g(e=>(e.client??O).patch({security:[{scheme:"bearer",type:"http"}],url:"/profiles/profile",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerUpdateProfile"),ep=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/saved-items",...e}),"analyticsControllerLoadSavedItems"),tp=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/sessions",...e}),"analyticsControllerLoadSessions"),np=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/new-lists",...e}),"analyticsControllerLoadNewLists"),ip=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/collect",...e,headers:{"Content-Type":"application/json",...e.headers}}),"trackingControllerCollect"),sp=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/orders",...e}),"ordersControllerFind"),rp=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/orders/{orderId}",...e}),"ordersControllerFindOne"),op=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists",...e}),"sharedListsControllerFindAll"),ap=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"sharedListsControllerSave"),lp=g(e=>(e.client??O).delete({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}",...e}),"sharedListsControllerDeleteById"),cp=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}",...e}),"sharedListsControllerFindById"),up=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}/items",...e}),"sharedListsControllerFindItems"),dp=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/notifications",...e}),"notificationsControllerFind"),pp=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/notifications/unread/count",...e}),"notificationsControllerGetUnreadCount"),hp=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/notifications/read",...e,headers:{"Content-Type":"application/json",...e.headers}}),"notificationsControllerMarkAsRead"),fp=g(e=>(e?.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/notifications/read/all",...e}),"notificationsControllerMarkAllAsRead"),mp=g(e=>(e.client??O).delete({security:[{scheme:"bearer",type:"http"}],url:"/notifications/{id}",...e}),"notificationsControllerDeleteById"),yp=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions",...e}),"subscriptionsControllerFind"),vp=g(e=>(e.client??O).post({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions",...e,headers:{"Content-Type":"application/json",...e.headers}}),"subscriptionsControllerCreate"),gp=g(e=>(e.client??O).delete({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e}),"subscriptionsControllerDelete"),wp=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e}),"subscriptionsControllerFindById"),bp=g(e=>(e.client??O).patch({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"subscriptionsControllerUpdate"),Ip=g(e=>(e?.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists",...e}),"smartListsControllerFindAll"),Sp=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists/{smartListId}",...e}),"smartListsControllerFindById"),xp=g(e=>(e.client??O).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists/{smartListId}/items",...e}),"smartListsControllerFindItems"),Ji="2026-04",qI=g(e=>new Cp(e),"createApiClient"),Fo=class{static{r(this,"xe")}constructor(t){this.version=Ji,this.items={list:g(n=>this.handlePaginatedRequest(Vd({query:n,client:this.client})),"list"),create:g(n=>this.handleRequest(Hd({body:n,client:this.client})),"create"),delete:g(n=>this.handleRequest($d({body:{itemIds:n},client:this.client})),"delete"),findById:g(n=>this.handleRequest(Gd({path:{itemId:n},client:this.client})),"findById"),updateById:g((n,i)=>this.handleRequest(Kd({body:i,path:{itemId:n},client:this.client})),"updateById"),deleteById:g(n=>this.handleRequest(zd({path:{itemId:n},client:this.client})),"deleteById"),setListsById:g((n,i)=>this.handleRequest(Wd({body:{listIds:i},path:{itemId:n},client:this.client})),"setListsById"),count:g(()=>this.handleRequest(Qd({client:this.client})),"count")},this.lists={list:g(n=>this.handlePaginatedRequest(_d({query:n,client:this.client})),"list"),create:g(n=>this.handleRequest(Md({body:n,client:this.client})),"create"),findById:g(n=>this.handleRequest(Bd({path:{listId:n},client:this.client})),"findById"),updateById:g((n,i)=>this.handleRequest(Fd({body:i,path:{listId:n},client:this.client})),"updateById"),deleteById:g(n=>this.handleRequest(qd({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(Nd({body:{itemIds:i},path:{listId:n},client:this.client})),"addItemsToList"),removeItemFromList:g((n,i)=>this.handleRequest(Ud({path:{listId:n,itemId:i},client:this.client})),"removeItemFromList")},this.profiles={createToken:g((n={})=>this.handleRequest(Jd({body:n,client:this.client})),"createToken"),identify:g(n=>this.handleRequest(Xd({body:n,client:this.client})),"identify"),getProfile:g(()=>this.handleRequest(Yd({client:this.client})),"getProfile"),updateProfile:g(n=>this.handleRequest(Zd({body:n,client:this.client})),"updateProfile")},this.orders={list:g(n=>this.handlePaginatedRequest(sp({query:n,client:this.client})),"list"),findById:g(n=>this.handleRequest(rp({path:{orderId:n},client:this.client})),"findById")},this.sharedLists={list:g(n=>this.handlePaginatedRequest(op({query:n,client:this.client})),"list"),save:g(n=>this.handleRequest(ap({body:{listId:n},client:this.client})),"save"),findById:g(n=>this.handleRequest(cp({path:{sharedListId:n},client:this.client})),"findById"),deleteById:g(n=>this.handleRequest(lp({path:{sharedListId:n},client:this.client})),"deleteById"),findItems:g((n,i)=>this.handlePaginatedRequest(up({path:{sharedListId:n},query:i,client:this.client})),"findItems")},this.analytics={savedItems:g(n=>this.handleRequest(ep({query:n,client:this.client})),"savedItems"),sessions:g(n=>this.handleRequest(tp({query:n,client:this.client})),"sessions"),newLists:g(n=>this.handleRequest(np({query:n,client:this.client})),"newLists")},this.tracking={track:g(n=>this.handleRequest(ip({body:n,client:this.client})),"track")},this.notifications={list:g(n=>this.handlePaginatedRequest(dp({query:n,client:this.client})),"list"),getUnreadCount:g(()=>this.handleRequest(pp({client:this.client})),"getUnreadCount"),markAsRead:g(n=>this.handleRequest(hp({body:{notificationIds:n},client:this.client})),"markAsRead"),markAllAsRead:g(()=>this.handleRequest(fp({client:this.client})),"markAllAsRead"),deleteById:g(n=>this.handleRequest(mp({path:{id:n},client:this.client})),"deleteById")},this.subscriptions={list:g(n=>this.handlePaginatedRequest(yp({query:n,client:this.client})),"list"),create:g(n=>this.handleRequest(vp({body:n,client:this.client})),"create"),findById:g(n=>this.handleRequest(wp({path:{id:n},client:this.client})),"findById"),updateById:g((n,i)=>this.handleRequest(bp({body:i,path:{id:n},client:this.client})),"updateById"),deleteById:g(n=>this.handleRequest(gp({path:{id:n},client:this.client})),"deleteById")},this.smartLists={list:g(()=>this.handleRequest(Ip({client:this.client})),"list"),findById:g(n=>this.handleRequest(Sp({path:{smartListId:n},client:this.client})),"findById"),findItems:g((n,i)=>this.handlePaginatedRequest(xp({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=Bo(Xi({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(Fo,"SwishClient");var Cp=Fo;var jn=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":Ji},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 Nn=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 _e(`swish-api-${a}`,"max-age=60, stale-while-revalidate=3600",s+Hi),this.cache.cleanupExpiredEntries().catch(c=>{console.warn("Swish API cache initialization cleanup error:",c)}),this.auth=new jn(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=xo(l),this.itemsLoader=Ao(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 Un=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 $n=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@${De}/${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@${De}/${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@${De}/theme.css`,n=await fetch(t).then(o=>o.text()),i=new CSSStyleSheet;i.replaceSync(n);let s=Ep(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@${De}/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(`
|
|
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(`
|
|
270
270
|
html[swish-locked] body {
|
|
271
271
|
overflow: hidden;
|
|
272
272
|
position: fixed;
|
|
@@ -274,4 +274,4 @@ Values:
|
|
|
274
274
|
left: 0px;
|
|
275
275
|
right: 0px;
|
|
276
276
|
}
|
|
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
|
|
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};
|