@swishapp/sdk 0.108.0 → 0.109.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.
@@ -0,0 +1,22 @@
1
+ import * as v from "valibot";
2
+ import { IntentHandler } from "../intent-handler";
3
+ import { IntentResponse, SuccessIntentResponse } from "../types";
4
+ export declare const InitiateCheckoutIntentDataSchema: v.UnionSchema<[v.ObjectSchema<{
5
+ readonly variantId: v.SchemaWithPipe<readonly [v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, string>]>, v.NumberSchema<undefined>], undefined>, v.TransformAction<string | number, number>, v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 1, undefined>]>]>;
6
+ readonly quantity: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 1, undefined>]>, 1>;
7
+ }, undefined>, v.ObjectSchema<{
8
+ readonly items: v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
9
+ readonly variantId: v.SchemaWithPipe<readonly [v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, string>]>, v.NumberSchema<undefined>], undefined>, v.TransformAction<string | number, number>, v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 1, undefined>]>]>;
10
+ readonly quantity: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 1, undefined>]>, 1>;
11
+ }, undefined>, undefined>, v.MinLengthAction<{
12
+ variantId: number;
13
+ quantity: number;
14
+ }[], 1, undefined>]>;
15
+ }, undefined>], undefined>;
16
+ export type InitiateCheckoutIntentData = v.InferInput<typeof InitiateCheckoutIntentDataSchema>;
17
+ export type InitiateCheckoutSuccessResponse = SuccessIntentResponse<{
18
+ checkoutUrl: string;
19
+ }>;
20
+ export declare class InitiateCheckoutHandler extends IntentHandler<"initiate:checkout"> {
21
+ invoke(data: InitiateCheckoutIntentData): Promise<IntentResponse<"initiate:checkout">>;
22
+ }
@@ -0,0 +1,13 @@
1
+ import * as v from "valibot";
2
+ import { IntentHandler } from "../intent-handler";
3
+ import { IntentResponse, SuccessIntentResponse } from "../types";
4
+ export declare const InitiateSignInIntentDataSchema: v.ObjectSchema<{
5
+ readonly returnTo: v.StringSchema<undefined>;
6
+ }, undefined>;
7
+ export type InitiateSignInIntentData = v.InferInput<typeof InitiateSignInIntentDataSchema>;
8
+ export type InitiateSignInSuccessResponse = SuccessIntentResponse<void>;
9
+ export declare class InitiateSignInHandler extends IntentHandler<"initiate:sign-in"> {
10
+ invoke(data: InitiateSignInIntentData): Promise<IntentResponse<"initiate:sign-in">>;
11
+ private scheduleRedirect;
12
+ private redirectToSignIn;
13
+ }
@@ -10,6 +10,6 @@ export declare const OpenListMenuIntentDataSchema: v.ObjectSchema<{
10
10
  }, undefined>;
11
11
  export type OpenListMenuIntentData = v.InferInput<typeof OpenListMenuIntentDataSchema>;
12
12
  export type OpenListMenuSuccessResponse = EditListSuccessResponse | DeleteListSuccessResponse | EditListAccessSuccessResponse | ShareListSuccessResponse;
