@swishapp/sdk 0.55.0 → 0.57.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/dom/dom-utils.d.ts +2 -1
  2. package/dist/index.d.ts +2 -1
  3. package/dist/intents/handlers/create-item-handler.d.ts +29 -0
  4. package/dist/intents/handlers/create-list-handler.d.ts +13 -0
  5. package/dist/intents/handlers/delete-item-handler.d.ts +18 -0
  6. package/dist/intents/handlers/delete-list-handler.d.ts +18 -0
  7. package/dist/intents/handlers/edit-item-lists-handler.d.ts +25 -0
  8. package/dist/intents/handlers/edit-item-variant-handler.d.ts +28 -0
  9. package/dist/intents/handlers/edit-list-handler.d.ts +19 -0
  10. package/dist/intents/handlers/open-home-handler.d.ts +10 -0
  11. package/dist/intents/handlers/open-list-menu-handler.d.ts +18 -0
  12. package/dist/intents/handlers/open-quick-buy-handler.d.ts +18 -0
  13. package/dist/intents/handlers/open-sign-in-handler.d.ts +16 -0
  14. package/dist/intents/hooks/after-create-item-hook.d.ts +6 -0
  15. package/dist/intents/hooks/after-edit-item-lists-hook.d.ts +6 -0
  16. package/dist/intents/intent-handler.d.ts +10 -0
  17. package/dist/intents/intent-hook.d.ts +9 -0
  18. package/dist/intents/intents.d.ts +21 -0
  19. package/dist/intents/types.d.ts +72 -0
  20. package/dist/state/index.d.ts +1 -1
  21. package/dist/state/item-context-signal.d.ts +0 -2
  22. package/dist/state/item-state-signal.d.ts +2 -2
  23. package/dist/storefront-api/load-save-intent-data.d.ts +12 -0
  24. package/dist/storefront-api/queries/fragments.d.ts +3 -2
  25. package/dist/storefront-api/queries/index.d.ts +10 -8
  26. package/dist/storefront-api/storefront-api-client.d.ts +8 -3
  27. package/dist/storefront-api/types/storefront.generated.d.ts +66 -16
  28. package/dist/swish-ui/swish-ui-utils.d.ts +45 -30
  29. package/dist/swish.d.ts +9 -39
  30. package/dist/swish.js +126 -71
  31. package/dist/utils/shopify-gid.d.ts +2 -2
  32. package/package.json +3 -2
