@swishapp/sdk 0.107.0 → 0.108.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.
@@ -28,6 +28,7 @@ export interface SwishBadgeOptions {
28
28
  }
29
29
  export interface SwishProductOptions {
30
30
  sortValues: (args: {
31
+ option: NonNullable<GetProductOptionsQuery["product"]>["options"][number];
31
32
  optionValues: NonNullable<GetProductOptionsQuery["product"]>["options"][number]["optionValues"];
32
33
  }) => NonNullable<GetProductOptionsQuery["product"]>["options"][number]["optionValues"];
33
34
  }
@@ -82,9 +82,16 @@ export declare class StorefrontApiClient {
82
82
  errors: ResponseErrors | null;
83
83
  } | {
84
84
  data: {
85
- product: {
86
- options: {
87
- optionValues: (Pick<import("./types/storefront.types").ProductOptionValue, "name"> & {
85
+ badges: import("../utils/shopify-badge-utils").Badge[];
86
+ product?: import("./types/storefront.types").Maybe<(Pick<import("./types/storefront.types").Product, "id" | "availableForSale" | "isGiftCard" | "onlineStoreUrl" | "description" | "descriptionHtml" | "handle" | "productType" | "tags" | "title" | "encodedVariantAvailability" | "encodedVariantExistence"> & {
87
+ category?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").TaxonomyCategory, "id" | "name">>;
88
+ compareAtPriceRange: {
89
+ maxVariantPrice: Pick<import("./types/storefront.types").MoneyV2, "amount" | "currencyCode">;
90
+ minVariantPrice: Pick<import("./types/storefront.types").MoneyV2, "amount" | "currencyCode">;
91
+ };
92
+ featuredImage?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").Image, "id" | "altText" | "url" | "thumbhash">>;
93
+ options: Array<(Pick<import("./types/storefront.types").ProductOption, "id" | "name"> & {
94
+ optionValues: Array<(Pick<import("./types/storefront.types").ProductOptionValue, "name"> & {
88
95
  swatch?: import("./types/storefront.types").Maybe<(Pick<import("./types/storefront.types").ProductOptionValueSwatch, "color"> & {
89
96
  image?: import("./types/storefront.types").Maybe<{
90
97
  previewImage?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").Image, "url">>;
@@ -93,28 +100,8 @@ export declare class StorefrontApiClient {
93
100
  firstSelectableVariant?: import("./types/storefront.types").Maybe<(Pick<import("./types/storefront.types").ProductVariant, "id"> & {
94
101
  image?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").Image, "id" | "altText" | "url" | "thumbhash">>;
95
102
  })>;
96
- })[];
97
- name: import("./types/storefront.types").Scalars["String"]["output"];
98
- id: import("./types/storefront.types").Scalars["ID"]["output"];
99
- }[];
100
- title: import("./types/storefront.types").Scalars["String"]["output"];
101
- id: import("./types/storefront.types").Scalars["ID"]["output"];
102
- availableForSale: import("./types/storefront.types").Scalars["Boolean"]["output"];
103
- isGiftCard: import("./types/storefront.types").Scalars["Boolean"]["output"];
104
- onlineStoreUrl?: import("./types/storefront.types").Maybe<import("./types/storefront.types").Scalars["URL"]["output"]>;
105
- description: import("./types/storefront.types").Scalars["String"]["output"];
106
- descriptionHtml: import("./types/storefront.types").Scalars["HTML"]["output"];
107
- handle: import("./types/storefront.types").Scalars["String"]["output"];
108
- productType: import("./types/storefront.types").Scalars["String"]["output"];
109
- tags: Array<import("./types/storefront.types").Scalars["String"]["output"]>;
110
- encodedVariantAvailability?: import("./types/storefront.types").Maybe<import("./types/storefront.types").Scalars["String"]["output"]> | undefined;
111
- encodedVariantExistence?: import("./types/storefront.types").Maybe<import("./types/storefront.types").Scalars["String"]["output"]> | undefined;
112
- category?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").TaxonomyCategory, "id" | "name">>;
113
- compareAtPriceRange: {
114
- maxVariantPrice: Pick<import("./types/storefront.types").MoneyV2, "amount" | "currencyCode">;
115
- minVariantPrice: Pick<import("./types/storefront.types").MoneyV2, "amount" | "currencyCode">;
116
- };
117
- featuredImage?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").Image, "id" | "altText" | "url" | "thumbhash">>;
103
+ })>;
104
+ })>;
118
105
  priceRange: {
119
106
  maxVariantPrice: Pick<import("./types/storefront.types").MoneyV2, "amount" | "currencyCode">;
120
107
  minVariantPrice: Pick<import("./types/storefront.types").MoneyV2, "amount" | "currencyCode">;
@@ -124,8 +111,7 @@ export declare class StorefrontApiClient {
124
111
  images: {
125
112
  nodes: Array<Pick<import("./types/storefront.types").Image, "id" | "altText" | "url" | "thumbhash">>;
126
113
  };
127
- } | undefined;
128
- badges: import("../utils/shopify-badge-utils").Badge[];
114
+ })>;
129
115
  variant?: import("./types/storefront.types").Maybe<(Pick<import("./types/storefront.types").ProductVariant, "id" | "availableForSale" | "currentlyNotInStock" | "sku" | "title"> & {
130
116
  compareAtPrice?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").MoneyV2, "amount" | "currencyCode">>;
131
117
  image?: import("./types/storefront.types").Maybe<Pick<import("./types/storefront.types").Image, "id" | "altText" | "url" | "thumbhash">>;
package/dist/swish.js CHANGED
@@ -4,8 +4,8 @@ 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 V={id:e.id,targetEl:l,renderTargetEl:y,mountEl:I.mountEl,containerEl:b,rowEl:g,cleanup:i(k=>p.push(k),"cleanup")};e.element?.name==="save-button"&&Wr(n,V),e.onMount?.(V)},"mountElement"),u=i(l=>{let p=r.get(l);if(p){if(e.onUnmount?.({id:e.id,targetEl:p.targetEl,renderTargetEl:p.renderTargetEl,mountEl:p.mountEl,containerEl:p.containerEl,rowEl:p.rowEl}),p.cleanupFns.forEach(f=>f()),p.targetEl.getAttribute("swish-placement-target")===e.id&&p.targetEl.removeAttribute("swish-placement-target"),p.ownsNode&&(p.containerEl||p.mountEl).remove(),p.rowEl){if(p.rowWasCreated){let f=p.rowEl.parentElement;f&&p.targetEl.parentElement===p.rowEl?p.rowEl.replaceWith(p.targetEl):f?f.removeChild(p.rowEl):p.rowEl.remove()}else if(p.rowInlineAttrPrevValue!==void 0){let f=p.rowInlineAttrPrevValue;f===null?p.rowEl.removeAttribute("swish-placement-inline-row"):p.rowEl.setAttribute("swish-placement-inline-row",f)}}r.delete(l)}},"unmountElement");return{mount:s,unmount:i(()=>{t&&(t.disconnect(),t=null),r.forEach((l,p)=>u(p)),r.clear()},"unmount")}}i(fn,"createPlacement");var Wr=i((n,{mountEl:e,targetEl:t,cleanup:r})=>{let s=n.state.itemContext(t),o=n.state.effect(()=>{let{loading:a,productId:u,variantId:c}=s.value;a||(e.setAttribute("product-id",u??""),e.setAttribute("variant-id",c??""))});r(()=>o?.())},"saveButtonMount");function Kr(n){let e=Xr(n.id),t=ss(n),r=document.getElementById(e);if(r){r.textContent=t;return}let s=document.createElement("style");s.id=e,s.setAttribute("swish-placement-style",n.id),s.textContent=t,document.head.appendChild(s)}i(Kr,"ensurePlacementStylesheet");function Xr(n){return`swish-placement-style-${Yr(n)}`}i(Xr,"getPlacementStyleId");function Yr(n){return n.replace(/[^a-zA-Z0-9\-_]/g,"_")}i(Yr,"cssEscapeId");function pn(n){return`--swish-placement-${Jr(String(n))}`}i(pn,"designKeyToCSSVar");function Jr(n){return n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase()}i(Jr,"toKebabCase");function Zr(n){return Object.entries(n??{sm:500,lg:700}).map(([r,s])=>({name:r,minWidth:s})).sort((r,s)=>r.minWidth-s.minWidth)}i(Zr,"getBreakpoints");function hn(n,e){if(n==null)return{};if(typeof n=="object"&&!Array.isArray(n)){if(e&&e.size){let t=Object.keys(n);return"base"in n||t.some(s=>e.has(s))?n:{base:n}}return n}return{base:n}}i(hn,"normalizeResponsiveValue");var es=new Set(["fontWeight","lineHeight","pressedScale","backgroundAlpha","pressedOpacity","pressedScale"]);function dn(n,e){if(e!=null)return typeof e=="number"&&!es.has(n)?`${e}px`:String(e)}i(dn,"formatDesignValue");function ts(n,e,t){if(!e)return"";let r=new Set(t.map(c=>c.name)),s=[],o={},a=Object.entries(e).map(([c,l])=>[c,l]);for(let[c,l]of a){let p=hn(l,r),f=dn(String(c),p.base);f!==void 0&&s.push(`${pn(c)}:${f};`);for(let y of t){let h=p[y.name],b=dn(String(c),h);b!==void 0&&(o[y.name]||(o[y.name]=[]),o[y.name].push(`${pn(c)}:${b};`))}}let u=[];s.length&&u.push(`[swish-placement-element="${n}"]{${s.join("")}}`);for(let c of t){let l=o[c.name];l?.length&&u.push(`@media(min-width:${c.minWidth}px){[swish-placement-element="${n}"]{${l.join("")}}}`)}return u.join("")}i(ts,"emitDesignCSS");function be(n){return n==null?"0px":typeof n=="number"?`${n}px`:n}i(be,"formatOffsetValue");function ns(n){return n==null?"":typeof n=="number"?`${n}`:n}i(ns,"formatZIndexValue");function rs(n,e,t){let r=new Set(t.map(l=>l.name)),s=hn(e,r),o=s.base??{},a=be(o.x),u=be(o.y),c=[];c.push(`[swish-placement-overlay="${n}"]{--swish-placement-offset-x:${a};--swish-placement-offset-y:${u};}`);for(let l of t){let p=s[l.name];if(!p)continue;let f=be(p.x),y=be(p.y);c.push(`@media(min-width:${l.minWidth}px){[swish-placement-overlay="${n}"]{--swish-placement-offset-x:${f};--swish-placement-offset-y:${y};}}`)}return c.join("")}i(rs,"emitOverlayOffsetCSS");function ss(n){let e=n.id,t=Zr(n.breakpoints),r=`[swish-placement-inline-row="${e}"]{display:flex;flex-direction:row;align-items:center;gap:var(--swish-placement-inline-gap,8px);width:100%}[swish-placement-inline-row="${e}"]>*:not([swish-placement-element="${e}"]){flex:1;min-width:0}`,s=`[swish-placement-overlay="${e}"]{position:absolute;z-index:var(--swish-placement-overlay-z,10);transform:translate(calc(var(--swish-placement-sign-x,1)*var(--swish-placement-offset-x,0px)),calc(var(--swish-placement-sign-y,1)*var(--swish-placement-offset-y,0px)));}[swish-placement-overlay="${e}"][swish-placement-anchor="top-left"]{top:0;left:0;}[swish-placement-overlay="${e}"][swish-placement-anchor="top-right"]{top:0;right:0;}[swish-placement-overlay="${e}"][swish-placement-anchor="bottom-left"]{bottom:0;left:0;}[swish-placement-overlay="${e}"][swish-placement-anchor="bottom-right"]{bottom:0;right:0;}[swish-placement-overlay="${e}"][swish-placement-anchor$="left"]{--swish-placement-sign-x:1;}[swish-placement-overlay="${e}"][swish-placement-anchor$="right"]{--swish-placement-sign-x:-1;}[swish-placement-overlay="${e}"][swish-placement-anchor^="top"]{--swish-placement-sign-y:1;}[swish-placement-overlay="${e}"][swish-placement-anchor^="bottom"]{--swish-placement-sign-y:-1;}`,o="";if(n.layout?.type==="overlay"){let a=rs(e,n.layout.offset,t),u=n.layout.zIndex?`[swish-placement-overlay="${e}"]{--swish-placement-overlay-z:${ns(n.layout.zIndex)};}`:"";o+=a+u+s}else n.layout?.type==="inline"&&(o+=r);if(n.design){let a=ts(e,n.design,t);a&&(o+=a)}return n.css&&(o+=n.css.trim()),o}i(ss,"buildPlacementCSS");function is(n,e){if(!e||e==="target")return n;if("closest"in e)return n.closest(e.closest);if("query"in e)return n.querySelector(e.query);if("withinClosest"in e){let t=n.closest(e.withinClosest.root);return t?t.querySelector(e.withinClosest.selector):null}return n}i(is,"resolveMountTarget");function os(n,e,t){switch(t){case"before":return n.parentElement?(n.before(e),!0):!1;case"after":{let r=n.parentElement;return r?(r.insertBefore(e,n.nextSibling),!0):!1}case"append":return n.appendChild(e),!0;case"prepend":return n.insertBefore(e,n.firstChild),!0;case"replace":return n.parentElement?(n.replaceWith(e),!0):!1}}i(os,"insertIntoDOM");function as(n){let e=n.parentElement;return e?(window.getComputedStyle(e).position==="static"&&(e.style.position="relative"),e):null}i(as,"ensureRelativeParent");function us(n,e,t){if(!e.parentElement)throw new Error("Cannot inline-wrap: refEl has no parentElement");let s=document.createElement("div");return s.setAttribute("swish-placement-inline-row",n),e.before(s),s.appendChild(e),s}i(us,"wrapWithFlexRow");function cs(n,e){let t=e.tag||"div",r=document.createElement(t);return r.setAttribute("swish-placement-container",n),e.classNames&&mn(r,e.classNames),r}i(cs,"createContainer");function ls(n,e){return n.ui.createElement(e.name,{})}i(ls,"createElement");function ps(n,e){for(let[t,r]of Object.entries(e)){let s=t.replace(/([A-Z])/g,"-$1").toLowerCase();r===!1||r===void 0||r===null||(r===!0?n.setAttribute(s,"true"):n.setAttribute(s,String(r)))}}i(ps,"applyProps");function mn(n,e){n.classList.add(...e)}i(mn,"applyClassNames");var Se=class{constructor(){this.eventBus=new EventTarget}static{i(this,"EventBus")}subscribe(e,t,r){return Array.isArray(e)||(e=[e]),e.forEach(s=>{this.eventBus.addEventListener(s,t,r)}),()=>{e.forEach(s=>{this.eventBus.removeEventListener(s,t,r)})}}unsubscribe(e,t,r){this.eventBus.removeEventListener(e,t,r)}publish(e,t){this.eventBus.dispatchEvent(new CustomEvent(e,{detail:t}))}};var m=class{constructor(e,t,r,s){this.swish=e;this.ui=t;this.eventBus=r;this.options=s}static{i(this,"IntentHandler")}};var Ee=class extends m{static{i(this,"CreateListHandler")}async invoke(e){let t=await this.ui.showListEditor();if(t.code==="closed")return{intent:"create:list",code:"closed"};let{list:r}=t.data;return{intent:"create:list",code:"ok",data:{list:r}}}};var wt;function vn(n){return{lang:n?.lang??wt?.lang,message:n?.message,abortEarly:n?.abortEarly??wt?.abortEarly,abortPipeEarly:n?.abortPipeEarly??wt?.abortPipeEarly}}i(vn,"getGlobalConfig");var ds;function fs(n){return ds?.get(n)}i(fs,"getGlobalMessage");var hs;function ms(n){return hs?.get(n)}i(ms,"getSchemaMessage");var ys;function vs(n,e){return ys?.get(n)?.get(e)}i(vs,"getSpecificMessage");function xe(n){let e=typeof n;return e==="string"?`"${n}"`:e==="number"||e==="bigint"||e==="boolean"?`${n}`:e==="object"||e==="function"?(n&&Object.getPrototypeOf(n)?.constructor?.name)??"null":e}i(xe,"_stringify");function K(n,e,t,r,s){let o=s&&"input"in s?s.input:t.value,a=s?.expected??n.expects??null,u=s?.received??xe(o),c={kind:n.kind,type:n.type,input:o,expected:a,received:u,message:`Invalid ${e}: ${a?`Expected ${a} but r`:"R"}eceived ${u}`,requirement:n.requirement,path:s?.path,issues:s?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},l=n.kind==="schema",p=s?.message??n.message??vs(n.reference,c.lang)??(l?ms(c.lang):null)??r.message??fs(c.lang);p!==void 0&&(c.message=typeof p=="function"?p(c):p),l&&(t.typed=!1),t.issues?t.issues.push(c):t.issues=[c]}i(K,"_addIssue");function J(n){return{version:1,vendor:"valibot",validate(e){return n["~run"]({value:e},vn())}}}i(J,"_getStandardProps");function gn(n,e){let t=[...new Set(n)];return t.length>1?`(${t.join(` ${e} `)})`:t[0]??"never"}i(gn,"_joinExpects");function It(n,e){return{kind:"validation",type:"min_length",reference:It,async:!1,expects:`>=${n}`,requirement:n,message:e,"~run"(t,r){return t.typed&&t.value.length<this.requirement&&K(this,"length",t,r,{received:`${t.value.length}`}),t}}}i(It,"minLength");function te(n,e){return{kind:"validation",type:"min_value",reference:te,async:!1,expects:`>=${n instanceof Date?n.toJSON():xe(n)}`,requirement:n,message:e,"~run"(t,r){return t.typed&&!(t.value>=this.requirement)&&K(this,"value",t,r,{received:t.value instanceof Date?t.value.toJSON():xe(t.value)}),t}}}i(te,"minValue");function P(n){return{kind:"transformation",type:"transform",reference:P,async:!1,operation:n,"~run"(e){return e.value=this.operation(e.value),e}}}i(P,"transform");function gs(n,e,t){return typeof n.fallback=="function"?n.fallback(e,t):n.fallback}i(gs,"getFallback");function wn(n,e,t){return typeof n.default=="function"?n.default(e,t):n.default}i(wn,"getDefault");function de(n,e){return{kind:"schema",type:"array",reference:de,expects:"Array",async:!1,item:n,message:e,get"~standard"(){return J(this)},"~run"(t,r){let s=t.value;if(Array.isArray(s)){t.typed=!0,t.value=[];for(let o=0;o<s.length;o++){let a=s[o],u=this.item["~run"]({value:a},r);if(u.issues){let c={type:"array",origin:"value",input:s,key:o,value:a};for(let l of u.issues)l.path?l.path.unshift(c):l.path=[c],t.issues?.push(l);if(t.issues||(t.issues=u.issues),r.abortEarly){t.typed=!1;break}}u.typed||(t.typed=!1),t.value.push(u.value)}}else K(this,"type",t,r);return t}}}i(de,"array");function bt(n){return{kind:"schema",type:"boolean",reference:bt,expects:"boolean",async:!1,message:n,get"~standard"(){return J(this)},"~run"(e,t){return typeof e.value=="boolean"?e.typed=!0:K(this,"type",e,t),e}}}i(bt,"boolean");function x(n){return{kind:"schema",type:"number",reference:x,expects:"number",async:!1,message:n,get"~standard"(){return J(this)},"~run"(e,t){return typeof e.value=="number"&&!isNaN(e.value)?e.typed=!0:K(this,"type",e,t),e}}}i(x,"number");function w(n,e){return{kind:"schema",type:"object",reference:w,expects:"Object",async:!1,entries:n,message:e,get"~standard"(){return J(this)},"~run"(t,r){let s=t.value;if(s&&typeof s=="object"){t.typed=!0,t.value={};for(let o in this.entries){let a=this.entries[o];if(o in s||(a.type==="exact_optional"||a.type==="optional"||a.type==="nullish")&&a.default!==void 0){let u=o in s?s[o]:wn(a),c=a["~run"]({value:u},r);if(c.issues){let l={type:"object",origin:"value",input:s,key:o,value:u};for(let p of c.issues)p.path?p.path.unshift(l):p.path=[l],t.issues?.push(p);if(t.issues||(t.issues=c.issues),r.abortEarly){t.typed=!1;break}}c.typed||(t.typed=!1),t.value[o]=c.value}else if(a.fallback!==void 0)t.value[o]=gs(a);else if(a.type!=="exact_optional"&&a.type!=="optional"&&a.type!=="nullish"&&(K(this,"key",t,r,{input:void 0,expected:`"${o}"`,path:[{type:"object",origin:"key",input:s,key:o,value:s[o]}]}),r.abortEarly))break}}else K(this,"type",t,r);return t}}}i(w,"object");function _(n,e){return{kind:"schema",type:"optional",reference:_,expects:`(${n.expects} | undefined)`,async:!1,wrapped:n,default:e,get"~standard"(){return J(this)},"~run"(t,r){return t.value===void 0&&(this.default!==void 0&&(t.value=wn(this,t,r)),t.value===void 0)?(t.typed=!0,t):this.wrapped["~run"](t,r)}}}i(_,"optional");function fe(n,e){return{kind:"schema",type:"picklist",reference:fe,expects:gn(n.map(xe),"|"),async:!1,options:n,message:e,get"~standard"(){return J(this)},"~run"(t,r){return this.options.includes(t.value)?t.typed=!0:K(this,"type",t,r),t}}}i(fe,"picklist");function v(n){return{kind:"schema",type:"string",reference:v,expects:"string",async:!1,message:n,get"~standard"(){return J(this)},"~run"(e,t){return typeof e.value=="string"?e.typed=!0:K(this,"type",e,t),e}}}i(v,"string");function yn(n){let e;if(n)for(let t of n)e?e.push(...t.issues):e=t.issues;return e}i(yn,"_subIssues");function M(n,e){return{kind:"schema",type:"union",reference:M,expects:gn(n.map(t=>t.expects),"|"),async:!1,options:n,message:e,get"~standard"(){return J(this)},"~run"(t,r){let s,o,a;for(let u of this.options){let c=u["~run"]({value:t.value},r);if(c.typed)if(c.issues)o?o.push(c):o=[c];else{s=c;break}else a?a.push(c):a=[c]}if(s)return s;if(o){if(o.length===1)return o[0];K(this,"type",t,r,{issues:yn(o)}),t.typed=!0}else{if(a?.length===1)return a[0];K(this,"type",t,r,{issues:yn(a)})}return t}}}i(M,"union");function S(...n){return{...n[0],pipe:n,get"~standard"(){return J(this)},"~run"(e,t){for(let r of n)if(r.kind!=="metadata"){if(e.issues&&(r.kind==="schema"||r.kind==="transformation")){e.typed=!1;break}(!e.issues||!t.abortEarly&&!t.abortPipeEarly)&&(e=r["~run"](e,t))}return e}}}i(S,"pipe");function E(n,e,t){let r=n["~run"]({value:e},vn(t));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}i(E,"safeParse");var ws=w({itemId:v(),delete:_(bt())}),Ce=class extends m{static{i(this,"UnsaveItemHandler")}async invoke(e){let t=E(ws,e);if(!t.success)return{intent:"unsave:item",code:"error",message:"Invalid intent data",issues:t.issues.map(a=>a.message)};let{itemId:r,delete:s}=t.output;if(this.options.unsaveProduct.selectList&&!s){let a=await this.ui.showListSelect({itemId:r});if(a.code==="closed")return{intent:"unsave:item",code:"closed"};if(a.data.action==="submit"){let{item:u,product:c,variant:l}=a.data.data;return{intent:"edit:item-lists",code:"ok",data:{item:u,product:c,variant:l}}}if(a.data.action==="unsave"){let{itemId:u}=a.data.data;return{intent:"unsave:item",code:"ok",data:{itemId:u}}}}if(!this.options.unsaveProduct.confirm){let a=await this.swish.api.items.deleteById(r);return"error"in a?{intent:"unsave:item",code:"error",message:"Failed to delete item",issues:[a.error.message]}:{intent:"unsave:item",code:"ok",data:{itemId:r}}}return(await this.ui.showUnsaveAlert({itemId:r})).code==="closed"?{intent:"unsave:item",code:"closed"}:{intent:"unsave:item",code:"ok",data:{itemId:r}}}};var Is=w({listId:v()}),ke=class extends m{static{i(this,"DeleteListHandler")}async invoke(e){let t=E(Is,e);if(!t.success)return{intent:"delete:list",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{listId:r}=t.output;return(await this.ui.showDeleteListAlert({listId:r})).code==="closed"?{intent:"delete:list",code:"closed"}:{intent:"delete:list",code:"ok",data:{listId:r}}}};var bs=w({itemId:v()}),Re=class extends m{static{i(this,"EditItemListsHandler")}async invoke(e){let t=E(bs,e);if(!t.success)return{intent:"edit:item-lists",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{itemId:r}=t.output,s=await this.ui.showListSelect({itemId:r});if(s.code==="closed")return{intent:"edit:item-lists",code:"closed"};if(s.data.action==="submit"){let{item:o,product:a,variant:u}=s.data.data;return{intent:"edit:item-lists",code:"ok",data:{item:o,product:a,variant:u}}}return{intent:"unsave:item",code:"ok",data:{itemId:s.data.data.itemId}}}};var Ss=w({itemId:S(v()),productId:S(M([S(v(),P(A)),x()]),P(n=>Number(n)),x()),variantId:_(S(M([S(v(),P(A)),x()]),P(n=>Number(n)),x()))}),Ae=class extends m{static{i(this,"EditItemVariantHandler")}async invoke(e){let t=E(Ss,e);if(!t.success)return{intent:"edit:item-variant",code:"error",message:"Invalid intent data",issues:t.issues.map(y=>y.message)};let{itemId:r,productId:s,variantId:o}=t.output;if(!(!o||this.swish.options.intents.editSavedProduct.promptVariantChange)){let y=await this.swish.api.items.updateById(r,{productId:s,variantId:o});if("error"in y)return{intent:"edit:item-variant",code:"error",message:"Failed to update variant",issues:[y.error.message]};if(!y.data)return{intent:"edit:item-variant",code:"error",message:"Failed to update variant",issues:["No item returned from API"]};let h=await this.swish.storefront.loadSaveIntentData({productId:D("Product",s),variantId:o?D("ProductVariant",o):void 0});if(!h.data?.product)return{intent:"edit:item-variant",code:"error",message:"Failed to load save intent data",issues:[h.errors?.message??"No product data returned from API"]};let b=h.data?.product,g="variant"in h.data?h.data.variant:void 0;return{intent:"edit:item-variant",code:"ok",data:{item:y.data,product:b,variant:g}}}let u=await this.ui.showVariantSelect({itemId:r,productId:s,variantId:o});if(u.code==="closed")return{intent:"edit:item-variant",code:"closed"};let{item:c,product:l,variant:p}=u.data;return{intent:"edit:item-variant",code:"ok",data:{item:c,product:l,variant:p}}}};var Es=w({listId:v()}),De=class extends m{static{i(this,"EditListHandler")}async invoke(e){let t=E(Es,e);if(!t.success)return{intent:"edit:list",code:"error",message:"Invalid intent data",issues:t.issues.map(a=>a.message)};let{listId:r}=t.output,s=await this.ui.showListEditor({listId:r});if(s.code==="closed")return{intent:"edit:list",code:"closed"};let{list:o}=s.data;return{intent:"edit:list",code:"ok",data:{list:o}}}};var xs=w({listId:v(),access:fe(["public","private"])}),Pe=class extends m{static{i(this,"EditListAccessHandler")}async invoke(e){let t=E(xs,e);if(!t.success)return{intent:"edit:list-access",code:"error",message:"Invalid intent data",issues:t.issues.map(u=>u.message)};let{listId:r,access:s}=t.output;if((await this.ui.showConfirmDialog({titleKey:s==="public"?"listMenu.public.title":"listMenu.private.title",descriptionKey:s==="public"?"listMenu.public.description":"listMenu.private.description",confirmLabelKey:s==="public"?"listMenu.public.text":"listMenu.private.text",cancelLabelKey:"listMenu.cancel",danger:!1})).code==="closed")return{intent:"edit:list-access",code:"closed"};let a=await this.swish.api.lists.updateById(r,{access:s});return"error"in a?{intent:"edit:list-access",code:"error",message:"Failed to update list access",issues:[a.error.message]}:a.data?{intent:"edit:list-access",code:"ok",data:{list:a.data}}:{intent:"edit:list-access",code:"error",message:"Failed to update list access",issues:["API response missing data"]}}};var Te=class extends m{static{i(this,"OpenHomeHandler")}async invoke(e){return{intent:"open:home",code:(await this.ui.showDrawer()).code,data:void 0}}};var Cs=w({listId:v()}),_e=class extends m{static{i(this,"OpenListDetailPageMenuHandler")}async invoke(e){let t=E(Cs,e);if(!t.success)return{intent:"open:list-detail-page-menu",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{listId:r}=t.output;return{intent:"open:list-detail-page-menu",code:(await this.ui.showListDetailPageMenu({listId:r})).code,data:void 0}}};var ks=w({listId:v()}),Oe=class extends m{static{i(this,"OpenListHandler")}async invoke(e){let t=E(ks,e);if(!t.success)return{intent:"open:list",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{listId:r}=t.output;return{intent:"open:list",code:(await this.ui.showDrawer({view:"list",listId:r})).code,data:void 0}}};var Rs=w({listId:v()}),Le=class extends m{static{i(this,"OpenListMenuHandler")}async invoke(e){let t=E(Rs,e);if(!t.success)return{intent:"open:list-menu",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{listId:r}=t.output,s=await this.ui.showListMenu({listId:r});if(s.code==="closed")return{intent:"open:list-menu",code:"closed"};if(s.data.action==="edit")return{intent:"edit:list",code:"ok",data:s.data.data};if(s.data.action==="delete")return{intent:"delete:list",code:"ok",data:{listId:r}};if(s.data.action==="edit-access"){let o=s.data.data?.currentListAccess,a=o==="public"?"private":o==="private"?"public":void 0;return a?(await this.swish.intents.invoke("edit:list-access",{listId:r,access:a})).complete:{intent:"open:list-menu",code:"error",message:"Missing list access from UI",issues:["List menu UI did not provide currentListAccess"]}}return s.data.action==="share"?(await this.swish.intents.invoke("share:list",{listId:r})).complete:{intent:"open:list-menu",code:"error",message:"Unknown list menu action",issues:["Unknown action returned from list menu UI"]}}};var $e=class extends m{static{i(this,"OpenListsHandler")}async invoke(e){return{intent:"open:lists",code:(await this.ui.showDrawer({view:"lists"})).code,data:void 0}}};var Ve=class extends m{static{i(this,"OpenNotificationsHandler")}async invoke(e){return{intent:"open:notifications",code:(await this.ui.showDrawer({view:"notifications"})).code,data:void 0}}};var As=w({orderId:S(M([S(v(),P(A)),x()]),P(n=>Number(n)),x())}),Me=class extends m{static{i(this,"OpenOrderHandler")}async invoke(e){let t=E(As,e);if(!t.success)return{intent:"open:order",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{orderId:r}=t.output;return{intent:"open:order",code:(await this.ui.showDrawer({view:"order",orderId:r.toString()})).code,data:void 0}}};var Ds=w({orderId:v()}),qe=class extends m{static{i(this,"OpenOrderMenuHandler")}async invoke(e){let t=E(Ds,e);if(!t.success)return{intent:"open:order-menu",code:"error",message:"Invalid intent data",issues:t.issues.map(o=>o.message)};let{orderId:r}=t.output;return{intent:"open:order-menu",code:(await this.ui.showOrderMenu({orderId:r})).code,data:void 0}}};var Ne=class extends m{static{i(this,"OpenOrdersHandler")}async invoke(e){return{intent:"open:orders",code:(await this.ui.showDrawer({view:"orders"})).code,data:void 0}}};var Ps=w({productId:S(M([S(v(),P(A)),x()]),P(n=>Number(n)),x()),variantId:_(S(M([S(v(),P(A)),x()]),P(Number),x()))}),Be=class extends m{static{i(this,"OpenProductHandler")}async invoke(e){let t=E(Ps,e);if(!t.success)return{intent:"open:product",code:"error",message:"Invalid intent data",issues:t.issues.map(a=>a.message)};let{productId:r,variantId:s}=t.output;return{intent:"open:product",code:(await this.ui.showDrawer({view:"product",productId:r.toString(),variantId:s?.toString()})).code,data:void 0}}};var Ue=class extends m{static{i(this,"OpenProfileHandler")}async invoke(e){return{intent:"open:profile",code:(await this.ui.showDrawer({view:"profile"})).code,data:void 0}}};var Ts=w({productId:S(M([S(v(),P(A)),x()]),P(n=>Number(n)),x()),variantId:_(S(M([S(v(),P(A)),x()]),P(Number),x()))}),Fe=class extends m{static{i(this,"OpenQuickBuyHandler")}async invoke(e){let t=E(Ts,e);if(!t.success)return{intent:"open:quick-buy",code:"error",message:"Invalid intent data",issues:t.issues.map(a=>a.message)};let{productId:r,variantId:s}=t.output,o=await this.ui.showQuickBuy({productId:r,variantId:s});return o.code==="closed"?{intent:"open:quick-buy",code:"closed"}:{intent:"open:quick-buy",code:"ok",data:o.data}}};var je=class extends m{static{i(this,"OpenSavesHandler")}async invoke(e){return{intent:"open:saves",code:(await this.ui.showDrawer({view:"saves"})).code,data:void 0}}};var Fa=w({returnTo:_(v())}),Ge=class extends m{static{i(this,"OpenSignInHandler")}async invoke(e){return{intent:"open:sign-in",code:(await this.ui.showSignIn({returnTo:e?.returnTo})).code,data:void 0}}};var _s=w({productId:S(M([S(v(),P(A)),x()]),P(n=>Number(n)),x()),variantId:_(S(M([S(v(),P(A)),x()]),P(Number),x())),quantity:_(S(x(),te(1))),tags:_(de(v()))}),He=class extends m{static{i(this,"SaveItemHandler")}async invoke(e){let t=E(_s,e);if(!t.success)return{intent:"save:item",code:"error",message:"Invalid intent data",issues:t.issues.map(h=>h.message)};let{productId:r,variantId:s,quantity:o,tags:a}=t.output,u=await this.swish.storefront.loadSaveIntentData({productId:D("Product",r),variantId:s?D("ProductVariant",s):void 0});if(u.errors)return{intent:"save:item",code:"error",message:u.errors.message??"Failed to load save intent data",issues:u.errors.graphQLErrors?.map(h=>h.message)??[]};if(!u.data||!u.data.product)return{intent:"save:item",code:"error",message:"Failed to load save intent data",issues:["API response missing data"]};let{product:c}=u.data,l=c.variantsCount?.count&&c.variantsCount.count>1,p=!!s,f=!this.options.saveProduct.promptVariantIfMissing||!this.options.saveProduct.promptVariantIfPresent&&p;if(!l||f){let h=i(()=>!l&&c.selectedOrFirstAvailableVariant?Number(A(c.selectedOrFirstAvailableVariant.id)):s,"variantIdToUse"),b=await this.swish.api.items.create({productId:r,variantId:h(),quantity:o,tags:a});if("error"in b)return{intent:"save:item",code:"error",message:"Failed to create item",issues:[b.error.message]};if(!b.data)return{intent:"save:item",code:"error",message:"Could not complete item creation",issues:["API response missing data"]};let g="variant"in u.data?u.data.variant:void 0;return{intent:"save:item",code:"ok",data:{item:b.data,product:c,variant:l?g:c.selectedOrFirstAvailableVariant}}}let y=await this.ui.showVariantSelect({productId:r,variantId:s});return y.code==="closed"?{intent:"save:item",code:"closed"}:{intent:"save:item",code:"ok",data:y.data}}};function he(n,e){let{storeDomain:t}=n.options.storefrontApi,{rootUrl:r,listDetailPagePath:s}=n.options.storefrontContext.routes,o=new URL(`https://${t}`),a=new URL(`${r==="/"?"":r}${s}`,o);return a.searchParams.set("public-list-id",e.publicListId),a}i(he,"buildShareListUrl");async function me(n){return typeof navigator?.clipboard?.writeText!="function"?{ok:!1,issues:["Clipboard API not available"]}:navigator.clipboard.writeText(n).then(()=>({ok:!0})).catch(e=>({ok:!1,issues:[e?.message??"Failed to copy to clipboard"]}))}i(me,"copyToClipboard");function In(){let n=navigator.userAgent.includes("Mac OS")&&navigator.maxTouchPoints>1;return/Android|Mobile/i.test(navigator.userAgent)||n}i(In,"isMobileDevice");var Os=w({listId:v()}),Qe=class extends m{static{i(this,"ShareListHandler")}async invoke(e){let t=E(Os,e);if(!t.success)return{intent:"share:list",code:"error",message:"Invalid intent data",issues:t.issues.map(u=>u.message)};let{listId:r}=t.output,s=he(this.swish,{publicListId:r}).toString();if(In()&&typeof navigator.share=="function"&&(await navigator.share({title:"Share list",url:s}).then(()=>({ok:!0})).catch(()=>({ok:!1}))).ok)return{intent:"share:list",code:"ok",data:{listId:r,url:s,method:"native"}};let a=await me(s);return a.ok?{intent:"share:list",code:"ok",data:{listId:r,url:s,method:"clipboard"}}:{intent:"share:list",code:"error",message:"Failed to share list",issues:a.issues}}};var uu=w({title:_(v()),text:v(),image:_(v()),action:_(w({label:v(),url:_(v())})),variant:_(fe(["compact","full"])),icon:_(v())}),ze=class extends m{static{i(this,"ShowToastHandler")}async invoke(e){return{intent:"show:toast",code:(await this.ui.showToast(e)).code,data:void 0}}};var St=S(M([S(v(),P(A)),x()]),P(n=>Number(n)),S(x(),te(1)));var Ls=M([w({variantId:St,quantity:_(S(x(),te(1)),1)}),w({items:S(de(w({variantId:St,quantity:_(S(x(),te(1)),1)})),It(1))})]),We=class extends m{static{i(this,"CreateCartLineHandler")}async invoke(e){let t=E(Ls,e);if(!t.success)return{intent:"create:cart-line",code:"error",message:"Invalid intent data",issues:t.issues.map(s=>s.message)};let r=t.output;try{let s="items"in r?r.items.map(a=>({id:a.variantId,quantity:a.quantity})):[{id:r.variantId,quantity:r.quantity}];return{intent:"create:cart-line",code:"ok",data:await this.swish.ajax.addToCart({items:s})}}catch(s){let o=[],a="Failed to add item to cart";return s instanceof Error?(s.message&&(a=s.message,o.push(s.message)),s.stack&&o.push(s.stack)):typeof s=="string"&&s.trim()?(a=s,o.push(s)):s!=null&&o.push(String(s)),{intent:"create:cart-line",code:"error",message:a,issues:o.length?o:["Cart request failed"]}}}};var z=class{constructor(e,t,r){this.swish=e;this.ui=t;this.options=r}static{i(this,"IntentHook")}};var Ke=class extends z{static{i(this,"AfterEditItemListsHook")}async invoke(e){if(this.options.editSavedProduct.showFeedback&&e.code==="ok"){if("itemId"in e.data)return;let{product:t,variant:r}=e.data;t&&(await(await this.swish.intents.invoke("show:toast",{title:"Saved",text:t.title,image:r?.image?.url??t.featuredImage?.url,action:{label:"View"}})).complete).code==="ok"&&this.swish.intents.invoke("open:home")}}};var Xe=class extends z{static{i(this,"AfterEditListAccessHook")}async invoke(e){if(e.code!=="ok")return;let t=e.data.list.access==="public"?"List is now public":"List is now private";await(await this.swish.intents.invoke("show:toast",{text:t,variant:"compact",icon:"check"})).complete}};var Ye=class extends z{static{i(this,"AfterOpenHomeHook")}async invoke(e){if(e.code==="closed"){let t=new URL(window.location.href);(t.hash==="#swish-home"||t.hash==="#swish")&&(t.hash="",window.history.replaceState({},document.title,t.toString()))}}};var Je=class extends z{static{i(this,"AfterSaveItemHook")}async invoke(e){if(this.options.saveProduct.showFeedback&&e.code==="ok"){let{item:t,product:r,variant:s}=e.data;r&&(await(await this.swish.intents.invoke("show:toast",{title:"Saved",text:r.title,image:s?.image?.url??r.featuredImage?.url,action:{label:"Add to List"}})).complete).code==="ok"&&this.swish.intents.invoke("edit:item-lists",{itemId:t.id})}}};var Ze=class extends z{static{i(this,"AfterShareListHook")}async invoke(e){if(e.code!=="ok")return;await(await this.swish.intents.invoke("show:toast",{variant:"compact",text:"Link shared",icon:"check"})).complete}};var et=class{static{i(this,"Intents")}constructor(e,t){this.swish=e,this.ui=t,this.eventBus=new EventTarget,this.options=e.options.intents,this.handlers={"create:cart-line":new We(this.swish,this.ui,this.eventBus,this.options),"save:item":new He(this.swish,this.ui,this.eventBus,this.options),"unsave:item":new Ce(this.swish,this.ui,this.eventBus,this.options),"edit:item-variant":new Ae(this.swish,this.ui,this.eventBus,this.options),"edit:item-lists":new Re(this.swish,this.ui,this.eventBus,this.options),"create:list":new Ee(this.swish,this.ui,this.eventBus,this.options),"edit:list":new De(this.swish,this.ui,this.eventBus,this.options),"edit:list-access":new Pe(this.swish,this.ui,this.eventBus,this.options),"delete:list":new ke(this.swish,this.ui,this.eventBus,this.options),"open:home":new Te(this.swish,this.ui,this.eventBus,this.options),"share:list":new Qe(this.swish,this.ui,this.eventBus,this.options),"open:list":new Oe(this.swish,this.ui,this.eventBus,this.options),"open:lists":new $e(this.swish,this.ui,this.eventBus,this.options),"open:orders":new Ne(this.swish,this.ui,this.eventBus,this.options),"open:order":new Me(this.swish,this.ui,this.eventBus,this.options),"open:saves":new je(this.swish,this.ui,this.eventBus,this.options),"open:notifications":new Ve(this.swish,this.ui,this.eventBus,this.options),"open:profile":new Ue(this.swish,this.ui,this.eventBus,this.options),"open:product":new Be(this.swish,this.ui,this.eventBus,this.options),"open:list-menu":new Le(this.swish,this.ui,this.eventBus,this.options),"open:order-menu":new qe(this.swish,this.ui,this.eventBus,this.options),"open:list-detail-page-menu":new _e(this.swish,this.ui,this.eventBus,this.options),"open:sign-in":new Ge(this.swish,this.ui,this.eventBus,this.options),"open:quick-buy":new Fe(this.swish,this.ui,this.eventBus,this.options),"show:toast":new ze(this.swish,this.ui,this.eventBus,this.options)},this.initIntentHooks(),this.initIntentWatcher()}publishAnalyticsEvent(e,t){typeof window.Shopify?.analytics?.publish=="function"&&window.Shopify.analytics.publish(e,t)}async invoke(e,...t){let r=t[0],s={lifecycle:"before",intent:e,data:r};return this.publishAnalyticsEvent("swish-intent",s),this.publishAnalyticsEvent(`swish-intent=${e}`,s),{intent:e,data:r,complete:this.handleIntent(e,r).then(o=>{let a={lifecycle:"after",intent:e,data:r,response:o};return this.publishAnalyticsEvent("swish-intent",a),this.publishAnalyticsEvent(`swish-intent=${e}`,a),this.eventBus.dispatchEvent(new CustomEvent(e,{detail:o})),o})}}listen(e,t){let r=i(o=>{"detail"in o&&o.detail?t(o.detail):console.warn("Intent response event without detail",o)},"eventListener"),s=i(()=>{this.eventBus.removeEventListener(e,r)},"unsubscribe");return this.eventBus.addEventListener(e,r),s}parseIntentFromString(e){if(typeof e=="string"){let[t,...r]=e.split(","),s=r.reduce((o,a)=>{let[u,c]=a.split("=");return o[u]=c,o},{});return{intent:t,data:s}}return{intent:e,data:{}}}parseIntentFromHash(e){let t=e.startsWith("#")?e.slice(1):e;return{swish:"open:home","swish-home":"open:home","swish-lists":"open:lists","swish-orders":"open:orders","swish-saves":"open:saves","swish-notifications":"open:notifications","swish-profile":"open:profile"}[t]||null}async handleIntent(e,t){let r=this.handlers[e];return r?r.invoke(t):{intent:e,code:"error",message:"Invalid intent",issues:[`Intent ${e} not found`]}}initIntentHooks(){this.eventBus.addEventListener("save:item",e=>{new Je(this.swish,this.ui,this.options).invoke(e.detail)}),this.eventBus.addEventListener("edit:item-lists",e=>{new Ke(this.swish,this.ui,this.options).invoke(e.detail)}),this.eventBus.addEventListener("open:home",e=>{new Ye(this.swish,this.ui,this.options).invoke(e.detail)}),this.eventBus.addEventListener("edit:list-access",e=>{new Xe(this.swish,this.ui,this.options).invoke(e.detail)}),this.eventBus.addEventListener("share:list",e=>{new Ze(this.swish,this.ui,this.options).invoke(e.detail)})}initIntentWatcher(){ie({selector:"[swish-intent]",onElementFound:i(e=>{let t=e.getAttribute("swish-intent");t&&e.addEventListener("click",()=>{let{intent:r,data:s}=this.parseIntentFromString(t);Object.keys(s).length>0?this.invoke(r,s):this.invoke(r)})},"onElementFound")}),ie({selector:"a[href*='swish-intent='],a[href*='#swish']",onElementFound:i(e=>{e instanceof HTMLAnchorElement&&e.addEventListener("click",t=>{if(!t.metaKey&&!t.ctrlKey&&!t.shiftKey&&!t.altKey){let r=new URL(e.href),s=r.hash,o=r.searchParams.get("swish-intent");if(o){let{intent:a,data:u}=this.parseIntentFromString(o);a&&(t.preventDefault(),t.stopPropagation(),Object.keys(u).length>0?this.invoke(a,u):this.invoke(a))}else if(s){let a=this.parseIntentFromHash(s);a&&(t.preventDefault(),t.stopPropagation(),this.invoke(a))}}})},"onElementFound")}),le({fireOnInit:!0,onLocationChange:i(e=>{let t=new URL(e.href),r=t.hash,s=t.searchParams.get("swish-intent");if(s){let{intent:o,data:a}=this.parseIntentFromString(s);o&&(Object.keys(a).length>0?this.invoke(o,a):this.invoke(o))}else if(r){let o=this.parseIntentFromHash(r);o&&this.invoke(o)}},"onLocationChange")})}};var bn=i(n=>({swishApi:{authProxy:n.swishApi?.authProxy??"/apps/wishlist/api",version:n.swishApi?.version??"2026-01"},storefrontApi:{storeDomain:n.storefrontApi?.storeDomain??"",accessToken:n.storefrontApi?.accessToken??""},storefrontContext:{...n.storefrontContext,routes:{...n.storefrontContext.routes,rootUrl:n.storefrontContext.routes?.rootUrl??"/",listDetailPagePath:n.storefrontContext.routes?.listDetailPagePath??"/apps/wishlist"},localization:{country:n.storefrontContext.localization.country.toUpperCase(),language:n.storefrontContext.localization.language.toUpperCase(),market:n.storefrontContext.localization.market}},badges:{getBadges:n.badges?.getBadges??(({defaultBadges:e})=>e)},productOptions:{sortValues:n.productOptions?.sortValues??(({optionValues:e})=>e)},metafields:{product:n.metafields?.product??[],productVariant:n.metafields?.productVariant??[]},features:{accounts:n?.features?.accounts??!0,lists:n?.features?.lists??!0,orders:n?.features?.orders??!0,notifications:n?.features?.notifications??!0},intents:{saveProduct:{promptVariantIfMissing:n?.intents?.saveProduct?.promptVariantIfMissing??!0,promptVariantIfPresent:n?.intents?.saveProduct?.promptVariantIfPresent??!0,showFeedback:n?.intents?.saveProduct?.showFeedback??!0},unsaveProduct:{selectList:n?.intents?.unsaveProduct?.selectList??!0,confirm:n?.intents?.unsaveProduct?.confirm??!0,showFeedback:n?.intents?.unsaveProduct?.showFeedback??!0},editSavedProduct:{promptVariantChange:n?.intents?.editSavedProduct?.promptVariantChange??!0,showFeedback:n?.intents?.editSavedProduct?.showFeedback??!0}},swishUi:{baseUrl:n.swishUi?.baseUrl??"https://swish.app/cdn",version:n.swishUi?.version??tt,components:{productRow:{showVariantTitle:n.swishUi?.components?.productRow?.showVariantTitle??!1},productDetail:{descriptionMaxLines:n.swishUi?.components?.productDetail?.descriptionMaxLines??4},variantSelect:{displayType:n.swishUi?.components?.variantSelect?.displayType??"pills"},icons:n.swishUi?.components?.icons??{},imageSlider:{flush:n.swishUi?.components?.imageSlider?.flush??!1,loop:n.swishUi?.components?.imageSlider?.loop??!1},images:{baseTint:n.swishUi?.components?.images?.baseTint??!1},buyButtons:{shopPay:n.swishUi?.components?.buyButtons?.shopPay??!1},listDetailPage:{desktopColumns:n.swishUi?.components?.listDetailPage?.desktopColumns??4,showBuyButton:n.swishUi?.components?.listDetailPage?.showBuyButton??!0,showVariantOptionNames:n.swishUi?.components?.listDetailPage?.showVariantOptionNames??!1,enableVariantChange:n.swishUi?.components?.listDetailPage?.enableVariantChange??!0},drawer:{title:n.swishUi?.components?.drawer?.title??"",logo:{url:n.swishUi?.components?.drawer?.logo?.url??"",altText:n.swishUi?.components?.drawer?.logo?.altText??""},navigation:{enabled:n.swishUi?.components?.drawer?.navigation?.enabled??!0,variant:n.swishUi?.components?.drawer?.navigation?.variant??"floating",items:n.swishUi?.components?.drawer?.navigation?.items??[]},emptyCallout:{enabled:n.swishUi?.components?.drawer?.emptyCallout?.enabled??!1,shoppingCalloutUrl:n.swishUi?.components?.drawer?.emptyCallout?.shoppingCalloutUrl??"/collections/all"},miniMenu:{enabled:n.swishUi?.components?.drawer?.miniMenu?.enabled??!0,items:n.swishUi?.components?.drawer?.miniMenu?.items??[]},listDetailView:{enableVariantChange:n.swishUi?.components?.drawer?.listDetailView?.enableVariantChange??!1,showVariantOptionNames:n.swishUi?.components?.drawer?.listDetailView?.showVariantOptionNames??!1}}},css:n.swishUi?.css??[],design:n.swishUi?.design??{}}}),"createSwishOptions");var $s=Symbol.for("preact-signals");function rt(){if(ne>1)ne--;else{for(var n,e=!1;ye!==void 0;){var t=ye;for(ye=void 0,Et++;t!==void 0;){var r=t.o;if(t.o=void 0,t.f&=-3,!(8&t.f)&&xn(t))try{t.c()}catch(s){e||(n=s,e=!0)}t=r}}if(Et=0,ne--,e)throw n}}i(rt,"t");function re(n){if(ne>0)return n();ne++;try{return n()}finally{rt()}}i(re,"r");var C=void 0;function Sn(n){var e=C;C=void 0;try{return n()}finally{C=e}}i(Sn,"n");var ye=void 0,ne=0,Et=0,nt=0;function En(n){if(C!==void 0){var e=n.n;if(e===void 0||e.t!==C)return e={i:0,S:n,p:C.s,n:void 0,t:C,e:void 0,x:void 0,r:e},C.s!==void 0&&(C.s.n=e),C.s=e,n.n=e,32&C.f&&n.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=C.s,e.n=void 0,C.s.n=e,C.s=e),e}}i(En,"e");function B(n,e){this.v=n,this.i=0,this.n=void 0,this.t=void 0,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}i(B,"u");B.prototype.brand=$s;B.prototype.h=function(){return!0};B.prototype.S=function(n){var e=this,t=this.t;t!==n&&n.e===void 0&&(n.x=t,this.t=n,t!==void 0?t.e=n:Sn(function(){var r;(r=e.W)==null||r.call(e)}))};B.prototype.U=function(n){var e=this;if(this.t!==void 0){var t=n.e,r=n.x;t!==void 0&&(t.x=r,n.e=void 0),r!==void 0&&(r.e=t,n.x=void 0),n===this.t&&(this.t=r,r===void 0&&Sn(function(){var s;(s=e.Z)==null||s.call(e)}))}};B.prototype.subscribe=function(n){var e=this;return Q(function(){var t=e.value,r=C;C=void 0;try{n(t)}finally{C=r}},{name:"sub"})};B.prototype.valueOf=function(){return this.value};B.prototype.toString=function(){return this.value+""};B.prototype.toJSON=function(){return this.value};B.prototype.peek=function(){var n=C;C=void 0;try{return this.value}finally{C=n}};Object.defineProperty(B.prototype,"value",{get:i(function(){var n=En(this);return n!==void 0&&(n.i=this.i),this.v},"get"),set:i(function(n){if(n!==this.v){if(Et>100)throw new Error("Cycle detected");this.v=n,this.i++,nt++,ne++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{rt()}}},"set")});function $(n,e){return new B(n,e)}i($,"d");function xn(n){for(var e=n.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}i(xn,"c");function Cn(n){for(var e=n.s;e!==void 0;e=e.n){var t=e.S.n;if(t!==void 0&&(e.r=t),e.S.n=e,e.i=-1,e.n===void 0){n.s=e;break}}}i(Cn,"a");function kn(n){for(var e=n.s,t=void 0;e!==void 0;){var r=e.p;e.i===-1?(e.S.U(e),r!==void 0&&(r.n=e.n),e.n!==void 0&&(e.n.p=r)):t=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=r}n.s=t}i(kn,"l");function oe(n,e){B.call(this,void 0),this.x=n,this.s=void 0,this.g=nt-1,this.f=4,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}i(oe,"y");oe.prototype=new B;oe.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===nt))return!0;if(this.g=nt,this.f|=1,this.i>0&&!xn(this))return this.f&=-2,!0;var n=C;try{Cn(this),C=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return C=n,kn(this),this.f&=-2,!0};oe.prototype.S=function(n){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}B.prototype.S.call(this,n)};oe.prototype.U=function(n){if(this.t!==void 0&&(B.prototype.U.call(this,n),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}};oe.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var n=this.t;n!==void 0;n=n.x)n.t.N()}};Object.defineProperty(oe.prototype,"value",{get:i(function(){if(1&this.f)throw new Error("Cycle detected");var n=En(this);if(this.h(),n!==void 0&&(n.i=this.i),16&this.f)throw this.v;return this.v},"get")});function F(n,e){return new oe(n,e)}i(F,"w");function Rn(n){var e=n.u;if(n.u=void 0,typeof e=="function"){ne++;var t=C;C=void 0;try{e()}catch(r){throw n.f&=-2,n.f|=8,xt(n),r}finally{C=t,rt()}}}i(Rn,"_");function xt(n){for(var e=n.s;e!==void 0;e=e.n)e.S.U(e);n.x=void 0,n.s=void 0,Rn(n)}i(xt,"b");function Vs(n){if(C!==this)throw new Error("Out-of-order effect");kn(this),C=n,this.f&=-2,8&this.f&&xt(this),rt()}i(Vs,"g");function pe(n,e){this.x=n,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=e?.name}i(pe,"p");pe.prototype.c=function(){var n=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.u=e)}finally{n()}};pe.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Rn(this),Cn(this),ne++;var n=C;return C=this,Vs.bind(this,n)};pe.prototype.N=function(){2&this.f||(this.f|=2,this.o=ye,ye=this)};pe.prototype.d=function(){this.f|=8,1&this.f||xt(this)};pe.prototype.dispose=function(){this.d()};function Q(n,e){var t=new pe(n,e);try{t.c()}catch(s){throw t.d(),s}var r=t.d.bind(t);return r[Symbol.dispose]=r,r}i(Q,"E");var Ms=/\/products\/([^/?#]+)(?:\?(?:[^#]*?&)?variant=(\d+))?/,Ct=i(n=>{let e=n.match(Ms);return e?{productHandle:e[1],variantId:e[2]}:null},"parseProductUrl"),An=i(({source:n,onProductUrlChange:e})=>{let t=i(r=>{let s=Ct(r);s?.productHandle&&e(s)},"handleChange");if(n instanceof HTMLAnchorElement)return ln({element:n,onHrefChange:i(r=>t(r),"onHrefChange")});if(n instanceof Location)return le({onLocationChange:i(r=>t(r.href),"onLocationChange")});throw new Error("Invalid source for observing product url")},"observeProductUrl");var Dn=i(n=>e=>{let{productHandle:t,productId:r,variantId:s,itemId:o}=e?.dataset??{},c=!!(r||t)||!!o,l=$({loading:!1,productId:r,variantId:s,itemId:o});if(!c){let p=e instanceof HTMLAnchorElement?e:window.location,f=Ct(p.href);f?.productHandle&&f.productHandle!==l.value.productHandle&&(l.value={...l.value,...f,productId:void 0},An({source:p,onProductUrlChange:i(y=>{l.value={...l.value,...y,productId:y.productHandle!==l.value.productHandle?void 0:l.value.productId}},"onProductUrlChange")}))}return Q(()=>{l.value.loading||!l.value.productId&&l.value.productHandle&&(l.value={...l.value,loading:!0},n.storefront.loadProductId({productHandle:l.value.productHandle}).then(p=>{p.errors&&console.error("Error loading product id",p.errors),l.value={...l.value,productId:p.data?.product?.id?A(p.data.product.id):void 0,loading:!1}}))}),l},"itemContextSignal");var Pn=i(n=>e=>{let t=F(()=>{let{productId:T,variantId:I,loading:V}=e.value;return!T||V?null:I?`variant:${A(I)}`:`product:${A(T)}`}),r=F(()=>e.value.loading||!!e.value.itemId||!e.value.productId),s=F(()=>({limit:1,query:t.value??void 0})),o=$(!r.value),a=$(null),u=$(!1),c=$(!1),{data:l,loading:p,error:f,refetching:y}=n.state.swishQuery(T=>n.api.items.list(T),{refetch:["item-create","item-update","item-delete"],variables:s,skip:r}),h=$(e.value.itemId??null);Q(()=>{re(()=>{if(o.value=p.value,a.value=f.value,!e.value.itemId){let T=l.value?.[0]?.id??null;T!==h.value&&(h.value=T)}})});async function b(){if(!h.value)return;u.value=!0;let I=await(await n.intents.invoke("unsave:item",{itemId:h.value})).complete;I.code==="ok"&&"itemId"in I.data&&(h.value=null),u.value=!1}i(b,"unsave");async function g(){if(!h.value)return;u.value=!0;let I=await(await n.intents.invoke("edit:item-lists",{itemId:h.value})).complete;I.code==="ok"&&"itemId"in I.data&&(h.value=null),u.value=!1}i(g,"update");async function O(){let{productId:T,variantId:I}=e.value;if(!T)return;u.value=!0,c.value=!0;let k=await(await n.intents.invoke("save:item",{productId:T,variantId:I})).complete;if(k.code==="ok"){let ee=k.data;h.value=ee.item.id,u.value=!1}else k.code==="error"&&console.warn("Failed to create item",k),re(()=>{u.value=!1,c.value=!1})}i(O,"save");let N=F(()=>o.value||u.value||e.value.loading);Q(()=>{c.value&&!u.value&&!y.value&&(c.value=!1)});let L=F(()=>{let T=y.value&&c.value,I=!!h.value,V=!I&&(u.value||T),k=I&&(u.value||T),ee=F(()=>V?"saving":k?"unsaving":I?"saved":"unsaved");return{error:a.value,status:ee.value,savedItemId:h.value,loading:N.value,submitting:u.value,saved:I,saving:V,unsaving:k}});async function G(){N.value||(L.value.saved&&L.value.savedItemId?b():L.value.saved||await O())}return i(G,"toggle"),Object.assign(L,{save:O,unsave:b,update:g,toggle:G})},"itemStateSignal");var Tn=i(n=>()=>{let{data:e,loading:t,error:r}=n.state.swishQuery(()=>n.api.items.count(),{refetch:["item-create","item-delete"]}),s=$(0),o=$(!0),a=$(null);return Q(()=>{re(()=>{o.value=t.value,a.value=r.value,s.value=e.value?.count??0})}),F(()=>({count:s.value,loading:o.value,error:a.value}))},"itemCountSignal");var qs="token-update",_n=i(n=>(e,t)=>{let r=$(null),s=$(null),o=$(null),a=$(!t?.skip),u=$(!1),c=F(()=>a.value&&u.value);async function l(){if(!t?.skip?.value)try{a.value=!0;let p=await e(t?.variables?.value);re(()=>{o.value="error"in p?p.error:null,r.value="data"in p?p.data:null,s.value="pageInfo"in p?p.pageInfo:null,a.value=!1,u.value=!0})}catch(p){re(()=>{o.value=p,a.value=!1,u.value=!0})}}return i(l,"executeFetch"),Q(()=>{if(l(),t?.refetch?.length){let p=[...t.refetch,qs];return n.events.subscribe(p,l)}}),{data:r,pageInfo:s,error:o,loading:a,refetching:c}},"swishQuerySignals");var ae="GraphQL Client";var kt="An error occurred while fetching from the API. Review 'graphQLErrors' for details.",Rt="Response returned unexpected Content-Type:",At="An unknown error has occurred. The API did not return a data object or any errors in its response.",st={json:"application/json",multipart:"multipart/mixed"},Dt="X-SDK-Variant",Pt="X-SDK-Version",Ln="shopify-graphql-client",$n="1.4.1",it=1e3,Vn=[429,503],Tt=/@(defer)\b/i,On=`\r
8
- `,Mn=/boundary="?([^=";]+)"?/i,_t=On+On;function X(n,e=ae){return n.startsWith(`${e}`)?n:`${e}: ${n}`}i(X,"formatErrorMessage");function Z(n){return n instanceof Error?n.message:JSON.stringify(n)}i(Z,"getErrorMessage");function Ot(n){return n instanceof Error&&n.cause?n.cause:void 0}i(Ot,"getErrorCause");function Lt(n){return n.flatMap(({errors:e})=>e??[])}i(Lt,"combineErrors");function ot({client:n,retries:e}){if(e!==void 0&&(typeof e!="number"||e<0||e>3))throw new Error(`${n}: The provided "retries" value (${e}) is invalid - it cannot be less than ${0} or greater than ${3}`)}i(ot,"validateRetries");function U(n,e){return e&&(typeof e!="object"||Array.isArray(e)||typeof e=="object"&&Object.keys(e).length>0)?{[n]:e}:{}}i(U,"getKeyValueIfValid");function $t(n,e){if(n.length===0)return e;let r={[n.pop()]:e};return n.length===0?r:$t(n,r)}i($t,"buildDataObjectByPath");function Bn(n,e){return Object.keys(e||{}).reduce((t,r)=>(typeof e[r]=="object"||Array.isArray(e[r]))&&n[r]?(t[r]=Bn(n[r],e[r]),t):(t[r]=e[r],t),Array.isArray(n)?[...n]:{...n})}i(Bn,"combineObjects");function Vt([n,...e]){return e.reduce(Bn,{...n})}i(Vt,"buildCombinedDataObject");function Mt({clientLogger:n,customFetchApi:e=fetch,client:t=ae,defaultRetryWaitTime:r=it,retriableCodes:s=Vn}){let o=i(async(a,u,c)=>{let l=u+1,p=c+1,f;try{if(f=await e(...a),n({type:"HTTP-Response",content:{requestParams:a,response:f}}),!f.ok&&s.includes(f.status)&&l<=p)throw new Error;let y=f?.headers.get("X-Shopify-API-Deprecated-Reason")||"";return y&&n({type:"HTTP-Response-GraphQL-Deprecation-Notice",content:{requestParams:a,deprecationNotice:y}}),f}catch(y){if(l<=p){let h=f?.headers.get("Retry-After");return await Ns(h?parseInt(h,10):r),n({type:"HTTP-Retry",content:{requestParams:a,lastResponse:f,retryAttempt:u,maxRetries:c}}),o(a,l,c)}throw new Error(X(`${c>0?`Attempted maximum number of ${c} network retries. Last message - `:""}${Z(y)}`,t))}},"httpFetch");return o}i(Mt,"generateHttpFetch");async function Ns(n){return new Promise(e=>setTimeout(e,n))}i(Ns,"sleep");function qt({headers:n,url:e,customFetchApi:t=fetch,retries:r=0,logger:s}){ot({client:ae,retries:r});let o={headers:n,url:e,retries:r},a=Bs(s),u=Mt({customFetchApi:t,clientLogger:a,defaultRetryWaitTime:it}),c=Us(u,o),l=Fs(c),p=Ks(c);return{config:o,fetch:c,request:l,requestStream:p}}i(qt,"createGraphQLClient");function Bs(n){return e=>{n&&n(e)}}i(Bs,"generateClientLogger");async function Un(n){let{errors:e,data:t,extensions:r}=await n.json();return{...U("data",t),...U("extensions",r),headers:n.headers,...e||!t?{errors:{networkStatusCode:n.status,message:X(e?kt:At),...U("graphQLErrors",e),response:n}}:{}}}i(Un,"processJSONResponse");function Us(n,{url:e,headers:t,retries:r}){return async(s,o={})=>{let{variables:a,headers:u,url:c,retries:l,keepalive:p,signal:f}=o,y=JSON.stringify({query:s,variables:a});ot({client:ae,retries:l});let h=Object.entries({...t,...u}).reduce((g,[O,N])=>(g[O]=Array.isArray(N)?N.join(", "):N.toString(),g),{});return!h[Dt]&&!h[Pt]&&(h[Dt]=Ln,h[Pt]=$n),n([c??e,{method:"POST",headers:h,body:y,signal:f,keepalive:p}],1,l??r)}}i(Us,"generateFetch");function Fs(n){return async(...e)=>{if(Tt.test(e[0]))throw new Error(X("This operation will result in a streamable response - use requestStream() instead."));let t=null;try{t=await n(...e);let{status:r,statusText:s}=t,o=t.headers.get("content-type")||"";return t.ok?o.includes(st.json)?await Un(t):{errors:{networkStatusCode:r,message:X(`${Rt} ${o}`),response:t}}:{errors:{networkStatusCode:r,message:X(s),response:t}}}catch(r){return{errors:{message:Z(r),...t==null?{}:{networkStatusCode:t.status,response:t}}}}}}i(Fs,"generateRequest");async function*js(n){let e=new TextDecoder;if(n.body[Symbol.asyncIterator])for await(let t of n.body)yield e.decode(t);else{let t=n.body.getReader(),r;try{for(;!(r=await t.read()).done;)yield e.decode(r.value)}finally{t.cancel()}}}i(js,"getStreamBodyIterator");function Gs(n,e){return{async*[Symbol.asyncIterator](){try{let t="";for await(let r of n)if(t+=r,t.indexOf(e)>-1){let s=t.lastIndexOf(e),a=t.slice(0,s).split(e).filter(u=>u.trim().length>0).map(u=>u.slice(u.indexOf(_t)+_t.length).trim());a.length>0&&(yield a),t=t.slice(s+e.length),t.trim()==="--"&&(t="")}}catch(t){throw new Error(`Error occured while processing stream payload - ${Z(t)}`)}}}}i(Gs,"readStreamChunk");function Hs(n){return{async*[Symbol.asyncIterator](){yield{...await Un(n),hasNext:!1}}}}i(Hs,"createJsonResponseAsyncIterator");function Qs(n){return n.map(e=>{try{return JSON.parse(e)}catch(t){throw new Error(`Error in parsing multipart response - ${Z(t)}`)}}).map(e=>{let{data:t,incremental:r,hasNext:s,extensions:o,errors:a}=e;if(!r)return{data:t||{},...U("errors",a),...U("extensions",o),hasNext:s};let u=r.map(({data:c,path:l,errors:p})=>({data:c&&l?$t(l,c):{},...U("errors",p)}));return{data:u.length===1?u[0].data:Vt([...u.map(({data:c})=>c)]),...U("errors",Lt(u)),hasNext:s}})}i(Qs,"getResponseDataFromChunkBodies");function zs(n,e){if(n.length>0)throw new Error(kt,{cause:{graphQLErrors:n}});if(Object.keys(e).length===0)throw new Error(At)}i(zs,"validateResponseData");function Ws(n,e){let t=(e??"").match(Mn),r=`--${t?t[1]:"-"}`;if(!n.body?.getReader&&!n.body?.[Symbol.asyncIterator])throw new Error("API multipart response did not return an iterable body",{cause:n});let s=js(n),o={},a;return{async*[Symbol.asyncIterator](){try{let u=!0;for await(let c of Gs(s,r)){let l=Qs(c);a=l.find(f=>f.extensions)?.extensions??a;let p=Lt(l);o=Vt([o,...l.map(({data:f})=>f)]),u=l.slice(-1)[0].hasNext,zs(p,o),yield{...U("data",o),...U("extensions",a),hasNext:u}}if(u)throw new Error("Response stream terminated unexpectedly")}catch(u){let c=Ot(u);yield{...U("data",o),...U("extensions",a),errors:{message:X(Z(u)),networkStatusCode:n.status,...U("graphQLErrors",c?.graphQLErrors),response:n},hasNext:!1}}}}}i(Ws,"createMultipartResponseAsyncInterator");function Ks(n){return async(...e)=>{if(!Tt.test(e[0]))throw new Error(X("This operation does not result in a streamable response - use request() instead."));try{let t=await n(...e),{statusText:r}=t;if(!t.ok)throw new Error(r,{cause:t});let s=t.headers.get("content-type")||"";switch(!0){case s.includes(st.json):return Hs(t);case s.includes(st.multipart):return Ws(t,s);default:throw new Error(`${Rt} ${s}`,{cause:t})}}catch(t){return{async*[Symbol.asyncIterator](){let r=Ot(t);yield{errors:{message:X(Z(t)),...U("networkStatusCode",r?.status),...U("response",r)},hasNext:!1}}}}}}i(Ks,"generateRequestStream");function Nt({client:n,storeDomain:e}){try{if(!e||typeof e!="string")throw new Error;let t=e.trim(),r=t.match(/^https?:/)?t:`https://${t}`,s=new URL(r);return s.protocol="https",s.origin}catch(t){throw new Error(`${n}: a valid store domain ("${e}") must be provided`,{cause:t})}}i(Nt,"validateDomainAndGetStoreUrl");function at({client:n,currentSupportedApiVersions:e,apiVersion:t,logger:r}){let s=`${n}: the provided apiVersion ("${t}")`,o=`Currently supported API versions: ${e.join(", ")}`;if(!t||typeof t!="string")throw new Error(`${s} is invalid. ${o}`);let a=t.trim();e.includes(a)||(r?r({type:"Unsupported_Api_Version",content:{apiVersion:t,supportedApiVersions:e}}):console.warn(`${s} is likely deprecated or not supported. ${o}`))}i(at,"validateApiVersion");function ut(n){let e=n*3-2;return e===10?e:`0${e}`}i(ut,"getQuarterMonth");function Bt(n,e,t){let r=e-t;return r<=0?`${n-1}-${ut(r+4)}`:`${n}-${ut(r)}`}i(Bt,"getPrevousVersion");function Fn(){let n=new Date,e=n.getUTCMonth(),t=n.getUTCFullYear(),r=Math.floor(e/3+1);return{year:t,quarter:r,version:`${t}-${ut(r)}`}}i(Fn,"getCurrentApiVersion");function Ut(){let{year:n,quarter:e,version:t}=Fn(),r=e===4?`${n+1}-01`:`${n}-${ut(e+1)}`;return[Bt(n,e,3),Bt(n,e,2),Bt(n,e,1),t,r,"unstable"]}i(Ut,"getCurrentSupportedApiVersions");function Ft(n){return e=>({...e??{},...n.headers})}i(Ft,"generateGetHeaders");function jt({getHeaders:n,getApiUrl:e}){return(t,r)=>{let s=[t];if(r&&Object.keys(r).length>0){let{variables:o,apiVersion:a,headers:u,retries:c,signal:l}=r;s.push({...o?{variables:o}:{},...u?{headers:n(u)}:{},...a?{url:e(a)}:{},...c?{retries:c}:{},...l?{signal:l}:{}})}return s}}i(jt,"generateGetGQLClientParams");var Gt="application/json",jn="storefront-api-client",Gn="1.0.9",Hn="X-Shopify-Storefront-Access-Token",Qn="Shopify-Storefront-Private-Token",zn="X-SDK-Variant",Wn="X-SDK-Version",Kn="X-SDK-Variant-Source",ue="Storefront API Client";function Xn(n){if(n&&typeof window<"u")throw new Error(`${ue}: private access tokens and headers should only be used in a server-to-server implementation. Use the public API access token in nonserver environments.`)}i(Xn,"validatePrivateAccessTokenUsage");function Yn(n,e){if(!n&&!e)throw new Error(`${ue}: a public or private access token must be provided`);if(n&&e)throw new Error(`${ue}: only provide either a public or private access token`)}i(Yn,"validateRequiredAccessTokens");function Ht({storeDomain:n,apiVersion:e,publicAccessToken:t,privateAccessToken:r,clientName:s,retries:o=0,customFetchApi:a,logger:u}){let c=Ut(),l=Nt({client:ue,storeDomain:n}),p={client:ue,currentSupportedApiVersions:c,logger:u};at({...p,apiVersion:e}),Yn(t,r),Xn(r);let f=Xs(l,e,p),y={storeDomain:l,apiVersion:e,...t?{publicAccessToken:t}:{privateAccessToken:r},headers:{"Content-Type":Gt,Accept:Gt,[zn]:jn,[Wn]:Gn,...s?{[Kn]:s}:{},...t?{[Hn]:t}:{[Qn]:r}},apiUrl:f(),clientName:s},h=qt({headers:y.headers,url:y.apiUrl,retries:o,customFetchApi:a,logger:u}),b=Ft(y),g=Ys(y,f),O=jt({getHeaders:b,getApiUrl:g});return Object.freeze({config:y,getHeaders:b,getApiUrl:g,fetch:i((...L)=>h.fetch(...O(...L)),"fetch"),request:i((...L)=>h.request(...O(...L)),"request"),requestStream:i((...L)=>h.requestStream(...O(...L)),"requestStream")})}i(Ht,"createStorefrontApiClient");function Xs(n,e,t){return r=>{r&&at({...t,apiVersion:r});let s=(r??e).trim();return`${n}/api/${s}/graphql.json`}}i(Xs,"generateApiUrlFormatter");function Ys(n,e){return t=>t?e(t):n.apiUrl}i(Ys,"generateGetApiUrl");var j=`
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=`
9
9
  fragment productImageFields on Image {
10
10
  id
11
11
  altText
@@ -439,11 +439,11 @@ Values:
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}).then(t=>t.data?{...t,data:{...t.data,product:t.data.product?{...t.data.product,options:t.data.product.options.map(r=>({...r,optionValues:this.productOptions.sortValues({optionValues:r.optionValues.slice()})}))}:void 0}}:t),"loadProductOptions");this.loadSelectedVariant=i(async e=>br(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}),"loadSelectedVariant");this.loadProductCardData=i(async e=>hr(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}).then(t=>t.data?"variant"in t.data?{...t,data:{...t.data,badges:this.badges.getBadges({product:t.data.product,variant:t.data.variant})}}:{...t,data:{...t.data,badges:this.badges.getBadges({product:t.data.product})}}:t),"loadProductCardData");this.loadProductDetailData=i(async e=>mr(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}).then(t=>{if(!t.data)return t;let r=t.data.product?{...t.data.product,options:t.data.product.options.map(s=>({...s,optionValues:this.productOptions.sortValues({optionValues:s.optionValues.slice()})}))}:void 0;return"variant"in t.data?{...t,data:{...t.data,product:r,badges:this.badges.getBadges({product:r,variant:t.data.variant})}}:{...t,data:{...t.data,product:r,badges:this.badges.getBadges({product:r})}}}),"loadProductDetailData");this.loadProductImages=i(async e=>vr(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}),"loadProductImages");this.loadProductRecommendations=i(async e=>wr(this,{...e,country:this.context.localization.country,language:this.context.localization.language}),"loadProductRecommendations");this.loadProductId=i(async e=>yr(this,e),"loadProductId");this.loadSaveIntentData=i(async e=>Ir(this,{...e,...this.metafields,country:this.context.localization.country,language:this.context.localization.language}),"loadSaveIntentData");this.options=e,this.context=t,this.badges=r,this.productOptions=s,this.metafields={productMetafields:o?.product.map(u=>({namespace:u.split(".")[0],key:u.split(".")[1]}))??[],variantMetafields:o?.productVariant.map(u=>({namespace:u.split(".")[0],key:u.split(".")[1]}))??[]};let a=H(t.myshopifyDomain);this.shortCache=new Y(`storefront-api-short-${a}`,"max-age=60, stale-while-revalidate=3600"),this.longCache=new Y(`storefront-api-long-${a}`,"max-age=3600, stale-while-revalidate=86400"),this.shortCache.cleanupExpiredEntries().catch(u=>{console.warn("Storefront API cache initialization cleanup error:",u)}),this.longCache.cleanupExpiredEntries().catch(u=>{console.warn("Storefront API cache initialization cleanup error:",u)}),this.client=Ht({apiVersion:Js,customFetchApi:i((u,c)=>c?.method==="OPTIONS"?this.fetch(u,c):Zs.some(l=>c?.body?.toString().includes(`query ${l}`))?this.longCache.fetchWithCache(u,c):this.shortCache.fetchWithCache(u,c),"customFetchApi"),publicAccessToken:this.options.accessToken,storeDomain:this.options.storeDomain})}static{i(this,"StorefrontApiClient")}fetch(e,t){return t?.method==="OPTIONS"?fetch(e,t):this.shortCache.fetchWithCache(e,t)}async clearCache(){await this.shortCache.clear()}};var ei=Object.defineProperty,d=i((n,e)=>ei(n,"name",{value:e,configurable:!0}),"n"),ti={bodySerializer:d(n=>JSON.stringify(n,(e,t)=>typeof t=="bigint"?t.toString():t),"bodySerializer")},ni={$body_:"body",$headers_:"headers",$path_:"path",$query_:"query"},Lp=Object.entries(ni),ri=d(({onRequest:n,onSseError:e,onSseEvent:t,responseTransformer:r,responseValidator:s,sseDefaultRetryDelay:o,sseMaxRetryAttempts:a,sseMaxRetryDelay:u,sseSleepFn:c,url:l,...p})=>{let f,y=c??(h=>new Promise(b=>setTimeout(b,h)));return{stream:d(async function*(){let h=o??3e3,b=0,g=p.signal??new AbortController().signal;for(;!g.aborted;){b++;let O=p.headers instanceof Headers?p.headers:new Headers(p.headers);f!==void 0&&O.set("Last-Event-ID",f);try{let N={redirect:"follow",...p,body:p.serializedBody,headers:O,signal:g},L=new Request(l,N);n&&(L=await n(l,N));let G=await(p.fetch??globalThis.fetch)(L);if(!G.ok)throw new Error(`SSE failed: ${G.status} ${G.statusText}`);if(!G.body)throw new Error("No body in SSE response");let T=G.body.pipeThrough(new TextDecoderStream).getReader(),I="",V=d(()=>{try{T.cancel()}catch{}},"abortHandler");g.addEventListener("abort",V);try{for(;;){let{done:k,value:ee}=await T.read();if(k)break;I+=ee;let sn=I.split(`
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(`
443
443
 
444
- `);I=sn.pop()??"";for(let Mr of sn){let qr=Mr.split(`
444
+ `);I=sn.pop()??"";for(let Vr of sn){let qr=Vr.split(`
445
445
  `),ge=[],on;for(let W of qr)if(W.startsWith("data:"))ge.push(W.replace(/^data:\s*/,""));else if(W.startsWith("event:"))on=W.replace(/^event:\s*/,"");else if(W.startsWith("id:"))f=W.replace(/^id:\s*/,"");else if(W.startsWith("retry:")){let un=Number.parseInt(W.replace(/^retry:\s*/,""),10);Number.isNaN(un)||(h=un)}let se,an=!1;if(ge.length){let W=ge.join(`
446
- `);try{se=JSON.parse(W),an=!0}catch{se=W}}an&&(s&&await s(se),r&&(se=await r(se))),t?.({data:se,event:on,id:f,retry:h}),ge.length&&(yield se)}}}finally{g.removeEventListener("abort",V),T.releaseLock()}break}catch(N){if(e?.(N),a!==void 0&&b>=a)break;let L=Math.min(h*2**(b-1),u??3e4);await y(L)}}},"createStream")()}},"createSseClient"),si=d(n=>{switch(n){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorArrayExplode"),ii=d(n=>{switch(n){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},"separatorArrayNoExplode"),oi=d(n=>{switch(n){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorObjectExplode"),xr=d(({allowReserved:n,explode:e,name:t,style:r,value:s})=>{if(!e){let u=(n?s:s.map(c=>encodeURIComponent(c))).join(ii(r));switch(r){case"label":return`.${u}`;case"matrix":return`;${t}=${u}`;case"simple":return u;default:return`${t}=${u}`}}let o=si(r),a=s.map(u=>r==="label"||r==="simple"?n?u:encodeURIComponent(u):pt({allowReserved:n,name:t,value:u})).join(o);return r==="label"||r==="matrix"?o+a:a},"serializeArrayParam"),pt=d(({allowReserved:n,name:e,value:t})=>{if(t==null)return"";if(typeof t=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${e}=${n?t:encodeURIComponent(t)}`},"serializePrimitiveParam"),Cr=d(({allowReserved:n,explode:e,name:t,style:r,value:s,valueOnly:o})=>{if(s instanceof Date)return o?s.toISOString():`${t}=${s.toISOString()}`;if(r!=="deepObject"&&!e){let c=[];Object.entries(s).forEach(([p,f])=>{c=[...c,p,n?f:encodeURIComponent(f)]});let l=c.join(",");switch(r){case"form":return`${t}=${l}`;case"label":return`.${l}`;case"matrix":return`;${t}=${l}`;default:return l}}let a=oi(r),u=Object.entries(s).map(([c,l])=>pt({allowReserved:n,name:r==="deepObject"?`${t}[${c}]`:c,value:l})).join(a);return r==="label"||r==="matrix"?a+u:u},"serializeObjectParam"),ai=/\{[^{}]+\}/g,ui=d(({path:n,url:e})=>{let t=e,r=e.match(ai);if(r)for(let s of r){let o=!1,a=s.substring(1,s.length-1),u="simple";a.endsWith("*")&&(o=!0,a=a.substring(0,a.length-1)),a.startsWith(".")?(a=a.substring(1),u="label"):a.startsWith(";")&&(a=a.substring(1),u="matrix");let c=n[a];if(c==null)continue;if(Array.isArray(c)){t=t.replace(s,xr({explode:o,name:a,style:u,value:c}));continue}if(typeof c=="object"){t=t.replace(s,Cr({explode:o,name:a,style:u,value:c,valueOnly:!0}));continue}if(u==="matrix"){t=t.replace(s,`;${pt({name:a,value:c})}`);continue}let l=encodeURIComponent(u==="label"?`.${c}`:c);t=t.replace(s,l)}return t},"defaultPathSerializer"),ci=d(({baseUrl:n,path:e,query:t,querySerializer:r,url:s})=>{let o=s.startsWith("/")?s:`/${s}`,a=(n??"")+o;e&&(a=ui({path:e,url:a}));let u=t?r(t):"";return u.startsWith("?")&&(u=u.substring(1)),u&&(a+=`?${u}`),a},"getUrl");function kr(n){let e=n.body!==void 0;if(e&&n.bodySerializer)return"serializedBody"in n?n.serializedBody!==void 0&&n.serializedBody!==""?n.serializedBody:null:n.body!==""?n.body:null;if(e)return n.body}i(kr,"K");d(kr,"getValidRequestBody");var li=d(async(n,e)=>{let t=typeof e=="function"?await e(n):e;if(t)return n.scheme==="bearer"?`Bearer ${t}`:n.scheme==="basic"?`Basic ${btoa(t)}`:t},"getAuthToken"),Rr=d(({allowReserved:n,array:e,object:t}={})=>d(r=>{let s=[];if(r&&typeof r=="object")for(let o in r){let a=r[o];if(a!=null)if(Array.isArray(a)){let u=xr({allowReserved:n,explode:!0,name:o,style:"form",value:a,...e});u&&s.push(u)}else if(typeof a=="object"){let u=Cr({allowReserved:n,explode:!0,name:o,style:"deepObject",value:a,...t});u&&s.push(u)}else{let u=pt({allowReserved:n,name:o,value:a});u&&s.push(u)}}return s.join("&")},"querySerializer"),"createQuerySerializer"),pi=d(n=>{var e;if(!n)return"stream";let t=(e=n.split(";")[0])==null?void 0:e.trim();if(t){if(t.startsWith("application/json")||t.endsWith("+json"))return"json";if(t==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some(r=>t.startsWith(r)))return"blob";if(t.startsWith("text/"))return"text"}},"getParseAs"),di=d((n,e)=>{var t,r;return e?!!(n.headers.has(e)||(t=n.query)!=null&&t[e]||(r=n.headers.get("Cookie"))!=null&&r.includes(`${e}=`)):!1},"checkForExistence"),fi=d(async({security:n,...e})=>{for(let t of n){if(di(e,t.name))continue;let r=await li(t,e.auth);if(!r)continue;let s=t.name??"Authorization";switch(t.in){case"query":e.query||(e.query={}),e.query[s]=r;break;case"cookie":e.headers.append("Cookie",`${s}=${r}`);break;case"header":default:e.headers.set(s,r);break}}},"setAuthParams"),Sr=d(n=>ci({baseUrl:n.baseUrl,path:n.path,query:n.query,querySerializer:typeof n.querySerializer=="function"?n.querySerializer:Rr(n.querySerializer),url:n.url}),"buildUrl"),Er=d((n,e)=>{var t;let r={...n,...e};return(t=r.baseUrl)!=null&&t.endsWith("/")&&(r.baseUrl=r.baseUrl.substring(0,r.baseUrl.length-1)),r.headers=Ar(n.headers,e.headers),r},"mergeConfigs"),hi=d(n=>{let e=[];return n.forEach((t,r)=>{e.push([r,t])}),e},"headersEntries"),Ar=d((...n)=>{let e=new Headers;for(let t of n){if(!t)continue;let r=t instanceof Headers?hi(t):Object.entries(t);for(let[s,o]of r)if(o===null)e.delete(s);else if(Array.isArray(o))for(let a of o)e.append(s,a);else o!==void 0&&e.set(s,typeof o=="object"?JSON.stringify(o):o)}return e},"mergeHeaders"),Dr=class{static{i(this,"$")}constructor(){this.fns=[]}clear(){this.fns=[]}eject(e){let t=this.getInterceptorIndex(e);this.fns[t]&&(this.fns[t]=null)}exists(e){let t=this.getInterceptorIndex(e);return!!this.fns[t]}getInterceptorIndex(e){return typeof e=="number"?this.fns[e]?e:-1:this.fns.indexOf(e)}update(e,t){let r=this.getInterceptorIndex(e);return this.fns[r]?(this.fns[r]=t,e):!1}use(e){return this.fns.push(e),this.fns.length-1}};d(Dr,"Interceptors");var Yt=Dr,mi=d(()=>({error:new Yt,request:new Yt,response:new Yt}),"createInterceptors"),yi=Rr({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),vi={"Content-Type":"application/json"},lt=d((n={})=>({...ti,headers:vi,parseAs:"auto",querySerializer:yi,...n}),"createConfig"),Jt=d((n={})=>{let e=Er(lt(),n),t=d(()=>({...e}),"getConfig"),r=d(l=>(e=Er(e,l),t()),"setConfig"),s=mi(),o=d(async l=>{let p={...e,...l,fetch:l.fetch??e.fetch??globalThis.fetch,headers:Ar(e.headers,l.headers),serializedBody:void 0};p.security&&await fi({...p,security:p.security}),p.requestValidator&&await p.requestValidator(p),p.body!==void 0&&p.bodySerializer&&(p.serializedBody=p.bodySerializer(p.body)),(p.body===void 0||p.serializedBody==="")&&p.headers.delete("Content-Type");let f=Sr(p);return{opts:p,url:f}},"beforeRequest"),a=d(async l=>{let{opts:p,url:f}=await o(l),y={redirect:"follow",...p,body:kr(p)},h=new Request(f,y);for(let I of s.request.fns)I&&(h=await I(h,p));let b=p.fetch,g=await b(h);for(let I of s.response.fns)I&&(g=await I(g,h,p));let O={request:h,response:g};if(g.ok){let I=(p.parseAs==="auto"?pi(g.headers.get("Content-Type")):p.parseAs)??"json";if(g.status===204||g.headers.get("Content-Length")==="0"){let k;switch(I){case"arrayBuffer":case"blob":case"text":k=await g[I]();break;case"formData":k=new FormData;break;case"stream":k=g.body;break;case"json":default:k={};break}return p.responseStyle==="data"?k:{data:k,...O}}let V;switch(I){case"arrayBuffer":case"blob":case"formData":case"json":case"text":V=await g[I]();break;case"stream":return p.responseStyle==="data"?g.body:{data:g.body,...O}}return I==="json"&&(p.responseValidator&&await p.responseValidator(V),p.responseTransformer&&(V=await p.responseTransformer(V))),p.responseStyle==="data"?V:{data:V,...O}}let N=await g.text(),L;try{L=JSON.parse(N)}catch{}let G=L??N,T=G;for(let I of s.error.fns)I&&(T=await I(G,g,h,p));if(T=T||{},p.throwOnError)throw T;return p.responseStyle==="data"?void 0:{error:T,...O}},"request"),u=d(l=>p=>a({...p,method:l}),"makeMethodFn"),c=d(l=>async p=>{let{opts:f,url:y}=await o(p);return ri({...f,body:f.body,headers:f.headers,method:l,onRequest:d(async(h,b)=>{let g=new Request(h,b);for(let O of s.request.fns)O&&(g=await O(g,f));return g},"onRequest"),url:y})},"makeSseFn");return{buildUrl:Sr,connect:u("CONNECT"),delete:u("DELETE"),get:u("GET"),getConfig:t,head:u("HEAD"),interceptors:s,options:u("OPTIONS"),patch:u("PATCH"),post:u("POST"),put:u("PUT"),request:a,setConfig:r,sse:{connect:c("CONNECT"),delete:c("DELETE"),get:c("GET"),head:c("HEAD"),options:c("OPTIONS"),patch:c("PATCH"),post:c("POST"),put:c("PUT"),trace:c("TRACE")},trace:u("TRACE")}},"createClient"),R=Jt(lt({baseUrl:"https://swish.app/api/2026-01"})),gi=d(n=>(n?.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/lists",...n}),"listControllerFind"),wi=d(n=>(n.client??R).post({security:[{scheme:"bearer",type:"http"}],url:"/lists",...n,headers:{"Content-Type":"application/json",...n.headers}}),"listControllerCreate"),Ii=d(n=>(n.client??R).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...n}),"listControllerDeleteById"),bi=d(n=>(n.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...n}),"listControllerFindById"),Si=d(n=>(n.client??R).patch({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...n,headers:{"Content-Type":"application/json",...n.headers}}),"listControllerUpdateById"),Ei=d(n=>(n.client??R).put({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/order",...n,headers:{"Content-Type":"application/json",...n.headers}}),"listControllerSetListItemsOrder"),xi=d(n=>(n.client??R).post({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items",...n,headers:{"Content-Type":"application/json",...n.headers}}),"listControllerAddItemsToList"),Ci=d(n=>(n.client??R).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/{itemId}",...n}),"listControllerRemoveItemFromList"),ki=d(n=>(n.client??R).delete({security:[{scheme:"bearer",type:"http"}],url:"/items",...n,headers:{"Content-Type":"application/json",...n.headers}}),"itemControllerDelete"),Ri=d(n=>(n?.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/items",...n}),"itemControllerFind"),Ai=d(n=>(n.client??R).post({security:[{scheme:"bearer",type:"http"}],url:"/items",...n,headers:{"Content-Type":"application/json",...n.headers}}),"itemControllerCreate"),Di=d(n=>(n?.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/items/count",...n}),"itemControllerCount"),Pi=d(n=>(n.client??R).delete({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...n}),"itemControllerDeleteById"),Ti=d(n=>(n.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...n}),"itemControllerFindById"),_i=d(n=>(n.client??R).patch({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...n,headers:{"Content-Type":"application/json",...n.headers}}),"itemControllerUpdateById"),Oi=d(n=>(n.client??R).put({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}/lists",...n,headers:{"Content-Type":"application/json",...n.headers}}),"itemControllerSetListsById"),Li=d(n=>(n.client??R).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/identify",...n,headers:{"Content-Type":"application/json",...n.headers}}),"profileControllerIdentify"),$i=d(n=>(n.client??R).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/token",...n,headers:{"Content-Type":"application/json",...n.headers}}),"profileControllerCreateToken"),Vi=d(n=>(n?.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/profiles",...n}),"profileControllerGetProfile"),Mi=d(n=>(n.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/saved-items",...n}),"analyticsControllerLoadSavedItems"),qi=d(n=>(n.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/sessions",...n}),"analyticsControllerLoadSessions"),Ni=d(n=>(n.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/new-lists",...n}),"analyticsControllerLoadNewLists"),Bi=d(n=>(n.client??R).post({security:[{scheme:"bearer",type:"http"}],url:"/tracking",...n,headers:{"Content-Type":"application/json",...n.headers}}),"trackingControllerTrack"),Ui=d(n=>(n?.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/orders",...n}),"ordersControllerFind"),Fi=d(n=>(n.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/orders/{orderId}",...n}),"ordersControllerFindOne"),ji=d(n=>(n.client??R).post({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{listId}/save",...n}),"sharedListsControllerSave"),Gi=d(n=>(n.client??R).delete({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{listId}",...n}),"sharedListsControllerDeleteById"),Hi=d(n=>(n.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{listId}",...n}),"sharedListsControllerFindById"),Qi=d(n=>(n?.client??R).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists",...n}),"sharedListsControllerFindAll"),Zt="2026-01",Pr=d(n=>new zi(n),"createApiClient"),Tr=class{static{i(this,"H")}constructor(e){this.version=Zt,this.items={list:d(u=>this.handlePaginatedRequest(Ri({query:u,client:this.directClient})),"list"),create:d(u=>this.handleRequest(Ai({body:u,client:this.directClient})),"create"),delete:d(u=>this.handleRequest(ki({body:{itemIds:u},client:this.directClient})),"delete"),findById:d(u=>this.handleRequest(Ti({path:{itemId:u},client:this.directClient})),"findById"),updateById:d((u,c)=>this.handleRequest(_i({body:c,path:{itemId:u},client:this.directClient})),"updateById"),deleteById:d(u=>this.handleRequest(Pi({path:{itemId:u},client:this.directClient})),"deleteById"),setListsById:d((u,c)=>this.handleRequest(Oi({body:{listIds:c},path:{itemId:u},client:this.directClient})),"setListsById"),count:d(()=>this.handleRequest(Di({client:this.directClient})),"count")},this.lists={list:d(u=>this.handlePaginatedRequest(gi({query:u,client:this.directClient})),"list"),create:d(u=>this.handleRequest(wi({body:u,client:this.directClient})),"create"),findById:d(u=>this.handleRequest(bi({path:{listId:u},client:this.directClient})),"findById"),updateById:d((u,c)=>this.handleRequest(Si({body:c,path:{listId:u},client:this.directClient})),"updateById"),deleteById:d(u=>this.handleRequest(Ii({path:{listId:u},client:this.directClient})),"deleteById"),orderItems:d((u,c)=>this.handleRequest(Ei({body:{itemIds:c},path:{listId:u},client:this.directClient})),"orderItems"),addItemsToList:d((u,c)=>this.handleRequest(xi({body:{itemIds:c},path:{listId:u},client:this.directClient})),"addItemsToList"),removeItemFromList:d((u,c)=>this.handleRequest(Ci({path:{listId:u,itemId:c},client:this.directClient})),"removeItemFromList")},this.profiles={createToken:d((u={})=>this.handleRequest($i({body:u,client:this.proxyClient??this.directClient})),"createToken"),identify:d(u=>this.handleRequest(Li({body:u,client:this.directClient})),"identify"),getProfile:d(()=>this.handleRequest(Vi({client:this.directClient})),"getProfile")},this.orders={list:d(u=>this.handlePaginatedRequest(Ui({query:u,client:this.directClient})),"list"),findById:d(u=>this.handleRequest(Fi({path:{orderId:u},client:this.directClient})),"findById")},this.sharedLists={list:d(u=>this.handlePaginatedRequest(Qi({query:u,client:this.directClient})),"list"),save:d(u=>this.handleRequest(ji({path:{listId:u},client:this.directClient})),"save"),findById:d(u=>this.handleRequest(Hi({path:{listId:u},client:this.directClient})),"findById"),deleteById:d(u=>this.handleRequest(Gi({path:{listId:u},client:this.directClient})),"deleteById")},this.analytics={savedItems:d(u=>this.handleRequest(Mi({query:u,client:this.directClient})),"savedItems"),sessions:d(u=>this.handleRequest(qi({query:u,client:this.directClient})),"sessions"),newLists:d(u=>this.handleRequest(Ni({query:u,client:this.directClient})),"newLists")},this.tracking={track:d((u,c)=>this.handleRequest(Bi({body:u,headers:c,client:this.directClient})),"track")},this.handleRequest=d(async u=>{let{data:c,error:l}=await u;return l!=null&&l.error?{error:l.error}:{data:c?.data}},"handleRequest"),this.handlePaginatedRequest=d(async u=>{var c;let{data:l,error:p}=await u;return p!=null&&p.error?{error:p.error}:{data:l?.data??[],pageInfo:l?.pageInfo??{next:null,previous:null,totalCount:((c=l?.data)==null?void 0:c.length)??0}}},"handlePaginatedRequest");var t,r,s,o,a;(t=e.config)!=null&&t.version&&(this.version=e.config.version),this.directClient=Jt(lt({baseUrl:`https://swish.app/api/${this.version}`,...e.config})),(r=e.config)!=null&&r.authProxy&&(this.proxyClient=Jt(lt({...e.config,baseUrl:e.config.authProxy}))),e.authToken&&(this.authToken=e.authToken),e.requestInterceptor&&((s=this.proxyClient)==null||s.interceptors.request.use(e.requestInterceptor),this.directClient.interceptors.request.use(e.requestInterceptor)),e.responseInterceptor&&((o=this.proxyClient)==null||o.interceptors.response.use(e.responseInterceptor),this.directClient.interceptors.response.use(e.responseInterceptor)),(a=this.proxyClient)==null||a.interceptors.request.use(this.proxyRequestInterceptor.bind(this)),this.directClient.interceptors.request.use(this.directRequestInterceptor.bind(this))}setAuthToken(e){this.authToken=e}proxyRequestInterceptor(e){return this.version&&e.headers.set("Swish-Api-Version",this.version),e}directRequestInterceptor(e){return this.authToken&&e.headers.set("Authorization",`Bearer ${this.authToken}`),e}};d(Tr,"SwishClient");var zi=Tr;var $r=Qr(Lr(),1);var Vr=i(n=>new $r.default(async e=>{let t=[...new Set(e)].sort((s,o)=>s.localeCompare(o)),r=await n.items.list({query:t.join(" "),limit:200});return"error"in r?(console.error("Failed to load items",r.error),e.map(()=>({data:[],pageInfo:{next:null,previous:null,totalCount:0}}))):e.map(s=>{let o=r.data.find(a=>s===`variant:${a.variantId}`||s===`product:${a.productId}`);return{data:o?[o]:[],pageInfo:{next:null,previous:null,totalCount:o?1:0}}})},{batchScheduleFn:i(e=>setTimeout(e,50),"batchScheduleFn"),cache:!1,maxBatchSize:200}),"createItemsBatchLoader");var dt=class{constructor(e,t,r){this.tokenHasProfile=!1;this.api=e,this.context=t,this.eventBus=r}static{i(this,"SwishApiAuth")}hasProfile(){return this.tokenHasProfile}hasToken(){return!!this.getSwishToken()}async renewToken(){return this._renewPromise?this._renewPromise:(this._renewPromise=(async()=>{this._initPromise=void 0,this.deleteSwishToken(),await this.init(),this._renewPromise=void 0})(),this._renewPromise)}async init(){return this._initPromise?this._initPromise:(this._initPromise=(async()=>{this.migrateLegacySession();let e=this.context.customer.id;e?(this.hasSessionToken()&&await this.api.clearCache(),await this.initCustomer(e)):(this.hasCustomerToken()&&await this.resetSession(),await this.initSession()),this.eventBus.publish("token-update",null)})(),this._initPromise)}async initCustomer(e){let t=`gid://shopify/Customer/${e}`,r=this.getTokenBySub(t);if(r){this.initToken(r);return}let s=this.getSessionId();await this.acquireToken(s,t)}async initSession(){let e=this.getSessionId(),t=e?this.getTokenBySub(e):null;if(t){this.initToken(t);return}await this.acquireToken(e)}initToken(e){let t=this.getTokenData(e);if(!t)throw new Error("Invalid Swish token.");this.tokenHasProfile=t.has_profile!==!1,this.api.setAuthToken(e)}async acquireToken(e,t){let r=await this.api.profiles.createToken({customer:t,session:e});if("error"in r)throw console.error("Failed to create customer token",r.error),new Error("Failed to create customer token");if(!r.data?.token)throw console.error("Failed to create customer token empty response"),new Error("Failed to create customer token");r.data.profile.startsWith("gid://swish/Session/")&&this.setSessionId(r.data.profile),this.setSwishToken(r.data.token),this.initToken(r.data.token)}async resetSession(){this.deleteSessionId(),this.deleteSwishToken(),await this.api.clearCache()}getTokenData(e){try{return JSON.parse(atob(e.split(".")[1]))}catch(t){return console.error("Failed to parse Swish token",{cause:t}),null}}willTokenExpire(e,t=60){let r=this.getTokenData(e);return!!(r&&r.exp&&r.exp<Date.now()/1e3+t)}hasCustomerToken(){let e=this.getSwishToken();return e?this.getTokenData(e)?.sub?.startsWith("gid://shopify/Customer/")??!1:!1}hasSessionToken(){let e=this.getSwishToken();return e?this.getTokenData(e)?.sub?.startsWith("gid://swish/Session/")??!1:!1}getTokenBySub(e){if(!e)return null;let t=this.getSwishToken();if(!t)return null;let r=this.getTokenData(t);return!r||r.sub!==e||this.willTokenExpire(t,60)?null:t}getSessionId(){let e=H(this.context.myshopifyDomain);return localStorage.getItem(`swish-session-${e}`)??void 0}setSessionId(e){let t=H(this.context.myshopifyDomain);localStorage.setItem(`swish-session-${t}`,e)}deleteSessionId(){let e=H(this.context.myshopifyDomain);localStorage.removeItem(`swish-session-${e}`)}getSwishToken(){let e=H(this.context.myshopifyDomain);return sessionStorage.getItem(`swish-token-${e}`)??void 0}setSwishToken(e){let t=H(this.context.myshopifyDomain);sessionStorage.setItem(`swish-token-${t}`,e)}deleteSwishToken(){let e=H(this.context.myshopifyDomain);sessionStorage.removeItem(`swish-token-${e}`)}migrateLegacySession(){try{let e=localStorage.getItem("wk_session_id")??localStorage.getItem("swish-profile")?.split("/").pop()??localStorage.getItem("swish-session")?.split("/").pop();e&&(this.setSessionId(`gid://swish/Session/${e}`),localStorage.removeItem("wk_session_id"),localStorage.removeItem("swish-profile"),localStorage.removeItem("swish-session"))}catch(e){console.warn("Failed to migrate legacy session id to Swish session",{cause:e})}}};var ft=class{static{i(this,"SwishApi")}constructor(e,t,r,s){this.config=e,this.storefrontContext=t;let o=H(t.myshopifyDomain);this.cache=new Y(`swish-api-${o}`,"max-age=60, stale-while-revalidate=3600",s+(e.version??Zt)),this.cache.cleanupExpiredEntries().catch(a=>{console.warn("Swish API cache initialization cleanup error:",a)}),this.auth=new dt(this,t,r),this.apiClient=Pr({authToken:this.auth.getSwishToken(),config:{...e,fetch:this.fetchFunction.bind(this)},requestInterceptor:this.requestInterceptor.bind(this),responseInterceptor:this.responseInterceptor.bind(this)}),this.itemsLoader=Vr(this)}async fetchFunction(e,t){let r=e instanceof Request?e.method:t?.method??"GET",o=(e instanceof Request?e.url:typeof e=="string"?e:e.toString()).includes("/orders");return r==="GET"&&!o?this.cache.fetchWithCache(e,t):fetch(e,t)}async requestInterceptor(e){let t=new URL(e.url,window.location.origin);!!this.config.authProxy&&t.pathname.startsWith(this.config.authProxy)||await this.initAuth();try{e.headers.set("Country",this.storefrontContext.localization.country),e.headers.set("Language",this.storefrontContext.localization.language),e.headers.set("Market",this.storefrontContext.localization.market)}catch(s){console.warn("Failed to set storefront context headers:",s)}return this.config.requestInterceptor&&(e=await this.config.requestInterceptor(e)),e}async responseInterceptor(e,t){let r=t.method!=="GET",s=t.url.includes("/profiles/token");if(r&&!s){let o=this.auth.hasToken(),a=!this.auth.hasProfile(),u=e.ok;await this.cache.clear(),o&&a&&u&&await this.auth.renewToken()}return await this.config.responseInterceptor?.(e,t),e}setAuthToken(e){this.apiClient.setAuthToken(e)}initAuth(){return this.auth.init()}async withFallback(e,t){return await this.initAuth(),this.auth.hasProfile()?e():Promise.resolve(t)}get items(){return{...this.apiClient.items,count:i(async()=>this.withFallback(()=>this.apiClient.items.count(),{data:{count:0}}),"count"),list:i(async(e,t)=>{let r=i(()=>{if(t?.batch&&e?.query){e.limit!==1&&console.warn("Batching will always limit to 1 item");let s=e.query.split(" ");s.length>1&&console.warn("Batching will only support one query parameter");let o=s[0];if(!o.match(/^product:\d+$/)&&!o.match(/^variant:\d+$/))console.warn("Batching will only support product:<id> or variant:<id>");else return this.itemsLoader?.load(o)}return this.apiClient.items.list(e)},"execute");return t?.shared?r():this.withFallback(r,{data:[],pageInfo:{next:null,previous:null,totalCount:0}})},"list"),findById:i(async e=>this.withFallback(()=>this.apiClient.items.findById(e),{data:null}),"findById")}}get lists(){return{...this.apiClient.lists,list:i(async e=>this.withFallback(()=>this.apiClient.lists.list(e),{data:[],pageInfo:{next:null,previous:null,totalCount:0}}),"list"),findById:i(async(e,t)=>{let r=i(()=>this.apiClient.lists.findById(e),"execute");return t?.shared?r():this.withFallback(()=>this.apiClient.lists.findById(e),{data:null})},"findById")}}get orders(){return{...this.apiClient.orders,list:i(async e=>this.withFallback(()=>this.apiClient.orders.list(e),{data:[],pageInfo:{next:null,previous:null,totalCount:0}}),"list"),findById:i(async e=>this.withFallback(()=>(typeof e=="string"&&(e=parseInt(e.split("/").pop()??e)),this.apiClient.orders.findById(e)),{data:null}),"findById")}}get profiles(){return this.apiClient.profiles}async clearCache(){await this.cache.clear()}};var ht=class{constructor(e){this.eventMap={"POST /items\\/?$":"item-create","DELETE /items\\/?$":"item-delete","PATCH /items\\/([^/]+)\\/?$":"item-update","DELETE /items\\/([^/]+)\\/?$":"item-delete","PUT /items\\/([^/]+)\\/lists\\/?$":"item-lists-update","POST /lists\\/?$":"list-create","DELETE /lists\\/?$":"list-delete","PATCH /lists\\/([^/]+)\\/?$":"list-update","DELETE /lists\\/([^/]+)\\/?$":"list-delete"};this.eventBus=e,this.processFetchResponse=this.processFetchResponse.bind(this)}static{i(this,"SwishApiPublisher")}async processFetchResponse(e,t){try{let r=this.getEventName(t.method,e.status,t.url);if(!r)return;let s=await e.clone().text();if(e.headers.get("Content-Type")?.includes("application/json"))try{s=JSON.parse(s).data}catch(o){console.warn(o)}this.eventBus.publish(r,s)}catch(r){console.warn(r)}}getEventName(e,t,r){e=e.toUpperCase();let s=new URL(r).pathname;return e==="GET"||t<200||t>=300?void 0:Object.entries(this.eventMap).find(([a])=>{let[u,c]=a.split(" ");return u!==e?!1:new RegExp(c).test(s)})?.[1]}};var mt=class{constructor(e,t){this.inflightModals=new Map;this.modalsWithScrollLock=new Set;this.scrollLockRefCount=0;this.scrollPositionBeforeLock=0;this._templatePromises=new Map;this._importPromises=new Map;this._lockScroll=i(()=>this.lockScroll(),"_lockScroll");this._unlockScroll=i(()=>this.unlockScroll(),"_unlockScroll");this.swishUiOptions=e,this.storefrontContext=t}static{i(this,"SwishUi")}async hideModal(e){if(this.inflightModals.has(e))return this.inflightModals.get(e);let t=(async()=>{try{if(typeof e=="string"&&(e=await this.requireUiComponent(e)),!e||e.getAttribute("open")!=="true")return;e.setAttribute("open","false")}finally{e&&typeof e!="string"&&this.modalsWithScrollLock.has(e)&&(this.modalsWithScrollLock.delete(e),this.unlockScroll())}})().finally(()=>{this.inflightModals.delete(e)});return this.inflightModals.set(e,t),t}async showModal(e){if(this.inflightModals.has(e))return this.inflightModals.get(e);let t=(async()=>{typeof e=="string"&&(e=await this.requireUiComponent(e)),!(!e||e.getAttribute("open")==="true")&&(this.lockScroll(),this.modalsWithScrollLock.add(e),e.setAttribute("open","true"))})().finally(()=>{this.inflightModals.delete(e)});return this.inflightModals.set(e,t),t}waitForEvent(e,t){return new Promise(r=>{let s=[],o=i(()=>{s.forEach(({event:a,listener:u})=>{e.removeEventListener(a,u)})},"cleanup");Object.entries(t).forEach(([a,u])=>{let c=i(l=>{let p=u(l);o(),r(p)},"listener");s.push({event:a,listener:c}),e.addEventListener(a,c)})})}async showSignIn(e){let t=await this.requireUiComponent("sign-in");t.setAttribute("return-to",e?.returnTo??window.location.pathname),await this.showModal(t);let r=await this.waitForEvent(t,{close:i(()=>({code:"closed"}),"close")});return await this.hideModal(t),r}async showUnsaveAlert(e){if(!e.itemId)throw new Error("An itemId is required to show the unsave alert");await this.hideAllToasts();let t=await this.requireUiComponent("unsave-alert");t.setAttribute("item-id",e.itemId),await this.showModal(t);let r=await this.waitForEvent(t,{submit:i(s=>s instanceof CustomEvent?{code:"ok",data:s.detail}:(console.warn("Unsave alert submitted without detail",s),{code:"closed"}),"submit"),close:i(()=>({code:"closed"}),"close")});return await this.hideModal(t),r}async showDeleteListAlert(e){if(!e.listId)throw new Error("A listId is required to show the delete list alert");await this.hideAllToasts();let t=await this.requireUiComponent("delete-list-alert");t.setAttribute("list-id",e.listId),await this.showModal(t);let r=await this.waitForEvent(t,{submit:i(()=>({code:"ok",data:void 0}),"submit"),close:i(()=>({code:"closed"}),"close")});return await this.hideModal(t),r}async showConfirmDialog(e){await this.hideAllToasts();let t=await this.requireUiComponent("confirm-dialog");e.titleKey?t.setAttribute("title-key",e.titleKey):t.removeAttribute("title-key"),e.descriptionKey?t.setAttribute("description-key",e.descriptionKey):t.removeAttribute("description-key"),e.confirmLabelKey?t.setAttribute("confirm-label-key",e.confirmLabelKey):t.removeAttribute("confirm-label-key"),e.cancelLabelKey?t.setAttribute("cancel-label-key",e.cancelLabelKey):t.removeAttribute("cancel-label-key"),e.danger?t.setAttribute("danger",""):t.removeAttribute("danger"),await this.showModal(t);let r=await this.waitForEvent(t,{submit:i(()=>({code:"ok",data:void 0}),"submit"),close:i(()=>({code:"closed"}),"close")});return await this.hideModal(t),r}async showDrawer(e){await this.hideAllToasts();let t=await this.requireUiComponent("drawer");t.setAttribute("account-url",this.storefrontContext.routes.accountUrl),this.storefrontContext.customer.id&&t.setAttribute("customer-id",this.storefrontContext.customer.id),t.setAttribute("view",e?.view??"home"),e?.listId&&t.setAttribute("list-id",e.listId),e?.productId&&t.setAttribute("product-id",e.productId),e?.variantId&&t.setAttribute("variant-id",e.variantId),e?.orderId&&t.setAttribute("order-id",e.orderId),await this.showModal(t);let r=await this.waitForEvent(t,{close:i(()=>({code:"closed"}),"close")});return await this.hideModal(t),r}async showListMenu(e){if(!e.listId)throw new Error("listId is required");await this.hideAllToasts();let t=await this.requireUiComponent("list-menu");t.setAttribute("list-id",e.listId),await this.showModal(t);let r=await this.waitForEvent(t,{close:i(()=>({code:"closed"}),"close"),edit:i(s=>s instanceof CustomEvent?{code:"ok",data:{action:"edit",data:s.detail}}:(console.warn("List menu edit without detail",s),{code:"closed"}),"edit"),delete:i(()=>({code:"ok",data:{action:"delete"}}),"delete"),share:i(()=>({code:"ok",data:{action:"share"}}),"share"),"edit-access":i(s=>{if(s instanceof CustomEvent){let a=s.detail?.currentListAccess;if(a==="public"||a==="private")return{code:"ok",data:{action:"edit-access",data:{currentListAccess:a}}}}return{code:"ok",data:{action:"edit-access"}}},"edit-access")});return await this.hideModal(t),r}async showOrderMenu(e){if(!e.orderId)throw new Error("orderId is required");await this.hideAllToasts();let t=await this.requireUiComponent("order-menu");t.setAttribute("order-id",e.orderId),await this.showModal(t);let r=await this.waitForEvent(t,{close:i(()=>({code:"closed"}),"close")});return await this.hideModal(t),r}async showListDetailPageMenu(e){await this.hideAllToasts();let t=await this.requireUiComponent("list-detail-page-menu");t.setAttribute("list-id",e.listId),await this.showModal(t);let r=await this.waitForEvent(t,{close:i(()=>({code:"closed"}),"close")});return await this.hideModal(t),r}async showListSelect(e){if(!e.itemId)throw new Error("itemId is required");await this.hideAllToasts();let t=await this.requireUiComponent("list-select");t.setAttribute("item-id",e.itemId),await this.showModal(t);let r=await this.waitForEvent(t,{close:i(()=>({code:"closed"}),"close"),submit:i(s=>"detail"in s&&s.detail?{code:"ok",data:{action:"submit",data:s.detail}}:(console.warn("List select submit without detail",s),{code:"closed"}),"submit"),unsave:i(s=>s instanceof CustomEvent?{code:"ok",data:{action:"unsave",data:s.detail}}:(console.warn("List select unsave without detail",s),{code:"closed"}),"unsave")});return await this.hideModal(t),r}async initListDetailPage(e,t){let r=await this.requireUiComponent("list-detail-page",{refElement:t});e.listId&&r.setAttribute("list-id",e.listId)}async showToast(e){let t=Date.now(),r=await this.requireUiComponent("toast-manager",{onHydrated:i(s=>{s.current.show(e,t)},"onHydrated")});return this.waitForEvent(r,{[`close-${t}`]:()=>({code:"closed"}),[`submit-${t}`]:()=>({code:"ok",data:void 0})})}async hideAllToasts(){this.queryComponent("toast-manager")&&await this.requireUiComponent("toast-manager",{onHydrated:i(e=>{e.current.clear()},"onHydrated")})}async showVariantSelect(e){await this.hideAllToasts();let t=await this.requireUiComponent("variant-select");if(e?.itemId&&t.setAttribute("item-id",e.itemId),e?.productId)t.setAttribute("product-id",e.productId.toString());else if(e?.productHandle)t.setAttribute("product-handle",e.productHandle);else throw new Error("Either productId or productHandle must be provided");e?.variantId&&t.setAttribute("variant-id",e.variantId.toString()),await this.showModal(t);let r=await this.waitForEvent(t,{close:i(()=>({code:"closed"}),"close"),submit:i(s=>"detail"in s&&s.detail?{code:"ok",data:s.detail}:(console.warn("Variant select submit without detail",s),{code:"closed"}),"submit")});return await this.hideModal(t),r}async showQuickBuy(e){await this.hideAllToasts();let t=await this.requireUiComponent("quick-buy");if(e?.productId)t.setAttribute("product-id",e.productId.toString());else if(e?.productHandle)t.setAttribute("product-handle",e.productHandle);else throw new Error("ProductId or productHandle must be provided");e?.variantId&&t.setAttribute("variant-id",e.variantId.toString()),await this.showModal(t);let r=await this.waitForEvent(t,{close:i(()=>({code:"closed"}),"close"),submit:i(s=>"detail"in s&&s.detail?{code:"ok",data:s.detail}:(console.warn("Quick buy submit without detail",s),{code:"closed"}),"submit")});return await this.hideModal(t),r}async showListEditor(e){let t=await this.requireUiComponent("list-editor");e?.listId&&t.setAttribute("list-id",e.listId),await this.showModal(t);let r=await this.waitForEvent(t,{close:i(()=>({code:"closed"}),"close"),submit:i(s=>"detail"in s&&s.detail?{code:"ok",data:s.detail}:(console.warn("List editor submit without detail",s),{code:"closed"}),"submit")});return await this.hideModal(t),r}async createElement(e,t){let[r,{themeVariablesStylesheet:s}]=await Promise.all([this.loadTemplate(e),this.loadCricalResources()]),o=document.createElement("template");o.innerHTML=r.replace(' shadowrootmode="open"',"");let a=o.content.firstElementChild;return a.addEventListener("connected",()=>{a.shadowRoot&&(a.shadowRoot.adoptedStyleSheets=[s],this.hydrateElement(e,a,t?.onHydrated))},{once:!0}),a}async hydrateElement(e,t,r){if(t.hasAttribute("hydrated")){r?.(t.getComponentRef());return}await Promise.all([this.loadNonCriticalResources(),this.importScript(e)]).then(([{bundleCssStylesheet:s,customCssStylesheets:o},{hydrate:a}])=>{t.shadowRoot&&s&&(t.shadowRoot.adoptedStyleSheets=[...t.shadowRoot.adoptedStyleSheets,...o,s],t.shadowRoot?.querySelector(":host > style")?.remove()),a(t),t.setAttribute("hydrated","")}),r?.(t.getComponentRef())}async requireUiComponent(e,t){this.loadCricalResources();let r=await this.loadTemplate(e),s=this.queryComponent(e)??await this.insertComponent({name:e,template:r,refElement:t?.refElement??document.body,position:"beforeend"});return s.shadowRoot&&!s.hasAttribute("hydrated")?Promise.all([this.loadNonCriticalResources(),this.importScript(e)]).then(([{bundleCssStylesheet:o,customCssStylesheets:a},{hydrate:u}])=>{s.shadowRoot&&o&&(s.shadowRoot.adoptedStyleSheets=[...s.shadowRoot.adoptedStyleSheets,...a,o],s.shadowRoot?.querySelector(":host > style")?.remove()),u(s),s.setAttribute("hydrated",""),t?.onHydrated?.(s.getComponentRef())}):s.hasAttribute("hydrated")&&t?.onHydrated?.(s.getComponentRef()),s}async loadTemplate(e){let t=`${this.swishUiOptions.baseUrl}/ui@${this.swishUiOptions.version}/${e}.html`;if(this._templatePromises.has(t))return this._templatePromises.get(t);let r=fetch(t).then(s=>s.text());return this._templatePromises.set(t,r),r}async importScript(e){let t=`${this.swishUiOptions.baseUrl}/ui@${this.swishUiOptions.version}/${e}.js`;if(this._importPromises.has(t))return this._importPromises.get(t);let r=import(t);return this._importPromises.set(t,r),r}async loadCricalResources(){return this._loadCricalResourcesPromise?this._loadCricalResourcesPromise:(this._loadCricalResourcesPromise=(async()=>{let e=`${this.swishUiOptions.baseUrl}/ui@${this.swishUiOptions.version}/theme.css`,t=await fetch(e).then(o=>o.text()),r=new CSSStyleSheet;r.replaceSync(t);let s=ro(this.swishUiOptions.design);return Object.entries(s).forEach(([o,a])=>{r.cssRules[0].cssRules[0].style.setProperty(o,a)}),{themeVariablesStylesheet:r}})(),this._loadCricalResourcesPromise)}async loadNonCriticalResources(){return this._loadNonCriticalResourcesPromise?this._loadNonCriticalResourcesPromise:(this._loadNonCriticalResourcesPromise=(async()=>{let e=`${this.swishUiOptions.baseUrl}/ui@${this.swishUiOptions.version}/bundle.css`,t=i(o=>{let a=new CSSStyleSheet;return a.replaceSync(o),a},"createCssStylesheet"),[r,...s]=await Promise.all([fetch(e).then(o=>o.text()).then(t),...this.swishUiOptions.css.map(async o=>o instanceof URL?t(await fetch(o).then(a=>a.text())):t(o))]);return{bundleCssStylesheet:r,customCssStylesheets:s}})(),this._loadNonCriticalResourcesPromise)}async insertComponent({name:e,template:t,position:r,refElement:s}){let{themeVariablesStylesheet:o}=await this.loadCricalResources();s.insertAdjacentHTML(r,t.replace(' shadowrootmode="open"',""));let a=this.queryComponent(e);if(!a)throw new Error(`Element ${e} not found in DOM`);return a.shadowRoot&&(a.shadowRoot.adoptedStyleSheets=[o]),a}queryComponent(e,t){let r=`swish-ui[ref="${e}${t?`-${t}`:""}"]`;return document.querySelector(r)}lockScroll(){this.scrollLockRefCount++,this.scrollLockRefCount===1&&(this.scrollPositionBeforeLock=window.scrollY,this.scrollLockStyleSheet||(this.scrollLockStyleSheet=new CSSStyleSheet,document.adoptedStyleSheets=[...document.adoptedStyleSheets,this.scrollLockStyleSheet]),this.scrollLockStyleSheet.replaceSync(`
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(`
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.107.0",qd=`https://swish.app/cdn/sdk@${tt}/swish.js`,Nd=i(async n=>{if(typeof window>"u")throw new Error("Swish is not supported in this environment");if(window.swish)return window.swish;let e=bn(n),t=new rn(e);return window.swish=t,document.dispatchEvent(new Event("swish-ready")),t.api.initAuth().then(()=>{typeof window.Shopify?.analytics?.publish=="function"&&window.Shopify.analytics.publish("swish-ready",{market:e.storefrontContext.localization.market,country:e.storefrontContext.localization.country,language:e.storefrontContext.localization.language,rootUrl:e.storefrontContext.routes.rootUrl})}),t},"createSwish"),rn=class{constructor(e){this.dom={createElementLocator:ie,createLocationObserver:le,createPlacement:i(e=>fn(this,e),"createPlacement")};this.ui={createElement:i((e,t)=>this.swishUi.createElement(e,t),"createElement")};this.utils={copyToClipboard:me,createShareUrl:i(e=>he(this,e),"createShareUrl")};this.state={itemContext:Dn(this),itemState:Pn(this),itemCount:Tn(this),swishQuery:_n(this),effect:Q,signal:$,computed:F};this.swishOptions=e,this.events=new Se,this.swishBadges=new vt({getBadges:this.swishOptions.badges?.getBadges}),this.swishApiPublisher=new ht(this.events);let t=[tt,e.swishUi?.version].join("-");this.swishApi=new ft({...this.swishOptions.swishApi,responseInterceptor:this.swishApiPublisher.processFetchResponse},this.swishOptions.storefrontContext,this.events,t),this.ajaxApiPublisher=new Ie(this.events),this.ajaxApi=new we({storeDomain:this.swishOptions.storefrontApi.storeDomain,responseInterceptor:this.ajaxApiPublisher.processFetchResponse}),this.ajaxApi.patchFetch(),this.storefrontApi=new ct(this.swishOptions.storefrontApi,this.swishOptions.storefrontContext,this.swishBadges,this.swishOptions.productOptions,this.swishOptions.metafields),this.swishUi=new mt(this.swishOptions.swishUi,this.swishOptions.storefrontContext),this.events.subscribe(["cart-add","cart-update","cart-change","cart-clear"],()=>{this.ajaxApi.clearCache()}),customElements.get("swish-ui")||customElements.define("swish-ui",yt),this.intents=new et(this,this.swishUi)}static{i(this,"SwishApp")}get options(){return this.swishOptions}get storefrontContext(){return this.swishOptions.storefrontContext}get badges(){return this.swishBadges}get api(){return this.swishApi}get storefront(){return this.storefrontApi}get ajax(){return this.ajaxApi}get shopUrl(){return`https://${this.swishOptions.storefrontApi.storeDomain}`}};export{tt as VERSION,he as buildShareListUrl,me as copyToClipboard,Nd as createSwish,qd as swishSdkUrl};
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swishapp/sdk",
3
- "version": "0.107.0",
3
+ "version": "0.108.0",
4
4
  "description": "JS SDK for Swish.",
5
5
  "author": "Swish",
6
6
  "license": "UNLICENSED",