13
- export declare class OpenListMenuHandler extends IntentHandler<"open:list-menu" | "edit:list" | "delete:list" | "edit:list-access" | "share:list"> {
14
- invoke(data: OpenListMenuIntentData): Promise<IntentResponse<"open:list-menu" | "edit:list" | "delete:list" | "edit:list-access" | "share:list">>;
13
+ export declare class OpenListMenuHandler extends IntentHandler<"open:list-menu" | "edit:list" | "delete:list" | "edit:list-access" | "initiate:share"> {
14
+ invoke(data: OpenListMenuIntentData): Promise<IntentResponse<"open:list-menu" | "edit:list" | "delete:list" | "edit:list-access" | "initiate:share">>;
15
15
  }
@@ -11,6 +11,6 @@ export type ShareListSuccessResponse = SuccessIntentResponse<{
11
11
  method: "native" | "clipboard";
12
12
  publicListId?: string;
13
13
  }>;
14
- export declare class ShareListHandler extends IntentHandler<"share:list"> {
15
- invoke(data: ShareListIntentData): Promise<IntentResponse<"share:list">>;
14
+ export declare class ShareListHandler extends IntentHandler<"initiate:share"> {
15
+ invoke(data: ShareListIntentData): Promise<IntentResponse<"initiate:share">>;
16
16
  }
@@ -1,5 +1,5 @@
1
1
  import { IntentHook } from "../intent-hook";
2
2
  import { IntentResponse } from "../types";
3
- export declare class AfterShareListHook extends IntentHook<"share:list"> {
4
- invoke(response: IntentResponse<"share:list">): Promise<void>;
3
+ export declare class AfterShareListHook extends IntentHook<"initiate:share"> {
4
+ invoke(response: IntentResponse<"initiate:share">): Promise<void>;
5
5
  }
@@ -1,5 +1,6 @@
1
1
  import type { CreateListIntentData, CreateListSuccessResponse } from "./handlers/create-list-handler";
2
2
  import type { CreateCartLineIntentData, CreateCartLineSuccessResponse } from "./handlers/create-cart-line-handler";
3
+ import type { InitiateCheckoutIntentData, InitiateCheckoutSuccessResponse } from "./handlers/initiate-checkout-handler";
3
4
  import type { DeleteListIntentData, DeleteListSuccessResponse } from "./handlers/delete-list-handler";
4
5
  import type { EditItemListsIntentData, EditItemListsSuccessResponse } from "./handlers/edit-item-lists-handler";
5
6
  import type { EditItemVariantIntentData, EditItemVariantSuccessResponse } from "./handlers/edit-item-variant-handler";
@@ -19,12 +20,13 @@ import { OpenProfileSuccessResponse } from "./handlers/open-profile-handler";
19
20
  import type { OpenQuickBuyIntentData, OpenQuickBuySuccessResponse } from "./handlers/open-quick-buy-handler";
20
21
  import { OpenSavesSuccessResponse } from "./handlers/open-saves-handler";
21
22
  import type { OpenSignInIntentData, OpenSignInSuccessResponse } from "./handlers/open-sign-in-handler";
23
+ import type { InitiateSignInIntentData, InitiateSignInSuccessResponse } from "./handlers/initiate-sign-in-handler";
22
24
  import type { SaveItemIntentData, SaveItemSuccessResponse } from "./handlers/save-item-handler";
23
25
  import type { ShareListIntentData, ShareListSuccessResponse } from "./handlers/share-list-handler";
24
26
  import { ToastIntentData, ToastSuccessResponse } from "./handlers/show-toast-handler";
25
27
  import type { UnsaveItemIntentData, UnsaveItemSuccessResponse } from "./handlers/unsave-item-handler";
26
- export type { CreateCartLineSuccessResponse, CreateListSuccessResponse, DeleteListSuccessResponse, EditItemListsSuccessResponse, EditItemVariantSuccessResponse, EditListAccessSuccessResponse, EditListSuccessResponse, SaveItemSuccessResponse, ShareListSuccessResponse, ToastSuccessResponse, UnsaveItemSuccessResponse, };
27
- export type Intent = "create:cart-line" | "save:item" | "edit:item-variant" | "edit:item-lists" | "unsave:item" | "edit:list" | "edit:list-access" | "delete:list" | "create:list" | "share:list" | "open:home" | "open:list" | "open:lists" | "open:orders" | "open:order" | "open:saves" | "open:notifications" | "open:profile" | "open:product" | "open:list-menu" | "open:order-menu" | "open:list-detail-page-menu" | "open:sign-in" | "open:quick-buy" | "show:toast";
28
+ export type { CreateCartLineSuccessResponse, InitiateCheckoutSuccessResponse, CreateListSuccessResponse, DeleteListSuccessResponse, EditItemListsSuccessResponse, EditItemVariantSuccessResponse, EditListAccessSuccessResponse, EditListSuccessResponse, SaveItemSuccessResponse, ShareListSuccessResponse, ToastSuccessResponse, UnsaveItemSuccessResponse, };
29
+ export type Intent = "create:cart-line" | "initiate:checkout" | "save:item" | "edit:item-variant" | "edit:item-lists" | "unsave:item" | "edit:list" | "edit:list-access" | "delete:list" | "create:list" | "initiate:share" | "open:home" | "open:list" | "open:lists" | "open:orders" | "open:order" | "open:saves" | "open:notifications" | "open:profile" | "open:product" | "open:list-menu" | "open:order-menu" | "open:list-detail-page-menu" | "initiate:sign-in" | "open:sign-in" | "open:quick-buy" | "show:toast";
28
30
  export type IntentQueryParam = `${string}=${string}`;
29
31
  export type IntentQueryWithParams = `${Intent},${IntentQueryParam}`;
30
32
  export type IntentResponse<I extends Intent = Intent> = ClosedIntentResponse<I> | ErrorIntentResponse<I> | IntentToSuccessResponse<I>;
@@ -52,6 +54,7 @@ export interface SuccessIntentResponse<T, I extends Intent = Intent> extends Int
52
54
  }
53
55
  interface IntentDataMap {
54
56
  "create:cart-line": CreateCartLineIntentData;
57
+ "initiate:checkout": InitiateCheckoutIntentData;
55
58
  "save:item": SaveItemIntentData;
56
59
  "edit:item-variant": EditItemVariantIntentData;
57
60
  "edit:item-lists": EditItemListsIntentData;
@@ -60,7 +63,7 @@ interface IntentDataMap {
60
63
  "edit:list-access": EditListAccessIntentData;
61
64
  "delete:list": DeleteListIntentData;
62
65
  "create:list": CreateListIntentData;
63
- "share:list": ShareListIntentData;
66
+ "initiate:share": ShareListIntentData;
64
67
  "open:home": void;
65
68
  "open:list": OpenListIntentData;
66
69
  "open:lists": void;
@@ -73,12 +76,14 @@ interface IntentDataMap {
73
76
  "open:list-menu": OpenListMenuIntentData;
74
77
  "open:order-menu": OpenOrderMenuIntentData;
75
78
  "open:list-detail-page-menu": OpenListDetailPageMenuIntentData;
79
+ "initiate:sign-in": InitiateSignInIntentData;
76
80
  "open:sign-in": OpenSignInIntentData | undefined;
77
81
  "open:quick-buy": OpenQuickBuyIntentData;
78
82
  "show:toast": ToastIntentData;
79
83
  }
80
84
  interface IntentSuccessResponseMap {
81
85
  "create:cart-line": CreateCartLineSuccessResponse;
86
+ "initiate:checkout": InitiateCheckoutSuccessResponse;
82
87
  "save:item": SaveItemSuccessResponse;
83
88
  "edit:item-variant": EditItemVariantSuccessResponse;
84
89
  "edit:item-lists": EditItemListsSuccessResponse | UnsaveItemSuccessResponse;
@@ -87,7 +92,7 @@ interface IntentSuccessResponseMap {
87
92
  "edit:list-access": EditListAccessSuccessResponse;
88
93
  "delete:list": DeleteListSuccessResponse;
89
94
  "create:list": CreateListSuccessResponse;
90
- "share:list": ShareListSuccessResponse;
95
+ "initiate:share": ShareListSuccessResponse;
91
96
  "open:home": OpenHomeSuccessResponse;
92
97
  "open:list": OpenListSuccessResponse;
93
98
  "open:lists": OpenListsSuccessResponse;
@@ -100,6 +105,7 @@ interface IntentSuccessResponseMap {
100
105
  "open:list-menu": OpenListMenuSuccessResponse;
101
106
  "open:order-menu": OpenOrderMenuSuccessResponse;
102
107
  "open:list-detail-page-menu": OpenListDetailPageMenuSuccessResponse;
108
+ "initiate:sign-in": InitiateSignInSuccessResponse;
103
109
  "open:sign-in": OpenSignInSuccessResponse;
104
110
  "open:quick-buy": OpenQuickBuySuccessResponse;
105
111
  "show:toast": ToastSuccessResponse;
package/dist/swish.js CHANGED
@@ -1,18 +1,18 @@
1
- var Nr=Object.create;var gt=Object.defineProperty;var Br=Object.getOwnPropertyDescriptor;var Ur=Object.getOwnPropertyNames;var Fr=Object.getPrototypeOf,jr=Object.prototype.hasOwnProperty;var i=(n,e)=>gt(n,"name",{value:e,configurable:!0});var Gr=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var Hr=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Ur(e))!jr.call(n,s)&&s!==t&&gt(n,s,{get:()=>e[s],enumerable:!(r=Br(e,s))||r.enumerable});return n};var Qr=(n,e,t)=>(t=n!=null?Nr(Fr(n)):{},Hr(e||!n||!n.__esModule?gt(t,"default",{value:n,enumerable:!0}):t,n));var Lr=Gr((Np,Or)=>{"use strict";var Wi=(function(){function n(t,r){if(typeof t!="function")throw new TypeError("DataLoader must be constructed with a function which accepts "+("Array<key> and returns Promise<Array<value>>, but got: "+t+"."));this._batchLoadFn=t,this._maxBatchSize=Ji(r),this._batchScheduleFn=Zi(r),this._cacheKeyFn=eo(r),this._cacheMap=to(r),this._batch=null,this.name=no(r)}i(n,"DataLoader");var e=n.prototype;return e.load=i(function(r){if(r==null)throw new TypeError("The loader.load() function must be called with a value, "+("but got: "+String(r)+"."));var s=Xi(this),o=this._cacheMap,a;if(o){a=this._cacheKeyFn(r);var u=o.get(a);if(u){var c=s.cacheHits||(s.cacheHits=[]);return new Promise(function(p){c.push(function(){p(u)})})}}s.keys.push(r);var l=new Promise(function(p,f){s.callbacks.push({resolve:p,reject:f})});return o&&o.set(a,l),l},"load"),e.loadMany=i(function(r){if(!_r(r))throw new TypeError("The loader.loadMany() function must be called with Array<key> "+("but got: "+r+"."));for(var s=[],o=0;o<r.length;o++)s.push(this.load(r[o]).catch(function(a){return a}));return Promise.all(s)},"loadMany"),e.clear=i(function(r){var s=this._cacheMap;if(s){var o=this._cacheKeyFn(r);s.delete(o)}return this},"clear"),e.clearAll=i(function(){var r=this._cacheMap;return r&&r.clear(),this},"clearAll"),e.prime=i(function(r,s){var o=this._cacheMap;if(o){var a=this._cacheKeyFn(r);if(o.get(a)===void 0){var u;s instanceof Error?(u=Promise.reject(s),u.catch(function(){})):u=Promise.resolve(s),o.set(a,u)}}return this},"prime"),n})(),Ki=typeof process=="object"&&typeof process.nextTick=="function"?function(n){en||(en=Promise.resolve()),en.then(function(){process.nextTick(n)})}:typeof setImmediate=="function"?function(n){setImmediate(n)}:function(n){setTimeout(n)},en;function Xi(n){var e=n._batch;if(e!==null&&!e.hasDispatched&&e.keys.length<n._maxBatchSize)return e;var t={hasDispatched:!1,keys:[],callbacks:[]};return n._batch=t,n._batchScheduleFn(function(){Yi(n,t)}),t}i(Xi,"getCurrentBatch");function Yi(n,e){if(e.hasDispatched=!0,e.keys.length===0){nn(e);return}var t;try{t=n._batchLoadFn(e.keys)}catch(r){return tn(n,e,new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function "+("errored synchronously: "+String(r)+".")))}if(!t||typeof t.then!="function")return tn(n,e,new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did "+("not return a Promise: "+String(t)+".")));t.then(function(r){if(!_r(r))throw new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did "+("not return a Promise of an Array: "+String(r)+"."));if(r.length!==e.keys.length)throw new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array of the same length as the Array of keys."+(`
1
+ var Ur=Object.create;var St=Object.defineProperty;var Fr=Object.getOwnPropertyDescriptor;var jr=Object.getOwnPropertyNames;var Gr=Object.getPrototypeOf,Hr=Object.prototype.hasOwnProperty;var i=(n,e)=>St(n,"name",{value:e,configurable:!0});var Qr=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var zr=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of jr(e))!Hr.call(n,s)&&s!==t&&St(n,s,{get:()=>e[s],enumerable:!(r=Fr(e,s))||r.enumerable});return n};var Wr=(n,e,t)=>(t=n!=null?Ur(Gr(n)):{},zr(e||!n||!n.__esModule?St(t,"default",{value:n,enumerable:!0}):t,n));var Mr=Qr((td,$r)=>{"use strict";var to=(function(){function n(t,r){if(typeof t!="function")throw new TypeError("DataLoader must be constructed with a function which accepts "+("Array<key> and returns Promise<Array<value>>, but got: "+t+"."));this._batchLoadFn=t,this._maxBatchSize=io(r),this._batchScheduleFn=oo(r),this._cacheKeyFn=ao(r),this._cacheMap=uo(r),this._batch=null,this.name=co(r)}i(n,"DataLoader");var e=n.prototype;return e.load=i(function(r){if(r==null)throw new TypeError("The loader.load() function must be called with a value, "+("but got: "+String(r)+"."));var s=ro(this),o=this._cacheMap,a;if(o){a=this._cacheKeyFn(r);var u=o.get(a);if(u){var c=s.cacheHits||(s.cacheHits=[]);return new Promise(function(p){c.push(function(){p(u)})})}}s.keys.push(r);var l=new Promise(function(p,f){s.callbacks.push({resolve:p,reject:f})});return o&&o.set(a,l),l},"load"),e.loadMany=i(function(r){if(!Lr(r))throw new TypeError("The loader.loadMany() function must be called with Array<key> "+("but got: "+r+"."));for(var s=[],o=0;o<r.length;o++)s.push(this.load(r[o]).catch(function(a){return a}));return Promise.all(s)},"loadMany"),e.clear=i(function(r){var s=this._cacheMap;if(s){var o=this._cacheKeyFn(r);s.delete(o)}return this},"clear"),e.clearAll=i(function(){var r=this._cacheMap;return r&&r.clear(),this},"clearAll"),e.prime=i(function(r,s){var o=this._cacheMap;if(o){var a=this._cacheKeyFn(r);if(o.get(a)===void 0){var u;s instanceof Error?(u=Promise.reject(s),u.catch(function(){})):u=Promise.resolve(s),o.set(a,u)}}return this},"prime"),n})(),no=typeof process=="object"&&typeof process.nextTick=="function"?function(n){nn||(nn=Promise.resolve()),nn.then(function(){process.nextTick(n)})}:typeof setImmediate=="function"?function(n){setImmediate(n)}:function(n){setTimeout(n)},nn;function ro(n){var e=n._batch;if(e!==null&&!e.hasDispatched&&e.keys.length<n._maxBatchSize)return e;var t={hasDispatched:!1,keys:[],callbacks:[]};return n._batch=t,n._batchScheduleFn(function(){so(n,t)}),t}i(ro,"getCurrentBatch");function so(n,e){if(e.hasDispatched=!0,e.keys.length===0){sn(e);return}var t;try{t=n._batchLoadFn(e.keys)}catch(r){return rn(n,e,new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function "+("errored synchronously: "+String(r)+".")))}if(!t||typeof t.then!="function")return rn(n,e,new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did "+("not return a Promise: "+String(t)+".")));t.then(function(r){if(!Lr(r))throw new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did "+("not return a Promise of an Array: "+String(r)+"."));if(r.length!==e.keys.length)throw new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array of the same length as the Array of keys."+(`
2
2
 
3
3
  Keys:
4
4
  `+String(e.keys))+(`
5
5
 
6
6
  Values:
7
- `+String(r)));nn(e);for(var s=0;s<e.callbacks.length;s++){var o=r[s];o instanceof Error?e.callbacks[s].reject(o):e.callbacks[s].resolve(o)}}).catch(function(r){tn(n,e,r)})}i(Yi,"dispatchBatch");function tn(n,e,t){nn(e);for(var r=0;r<e.keys.length;r++)n.clear(e.keys[r]),e.callbacks[r].reject(t)}i(tn,"failedDispatch");function nn(n){if(n.cacheHits)for(var e=0;e<n.cacheHits.length;e++)n.cacheHits[e]()}i(nn,"resolveCacheHits");function Ji(n){var e=!n||n.batch!==!1;if(!e)return 1;var t=n&&n.maxBatchSize;if(t===void 0)return 1/0;if(typeof t!="number"||t<1)throw new TypeError("maxBatchSize must be a positive number: "+t);return t}i(Ji,"getValidMaxBatchSize");function Zi(n){var e=n&&n.batchScheduleFn;if(e===void 0)return Ki;if(typeof e!="function")throw new TypeError("batchScheduleFn must be a function: "+e);return e}i(Zi,"getValidBatchScheduleFn");function eo(n){var e=n&&n.cacheKeyFn;if(e===void 0)return function(t){return t};if(typeof e!="function")throw new TypeError("cacheKeyFn must be a function: "+e);return e}i(eo,"getValidCacheKeyFn");function to(n){var e=!n||n.cache!==!1;if(!e)return null;var t=n&&n.cacheMap;if(t===void 0)return new Map;if(t!==null){var r=["get","set","delete","clear"],s=r.filter(function(o){return t&&typeof t[o]!="function"});if(s.length!==0)throw new TypeError("Custom cacheMap missing methods: "+s.join(", "))}return t}i(to,"getValidCacheMap");function no(n){return n&&n.name?n.name:null}i(no,"getValidName");function _r(n){return typeof n=="object"&&n!==null&&typeof n.length=="number"&&(n.length===0||n.length>0&&Object.prototype.hasOwnProperty.call(n,n.length-1))}i(_r,"isArrayLike");Or.exports=Wi});var A=i(n=>n.split("/").pop()??"","shopifyGidToId"),D=i((n,e)=>`gid://shopify/${n}/${e}`,"shopifyIdToGid"),H=i(n=>n.toLowerCase().replace(".myshopify.com",""),"toShopName");var Y=class{constructor(e,t,r=""){this.revalidationPromises=new Map;this.inFlightRequests=new Map;this.clearCachePromise=null;this.cacheName=e,this.defaultCacheControl=t,this.keyPrefix=r}static{i(this,"FetchCache")}async get(e){try{let t=await caches.open(this.cacheName),r=await t.match(e);if(r&&this.isExpired(r)){await t.delete(e);return}return r}catch(t){console.warn("Cache get error:",t);return}}async set(e,t,r){try{if(r?.includes("no-cache"))return;let s=this.createCacheableResponse(t,r);await(await caches.open(this.cacheName)).put(e,s)}catch(s){console.warn("Cache set error:",s)}}async fetchWithCache(e,t,r){let s=await this.getCacheKey(e,t);if(this.clearCachePromise&&await this.clearCachePromise,this.inFlightRequests.has(s))return this.inFlightRequests.get(s).then(a=>a.clone());let o=(async()=>{let a=await this.get(s);if(a)return this.isStaleButRevalidatable(a)&&this.revalidateInBackground(s,e,t,r),a.clone();let u=await fetch(e,t);return u.ok&&await this.set(s,u.clone(),r??this.defaultCacheControl),u})().finally(()=>{this.inFlightRequests.delete(s)});return this.inFlightRequests.set(s,o),o}async delete(e){try{return await(await caches.open(this.cacheName)).delete(e)}catch(t){return console.warn("Cache delete error:",t),!1}}async clear(){return this.clearCachePromise?this.clearCachePromise:(this.clearCachePromise=new Promise(async(e,t)=>{try{let r=await caches.open(this.cacheName),s=await r.keys();await Promise.all(s.map(o=>r.delete(o))),e()}catch(r){console.warn("Cache clear error:",r),t(r)}}),this.clearCachePromise.then(()=>{this.clearCachePromise=null}).catch(e=>{console.warn("Cache clear error:",e)}))}async keys(){try{return(await(await caches.open(this.cacheName)).keys()).map(r=>r.url)}catch(e){return console.warn("Cache keys error:",e),[]}}async has(e){try{let t=await caches.open(this.cacheName),r=await t.match(e);return r&&this.isExpired(r)?(await t.delete(e),!1):r!==void 0}catch(t){return console.warn("Cache has error:",t),!1}}async getStats(){try{return{total:(await(await caches.open(this.cacheName)).keys()).length}}catch(e){return console.warn("Cache stats error:",e),{total:0}}}async cleanupExpiredEntries(){try{let e=await caches.open(this.cacheName),t=await e.keys(),r=0;for(let o of t){let a=await e.match(o);a&&this.isExpired(a)&&(await e.delete(o),r++)}let s=t.length-r;return{removed:r,remaining:s}}catch(e){return console.warn("Cache cleanup error:",e),{removed:0,remaining:0}}}async getCacheKey(e,t){let r=this.getInputUrl(e),s=`${this.keyPrefix}${r}/${JSON.stringify(t)}`,a=new TextEncoder().encode(s),u=await crypto.subtle.digest("SHA-256",a);return`/${Array.from(new Uint8Array(u)).map(p=>p.toString(16).padStart(2,"0")).join("")}`}getInputUrl(e){return e instanceof URL?e.toString():typeof e=="string"?e:e.url}isExpired(e){let t=e.headers.get("Cache-Control");if(!t)return!1;let r=this.parseMaxAge(t),s=this.parseStaleWhileRevalidate(t);if(r===null)return!1;let o=e.headers.get("Date");if(!o)return!1;let a=new Date(o).getTime(),c=(Date.now()-a)/1e3,l=r+(s??0);return c>l}isStaleButRevalidatable(e){let t=e.headers.get("Cache-Control");if(!t)return!1;let r=this.parseMaxAge(t),s=this.parseStaleWhileRevalidate(t);if(r===null||s===null)return!1;let o=e.headers.get("Date");if(!o)return!1;let a=new Date(o).getTime(),c=(Date.now()-a)/1e3;return c>r&&c<=r+s}async revalidateInBackground(e,t,r,s){if(this.revalidationPromises.has(e))return;let o=(async()=>{try{let a=await fetch(t,r);a.ok&&await this.set(e,a.clone(),s??this.defaultCacheControl)}catch(a){console.warn("Background revalidation error:",a)}finally{this.revalidationPromises.delete(e)}})();this.revalidationPromises.set(e,o)}parseMaxAge(e){let t=new RegExp(/max-age=(\d+)/).exec(e);return t?parseInt(t[1],10):null}parseStaleWhileRevalidate(e){let t=new RegExp(/stale-while-revalidate=(\d+)/).exec(e);return t?parseInt(t[1],10):null}createCacheableResponse(e,t){let r=new Headers(e.headers);return r.set("Cache-Control",t),r.has("Date")||r.set("Date",new Date().toUTCString()),new Response(e.body,{status:e.status,statusText:e.statusText,headers:r})}};var we=class{static{i(this,"AjaxApiClient")}constructor(e){this.config=e;let t=H(e.storeDomain);this.cache=new Y(`ajax-api-${t}`,"max-age=60, stale-while-revalidate=3600"),this.cache.cleanupExpiredEntries().catch(r=>{console.warn("Ajax API cache initialization cleanup error:",r)})}patchFetch(){if(!window.fetch||typeof window.fetch!="function")return;let e=window.fetch,t=this.config.responseInterceptor,r=this.getFetchRequest.bind(this);window.fetch=function(...s){let o=e.apply(this,s);if(typeof t=="function"){let a=r(s[0]);o.then(u=>t(u,a))}return o}}getFetchRequest(e){return e instanceof Request?e:new Request(e)}getBaseUrl(){if(!this.config?.storeDomain)throw new Error("Cart API client not initialized - missing store domain");return`https://${this.config.storeDomain}`}fetch(e,t){return(e instanceof Request?e.method:t?.method??"GET")==="GET"?this.cache.fetchWithCache(e,t):fetch(e,t)}async request(e,t={}){let r=`${this.getBaseUrl()}${e}`,s={"Content-Type":"application/json",Accept:"application/json"},o=await this.fetch(r,{...t,headers:{...s,...t.headers}});if(!o.ok){let a;try{a=await o.json()}catch{a={message:`HTTP ${o.status}: ${o.statusText}`,status:o.status.toString(),description:o.statusText}}throw new Error(a.message||a.description)}return o.json()}async fetchCart(){return this.request("/cart.js")}async addToCart(e){let t={...e,items:e.items.map(r=>{let s=Number(A(String(r.id)));if(!Number.isFinite(s)||s<=0)throw new Error(`Invalid Shopify ID: ${r.id}`);return{...r,id:s}})};return this.request("/cart/add.js",{method:"POST",body:JSON.stringify(t)})}async clearCache(){await this.cache.clear()}};var Ie=class{constructor(e){this.eventMap={"/cart/add":"cart-add","/cart/update":"cart-update","/cart/change":"cart-change","/cart/clear":"cart-clear"};this.eventBus=e,this.processFetchResponse=this.processFetchResponse.bind(this)}static{i(this,"AjaxApiPublisher")}async processFetchResponse(e,t){try{let r=this.getEventName(t.url);if(r){let s=await e.clone().json();this.eventBus.publish(r,s)}}catch(r){console.warn(r)}}getEventName(e){for(let[t,r]of Object.entries(this.eventMap))if(e.includes(t))return r;return null}};function zr(){let n=document.body||document.documentElement;return n?Promise.resolve(n):new Promise(e=>{window.addEventListener("DOMContentLoaded",()=>e(n))})}i(zr,"waitForDOM");function ie({onElementFound:n,selector:e,observerOptions:t,mustMatch:r}){let s=new WeakSet,o=new MutationObserver(l=>{let p=!1;for(let f of l)if(f.addedNodes.length>0){p=!0;break}p&&a()}),a=i(()=>{document.querySelectorAll(e).forEach(l=>{s.has(l)||(s.add(l),r?.(l)!==!1&&u(l))})},"locateElements"),u=i(l=>{if(!t){n(l);return}let p=new IntersectionObserver(f=>{for(let y of f)y.isIntersecting&&(p.disconnect(),n(l))},t);p.observe(l)},"observeElement");return i(async()=>{let l=await zr();a(),o.observe(l,{childList:!0,subtree:!0})},"locateAndObserveElements")(),o}i(ie,"createElementLocator");function le({onLocationChange:n,fireOnInit:e=!1}){let t=i(()=>{n(window.location)},"handleChange");window.addEventListener("popstate",t);let r=history.pushState,s=history.replaceState;return history.pushState=function(...o){r.apply(this,o),t()},history.replaceState=function(...o){s.apply(this,o),t()},e&&t(),()=>{window.removeEventListener("popstate",t),history.pushState=r,history.replaceState=s}}i(le,"createLocationObserver");function ln({element:n,onHrefChange:e}){let t=i(()=>{e(n.href)},"handleChange"),r=new MutationObserver(()=>{t()});return r.observe(n,{attributes:!0,attributeFilter:["href"]}),()=>{r.disconnect()}}i(ln,"createHrefObserver");function fn(n,e){if(!e.element)throw new Error("Element must be provided");let t=null,r=new Map,s=i(()=>{if(t){console.warn("Placement already mounted. Skipping mount.");return}Kr(e),t=ie({selector:e.target.selector,observerOptions:e.target.observerOptions,mustMatch:e.target.mustMatch,onElementFound:i(l=>o(l),"onElementFound")})},"mount"),o=i(l=>{r.has(l)||l.hasAttribute("swish-ignore")||l.getAttribute("swish-placement-target")===e.id||(l.setAttribute("swish-placement-target",e.id),a(l))},"evaluateAndMount"),a=i(async l=>{let p=[],f=e.mount.mode,y=is(l,e.mount.at);if(!y)return;let h=await(typeof e.element=="function"?e.element(e):ls(n,e.element));if(!h)return;if(h.setAttribute("swish-placement-element",e.id),typeof e.element!="function"){let k=e.element;k.props&&ps(h,k.props),k.classNames&&mn(h,k.classNames)}let b;e.container&&(b=cs(e.id,e.container),b.appendChild(h));let g,O=b??h;if(e.layout?.type==="overlay"){as(y);let k=e.layout.anchor??"bottom-right";O.setAttribute("swish-placement-overlay",e.id),O.setAttribute("swish-placement-anchor",k)}let N=!1,L;if(e.layout?.type==="inline"){let k=e.layout,ee=k.rowSelector?y.closest(k.rowSelector):null;ee?g=ee:(g=us(e.id,y,k),N=!0),L=g.getAttribute("swish-placement-inline-row"),g.setAttribute("swish-placement-inline-row",e.id)}let G=b??h;if(!os(y,G,f)){try{G.remove()}catch{}return}let I={targetEl:l,renderTargetEl:y,mountEl:h,containerEl:b,rowEl:g,rowWasCreated:N,rowInlineAttrPrevValue:L,cleanupFns:p,ownsNode:!0};r.set(l,I);let M={id:e.id,targetEl:l,renderTargetEl:y,mountEl:I.mountEl,containerEl:b,rowEl:g,cleanup:i(k=>p.push(k),"cleanup")};e.element?.name==="save-button"&&Wr(n,M),e.onMount?.(M)},"mountElement"),u=i(l=>{let p=r.get(l);if(p){if(e.onUnmount?.({id:e.id,targetEl:p.targetEl,renderTargetEl:p.renderTargetEl,mountEl:p.mountEl,containerEl:p.containerEl,rowEl:p.rowEl}),p.cleanupFns.forEach(f=>f()),p.targetEl.getAttribute("swish-placement-target")===e.id&&p.targetEl.removeAttribute("swish-placement-target"),p.ownsNode&&(p.containerEl||p.mountEl).remove(),p.rowEl){if(p.rowWasCreated){let f=p.rowEl.parentElement;f&&p.targetEl.parentElement===p.rowEl?p.rowEl.replaceWith(p.targetEl):f?f.removeChild(p.rowEl):p.rowEl.remove()}else if(p.rowInlineAttrPrevValue!==void 0){let f=p.rowInlineAttrPrevValue;f===null?p.rowEl.removeAttribute("swish-placement-inline-row"):p.rowEl.setAttribute("swish-placement-inline-row",f)}}r.delete(l)}},"unmountElement");return{mount:s,unmount:i(()=>{t&&(t.disconnect(),t=null),r.forEach((l,p)=>u(p)),r.clear()},"unmount")}}i(fn,"createPlacement");var Wr=i((n,{mountEl:e,targetEl:t,cleanup:r})=>{let s=n.state.itemContext(t),o=n.state.effect(()=>{let{loading:a,productId:u,variantId:c}=s.value;a||(e.setAttribute("product-id",u??""),e.setAttribute("variant-id",c??""))});r(()=>o?.())},"saveButtonMount");function Kr(n){let e=Xr(n.id),t=ss(n),r=document.getElementById(e);if(r){r.textContent=t;return}let s=document.createElement("style");s.id=e,s.setAttribute("swish-placement-style",n.id),s.textContent=t,document.head.appendChild(s)}i(Kr,"ensurePlacementStylesheet");function Xr(n){return`swish-placement-style-${Yr(n)}`}i(Xr,"getPlacementStyleId");function Yr(n){return n.replace(/[^a-zA-Z0-9\-_]/g,"_")}i(Yr,"cssEscapeId");function pn(n){return`--swish-placement-${Jr(String(n))}`}i(pn,"designKeyToCSSVar");function Jr(n){return n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase()}i(Jr,"toKebabCase");function Zr(n){return Object.entries(n??{sm:500,lg:700}).map(([r,s])=>({name:r,minWidth:s})).sort((r,s)=>r.minWidth-s.minWidth)}i(Zr,"getBreakpoints");function hn(n,e){if(n==null)return{};if(typeof n=="object"&&!Array.isArray(n)){if(e&&e.size){let t=Object.keys(n);return"base"in n||t.some(s=>e.has(s))?n:{base:n}}return n}return{base:n}}i(hn,"normalizeResponsiveValue");var es=new Set(["fontWeight","lineHeight","pressedScale","backgroundAlpha","pressedOpacity","pressedScale"]);function dn(n,e){if(e!=null)return typeof e=="number"&&!es.has(n)?`${e}px`:String(e)}i(dn,"formatDesignValue");function ts(n,e,t){if(!e)return"";let r=new Set(t.map(c=>c.name)),s=[],o={},a=Object.entries(e).map(([c,l])=>[c,l]);for(let[c,l]of a){let p=hn(l,r),f=dn(String(c),p.base);f!==void 0&&s.push(`${pn(c)}:${f};`);for(let y of t){let h=p[y.name],b=dn(String(c),h);b!==void 0&&(o[y.name]||(o[y.name]=[]),o[y.name].push(`${pn(c)}:${b};`))}}let u=[];s.length&&u.push(`[swish-placement-element="${n}"]{${s.join("")}}`);for(let c of t){let l=o[c.name];l?.length&&u.push(`@media(min-width:${c.minWidth}px){[swish-placement-element="${n}"]{${l.join("")}}}`)}return u.join("")}i(ts,"emitDesignCSS");function be(n){return n==null?"0px":typeof n=="number"?`${n}px`:n}i(be,"formatOffsetValue");function ns(n){return n==null?"":typeof n=="number"?`${n}`:n}i(ns,"formatZIndexValue");function rs(n,e,t){let r=new Set(t.map(l=>l.name)),s=hn(e,r),o=s.base??{},a=be(o.x),u=be(o.y),c=[];c.push(`[swish-placement-overlay="${n}"]{--swish-placement-offset-x:${a};--swish-placement-offset-y:${u};}`);for(let l of t){let p=s[l.name];if(!p)continue;let f=be(p.x),y=be(p.y);c.push(`@media(min-width:${l.minWidth}px){[swish-placement-overlay="${n}"]{--swish-placement-offset-x:${f};--swish-placement-offset-y:${y};}}`)}return c.join("")}i(rs,"emitOverlayOffsetCSS");function ss(n){let e=n.id,t=Zr(n.breakpoints),r=`[swish-placement-inline-row="${e}"]{display:flex;flex-direction:row;align-items:center;gap:var(--swish-placement-inline-gap,8px);width:100%}[swish-placement-inline-row="${e}"]>*:not([swish-placement-element="${e}"]){flex:1;min-width:0}`,s=`[swish-placement-overlay="${e}"]{position:absolute;z-index:var(--swish-placement-overlay-z,10);transform:translate(calc(var(--swish-placement-sign-x,1)*var(--swish-placement-offset-x,0px)),calc(var(--swish-placement-sign-y,1)*var(--swish-placement-offset-y,0px)));}[swish-placement-overlay="${e}"][swish-placement-anchor="top-left"]{top:0;left:0;}[swish-placement-overlay="${e}"][swish-placement-anchor="top-right"]{top:0;right:0;}[swish-placement-overlay="${e}"][swish-placement-anchor="bottom-left"]{bottom:0;left:0;}[swish-placement-overlay="${e}"][swish-placement-anchor="bottom-right"]{bottom:0;right:0;}[swish-placement-overlay="${e}"][swish-placement-anchor$="left"]{--swish-placement-sign-x:1;}[swish-placement-overlay="${e}"][swish-placement-anchor$="right"]{--swish-placement-sign-x:-1;}[swish-placement-overlay="${e}"][swish-placement-anchor^="top"]{--swish-placement-sign-y:1;}[swish-placement-overlay="${e}"][swish-placement-anchor^="bottom"]{--swish-placement-sign-y:-1;}`,o="";if(n.layout?.type==="overlay"){let a=rs(e,n.layout.offset,t),u=n.layout.zIndex?`[swish-placement-overlay="${e}"]{--swish-placement-overlay-z:${ns(n.layout.zIndex)};}`:"";o+=a+u+s}else n.layout?.type==="inline"&&(o+=r);if(n.design){let a=ts(e,n.design,t);a&&(o+=a)}return n.css&&(o+=n.css.trim()),o}i(ss,"buildPlacementCSS");function is(n,e){if(!e||e==="target")return n;if("closest"in e)return n.closest(e.closest);if("query"in e)return n.querySelector(e.query);if("withinClosest"in e){let t=n.closest(e.withinClosest.root);return t?t.querySelector(e.withinClosest.selector):null}return n}i(is,"resolveMountTarget");function os(n,e,t){switch(t){case"before":return n.parentElement?(n.before(e),!0):!1;case"after":{let r=n.parentElement;return r?(r.insertBefore(e,n.nextSibling),!0):!1}case"append":return n.appendChild(e),!0;case"prepend":return n.insertBefore(e,n.firstChild),!0;case"replace":return n.parentElement?(n.replaceWith(e),!0):!1}}i(os,"insertIntoDOM");function as(n){let e=n.parentElement;return e?(window.getComputedStyle(e).position==="static"&&(e.style.position="relative"),e):null}i(as,"ensureRelativeParent");function us(n,e,t){if(!e.parentElement)throw new Error("Cannot inline-wrap: refEl has no parentElement");let s=document.createElement("div");return s.setAttribute("swish-placement-inline-row",n),e.before(s),s.appendChild(e),s}i(us,"wrapWithFlexRow");function cs(n,e){let t=e.tag||"div",r=document.createElement(t);return r.setAttribute("swish-placement-container",n),e.classNames&&mn(r,e.classNames),r}i(cs,"createContainer");function ls(n,e){return n.ui.createElement(e.name,{})}i(ls,"createElement");function ps(n,e){for(let[t,r]of Object.entries(e)){let s=t.replace(/([A-Z])/g,"-$1").toLowerCase();r===!1||r===void 0||r===null||(r===!0?n.setAttribute(s,"true"):n.setAttribute(s,String(r)))}}i(ps,"applyProps");function mn(n,e){n.classList.add(...e)}i(mn,"applyClassNames");var Se=class{constructor(){this.eventBus=new EventTarget}static{i(this,"EventBus")}subscribe(e,t,r){return Array.isArray(e)||(e=[e]),e.forEach(s=>{this.eventBus.addEventListener(s,t,r)}),()=>{e.forEach(s=>{this.eventBus.removeEventListener(s,t,r)})}}unsubscribe(e,t,r){this.eventBus.removeEventListener(e,t,r)}publish(e,t){this.eventBus.dispatchEvent(new CustomEvent(e,{detail:t}))}};var m=class{constructor(e,t,r,s){this.swish=e;this.ui=t;this.eventBus=r;this.options=s}static{i(this,"IntentHandler")}};var Ee=class extends m{static{i(this,"CreateListHandler")}async invoke(e){let t=await this.ui.showListEditor();if(t.code==="closed")return{intent:"create:list",code:"closed"};let{list:r}=t.data;return{intent:"create:list",code:"ok",data:{list:r}}}};var wt;function vn(n){return{lang:n?.lang??wt?.lang,message:n?.message,abortEarly:n?.abortEarly??wt?.abortEarly,abortPipeEarly:n?.abortPipeEarly??wt?.abortPipeEarly}}i(vn,"getGlobalConfig");var ds;function fs(n){return ds?.get(n)}i(fs,"getGlobalMessage");var hs;function ms(n){return hs?.get(n)}i(ms,"getSchemaMessage");var ys;function vs(n,e){return ys?.get(n)?.get(e)}i(vs,"getSpecificMessage");function xe(n){let e=typeof n;return e==="string"?`"${n}"`:e==="number"||e==="bigint"||e==="boolean"?`${n}`:e==="object"||e==="function"?(n&&Object.getPrototypeOf(n)?.constructor?.name)??"null":e}i(xe,"_stringify");function K(n,e,t,r,s){let o=s&&"input"in s?s.input:t.value,a=s?.expected??n.expects??null,u=s?.received??xe(o),c={kind:n.kind,type:n.type,input:o,expected:a,received:u,message:`Invalid ${e}: ${a?`Expected ${a} but r`:"R"}eceived ${u}`,requirement:n.requirement,path:s?.path,issues:s?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},l=n.kind==="schema",p=s?.message??n.message??vs(n.reference,c.lang)??(l?ms(c.lang):null)??r.message??fs(c.lang);p!==void 0&&(c.message=typeof p=="function"?p(c):p),l&&(t.typed=!1),t.issues?t.issues.push(c):t.issues=[c]}i(K,"_addIssue");function J(n){return{version:1,vendor:"valibot",validate(e){return n["~run"]({value:e},vn())}}}i(J,"_getStandardProps");function gn(n,e){let t=[...new Set(n)];return t.length>1?`(${t.join(` ${e} `)})`:t[0]??"never"}i(gn,"_joinExpects");function It(n,e){return{kind:"validation",type:"min_length",reference:It,async:!1,expects:`>=${n}`,requirement:n,message:e,"~run"(t,r){return t.typed&&t.value.length<this.requirement&&K(this,"length",t,r,{received:`${t.value.length}`}),t}}}i(It,"minLength");function te(n,e){return{kind:"validation",type:"min_value",reference:te,async:!1,expects:`>=${n instanceof Date?n.toJSON():xe(n)}`,requirement:n,message:e,"~run"(t,r){return t.typed&&!(t.value>=this.requirement)&&K(this,"value",t,r,{received:t.value instanceof Date?t.value.toJSON():xe(t.value)}),t}}}i(te,"minValue");function P(n){return{kind:"transformation",type:"transform",reference:P,async:!1,operation:n,"~run"(e){return e.value=this.operation(e.value),e}}}i(P,"transform");function gs(n,e,t){return typeof n.fallback=="function"?n.fallback(e,t):n.fallback}i(gs,"getFallback");function wn(n,e,t){return typeof n.default=="function"?n.default(e,t):n.default}i(wn,"getDefault");function de(n,e){return{kind:"schema",type:"array",reference:de,expects:"Array",async:!1,item:n,message:e,get"~standard"(){return J(this)},"~run"(t,r){let s=t.value;if(Array.isArray(s)){t.typed=!0,t.value=[];for(let o=0;o<s.length;o++){let a=s[o],u=this.item["~run"]({value:a},r);if(u.issues){let c={type:"array",origin:"value",input:s,key:o,value:a};for(let l of u.issues)l.path?l.path.unshift(c):l.path=[c],t.issues?.push(l);if(t.issues||(t.issues=u.issues),r.abortEarly){t.typed=!1;break}}u.typed||(t.typed=!1),t.value.push(u.value)}}else K(this,"type",t,r);return t}}}i(de,"array");function bt(n){return{kind:"schema",type:"boolean",reference:bt,expects:"boolean",async:!1,message:n,get"~standard"(){return J(this)},"~run"(e,t){return typeof e.value=="boolean"?e.typed=!0:K(this,"type",e,t),e}}}i(bt,"boolean");function x(n){return{kind:"schema",type:"number",reference:x,expects:"number",async:!1,message:n,get"~standard"(){return J(this)},"~run"(e,t){return typeof e.value=="number"&&!isNaN(e.value)?e.typed=!0:K(this,"type",e,t),e}}}i(x,"number");function w(n,e){return{kind:"schema",type:"object",reference:w,expects:"Object",async:!1,entries:n,message:e,get"~standard"(){return J(this)},"~run"(t,r){let s=t.value;if(s&&typeof s=="object"){t.typed=!0,t.value={};for(let o in this.entries){let a=this.entries[o];if(o in s||(a.type==="exact_optional"||a.type==="optional"||a.type==="nullish")&&a.default!==void 0){let u=o in s?s[o]:wn(a),c=a["~run"]({value:u},r);if(c.issues){let l={type:"object",origin:"value",input:s,key:o,value:u};for(let p of c.issues)p.path?p.path.unshift(l):p.path=[l],t.issues?.push(p);if(t.issues||(t.issues=c.issues),r.abortEarly){t.typed=!1;break}}c.typed||(t.typed=!1),t.value[o]=c.value}else if(a.fallback!==void 0)t.value[o]=gs(a);else if(a.type!=="exact_optional"&&a.type!=="optional"&&a.type!=="nullish"&&(K(this,"key",t,r,{input:void 0,expected:`"${o}"`,path:[{type:"object",origin:"key",input:s,key:o,value:s[o]}]}),r.abortEarly))break}}else K(this,"type",t,r);return t}}}i(w,"object");function _(n,e){return{kind:"schema",type:"optional",reference:_,expects:`(${n.expects} | undefined)`,async:!1,wrapped:n,default:e,get"~standard"(){return J(this)},"~run"(t,r){return t.value===void 0&&(this.default!==void 0&&(t.value=wn(this,t,r)),t.value===void 0)?(t.typed=!0,t):this.wrapped["~run"](t,r)}}}i(_,"optional");function fe(n,e){return{kind:"schema",type:"picklist",reference:fe,expects:gn(n.map(xe),"|"),async:!1,options:n,message:e,get"~standard"(){return J(this)},"~run"(t,r){return this.options.includes(t.value)?t.typed=!0:K(this,"type",t,r),t}}}i(fe,"picklist");function v(n){return{kind:"schema",type:"string",reference:v,expects:"string",async:!1,message:n,get"~standard"(){return J(this)},"~run"(e,t){return typeof e.value=="string"?e.typed=!0:K(this,"type",e,t),e}}}i(v,"string");function yn(n){let e;if(n)for(let t of n)e?e.push(...t.issues):e=t.issues;return e}i(yn,"_subIssues");function V(n,e){return{kind:"schema",type:"union",reference:V,expects:gn(n.map(t=>t.expects),"|"),async:!1,options:n,message:e,get"~standard"(){return J(this)},"~run"(t,r){let s,o,a;for(let u of this.options){let c=u["~run"]({value:t.value},r);if(c.typed)if(c.issues)o?o.push(c):o=[c];else{s=c;break}else a?a.push(c):a=[c]}if(s)return s;if(o){if(o.length===1)return o[0];K(this,"type",t,r,{issues:yn(o)}),t.typed=!0}else{if(a?.length===1)return a[0];K(this,"type",t,r,{issues:yn(a)})}return t}}}i(V,"union");function S(...n){return{...n[0],pipe:n,get"~standard"(){return J(this)},"~run"(e,t){for(let r of n)if(r.kind!=="metadata"){if(e.issues&&(r.kind==="schema"||r.kind==="transformation")){e.typed=!1;break}(!e.issues||!t.abortEarly&&!t.abortPipeEarly)&&(e=r["~run"](e,t))}return e}}}i(S,"pipe");function E(n,e,t){let r=n["~run"]({value:e},vn(t));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}i(E,"safeParse");var ws=w({itemId:v(),delete:_(bt())}),Ce=class extends m{static{i(this,"UnsaveItemHandler")}async invoke(e){let t=E(ws,e);if(!t.success)return{intent:"unsave:item",code:"error",message:"Invalid intent data",issues:t.issues.map(a=>a.message)};let{itemId:r,delete:s}=t.output;if(this.options.unsaveProduct.selectList&&!s){let a=await this.ui.showListSelect({itemId:r});if(a.code==="closed")return{intent:"unsave:item",code:"closed"};if(a.data.action==="submit"){let{item:u,product:c,variant:l}=a.data.data;return{intent:"edit:item-lists",code:"ok",data:{item:u,product:c,variant:l}}}if(a.data.action==="unsave"){let{itemId:u}=a.data.data;return{intent:"unsave:item",code:"ok",data:{itemId:u}}}}if(!this.options.unsaveProduct.confirm){let a=await this.swish.api.items.deleteById(r);return"error"in a?{intent:"unsave:item",code:"error",message:"Failed to delete item",issues:[a.error.message]}:{intent:"unsave:item",code:"ok",data:{itemId:r}}}return(await this.ui.showUnsaveAlert({itemId:r})).code==="closed"?{intent:"unsave:item",code:"closed"}:{intent:"unsave:item",code:"ok",data:{itemId:r}}}};var Is=w({listId:v()}),ke=class extends m{static{i(this,"DeleteListHandler")}async invoke(e){let t=E(Is,e);if(!t.success)return{intent:"delete:list",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{listId:r}=t.output;return(await this.ui.showDeleteListAlert({listId:r})).code==="closed"?{intent:"delete:list",code:"closed"}:{intent:"delete:list",code:"ok",data:{listId:r}}}};var bs=w({itemId:v()}),Re=class extends m{static{i(this,"EditItemListsHandler")}async invoke(e){let t=E(bs,e);if(!t.success)return{intent:"edit:item-lists",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{itemId:r}=t.output,s=await this.ui.showListSelect({itemId:r});if(s.code==="closed")return{intent:"edit:item-lists",code:"closed"};if(s.data.action==="submit"){let{item:o,product:a,variant:u}=s.data.data;return{intent:"edit:item-lists",code:"ok",data:{item:o,product:a,variant:u}}}return{intent:"unsave:item",code:"ok",data:{itemId:s.data.data.itemId}}}};var Ss=w({itemId:S(v()),productId:S(V([S(v(),P(A)),x()]),P(n=>Number(n)),x()),variantId:_(S(V([S(v(),P(A)),x()]),P(n=>Number(n)),x()))}),Ae=class extends m{static{i(this,"EditItemVariantHandler")}async invoke(e){let t=E(Ss,e);if(!t.success)return{intent:"edit:item-variant",code:"error",message:"Invalid intent data",issues:t.issues.map(y=>y.message)};let{itemId:r,productId:s,variantId:o}=t.output;if(!(!o||this.swish.options.intents.editSavedProduct.promptVariantChange)){let y=await this.swish.api.items.updateById(r,{productId:s,variantId:o});if("error"in y)return{intent:"edit:item-variant",code:"error",message:"Failed to update variant",issues:[y.error.message]};if(!y.data)return{intent:"edit:item-variant",code:"error",message:"Failed to update variant",issues:["No item returned from API"]};let h=await this.swish.storefront.loadSaveIntentData({productId:D("Product",s),variantId:o?D("ProductVariant",o):void 0});if(!h.data?.product)return{intent:"edit:item-variant",code:"error",message:"Failed to load save intent data",issues:[h.errors?.message??"No product data returned from API"]};let b=h.data?.product,g="variant"in h.data?h.data.variant:void 0;return{intent:"edit:item-variant",code:"ok",data:{item:y.data,product:b,variant:g}}}let u=await this.ui.showVariantSelect({itemId:r,productId:s,variantId:o});if(u.code==="closed")return{intent:"edit:item-variant",code:"closed"};let{item:c,product:l,variant:p}=u.data;return{intent:"edit:item-variant",code:"ok",data:{item:c,product:l,variant:p}}}};var Es=w({listId:v()}),De=class extends m{static{i(this,"EditListHandler")}async invoke(e){let t=E(Es,e);if(!t.success)return{intent:"edit:list",code:"error",message:"Invalid intent data",issues:t.issues.map(a=>a.message)};let{listId:r}=t.output,s=await this.ui.showListEditor({listId:r});if(s.code==="closed")return{intent:"edit:list",code:"closed"};let{list:o}=s.data;return{intent:"edit:list",code:"ok",data:{list:o}}}};var xs=w({listId:v(),access:fe(["public","private"])}),Pe=class extends m{static{i(this,"EditListAccessHandler")}async invoke(e){let t=E(xs,e);if(!t.success)return{intent:"edit:list-access",code:"error",message:"Invalid intent data",issues:t.issues.map(u=>u.message)};let{listId:r,access:s}=t.output;if((await this.ui.showConfirmDialog({titleKey:s==="public"?"listMenu.public.title":"listMenu.private.title",descriptionKey:s==="public"?"listMenu.public.description":"listMenu.private.description",confirmLabelKey:s==="public"?"listMenu.public.text":"listMenu.private.text",cancelLabelKey:"listMenu.cancel",danger:!1})).code==="closed")return{intent:"edit:list-access",code:"closed"};let a=await this.swish.api.lists.updateById(r,{access:s});return"error"in a?{intent:"edit:list-access",code:"error",message:"Failed to update list access",issues:[a.error.message]}:a.data?{intent:"edit:list-access",code:"ok",data:{list:a.data}}:{intent:"edit:list-access",code:"error",message:"Failed to update list access",issues:["API response missing data"]}}};var Te=class extends m{static{i(this,"OpenHomeHandler")}async invoke(e){return{intent:"open:home",code:(await this.ui.showDrawer()).code,data:void 0}}};var Cs=w({listId:v()}),_e=class extends m{static{i(this,"OpenListDetailPageMenuHandler")}async invoke(e){let t=E(Cs,e);if(!t.success)return{intent:"open:list-detail-page-menu",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{listId:r}=t.output;return{intent:"open:list-detail-page-menu",code:(await this.ui.showListDetailPageMenu({listId:r})).code,data:void 0}}};var ks=w({listId:v()}),Oe=class extends m{static{i(this,"OpenListHandler")}async invoke(e){let t=E(ks,e);if(!t.success)return{intent:"open:list",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{listId:r}=t.output;return{intent:"open:list",code:(await this.ui.showDrawer({view:"list",listId:r})).code,data:void 0}}};var Rs=w({listId:v()}),Le=class extends m{static{i(this,"OpenListMenuHandler")}async invoke(e){let t=E(Rs,e);if(!t.success)return{intent:"open:list-menu",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{listId:r}=t.output,s=await this.ui.showListMenu({listId:r});if(s.code==="closed")return{intent:"open:list-menu",code:"closed"};if(s.data.action==="edit")return{intent:"edit:list",code:"ok",data:s.data.data};if(s.data.action==="delete")return{intent:"delete:list",code:"ok",data:{listId:r}};if(s.data.action==="edit-access"){let o=s.data.data?.currentListAccess,a=o==="public"?"private":o==="private"?"public":void 0;return a?(await this.swish.intents.invoke("edit:list-access",{listId:r,access:a})).complete:{intent:"open:list-menu",code:"error",message:"Missing list access from UI",issues:["List menu UI did not provide currentListAccess"]}}return s.data.action==="share"?(await this.swish.intents.invoke("share:list",{listId:r})).complete:{intent:"open:list-menu",code:"error",message:"Unknown list menu action",issues:["Unknown action returned from list menu UI"]}}};var $e=class extends m{static{i(this,"OpenListsHandler")}async invoke(e){return{intent:"open:lists",code:(await this.ui.showDrawer({view:"lists"})).code,data:void 0}}};var Me=class extends m{static{i(this,"OpenNotificationsHandler")}async invoke(e){return{intent:"open:notifications",code:(await this.ui.showDrawer({view:"notifications"})).code,data:void 0}}};var As=w({orderId:S(V([S(v(),P(A)),x()]),P(n=>Number(n)),x())}),Ve=class extends m{static{i(this,"OpenOrderHandler")}async invoke(e){let t=E(As,e);if(!t.success)return{intent:"open:order",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{orderId:r}=t.output;return{intent:"open:order",code:(await this.ui.showDrawer({view:"order",orderId:r.toString()})).code,data:void 0}}};var Ds=w({orderId:v()}),qe=class extends m{static{i(this,"OpenOrderMenuHandler")}async invoke(e){let t=E(Ds,e);if(!t.success)return{intent:"open:order-menu",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{orderId:r}=t.output;return{intent:"open:order-menu",code:(await this.ui.showOrderMenu({orderId:r})).code,data:void 0}}};var Ne=class extends m{static{i(this,"OpenOrdersHandler")}async invoke(e){return{intent:"open:orders",code:(await this.ui.showDrawer({view:"orders"})).code,data:void 0}}};var Ps=w({productId:S(V([S(v(),P(A)),x()]),P(n=>Number(n)),x()),variantId:_(S(V([S(v(),P(A)),x()]),P(Number),x()))}),Be=class extends m{static{i(this,"OpenProductHandler")}async invoke(e){let t=E(Ps,e);if(!t.success)return{intent:"open:product",code:"error",message:"Invalid intent data",issues:t.issues.map(a=>a.message)};let{productId:r,variantId:s}=t.output;return{intent:"open:product",code:(await this.ui.showDrawer({view:"product",productId:r.toString(),variantId:s?.toString()})).code,data:void 0}}};var Ue=class extends m{static{i(this,"OpenProfileHandler")}async invoke(e){return{intent:"open:profile",code:(await this.ui.showDrawer({view:"profile"})).code,data:void 0}}};var Ts=w({productId:S(V([S(v(),P(A)),x()]),P(n=>Number(n)),x()),variantId:_(S(V([S(v(),P(A)),x()]),P(Number),x()))}),Fe=class extends m{static{i(this,"OpenQuickBuyHandler")}async invoke(e){let t=E(Ts,e);if(!t.success)return{intent:"open:quick-buy",code:"error",message:"Invalid intent data",issues:t.issues.map(a=>a.message)};let{productId:r,variantId:s}=t.output,o=await this.ui.showQuickBuy({productId:r,variantId:s});return o.code==="closed"?{intent:"open:quick-buy",code:"closed"}:{intent:"open:quick-buy",code:"ok",data:o.data}}};var je=class extends m{static{i(this,"OpenSavesHandler")}async invoke(e){return{intent:"open:saves",code:(await this.ui.showDrawer({view:"saves"})).code,data:void 0}}};var Fa=w({returnTo:_(v())}),Ge=class extends m{static{i(this,"OpenSignInHandler")}async invoke(e){return{intent:"open:sign-in",code:(await this.ui.showSignIn({returnTo:e?.returnTo})).code,data:void 0}}};var _s=w({productId:S(V([S(v(),P(A)),x()]),P(n=>Number(n)),x()),variantId:_(S(V([S(v(),P(A)),x()]),P(Number),x())),quantity:_(S(x(),te(1))),tags:_(de(v()))}),He=class extends m{static{i(this,"SaveItemHandler")}async invoke(e){let t=E(_s,e);if(!t.success)return{intent:"save:item",code:"error",message:"Invalid intent data",issues:t.issues.map(h=>h.message)};let{productId:r,variantId:s,quantity:o,tags:a}=t.output,u=await this.swish.storefront.loadSaveIntentData({productId:D("Product",r),variantId:s?D("ProductVariant",s):void 0});if(u.errors)return{intent:"save:item",code:"error",message:u.errors.message??"Failed to load save intent data",issues:u.errors.graphQLErrors?.map(h=>h.message)??[]};if(!u.data||!u.data.product)return{intent:"save:item",code:"error",message:"Failed to load save intent data",issues:["API response missing data"]};let{product:c}=u.data,l=c.variantsCount?.count&&c.variantsCount.count>1,p=!!s,f=!this.options.saveProduct.promptVariantIfMissing||!this.options.saveProduct.promptVariantIfPresent&&p;if(!l||f){let h=i(()=>!l&&c.selectedOrFirstAvailableVariant?Number(A(c.selectedOrFirstAvailableVariant.id)):s,"variantIdToUse"),b=await this.swish.api.items.create({productId:r,variantId:h(),quantity:o,tags:a});if("error"in b)return{intent:"save:item",code:"error",message:"Failed to create item",issues:[b.error.message]};if(!b.data)return{intent:"save:item",code:"error",message:"Could not complete item creation",issues:["API response missing data"]};let g="variant"in u.data?u.data.variant:void 0;return{intent:"save:item",code:"ok",data:{item:b.data,product:c,variant:l?g:c.selectedOrFirstAvailableVariant}}}let y=await this.ui.showVariantSelect({productId:r,variantId:s});return y.code==="closed"?{intent:"save:item",code:"closed"}:{intent:"save:item",code:"ok",data:y.data}}};function he(n,e){let{storeDomain:t}=n.options.storefrontApi,{rootUrl:r,listDetailPagePath:s}=n.options.storefrontContext.routes,o=new URL(`https://${t}`),a=new URL(`${r==="/"?"":r}${s}`,o);return a.searchParams.set("public-list-id",e.publicListId),a}i(he,"buildShareListUrl");async function me(n){return typeof navigator?.clipboard?.writeText!="function"?{ok:!1,issues:["Clipboard API not available"]}:navigator.clipboard.writeText(n).then(()=>({ok:!0})).catch(e=>({ok:!1,issues:[e?.message??"Failed to copy to clipboard"]}))}i(me,"copyToClipboard");function In(){let n=navigator.userAgent.includes("Mac OS")&&navigator.maxTouchPoints>1;return/Android|Mobile/i.test(navigator.userAgent)||n}i(In,"isMobileDevice");var Os=w({listId:v()}),Qe=class extends m{static{i(this,"ShareListHandler")}async invoke(e){let t=E(Os,e);if(!t.success)return{intent:"share:list",code:"error",message:"Invalid intent data",issues:t.issues.map(u=>u.message)};let{listId:r}=t.output,s=he(this.swish,{publicListId:r}).toString();if(In()&&typeof navigator.share=="function"&&(await navigator.share({title:"Share list",url:s}).then(()=>({ok:!0})).catch(()=>({ok:!1}))).ok)return{intent:"share:list",code:"ok",data:{listId:r,url:s,method:"native"}};let a=await me(s);return a.ok?{intent:"share:list",code:"ok",data:{listId:r,url:s,method:"clipboard"}}:{intent:"share:list",code:"error",message:"Failed to share list",issues:a.issues}}};var uu=w({title:_(v()),text:v(),image:_(v()),action:_(w({label:v(),url:_(v())})),variant:_(fe(["compact","full"])),icon:_(v())}),ze=class extends m{static{i(this,"ShowToastHandler")}async invoke(e){return{intent:"show:toast",code:(await this.ui.showToast(e)).code,data:void 0}}};var St=S(V([S(v(),P(A)),x()]),P(n=>Number(n)),S(x(),te(1)));var Ls=V([w({variantId:St,quantity:_(S(x(),te(1)),1)}),w({items:S(de(w({variantId:St,quantity:_(S(x(),te(1)),1)})),It(1))})]),We=class extends m{static{i(this,"CreateCartLineHandler")}async invoke(e){let t=E(Ls,e);if(!t.success)return{intent:"create:cart-line",code:"error",message:"Invalid intent data",issues:t.issues.map(s=>s.message)};let r=t.output;try{let s="items"in r?r.items.map(a=>({id:a.variantId,quantity:a.quantity})):[{id:r.variantId,quantity:r.quantity}];return{intent:"create:cart-line",code:"ok",data:await this.swish.ajax.addToCart({items:s})}}catch(s){let o=[],a="Failed to add item to cart";return s instanceof Error?(s.message&&(a=s.message,o.push(s.message)),s.stack&&o.push(s.stack)):typeof s=="string"&&s.trim()?(a=s,o.push(s)):s!=null&&o.push(String(s)),{intent:"create:cart-line",code:"error",message:a,issues:o.length?o:["Cart request failed"]}}}};var z=class{constructor(e,t,r){this.swish=e;this.ui=t;this.options=r}static{i(this,"IntentHook")}};var Ke=class extends z{static{i(this,"AfterEditItemListsHook")}async invoke(e){if(this.options.editSavedProduct.showFeedback&&e.code==="ok"){if("itemId"in e.data)return;let{product:t,variant:r}=e.data;t&&(await(await this.swish.intents.invoke("show:toast",{title:"Saved",text:t.title,image:r?.image?.url??t.featuredImage?.url,action:{label:"View"}})).complete).code==="ok"&&this.swish.intents.invoke("open:home")}}};var Xe=class extends z{static{i(this,"AfterEditListAccessHook")}async invoke(e){if(e.code!=="ok")return;let t=e.data.list.access==="public"?"List is now public":"List is now private";await(await this.swish.intents.invoke("show:toast",{text:t,variant:"compact",icon:"check"})).complete}};var Ye=class extends z{static{i(this,"AfterOpenHomeHook")}async invoke(e){if(e.code==="closed"){let t=new URL(window.location.href);(t.hash==="#swish-home"||t.hash==="#swish")&&(t.hash="",window.history.replaceState({},document.title,t.toString()))}}};var Je=class extends z{static{i(this,"AfterSaveItemHook")}async invoke(e){if(this.options.saveProduct.showFeedback&&e.code==="ok"){let{item:t,product:r,variant:s}=e.data;r&&(await(await this.swish.intents.invoke("show:toast",{title:"Saved",text:r.title,image:s?.image?.url??r.featuredImage?.url,action:{label:"Add to List"}})).complete).code==="ok"&&this.swish.intents.invoke("edit:item-lists",{itemId:t.id})}}};var Ze=class extends z{static{i(this,"AfterShareListHook")}async invoke(e){if(e.code!=="ok")return;await(await this.swish.intents.invoke("show:toast",{variant:"compact",text:"Link shared",icon:"check"})).complete}};var et=class{static{i(this,"Intents")}constructor(e,t){this.swish=e,this.ui=t,this.eventBus=new EventTarget,this.options=e.options.intents,this.handlers={"create:cart-line":new We(this.swish,this.ui,this.eventBus,this.options),"save:item":new He(this.swish,this.ui,this.eventBus,this.options),"unsave:item":new Ce(this.swish,this.ui,this.eventBus,this.options),"edit:item-variant":new Ae(this.swish,this.ui,this.eventBus,this.options),"edit:item-lists":new Re(this.swish,this.ui,this.eventBus,this.options),"create:list":new Ee(this.swish,this.ui,this.eventBus,this.options),"edit:list":new De(this.swish,this.ui,this.eventBus,this.options),"edit:list-access":new Pe(this.swish,this.ui,this.eventBus,this.options),"delete:list":new ke(this.swish,this.ui,this.eventBus,this.options),"open:home":new Te(this.swish,this.ui,this.eventBus,this.options),"share:list":new Qe(this.swish,this.ui,this.eventBus,this.options),"open:list":new Oe(this.swish,this.ui,this.eventBus,this.options),"open:lists":new $e(this.swish,this.ui,this.eventBus,this.options),"open:orders":new Ne(this.swish,this.ui,this.eventBus,this.options),"open:order":new Ve(this.swish,this.ui,this.eventBus,this.options),"open:saves":new je(this.swish,this.ui,this.eventBus,this.options),"open:notifications":new Me(this.swish,this.ui,this.eventBus,this.options),"open:profile":new Ue(this.swish,this.ui,this.eventBus,this.options),"open:product":new Be(this.swish,this.ui,this.eventBus,this.options),"open:list-menu":new Le(this.swish,this.ui,this.eventBus,this.options),"open:order-menu":new qe(this.swish,this.ui,this.eventBus,this.options),"open:list-detail-page-menu":new _e(this.swish,this.ui,this.eventBus,this.options),"open:sign-in":new Ge(this.swish,this.ui,this.eventBus,this.options),"open:quick-buy":new Fe(this.swish,this.ui,this.eventBus,this.options),"show:toast":new ze(this.swish,this.ui,this.eventBus,this.options)},this.initIntentHooks(),this.initIntentWatcher()}publishAnalyticsEvent(e,t){typeof window.Shopify?.analytics?.publish=="function"&&window.Shopify.analytics.publish(e,t)}async invoke(e,...t){let r=t[0],s={lifecycle:"before",intent:e,data:r};return this.publishAnalyticsEvent("swish-intent",s),this.publishAnalyticsEvent(`swish-intent=${e}`,s),{intent:e,data:r,complete:this.handleIntent(e,r).then(o=>{let a={lifecycle:"after",intent:e,data:r,response:o};return this.publishAnalyticsEvent("swish-intent",a),this.publishAnalyticsEvent(`swish-intent=${e}`,a),this.eventBus.dispatchEvent(new CustomEvent(e,{detail:o})),o})}}listen(e,t){let r=i(o=>{"detail"in o&&o.detail?t(o.detail):console.warn("Intent response event without detail",o)},"eventListener"),s=i(()=>{this.eventBus.removeEventListener(e,r)},"unsubscribe");return this.eventBus.addEventListener(e,r),s}parseIntentFromString(e){if(typeof e=="string"){let[t,...r]=e.split(","),s=r.reduce((o,a)=>{let[u,c]=a.split("=");return o[u]=c,o},{});return{intent:t,data:s}}return{intent:e,data:{}}}parseIntentFromHash(e){let t=e.startsWith("#")?e.slice(1):e;return{swish:"open:home","swish-home":"open:home","swish-lists":"open:lists","swish-orders":"open:orders","swish-saves":"open:saves","swish-notifications":"open:notifications","swish-profile":"open:profile"}[t]||null}async handleIntent(e,t){let r=this.handlers[e];return r?r.invoke(t):{intent:e,code:"error",message:"Invalid intent",issues:[`Intent ${e} not found`]}}initIntentHooks(){this.eventBus.addEventListener("save:item",e=>{new Je(this.swish,this.ui,this.options).invoke(e.detail)}),this.eventBus.addEventListener("edit:item-lists",e=>{new Ke(this.swish,this.ui,this.options).invoke(e.detail)}),this.eventBus.addEventListener("open:home",e=>{new Ye(this.swish,this.ui,this.options).invoke(e.detail)}),this.eventBus.addEventListener("edit:list-access",e=>{new Xe(this.swish,this.ui,this.options).invoke(e.detail)}),this.eventBus.addEventListener("share:list",e=>{new Ze(this.swish,this.ui,this.options).invoke(e.detail)})}initIntentWatcher(){ie({selector:"[swish-intent]",onElementFound:i(e=>{let t=e.getAttribute("swish-intent");t&&e.addEventListener("click",()=>{let{intent:r,data:s}=this.parseIntentFromString(t);Object.keys(s).length>0?this.invoke(r,s):this.invoke(r)})},"onElementFound")}),ie({selector:"a[href*='swish-intent='],a[href*='#swish']",onElementFound:i(e=>{e instanceof HTMLAnchorElement&&e.addEventListener("click",t=>{if(!t.metaKey&&!t.ctrlKey&&!t.shiftKey&&!t.altKey){let r=new URL(e.href),s=r.hash,o=r.searchParams.get("swish-intent");if(o){let{intent:a,data:u}=this.parseIntentFromString(o);a&&(t.preventDefault(),t.stopPropagation(),Object.keys(u).length>0?this.invoke(a,u):this.invoke(a))}else if(s){let a=this.parseIntentFromHash(s);a&&(t.preventDefault(),t.stopPropagation(),this.invoke(a))}}})},"onElementFound")}),le({fireOnInit:!0,onLocationChange:i(e=>{let t=new URL(e.href),r=t.hash,s=t.searchParams.get("swish-intent");if(s){let{intent:o,data:a}=this.parseIntentFromString(s);o&&(Object.keys(a).length>0?this.invoke(o,a):this.invoke(o))}else if(r){let o=this.parseIntentFromHash(r);o&&this.invoke(o)}},"onLocationChange")})}};var bn=i(n=>({swishApi:{authProxy:n.swishApi?.authProxy??"/apps/wishlist/api",version:n.swishApi?.version??"2026-01"},storefrontApi:{storeDomain:n.storefrontApi?.storeDomain??"",accessToken:n.storefrontApi?.accessToken??""},storefrontContext:{...n.storefrontContext,routes:{...n.storefrontContext.routes,rootUrl:n.storefrontContext.routes?.rootUrl??"/",listDetailPagePath:n.storefrontContext.routes?.listDetailPagePath??"/apps/wishlist"},localization:{country:n.storefrontContext.localization.country.toUpperCase(),language:n.storefrontContext.localization.language.toUpperCase(),market:n.storefrontContext.localization.market}},badges:{getBadges:n.badges?.getBadges??(({defaultBadges:e})=>e)},productOptions:{sortValues:n.productOptions?.sortValues??(({option:e,optionValues:t})=>t)},metafields:{product:n.metafields?.product??[],productVariant:n.metafields?.productVariant??[]},features:{accounts:n?.features?.accounts??!0,lists:n?.features?.lists??!0,orders:n?.features?.orders??!0,notifications:n?.features?.notifications??!0},intents:{saveProduct:{promptVariantIfMissing:n?.intents?.saveProduct?.promptVariantIfMissing??!0,promptVariantIfPresent:n?.intents?.saveProduct?.promptVariantIfPresent??!0,showFeedback:n?.intents?.saveProduct?.showFeedback??!0},unsaveProduct:{selectList:n?.intents?.unsaveProduct?.selectList??!0,confirm:n?.intents?.unsaveProduct?.confirm??!0,showFeedback:n?.intents?.unsaveProduct?.showFeedback??!0},editSavedProduct:{promptVariantChange:n?.intents?.editSavedProduct?.promptVariantChange??!0,showFeedback:n?.intents?.editSavedProduct?.showFeedback??!0}},swishUi:{baseUrl:n.swishUi?.baseUrl??"https://swish.app/cdn",version:n.swishUi?.version??tt,components:{productRow:{showVariantTitle:n.swishUi?.components?.productRow?.showVariantTitle??!1},productDetail:{descriptionMaxLines:n.swishUi?.components?.productDetail?.descriptionMaxLines??4},variantSelect:{displayType:n.swishUi?.components?.variantSelect?.displayType??"pills"},icons:n.swishUi?.components?.icons??{},imageSlider:{flush:n.swishUi?.components?.imageSlider?.flush??!1,loop:n.swishUi?.components?.imageSlider?.loop??!1},images:{baseTint:n.swishUi?.components?.images?.baseTint??!1},buyButtons:{shopPay:n.swishUi?.components?.buyButtons?.shopPay??!1},listDetailPage:{desktopColumns:n.swishUi?.components?.listDetailPage?.desktopColumns??4,showBuyButton:n.swishUi?.components?.listDetailPage?.showBuyButton??!0,showVariantOptionNames:n.swishUi?.components?.listDetailPage?.showVariantOptionNames??!1,enableVariantChange:n.swishUi?.components?.listDetailPage?.enableVariantChange??!0},drawer:{title:n.swishUi?.components?.drawer?.title??"",logo:{url:n.swishUi?.components?.drawer?.logo?.url??"",altText:n.swishUi?.components?.drawer?.logo?.altText??""},navigation:{enabled:n.swishUi?.components?.drawer?.navigation?.enabled??!0,variant:n.swishUi?.components?.drawer?.navigation?.variant??"floating",items:n.swishUi?.components?.drawer?.navigation?.items??[]},emptyCallout:{enabled:n.swishUi?.components?.drawer?.emptyCallout?.enabled??!1,shoppingCalloutUrl:n.swishUi?.components?.drawer?.emptyCallout?.shoppingCalloutUrl??"/collections/all"},miniMenu:{enabled:n.swishUi?.components?.drawer?.miniMenu?.enabled??!0,items:n.swishUi?.components?.drawer?.miniMenu?.items??[]},listDetailView:{enableVariantChange:n.swishUi?.components?.drawer?.listDetailView?.enableVariantChange??!1,showVariantOptionNames:n.swishUi?.components?.drawer?.listDetailView?.showVariantOptionNames??!1}}},css:n.swishUi?.css??[],design:n.swishUi?.design??{}}}),"createSwishOptions");var $s=Symbol.for("preact-signals");function rt(){if(ne>1)ne--;else{for(var n,e=!1;ye!==void 0;){var t=ye;for(ye=void 0,Et++;t!==void 0;){var r=t.o;if(t.o=void 0,t.f&=-3,!(8&t.f)&&xn(t))try{t.c()}catch(s){e||(n=s,e=!0)}t=r}}if(Et=0,ne--,e)throw n}}i(rt,"t");function re(n){if(ne>0)return n();ne++;try{return n()}finally{rt()}}i(re,"r");var C=void 0;function Sn(n){var e=C;C=void 0;try{return n()}finally{C=e}}i(Sn,"n");var ye=void 0,ne=0,Et=0,nt=0;function En(n){if(C!==void 0){var e=n.n;if(e===void 0||e.t!==C)return e={i:0,S:n,p:C.s,n:void 0,t:C,e:void 0,x:void 0,r:e},C.s!==void 0&&(C.s.n=e),C.s=e,n.n=e,32&C.f&&n.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=C.s,e.n=void 0,C.s.n=e,C.s=e),e}}i(En,"e");function B(n,e){this.v=n,this.i=0,this.n=void 0,this.t=void 0,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}i(B,"u");B.prototype.brand=$s;B.prototype.h=function(){return!0};B.prototype.S=function(n){var e=this,t=this.t;t!==n&&n.e===void 0&&(n.x=t,this.t=n,t!==void 0?t.e=n:Sn(function(){var r;(r=e.W)==null||r.call(e)}))};B.prototype.U=function(n){var e=this;if(this.t!==void 0){var t=n.e,r=n.x;t!==void 0&&(t.x=r,n.e=void 0),r!==void 0&&(r.e=t,n.x=void 0),n===this.t&&(this.t=r,r===void 0&&Sn(function(){var s;(s=e.Z)==null||s.call(e)}))}};B.prototype.subscribe=function(n){var e=this;return Q(function(){var t=e.value,r=C;C=void 0;try{n(t)}finally{C=r}},{name:"sub"})};B.prototype.valueOf=function(){return this.value};B.prototype.toString=function(){return this.value+""};B.prototype.toJSON=function(){return this.value};B.prototype.peek=function(){var n=C;C=void 0;try{return this.value}finally{C=n}};Object.defineProperty(B.prototype,"value",{get:i(function(){var n=En(this);return n!==void 0&&(n.i=this.i),this.v},"get"),set:i(function(n){if(n!==this.v){if(Et>100)throw new Error("Cycle detected");this.v=n,this.i++,nt++,ne++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{rt()}}},"set")});function $(n,e){return new B(n,e)}i($,"d");function xn(n){for(var e=n.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}i(xn,"c");function Cn(n){for(var e=n.s;e!==void 0;e=e.n){var t=e.S.n;if(t!==void 0&&(e.r=t),e.S.n=e,e.i=-1,e.n===void 0){n.s=e;break}}}i(Cn,"a");function kn(n){for(var e=n.s,t=void 0;e!==void 0;){var r=e.p;e.i===-1?(e.S.U(e),r!==void 0&&(r.n=e.n),e.n!==void 0&&(e.n.p=r)):t=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=r}n.s=t}i(kn,"l");function oe(n,e){B.call(this,void 0),this.x=n,this.s=void 0,this.g=nt-1,this.f=4,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}i(oe,"y");oe.prototype=new B;oe.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===nt))return!0;if(this.g=nt,this.f|=1,this.i>0&&!xn(this))return this.f&=-2,!0;var n=C;try{Cn(this),C=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return C=n,kn(this),this.f&=-2,!0};oe.prototype.S=function(n){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}B.prototype.S.call(this,n)};oe.prototype.U=function(n){if(this.t!==void 0&&(B.prototype.U.call(this,n),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}};oe.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var n=this.t;n!==void 0;n=n.x)n.t.N()}};Object.defineProperty(oe.prototype,"value",{get:i(function(){if(1&this.f)throw new Error("Cycle detected");var n=En(this);if(this.h(),n!==void 0&&(n.i=this.i),16&this.f)throw this.v;return this.v},"get")});function F(n,e){return new oe(n,e)}i(F,"w");function Rn(n){var e=n.u;if(n.u=void 0,typeof e=="function"){ne++;var t=C;C=void 0;try{e()}catch(r){throw n.f&=-2,n.f|=8,xt(n),r}finally{C=t,rt()}}}i(Rn,"_");function xt(n){for(var e=n.s;e!==void 0;e=e.n)e.S.U(e);n.x=void 0,n.s=void 0,Rn(n)}i(xt,"b");function Ms(n){if(C!==this)throw new Error("Out-of-order effect");kn(this),C=n,this.f&=-2,8&this.f&&xt(this),rt()}i(Ms,"g");function pe(n,e){this.x=n,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=e?.name}i(pe,"p");pe.prototype.c=function(){var n=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.u=e)}finally{n()}};pe.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Rn(this),Cn(this),ne++;var n=C;return C=this,Ms.bind(this,n)};pe.prototype.N=function(){2&this.f||(this.f|=2,this.o=ye,ye=this)};pe.prototype.d=function(){this.f|=8,1&this.f||xt(this)};pe.prototype.dispose=function(){this.d()};function Q(n,e){var t=new pe(n,e);try{t.c()}catch(s){throw t.d(),s}var r=t.d.bind(t);return r[Symbol.dispose]=r,r}i(Q,"E");var Vs=/\/products\/([^/?#]+)(?:\?(?:[^#]*?&)?variant=(\d+))?/,Ct=i(n=>{let e=n.match(Vs);return e?{productHandle:e[1],variantId:e[2]}:null},"parseProductUrl"),An=i(({source:n,onProductUrlChange:e})=>{let t=i(r=>{let s=Ct(r);s?.productHandle&&e(s)},"handleChange");if(n instanceof HTMLAnchorElement)return ln({element:n,onHrefChange:i(r=>t(r),"onHrefChange")});if(n instanceof Location)return le({onLocationChange:i(r=>t(r.href),"onLocationChange")});throw new Error("Invalid source for observing product url")},"observeProductUrl");var Dn=i(n=>e=>{let{productHandle:t,productId:r,variantId:s,itemId:o}=e?.dataset??{},c=!!(r||t)||!!o,l=$({loading:!1,productId:r,variantId:s,itemId:o});if(!c){let p=e instanceof HTMLAnchorElement?e:window.location,f=Ct(p.href);f?.productHandle&&f.productHandle!==l.value.productHandle&&(l.value={...l.value,...f,productId:void 0},An({source:p,onProductUrlChange:i(y=>{l.value={...l.value,...y,productId:y.productHandle!==l.value.productHandle?void 0:l.value.productId}},"onProductUrlChange")}))}return Q(()=>{l.value.loading||!l.value.productId&&l.value.productHandle&&(l.value={...l.value,loading:!0},n.storefront.loadProductId({productHandle:l.value.productHandle}).then(p=>{p.errors&&console.error("Error loading product id",p.errors),l.value={...l.value,productId:p.data?.product?.id?A(p.data.product.id):void 0,loading:!1}}))}),l},"itemContextSignal");var Pn=i(n=>e=>{let t=F(()=>{let{productId:T,variantId:I,loading:M}=e.value;return!T||M?null:I?`variant:${A(I)}`:`product:${A(T)}`}),r=F(()=>e.value.loading||!!e.value.itemId||!e.value.productId),s=F(()=>({limit:1,query:t.value??void 0})),o=$(!r.value),a=$(null),u=$(!1),c=$(!1),{data:l,loading:p,error:f,refetching:y}=n.state.swishQuery(T=>n.api.items.list(T),{refetch:["item-create","item-update","item-delete"],variables:s,skip:r}),h=$(e.value.itemId??null);Q(()=>{re(()=>{if(o.value=p.value,a.value=f.value,!e.value.itemId){let T=l.value?.[0]?.id??null;T!==h.value&&(h.value=T)}})});async function b(){if(!h.value)return;u.value=!0;let I=await(await n.intents.invoke("unsave:item",{itemId:h.value})).complete;I.code==="ok"&&"itemId"in I.data&&(h.value=null),u.value=!1}i(b,"unsave");async function g(){if(!h.value)return;u.value=!0;let I=await(await n.intents.invoke("edit:item-lists",{itemId:h.value})).complete;I.code==="ok"&&"itemId"in I.data&&(h.value=null),u.value=!1}i(g,"update");async function O(){let{productId:T,variantId:I}=e.value;if(!T)return;u.value=!0,c.value=!0;let k=await(await n.intents.invoke("save:item",{productId:T,variantId:I})).complete;if(k.code==="ok"){let ee=k.data;h.value=ee.item.id,u.value=!1}else k.code==="error"&&console.warn("Failed to create item",k),re(()=>{u.value=!1,c.value=!1})}i(O,"save");let N=F(()=>o.value||u.value||e.value.loading);Q(()=>{c.value&&!u.value&&!y.value&&(c.value=!1)});let L=F(()=>{let T=y.value&&c.value,I=!!h.value,M=!I&&(u.value||T),k=I&&(u.value||T),ee=F(()=>M?"saving":k?"unsaving":I?"saved":"unsaved");return{error:a.value,status:ee.value,savedItemId:h.value,loading:N.value,submitting:u.value,saved:I,saving:M,unsaving:k}});async function G(){N.value||(L.value.saved&&L.value.savedItemId?b():L.value.saved||await O())}return i(G,"toggle"),Object.assign(L,{save:O,unsave:b,update:g,toggle:G})},"itemStateSignal");var Tn=i(n=>()=>{let{data:e,loading:t,error:r}=n.state.swishQuery(()=>n.api.items.count(),{refetch:["item-create","item-delete"]}),s=$(0),o=$(!0),a=$(null);return Q(()=>{re(()=>{o.value=t.value,a.value=r.value,s.value=e.value?.count??0})}),F(()=>({count:s.value,loading:o.value,error:a.value}))},"itemCountSignal");var qs="token-update",_n=i(n=>(e,t)=>{let r=$(null),s=$(null),o=$(null),a=$(!t?.skip),u=$(!1),c=F(()=>a.value&&u.value);async function l(){if(!t?.skip?.value)try{a.value=!0;let p=await e(t?.variables?.value);re(()=>{o.value="error"in p?p.error:null,r.value="data"in p?p.data:null,s.value="pageInfo"in p?p.pageInfo:null,a.value=!1,u.value=!0})}catch(p){re(()=>{o.value=p,a.value=!1,u.value=!0})}}return i(l,"executeFetch"),Q(()=>{if(l(),t?.refetch?.length){let p=[...t.refetch,qs];return n.events.subscribe(p,l)}}),{data:r,pageInfo:s,error:o,loading:a,refetching:c}},"swishQuerySignals");var ae="GraphQL Client";var kt="An error occurred while fetching from the API. Review 'graphQLErrors' for details.",Rt="Response returned unexpected Content-Type:",At="An unknown error has occurred. The API did not return a data object or any errors in its response.",st={json:"application/json",multipart:"multipart/mixed"},Dt="X-SDK-Variant",Pt="X-SDK-Version",Ln="shopify-graphql-client",$n="1.4.1",it=1e3,Mn=[429,503],Tt=/@(defer)\b/i,On=`\r
8
- `,Vn=/boundary="?([^=";]+)"?/i,_t=On+On;function X(n,e=ae){return n.startsWith(`${e}`)?n:`${e}: ${n}`}i(X,"formatErrorMessage");function Z(n){return n instanceof Error?n.message:JSON.stringify(n)}i(Z,"getErrorMessage");function Ot(n){return n instanceof Error&&n.cause?n.cause:void 0}i(Ot,"getErrorCause");function Lt(n){return n.flatMap(({errors:e})=>e??[])}i(Lt,"combineErrors");function ot({client:n,retries:e}){if(e!==void 0&&(typeof e!="number"||e<0||e>3))throw new Error(`${n}: The provided "retries" value (${e}) is invalid - it cannot be less than ${0} or greater than ${3}`)}i(ot,"validateRetries");function U(n,e){return e&&(typeof e!="object"||Array.isArray(e)||typeof e=="object"&&Object.keys(e).length>0)?{[n]:e}:{}}i(U,"getKeyValueIfValid");function $t(n,e){if(n.length===0)return e;let r={[n.pop()]:e};return n.length===0?r:$t(n,r)}i($t,"buildDataObjectByPath");function Bn(n,e){return Object.keys(e||{}).reduce((t,r)=>(typeof e[r]=="object"||Array.isArray(e[r]))&&n[r]?(t[r]=Bn(n[r],e[r]),t):(t[r]=e[r],t),Array.isArray(n)?[...n]:{...n})}i(Bn,"combineObjects");function Mt([n,...e]){return e.reduce(Bn,{...n})}i(Mt,"buildCombinedDataObject");function Vt({clientLogger:n,customFetchApi:e=fetch,client:t=ae,defaultRetryWaitTime:r=it,retriableCodes:s=Mn}){let o=i(async(a,u,c)=>{let l=u+1,p=c+1,f;try{if(f=await e(...a),n({type:"HTTP-Response",content:{requestParams:a,response:f}}),!f.ok&&s.includes(f.status)&&l<=p)throw new Error;let y=f?.headers.get("X-Shopify-API-Deprecated-Reason")||"";return y&&n({type:"HTTP-Response-GraphQL-Deprecation-Notice",content:{requestParams:a,deprecationNotice:y}}),f}catch(y){if(l<=p){let h=f?.headers.get("Retry-After");return await Ns(h?parseInt(h,10):r),n({type:"HTTP-Retry",content:{requestParams:a,lastResponse:f,retryAttempt:u,maxRetries:c}}),o(a,l,c)}throw new Error(X(`${c>0?`Attempted maximum number of ${c} network retries. Last message - `:""}${Z(y)}`,t))}},"httpFetch");return o}i(Vt,"generateHttpFetch");async function Ns(n){return new Promise(e=>setTimeout(e,n))}i(Ns,"sleep");function qt({headers:n,url:e,customFetchApi:t=fetch,retries:r=0,logger:s}){ot({client:ae,retries:r});let o={headers:n,url:e,retries:r},a=Bs(s),u=Vt({customFetchApi:t,clientLogger:a,defaultRetryWaitTime:it}),c=Us(u,o),l=Fs(c),p=Ks(c);return{config:o,fetch:c,request:l,requestStream:p}}i(qt,"createGraphQLClient");function Bs(n){return e=>{n&&n(e)}}i(Bs,"generateClientLogger");async function Un(n){let{errors:e,data:t,extensions:r}=await n.json();return{...U("data",t),...U("extensions",r),headers:n.headers,...e||!t?{errors:{networkStatusCode:n.status,message:X(e?kt:At),...U("graphQLErrors",e),response:n}}:{}}}i(Un,"processJSONResponse");function Us(n,{url:e,headers:t,retries:r}){return async(s,o={})=>{let{variables:a,headers:u,url:c,retries:l,keepalive:p,signal:f}=o,y=JSON.stringify({query:s,variables:a});ot({client:ae,retries:l});let h=Object.entries({...t,...u}).reduce((g,[O,N])=>(g[O]=Array.isArray(N)?N.join(", "):N.toString(),g),{});return!h[Dt]&&!h[Pt]&&(h[Dt]=Ln,h[Pt]=$n),n([c??e,{method:"POST",headers:h,body:y,signal:f,keepalive:p}],1,l??r)}}i(Us,"generateFetch");function Fs(n){return async(...e)=>{if(Tt.test(e[0]))throw new Error(X("This operation will result in a streamable response - use requestStream() instead."));let t=null;try{t=await n(...e);let{status:r,statusText:s}=t,o=t.headers.get("content-type")||"";return t.ok?o.includes(st.json)?await Un(t):{errors:{networkStatusCode:r,message:X(`${Rt} ${o}`),response:t}}:{errors:{networkStatusCode:r,message:X(s),response:t}}}catch(r){return{errors:{message:Z(r),...t==null?{}:{networkStatusCode:t.status,response:t}}}}}}i(Fs,"generateRequest");async function*js(n){let e=new TextDecoder;if(n.body[Symbol.asyncIterator])for await(let t of n.body)yield e.decode(t);else{let t=n.body.getReader(),r;try{for(;!(r=await t.read()).done;)yield e.decode(r.value)}finally{t.cancel()}}}i(js,"getStreamBodyIterator");function Gs(n,e){return{async*[Symbol.asyncIterator](){try{let t="";for await(let r of n)if(t+=r,t.indexOf(e)>-1){let s=t.lastIndexOf(e),a=t.slice(0,s).split(e).filter(u=>u.trim().length>0).map(u=>u.slice(u.indexOf(_t)+_t.length).trim());a.length>0&&(yield a),t=t.slice(s+e.length),t.trim()==="--"&&(t="")}}catch(t){throw new Error(`Error occured while processing stream payload - ${Z(t)}`)}}}}i(Gs,"readStreamChunk");function Hs(n){return{async*[Symbol.asyncIterator](){yield{...await Un(n),hasNext:!1}}}}i(Hs,"createJsonResponseAsyncIterator");function Qs(n){return n.map(e=>{try{return JSON.parse(e)}catch(t){throw new Error(`Error in parsing multipart response - ${Z(t)}`)}}).map(e=>{let{data:t,incremental:r,hasNext:s,extensions:o,errors:a}=e;if(!r)return{data:t||{},...U("errors",a),...U("extensions",o),hasNext:s};let u=r.map(({data:c,path:l,errors:p})=>({data:c&&l?$t(l,c):{},...U("errors",p)}));return{data:u.length===1?u[0].data:Mt([...u.map(({data:c})=>c)]),...U("errors",Lt(u)),hasNext:s}})}i(Qs,"getResponseDataFromChunkBodies");function zs(n,e){if(n.length>0)throw new Error(kt,{cause:{graphQLErrors:n}});if(Object.keys(e).length===0)throw new Error(At)}i(zs,"validateResponseData");function Ws(n,e){let t=(e??"").match(Vn),r=`--${t?t[1]:"-"}`;if(!n.body?.getReader&&!n.body?.[Symbol.asyncIterator])throw new Error("API multipart response did not return an iterable body",{cause:n});let s=js(n),o={},a;return{async*[Symbol.asyncIterator](){try{let u=!0;for await(let c of Gs(s,r)){let l=Qs(c);a=l.find(f=>f.extensions)?.extensions??a;let p=Lt(l);o=Mt([o,...l.map(({data:f})=>f)]),u=l.slice(-1)[0].hasNext,zs(p,o),yield{...U("data",o),...U("extensions",a),hasNext:u}}if(u)throw new Error("Response stream terminated unexpectedly")}catch(u){let c=Ot(u);yield{...U("data",o),...U("extensions",a),errors:{message:X(Z(u)),networkStatusCode:n.status,...U("graphQLErrors",c?.graphQLErrors),response:n},hasNext:!1}}}}}i(Ws,"createMultipartResponseAsyncInterator");function Ks(n){return async(...e)=>{if(!Tt.test(e[0]))throw new Error(X("This operation does not result in a streamable response - use request() instead."));try{let t=await n(...e),{statusText:r}=t;if(!t.ok)throw new Error(r,{cause:t});let s=t.headers.get("content-type")||"";switch(!0){case s.includes(st.json):return Hs(t);case s.includes(st.multipart):return Ws(t,s);default:throw new Error(`${Rt} ${s}`,{cause:t})}}catch(t){return{async*[Symbol.asyncIterator](){let r=Ot(t);yield{errors:{message:X(Z(t)),...U("networkStatusCode",r?.status),...U("response",r)},hasNext:!1}}}}}}i(Ks,"generateRequestStream");function Nt({client:n,storeDomain:e}){try{if(!e||typeof e!="string")throw new Error;let t=e.trim(),r=t.match(/^https?:/)?t:`https://${t}`,s=new URL(r);return s.protocol="https",s.origin}catch(t){throw new Error(`${n}: a valid store domain ("${e}") must be provided`,{cause:t})}}i(Nt,"validateDomainAndGetStoreUrl");function at({client:n,currentSupportedApiVersions:e,apiVersion:t,logger:r}){let s=`${n}: the provided apiVersion ("${t}")`,o=`Currently supported API versions: ${e.join(", ")}`;if(!t||typeof t!="string")throw new Error(`${s} is invalid. ${o}`);let a=t.trim();e.includes(a)||(r?r({type:"Unsupported_Api_Version",content:{apiVersion:t,supportedApiVersions:e}}):console.warn(`${s} is likely deprecated or not supported. ${o}`))}i(at,"validateApiVersion");function ut(n){let e=n*3-2;return e===10?e:`0${e}`}i(ut,"getQuarterMonth");function Bt(n,e,t){let r=e-t;return r<=0?`${n-1}-${ut(r+4)}`:`${n}-${ut(r)}`}i(Bt,"getPrevousVersion");function Fn(){let n=new Date,e=n.getUTCMonth(),t=n.getUTCFullYear(),r=Math.floor(e/3+1);return{year:t,quarter:r,version:`${t}-${ut(r)}`}}i(Fn,"getCurrentApiVersion");function Ut(){let{year:n,quarter:e,version:t}=Fn(),r=e===4?`${n+1}-01`:`${n}-${ut(e+1)}`;return[Bt(n,e,3),Bt(n,e,2),Bt(n,e,1),t,r,"unstable"]}i(Ut,"getCurrentSupportedApiVersions");function Ft(n){return e=>({...e??{},...n.headers})}i(Ft,"generateGetHeaders");function jt({getHeaders:n,getApiUrl:e}){return(t,r)=>{let s=[t];if(r&&Object.keys(r).length>0){let{variables:o,apiVersion:a,headers:u,retries:c,signal:l}=r;s.push({...o?{variables:o}:{},...u?{headers:n(u)}:{},...a?{url:e(a)}:{},...c?{retries:c}:{},...l?{signal:l}:{}})}return s}}i(jt,"generateGetGQLClientParams");var Gt="application/json",jn="storefront-api-client",Gn="1.0.9",Hn="X-Shopify-Storefront-Access-Token",Qn="Shopify-Storefront-Private-Token",zn="X-SDK-Variant",Wn="X-SDK-Version",Kn="X-SDK-Variant-Source",ue="Storefront API Client";function Xn(n){if(n&&typeof window<"u")throw new Error(`${ue}: private access tokens and headers should only be used in a server-to-server implementation. Use the public API access token in nonserver environments.`)}i(Xn,"validatePrivateAccessTokenUsage");function Yn(n,e){if(!n&&!e)throw new Error(`${ue}: a public or private access token must be provided`);if(n&&e)throw new Error(`${ue}: only provide either a public or private access token`)}i(Yn,"validateRequiredAccessTokens");function Ht({storeDomain:n,apiVersion:e,publicAccessToken:t,privateAccessToken:r,clientName:s,retries:o=0,customFetchApi:a,logger:u}){let c=Ut(),l=Nt({client:ue,storeDomain:n}),p={client:ue,currentSupportedApiVersions:c,logger:u};at({...p,apiVersion:e}),Yn(t,r),Xn(r);let f=Xs(l,e,p),y={storeDomain:l,apiVersion:e,...t?{publicAccessToken:t}:{privateAccessToken:r},headers:{"Content-Type":Gt,Accept:Gt,[zn]:jn,[Wn]:Gn,...s?{[Kn]:s}:{},...t?{[Hn]:t}:{[Qn]:r}},apiUrl:f(),clientName:s},h=qt({headers:y.headers,url:y.apiUrl,retries:o,customFetchApi:a,logger:u}),b=Ft(y),g=Ys(y,f),O=jt({getHeaders:b,getApiUrl:g});return Object.freeze({config:y,getHeaders:b,getApiUrl:g,fetch:i((...L)=>h.fetch(...O(...L)),"fetch"),request:i((...L)=>h.request(...O(...L)),"request"),requestStream:i((...L)=>h.requestStream(...O(...L)),"requestStream")})}i(Ht,"createStorefrontApiClient");function Xs(n,e,t){return r=>{r&&at({...t,apiVersion:r});let s=(r??e).trim();return`${n}/api/${s}/graphql.json`}}i(Xs,"generateApiUrlFormatter");function Ys(n,e){return t=>t?e(t):n.apiUrl}i(Ys,"generateGetApiUrl");var j=`
7
+ `+String(r)));sn(e);for(var s=0;s<e.callbacks.length;s++){var o=r[s];o instanceof Error?e.callbacks[s].reject(o):e.callbacks[s].resolve(o)}}).catch(function(r){rn(n,e,r)})}i(so,"dispatchBatch");function rn(n,e,t){sn(e);for(var r=0;r<e.keys.length;r++)n.clear(e.keys[r]),e.callbacks[r].reject(t)}i(rn,"failedDispatch");function sn(n){if(n.cacheHits)for(var e=0;e<n.cacheHits.length;e++)n.cacheHits[e]()}i(sn,"resolveCacheHits");function io(n){var e=!n||n.batch!==!1;if(!e)return 1;var t=n&&n.maxBatchSize;if(t===void 0)return 1/0;if(typeof t!="number"||t<1)throw new TypeError("maxBatchSize must be a positive number: "+t);return t}i(io,"getValidMaxBatchSize");function oo(n){var e=n&&n.batchScheduleFn;if(e===void 0)return no;if(typeof e!="function")throw new TypeError("batchScheduleFn must be a function: "+e);return e}i(oo,"getValidBatchScheduleFn");function ao(n){var e=n&&n.cacheKeyFn;if(e===void 0)return function(t){return t};if(typeof e!="function")throw new TypeError("cacheKeyFn must be a function: "+e);return e}i(ao,"getValidCacheKeyFn");function uo(n){var e=!n||n.cache!==!1;if(!e)return null;var t=n&&n.cacheMap;if(t===void 0)return new Map;if(t!==null){var r=["get","set","delete","clear"],s=r.filter(function(o){return t&&typeof t[o]!="function"});if(s.length!==0)throw new TypeError("Custom cacheMap missing methods: "+s.join(", "))}return t}i(uo,"getValidCacheMap");function co(n){return n&&n.name?n.name:null}i(co,"getValidName");function Lr(n){return typeof n=="object"&&n!==null&&typeof n.length=="number"&&(n.length===0||n.length>0&&Object.prototype.hasOwnProperty.call(n,n.length-1))}i(Lr,"isArrayLike");$r.exports=to});var A=i(n=>n.split("/").pop()??"","shopifyGidToId"),D=i((n,e)=>`gid://shopify/${n}/${e}`,"shopifyIdToGid"),H=i(n=>n.toLowerCase().replace(".myshopify.com",""),"toShopName");var J=class{constructor(e,t,r=""){this.revalidationPromises=new Map;this.inFlightRequests=new Map;this.clearCachePromise=null;this.cacheName=e,this.defaultCacheControl=t,this.keyPrefix=r}static{i(this,"FetchCache")}async get(e){try{let t=await caches.open(this.cacheName),r=await t.match(e);if(r&&this.isExpired(r)){await t.delete(e);return}return r}catch(t){console.warn("Cache get error:",t);return}}async set(e,t,r){try{if(r?.includes("no-cache"))return;let s=this.createCacheableResponse(t,r);await(await caches.open(this.cacheName)).put(e,s)}catch(s){console.warn("Cache set error:",s)}}async fetchWithCache(e,t,r){let s=await this.getCacheKey(e,t);if(this.clearCachePromise&&await this.clearCachePromise,this.inFlightRequests.has(s))return this.inFlightRequests.get(s).then(a=>a.clone());let o=(async()=>{let a=await this.get(s);if(a)return this.isStaleButRevalidatable(a)&&this.revalidateInBackground(s,e,t,r),a.clone();let u=await fetch(e,t);return u.ok&&await this.set(s,u.clone(),r??this.defaultCacheControl),u})().finally(()=>{this.inFlightRequests.delete(s)});return this.inFlightRequests.set(s,o),o}async delete(e){try{return await(await caches.open(this.cacheName)).delete(e)}catch(t){return console.warn("Cache delete error:",t),!1}}async clear(){return this.clearCachePromise?this.clearCachePromise:(this.clearCachePromise=new Promise(async(e,t)=>{try{let r=await caches.open(this.cacheName),s=await r.keys();await Promise.all(s.map(o=>r.delete(o))),e()}catch(r){console.warn("Cache clear error:",r),t(r)}}),this.clearCachePromise.then(()=>{this.clearCachePromise=null}).catch(e=>{console.warn("Cache clear error:",e)}))}async keys(){try{return(await(await caches.open(this.cacheName)).keys()).map(r=>r.url)}catch(e){return console.warn("Cache keys error:",e),[]}}async has(e){try{let t=await caches.open(this.cacheName),r=await t.match(e);return r&&this.isExpired(r)?(await t.delete(e),!1):r!==void 0}catch(t){return console.warn("Cache has error:",t),!1}}async getStats(){try{return{total:(await(await caches.open(this.cacheName)).keys()).length}}catch(e){return console.warn("Cache stats error:",e),{total:0}}}async cleanupExpiredEntries(){try{let e=await caches.open(this.cacheName),t=await e.keys(),r=0;for(let o of t){let a=await e.match(o);a&&this.isExpired(a)&&(await e.delete(o),r++)}let s=t.length-r;return{removed:r,remaining:s}}catch(e){return console.warn("Cache cleanup error:",e),{removed:0,remaining:0}}}async getCacheKey(e,t){let r=this.getInputUrl(e),s=`${this.keyPrefix}${r}/${JSON.stringify(t)}`,a=new TextEncoder().encode(s),u=await crypto.subtle.digest("SHA-256",a);return`/${Array.from(new Uint8Array(u)).map(p=>p.toString(16).padStart(2,"0")).join("")}`}getInputUrl(e){return e instanceof URL?e.toString():typeof e=="string"?e:e.url}isExpired(e){let t=e.headers.get("Cache-Control");if(!t)return!1;let r=this.parseMaxAge(t),s=this.parseStaleWhileRevalidate(t);if(r===null)return!1;let o=e.headers.get("Date");if(!o)return!1;let a=new Date(o).getTime(),c=(Date.now()-a)/1e3,l=r+(s??0);return c>l}isStaleButRevalidatable(e){let t=e.headers.get("Cache-Control");if(!t)return!1;let r=this.parseMaxAge(t),s=this.parseStaleWhileRevalidate(t);if(r===null||s===null)return!1;let o=e.headers.get("Date");if(!o)return!1;let a=new Date(o).getTime(),c=(Date.now()-a)/1e3;return c>r&&c<=r+s}async revalidateInBackground(e,t,r,s){if(this.revalidationPromises.has(e))return;let o=(async()=>{try{let a=await fetch(t,r);a.ok&&await this.set(e,a.clone(),s??this.defaultCacheControl)}catch(a){console.warn("Background revalidation error:",a)}finally{this.revalidationPromises.delete(e)}})();this.revalidationPromises.set(e,o)}parseMaxAge(e){let t=new RegExp(/max-age=(\d+)/).exec(e);return t?parseInt(t[1],10):null}parseStaleWhileRevalidate(e){let t=new RegExp(/stale-while-revalidate=(\d+)/).exec(e);return t?parseInt(t[1],10):null}createCacheableResponse(e,t){let r=new Headers(e.headers);return r.set("Cache-Control",t),r.has("Date")||r.set("Date",new Date().toUTCString()),new Response(e.body,{status:e.status,statusText:e.statusText,headers:r})}};var be=class{static{i(this,"AjaxApiClient")}constructor(e){this.config=e;let t=H(e.storeDomain);this.cache=new J(`ajax-api-${t}`,"max-age=60, stale-while-revalidate=3600"),this.cache.cleanupExpiredEntries().catch(r=>{console.warn("Ajax API cache initialization cleanup error:",r)})}patchFetch(){if(!window.fetch||typeof window.fetch!="function")return;let e=window.fetch,t=this.config.responseInterceptor,r=this.getFetchRequest.bind(this);window.fetch=function(...s){let o=e.apply(this,s);if(typeof t=="function"){let a=r(s[0]);o.then(u=>t(u,a))}return o}}getFetchRequest(e){return e instanceof Request?e:new Request(e)}getBaseUrl(){if(!this.config?.storeDomain)throw new Error("Cart API client not initialized - missing store domain");return`https://${this.config.storeDomain}`}fetch(e,t){return(e instanceof Request?e.method:t?.method??"GET")==="GET"?this.cache.fetchWithCache(e,t):fetch(e,t)}async request(e,t={}){let r=`${this.getBaseUrl()}${e}`,s={"Content-Type":"application/json",Accept:"application/json"},o=await this.fetch(r,{...t,headers:{...s,...t.headers}});if(!o.ok){let a;try{a=await o.json()}catch{a={message:`HTTP ${o.status}: ${o.statusText}`,status:o.status.toString(),description:o.statusText}}throw new Error(a.message||a.description)}return o.json()}async fetchCart(){return this.request("/cart.js")}async addToCart(e){let t={...e,items:e.items.map(r=>{let s=Number(A(String(r.id)));if(!Number.isFinite(s)||s<=0)throw new Error(`Invalid Shopify ID: ${r.id}`);return{...r,id:s}})};return this.request("/cart/add.js",{method:"POST",body:JSON.stringify(t)})}async clearCache(){await this.cache.clear()}};var Se=class{constructor(e){this.eventMap={"/cart/add":"cart-add","/cart/update":"cart-update","/cart/change":"cart-change","/cart/clear":"cart-clear"};this.eventBus=e,this.processFetchResponse=this.processFetchResponse.bind(this)}static{i(this,"AjaxApiPublisher")}async processFetchResponse(e,t){try{let r=this.getEventName(t.url);if(r){let s=await e.clone().json();this.eventBus.publish(r,s)}}catch(r){console.warn(r)}}getEventName(e){for(let[t,r]of Object.entries(this.eventMap))if(e.includes(t))return r;return null}};function Kr(){let n=document.body||document.documentElement;return n?Promise.resolve(n):new Promise(e=>{window.addEventListener("DOMContentLoaded",()=>e(n))})}i(Kr,"waitForDOM");function ie({onElementFound:n,selector:e,observerOptions:t,mustMatch:r}){let s=new WeakSet,o=new MutationObserver(l=>{let p=!1;for(let f of l)if(f.addedNodes.length>0){p=!0;break}p&&a()}),a=i(()=>{document.querySelectorAll(e).forEach(l=>{s.has(l)||(s.add(l),r?.(l)!==!1&&u(l))})},"locateElements"),u=i(l=>{if(!t){n(l);return}let p=new IntersectionObserver(f=>{for(let y of f)y.isIntersecting&&(p.disconnect(),n(l))},t);p.observe(l)},"observeElement");return i(async()=>{let l=await Kr();a(),o.observe(l,{childList:!0,subtree:!0})},"locateAndObserveElements")(),o}i(ie,"createElementLocator");function pe({onLocationChange:n,fireOnInit:e=!1}){let t=i(()=>{n(window.location)},"handleChange");window.addEventListener("popstate",t);let r=history.pushState,s=history.replaceState;return history.pushState=function(...o){r.apply(this,o),t()},history.replaceState=function(...o){s.apply(this,o),t()},e&&t(),()=>{window.removeEventListener("popstate",t),history.pushState=r,history.replaceState=s}}i(pe,"createLocationObserver");function dn({element:n,onHrefChange:e}){let t=i(()=>{e(n.href)},"handleChange"),r=new MutationObserver(()=>{t()});return r.observe(n,{attributes:!0,attributeFilter:["href"]}),()=>{r.disconnect()}}i(dn,"createHrefObserver");function mn(n,e){if(!e.element)throw new Error("Element must be provided");let t=null,r=new Map,s=i(()=>{if(t){console.warn("Placement already mounted. Skipping mount.");return}Yr(e),t=ie({selector:e.target.selector,observerOptions:e.target.observerOptions,mustMatch:e.target.mustMatch,onElementFound:i(l=>o(l),"onElementFound")})},"mount"),o=i(l=>{r.has(l)||l.hasAttribute("swish-ignore")||l.getAttribute("swish-placement-target")===e.id||(l.setAttribute("swish-placement-target",e.id),a(l))},"evaluateAndMount"),a=i(async l=>{let p=[],f=e.mount.mode,y=as(l,e.mount.at);if(!y)return;let h=await(typeof e.element=="function"?e.element(e):ds(n,e.element));if(!h)return;if(h.setAttribute("swish-placement-element",e.id),typeof e.element!="function"){let C=e.element;C.props&&fs(h,C.props),C.classNames&&vn(h,C.classNames)}let x;e.container&&(x=ps(e.id,e.container),x.appendChild(h));let w,O=x??h;if(e.layout?.type==="overlay"){cs(y);let C=e.layout.anchor??"bottom-right";O.setAttribute("swish-placement-overlay",e.id),O.setAttribute("swish-placement-anchor",C)}let N=!1,L;if(e.layout?.type==="inline"){let C=e.layout,te=C.rowSelector?y.closest(C.rowSelector):null;te?w=te:(w=ls(e.id,y,C),N=!0),L=w.getAttribute("swish-placement-inline-row"),w.setAttribute("swish-placement-inline-row",e.id)}let G=x??h;if(!us(y,G,f)){try{G.remove()}catch{}return}let I={targetEl:l,renderTargetEl:y,mountEl:h,containerEl:x,rowEl:w,rowWasCreated:N,rowInlineAttrPrevValue:L,cleanupFns:p,ownsNode:!0};r.set(l,I);let q={id:e.id,targetEl:l,renderTargetEl:y,mountEl:I.mountEl,containerEl:x,rowEl:w,cleanup:i(C=>p.push(C),"cleanup")};e.element?.name==="save-button"&&Xr(n,q),e.onMount?.(q)},"mountElement"),u=i(l=>{let p=r.get(l);if(p){if(e.onUnmount?.({id:e.id,targetEl:p.targetEl,renderTargetEl:p.renderTargetEl,mountEl:p.mountEl,containerEl:p.containerEl,rowEl:p.rowEl}),p.cleanupFns.forEach(f=>f()),p.targetEl.getAttribute("swish-placement-target")===e.id&&p.targetEl.removeAttribute("swish-placement-target"),p.ownsNode&&(p.containerEl||p.mountEl).remove(),p.rowEl){if(p.rowWasCreated){let f=p.rowEl.parentElement;f&&p.targetEl.parentElement===p.rowEl?p.rowEl.replaceWith(p.targetEl):f?f.removeChild(p.rowEl):p.rowEl.remove()}else if(p.rowInlineAttrPrevValue!==void 0){let f=p.rowInlineAttrPrevValue;f===null?p.rowEl.removeAttribute("swish-placement-inline-row"):p.rowEl.setAttribute("swish-placement-inline-row",f)}}r.delete(l)}},"unmountElement");return{mount:s,unmount:i(()=>{t&&(t.disconnect(),t=null),r.forEach((l,p)=>u(p)),r.clear()},"unmount")}}i(mn,"createPlacement");var Xr=i((n,{mountEl:e,targetEl:t,cleanup:r})=>{let s=n.state.itemContext(t),o=n.state.effect(()=>{let{loading:a,productId:u,variantId:c}=s.value;a||(e.setAttribute("product-id",u??""),e.setAttribute("variant-id",c??""))});r(()=>o?.())},"saveButtonMount");function Yr(n){let e=Jr(n.id),t=os(n),r=document.getElementById(e);if(r){r.textContent=t;return}let s=document.createElement("style");s.id=e,s.setAttribute("swish-placement-style",n.id),s.textContent=t,document.head.appendChild(s)}i(Yr,"ensurePlacementStylesheet");function Jr(n){return`swish-placement-style-${Zr(n)}`}i(Jr,"getPlacementStyleId");function Zr(n){return n.replace(/[^a-zA-Z0-9\-_]/g,"_")}i(Zr,"cssEscapeId");function fn(n){return`--swish-placement-${es(String(n))}`}i(fn,"designKeyToCSSVar");function es(n){return n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase()}i(es,"toKebabCase");function ts(n){return Object.entries(n??{sm:500,lg:700}).map(([r,s])=>({name:r,minWidth:s})).sort((r,s)=>r.minWidth-s.minWidth)}i(ts,"getBreakpoints");function yn(n,e){if(n==null)return{};if(typeof n=="object"&&!Array.isArray(n)){if(e&&e.size){let t=Object.keys(n);return"base"in n||t.some(s=>e.has(s))?n:{base:n}}return n}return{base:n}}i(yn,"normalizeResponsiveValue");var ns=new Set(["fontWeight","lineHeight","pressedScale","backgroundAlpha","pressedOpacity","pressedScale"]);function hn(n,e){if(e!=null)return typeof e=="number"&&!ns.has(n)?`${e}px`:String(e)}i(hn,"formatDesignValue");function rs(n,e,t){if(!e)return"";let r=new Set(t.map(c=>c.name)),s=[],o={},a=Object.entries(e).map(([c,l])=>[c,l]);for(let[c,l]of a){let p=yn(l,r),f=hn(String(c),p.base);f!==void 0&&s.push(`${fn(c)}:${f};`);for(let y of t){let h=p[y.name],x=hn(String(c),h);x!==void 0&&(o[y.name]||(o[y.name]=[]),o[y.name].push(`${fn(c)}:${x};`))}}let u=[];s.length&&u.push(`[swish-placement-element="${n}"]{${s.join("")}}`);for(let c of t){let l=o[c.name];l?.length&&u.push(`@media(min-width:${c.minWidth}px){[swish-placement-element="${n}"]{${l.join("")}}}`)}return u.join("")}i(rs,"emitDesignCSS");function Ee(n){return n==null?"0px":typeof n=="number"?`${n}px`:n}i(Ee,"formatOffsetValue");function ss(n){return n==null?"":typeof n=="number"?`${n}`:n}i(ss,"formatZIndexValue");function is(n,e,t){let r=new Set(t.map(l=>l.name)),s=yn(e,r),o=s.base??{},a=Ee(o.x),u=Ee(o.y),c=[];c.push(`[swish-placement-overlay="${n}"]{--swish-placement-offset-x:${a};--swish-placement-offset-y:${u};}`);for(let l of t){let p=s[l.name];if(!p)continue;let f=Ee(p.x),y=Ee(p.y);c.push(`@media(min-width:${l.minWidth}px){[swish-placement-overlay="${n}"]{--swish-placement-offset-x:${f};--swish-placement-offset-y:${y};}}`)}return c.join("")}i(is,"emitOverlayOffsetCSS");function os(n){let e=n.id,t=ts(n.breakpoints),r=`[swish-placement-inline-row="${e}"]{display:flex;flex-direction:row;align-items:center;gap:var(--swish-placement-inline-gap,8px);width:100%}[swish-placement-inline-row="${e}"]>*:not([swish-placement-element="${e}"]){flex:1;min-width:0}`,s=`[swish-placement-overlay="${e}"]{position:absolute;z-index:var(--swish-placement-overlay-z,10);transform:translate(calc(var(--swish-placement-sign-x,1)*var(--swish-placement-offset-x,0px)),calc(var(--swish-placement-sign-y,1)*var(--swish-placement-offset-y,0px)));}[swish-placement-overlay="${e}"][swish-placement-anchor="top-left"]{top:0;left:0;}[swish-placement-overlay="${e}"][swish-placement-anchor="top-right"]{top:0;right:0;}[swish-placement-overlay="${e}"][swish-placement-anchor="bottom-left"]{bottom:0;left:0;}[swish-placement-overlay="${e}"][swish-placement-anchor="bottom-right"]{bottom:0;right:0;}[swish-placement-overlay="${e}"][swish-placement-anchor$="left"]{--swish-placement-sign-x:1;}[swish-placement-overlay="${e}"][swish-placement-anchor$="right"]{--swish-placement-sign-x:-1;}[swish-placement-overlay="${e}"][swish-placement-anchor^="top"]{--swish-placement-sign-y:1;}[swish-placement-overlay="${e}"][swish-placement-anchor^="bottom"]{--swish-placement-sign-y:-1;}`,o="";if(n.layout?.type==="overlay"){let a=is(e,n.layout.offset,t),u=n.layout.zIndex?`[swish-placement-overlay="${e}"]{--swish-placement-overlay-z:${ss(n.layout.zIndex)};}`:"";o+=a+u+s}else n.layout?.type==="inline"&&(o+=r);if(n.design){let a=rs(e,n.design,t);a&&(o+=a)}return n.css&&(o+=n.css.trim()),o}i(os,"buildPlacementCSS");function as(n,e){if(!e||e==="target")return n;if("closest"in e)return n.closest(e.closest);if("query"in e)return n.querySelector(e.query);if("withinClosest"in e){let t=n.closest(e.withinClosest.root);return t?t.querySelector(e.withinClosest.selector):null}return n}i(as,"resolveMountTarget");function us(n,e,t){switch(t){case"before":return n.parentElement?(n.before(e),!0):!1;case"after":{let r=n.parentElement;return r?(r.insertBefore(e,n.nextSibling),!0):!1}case"append":return n.appendChild(e),!0;case"prepend":return n.insertBefore(e,n.firstChild),!0;case"replace":return n.parentElement?(n.replaceWith(e),!0):!1}}i(us,"insertIntoDOM");function cs(n){let e=n.parentElement;return e?(window.getComputedStyle(e).position==="static"&&(e.style.position="relative"),e):null}i(cs,"ensureRelativeParent");function ls(n,e,t){if(!e.parentElement)throw new Error("Cannot inline-wrap: refEl has no parentElement");let s=document.createElement("div");return s.setAttribute("swish-placement-inline-row",n),e.before(s),s.appendChild(e),s}i(ls,"wrapWithFlexRow");function ps(n,e){let t=e.tag||"div",r=document.createElement(t);return r.setAttribute("swish-placement-container",n),e.classNames&&vn(r,e.classNames),r}i(ps,"createContainer");function ds(n,e){return n.ui.createElement(e.name,{})}i(ds,"createElement");function fs(n,e){for(let[t,r]of Object.entries(e)){let s=t.replace(/([A-Z])/g,"-$1").toLowerCase();r===!1||r===void 0||r===null||(r===!0?n.setAttribute(s,"true"):n.setAttribute(s,String(r)))}}i(fs,"applyProps");function vn(n,e){n.classList.add(...e)}i(vn,"applyClassNames");var xe=class{constructor(){this.eventBus=new EventTarget}static{i(this,"EventBus")}subscribe(e,t,r){return Array.isArray(e)||(e=[e]),e.forEach(s=>{this.eventBus.addEventListener(s,t,r)}),()=>{e.forEach(s=>{this.eventBus.removeEventListener(s,t,r)})}}unsubscribe(e,t,r){this.eventBus.removeEventListener(e,t,r)}publish(e,t){this.eventBus.dispatchEvent(new CustomEvent(e,{detail:t}))}};var Et;function wn(n){return{lang:n?.lang??Et?.lang,message:n?.message,abortEarly:n?.abortEarly??Et?.abortEarly,abortPipeEarly:n?.abortPipeEarly??Et?.abortPipeEarly}}i(wn,"getGlobalConfig");var hs;function ms(n){return hs?.get(n)}i(ms,"getGlobalMessage");var ys;function vs(n){return ys?.get(n)}i(vs,"getSchemaMessage");var gs;function ws(n,e){return gs?.get(n)?.get(e)}i(ws,"getSpecificMessage");function ke(n){let e=typeof n;return e==="string"?`"${n}"`:e==="number"||e==="bigint"||e==="boolean"?`${n}`:e==="object"||e==="function"?(n&&Object.getPrototypeOf(n)?.constructor?.name)??"null":e}i(ke,"_stringify");function K(n,e,t,r,s){let o=s&&"input"in s?s.input:t.value,a=s?.expected??n.expects??null,u=s?.received??ke(o),c={kind:n.kind,type:n.type,input:o,expected:a,received:u,message:`Invalid ${e}: ${a?`Expected ${a} but r`:"R"}eceived ${u}`,requirement:n.requirement,path:s?.path,issues:s?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},l=n.kind==="schema",p=s?.message??n.message??ws(n.reference,c.lang)??(l?vs(c.lang):null)??r.message??ms(c.lang);p!==void 0&&(c.message=typeof p=="function"?p(c):p),l&&(t.typed=!1),t.issues?t.issues.push(c):t.issues=[c]}i(K,"_addIssue");function Z(n){return{version:1,vendor:"valibot",validate(e){return n["~run"]({value:e},wn())}}}i(Z,"_getStandardProps");function In(n,e){let t=[...new Set(n)];return t.length>1?`(${t.join(` ${e} `)})`:t[0]??"never"}i(In,"_joinExpects");function he(n,e){return{kind:"validation",type:"min_length",reference:he,async:!1,expects:`>=${n}`,requirement:n,message:e,"~run"(t,r){return t.typed&&t.value.length<this.requirement&&K(this,"length",t,r,{received:`${t.value.length}`}),t}}}i(he,"minLength");function X(n,e){return{kind:"validation",type:"min_value",reference:X,async:!1,expects:`>=${n instanceof Date?n.toJSON():ke(n)}`,requirement:n,message:e,"~run"(t,r){return t.typed&&!(t.value>=this.requirement)&&K(this,"value",t,r,{received:t.value instanceof Date?t.value.toJSON():ke(t.value)}),t}}}i(X,"minValue");function T(n){return{kind:"transformation",type:"transform",reference:T,async:!1,operation:n,"~run"(e){return e.value=this.operation(e.value),e}}}i(T,"transform");function Is(n,e,t){return typeof n.fallback=="function"?n.fallback(e,t):n.fallback}i(Is,"getFallback");function bn(n,e,t){return typeof n.default=="function"?n.default(e,t):n.default}i(bn,"getDefault");function oe(n,e){return{kind:"schema",type:"array",reference:oe,expects:"Array",async:!1,item:n,message:e,get"~standard"(){return Z(this)},"~run"(t,r){let s=t.value;if(Array.isArray(s)){t.typed=!0,t.value=[];for(let o=0;o<s.length;o++){let a=s[o],u=this.item["~run"]({value:a},r);if(u.issues){let c={type:"array",origin:"value",input:s,key:o,value:a};for(let l of u.issues)l.path?l.path.unshift(c):l.path=[c],t.issues?.push(l);if(t.issues||(t.issues=u.issues),r.abortEarly){t.typed=!1;break}}u.typed||(t.typed=!1),t.value.push(u.value)}}else K(this,"type",t,r);return t}}}i(oe,"array");function xt(n){return{kind:"schema",type:"boolean",reference:xt,expects:"boolean",async:!1,message:n,get"~standard"(){return Z(this)},"~run"(e,t){return typeof e.value=="boolean"?e.typed=!0:K(this,"type",e,t),e}}}i(xt,"boolean");function E(n){return{kind:"schema",type:"number",reference:E,expects:"number",async:!1,message:n,get"~standard"(){return Z(this)},"~run"(e,t){return typeof e.value=="number"&&!isNaN(e.value)?e.typed=!0:K(this,"type",e,t),e}}}i(E,"number");function g(n,e){return{kind:"schema",type:"object",reference:g,expects:"Object",async:!1,entries:n,message:e,get"~standard"(){return Z(this)},"~run"(t,r){let s=t.value;if(s&&typeof s=="object"){t.typed=!0,t.value={};for(let o in this.entries){let a=this.entries[o];if(o in s||(a.type==="exact_optional"||a.type==="optional"||a.type==="nullish")&&a.default!==void 0){let u=o in s?s[o]:bn(a),c=a["~run"]({value:u},r);if(c.issues){let l={type:"object",origin:"value",input:s,key:o,value:u};for(let p of c.issues)p.path?p.path.unshift(l):p.path=[l],t.issues?.push(p);if(t.issues||(t.issues=c.issues),r.abortEarly){t.typed=!1;break}}c.typed||(t.typed=!1),t.value[o]=c.value}else if(a.fallback!==void 0)t.value[o]=Is(a);else if(a.type!=="exact_optional"&&a.type!=="optional"&&a.type!=="nullish"&&(K(this,"key",t,r,{input:void 0,expected:`"${o}"`,path:[{type:"object",origin:"key",input:s,key:o,value:s[o]}]}),r.abortEarly))break}}else K(this,"type",t,r);return t}}}i(g,"object");function P(n,e){return{kind:"schema",type:"optional",reference:P,expects:`(${n.expects} | undefined)`,async:!1,wrapped:n,default:e,get"~standard"(){return Z(this)},"~run"(t,r){return t.value===void 0&&(this.default!==void 0&&(t.value=bn(this,t,r)),t.value===void 0)?(t.typed=!0,t):this.wrapped["~run"](t,r)}}}i(P,"optional");function me(n,e){return{kind:"schema",type:"picklist",reference:me,expects:In(n.map(ke),"|"),async:!1,options:n,message:e,get"~standard"(){return Z(this)},"~run"(t,r){return this.options.includes(t.value)?t.typed=!0:K(this,"type",t,r),t}}}i(me,"picklist");function v(n){return{kind:"schema",type:"string",reference:v,expects:"string",async:!1,message:n,get"~standard"(){return Z(this)},"~run"(e,t){return typeof e.value=="string"?e.typed=!0:K(this,"type",e,t),e}}}i(v,"string");function gn(n){let e;if(n)for(let t of n)e?e.push(...t.issues):e=t.issues;return e}i(gn,"_subIssues");function $(n,e){return{kind:"schema",type:"union",reference:$,expects:In(n.map(t=>t.expects),"|"),async:!1,options:n,message:e,get"~standard"(){return Z(this)},"~run"(t,r){let s,o,a;for(let u of this.options){let c=u["~run"]({value:t.value},r);if(c.typed)if(c.issues)o?o.push(c):o=[c];else{s=c;break}else a?a.push(c):a=[c]}if(s)return s;if(o){if(o.length===1)return o[0];K(this,"type",t,r,{issues:gn(o)}),t.typed=!0}else{if(a?.length===1)return a[0];K(this,"type",t,r,{issues:gn(a)})}return t}}}i($,"union");function b(...n){return{...n[0],pipe:n,get"~standard"(){return Z(this)},"~run"(e,t){for(let r of n)if(r.kind!=="metadata"){if(e.issues&&(r.kind==="schema"||r.kind==="transformation")){e.typed=!1;break}(!e.issues||!t.abortEarly&&!t.abortPipeEarly)&&(e=r["~run"](e,t))}return e}}}i(b,"pipe");function S(n,e,t){let r=n["~run"]({value:e},wn(t));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}i(S,"safeParse");var de=b($([b(v(),T(A)),E()]),T(n=>Number(n)),b(E(),X(1)));var m=class{constructor(e,t,r,s){this.swish=e;this.ui=t;this.eventBus=r;this.options=s}static{i(this,"IntentHandler")}};var bs=$([g({variantId:de,quantity:P(b(E(),X(1)),1)}),g({items:b(oe(g({variantId:de,quantity:P(b(E(),X(1)),1)})),he(1))})]),Ce=class extends m{static{i(this,"CreateCartLineHandler")}async invoke(e){let t=S(bs,e);if(!t.success)return{intent:"create:cart-line",code:"error",message:"Invalid intent data",issues:t.issues.map(s=>s.message)};let r=t.output;try{let s="items"in r?r.items.map(a=>({id:a.variantId,quantity:a.quantity})):[{id:r.variantId,quantity:r.quantity}];return{intent:"create:cart-line",code:"ok",data:await this.swish.ajax.addToCart({items:s})}}catch(s){let o=[],a="Failed to add item to cart";return s instanceof Error?(s.message&&(a=s.message,o.push(s.message)),s.stack&&o.push(s.stack)):typeof s=="string"&&s.trim()?(a=s,o.push(s)):s!=null&&o.push(String(s)),{intent:"create:cart-line",code:"error",message:a,issues:o.length?o:["Cart request failed"]}}}};var Ss=g({variantId:de,quantity:P(b(E(),X(1)),1)}),Es=150,xs=$([g({variantId:de,quantity:P(b(E(),X(1)),1)}),g({items:b(oe(Ss),he(1))})]),Re=class extends m{static{i(this,"InitiateCheckoutHandler")}async invoke(e){let t=S(xs,e);if(!t.success)return{intent:"initiate:checkout",code:"error",message:"Invalid intent data",issues:t.issues.map(u=>u.message)};let r=t.output,o=("items"in r?r.items:[{variantId:r.variantId,quantity:r.quantity}]).map(u=>`${u.variantId}:${u.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),Es),{intent:"initiate:checkout",code:"ok",data:{checkoutUrl:a.href}}}};var Ae=class extends m{static{i(this,"CreateListHandler")}async invoke(e){let t=await this.ui.showListEditor();if(t.code==="closed")return{intent:"create:list",code:"closed"};let{list:r}=t.data;return{intent:"create:list",code:"ok",data:{list:r}}}};var ks=g({listId:v()}),De=class extends m{static{i(this,"DeleteListHandler")}async invoke(e){let t=S(ks,e);if(!t.success)return{intent:"delete:list",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{listId:r}=t.output;return(await this.ui.showDeleteListAlert({listId:r})).code==="closed"?{intent:"delete:list",code:"closed"}:{intent:"delete:list",code:"ok",data:{listId:r}}}};var Cs=g({itemId:v()}),Pe=class extends m{static{i(this,"EditItemListsHandler")}async invoke(e){let t=S(Cs,e);if(!t.success)return{intent:"edit:item-lists",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{itemId:r}=t.output,s=await this.ui.showListSelect({itemId:r});if(s.code==="closed")return{intent:"edit:item-lists",code:"closed"};if(s.data.action==="submit"){let{item:o,product:a,variant:u}=s.data.data;return{intent:"edit:item-lists",code:"ok",data:{item:o,product:a,variant:u}}}return{intent:"unsave:item",code:"ok",data:{itemId:s.data.data.itemId}}}};var Rs=g({itemId:b(v()),productId:b($([b(v(),T(A)),E()]),T(n=>Number(n)),E()),variantId:P(b($([b(v(),T(A)),E()]),T(n=>Number(n)),E()))}),Te=class extends m{static{i(this,"EditItemVariantHandler")}async invoke(e){let t=S(Rs,e);if(!t.success)return{intent:"edit:item-variant",code:"error",message:"Invalid intent data",issues:t.issues.map(y=>y.message)};let{itemId:r,productId:s,variantId:o}=t.output;if(!(!o||this.swish.options.intents.editSavedProduct.promptVariantChange)){let y=await this.swish.api.items.updateById(r,{productId:s,variantId:o});if("error"in y)return{intent:"edit:item-variant",code:"error",message:"Failed to update variant",issues:[y.error.message]};if(!y.data)return{intent:"edit:item-variant",code:"error",message:"Failed to update variant",issues:["No item returned from API"]};let h=await this.swish.storefront.loadSaveIntentData({productId:D("Product",s),variantId:o?D("ProductVariant",o):void 0});if(!h.data?.product)return{intent:"edit:item-variant",code:"error",message:"Failed to load save intent data",issues:[h.errors?.message??"No product data returned from API"]};let x=h.data?.product,w="variant"in h.data?h.data.variant:void 0;return{intent:"edit:item-variant",code:"ok",data:{item:y.data,product:x,variant:w}}}let u=await this.ui.showVariantSelect({itemId:r,productId:s,variantId:o});if(u.code==="closed")return{intent:"edit:item-variant",code:"closed"};let{item:c,product:l,variant:p}=u.data;return{intent:"edit:item-variant",code:"ok",data:{item:c,product:l,variant:p}}}};var As=g({listId:v(),access:me(["public","private"])}),_e=class extends m{static{i(this,"EditListAccessHandler")}async invoke(e){let t=S(As,e);if(!t.success)return{intent:"edit:list-access",code:"error",message:"Invalid intent data",issues:t.issues.map(u=>u.message)};let{listId:r,access:s}=t.output;if((await this.ui.showConfirmDialog({titleKey:s==="public"?"listMenu.public.title":"listMenu.private.title",descriptionKey:s==="public"?"listMenu.public.description":"listMenu.private.description",confirmLabelKey:s==="public"?"listMenu.public.text":"listMenu.private.text",cancelLabelKey:"listMenu.cancel",danger:!1})).code==="closed")return{intent:"edit:list-access",code:"closed"};let a=await this.swish.api.lists.updateById(r,{access:s});return"error"in a?{intent:"edit:list-access",code:"error",message:"Failed to update list access",issues:[a.error.message]}:a.data?{intent:"edit:list-access",code:"ok",data:{list:a.data}}:{intent:"edit:list-access",code:"error",message:"Failed to update list access",issues:["API response missing data"]}}};var Ds=g({listId:v()}),Oe=class extends m{static{i(this,"EditListHandler")}async invoke(e){let t=S(Ds,e);if(!t.success)return{intent:"edit:list",code:"error",message:"Invalid intent data",issues:t.issues.map(a=>a.message)};let{listId:r}=t.output,s=await this.ui.showListEditor({listId:r});if(s.code==="closed")return{intent:"edit:list",code:"closed"};let{list:o}=s.data;return{intent:"edit:list",code:"ok",data:{list:o}}}};var Ps=150,Ts=g({returnTo:v()}),Le=class extends m{static{i(this,"InitiateSignInHandler")}async invoke(e){let t=S(Ts,e);if(!t.success)return{intent:"initiate:sign-in",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let r=t.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(r),{intent:"initiate:sign-in",code:"ok",data:void 0})}scheduleRedirect(e){window.setTimeout(()=>this.redirectToSignIn(e),Ps)}redirectToSignIn(e){let t=this.swish.storefrontContext.routes.accountUrl,r=new URL(t,window.location.origin);r.searchParams.set("return_url",e),window.location.assign(r.toString())}};var $e=class extends m{static{i(this,"OpenHomeHandler")}async invoke(e){return{intent:"open:home",code:(await this.ui.showDrawer()).code,data:void 0}}};var _s=g({listId:v()}),Me=class extends m{static{i(this,"OpenListDetailPageMenuHandler")}async invoke(e){let t=S(_s,e);if(!t.success)return{intent:"open:list-detail-page-menu",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{listId:r}=t.output;return{intent:"open:list-detail-page-menu",code:(await this.ui.showListDetailPageMenu({listId:r})).code,data:void 0}}};var Os=g({listId:v()}),Ve=class extends m{static{i(this,"OpenListHandler")}async invoke(e){let t=S(Os,e);if(!t.success)return{intent:"open:list",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{listId:r}=t.output;return{intent:"open:list",code:(await this.ui.showDrawer({view:"list",listId:r})).code,data:void 0}}};var Ls=g({listId:v()}),qe=class extends m{static{i(this,"OpenListMenuHandler")}async invoke(e){let t=S(Ls,e);if(!t.success)return{intent:"open:list-menu",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{listId:r}=t.output,s=await this.ui.showListMenu({listId:r});if(s.code==="closed")return{intent:"open:list-menu",code:"closed"};if(s.data.action==="edit")return{intent:"edit:list",code:"ok",data:s.data.data};if(s.data.action==="delete")return{intent:"delete:list",code:"ok",data:{listId:r}};if(s.data.action==="edit-access"){let o=s.data.data?.currentListAccess,a=o==="public"?"private":o==="private"?"public":void 0;return a?(await this.swish.intents.invoke("edit:list-access",{listId:r,access:a})).complete:{intent:"open:list-menu",code:"error",message:"Missing list access from UI",issues:["List menu UI did not provide currentListAccess"]}}return s.data.action==="share"?(await this.swish.intents.invoke("initiate:share",{listId:r})).complete:{intent:"open:list-menu",code:"error",message:"Unknown list menu action",issues:["Unknown action returned from list menu UI"]}}};var Ne=class extends m{static{i(this,"OpenListsHandler")}async invoke(e){return{intent:"open:lists",code:(await this.ui.showDrawer({view:"lists"})).code,data:void 0}}};var Be=class extends m{static{i(this,"OpenNotificationsHandler")}async invoke(e){return{intent:"open:notifications",code:(await this.ui.showDrawer({view:"notifications"})).code,data:void 0}}};var $s=g({orderId:b($([b(v(),T(A)),E()]),T(n=>Number(n)),E())}),Ue=class extends m{static{i(this,"OpenOrderHandler")}async invoke(e){let t=S($s,e);if(!t.success)return{intent:"open:order",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{orderId:r}=t.output;return{intent:"open:order",code:(await this.ui.showDrawer({view:"order",orderId:r.toString()})).code,data:void 0}}};var Ms=g({orderId:v()}),Fe=class extends m{static{i(this,"OpenOrderMenuHandler")}async invoke(e){let t=S(Ms,e);if(!t.success)return{intent:"open:order-menu",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{orderId:r}=t.output;return{intent:"open:order-menu",code:(await this.ui.showOrderMenu({orderId:r})).code,data:void 0}}};var je=class extends m{static{i(this,"OpenOrdersHandler")}async invoke(e){return{intent:"open:orders",code:(await this.ui.showDrawer({view:"orders"})).code,data:void 0}}};var Vs=g({productId:b($([b(v(),T(A)),E()]),T(n=>Number(n)),E()),variantId:P(b($([b(v(),T(A)),E()]),T(Number),E()))}),Ge=class extends m{static{i(this,"OpenProductHandler")}async invoke(e){let t=S(Vs,e);if(!t.success)return{intent:"open:product",code:"error",message:"Invalid intent data",issues:t.issues.map(a=>a.message)};let{productId:r,variantId:s}=t.output;return{intent:"open:product",code:(await this.ui.showDrawer({view:"product",productId:r.toString(),variantId:s?.toString()})).code,data:void 0}}};var He=class extends m{static{i(this,"OpenProfileHandler")}async invoke(e){return{intent:"open:profile",code:(await this.ui.showDrawer({view:"profile"})).code,data:void 0}}};var qs=g({productId:b($([b(v(),T(A)),E()]),T(n=>Number(n)),E()),variantId:P(b($([b(v(),T(A)),E()]),T(Number),E()))}),Qe=class extends m{static{i(this,"OpenQuickBuyHandler")}async invoke(e){let t=S(qs,e);if(!t.success)return{intent:"open:quick-buy",code:"error",message:"Invalid intent data",issues:t.issues.map(a=>a.message)};let{productId:r,variantId:s}=t.output,o=await this.ui.showQuickBuy({productId:r,variantId:s});return o.code==="closed"?{intent:"open:quick-buy",code:"closed"}:{intent:"open:quick-buy",code:"ok",data:o.data}}};var ze=class extends m{static{i(this,"OpenSavesHandler")}async invoke(e){return{intent:"open:saves",code:(await this.ui.showDrawer({view:"saves"})).code,data:void 0}}};var iu=g({returnTo:P(v())}),We=class extends m{static{i(this,"OpenSignInHandler")}async invoke(e){return{intent:"open:sign-in",code:(await this.ui.showSignIn({returnTo:e?.returnTo})).code,data:void 0}}};var Ns=g({productId:b($([b(v(),T(A)),E()]),T(n=>Number(n)),E()),variantId:P(b($([b(v(),T(A)),E()]),T(Number),E())),quantity:P(b(E(),X(1))),tags:P(oe(v()))}),Ke=class extends m{static{i(this,"SaveItemHandler")}async invoke(e){let t=S(Ns,e);if(!t.success)return{intent:"save:item",code:"error",message:"Invalid intent data",issues:t.issues.map(h=>h.message)};let{productId:r,variantId:s,quantity:o,tags:a}=t.output,u=await this.swish.storefront.loadSaveIntentData({productId:D("Product",r),variantId:s?D("ProductVariant",s):void 0});if(u.errors)return{intent:"save:item",code:"error",message:u.errors.message??"Failed to load save intent data",issues:u.errors.graphQLErrors?.map(h=>h.message)??[]};if(!u.data||!u.data.product)return{intent:"save:item",code:"error",message:"Failed to load save intent data",issues:["API response missing data"]};let{product:c}=u.data,l=c.variantsCount?.count&&c.variantsCount.count>1,p=!!s,f=!this.options.saveProduct.promptVariantIfMissing||!this.options.saveProduct.promptVariantIfPresent&&p;if(!l||f){let h=i(()=>!l&&c.selectedOrFirstAvailableVariant?Number(A(c.selectedOrFirstAvailableVariant.id)):s,"variantIdToUse"),x=await this.swish.api.items.create({productId:r,variantId:h(),quantity:o,tags:a});if("error"in x)return{intent:"save:item",code:"error",message:"Failed to create item",issues:[x.error.message]};if(!x.data)return{intent:"save:item",code:"error",message:"Could not complete item creation",issues:["API response missing data"]};let w="variant"in u.data?u.data.variant:void 0;return{intent:"save:item",code:"ok",data:{item:x.data,product:c,variant:l?w:c.selectedOrFirstAvailableVariant}}}let y=await this.ui.showVariantSelect({productId:r,variantId:s});return y.code==="closed"?{intent:"save:item",code:"closed"}:{intent:"save:item",code:"ok",data:y.data}}};function ye(n,e){let{storeDomain:t}=n.options.storefrontApi,{rootUrl:r,listDetailPagePath:s}=n.options.storefrontContext.routes,o=new URL(`https://${t}`),a=new URL(`${r==="/"?"":r}${s}`,o);return a.searchParams.set("public-list-id",e.publicListId),a}i(ye,"buildShareListUrl");async function ve(n){return typeof navigator?.clipboard?.writeText!="function"?{ok:!1,issues:["Clipboard API not available"]}:navigator.clipboard.writeText(n).then(()=>({ok:!0})).catch(e=>({ok:!1,issues:[e?.message??"Failed to copy to clipboard"]}))}i(ve,"copyToClipboard");function Sn(){let n=navigator.userAgent.includes("Mac OS")&&navigator.maxTouchPoints>1;return/Android|Mobile/i.test(navigator.userAgent)||n}i(Sn,"isMobileDevice");var Bs=g({listId:v()}),Xe=class extends m{static{i(this,"ShareListHandler")}async invoke(e){let t=S(Bs,e);if(!t.success)return{intent:"initiate:share",code:"error",message:"Invalid intent data",issues:t.issues.map(u=>u.message)};let{listId:r}=t.output,s=ye(this.swish,{publicListId:r}).toString();if(Sn()&&typeof navigator.share=="function"&&(await navigator.share({title:"Share list",url:s}).then(()=>({ok:!0})).catch(()=>({ok:!1}))).ok)return{intent:"initiate:share",code:"ok",data:{listId:r,url:s,method:"native"}};let a=await ve(s);return a.ok?{intent:"initiate:share",code:"ok",data:{listId:r,url:s,method:"clipboard"}}:{intent:"initiate:share",code:"error",message:"Failed to share list",issues:a.issues}}};var ku=g({title:P(v()),text:v(),image:P(v()),action:P(g({label:v(),url:P(v())})),variant:P(me(["compact","full"])),icon:P(v())}),Ye=class extends m{static{i(this,"ShowToastHandler")}async invoke(e){return{intent:"show:toast",code:(await this.ui.showToast(e)).code,data:void 0}}};var Us=g({itemId:v(),delete:P(xt())}),Je=class extends m{static{i(this,"UnsaveItemHandler")}async invoke(e){let t=S(Us,e);if(!t.success)return{intent:"unsave:item",code:"error",message:"Invalid intent data",issues:t.issues.map(a=>a.message)};let{itemId:r,delete:s}=t.output;if(this.options.unsaveProduct.selectList&&!s){let a=await this.ui.showListSelect({itemId:r});if(a.code==="closed")return{intent:"unsave:item",code:"closed"};if(a.data.action==="submit"){let{item:u,product:c,variant:l}=a.data.data;return{intent:"edit:item-lists",code:"ok",data:{item:u,product:c,variant:l}}}if(a.data.action==="unsave"){let{itemId:u}=a.data.data;return{intent:"unsave:item",code:"ok",data:{itemId:u}}}}if(!this.options.unsaveProduct.confirm){let a=await this.swish.api.items.deleteById(r);return"error"in a?{intent:"unsave:item",code:"error",message:"Failed to delete item",issues:[a.error.message]}:{intent:"unsave:item",code:"ok",data:{itemId:r}}}return(await this.ui.showUnsaveAlert({itemId:r})).code==="closed"?{intent:"unsave:item",code:"closed"}:{intent:"unsave:item",code:"ok",data:{itemId:r}}}};var z=class{constructor(e,t,r){this.swish=e;this.ui=t;this.options=r}static{i(this,"IntentHook")}};var Ze=class extends z{static{i(this,"AfterEditItemListsHook")}async invoke(e){if(this.options.editSavedProduct.showFeedback&&e.code==="ok"){if("itemId"in e.data)return;let{product:t,variant:r}=e.data;t&&(await(await this.swish.intents.invoke("show:toast",{title:"Saved",text:t.title,image:r?.image?.url??t.featuredImage?.url,action:{label:"View"}})).complete).code==="ok"&&this.swish.intents.invoke("open:home")}}};var et=class extends z{static{i(this,"AfterEditListAccessHook")}async invoke(e){if(e.code!=="ok")return;let t=e.data.list.access==="public"?"List is now public":"List is now private";await(await this.swish.intents.invoke("show:toast",{text:t,variant:"compact",icon:"check"})).complete}};var tt=class extends z{static{i(this,"AfterOpenHomeHook")}async invoke(e){if(e.code==="closed"){let t=new URL(window.location.href);(t.hash==="#swish-home"||t.hash==="#swish")&&(t.hash="",window.history.replaceState({},document.title,t.toString()))}}};var nt=class extends z{static{i(this,"AfterSaveItemHook")}async invoke(e){if(this.options.saveProduct.showFeedback&&e.code==="ok"){let{item:t,product:r,variant:s}=e.data;r&&(await(await this.swish.intents.invoke("show:toast",{title:"Saved",text:r.title,image:s?.image?.url??r.featuredImage?.url,action:{label:"Add to List"}})).complete).code==="ok"&&this.swish.intents.invoke("edit:item-lists",{itemId:t.id})}}};var rt=class extends z{static{i(this,"AfterShareListHook")}async invoke(e){if(e.code!=="ok")return;await(await this.swish.intents.invoke("show:toast",{variant:"compact",text:"Link shared",icon:"check"})).complete}};var st=class{static{i(this,"Intents")}constructor(e,t){this.swish=e,this.ui=t,this.eventBus=new EventTarget,this.options=e.options.intents,this.handlers={"create:cart-line":new Ce(this.swish,this.ui,this.eventBus,this.options),"initiate:checkout":new Re(this.swish,this.ui,this.eventBus,this.options),"save:item":new Ke(this.swish,this.ui,this.eventBus,this.options),"unsave:item":new Je(this.swish,this.ui,this.eventBus,this.options),"edit:item-variant":new Te(this.swish,this.ui,this.eventBus,this.options),"edit:item-lists":new Pe(this.swish,this.ui,this.eventBus,this.options),"create:list":new Ae(this.swish,this.ui,this.eventBus,this.options),"edit:list":new Oe(this.swish,this.ui,this.eventBus,this.options),"edit:list-access":new _e(this.swish,this.ui,this.eventBus,this.options),"delete:list":new De(this.swish,this.ui,this.eventBus,this.options),"open:home":new $e(this.swish,this.ui,this.eventBus,this.options),"initiate:share":new Xe(this.swish,this.ui,this.eventBus,this.options),"open:list":new Ve(this.swish,this.ui,this.eventBus,this.options),"open:lists":new Ne(this.swish,this.ui,this.eventBus,this.options),"open:orders":new je(this.swish,this.ui,this.eventBus,this.options),"open:order":new Ue(this.swish,this.ui,this.eventBus,this.options),"open:saves":new ze(this.swish,this.ui,this.eventBus,this.options),"open:notifications":new Be(this.swish,this.ui,this.eventBus,this.options),"open:profile":new He(this.swish,this.ui,this.eventBus,this.options),"open:product":new Ge(this.swish,this.ui,this.eventBus,this.options),"open:list-menu":new qe(this.swish,this.ui,this.eventBus,this.options),"open:order-menu":new Fe(this.swish,this.ui,this.eventBus,this.options),"open:list-detail-page-menu":new Me(this.swish,this.ui,this.eventBus,this.options),"initiate:sign-in":new Le(this.swish,this.ui,this.eventBus,this.options),"open:sign-in":new We(this.swish,this.ui,this.eventBus,this.options),"open:quick-buy":new Qe(this.swish,this.ui,this.eventBus,this.options),"show:toast":new Ye(this.swish,this.ui,this.eventBus,this.options)},this.initIntentHooks(),this.initIntentWatcher()}publishAnalyticsEvent(e,t){typeof window.Shopify?.analytics?.publish=="function"&&window.Shopify.analytics.publish(e,t)}async invoke(e,...t){let r=t[0],s={lifecycle:"before",intent:e,data:r};return this.publishAnalyticsEvent("swish-intent",s),this.publishAnalyticsEvent(`swish-intent=${e}`,s),{intent:e,data:r,complete:this.handleIntent(e,r).then(o=>{let a={lifecycle:"after",intent:e,data:r,response:o};return this.publishAnalyticsEvent("swish-intent",a),this.publishAnalyticsEvent(`swish-intent=${e}`,a),this.eventBus.dispatchEvent(new CustomEvent(e,{detail:o})),o})}}listen(e,t){let r=i(o=>{"detail"in o&&o.detail?t(o.detail):console.warn("Intent response event without detail",o)},"eventListener"),s=i(()=>{this.eventBus.removeEventListener(e,r)},"unsubscribe");return this.eventBus.addEventListener(e,r),s}parseIntentFromString(e){if(typeof e=="string"){let[t,...r]=e.split(","),s=r.reduce((o,a)=>{let[u,c]=a.split("=");return o[u]=c,o},{});return{intent:t,data:s}}return{intent:e,data:{}}}parseIntentFromHash(e){let t=e.startsWith("#")?e.slice(1):e;return{swish:"open:home","swish-home":"open:home","swish-lists":"open:lists","swish-orders":"open:orders","swish-saves":"open:saves","swish-notifications":"open:notifications","swish-profile":"open:profile"}[t]||null}async handleIntent(e,t){let r=this.handlers[e];return r?r.invoke(t):{intent:e,code:"error",message:"Invalid intent",issues:[`Intent ${e} not found`]}}initIntentHooks(){this.eventBus.addEventListener("save:item",e=>{new nt(this.swish,this.ui,this.options).invoke(e.detail)}),this.eventBus.addEventListener("edit:item-lists",e=>{new Ze(this.swish,this.ui,this.options).invoke(e.detail)}),this.eventBus.addEventListener("open:home",e=>{new tt(this.swish,this.ui,this.options).invoke(e.detail)}),this.eventBus.addEventListener("edit:list-access",e=>{new et(this.swish,this.ui,this.options).invoke(e.detail)}),this.eventBus.addEventListener("initiate:share",e=>{new rt(this.swish,this.ui,this.options).invoke(e.detail)})}initIntentWatcher(){ie({selector:"[swish-intent]",onElementFound:i(e=>{let t=e.getAttribute("swish-intent");t&&e.addEventListener("click",()=>{let{intent:r,data:s}=this.parseIntentFromString(t);Object.keys(s).length>0?this.invoke(r,s):this.invoke(r)})},"onElementFound")}),ie({selector:"a[href*='swish-intent='],a[href*='#swish']",onElementFound:i(e=>{e instanceof HTMLAnchorElement&&e.addEventListener("click",t=>{if(!t.metaKey&&!t.ctrlKey&&!t.shiftKey&&!t.altKey){let r=new URL(e.href),s=r.hash,o=r.searchParams.get("swish-intent");if(o){let{intent:a,data:u}=this.parseIntentFromString(o);a&&(t.preventDefault(),t.stopPropagation(),Object.keys(u).length>0?this.invoke(a,u):this.invoke(a))}else if(s){let a=this.parseIntentFromHash(s);a&&(t.preventDefault(),t.stopPropagation(),this.invoke(a))}}})},"onElementFound")}),pe({fireOnInit:!0,onLocationChange:i(e=>{let t=new URL(e.href),r=t.hash,s=t.searchParams.get("swish-intent");if(s){let{intent:o,data:a}=this.parseIntentFromString(s);o&&(Object.keys(a).length>0?this.invoke(o,a):this.invoke(o))}else if(r){let o=this.parseIntentFromHash(r);o&&this.invoke(o)}},"onLocationChange")})}};var En=i(n=>({swishApi:{authProxy:n.swishApi?.authProxy??"/apps/wishlist/api",version:n.swishApi?.version??"2026-01"},storefrontApi:{storeDomain:n.storefrontApi?.storeDomain??"",accessToken:n.storefrontApi?.accessToken??""},storefrontContext:{...n.storefrontContext,routes:{...n.storefrontContext.routes,rootUrl:n.storefrontContext.routes?.rootUrl??"/",listDetailPagePath:n.storefrontContext.routes?.listDetailPagePath??"/apps/wishlist"},localization:{country:n.storefrontContext.localization.country.toUpperCase(),language:n.storefrontContext.localization.language.toUpperCase(),market:n.storefrontContext.localization.market}},badges:{getBadges:n.badges?.getBadges??(({defaultBadges:e})=>e)},productOptions:{sortValues:n.productOptions?.sortValues??(({option:e,optionValues:t})=>t)},metafields:{product:n.metafields?.product??[],productVariant:n.metafields?.productVariant??[]},features:{accounts:n?.features?.accounts??!0,lists:n?.features?.lists??!0,orders:n?.features?.orders??!0,notifications:n?.features?.notifications??!0},intents:{saveProduct:{promptVariantIfMissing:n?.intents?.saveProduct?.promptVariantIfMissing??!0,promptVariantIfPresent:n?.intents?.saveProduct?.promptVariantIfPresent??!0,showFeedback:n?.intents?.saveProduct?.showFeedback??!0},unsaveProduct:{selectList:n?.intents?.unsaveProduct?.selectList??!0,confirm:n?.intents?.unsaveProduct?.confirm??!0,showFeedback:n?.intents?.unsaveProduct?.showFeedback??!0},editSavedProduct:{promptVariantChange:n?.intents?.editSavedProduct?.promptVariantChange??!0,showFeedback:n?.intents?.editSavedProduct?.showFeedback??!0}},swishUi:{baseUrl:n.swishUi?.baseUrl??"https://swish.app/cdn",version:n.swishUi?.version??it,components:{productRow:{showVariantTitle:n.swishUi?.components?.productRow?.showVariantTitle??!1},productDetail:{descriptionMaxLines:n.swishUi?.components?.productDetail?.descriptionMaxLines??4},variantSelect:{displayType:n.swishUi?.components?.variantSelect?.displayType??"pills"},icons:n.swishUi?.components?.icons??{},imageSlider:{flush:n.swishUi?.components?.imageSlider?.flush??!1,loop:n.swishUi?.components?.imageSlider?.loop??!1},images:{baseTint:n.swishUi?.components?.images?.baseTint??!1},buyButtons:{shopPay:n.swishUi?.components?.buyButtons?.shopPay??!1},listDetailPage:{desktopColumns:n.swishUi?.components?.listDetailPage?.desktopColumns??4,showBuyButton:n.swishUi?.components?.listDetailPage?.showBuyButton??!0,showVariantOptionNames:n.swishUi?.components?.listDetailPage?.showVariantOptionNames??!1,enableVariantChange:n.swishUi?.components?.listDetailPage?.enableVariantChange??!0},drawer:{title:n.swishUi?.components?.drawer?.title??"",logo:{url:n.swishUi?.components?.drawer?.logo?.url??"",altText:n.swishUi?.components?.drawer?.logo?.altText??""},navigation:{enabled:n.swishUi?.components?.drawer?.navigation?.enabled??!0,variant:n.swishUi?.components?.drawer?.navigation?.variant??"floating",items:n.swishUi?.components?.drawer?.navigation?.items??[]},emptyCallout:{enabled:n.swishUi?.components?.drawer?.emptyCallout?.enabled??!1,shoppingCalloutUrl:n.swishUi?.components?.drawer?.emptyCallout?.shoppingCalloutUrl??"/collections/all"},miniMenu:{enabled:n.swishUi?.components?.drawer?.miniMenu?.enabled??!0,items:n.swishUi?.components?.drawer?.miniMenu?.items??[]},listDetailView:{enableVariantChange:n.swishUi?.components?.drawer?.listDetailView?.enableVariantChange??!1,showVariantOptionNames:n.swishUi?.components?.drawer?.listDetailView?.showVariantOptionNames??!1}}},css:n.swishUi?.css??[],design:n.swishUi?.design??{}}}),"createSwishOptions");var Fs=Symbol.for("preact-signals");function at(){if(ne>1)ne--;else{for(var n,e=!1;ge!==void 0;){var t=ge;for(ge=void 0,kt++;t!==void 0;){var r=t.o;if(t.o=void 0,t.f&=-3,!(8&t.f)&&Cn(t))try{t.c()}catch(s){e||(n=s,e=!0)}t=r}}if(kt=0,ne--,e)throw n}}i(at,"t");function re(n){if(ne>0)return n();ne++;try{return n()}finally{at()}}i(re,"r");var k=void 0;function xn(n){var e=k;k=void 0;try{return n()}finally{k=e}}i(xn,"n");var ge=void 0,ne=0,kt=0,ot=0;function kn(n){if(k!==void 0){var e=n.n;if(e===void 0||e.t!==k)return e={i:0,S:n,p:k.s,n:void 0,t:k,e:void 0,x:void 0,r:e},k.s!==void 0&&(k.s.n=e),k.s=e,n.n=e,32&k.f&&n.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=k.s,e.n=void 0,k.s.n=e,k.s=e),e}}i(kn,"e");function B(n,e){this.v=n,this.i=0,this.n=void 0,this.t=void 0,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}i(B,"u");B.prototype.brand=Fs;B.prototype.h=function(){return!0};B.prototype.S=function(n){var e=this,t=this.t;t!==n&&n.e===void 0&&(n.x=t,this.t=n,t!==void 0?t.e=n:xn(function(){var r;(r=e.W)==null||r.call(e)}))};B.prototype.U=function(n){var e=this;if(this.t!==void 0){var t=n.e,r=n.x;t!==void 0&&(t.x=r,n.e=void 0),r!==void 0&&(r.e=t,n.x=void 0),n===this.t&&(this.t=r,r===void 0&&xn(function(){var s;(s=e.Z)==null||s.call(e)}))}};B.prototype.subscribe=function(n){var e=this;return Q(function(){var t=e.value,r=k;k=void 0;try{n(t)}finally{k=r}},{name:"sub"})};B.prototype.valueOf=function(){return this.value};B.prototype.toString=function(){return this.value+""};B.prototype.toJSON=function(){return this.value};B.prototype.peek=function(){var n=k;k=void 0;try{return this.value}finally{k=n}};Object.defineProperty(B.prototype,"value",{get:i(function(){var n=kn(this);return n!==void 0&&(n.i=this.i),this.v},"get"),set:i(function(n){if(n!==this.v){if(kt>100)throw new Error("Cycle detected");this.v=n,this.i++,ot++,ne++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{at()}}},"set")});function V(n,e){return new B(n,e)}i(V,"d");function Cn(n){for(var e=n.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}i(Cn,"c");function Rn(n){for(var e=n.s;e!==void 0;e=e.n){var t=e.S.n;if(t!==void 0&&(e.r=t),e.S.n=e,e.i=-1,e.n===void 0){n.s=e;break}}}i(Rn,"a");function An(n){for(var e=n.s,t=void 0;e!==void 0;){var r=e.p;e.i===-1?(e.S.U(e),r!==void 0&&(r.n=e.n),e.n!==void 0&&(e.n.p=r)):t=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=r}n.s=t}i(An,"l");function ae(n,e){B.call(this,void 0),this.x=n,this.s=void 0,this.g=ot-1,this.f=4,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}i(ae,"y");ae.prototype=new B;ae.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===ot))return!0;if(this.g=ot,this.f|=1,this.i>0&&!Cn(this))return this.f&=-2,!0;var n=k;try{Rn(this),k=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return k=n,An(this),this.f&=-2,!0};ae.prototype.S=function(n){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}B.prototype.S.call(this,n)};ae.prototype.U=function(n){if(this.t!==void 0&&(B.prototype.U.call(this,n),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}};ae.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var n=this.t;n!==void 0;n=n.x)n.t.N()}};Object.defineProperty(ae.prototype,"value",{get:i(function(){if(1&this.f)throw new Error("Cycle detected");var n=kn(this);if(this.h(),n!==void 0&&(n.i=this.i),16&this.f)throw this.v;return this.v},"get")});function F(n,e){return new ae(n,e)}i(F,"w");function Dn(n){var e=n.u;if(n.u=void 0,typeof e=="function"){ne++;var t=k;k=void 0;try{e()}catch(r){throw n.f&=-2,n.f|=8,Ct(n),r}finally{k=t,at()}}}i(Dn,"_");function Ct(n){for(var e=n.s;e!==void 0;e=e.n)e.S.U(e);n.x=void 0,n.s=void 0,Dn(n)}i(Ct,"b");function js(n){if(k!==this)throw new Error("Out-of-order effect");An(this),k=n,this.f&=-2,8&this.f&&Ct(this),at()}i(js,"g");function fe(n,e){this.x=n,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=e?.name}i(fe,"p");fe.prototype.c=function(){var n=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.u=e)}finally{n()}};fe.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Dn(this),Rn(this),ne++;var n=k;return k=this,js.bind(this,n)};fe.prototype.N=function(){2&this.f||(this.f|=2,this.o=ge,ge=this)};fe.prototype.d=function(){this.f|=8,1&this.f||Ct(this)};fe.prototype.dispose=function(){this.d()};function Q(n,e){var t=new fe(n,e);try{t.c()}catch(s){throw t.d(),s}var r=t.d.bind(t);return r[Symbol.dispose]=r,r}i(Q,"E");var Gs=/\/products\/([^/?#]+)(?:\?(?:[^#]*?&)?variant=(\d+))?/,Rt=i(n=>{let e=n.match(Gs);return e?{productHandle:e[1],variantId:e[2]}:null},"parseProductUrl"),Pn=i(({source:n,onProductUrlChange:e})=>{let t=i(r=>{let s=Rt(r);s?.productHandle&&e(s)},"handleChange");if(n instanceof HTMLAnchorElement)return dn({element:n,onHrefChange:i(r=>t(r),"onHrefChange")});if(n instanceof Location)return pe({onLocationChange:i(r=>t(r.href),"onLocationChange")});throw new Error("Invalid source for observing product url")},"observeProductUrl");var Tn=i(n=>e=>{let{productHandle:t,productId:r,variantId:s,itemId:o}=e?.dataset??{},c=!!(r||t)||!!o,l=V({loading:!1,productId:r,variantId:s,itemId:o});if(!c){let p=e instanceof HTMLAnchorElement?e:window.location,f=Rt(p.href);f?.productHandle&&f.productHandle!==l.value.productHandle&&(l.value={...l.value,...f,productId:void 0},Pn({source:p,onProductUrlChange:i(y=>{l.value={...l.value,...y,productId:y.productHandle!==l.value.productHandle?void 0:l.value.productId}},"onProductUrlChange")}))}return Q(()=>{l.value.loading||!l.value.productId&&l.value.productHandle&&(l.value={...l.value,loading:!0},n.storefront.loadProductId({productHandle:l.value.productHandle}).then(p=>{p.errors&&console.error("Error loading product id",p.errors),l.value={...l.value,productId:p.data?.product?.id?A(p.data.product.id):void 0,loading:!1}}))}),l},"itemContextSignal");var _n=i(n=>e=>{let t=F(()=>{let{productId:_,variantId:I,loading:q}=e.value;return!_||q?null:I?`variant:${A(I)}`:`product:${A(_)}`}),r=F(()=>e.value.loading||!!e.value.itemId||!e.value.productId),s=F(()=>({limit:1,query:t.value??void 0})),o=V(!r.value),a=V(null),u=V(!1),c=V(!1),{data:l,loading:p,error:f,refetching:y}=n.state.swishQuery(_=>n.api.items.list(_),{refetch:["item-create","item-update","item-delete"],variables:s,skip:r}),h=V(e.value.itemId??null);Q(()=>{re(()=>{if(o.value=p.value,a.value=f.value,!e.value.itemId){let _=l.value?.[0]?.id??null;_!==h.value&&(h.value=_)}})});async function x(){if(!h.value)return;u.value=!0;let I=await(await n.intents.invoke("unsave:item",{itemId:h.value})).complete;I.code==="ok"&&"itemId"in I.data&&(h.value=null),u.value=!1}i(x,"unsave");async function w(){if(!h.value)return;u.value=!0;let I=await(await n.intents.invoke("edit:item-lists",{itemId:h.value})).complete;I.code==="ok"&&"itemId"in I.data&&(h.value=null),u.value=!1}i(w,"update");async function O(){let{productId:_,variantId:I}=e.value;if(!_)return;u.value=!0,c.value=!0;let C=await(await n.intents.invoke("save:item",{productId:_,variantId:I})).complete;if(C.code==="ok"){let te=C.data;h.value=te.item.id,u.value=!1}else C.code==="error"&&console.warn("Failed to create item",C),re(()=>{u.value=!1,c.value=!1})}i(O,"save");let N=F(()=>o.value||u.value||e.value.loading);Q(()=>{c.value&&!u.value&&!y.value&&(c.value=!1)});let L=F(()=>{let _=y.value&&c.value,I=!!h.value,q=!I&&(u.value||_),C=I&&(u.value||_),te=F(()=>q?"saving":C?"unsaving":I?"saved":"unsaved");return{error:a.value,status:te.value,savedItemId:h.value,loading:N.value,submitting:u.value,saved:I,saving:q,unsaving:C}});async function G(){N.value||(L.value.saved&&L.value.savedItemId?x():L.value.saved||await O())}return i(G,"toggle"),Object.assign(L,{save:O,unsave:x,update:w,toggle:G})},"itemStateSignal");var On=i(n=>()=>{let{data:e,loading:t,error:r}=n.state.swishQuery(()=>n.api.items.count(),{refetch:["item-create","item-delete"]}),s=V(0),o=V(!0),a=V(null);return Q(()=>{re(()=>{o.value=t.value,a.value=r.value,s.value=e.value?.count??0})}),F(()=>({count:s.value,loading:o.value,error:a.value}))},"itemCountSignal");var Hs="token-update",Ln=i(n=>(e,t)=>{let r=V(null),s=V(null),o=V(null),a=V(!t?.skip),u=V(!1),c=F(()=>a.value&&u.value);async function l(){if(!t?.skip?.value)try{a.value=!0;let p=await e(t?.variables?.value);re(()=>{o.value="error"in p?p.error:null,r.value="data"in p?p.data:null,s.value="pageInfo"in p?p.pageInfo:null,a.value=!1,u.value=!0})}catch(p){re(()=>{o.value=p,a.value=!1,u.value=!0})}}return i(l,"executeFetch"),Q(()=>{if(l(),t?.refetch?.length){let p=[...t.refetch,Hs];return n.events.subscribe(p,l)}}),{data:r,pageInfo:s,error:o,loading:a,refetching:c}},"swishQuerySignals");var ue="GraphQL Client";var At="An error occurred while fetching from the API. Review 'graphQLErrors' for details.",Dt="Response returned unexpected Content-Type:",Pt="An unknown error has occurred. The API did not return a data object or any errors in its response.",ut={json:"application/json",multipart:"multipart/mixed"},Tt="X-SDK-Variant",_t="X-SDK-Version",Mn="shopify-graphql-client",Vn="1.4.1",ct=1e3,qn=[429,503],Ot=/@(defer)\b/i,$n=`\r
8
+ `,Nn=/boundary="?([^=";]+)"?/i,Lt=$n+$n;function Y(n,e=ue){return n.startsWith(`${e}`)?n:`${e}: ${n}`}i(Y,"formatErrorMessage");function ee(n){return n instanceof Error?n.message:JSON.stringify(n)}i(ee,"getErrorMessage");function $t(n){return n instanceof Error&&n.cause?n.cause:void 0}i($t,"getErrorCause");function Mt(n){return n.flatMap(({errors:e})=>e??[])}i(Mt,"combineErrors");function lt({client:n,retries:e}){if(e!==void 0&&(typeof e!="number"||e<0||e>3))throw new Error(`${n}: The provided "retries" value (${e}) is invalid - it cannot be less than ${0} or greater than ${3}`)}i(lt,"validateRetries");function U(n,e){return e&&(typeof e!="object"||Array.isArray(e)||typeof e=="object"&&Object.keys(e).length>0)?{[n]:e}:{}}i(U,"getKeyValueIfValid");function Vt(n,e){if(n.length===0)return e;let r={[n.pop()]:e};return n.length===0?r:Vt(n,r)}i(Vt,"buildDataObjectByPath");function Fn(n,e){return Object.keys(e||{}).reduce((t,r)=>(typeof e[r]=="object"||Array.isArray(e[r]))&&n[r]?(t[r]=Fn(n[r],e[r]),t):(t[r]=e[r],t),Array.isArray(n)?[...n]:{...n})}i(Fn,"combineObjects");function qt([n,...e]){return e.reduce(Fn,{...n})}i(qt,"buildCombinedDataObject");function Nt({clientLogger:n,customFetchApi:e=fetch,client:t=ue,defaultRetryWaitTime:r=ct,retriableCodes:s=qn}){let o=i(async(a,u,c)=>{let l=u+1,p=c+1,f;try{if(f=await e(...a),n({type:"HTTP-Response",content:{requestParams:a,response:f}}),!f.ok&&s.includes(f.status)&&l<=p)throw new Error;let y=f?.headers.get("X-Shopify-API-Deprecated-Reason")||"";return y&&n({type:"HTTP-Response-GraphQL-Deprecation-Notice",content:{requestParams:a,deprecationNotice:y}}),f}catch(y){if(l<=p){let h=f?.headers.get("Retry-After");return await Qs(h?parseInt(h,10):r),n({type:"HTTP-Retry",content:{requestParams:a,lastResponse:f,retryAttempt:u,maxRetries:c}}),o(a,l,c)}throw new Error(Y(`${c>0?`Attempted maximum number of ${c} network retries. Last message - `:""}${ee(y)}`,t))}},"httpFetch");return o}i(Nt,"generateHttpFetch");async function Qs(n){return new Promise(e=>setTimeout(e,n))}i(Qs,"sleep");function Bt({headers:n,url:e,customFetchApi:t=fetch,retries:r=0,logger:s}){lt({client:ue,retries:r});let o={headers:n,url:e,retries:r},a=zs(s),u=Nt({customFetchApi:t,clientLogger:a,defaultRetryWaitTime:ct}),c=Ws(u,o),l=Ks(c),p=ni(c);return{config:o,fetch:c,request:l,requestStream:p}}i(Bt,"createGraphQLClient");function zs(n){return e=>{n&&n(e)}}i(zs,"generateClientLogger");async function jn(n){let{errors:e,data:t,extensions:r}=await n.json();return{...U("data",t),...U("extensions",r),headers:n.headers,...e||!t?{errors:{networkStatusCode:n.status,message:Y(e?At:Pt),...U("graphQLErrors",e),response:n}}:{}}}i(jn,"processJSONResponse");function Ws(n,{url:e,headers:t,retries:r}){return async(s,o={})=>{let{variables:a,headers:u,url:c,retries:l,keepalive:p,signal:f}=o,y=JSON.stringify({query:s,variables:a});lt({client:ue,retries:l});let h=Object.entries({...t,...u}).reduce((w,[O,N])=>(w[O]=Array.isArray(N)?N.join(", "):N.toString(),w),{});return!h[Tt]&&!h[_t]&&(h[Tt]=Mn,h[_t]=Vn),n([c??e,{method:"POST",headers:h,body:y,signal:f,keepalive:p}],1,l??r)}}i(Ws,"generateFetch");function Ks(n){return async(...e)=>{if(Ot.test(e[0]))throw new Error(Y("This operation will result in a streamable response - use requestStream() instead."));let t=null;try{t=await n(...e);let{status:r,statusText:s}=t,o=t.headers.get("content-type")||"";return t.ok?o.includes(ut.json)?await jn(t):{errors:{networkStatusCode:r,message:Y(`${Dt} ${o}`),response:t}}:{errors:{networkStatusCode:r,message:Y(s),response:t}}}catch(r){return{errors:{message:ee(r),...t==null?{}:{networkStatusCode:t.status,response:t}}}}}}i(Ks,"generateRequest");async function*Xs(n){let e=new TextDecoder;if(n.body[Symbol.asyncIterator])for await(let t of n.body)yield e.decode(t);else{let t=n.body.getReader(),r;try{for(;!(r=await t.read()).done;)yield e.decode(r.value)}finally{t.cancel()}}}i(Xs,"getStreamBodyIterator");function Ys(n,e){return{async*[Symbol.asyncIterator](){try{let t="";for await(let r of n)if(t+=r,t.indexOf(e)>-1){let s=t.lastIndexOf(e),a=t.slice(0,s).split(e).filter(u=>u.trim().length>0).map(u=>u.slice(u.indexOf(Lt)+Lt.length).trim());a.length>0&&(yield a),t=t.slice(s+e.length),t.trim()==="--"&&(t="")}}catch(t){throw new Error(`Error occured while processing stream payload - ${ee(t)}`)}}}}i(Ys,"readStreamChunk");function Js(n){return{async*[Symbol.asyncIterator](){yield{...await jn(n),hasNext:!1}}}}i(Js,"createJsonResponseAsyncIterator");function Zs(n){return n.map(e=>{try{return JSON.parse(e)}catch(t){throw new Error(`Error in parsing multipart response - ${ee(t)}`)}}).map(e=>{let{data:t,incremental:r,hasNext:s,extensions:o,errors:a}=e;if(!r)return{data:t||{},...U("errors",a),...U("extensions",o),hasNext:s};let u=r.map(({data:c,path:l,errors:p})=>({data:c&&l?Vt(l,c):{},...U("errors",p)}));return{data:u.length===1?u[0].data:qt([...u.map(({data:c})=>c)]),...U("errors",Mt(u)),hasNext:s}})}i(Zs,"getResponseDataFromChunkBodies");function ei(n,e){if(n.length>0)throw new Error(At,{cause:{graphQLErrors:n}});if(Object.keys(e).length===0)throw new Error(Pt)}i(ei,"validateResponseData");function ti(n,e){let t=(e??"").match(Nn),r=`--${t?t[1]:"-"}`;if(!n.body?.getReader&&!n.body?.[Symbol.asyncIterator])throw new Error("API multipart response did not return an iterable body",{cause:n});let s=Xs(n),o={},a;return{async*[Symbol.asyncIterator](){try{let u=!0;for await(let c of Ys(s,r)){let l=Zs(c);a=l.find(f=>f.extensions)?.extensions??a;let p=Mt(l);o=qt([o,...l.map(({data:f})=>f)]),u=l.slice(-1)[0].hasNext,ei(p,o),yield{...U("data",o),...U("extensions",a),hasNext:u}}if(u)throw new Error("Response stream terminated unexpectedly")}catch(u){let c=$t(u);yield{...U("data",o),...U("extensions",a),errors:{message:Y(ee(u)),networkStatusCode:n.status,...U("graphQLErrors",c?.graphQLErrors),response:n},hasNext:!1}}}}}i(ti,"createMultipartResponseAsyncInterator");function ni(n){return async(...e)=>{if(!Ot.test(e[0]))throw new Error(Y("This operation does not result in a streamable response - use request() instead."));try{let t=await n(...e),{statusText:r}=t;if(!t.ok)throw new Error(r,{cause:t});let s=t.headers.get("content-type")||"";switch(!0){case s.includes(ut.json):return Js(t);case s.includes(ut.multipart):return ti(t,s);default:throw new Error(`${Dt} ${s}`,{cause:t})}}catch(t){return{async*[Symbol.asyncIterator](){let r=$t(t);yield{errors:{message:Y(ee(t)),...U("networkStatusCode",r?.status),...U("response",r)},hasNext:!1}}}}}}i(ni,"generateRequestStream");function Ut({client:n,storeDomain:e}){try{if(!e||typeof e!="string")throw new Error;let t=e.trim(),r=t.match(/^https?:/)?t:`https://${t}`,s=new URL(r);return s.protocol="https",s.origin}catch(t){throw new Error(`${n}: a valid store domain ("${e}") must be provided`,{cause:t})}}i(Ut,"validateDomainAndGetStoreUrl");function pt({client:n,currentSupportedApiVersions:e,apiVersion:t,logger:r}){let s=`${n}: the provided apiVersion ("${t}")`,o=`Currently supported API versions: ${e.join(", ")}`;if(!t||typeof t!="string")throw new Error(`${s} is invalid. ${o}`);let a=t.trim();e.includes(a)||(r?r({type:"Unsupported_Api_Version",content:{apiVersion:t,supportedApiVersions:e}}):console.warn(`${s} is likely deprecated or not supported. ${o}`))}i(pt,"validateApiVersion");function dt(n){let e=n*3-2;return e===10?e:`0${e}`}i(dt,"getQuarterMonth");function Ft(n,e,t){let r=e-t;return r<=0?`${n-1}-${dt(r+4)}`:`${n}-${dt(r)}`}i(Ft,"getPrevousVersion");function Gn(){let n=new Date,e=n.getUTCMonth(),t=n.getUTCFullYear(),r=Math.floor(e/3+1);return{year:t,quarter:r,version:`${t}-${dt(r)}`}}i(Gn,"getCurrentApiVersion");function jt(){let{year:n,quarter:e,version:t}=Gn(),r=e===4?`${n+1}-01`:`${n}-${dt(e+1)}`;return[Ft(n,e,3),Ft(n,e,2),Ft(n,e,1),t,r,"unstable"]}i(jt,"getCurrentSupportedApiVersions");function Gt(n){return e=>({...e??{},...n.headers})}i(Gt,"generateGetHeaders");function Ht({getHeaders:n,getApiUrl:e}){return(t,r)=>{let s=[t];if(r&&Object.keys(r).length>0){let{variables:o,apiVersion:a,headers:u,retries:c,signal:l}=r;s.push({...o?{variables:o}:{},...u?{headers:n(u)}:{},...a?{url:e(a)}:{},...c?{retries:c}:{},...l?{signal:l}:{}})}return s}}i(Ht,"generateGetGQLClientParams");var Qt="application/json",Hn="storefront-api-client",Qn="1.0.9",zn="X-Shopify-Storefront-Access-Token",Wn="Shopify-Storefront-Private-Token",Kn="X-SDK-Variant",Xn="X-SDK-Version",Yn="X-SDK-Variant-Source",ce="Storefront API Client";function Jn(n){if(n&&typeof window<"u")throw new Error(`${ce}: private access tokens and headers should only be used in a server-to-server implementation. Use the public API access token in nonserver environments.`)}i(Jn,"validatePrivateAccessTokenUsage");function Zn(n,e){if(!n&&!e)throw new Error(`${ce}: a public or private access token must be provided`);if(n&&e)throw new Error(`${ce}: only provide either a public or private access token`)}i(Zn,"validateRequiredAccessTokens");function zt({storeDomain:n,apiVersion:e,publicAccessToken:t,privateAccessToken:r,clientName:s,retries:o=0,customFetchApi:a,logger:u}){let c=jt(),l=Ut({client:ce,storeDomain:n}),p={client:ce,currentSupportedApiVersions:c,logger:u};pt({...p,apiVersion:e}),Zn(t,r),Jn(r);let f=ri(l,e,p),y={storeDomain:l,apiVersion:e,...t?{publicAccessToken:t}:{privateAccessToken:r},headers:{"Content-Type":Qt,Accept:Qt,[Kn]:Hn,[Xn]:Qn,...s?{[Yn]:s}:{},...t?{[zn]:t}:{[Wn]:r}},apiUrl:f(),clientName:s},h=Bt({headers:y.headers,url:y.apiUrl,retries:o,customFetchApi:a,logger:u}),x=Gt(y),w=si(y,f),O=Ht({getHeaders:x,getApiUrl:w});return Object.freeze({config:y,getHeaders:x,getApiUrl:w,fetch:i((...L)=>h.fetch(...O(...L)),"fetch"),request:i((...L)=>h.request(...O(...L)),"request"),requestStream:i((...L)=>h.requestStream(...O(...L)),"requestStream")})}i(zt,"createStorefrontApiClient");function ri(n,e,t){return r=>{r&&pt({...t,apiVersion:r});let s=(r??e).trim();return`${n}/api/${s}/graphql.json`}}i(ri,"generateApiUrlFormatter");function si(n,e){return t=>t?e(t):n.apiUrl}i(si,"generateGetApiUrl");var j=`
9
9
  fragment productImageFields on Image {
10
10
  id
11
11
  altText
12
12
  url
13
13
  thumbhash
14
14
  }
15
- `,Qt=`
15
+ `,Wt=`
16
16
  fragment saveIntentProductFields on Product {
17
17
  id
18
18
  availableForSale
@@ -37,7 +37,7 @@ Values:
37
37
  }
38
38
  title
39
39
  }
40
- `,ve=`
40
+ `,we=`
41
41
  fragment productCardDataFields on Product {
42
42
  id
43
43
  availableForSale
@@ -90,7 +90,7 @@ Values:
90
90
  value
91
91
  }
92
92
  }
93
- `,zt=`
93
+ `,Kt=`
94
94
  fragment productVariantDataFields on ProductVariant {
95
95
  id
96
96
  availableForSale
@@ -119,7 +119,7 @@ Values:
119
119
  value
120
120
  }
121
121
  }
122
- `,Wt=`
122
+ `,Xt=`
123
123
  fragment productOptionsVariantFields on ProductVariant {
124
124
  id
125
125
  selectedOptions {
@@ -127,7 +127,7 @@ Values:
127
127
  value
128
128
  }
129
129
  }
130
- `,Kt=`
130
+ `,Yt=`
131
131
  fragment selectedVariantFields on Product {
132
132
  id
133
133
  availableForSale
@@ -158,7 +158,7 @@ Values:
158
158
  }
159
159
  }
160
160
  }
161
- `,ce=`
161
+ `,le=`
162
162
  fragment productOptionsFields on Product {
163
163
  id
164
164
  availableForSale
@@ -194,7 +194,7 @@ Values:
194
194
  }
195
195
  }
196
196
  }
197
- `,Xt=`
197
+ `,Jt=`
198
198
  fragment productImagesFields on Product {
199
199
  images(first: 20) {
200
200
  nodes {
@@ -202,7 +202,7 @@ Values:
202
202
  }
203
203
  }
204
204
  }
205
- `;var Jn=`
205
+ `;var er=`
206
206
  query GetSaveIntentData(
207
207
  $productId: ID!
208
208
  $country: CountryCode!
@@ -212,9 +212,9 @@ Values:
212
212
  ...saveIntentProductFields
213
213
  }
214
214
  }
215
- ${Qt}
215
+ ${Wt}
216
216
  ${j}
217
- `,Zn=`
217
+ `,tr=`
218
218
  query GetSaveIntentDataWithVariant(
219
219
  $productId: ID!
220
220
  $variantId: ID!
@@ -228,9 +228,9 @@ Values:
228
228
  ...saveIntentVariantFields
229
229
  }
230
230
  }
231
- ${Qt}
231
+ ${Wt}
232
232
  ${j}
233
- `,er=`
233
+ `,nr=`
234
234
  query GetProductCardData(
235
235
  $productId: ID!
236
236
  $productMetafields: [HasMetafieldsIdentifier!]!
@@ -241,9 +241,9 @@ Values:
241
241
  ...productCardDataFields
242
242
  }
243
243
  }
244
- ${ve}
244
+ ${we}
245
245
  ${j}
246
- `,tr=`
246
+ `,rr=`
247
247
  query GetProductCardDataWithVariant(
248
248
  $productId: ID!
249
249
  $variantId: ID!
@@ -259,10 +259,10 @@ Values:
259
259
  ...productVariantDataFields
260
260
  }
261
261
  }