package/dist/swish.js CHANGED
@@ -1,18 +1,54 @@
1
- var jr=Object.create;var Le=Object.defineProperty;var Qr=Object.getOwnPropertyDescriptor;var zr=Object.getOwnPropertyNames;var Wr=Object.getPrototypeOf,Yr=Object.prototype.hasOwnProperty;var o=(t,e)=>Le(t,"name",{value:e,configurable:!0});var Kr=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Jr=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of zr(e))!Yr.call(t,a)&&a!==r&&Le(t,a,{get:()=>e[a],enumerable:!(n=Qr(e,a))||n.enumerable});return t};var Xr=(t,e,r)=>(r=t!=null?jr(Wr(t)):{},Jr(e||!t||!t.__esModule?Le(r,"default",{value:t,enumerable:!0}):r,t));var Dr=Kr((ts,Pr)=>{"use strict";var aa=(function(){function t(r,n){if(typeof r!="function")throw new TypeError("DataLoader must be constructed with a function which accepts "+("Array<key> and returns Promise<Array<value>>, but got: "+r+"."));this._batchLoadFn=r,this._maxBatchSize=ca(n),this._batchScheduleFn=la(n),this._cacheKeyFn=da(n),this._cacheMap=ua(n),this._batch=null,this.name=pa(n)}o(t,"DataLoader");var e=t.prototype;return e.load=o(function(n){if(n==null)throw new TypeError("The loader.load() function must be called with a value, "+("but got: "+String(n)+"."));var a=ia(this),i=this._cacheMap,s;if(i){s=this._cacheKeyFn(n);var c=i.get(s);if(c){var l=a.cacheHits||(a.cacheHits=[]);return new Promise(function(d){l.push(function(){d(c)})})}}a.keys.push(n);var p=new Promise(function(d,h){a.callbacks.push({resolve:d,reject:h})});return i&&i.set(s,p),p},"load"),e.loadMany=o(function(n){if(!Tr(n))throw new TypeError("The loader.loadMany() function must be called with Array<key> "+("but got: "+n+"."));for(var a=[],i=0;i<n.length;i++)a.push(this.load(n[i]).catch(function(s){return s}));return Promise.all(a)},"loadMany"),e.clear=o(function(n){var a=this._cacheMap;if(a){var i=this._cacheKeyFn(n);a.delete(i)}return this},"clear"),e.clearAll=o(function(){var n=this._cacheMap;return n&&n.clear(),this},"clearAll"),e.prime=o(function(n,a){var i=this._cacheMap;if(i){var s=this._cacheKeyFn(n);if(i.get(s)===void 0){var c;a instanceof Error?(c=Promise.reject(a),c.catch(function(){})):c=Promise.resolve(a),i.set(s,c)}}return this},"prime"),t})(),oa=typeof process=="object"&&typeof process.nextTick=="function"?function(t){ct||(ct=Promise.resolve()),ct.then(function(){process.nextTick(t)})}:typeof setImmediate=="function"?function(t){setImmediate(t)}:function(t){setTimeout(t)},ct;function ia(t){var e=t._batch;if(e!==null&&!e.hasDispatched&&e.keys.length<t._maxBatchSize)return e;var r={hasDispatched:!1,keys:[],callbacks:[]};return t._batch=r,t._batchScheduleFn(function(){sa(t,r)}),r}o(ia,"getCurrentBatch");function sa(t,e){if(e.hasDispatched=!0,e.keys.length===0){dt(e);return}var r;try{r=t._batchLoadFn(e.keys)}catch(n){return lt(t,e,new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function "+("errored synchronously: "+String(n)+".")))}if(!r||typeof r.then!="function")return lt(t,e,new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did "+("not return a Promise: "+String(r)+".")));r.then(function(n){if(!Tr(n))throw new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did "+("not return a Promise of an Array: "+String(n)+"."));if(n.length!==e.keys.length)throw new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array of the same length as the Array of keys."+(`
1
+ var _r=Object.create;var it=Object.defineProperty;var Or=Object.getOwnPropertyDescriptor;var $r=Object.getOwnPropertyNames;var Lr=Object.getPrototypeOf,Vr=Object.prototype.hasOwnProperty;var i=(n,e)=>it(n,"name",{value:e,configurable:!0});var qr=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var Nr=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of $r(e))!Vr.call(n,s)&&s!==t&&it(n,s,{get:()=>e[s],enumerable:!(r=Or(e,s))||r.enumerable});return n};var Br=(n,e,t)=>(t=n!=null?_r(Lr(n)):{},Nr(e||!n||!n.__esModule?it(t,"default",{value:n,enumerable:!0}):t,n));var Dr=qr((Ul,Ar)=>{"use strict";var hs=(function(){function n(t,r){if(typeof t!="function")throw new TypeError("DataLoader must be constructed with a function which accepts "+("Array<key> and returns Promise<Array<value>>, but got: "+t+"."));this._batchLoadFn=t,this._maxBatchSize=gs(r),this._batchScheduleFn=Is(r),this._cacheKeyFn=bs(r),this._cacheMap=ws(r),this._batch=null,this.name=Es(r)}i(n,"DataLoader");var e=n.prototype;return e.load=i(function(r){if(r==null)throw new TypeError("The loader.load() function must be called with a value, "+("but got: "+String(r)+"."));var s=ms(this),o=this._cacheMap,a;if(o){a=this._cacheKeyFn(r);var u=o.get(a);if(u){var l=s.cacheHits||(s.cacheHits=[]);return new Promise(function(p){l.push(function(){p(u)})})}}s.keys.push(r);var c=new Promise(function(p,d){s.callbacks.push({resolve:p,reject:d})});return o&&o.set(a,c),c},"load"),e.loadMany=i(function(r){if(!xr(r))throw new TypeError("The loader.loadMany() function must be called with Array<key> "+("but got: "+r+"."));for(var s=[],o=0;o<r.length;o++)s.push(this.load(r[o]).catch(function(a){return a}));return Promise.all(s)},"loadMany"),e.clear=i(function(r){var s=this._cacheMap;if(s){var o=this._cacheKeyFn(r);s.delete(o)}return this},"clear"),e.clearAll=i(function(){var r=this._cacheMap;return r&&r.clear(),this},"clearAll"),e.prime=i(function(r,s){var o=this._cacheMap;if(o){var a=this._cacheKeyFn(r);if(o.get(a)===void 0){var u;s instanceof Error?(u=Promise.reject(s),u.catch(function(){})):u=Promise.resolve(s),o.set(a,u)}}return this},"prime"),n})(),ys=typeof process=="object"&&typeof process.nextTick=="function"?function(n){Ut||(Ut=Promise.resolve()),Ut.then(function(){process.nextTick(n)})}:typeof setImmediate=="function"?function(n){setImmediate(n)}:function(n){setTimeout(n)},Ut;function ms(n){var e=n._batch;if(e!==null&&!e.hasDispatched&&e.keys.length<n._maxBatchSize)return e;var t={hasDispatched:!1,keys:[],callbacks:[]};return n._batch=t,n._batchScheduleFn(function(){vs(n,t)}),t}i(ms,"getCurrentBatch");function vs(n,e){if(e.hasDispatched=!0,e.keys.length===0){Ht(e);return}var t;try{t=n._batchLoadFn(e.keys)}catch(r){return Mt(n,e,new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function "+("errored synchronously: "+String(r)+".")))}if(!t||typeof t.then!="function")return Mt(n,e,new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did "+("not return a Promise: "+String(t)+".")));t.then(function(r){if(!xr(r))throw new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did "+("not return a Promise of an Array: "+String(r)+"."));if(r.length!==e.keys.length)throw new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array of the same length as the Array of keys."+(`
2
2
 
3
3
  Keys:
4
4
  `+String(e.keys))+(`
5
5
 
6
6
  Values:
7
- `+String(n)));dt(e);for(var a=0;a<e.callbacks.length;a++){var i=n[a];i instanceof Error?e.callbacks[a].reject(i):e.callbacks[a].resolve(i)}}).catch(function(n){lt(t,e,n)})}o(sa,"dispatchBatch");function lt(t,e,r){dt(e);for(var n=0;n<e.keys.length;n++)t.clear(e.keys[n]),e.callbacks[n].reject(r)}o(lt,"failedDispatch");function dt(t){if(t.cacheHits)for(var e=0;e<t.cacheHits.length;e++)t.cacheHits[e]()}o(dt,"resolveCacheHits");function ca(t){var e=!t||t.batch!==!1;if(!e)return 1;var r=t&&t.maxBatchSize;if(r===void 0)return 1/0;if(typeof r!="number"||r<1)throw new TypeError("maxBatchSize must be a positive number: "+r);return r}o(ca,"getValidMaxBatchSize");function la(t){var e=t&&t.batchScheduleFn;if(e===void 0)return oa;if(typeof e!="function")throw new TypeError("batchScheduleFn must be a function: "+e);return e}o(la,"getValidBatchScheduleFn");function da(t){var e=t&&t.cacheKeyFn;if(e===void 0)return function(r){return r};if(typeof e!="function")throw new TypeError("cacheKeyFn must be a function: "+e);return e}o(da,"getValidCacheKeyFn");function ua(t){var e=!t||t.cache!==!1;if(!e)return null;var r=t&&t.cacheMap;if(r===void 0)return new Map;if(r!==null){var n=["get","set","delete","clear"],a=n.filter(function(i){return r&&typeof r[i]!="function"});if(a.length!==0)throw new TypeError("Custom cacheMap missing methods: "+a.join(", "))}return r}o(ua,"getValidCacheMap");function pa(t){return t&&t.name?t.name:null}o(pa,"getValidName");function Tr(t){return typeof t=="object"&&t!==null&&typeof t.length=="number"&&(t.length===0||t.length>0&&Object.prototype.hasOwnProperty.call(t,t.length-1))}o(Tr,"isArrayLike");Pr.exports=aa});var Q=o(t=>t.split("/").pop(),"shopifyGidToId"),R=o((t,e)=>`gid://shopify/${t}/${e}`,"shopifyIdToGid");var F=class{constructor(e,r,n=""){this.revalidationPromises=new Map;this.inFlightRequests=new Map;this.cacheName=e,this.defaultCacheControl=r,this.keyPrefix=n}static{o(this,"FetchCache")}async get(e){try{let r=await caches.open(this.cacheName),n=await r.match(e);if(n&&this.isExpired(n)){await r.delete(e);return}return n}catch(r){console.warn("Cache get error:",r);return}}async set(e,r,n){try{if(n?.includes("no-cache"))return;let a=this.createCacheableResponse(r,n);await(await caches.open(this.cacheName)).put(e,a)}catch(a){console.warn("Cache set error:",a)}}async fetchWithCache(e,r,n){let a=await this.getCacheKey(e,r);if(this.inFlightRequests.has(a))return this.inFlightRequests.get(a).then(s=>s.clone());let i=(async()=>{let s=await this.get(a);if(s)return this.isStaleButRevalidatable(s)&&this.revalidateInBackground(a,e,r,n),s.clone();let c=await fetch(e,r);return c.ok&&await this.set(a,c.clone(),n??this.defaultCacheControl),c})().finally(()=>{this.inFlightRequests.delete(a)});return this.inFlightRequests.set(a,i),i}async delete(e){try{return await(await caches.open(this.cacheName)).delete(e)}catch(r){return console.warn("Cache delete error:",r),!1}}async clear(){try{let e=await caches.open(this.cacheName),r=await e.keys();await Promise.all(r.map(n=>e.delete(n)))}catch(e){console.warn("Cache clear error:",e)}}async keys(){try{return(await(await caches.open(this.cacheName)).keys()).map(n=>n.url)}catch(e){return console.warn("Cache keys error:",e),[]}}async has(e){try{let r=await caches.open(this.cacheName),n=await r.match(e);return n&&this.isExpired(n)?(await r.delete(e),!1):n!==void 0}catch(r){return console.warn("Cache has error:",r),!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),r=await e.keys(),n=0;for(let i of r){let s=await e.match(i);s&&this.isExpired(s)&&(await e.delete(i),n++)}let a=r.length-n;return{removed:n,remaining:a}}catch(e){return console.warn("Cache cleanup error:",e),{removed:0,remaining:0}}}async getCacheKey(e,r){let n=this.getInputUrl(e),a=`${this.keyPrefix}${n}/${JSON.stringify(r)}`,s=new TextEncoder().encode(a),c=await crypto.subtle.digest("SHA-256",s);return`/${Array.from(new Uint8Array(c)).map(d=>d.toString(16).padStart(2,"0")).join("")}`}getInputUrl(e){return e instanceof URL?e.toString():typeof e=="string"?e:e.url}isExpired(e){let r=e.headers.get("Cache-Control");if(!r)return!1;let n=this.parseMaxAge(r),a=this.parseStaleWhileRevalidate(r);if(n===null)return!1;let i=e.headers.get("Date");if(!i)return!1;let s=new Date(i).getTime(),l=(Date.now()-s)/1e3,p=n+(a??0);return l>p}isStaleButRevalidatable(e){let r=e.headers.get("Cache-Control");if(!r)return!1;let n=this.parseMaxAge(r),a=this.parseStaleWhileRevalidate(r);if(n===null||a===null)return!1;let i=e.headers.get("Date");if(!i)return!1;let s=new Date(i).getTime(),l=(Date.now()-s)/1e3;return l>n&&l<=n+a}async revalidateInBackground(e,r,n,a){if(this.revalidationPromises.has(e))return;let i=(async()=>{try{let s=await fetch(r,n);s.ok&&await this.set(e,s.clone(),a??this.defaultCacheControl)}catch(s){console.warn("Background revalidation error:",s)}finally{this.revalidationPromises.delete(e)}})();this.revalidationPromises.set(e,i)}parseMaxAge(e){let r=new RegExp(/max-age=(\d+)/).exec(e);return r?parseInt(r[1],10):null}parseStaleWhileRevalidate(e){let r=new RegExp(/stale-while-revalidate=(\d+)/).exec(e);return r?parseInt(r[1],10):null}createCacheableResponse(e,r){let n=new Headers(e.headers);return n.set("Cache-Control",r),n.has("Date")||n.set("Date",new Date().toUTCString()),new Response(e.body,{status:e.status,statusText:e.statusText,headers:n})}};var ue=class{static{o(this,"AjaxApiClient")}constructor(e){this.config=e,this.cache=new F("ajax-api","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,r=this.config.responseInterceptor,n=this.getFetchRequest.bind(this);window.fetch=function(...a){let i=e.apply(this,a);if(typeof r=="function"){let s=n(a[0]);i.then(c=>r(c,s))}return i}}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,r){return r?.method==="OPTIONS"?fetch(e,r):(e instanceof Request?e.method:r?.method??"GET")==="GET"?this.cache.fetchWithCache(e,r):fetch(e,r)}async request(e,r={}){let n=`${this.getBaseUrl()}${e}`,a={"Content-Type":"application/json",Accept:"application/json"};if(r.method==="GET"||!r.method){let s=await this.cache.fetchWithCache(n,{...r,headers:{...a,...r.headers}});if(!s.ok){let c;try{c=await s.json()}catch{c={message:`HTTP ${s.status}: ${s.statusText}`,status:s.status.toString(),description:s.statusText}}throw new Error(c.message||c.description)}return s.json()}let i=await this.fetch(n,{...r,headers:{...a,...r.headers}});if(!i.ok){let s;try{s=await i.json()}catch{s={message:`HTTP ${i.status}: ${i.statusText}`,status:i.status.toString(),description:i.statusText}}throw new Error(s.message||s.description)}return i.json()}async fetchCart(){return this.request("/cart.js")}async addToCart(e){let r={...e,items:e.items.map(n=>{let a=Q(n.id);if(!a)throw new Error(`Invalid Shopify GID format: ${n.id}`);let i=parseInt(a,10);if(isNaN(i))throw new Error(`Invalid numeric ID extracted from GID: ${n.id}`);return{...n,id:i}})};return this.request("/cart/add.js",{method:"POST",body:JSON.stringify(r)})}async clearCache(){await this.cache.clear()}};var pe=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{o(this,"AjaxApiPublisher")}async processFetchResponse(e,r){try{let n=this.getEventName(r.url);if(n){let a=await e.clone().json();this.eventBus.publish(n,a)}}catch(n){console.warn(n)}}getEventName(e){for(let[r,n]of Object.entries(this.eventMap))if(e.includes(r))return n;return null}};function Zr(){let t=document.body||document.documentElement;return t?Promise.resolve(t):new Promise(e=>{window.addEventListener("DOMContentLoaded",()=>e(t))})}o(Zr,"waitForDOM");function gt({onElementFound:t,selector:e,observerOptions:r}){let n=new WeakSet,a=new MutationObserver(l=>{let p=!1;for(let d of l)if(d.addedNodes.length>0){p=!0;break}p&&i()}),i=o(()=>{document.querySelectorAll(e).forEach(l=>{n.has(l)||(s(l),n.add(l))})},"locateElements"),s=o(l=>{if(!r){t(l);return}let p=new IntersectionObserver(d=>{for(let h of d)h.isIntersecting&&(p.disconnect(),t(l))},r);p.observe(l)},"observeElement");return o(async()=>{let l=await Zr();i(),a.observe(l,{childList:!0,subtree:!0})},"locateAndObserveElements")(),a}o(gt,"createElementLocator");function he({onLocationChange:t}){let e=o(()=>{t(window.location)},"handleChange");window.addEventListener("popstate",e);let r=history.pushState,n=history.replaceState;return history.pushState=function(...a){r.apply(this,a),e()},history.replaceState=function(...a){n.apply(this,a),e()},()=>{window.removeEventListener("popstate",e),history.pushState=r,history.replaceState=n}}o(he,"createLocationObserver");function vt({element:t,onHrefChange:e}){let r=o(()=>{e(t.href)},"handleChange"),n=new MutationObserver(()=>{r()});return n.observe(t,{attributes:!0,attributeFilter:["href"]}),()=>{n.disconnect()}}o(vt,"createHrefObserver");var fe=class{constructor(){this.eventBus=new EventTarget}static{o(this,"EventBus")}subscribe(e,r,n){return Array.isArray(e)||(e=[e]),e.forEach(a=>{this.eventBus.addEventListener(a,r,n)}),()=>{e.forEach(a=>{this.eventBus.removeEventListener(a,r,n)})}}unsubscribe(e,r,n){this.eventBus.removeEventListener(e,r,n)}publish(e,r){this.eventBus.dispatchEvent(new CustomEvent(e,{detail:r}))}};var en=Symbol.for("preact-signals");function ye(){if(z>1)z--;else{for(var t,e=!1;se!==void 0;){var r=se;for(se=void 0,Oe++;r!==void 0;){var n=r.o;if(r.o=void 0,r.f&=-3,!(8&r.f)&&It(r))try{r.c()}catch(a){e||(t=a,e=!0)}r=n}}if(Oe=0,z--,e)throw t}}o(ye,"t");function W(t){if(z>0)return t();z++;try{return t()}finally{ye()}}o(W,"r");var v=void 0;function Ct(t){var e=v;v=void 0;try{return t()}finally{v=e}}o(Ct,"n");var se=void 0,z=0,Oe=0,me=0;function wt(t){if(v!==void 0){var e=t.n;if(e===void 0||e.t!==v)return e={i:0,S:t,p:v.s,n:void 0,t:v,e:void 0,x:void 0,r:e},v.s!==void 0&&(v.s.n=e),v.s=e,t.n=e,32&v.f&&t.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=v.s,e.n=void 0,v.s.n=e,v.s=e),e}}o(wt,"e");function D(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}o(D,"u");D.prototype.brand=en;D.prototype.h=function(){return!0};D.prototype.S=function(t){var e=this,r=this.t;r!==t&&t.e===void 0&&(t.x=r,this.t=t,r!==void 0?r.e=t:Ct(function(){var n;(n=e.W)==null||n.call(e)}))};D.prototype.U=function(t){var e=this;if(this.t!==void 0){var r=t.e,n=t.x;r!==void 0&&(r.x=n,t.e=void 0),n!==void 0&&(n.e=r,t.x=void 0),t===this.t&&(this.t=n,n===void 0&&Ct(function(){var a;(a=e.Z)==null||a.call(e)}))}};D.prototype.subscribe=function(t){var e=this;return $(function(){var r=e.value,n=v;v=void 0;try{t(r)}finally{v=n}},{name:"sub"})};D.prototype.valueOf=function(){return this.value};D.prototype.toString=function(){return this.value+""};D.prototype.toJSON=function(){return this.value};D.prototype.peek=function(){var t=v;v=void 0;try{return this.value}finally{v=t}};Object.defineProperty(D.prototype,"value",{get:o(function(){var t=wt(this);return t!==void 0&&(t.i=this.i),this.v},"get"),set:o(function(t){if(t!==this.v){if(Oe>100)throw new Error("Cycle detected");this.v=t,this.i++,me++,z++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{ye()}}},"set")});function b(t,e){return new D(t,e)}o(b,"d");function It(t){for(var e=t.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}o(It,"c");function bt(t){for(var e=t.s;e!==void 0;e=e.n){var r=e.S.n;if(r!==void 0&&(e.r=r),e.S.n=e,e.i=-1,e.n===void 0){t.s=e;break}}}o(bt,"a");function Et(t){for(var e=t.s,r=void 0;e!==void 0;){var n=e.p;e.i===-1?(e.S.U(e),n!==void 0&&(n.n=e.n),e.n!==void 0&&(e.n.p=n)):r=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=n}t.s=r}o(Et,"l");function Z(t,e){D.call(this,void 0),this.x=t,this.s=void 0,this.g=me-1,this.f=4,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}o(Z,"y");Z.prototype=new D;Z.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===me))return!0;if(this.g=me,this.f|=1,this.i>0&&!It(this))return this.f&=-2,!0;var t=v;try{bt(this),v=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(r){this.v=r,this.f|=16,this.i++}return v=t,Et(this),this.f&=-2,!0};Z.prototype.S=function(t){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}D.prototype.S.call(this,t)};Z.prototype.U=function(t){if(this.t!==void 0&&(D.prototype.U.call(this,t),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}};Z.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;t!==void 0;t=t.x)t.t.N()}};Object.defineProperty(Z.prototype,"value",{get:o(function(){if(1&this.f)throw new Error("Cycle detected");var t=wt(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v},"get")});function q(t,e){return new Z(t,e)}o(q,"w");function St(t){var e=t.u;if(t.u=void 0,typeof e=="function"){z++;var r=v;v=void 0;try{e()}catch(n){throw t.f&=-2,t.f|=8,$e(t),n}finally{v=r,ye()}}}o(St,"_");function $e(t){for(var e=t.s;e!==void 0;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,St(t)}o($e,"b");function tn(t){if(v!==this)throw new Error("Out-of-order effect");Et(this),v=t,this.f&=-2,8&this.f&&$e(this),ye()}o(tn,"g");function oe(t,e){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=e?.name}o(oe,"p");oe.prototype.c=function(){var t=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.u=e)}finally{t()}};oe.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,St(this),bt(this),z++;var t=v;return v=this,tn.bind(this,t)};oe.prototype.N=function(){2&this.f||(this.f|=2,this.o=se,se=this)};oe.prototype.d=function(){this.f|=8,1&this.f||$e(this)};oe.prototype.dispose=function(){this.d()};function $(t,e){var r=new oe(t,e);try{r.c()}catch(a){throw r.d(),a}var n=r.d.bind(r);return n[Symbol.dispose]=n,n}o($,"E");var rn=/^(?:https?:\/\/[^/]+)?(?:\/[a-z]{2})?\/products\/([^/?#]+)(?:\?variant=(\d+))?/,Ve=o(t=>{let e=t.match(rn);return e?{productHandle:e[1],variantId:e[2]}:null},"parseProductUrl"),At=o(({source:t,onProductUrlChange:e})=>{let r=o(n=>{let a=Ve(n);a?.productHandle&&e(a)},"handleChange");if(t instanceof HTMLAnchorElement)return vt({element:t,onHrefChange:o(n=>r(n),"onHrefChange")});if(t instanceof Location)return he({onLocationChange:o(n=>r(n.href),"onLocationChange")});throw new Error("Invalid source for observing product url")},"observeProductUrl");var Rt=o(t=>e=>{let{productHandle:r,productId:n,variantId:a,itemId:i,defaultVariantId:s}=e?.dataset??{},c=e?.hasAttribute("skip-variant-select"),d=!!(n||r)||!!i,h=b({loading:!1,productId:n,variantId:a,itemId:i,skipVariantSelect:c,defaultVariantId:s});if(!d){let C=e instanceof HTMLAnchorElement?e:window.location,m=Ve(C.href);m?.productHandle&&m.productHandle!==h.value.productHandle&&(h.value={...h.value,...m,productId:void 0},At({source:C,onProductUrlChange:o(I=>{h.value={...h.value,...I,productId:I.productHandle!==h.value.productHandle?void 0:h.value.productId}},"onProductUrlChange")}))}return $(()=>{h.value.loading||!h.value.productId&&h.value.productHandle&&(h.value={...h.value,loading:!0},t.storefront.loadProductId({productHandle:h.value.productHandle}).then(C=>{C.errors&&console.error("Error loading product id",C.errors),h.value={...h.value,productId:C.data?.product?.id?Q(C.data.product.id):void 0,loading:!1}}))}),h},"itemContextSignal");var Tt=o(t=>e=>{let r=q(()=>{let{productId:y,variantId:w,loading:E}=e.value;return!y||E?null:w?`variant:${Q(w)}`:`product:${Q(y)}`}),n=q(()=>e.value.loading||!!e.value.itemId||!e.value.productId),a=q(()=>({limit:1,query:r.value??void 0})),i=b(!n.value),s=b(null),c=b(!1),l=b(!1),{data:p,loading:d,error:h,refetching:C}=t.state.swishQuery(y=>t.api.items.list(y),{refetch:["item-create","item-update","item-delete"],variables:a,skip:n}),m=b(e.value.itemId??null);$(()=>{W(()=>{if(i.value=d.value,s.value=h.value,!e.value.itemId){let y=p.value?.[0]?.id??null;y!==m.value&&(m.value=y)}})});function I(y){t.ui.showListSelect({itemId:y,onSubmit:o(({item:w,product:E,variant:H})=>{t.ui.showToast({title:"Saved",text:E.title,image:H?.image?.url??E.featuredImage?.url,action:{label:"Add to List",onAction:o(()=>{I(w.id)},"onAction")}})},"onSubmit"),onUnsave:o(()=>{m.value=null},"onUnsave")})}o(I,"showListSelect");function g(){m.value&&t.ui.showUnsaveAlert({itemId:m.value,onSubmit:o(()=>{m.value=null},"onSubmit")})}o(g,"unsave");function A(){m.value&&I(m.value)}o(A,"update");async function P(){let{productId:y,variantId:w,skipVariantSelect:E,defaultVariantId:H}=e.value;if(!e.value.variantId&&!E){t.ui.showVariantSelect({productId:e.value.productId,action:"save",onSubmit:o(async({item:L,product:M,variant:j})=>{m.value=L.id,t.ui.showToast({title:"Saved",text:M.title,image:j?.image?.url??M.featuredImage?.url,action:{label:"Add to List",onAction:o(()=>{I(L.id)},"onAction")}})},"onSubmit")});return}E&&H&&(w=H),c.value=!0,l.value=!0;try{let L=await t.api.items.create({productId:Number(y),variantId:w?Number(Q(w)):void 0});if("error"in L)throw new Error(L.error.message);if(!L.data)throw new Error("API response missing data");let M=L.data;m.value=M.id;let{data:j}=await t.storefront.loadProductCardData({productId:M.productId.toString(),variantId:M.variantId?.toString()});if(j&&"variant"in j&&j.product){let{product:J,variant:de}=j;t.ui.showToast({title:"Saved",text:J.title,image:de?.image?.url??J.featuredImage?.url,action:{label:"Add to List",onAction:o(()=>{I(M.id)},"onAction")}})}c.value=!1}catch(L){console.error("Failed to create item",L),W(()=>{c.value=!1,l.value=!1})}}o(P,"save");let T=q(()=>i.value||c.value||e.value.loading);$(()=>{l.value&&!c.value&&!C.value&&(l.value=!1)});let _=q(()=>{let y=C.value&&l.value,w=!!m.value,E=!w&&(c.value||y),H=w&&(c.value||y),L=q(()=>E?"saving":H?"unsaving":w?"saved":"unsaved");return{error:s.value,status:L.value,savedItemId:m.value,loading:T.value,submitting:c.value,saved:w,saving:E,unsaving:H}});async function U(){T.value||(_.value.saved&&_.value.savedItemId?I(_.value.savedItemId):_.value.saved||await P())}return o(U,"toggle"),Object.assign(_,{save:P,unsave:g,update:A,toggle:U})},"itemStateSignal");var Pt=o(t=>()=>{let{data:e,loading:r,error:n}=t.state.swishQuery(()=>t.api.items.count(),{refetch:["item-create","item-delete"]}),a=b(0),i=b(!0),s=b(null);return $(()=>{W(()=>{i.value=r.value,s.value=n.value,a.value=e.value?.count??0})}),q(()=>({count:a.value,loading:i.value,error:s.value}))},"itemCountSignal");var Dt=o(t=>(e,r)=>{let n=b(null),a=b(null),i=b(null),s=b(!r?.skip),c=b(!1),l=q(()=>s.value&&c.value);async function p(){if(!r?.skip?.value)try{s.value=!0;let d=await e(r?.variables?.value);W(()=>{i.value="error"in d?d.error:null,n.value="data"in d?d.data:null,a.value="pageInfo"in d?d.pageInfo:null,s.value=!1,c.value=!0})}catch(d){W(()=>{i.value=d,s.value=!1,c.value=!0})}}return o(p,"executeFetch"),$(()=>{if(p(),r?.refetch?.length)return t.events.subscribe(r.refetch,p)}),{data:n,pageInfo:a,error:i,loading:s,refetching:l}},"swishQuerySignals");var ee="GraphQL Client";var Ue="An error occurred while fetching from the API. Review 'graphQLErrors' for details.",Ne="Response returned unexpected Content-Type:",qe="An unknown error has occurred. The API did not return a data object or any errors in its response.",ge={json:"application/json",multipart:"multipart/mixed"},Be="X-SDK-Variant",Ge="X-SDK-Version",_t="shopify-graphql-client",Lt="1.4.1",ve=1e3,Ot=[429,503],He=/@(defer)\b/i,xt=`\r
8
- `,$t=/boundary="?([^=";]+)"?/i,Me=xt+xt;function B(t,e=ee){return t.startsWith(`${e}`)?t:`${e}: ${t}`}o(B,"formatErrorMessage");function k(t){return t instanceof Error?t.message:JSON.stringify(t)}o(k,"getErrorMessage");function Fe(t){return t instanceof Error&&t.cause?t.cause:void 0}o(Fe,"getErrorCause");function ke(t){return t.flatMap(({errors:e})=>e??[])}o(ke,"combineErrors");function Ce({client:t,retries:e}){if(e!==void 0&&(typeof e!="number"||e<0||e>3))throw new Error(`${t}: The provided "retries" value (${e}) is invalid - it cannot be less than ${0} or greater than ${3}`)}o(Ce,"validateRetries");function x(t,e){return e&&(typeof e!="object"||Array.isArray(e)||typeof e=="object"&&Object.keys(e).length>0)?{[t]:e}:{}}o(x,"getKeyValueIfValid");function je(t,e){if(t.length===0)return e;let n={[t.pop()]:e};return t.length===0?n:je(t,n)}o(je,"buildDataObjectByPath");function Nt(t,e){return Object.keys(e||{}).reduce((r,n)=>(typeof e[n]=="object"||Array.isArray(e[n]))&&t[n]?(r[n]=Nt(t[n],e[n]),r):(r[n]=e[n],r),Array.isArray(t)?[...t]:{...t})}o(Nt,"combineObjects");function Qe([t,...e]){return e.reduce(Nt,{...t})}o(Qe,"buildCombinedDataObject");function ze({clientLogger:t,customFetchApi:e=fetch,client:r=ee,defaultRetryWaitTime:n=ve,retriableCodes:a=Ot}){let i=o(async(s,c,l)=>{let p=c+1,d=l+1,h;try{if(h=await e(...s),t({type:"HTTP-Response",content:{requestParams:s,response:h}}),!h.ok&&a.includes(h.status)&&p<=d)throw new Error;let C=h?.headers.get("X-Shopify-API-Deprecated-Reason")||"";return C&&t({type:"HTTP-Response-GraphQL-Deprecation-Notice",content:{requestParams:s,deprecationNotice:C}}),h}catch(C){if(p<=d){let m=h?.headers.get("Retry-After");return await nn(m?parseInt(m,10):n),t({type:"HTTP-Retry",content:{requestParams:s,lastResponse:h,retryAttempt:c,maxRetries:l}}),i(s,p,l)}throw new Error(B(`${l>0?`Attempted maximum number of ${l} network retries. Last message - `:""}${k(C)}`,r))}},"httpFetch");return i}o(ze,"generateHttpFetch");async function nn(t){return new Promise(e=>setTimeout(e,t))}o(nn,"sleep");function We({headers:t,url:e,customFetchApi:r=fetch,retries:n=0,logger:a}){Ce({client:ee,retries:n});let i={headers:t,url:e,retries:n},s=an(a),c=ze({customFetchApi:r,clientLogger:s,defaultRetryWaitTime:ve}),l=on(c,i),p=sn(l),d=fn(l);return{config:i,fetch:l,request:p,requestStream:d}}o(We,"createGraphQLClient");function an(t){return e=>{t&&t(e)}}o(an,"generateClientLogger");async function qt(t){let{errors:e,data:r,extensions:n}=await t.json();return{...x("data",r),...x("extensions",n),headers:t.headers,...e||!r?{errors:{networkStatusCode:t.status,message:B(e?Ue:qe),...x("graphQLErrors",e),response:t}}:{}}}o(qt,"processJSONResponse");function on(t,{url:e,headers:r,retries:n}){return async(a,i={})=>{let{variables:s,headers:c,url:l,retries:p,keepalive:d,signal:h}=i,C=JSON.stringify({query:a,variables:s});Ce({client:ee,retries:p});let m=Object.entries({...r,...c}).reduce((g,[A,P])=>(g[A]=Array.isArray(P)?P.join(", "):P.toString(),g),{});return!m[Be]&&!m[Ge]&&(m[Be]=_t,m[Ge]=Lt),t([l??e,{method:"POST",headers:m,body:C,signal:h,keepalive:d}],1,p??n)}}o(on,"generateFetch");function sn(t){return async(...e)=>{if(He.test(e[0]))throw new Error(B("This operation will result in a streamable response - use requestStream() instead."));let r=null;try{r=await t(...e);let{status:n,statusText:a}=r,i=r.headers.get("content-type")||"";return r.ok?i.includes(ge.json)?await qt(r):{errors:{networkStatusCode:n,message:B(`${Ne} ${i}`),response:r}}:{errors:{networkStatusCode:n,message:B(a),response:r}}}catch(n){return{errors:{message:k(n),...r==null?{}:{networkStatusCode:r.status,response:r}}}}}}o(sn,"generateRequest");async function*cn(t){let e=new TextDecoder;if(t.body[Symbol.asyncIterator])for await(let r of t.body)yield e.decode(r);else{let r=t.body.getReader(),n;try{for(;!(n=await r.read()).done;)yield e.decode(n.value)}finally{r.cancel()}}}o(cn,"getStreamBodyIterator");function ln(t,e){return{async*[Symbol.asyncIterator](){try{let r="";for await(let n of t)if(r+=n,r.indexOf(e)>-1){let a=r.lastIndexOf(e),s=r.slice(0,a).split(e).filter(c=>c.trim().length>0).map(c=>c.slice(c.indexOf(Me)+Me.length).trim());s.length>0&&(yield s),r=r.slice(a+e.length),r.trim()==="--"&&(r="")}}catch(r){throw new Error(`Error occured while processing stream payload - ${k(r)}`)}}}}o(ln,"readStreamChunk");function dn(t){return{async*[Symbol.asyncIterator](){yield{...await qt(t),hasNext:!1}}}}o(dn,"createJsonResponseAsyncIterator");function un(t){return t.map(e=>{try{return JSON.parse(e)}catch(r){throw new Error(`Error in parsing multipart response - ${k(r)}`)}}).map(e=>{let{data:r,incremental:n,hasNext:a,extensions:i,errors:s}=e;if(!n)return{data:r||{},...x("errors",s),...x("extensions",i),hasNext:a};let c=n.map(({data:l,path:p,errors:d})=>({data:l&&p?je(p,l):{},...x("errors",d)}));return{data:c.length===1?c[0].data:Qe([...c.map(({data:l})=>l)]),...x("errors",ke(c)),hasNext:a}})}o(un,"getResponseDataFromChunkBodies");function pn(t,e){if(t.length>0)throw new Error(Ue,{cause:{graphQLErrors:t}});if(Object.keys(e).length===0)throw new Error(qe)}o(pn,"validateResponseData");function hn(t,e){let r=(e??"").match($t),n=`--${r?r[1]:"-"}`;if(!t.body?.getReader&&!t.body?.[Symbol.asyncIterator])throw new Error("API multipart response did not return an iterable body",{cause:t});let a=cn(t),i={},s;return{async*[Symbol.asyncIterator](){try{let c=!0;for await(let l of ln(a,n)){let p=un(l);s=p.find(h=>h.extensions)?.extensions??s;let d=ke(p);i=Qe([i,...p.map(({data:h})=>h)]),c=p.slice(-1)[0].hasNext,pn(d,i),yield{...x("data",i),...x("extensions",s),hasNext:c}}if(c)throw new Error("Response stream terminated unexpectedly")}catch(c){let l=Fe(c);yield{...x("data",i),...x("extensions",s),errors:{message:B(k(c)),networkStatusCode:t.status,...x("graphQLErrors",l?.graphQLErrors),response:t},hasNext:!1}}}}}o(hn,"createMultipartResponseAsyncInterator");function fn(t){return async(...e)=>{if(!He.test(e[0]))throw new Error(B("This operation does not result in a streamable response - use request() instead."));try{let r=await t(...e),{statusText:n}=r;if(!r.ok)throw new Error(n,{cause:r});let a=r.headers.get("content-type")||"";switch(!0){case a.includes(ge.json):return dn(r);case a.includes(ge.multipart):return hn(r,a);default:throw new Error(`${Ne} ${a}`,{cause:r})}}catch(r){return{async*[Symbol.asyncIterator](){let n=Fe(r);yield{errors:{message:B(k(r)),...x("networkStatusCode",n?.status),...x("response",n)},hasNext:!1}}}}}}o(fn,"generateRequestStream");function Ye({client:t,storeDomain:e}){try{if(!e||typeof e!="string")throw new Error;let r=e.trim(),n=r.match(/^https?:/)?r:`https://${r}`,a=new URL(n);return a.protocol="https",a.origin}catch(r){throw new Error(`${t}: a valid store domain ("${e}") must be provided`,{cause:r})}}o(Ye,"validateDomainAndGetStoreUrl");function we({client:t,currentSupportedApiVersions:e,apiVersion:r,logger:n}){let a=`${t}: the provided apiVersion ("${r}")`,i=`Currently supported API versions: ${e.join(", ")}`;if(!r||typeof r!="string")throw new Error(`${a} is invalid. ${i}`);let s=r.trim();e.includes(s)||(n?n({type:"Unsupported_Api_Version",content:{apiVersion:r,supportedApiVersions:e}}):console.warn(`${a} is likely deprecated or not supported. ${i}`))}o(we,"validateApiVersion");function Ie(t){let e=t*3-2;return e===10?e:`0${e}`}o(Ie,"getQuarterMonth");function Ke(t,e,r){let n=e-r;return n<=0?`${t-1}-${Ie(n+4)}`:`${t}-${Ie(n)}`}o(Ke,"getPrevousVersion");function Bt(){let t=new Date,e=t.getUTCMonth(),r=t.getUTCFullYear(),n=Math.floor(e/3+1);return{year:r,quarter:n,version:`${r}-${Ie(n)}`}}o(Bt,"getCurrentApiVersion");function Je(){let{year:t,quarter:e,version:r}=Bt(),n=e===4?`${t+1}-01`:`${t}-${Ie(e+1)}`;return[Ke(t,e,3),Ke(t,e,2),Ke(t,e,1),r,n,"unstable"]}o(Je,"getCurrentSupportedApiVersions");function Xe(t){return e=>({...e??{},...t.headers})}o(Xe,"generateGetHeaders");function Ze({getHeaders:t,getApiUrl:e}){return(r,n)=>{let a=[r];if(n&&Object.keys(n).length>0){let{variables:i,apiVersion:s,headers:c,retries:l,signal:p}=n;a.push({...i?{variables:i}:{},...c?{headers:t(c)}:{},...s?{url:e(s)}:{},...l?{retries:l}:{},...p?{signal:p}:{}})}return a}}o(Ze,"generateGetGQLClientParams");var et="application/json",Gt="storefront-api-client",Ht="1.0.9",Mt="X-Shopify-Storefront-Access-Token",Ft="Shopify-Storefront-Private-Token",kt="X-SDK-Variant",jt="X-SDK-Version",Qt="X-SDK-Variant-Source",te="Storefront API Client";function zt(t){if(t&&typeof window<"u")throw new Error(`${te}: private access tokens and headers should only be used in a server-to-server implementation. Use the public API access token in nonserver environments.`)}o(zt,"validatePrivateAccessTokenUsage");function Wt(t,e){if(!t&&!e)throw new Error(`${te}: a public or private access token must be provided`);if(t&&e)throw new Error(`${te}: only provide either a public or private access token`)}o(Wt,"validateRequiredAccessTokens");function tt({storeDomain:t,apiVersion:e,publicAccessToken:r,privateAccessToken:n,clientName:a,retries:i=0,customFetchApi:s,logger:c}){let l=Je(),p=Ye({client:te,storeDomain:t}),d={client:te,currentSupportedApiVersions:l,logger:c};we({...d,apiVersion:e}),Wt(r,n),zt(n);let h=mn(p,e,d),C={storeDomain:p,apiVersion:e,...r?{publicAccessToken:r}:{privateAccessToken:n},headers:{"Content-Type":et,Accept:et,[kt]:Gt,[jt]:Ht,...a?{[Qt]:a}:{},...r?{[Mt]:r}:{[Ft]:n}},apiUrl:h(),clientName:a},m=We({headers:C.headers,url:C.apiUrl,retries:i,customFetchApi:s,logger:c}),I=Xe(C),g=yn(C,h),A=Ze({getHeaders:I,getApiUrl:g});return Object.freeze({config:C,getHeaders:I,getApiUrl:g,fetch:o((...T)=>m.fetch(...A(...T)),"fetch"),request:o((...T)=>m.request(...A(...T)),"request"),requestStream:o((...T)=>m.requestStream(...A(...T)),"requestStream")})}o(tt,"createStorefrontApiClient");function mn(t,e,r){return n=>{n&&we({...r,apiVersion:n});let a=(n??e).trim();return`${t}/api/${a}/graphql.json`}}o(mn,"generateApiUrlFormatter");function yn(t,e){return r=>r?e(r):t.apiUrl}o(yn,"generateGetApiUrl");var O=`
7
+ `+String(r)));Ht(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){Mt(n,e,r)})}i(vs,"dispatchBatch");function Mt(n,e,t){Ht(e);for(var r=0;r<e.keys.length;r++)n.clear(e.keys[r]),e.callbacks[r].reject(t)}i(Mt,"failedDispatch");function Ht(n){if(n.cacheHits)for(var e=0;e<n.cacheHits.length;e++)n.cacheHits[e]()}i(Ht,"resolveCacheHits");function gs(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(gs,"getValidMaxBatchSize");function Is(n){var e=n&&n.batchScheduleFn;if(e===void 0)return ys;if(typeof e!="function")throw new TypeError("batchScheduleFn must be a function: "+e);return e}i(Is,"getValidBatchScheduleFn");function bs(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(bs,"getValidCacheKeyFn");function ws(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(ws,"getValidCacheMap");function Es(n){return n&&n.name?n.name:null}i(Es,"getValidName");function xr(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(xr,"isArrayLike");Ar.exports=hs});var P=i(n=>n.split("/").pop()??"","shopifyGidToId"),E=i((n,e)=>`gid://shopify/${n}/${e}`,"shopifyIdToGid");var K=class{constructor(e,t,r=""){this.revalidationPromises=new Map;this.inFlightRequests=new Map;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.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(){try{let e=await caches.open(this.cacheName),t=await e.keys();await Promise.all(t.map(r=>e.delete(r)))}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(),l=(Date.now()-a)/1e3,c=r+(s??0);return l>c}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(),l=(Date.now()-a)/1e3;return l>r&&l<=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 Se=class{static{i(this,"AjaxApiClient")}constructor(e){this.config=e,this.cache=new K("ajax-api","max-age=60, stale-while-revalidate=3600"),this.cache.cleanupExpiredEntries().catch(t=>{console.warn("Ajax API cache initialization cleanup error:",t)})}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 t?.method==="OPTIONS"?fetch(e,t):(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"};if(t.method==="GET"||!t.method){let a=await this.cache.fetchWithCache(r,{...t,headers:{...s,...t.headers}});if(!a.ok){let u;try{u=await a.json()}catch{u={message:`HTTP ${a.status}: ${a.statusText}`,status:a.status.toString(),description:a.statusText}}throw new Error(u.message||u.description)}return a.json()}let 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=P(r.id);if(!s)throw new Error(`Invalid Shopify GID format: ${r.id}`);let o=parseInt(s,10);if(isNaN(o))throw new Error(`Invalid numeric ID extracted from GID: ${r.id}`);return{...r,id:o}})};return this.request("/cart/add.js",{method:"POST",body:JSON.stringify(t)})}async clearCache(){await this.cache.clear()}};var Ce=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 Gr(){let n=document.body||document.documentElement;return n?Promise.resolve(n):new Promise(e=>{window.addEventListener("DOMContentLoaded",()=>e(n))})}i(Gr,"waitForDOM");function ge({onElementFound:n,selector:e,observerOptions:t}){let r=new WeakSet,s=new MutationObserver(l=>{let c=!1;for(let p of l)if(p.addedNodes.length>0){c=!0;break}c&&o()}),o=i(()=>{document.querySelectorAll(e).forEach(l=>{r.has(l)||(a(l),r.add(l))})},"locateElements"),a=i(l=>{if(!t){n(l);return}let c=new IntersectionObserver(p=>{for(let d of p)d.isIntersecting&&(c.disconnect(),n(l))},t);c.observe(l)},"observeElement");return i(async()=>{let l=await Gr();o(),s.observe(l,{childList:!0,subtree:!0})},"locateAndObserveElements")(),s}i(ge,"createElementLocator");function fe({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(fe,"createLocationObserver");function Yt({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(Yt,"createHrefObserver");var xe=class{constructor(){this.eventBus=new EventTarget}static{i(this,"EventBus")}subscribe(e,t,r){return Array.isArray(e)||(e=[e]),e.forEach(s=>{this.eventBus.addEventListener(s,t,r)}),()=>{e.forEach(s=>{this.eventBus.removeEventListener(s,t,r)})}}unsubscribe(e,t,r){this.eventBus.removeEventListener(e,t,r)}publish(e,t){this.eventBus.dispatchEvent(new CustomEvent(e,{detail:t}))}};var st;function at(n){return{lang:n?.lang??st?.lang,message:n?.message,abortEarly:n?.abortEarly??st?.abortEarly,abortPipeEarly:n?.abortPipeEarly??st?.abortPipeEarly}}i(at,"getGlobalConfig");var jr;function Ur(n){return jr?.get(n)}i(Ur,"getGlobalMessage");var Mr;function Hr(n){return Mr?.get(n)}i(Hr,"getSchemaMessage");var Fr;function Qr(n,e){return Fr?.get(n)?.get(e)}i(Qr,"getSpecificMessage");function ot(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(ot,"_stringify");function J(n,e,t,r,s){let o=s&&"input"in s?s.input:t.value,a=s?.expected??n.expects??null,u=s?.received??ot(o),l={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},c=n.kind==="schema",p=s?.message??n.message??Qr(n.reference,l.lang)??(c?Hr(l.lang):null)??r.message??Ur(l.lang);p!==void 0&&(l.message=typeof p=="function"?p(l):p),c&&(t.typed=!1),t.issues?t.issues.push(l):t.issues=[l]}i(J,"_addIssue");function re(n){return{version:1,vendor:"valibot",validate(e){return n["~run"]({value:e},at())}}}i(re,"_getStandardProps");function zr(n,e){let t=[...new Set(n)];return t.length>1?`(${t.join(` ${e} `)})`:t[0]??"never"}i(zr,"_joinExpects");var Wr=class extends Error{static{i(this,"ValiError")}constructor(n){super(n[0].message),this.name="ValiError",this.issues=n}};function ut(n,e){return{kind:"validation",type:"min_value",reference:ut,async:!1,expects:`>=${n instanceof Date?n.toJSON():ot(n)}`,requirement:n,message:e,"~run"(t,r){return t.typed&&!(t.value>=this.requirement)&&J(this,"value",t,r,{received:t.value instanceof Date?t.value.toJSON():ot(t.value)}),t}}}i(ut,"minValue");function B(n){return{kind:"transformation",type:"transform",reference:B,async:!1,operation:n,"~run"(e){return e.value=this.operation(e.value),e}}}i(B,"transform");function Xr(n,e,t){return typeof n.fallback=="function"?n.fallback(e,t):n.fallback}i(Xr,"getFallback");function Zt(n,e,t){return typeof n.default=="function"?n.default(e,t):n.default}i(Zt,"getDefault");function lt(n,e){return{kind:"schema",type:"array",reference:lt,expects:"Array",async:!1,item:n,message:e,get"~standard"(){return re(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 l={type:"array",origin:"value",input:s,key:o,value:a};for(let c of u.issues)c.path?c.path.unshift(l):c.path=[l],t.issues?.push(c);if(t.issues||(t.issues=u.issues),r.abortEarly){t.typed=!1;break}}u.typed||(t.typed=!1),t.value.push(u.value)}}else J(this,"type",t,r);return t}}}i(lt,"array");function H(n){return{kind:"schema",type:"number",reference:H,expects:"number",async:!1,message:n,get"~standard"(){return re(this)},"~run"(e,t){return typeof e.value=="number"&&!isNaN(e.value)?e.typed=!0:J(this,"type",e,t),e}}}i(H,"number");function C(n,e){return{kind:"schema",type:"object",reference:C,expects:"Object",async:!1,entries:n,message:e,get"~standard"(){return re(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]:Zt(a),l=a["~run"]({value:u},r);if(l.issues){let c={type:"object",origin:"value",input:s,key:o,value:u};for(let p of l.issues)p.path?p.path.unshift(c):p.path=[c],t.issues?.push(p);if(t.issues||(t.issues=l.issues),r.abortEarly){t.typed=!1;break}}l.typed||(t.typed=!1),t.value[o]=l.value}else if(a.fallback!==void 0)t.value[o]=Xr(a);else if(a.type!=="exact_optional"&&a.type!=="optional"&&a.type!=="nullish"&&(J(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 J(this,"type",t,r);return t}}}i(C,"object");function G(n,e){return{kind:"schema",type:"optional",reference:G,expects:`(${n.expects} | undefined)`,async:!1,wrapped:n,default:e,get"~standard"(){return re(this)},"~run"(t,r){return t.value===void 0&&(this.default!==void 0&&(t.value=Zt(this,t,r)),t.value===void 0)?(t.typed=!0,t):this.wrapped["~run"](t,r)}}}i(G,"optional");function b(n){return{kind:"schema",type:"string",reference:b,expects:"string",async:!1,message:n,get"~standard"(){return re(this)},"~run"(e,t){return typeof e.value=="string"?e.typed=!0:J(this,"type",e,t),e}}}i(b,"string");function Jt(n){let e;if(n)for(let t of n)e?e.push(...t.issues):e=t.issues;return e}i(Jt,"_subIssues");function ie(n,e){return{kind:"schema",type:"union",reference:ie,expects:zr(n.map(t=>t.expects),"|"),async:!1,options:n,message:e,get"~standard"(){return re(this)},"~run"(t,r){let s,o,a;for(let u of this.options){let l=u["~run"]({value:t.value},r);if(l.typed)if(l.issues)o?o.push(l):o=[l];else{s=l;break}else a?a.push(l):a=[l]}if(s)return s;if(o){if(o.length===1)return o[0];J(this,"type",t,r,{issues:Jt(o)}),t.typed=!0}else{if(a?.length===1)return a[0];J(this,"type",t,r,{issues:Jt(a)})}return t}}}i(ie,"union");function en(n,e,t){let r=n["~run"]({value:e},at(t));if(r.issues)throw new Wr(r.issues);return r.value}i(en,"parse");function V(...n){return{...n[0],pipe:n,get"~standard"(){return re(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(V,"pipe");function O(n,e,t){let r=n["~run"]({value:e},at(t));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}i(O,"safeParse");var S=class{constructor(e,t,r){this.swish=e;this.eventBus=t;this.options=r}static{i(this,"IntentHandler")}};var Kr=".swish-shop-bridge{position:absolute!important;top:0!important;left:0!important;padding:0!important;border:0!important;margin:0!important;pointer-events:none!important}.swish-shop-bridge input{appearance:none!important;border:none!important;width:1px!important;height:1px!important;padding:0!important;margin:0!important;background:rgba(0,0,0,0)!important}",Yr=`<form class=swish-shop-bridge data-login-with-shop-sign-in=true id=customer_login><input name=customer[email] id=customer_login_email> <input name=return_url type=hidden value=${window.location.pathname}></form>`,ct=class extends HTMLElement{constructor(){super();this.swish=window.swish;this.emailInput=this.querySelector('form[data-login-with-shop-sign-in] input[type="email"],form[data-login-with-shop-sign-in] input[name="customer[email]"'),this.emailInput||(this.innerHTML=`
8
+ <style>${Kr}</style>
9
+ ${Yr}
10
+ `,this.emailInput=this.querySelector("#customer_login_email")),this.shopModalObserver=new MutationObserver(t=>{t.forEach(r=>{r.attributeName==="style"&&document.documentElement.style.overflow==="hidden"&&this.dispatchEvent(new CustomEvent("shop-modal-open"))})}),this.shopModalObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["style"]})}static{i(this,"ShopBridge")}disconnectedCallback(){this.shopModalObserver?.disconnect()}async load(){try{(window.Shopify?.featureAssets?.["shop-js"]?.["init-customer-accounts"]?.[0]??"").includes("init-customer-accounts")&&(await Promise.all(window.Shopify?.featureAssets?.["shop-js"]?.["init-customer-accounts"]?.map(r=>import(`/cdn/shopifycloud/shop-js/${r}`))??[]),window.Shopify?.SignInWithShop?.initCustomerAccounts?.(!0,{fedCMEnabled:!0,windoidEnabled:!1}))}catch(t){console.warn("Failed to initialize Shop JS",t)}}update(t){if(t.email&&(this.emailInput.value=t.email,this.emailInput.dispatchEvent(new Event("input"))),t.returnTo){let r=this.querySelector("input[name='return_url']");r&&(r.value=t.returnTo)}}};customElements.define("swish-shop-bridge",ct);var se={baseUrl:"/apps/wishlist",version:"0.0.0"},Ae,De,Re,nn=i(n=>{se=n},"setConfig"),Z=new Map,rn=i(async n=>{if(Z.has(n))return Z.get(n);let e=(async()=>{typeof n=="string"&&(n=await U(n)),!(!n||n.getAttribute("open")!=="true")&&n.setAttribute("open","false")})().finally(()=>{Z.delete(n)});return ti(),Z.set(n,e),e},"hideModal"),Q=i(async n=>{if(Z.has(n))return Z.get(n);let e=(async()=>{typeof n=="string"&&(n=await U(n)),!(!n||n.getAttribute("open")==="true")&&n.setAttribute("open","true")})().finally(()=>{Z.delete(n)});return ei(),Z.set(n,e),e},"showModal"),sn=i(async n=>{let e=await U("sign-in",{listeners:{close:i(()=>{n?.onClose?.()},"close")}});e.setAttribute("return-to",n?.returnTo??window.location.pathname),await Q(e)},"showSignIn"),on=i(async n=>{if(!n.itemId)throw new Error("An itemId is required to show the unsave alert");oe();let e=await U("unsave-alert",{listeners:{submit:i(t=>{t instanceof CustomEvent?n.onSubmit?.(t.detail):console.warn("Unsave alert submitted without detail",t)},"submit"),close:i(()=>{n.onClose?.()},"close")}});e.setAttribute("item-id",n.itemId),await Q(e)},"showUnsaveAlert"),an=i(async n=>{if(!n.listId)throw new Error("A listId is required to show the delete list alert");oe();let e=await U("delete-list-alert",{listeners:{submit:i(()=>{n.onSubmit?.()},"submit"),close:i(()=>{n.onClose?.()},"close")}});e.setAttribute("list-id",n.listId),await Q(e)},"showDeleteListAlert"),Pe=i(async n=>{oe();let e=await U("drawer",{listeners:{close:i(()=>{n?.onClose?.()},"close")}});e.setAttribute("account-url",h.routes.accountUrl),h.customer.id&&e.setAttribute("customer-id",h.customer.id),await Q(e)},"showDrawer"),un=i(async n=>{if(!n.listId)throw new Error("listId is required");oe();let e=await U("list-menu",{listeners:{close:i(t=>{n.onClose?.()},"close"),edit:i(t=>{t instanceof CustomEvent?n.onEdit?.(t.detail):console.warn("List menu submitted without detail",t)},"edit"),delete:i(t=>{t instanceof CustomEvent?n.onDelete?.():console.warn("List menu deleted without detail",t)},"delete")}});e.setAttribute("list-id",n.listId),await Q(e)},"showListMenu"),ln=i(async n=>{if(!n.itemId)throw new Error("itemId is required");oe();let e=await U("list-select",{listeners:{submit:i(async t=>{"detail"in t&&t.detail?n?.onSubmit?.(t.detail):console.warn("List select form submitted without detail",t)},"submit"),close:i(()=>{n.onClose?.()},"close"),unsave:i(t=>{t instanceof CustomEvent?n.onUnsave?.(t.detail):console.warn("List select unsave without detail",t)},"unsave")}});e.setAttribute("item-id",n.itemId),await Q(e)},"showListSelect"),cn=i(async n=>{await U("toast-manager",{onHydrated:i(e=>{e.current.show(n)},"onHydrated")})},"showToast"),oe=i(async()=>{pt("toast-manager")&&await U("toast-manager",{onHydrated:i(n=>{n.current.clear()},"onHydrated")})},"hideAllToasts"),pn=i(async n=>{oe();let e=await U("variant-select",{listeners:{submit:i(async t=>{"detail"in t&&t.detail?n?.onSubmit?.(t.detail):console.warn("Variant select form submitted without detail",t)},"submit"),close:i(()=>{n?.onClose?.()},"close")}});if(n?.productId)e.setAttribute("product-id",n.productId);else if(n?.productHandle)e.setAttribute("product-handle",n.productHandle);else throw new Error("Either productId or productHandle must be provided");n?.variantId&&e.setAttribute("variant-id",n.variantId),n?.displayType&&e.setAttribute("display-type",n.displayType),await Q(e)},"showVariantSelect"),fn=i(async n=>{oe();let e=await U("quick-buy",{listeners:{submit:i(async t=>{"detail"in t&&t.detail?n?.onSubmit?.(t.detail):console.warn("Quick buy form submitted without detail",t)},"submit"),close:i(()=>{n?.onClose?.()},"close")}});if(n?.productId)e.setAttribute("product-id",n.productId);else throw new Error("ProductId must be provided");n?.variantId&&e.setAttribute("variant-id",n.variantId),await Q(e)},"showQuickBuy"),Te=i(async n=>{let e=await U("list-editor",{listeners:{submit:i(async t=>{"detail"in t&&t.detail?n?.onSubmit?.(t.detail):console.warn("List editor form submitted without detail",t)},"submit"),close:i(()=>{n?.onClose?.()},"close")}});n?.listId&&e.setAttribute("list-id",n.listId),await Q(e)},"showListEditor"),dn=i(async({onShopModalOpen:n})=>{let e=document.querySelector("swish-shop-bridge");if(e||(document.body.insertAdjacentHTML("beforeend","<swish-shop-bridge></swish-shop-bridge>"),e=document.querySelector("swish-shop-bridge")),!e)throw new Error("Failed to initialize Shop Bridge");return e.addEventListener("shop-modal-open",()=>n(),{once:!0}),await e.load(),e},"initShopBridge"),be=i(async()=>Re||(Re=fetch(`${se?.baseUrl??""}/ui@${se.version}/manifest.json`).then(n=>n.json()),Re),"loadManifest"),tn=new Map,U=i(async(n,e)=>{let t=await be(),r=t.prerender[n],s=`${se?.baseUrl??""}/ui@${se?.version}/${t.scripts[n]}`,o=e?.instance,a=e?.listeners,u=pt(n,o)??await Zr({name:n,template:r,refElement:document.body,position:"beforeend",instance:o});u.shadowRoot&&!u.hasAttribute("hydrated")?Promise.all([Jr(),import(s)]).then(([l,{hydrate:c}])=>{u.shadowRoot&&l&&(u.shadowRoot.adoptedStyleSheets=[...u.shadowRoot.adoptedStyleSheets,l]),c(u),u.setAttribute("hydrated",""),e?.onHydrated?.(u.getComponentRef())}):u.hasAttribute("hydrated")&&e?.onHydrated?.(u.getComponentRef());for(let{event:l,listener:c}of tn.values())u.removeEventListener(l,c);for(let[l,c]of Object.entries(a??{}))tn.set(`${n}-${o}-${l}`,{event:l,listener:c}),u.addEventListener(l,c);return u},"requireUiComponent");async function Jr(){return De||(De=new Promise((n,e)=>be().then(t=>t.stylesheets.nonCritical?fetch(`${se?.baseUrl??""}/ui@${se?.version}/${t.stylesheets.nonCritical}`):new Response("")).then(t=>t.text()).then(t=>{let r=new CSSStyleSheet;r.replaceSync(t),n(r)}).catch(e)),De)}i(Jr,"loadNonCriticalStylesheet");var Zr=i(async({name:n,instance:e,template:t,position:r,refElement:s})=>{s.insertAdjacentHTML(r,t.replace(' shadowrootmode="open"',""));let o=pt(n,e);if(!o)throw new Error(`Element ${n} not found in DOM`);if(!Ae){let a=await be();Ae=new CSSStyleSheet,Ae.replaceSync(a.css.critical)}return o.shadowRoot&&(o.shadowRoot.adoptedStyleSheets=[Ae]),o},"insertComponent"),pt=i((n,e)=>{let t=`swish-ui[ref="${n}${e?`-${e}`:""}"]`;return document.querySelector(t)},"queryComponent"),de,Ie=0,ke=0,ei=i(()=>{Ie++,Ie===1&&(ke=window.scrollY,de||(de=new CSSStyleSheet,document.adoptedStyleSheets=[...document.adoptedStyleSheets,de]),de.replaceSync(`
11
+ html[locked] body {
12
+ overflow: hidden;
13
+ position: fixed;
14
+ top: -${ke}px;
15
+ left: 0px;
16
+ right: 0px;
17
+ }
18
+ `),document.documentElement.setAttribute("locked",""))},"lockScroll"),ti=i(()=>{Ie>0&&Ie--,Ie===0&&(de&&de.replaceSync(""),window.scrollTo({top:ke,behavior:"instant"}),ke=0,document.documentElement.removeAttribute("locked"))},"unlockScroll");typeof requestIdleCallback=="function"?requestIdleCallback(()=>{be()}):setTimeout(()=>{be()},1e3);var ni=C({itemId:G(V(b())),productId:V(ie([V(b(),B(P)),H()]),B(n=>Number(n)),H()),variantId:G(V(ie([V(b(),B(P)),H()]),B(n=>Number(n)),H()))}),he=class extends S{static{i(this,"EditItemVariantHandler")}async invoke(e,t=!1){return new Promise(r=>{let s=e.data,o=O(ni,s);if(!o.success){r({code:"error",message:"Invalid intent data",issues:o.issues.map(c=>c.message)});return}let{itemId:a,productId:u,variantId:l}=o.output;pn({productId:u.toString(),variantId:l?.toString(),onClose:i(()=>{r({code:"closed"})},"onClose"),onSubmit:i(async c=>{let{item:p,product:d,variant:v}=c,y={code:"ok",data:{item:p,product:d,variant:v}};t||this.eventBus.dispatchEvent(new CustomEvent("edit:swish/ItemVariant",{detail:y})),r(y)},"onSubmit")})})}};var ri=C({productId:V(ie([V(b(),B(P)),H()]),B(n=>Number(n)),H()),variantId:G(V(ie([V(b(),B(P)),H()]),B(Number),H())),quantity:G(V(H(),ut(1))),tags:G(lt(b()))}),_e=class extends S{static{i(this,"CreateItemHandler")}async invoke(e){let t=e.data,r=O(ri,t);if(!r.success)return{code:"error",message:"Invalid intent data",issues:r.issues.map(v=>v.message)};let{productId:s,variantId:o,quantity:a,tags:u}=r.output,l=await this.swish.storefront.loadSaveIntentData({productId:E("Product",s),variantId:o?E("ProductVariant",o):void 0});if(l.errors)return{code:"error",message:l.errors.message??"Failed to load save intent data",issues:l.errors.graphQLErrors?.map(v=>v.message)??[]};if(!l.data||!l.data.product)return{code:"error",message:"Failed to load save intent data",issues:["API response missing data"]};let{product:c}=l.data,p=c.variantsCount?.count&&c.variantsCount.count>1;if(!p||this.options.allowSaveWithoutVariant){let v=i(()=>!p&&c.selectedOrFirstAvailableVariant?Number(P(c.selectedOrFirstAvailableVariant.id)):o,"variantIdToUse"),y=await this.swish.api.items.create({productId:s,variantId:v(),quantity:a,tags:u});if("error"in y)return{code:"error",message:"Failed to create item",issues:[y.error.message]};if(!y.data)return{code:"error",message:"Could not complete item creation",issues:["API response missing data"]};let k="variant"in l.data?l.data.variant:void 0,m={code:"ok",data:{item:y.data,product:c,variant:p?k:c.selectedOrFirstAvailableVariant}};return this.eventBus.dispatchEvent(new CustomEvent("create:swish/Item",{detail:m})),m}let d=await new he(this.swish,this.eventBus,this.options).invoke({action:"edit",type:"swish/ItemVariant",data:{productId:s,variantId:o}});return this.eventBus.dispatchEvent(new CustomEvent("create:swish/Item",{detail:d})),d}};var Oe=class extends S{static{i(this,"CreateListHandler")}async invoke(e){return new Promise(t=>{Te({onClose:i(()=>{t({code:"closed"})},"onClose"),onSubmit:i(async r=>{let{list:s}=r;t({code:"ok",data:{list:s}})},"onSubmit")})})}};var ii=C({itemId:b()}),$e=class extends S{static{i(this,"DeleteItemHandler")}async invoke(e){return new Promise(t=>{let r=O(ii,e.data);if(!r.success){t({code:"error",message:"Invalid intent data",issues:r.issues.map(o=>o.message)});return}let{itemId:s}=r.output;on({itemId:s,onClose:i(()=>{t({code:"closed"})},"onClose"),onSubmit:i(()=>{t({code:"ok",data:{itemId:s}})},"onSubmit")})})}};var si=C({listId:b()}),Le=class extends S{static{i(this,"DeleteListHandler")}async invoke(e){return new Promise(t=>{let r=e.data,s=O(si,r);if(!s.success){t({code:"error",message:"Invalid intent data",issues:s.issues.map(a=>a.message)});return}let{listId:o}=s.output;an({listId:o,onClose:i(()=>{t({code:"closed"})},"onClose"),onSubmit:i(async()=>{t({code:"ok",data:{listId:o}})},"onSubmit")})})}};var oi=C({itemId:b()}),Ve=class extends S{static{i(this,"EditItemListsHandler")}async invoke(e,t=!1){return new Promise(r=>{let s=e.data,o=O(oi,s);if(!o.success){r({code:"error",message:"Invalid intent data",issues:o.issues.map(u=>u.message)});return}let{itemId:a}=o.output;ln({itemId:a,onClose:i(()=>{r({code:"closed"})},"onClose"),onSubmit:i(async u=>{let{item:l,product:c,variant:p}=u,d={code:"ok",data:{item:l,product:c,variant:p}};t||this.eventBus.dispatchEvent(new CustomEvent("edit:swish/ItemLists",{detail:d})),r(d)},"onSubmit"),onUnsave(u){let l={code:"ok",data:{itemId:u.itemId}};r(l)}})})}};var ai=C({listId:b()}),qe=class extends S{static{i(this,"EditListHandler")}async invoke(e){return new Promise(t=>{let r=e.data,s=O(ai,r);if(!s.success){t({code:"error",message:"Invalid intent data",issues:s.issues.map(a=>a.message)});return}let{listId:o}=s.output;Te({listId:o,onClose:i(()=>{t({code:"closed"})},"onClose"),onSubmit:i(async a=>{let{list:u}=a;t({code:"ok",data:{list:u}})},"onSubmit")})})}};var Ne=class extends S{static{i(this,"OpenHomeHandler")}async invoke(e){return new Promise(t=>{Pe({onClose:i(()=>{t({code:"closed"})},"onClose")})})}};var ui=C({listId:b()}),Be=class extends S{static{i(this,"OpenListMenuHandler")}async invoke(e){return new Promise(t=>{let r=e.data,s=O(ui,r);if(!s.success){t({code:"error",message:"Invalid intent data",issues:s.issues.map(a=>a.message)});return}let{listId:o}=s.output;un({listId:o,onClose:i(()=>{t({code:"closed"})},"onClose"),onEdit:i(a=>{t({code:"ok",data:a})},"onEdit"),onDelete:i(()=>{t({code:"ok",data:{listId:o}})},"onDelete")})})}};var qo=C({returnTo:G(b())}),Ge=class extends S{static{i(this,"OpenSignInHandler")}async invoke(e){return new Promise(t=>{sn({returnTo:e.data?.returnTo,onClose:i(()=>{t({code:"closed"})},"onClose")})})}};var li=C({productId:b(),variantId:G(b())}),je=class extends S{static{i(this,"OpenQuickBuyHandler")}async invoke(e){return new Promise(t=>{let r=O(li,e.data);if(!r.success){t({code:"error",message:"Invalid intent data",issues:r.issues.map(a=>a.message)});return}let{productId:s,variantId:o}=r.output;fn({productId:s,variantId:o,onClose:i(()=>{t({code:"closed"})},"onClose"),onSubmit:i(a=>{t({code:"ok",data:a})},"onSubmit")})})}};var ye=class{constructor(e,t){this.swish=e;this.options=t}static{i(this,"IntentHook")}};var Ue=class extends ye{static{i(this,"AfterCreateItemHook")}async invoke(e){if(this.options.showToastAfterSave&&e.code==="ok"){let{item:t,product:r,variant:s}=e.data;r&&this.swish.ui.showToast({title:"Saved",text:r.title,image:s?.image?.url??r.featuredImage?.url,action:{label:"Add to List",onClick:i(()=>{this.swish.intents.invoke({action:"edit",type:"swish/ItemLists",data:{itemId:t.id}})},"onClick")}})}}};var Me=class extends ye{static{i(this,"AfterEditItemListsHook")}async invoke(e){if(this.options.showToastAfterSave&&e.code==="ok"){if("itemId"in e.data)return;let{item:t,product:r,variant:s}=e.data;r&&this.swish.ui.showToast({title:"Saved",text:r.title,image:s?.image?.url??r.featuredImage?.url,action:{label:"View",onClick:i(()=>{Pe()},"onClick")}})}}};var He=class{static{i(this,"Intents")}constructor(e,t){this.swish=e,this.eventBus=new EventTarget,this.options=t,this.initIntentHooks(),this.initIntentWatcher()}async invoke(e){let t=this.parseIntent(e);return{intent:t,complete:this.handleIntent(t)}}listen(e,t){let r=this.getIntentQuery(e),s=i(a=>{"detail"in a&&a.detail?t(a.detail):console.warn("Intent response event without detail",a)},"eventListener"),o=i(()=>{this.eventBus.removeEventListener(r,s)},"unsubscribe");return this.eventBus.addEventListener(r,s),o}getIntentQuery(e){return`${e.action}:${e.type}`}parseIntent(e){if(typeof e=="string"){let[t,...r]=e.split(","),[s,o]=t.split(":"),a=r.reduce((u,l)=>{let[c,p]=l.split("=");return u[c]=p,u},{});return{action:s,type:o,data:a}}return e}async handleIntent(e){return e.action==="create"&&e.type==="swish/Item"?new _e(this.swish,this.eventBus,this.options).invoke(e):e.action==="delete"&&e.type==="swish/Item"?new $e(this.swish,this.eventBus,this.options).invoke(e):e.action==="edit"&&e.type==="swish/ItemVariant"?new he(this.swish,this.eventBus,this.options).invoke(e):e.action==="edit"&&e.type==="swish/ItemLists"?new Ve(this.swish,this.eventBus,this.options).invoke(e):e.action==="create"&&e.type==="swish/List"?new Oe(this.swish,this.eventBus,this.options).invoke(e):e.action==="edit"&&e.type==="swish/List"?new qe(this.swish,this.eventBus,this.options).invoke(e):e.action==="delete"&&e.type==="swish/List"?new Le(this.swish,this.eventBus,this.options).invoke(e):e.action==="open"&&e.type==="swish/Home"?new Ne(this.swish,this.eventBus,this.options).invoke(e):e.action==="open"&&e.type==="swish/ListMenu"?new Be(this.swish,this.eventBus,this.options).invoke(e):e.action==="open"&&e.type==="swish/SignIn"?new Ge(this.swish,this.eventBus,this.options).invoke(e):e.action==="open"&&e.type==="swish/QuickBuy"?new je(this.swish,this.eventBus,this.options).invoke(e):{code:"error",message:"Invalid intent",issues:["Invalid intent"]}}initIntentHooks(){this.eventBus.addEventListener("create:swish/Item",e=>{new Ue(this.swish,this.options).invoke(e.detail)}),this.eventBus.addEventListener("edit:swish/ItemLists",e=>{new Me(this.swish,this.options).invoke(e.detail)})}initIntentWatcher(){ge({selector:"[swish-intent]",onElementFound:i(e=>{let t=this.parseIntent(e.getAttribute("swish-intent"));t&&e.addEventListener("click",()=>{this.handleIntent(t)})},"onElementFound")}),ge({selector:"a[href*='swish-intent=']",onElementFound:i(e=>{e instanceof HTMLAnchorElement&&e.addEventListener("click",t=>{if(!t.metaKey&&!t.ctrlKey&&!t.shiftKey&&!t.altKey){let s=new URL(e.href).searchParams.get("swish-intent");if(s){let o=this.parseIntent(s);o&&(t.preventDefault(),t.stopPropagation(),this.handleIntent(o))}}})},"onElementFound")}),fe({fireOnInit:!0,onLocationChange:i(e=>{let t=new URLSearchParams(window.location.search).get("swish-intent");if(t){let r=this.parseIntent(t);if(r){this.handleIntent(r);let s=new URL(window.location.href);s.searchParams.delete("swish-intent"),window.history.replaceState({},document.title,s.toString())}}},"onLocationChange")})}};var ci=Symbol.for("preact-signals");function Qe(){if(ee>1)ee--;else{for(var n,e=!1;we!==void 0;){var t=we;for(we=void 0,ft++;t!==void 0;){var r=t.o;if(t.o=void 0,t.f&=-3,!(8&t.f)&&mn(t))try{t.c()}catch(s){e||(n=s,e=!0)}t=r}}if(ft=0,ee--,e)throw n}}i(Qe,"t");function te(n){if(ee>0)return n();ee++;try{return n()}finally{Qe()}}i(te,"r");var I=void 0;function hn(n){var e=I;I=void 0;try{return n()}finally{I=e}}i(hn,"n");var we=void 0,ee=0,ft=0,Fe=0;function yn(n){if(I!==void 0){var e=n.n;if(e===void 0||e.t!==I)return e={i:0,S:n,p:I.s,n:void 0,t:I,e:void 0,x:void 0,r:e},I.s!==void 0&&(I.s.n=e),I.s=e,n.n=e,32&I.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=I.s,e.n=void 0,I.s.n=e,I.s=e),e}}i(yn,"e");function q(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(q,"u");q.prototype.brand=ci;q.prototype.h=function(){return!0};q.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:hn(function(){var r;(r=e.W)==null||r.call(e)}))};q.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&&hn(function(){var s;(s=e.Z)==null||s.call(e)}))}};q.prototype.subscribe=function(n){var e=this;return M(function(){var t=e.value,r=I;I=void 0;try{n(t)}finally{I=r}},{name:"sub"})};q.prototype.valueOf=function(){return this.value};q.prototype.toString=function(){return this.value+""};q.prototype.toJSON=function(){return this.value};q.prototype.peek=function(){var n=I;I=void 0;try{return this.value}finally{I=n}};Object.defineProperty(q.prototype,"value",{get:i(function(){var n=yn(this);return n!==void 0&&(n.i=this.i),this.v},"get"),set:i(function(n){if(n!==this.v){if(ft>100)throw new Error("Cycle detected");this.v=n,this.i++,Fe++,ee++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{Qe()}}},"set")});function x(n,e){return new q(n,e)}i(x,"d");function mn(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(mn,"c");function vn(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(vn,"a");function gn(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(gn,"l");function ae(n,e){q.call(this,void 0),this.x=n,this.s=void 0,this.g=Fe-1,this.f=4,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}i(ae,"y");ae.prototype=new q;ae.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Fe))return!0;if(this.g=Fe,this.f|=1,this.i>0&&!mn(this))return this.f&=-2,!0;var n=I;try{vn(this),I=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 I=n,gn(this),this.f&=-2,!0};ae.prototype.S=function(n){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}q.prototype.S.call(this,n)};ae.prototype.U=function(n){if(this.t!==void 0&&(q.prototype.U.call(this,n),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}};ae.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var n=this.t;n!==void 0;n=n.x)n.t.N()}};Object.defineProperty(ae.prototype,"value",{get:i(function(){if(1&this.f)throw new Error("Cycle detected");var n=yn(this);if(this.h(),n!==void 0&&(n.i=this.i),16&this.f)throw this.v;return this.v},"get")});function j(n,e){return new ae(n,e)}i(j,"w");function In(n){var e=n.u;if(n.u=void 0,typeof e=="function"){ee++;var t=I;I=void 0;try{e()}catch(r){throw n.f&=-2,n.f|=8,dt(n),r}finally{I=t,Qe()}}}i(In,"_");function dt(n){for(var e=n.s;e!==void 0;e=e.n)e.S.U(e);n.x=void 0,n.s=void 0,In(n)}i(dt,"b");function pi(n){if(I!==this)throw new Error("Out-of-order effect");gn(this),I=n,this.f&=-2,8&this.f&&dt(this),Qe()}i(pi,"g");function me(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(me,"p");me.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()}};me.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,In(this),vn(this),ee++;var n=I;return I=this,pi.bind(this,n)};me.prototype.N=function(){2&this.f||(this.f|=2,this.o=we,we=this)};me.prototype.d=function(){this.f|=8,1&this.f||dt(this)};me.prototype.dispose=function(){this.d()};function M(n,e){var t=new me(n,e);try{t.c()}catch(s){throw t.d(),s}var r=t.d.bind(t);return r[Symbol.dispose]=r,r}i(M,"E");var fi=/^(?:https?:\/\/[^/]+)?(?:\/[a-z]{2})?\/products\/([^/?#]+)(?:\?variant=(\d+))?/,ht=i(n=>{let e=n.match(fi);return e?{productHandle:e[1],variantId:e[2]}:null},"parseProductUrl"),bn=i(({source:n,onProductUrlChange:e})=>{let t=i(r=>{let s=ht(r);s?.productHandle&&e(s)},"handleChange");if(n instanceof HTMLAnchorElement)return Yt({element:n,onHrefChange:i(r=>t(r),"onHrefChange")});if(n instanceof Location)return fe({onLocationChange:i(r=>t(r.href),"onLocationChange")});throw new Error("Invalid source for observing product url")},"observeProductUrl");var wn=i(n=>e=>{let{productHandle:t,productId:r,variantId:s,itemId:o}=e?.dataset??{},l=!!(r||t)||!!o,c=x({loading:!1,productId:r,variantId:s,itemId:o});if(!l){let p=e instanceof HTMLAnchorElement?e:window.location,d=ht(p.href);d?.productHandle&&d.productHandle!==c.value.productHandle&&(c.value={...c.value,...d,productId:void 0},bn({source:p,onProductUrlChange:i(v=>{c.value={...c.value,...v,productId:v.productHandle!==c.value.productHandle?void 0:c.value.productId}},"onProductUrlChange")}))}return M(()=>{c.value.loading||!c.value.productId&&c.value.productHandle&&(c.value={...c.value,loading:!0},n.storefront.loadProductId({productHandle:c.value.productHandle}).then(p=>{p.errors&&console.error("Error loading product id",p.errors),c.value={...c.value,productId:p.data?.product?.id?P(p.data.product.id):void 0,loading:!1}}))}),c},"itemContextSignal");var En=i(n=>e=>{let t=j(()=>{let{productId:w,variantId:g,loading:T}=e.value;return!w||T?null:g?`variant:${P(g)}`:`product:${P(w)}`}),r=j(()=>e.value.loading||!!e.value.itemId||!e.value.productId),s=j(()=>({limit:1,query:t.value??void 0})),o=x(!r.value),a=x(null),u=x(!1),l=x(!1),{data:c,loading:p,error:d,refetching:v}=n.state.swishQuery(w=>n.api.items.list(w),{refetch:["item-create","item-update","item-delete"],variables:s,skip:r}),y=x(e.value.itemId??null);M(()=>{te(()=>{if(o.value=p.value,a.value=d.value,!e.value.itemId){let w=c.value?.[0]?.id??null;w!==y.value&&(y.value=w)}})});async function k(){if(!y.value)return;u.value=!0,(await(await n.intents.invoke({action:"delete",type:"swish/Item",data:{itemId:y.value}})).complete).code==="ok"&&(y.value=null),u.value=!1}i(k,"unsave");async function m(){if(!y.value)return;u.value=!0;let g=await(await n.intents.invoke({action:"edit",type:"swish/ItemLists",data:{itemId:y.value}})).complete;g.code==="ok"&&"itemId"in g.data&&(y.value=null),u.value=!1}i(m,"update");async function A(){let{productId:w,variantId:g}=e.value;if(!w)return;u.value=!0,l.value=!0;let _=await(await n.intents.invoke({action:"create",type:"swish/Item",data:{productId:w,variantId:g}})).complete;if(_.code==="ok"){let ve=_.data;y.value=ve.item.id,u.value=!1}else _.code==="error"&&console.warn("Failed to create item",_),te(()=>{u.value=!1,l.value=!1})}i(A,"save");let L=j(()=>o.value||u.value||e.value.loading);M(()=>{l.value&&!u.value&&!v.value&&(l.value=!1)});let R=j(()=>{let w=v.value&&l.value,g=!!y.value,T=!g&&(u.value||w),_=g&&(u.value||w),ve=j(()=>T?"saving":_?"unsaving":g?"saved":"unsaved");return{error:a.value,status:ve.value,savedItemId:y.value,loading:L.value,submitting:u.value,saved:g,saving:T,unsaving:_}});async function z(){L.value||(R.value.saved&&R.value.savedItemId?m():R.value.saved||await A())}return i(z,"toggle"),Object.assign(R,{save:A,unsave:k,update:m,toggle:z})},"itemStateSignal");var Sn=i(n=>()=>{let{data:e,loading:t,error:r}=n.state.swishQuery(()=>n.api.items.count(),{refetch:["item-create","item-delete"]}),s=x(0),o=x(!0),a=x(null);return M(()=>{te(()=>{o.value=t.value,a.value=r.value,s.value=e.value?.count??0})}),j(()=>({count:s.value,loading:o.value,error:a.value}))},"itemCountSignal");var Cn=i(n=>(e,t)=>{let r=x(null),s=x(null),o=x(null),a=x(!t?.skip),u=x(!1),l=j(()=>a.value&&u.value);async function c(){if(!t?.skip?.value)try{a.value=!0;let p=await e(t?.variables?.value);te(()=>{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){te(()=>{o.value=p,a.value=!1,u.value=!0})}}return i(c,"executeFetch"),M(()=>{if(c(),t?.refetch?.length)return n.events.subscribe(t.refetch,c)}),{data:r,pageInfo:s,error:o,loading:a,refetching:l}},"swishQuerySignals");var ue="GraphQL Client";var yt="An error occurred while fetching from the API. Review 'graphQLErrors' for details.",mt="Response returned unexpected Content-Type:",vt="An unknown error has occurred. The API did not return a data object or any errors in its response.",ze={json:"application/json",multipart:"multipart/mixed"},gt="X-SDK-Variant",It="X-SDK-Version",An="shopify-graphql-client",Dn="1.4.1",We=1e3,Rn=[429,503],bt=/@(defer)\b/i,xn=`\r
19
+ `,kn=/boundary="?([^=";]+)"?/i,wt=xn+xn;function X(n,e=ue){return n.startsWith(`${e}`)?n:`${e}: ${n}`}i(X,"formatErrorMessage");function Y(n){return n instanceof Error?n.message:JSON.stringify(n)}i(Y,"getErrorMessage");function Et(n){return n instanceof Error&&n.cause?n.cause:void 0}i(Et,"getErrorCause");function St(n){return n.flatMap(({errors:e})=>e??[])}i(St,"combineErrors");function Xe({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(Xe,"validateRetries");function N(n,e){return e&&(typeof e!="object"||Array.isArray(e)||typeof e=="object"&&Object.keys(e).length>0)?{[n]:e}:{}}i(N,"getKeyValueIfValid");function Ct(n,e){if(n.length===0)return e;let r={[n.pop()]:e};return n.length===0?r:Ct(n,r)}i(Ct,"buildDataObjectByPath");function _n(n,e){return Object.keys(e||{}).reduce((t,r)=>(typeof e[r]=="object"||Array.isArray(e[r]))&&n[r]?(t[r]=_n(n[r],e[r]),t):(t[r]=e[r],t),Array.isArray(n)?[...n]:{...n})}i(_n,"combineObjects");function xt([n,...e]){return e.reduce(_n,{...n})}i(xt,"buildCombinedDataObject");function At({clientLogger:n,customFetchApi:e=fetch,client:t=ue,defaultRetryWaitTime:r=We,retriableCodes:s=Rn}){let o=i(async(a,u,l)=>{let c=u+1,p=l+1,d;try{if(d=await e(...a),n({type:"HTTP-Response",content:{requestParams:a,response:d}}),!d.ok&&s.includes(d.status)&&c<=p)throw new Error;let v=d?.headers.get("X-Shopify-API-Deprecated-Reason")||"";return v&&n({type:"HTTP-Response-GraphQL-Deprecation-Notice",content:{requestParams:a,deprecationNotice:v}}),d}catch(v){if(c<=p){let y=d?.headers.get("Retry-After");return await di(y?parseInt(y,10):r),n({type:"HTTP-Retry",content:{requestParams:a,lastResponse:d,retryAttempt:u,maxRetries:l}}),o(a,c,l)}throw new Error(X(`${l>0?`Attempted maximum number of ${l} network retries. Last message - `:""}${Y(v)}`,t))}},"httpFetch");return o}i(At,"generateHttpFetch");async function di(n){return new Promise(e=>setTimeout(e,n))}i(di,"sleep");function Dt({headers:n,url:e,customFetchApi:t=fetch,retries:r=0,logger:s}){Xe({client:ue,retries:r});let o={headers:n,url:e,retries:r},a=hi(s),u=At({customFetchApi:t,clientLogger:a,defaultRetryWaitTime:We}),l=yi(u,o),c=mi(l),p=Si(l);return{config:o,fetch:l,request:c,requestStream:p}}i(Dt,"createGraphQLClient");function hi(n){return e=>{n&&n(e)}}i(hi,"generateClientLogger");async function On(n){let{errors:e,data:t,extensions:r}=await n.json();return{...N("data",t),...N("extensions",r),headers:n.headers,...e||!t?{errors:{networkStatusCode:n.status,message:X(e?yt:vt),...N("graphQLErrors",e),response:n}}:{}}}i(On,"processJSONResponse");function yi(n,{url:e,headers:t,retries:r}){return async(s,o={})=>{let{variables:a,headers:u,url:l,retries:c,keepalive:p,signal:d}=o,v=JSON.stringify({query:s,variables:a});Xe({client:ue,retries:c});let y=Object.entries({...t,...u}).reduce((m,[A,L])=>(m[A]=Array.isArray(L)?L.join(", "):L.toString(),m),{});return!y[gt]&&!y[It]&&(y[gt]=An,y[It]=Dn),n([l??e,{method:"POST",headers:y,body:v,signal:d,keepalive:p}],1,c??r)}}i(yi,"generateFetch");function mi(n){return async(...e)=>{if(bt.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(ze.json)?await On(t):{errors:{networkStatusCode:r,message:X(`${mt} ${o}`),response:t}}:{errors:{networkStatusCode:r,message:X(s),response:t}}}catch(r){return{errors:{message:Y(r),...t==null?{}:{networkStatusCode:t.status,response:t}}}}}}i(mi,"generateRequest");async function*vi(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(vi,"getStreamBodyIterator");function gi(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(wt)+wt.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 - ${Y(t)}`)}}}}i(gi,"readStreamChunk");function Ii(n){return{async*[Symbol.asyncIterator](){yield{...await On(n),hasNext:!1}}}}i(Ii,"createJsonResponseAsyncIterator");function bi(n){return n.map(e=>{try{return JSON.parse(e)}catch(t){throw new Error(`Error in parsing multipart response - ${Y(t)}`)}}).map(e=>{let{data:t,incremental:r,hasNext:s,extensions:o,errors:a}=e;if(!r)return{data:t||{},...N("errors",a),...N("extensions",o),hasNext:s};let u=r.map(({data:l,path:c,errors:p})=>({data:l&&c?Ct(c,l):{},...N("errors",p)}));return{data:u.length===1?u[0].data:xt([...u.map(({data:l})=>l)]),...N("errors",St(u)),hasNext:s}})}i(bi,"getResponseDataFromChunkBodies");function wi(n,e){if(n.length>0)throw new Error(yt,{cause:{graphQLErrors:n}});if(Object.keys(e).length===0)throw new Error(vt)}i(wi,"validateResponseData");function Ei(n,e){let t=(e??"").match(kn),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=vi(n),o={},a;return{async*[Symbol.asyncIterator](){try{let u=!0;for await(let l of gi(s,r)){let c=bi(l);a=c.find(d=>d.extensions)?.extensions??a;let p=St(c);o=xt([o,...c.map(({data:d})=>d)]),u=c.slice(-1)[0].hasNext,wi(p,o),yield{...N("data",o),...N("extensions",a),hasNext:u}}if(u)throw new Error("Response stream terminated unexpectedly")}catch(u){let l=Et(u);yield{...N("data",o),...N("extensions",a),errors:{message:X(Y(u)),networkStatusCode:n.status,...N("graphQLErrors",l?.graphQLErrors),response:n},hasNext:!1}}}}}i(Ei,"createMultipartResponseAsyncInterator");function Si(n){return async(...e)=>{if(!bt.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(ze.json):return Ii(t);case s.includes(ze.multipart):return Ei(t,s);default:throw new Error(`${mt} ${s}`,{cause:t})}}catch(t){return{async*[Symbol.asyncIterator](){let r=Et(t);yield{errors:{message:X(Y(t)),...N("networkStatusCode",r?.status),...N("response",r)},hasNext:!1}}}}}}i(Si,"generateRequestStream");function Rt({client:n,storeDomain:e}){try{if(!e||typeof e!="string")throw new Error;let t=e.trim(),r=t.match(/^https?:/)?t:`https://${t}`,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(Rt,"validateDomainAndGetStoreUrl");function Ke({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(Ke,"validateApiVersion");function Ye(n){let e=n*3-2;return e===10?e:`0${e}`}i(Ye,"getQuarterMonth");function kt(n,e,t){let r=e-t;return r<=0?`${n-1}-${Ye(r+4)}`:`${n}-${Ye(r)}`}i(kt,"getPrevousVersion");function $n(){let n=new Date,e=n.getUTCMonth(),t=n.getUTCFullYear(),r=Math.floor(e/3+1);return{year:t,quarter:r,version:`${t}-${Ye(r)}`}}i($n,"getCurrentApiVersion");function Pt(){let{year:n,quarter:e,version:t}=$n(),r=e===4?`${n+1}-01`:`${n}-${Ye(e+1)}`;return[kt(n,e,3),kt(n,e,2),kt(n,e,1),t,r,"unstable"]}i(Pt,"getCurrentSupportedApiVersions");function Tt(n){return e=>({...e??{},...n.headers})}i(Tt,"generateGetHeaders");function _t({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:l,signal:c}=r;s.push({...o?{variables:o}:{},...u?{headers:n(u)}:{},...a?{url:e(a)}:{},...l?{retries:l}:{},...c?{signal:c}:{}})}return s}}i(_t,"generateGetGQLClientParams");var Ot="application/json",Ln="storefront-api-client",Vn="1.0.9",qn="X-Shopify-Storefront-Access-Token",Nn="Shopify-Storefront-Private-Token",Bn="X-SDK-Variant",Gn="X-SDK-Version",jn="X-SDK-Variant-Source",le="Storefront API Client";function Un(n){if(n&&typeof window<"u")throw new Error(`${le}: 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(Un,"validatePrivateAccessTokenUsage");function Mn(n,e){if(!n&&!e)throw new Error(`${le}: a public or private access token must be provided`);if(n&&e)throw new Error(`${le}: only provide either a public or private access token`)}i(Mn,"validateRequiredAccessTokens");function $t({storeDomain:n,apiVersion:e,publicAccessToken:t,privateAccessToken:r,clientName:s,retries:o=0,customFetchApi:a,logger:u}){let l=Pt(),c=Rt({client:le,storeDomain:n}),p={client:le,currentSupportedApiVersions:l,logger:u};Ke({...p,apiVersion:e}),Mn(t,r),Un(r);let d=Ci(c,e,p),v={storeDomain:c,apiVersion:e,...t?{publicAccessToken:t}:{privateAccessToken:r},headers:{"Content-Type":Ot,Accept:Ot,[Bn]:Ln,[Gn]:Vn,...s?{[jn]:s}:{},...t?{[qn]:t}:{[Nn]:r}},apiUrl:d(),clientName:s},y=Dt({headers:v.headers,url:v.apiUrl,retries:o,customFetchApi:a,logger:u}),k=Tt(v),m=xi(v,d),A=_t({getHeaders:k,getApiUrl:m});return Object.freeze({config:v,getHeaders:k,getApiUrl:m,fetch:i((...R)=>y.fetch(...A(...R)),"fetch"),request:i((...R)=>y.request(...A(...R)),"request"),requestStream:i((...R)=>y.requestStream(...A(...R)),"requestStream")})}i($t,"createStorefrontApiClient");function Ci(n,e,t){return r=>{r&&Ke({...t,apiVersion:r});let s=(r??e).trim();return`${n}/api/${s}/graphql.json`}}i(Ci,"generateApiUrlFormatter");function xi(n,e){return t=>t?e(t):n.apiUrl}i(xi,"generateGetApiUrl");var $=`
9
20
  fragment productImageFields on Image {
10
21
  id
11
22
  altText
12
23
  url
13
24
  thumbhash
14
25
  }
15
- `,re=`
26
+ `,Lt=`
27
+ fragment saveIntentProductFields on Product {
28
+ id
29
+ availableForSale
30
+ featuredImage {
31
+ ...productImageFields
32
+ }
33
+ handle
34
+ title
35
+ variantsCount {
36
+ count
37
+ }
38
+ selectedOrFirstAvailableVariant {
39
+ ...saveIntentVariantFields
40
+ }
41
+ }
42
+ fragment saveIntentVariantFields on ProductVariant {
43
+ id
44
+ availableForSale
45
+ currentlyNotInStock
46
+ image {
47
+ ...productImageFields
48
+ }
49
+ title
50
+ }
51
+ `,ce=`
16
52
  fragment productCardDataFields on Product {
17
53
  id
18
54
  availableForSale
@@ -61,7 +97,7 @@ Values:
61
97
  value
62
98
  }
63
99
  }
64
- `,rt=`
100
+ `,Vt=`
65
101
  fragment productVariantDataFields on ProductVariant {
66
102
  id
67
103
  availableForSale
@@ -90,7 +126,7 @@ Values:
90
126
  value
91
127
  }
92
128
  }
93
- `,nt=`
129
+ `,qt=`
94
130
  fragment productOptionsVariantFields on ProductVariant {
95
131
  id
96
132
  selectedOptions {
@@ -98,9 +134,10 @@ Values:
98
134
  value
99
135
  }
100
136
  }
101
- `,at=`
137
+ `,Nt=`
102
138
  fragment selectedVariantFields on Product {
103
139
  id
140
+ availableForSale
104
141
  title
105
142
  handle
106
143
  featuredImage {
@@ -128,9 +165,10 @@ Values:
128
165
  }
129
166
  }
130
167
  }
131
- `,ne=`
168
+ `,pe=`
132
169
  fragment productOptionsFields on Product {
133
170
  id
171
+ availableForSale
134
172
  title
135
173
  featuredImage {
136
174
  ...productImageFields
@@ -163,7 +201,7 @@ Values:
163
201
  }
164
202
  }
165
203
  }
