@swishapp/sdk 0.58.0 → 0.60.0-beta.1

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