262
- ${ve}
263
- ${zt}
262
+ ${we}
263
+ ${Kt}
264
264
  ${j}
265
- `,nr=`
265
+ `,sr=`
266
266
  query GetProductOptions(
267
267
  $productId: ID!
268
268
  $country: CountryCode!
@@ -272,9 +272,9 @@ Values:
272
272
  ...productOptionsFields
273
273
  }
274
274
  }
275
- ${ce}
275
+ ${le}
276
276
  ${j}
277
- `,rr=`
277
+ `,ir=`
278
278
  query GetProductOptionsByHandle(
279
279
  $handle: String!
280
280
  $country: CountryCode!
@@ -284,9 +284,9 @@ Values:
284
284
  ...productOptionsFields
285
285
  }
286
286
  }
287
- ${ce}
287
+ ${le}
288
288
  ${j}
289
- `,sr=`
289
+ `,or=`
290
290
  query GetProductOptionsWithVariant(
291
291
  $productId: ID!
292
292
  $variantId: ID!
@@ -300,10 +300,10 @@ Values:
300
300
  ...productOptionsVariantFields
301
301
  }
302
302
  }
303
- ${ce}
304
- ${Wt}
303
+ ${le}
304
+ ${Xt}
305
305
  ${j}
306
- `,ir=`
306
+ `,ar=`
307
307
  query GetProductOptionsByHandleWithVariant(
308
308
  $handle: String!
309
309
  $variantId: ID!
@@ -317,10 +317,10 @@ Values:
317
317
  ...productOptionsVariantFields
318
318
  }