166
- `,ot=`
204
+ `,Bt=`
167
205
  fragment productImagesFields on Product {
168
206
  images(first: 20) {
169
207
  nodes {
@@ -171,7 +209,35 @@ Values:
171
209
  }
172
210
  }
173
211
  }
174
- `;var Yt=`
212
+ `;var Hn=`
213
+ query GetSaveIntentData(
214
+ $productId: ID!
215
+ $country: CountryCode!
216
+ $language: LanguageCode!
217
+ ) @inContext(country: $country, language: $language) {
218
+ product(id: $productId) {
219
+ ...saveIntentProductFields
220
+ }
221
+ }
222
+ ${Lt}
223
+ ${$}
224
+ `,Fn=`
225
+ query GetSaveIntentDataWithVariant(
226
+ $productId: ID!
227
+ $variantId: ID!
228
+ $country: CountryCode!
229
+ $language: LanguageCode!
230
+ ) @inContext(country: $country, language: $language) {
231
+ product(id: $productId) {
232
+ ...saveIntentProductFields
233
+ }
234
+ variant: node(id: $variantId) {
235
+ ...saveIntentVariantFields
236
+ }
237
+ }
238
+ ${Lt}
239
+ ${$}
240
+ `,Qn=`
175
241
  query GetProductCardData(
176
242
  $productId: ID!
177
243
  $productMetafields: [HasMetafieldsIdentifier!]!
@@ -182,9 +248,9 @@ Values:
182
248
  ...productCardDataFields
183
249
  }
184
250
  }
185
- ${re}
186
- ${O}
187
- `,Kt=`
251
+ ${ce}
252
+ ${$}
253
+ `,zn=`
188
254
  query GetProductCardDataWithVariant(
189
255
  $productId: ID!
190
256
  $variantId: ID!
@@ -200,10 +266,10 @@ Values:
200
266
  ...productVariantDataFields
201
267
  }
202
268
  }
203
- ${re}
204
- ${rt}
205
- ${O}
206
- `,Jt=`
269
+ ${ce}
270
+ ${Vt}
271
+ ${$}
272
+ `,Wn=`
207
273
  query GetProductOptions(
208
274
  $productId: ID!
209
275
  $country: CountryCode!
@@ -213,9 +279,9 @@ Values:
213
279
  ...productOptionsFields
214
280
  }
215
281
  }
216
- ${ne}
217
- ${O}
218
- `,Xt=`
282
+ ${pe}
283
+ ${$}
284
+ `,Xn=`
219
285
  query GetProductOptionsByHandle(
220
286
  $handle: String!
221
287
  $country: CountryCode!
@@ -225,9 +291,9 @@ Values:
225
291
  ...productOptionsFields
226
292
  }
227
293
  }
228
- ${ne}
229
- ${O}
230
- `,Zt=`
294
+ ${pe}
295
+ ${$}
296
+ `,Kn=`
231
297
  query GetProductOptionsWithVariant(
232
298
  $productId: ID!
233
299
  $variantId: ID!
@@ -241,10 +307,10 @@ Values:
241
307
  ...productOptionsVariantFields
242
308
  }