319
319
  }
320
- ${ce}
321
- ${Wt}
320
+ ${le}
321
+ ${Xt}
322
322
  ${j}
323
- `,or=`
323
+ `,ur=`
324
324
  query GetSelectedVariant(
325
325
  $productId: ID!
326
326
  $selectedOptions: [SelectedOptionInput!]!
@@ -331,9 +331,9 @@ Values:
331
331
  ...selectedVariantFields
332
332
  }
333
333
  }
334
- ${Kt}
334
+ ${Yt}
335
335
  ${j}
336
- `,ar=`
336
+ `,cr=`
337
337
  query GetSelectedVariantByHandle(
338
338
  $handle: String!
339
339
  $selectedOptions: [SelectedOptionInput!]!
@@ -344,9 +344,9 @@ Values:
344
344
  ...selectedVariantFields
345
345
  }
346
346
  }
347
- ${Kt}
347
+ ${Yt}
348
348
  ${j}
349
- `,ur=`
349
+ `,lr=`
350
350
  query GetProductDetailData(
351
351
  $productId: ID!
352
352
  $productMetafields: [HasMetafieldsIdentifier!]!
@@ -359,11 +359,11 @@ Values:
359
359
  ...productImagesFields
360
360
  }
361
361
  }
362
- ${ve}
363
- ${ce}
364
- ${Xt}
362
+ ${we}
363
+ ${le}
364
+ ${Jt}
365
365
  ${j}