243
309
  }
244
- ${ne}
245
- ${nt}
246
- ${O}
247
- `,er=`
310
+ ${pe}
311
+ ${qt}
312
+ ${$}
313
+ `,Yn=`
248
314
  query GetProductOptionsByHandleWithVariant(
249
315
  $handle: String!
250
316
  $variantId: ID!
@@ -258,10 +324,10 @@ Values:
258
324
  ...productOptionsVariantFields
259
325
  }
260
326
  }
261
- ${ne}
262
- ${nt}
263
- ${O}
264
- `,tr=`
327
+ ${pe}
328
+ ${qt}
329
+ ${$}
330
+ `,Jn=`
265
331
  query GetSelectedVariant(
266
332
  $productId: ID!
267
333
  $selectedOptions: [SelectedOptionInput!]!
@@ -272,9 +338,9 @@ Values:
272
338
  ...selectedVariantFields
273
339
  }
274
340
  }
275
- ${at}
276
- ${O}
277
- `,rr=`
341
+ ${Nt}
342
+ ${$}
343
+ `,Zn=`
278
344
  query GetSelectedVariantByHandle(
279
345
  $handle: String!
280
346
  $selectedOptions: [SelectedOptionInput!]!
@@ -285,9 +351,9 @@ Values:
285
351
  ...selectedVariantFields
286
352
  }
287
353
  }
288
- ${at}
289
- ${O}
290
- `,nr=`
354
+ ${Nt}
355
+ ${$}
356
+ `,er=`
291
357
  query GetProductDetailData(
292
358
  $productId: ID!
293
359
  $productMetafields: [HasMetafieldsIdentifier!]!
@@ -300,11 +366,11 @@ Values:
300
366
  ...productImagesFields
301
367
  }
302
368
  }
303
- ${re}
304
- ${ne}
305
- ${ot}
306
- ${O}
307
- `,ar=`
369
+ ${ce}
370
+ ${pe}
371
+ ${Bt}
372
+ ${$}
373
+ `,tr=`
308
374
  query GetProductDetailDataWithVariant(
309
375
  $productId: ID!
310
376
  $variantId: ID!
@@ -322,12 +388,12 @@ Values:
322
388
  ...productVariantDataFields
323
389
  }
324
390
  }
325
- ${re}
326
- ${ne}
327
- ${rt}
328
- ${ot}
329
- ${O}
330
- `,or=`
391
+ ${ce}
392
+ ${pe}
393
+ ${Vt}
394
+ ${Bt}
395
+ ${$}
396
+ `,nr=`
331
397
  query GetProductImagesById(
332
398
  $ids: [ID!]!
333
399
  $country: CountryCode!
@@ -351,8 +417,8 @@ Values:
351
417
  }
352
418
  }
353
419
  }
354
- ${O}
355
- `,ir=`
420
+ ${$}
421
+ `,rr=`
356
422
  query GetProductRecommendationsById(
357
423
  $productId: ID!
358
424
  $intent: ProductRecommendationIntent
@@ -364,9 +430,9 @@ Values:
364
430
  ...productCardDataFields
365
431
  }
366
432
  }
367
- ${re}
368
- ${O}
369
- `,sr=`
433
+ ${ce}
434
+ ${$}
435
+ `,ir=`
370
436
  query GetProductRecommendationsByHandle(
371
437
  $handle: String!
372
438
  $intent: ProductRecommendationIntent
@@ -378,27 +444,16 @@ Values:
378
444
  ...productCardDataFields
379
445
  }
380
446
  }
381
- ${re}
382
- ${O}
383
- `,cr=`
447
+ ${ce}
448
+ ${$}
449
+ `,sr=`
384
450
  query GetProductIdByHandle($handle: String!) {
385
451
  product(handle: $handle) {
386
452
  id
387
453
  }
388
454
  }