366
- `,cr=`
366
+ `,pr=`
367
367
  query GetProductDetailDataWithVariant(
368
368
  $productId: ID!
369
369
  $variantId: ID!
@@ -381,12 +381,12 @@ Values:
381
381
  ...productVariantDataFields
382
382
  }
383
383
  }
384
- ${ve}
385
- ${ce}
386
- ${zt}
387
- ${Xt}
384
+ ${we}
385
+ ${le}
386
+ ${Kt}
387
+ ${Jt}
388
388
  ${j}
389
- `,lr=`
389
+ `,dr=`
390
390
  query GetProductImagesById(
391
391
  $ids: [ID!]!
392
392
  $country: CountryCode!
@@ -411,7 +411,7 @@ Values:
411
411
  }
412
412
  }
413
413
  ${j}
414
- `,pr=`
414
+ `,fr=`
415
415
  query GetProductRecommendationsById(
416
416
  $productId: ID!
417
417
  $intent: ProductRecommendationIntent
@@ -422,7 +422,7 @@ Values:
422
422
  id
423
423
  }
424
424
  }
425
- `,dr=`
425
+ `,hr=`
426
426
  query GetProductRecommendationsByHandle(
427
427
  $handle: String!
428
428
  $intent: ProductRecommendationIntent
@@ -433,17 +433,17 @@ Values:
433
433
  id
434
434
  }
435
435
  }
436
- `,fr=`
436
+ `,mr=`
437
437
  query GetProductIdByHandle($handle: String!) {
438
438
  product(handle: $handle) {
439
439
  id
440
440
  }
441
441
  }
442
- `;var hr=i(async(n,{productId:e,variantId:t,productMetafields:r=[],variantMetafields:s=[],country:o,language:a})=>{if(!e)throw new Error("A productId must be provided");let u=i(()=>{if(e&&!t)return er;if(e&&t)return tr},"getProductOptionsQuery"),c=i(()=>{if(e&&!t)return{productId:D("Product",e),productMetafields:r,country:o,language:a};if(e&&t)return{productId:D("Product",e),variantId:D("ProductVariant",t),productMetafields:r,variantMetafields:s,country:o,language:a}},"getVariables"),l=u(),p=c();if(!p||!l)throw new Error("Invalid query arguments");return n.query(l,p)},"loadProductCardData");var mr=i(async(n,{productId:e,variantId:t,productMetafields:r=[],variantMetafields:s=[],country:o,language:a})=>{if(!e)throw new Error("A productId must be provided");let u=i(()=>{if(e&&!t)return ur;if(e&&t)return cr},"getProductDetailDataQuery"),c=i(()=>{if(e&&!t)return{productId:D("Product",e),productMetafields:r,country:o,language:a};if(e&&t)return{productId:D("Product",e),variantId:D("ProductVariant",t),productMetafields:r,variantMetafields:s,country:o,language:a}},"getVariables"),l=u(),p=c();if(!p||!l)throw new Error("Invalid query arguments");return n.query(l,p)},"loadProductDetailData");var yr=i(async(n,{productHandle:e})=>{if(!e)throw new Error("A product handle must be provided");return n.query(fr,{handle:e})},"loadProductId");var vr=i(async(n,{items:e,country:t,language:r})=>{if(!e?.length)throw new Error("A list of items must be provided");let s={ids:e.map(o=>o.variantId?D("ProductVariant",o.variantId.toString()):D("Product",o.productId.toString())),country:t,language:r};try{return{data:(await n.query(lr,s)).data?.nodes.map(u=>u===null?null:"image"in u?u.image:"featuredImage"in u?u.featuredImage:null).filter(u=>u!==null)??[],error:null}}catch(o){return console.error(o),{data:null,error:o}}},"loadProductImages");var gr=i(async(n,{productId:e,productHandle:t,variantId:r,country:s,language:o})=>{if(!e&&!t)throw new Error("Either productId or handle must be provided");let a=i(()=>{if(e&&!r)return nr;if(t&&!r)return rr;if(e&&r)return sr;if(t&&r)return ir},"getProductOptionsQuery"),u=i(()=>{if(e&&!r)return{productId:D("Product",e),country:s,language:o};if(t&&!r)return{handle:t,country:s,language:o};if(e&&r)return{productId:D("Product",e),variantId:D("ProductVariant",r),country:s,language:o};if(t&&r)return{handle:t,variantId:D("ProductVariant",r),country:s,language:o}},"getVariables"),c=a(),l=u();if(!l||!c)throw new Error("Invalid query arguments");return n.query(c,l)},"loadProductOptions");var wr=i(async(n,{productId:e,productHandle:t,intent:r,country:s,language:o})=>{if(!e&&!t)throw new Error("Either productId or productHandle must be provided");if(e){let u={productId:D("Product",e),intent:r,country:s,language:o};return n.query(pr,u)}let a={handle:t,intent:r,country:s,language:o};return n.query(dr,a)},"loadProductRecommendations");var Ir=i(async(n,{productId:e,variantId:t,country:r,language:s})=>{let o=i(()=>{if(e&&!t)return Jn;if(e&&t)return Zn},"getProductOptionsQuery"),a=i(()=>{if(e&&!t)return{productId:D("Product",A(e)),country:r,language:s};if(e&&t)return{productId:D("Product",A(e)),variantId:D("ProductVariant",A(t)),country:r,language:s}},"getVariables"),u=o(),c=a();if(!c||!u)throw new Error("Invalid query arguments");return n.query(u,c)},"loadSaveIntentData");var br=i(async(n,{productId:e,productHandle:t,selectedOptions:r,country:s,language:o})=>{if(!e&&!t)throw new Error("Either productId or handle must be provided");let a=e?or:ar,u=e?{productId:`gid://shopify/Product/${e}`,selectedOptions:r,country:s,language:o}:{handle:t,selectedOptions:r,country:s,language:o};return n.query(a,u)},"loadSelectedVariant");var Js="2026-01",Zs=["GetProductIdByHandle"],ct=class{constructor(e,t,r,s,o){this.client=null;this.query=i(async(e,t)=>{if(!this.client)throw new Error("Storefront API client not initialized");let r=await this.client.request(e,{variables:t});return{data:r.data,errors:r.errors??null}},"query");this.loadProductOptions=i(async e=>gr(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}),"loadProductOptions");this.loadSelectedVariant=i(async e=>br(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}),"loadSelectedVariant");this.loadProductCardData=i(async e=>hr(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}).then(t=>t.data?"variant"in t.data?{...t,data:{...t.data,badges:this.badges.getBadges({product:t.data.product,variant:t.data.variant})}}:{...t,data:{...t.data,badges:this.badges.getBadges({product:t.data.product})}}:t),"loadProductCardData");this.loadProductDetailData=i(async e=>mr(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}).then(t=>{if(!t.data)return t;let r=t.data.product;return"variant"in t.data?{...t,data:{...t.data,badges:this.badges.getBadges({product:r,variant:t.data.variant})}}:{...t,data:{...t.data,badges:this.badges.getBadges({product:r})}}}),"loadProductDetailData");this.loadProductImages=i(async e=>vr(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}),"loadProductImages");this.loadProductRecommendations=i(async e=>wr(this,{...e,country:this.context.localization.country,language:this.context.localization.language}),"loadProductRecommendations");this.loadProductId=i(async e=>yr(this,e),"loadProductId");this.loadSaveIntentData=i(async e=>Ir(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}),"loadSaveIntentData");this.options=e,this.context=t,this.badges=r,this.productOptions=s,this.metafields={productMetafields:o?.product.map(u=>({namespace:u.split(".")[0],key:u.split(".")[1]}))??[],variantMetafields:o?.productVariant.map(u=>({namespace:u.split(".")[0],key:u.split(".")[1]}))??[]};let a=H(t.myshopifyDomain);this.shortCache=new Y(`storefront-api-short-${a}`,"max-age=60, stale-while-revalidate=3600"),this.longCache=new Y(`storefront-api-long-${a}`,"max-age=3600, stale-while-revalidate=86400"),this.shortCache.cleanupExpiredEntries().catch(u=>{console.warn("Storefront API cache initialization cleanup error:",u)}),this.longCache.cleanupExpiredEntries().catch(u=>{console.warn("Storefront API cache initialization cleanup error:",u)}),this.client=Ht({apiVersion:Js,customFetchApi:i((u,c)=>c?.method==="OPTIONS"?this.fetch(u,c):Zs.some(l=>c?.body?.toString().includes(`query ${l}`))?this.longCache.fetchWithCache(u,c):this.shortCache.fetchWithCache(u,c),"customFetchApi"),publicAccessToken:this.options.accessToken,storeDomain:this.options.storeDomain})}static{i(this,"StorefrontApiClient")}fetch(e,t){return t?.method==="OPTIONS"?fetch(e,t):this.shortCache.fetchWithCache(e,t)}async clearCache(){await this.shortCache.clear()}};var ei=Object.defineProperty,d=i((n,e)=>ei(n,"name",{value:e,configurable:!0}),"n"),ti={bodySerializer:d(n=>JSON.stringify(n,(e,t)=>typeof t=="bigint"?t.toString():t),"bodySerializer")},ni={$body_:"body",$headers_:"headers",$path_:"path",$query_:"query"},Lp=Object.entries(ni),ri=d(({onRequest:n,onSseError:e,onSseEvent:t,responseTransformer:r,responseValidator:s,sseDefaultRetryDelay:o,sseMaxRetryAttempts:a,sseMaxRetryDelay:u,sseSleepFn:c,url:l,...p})=>{let f,y=c??(h=>new Promise(b=>setTimeout(b,h)));return{stream:d(async function*(){let h=o??3e3,b=0,g=p.signal??new AbortController().signal;for(;!g.aborted;){b++;let O=p.headers instanceof Headers?p.headers:new Headers(p.headers);f!==void 0&&O.set("Last-Event-ID",f);try{let N={redirect:"follow",...p,body:p.serializedBody,headers:O,signal:g},L=new Request(l,N);n&&(L=await n(l,N));let G=await(p.fetch??globalThis.fetch)(L);if(!G.ok)throw new Error(`SSE failed: ${G.status} ${G.statusText}`);if(!G.body)throw new Error("No body in SSE response");let T=G.body.pipeThrough(new TextDecoderStream).getReader(),I="",M=d(()=>{try{T.cancel()}catch{}},"abortHandler");g.addEventListener("abort",M);try{for(;;){let{done:k,value:ee}=await T.read();if(k)break;I+=ee;let sn=I.split(`
442
+ `;var yr=i(async(n,{productId:e,variantId:t,productMetafields:r=[],variantMetafields:s=[],country:o,language:a})=>{if(!e)throw new Error("A productId must be provided");let u=i(()=>{if(e&&!t)return nr;if(e&&t)return rr},"getProductOptionsQuery"),c=i(()=>{if(e&&!t)return{productId:D("Product",e),productMetafields:r,country:o,language:a};if(e&&t)return{productId:D("Product",e),variantId:D("ProductVariant",t),productMetafields:r,variantMetafields:s,country:o,language:a}},"getVariables"),l=u(),p=c();if(!p||!l)throw new Error("Invalid query arguments");return n.query(l,p)},"loadProductCardData");var vr=i(async(n,{productId:e,variantId:t,productMetafields:r=[],variantMetafields:s=[],country:o,language:a})=>{if(!e)throw new Error("A productId must be provided");let u=i(()=>{if(e&&!t)return lr;if(e&&t)return pr},"getProductDetailDataQuery"),c=i(()=>{if(e&&!t)return{productId:D("Product",e),productMetafields:r,country:o,language:a};if(e&&t)return{productId:D("Product",e),variantId:D("ProductVariant",t),productMetafields:r,variantMetafields:s,country:o,language:a}},"getVariables"),l=u(),p=c();if(!p||!l)throw new Error("Invalid query arguments");return n.query(l,p)},"loadProductDetailData");var gr=i(async(n,{productHandle:e})=>{if(!e)throw new Error("A product handle must be provided");return n.query(mr,{handle:e})},"loadProductId");var wr=i(async(n,{items:e,country:t,language:r})=>{if(!e?.length)throw new Error("A list of items must be provided");let s={ids:e.map(o=>o.variantId?D("ProductVariant",o.variantId.toString()):D("Product",o.productId.toString())),country:t,language:r};try{return{data:(await n.query(dr,s)).data?.nodes.map(u=>u===null?null:"image"in u?u.image:"featuredImage"in u?u.featuredImage:null).filter(u=>u!==null)??[],error:null}}catch(o){return console.error(o),{data:null,error:o}}},"loadProductImages");var Ir=i(async(n,{productId:e,productHandle:t,variantId:r,country:s,language:o})=>{if(!e&&!t)throw new Error("Either productId or handle must be provided");let a=i(()=>{if(e&&!r)return sr;if(t&&!r)return ir;if(e&&r)return or;if(t&&r)return ar},"getProductOptionsQuery"),u=i(()=>{if(e&&!r)return{productId:D("Product",e),country:s,language:o};if(t&&!r)return{handle:t,country:s,language:o};if(e&&r)return{productId:D("Product",e),variantId:D("ProductVariant",r),country:s,language:o};if(t&&r)return{handle:t,variantId:D("ProductVariant",r),country:s,language:o}},"getVariables"),c=a(),l=u();if(!l||!c)throw new Error("Invalid query arguments");return n.query(c,l)},"loadProductOptions");var br=i(async(n,{productId:e,productHandle:t,intent:r,country:s,language:o})=>{if(!e&&!t)throw new Error("Either productId or productHandle must be provided");if(e){let u={productId:D("Product",e),intent:r,country:s,language:o};return n.query(fr,u)}let a={handle:t,intent:r,country:s,language:o};return n.query(hr,a)},"loadProductRecommendations");var Sr=i(async(n,{productId:e,variantId:t,country:r,language:s})=>{let o=i(()=>{if(e&&!t)return er;if(e&&t)return tr},"getProductOptionsQuery"),a=i(()=>{if(e&&!t)return{productId:D("Product",A(e)),country:r,language:s};if(e&&t)return{productId:D("Product",A(e)),variantId:D("ProductVariant",A(t)),country:r,language:s}},"getVariables"),u=o(),c=a();if(!c||!u)throw new Error("Invalid query arguments");return n.query(u,c)},"loadSaveIntentData");var Er=i(async(n,{productId:e,productHandle:t,selectedOptions:r,country:s,language:o})=>{if(!e&&!t)throw new Error("Either productId or handle must be provided");let a=e?ur:cr,u=e?{productId:`gid://shopify/Product/${e}`,selectedOptions:r,country:s,language:o}:{handle:t,selectedOptions:r,country:s,language:o};return n.query(a,u)},"loadSelectedVariant");var ii="2026-01",oi=["GetProductIdByHandle"],ft=class{constructor(e,t,r,s,o){this.client=null;this.query=i(async(e,t)=>{if(!this.client)throw new Error("Storefront API client not initialized");let r=await this.client.request(e,{variables:t});return{data:r.data,errors:r.errors??null}},"query");this.loadProductOptions=i(async e=>Ir(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}),"loadProductOptions");this.loadSelectedVariant=i(async e=>Er(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}),"loadSelectedVariant");this.loadProductCardData=i(async e=>yr(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}).then(t=>t.data?"variant"in t.data?{...t,data:{...t.data,badges:this.badges.getBadges({product:t.data.product,variant:t.data.variant})}}:{...t,data:{...t.data,badges:this.badges.getBadges({product:t.data.product})}}:t),"loadProductCardData");this.loadProductDetailData=i(async e=>vr(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}).then(t=>{if(!t.data)return t;let r=t.data.product;return"variant"in t.data?{...t,data:{...t.data,badges:this.badges.getBadges({product:r,variant:t.data.variant})}}:{...t,data:{...t.data,badges:this.badges.getBadges({product:r})}}}),"loadProductDetailData");this.loadProductImages=i(async e=>wr(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}),"loadProductImages");this.loadProductRecommendations=i(async e=>br(this,{...e,country:this.context.localization.country,language:this.context.localization.language}),"loadProductRecommendations");this.loadProductId=i(async e=>gr(this,e),"loadProductId");this.loadSaveIntentData=i(async e=>Sr(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}),"loadSaveIntentData");this.options=e,this.context=t,this.badges=r,this.productOptions=s,this.metafields={productMetafields:o?.product.map(u=>({namespace:u.split(".")[0],key:u.split(".")[1]}))??[],variantMetafields:o?.productVariant.map(u=>({namespace:u.split(".")[0],key:u.split(".")[1]}))??[]};let a=H(t.myshopifyDomain);this.shortCache=new J(`storefront-api-short-${a}`,"max-age=60, stale-while-revalidate=3600"),this.longCache=new J(`storefront-api-long-${a}`,"max-age=3600, stale-while-revalidate=86400"),this.shortCache.cleanupExpiredEntries().catch(u=>{console.warn("Storefront API cache initialization cleanup error:",u)}),this.longCache.cleanupExpiredEntries().catch(u=>{console.warn("Storefront API cache initialization cleanup error:",u)}),this.client=zt({apiVersion:ii,customFetchApi:i((u,c)=>c?.method==="OPTIONS"?this.fetch(u,c):oi.some(l=>c?.body?.toString().includes(`query ${l}`))?this.longCache.fetchWithCache(u,c):this.shortCache.fetchWithCache(u,c),"customFetchApi"),publicAccessToken:this.options.accessToken,storeDomain:this.options.storeDomain})}static{i(this,"StorefrontApiClient")}fetch(e,t){return t?.method==="OPTIONS"?fetch(e,t):this.shortCache.fetchWithCache(e,t)}async clearCache(){await this.shortCache.clear()}};var ai=Object.defineProperty,d=i((n,e)=>ai(n,"name",{value:e,configurable:!0}),"n"),ui={bodySerializer:d(n=>JSON.stringify(n,(e,t)=>typeof t=="bigint"?t.toString():t),"bodySerializer")},ci={$body_:"body",$headers_:"headers",$path_:"path",$query_:"query"},Xp=Object.entries(ci),li=d(({onRequest:n,onSseError:e,onSseEvent:t,responseTransformer:r,responseValidator:s,sseDefaultRetryDelay:o,sseMaxRetryAttempts:a,sseMaxRetryDelay:u,sseSleepFn:c,url:l,...p})=>{let f,y=c??(h=>new Promise(x=>setTimeout(x,h)));return{stream:d(async function*(){let h=o??3e3,x=0,w=p.signal??new AbortController().signal;for(;!w.aborted;){x++;let O=p.headers instanceof Headers?p.headers:new Headers(p.headers);f!==void 0&&O.set("Last-Event-ID",f);try{let N={redirect:"follow",...p,body:p.serializedBody,headers:O,signal:w},L=new Request(l,N);n&&(L=await n(l,N));let G=await(p.fetch??globalThis.fetch)(L);if(!G.ok)throw new Error(`SSE failed: ${G.status} ${G.statusText}`);if(!G.body)throw new Error("No body in SSE response");let _=G.body.pipeThrough(new TextDecoderStream).getReader(),I="",q=d(()=>{try{_.cancel()}catch{}},"abortHandler");w.addEventListener("abort",q);try{for(;;){let{done:C,value:te}=await _.read();if(C)break;I+=te;let an=I.split(`
443
443
 