389
- `;var lr=o(async(t,{productId:e,variantId:r,productMetafields:n=[],variantMetafields:a=[]})=>{if(!e)throw new Error("A productId must be provided");let i=o(()=>{if(e&&!r)return Yt;if(e&&r)return Kt},"getProductOptionsQuery"),s=o(()=>{if(e&&!r)return{productId:R("Product",e),productMetafields:n,country:f.localization.country.toUpperCase(),language:f.localization.language.toUpperCase()};if(e&&r)return{productId:R("Product",e),variantId:R("ProductVariant",r),productMetafields:n,variantMetafields:a,country:f.localization.country.toUpperCase(),language:f.localization.language.toUpperCase()}},"getVariables"),c=i(),l=s();if(!l||!c)throw new Error("Invalid query arguments");return t.query(c,l)},"loadProductCardData");var dr=o(async(t,{productId:e,variantId:r,productMetafields:n=[],variantMetafields:a=[]})=>{if(!e)throw new Error("A productId must be provided");let i=o(()=>{if(e&&!r)return nr;if(e&&r)return ar},"getProductOptionsQuery"),s=o(()=>{if(e&&!r)return{productId:R("Product",e),productMetafields:n,country:f.localization.country.toUpperCase(),language:f.localization.language.toUpperCase()};if(e&&r)return{productId:R("Product",e),variantId:R("ProductVariant",r),productMetafields:n,variantMetafields:a,country:f.localization.country.toUpperCase(),language:f.localization.language.toUpperCase()}},"getVariables"),c=i(),l=s();if(!l||!c)throw new Error("Invalid query arguments");return t.query(c,l)},"loadProductDetailData");var ur=o(async(t,{items:e})=>{if(!e?.length)throw new Error("A list of items must be provided");let r={ids:e.map(n=>n.variantId?R("ProductVariant",n.variantId.toString()):R("Product",n.productId.toString())),country:f.localization.country.toUpperCase(),language:f.localization.language.toUpperCase()};try{return{data:(await t.query(or,r)).data?.nodes.map(i=>i===null?null:"image"in i?i.image:"featuredImage"in i?i.featuredImage:null).filter(i=>i!==null)??[],error:null}}catch(n){return console.error(n),{data:null,error:n}}},"loadProductImages");var pr=o(async(t,{productId:e,productHandle:r,variantId:n})=>{if(!e&&!r)throw new Error("Either productId or handle must be provided");let a=o(()=>{if(e&&!n)return Jt;if(r&&!n)return Xt;if(e&&n)return Zt;if(r&&n)return er},"getProductOptionsQuery"),i=o(()=>{if(e&&!n)return{productId:R("Product",e),country:f.localization.country.toUpperCase(),language:f.localization.language.toUpperCase()};if(r&&!n)return{handle:r,country:f.localization.country.toUpperCase(),language:f.localization.language.toUpperCase()};if(e&&n)return{productId:R("Product",e),variantId:R("ProductVariant",n),country:f.localization.country.toUpperCase(),language:f.localization.language.toUpperCase()};if(r&&n)return{handle:r,variantId:R("ProductVariant",n),country:f.localization.country.toUpperCase(),language:f.localization.language.toUpperCase()}},"getVariables"),s=a(),c=i();if(!c||!s)throw new Error("Invalid query arguments");return t.query(s,c)},"loadProductOptions");var hr=o(async(t,{productId:e,productHandle:r,selectedOptions:n})=>{if(!e&&!r)throw new Error("Either productId or handle must be provided");let a=e?tr:rr,i=e?{productId:`gid://shopify/Product/${e}`,selectedOptions:n,country:f.localization.country.toUpperCase(),language:f.localization.language.toUpperCase()}:{handle:r,selectedOptions:n,country:f.localization.country.toUpperCase(),language:f.localization.language.toUpperCase()};return t.query(a,i)},"loadSelectedVariant");var fr=o(async(t,{productId:e,productHandle:r,intent:n,productMetafields:a=[]})=>{if(!e&&!r)throw new Error("Either productId or productHandle must be provided");let i=f.localization.country.toUpperCase(),s=f.localization.language.toUpperCase();if(e){let l={productId:R("Product",e),intent:n,productMetafields:a,country:i,language:s};return t.query(ir,l)}let c={handle:r,intent:n,productMetafields:a,country:i,language:s};return t.query(sr,c)},"loadProductRecommendations");var mr=o(async(t,{productHandle:e})=>{if(!e)throw new Error("A product handle must be provided");return t.query(cr,{handle:e})},"loadProductId");var gn="2025-07",vn=["GetProductIdByHandle"],be=class{constructor(e){this.client=null;this.query=o(async(e,r)=>{if(!this.client)throw new Error("Storefront API client not initialized");let n=await this.client.request(e,{variables:r});return{data:n.data,errors:n.errors??null}},"query");this.loadProductOptions=o(async e=>pr(this,e),"loadProductOptions");this.loadSelectedVariant=o(async e=>hr(this,e),"loadSelectedVariant");this.loadProductCardData=o(async e=>lr(this,e),"loadProductCardData");this.loadProductDetailData=o(async e=>dr(this,e),"loadProductDetailData");this.loadProductImages=o(async e=>ur(this,e),"loadProductImages");this.loadProductRecommendations=o(async e=>fr(this,e),"loadProductRecommendations");this.loadProductId=o(async e=>mr(this,e),"loadProductId");this.shortCache=new F("storefront-api-short","max-age=60, stale-while-revalidate=3600"),this.longCache=new F("storefront-api-long","max-age=3600, stale-while-revalidate=86400"),this.shortCache.cleanupExpiredEntries().catch(r=>{console.warn("Storefront API cache initialization cleanup error:",r)}),this.longCache.cleanupExpiredEntries().catch(r=>{console.warn("Storefront API cache initialization cleanup error:",r)}),this.client=tt({apiVersion:gn,customFetchApi:o((r,n)=>n?.method==="OPTIONS"?this.fetch(r,n):vn.some(a=>n?.body?.toString().includes(`query ${a}`))?this.longCache.fetchWithCache(r,n):this.shortCache.fetchWithCache(r,n),"customFetchApi"),publicAccessToken:e.accessToken,storeDomain:e.storeDomain})}static{o(this,"StorefrontApiClient")}fetch(e,r){return r?.method==="OPTIONS"?fetch(e,r):this.shortCache.fetchWithCache(e,r)}async clearCache(){await this.shortCache.clear()}};var Cn=Object.defineProperty,u=o((t,e)=>Cn(t,"name",{value:e,configurable:!0}),"n"),wn={bodySerializer:u(t=>JSON.stringify(t,(e,r)=>typeof r=="bigint"?r.toString():r),"bodySerializer")},In={$body_:"body",$headers_:"headers",$path_:"path",$query_:"query"},Ki=Object.entries(In),bn=u(({onRequest:t,onSseError:e,onSseEvent:r,responseTransformer:n,responseValidator:a,sseDefaultRetryDelay:i,sseMaxRetryAttempts:s,sseMaxRetryDelay:c,sseSleepFn:l,url:p,...d})=>{let h,C=l??(m=>new Promise(I=>setTimeout(I,m)));return{stream:u(async function*(){let m=i??3e3,I=0,g=d.signal??new AbortController().signal;for(;!g.aborted;){I++;let A=d.headers instanceof Headers?d.headers:new Headers(d.headers);h!==void 0&&A.set("Last-Event-ID",h);try{let P={redirect:"follow",...d,body:d.serializedBody,headers:A,signal:g},T=new Request(p,P);t&&(T=await t(p,P));let _=await(d.fetch??globalThis.fetch)(T);if(!_.ok)throw new Error(`SSE failed: ${_.status} ${_.statusText}`);if(!_.body)throw new Error("No body in SSE response");let U=_.body.pipeThrough(new TextDecoderStream).getReader(),y="",w=u(()=>{try{U.cancel()}catch{}},"abortHandler");g.addEventListener("abort",w);try{for(;;){let{done:E,value:H}=await U.read();if(E)break;y+=H;let L=y.split(`
455
+ `;var or=i(async(n,{productId:e,variantId:t,productMetafields:r=[],variantMetafields:s=[]})=>{if(!e)throw new Error("A productId must be provided");let o=i(()=>{if(e&&!t)return Qn;if(e&&t)return zn},"getProductOptionsQuery"),a=i(()=>{if(e&&!t)return{productId:E("Product",e),productMetafields:r,country:h.localization.country.toUpperCase(),language:h.localization.language.toUpperCase()};if(e&&t)return{productId:E("Product",e),variantId:E("ProductVariant",t),productMetafields:r,variantMetafields:s,country:h.localization.country.toUpperCase(),language:h.localization.language.toUpperCase()}},"getVariables"),u=o(),l=a();if(!l||!u)throw new Error("Invalid query arguments");return n.query(u,l)},"loadProductCardData");var ar=i(async(n,{productId:e,variantId:t,productMetafields:r=[],variantMetafields:s=[]})=>{if(!e)throw new Error("A productId must be provided");let o=i(()=>{if(e&&!t)return er;if(e&&t)return tr},"getProductOptionsQuery"),a=i(()=>{if(e&&!t)return{productId:E("Product",e),productMetafields:r,country:h.localization.country.toUpperCase(),language:h.localization.language.toUpperCase()};if(e&&t)return{productId:E("Product",e),variantId:E("ProductVariant",t),productMetafields:r,variantMetafields:s,country:h.localization.country.toUpperCase(),language:h.localization.language.toUpperCase()}},"getVariables"),u=o(),l=a();if(!l||!u)throw new Error("Invalid query arguments");return n.query(u,l)},"loadProductDetailData");var ur=i(async(n,{productHandle:e})=>{if(!e)throw new Error("A product handle must be provided");return n.query(sr,{handle:e})},"loadProductId");var lr=i(async(n,{items:e})=>{if(!e?.length)throw new Error("A list of items must be provided");let t={ids:e.map(r=>r.variantId?E("ProductVariant",r.variantId.toString()):E("Product",r.productId.toString())),country:h.localization.country.toUpperCase(),language:h.localization.language.toUpperCase()};try{return{data:(await n.query(nr,t)).data?.nodes.map(o=>o===null?null:"image"in o?o.image:"featuredImage"in o?o.featuredImage:null).filter(o=>o!==null)??[],error:null}}catch(r){return console.error(r),{data:null,error:r}}},"loadProductImages");var cr=i(async(n,{productId:e,productHandle:t,variantId:r})=>{if(!e&&!t)throw new Error("Either productId or handle must be provided");let s=i(()=>{if(e&&!r)return Wn;if(t&&!r)return Xn;if(e&&r)return Kn;if(t&&r)return Yn},"getProductOptionsQuery"),o=i(()=>{if(e&&!r)return{productId:E("Product",e),country:h.localization.country.toUpperCase(),language:h.localization.language.toUpperCase()};if(t&&!r)return{handle:t,country:h.localization.country.toUpperCase(),language:h.localization.language.toUpperCase()};if(e&&r)return{productId:E("Product",e),variantId:E("ProductVariant",r),country:h.localization.country.toUpperCase(),language:h.localization.language.toUpperCase()};if(t&&r)return{handle:t,variantId:E("ProductVariant",r),country:h.localization.country.toUpperCase(),language:h.localization.language.toUpperCase()}},"getVariables"),a=s(),u=o();if(!u||!a)throw new Error("Invalid query arguments");return n.query(a,u)},"loadProductOptions");var pr=i(async(n,{productId:e,productHandle:t,intent:r,productMetafields:s=[]})=>{if(!e&&!t)throw new Error("Either productId or productHandle must be provided");let o=h.localization.country.toUpperCase(),a=h.localization.language.toUpperCase();if(e){let l={productId:E("Product",e),intent:r,productMetafields:s,country:o,language:a};return n.query(rr,l)}let u={handle:t,intent:r,productMetafields:s,country:o,language:a};return n.query(ir,u)},"loadProductRecommendations");var Ai=C({productId:V(b(),B(P)),variantId:G(V(b(),B(P)))}),fr=i(async(n,e)=>{let{productId:t,variantId:r}=en(Ai,e),s=i(()=>{if(t&&!r)return Hn;if(t&&r)return Fn},"getProductOptionsQuery"),o=i(()=>{if(t&&!r)return{productId:E("Product",t),country:h.localization.country.toUpperCase(),language:h.localization.language.toUpperCase()};if(t&&r)return{productId:E("Product",t),variantId:E("ProductVariant",r),country:h.localization.country.toUpperCase(),language:h.localization.language.toUpperCase()}},"getVariables"),a=s(),u=o();if(!u||!a)throw new Error("Invalid query arguments");return n.query(a,u)},"loadSaveIntentData");var dr=i(async(n,{productId:e,productHandle:t,selectedOptions:r})=>{if(!e&&!t)throw new Error("Either productId or handle must be provided");let s=e?Jn:Zn,o=e?{productId:`gid://shopify/Product/${e}`,selectedOptions:r,country:h.localization.country.toUpperCase(),language:h.localization.language.toUpperCase()}:{handle:t,selectedOptions:r,country:h.localization.country.toUpperCase(),language:h.localization.language.toUpperCase()};return n.query(s,o)},"loadSelectedVariant");var Di="2025-07",Ri=["GetProductIdByHandle"],Je=class{constructor(e){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=>cr(this,e),"loadProductOptions");this.loadSelectedVariant=i(async e=>dr(this,e),"loadSelectedVariant");this.loadProductCardData=i(async e=>or(this,e),"loadProductCardData");this.loadProductDetailData=i(async e=>ar(this,e),"loadProductDetailData");this.loadProductImages=i(async e=>lr(this,e),"loadProductImages");this.loadProductRecommendations=i(async e=>pr(this,e),"loadProductRecommendations");this.loadProductId=i(async e=>ur(this,e),"loadProductId");this.loadSaveIntentData=i(async e=>fr(this,e),"loadSaveIntentData");this.shortCache=new K("storefront-api-short","max-age=60, stale-while-revalidate=3600"),this.longCache=new K("storefront-api-long","max-age=3600, stale-while-revalidate=86400"),this.shortCache.cleanupExpiredEntries().catch(t=>{console.warn("Storefront API cache initialization cleanup error:",t)}),this.longCache.cleanupExpiredEntries().catch(t=>{console.warn("Storefront API cache initialization cleanup error:",t)}),this.client=$t({apiVersion:Di,customFetchApi:i((t,r)=>r?.method==="OPTIONS"?this.fetch(t,r):Ri.some(s=>r?.body?.toString().includes(`query ${s}`))?this.longCache.fetchWithCache(t,r):this.shortCache.fetchWithCache(t,r),"customFetchApi"),publicAccessToken:e.accessToken,storeDomain:e.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 ki=Object.defineProperty,f=i((n,e)=>ki(n,"name",{value:e,configurable:!0}),"n"),Pi={bodySerializer:f(n=>JSON.stringify(n,(e,t)=>typeof t=="bigint"?t.toString():t),"bodySerializer")},Ti={$body_:"body",$headers_:"headers",$path_:"path",$query_:"query"},ql=Object.entries(Ti),_i=f(({onRequest:n,onSseError:e,onSseEvent:t,responseTransformer:r,responseValidator:s,sseDefaultRetryDelay:o,sseMaxRetryAttempts:a,sseMaxRetryDelay:u,sseSleepFn:l,url:c,...p})=>{let d,v=l??(y=>new Promise(k=>setTimeout(k,y)));return{stream:f(async function*(){let y=o??3e3,k=0,m=p.signal??new AbortController().signal;for(;!m.aborted;){k++;let A=p.headers instanceof Headers?p.headers:new Headers(p.headers);d!==void 0&&A.set("Last-Event-ID",d);try{let L={redirect:"follow",...p,body:p.serializedBody,headers:A,signal:m},R=new Request(c,L);n&&(R=await n(c,L));let z=await(p.fetch??globalThis.fetch)(R);if(!z.ok)throw new Error(`SSE failed: ${z.status} ${z.statusText}`);if(!z.body)throw new Error("No body in SSE response");let w=z.body.pipeThrough(new TextDecoderStream).getReader(),g="",T=f(()=>{try{w.cancel()}catch{}},"abortHandler");m.addEventListener("abort",T);try{for(;;){let{done:_,value:ve}=await w.read();if(_)break;g+=ve;let Qt=g.split(`
390
456
 