444
- `);I=sn.pop()??"";for(let Vr of sn){let qr=Vr.split(`
445
- `),ge=[],on;for(let W of qr)if(W.startsWith("data:"))ge.push(W.replace(/^data:\s*/,""));else if(W.startsWith("event:"))on=W.replace(/^event:\s*/,"");else if(W.startsWith("id:"))f=W.replace(/^id:\s*/,"");else if(W.startsWith("retry:")){let un=Number.parseInt(W.replace(/^retry:\s*/,""),10);Number.isNaN(un)||(h=un)}let se,an=!1;if(ge.length){let W=ge.join(`
446
- `);try{se=JSON.parse(W),an=!0}catch{se=W}}an&&(s&&await s(se),r&&(se=await r(se))),t?.({data:se,event:on,id:f,retry:h}),ge.length&&(yield se)}}}finally{g.removeEventListener("abort",M),T.releaseLock()}break}catch(N){if(e?.(N),a!==void 0&&b>=a)break;let L=Math.min(h*2**(b-1),u??3e4);await y(L)}}},"createStream")()}},"createSseClient"),si=d(n=>{switch(n){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorArrayExplode"),ii=d(n=>{switch(n){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},"separatorArrayNoExplode"),oi=d(n=>{switch(n){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorObjectExplode"),xr=d(({allowReserved:n,explode:e,name:t,style:r,value:s})=>{if(!e){let u=(n?s:s.map(c=>encodeURIComponent(c))).join(ii(r));switch(r){case"label":return`.${u}`;case"matrix":return`;${t}=${u}`;case"simple":return u;default:return`${t}=${u}`}}let o=si(r),a=s.map(u=>r==="label"||r==="simple"?n?u:encodeURIComponent(u):pt({allowReserved:n,name:t,value:u})).join(o);return r==="label"||r==="matrix"?o+a:a},"serializeArrayParam"),pt=d(({allowReserved:n,name:e,value:t})=>{if(t==null)return"";if(typeof t=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${e}=${n?t:encodeURIComponent(t)}`},"serializePrimitiveParam"),Cr=d(({allowReserved:n,explode:e,name:t,style:r,value:s,valueOnly:o})=>{if(s instanceof Date)return o?s.toISOString():`${t}=${s.toISOString()}`;if(r!=="deepObject"&&!e){let c=[];Object.entries(s).forEach(([p,f])=>{c=[...c,p,n?f:encodeURIComponent(f)]});let l=c.join(",");switch(r){case"form":return`${t}=${l}`;case"label":return`.${l}`;case"matrix":return`;${t}=${l}`;default:return l}}let a=oi(r),u=Object.entries(s).map(([c,l])=>pt({allowReserved:n,name:r==="deepObject"?`${t}[${c}]`:c,value:l})).join(a);return r==="label"||r==="matrix"?a+u:u},"serializeObjectParam"),ai=/\{[^{}]+\}/g,ui=d(({path:n,url:e})=>{let t=e,r=e.match(ai);if(r)for(let s of r){let o=!1,a=s.substring(1,s.length-1),u="simple";a.endsWith("*")&&(o=!0,a=a.substring(0,a.length-1)),a.startsWith(".")?(a=a.substring(1),u="label"):a.startsWith(";")&&(a=a.substring(1),u="matrix");let c=n[a];if(c==null)continue;if(Array.isArray(c)){t=t.replace(s,xr({explode:o,name:a,style:u,value:c}));continue}if(typeof c=="object"){t=t.replace(s,Cr({explode:o,name:a,style:u,value:c,valueOnly:!0}));continue}if(u==="matrix"){t=t.replace(s,`;${pt({name:a,value:c})}`);continue}let l=encodeURIComponent(u==="label"?`.${c}`:c);t=t.replace(s,l)}return t},"defaultPathSerializer"),ci=d(({baseUrl:n,path:e,query:t,querySerializer:r,url:s})=>{let o=s.startsWith("/")?s:`/${s}`,a=(n??"")+o;e&&(a=ui({path:e,url:a}));let u=t?r(t):"";return u.startsWith("?")&&(u=u.substring(1)),u&&(a+=`?${u}`),a},"getUrl");function kr(n){let e=n.body!==void 0;if(e&&n.bodySerializer)return"serializedBody"in n?n.serializedBody!==void 0&&n.serializedBody!==""?n.serializedBody:null:n.body!==""?n.body:null;if(e)return n.body}i(kr,"K");d(kr,"getValidRequestBody");var li=d(async(n,e)=>{let t=typeof e=="function"?await e(n):e;if(t)return n.scheme==="bearer"?`Bearer ${t}`:n.scheme==="basic"?`Basic ${btoa(t)}`:t},"getAuthToken"),Rr=d(({allowReserved:n,array:e,object:t}={})=>d(r=>{let s=[];if(r&&typeof r=="object")for(let o in r){let a=r[o];if(a!=null)if(Array.isArray(a)){let u=xr({allowReserved:n,explode:!0,name:o,style:"form",value:a,...e});u&&s.push(u)}else if(typeof a=="object"){let u=Cr({allowReserved:n,explode:!0,name:o,style:"deepObject",value:a,...t});u&&s.push(u)}else{let u=pt({allowReserved:n,name:o,value:a});u&&s.push(u)}}return s.join("&")},"querySerializer"),"createQuerySerializer"),pi=d(n=>{var e;if(!n)return"stream";let t=(e=n.split(";")[0])==null?void 0:e.trim();if(t){if(t.startsWith("application/json")||t.endsWith("+json"))return"json";if(t==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some(r=>t.startsWith(r)))return"blob";if(t.startsWith("text/"))return"text"}},"getParseAs"),di=d((n,e)=>{var t,r;return e?!!(n.headers.has(e)||(t=n.query)!=null&&t[e]||(r=n.headers.get("Cookie"))!=null&&r.includes(`${e}=`)):!1},"checkForExistence"),fi=d(async({security:n,...e})=>{for(let t of n){if(di(e,t.name))continue;let r=await li(t,e.auth);if(!r)continue;let s=t.name??"Authorization";switch(t.in){case"query":e.query||(e.query={}),e.query[s]=r;break;case"cookie":e.headers.append("Cookie",`${s}=${r}`);break;case"header":default:e.headers.set(s,r);break}}},"setAuthParams"),Sr=d(n=>ci({baseUrl:n.baseUrl,path:n.path,query:n.query,querySerializer:typeof n.querySerializer=="function"?n.querySerializer:Rr(n.querySerializer),url:n.url}),"buildUrl"),Er=d((n,e)=>{var t;let r={...n,...e};return(t=r.baseUrl)!=null&&t.endsWith("/")&&(r.baseUrl=r.baseUrl.substring(0,r.baseUrl.length-1)),r.headers=Ar(n.headers,e.headers),r},"mergeConfigs"),hi=d(n=>{let e=[];return n.forEach((t,r)=>{e.push([r,t])}),e},"headersEntries"),Ar=d((...n)=>{let e=new Headers;for(let t of n){if(!t)continue;let r=t instanceof Headers?hi(t):Object.entries(t);for(let[s,o]of r)if(o===null)e.delete(s);else if(Array.isArray(o))for(let a of o)e.append(s,a);else o!==void 0&&e.set(s,typeof o=="object"?JSON.stringify(o):o)}return e},"mergeHeaders"),Dr=class{static{i(this,"$")}constructor(){this.fns=[]}clear(){this.fns=[]}eject(e){let t=this.getInterceptorIndex(e);this.fns[t]&&(this.fns[t]=null)}exists(e){let t=this.getInterceptorIndex(e);return!!this.fns[t]}getInterceptorIndex(e){return typeof e=="number"?this.fns[e]?e:-1:this.fns.indexOf(e)}update(e,t){let r=this.getInterceptorIndex(e);return this.fns[r]?(this.fns[r]=t,e):!1}use(e){return this.fns.push(e),this.fns.length-1}};d(Dr,"Interceptors");var Yt=Dr,mi=d(()=>({error:new Yt,request:new Yt,response:new Yt}),"createInterceptors"),yi=Rr({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),vi={"Content-Type":"application/json"},lt=d((n={})=>({...ti,headers:vi,parseAs:"auto",querySerializer:yi,...n}),"createConfig"),Jt=d((n={})=>{let e=Er(lt(),n),t=d(()=>({...e}),"getConfig"),r=d(l=>(e=Er(e,l),t()),"setConfig"),s=mi(),o=d(async l=>{let p={...e,...l,fetch:l.fetch??e.fetch??globalThis.fetch,headers:Ar(e.headers,l.headers),serializedBody:void 0};p.security&&await fi({...p,security:p.security}),p.requestValidator&&await p.requestValidator(p),p.body!==void 0&&p.bodySerializer&&(p.serializedBody=p.bodySerializer(p.body)),(p.body===void 0||p.serializedBody==="")&&p.headers.delete("Content-Type");let f=Sr(p);return{opts:p,url:f}},"beforeRequest"),a=d(async l=>{let{opts:p,url:f}=await o(l),y={redirect:"follow",...p,body:kr(p)},h=new Request(f,y);for(let I of s.request.fns)I&&(h=await I(h,p));let b=p.fetch,g=await b(h);for(let I of s.response.fns)I&&(g=await I(g,h,p));let O={request:h,response:g};if(g.ok){let I=(p.parseAs==="auto"?pi(g.headers.get("Content-Type")):p.parseAs)??"json";if(g.status===204||g.headers.get("Content-Length")==="0"){let k;switch(I){case"arrayBuffer":case"blob":case"text":k=await g[I]();break;case"formData":k=new FormData;break;case"stream":k=g.body;break;case"json":default:k={};break}return p.responseStyle==="data"?k:{data:k,...O}}let M;switch(I){case"arrayBuffer":case"blob":case"formData":case"json":case"text":M=await g[I]();break;case"stream":return p.responseStyle==="data"?g.body:{data:g.body,...O}}return I==="json"&&(p.responseValidator&&await p.responseValidator(M),p.responseTransformer&&(M=await p.responseTransformer(M))),p.responseStyle==="data"?M:{data:M,...O}}let N=await g.text(),L;try{L=JSON.parse(N)}catch{}let G=L??N,T=G;for(let I of s.error.fns)I&&(T=await I(G,g,h,p));if(T=T||{},p.throwOnError)throw T;return p.responseStyle==="data"?void 0:{error:T,...O}},"request"),u=d(l=>p=>a({...p,method:l}),"makeMethodFn"),c=d(l=>async p=>{let{opts:f,url:y}=await o(p);return ri({...f,body:f.body,headers:f.headers,method:l,onRequest:d(async(h,b)=>{let g=new Request(h,b);for(let O of s.request.fns)O&&(g=await O(g,f));return g},"onRequest"),url:y})},"makeSseFn");return{buildUrl:Sr,connect:u("CONNECT"),delete:u("DELETE"),get:u("GET"),getConfig:t,head:u("HEAD"),interceptors:s,options:u("OPTIONS"),patch:u("PATCH"),post:u("POST"),put:u("PUT"),request:a,setConfig:r,sse:{connect:c("CONNECT"),delete:c("DELETE"),get:c("GET"),head:c("HEAD"),options:c("OPTIONS"),patch:c("PATCH"),post:c("POST"),put:c("PUT"),trace:c("TRACE")},trace:u("TRACE")}},"createClient"),R=Jt(lt({baseUrl:"https://swish.app/api/2026-01"})),gi=d(n=>(n?.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/lists",...n}),"listControllerFind"),wi=d(n=>(n.client??R).post({security:[{scheme:"bearer",type:"http"}],url:"/lists",...n,headers:{"Content-Type":"application/json",...n.headers}}),"listControllerCreate"),Ii=d(n=>(n.client??R).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...n}),"listControllerDeleteById"),bi=d(n=>(n.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...n}),"listControllerFindById"),Si=d(n=>(n.client??R).patch({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...n,headers:{"Content-Type":"application/json",...n.headers}}),"listControllerUpdateById"),Ei=d(n=>(n.client??R).put({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/order",...n,headers:{"Content-Type":"application/json",...n.headers}}),"listControllerSetListItemsOrder"),xi=d(n=>(n.client??R).post({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items",...n,headers:{"Content-Type":"application/json",...n.headers}}),"listControllerAddItemsToList"),Ci=d(n=>(n.client??R).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/{itemId}",...n}),"listControllerRemoveItemFromList"),ki=d(n=>(n.client??R).delete({security:[{scheme:"bearer",type:"http"}],url:"/items",...n,headers:{"Content-Type":"application/json",...n.headers}}),"itemControllerDelete"),Ri=d(n=>(n?.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/items",...n}),"itemControllerFind"),Ai=d(n=>(n.client??R).post({security:[{scheme:"bearer",type:"http"}],url:"/items",...n,headers:{"Content-Type":"application/json",...n.headers}}),"itemControllerCreate"),Di=d(n=>(n?.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/items/count",...n}),"itemControllerCount"),Pi=d(n=>(n.client??R).delete({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...n}),"itemControllerDeleteById"),Ti=d(n=>(n.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...n}),"itemControllerFindById"),_i=d(n=>(n.client??R).patch({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...n,headers:{"Content-Type":"application/json",...n.headers}}),"itemControllerUpdateById"),Oi=d(n=>(n.client??R).put({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}/lists",...n,headers:{"Content-Type":"application/json",...n.headers}}),"itemControllerSetListsById"),Li=d(n=>(n.client??R).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/identify",...n,headers:{"Content-Type":"application/json",...n.headers}}),"profileControllerIdentify"),$i=d(n=>(n.client??R).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/token",...n,headers:{"Content-Type":"application/json",...n.headers}}),"profileControllerCreateToken"),Mi=d(n=>(n?.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/profiles",...n}),"profileControllerGetProfile"),Vi=d(n=>(n.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/saved-items",...n}),"analyticsControllerLoadSavedItems"),qi=d(n=>(n.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/sessions",...n}),"analyticsControllerLoadSessions"),Ni=d(n=>(n.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/new-lists",...n}),"analyticsControllerLoadNewLists"),Bi=d(n=>(n.client??R).post({security:[{scheme:"bearer",type:"http"}],url:"/tracking",...n,headers:{"Content-Type":"application/json",...n.headers}}),"trackingControllerTrack"),Ui=d(n=>(n?.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/orders",...n}),"ordersControllerFind"),Fi=d(n=>(n.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/orders/{orderId}",...n}),"ordersControllerFindOne"),ji=d(n=>(n.client??R).post({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{listId}/save",...n}),"sharedListsControllerSave"),Gi=d(n=>(n.client??R).delete({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{listId}",...n}),"sharedListsControllerDeleteById"),Hi=d(n=>(n.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{listId}",...n}),"sharedListsControllerFindById"),Qi=d(n=>(n?.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists",...n}),"sharedListsControllerFindAll"),Zt="2026-01",Pr=d(n=>new zi(n),"createApiClient"),Tr=class{static{i(this,"H")}constructor(e){this.version=Zt,this.items={list:d(u=>this.handlePaginatedRequest(Ri({query:u,client:this.directClient})),"list"),create:d(u=>this.handleRequest(Ai({body:u,client:this.directClient})),"create"),delete:d(u=>this.handleRequest(ki({body:{itemIds:u},client:this.directClient})),"delete"),findById:d(u=>this.handleRequest(Ti({path:{itemId:u},client:this.directClient})),"findById"),updateById:d((u,c)=>this.handleRequest(_i({body:c,path:{itemId:u},client:this.directClient})),"updateById"),deleteById:d(u=>this.handleRequest(Pi({path:{itemId:u},client:this.directClient})),"deleteById"),setListsById:d((u,c)=>this.handleRequest(Oi({body:{listIds:c},path:{itemId:u},client:this.directClient})),"setListsById"),count:d(()=>this.handleRequest(Di({client:this.directClient})),"count")},this.lists={list:d(u=>this.handlePaginatedRequest(gi({query:u,client:this.directClient})),"list"),create:d(u=>this.handleRequest(wi({body:u,client:this.directClient})),"create"),findById:d(u=>this.handleRequest(bi({path:{listId:u},client:this.directClient})),"findById"),updateById:d((u,c)=>this.handleRequest(Si({body:c,path:{listId:u},client:this.directClient})),"updateById"),deleteById:d(u=>this.handleRequest(Ii({path:{listId:u},client:this.directClient})),"deleteById"),orderItems:d((u,c)=>this.handleRequest(Ei({body:{itemIds:c},path:{listId:u},client:this.directClient})),"orderItems"),addItemsToList:d((u,c)=>this.handleRequest(xi({body:{itemIds:c},path:{listId:u},client:this.directClient})),"addItemsToList"),removeItemFromList:d((u,c)=>this.handleRequest(Ci({path:{listId:u,itemId:c},client:this.directClient})),"removeItemFromList")},this.profiles={createToken:d((u={})=>this.handleRequest($i({body:u,client:this.proxyClient??this.directClient})),"createToken"),identify:d(u=>this.handleRequest(Li({body:u,client:this.directClient})),"identify"),getProfile:d(()=>this.handleRequest(Mi({client:this.directClient})),"getProfile")},this.orders={list:d(u=>this.handlePaginatedRequest(Ui({query:u,client:this.directClient})),"list"),findById:d(u=>this.handleRequest(Fi({path:{orderId:u},client:this.directClient})),"findById")},this.sharedLists={list:d(u=>this.handlePaginatedRequest(Qi({query:u,client:this.directClient})),"list"),save:d(u=>this.handleRequest(ji({path:{listId:u},client:this.directClient})),"save"),findById:d(u=>this.handleRequest(Hi({path:{listId:u},client:this.directClient})),"findById"),deleteById:d(u=>this.handleRequest(Gi({path:{listId:u},client:this.directClient})),"deleteById")},this.analytics={savedItems:d(u=>this.handleRequest(Vi({query:u,client:this.directClient})),"savedItems"),sessions:d(u=>this.handleRequest(qi({query:u,client:this.directClient})),"sessions"),newLists:d(u=>this.handleRequest(Ni({query:u,client:this.directClient})),"newLists")},this.tracking={track:d((u,c)=>this.handleRequest(Bi({body:u,headers:c,client:this.directClient})),"track")},this.handleRequest=d(async u=>{let{data:c,error:l}=await u;return l!=null&&l.error?{error:l.error}:{data:c?.data}},"handleRequest"),this.handlePaginatedRequest=d(async u=>{var c;let{data:l,error:p}=await u;return p!=null&&p.error?{error:p.error}:{data:l?.data??[],pageInfo:l?.pageInfo??{next:null,previous:null,totalCount:((c=l?.data)==null?void 0:c.length)??0}}},"handlePaginatedRequest");var t,r,s,o,a;(t=e.config)!=null&&t.version&&(this.version=e.config.version),this.directClient=Jt(lt({baseUrl:`https://swish.app/api/${this.version}`,...e.config})),(r=e.config)!=null&&r.authProxy&&(this.proxyClient=Jt(lt({...e.config,baseUrl:e.config.authProxy}))),e.authToken&&(this.authToken=e.authToken),e.requestInterceptor&&((s=this.proxyClient)==null||s.interceptors.request.use(e.requestInterceptor),this.directClient.interceptors.request.use(e.requestInterceptor)),e.responseInterceptor&&((o=this.proxyClient)==null||o.interceptors.response.use(e.responseInterceptor),this.directClient.interceptors.response.use(e.responseInterceptor)),(a=this.proxyClient)==null||a.interceptors.request.use(this.proxyRequestInterceptor.bind(this)),this.directClient.interceptors.request.use(this.directRequestInterceptor.bind(this))}setAuthToken(e){this.authToken=e}proxyRequestInterceptor(e){return this.version&&e.headers.set("Swish-Api-Version",this.version),e}directRequestInterceptor(e){return this.authToken&&e.headers.set("Authorization",`Bearer ${this.authToken}`),e}};d(Tr,"SwishClient");var zi=Tr;var $r=Qr(Lr(),1);var Mr=i(n=>new $r.default(async e=>{let t=[...new Set(e)].sort((s,o)=>s.localeCompare(o)),r=await n.items.list({query:t.join(" "),limit:200});return"error"in r?(console.error("Failed to load items",r.error),e.map(()=>({data:[],pageInfo:{next:null,previous:null,totalCount:0}}))):e.map(s=>{let o=r.data.find(a=>s===`variant:${a.variantId}`||s===`product:${a.productId}`);return{data:o?[o]:[],pageInfo:{next:null,previous:null,totalCount:o?1:0}}})},{batchScheduleFn:i(e=>setTimeout(e,50),"batchScheduleFn"),cache:!1,maxBatchSize:200}),"createItemsBatchLoader");var dt=class{constructor(e,t,r){this.tokenHasProfile=!1;this.api=e,this.context=t,this.eventBus=r}static{i(this,"SwishApiAuth")}hasProfile(){return this.tokenHasProfile}hasToken(){return!!this.getSwishToken()}async renewToken(){return this._renewPromise?this._renewPromise:(this._renewPromise=(async()=>{this._initPromise=void 0,this.deleteSwishToken(),await this.init(),this._renewPromise=void 0})(),this._renewPromise)}async init(){return this._initPromise?this._initPromise:(this._initPromise=(async()=>{this.migrateLegacySession();let e=this.context.customer.id;e?(this.hasSessionToken()&&await this.api.clearCache(),await this.initCustomer(e)):(this.hasCustomerToken()&&await this.resetSession(),await this.initSession()),this.eventBus.publish("token-update",null)})(),this._initPromise)}async initCustomer(e){let t=`gid://shopify/Customer/${e}`,r=this.getTokenBySub(t);if(r){this.initToken(r);return}let s=this.getSessionId();await this.acquireToken(s,t)}async initSession(){let e=this.getSessionId(),t=e?this.getTokenBySub(e):null;if(t){this.initToken(t);return}await this.acquireToken(e)}initToken(e){let t=this.getTokenData(e);if(!t)throw new Error("Invalid Swish token.");this.tokenHasProfile=t.has_profile!==!1,this.api.setAuthToken(e)}async acquireToken(e,t){let r=await this.api.profiles.createToken({customer:t,session:e});if("error"in r)throw console.error("Failed to create customer token",r.error),new Error("Failed to create customer token");if(!r.data?.token)throw console.error("Failed to create customer token empty response"),new Error("Failed to create customer token");r.data.profile.startsWith("gid://swish/Session/")&&this.setSessionId(r.data.profile),this.setSwishToken(r.data.token),this.initToken(r.data.token)}async resetSession(){this.deleteSessionId(),this.deleteSwishToken(),await this.api.clearCache()}getTokenData(e){try{return JSON.parse(atob(e.split(".")[1]))}catch(t){return console.error("Failed to parse Swish token",{cause:t}),null}}willTokenExpire(e,t=60){let r=this.getTokenData(e);return!!(r&&r.exp&&r.exp<Date.now()/1e3+t)}hasCustomerToken(){let e=this.getSwishToken();return e?this.getTokenData(e)?.sub?.startsWith("gid://shopify/Customer/")??!1:!1}hasSessionToken(){let e=this.getSwishToken();return e?this.getTokenData(e)?.sub?.startsWith("gid://swish/Session/")??!1:!1}getTokenBySub(e){if(!e)return null;let t=this.getSwishToken();if(!t)return null;let r=this.getTokenData(t);return!r||r.sub!==e||this.willTokenExpire(t,60)?null:t}getSessionId(){let e=H(this.context.myshopifyDomain);return localStorage.getItem(`swish-session-${e}`)??void 0}setSessionId(e){let t=H(this.context.myshopifyDomain);localStorage.setItem(`swish-session-${t}`,e)}deleteSessionId(){let e=H(this.context.myshopifyDomain);localStorage.removeItem(`swish-session-${e}`)}getSwishToken(){let e=H(this.context.myshopifyDomain);return sessionStorage.getItem(`swish-token-${e}`)??void 0}setSwishToken(e){let t=H(this.context.myshopifyDomain);sessionStorage.setItem(`swish-token-${t}`,e)}deleteSwishToken(){let e=H(this.context.myshopifyDomain);sessionStorage.removeItem(`swish-token-${e}`)}migrateLegacySession(){try{let e=localStorage.getItem("wk_session_id")??localStorage.getItem("swish-profile")?.split("/").pop()??localStorage.getItem("swish-session")?.split("/").pop();e&&(this.setSessionId(`gid://swish/Session/${e}`),localStorage.removeItem("wk_session_id"),localStorage.removeItem("swish-profile"),localStorage.removeItem("swish-session"))}catch(e){console.warn("Failed to migrate legacy session id to Swish session",{cause:e})}}};var ft=class{static{i(this,"SwishApi")}constructor(e,t,r,s){this.config=e,this.storefrontContext=t;let o=H(t.myshopifyDomain);this.cache=new Y(`swish-api-${o}`,"max-age=60, stale-while-revalidate=3600",s+(e.version??Zt)),this.cache.cleanupExpiredEntries().catch(a=>{console.warn("Swish API cache initialization cleanup error:",a)}),this.auth=new dt(this,t,r),this.apiClient=Pr({authToken:this.auth.getSwishToken(),config:{...e,fetch:this.fetchFunction.bind(this)},requestInterceptor:this.requestInterceptor.bind(this),responseInterceptor:this.responseInterceptor.bind(this)}),this.itemsLoader=Mr(this)}async fetchFunction(e,t){let r=e instanceof Request?e.method:t?.method??"GET",o=(e instanceof Request?e.url:typeof e=="string"?e:e.toString()).includes("/orders");return r==="GET"&&!o?this.cache.fetchWithCache(e,t):fetch(e,t)}async requestInterceptor(e){let t=new URL(e.url,window.location.origin);!!this.config.authProxy&&t.pathname.startsWith(this.config.authProxy)||await this.initAuth();try{e.headers.set("Country",this.storefrontContext.localization.country),e.headers.set("Language",this.storefrontContext.localization.language),e.headers.set("Market",this.storefrontContext.localization.market)}catch(s){console.warn("Failed to set storefront context headers:",s)}return this.config.requestInterceptor&&(e=await this.config.requestInterceptor(e)),e}async responseInterceptor(e,t){let r=t.method!=="GET",s=t.url.includes("/profiles/token");if(r&&!s){let o=this.auth.hasToken(),a=!this.auth.hasProfile(),u=e.ok;await this.cache.clear(),o&&a&&u&&await this.auth.renewToken()}return await this.config.responseInterceptor?.(e,t),e}setAuthToken(e){this.apiClient.setAuthToken(e)}initAuth(){return this.auth.init()}async withFallback(e,t){return await this.initAuth(),this.auth.hasProfile()?e():Promise.resolve(t)}get items(){return{...this.apiClient.items,count:i(async()=>this.withFallback(()=>this.apiClient.items.count(),{data:{count:0}}),"count"),list:i(async(e,t)=>{let r=i(()=>{if(t?.batch&&e?.query){e.limit!==1&&console.warn("Batching will always limit to 1 item");let s=e.query.split(" ");s.length>1&&console.warn("Batching will only support one query parameter");let o=s[0];if(!o.match(/^product:\d+$/)&&!o.match(/^variant:\d+$/))console.warn("Batching will only support product:<id> or variant:<id>");else return this.itemsLoader?.load(o)}return this.apiClient.items.list(e)},"execute");return t?.shared?r():this.withFallback(r,{data:[],pageInfo:{next:null,previous:null,totalCount:0}})},"list"),findById:i(async e=>this.withFallback(()=>this.apiClient.items.findById(e),{data:null}),"findById")}}get lists(){return{...this.apiClient.lists,list:i(async e=>this.withFallback(()=>this.apiClient.lists.list(e),{data:[],pageInfo:{next:null,previous:null,totalCount:0}}),"list"),findById:i(async(e,t)=>{let r=i(()=>this.apiClient.lists.findById(e),"execute");return t?.shared?r():this.withFallback(()=>this.apiClient.lists.findById(e),{data:null})},"findById")}}get orders(){return{...this.apiClient.orders,list:i(async e=>this.withFallback(()=>this.apiClient.orders.list(e),{data:[],pageInfo:{next:null,previous:null,totalCount:0}}),"list"),findById:i(async e=>this.withFallback(()=>(typeof e=="string"&&(e=parseInt(e.split("/").pop()??e)),this.apiClient.orders.findById(e)),{data:null}),"findById")}}get profiles(){return this.apiClient.profiles}async clearCache(){await this.cache.clear()}};var ht=class{constructor(e){this.eventMap={"POST /items\\/?$":"item-create","DELETE /items\\/?$":"item-delete","PATCH /items\\/([^/]+)\\/?$":"item-update","DELETE /items\\/([^/]+)\\/?$":"item-delete","PUT /items\\/([^/]+)\\/lists\\/?$":"item-lists-update","POST /lists\\/?$":"list-create","DELETE /lists\\/?$":"list-delete","PATCH /lists\\/([^/]+)\\/?$":"list-update","DELETE /lists\\/([^/]+)\\/?$":"list-delete"};this.eventBus=e,this.processFetchResponse=this.processFetchResponse.bind(this)}static{i(this,"SwishApiPublisher")}async processFetchResponse(e,t){try{let r=this.getEventName(t.method,e.status,t.url);if(!r)return;let s=await e.clone().text();if(e.headers.get("Content-Type")?.includes("application/json"))try{s=JSON.parse(s).data}catch(o){console.warn(o)}this.eventBus.publish(r,s)}catch(r){console.warn(r)}}getEventName(e,t,r){e=e.toUpperCase();let s=new URL(r).pathname;return e==="GET"||t<200||t>=300?void 0:Object.entries(this.eventMap).find(([a])=>{let[u,c]=a.split(" ");return u!==e?!1:new RegExp(c).test(s)})?.[1]}};var mt=class{constructor(e,t){this.inflightModals=new Map;this.modalsWithScrollLock=new Set;this.scrollLockRefCount=0;this.scrollPositionBeforeLock=0;this._templatePromises=new Map;this._importPromises=new Map;this._lockScroll=i(()=>this.lockScroll(),"_lockScroll");this._unlockScroll=i(()=>this.unlockScroll(),"_unlockScroll");this.swishUiOptions=e,this.storefrontContext=t}static{i(this,"SwishUi")}async hideModal(e){if(this.inflightModals.has(e))return this.inflightModals.get(e);let t=(async()=>{try{if(typeof e=="string"&&(e=await this.requireUiComponent(e)),!e||e.getAttribute("open")!=="true")return;e.setAttribute("open","false")}finally{e&&typeof e!="string"&&this.modalsWithScrollLock.has(e)&&(this.modalsWithScrollLock.delete(e),this.unlockScroll())}})().finally(()=>{this.inflightModals.delete(e)});return this.inflightModals.set(e,t),t}async showModal(e){if(this.inflightModals.has(e))return this.inflightModals.get(e);let t=(async()=>{typeof e=="string"&&(e=await this.requireUiComponent(e)),!(!e||e.getAttribute("open")==="true")&&(this.lockScroll(),this.modalsWithScrollLock.add(e),e.setAttribute("open","true"))})().finally(()=>{this.inflightModals.delete(e)});return this.inflightModals.set(e,t),t}waitForEvent(e,t){return new Promise(r=>{let s=[],o=i(()=>{s.forEach(({event:a,listener:u})=>{e.removeEventListener(a,u)})},"cleanup");Object.entries(t).forEach(([a,u])=>{let c=i(l=>{let p=u(l);o(),r(p)},"listener");s.push({event:a,listener:c}),e.addEventListener(a,c)})})}async showSignIn(e){let t=await this.requireUiComponent("sign-in");t.setAttribute("return-to",e?.returnTo??window.location.pathname),await this.showModal(t);let r=await this.waitForEvent(t,{close:i(()=>({code:"closed"}),"close")});return await this.hideModal(t),r}async showUnsaveAlert(e){if(!e.itemId)throw new Error("An itemId is required to show the unsave alert");await this.hideAllToasts();let t=await this.requireUiComponent("unsave-alert");t.setAttribute("item-id",e.itemId),await this.showModal(t);let r=await this.waitForEvent(t,{submit:i(s=>s instanceof CustomEvent?{code:"ok",data:s.detail}:(console.warn("Unsave alert submitted without detail",s),{code:"closed"}),"submit"),close:i(()=>({code:"closed"}),"close")});return await this.hideModal(t),r}async showDeleteListAlert(e){if(!e.listId)throw new Error("A listId is required to show the delete list alert");await this.hideAllToasts();let t=await this.requireUiComponent("delete-list-alert");t.setAttribute("list-id",e.listId),await this.showModal(t);let r=await this.waitForEvent(t,{submit:i(()=>({code:"ok",data:void 0}),"submit"),close:i(()=>({code:"closed"}),"close")});return await this.hideModal(t),r}async showConfirmDialog(e){await this.hideAllToasts();let t=await this.requireUiComponent("confirm-dialog");e.titleKey?t.setAttribute("title-key",e.titleKey):t.removeAttribute("title-key"),e.descriptionKey?t.setAttribute("description-key",e.descriptionKey):t.removeAttribute("description-key"),e.confirmLabelKey?t.setAttribute("confirm-label-key",e.confirmLabelKey):t.removeAttribute("confirm-label-key"),e.cancelLabelKey?t.setAttribute("cancel-label-key",e.cancelLabelKey):t.removeAttribute("cancel-label-key"),e.danger?t.setAttribute("danger",""):t.removeAttribute("danger"),await this.showModal(t);let r=await this.waitForEvent(t,{submit:i(()=>({code:"ok",data:void 0}),"submit"),close:i(()=>({code:"closed"}),"close")});return await this.hideModal(t),r}async showDrawer(e){await this.hideAllToasts();let t=await this.requireUiComponent("drawer");t.setAttribute("account-url",this.storefrontContext.routes.accountUrl),this.storefrontContext.customer.id&&t.setAttribute("customer-id",this.storefrontContext.customer.id),t.setAttribute("view",e?.view??"home"),e?.listId&&t.setAttribute("list-id",e.listId),e?.productId&&t.setAttribute("product-id",e.productId),e?.variantId&&t.setAttribute("variant-id",e.variantId),e?.orderId&&t.setAttribute("order-id",e.orderId),await this.showModal(t);let r=await this.waitForEvent(t,{close:i(()=>({code:"closed"}),"close")});return await this.hideModal(t),r}async showListMenu(e){if(!e.listId)throw new Error("listId is required");await this.hideAllToasts();let t=await this.requireUiComponent("list-menu");t.setAttribute("list-id",e.listId),await this.showModal(t);let r=await this.waitForEvent(t,{close:i(()=>({code:"closed"}),"close"),edit:i(s=>s instanceof CustomEvent?{code:"ok",data:{action:"edit",data:s.detail}}:(console.warn("List menu edit without detail",s),{code:"closed"}),"edit"),delete:i(()=>({code:"ok",data:{action:"delete"}}),"delete"),share:i(()=>({code:"ok",data:{action:"share"}}),"share"),"edit-access":i(s=>{if(s instanceof CustomEvent){let a=s.detail?.currentListAccess;if(a==="public"||a==="private")return{code:"ok",data:{action:"edit-access",data:{currentListAccess:a}}}}return{code:"ok",data:{action:"edit-access"}}},"edit-access")});return await this.hideModal(t),r}async showOrderMenu(e){if(!e.orderId)throw new Error("orderId is required");await this.hideAllToasts();let t=await this.requireUiComponent("order-menu");t.setAttribute("order-id",e.orderId),await this.showModal(t);let r=await this.waitForEvent(t,{close:i(()=>({code:"closed"}),"close")});return await this.hideModal(t),r}async showListDetailPageMenu(e){await this.hideAllToasts();let t=await this.requireUiComponent("list-detail-page-menu");t.setAttribute("list-id",e.listId),await this.showModal(t);let r=await this.waitForEvent(t,{close:i(()=>({code:"closed"}),"close")});return await this.hideModal(t),r}async showListSelect(e){if(!e.itemId)throw new Error("itemId is required");await this.hideAllToasts();let t=await this.requireUiComponent("list-select");t.setAttribute("item-id",e.itemId),await this.showModal(t);let r=await this.waitForEvent(t,{close:i(()=>({code:"closed"}),"close"),submit:i(s=>"detail"in s&&s.detail?{code:"ok",data:{action:"submit",data:s.detail}}:(console.warn("List select submit without detail",s),{code:"closed"}),"submit"),unsave:i(s=>s instanceof CustomEvent?{code:"ok",data:{action:"unsave",data:s.detail}}:(console.warn("List select unsave without detail",s),{code:"closed"}),"unsave")});return await this.hideModal(t),r}async initListDetailPage(e,t){let r=await this.requireUiComponent("list-detail-page",{refElement:t});e.listId&&r.setAttribute("list-id",e.listId)}async showToast(e){let t=Date.now(),r=await this.requireUiComponent("toast-manager",{onHydrated:i(s=>{s.current.show(e,t)},"onHydrated")});return this.waitForEvent(r,{[`close-${t}`]:()=>({code:"closed"}),[`submit-${t}`]:()=>({code:"ok",data:void 0})})}async hideAllToasts(){this.queryComponent("toast-manager")&&await this.requireUiComponent("toast-manager",{onHydrated:i(e=>{e.current.clear()},"onHydrated")})}async showVariantSelect(e){await this.hideAllToasts();let t=await this.requireUiComponent("variant-select");if(e?.itemId&&t.setAttribute("item-id",e.itemId),e?.productId)t.setAttribute("product-id",e.productId.toString());else if(e?.productHandle)t.setAttribute("product-handle",e.productHandle);else throw new Error("Either productId or productHandle must be provided");e?.variantId&&t.setAttribute("variant-id",e.variantId.toString()),await this.showModal(t);let r=await this.waitForEvent(t,{close:i(()=>({code:"closed"}),"close"),submit:i(s=>"detail"in s&&s.detail?{code:"ok",data:s.detail}:(console.warn("Variant select submit without detail",s),{code:"closed"}),"submit")});return await this.hideModal(t),r}async showQuickBuy(e){await this.hideAllToasts();let t=await this.requireUiComponent("quick-buy");if(e?.productId)t.setAttribute("product-id",e.productId.toString());else if(e?.productHandle)t.setAttribute("product-handle",e.productHandle);else throw new Error("ProductId or productHandle must be provided");e?.variantId&&t.setAttribute("variant-id",e.variantId.toString()),await this.showModal(t);let r=await this.waitForEvent(t,{close:i(()=>({code:"closed"}),"close"),submit:i(s=>"detail"in s&&s.detail?{code:"ok",data:s.detail}:(console.warn("Quick buy submit without detail",s),{code:"closed"}),"submit")});return await this.hideModal(t),r}async showListEditor(e){let t=await this.requireUiComponent("list-editor");e?.listId&&t.setAttribute("list-id",e.listId),await this.showModal(t);let r=await this.waitForEvent(t,{close:i(()=>({code:"closed"}),"close"),submit:i(s=>"detail"in s&&s.detail?{code:"ok",data:s.detail}:(console.warn("List editor submit without detail",s),{code:"closed"}),"submit")});return await this.hideModal(t),r}async createElement(e,t){let[r,{themeVariablesStylesheet:s}]=await Promise.all([this.loadTemplate(e),this.loadCricalResources()]),o=document.createElement("template");o.innerHTML=r.replace(' shadowrootmode="open"',"");let a=o.content.firstElementChild;return a.addEventListener("connected",()=>{a.shadowRoot&&(a.shadowRoot.adoptedStyleSheets=[s],this.hydrateElement(e,a,t?.onHydrated))},{once:!0}),a}async hydrateElement(e,t,r){if(t.hasAttribute("hydrated")){r?.(t.getComponentRef());return}await Promise.all([this.loadNonCriticalResources(),this.importScript(e)]).then(([{bundleCssStylesheet:s,customCssStylesheets:o},{hydrate:a}])=>{t.shadowRoot&&s&&(t.shadowRoot.adoptedStyleSheets=[...t.shadowRoot.adoptedStyleSheets,...o,s],t.shadowRoot?.querySelector(":host > style")?.remove()),a(t),t.setAttribute("hydrated","")}),r?.(t.getComponentRef())}async requireUiComponent(e,t){this.loadCricalResources();let r=await this.loadTemplate(e),s=this.queryComponent(e)??await this.insertComponent({name:e,template:r,refElement:t?.refElement??document.body,position:"beforeend"});return s.shadowRoot&&!s.hasAttribute("hydrated")?Promise.all([this.loadNonCriticalResources(),this.importScript(e)]).then(([{bundleCssStylesheet:o,customCssStylesheets:a},{hydrate:u}])=>{s.shadowRoot&&o&&(s.shadowRoot.adoptedStyleSheets=[...s.shadowRoot.adoptedStyleSheets,...a,o],s.shadowRoot?.querySelector(":host > style")?.remove()),u(s),s.setAttribute("hydrated",""),t?.onHydrated?.(s.getComponentRef())}):s.hasAttribute("hydrated")&&t?.onHydrated?.(s.getComponentRef()),s}async loadTemplate(e){let t=`${this.swishUiOptions.baseUrl}/ui@${this.swishUiOptions.version}/${e}.html`;if(this._templatePromises.has(t))return this._templatePromises.get(t);let r=fetch(t).then(s=>s.text());return this._templatePromises.set(t,r),r}async importScript(e){let t=`${this.swishUiOptions.baseUrl}/ui@${this.swishUiOptions.version}/${e}.js`;if(this._importPromises.has(t))return this._importPromises.get(t);let r=import(t);return this._importPromises.set(t,r),r}async loadCricalResources(){return this._loadCricalResourcesPromise?this._loadCricalResourcesPromise:(this._loadCricalResourcesPromise=(async()=>{let e=`${this.swishUiOptions.baseUrl}/ui@${this.swishUiOptions.version}/theme.css`,t=await fetch(e).then(o=>o.text()),r=new CSSStyleSheet;r.replaceSync(t);let s=ro(this.swishUiOptions.design);return Object.entries(s).forEach(([o,a])=>{r.cssRules[0].cssRules[0].style.setProperty(o,a)}),{themeVariablesStylesheet:r}})(),this._loadCricalResourcesPromise)}async loadNonCriticalResources(){return this._loadNonCriticalResourcesPromise?this._loadNonCriticalResourcesPromise:(this._loadNonCriticalResourcesPromise=(async()=>{let e=`${this.swishUiOptions.baseUrl}/ui@${this.swishUiOptions.version}/bundle.css`,t=i(o=>{let a=new CSSStyleSheet;return a.replaceSync(o),a},"createCssStylesheet"),[r,...s]=await Promise.all([fetch(e).then(o=>o.text()).then(t),...this.swishUiOptions.css.map(async o=>o instanceof URL?t(await fetch(o).then(a=>a.text())):t(o))]);return{bundleCssStylesheet:r,customCssStylesheets:s}})(),this._loadNonCriticalResourcesPromise)}async insertComponent({name:e,template:t,position:r,refElement:s}){let{themeVariablesStylesheet:o}=await this.loadCricalResources();s.insertAdjacentHTML(r,t.replace(' shadowrootmode="open"',""));let a=this.queryComponent(e);if(!a)throw new Error(`Element ${e} not found in DOM`);return a.shadowRoot&&(a.shadowRoot.adoptedStyleSheets=[o]),a}queryComponent(e,t){let r=`swish-ui[ref="${e}${t?`-${t}`:""}"]`;return document.querySelector(r)}lockScroll(){this.scrollLockRefCount++,this.scrollLockRefCount===1&&(this.scrollPositionBeforeLock=window.scrollY,this.scrollLockStyleSheet||(this.scrollLockStyleSheet=new CSSStyleSheet,document.adoptedStyleSheets=[...document.adoptedStyleSheets,this.scrollLockStyleSheet]),this.scrollLockStyleSheet.replaceSync(`
444
+ `);I=an.pop()??"";for(let Nr of an){let Br=Nr.split(`
445
+ `),Ie=[],un;for(let W of Br)if(W.startsWith("data:"))Ie.push(W.replace(/^data:\s*/,""));else if(W.startsWith("event:"))un=W.replace(/^event:\s*/,"");else if(W.startsWith("id:"))f=W.replace(/^id:\s*/,"");else if(W.startsWith("retry:")){let ln=Number.parseInt(W.replace(/^retry:\s*/,""),10);Number.isNaN(ln)||(h=ln)}let se,cn=!1;if(Ie.length){let W=Ie.join(`
446
+ `);try{se=JSON.parse(W),cn=!0}catch{se=W}}cn&&(s&&await s(se),r&&(se=await r(se))),t?.({data:se,event:un,id:f,retry:h}),Ie.length&&(yield se)}}}finally{w.removeEventListener("abort",q),_.releaseLock()}break}catch(N){if(e?.(N),a!==void 0&&x>=a)break;let L=Math.min(h*2**(x-1),u??3e4);await y(L)}}},"createStream")()}},"createSseClient"),pi=d(n=>{switch(n){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorArrayExplode"),di=d(n=>{switch(n){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},"separatorArrayNoExplode"),fi=d(n=>{switch(n){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorObjectExplode"),Cr=d(({allowReserved:n,explode:e,name:t,style:r,value:s})=>{if(!e){let u=(n?s:s.map(c=>encodeURIComponent(c))).join(di(r));switch(r){case"label":return`.${u}`;case"matrix":return`;${t}=${u}`;case"simple":return u;default:return`${t}=${u}`}}let o=pi(r),a=s.map(u=>r==="label"||r==="simple"?n?u:encodeURIComponent(u):mt({allowReserved:n,name:t,value:u})).join(o);return r==="label"||r==="matrix"?o+a:a},"serializeArrayParam"),mt=d(({allowReserved:n,name:e,value:t})=>{if(t==null)return"";if(typeof t=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${e}=${n?t:encodeURIComponent(t)}`},"serializePrimitiveParam"),Rr=d(({allowReserved:n,explode:e,name:t,style:r,value:s,valueOnly:o})=>{if(s instanceof Date)return o?s.toISOString():`${t}=${s.toISOString()}`;if(r!=="deepObject"&&!e){let c=[];Object.entries(s).forEach(([p,f])=>{c=[...c,p,n?f:encodeURIComponent(f)]});let l=c.join(",");switch(r){case"form":return`${t}=${l}`;case"label":return`.${l}`;case"matrix":return`;${t}=${l}`;default:return l}}let a=fi(r),u=Object.entries(s).map(([c,l])=>mt({allowReserved:n,name:r==="deepObject"?`${t}[${c}]`:c,value:l})).join(a);return r==="label"||r==="matrix"?a+u:u},"serializeObjectParam"),hi=/\{[^{}]+\}/g,mi=d(({path:n,url:e})=>{let t=e,r=e.match(hi);if(r)for(let s of r){let o=!1,a=s.substring(1,s.length-1),u="simple";a.endsWith("*")&&(o=!0,a=a.substring(0,a.length-1)),a.startsWith(".")?(a=a.substring(1),u="label"):a.startsWith(";")&&(a=a.substring(1),u="matrix");let c=n[a];if(c==null)continue;if(Array.isArray(c)){t=t.replace(s,Cr({explode:o,name:a,style:u,value:c}));continue}if(typeof c=="object"){t=t.replace(s,Rr({explode:o,name:a,style:u,value:c,valueOnly:!0}));continue}if(u==="matrix"){t=t.replace(s,`;${mt({name:a,value:c})}`);continue}let l=encodeURIComponent(u==="label"?`.${c}`:c);t=t.replace(s,l)}return t},"defaultPathSerializer"),yi=d(({baseUrl:n,path:e,query:t,querySerializer:r,url:s})=>{let o=s.startsWith("/")?s:`/${s}`,a=(n??"")+o;e&&(a=mi({path:e,url:a}));let u=t?r(t):"";return u.startsWith("?")&&(u=u.substring(1)),u&&(a+=`?${u}`),a},"getUrl");function Ar(n){let e=n.body!==void 0;if(e&&n.bodySerializer)return"serializedBody"in n?n.serializedBody!==void 0&&n.serializedBody!==""?n.serializedBody:null:n.body!==""?n.body:null;if(e)return n.body}i(Ar,"K");d(Ar,"getValidRequestBody");var vi=d(async(n,e)=>{let t=typeof e=="function"?await e(n):e;if(t)return n.scheme==="bearer"?`Bearer ${t}`:n.scheme==="basic"?`Basic ${btoa(t)}`:t},"getAuthToken"),Dr=d(({allowReserved:n,array:e,object:t}={})=>d(r=>{let s=[];if(r&&typeof r=="object")for(let o in r){let a=r[o];if(a!=null)if(Array.isArray(a)){let u=Cr({allowReserved:n,explode:!0,name:o,style:"form",value:a,...e});u&&s.push(u)}else if(typeof a=="object"){let u=Rr({allowReserved:n,explode:!0,name:o,style:"deepObject",value:a,...t});u&&s.push(u)}else{let u=mt({allowReserved:n,name:o,value:a});u&&s.push(u)}}return s.join("&")},"querySerializer"),"createQuerySerializer"),gi=d(n=>{var e;if(!n)return"stream";let t=(e=n.split(";")[0])==null?void 0:e.trim();if(t){if(t.startsWith("application/json")||t.endsWith("+json"))return"json";if(t==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some(r=>t.startsWith(r)))return"blob";if(t.startsWith("text/"))return"text"}},"getParseAs"),wi=d((n,e)=>{var t,r;return e?!!(n.headers.has(e)||(t=n.query)!=null&&t[e]||(r=n.headers.get("Cookie"))!=null&&r.includes(`${e}=`)):!1},"checkForExistence"),Ii=d(async({security:n,...e})=>{for(let t of n){if(wi(e,t.name))continue;let r=await vi(t,e.auth);if(!r)continue;let s=t.name??"Authorization";switch(t.in){case"query":e.query||(e.query={}),e.query[s]=r;break;case"cookie":e.headers.append("Cookie",`${s}=${r}`);break;case"header":default:e.headers.set(s,r);break}}},"setAuthParams"),xr=d(n=>yi({baseUrl:n.baseUrl,path:n.path,query:n.query,querySerializer:typeof n.querySerializer=="function"?n.querySerializer:Dr(n.querySerializer),url:n.url}),"buildUrl"),kr=d((n,e)=>{var t;let r={...n,...e};return(t=r.baseUrl)!=null&&t.endsWith("/")&&(r.baseUrl=r.baseUrl.substring(0,r.baseUrl.length-1)),r.headers=Pr(n.headers,e.headers),r},"mergeConfigs"),bi=d(n=>{let e=[];return n.forEach((t,r)=>{e.push([r,t])}),e},"headersEntries"),Pr=d((...n)=>{let e=new Headers;for(let t of n){if(!t)continue;let r=t instanceof Headers?bi(t):Object.entries(t);for(let[s,o]of r)if(o===null)e.delete(s);else if(Array.isArray(o))for(let a of o)e.append(s,a);else o!==void 0&&e.set(s,typeof o=="object"?JSON.stringify(o):o)}return e},"mergeHeaders"),Tr=class{static{i(this,"$")}constructor(){this.fns=[]}clear(){this.fns=[]}eject(e){let t=this.getInterceptorIndex(e);this.fns[t]&&(this.fns[t]=null)}exists(e){let t=this.getInterceptorIndex(e);return!!this.fns[t]}getInterceptorIndex(e){return typeof e=="number"?this.fns[e]?e:-1:this.fns.indexOf(e)}update(e,t){let r=this.getInterceptorIndex(e);return this.fns[r]?(this.fns[r]=t,e):!1}use(e){return this.fns.push(e),this.fns.length-1}};d(Tr,"Interceptors");var Zt=Tr,Si=d(()=>({error:new Zt,request:new Zt,response:new Zt}),"createInterceptors"),Ei=Dr({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),xi={"Content-Type":"application/json"},ht=d((n={})=>({...ui,headers:xi,parseAs:"auto",querySerializer:Ei,...n}),"createConfig"),en=d((n={})=>{let e=kr(ht(),n),t=d(()=>({...e}),"getConfig"),r=d(l=>(e=kr(e,l),t()),"setConfig"),s=Si(),o=d(async l=>{let p={...e,...l,fetch:l.fetch??e.fetch??globalThis.fetch,headers:Pr(e.headers,l.headers),serializedBody:void 0};p.security&&await Ii({...p,security:p.security}),p.requestValidator&&await p.requestValidator(p),p.body!==void 0&&p.bodySerializer&&(p.serializedBody=p.bodySerializer(p.body)),(p.body===void 0||p.serializedBody==="")&&p.headers.delete("Content-Type");let f=xr(p);return{opts:p,url:f}},"beforeRequest"),a=d(async l=>{let{opts:p,url:f}=await o(l),y={redirect:"follow",...p,body:Ar(p)},h=new Request(f,y);for(let I of s.request.fns)I&&(h=await I(h,p));let x=p.fetch,w=await x(h);for(let I of s.response.fns)I&&(w=await I(w,h,p));let O={request:h,response:w};if(w.ok){let I=(p.parseAs==="auto"?gi(w.headers.get("Content-Type")):p.parseAs)??"json";if(w.status===204||w.headers.get("Content-Length")==="0"){let C;switch(I){case"arrayBuffer":case"blob":case"text":C=await w[I]();break;case"formData":C=new FormData;break;case"stream":C=w.body;break;case"json":default:C={};break}return p.responseStyle==="data"?C:{data:C,...O}}let q;switch(I){case"arrayBuffer":case"blob":case"formData":case"json":case"text":q=await w[I]();break;case"stream":return p.responseStyle==="data"?w.body:{data:w.body,...O}}return I==="json"&&(p.responseValidator&&await p.responseValidator(q),p.responseTransformer&&(q=await p.responseTransformer(q))),p.responseStyle==="data"?q:{data:q,...O}}let N=await w.text(),L;try{L=JSON.parse(N)}catch{}let G=L??N,_=G;for(let I of s.error.fns)I&&(_=await I(G,w,h,p));if(_=_||{},p.throwOnError)throw _;return p.responseStyle==="data"?void 0:{error:_,...O}},"request"),u=d(l=>p=>a({...p,method:l}),"makeMethodFn"),c=d(l=>async p=>{let{opts:f,url:y}=await o(p);return li({...f,body:f.body,headers:f.headers,method:l,onRequest:d(async(h,x)=>{let w=new Request(h,x);for(let O of s.request.fns)O&&(w=await O(w,f));return w},"onRequest"),url:y})},"makeSseFn");return{buildUrl:xr,connect:u("CONNECT"),delete:u("DELETE"),get:u("GET"),getConfig:t,head:u("HEAD"),interceptors:s,options:u("OPTIONS"),patch:u("PATCH"),post:u("POST"),put:u("PUT"),request:a,setConfig:r,sse:{connect:c("CONNECT"),delete:c("DELETE"),get:c("GET"),head:c("HEAD"),options:c("OPTIONS"),patch:c("PATCH"),post:c("POST"),put:c("PUT"),trace:c("TRACE")},trace:u("TRACE")}},"createClient"),R=en(ht({baseUrl:"https://swish.app/api/2026-01"})),ki=d(n=>(n?.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/lists",...n}),"listControllerFind"),Ci=d(n=>(n.client??R).post({security:[{scheme:"bearer",type:"http"}],url:"/lists",...n,headers:{"Content-Type":"application/json",...n.headers}}),"listControllerCreate"),Ri=d(n=>(n.client??R).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...n}),"listControllerDeleteById"),Ai=d(n=>(n.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...n}),"listControllerFindById"),Di=d(n=>(n.client??R).patch({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...n,headers:{"Content-Type":"application/json",...n.headers}}),"listControllerUpdateById"),Pi=d(n=>(n.client??R).put({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/order",...n,headers:{"Content-Type":"application/json",...n.headers}}),"listControllerSetListItemsOrder"),Ti=d(n=>(n.client??R).post({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items",...n,headers:{"Content-Type":"application/json",...n.headers}}),"listControllerAddItemsToList"),_i=d(n=>(n.client??R).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/{itemId}",...n}),"listControllerRemoveItemFromList"),Oi=d(n=>(n.client??R).delete({security:[{scheme:"bearer",type:"http"}],url:"/items",...n,headers:{"Content-Type":"application/json",...n.headers}}),"itemControllerDelete"),Li=d(n=>(n?.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/items",...n}),"itemControllerFind"),$i=d(n=>(n.client??R).post({security:[{scheme:"bearer",type:"http"}],url:"/items",...n,headers:{"Content-Type":"application/json",...n.headers}}),"itemControllerCreate"),Mi=d(n=>(n?.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/items/count",...n}),"itemControllerCount"),Vi=d(n=>(n.client??R).delete({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...n}),"itemControllerDeleteById"),qi=d(n=>(n.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...n}),"itemControllerFindById"),Ni=d(n=>(n.client??R).patch({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...n,headers:{"Content-Type":"application/json",...n.headers}}),"itemControllerUpdateById"),Bi=d(n=>(n.client??R).put({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}/lists",...n,headers:{"Content-Type":"application/json",...n.headers}}),"itemControllerSetListsById"),Ui=d(n=>(n.client??R).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/identify",...n,headers:{"Content-Type":"application/json",...n.headers}}),"profileControllerIdentify"),Fi=d(n=>(n.client??R).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/token",...n,headers:{"Content-Type":"application/json",...n.headers}}),"profileControllerCreateToken"),ji=d(n=>(n?.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/profiles",...n}),"profileControllerGetProfile"),Gi=d(n=>(n.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/saved-items",...n}),"analyticsControllerLoadSavedItems"),Hi=d(n=>(n.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/sessions",...n}),"analyticsControllerLoadSessions"),Qi=d(n=>(n.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/new-lists",...n}),"analyticsControllerLoadNewLists"),zi=d(n=>(n.client??R).post({security:[{scheme:"bearer",type:"http"}],url:"/tracking",...n,headers:{"Content-Type":"application/json",...n.headers}}),"trackingControllerTrack"),Wi=d(n=>(n?.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/orders",...n}),"ordersControllerFind"),Ki=d(n=>(n.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/orders/{orderId}",...n}),"ordersControllerFindOne"),Xi=d(n=>(n.client??R).post({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{listId}/save",...n}),"sharedListsControllerSave"),Yi=d(n=>(n.client??R).delete({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{listId}",...n}),"sharedListsControllerDeleteById"),Ji=d(n=>(n.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{listId}",...n}),"sharedListsControllerFindById"),Zi=d(n=>(n?.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists",...n}),"sharedListsControllerFindAll"),tn="2026-01",_r=d(n=>new eo(n),"createApiClient"),Or=class{static{i(this,"H")}constructor(e){this.version=tn,this.items={list:d(u=>this.handlePaginatedRequest(Li({query:u,client:this.directClient})),"list"),create:d(u=>this.handleRequest($i({body:u,client:this.directClient})),"create"),delete:d(u=>this.handleRequest(Oi({body:{itemIds:u},client:this.directClient})),"delete"),findById:d(u=>this.handleRequest(qi({path:{itemId:u},client:this.directClient})),"findById"),updateById:d((u,c)=>this.handleRequest(Ni({body:c,path:{itemId:u},client:this.directClient})),"updateById"),deleteById:d(u=>this.handleRequest(Vi({path:{itemId:u},client:this.directClient})),"deleteById"),setListsById:d((u,c)=>this.handleRequest(Bi({body:{listIds:c},path:{itemId:u},client:this.directClient})),"setListsById"),count:d(()=>this.handleRequest(Mi({client:this.directClient})),"count")},this.lists={list:d(u=>this.handlePaginatedRequest(ki({query:u,client:this.directClient})),"list"),create:d(u=>this.handleRequest(Ci({body:u,client:this.directClient})),"create"),findById:d(u=>this.handleRequest(Ai({path:{listId:u},client:this.directClient})),"findById"),updateById:d((u,c)=>this.handleRequest(Di({body:c,path:{listId:u},client:this.directClient})),"updateById"),deleteById:d(u=>this.handleRequest(Ri({path:{listId:u},client:this.directClient})),"deleteById"),orderItems:d((u,c)=>this.handleRequest(Pi({body:{itemIds:c},path:{listId:u},client:this.directClient})),"orderItems"),addItemsToList:d((u,c)=>this.handleRequest(Ti({body:{itemIds:c},path:{listId:u},client:this.directClient})),"addItemsToList"),removeItemFromList:d((u,c)=>this.handleRequest(_i({path:{listId:u,itemId:c},client:this.directClient})),"removeItemFromList")},this.profiles={createToken:d((u={})=>this.handleRequest(Fi({body:u,client:this.proxyClient??this.directClient})),"createToken"),identify:d(u=>this.handleRequest(Ui({body:u,client:this.directClient})),"identify"),getProfile:d(()=>this.handleRequest(ji({client:this.directClient})),"getProfile")},this.orders={list:d(u=>this.handlePaginatedRequest(Wi({query:u,client:this.directClient})),"list"),findById:d(u=>this.handleRequest(Ki({path:{orderId:u},client:this.directClient})),"findById")},this.sharedLists={list:d(u=>this.handlePaginatedRequest(Zi({query:u,client:this.directClient})),"list"),save:d(u=>this.handleRequest(Xi({path:{listId:u},client:this.directClient})),"save"),findById:d(u=>this.handleRequest(Ji({path:{listId:u},client:this.directClient})),"findById"),deleteById:d(u=>this.handleRequest(Yi({path:{listId:u},client:this.directClient})),"deleteById")},this.analytics={savedItems:d(u=>this.handleRequest(Gi({query:u,client:this.directClient})),"savedItems"),sessions:d(u=>this.handleRequest(Hi({query:u,client:this.directClient})),"sessions"),newLists:d(u=>this.handleRequest(Qi({query:u,client:this.directClient})),"newLists")},this.tracking={track:d((u,c)=>this.handleRequest(zi({body:u,headers:c,client:this.directClient})),"track")},this.handleRequest=d(async u=>{let{data:c,error:l}=await u;return l!=null&&l.error?{error:l.error}:{data:c?.data}},"handleRequest"),this.handlePaginatedRequest=d(async u=>{var c;let{data:l,error:p}=await u;return p!=null&&p.error?{error:p.error}:{data:l?.data??[],pageInfo:l?.pageInfo??{next:null,previous:null,totalCount:((c=l?.data)==null?void 0:c.length)??0}}},"handlePaginatedRequest");var t,r,s,o,a;(t=e.config)!=null&&t.version&&(this.version=e.config.version),this.directClient=en(ht({baseUrl:`https://swish.app/api/${this.version}`,...e.config})),(r=e.config)!=null&&r.authProxy&&(this.proxyClient=en(ht({...e.config,baseUrl:e.config.authProxy}))),e.authToken&&(this.authToken=e.authToken),e.requestInterceptor&&((s=this.proxyClient)==null||s.interceptors.request.use(e.requestInterceptor),this.directClient.interceptors.request.use(e.requestInterceptor)),e.responseInterceptor&&((o=this.proxyClient)==null||o.interceptors.response.use(e.responseInterceptor),this.directClient.interceptors.response.use(e.responseInterceptor)),(a=this.proxyClient)==null||a.interceptors.request.use(this.proxyRequestInterceptor.bind(this)),this.directClient.interceptors.request.use(this.directRequestInterceptor.bind(this))}setAuthToken(e){this.authToken=e}proxyRequestInterceptor(e){return this.version&&e.headers.set("Swish-Api-Version",this.version),e}directRequestInterceptor(e){return this.authToken&&e.headers.set("Authorization",`Bearer ${this.authToken}`),e}};d(Or,"SwishClient");var eo=Or;var Vr=Wr(Mr(),1);var qr=i(n=>new Vr.default(async e=>{let t=[...new Set(e)].sort((s,o)=>s.localeCompare(o)),r=await n.items.list({query:t.join(" "),limit:200});return"error"in r?(console.error("Failed to load items",r.error),e.map(()=>({data:[],pageInfo:{next:null,previous:null,totalCount:0}}))):e.map(s=>{let o=r.data.find(a=>s===`variant:${a.variantId}`||s===`product:${a.productId}`);return{data:o?[o]:[],pageInfo:{next:null,previous:null,totalCount:o?1:0}}})},{batchScheduleFn:i(e=>setTimeout(e,50),"batchScheduleFn"),cache:!1,maxBatchSize:200}),"createItemsBatchLoader");var yt=class{constructor(e,t,r){this.tokenHasProfile=!1;this.api=e,this.context=t,this.eventBus=r}static{i(this,"SwishApiAuth")}hasProfile(){return this.tokenHasProfile}hasToken(){return!!this.getSwishToken()}async renewToken(){return this._renewPromise?this._renewPromise:(this._renewPromise=(async()=>{this._initPromise=void 0,this.deleteSwishToken(),await this.init(),this._renewPromise=void 0})(),this._renewPromise)}async init(){return this._initPromise?this._initPromise:(this._initPromise=(async()=>{this.migrateLegacySession();let e=this.context.customer.id;e?(this.hasSessionToken()&&await this.api.clearCache(),await this.initCustomer(e)):(this.hasCustomerToken()&&await this.resetSession(),await this.initSession()),this.eventBus.publish("token-update",null)})(),this._initPromise)}async initCustomer(e){let t=`gid://shopify/Customer/${e}`,r=this.getTokenBySub(t);if(r){this.initToken(r);return}let s=this.getSessionId();await this.acquireToken(s,t)}async initSession(){let e=this.getSessionId(),t=e?this.getTokenBySub(e):null;if(t){this.initToken(t);return}await this.acquireToken(e)}initToken(e){let t=this.getTokenData(e);if(!t)throw new Error("Invalid Swish token.");this.tokenHasProfile=t.has_profile!==!1,this.api.setAuthToken(e)}async acquireToken(e,t){let r=await this.api.profiles.createToken({customer:t,session:e});if("error"in r)throw console.error("Failed to create customer token",r.error),new Error("Failed to create customer token");if(!r.data?.token)throw console.error("Failed to create customer token empty response"),new Error("Failed to create customer token");r.data.profile.startsWith("gid://swish/Session/")&&this.setSessionId(r.data.profile),this.setSwishToken(r.data.token),this.initToken(r.data.token)}async resetSession(){this.deleteSessionId(),this.deleteSwishToken(),await this.api.clearCache()}getTokenData(e){try{return JSON.parse(atob(e.split(".")[1]))}catch(t){return console.error("Failed to parse Swish token",{cause:t}),null}}willTokenExpire(e,t=60){let r=this.getTokenData(e);return!!(r&&r.exp&&r.exp<Date.now()/1e3+t)}hasCustomerToken(){let e=this.getSwishToken();return e?this.getTokenData(e)?.sub?.startsWith("gid://shopify/Customer/")??!1:!1}hasSessionToken(){let e=this.getSwishToken();return e?this.getTokenData(e)?.sub?.startsWith("gid://swish/Session/")??!1:!1}getTokenBySub(e){if(!e)return null;let t=this.getSwishToken();if(!t)return null;let r=this.getTokenData(t);return!r||r.sub!==e||this.willTokenExpire(t,60)?null:t}getSessionId(){let e=H(this.context.myshopifyDomain);return localStorage.getItem(`swish-session-${e}`)??void 0}setSessionId(e){let t=H(this.context.myshopifyDomain);localStorage.setItem(`swish-session-${t}`,e)}deleteSessionId(){let e=H(this.context.myshopifyDomain);localStorage.removeItem(`swish-session-${e}`)}getSwishToken(){let e=H(this.context.myshopifyDomain);return sessionStorage.getItem(`swish-token-${e}`)??void 0}setSwishToken(e){let t=H(this.context.myshopifyDomain);sessionStorage.setItem(`swish-token-${t}`,e)}deleteSwishToken(){let e=H(this.context.myshopifyDomain);sessionStorage.removeItem(`swish-token-${e}`)}migrateLegacySession(){try{let e=localStorage.getItem("wk_session_id")??localStorage.getItem("swish-profile")?.split("/").pop()??localStorage.getItem("swish-session")?.split("/").pop();e&&(this.setSessionId(`gid://swish/Session/${e}`),localStorage.removeItem("wk_session_id"),localStorage.removeItem("swish-profile"),localStorage.removeItem("swish-session"))}catch(e){console.warn("Failed to migrate legacy session id to Swish session",{cause:e})}}};var vt=class{static{i(this,"SwishApi")}constructor(e,t,r,s){this.config=e,this.storefrontContext=t;let o=H(t.myshopifyDomain);this.cache=new J(`swish-api-${o}`,"max-age=60, stale-while-revalidate=3600",s+(e.version??tn)),this.cache.cleanupExpiredEntries().catch(a=>{console.warn("Swish API cache initialization cleanup error:",a)}),this.auth=new yt(this,t,r),this.apiClient=_r({authToken:this.auth.getSwishToken(),config:{...e,fetch:this.fetchFunction.bind(this)},requestInterceptor:this.requestInterceptor.bind(this),responseInterceptor:this.responseInterceptor.bind(this)}),this.itemsLoader=qr(this)}async fetchFunction(e,t){let r=e instanceof Request?e.method:t?.method??"GET",o=(e instanceof Request?e.url:typeof e=="string"?e:e.toString()).includes("/orders");return r==="GET"&&!o?this.cache.fetchWithCache(e,t):fetch(e,t)}async requestInterceptor(e){let t=new URL(e.url,window.location.origin);!!this.config.authProxy&&t.pathname.startsWith(this.config.authProxy)||await this.initAuth();try{e.headers.set("Country",this.storefrontContext.localization.country),e.headers.set("Language",this.storefrontContext.localization.language),e.headers.set("Market",this.storefrontContext.localization.market)}catch(s){console.warn("Failed to set storefront context headers:",s)}return this.config.requestInterceptor&&(e=await this.config.requestInterceptor(e)),e}async responseInterceptor(e,t){let r=t.method!=="GET",s=t.url.includes("/profiles/token");if(r&&!s){let o=this.auth.hasToken(),a=!this.auth.hasProfile(),u=e.ok;await this.cache.clear(),o&&a&&u&&await this.auth.renewToken()}return await this.config.responseInterceptor?.(e,t),e}setAuthToken(e){this.apiClient.setAuthToken(e)}initAuth(){return this.auth.init()}async withFallback(e,t){return await this.initAuth(),this.auth.hasProfile()?e():Promise.resolve(t)}get items(){return{...this.apiClient.items,count:i(async()=>this.withFallback(()=>this.apiClient.items.count(),{data:{count:0}}),"count"),list:i(async(e,t)=>{let r=i(()=>{if(t?.batch&&e?.query){e.limit!==1&&console.warn("Batching will always limit to 1 item");let s=e.query.split(" ");s.length>1&&console.warn("Batching will only support one query parameter");let o=s[0];if(!o.match(/^product:\d+$/)&&!o.match(/^variant:\d+$/))console.warn("Batching will only support product:<id> or variant:<id>");else return this.itemsLoader?.load(o)}return this.apiClient.items.list(e)},"execute");return t?.shared?r():this.withFallback(r,{data:[],pageInfo:{next:null,previous:null,totalCount:0}})},"list"),findById:i(async e=>this.withFallback(()=>this.apiClient.items.findById(e),{data:null}),"findById")}}get lists(){return{...this.apiClient.lists,list:i(async e=>this.withFallback(()=>this.apiClient.lists.list(e),{data:[],pageInfo:{next:null,previous:null,totalCount:0}}),"list"),findById:i(async(e,t)=>{let r=i(()=>this.apiClient.lists.findById(e),"execute");return t?.shared?r():this.withFallback(()=>this.apiClient.lists.findById(e),{data:null})},"findById")}}get orders(){return{...this.apiClient.orders,list:i(async e=>this.withFallback(()=>this.apiClient.orders.list(e),{data:[],pageInfo:{next:null,previous:null,totalCount:0}}),"list"),findById:i(async e=>this.withFallback(()=>(typeof e=="string"&&(e=parseInt(e.split("/").pop()??e)),this.apiClient.orders.findById(e)),{data:null}),"findById")}}get profiles(){return this.apiClient.profiles}async clearCache(){await this.cache.clear()}};var gt=class{constructor(e){this.eventMap={"POST /items\\/?$":"item-create","DELETE /items\\/?$":"item-delete","PATCH /items\\/([^/]+)\\/?$":"item-update","DELETE /items\\/([^/]+)\\/?$":"item-delete","PUT /items\\/([^/]+)\\/lists\\/?$":"item-lists-update","POST /lists\\/?$":"list-create","DELETE /lists\\/?$":"list-delete","PATCH /lists\\/([^/]+)\\/?$":"list-update","DELETE /lists\\/([^/]+)\\/?$":"list-delete"};this.eventBus=e,this.processFetchResponse=this.processFetchResponse.bind(this)}static{i(this,"SwishApiPublisher")}async processFetchResponse(e,t){try{let r=this.getEventName(t.method,e.status,t.url);if(!r)return;let s=await e.clone().text();if(e.headers.get("Content-Type")?.includes("application/json"))try{s=JSON.parse(s).data}catch(o){console.warn(o)}this.eventBus.publish(r,s)}catch(r){console.warn(r)}}getEventName(e,t,r){e=e.toUpperCase();let s=new URL(r).pathname;return e==="GET"||t<200||t>=300?void 0:Object.entries(this.eventMap).find(([a])=>{let[u,c]=a.split(" ");return u!==e?!1:new RegExp(c).test(s)})?.[1]}};var wt=class{constructor(e,t){this.inflightModals=new Map;this.modalsWithScrollLock=new Set;this.scrollLockRefCount=0;this.scrollPositionBeforeLock=0;this._templatePromises=new Map;this._importPromises=new Map;this._lockScroll=i(()=>this.lockScroll(),"_lockScroll");this._unlockScroll=i(()=>this.unlockScroll(),"_unlockScroll");this.swishUiOptions=e,this.storefrontContext=t}static{i(this,"SwishUi")}async hideModal(e){if(this.inflightModals.has(e))return this.inflightModals.get(e);let t=(async()=>{try{if(typeof e=="string"&&(e=await this.requireUiComponent(e)),!e||e.getAttribute("open")!=="true")return;e.setAttribute("open","false")}finally{e&&typeof e!="string"&&this.modalsWithScrollLock.has(e)&&(this.modalsWithScrollLock.delete(e),this.unlockScroll())}})().finally(()=>{this.inflightModals.delete(e)});return this.inflightModals.set(e,t),t}async showModal(e){if(this.inflightModals.has(e))return this.inflightModals.get(e);let t=(async()=>{typeof e=="string"&&(e=await this.requireUiComponent(e)),!(!e||e.getAttribute("open")==="true")&&(this.lockScroll(),this.modalsWithScrollLock.add(e),e.setAttribute("open","true"))})().finally(()=>{this.inflightModals.delete(e)});return this.inflightModals.set(e,t),t}waitForEvent(e,t){return new Promise(r=>{let s=[],o=i(()=>{s.forEach(({event:a,listener:u})=>{e.removeEventListener(a,u)})},"cleanup");Object.entries(t).forEach(([a,u])=>{let c=i(l=>{let p=u(l);o(),r(p)},"listener");s.push({event:a,listener:c}),e.addEventListener(a,c)})})}async showSignIn(e){let t=await this.requireUiComponent("sign-in");t.setAttribute("return-to",e?.returnTo??window.location.pathname),await this.showModal(t);let r=await this.waitForEvent(t,{submit:i(()=>({code:"ok",data:void 0}),"submit"),close:i(()=>({code:"closed"}),"close")});return await this.hideModal(t),r}async showUnsaveAlert(e){if(!e.itemId)throw new Error("An itemId is required to show the unsave alert");await this.hideAllToasts();let t=await this.requireUiComponent("unsave-alert");t.setAttribute("item-id",e.itemId),await this.showModal(t);let r=await this.waitForEvent(t,{submit:i(s=>s instanceof CustomEvent?{code:"ok",data:s.detail}:(console.warn("Unsave alert submitted without detail",s),{code:"closed"}),"submit"),close:i(()=>({code:"closed"}),"close")});return await this.hideModal(t),r}async showDeleteListAlert(e){if(!e.listId)throw new Error("A listId is required to show the delete list alert");await this.hideAllToasts();let t=await this.requireUiComponent("delete-list-alert");t.setAttribute("list-id",e.listId),await this.showModal(t);let r=await this.waitForEvent(t,{submit:i(()=>({code:"ok",data:void 0}),"submit"),close:i(()=>({code:"closed"}),"close")});return await this.hideModal(t),r}async showConfirmDialog(e){await this.hideAllToasts();let t=await this.requireUiComponent("confirm-dialog");e.titleKey?t.setAttribute("title-key",e.titleKey):t.removeAttribute("title-key"),e.descriptionKey?t.setAttribute("description-key",e.descriptionKey):t.removeAttribute("description-key"),e.confirmLabelKey?t.setAttribute("confirm-label-key",e.confirmLabelKey):t.removeAttribute("confirm-label-key"),e.cancelLabelKey?t.setAttribute("cancel-label-key",e.cancelLabelKey):t.removeAttribute("cancel-label-key"),e.danger?t.setAttribute("danger",""):t.removeAttribute("danger"),await this.showModal(t);let r=await this.waitForEvent(t,{submit:i(()=>({code:"ok",data:void 0}),"submit"),close:i(()=>({code:"closed"}),"close")});return await this.hideModal(t),r}async showDrawer(e){await this.hideAllToasts();let t=await this.requireUiComponent("drawer");t.setAttribute("account-url",this.storefrontContext.routes.accountUrl),this.storefrontContext.customer.id&&t.setAttribute("customer-id",this.storefrontContext.customer.id),t.setAttribute("view",e?.view??"home"),e?.listId&&t.setAttribute("list-id",e.listId),e?.productId&&t.setAttribute("product-id",e.productId),e?.variantId&&t.setAttribute("variant-id",e.variantId),e?.orderId&&t.setAttribute("order-id",e.orderId),await this.showModal(t);let r=await this.waitForEvent(t,{close:i(()=>({code:"closed"}),"close")});return await this.hideModal(t),r}async showListMenu(e){if(!e.listId)throw new Error("listId is required");await this.hideAllToasts();let t=await this.requireUiComponent("list-menu");t.setAttribute("list-id",e.listId),await this.showModal(t);let r=await this.waitForEvent(t,{close:i(()=>({code:"closed"}),"close"),edit:i(s=>s instanceof CustomEvent?{code:"ok",data:{action:"edit",data:s.detail}}:(console.warn("List menu edit without detail",s),{code:"closed"}),"edit"),delete:i(()=>({code:"ok",data:{action:"delete"}}),"delete"),share:i(()=>({code:"ok",data:{action:"share"}}),"share"),"edit-access":i(s=>{if(s instanceof CustomEvent){let a=s.detail?.currentListAccess;if(a==="public"||a==="private")return{code:"ok",data:{action:"edit-access",data:{currentListAccess:a}}}}return{code:"ok",data:{action:"edit-access"}}},"edit-access")});return await this.hideModal(t),r}async showOrderMenu(e){if(!e.orderId)throw new Error("orderId is required");await this.hideAllToasts();let t=await this.requireUiComponent("order-menu");t.setAttribute("order-id",e.orderId),await this.showModal(t);let r=await this.waitForEvent(t,{close:i(()=>({code:"closed"}),"close")});return await this.hideModal(t),r}async showListDetailPageMenu(e){await this.hideAllToasts();let t=await this.requireUiComponent("list-detail-page-menu");t.setAttribute("list-id",e.listId),await this.showModal(t);let r=await this.waitForEvent(t,{close:i(()=>({code:"closed"}),"close")});return await this.hideModal(t),r}async showListSelect(e){if(!e.itemId)throw new Error("itemId is required");await this.hideAllToasts();let t=await this.requireUiComponent("list-select");t.setAttribute("item-id",e.itemId),await this.showModal(t);let r=await this.waitForEvent(t,{close:i(()=>({code:"closed"}),"close"),submit:i(s=>"detail"in s&&s.detail?{code:"ok",data:{action:"submit",data:s.detail}}:(console.warn("List select submit without detail",s),{code:"closed"}),"submit"),unsave:i(s=>s instanceof CustomEvent?{code:"ok",data:{action:"unsave",data:s.detail}}:(console.warn("List select unsave without detail",s),{code:"closed"}),"unsave")});return await this.hideModal(t),r}async initListDetailPage(e,t){let r=await this.requireUiComponent("list-detail-page",{refElement:t});e.listId&&r.setAttribute("list-id",e.listId)}async showToast(e){let t=Date.now(),r=await this.requireUiComponent("toast-manager",{onHydrated:i(s=>{s.current.show(e,t)},"onHydrated")});return this.waitForEvent(r,{[`close-${t}`]:()=>({code:"closed"}),[`submit-${t}`]:()=>({code:"ok",data:void 0})})}async hideAllToasts(){this.queryComponent("toast-manager")&&await this.requireUiComponent("toast-manager",{onHydrated:i(e=>{e.current.clear()},"onHydrated")})}async showVariantSelect(e){await this.hideAllToasts();let t=await this.requireUiComponent("variant-select");if(e?.itemId&&t.setAttribute("item-id",e.itemId),e?.productId)t.setAttribute("product-id",e.productId.toString());else if(e?.productHandle)t.setAttribute("product-handle",e.productHandle);else throw new Error("Either productId or productHandle must be provided");e?.variantId&&t.setAttribute("variant-id",e.variantId.toString()),await this.showModal(t);let r=await this.waitForEvent(t,{close:i(()=>({code:"closed"}),"close"),submit:i(s=>"detail"in s&&s.detail?{code:"ok",data:s.detail}:(console.warn("Variant select submit without detail",s),{code:"closed"}),"submit")});return await this.hideModal(t),r}async showQuickBuy(e){await this.hideAllToasts();let t=await this.requireUiComponent("quick-buy");if(e?.productId)t.setAttribute("product-id",e.productId.toString());else if(e?.productHandle)t.setAttribute("product-handle",e.productHandle);else throw new Error("ProductId or productHandle must be provided");e?.variantId&&t.setAttribute("variant-id",e.variantId.toString()),await this.showModal(t);let r=await this.waitForEvent(t,{close:i(()=>({code:"closed"}),"close"),submit:i(s=>"detail"in s&&s.detail?{code:"ok",data:s.detail}:(console.warn("Quick buy submit without detail",s),{code:"closed"}),"submit")});return await this.hideModal(t),r}async showListEditor(e){let t=await this.requireUiComponent("list-editor");e?.listId&&t.setAttribute("list-id",e.listId),await this.showModal(t);let r=await this.waitForEvent(t,{close:i(()=>({code:"closed"}),"close"),submit:i(s=>"detail"in s&&s.detail?{code:"ok",data:s.detail}:(console.warn("List editor submit without detail",s),{code:"closed"}),"submit")});return await this.hideModal(t),r}async createElement(e,t){let[r,{themeVariablesStylesheet:s}]=await Promise.all([this.loadTemplate(e),this.loadCricalResources()]),o=document.createElement("template");o.innerHTML=r.replace(' shadowrootmode="open"',"");let a=o.content.firstElementChild;return a.addEventListener("connected",()=>{a.shadowRoot&&(a.shadowRoot.adoptedStyleSheets=[s],this.hydrateElement(e,a,t?.onHydrated))},{once:!0}),a}async hydrateElement(e,t,r){if(t.hasAttribute("hydrated")){r?.(t.getComponentRef());return}await Promise.all([this.loadNonCriticalResources(),this.importScript(e)]).then(([{bundleCssStylesheet:s,customCssStylesheets:o},{hydrate:a}])=>{t.shadowRoot&&s&&(t.shadowRoot.adoptedStyleSheets=[...t.shadowRoot.adoptedStyleSheets,...o,s],t.shadowRoot?.querySelector(":host > style")?.remove()),a(t),t.setAttribute("hydrated","")}),r?.(t.getComponentRef())}async requireUiComponent(e,t){this.loadCricalResources();let r=await this.loadTemplate(e),s=this.queryComponent(e)??await this.insertComponent({name:e,template:r,refElement:t?.refElement??document.body,position:"beforeend"});return s.shadowRoot&&!s.hasAttribute("hydrated")?Promise.all([this.loadNonCriticalResources(),this.importScript(e)]).then(([{bundleCssStylesheet:o,customCssStylesheets:a},{hydrate:u}])=>{s.shadowRoot&&o&&(s.shadowRoot.adoptedStyleSheets=[...s.shadowRoot.adoptedStyleSheets,...a,o],s.shadowRoot?.querySelector(":host > style")?.remove()),u(s),s.setAttribute("hydrated",""),t?.onHydrated?.(s.getComponentRef())}):s.hasAttribute("hydrated")&&t?.onHydrated?.(s.getComponentRef()),s}async loadTemplate(e){let t=`${this.swishUiOptions.baseUrl}/ui@${this.swishUiOptions.version}/${e}.html`;if(this._templatePromises.has(t))return this._templatePromises.get(t);let r=fetch(t).then(s=>s.text());return this._templatePromises.set(t,r),r}async importScript(e){let t=`${this.swishUiOptions.baseUrl}/ui@${this.swishUiOptions.version}/${e}.js`;if(this._importPromises.has(t))return this._importPromises.get(t);let r=import(t);return this._importPromises.set(t,r),r}async loadCricalResources(){return this._loadCricalResourcesPromise?this._loadCricalResourcesPromise:(this._loadCricalResourcesPromise=(async()=>{let e=`${this.swishUiOptions.baseUrl}/ui@${this.swishUiOptions.version}/theme.css`,t=await fetch(e).then(o=>o.text()),r=new CSSStyleSheet;r.replaceSync(t);let s=lo(this.swishUiOptions.design);return Object.entries(s).forEach(([o,a])=>{r.cssRules[0].cssRules[0].style.setProperty(o,a)}),{themeVariablesStylesheet:r}})(),this._loadCricalResourcesPromise)}async loadNonCriticalResources(){return this._loadNonCriticalResourcesPromise?this._loadNonCriticalResourcesPromise:(this._loadNonCriticalResourcesPromise=(async()=>{let e=`${this.swishUiOptions.baseUrl}/ui@${this.swishUiOptions.version}/bundle.css`,t=i(o=>{let a=new CSSStyleSheet;return a.replaceSync(o),a},"createCssStylesheet"),[r,...s]=await Promise.all([fetch(e).then(o=>o.text()).then(t),...this.swishUiOptions.css.map(async o=>o instanceof URL?t(await fetch(o).then(a=>a.text())):t(o))]);return{bundleCssStylesheet:r,customCssStylesheets:s}})(),this._loadNonCriticalResourcesPromise)}async insertComponent({name:e,template:t,position:r,refElement:s}){let{themeVariablesStylesheet:o}=await this.loadCricalResources();s.insertAdjacentHTML(r,t.replace(' shadowrootmode="open"',""));let a=this.queryComponent(e);if(!a)throw new Error(`Element ${e} not found in DOM`);return a.shadowRoot&&(a.shadowRoot.adoptedStyleSheets=[o]),a}queryComponent(e,t){let r=`swish-ui[ref="${e}${t?`-${t}`:""}"]`;return document.querySelector(r)}lockScroll(){this.scrollLockRefCount++,this.scrollLockRefCount===1&&(this.scrollPositionBeforeLock=window.scrollY,this.scrollLockStyleSheet||(this.scrollLockStyleSheet=new CSSStyleSheet,document.adoptedStyleSheets=[...document.adoptedStyleSheets,this.scrollLockStyleSheet]),this.scrollLockStyleSheet.replaceSync(`
447
447
  html[swish-locked] body {
448
448
  overflow: hidden;
449
449
  position: fixed;
@@ -451,4 +451,4 @@ Values:
451
451
  left: 0px;
452
452
  right: 0px;
453
453
  }
454
- `),document.documentElement.setAttribute("swish-locked",""))}unlockScroll(){this.scrollLockRefCount>0&&this.scrollLockRefCount--,this.scrollLockRefCount===0&&(this.scrollLockStyleSheet&&this.scrollLockStyleSheet.replaceSync(""),window.scrollTo({top:this.scrollPositionBeforeLock,behavior:"instant"}),this.scrollPositionBeforeLock=0,document.documentElement.removeAttribute("swish-locked"))}};function ro(n){if(!n)return{};let e={},t=i(r=>{Object.entries(r).forEach(([s,o])=>{if(o!=null){if(typeof o=="object"&&!Array.isArray(o)){t(o);return}if(typeof o=="string"||typeof o=="number"){let a=s.startsWith("--")?s:`--swish-theme-${so(s)}`;e[a]=io(s,o)}}})},"walk");return t(n),e}i(ro,"flattenDesignTokens");function so(n){return n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase()}i(so,"toKebabCase");function io(n,e){return typeof e=="number"&&!oo(n)?`${e}px`:String(e)}i(io,"formatDesignValue");function oo(n){let e=n.toLowerCase();return e.includes("fontweight")||e.includes("scale")||e.includes("letterspacing")||e.includes("lineheight")}i(oo,"isNonPxValue");var ao=typeof HTMLElement<"u"?HTMLElement:class{},yt=class extends ao{constructor(){super();this.getComponentRef=i(()=>this.componentRef,"getComponentRef");this.setComponentRef=i(t=>{this.componentRef=t},"setComponentRef");this.shadowRoot||this.attachShadow({mode:"open"});let t=this.querySelector("template");t&&this.shadowRoot&&(this.shadowRoot.appendChild(t.content),t.remove())}static{i(this,"SwishUiElement")}connectedCallback(){this.dispatchEvent(new CustomEvent("connected"))}};var vt=class{static{i(this,"ShopifyBadgesUtils")}#e;constructor({getBadges:e}){this.#e=e?.bind(this)}getBadges({product:e,variant:t}){try{let r=this.getDefaultBadges({product:e,variant:t});return this.#e?this.mapBadges(this.#e({product:e,variant:t,defaultBadges:r})??[]):this.mapBadges(r)}catch(r){return console.error("Error getting badges",r),[]}}getDefaultBadges({product:e,variant:t}){let r=[];if(e?.availableForSale===!1||t?.availableForSale===!1)return r.push("Sold out"),r;let s=t?t.price.amount:e?.priceRange?.minVariantPrice.amount,o=t?t.compareAtPrice?.amount:e?.compareAtPriceRange?.minVariantPrice.amount;return o&&parseFloat(o)>parseFloat(s)&&r.push("Sale"),r}mapBadges(e){return e.map(t=>typeof t=="string"?{id:t.toLowerCase().replace(/[^a-z0-9]/g,"_"),label:t}:t)}};var tt="0.108.0",qd=`https://swish.app/cdn/sdk@${tt}/swish.js`,Nd=i(async n=>{if(typeof window>"u")throw new Error("Swish is not supported in this environment");if(window.swish)return window.swish;let e=bn(n),t=new rn(e);return window.swish=t,document.dispatchEvent(new Event("swish-ready")),t.api.initAuth().then(()=>{typeof window.Shopify?.analytics?.publish=="function"&&window.Shopify.analytics.publish("swish-ready",{market:e.storefrontContext.localization.market,country:e.storefrontContext.localization.country,language:e.storefrontContext.localization.language,rootUrl:e.storefrontContext.routes.rootUrl})}),t},"createSwish"),rn=class{constructor(e){this.dom={createElementLocator:ie,createLocationObserver:le,createPlacement:i(e=>fn(this,e),"createPlacement")};this.ui={createElement:i((e,t)=>this.swishUi.createElement(e,t),"createElement")};this.utils={copyToClipboard:me,createShareUrl:i(e=>he(this,e),"createShareUrl")};this.state={itemContext:Dn(this),itemState:Pn(this),itemCount:Tn(this),swishQuery:_n(this),effect:Q,signal:$,computed:F};this.swishOptions=e,this.events=new Se,this.swishBadges=new vt({getBadges:this.swishOptions.badges?.getBadges}),this.swishApiPublisher=new ht(this.events);let t=[tt,e.swishUi?.version].join("-");this.swishApi=new ft({...this.swishOptions.swishApi,responseInterceptor:this.swishApiPublisher.processFetchResponse},this.swishOptions.storefrontContext,this.events,t),this.ajaxApiPublisher=new Ie(this.events),this.ajaxApi=new we({storeDomain:this.swishOptions.storefrontApi.storeDomain,responseInterceptor:this.ajaxApiPublisher.processFetchResponse}),this.ajaxApi.patchFetch(),this.storefrontApi=new ct(this.swishOptions.storefrontApi,this.swishOptions.storefrontContext,this.swishBadges,this.swishOptions.productOptions,this.swishOptions.metafields),this.swishUi=new mt(this.swishOptions.swishUi,this.swishOptions.storefrontContext),this.events.subscribe(["cart-add","cart-update","cart-change","cart-clear"],()=>{this.ajaxApi.clearCache()}),customElements.get("swish-ui")||customElements.define("swish-ui",yt),this.intents=new et(this,this.swishUi)}static{i(this,"SwishApp")}get options(){return this.swishOptions}get storefrontContext(){return this.swishOptions.storefrontContext}get badges(){return this.swishBadges}get api(){return this.swishApi}get storefront(){return this.storefrontApi}get ajax(){return this.ajaxApi}get shopUrl(){return`https://${this.swishOptions.storefrontApi.storeDomain}`}};export{tt as VERSION,he as buildShareListUrl,me as copyToClipboard,Nd as createSwish,qd as swishSdkUrl};
454
+ `),document.documentElement.setAttribute("swish-locked",""))}unlockScroll(){this.scrollLockRefCount>0&&this.scrollLockRefCount--,this.scrollLockRefCount===0&&(this.scrollLockStyleSheet&&this.scrollLockStyleSheet.replaceSync(""),window.scrollTo({top:this.scrollPositionBeforeLock,behavior:"instant"}),this.scrollPositionBeforeLock=0,document.documentElement.removeAttribute("swish-locked"))}};function lo(n){if(!n)return{};let e={},t=i(r=>{Object.entries(r).forEach(([s,o])=>{if(o!=null){if(typeof o=="object"&&!Array.isArray(o)){t(o);return}if(typeof o=="string"||typeof o=="number"){let a=s.startsWith("--")?s:`--swish-theme-${po(s)}`;e[a]=fo(s,o)}}})},"walk");return t(n),e}i(lo,"flattenDesignTokens");function po(n){return n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase()}i(po,"toKebabCase");function fo(n,e){return typeof e=="number"&&!ho(n)?`${e}px`:String(e)}i(fo,"formatDesignValue");function ho(n){let e=n.toLowerCase();return e.includes("fontweight")||e.includes("scale")||e.includes("letterspacing")||e.includes("lineheight")}i(ho,"isNonPxValue");var mo=typeof HTMLElement<"u"?HTMLElement:class{},It=class extends mo{constructor(){super();this.getComponentRef=i(()=>this.componentRef,"getComponentRef");this.setComponentRef=i(t=>{this.componentRef=t},"setComponentRef");this.shadowRoot||this.attachShadow({mode:"open"});let t=this.querySelector("template");t&&this.shadowRoot&&(this.shadowRoot.appendChild(t.content),t.remove())}static{i(this,"SwishUiElement")}connectedCallback(){this.dispatchEvent(new CustomEvent("connected"))}};var bt=class{static{i(this,"ShopifyBadgesUtils")}#e;constructor({getBadges:e}){this.#e=e?.bind(this)}getBadges({product:e,variant:t}){try{let r=this.getDefaultBadges({product:e,variant:t});return this.#e?this.mapBadges(this.#e({product:e,variant:t,defaultBadges:r})??[]):this.mapBadges(r)}catch(r){return console.error("Error getting badges",r),[]}}getDefaultBadges({product:e,variant:t}){let r=[];if(e?.availableForSale===!1||t?.availableForSale===!1)return r.push("Sold out"),r;let s=t?t.price.amount:e?.priceRange?.minVariantPrice.amount,o=t?t.compareAtPrice?.amount:e?.compareAtPriceRange?.minVariantPrice.amount;return o&&parseFloat(o)>parseFloat(s)&&r.push("Sale"),r}mapBadges(e){return e.map(t=>typeof t=="string"?{id:t.toLowerCase().replace(/[^a-z0-9]/g,"_"),label:t}:t)}};var it="0.109.0",ef=`https://swish.app/cdn/sdk@${it}/swish.js`,tf=i(async n=>{if(typeof window>"u")throw new Error("Swish is not supported in this environment");if(window.swish)return window.swish;let e=En(n),t=new on(e);return window.swish=t,document.dispatchEvent(new Event("swish-ready")),t.api.initAuth().then(()=>{typeof window.Shopify?.analytics?.publish=="function"&&window.Shopify.analytics.publish("swish-ready",{market:e.storefrontContext.localization.market,country:e.storefrontContext.localization.country,language:e.storefrontContext.localization.language,rootUrl:e.storefrontContext.routes.rootUrl})}),t},"createSwish"),on=class{constructor(e){this.dom={createElementLocator:ie,createLocationObserver:pe,createPlacement:i(e=>mn(this,e),"createPlacement")};this.ui={createElement:i((e,t)=>this.swishUi.createElement(e,t),"createElement")};this.utils={copyToClipboard:ve,createShareUrl:i(e=>ye(this,e),"createShareUrl")};this.state={itemContext:Tn(this),itemState:_n(this),itemCount:On(this),swishQuery:Ln(this),effect:Q,signal:V,computed:F};this.swishOptions=e,this.events=new xe,this.swishBadges=new bt({getBadges:this.swishOptions.badges?.getBadges}),this.swishApiPublisher=new gt(this.events);let t=[it,e.swishUi?.version].join("-");this.swishApi=new vt({...this.swishOptions.swishApi,responseInterceptor:this.swishApiPublisher.processFetchResponse},this.swishOptions.storefrontContext,this.events,t),this.ajaxApiPublisher=new Se(this.events),this.ajaxApi=new be({storeDomain:this.swishOptions.storefrontApi.storeDomain,responseInterceptor:this.ajaxApiPublisher.processFetchResponse}),this.ajaxApi.patchFetch(),this.storefrontApi=new ft(this.swishOptions.storefrontApi,this.swishOptions.storefrontContext,this.swishBadges,this.swishOptions.productOptions,this.swishOptions.metafields),this.swishUi=new wt(this.swishOptions.swishUi,this.swishOptions.storefrontContext),this.events.subscribe(["cart-add","cart-update","cart-change","cart-clear"],()=>{this.ajaxApi.clearCache()}),customElements.get("swish-ui")||customElements.define("swish-ui",It),this.intents=new st(this,this.swishUi)}static{i(this,"SwishApp")}get options(){return this.swishOptions}get storefrontContext(){return this.swishOptions.storefrontContext}get badges(){return this.swishBadges}get api(){return this.swishApi}get storefront(){return this.storefrontApi}get ajax(){return this.ajaxApi}get shopUrl(){return`https://${this.swishOptions.storefrontApi.storeDomain}`}};export{it as VERSION,ye as buildShareListUrl,ve as copyToClipboard,tf as createSwish,ef as swishSdkUrl};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swishapp/sdk",
3
- "version": "0.108.0",
3
+ "version": "0.109.0",
4
4
  "description": "JS SDK for Swish.",
5
5
  "author": "Swish",
6
6
  "license": "UNLICENSED",