391
- `);y=L.pop()??"";for(let M of L){let j=M.split(`
392
- `),J=[],de;for(let N of j)if(N.startsWith("data:"))J.push(N.replace(/^data:\s*/,""));else if(N.startsWith("event:"))de=N.replace(/^event:\s*/,"");else if(N.startsWith("id:"))h=N.replace(/^id:\s*/,"");else if(N.startsWith("retry:")){let mt=Number.parseInt(N.replace(/^retry:\s*/,""),10);Number.isNaN(mt)||(m=mt)}let X,ft=!1;if(J.length){let N=J.join(`
393
- `);try{X=JSON.parse(N),ft=!0}catch{X=N}}ft&&(a&&await a(X),n&&(X=await n(X))),r?.({data:X,event:de,id:h,retry:m}),J.length&&(yield X)}}}finally{g.removeEventListener("abort",w),U.releaseLock()}break}catch(P){if(e?.(P),s!==void 0&&I>=s)break;let T=Math.min(m*2**(I-1),c??3e4);await C(T)}}},"createStream")()}},"createSseClient"),En=u(t=>{switch(t){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorArrayExplode"),Sn=u(t=>{switch(t){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},"separatorArrayNoExplode"),An=u(t=>{switch(t){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorObjectExplode"),vr=u(({allowReserved:t,explode:e,name:r,style:n,value:a})=>{if(!e){let c=(t?a:a.map(l=>encodeURIComponent(l))).join(Sn(n));switch(n){case"label":return`.${c}`;case"matrix":return`;${r}=${c}`;case"simple":return c;default:return`${r}=${c}`}}let i=En(n),s=a.map(c=>n==="label"||n==="simple"?t?c:encodeURIComponent(c):Ee({allowReserved:t,name:r,value:c})).join(i);return n==="label"||n==="matrix"?i+s:s},"serializeArrayParam"),Ee=u(({allowReserved:t,name:e,value:r})=>{if(r==null)return"";if(typeof r=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${e}=${t?r:encodeURIComponent(r)}`},"serializePrimitiveParam"),Cr=u(({allowReserved:t,explode:e,name:r,style:n,value:a,valueOnly:i})=>{if(a instanceof Date)return i?a.toISOString():`${r}=${a.toISOString()}`;if(n!=="deepObject"&&!e){let l=[];Object.entries(a).forEach(([d,h])=>{l=[...l,d,t?h:encodeURIComponent(h)]});let p=l.join(",");switch(n){case"form":return`${r}=${p}`;case"label":return`.${p}`;case"matrix":return`;${r}=${p}`;default:return p}}let s=An(n),c=Object.entries(a).map(([l,p])=>Ee({allowReserved:t,name:n==="deepObject"?`${r}[${l}]`:l,value:p})).join(s);return n==="label"||n==="matrix"?s+c:c},"serializeObjectParam"),Rn=/\{[^{}]+\}/g,Tn=u(({path:t,url:e})=>{let r=e,n=e.match(Rn);if(n)for(let a of n){let i=!1,s=a.substring(1,a.length-1),c="simple";s.endsWith("*")&&(i=!0,s=s.substring(0,s.length-1)),s.startsWith(".")?(s=s.substring(1),c="label"):s.startsWith(";")&&(s=s.substring(1),c="matrix");let l=t[s];if(l==null)continue;if(Array.isArray(l)){r=r.replace(a,vr({explode:i,name:s,style:c,value:l}));continue}if(typeof l=="object"){r=r.replace(a,Cr({explode:i,name:s,style:c,value:l,valueOnly:!0}));continue}if(c==="matrix"){r=r.replace(a,`;${Ee({name:s,value:l})}`);continue}let p=encodeURIComponent(c==="label"?`.${l}`:l);r=r.replace(a,p)}return r},"defaultPathSerializer"),Pn=u(({baseUrl:t,path:e,query:r,querySerializer:n,url:a})=>{let i=a.startsWith("/")?a:`/${a}`,s=(t??"")+i;e&&(s=Tn({path:e,url:s}));let c=r?n(r):"";return c.startsWith("?")&&(c=c.substring(1)),c&&(s+=`?${c}`),s},"getUrl");function wr(t){let e=t.body!==void 0;if(e&&t.bodySerializer)return"serializedBody"in t?t.serializedBody!==void 0&&t.serializedBody!==""?t.serializedBody:null:t.body!==""?t.body:null;if(e)return t.body}o(wr,"G");u(wr,"getValidRequestBody");var Dn=u(async(t,e)=>{let r=typeof e=="function"?await e(t):e;if(r)return t.scheme==="bearer"?`Bearer ${r}`:t.scheme==="basic"?`Basic ${btoa(r)}`:r},"getAuthToken"),Ir=u(({allowReserved:t,array:e,object:r}={})=>u(n=>{let a=[];if(n&&typeof n=="object")for(let i in n){let s=n[i];if(s!=null)if(Array.isArray(s)){let c=vr({allowReserved:t,explode:!0,name:i,style:"form",value:s,...e});c&&a.push(c)}else if(typeof s=="object"){let c=Cr({allowReserved:t,explode:!0,name:i,style:"deepObject",value:s,...r});c&&a.push(c)}else{let c=Ee({allowReserved:t,name:i,value:s});c&&a.push(c)}}return a.join("&")},"querySerializer"),"createQuerySerializer"),xn=u(t=>{var e;if(!t)return"stream";let r=(e=t.split(";")[0])==null?void 0:e.trim();if(r){if(r.startsWith("application/json")||r.endsWith("+json"))return"json";if(r==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some(n=>r.startsWith(n)))return"blob";if(r.startsWith("text/"))return"text"}},"getParseAs"),_n=u((t,e)=>{var r,n;return e?!!(t.headers.has(e)||(r=t.query)!=null&&r[e]||(n=t.headers.get("Cookie"))!=null&&n.includes(`${e}=`)):!1},"checkForExistence"),Ln=u(async({security:t,...e})=>{for(let r of t){if(_n(e,r.name))continue;let n=await Dn(r,e.auth);if(!n)continue;let a=r.name??"Authorization";switch(r.in){case"query":e.query||(e.query={}),e.query[a]=n;break;case"cookie":e.headers.append("Cookie",`${a}=${n}`);break;case"header":default:e.headers.set(a,n);break}}},"setAuthParams"),yr=u(t=>Pn({baseUrl:t.baseUrl,path:t.path,query:t.query,querySerializer:typeof t.querySerializer=="function"?t.querySerializer:Ir(t.querySerializer),url:t.url}),"buildUrl"),gr=u((t,e)=>{var r;let n={...t,...e};return(r=n.baseUrl)!=null&&r.endsWith("/")&&(n.baseUrl=n.baseUrl.substring(0,n.baseUrl.length-1)),n.headers=br(t.headers,e.headers),n},"mergeConfigs"),On=u(t=>{let e=[];return t.forEach((r,n)=>{e.push([n,r])}),e},"headersEntries"),br=u((...t)=>{let e=new Headers;for(let r of t){if(!r)continue;let n=r instanceof Headers?On(r):Object.entries(r);for(let[a,i]of n)if(i===null)e.delete(a);else if(Array.isArray(i))for(let s of i)e.append(a,s);else i!==void 0&&e.set(a,typeof i=="object"?JSON.stringify(i):i)}return e},"mergeHeaders"),Er=class{static{o(this,"$")}constructor(){this.fns=[]}clear(){this.fns=[]}eject(e){let r=this.getInterceptorIndex(e);this.fns[r]&&(this.fns[r]=null)}exists(e){let r=this.getInterceptorIndex(e);return!!this.fns[r]}getInterceptorIndex(e){return typeof e=="number"?this.fns[e]?e:-1:this.fns.indexOf(e)}update(e,r){let n=this.getInterceptorIndex(e);return this.fns[n]?(this.fns[n]=r,e):!1}use(e){return this.fns.push(e),this.fns.length-1}};u(Er,"Interceptors");var it=Er,$n=u(()=>({error:new it,request:new it,response:new it}),"createInterceptors"),Vn=Ir({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),Un={"Content-Type":"application/json"},st=u((t={})=>({...wn,headers:Un,parseAs:"auto",querySerializer:Vn,...t}),"createConfig"),Sr=u((t={})=>{let e=gr(st(),t),r=u(()=>({...e}),"getConfig"),n=u(p=>(e=gr(e,p),r()),"setConfig"),a=$n(),i=u(async p=>{let d={...e,...p,fetch:p.fetch??e.fetch??globalThis.fetch,headers:br(e.headers,p.headers),serializedBody:void 0};d.security&&await Ln({...d,security:d.security}),d.requestValidator&&await d.requestValidator(d),d.body!==void 0&&d.bodySerializer&&(d.serializedBody=d.bodySerializer(d.body)),(d.body===void 0||d.serializedBody==="")&&d.headers.delete("Content-Type");let h=yr(d);return{opts:d,url:h}},"beforeRequest"),s=u(async p=>{let{opts:d,url:h}=await i(p),C={redirect:"follow",...d,body:wr(d)},m=new Request(h,C);for(let y of a.request.fns)y&&(m=await y(m,d));let I=d.fetch,g=await I(m);for(let y of a.response.fns)y&&(g=await y(g,m,d));let A={request:m,response:g};if(g.ok){let y=(d.parseAs==="auto"?xn(g.headers.get("Content-Type")):d.parseAs)??"json";if(g.status===204||g.headers.get("Content-Length")==="0"){let E;switch(y){case"arrayBuffer":case"blob":case"text":E=await g[y]();break;case"formData":E=new FormData;break;case"stream":E=g.body;break;case"json":default:E={};break}return d.responseStyle==="data"?E:{data:E,...A}}let w;switch(y){case"arrayBuffer":case"blob":case"formData":case"json":case"text":w=await g[y]();break;case"stream":return d.responseStyle==="data"?g.body:{data:g.body,...A}}return y==="json"&&(d.responseValidator&&await d.responseValidator(w),d.responseTransformer&&(w=await d.responseTransformer(w))),d.responseStyle==="data"?w:{data:w,...A}}let P=await g.text(),T;try{T=JSON.parse(P)}catch{}let _=T??P,U=_;for(let y of a.error.fns)y&&(U=await y(_,g,m,d));if(U=U||{},d.throwOnError)throw U;return d.responseStyle==="data"?void 0:{error:U,...A}},"request"),c=u(p=>d=>s({...d,method:p}),"makeMethodFn"),l=u(p=>async d=>{let{opts:h,url:C}=await i(d);return bn({...h,body:h.body,headers:h.headers,method:p,onRequest:u(async(m,I)=>{let g=new Request(m,I);for(let A of a.request.fns)A&&(g=await A(g,h));return g},"onRequest"),url:C})},"makeSseFn");return{buildUrl:yr,connect:c("CONNECT"),delete:c("DELETE"),get:c("GET"),getConfig:r,head:c("HEAD"),interceptors:a,options:c("OPTIONS"),patch:c("PATCH"),post:c("POST"),put:c("PUT"),request:s,setConfig:n,sse:{connect:l("CONNECT"),delete:l("DELETE"),get:l("GET"),head:l("HEAD"),options:l("OPTIONS"),patch:l("PATCH"),post:l("POST"),put:l("PUT"),trace:l("TRACE")},trace:c("TRACE")}},"createClient"),S=Sr(st({baseUrl:"https://swish.app/api/2025-10"})),Nn=u(t=>(t?.client??S).get({security:[{scheme:"bearer",type:"http"}],url:"/lists",...t}),"listControllerFind"),qn=u(t=>(t.client??S).post({security:[{scheme:"bearer",type:"http"}],url:"/lists",...t,headers:{"Content-Type":"application/json",...t.headers}}),"listControllerCreate"),Bn=u(t=>(t.client??S).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...t}),"listControllerDeleteById"),Gn=u(t=>(t.client??S).get({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...t}),"listControllerFindById"),Hn=u(t=>(t.client??S).patch({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...t,headers:{"Content-Type":"application/json",...t.headers}}),"listControllerUpdateById"),Mn=u(t=>(t.client??S).put({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/order",...t,headers:{"Content-Type":"application/json",...t.headers}}),"listControllerSetListItemsOrder"),Fn=u(t=>(t.client??S).post({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items",...t,headers:{"Content-Type":"application/json",...t.headers}}),"listControllerAddItemsToList"),kn=u(t=>(t.client??S).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/{itemId}",...t}),"listControllerRemoveItemFromList"),jn=u(t=>(t.client??S).delete({security:[{scheme:"bearer",type:"http"}],url:"/items",...t,headers:{"Content-Type":"application/json",...t.headers}}),"itemControllerDelete"),Qn=u(t=>(t?.client??S).get({security:[{scheme:"bearer",type:"http"}],url:"/items",...t}),"itemControllerFind"),zn=u(t=>(t.client??S).post({security:[{scheme:"bearer",type:"http"}],url:"/items",...t,headers:{"Content-Type":"application/json",...t.headers}}),"itemControllerCreate"),Wn=u(t=>(t?.client??S).get({security:[{scheme:"bearer",type:"http"}],url:"/items/count",...t}),"itemControllerCount"),Yn=u(t=>(t.client??S).delete({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...t}),"itemControllerDeleteById"),Kn=u(t=>(t.client??S).get({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...t}),"itemControllerFindById"),Jn=u(t=>(t.client??S).patch({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...t,headers:{"Content-Type":"application/json",...t.headers}}),"itemControllerUpdateById"),Xn=u(t=>(t.client??S).put({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}/lists",...t,headers:{"Content-Type":"application/json",...t.headers}}),"itemControllerSetListsById"),Zn=u(t=>(t?.client??S).get({security:[{scheme:"bearer",type:"http"}],url:"/profiles/accounts-version",...t}),"profileControllerCustomerAccountsVersion"),ea=u(t=>(t.client??S).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/identify",...t,headers:{"Content-Type":"application/json",...t.headers}}),"profileControllerIdentify"),ta=u(t=>(t.client??S).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/token",...t,headers:{"Content-Type":"application/json",...t.headers}}),"profileControllerCreateToken"),Se="2025-10",ra=`https://swish.app/api/${Se}`,Ar=u(t=>new na(t),"createApiClient"),Rr=class{static{o(this,"H")}constructor(e){this.client=Sr(st({baseUrl:ra})),this.items={list:u(r=>this.handlePaginatedRequest(Qn({query:r,client:this.client})),"list"),create:u(r=>this.handleRequest(zn({body:r,client:this.client})),"create"),delete:u(r=>this.handleRequest(jn({body:{itemIds:r},client:this.client})),"delete"),findById:u(r=>this.handleRequest(Kn({path:{itemId:r},client:this.client})),"findById"),updateById:u((r,n)=>this.handleRequest(Jn({body:n,path:{itemId:r},client:this.client})),"updateById"),deleteById:u(r=>this.handleRequest(Yn({path:{itemId:r},client:this.client})),"deleteById"),setListsById:u((r,n)=>this.handleRequest(Xn({body:{listIds:n},path:{itemId:r},client:this.client})),"setListsById"),count:u(()=>this.handleRequest(Wn({client:this.client})),"count")},this.lists={list:u(r=>this.handlePaginatedRequest(Nn({query:r,client:this.client})),"list"),create:u(r=>this.handleRequest(qn({body:r,client:this.client})),"create"),findById:u(r=>this.handleRequest(Gn({path:{listId:r},client:this.client})),"findById"),updateById:u((r,n)=>this.handleRequest(Hn({body:n,path:{listId:r},client:this.client})),"updateById"),deleteById:u(r=>this.handleRequest(Bn({path:{listId:r},client:this.client})),"deleteById"),orderItems:u((r,n)=>this.handleRequest(Mn({body:{itemIds:n},path:{listId:r},client:this.client})),"orderItems"),addItemsToList:u((r,n)=>this.handleRequest(Fn({body:{itemIds:n},path:{listId:r},client:this.client})),"addItemsToList"),removeItemFromList:u((r,n)=>this.handleRequest(kn({path:{listId:r,itemId:n},client:this.client})),"removeItemFromList")},this.profiles={customerAccountsVersion:u(()=>this.handleRequest(Zn({client:this.client})),"customerAccountsVersion"),createToken:u((r={})=>this.handleRequest(ta({body:r,client:this.client})),"createToken"),identify:u(r=>this.handleRequest(ea({body:r,client:this.client})),"identify")},this.handleRequest=u(async r=>{let{data:n,error:a}=await r;return a!=null&&a.error?{error:a.error}:{data:n?.data}},"handleRequest"),this.handlePaginatedRequest=u(async r=>{var n;let{data:a,error:i}=await r;return i!=null&&i.error?{error:i.error}:{data:a?.data??[],pageInfo:a?.pageInfo??{next:null,previous:null,totalCount:((n=a?.data)==null?void 0:n.length)??0}}},"handlePaginatedRequest"),this.profile=e.profile,e.authToken&&(this.authToken=e.authToken),e.config&&this.client.setConfig(e.config),this.client.interceptors.request.use(this.requestInterceptor.bind(this)),e.requestInterceptor&&this.client.interceptors.request.use(e.requestInterceptor),e.responseInterceptor&&this.client.interceptors.response.use(e.responseInterceptor)}setProfile(e){this.profile=e}getProfile(){return this.profile}setAuthToken(e){this.authToken=e}setConfig(e){this.client.setConfig(e)}requestInterceptor(e){return this.authToken&&e.headers.set("Authorization",`Bearer ${this.authToken}`),this.profile&&e.headers.set("Profile",this.profile),e}};u(Rr,"SwishClient");var na=Rr;var xr=Xr(Dr(),1);var _r=o(t=>new xr.default(async e=>{let r=[...new Set(e)].sort((a,i)=>a.localeCompare(i)),n=await t.items.list({query:r.join(" "),limit:200});return"error"in n?(console.error("Failed to load items",n.error),e.map(()=>({data:[],pageInfo:{next:null,previous:null,totalCount:0}}))):e.map(a=>{let i=n.data.find(s=>a===`variant:${s.variantId}`||a===`product:${s.productId}`);return{data:i?[i]:[],pageInfo:{next:null,previous:null,totalCount:i?1:0}}})},{batchScheduleFn:o(e=>setTimeout(e,50),"batchScheduleFn"),cache:!1,maxBatchSize:200}),"createItemsBatchLoader");var Ae=class{static{o(this,"SwishApi")}constructor(e,r){this.config=e,this.cache=new F("swish-api","max-age=60, stale-while-revalidate=3600",r+Se),this.cache.cleanupExpiredEntries().catch(a=>{console.warn("Swish API cache initialization cleanup error:",a)});let n=this.config.loadProfile?.();this.apiClient=Ar({profile:n,config:{...e,fetch:o((a,i)=>(a instanceof Request?a.method:i?.method??"GET")==="GET"?this.cache.fetchWithCache(a,i):fetch(a,i),"fetch")},requestInterceptor:o(async a=>(a.headers.set("Swish-Api-Version",Se),a),"requestInterceptor"),responseInterceptor:o(async(a,i)=>(this.processProfileHeader(a),i.method!=="GET"&&await this.cache.clear(),await this.config.responseInterceptor?.(a,i),a),"responseInterceptor")}),this.itemsLoader=_r(this)}processProfileHeader(e){let r=e.headers.get("Set-Profile");r?(this.apiClient.setProfile(r),this.config.storeProfile?.(r)):r===""&&this.config.deleteProfile?.()}get items(){return{...this.apiClient.items,list:o(async(e,r)=>{if(!f.customer.id&&!this.apiClient.getProfile())return{data:[],pageInfo:{next:null,previous:null,totalCount:0}};if(r?.batch&&e?.query){e.limit!==1&&console.warn("Batching will always limit to 1 item");let n=e.query.split(" ");n.length>1&&console.warn("Batching will only support one query parameter");let a=n[0];if(!a.match(/^product:\d+$/)&&!a.match(/^variant:\d+$/))console.warn("Batching will only support product:<id> or variant:<id>");else return this.itemsLoader?.load(a)}return this.apiClient.items.list(e)},"list"),findById:o(async e=>!f.customer.id&&!this.apiClient.getProfile()?{data:null}:this.apiClient.items.findById(e),"findById")}}get lists(){return{...this.apiClient.lists,list:o(async e=>!f.customer.id&&!this.apiClient.getProfile()?{data:[],pageInfo:{next:null,previous:null,totalCount:0}}:this.apiClient.lists.list(e),"list"),findById:o(async e=>!f.customer.id&&!this.apiClient.getProfile()?{data:null}:this.apiClient.lists.findById(e),"findById")}}get profiles(){return this.apiClient.profiles}async clearCache(){await this.cache.clear()}};var Re=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{o(this,"SwishApiPublisher")}async processFetchResponse(e,r){try{let n=this.getEventName(r.method,e.status,r.url);if(!n)return;let a=await e.clone().text();if(e.headers.get("Content-Type")?.includes("application/json"))try{a=JSON.parse(a).data}catch(i){console.warn(i)}this.eventBus.publish(n,a)}catch(n){console.warn(n)}}getEventName(e,r,n){e=e.toUpperCase();let a=new URL(n).pathname;return e==="GET"||r<200||r>=300?void 0:Object.entries(this.eventMap).find(([s])=>{let[c,l]=s.split(" ");return c!==e?!1:new RegExp(l).test(a)})?.[1]}};var Te=class extends HTMLElement{constructor(){super();this.getComponentRef=o(()=>this.componentRef,"getComponentRef");this.setComponentRef=o(r=>{this.componentRef=r},"setComponentRef");this.shadowRoot||this.attachShadow({mode:"open"});let r=this.querySelector("template");r&&this.shadowRoot&&(this.shadowRoot.appendChild(r.content),r.remove())}static{o(this,"SwishUiElement")}};var ha=".swish-shop-bridge{position:absolute!important;top:0!important;left:0!important;padding:0!important;border:0!important;margin:0!important;pointer-events:none!important}.swish-shop-bridge input{appearance:none!important;border:none!important;width:1px!important;height:1px!important;padding:0!important;margin:0!important;background:rgba(0,0,0,0)!important}",fa=`<form class=swish-shop-bridge data-login-with-shop-sign-in=true id=customer_login><input name=customer[email] id=customer_login_email> <input name=return_url type=hidden value=${window.location.pathname}></form>`,ut=class extends HTMLElement{constructor(){super();this.swish=window.swish;this.emailInput=this.querySelector('form[data-login-with-shop-sign-in] input[type="email"],form[data-login-with-shop-sign-in] input[name="customer[email]"'),this.emailInput||(this.innerHTML=`
394
- <style>${ha}</style>
395
- ${fa}
396
- `,this.emailInput=this.querySelector("#customer_login_email")),this.shopModalObserver=new MutationObserver(r=>{r.forEach(n=>{n.attributeName==="style"&&document.documentElement.style.overflow==="hidden"&&this.dispatchEvent(new CustomEvent("shop-modal-open"))})}),this.shopModalObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["style"]})}static{o(this,"ShopBridge")}disconnectedCallback(){this.shopModalObserver?.disconnect()}async load(){try{(window.Shopify?.featureAssets?.["shop-js"]?.["init-customer-accounts"]?.[0]??"").includes("init-customer-accounts")&&(await Promise.all(window.Shopify?.featureAssets?.["shop-js"]?.["init-customer-accounts"]?.map(n=>import(`/cdn/shopifycloud/shop-js/${n}`))??[]),window.Shopify?.SignInWithShop?.initCustomerAccounts?.(!0,{fedCMEnabled:!0,windoidEnabled:!1}))}catch(r){console.warn("Failed to initialize Shop JS",r)}}update(r){if(r.email&&(this.emailInput.value=r.email,this.emailInput.dispatchEvent(new Event("input"))),r.returnTo){let n=this.querySelector("input[name='return_url']");n&&(n.value=r.returnTo)}}};customElements.define("swish-shop-bridge",ut);var ae={baseUrl:"/apps/wishlist",version:"0.0.0"},Pe,De,xe,Or=o(t=>{ae=t},"setConfig"),Y=new Map,$r=o(async t=>{if(Y.has(t))return Y.get(t);let e=(async()=>{typeof t=="string"&&(t=await V(t)),!(!t||t.getAttribute("open")!=="true")&&t.setAttribute("open","false")})().finally(()=>{Y.delete(t)});return va(),Y.set(t,e),e},"hideModal"),G=o(async t=>{if(Y.has(t))return Y.get(t);let e=(async()=>{typeof t=="string"&&(t=await V(t)),!(!t||t.getAttribute("open")==="true")&&t.setAttribute("open","true")})().finally(()=>{Y.delete(t)});return ga(),Y.set(t,e),e},"showModal"),Vr=o(async t=>{let e=await V("sign-in");e.setAttribute("return-to",t?.returnTo??window.location.pathname),await G(e)},"showSignIn"),Ur=o(async t=>{if(!t.itemId)throw new Error("An itemId is required to show the unsave alert");K();let e=await V("unsave-alert",{listeners:{submit:o(r=>{r instanceof CustomEvent?t.onSubmit?.(r.detail):console.warn("Unsave alert submitted without detail",r)},"submit"),cancel:o(()=>{t.onCancel?.()},"cancel")}});e.setAttribute("item-id",t.itemId),await G(e)},"showUnsaveAlert"),Nr=o(async t=>{if(!t.listId)throw new Error("A listId is required to show the delete list alert");K();let e=await V("delete-list-alert",{listeners:{submit:o(()=>{t.onSubmit?.()},"submit"),cancel:o(()=>{t.onCancel?.()},"cancel")}});e.setAttribute("list-id",t.listId),await G(e)},"showDeleteListAlert"),qr=o(async()=>{K();let t=await V("drawer");t.setAttribute("account-url",f.routes.accountUrl),f.customer.id&&t.setAttribute("customer-id",f.customer.id),await G(t)},"showDrawer"),Br=o(async t=>{if(!t.listId)throw new Error("listId is required");K();let e=await V("list-menu",{listeners:{close:o(r=>{"detail"in r&&r.detail?t.onClose?.(r.detail):(console.warn("List menu closed without detail",r),t.onClose?.({reason:"unknown"}))},"close")}});e.setAttribute("list-id",t.listId),await G(e)},"showListMenu"),Gr=o(async t=>{if(!t.itemId)throw new Error("itemId is required");K();let e=await V("list-select",{listeners:{submit:o(async r=>{"detail"in r&&r.detail?t?.onSubmit?.(r.detail):console.warn("List select form submitted without detail",r)},"submit"),close:o(()=>{t.onClose?.()},"close"),unsave:o(r=>{r instanceof CustomEvent?t.onUnsave?.(r.detail):console.warn("List select unsave without detail",r)},"unsave")}});e.setAttribute("item-id",t.itemId),await G(e)},"showListSelect"),Hr=o(async t=>{await V("toast-manager",{onHydrated:o(e=>{e.current.show(t)},"onHydrated")})},"showToast"),K=o(async()=>{pt("toast-manager")&&await V("toast-manager",{onHydrated:o(t=>{t.current.clear()},"onHydrated")})},"hideAllToasts"),Mr=o(async t=>{K();let e=await V("variant-select",{listeners:{submit:o(async r=>{"detail"in r&&r.detail?t?.onSubmit?.(r.detail):console.warn("Variant select form submitted without detail",r)},"submit")}});if(t?.productId)e.setAttribute("product-id",t.productId);else if(t?.productHandle)e.setAttribute("product-handle",t.productHandle);else throw new Error("Either productId or productHandle must be provided");t?.variantId&&e.setAttribute("variant-id",t.variantId),t?.action&&e.setAttribute("action",t.action),t?.displayType&&e.setAttribute("display-type",t.displayType),await G(e)},"showVariantSelect"),Fr=o(async t=>{let e=await V("list-editor",{listeners:{submit:o(async r=>{"detail"in r&&r.detail?t?.onSubmit?.(r.detail):console.warn("List editor form submitted without detail",r)},"submit")}});t?.listId&&e.setAttribute("list-id",t.listId),await G(e)},"showListEditor"),kr=o(async({onShopModalOpen:t})=>{let e=document.querySelector("swish-shop-bridge");if(e||(document.body.insertAdjacentHTML("beforeend","<swish-shop-bridge></swish-shop-bridge>"),e=document.querySelector("swish-shop-bridge")),!e)throw new Error("Failed to initialize Shop Bridge");return e.addEventListener("shop-modal-open",()=>t(),{once:!0}),await e.load(),e},"initShopBridge"),le=o(async()=>xe||(xe=fetch(`${ae?.baseUrl??""}/ui@${ae.version}/manifest.json`).then(t=>t.json()),xe),"loadManifest"),Lr=new Map,V=o(async(t,e)=>{let r=await le(),n=r.prerender[t],a=`${ae?.baseUrl??""}/ui@${ae?.version}/${r.scripts[t]}`,i=e?.instance,s=e?.listeners,c=pt(t,i)??await ya({name:t,template:n,refElement:document.body,position:"beforeend",instance:i});c.shadowRoot&&!c.hasAttribute("hydrated")?Promise.all([ma(),import(a)]).then(([l,{hydrate:p}])=>{c.shadowRoot&&l&&(c.shadowRoot.adoptedStyleSheets=[...c.shadowRoot.adoptedStyleSheets,l]),p(c),c.setAttribute("hydrated",""),e?.onHydrated?.(c.getComponentRef())}):c.hasAttribute("hydrated")&&e?.onHydrated?.(c.getComponentRef());for(let{event:l,listener:p}of Lr.values())c.removeEventListener(l,p);for(let[l,p]of Object.entries(s??{}))Lr.set(`${t}-${i}-${l}`,{event:l,listener:p}),c.addEventListener(l,p);return c},"requireUiComponent");async function ma(){return De||(De=new Promise((t,e)=>le().then(r=>r.stylesheets.nonCritical?fetch(`${ae?.baseUrl??""}/ui@${ae?.version}/${r.stylesheets.nonCritical}`):new Response("")).then(r=>r.text()).then(r=>{let n=new CSSStyleSheet;n.replaceSync(r),t(n)}).catch(e)),De)}o(ma,"loadNonCriticalStylesheet");var ya=o(async({name:t,instance:e,template:r,position:n,refElement:a})=>{a.insertAdjacentHTML(n,r.replace(' shadowrootmode="open"',""));let i=pt(t,e);if(!i)throw new Error(`Element ${t} not found in DOM`);if(!Pe){let s=await le();Pe=new CSSStyleSheet,Pe.replaceSync(s.css.critical)}return i.shadowRoot&&(i.shadowRoot.adoptedStyleSheets=[Pe]),i},"insertComponent"),pt=o((t,e)=>{let r=`swish-ui[ref="${t}${e?`-${e}`:""}"]`;return document.querySelector(r)},"queryComponent"),ie,ce=0,_e=0,ga=o(()=>{ce++,ce===1&&(_e=window.scrollY,ie||(ie=new CSSStyleSheet,document.adoptedStyleSheets=[...document.adoptedStyleSheets,ie]),ie.replaceSync(`
397
- html[locked] body {
398
- overflow: hidden;
399
- position: fixed;
400
- top: -${_e}px;
401
- left: 0px;
402
- right: 0px;
403
- }
404
- `),document.documentElement.setAttribute("locked",""))},"lockScroll"),va=o(()=>{ce>0&&ce--,ce===0&&(ie&&ie.replaceSync(""),window.scrollTo({top:_e,behavior:"instant"}),_e=0,document.documentElement.removeAttribute("locked"))},"unlockScroll");typeof requestIdleCallback=="function"?requestIdleCallback(()=>{le()}):setTimeout(()=>{le()},1e3);var Ca="0.55.0",f={customer:{id:null,email:null,firstName:null,lastName:null,b2b:null},localization:{country:"",language:"",market:0},routes:{accountUrl:"/account",accountLoginUrl:"/account/login",rootUrl:"/"}},Gs=o(async t=>{if(typeof window>"u")throw new Error("Swish is not supported in this environment");if(window.swish)return window.swish;try{let n=localStorage.getItem("wk_session_id");n&&(localStorage.setItem("swish-profile",`gid://swish/Session/${n}`),localStorage.removeItem("wk_session_id"))}catch(n){console.warn("Failed to migrate legacy session id to Swish profile",{cause:n})}try{let n=document.getElementById("swishEmbedData");if(!n)throw new Error("Swish embed data not found");Object.assign(f,JSON.parse(n.innerText))}catch(n){console.warn("Could not read Swish embed data.",{cause:n})}let e=t.proxy?.baseUrl??"/apps/wishlist",r=new ht({loadProfile:o(()=>localStorage.getItem("swish-profile")??void 0,"loadProfile"),storeProfile:o(n=>localStorage.setItem("swish-profile",n),"storeProfile"),deleteProfile:o(()=>localStorage.removeItem("swish-profile"),"deleteProfile"),proxy:{baseUrl:e},ui:t.ui,storefront:t.storefront});try{let n=localStorage.getItem("swish-profile");n&&f.customer.id?await r.api.clearCache():!n&&!f.customer.id&&await r.api.clearCache()}catch(n){console.warn("Could not check if customer logged out.",{cause:n})}return window.swish=r,document.dispatchEvent(new Event("swish-ready")),r},"swishApp"),ht=class{constructor(e){this.ui={showSignIn:Vr,showVariantSelect:Mr,initShopBridge:kr,showToast:Hr,hideAllToasts:K,showListSelect:Gr,showDrawer:qr,showListEditor:Fr,showUnsaveAlert:Ur,hideModal:$r,showModal:G,showListMenu:Br,showDeleteListAlert:Nr};this.dom={createElementLocator:gt,createQueryParamsObserver:he};this.state={itemContext:Rt(this),itemState:Tt(this),itemCount:Pt(this),swishQuery:Dt(this),effect:$,signal:b};this.options=e,this.events=new fe;let r={baseUrl:`${this.options.proxy.baseUrl}/api`,...this.options.swishApi??{}};this.swishApiPublisher=new Re(this.events);let n=[Ca,e.ui?.version].join("-");this.swishApi=new Ae({...r,responseInterceptor:this.swishApiPublisher.processFetchResponse,loadProfile:e.loadProfile,storeProfile:e.storeProfile,deleteProfile:e.deleteProfile},n),this.ajaxApiPublisher=new pe(this.events),this.ajaxApi=new ue({storeDomain:this.options.storefront.storeDomain,responseInterceptor:this.ajaxApiPublisher.processFetchResponse}),this.storefrontApi=new be(this.options.storefront),this.options.ui&&Or(this.options.ui),this.events.subscribe(["cart-add","cart-update","cart-change","cart-clear"],()=>{this.ajaxApi.clearCache()}),customElements.get("swish-ui")||customElements.define("swish-ui",Te)}static{o(this,"SwishApp")}get customer(){return f.customer}get localization(){return f.localization}get shopifyRoutes(){return f.routes}get api(){return this.swishApi}get storefront(){return this.storefrontApi}get ajax(){return this.ajaxApi}get shopUrl(){return`https://${this.options.storefront.storeDomain}`}};export{ht as SwishApp,Ca as VERSION,Gs as swishApp,f as swishEmbedData};
457
+ `);g=Qt.pop()??"";for(let Pr of Qt){let Tr=Pr.split(`
458
+ `),Ee=[],zt;for(let F of Tr)if(F.startsWith("data:"))Ee.push(F.replace(/^data:\s*/,""));else if(F.startsWith("event:"))zt=F.replace(/^event:\s*/,"");else if(F.startsWith("id:"))d=F.replace(/^id:\s*/,"");else if(F.startsWith("retry:")){let Xt=Number.parseInt(F.replace(/^retry:\s*/,""),10);Number.isNaN(Xt)||(y=Xt)}let ne,Wt=!1;if(Ee.length){let F=Ee.join(`
459
+ `);try{ne=JSON.parse(F),Wt=!0}catch{ne=F}}Wt&&(s&&await s(ne),r&&(ne=await r(ne))),t?.({data:ne,event:zt,id:d,retry:y}),Ee.length&&(yield ne)}}}finally{m.removeEventListener("abort",T),w.releaseLock()}break}catch(L){if(e?.(L),a!==void 0&&k>=a)break;let R=Math.min(y*2**(k-1),u??3e4);await v(R)}}},"createStream")()}},"createSseClient"),Oi=f(n=>{switch(n){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorArrayExplode"),$i=f(n=>{switch(n){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},"separatorArrayNoExplode"),Li=f(n=>{switch(n){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorObjectExplode"),mr=f(({allowReserved:n,explode:e,name:t,style:r,value:s})=>{if(!e){let u=(n?s:s.map(l=>encodeURIComponent(l))).join($i(r));switch(r){case"label":return`.${u}`;case"matrix":return`;${t}=${u}`;case"simple":return u;default:return`${t}=${u}`}}let o=Oi(r),a=s.map(u=>r==="label"||r==="simple"?n?u:encodeURIComponent(u):Ze({allowReserved:n,name:t,value:u})).join(o);return r==="label"||r==="matrix"?o+a:a},"serializeArrayParam"),Ze=f(({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"),vr=f(({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 l=[];Object.entries(s).forEach(([p,d])=>{l=[...l,p,n?d:encodeURIComponent(d)]});let c=l.join(",");switch(r){case"form":return`${t}=${c}`;case"label":return`.${c}`;case"matrix":return`;${t}=${c}`;default:return c}}let a=Li(r),u=Object.entries(s).map(([l,c])=>Ze({allowReserved:n,name:r==="deepObject"?`${t}[${l}]`:l,value:c})).join(a);return r==="label"||r==="matrix"?a+u:u},"serializeObjectParam"),Vi=/\{[^{}]+\}/g,qi=f(({path:n,url:e})=>{let t=e,r=e.match(Vi);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 l=n[a];if(l==null)continue;if(Array.isArray(l)){t=t.replace(s,mr({explode:o,name:a,style:u,value:l}));continue}if(typeof l=="object"){t=t.replace(s,vr({explode:o,name:a,style:u,value:l,valueOnly:!0}));continue}if(u==="matrix"){t=t.replace(s,`;${Ze({name:a,value:l})}`);continue}let c=encodeURIComponent(u==="label"?`.${l}`:l);t=t.replace(s,c)}return t},"defaultPathSerializer"),Ni=f(({baseUrl:n,path:e,query:t,querySerializer:r,url:s})=>{let o=s.startsWith("/")?s:`/${s}`,a=(n??"")+o;e&&(a=qi({path:e,url:a}));let u=t?r(t):"";return u.startsWith("?")&&(u=u.substring(1)),u&&(a+=`?${u}`),a},"getUrl");function gr(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(gr,"G");f(gr,"getValidRequestBody");var Bi=f(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"),Ir=f(({allowReserved:n,array:e,object:t}={})=>f(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=mr({allowReserved:n,explode:!0,name:o,style:"form",value:a,...e});u&&s.push(u)}else if(typeof a=="object"){let u=vr({allowReserved:n,explode:!0,name:o,style:"deepObject",value:a,...t});u&&s.push(u)}else{let u=Ze({allowReserved:n,name:o,value:a});u&&s.push(u)}}return s.join("&")},"querySerializer"),"createQuerySerializer"),Gi=f(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"),ji=f((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"),Ui=f(async({security:n,...e})=>{for(let t of n){if(ji(e,t.name))continue;let r=await Bi(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"),hr=f(n=>Ni({baseUrl:n.baseUrl,path:n.path,query:n.query,querySerializer:typeof n.querySerializer=="function"?n.querySerializer:Ir(n.querySerializer),url:n.url}),"buildUrl"),yr=f((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=br(n.headers,e.headers),r},"mergeConfigs"),Mi=f(n=>{let e=[];return n.forEach((t,r)=>{e.push([r,t])}),e},"headersEntries"),br=f((...n)=>{let e=new Headers;for(let t of n){if(!t)continue;let r=t instanceof Headers?Mi(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"),wr=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}};f(wr,"Interceptors");var Gt=wr,Hi=f(()=>({error:new Gt,request:new Gt,response:new Gt}),"createInterceptors"),Fi=Ir({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),Qi={"Content-Type":"application/json"},jt=f((n={})=>({...Pi,headers:Qi,parseAs:"auto",querySerializer:Fi,...n}),"createConfig"),Er=f((n={})=>{let e=yr(jt(),n),t=f(()=>({...e}),"getConfig"),r=f(c=>(e=yr(e,c),t()),"setConfig"),s=Hi(),o=f(async c=>{let p={...e,...c,fetch:c.fetch??e.fetch??globalThis.fetch,headers:br(e.headers,c.headers),serializedBody:void 0};p.security&&await Ui({...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 d=hr(p);return{opts:p,url:d}},"beforeRequest"),a=f(async c=>{let{opts:p,url:d}=await o(c),v={redirect:"follow",...p,body:gr(p)},y=new Request(d,v);for(let g of s.request.fns)g&&(y=await g(y,p));let k=p.fetch,m=await k(y);for(let g of s.response.fns)g&&(m=await g(m,y,p));let A={request:y,response:m};if(m.ok){let g=(p.parseAs==="auto"?Gi(m.headers.get("Content-Type")):p.parseAs)??"json";if(m.status===204||m.headers.get("Content-Length")==="0"){let _;switch(g){case"arrayBuffer":case"blob":case"text":_=await m[g]();break;case"formData":_=new FormData;break;case"stream":_=m.body;break;case"json":default:_={};break}return p.responseStyle==="data"?_:{data:_,...A}}let T;switch(g){case"arrayBuffer":case"blob":case"formData":case"json":case"text":T=await m[g]();break;case"stream":return p.responseStyle==="data"?m.body:{data:m.body,...A}}return g==="json"&&(p.responseValidator&&await p.responseValidator(T),p.responseTransformer&&(T=await p.responseTransformer(T))),p.responseStyle==="data"?T:{data:T,...A}}let L=await m.text(),R;try{R=JSON.parse(L)}catch{}let z=R??L,w=z;for(let g of s.error.fns)g&&(w=await g(z,m,y,p));if(w=w||{},p.throwOnError)throw w;return p.responseStyle==="data"?void 0:{error:w,...A}},"request"),u=f(c=>p=>a({...p,method:c}),"makeMethodFn"),l=f(c=>async p=>{let{opts:d,url:v}=await o(p);return _i({...d,body:d.body,headers:d.headers,method:c,onRequest:f(async(y,k)=>{let m=new Request(y,k);for(let A of s.request.fns)A&&(m=await A(m,d));return m},"onRequest"),url:v})},"makeSseFn");return{buildUrl:hr,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:l("CONNECT"),delete:l("DELETE"),get:l("GET"),head:l("HEAD"),options:l("OPTIONS"),patch:l("PATCH"),post:l("POST"),put:l("PUT"),trace:l("TRACE")},trace:u("TRACE")}},"createClient"),D=Er(jt({baseUrl:"https://swish.app/api/2025-10"})),zi=f(n=>(n?.client??D).get({security:[{scheme:"bearer",type:"http"}],url:"/lists",...n}),"listControllerFind"),Wi=f(n=>(n.client??D).post({security:[{scheme:"bearer",type:"http"}],url:"/lists",...n,headers:{"Content-Type":"application/json",...n.headers}}),"listControllerCreate"),Xi=f(n=>(n.client??D).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...n}),"listControllerDeleteById"),Ki=f(n=>(n.client??D).get({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...n}),"listControllerFindById"),Yi=f(n=>(n.client??D).patch({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...n,headers:{"Content-Type":"application/json",...n.headers}}),"listControllerUpdateById"),Ji=f(n=>(n.client??D).put({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/order",...n,headers:{"Content-Type":"application/json",...n.headers}}),"listControllerSetListItemsOrder"),Zi=f(n=>(n.client??D).post({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items",...n,headers:{"Content-Type":"application/json",...n.headers}}),"listControllerAddItemsToList"),es=f(n=>(n.client??D).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/{itemId}",...n}),"listControllerRemoveItemFromList"),ts=f(n=>(n.client??D).delete({security:[{scheme:"bearer",type:"http"}],url:"/items",...n,headers:{"Content-Type":"application/json",...n.headers}}),"itemControllerDelete"),ns=f(n=>(n?.client??D).get({security:[{scheme:"bearer",type:"http"}],url:"/items",...n}),"itemControllerFind"),rs=f(n=>(n.client??D).post({security:[{scheme:"bearer",type:"http"}],url:"/items",...n,headers:{"Content-Type":"application/json",...n.headers}}),"itemControllerCreate"),is=f(n=>(n?.client??D).get({security:[{scheme:"bearer",type:"http"}],url:"/items/count",...n}),"itemControllerCount"),ss=f(n=>(n.client??D).delete({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...n}),"itemControllerDeleteById"),os=f(n=>(n.client??D).get({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...n}),"itemControllerFindById"),as=f(n=>(n.client??D).patch({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...n,headers:{"Content-Type":"application/json",...n.headers}}),"itemControllerUpdateById"),us=f(n=>(n.client??D).put({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}/lists",...n,headers:{"Content-Type":"application/json",...n.headers}}),"itemControllerSetListsById"),ls=f(n=>(n?.client??D).get({security:[{scheme:"bearer",type:"http"}],url:"/profiles/accounts-version",...n}),"profileControllerCustomerAccountsVersion"),cs=f(n=>(n.client??D).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/identify",...n,headers:{"Content-Type":"application/json",...n.headers}}),"profileControllerIdentify"),ps=f(n=>(n.client??D).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/token",...n,headers:{"Content-Type":"application/json",...n.headers}}),"profileControllerCreateToken"),et="2025-10",fs=`https://swish.app/api/${et}`,Sr=f(n=>new ds(n),"createApiClient"),Cr=class{static{i(this,"H")}constructor(e){this.client=Er(jt({baseUrl:fs})),this.items={list:f(t=>this.handlePaginatedRequest(ns({query:t,client:this.client})),"list"),create:f(t=>this.handleRequest(rs({body:t,client:this.client})),"create"),delete:f(t=>this.handleRequest(ts({body:{itemIds:t},client:this.client})),"delete"),findById:f(t=>this.handleRequest(os({path:{itemId:t},client:this.client})),"findById"),updateById:f((t,r)=>this.handleRequest(as({body:r,path:{itemId:t},client:this.client})),"updateById"),deleteById:f(t=>this.handleRequest(ss({path:{itemId:t},client:this.client})),"deleteById"),setListsById:f((t,r)=>this.handleRequest(us({body:{listIds:r},path:{itemId:t},client:this.client})),"setListsById"),count:f(()=>this.handleRequest(is({client:this.client})),"count")},this.lists={list:f(t=>this.handlePaginatedRequest(zi({query:t,client:this.client})),"list"),create:f(t=>this.handleRequest(Wi({body:t,client:this.client})),"create"),findById:f(t=>this.handleRequest(Ki({path:{listId:t},client:this.client})),"findById"),updateById:f((t,r)=>this.handleRequest(Yi({body:r,path:{listId:t},client:this.client})),"updateById"),deleteById:f(t=>this.handleRequest(Xi({path:{listId:t},client:this.client})),"deleteById"),orderItems:f((t,r)=>this.handleRequest(Ji({body:{itemIds:r},path:{listId:t},client:this.client})),"orderItems"),addItemsToList:f((t,r)=>this.handleRequest(Zi({body:{itemIds:r},path:{listId:t},client:this.client})),"addItemsToList"),removeItemFromList:f((t,r)=>this.handleRequest(es({path:{listId:t,itemId:r},client:this.client})),"removeItemFromList")},this.profiles={customerAccountsVersion:f(()=>this.handleRequest(ls({client:this.client})),"customerAccountsVersion"),createToken:f((t={})=>this.handleRequest(ps({body:t,client:this.client})),"createToken"),identify:f(t=>this.handleRequest(cs({body:t,client:this.client})),"identify")},this.handleRequest=f(async t=>{let{data:r,error:s}=await t;return s!=null&&s.error?{error:s.error}:{data:r?.data}},"handleRequest"),this.handlePaginatedRequest=f(async t=>{var r;let{data:s,error:o}=await t;return o!=null&&o.error?{error:o.error}:{data:s?.data??[],pageInfo:s?.pageInfo??{next:null,previous:null,totalCount:((r=s?.data)==null?void 0:r.length)??0}}},"handlePaginatedRequest"),this.profile=e.profile,e.authToken&&(this.authToken=e.authToken),e.config&&this.client.setConfig(e.config),this.client.interceptors.request.use(this.requestInterceptor.bind(this)),e.requestInterceptor&&this.client.interceptors.request.use(e.requestInterceptor),e.responseInterceptor&&this.client.interceptors.response.use(e.responseInterceptor)}setProfile(e){this.profile=e}getProfile(){return this.profile}setAuthToken(e){this.authToken=e}setConfig(e){this.client.setConfig(e)}requestInterceptor(e){return this.authToken&&e.headers.set("Authorization",`Bearer ${this.authToken}`),this.profile&&e.headers.set("Profile",this.profile),e}};f(Cr,"SwishClient");var ds=Cr;var Rr=Br(Dr(),1);var kr=i(n=>new Rr.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 tt=class{static{i(this,"SwishApi")}constructor(e,t){this.config=e,this.cache=new K("swish-api","max-age=60, stale-while-revalidate=3600",t+et),this.cache.cleanupExpiredEntries().catch(s=>{console.warn("Swish API cache initialization cleanup error:",s)});let r=this.config.loadProfile?.();this.apiClient=Sr({profile:r,config:{...e,fetch:i((s,o)=>(s instanceof Request?s.method:o?.method??"GET")==="GET"?this.cache.fetchWithCache(s,o):fetch(s,o),"fetch")},requestInterceptor:i(async s=>(s.headers.set("Swish-Api-Version",et),s),"requestInterceptor"),responseInterceptor:i(async(s,o)=>(this.processProfileHeader(s),o.method!=="GET"&&await this.cache.clear(),await this.config.responseInterceptor?.(s,o),s),"responseInterceptor")}),this.itemsLoader=kr(this)}processProfileHeader(e){let t=e.headers.get("Set-Profile");t?(this.apiClient.setProfile(t),this.config.storeProfile?.(t)):t===""&&this.config.deleteProfile?.()}get items(){return{...this.apiClient.items,list:i(async(e,t)=>{if(!h.customer.id&&!this.apiClient.getProfile())return{data:[],pageInfo:{next:null,previous:null,totalCount:0}};if(t?.batch&&e?.query){e.limit!==1&&console.warn("Batching will always limit to 1 item");let r=e.query.split(" ");r.length>1&&console.warn("Batching will only support one query parameter");let s=r[0];if(!s.match(/^product:\d+$/)&&!s.match(/^variant:\d+$/))console.warn("Batching will only support product:<id> or variant:<id>");else return this.itemsLoader?.load(s)}return this.apiClient.items.list(e)},"list"),findById:i(async e=>!h.customer.id&&!this.apiClient.getProfile()?{data:null}:this.apiClient.items.findById(e),"findById")}}get lists(){return{...this.apiClient.lists,list:i(async e=>!h.customer.id&&!this.apiClient.getProfile()?{data:[],pageInfo:{next:null,previous:null,totalCount:0}}:this.apiClient.lists.list(e),"list"),findById:i(async e=>!h.customer.id&&!this.apiClient.getProfile()?{data:null}:this.apiClient.lists.findById(e),"findById")}}get profiles(){return this.apiClient.profiles}async clearCache(){await this.cache.clear()}};var nt=class{constructor(e){this.eventMap={"POST /items\\/?$":"item-create","DELETE /items\\/?$":"item-delete","PATCH /items\\/([^/]+)\\/?$":"item-update","DELETE /items\\/([^/]+)\\/?$":"item-delete","PUT /items\\/([^/]+)\\/lists\\/?$":"item-lists-update","POST /lists\\/?$":"list-create","DELETE /lists\\/?$":"list-delete","PATCH /lists\\/([^/]+)\\/?$":"list-update","DELETE /lists\\/([^/]+)\\/?$":"list-delete"};this.eventBus=e,this.processFetchResponse=this.processFetchResponse.bind(this)}static{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,l]=a.split(" ");return u!==e?!1:new RegExp(l).test(s)})?.[1]}};var rt=class extends HTMLElement{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")}};var Ss="0.57.0",h={customer:{id:null,email:null,firstName:null,lastName:null,b2b:null},localization:{country:"",language:"",market:0},routes:{accountUrl:"/account",accountLoginUrl:"/account/login",rootUrl:"/"}},Ec=i(async n=>{if(typeof window>"u")throw new Error("Swish is not supported in this environment");if(window.swish)return window.swish;try{let r=localStorage.getItem("wk_session_id");r&&(localStorage.setItem("swish-profile",`gid://swish/Session/${r}`),localStorage.removeItem("wk_session_id"))}catch(r){console.warn("Failed to migrate legacy session id to Swish profile",{cause:r})}try{let r=document.getElementById("swishEmbedData");if(!r)throw new Error("Swish embed data not found");Object.assign(h,JSON.parse(r.innerText))}catch(r){console.warn("Could not read Swish embed data.",{cause:r})}let e=n.proxy?.baseUrl??"/apps/wishlist",t=new Ft({loadProfile:i(()=>localStorage.getItem("swish-profile")??void 0,"loadProfile"),storeProfile:i(r=>localStorage.setItem("swish-profile",r),"storeProfile"),deleteProfile:i(()=>localStorage.removeItem("swish-profile"),"deleteProfile"),proxy:{baseUrl:e},ui:n.ui,storefront:n.storefront});try{let r=localStorage.getItem("swish-profile");r&&h.customer.id?await t.api.clearCache():!r&&!h.customer.id&&await t.api.clearCache()}catch(r){console.warn("Could not check if customer logged out.",{cause:r})}return window.swish=t,document.dispatchEvent(new Event("swish-ready")),t},"swishApp"),Ft=class{constructor(e){this.ui={hideModal:rn,showModal:Q,initShopBridge:dn,showToast:cn};this.dom={createElementLocator:ge,createQueryParamsObserver:fe};this.state={itemContext:wn(this),itemState:En(this),itemCount:Sn(this),swishQuery:Cn(this),effect:M,signal:x,computed:j};this.options=e,this.events=new xe;let t={baseUrl:`${this.options.proxy.baseUrl}/api`,...this.options.swishApi??{}};this.swishApiPublisher=new nt(this.events);let r=[Ss,e.ui?.version].join("-");this.swishApi=new tt({...t,responseInterceptor:this.swishApiPublisher.processFetchResponse,loadProfile:e.loadProfile,storeProfile:e.storeProfile,deleteProfile:e.deleteProfile},r),this.ajaxApiPublisher=new Ce(this.events),this.ajaxApi=new Se({storeDomain:this.options.storefront.storeDomain,responseInterceptor:this.ajaxApiPublisher.processFetchResponse}),this.storefrontApi=new Je(this.options.storefront),this.options.ui&&nn(this.options.ui),this.events.subscribe(["cart-add","cart-update","cart-change","cart-clear"],()=>{this.ajaxApi.clearCache()}),customElements.get("swish-ui")||customElements.define("swish-ui",rt),this.intents=new He(this,{allowSaveWithoutVariant:!1,deleteSavedItemsWithoutEdit:!1,showToastAfterSave:!0,showToastAfterDelete:!0})}static{i(this,"SwishApp")}get customer(){return h.customer}get localization(){return h.localization}get shopifyRoutes(){return h.routes}get api(){return this.swishApi}get storefront(){return this.storefrontApi}get ajax(){return this.ajaxApi}get shopUrl(){return`https://${this.options.storefront.storeDomain}`}};export{Ft as SwishApp,Ss as VERSION,Ec as swishApp,h as swishEmbedData};