@occluze/tether 0.9.3 → 0.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/README.md +1 -1
  2. package/dist/esm/astro.js +1 -1
  3. package/dist/esm/chunks/account-2467DHLU.js +1 -0
  4. package/dist/esm/chunks/{account-pages-OZHK5HHY.js → account-pages-X7U3E7D7.js} +1 -1
  5. package/dist/esm/chunks/{analytics-QHX2YHZS.js → analytics-TF7M4KI2.js} +1 -1
  6. package/dist/esm/chunks/{chunk-GCGRUVYO.js → chunk-4QINHHE4.js} +1 -1
  7. package/dist/esm/chunks/chunk-5TS6IBBB.js +1 -0
  8. package/dist/esm/chunks/{chunk-NF5H2Q7V.js → chunk-646NGAEM.js} +1 -1
  9. package/dist/esm/chunks/chunk-67MCLHFS.js +1 -0
  10. package/dist/esm/chunks/{chunk-WHNUPECA.js → chunk-6FWNC7QH.js} +1 -1
  11. package/dist/esm/chunks/{chunk-74SGIWQE.js → chunk-AHYDU7Z6.js} +1 -1
  12. package/dist/esm/chunks/{chunk-A3GZFAB3.js → chunk-B2X6ZOKA.js} +1 -1
  13. package/dist/esm/chunks/chunk-C2GKO34C.js +1 -0
  14. package/dist/esm/chunks/chunk-EYVBEFKK.js +1 -0
  15. package/dist/esm/chunks/{chunk-SOLTIZAI.js → chunk-F3OXGENC.js} +1 -1
  16. package/dist/esm/chunks/{chunk-ZB4FBE6W.js → chunk-HEK66LYK.js} +1 -1
  17. package/dist/esm/chunks/{chunk-RVWHBZAF.js → chunk-I7XE7GQR.js} +1 -1
  18. package/dist/esm/chunks/chunk-KIZBET7N.js +1 -0
  19. package/dist/esm/chunks/chunk-UJYL5G7T.js +1 -0
  20. package/dist/esm/chunks/{chunk-LSB7RVRZ.js → chunk-UM37ZVSP.js} +1 -1
  21. package/dist/esm/chunks/chunk-YW3ZIFWB.js +1 -0
  22. package/dist/esm/chunks/{diagnose-O3QCZTHT.js → diagnose-AOSBLXOJ.js} +1 -1
  23. package/dist/esm/chunks/{extras-O6ZRL5FK.js → extras-THTXX76O.js} +1 -1
  24. package/dist/esm/chunks/lists-UJMD7BCQ.js +1 -0
  25. package/dist/esm/chunks/{markets-ui-V2ROBFZP.js → markets-ui-PTAY3FHU.js} +1 -1
  26. package/dist/esm/chunks/search-G2SRQXDG.js +1 -0
  27. package/dist/esm/index.js +1 -1
  28. package/dist/esm/server.js +1 -1
  29. package/dist/tether.account-pages.js +1 -1
  30. package/dist/tether.account-pages.min.js +1 -1
  31. package/dist/tether.account.js +16 -13
  32. package/dist/tether.account.min.js +1 -1
  33. package/dist/tether.analytics.js +1 -1
  34. package/dist/tether.analytics.min.js +1 -1
  35. package/dist/tether.diagnose.js +1 -1
  36. package/dist/tether.diagnose.min.js +1 -1
  37. package/dist/tether.js +145 -68
  38. package/dist/tether.lists.js +1 -1
  39. package/dist/tether.lists.min.js +1 -1
  40. package/dist/tether.markets.js +1 -1
  41. package/dist/tether.markets.min.js +1 -1
  42. package/dist/tether.min.js +1 -1
  43. package/dist/tether.min.js.map +4 -4
  44. package/dist/tether.search.js +56 -17
  45. package/dist/tether.search.min.js +1 -1
  46. package/dist/types/src/account/server-client.d.ts +2 -1
  47. package/dist/types/src/analytics-queue.d.ts +9 -0
  48. package/dist/types/src/cart/checkout.d.ts +2 -2
  49. package/dist/types/src/cart/drawer.d.ts +9 -4
  50. package/dist/types/src/cart/store.d.ts +2 -0
  51. package/dist/types/src/cart.d.ts +1 -1
  52. package/dist/types/src/client.d.ts +6 -0
  53. package/dist/types/src/dom.d.ts +13 -1
  54. package/dist/types/src/index.d.ts +1 -1
  55. package/dist/types/src/search.d.ts +1 -1
  56. package/dist/types/src/version.d.ts +1 -1
  57. package/package.json +1 -1
  58. package/dist/esm/chunks/account-3MYRPPTR.js +0 -1
  59. package/dist/esm/chunks/chunk-24KD36UC.js +0 -1
  60. package/dist/esm/chunks/chunk-2G6U6ZYV.js +0 -1
  61. package/dist/esm/chunks/chunk-A6BZFYZY.js +0 -1
  62. package/dist/esm/chunks/chunk-EYG7QGPA.js +0 -1
  63. package/dist/esm/chunks/chunk-FX7EJ6RB.js +0 -1
  64. package/dist/esm/chunks/chunk-PZERNTCD.js +0 -1
  65. package/dist/esm/chunks/chunk-SJNNEEDX.js +0 -1
  66. package/dist/esm/chunks/lists-XF33XENI.js +0 -1
  67. package/dist/esm/chunks/search-ZLKIFARH.js +0 -1
@@ -19,7 +19,7 @@
19
19
 
20
20
  // tether-core:client.ts
21
21
  var m2 = window.Tether.__core["client.ts"];
22
- var [endpoint, gql, matches, orNull, shaped, TetherError] = m2;
22
+ var [endpoint, gql, matches, orNull, shaped, TetherError, withTimeout] = m2;
23
23
 
24
24
  // tether-core:dom.ts
25
25
  var m3 = window.Tether.__core["dom.ts"];
@@ -44,6 +44,7 @@
44
44
  var DEFAULT_ACTION = "/search";
45
45
  var mounted = /* @__PURE__ */ new WeakSet();
46
46
  var searchBoxCount = 0;
47
+ var liveBoxes = /* @__PURE__ */ new Set();
47
48
  var linkIn = (node) => node.tagName === "A" ? node : node.querySelector("a");
48
49
  function bindValues(node, values) {
49
50
  qsa(node, sel("search-bind")).forEach((el) => {
@@ -74,6 +75,11 @@
74
75
  __publicField(this, "lastTerm", "");
75
76
  /** Results per term, for typing back and forth. */
76
77
  __publicField(this, "cache", /* @__PURE__ */ new Map());
78
+ /**
79
+ * Removes the box's listeners once its root has left the page. The window's own controller: a page's
80
+ * `addEventListener` takes only its own signals, and in jsdom those aren't Node's.
81
+ */
82
+ __publicField(this, "listening", new window.AbortController());
77
83
  this.root = root;
78
84
  this.input = input;
79
85
  this.results = results;
@@ -86,6 +92,14 @@
86
92
  this.resultsId = results.id;
87
93
  this.setUpAria();
88
94
  this.listen();
95
+ liveBoxes.add(this);
96
+ }
97
+ /** Stops the box whose root a page swap removed; the root mounts afresh if it comes back. */
98
+ stop() {
99
+ this.listening.abort();
100
+ clearTimeout(this.timer);
101
+ liveBoxes.delete(this);
102
+ mounted.delete(this.root);
89
103
  }
90
104
  setUpAria() {
91
105
  this.input.setAttribute("role", "combobox");
@@ -97,22 +111,43 @@
97
111
  this.results.hidden = true;
98
112
  }
99
113
  listen() {
100
- this.input.addEventListener("input", () => {
101
- const term = this.input.value.trim();
102
- if (term === this.lastTerm) return;
103
- this.lastTerm = term;
104
- clearTimeout(this.timer);
105
- this.timer = setTimeout(() => void this.search(term), cfg.searchDelay);
106
- });
107
- this.input.addEventListener("focus", () => {
108
- if (this.input.value.trim().length >= this.minCharacters && this.options().length) this.open(true);
109
- });
110
- this.input.addEventListener("keydown", (event) => {
111
- this.onKeydown(event);
112
- });
113
- document.addEventListener("click", (event) => {
114
- if (!this.root.contains(event.target)) this.open(false);
115
- });
114
+ const { signal } = this.listening;
115
+ this.input.addEventListener(
116
+ "input",
117
+ () => {
118
+ const term = this.input.value.trim();
119
+ if (term === this.lastTerm) return;
120
+ this.lastTerm = term;
121
+ clearTimeout(this.timer);
122
+ this.timer = setTimeout(() => void this.search(term), cfg.searchDelay);
123
+ },
124
+ { signal }
125
+ );
126
+ this.input.addEventListener(
127
+ "focus",
128
+ () => {
129
+ if (this.input.value.trim().length >= this.minCharacters && this.options().length) this.open(true);
130
+ },
131
+ { signal }
132
+ );
133
+ this.input.addEventListener(
134
+ "keydown",
135
+ (event) => {
136
+ this.onKeydown(event);
137
+ },
138
+ { signal }
139
+ );
140
+ document.addEventListener(
141
+ "click",
142
+ (event) => {
143
+ if (!this.root.isConnected) {
144
+ this.stop();
145
+ return;
146
+ }
147
+ if (!this.root.contains(event.target)) this.open(false);
148
+ },
149
+ { signal }
150
+ );
116
151
  }
117
152
  setState(state) {
118
153
  this.root.setAttribute(attr("search-state"), state);
@@ -200,6 +235,7 @@
200
235
  option.id || (option.id = `${this.resultsId}-${index}`);
201
236
  option.setAttribute("aria-selected", "false");
202
237
  });
238
+ this.input.removeAttribute("aria-activedescendant");
203
239
  }
204
240
  highlight(options, index) {
205
241
  options.forEach((option2, optionIndex) => {
@@ -229,6 +265,9 @@
229
265
  }
230
266
  };
231
267
  function mountSearch(root = document) {
268
+ liveBoxes.forEach((box) => {
269
+ if (!box.root.isConnected) box.stop();
270
+ });
232
271
  for (const el of within(root, sel("search"))) {
233
272
  if (mounted.has(el)) continue;
234
273
  mounted.add(el);
@@ -1 +1 @@
1
- (()=>{var b=Object.defineProperty;var D=(i,t,e)=>t in i?b(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var V=(i,t)=>{for(var e in t)b(i,e,{get:t[e],enumerable:!0})};var o=(i,t,e)=>D(i,typeof t!="symbol"?t+"":t,e);var y={};V(y,{mountSearch:()=>Z});var F=window.Tether.__core["config.ts"],[u,et,S,rt,it,E,nt]=F;var j=window.Tether.__core["client.ts"],[ot,A,at,x,L,lt]=j;var K=window.Tether.__core["dom.ts"],[ht,I,ut,mt,k,dt,N,p,pt,ft,f,gt,wt,yt,C,h,R,Tt,l,M,bt,P,m]=K;var Q=window.Tether.__core["mounting.ts"],[Et,At,xt,Lt,It,q]=Q;var Y=L({predictiveSearch:x({products:[{priceRange:"object"}],collections:["object"],queries:[{text:"string"}]})}),B="query TetherPredictive($q:String!,$limit:Int!){predictiveSearch(query:$q,limit:$limit,limitScope:EACH,types:[PRODUCT,COLLECTION,QUERY]){products{id handle title availableForSale featuredImage{url altText}priceRange{minVariantPrice{amount currencyCode}}}collections{handle title image{url altText}}queries{text}}}",J=6,z=10,W=2,X="/search",_=new WeakSet,$=0,U=i=>i.tagName==="A"?i:i.querySelector("a");function g(i,t){h(i,l("search-bind")).forEach(e=>{let r=p(e,"search-bind");r==="image"?M(e,t.image?.url,t.image?.altText||t.title):(r==="title"||r==="price"||r==="text")&&t[r]!=null&&P(e,t[r])})}function H(i,t){let e=U(i);e&&(t&&e.setAttribute("href",t),e.setAttribute("role","option"))}var w=class{constructor(t,e,r){o(this,"root");o(this,"input");o(this,"results");o(this,"limit");o(this,"minCharacters");o(this,"resultsId");o(this,"searchNumber",0);o(this,"timer");o(this,"lastTerm","");o(this,"cache",new Map);this.root=t,this.input=e,this.results=r,this.limit=f(t,"search-limit",{min:1,max:z,fallback:J}),this.minCharacters=f(t,"search-min",{min:1,fallback:W}),r.id||($+=1,r.id=`${u.prefix}-search-${$}`),this.resultsId=r.id,this.setUpAria(),this.listen()}setUpAria(){this.input.setAttribute("role","combobox"),this.input.setAttribute("aria-autocomplete","list"),this.input.setAttribute("aria-controls",this.resultsId),this.input.setAttribute("aria-expanded","false"),this.input.setAttribute("autocomplete","off"),this.results.hasAttribute("role")||this.results.setAttribute("role","listbox"),this.results.hidden=!0}listen(){this.input.addEventListener("input",()=>{let t=this.input.value.trim();t!==this.lastTerm&&(this.lastTerm=t,clearTimeout(this.timer),this.timer=setTimeout(()=>void this.search(t),u.searchDelay))}),this.input.addEventListener("focus",()=>{this.input.value.trim().length>=this.minCharacters&&this.options().length&&this.open(!0)}),this.input.addEventListener("keydown",t=>{this.onKeydown(t)}),document.addEventListener("click",t=>{this.root.contains(t.target)||this.open(!1)})}setState(t){this.root.setAttribute(I("search-state"),t)}open(t){this.root.classList.toggle("is-open",t),this.results.hidden=!t,this.input.setAttribute("aria-expanded",String(t)),t||this.input.removeAttribute("aria-activedescendant")}options(){return h(this.results,'[role="option"]')}async fetchResults(t){let e=this.cache.get(t);if(e)return e;let r=await A(B,{q:t,limit:this.limit},Y);return this.cache.set(t,r.predictiveSearch),r.predictiveSearch}async search(t){this.searchNumber+=1;let e=this.searchNumber;if(t.length<this.minCharacters){this.open(!1),this.setState("idle");return}this.setState("loading");try{let r=await this.fetchResults(t);e===this.searchNumber&&this.render(r,t)}catch(r){if(e!==this.searchNumber){S("a superseded search failed",r);return}this.setState("error"),E(r,"search")}}fillList(t,e,r){h(this.results,l(t)).forEach(a=>{R(a,e,r),m(a,e.length>0)})}queryUrl(t){let e=this.root.getAttribute("action")||X,r=e.includes("?")?"&":"?";return`${e}${r}${this.input.name||"q"}=${encodeURIComponent(t)}`}render(t,e){let r=t?.products??[],a=t?.collections??[],c=(t?.queries??[]).filter(s=>s.text.toLowerCase()!==e.toLowerCase());this.fillList("search-products",r,(s,n)=>{let O=N(n.priceRange.minVariantPrice);g(s,{title:n.title,price:O,image:n.featuredImage}),H(s,C(n.handle,n.id)),s.classList.toggle("is-sold-out",!n.availableForSale)}),this.fillList("search-collections",a,(s,n)=>{g(s,{title:n.title,image:n.image}),H(s,`${(u.collectionPath||"/collection").replace(/\/$/,"")}/${n.handle}`)}),this.fillList("search-queries",c,(s,n)=>{g(s,{text:n.text}),U(s)?.setAttribute("href",this.queryUrl(n.text))});let T=r.length+a.length+c.length;this.showCount(T),this.setState(T?"ready":"empty"),this.open(!0),k("search",{term:e,products:r,collections:a,queries:c},this.root)}showCount(t){h(this.root,l("show")).forEach(e=>{let r=p(e,"show");r==="search-empty"&&m(e,t===0),r==="search-results"&&m(e,t>0)}),this.options().forEach((e,r)=>{e.id||(e.id=`${this.resultsId}-${r}`),e.setAttribute("aria-selected","false")})}highlight(t,e){t.forEach((a,c)=>{a.setAttribute("aria-selected",String(c===e))});let r=t[e];r&&(this.input.setAttribute("aria-activedescendant",r.id),r.scrollIntoView?.({block:"nearest"}))}onKeydown(t){let e=this.options(),r=e.findIndex(a=>a.getAttribute("aria-selected")==="true");t.key==="ArrowDown"&&e.length?(t.preventDefault(),this.open(!0),this.highlight(e,(r+1)%e.length)):t.key==="ArrowUp"&&e.length?(t.preventDefault(),this.highlight(e,r<=0?e.length-1:r-1)):t.key==="Enter"&&r>=0?(t.preventDefault(),e[r]?.click()):t.key==="Escape"&&this.open(!1)}};function Z(i=document){for(let t of q(i,l("search"))){if(_.has(t))continue;_.add(t);let e=t.querySelector(l("search-input"))??t.querySelector("input"),r=t.querySelector(l("search-results"));e&&r&&new w(t,e,r)}}function d(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)}function G(i){return d(i)&&d(i.__core)&&d(i.__parts)}function v(i,t){let e=Reflect.get(window,"Tether");if(!G(e))throw new Error(`tether.${i}.js runs after the Tether script, which loads it, and needs its window.Tether`);e.__parts[i]=t}v("search",y);})();
1
+ (()=>{var E=Object.defineProperty;var V=(i,t,e)=>t in i?E(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var F=(i,t)=>{for(var e in t)E(i,e,{get:t[e],enumerable:!0})};var s=(i,t,e)=>V(i,typeof t!="symbol"?t+"":t,e);var b={};F(b,{mountSearch:()=>G});var j=window.Tether.__core["config.ts"],[u,rt,A,it,nt,x,st]=j;var B=window.Tether.__core["client.ts"],[at,L,lt,I,k,ct,ht]=B;var K=window.Tether.__core["dom.ts"],[dt,C,mt,pt,N,ft,R,p,gt,wt,f,yt,Tt,bt,M,h,P,St,l,q,Et,_,d]=K;var Q=window.Tether.__core["mounting.ts"],[xt,Lt,It,kt,Ct,v]=Q;var Y=k({predictiveSearch:I({products:[{priceRange:"object"}],collections:["object"],queries:[{text:"string"}]})}),J="query TetherPredictive($q:String!,$limit:Int!){predictiveSearch(query:$q,limit:$limit,limitScope:EACH,types:[PRODUCT,COLLECTION,QUERY]){products{id handle title availableForSale featuredImage{url altText}priceRange{minVariantPrice{amount currencyCode}}}collections{handle title image{url altText}}queries{text}}}",z=6,W=10,X=2,Z="/search",w=new WeakSet,$=0,y=new Set,U=i=>i.tagName==="A"?i:i.querySelector("a");function g(i,t){h(i,l("search-bind")).forEach(e=>{let r=p(e,"search-bind");r==="image"?q(e,t.image?.url,t.image?.altText||t.title):(r==="title"||r==="price"||r==="text")&&t[r]!=null&&_(e,t[r])})}function H(i,t){let e=U(i);e&&(t&&e.setAttribute("href",t),e.setAttribute("role","option"))}var T=class{constructor(t,e,r){s(this,"root");s(this,"input");s(this,"results");s(this,"limit");s(this,"minCharacters");s(this,"resultsId");s(this,"searchNumber",0);s(this,"timer");s(this,"lastTerm","");s(this,"cache",new Map);s(this,"listening",new window.AbortController);this.root=t,this.input=e,this.results=r,this.limit=f(t,"search-limit",{min:1,max:W,fallback:z}),this.minCharacters=f(t,"search-min",{min:1,fallback:X}),r.id||($+=1,r.id=`${u.prefix}-search-${$}`),this.resultsId=r.id,this.setUpAria(),this.listen(),y.add(this)}stop(){this.listening.abort(),clearTimeout(this.timer),y.delete(this),w.delete(this.root)}setUpAria(){this.input.setAttribute("role","combobox"),this.input.setAttribute("aria-autocomplete","list"),this.input.setAttribute("aria-controls",this.resultsId),this.input.setAttribute("aria-expanded","false"),this.input.setAttribute("autocomplete","off"),this.results.hasAttribute("role")||this.results.setAttribute("role","listbox"),this.results.hidden=!0}listen(){let{signal:t}=this.listening;this.input.addEventListener("input",()=>{let e=this.input.value.trim();e!==this.lastTerm&&(this.lastTerm=e,clearTimeout(this.timer),this.timer=setTimeout(()=>void this.search(e),u.searchDelay))},{signal:t}),this.input.addEventListener("focus",()=>{this.input.value.trim().length>=this.minCharacters&&this.options().length&&this.open(!0)},{signal:t}),this.input.addEventListener("keydown",e=>{this.onKeydown(e)},{signal:t}),document.addEventListener("click",e=>{if(!this.root.isConnected){this.stop();return}this.root.contains(e.target)||this.open(!1)},{signal:t})}setState(t){this.root.setAttribute(C("search-state"),t)}open(t){this.root.classList.toggle("is-open",t),this.results.hidden=!t,this.input.setAttribute("aria-expanded",String(t)),t||this.input.removeAttribute("aria-activedescendant")}options(){return h(this.results,'[role="option"]')}async fetchResults(t){let e=this.cache.get(t);if(e)return e;let r=await L(J,{q:t,limit:this.limit},Y);return this.cache.set(t,r.predictiveSearch),r.predictiveSearch}async search(t){this.searchNumber+=1;let e=this.searchNumber;if(t.length<this.minCharacters){this.open(!1),this.setState("idle");return}this.setState("loading");try{let r=await this.fetchResults(t);e===this.searchNumber&&this.render(r,t)}catch(r){if(e!==this.searchNumber){A("a superseded search failed",r);return}this.setState("error"),x(r,"search")}}fillList(t,e,r){h(this.results,l(t)).forEach(a=>{P(a,e,r),d(a,e.length>0)})}queryUrl(t){let e=this.root.getAttribute("action")||Z,r=e.includes("?")?"&":"?";return`${e}${r}${this.input.name||"q"}=${encodeURIComponent(t)}`}render(t,e){let r=t?.products??[],a=t?.collections??[],c=(t?.queries??[]).filter(o=>o.text.toLowerCase()!==e.toLowerCase());this.fillList("search-products",r,(o,n)=>{let D=R(n.priceRange.minVariantPrice);g(o,{title:n.title,price:D,image:n.featuredImage}),H(o,M(n.handle,n.id)),o.classList.toggle("is-sold-out",!n.availableForSale)}),this.fillList("search-collections",a,(o,n)=>{g(o,{title:n.title,image:n.image}),H(o,`${(u.collectionPath||"/collection").replace(/\/$/,"")}/${n.handle}`)}),this.fillList("search-queries",c,(o,n)=>{g(o,{text:n.text}),U(o)?.setAttribute("href",this.queryUrl(n.text))});let S=r.length+a.length+c.length;this.showCount(S),this.setState(S?"ready":"empty"),this.open(!0),N("search",{term:e,products:r,collections:a,queries:c},this.root)}showCount(t){h(this.root,l("show")).forEach(e=>{let r=p(e,"show");r==="search-empty"&&d(e,t===0),r==="search-results"&&d(e,t>0)}),this.options().forEach((e,r)=>{e.id||(e.id=`${this.resultsId}-${r}`),e.setAttribute("aria-selected","false")}),this.input.removeAttribute("aria-activedescendant")}highlight(t,e){t.forEach((a,c)=>{a.setAttribute("aria-selected",String(c===e))});let r=t[e];r&&(this.input.setAttribute("aria-activedescendant",r.id),r.scrollIntoView?.({block:"nearest"}))}onKeydown(t){let e=this.options(),r=e.findIndex(a=>a.getAttribute("aria-selected")==="true");t.key==="ArrowDown"&&e.length?(t.preventDefault(),this.open(!0),this.highlight(e,(r+1)%e.length)):t.key==="ArrowUp"&&e.length?(t.preventDefault(),this.highlight(e,r<=0?e.length-1:r-1)):t.key==="Enter"&&r>=0?(t.preventDefault(),e[r]?.click()):t.key==="Escape"&&this.open(!1)}};function G(i=document){y.forEach(t=>{t.root.isConnected||t.stop()});for(let t of v(i,l("search"))){if(w.has(t))continue;w.add(t);let e=t.querySelector(l("search-input"))??t.querySelector("input"),r=t.querySelector(l("search-results"));e&&r&&new T(t,e,r)}}function m(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)}function tt(i){return m(i)&&m(i.__core)&&m(i.__parts)}function O(i,t){let e=Reflect.get(window,"Tether");if(!tt(e))throw new Error(`tether.${i}.js runs after the Tether script, which loads it, and needs its window.Tether`);e.__parts[i]=t}O("search",b);})();
@@ -21,7 +21,8 @@ export interface ServerRequest {
21
21
  * cross-site forms.
22
22
  *
23
23
  * @throws {TetherError} `NOT_CONFIGURED` without `account.server`, `INVALID` for refused input, `HTTP_<status>` for
24
- * any other failure but a 401, with the Worker's `userErrors`; `NETWORK` when the Worker can't be reached.
24
+ * any other failure but a 401, with the Worker's `userErrors`; `NETWORK` when the Worker can't be reached or takes
25
+ * longer than `requestTimeout`.
25
26
  */
26
27
  export declare function serverFetch(path: string, { method, body }?: ServerRequest): Promise<ServerAnswer>;
27
28
  /**
@@ -0,0 +1,9 @@
1
+ import type { Parts } from './lazy.js';
2
+ /**
3
+ * Buffers the events the analytics part handles until `load` has the part, then hands it the buffer. When the part
4
+ * fails to load (an ad blocker, a CSP rule, an integrity mismatch) or to start, the buffer is emptied and its
5
+ * listeners removed, so the page keeps no cart or product details for a part that will never read them.
6
+ *
7
+ * @returns The buffer, which the part drains and then handles each event pushed to it as it comes.
8
+ */
9
+ export declare function queueAnalyticsEvents(load: () => Promise<Pick<Parts['analytics'], 'startAnalytics'>>): Event[];
@@ -7,8 +7,8 @@ type CheckoutResolver = () => Promise<string | null>;
7
7
  /** Sets the account part's checkout URL, or clears it with `null`. A URL it answers opens checkout logged in. */
8
8
  export declare function setCheckoutResolver(resolver: CheckoutResolver | null): void;
9
9
  /**
10
- * Goes to Shopify's checkout. With `_blank` the tab opens inside the click (Safari blocks `window.open` after an
11
- * await) and gets its URL once there is one.
10
+ * Goes to Shopify's checkout, with the cart as the changes already queued leave it. With `_blank` the tab opens inside
11
+ * the click (Safari blocks `window.open` after an await) and gets its URL once there is one.
12
12
  *
13
13
  * @returns The checkout URL, `null` with nothing to check out or after a reported failure.
14
14
  */
@@ -3,12 +3,17 @@ export declare const drawers: () => HTMLElement[];
3
3
  /** True while a drawer, or the drawer-less cart, is open. */
4
4
  export declare function isOpen(): boolean;
5
5
  /**
6
- * `aria-expanded` on the open buttons, and dialog semantics on the drawers unless their markup has its own. A closed
7
- * drawer is hidden from screen readers and, with `cartFocus`, out of the Tab order (inert), like a closed dialog.
6
+ * `aria-expanded` on the open buttons, and dialog semantics on the drawers unless their markup has its own. Each
7
+ * drawer follows its own open class: a closed one is hidden from screen readers and inert, out of the Tab order like
8
+ * a closed dialog, so nothing `aria-hidden` can take focus.
9
+ */
10
+ export declare function syncDrawerAria(): void;
11
+ /**
12
+ * Opens every drawer but `tether-cart-drawer="manual"` ones, which only the site opens, by adding the open class. On a
13
+ * page whose drawers are all manual it does nothing.
8
14
  */
9
- export declare function syncDrawerAria(open: boolean): void;
10
- /** Opens every drawer except `tether-cart-drawer="manual"` ones, which the site opens itself. */
11
15
  export declare function openCart(): void;
16
+ /** Closes every open drawer, `manual` ones included. */
12
17
  export declare function closeCart(): void;
13
18
  export declare function toggleCart(): void;
14
19
  /**
@@ -175,6 +175,8 @@ export declare function showLastKnownCount(): void;
175
175
  export declare function setWarnings(notes: readonly CartWarning[]): void;
176
176
  /** @returns A runner that starts each task once the one before has settled, whether it succeeded or failed. */
177
177
  export declare function serial(): <T>(task: () => Promise<T>) => Promise<T>;
178
+ /** The one queue every cart change runs through; the checkout's URL lookup waits in it too. */
179
+ export declare const runInOrder: <T>(task: () => Promise<T>) => Promise<T>;
178
180
  /**
179
181
  * Runs a cart change after the ones before it, so quick clicks never race. A failure sets the `error` status (shown by
180
182
  * `tether-show="cart-error"` until the next change succeeds), emits `tether:cart-error` and rejects.
@@ -84,7 +84,7 @@ export declare const Cart: {
84
84
  *
85
85
  * @throws {TetherError} `INVALID_DISCOUNT` (rejected) when Shopify doesn't accept the code.
86
86
  */
87
- applyDiscount(code: string): Promise<ShopifyCart | null>;
87
+ applyDiscount(typed: string): Promise<ShopifyCart | null>;
88
88
  removeDiscount(code: string): Promise<ShopifyCart | null>;
89
89
  /**
90
90
  * Sets who is buying; a country changes the cart's currency and prices to that market's.
@@ -104,6 +104,12 @@ export declare function withContext(query: string, ctx?: {
104
104
  country?: string | undefined;
105
105
  language?: string | undefined;
106
106
  }): string;
107
+ /**
108
+ * Runs `send` with a signal that aborts it, the answer's body included, after `ms` milliseconds (`0`: never), as
109
+ * `AbortSignal.timeout` would; Safari before 16 lacks that. A request that never settles would hold every cart change
110
+ * queued behind it (`enqueue`) for as long as the browser keeps the connection open.
111
+ */
112
+ export declare function withTimeout<T>(ms: number, send: (signal: AbortSignal | null) => Promise<T>): Promise<T>;
107
113
  /**
108
114
  * One Storefront API request, for any config: the browser's shared one (`gql`) or one the server helpers build.
109
115
  * Queries carry a time bucket so Shopify's cache of an identical query text is at most `maxAge` seconds old. A query
@@ -33,8 +33,18 @@ export declare function setText(el: Element, value: string | number | boolean |
33
33
  export declare function setTextTracked(el: HTMLElement, value: string | number | boolean | null | undefined): void;
34
34
  /** Shows or hides `el`, restoring its own display value when shown again. */
35
35
  export declare function show(el: HTMLElement, visible: boolean): void;
36
- /** Marks an option button or input as chosen: `is-selected`, `aria-pressed`, and its own or inner radio/checkbox. */
36
+ /**
37
+ * Marks an option element as chosen: `is-selected`, the ARIA state its role takes (`chosenState`), and its own or
38
+ * inner radio/checkbox. An element that is no button and has no role of its own (a Webflow button is a link) gets
39
+ * `role="button"`, where `aria-pressed` is valid.
40
+ */
37
41
  export declare function setSelected(el: Element, selected: boolean): void;
42
+ /**
43
+ * Marks an option element the visitor can't buy: `is-unavailable`, and `aria-disabled` on the control assistive
44
+ * technology reads, the element itself or the radio/checkbox inside it. It stays clickable: choosing it picks the
45
+ * closest variant that has it.
46
+ */
47
+ export declare function setUnavailable(el: Element, unavailable: boolean): void;
38
48
  /**
39
49
  * A global the page's own scripts set on `window`: `TETHER_CONFIG`, the site's config, `TETHER_INTEGRATION`, set by a
40
50
  * framework integration (Astro) that starts Tether itself, and GSAP's `ScrollTrigger`. Another script wrote it, so it
@@ -64,6 +74,8 @@ interface IntegerRange {
64
74
  max?: number;
65
75
  fallback: number;
66
76
  }
77
+ /** A whole number as text, the way attributes and quantity fields take one. */
78
+ export declare const INTEGER_TEXT: RegExp;
67
79
  /**
68
80
  * Parses a count attribute with the config's count-option rules: an integer above `max` is the site asking for as
69
81
  * much as there is, so it gets `max`; a missing or empty attribute is `fallback`, and so, with a warning, is one that
@@ -95,7 +95,7 @@ declare const publicApi: {
95
95
  setNote(note: string | null | undefined): Promise<ShopifyCart | null>;
96
96
  setAttributes(attributes: import("./cart/mutations.js").Attributes): Promise<ShopifyCart | null>;
97
97
  setDiscountCodes(codes: string | string[] | ((current: string[]) => string[])): Promise<ShopifyCart | null>;
98
- applyDiscount(code: string): Promise<ShopifyCart | null>;
98
+ applyDiscount(typed: string): Promise<ShopifyCart | null>;
99
99
  removeDiscount(code: string): Promise<ShopifyCart | null>;
100
100
  setBuyerIdentity(buyerIdentity: {
101
101
  countryCode?: string;
@@ -27,7 +27,7 @@ export interface SearchResults {
27
27
  queries: SearchQuery[];
28
28
  }
29
29
  /**
30
- * Sets up every `[tether-search]` in `root` (and `root` itself) once.
30
+ * Sets up every `[tether-search]` in `root` (and `root` itself) once, and stops the boxes no longer on the page.
31
31
  */
32
32
  export declare function mountSearch(root?: ParentNode & Partial<Pick<Element, 'matches'>>): void;
33
33
  export {};
@@ -1 +1 @@
1
- export declare const VERSION = "0.9.3";
1
+ export declare const VERSION = "0.9.4";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@occluze/tether",
3
- "version": "0.9.3",
3
+ "version": "0.9.4",
4
4
  "description": "Free, open-source alternative to Smootify and Storesynk (Shopyflow): Shopify products, cart and subscriptions in Webflow with HTML attributes. Optional Shopify to Webflow CMS sync.",
5
5
  "type": "module",
6
6
  "main": "dist/esm/index.js",
@@ -1 +0,0 @@
1
- import{f as V,g as G,h as H,i as O,m as v,n as W}from"./chunk-GCGRUVYO.js";import{a as L,c as M}from"./chunk-74SGIWQE.js";import{f as F,g as j,h as P}from"./chunk-FX7EJ6RB.js";import"./chunk-NF5H2Q7V.js";import{a as X}from"./chunk-SJNNEEDX.js";import"./chunk-RVWHBZAF.js";import"./chunk-WHNUPECA.js";import{C as $,D as _,F as A,H as x,O as q,a as f,m as c,n as m,p as d,t as h,w as N,y as D}from"./chunk-A6BZFYZY.js";import{D as T,F as l,G as U,d as I,g as y,r as E,x as i}from"./chunk-PZERNTCD.js";var g=null;function B(){let e=i.account?.server;if(!e)throw new f("Customer accounts need the Worker: set account.server",{code:"NOT_CONFIGURED"});return new URL(e,window.location.href).href.replace(/\/$/,"")}function J(e){e?F(L(),"1"):j(L())}async function ue(e,t){try{return await fetch(e,t)}catch(r){throw new f(`Network error: ${U(r)}`,{code:"NETWORK"})}}async function de(e){let t;try{t=await e.json()}catch{return{}}return I(t)?t:{}}async function p(e,{method:t="GET",body:r}={}){let n={method:t,credentials:"include"};t==="POST"&&(n.headers={"Content-Type":"application/json","X-Tether-Account":"1"}),r&&(n.body=JSON.stringify(r));let s=await ue(`${B()}${e}`,n);if(s.status===401)return{kind:"logged-out"};let o=await de(s);if(!s.ok){let u=y(o.error)??String(s.status),w=H(o.userErrors);throw new f(`Customer accounts: ${u}`,{status:s.status,...w.length>0&&{userErrors:w},...o.code==="INVALID"&&{code:"INVALID"}})}return{kind:"answer",data:o}}async function k(){if(!g){let e=await p("/me");g=e.kind==="answer"&&e.data.loggedIn===!0?{loggedIn:!0,customer:V(e.data.customer)}:{loggedIn:!1}}return J(g.loggedIn),g}var K=()=>g?.loggedIn===!0;function z(){g=null}function Q(e){let t=i.account?.navigate;t?t(e):window.location.assign(e)}var le=e=>e||i.account?.locale||(i.locale||"").split("-")[0]||"";function Y({returnTo:e,locale:t}){let r=new URL(`${B()}/login`);r.searchParams.set("returnTo",e);let n=le(t);n&&r.searchParams.set("locale",n),i.country&&r.searchParams.set("country",i.country.toUpperCase()),Q(r.toString())}async function Z(){let e=P.id();if(!(await k()).loggedIn||!e)return null;let t=await p("/cart",{method:"POST",body:{cartId:e}});return t.kind==="logged-out"?null:y(t.data.checkoutUrl)}async function ee(e){let t=await p("/logout",{method:"POST",body:{returnTo:e,cartId:P.id()}});g=null,J(!1),h("account-logout",{});let r=t.kind==="answer"?y(t.data.logoutUrl):null;return r?(Q(r),"redirected"):"stayed"}var R=10,b=50,te=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1&&e<=b,me=e=>q(e,"limit",{min:1,max:b,fallback:R}),ge=e=>e.replace(/\?.*$/,"").replace(/^.*\//,"");function fe(e){let t=i.account?.orderUrl;if(t)return t.replaceAll("{id}",encodeURIComponent(ge(e.id)));let r=e.statusPageUrl;return r!==null&&E(r)?r:null}var pe=e=>({name:e.name??"",date:_(e.processedAt),total:$(e.totalPrice),status:e.financialStatus?.toLowerCase(),fulfillment:e.fulfillmentStatus?.toLowerCase(),items:e.lineItems.nodes.map(t=>`${String(t.quantity)}\xD7 ${t.title??""}`).join(", ")});function we(e,t){let r=t.lineItems.nodes,n=fe(t),s=pe(t);d(e,c("order-bind")).forEach(o=>{let u=m(o,"order-bind")??"";if(u==="url"){n&&o.setAttribute("href",n);return}if(u==="image"){let S=r.find(ae=>ae.image)?.image;S&&N(o,S.url,S.altText||r[0]?.title||"");return}let w=v(s,u);w!==void 0&&A(o,w)}),d(e,c("order-lines")).forEach(o=>{W(o,r,null)}),m(e,"order-bind")==="url"&&n&&e.setAttribute("href",n)}async function re(e,t){let r=d(e,c("orders")),n=r[0];if(!n)return;O(e,"show",{"orders-loading":!0,"orders-empty":!1});let s=me(n),o;try{o=await t(s)}catch(u){l(u,"orders"),o=null}O(e,"show",{"orders-loading":!1,"orders-empty":o?.length===0}),r.forEach(u=>{D(u,o??[],we)})}var he=["order","addresses","subscriptions","profile-form","address-form"],Pe=K;function ye({returnTo:e=window.location.href,locale:t}={}){return new Promise(r=>{Y({returnTo:e,locale:t}),r()})}async function ie(){let e=await k();return e.loggedIn?e.customer:null}async function Ae({first:e=R}={}){if(!te(e))throw new f(`Customer accounts: orders() takes first from 1 to ${String(b)}`,{code:"INVALID"});let t=await p(`/orders?${new URLSearchParams({first:String(e)}).toString()}`);return t.kind==="logged-out"?[]:G(t.data.orders)}async function ve({returnTo:e=i.account?.logoutUrl||`${window.location.origin}/`}={}){await ee(e)==="stayed"&&await C(document)}async function ke(){try{return(await k()).loggedIn?{kind:"logged-in"}:{kind:"logged-out"}}catch(e){return{kind:"unknown",error:e}}}var ne=e=>he.some(t=>d(e,c(t)).length>0);function be(e){d(e,c("account-link")).forEach(t=>{t.setAttribute("href",Se(m(t,"account-link")))})}function Se(e){let t=i.account,r=`https://${i.domain}/account`;return e==="payment"?t?.paymentUrl||t?.subscriptionsUrl||r:e==="subscriptions"&&t?.subscriptionsUrl||r}async function C(e=document){let t=await ke();t.kind==="unknown"&&l(t.error,"account");let r=t.kind==="logged-in";if(d(e,c("show")).forEach(n=>{let s=m(n,"show");s==="logged-in"&&x(n,r),s==="logged-out"&&x(n,!r)}),be(e),t.kind==="unknown"&&ne(e)){(await a()).showUnavailable(e);return}r&&(await ce(e),await Promise.all([re(e,n=>Ae({first:n})),ne(e)?a().then(n=>n.renderPages(e)):null]))}async function ce(e){let t=d(e,c("account-bind"));if(!t.length)return;let r;try{r=await ie()}catch(s){l(s,"account");return}if(!r)return;let n={"first-name":r.firstName,"last-name":r.lastName,name:r.displayName,email:r.emailAddress?.emailAddress,address:r.defaultAddress?.formatted.join(", ")};t.forEach(s=>{let o=v(n,m(s,"account-bind")??"");o!=null&&A(s,o)})}var oe=null;function a(){return oe??(oe=X("account-pages").then(e=>(e.setup({serverFetch:p,customer:ie,bindCustomer:ce,reset:z}),e))),oe}var Ze=e=>a().then(t=>t.order(e)),et=e=>a().then(t=>t.updateProfile(e)),tt=()=>a().then(e=>e.addresses()),rt=(e,t)=>a().then(r=>r.saveAddress(e,t)),nt=e=>a().then(t=>t.deleteAddress(e)),ot=()=>a().then(e=>e.subscriptions()),st=(e,t)=>a().then(r=>r.subscriptionAction(e,t)),it=(e,t)=>a().then(r=>r.requestReturn(e,t));function xe(e){let t=e.target;t instanceof window.Element&&(t.closest(c("account-login"))?(e.preventDefault(),ye().catch(r=>{l(r,"login")})):t.closest(c("account-logout"))&&(e.preventDefault(),ve().catch(r=>{l(r,"logout")})))}function Le(){let e=new URL(window.location.href),t=e.searchParams.get("account");if(M(t))switch(e.searchParams.delete("account"),window.history.replaceState(window.history.state,"",e),t){case"in":h("account-login",{});break;case"expired":case"error":h("account-error",{error:t});break}}var se=!1;async function ct(e=document){if(se){await C(e);return}se=!0,document.addEventListener("click",xe),Le(),P.setCheckoutResolver(Z),await C(e),T("account",Pe()?"logged in":"logged out")}export{tt as addresses,ie as customer,nt as deleteAddress,Pe as isLoggedIn,ye as login,ve as logout,ct as mountAccount,Ze as order,Ae as orders,C as render,it as requestReturn,rt as saveAddress,st as subscriptionAction,ot as subscriptions,et as updateProfile};
@@ -1 +0,0 @@
1
- import{a as n}from"./chunk-SJNNEEDX.js";import{g as r}from"./chunk-LSB7RVRZ.js";import{m as e}from"./chunk-A6BZFYZY.js";import{F as i}from"./chunk-PZERNTCD.js";var d=()=>`${e("collection")},${e("products")},${e("recommendations")}`;function a(t){return r(t,"loading"),{root:t,load:()=>n("lists").then(o=>o.loadList(t)).catch(o=>{r(t,"error",o),i(o,"lists")})}}export{d as a,a as b};
@@ -1 +0,0 @@
1
- import{b as Q,c as y,d as j,h as J}from"./chunk-FX7EJ6RB.js";import{a as T,b as K,c as A,d as M,e as W,f as X,g as Y,h as _,i as z}from"./chunk-SOLTIZAI.js";import{d as D,e as V,f as E,k as G}from"./chunk-NF5H2Q7V.js";import{c as N,f as Z}from"./chunk-LSB7RVRZ.js";import{B as C,C as H,F as h,H as O,I as P,K as k,L as F,M as R,N as U,P as B,l as m,m as s,n as l,o as x,p as b,q as w,t as f,w as $}from"./chunk-A6BZFYZY.js";import{F as L,b as p,x as I}from"./chunk-PZERNTCD.js";var tt={money:H,percent:C},lt=e=>e.tagName==="INPUT";function q(e){let t=b(e,s("add-label"))[0]??e,n=t.dataset.tetherLabel??(lt(t)?t.value:t.textContent);return t.dataset.tetherLabel=n,{label:t,original:n}}function ct(e,t){let{product:n}=e,i=r=>t.selected[e.optName(r)]??"";e.$(s("option-selected")).forEach(r=>{h(r,i(l(r,"option-selected")))}),e.$(s("option-list")).forEach(r=>{let a=e.optName(l(r,"option-list"));b(r,s("option-value")).forEach(o=>{let c=l(o,"option-value")??"";P(o,t.selected[a]===c);let u=!K(n,t.selected,a,c);o.classList.toggle("is-unavailable",u),o.setAttribute("data-unavailable",u?"true":"false")})}),y(e,s("option")).forEach(r=>{r.value=i(l(r,"option"))}),y(e,s("variant-select")).forEach(r=>{r.value=t.variant.id})}function ut(e,t){let{variant:n,purchase:i,line:r}=t;e.$(s("purchase")).forEach(a=>{if(Q(a)){a.value=i.kind;return}let o=l(a,"purchase");P(a,o===i.kind);let c=o==="subscription"?!t.subscriptionAvailable:e.product.requiresSellingPlan;a.classList.toggle("is-unavailable",c)}),e.$(s("plan-value")).forEach(a=>{let o=l(a,"plan-value")??"";P(a,r.kind==="subscription"&&o===r.planId),a.classList.toggle("is-unavailable",!E(n,o));let c=e.plans.find(d=>d.id===o),u=z(n,o,c,tt);b(a,s("plan-bind")).forEach(d=>{let v=u.get(l(d,"plan-bind")??"");v&&h(d,v())})}),y(e,s("plan")).forEach(a=>{a.value=r.kind==="subscription"?r.planId:""})}function dt(e,t){let n=new Map(Object.entries(t.show));N.forEach(i=>n.set(i,i==="ready")),e.$(s("show")).forEach(i=>{let r=l(i,"show")??"",a=n.get(r);a!==void 0&&(N.some(o=>o===r)&&!Z(i,e.root)||O(i,a))})}function ht(e,t){let n=!t.variant.availableForSale;e.$(s("add-to-cart")).forEach(i=>{i.classList.toggle("is-disabled",n),i.setAttribute("aria-disabled",String(n)),"disabled"in i&&(i.disabled=n);let r=l(i,"soldout-text"),a=l(i,"subscribe-text");if(!r&&!a)return;let{label:o,original:c}=q(i),u=c;t.line.kind==="subscription"&&a&&(u=a),n&&r&&(u=r),i.getAttribute("aria-busy")!=="true"&&h(o,u)})}function et(e,t){let{variant:n}=t,{product:i}=e,r=_(t,tt);e.$(s("bind")).forEach(a=>{let o=l(a,"bind")??"";if(o==="variant-image"){$(a,n.image?.url||i.featuredImage?.url,n.image?.altText||i.title);return}let c=r.get(o);c&&h(a,c())}),ct(e,t),ut(e,t),dt(e,t),e.root.classList.toggle("is-subscription",t.line.kind==="subscription"),e.root.setAttribute(m("purchase-mode"),t.line.kind),ht(e,t)}var it=()=>s("product"),pt=e=>e.tagName==="INPUT"||e.tagName==="SELECT"||e.tagName==="TEXTAREA",nt=e=>e instanceof window.Element;function g(e,t,n){let i=t.closest(n);return i?.closest(it())===e.root?i:null}function mt(e,t){let{label:n,original:i}=q(t),r=l(t,"adding-text");R(t,async()=>{r&&h(n,r);try{await e.addToCart()}catch(a){L(a,"add to cart failed"),f("error",{error:a,context:"add-to-cart"},e.root)}finally{r&&h(n,i)}}).then(()=>{e.renderVariant()}).catch(a=>{L(a,"add to cart render")})}function ft(e,t,n){let i=g(e,n,s("option-value")),r=i?.closest(s("option-list"));if(i&&r){t.preventDefault(),e.select(e.optName(l(r,"option-list")),l(i,"option-value")??"");return}let a=g(e,n,s("plan-value"));if(a){t.preventDefault(),e.selectPlan(l(a,"plan-value"));return}let o=g(e,n,`${s("purchase")}:not(select)`);if(o){o.tagName!=="INPUT"&&t.preventDefault(),e.setPurchase(rt(l(o,"purchase")));return}let c=g(e,n,s("qty-plus")),u=c?null:g(e,n,s("qty-minus"));if(c||u){t.preventDefault(),e.setQuantity(e.quantity+(c?1:-1));return}let d=g(e,n,s("add-to-cart"));d&&(t.preventDefault(),mt(e,d))}var rt=e=>e==="subscription"?"subscription":"one-time";function vt(e,t){let n=pt(t)?t.value:"";t.matches(`select${s("option")}`)?e.select(e.optName(l(t,"option")),n):t.matches(`select${s("variant-select")}`)?e.selectVariant(n):t.matches(`select${s("plan")}`)?n?e.selectPlan(n):e.setPurchase("one-time"):t.matches(`select${s("purchase")}`)?e.setPurchase(rt(n)):t.matches(s("qty"))&&e.setQuantity(n)}function at(e){e.root.addEventListener("click",t=>{nt(t.target)&&ft(e,t,t.target)}),e.root.addEventListener("change",t=>{let{target:n}=t;nt(n)&&n.closest(it())===e.root&&vt(e,n)})}var gt=new WeakMap,bt=()=>s("product"),S=new Map;function Pt(e){e.forEach(t=>{S.has(t.handle)||S.set(t.handle,t.options.map(n=>n.name))})}var st=e=>e.tagName==="INPUT",Et=e=>e.tagName==="INPUT"||e.tagName==="SELECT"||e.tagName==="TEXTAREA";function yt(e){return st(e)&&e.type==="checkbox"?e.checked?e.value&&e.value!=="on"?e.value:"Yes":null:st(e)&&e.type==="radio"?e.checked?e.value:null:Et(e)&&e.value||null}var ot=class{constructor(t,n){p(this,"root");p(this,"product");p(this,"plans");p(this,"selected");p(this,"purchase");p(this,"variant");p(this,"quantity");this.root=t,this.product=n,this.plans=V(n);let i=new URLSearchParams(window.location.search),r=X(n,{variant:i.get("variant")||l(t,"variant"),sellingPlan:i.get("selling_plan"),defaultPlan:l(t,"default-plan"),defaultPurchase:l(t,"default-purchase")||I.defaultPurchase});this.selected=r.selected,this.purchase=r.purchase,this.variant=null,this.quantity=x(t,"quantity")?Math.max(0,parseInt(l(t,"quantity")??"",10)||0):1,gt.set(t,this),t.setAttribute(m("state"),"ready"),t.removeAttribute(m("error")),this.renderProduct(),at(this),this.renderVariant(),F(t,"product"),k("product"),f("product-ready",{product:n,scope:this},t)}update(t){let n=this.variant?.id;this.product=t,this.plans=V(t);let i=t.variants.nodes.find(r=>r.id===n);i&&(this.selected=T(i)),this.root.setAttribute(m("state"),"ready"),this.root.removeAttribute(m("error")),this.renderProduct(),this.renderVariant(),k("product"),f("product-updated",{product:t,scope:this},this.root)}$(t){let n=w(this.root,t,bt());return this.root.matches(t)?[this.root,...n]:n}optName(t){if(!t)return"";let{options:n}=this.product;if(n.some(r=>r.name===t))return t;let i=(S.get(this.product.handle)??[]).indexOf(t);return n[i]?.name??t}get plan(){let t=A(this.purchase);return this.plans.find(n=>n.id===t)??null}get subscriptionAvailable(){return this.plans.some(t=>E(this.variant,t.id))}get isSubscription(){return M(this.purchase,this.variant).kind==="subscription"}getLine(){if(!this.variant)return null;let t={merchandiseId:this.variant.id,quantity:this.quantity},n=M(this.purchase,this.variant);n.kind==="subscription"&&(t.sellingPlanId=n.planId);let i=this.collectAttributes();return i.length&&(t.attributes=i),t}collectAttributes(){let t=B(U(this.root,"line-attributes")),n=this.$(s("line-attribute")).flatMap(i=>{let r=yt(i);return r===null?[]:[{key:l(i,"line-attribute")??"",value:r}]});return[...t,...n]}select(t,n){if(this.selected[t]===n)return;let i=this.product.variants.nodes.filter(o=>o.selectedOptions.some(c=>c.name===t&&c.value===n)),[r]=i;if(!r)return;let a={...this.selected,[t]:n};if(!i.some(o=>o.selectedOptions.every(c=>a[c.name]===c.value))){let o=u=>u.selectedOptions.filter(v=>v.name!==t&&this.selected[v.name]===v.value).length*2+(u.availableForSale?1:0),c=i.reduce((u,d)=>o(d)>o(u)?d:u,r);Object.assign(a,T(c))}this.selected=a,this.renderVariant()}selectVariant(t){let n=this.product.variants.nodes.find(i=>i.id===D.variant(t));n&&(this.selected=T(n),this.renderVariant())}setPurchase(t){let n=W(this.product,this.variant,t,A(this.purchase));n.kind!==this.purchase.kind&&(this.purchase=n,this.renderVariant())}selectPlan(t){let n=G(this.product,t);n&&(this.purchase={kind:"subscription",planId:n.id},this.renderVariant())}setQuantity(t){let n=x(this.root,"quantity")?0:1;this.quantity=Math.max(n,parseInt(String(t),10)||0),this.$(s("qty")).forEach(i=>{h(i,this.quantity)}),this.renderVariant()}async addToCart(){if(!this.variant?.availableForSale)return null;let t=this.getLine();if(!t||t.quantity<1)return null;let n=await J.add(t);return f("product-added",{product:this.product,variant:this.variant,line:t},this.root),n}renderProduct(){let{product:t}=this;S.has(t.handle)||this.$(`${s("option-list")},select${s("option")}`).map(i=>l(i,"option-list")||l(i,"option")).some(i=>t.options.some(r=>r.name===i))&&Pt([t]),j(this)}renderVariant(){let t=Y(this.product,{selected:this.selected,purchase:this.purchase,quantity:this.quantity},I.lowStock);if(!t){this.variant=null;return}this.variant=t.variant,this.selected=t.selected,this.purchase=t.purchase,et(this,t),f("variant-changed",{product:this.product,variant:t.variant,selected:{...t.selected},purchase:t.purchase.kind,sellingPlanId:t.line.kind==="subscription"?t.line.planId:null},this.root)}};export{gt as a,Pt as b,ot as c};
@@ -1 +0,0 @@
1
- import{D as N,E as b,F as w,G as Q,b as T,d as E,e as x,o as V,p as G,t as j,u as q,x as c}from"./chunk-PZERNTCD.js";var g=class extends Error{constructor(r,{status:n,errors:o,userErrors:i,code:s}={}){super(r);T(this,"name","TetherError");T(this,"code");T(this,"status");T(this,"errors");T(this,"userErrors");this.code=s??(n?`HTTP_${n}`:"ERROR"),this.status=n,this.errors=o,this.userErrors=i}};function v(t,e){return typeof e=="function"?e(t):typeof e=="string"?e==="object"?E(t):typeof t===e:bt(e)?Array.isArray(t)&&t.every(r=>v(r,e[0])):E(t)&&Object.entries(e).every(([r,n])=>n===void 0||v(t[r],n))}var bt=t=>Array.isArray(t),Fe=t=>e=>e===null||v(e,t),Ve=t=>e=>v(e,t);function wt(t=c){return`https://${t.domain}/api/${t.apiVersion}/graphql.json`}var Y=/"(?:\\.|[^"\\\n])*"|#[^\n]*/g,St=/^\s*(?:query|mutation)(?:\s+\w+)?\s*(?:\([^)]*\))?/;function At(t){return/\bmutation\b/.test(t.replace(Y,""))?"mutation":"query"}function J(t,{country:e,language:r}){let n=[];if(e&&n.push(`country: ${e}`),r&&n.push(`language: ${r}`),!n.length)return t;let o=`@inContext(${n.join(", ")})`,i=t.replace(Y,p=>" ".repeat(p.length)),s=i.indexOf("{");if(i.slice(0,s).includes("@inContext"))return t;if(i.trimStart().startsWith("{"))return`query ${o} ${t.slice(s)}`;let a=St.exec(i);if(!a)return t;let l=a[0].length;return`${t.slice(0,l).trimEnd()} ${o} ${t.slice(l).trimStart()}`}function Ge(t,e=c){let r=V(e.country)??void 0,n=G(e.language)??void 0;return J(t,{country:r,language:n})}var I=300,xt=500,vt=3e4,W=430,kt=1e3,L="quantityAvailable",B=new Set,Rt=t=>`${t.domain} ${t.apiVersion} ${t.token}`;function Ot(t,e,r,{context:n,operation:o}){let i=typeof e=="string"?e:e(r),s=n?J(i,t):i;return t.maxAge<=0||o==="mutation"?s:`${s} #${Math.floor(Date.now()/(t.maxAge*kt))}`}var Nt=t=>new Promise(e=>setTimeout(e,t));function P(t,e){if(t===401||t===403){let r=e.token.startsWith("shpat_")?", not an Admin API token (shpat_\u2026)":"";return`Shopify rejected the Storefront token for ${e.domain} (${t}): use the public Storefront API token (Headless channel)${r}`}return t===404?`Store or API version not found (404): check domain ${e.domain} and apiVersion ${e.apiVersion}`:`HTTP ${t} from ${e.domain}`}function Ct(t){let e=x(t,"message"),r=x(x(t,"extensions"),"code"),n=typeof e=="string"?e:"";return typeof r=="string"?{message:n,extensions:{code:r}}:{message:n}}function Lt(t){if(!E(t))return null;let{data:e,errors:r}=t;return r==null?{data:e}:Array.isArray(r)?{data:e,errors:r.map(Ct)}:null}function C(t,e){return t.ok?new g(`Invalid response (${t.status})`,{code:"INVALID_RESPONSE",status:t.status}):new g(P(t.status,e),{status:t.status})}function K(t,e,r,n){let o=e.map(s=>s.message).filter(Boolean).join(" | "),i=o||"Storefront API error";return t.ok||(i=t.status===401||t.status===403||!o?P(t.status,r):o),new g(i,{status:t.status,errors:e,code:n})}function z(t,e){if(e==="any")return{kind:"retry",backoffMs:I};throw new g(`Network error: ${Q(t)}`,{code:"NETWORK"})}function It(t,e,r,n,o,i,s){if(r.includes(L)&&n.some(d=>d.message.includes(L)))return{kind:"inventory-refused",error:K(t,n,e)};let a=n.map(d=>d.extensions?.code);if(i!=="none"&&a.includes("THROTTLED"))return{kind:"retry",backoffMs:xt};let l=a.includes("INTERNAL_SERVER_ERROR");if(i==="any"&&l)return{kind:"retry",backoffMs:I};let p=t.ok&&(l||s==="mutation"&&o==null);throw K(t,n,e,p?"SERVER_ERROR":void 0)}async function Pt(t,e){if(!t)return e(null);let r=new AbortController,n=setTimeout(()=>{r.abort(new DOMException("signal timed out","TimeoutError"))},t);try{return await e(r.signal)}finally{clearTimeout(n)}}async function Mt(t,e,r,n,o,i,s){let a;try{a=await(t.fetch??fetch)(wt(t),{method:"POST",headers:{"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":t.token},body:JSON.stringify({query:e,variables:r}),signal:s})}catch(f){return z(f,o)}if(a.status===W)throw new g("Shopify security rejection (430)",{status:W});if(o!=="none"&&a.status===429||o==="any"&&a.status>=500)return{kind:"retry",backoffMs:I};let l;try{l=await a.json()}catch(f){if(f instanceof SyntaxError)throw C(a,t);return z(f,o)}let p=Lt(l);if(!p)throw C(a,t);let{data:d,errors:h=[]}=p;if(h.length)return It(a,t,e,h,d,o,i);if(!a.ok)throw new g(P(a.status,t),{status:a.status});if(!n(d))throw C(a,t);return{kind:"data",data:d}}async function X(t,e,r,n,{context:o=!0,operation:i="query"}={}){if(!t.domain||!t.token)throw new g("Tether is not configured: domain and token are required",{code:"NOT_CONFIGURED"});let s=Rt(t),a=i==="mutation"?"not-run":"any",l=0;for(;;){let p={inventory:!B.has(s)},d=Ot(t,e,p,{context:o,operation:i}),h=l<t.retries?a:"none",f=await Pt(t.requestTimeout,S=>Mt(t,d,r,n,h,i,S));switch(f.kind){case"data":return f.data;case"inventory-refused":if(typeof e=="string"||!p.inventory)throw f.error;N(`the token can't read inventory: ${L} is left out from now on`),B.add(s);break;case"retry":await Nt(Math.min(f.backoffMs*2**l,vt)),l+=1,N("retry",l);break}}}function je(t,e,r,n){return X(c,t,e,r,n)}var _t=t=>typeof t=="object"&&t!==null;function Ut(t,e,r={},n){return X(t,e,r,_t,{...n,operation:At(e)})}function qe(t,e,r){return Ut(c,t,e,r)}function Qe(t,e){if(!t)throw new g(`${e}: empty response`);let r=t.userErrors??[];if(r.length)throw new g(r.map(n=>n.message).join(" | "),{userErrors:r});return t}var m=t=>`${c.prefix}-${t}`,Ht=(t,e)=>e===void 0?`[${m(t)}]`:`[${m(t)}="${e}"]`,k=(t,e)=>t.getAttribute(m(e)),$t=(t,e)=>t.hasAttribute(m(e));function Z(t,e){return t?[...t.querySelectorAll(e)]:[]}var Dt=(t,e,r)=>Z(t,e).filter(n=>n.closest(r)===t),Ft=["product-ready","list-ready","cart-updated","cart-toggled","checkout","search"],tt=new WeakMap;function et(t,e){let r=new CustomEvent(`${c.prefix}:${t}`,{detail:e,bubbles:!0});return tt.set(r,t),r}function Vt(t,e){return tt.get(t)===e}function M(t,e,r=document){r.dispatchEvent(et(t,e))}function nt(t,{width:e,height:r,crop:n}={}){if(!t)return t;let o;try{o=new URL(t)}catch(i){if(i instanceof TypeError)return t;throw i}return e&&o.searchParams.set("width",String(e)),r&&o.searchParams.set("height",String(r)),n&&o.searchParams.set("crop",n),o.toString()}function _(t,e){return t.getAttribute(e)??t.getAttribute(m(e))??t.getAttribute(`data-${e}`)}function ot(t,e){if(!t||!e)return t;let r=_(e,"max-width"),n=_(e,"max-height");return nt(t,{width:r,height:n,crop:r||n?_(e,"crop"):null})}var rt=t=>t.replace(/\?.*$/,"");function it(t,e){return!t||!e?!1:rt(t)===rt(e)}function Gt(t){return/^\s*[a-z][a-z0-9+.-]*:/i.test(t)&&!/^\s*(https?:|data:image\/)/i.test(t)?"none":`url("${t.replace(/["\\\n\r\f]/g,n=>`\\${n.charCodeAt(0).toString(16)} `)}")`}function jt(t,e,r){if(!e)return;let n=ot(e,t);if(t.tagName!=="IMG"){t.style.backgroundImage=Gt(n);return}if(it(t.getAttribute("src"),n)){r!=null&&!t.getAttribute("alt")&&t.setAttribute("alt",r);return}t.removeAttribute("srcset"),t.removeAttribute("sizes"),t.setAttribute("src",n),r!=null&&t.setAttribute("alt",r),t.getAttribute("loading")||t.setAttribute("loading","lazy")}var U=new WeakMap,qt=t=>!!U.get(t),H=t=>t.cloneNode(!0);function st(t){let e=U.get(t);if(e!==void 0)return e;let r=t.firstElementChild,n=r?H(r):null;return U.set(t,n),t.replaceChildren(),n}function Qt(t,e,r){let n=st(t);if(!n){e.length&&b("repeater without a template child",t);return}t.replaceChildren(),e.forEach((o,i)=>{let s=H(n);r(s,o,i),t.appendChild(s)})}function Wt(t,e){let r=()=>{t.remove()};if(!e){r();return}try{e(t,r)}catch(n){w(n,"repeater onLeave"),r()}}function Bt(t,e,r,n){e.forEach((o,i)=>{if(!r.has(o))return;let s=e[i-1];if(s?.parentNode===t?s.after(o):t.prepend(o),!!n)try{n(o)}catch(a){w(a,"repeater onEnter")}})}function Kt(t,e,r,n,{onEnter:o,onLeave:i}={}){let s=st(t);if(!s){b("repeater without a template child",t);return}let a=`data-${c.prefix}-key`,l=`data-${c.prefix}-leaving`,p=()=>[...t.children].filter(u=>u.hasAttribute(a)&&!u.hasAttribute(l)),d=new Map(p().map(u=>[u.getAttribute(a),u])),h=[],f=new Set;e.forEach((u,A)=>{let O=String(r(u,A)),y=d.get(O);y?d.delete(O):(y=H(s),y.setAttribute(a,O),f.add(y)),n(y,u,A,f.has(y)),h.push(y)});let S=h.filter(u=>!f.has(u)),F=p().filter(u=>S.includes(u));if(!(F.length===S.length&&F.every((u,A)=>u===S[A]))){d.forEach(u=>{u.remove()}),h.forEach(u=>t.appendChild(u));return}Bt(t,h,f,o),d.forEach(u=>{u.setAttribute(l,""),u.removeAttribute(a),u.style.pointerEvents="none",u.inert=!0,Wt(u,i)})}var zt="http://www.w3.org/1999/xhtml",Yt=new Set(["h1","h2","h3","h4","h5","h6","p","span","div","br","hr","blockquote","code","pre","strong","em","b","i","u","s","small","sub","sup","ul","ol","li","dl","dt","dd","table","caption","colgroup","col","thead","tbody","tfoot","tr","th","td","a","img","picture","source","video","figure","figcaption","iframe"]),Jt=new Set(["script","style","template","noscript","textarea","select","title"]),Xt=new Set(["style","title","lang","dir","role","align","width","height"]),Zt=new Map([["a",new Set(["href","target","rel","hreflang"])],["img",new Set(["src","srcset","sizes","alt","loading","decoding"])],["source",new Set(["src","srcset","sizes","type","media"])],["video",new Set(["src","poster","controls","autoplay","muted","loop","playsinline","preload"])],["iframe",new Set(["src","allow","allowfullscreen","frameborder","loading"])],["blockquote",new Set(["cite"])],["ol",new Set(["start","type","reversed"])],["li",new Set(["value"])],["table",new Set(["border","cellpadding","cellspacing","summary"])],["col",new Set(["span"])],["colgroup",new Set(["span"])],["th",new Set(["colspan","rowspan","headers","scope","valign"])],["td",new Set(["colspan","rowspan","headers","valign"])]]),te=new Set(["href","src","poster","cite"]),ee=/^(javascript|vbscript|data):/i,re=/^data:image\/(png|gif|jpeg|webp|avif);/i,ne=new Set(["position","top","right","bottom","left","z-index","-webkit-box-reflect"]),oe=["inset","transform","translate","rotate","scale","offset"],ie=/\d(?:[sld]?v|cq)(?:w|h|i|b|min|max)\b/i,se=/^(?:outline|box-shadow|text-shadow|filter|text-decoration|text-underline-offset|text-stroke)|^(?:border-image|mask-border|mask-box-image)(?:-outset)?$/,at=40,ae=new Map([["letter-spacing",{px:4,em:.25}],["word-spacing",{px:4,em:.25}],["text-indent",{px:at}]]),ut=/(?<![\w#.-])[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?(%|[a-z]+)?/gi,ue=/(?<![\w-])(?!drop-shadow\(|blur\()[\w-]+\([^()]*\)/g,ct=/(?:var|calc|min|max|clamp|env|attr)\(/i,ce=/url\(|expression\(|@import/i,le=/[\u0000- ]/g,de="allow-scripts allow-same-origin allow-popups allow-presentation",fe=new Set(["autoplay","encrypted-media","picture-in-picture","fullscreen","clipboard-write","accelerometer","gyroscope","web-share"]),pe="strict-origin-when-cross-origin",ge=["https://www.youtube.com","https://www.youtube-nocookie.com","https://player.vimeo.com","https://www.loom.com","https://fast.wistia.net"];function me(t,e){return Xt.has(e)||e.startsWith("aria-")||(Zt.get(t)?.has(e)??!1)}function he(t,e,r){let n=r.replace(le,"");return ee.test(n)?t==="img"&&e==="src"&&re.test(n):!0}function lt(t,e){try{return new URL(t,e)}catch{return null}}function ye(t,e,r){let n=t.baseURI,o=lt(n)?.origin??"null";return{origin:o==="null"?null:o,baseUrl:n,styleParser:e,embedOrigins:new Set([...ge,...r])}}function Ee(t,e){let r=lt(t.trim(),e.baseUrl);return r!==null&&r.origin!==e.origin&&e.embedOrigins.has(r.origin)}function Te(t){let e=t.split(";").map(r=>r.trim().split(/\s+/)[0]?.toLowerCase()??"");return[...new Set(e.filter(r=>fe.has(r)))].join("; ")}function be(t,e){if(ne.has(t)||oe.some(n=>t.startsWith(n))||ie.test(e))return!0;let r=ae.get(t);return r?ct.test(e)||we(e,r):t.startsWith("margin")&&e.includes("-")}function we(t,e){return[...t.matchAll(ut)].some(([r="",n=""])=>{let o=parseFloat(r);if(o>=0)return!1;let i=e[n.toLowerCase()];return i===void 0||-o>i})}function Se(t,e){return se.test(t.replace(/^-webkit-/,""))?ct.test(e)?!0:[...e.replace(ue,"").matchAll(ut)].some(([r="",n=""])=>{let o=Math.abs(parseFloat(r));return o!==0&&(n.toLowerCase()!=="px"||o>at)}):!1}function Ae(t,e){let r=e.style;r.cssText=t;let n=Array.from({length:r.length},(i,s)=>r.item(s));for(let i of n){let s=r.getPropertyValue(i);(be(i,s)||Se(i,s)||ce.test(s))&&r.removeProperty(i)}let o=r.cssText;return e.removeAttribute("style"),o}function xe(t,e){let r=t.localName;for(let i of[...t.attributes]){let s=i.name.toLowerCase(),a=te.has(s);me(r,s)&&(!a||he(r,s,i.value))||t.removeAttribute(i.name)}let n=t.getAttribute("style");if(n===null)return;let o=Ae(n,e.styleParser);o===""?t.removeAttribute("style"):t.setAttribute("style",o)}var ve=new Set(["","_self","_parent","_top"]);function ke(t){if(t.localName==="iframe"){let n=Te(t.getAttribute("allow")??"");n===""?t.removeAttribute("allow"):t.setAttribute("allow",n),t.setAttribute("sandbox",de),t.setAttribute("referrerpolicy",pe);return}if(t.localName!=="a")return;let e=t.getAttribute("target");if(e===null||ve.has(e.toLowerCase()))return;let r=new Set((t.getAttribute("rel")??"").split(/\s+/).filter(Boolean));r.add("noopener"),r.add("noreferrer"),t.setAttribute("rel",[...r].join(" "))}function Re(t,e){let r=t.localName,n=t.namespaceURI===zt;if(n&&Jt.has(r)){t.remove();return}if(!n||!Yt.has(r)){t.replaceWith(...t.childNodes);return}if(r==="iframe"&&!Ee(t.getAttribute("src")??"",e)){t.remove();return}xe(t,e),ke(t)}function dt(t,e=globalThis.document,r=[]){let n=e.createElement("template");n.innerHTML=t??"";let o=ye(e,n,r);for(let i of[...n.content.querySelectorAll("*")])Re(i,o);return n.content}var ft="data-tether-seen",D="data-tether-shown",R="data-tether-prev-display",Oe=120;function sr(t,e){return q(c.productPath||"/product",t,e)}function Et(t,e){try{return t()}catch(r){if(r instanceof RangeError)return e;throw r}}function ar(t,e=c.locale){return t?Et(()=>new Intl.NumberFormat(e||void 0,{style:"percent",maximumFractionDigits:0}).format(t/100),`${t}%`):""}function ur(t){return t?c.formatMoney?c.formatMoney(t,c.locale):j(t,c.locale):""}function cr(t){return t?Et(()=>new Date(t).toLocaleDateString(c.locale||void 0),""):""}function lr(t,e){t.replaceChildren(dt(e,t.ownerDocument,c.embedOrigins))}var Tt=t=>t.tagName==="INPUT"||t.tagName==="TEXTAREA",pt=t=>t.tagName==="INPUT";function Ne(t,e){let r=e==null?"":String(e);Tt(t)?t.value=r:t.textContent=r}var gt=t=>Tt(t)?t.value:t.textContent;function dr(t,e){let r=gt(t);if(Ne(t,e),r!==gt(t)&&t.hasAttribute(ft)&&c.onValueChange)try{c.onValueChange(t,r)}catch(n){w(n,"onValueChange")}t.setAttribute(ft,"1")}function Ce(t){if(t.hasAttribute(D))return;t.setAttribute(D,""),t.removeAttribute("hidden");let e=t.getAttribute(R);e!==null?(t.style.display=e,t.removeAttribute(R)):t.style.display==="none"&&(t.style.display=""),typeof getComputedStyle=="function"&&getComputedStyle(t).display==="none"&&(t.style.display=t.getAttribute(m("display"))||"block")}function fr(t,e){if(e){Ce(t);return}t.removeAttribute(D),!t.hasAttribute(R)&&t.style.display!=="none"&&t.setAttribute(R,t.style.display),t.style.display="none"}function pr(t,e){t.classList.toggle("is-selected",e),t.setAttribute("aria-pressed",e?"true":"false"),pt(t)&&(t.type==="radio"||t.type==="checkbox")&&(t.checked=e);let r=t.querySelector('input[type="radio"],input[type="checkbox"]');r&&pt(r)&&(r.checked=e)}var mt,Le=t=>Reflect.get(window,t);function Ie(){let t=Le("ScrollTrigger");if(typeof t!="function")return;let e=Reflect.get(t,"refresh");typeof e=="function"&&Reflect.apply(e,t,[])}function Pe(t){clearTimeout(mt),mt=setTimeout(()=>{try{c.onLayoutChange?c.onLayoutChange(t):Ie()}catch(e){w(e,"layout-changed")}M("layout-changed",{reason:t})},Oe)}function gr(t,e){let r=[...t.querySelectorAll("img")].filter(i=>!i.complete),n=r.length,o=()=>{n-=1,n===0&&Pe(`${e}:images`)};r.forEach(i=>{i.addEventListener("load",o,{once:!0}),i.addEventListener("error",o,{once:!0})})}function mr(t,e){return t.getAttribute("aria-busy")==="true"?Promise.resolve(void 0):(t.setAttribute("aria-busy","true"),Promise.resolve().then(e).finally(()=>{t.removeAttribute("aria-busy")}))}function hr(t,e){let r=t?k(t,e):null;if(!r)return null;try{return JSON.parse(r)}catch{return b(`invalid JSON in ${m(e)}`,t),null}}var Me=/^-?\d+$/,ht=new WeakMap;function yt(t,e,r){let n=ht.get(t)??new Set;ht.set(t,n),!n.has(e)&&(n.add(e),b(`${m(e)} ${r}`,t))}function yr(t,e,{min:r,max:n,fallback:o}){let i=k(t,e)?.trim();if(!i)return o;let s=Me.test(i)?Number(i):Number.NaN;return Number.isNaN(s)||s<r?(yt(t,e,`${JSON.stringify(i)} is not a whole number from ${String(r)}: using ${String(o)}`),o):n===void 0||s<=n?s:(yt(t,e,`${i} is more than its maximum: using ${String(n)}`),n)}function $(t){return t==null?"":typeof t=="string"?t:typeof t=="number"||typeof t=="boolean"?String(t):JSON.stringify(t)}function Er(t){return Array.isArray(t)?t.filter(E).map(r=>({key:$(r.key),value:$(r.value)})):E(t)?Object.entries(t).map(([e,r])=>({key:e,value:$(r)})):[]}function Tr(t){return t?Array.isArray(t)?t.map(e=>({key:String(e.key),value:String(e.value??"")})):Object.entries(t).map(([e,r])=>({key:e,value:String(r??"")})):[]}export{g as a,v as b,Fe as c,Ve as d,wt as e,Ge as f,X as g,je as h,Ut as i,qe as j,Qe as k,m as l,Ht as m,k as n,$t as o,Z as p,Dt as q,Ft as r,Vt as s,M as t,nt as u,it as v,jt as w,qt as x,Qt as y,Kt as z,sr as A,ar as B,ur as C,cr as D,lr as E,Ne as F,dr as G,fr as H,pr as I,Le as J,Pe as K,gr as L,mr as M,hr as N,yr as O,Er as P,Tr as Q};
@@ -1 +0,0 @@
1
- import{a as A}from"./chunk-24KD36UC.js";import{a as l,b as K,c as $}from"./chunk-2G6U6ZYV.js";import{b as E,d as b,g as m}from"./chunk-LSB7RVRZ.js";import{c as C,f as M,g as H,h as R}from"./chunk-RVWHBZAF.js";import{f as T}from"./chunk-WHNUPECA.js";import{l as c,n as L,p as x,t as p}from"./chunk-A6BZFYZY.js";import{D as h,E as P,F as f,d as w,o as k,p as v,x as a}from"./chunk-PZERNTCD.js";var W='script[type="application/json"][data-tether-hydrate]',g=new WeakSet,ut=new WeakSet,s=new Set,N=new Set,F=new WeakMap;function q(){s.forEach(t=>{t.isConnected||s.delete(t)}),N.forEach(t=>{t.root.isConnected||N.delete(t)})}function J(t,e){return[...t.matches?.(e)?[t]:[],...x(t,e)]}function z(t,e){let n=L(t,"page-title");!n||typeof document>"u"||(document.title=n.replace(/\{title\}/g,e.title).replace(/\{vendor\}/g,e.vendor||"").replace(/\{type\}/g,e.productType||""))}function D(t,{fromUrl:e,raw:n}){e?(g.add(t),m(t,"not-found"),p("product-not-found",{key:null,source:n},t)):t.closest(A())||P(`[${c("product")}] without a value. Bind it to the Shopify handle field, or use "url:handle".`,t)}function B(t,e,{fromUrl:n,raw:r},o){let d=b(o);if(m(t,d?"not-found":"error",o),!d){f(o,`product ${e}`),p("error",{error:o,context:"product",key:e},t);return}p("product-not-found",{key:e,source:r},t),n?h(`product not found: ${e}`):f(o,`product ${e}`)}function Q(t){if(g.has(t))return!1;let{key:e,...n}=E(t);if(!e)return D(t,n),!1;g.add(t),s.add(t);let r={};F.set(t,r);let o=()=>F.get(t)===r;return l.get(t)?t.setAttribute(c("state"),"updating"):m(t,"loading"),j(C(e)).then(u=>{if(!o())return;let S=l.get(t);S?S.update(u):new $(t,u),z(t,u),a.revalidate&&H(e)&&U(e)}).catch(u=>{o()&&B(t,e,n,u)}),!0}function dt(){q(),s.forEach(t=>{t.getAttribute(c("state"))!=="error"||t.getAttribute(c("error"))==="not-found"||(g.delete(t),Q(t))})}var y=new Set;function U(t){y.size||setTimeout(_,0),y.add(t)}function Y(t,e){s.forEach(n=>{let r=l.get(n);if(!r||!n.isConnected)return;let o=E(n).key;o!==t&&o!==e.handle&&o!==e.id||JSON.stringify(r.product)!==JSON.stringify(e)&&r.update(e)})}function _(){let t=[...y];y=new Set,t.forEach(e=>{R(e).then(n=>{Y(e,n)}).catch(n=>{f(n,`refresh ${e}`)})})}var i=null,j=t=>(i?.add(t),t);function G(){if(!i)return;let t=[...i];Promise.allSettled(t).then(()=>{if(!(!i||t.some(e=>!i?.has(e)))){if(t.length!==i.size){G();return}i=null,document.documentElement.classList.remove(`${a.prefix}-market-pending`)}})}function I(t){if(!w(t))return{country:void 0,language:void 0,products:[]};let{products:e}=t,n=Array.isArray(e)?e:[];return{country:k(t.country)??void 0,language:v(t.language)??void 0,products:n.filter(T)}}var O=new WeakSet;function at(t=document){J(t,W).forEach(e=>{if(O.has(e))return;O.add(e);let n;try{n=JSON.parse(e.textContent)}catch(u){P("bad data-tether-hydrate",u);return}let{country:r,language:o,products:d}=I(n);if(K(d),r===a.country&&o===a.language){M(d);return}h("hydration skipped: other market"),i||(i=new Set,document.documentElement.classList.add(`${a.prefix}-market-pending`))})}export{g as a,ut as b,s as c,N as d,q as e,J as f,Q as g,dt as h,j as i,G as j,at as k};
@@ -1 +0,0 @@
1
- import{a as Pt,d as Q,e as kt}from"./chunk-NF5H2Q7V.js";import{c as Et}from"./chunk-RVWHBZAF.js";import{b as Z,d as R}from"./chunk-WHNUPECA.js";import{A as W,C as v,D as vt,E as At,F as g,G as k,H as M,K as Lt,Q as D,a as b,c as q,d as H,h as V,k as yt,l as L,m as s,n as f,o as Ct,p as d,t as y,v as bt,w as P,x as St,y as T,z as wt}from"./chunk-A6BZFYZY.js";import{D as ht,F as w,r as gt,x as l}from"./chunk-PZERNTCD.js";var ne={id:"string",quantity:"number",attributes:["object"],cost:{totalAmount:R,subtotalAmount:R,amountPerQuantity:R},merchandise:{id:"string",selectedOptions:["object"],product:"object"}},tt={id:"string",checkoutUrl:"string",totalQuantity:"number",attributes:["object"],discountCodes:["object"],cost:{totalAmount:R,subtotalAmount:R},lines:{nodes:[ne]}};var re='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',ie=60,et=!1,K=null,oe=t=>t!==null&&"focus"in t,It=t=>d(t,re).filter(e=>e.offsetParent!==null||e===document.activeElement),$=()=>d(document,s("cart-drawer")),nt=t=>t.classList.contains(l.cartDrawerOpenClass);function S(){let t=$();return t.length?t.some(nt):et}function j(t){d(document,s("cart-open")).forEach(e=>{e.setAttribute("aria-expanded",String(t))}),$().forEach(e=>{e.hasAttribute("role")||e.setAttribute("role","dialog"),!e.hasAttribute("aria-label")&&!e.hasAttribute("aria-labelledby")&&e.setAttribute("aria-label",f(e,"cart-label")||"Cart"),e.setAttribute("aria-modal",String(t)),!nt(e)&&(e.setAttribute("aria-hidden","true"),l.cartFocus&&(e.inert=!0))})}function ae(t){let e=It(t)[0]??t;e===t&&!t.hasAttribute("tabindex")&&(t.tabIndex=-1),e.focus({preventScroll:!0})}function B(){if(S())return;et=!0;let t=$().filter(n=>f(n,"cart-drawer")!=="manual");t.forEach(n=>{n.inert=!1,n.classList.add(l.cartDrawerOpenClass),n.setAttribute("aria-hidden","false")}),j(!0);let[e]=t;l.cartFocus&&e&&(K=oe(document.activeElement)?document.activeElement:null,setTimeout(()=>{ae(e)},ie)),l.onCartOpen?.(t),y("cart-toggled",{open:!0})}function rt(){if(!S())return;et=!1;let t=$(),e=t.some(n=>n.contains(document.activeElement));t.forEach(n=>{n.classList.remove(l.cartDrawerOpenClass),n.setAttribute("aria-hidden","true"),l.cartFocus&&(n.inert=!0)}),j(!1),e&&K?.isConnected&&K.focus({preventScroll:!0}),K=null,l.onCartClose?.(t),y("cart-toggled",{open:!1})}function xt(){S()?rt():B()}function se(t){if(t.key!=="Tab"||!l.cartFocus||!S())return;let e=$().find(nt);if(!e)return;let n=It(e),r=n[0],i=n.at(-1);if(!r||!i)return;let o=document.activeElement,a=t.shiftKey?o===r:o===i;e.contains(o)&&!a||(t.preventDefault(),(t.shiftKey?i:r).focus())}var ue=/^image:(\d+)$/,Tt="metafield:",ce=/^(rich_text|multi_line_text)_field$/,le=["","true","all","*"],ot=t=>t.tagName==="SELECT",it=(t,e)=>t.$(`select${e}`).filter(ot);function de(t,e){let n=e.images.nodes,r=[...t.children].map(o=>o.tagName==="IMG"?o:o.querySelector("img"));!St(t)&&r.length===n.length&&r.every((o,a)=>bt(o?.getAttribute("src"),n[a]?.url))||T(t,n,(o,a)=>{let u=o.matches(`img,${s("bind","image")}`)?o:d(o,"img")[0]??o;P(u,a.url,a.altText||e.title)})}function me(t,e,n){let r=n.indexOf("."),i=n.slice(0,r),o=n.slice(r+1),a=(e.metafields??[]).find(c=>c?.namespace===i&&c.key===o);if(!a){g(t,"");return}let u=a.reference?.image;if(u){P(t,u.url,u.altText);return}ce.test(a.type)&&(t.style.whiteSpace="pre-line"),g(t,a.value)}var pe=new Map(Object.entries({title:t=>t.title,"description-text":t=>t.description,vendor:t=>t.vendor,type:t=>t.productType,handle:t=>t.handle,"published-at":t=>vt(t.publishedAt),"min-price":t=>v(t.priceRange.minVariantPrice),"max-price":t=>v(t.priceRange.maxVariantPrice)}));function fe(t,e){let n=(t.getAttribute("exclude")??"").split(",").map(i=>i.trim()).filter(Boolean),r=e.tags.filter(i=>!n.includes(i));T(t,r,(i,o)=>{g(i,o)})}function ge(t,e,n){let r=pe.get(e);if(r){g(t,r(n));return}switch(e){case"description":At(t,n.descriptionHtml);break;case"featured-image":P(t,n.featuredImage?.url,n.featuredImage?.altText||n.title);break;case"url":case"link":{let i=W(n.handle,n.id);i&&t.setAttribute("href",i),e==="url"&&!t.firstElementChild&&!t.textContent.trim()&&g(t,n.title);break}case"images":de(t,n);break;case"tags":fe(t,n);break;default:he(t,e,n)}}function he(t,e,n){let r=ue.exec(e);if(r){let i=n.images.nodes[Number(r[1])-1]??n.featuredImage;P(t,i?.url,i?.altText||n.title)}else e.startsWith(Tt)&&me(t,n,e.slice(Tt.length))}function ye(t){let{product:e}=t;t.$(s("option-list")).forEach(n=>{let r=t.optName(f(n,"option-list")),i=e.options.find(o=>o.name===r);if(!i||i.optionValues.length<=1&&Ct(n,"hide-single")){M(n,!1);return}T(n,i.optionValues,(o,a)=>{o.setAttribute(L("option-value"),a.name);let u=d(o,s("bind","option-value"))[0];u?g(u,a.name):o.firstElementChild||g(o,a.name);let c=d(o,s("bind","swatch"))[0],{swatch:p}=a;!c||!p||(p.color&&(c.style.backgroundColor=p.color),p.image?.previewImage&&P(c,p.image.previewImage.url,a.name))})})}function Ce(t){let{product:e}=t;it(t,s("option")).forEach(n=>{let r=e.options.find(i=>i.name===t.optName(f(n,"option")));if(!r){M(n,!1);return}n.replaceChildren(...r.optionValues.map(i=>new Option(i.name,i.name)))}),it(t,s("variant-select")).forEach(n=>{n.replaceChildren(...e.variants.nodes.map(r=>new Option(r.title,r.id)))}),it(t,s("plan")).forEach(n=>{let r=t.plans.map(a=>new Option(a.name,a.id)),i=!e.requiresSellingPlan&&f(n,"plan")!=="subscription-only",o=n.getAttribute(L("one-time-label"))||"One-time purchase";n.replaceChildren(...i?[new Option(o,"")]:[],...r)})}function be(t){t.$(s("plan-list")).forEach(e=>{let n=(f(e,"plan-list")??"").trim(),r=le.includes(n.toLowerCase())?null:n,i=t.plans.filter(o=>!r||o.group.name===r);T(e,i,(o,a)=>{o.setAttribute(L("plan-value"),a.id),!o.firstElementChild&&!o.querySelector(s("plan-bind"))&&g(o,a.name)})})}function Xe(t){t.$(s("bind")).forEach(e=>{ge(e,f(e,"bind")??"",t.product)}),ye(t),Ce(t),be(t)}var Mt="Default Title",at=(t,e)=>e.get(t.id)?.quantity??t.quantity,$t=t=>t.split("/").pop()??t;function Se(t){let e=t.merchandise,n=W(e.product.handle,e.product.id);if(!n)return null;let r=new URLSearchParams;r.set("variant",$t(e.id));let i=t.sellingPlanAllocation?.sellingPlan.id;return i&&r.set("selling_plan",$t(i)),`${n}${n.includes("?")?"&":"?"}${r.toString()}`}var Ot=t=>t.merchandise.product.title,Rt={title:Ot,"product-title":Ot,"variant-title":t=>t.merchandise.title===Mt?"":t.merchandise.title,options:t=>t.merchandise.selectedOptions.filter(e=>e.value!==Mt).map(e=>`${e.name}: ${e.value}`).join(", "),vendor:t=>t.merchandise.product.vendor,sku:t=>t.merchandise.sku??"",price:t=>v(t.cost.amountPerQuantity),"compare-at-price":t=>v(t.cost.compareAtAmountPerQuantity??t.merchandise.compareAtPrice),"line-total":t=>v(t.cost.totalAmount),"line-subtotal":t=>v(t.cost.subtotalAmount),quantity:(t,e)=>at(t,e.pending),plan:t=>t.sellingPlanAllocation?.sellingPlan.name??"","plan-description":t=>t.sellingPlanAllocation?.sellingPlan.description??"",components:t=>(t.lineComponents??[]).map(e=>`${e.quantity} \xD7 ${e.merchandise.product.title}`).join(", ")},Ut="attribute:";function we(t,e,n){if(Object.hasOwn(Rt,e))return Rt[e]?.(t,n);if(!e.startsWith(Ut))return;let r=e.slice(Ut.length);return t.attributes.find(i=>i.key===r)?.value??""}function ve(t,e,n){let r=kt(n),i=!n.requiresSellingPlan&&f(t,"line-plan")!=="subscription-only",o={value:"",label:t.getAttribute(L("one-time-label"))||"One-time purchase"},a=[...i?[o]:[],...r.map(c=>({value:c.id,label:c.name}))],u=a.map(c=>c.value).join("|");t.dataset.tetherSig!==u&&(t.replaceChildren(...a.map(c=>{let p=document.createElement("option");return p.value=c.value,p.textContent=c.label,p})),t.dataset.tetherSig=u),t.value=e.sellingPlanAllocation?.sellingPlan.id??"",M(t,r.length>0)}function Ae(t,e,n){let r=!!e.sellingPlanAllocation;t.classList.toggle("is-subscription",r);let i=n.warnings.find(u=>u.target===e.id);t.classList.toggle("is-warning",!!i);let o=n.pending.has(e.id);t.classList.toggle("is-busy",o),o?t.setAttribute("aria-busy","true"):t.removeAttribute("aria-busy"),d(t,s("line","warning")).forEach(u=>{k(u,i?.message??"")});let a=new Map([["subscription",r],["one-time",!r],["on-sale",Pt(e.cost.compareAtAmountPerQuantity?.amount,e.cost.amountPerQuantity.amount)],["has-components",(e.lineComponents??[]).length>0],["warning",!!i]]);d(t,s("line-show")).forEach(u=>{let c=f(u,"line-show"),p=c===null?void 0:a.get(c);p!==void 0&&M(u,p)})}function Le(t,e,n){let r=e.merchandise;t.setAttribute(L("line-id"),e.id),d(t,s("line")).forEach(o=>{let a=f(o,"line")??"";if(a==="image"){P(o,r.image?.url??r.product.featuredImage?.url,r.product.title);return}if(a==="url"){let c=Se(e);c&&o.setAttribute("href",c);return}let u=we(e,a,n);u!==void 0&&k(o,u)}),Ae(t,e,n),d(t,s("line-plan")).filter(ot).forEach(o=>{Et(r.product.handle).then(a=>{ve(o,e,a)}).catch(a=>{w(a,"line plan options")})})}function Pe(t,e){let n=t?.totalQuantity??0,r=(t?.lines.nodes??[]).some(o=>o.sellingPlanAllocation),i=new Map([["cart-empty",n===0],["cart-filled",n>0],["cart-has-subscription",r],["cart-no-subscription",!r],["cart-has-discount",(t?.discountCodes??[]).some(o=>o.applicable)],["cart-error",e.failed],["cart-warning",e.warnings.length>0]]);d(document,s("show")).forEach(o=>{let a=f(o,"show"),u=a===null?void 0:i.get(a);u===void 0||o.closest(s("product"))||M(o,u)}),d(document,s("checkout")).forEach(o=>{o.classList.toggle("is-disabled",!n),o.setAttribute("aria-disabled",String(!n))})}function ke(t){d(document,`textarea${s("cart-note")},input${s("cart-note")}`).forEach(e=>{document.activeElement!==e&&g(e,t?.note??"")}),d(document,s("cart-discounts")).forEach(e=>{T(e,t?.discountCodes??[],(n,r)=>{n.setAttribute(L("discount-code"),r.code);let i=n.querySelector(s("discount","code"))??(n.firstElementChild?null:n);i&&g(i,r.code),n.classList.toggle("is-inapplicable",!r.applicable)})})}function qt(t){let{cart:e}=t,n=r=>e?v(e.cost[r]):"";j(S()),d(document,s("cart-count")).forEach(r=>{k(r,e?.totalQuantity??0)}),d(document,s("cart-subtotal")).forEach(r=>{k(r,n("subtotalAmount"))}),d(document,s("cart-total")).forEach(r=>{k(r,n("totalAmount"))}),d(document,s("cart-checkout-charge")).forEach(r=>{k(r,n("checkoutChargeAmount"))}),Pe(e,t),d(document,s("cart-warning")).forEach(r=>{k(r,[...new Set(t.warnings.map(i=>i.message))].join(" "))}),ke(e),d(document,s("cart-lines")).forEach(r=>{wt(r,e?.lines.nodes??[],i=>i.id,(i,o)=>{Le(i,o,t)},{onEnter:l.onLineEnter,onLeave:l.onLineLeave})}),e&&Lt("cart")}function Dt(t){d(document,s("cart-count")).forEach(e=>{/^\s*0?\s*$/.test(e.textContent)&&(e.textContent=String(t))})}function st(t,e="localStorage"){try{return window[e].getItem(t)}catch{return null}}function ut(t,e,n="localStorage"){try{window[n].setItem(t,e)}catch{}}function Qt(t,e="localStorage"){try{window[e].removeItem(t)}catch{}}var Nt=/^gid:\/\/shopify\/Cart\/[\w-]+(\?key=[\w-]+)?$/;var h={kind:"unknown"},U=[],O=new Map,G=()=>h;function m(){switch(h.kind){case"ready":case"error":return h.cart;case"unknown":case"empty":return null}}var Ft=()=>U,ct=t=>t?{kind:"ready",cart:t}:{kind:"empty"},Ht=()=>`${l.storageKey}:seen`;function E(){let t=st(l.storageKey);return t?Nt.test(t)?t:(I(),null):null}function I(){Qt(l.storageKey)}function lt(t){h=ct(t),t&&ut(l.storageKey,t.id)}function N(){qt({cart:m(),warnings:U,pending:O,failed:h.kind==="error"})}function _(t){N(),y("cart-updated",{cart:m(),reason:t})}function C(t,e){return lt(t),ut(Ht(),`${Date.now()}|${t?.totalQuantity??0}`),_(e),t}function F(t){h=t.kind==="loaded"?ct(t.cart):{kind:"error",error:t.error,cart:null},_("load")}function Ee(){let t=st(Ht())?.split("|")[1]??"",e=Number(t);return/^\d+$/.test(t)&&Number.isSafeInteger(e)?e:null}function Vt(){if(h.kind!=="unknown")return;let t=Ee();t!==null&&Dt(t)}function Wt(t){U=t.filter((e,n)=>t.findIndex(r=>r.message===e.message)===n).map(e=>({...e,message:l.warningText?.(e)||e.message})),U.length&&y("cart-warning",{warnings:U})}var _t=()=>{};function Ie(){let t=Promise.resolve();return e=>{let n=t.then(e);return t=n.then(_t,_t),n}}var xe=Ie();function Kt(t){return xe(t).then(e=>(h.kind==="error"&&(h=ct(h.cart),N()),e),e=>{throw h={kind:"error",error:e,cart:m()},N(),y("cart-error",{error:e}),e})}var dt=t=>at(t,O),Te=()=>({open:S(),count:m()?.totalQuantity??0,loaded:h.kind!=="unknown",warnings:[...U]});function jt(t){let e=["cart-updated","cart-toggled"].map(r=>`${l.prefix}:${r}`),n=()=>{t(m(),Te())};return e.forEach(r=>{document.addEventListener(r,n)}),n(),()=>{e.forEach(r=>{document.removeEventListener(r,n)})}}var Me=/does not exist|not found|invalid id/i,$e=t=>H({[t]:q({cart:q(tt)})});function X(t){return t instanceof b?t.userErrors?.some(e=>e.field?.[0]==="cartId")?!0:(t.errors??[]).some(e=>Me.test(e.message)):!1}function Gt(t){if(!(t instanceof b))return!1;let{code:e,status:n=0}=t;return e==="NETWORK"||e==="INVALID_RESPONSE"||e==="SERVER_ERROR"||n>=500}function Xt(t,e=1,n={}){let r=typeof t=="object"&&t!==null?t:{...n,quantity:e,...t==null?{}:{variantId:t}},i=Q.variant(r.merchandiseId||r.variantId||r.id);if(!i)throw new b("add(): variantId is required");let o=parseInt(String(r.quantity??1),10),a={merchandiseId:i,quantity:Math.max(1,o||1)},u=Q.sellingPlan(r.sellingPlanId||r.sellingPlan);u&&(a.sellingPlanId=u);let c=D(r.attributes);return c.length&&(a.attributes=c),a}function Oe(t,e,n){return r=>`mutation Tether_${t}(${e}){${t}(${n}){cart{...TetherCart}userErrors{field message}warnings{code message target}}}${Z(r)}`}async function Yt(t,e,n,r){let i=await V(Oe(t,e,n),r,$e(t),{operation:"mutation"}),o=yt(i[t],t);return Wt(o.warnings??[]),o.cart}function Bt(t){let e=l.country?{buyerIdentity:{countryCode:l.country},...t}:t;return Yt("cartCreate","$input: CartInput!","input: $input",{input:e})}async function x({name:t,args:e,inner:n,variables:r,createInput:i}){let o=E();if(!o)return i?Bt(i):null;try{return await Yt(t,`$cartId: ID!, ${e}`,`cartId: $cartId, ${n}`,{...r,cartId:o})}catch(a){if(!X(a)||(I(),!i))throw a;return ht("cart expired, creating a new one"),Bt(i)}}async function mt(t){return(await V(n=>`query TetherCart($id:ID!){cart(id:$id){...TetherCart}}${Z(n)}`,{id:t},H({cart:q(tt)}))).cart}async function zt(t){return(await V("query TetherCheckout($id:ID!){cart(id:$id){checkoutUrl}}",{id:t},H({cart:q({checkoutUrl:"string"})}))).cart?.checkoutUrl??null}function Jt(t,e){let n=typeof e=="number"?{quantity:e}:e,r={id:t};n.quantity!==void 0&&(r.quantity=n.quantity),"sellingPlanId"in n&&(r.sellingPlanId=n.sellingPlanId?Q.sellingPlan(n.sellingPlanId):null),n.attributes&&(r.attributes=D(n.attributes));let i=n.merchandiseId||n.variantId;return i&&(r.merchandiseId=Q.variant(i)),r}var pt=t=>x({name:"cartLinesUpdate",args:"$lines: [CartLineUpdateInput!]!",inner:"lines: $lines",variables:{lines:t},createInput:null}),Y=t=>x({name:"cartLinesRemove",args:"$lineIds: [ID!]!",inner:"lineIds: $lineIds",variables:{lineIds:t},createInput:null}),Zt=(t,e)=>e>0?pt([{id:t,quantity:e}]):Y([t]);var ft=null;function te(t){ft=t}var Re=t=>zt(t).then(e=>({kind:"url",url:e}),e=>({kind:"failed",error:e}));async function Ue(){if(!ft)return null;try{let t=await ft();return t&&`${t}${t.includes("?")?"&":"?"}logged_in=true`}catch(t){return w(t,"account checkout"),null}}async function qe(t){let e=Re(t),n=await Ue();if(n)return n;let r=await e;if(r.kind==="failed")throw r.error;if(!r.url)throw new b("No checkoutUrl (cart empty or expired)");return r.url}function De(t){try{t.opener=null}catch{}}async function ee(t=l.checkoutTarget){let e=E(),n=m();if(!e||n&&!n.totalQuantity)return null;let r=t==="_blank"?window.open("","_blank"):null;r&&De(r);try{let i=await qe(e);if(!gt(i))throw new b("The checkout URL is not https: not opened");return y("checkout",{url:i,cart:m()}),r&&!r.closed?r.location.href=i:window.location.href=i,i}catch(i){return r?.close(),w(i,"checkout failed"),null}}var J=()=>m()?.lines.nodes??[];async function Qe(){let t=E();if(t)try{let e=await mt(t);e||I(),C(e,"load")}catch(e){w(e,"cart reload after a failed change")}}function A(t){return Kt(()=>t().catch(async e=>{throw Gt(e)&&await Qe(),e}))}function Ne(t,e){let n=J().find(u=>u.id===t);if(!n)return Promise.resolve(m());let r=Math.max(0,dt(n)+e),i={quantity:r};O.set(t,i),_("pending");let o=()=>O.get(t)===i;return A(async()=>{if(!o())return m();if(J().find(p=>p.id===t)?.quantity===r)return m();let c=await Zt(t,r);return o()?C(c,r>0?"update":"remove"):(lt(c),c)}).finally(()=>{o()&&(O.delete(t),_("settled"))})}function _e(t){let e=(m()?.discountCodes??[]).map(r=>r.code),n=typeof t=="function"?t(e):t;return(Array.isArray(n)?n:[n]).map(r=>r.trim()).filter(Boolean)}function Fe(t){let e=new Map((m()?.attributes??[]).map(n=>[n.key,n.value]));return D(t).forEach(n=>e.set(n.key,n.value)),[...e].filter(([,n])=>n!=="").map(([n,r])=>({key:n,value:r}))}async function He(){let t=E();if(!t)return F({kind:"loaded",cart:null}),null;Vt();try{let e=await mt(t);e||I(),F({kind:"loaded",cart:e})}catch(e){w(e,"cart load failed"),X(e)&&I(),F({kind:"failed",error:e})}return m()}var z={init:He,id:E,get status(){return G()},get state(){return m()},get lines(){return[...J()]},get count(){return m()?.totalQuantity??0},get loaded(){return G().kind!=="unknown"},get lastError(){let t=G();return t.kind!=="error"?null:t.error instanceof Error?t.error:new Error(String(t.error))},get warnings(){return[...Ft()]},get pendingQty(){return O},setCheckoutResolver:te,forgetSaved(){I(),F({kind:"loaded",cart:null})},render:N,subscribe:jt,add(t,e=1,n={}){let r=(Array.isArray(t)?t:[t]).map(i=>Xt(i,e,n));return A(async()=>{let i=await x({name:"cartLinesAdd",args:"$lines: [CartLineInput!]!",inner:"lines: $lines",variables:{lines:r},createInput:{lines:r}});if(!i)throw new b("Shopify answered the add without a cart");return C(i,"add"),y("added",{cart:i,lines:r}),l.openCartOnAdd&&B(),i})},updateLine(t,e){let n=typeof e=="number"?e:e.quantity;if(n!==void 0&&n<=0)return z.removeLine(t);let r=Jt(t,e);return A(async()=>C(await pt([r]),"update"))},changeQuantity:Ne,quantityOf:dt,removeLine(t){let e=Array.isArray(t)?t:[t];return A(async()=>C(await Y(e),"remove"))},clear(){return A(async()=>{let t=J().map(e=>e.id);return t.length?C(await Y(t),"remove"):m()})},setNote(t){let e={note:t??""};return A(async()=>C(await x({name:"cartNoteUpdate",args:"$note: String!",inner:"note: $note",variables:e,createInput:e}),"note"))},setAttributes(t){return A(async()=>{let e={attributes:Fe(t)},n=await x({name:"cartAttributesUpdate",args:"$attributes: [AttributeInput!]!",inner:"attributes: $attributes",variables:e,createInput:e});return C(n,"attributes")})},setDiscountCodes(t){return A(async()=>{let e={discountCodes:_e(t)},n=await x({name:"cartDiscountCodesUpdate",args:"$discountCodes: [String!]!",inner:"discountCodes: $discountCodes",variables:e,createInput:e});return C(n,"discount")})},async applyDiscount(t){let e=await z.setDiscountCodes(i=>[...new Set([...i,t])]),n=t.toLowerCase();if((e?.discountCodes??[]).find(i=>i.code.toLowerCase()===n)?.applicable)return e;try{await z.removeDiscount(t)}catch(i){w(i,"removing a discount code Shopify refused")}throw new b(`Discount code not valid: ${t}`,{code:"INVALID_DISCOUNT"})},removeDiscount(t){let e=t.toLowerCase();return z.setDiscountCodes(n=>n.filter(r=>r.toLowerCase()!==e))},setBuyerIdentity(t,{create:e=!0}={}){return A(async()=>{let n=await x({name:"cartBuyerIdentityUpdate",args:"$buyerIdentity: CartBuyerIdentityInput!",inner:"buyerIdentity: $buyerIdentity",variables:{buyerIdentity:t},createInput:e?{buyerIdentity:t}:null}).catch(r=>{if(e||!X(r))throw r;return null});return C(n,"buyer-identity")})},checkout:ee,drawers:$,isOpen:S,open:B,close:rt,toggle:xt};export{se as a,ot as b,it as c,Xe as d,st as e,ut as f,Qt as g,z as h};
@@ -1 +0,0 @@
1
- var S=Object.defineProperty;var Z=(n,e,t)=>e in n?S(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Yn=(n,e)=>{for(var t in e)S(n,t,{get:e[t],enumerable:!0})};var Gn=(n,e,t)=>Z(n,typeof e!="symbol"?e+"":e,t);var Q=/^(\d{4})-(01|04|07|10)$/;function T(n){let e=Q.exec(typeof n=="string"?n:"");return e?{year:Number(e[1]),month:Number(e[2])}:null}var E=n=>T(n)!==null,B=(n,e)=>`${n}-${String(e).padStart(2,"0")}`;function A(n,e=1){let t=T(n);if(!t)throw new Error(`not a quarterly Shopify API version: ${n}`);let o=t.year*4+(t.month-1)/3+e;return B(Math.floor(o/4),o%4*3+1)}function zn(n,e=new Date){if(n==="unstable")return{version:n,ok:!1,note:'"unstable" changes without notice: pin a dated version such as 2026-07'};let t=T(n);if(!t)return{version:n,ok:!1,note:"not a quarterly version (YYYY-01, -04, -07 or -10)"};let o=new Date(Date.UTC(t.year,t.month-1,1)),r=new Date(Date.UTC(t.year,t.month-1+12,1)),i=(r.getTime()-e.getTime())/2630016e3,d=o<=e,l=`supported until about ${r.toISOString().slice(0,7)}`;return d?i<=0?l="no longer supported: Shopify falls back to the oldest supported version. Upgrade (see docs/reference.md)":i<3&&(l=`${l}: plan the upgrade to ${A(n)} or later (see docs/reference.md)`):l="not released yet (release candidate at best)",{version:n,ok:d&&i>0,monthsLeft:Math.round(i),next:A(n),note:l}}function C(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function q(n,e){return C(n)?n[e]:void 0}function v(n){return Array.isArray(n)?n:[]}function W(n){return typeof n=="string"&&n!==""?n:null}var X=n=>typeof n=="number"&&Number.isFinite(n)?n:null,Qn=n=>X(n)??0,R=(n,e)=>v(n).map(t=>e(t)),Bn=(n,e)=>({nodes:R(q(n,"nodes"),e)}),qn=n=>R(n,W).filter(e=>e!==null);var J=/^[A-Z]{2}$/,nn=new Set(["XX","T1"]),en=new Set(["PT_BR","PT_PT","ZH_CN","ZH_TW"]),tn=/^[A-Z]{2,3}$/;function h(n){let e=(typeof n=="string"?n:"").trim().toUpperCase();return!J.test(e)||nn.has(e)?null:e}function x(n){let e=(typeof n=="string"?n:"").trim().replace("-","_").toUpperCase();if(en.has(e))return e;let t=e.split("_")[0]??"";return tn.test(t)?t:null}var ne={domain:["PUBLIC_SHOPIFY_DOMAIN","PUBLIC_SHOPIFY_STORE_DOMAIN","SHOPIFY_DOMAIN"],token:["PUBLIC_SHOPIFY_STOREFRONT_TOKEN","PUBLIC_SHOPIFY_STOREFRONT_ACCESS_TOKEN","SHOPIFY_STOREFRONT_TOKEN"]};function ee(n){if(typeof n!="string")return!1;try{return new URL(n).protocol==="https:"}catch{return!1}}function te(n){return/^shp[a-z]{2}_/.test(n.trim())}function oe(n,e){if(!n)return"";let t=parseFloat(n.amount);if(Number.isNaN(t))return"";try{return new Intl.NumberFormat(e||void 0,{style:"currency",currency:n.currencyCode}).format(t)}catch{return`${n.currencyCode} ${t.toFixed(2)}`}}function re(n,e,t){if(!/\{(handle|id)\}/.test(n))return e?`${n.replace(/\/$/,"")}/${encodeURIComponent(e)}`:null;let o=t?t.split("/").at(-1)??"":"";return n.includes("{handle}")&&!e||n.includes("{id}")&&!o?null:n.replace(/\{handle\}/g,encodeURIComponent(e??"")).replace(/\{id\}/g,encodeURIComponent(o))}function ie(n){let e=String(n??"").trim();return e?e.startsWith("gid://")?e:/^\d+$/.test(e)?`gid://shopify/Product/${e}`:/\/products\/([^/?#]+)/.exec(e)?.[1]??e:null}var _="2026-07";var on=/^[A-Za-z0-9_.-]+$/,rn=/^(\$app(:[A-Za-z0-9_-]+)?|[A-Za-z0-9_.-]+)$/,w=(n,e)=>rn.test(n)&&on.test(e);function N(n){let e=n.indexOf(".");if(e<=0)return null;let t=n.slice(0,e),o=n.slice(e+1);return w(t,o)?{namespace:t,key:o}:null}var sn=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i,an=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,un=/^[A-Za-z_$][\w$]*$/,M="https://site.invalid",cn=new Set(["localhost","127.0.0.1","[::1]"]),I=["saved","server","webflow"],ln=["no-banner","default-banner","custom-banner"],y=n=>typeof n=="string"&&n!=="",fn=n=>typeof n=="function";function L(n,e){if(typeof n!="string"||!n)return"";let t=n.replace(/^https?:\/\//,"").replace(/\/.*$/,"");return yn(t)?t:(e("domain",n),"")}function U(n){if(!y(n))return!1;try{let e=new URL(n,`${M}/`);return e.origin===M?!0:e.protocol==="https:"||e.protocol==="http:"&&cn.has(e.hostname)}catch{return!1}}function F(n,e){return n==null||n===""?null:typeof n=="string"&&(U(n)||dn(n))?n:(e("partsUrl",n),null)}function dn(n){if(typeof location>"u")return!1;try{return new URL(n).origin===location.origin}catch{return!1}}function pn(n){if(typeof n!="string")return null;try{let e=new URL(n);return e.protocol==="https:"&&e.href===new URL(e.origin).href?e.origin:null}catch{return null}}function $(n,e){if(!Array.isArray(n))return e("embedOrigins",n),[];let t=[],o=n;for(let r of o){let i=pn(r);i?t.push(i):e("embedOrigin",r)}return t}function gn(n){if(typeof n=="string")return N(n);if(typeof n!="object"||n===null)return null;let e=Reflect.get(n,"namespace"),t=Reflect.get(n,"key");return typeof e!="string"||typeof t!="string"?null:w(e,t)?{namespace:e,key:t}:null}function V(n,e){if(!Array.isArray(n))return e("metafields",n),[];let t=[],o=n;for(let r of o){let i=gn(r);i?t.push(typeof r=="string"?r:i):e("metafield",r)}return t}var p=n=>e=>n(e)?e:void 0,yn=n=>y(n)&&sn.test(n),mn=n=>y(n)&&an.test(n),On=n=>typeof n=="boolean"||y(n)&&un.test(n),g=p(U),k=p(y),P=p(n=>typeof n=="boolean"),D=p(fn);function m(n,e,t,o){if(e==null)return null;if(!C(e))return o(n,e),null;let r={};for(let i in t){let d=e[i];if(d===void 0)continue;let l=t[i](d);l===void 0?o(`${n}.${i}`,d):r[i]=l}return r}var Cn={server:g,orderUrl:g,subscriptionsUrl:g,paymentUrl:g,logoutUrl:g,locale:k,navigate:D},kn="customer accounts need the Worker since 0.7.0: set account.server",Tn={country:k,language:k,locale:k},hn={detect:n=>{if(typeof n=="boolean")return n;let e=Array.isArray(n)?n:[n];return typeof n=="string"||Array.isArray(n)?I.filter(t=>e.includes(t)):void 0},locales:n=>{if(!C(n))return;let e={};for(let[t,o]of Object.entries(n)){let r=m(`markets.locales.${t}`,o,Tn,()=>{});r&&(e[t]=r)}return e},cookie:p(mn),remember:P,strict:P},xn={consent:n=>ln.find(e=>e===n),proxy:n=>n!==void 0&&!!n},wn={dataLayer:p(On),shopify:n=>typeof n=="boolean"?n:m("analytics.shopify",n,xn,()=>{})??void 0,onEvent:D};function H(n,e,t){let o=m("account",n,Cn,e);if(o===null)return null;let{server:r}=o;return r===void 0?(t(kn),null):{...o,server:r}}var b=(n,e)=>m("markets",n,hn,e),K=(n,e)=>m("analytics",n,wn,e);var u={domain:"",token:"",apiVersion:_,country:void 0,language:void 0,locale:void 0,markets:null,prefix:"tether",productPath:"/product",collectionPath:"/collection",metafields:[],embedOrigins:[],imagesFirst:25,variantsFirst:100,sellingPlanGroupsFirst:10,sellingPlansFirst:25,collectionFirst:24,retries:2,requestTimeout:15e3,revalidate:!0,storageKey:"",cartDrawerOpenClass:"is-open",openCartOnAdd:!0,cartFocus:!0,checkoutTarget:"_self",defaultPurchase:"one-time",variantUrl:!1,maxAge:60,lowStock:5,searchDelay:150,autoMount:!0,observe:!1,astro:!0,partsUrl:null,analytics:null,account:null,warningText:null,formatMoney:null,onLayoutChange:null,onCartOpen:null,onCartClose:null,onLineEnter:null,onLineLeave:null,onValueChange:null,onError:null,debug:!1},a={...u};function z(n){let e=t=>(c(`Tether.config is read-only (${String(t)}): pass options to Tether.init() instead`),!1);return new Proxy(n,{get(t,o){let r=Reflect.get(t,o);return typeof r=="object"&&r!==null?z(r):r},set:(t,o)=>e(o),deleteProperty:(t,o)=>e(o),defineProperty:(t,o)=>e(o)})}var Oe=z(a),Sn=/^[a-z][a-z0-9-]*$/,An=["revalidate","openCartOnAdd","cartFocus","variantUrl","autoMount","observe","astro","debug"],En=["token","productPath","collectionPath"],Rn=["imagesFirst","variantsFirst","sellingPlanGroupsFirst","sellingPlansFirst","collectionFirst","retries","requestTimeout","maxAge","lowStock","searchDelay"],_n=["warningText","formatMoney","onLayoutChange","onCartOpen","onCartClose","onLineEnter","onLineLeave","onValueChange","onError"];function f(n,e,t){return e!==void 0&&c(`invalid ${n} ${JSON.stringify(e)}: using ${JSON.stringify(t)}`),t}function s(n,e){c(`invalid ${n} ${JSON.stringify(e)}: ignored`)}function Nn(n){for(let e of Object.keys(n))Object.hasOwn(u,e)||c(`unknown option ${JSON.stringify(e)}: ignored`)}function Mn(n,e,t){typeof t=="function"?n[e]=t:t!=null&&s(e,t)}var Y=2147483647,Pn=10,O={min:1,max:250},In={imagesFirst:O,variantsFirst:O,sellingPlanGroupsFirst:O,sellingPlansFirst:O,collectionFirst:O,requestTimeout:{max:Y},searchDelay:{max:Y},retries:{max:Pn}};function Ln(n,e){let{min:t=0,max:o}=In[n]??{};return typeof e!="number"||!Number.isInteger(e)||e<t?f(n,e,u[n]):o===void 0||e<=o?e:(c(`${n} ${String(e)} is more than its maximum: using ${String(o)}`),o)}function Un(n,e){return typeof e=="boolean"?e:f(n,e,u[n])}function Fn(n,e){return typeof e=="string"?e:f(n,e,u[n])}var $n=/^\S+$/;function Vn(n,e){return typeof e=="string"&&$n.test(e)?e:f(n,e,u[n])}function Dn(n){if(!(n==null||n==="")){try{if(typeof n=="string"&&Intl.getCanonicalLocales(n).length)return n}catch{}s("locale",n)}}function G(n,e,t){return t.find(o=>o===e)??f(n,e,t[0])}function Hn(n){return n==="unstable"?(c('apiVersion "unstable" changes without notice. Pin a dated version (e.g. 2026-07).'),n):E(n)?n:f("apiVersion",n,u.apiVersion)}function j(n,e,t){if(e==null||e==="")return;let o=t(e);if(o!==null)return o;s(n,e)}function Kn(n){Nn(n);let e=L(n.domain,s),t=typeof n.prefix=="string"&&Sn.test(n.prefix)?n.prefix:f("prefix",n.prefix,u.prefix),o={...u,domain:e,apiVersion:Hn(n.apiVersion),country:j("country",n.country,h),locale:Dn(n.locale),partsUrl:F(n.partsUrl,s),language:j("language",n.language,x),markets:b(n.markets,s),analytics:K(n.analytics,s),account:H(n.account,s,c),prefix:t,storageKey:typeof n.storageKey=="string"&&n.storageKey?n.storageKey:`${t}:cart:${e}`,metafields:V(n.metafields??[],s),embedOrigins:$(n.embedOrigins??[],s),checkoutTarget:G("checkoutTarget",n.checkoutTarget,["_self","_blank"]),defaultPurchase:G("defaultPurchase",n.defaultPurchase,["one-time","subscription"]),cartDrawerOpenClass:Vn("cartDrawerOpenClass",n.cartDrawerOpenClass)};for(let r of Rn)o[r]=Ln(r,n[r]);for(let r of An)o[r]=Un(r,n[r]);for(let r of En)o[r]=Fn(r,n[r]);for(let r of _n)Mn(o,r,n[r]);return o}var Ce=n=>b(n,s);function ke(n={}){let e=Kn(n);for(let t of Object.keys(a))t in e||Reflect.deleteProperty(a,t);return Object.assign(a,e)}var Te=()=>!!(a.domain&&a.token);function he(...n){a.debug&&console.log(`[${a.prefix}]`,...n)}function c(...n){console.warn(`[${a.prefix}]`,...n)}function xe(n,e){if(c(e,n instanceof Error&&n.message?n.message:n),!!a.onError)try{a.onError(n,e)}catch(t){c("onError threw",t)}}function Se(n){return n instanceof Error?n.message:String(n)}export{Yn as a,Gn as b,zn as c,C as d,q as e,v as f,W as g,X as h,Qn as i,R as j,Bn as k,qn as l,I as m,gn as n,h as o,x as p,ne as q,ee as r,te as s,oe as t,re as u,ie as v,u as w,a as x,Oe as y,Kn as z,Ce as A,ke as B,Te as C,he as D,c as E,xe as F,Se as G};
@@ -1 +0,0 @@
1
- var e={diagnose:()=>import("./diagnose-O3QCZTHT.js"),markets:()=>import("./markets-ui-V2ROBFZP.js"),search:()=>import("./search-ZLKIFARH.js"),lists:()=>import("./lists-XF33XENI.js"),extras:()=>import("./extras-O6ZRL5FK.js"),account:()=>import("./account-3MYRPPTR.js"),"account-pages":()=>import("./account-pages-OZHK5HHY.js"),analytics:()=>import("./analytics-QHX2YHZS.js")},a=t=>e[t](),o=void 0;export{a,o as b};
@@ -1 +0,0 @@
1
- import{a as R}from"./chunk-24KD36UC.js";import"./chunk-SJNNEEDX.js";import{b as w,d as I,g as T}from"./chunk-LSB7RVRZ.js";import{a as H,b as m,d as h}from"./chunk-RVWHBZAF.js";import{c as q,h as x,i as M,j as F}from"./chunk-WHNUPECA.js";import{E as v,F as E,H as f,K,M as A,O,a as P,h as a,l as $,m as c,n as s,o as d,q as N,t as u,w as b,y as k}from"./chunk-A6BZFYZY.js";import{F as L,b as l,x as y}from"./chunk-PZERNTCD.js";var U="url:",W=`query TetherCollection($handle:String!,$first:Int!,$after:String,$sortKey:ProductCollectionSortKeys,$reverse:Boolean,$filters:[ProductFilter!]){collection(handle:$handle){${q()} products(first:$first,after:$after,sortKey:$sortKey,reverse:$reverse,filters:$filters){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}}`,j="query TetherSearch($first:Int!,$after:String,$query:String,$sortKey:ProductSortKeys,$reverse:Boolean){products(first:$first,after:$after,query:$query,sortKey:$sortKey,reverse:$reverse){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}";async function z({collection:n,query:t,first:r=y.collectionFirst,after:e=null,sortKey:o,reverse:i=!1,filters:D}={}){if(n){let S=await a(h(W),{handle:n,first:r,after:e,sortKey:o||void 0,reverse:i,filters:D??void 0},x);if(!S.collection)throw new P(`Collection not found: ${n}`,{code:"NOT_FOUND"});let{products:g,...Y}=S.collection;return g.nodes.forEach(m),{collection:Y,products:g.nodes,pageInfo:g.pageInfo}}let p=await a(h(j),{first:r,after:e,query:t||void 0,sortKey:o||void 0,reverse:i},M);return p.products.nodes.forEach(m),{collection:null,products:p.products.nodes,pageInfo:p.products.pageInfo}}async function X(n,t="RELATED"){let r=H(typeof n=="object"?n?.id:n);if(!r)throw new P("No product for recommendations",{code:"NOT_FOUND"});let e=r.startsWith("gid://"),i=(await a(h(`query TetherRecs(${e?"$id: ID!":"$handle: String!"},$intent:ProductRecommendationIntent){productRecommendations(${e?"productId: $id":"productHandle: $handle"},intent:$intent){...TetherProduct}}`),e?{id:r,intent:t}:{handle:r,intent:t},F)).productRecommendations??[];return i.forEach(m),i}var Z=n=>n instanceof window.Element,_=(n,t)=>O(n,"limit",{min:1,max:250,fallback:t}),G=n=>n==="COMPLEMENTARY"?"COMPLEMENTARY":"RELATED",C=class{constructor(t){l(this,"root");l(this,"products",[]);l(this,"pageInfo",null);l(this,"collection",null);l(this,"loadToken",0);this.root=t,t.addEventListener("click",r=>{if(!Z(r.target))return;let e=r.target.closest(c("load-more"));e?.closest(R())===t&&(r.preventDefault(),A(e,()=>this.load(!0)))})}$(t){return N(this.root,t,R())}options(){let{root:t}=this,r={reverse:s(t,"reverse")==="true",first:_(t,y.collectionFirst)},e=s(t,"sort");if(e&&(r.sortKey=e),d(t,"collection"))return r.collection=s(t,"collection")??"",r;let o=s(t,"products")??"";return r.query=o.startsWith(U)?new URL(window.location.href).searchParams.get(o.slice(U.length))||"":o,r}async loadRecommendations(){let{key:t}=w(this.root,window.location,"recommendations"),r=this.root.closest(c("product"));return!t&&r&&({key:t}=w(r)),X(t,G(s(this.root,"intent")))}async load(t=!1){this.loadToken+=1;let r=this.loadToken,e=()=>r!==this.loadToken;try{if(d(this.root,"recommendations")){let o=await this.loadRecommendations();if(e())return;this.products=o.slice(0,_(this.root,o.length))}else{let o=await z({...this.options(),after:t?this.pageInfo?.endCursor??null:null});if(e())return;this.collection=o.collection,this.pageInfo=o.pageInfo,this.products=t?[...this.products,...o.products]:o.products}this.render(),T(this.root,"ready"),u("list-ready",{products:this.products,collection:this.collection},this.root)}catch(o){if(e())return;t||T(this.root,I(o)?"not-found":"error",o),I(o)&&d(this.root,"recommendations")||L(o,"list load failed"),u("error",{error:o,context:"list"},this.root)}}render(){let{collection:t}=this;this.$(c("collection-bind")).forEach(e=>{switch(s(e,"collection-bind")??""){case"title":E(e,t?.title??"");break;case"description":v(e,t?.descriptionHtml);break;case"image":b(e,t?.image?.url,t?.image?.altText||t?.title);break;case"count":E(e,this.products.length);break}}),this.$(c("list")).forEach(e=>{k(e,this.products,(o,i)=>{o.setAttribute($("product"),i.handle),o.removeAttribute($("state"))}),u("list-rendered",{container:e},this.root)});let r=this.products.length===0;this.$(c("show")).forEach(e=>{let o=s(e,"show");o==="list-empty"&&f(e,r),o==="list-filled"&&f(e,!r)}),this.$(c("load-more")).forEach(e=>{f(e,!!this.pageInfo?.hasNextPage)}),K("list")}},Q=new WeakMap;function ct(n){let t=Q.get(n);return t||(t=new C(n),Q.set(n,t)),t.load()}export{z as getProducts,X as getRecommendations,ct as loadList};
@@ -1 +0,0 @@
1
- import{f as R}from"./chunk-EYG7QGPA.js";import"./chunk-24KD36UC.js";import"./chunk-2G6U6ZYV.js";import"./chunk-FX7EJ6RB.js";import"./chunk-SOLTIZAI.js";import"./chunk-NF5H2Q7V.js";import"./chunk-SJNNEEDX.js";import"./chunk-LSB7RVRZ.js";import"./chunk-RVWHBZAF.js";import"./chunk-WHNUPECA.js";import{A as C,C as M,F as q,H as m,O as p,c as E,d as T,h as A,l as I,m as o,n as d,p as h,t as L,w,y as x}from"./chunk-A6BZFYZY.js";import{D as y,F as S,b as n,x as u}from"./chunk-PZERNTCD.js";var N=T({predictiveSearch:E({products:[{priceRange:"object"}],collections:["object"],queries:[{text:"string"}]})}),U="query TetherPredictive($q:String!,$limit:Int!){predictiveSearch(query:$q,limit:$limit,limitScope:EACH,types:[PRODUCT,COLLECTION,QUERY]){products{id handle title availableForSale featuredImage{url altText}priceRange{minVariantPrice{amount currencyCode}}}collections{handle title image{url altText}}queries{text}}}",D=6,V=10,F=2,O="/search",k=new WeakSet,v=0,H=a=>a.tagName==="A"?a:a.querySelector("a");function f(a,t){h(a,o("search-bind")).forEach(e=>{let i=d(e,"search-bind");i==="image"?w(e,t.image?.url,t.image?.altText||t.title):(i==="title"||i==="price"||i==="text")&&t[i]!=null&&q(e,t[i])})}function $(a,t){let e=H(a);e&&(t&&e.setAttribute("href",t),e.setAttribute("role","option"))}var g=class{constructor(t,e,i){n(this,"root");n(this,"input");n(this,"results");n(this,"limit");n(this,"minCharacters");n(this,"resultsId");n(this,"searchNumber",0);n(this,"timer");n(this,"lastTerm","");n(this,"cache",new Map);this.root=t,this.input=e,this.results=i,this.limit=p(t,"search-limit",{min:1,max:V,fallback:D}),this.minCharacters=p(t,"search-min",{min:1,fallback:F}),i.id||(v+=1,i.id=`${u.prefix}-search-${v}`),this.resultsId=i.id,this.setUpAria(),this.listen()}setUpAria(){this.input.setAttribute("role","combobox"),this.input.setAttribute("aria-autocomplete","list"),this.input.setAttribute("aria-controls",this.resultsId),this.input.setAttribute("aria-expanded","false"),this.input.setAttribute("autocomplete","off"),this.results.hasAttribute("role")||this.results.setAttribute("role","listbox"),this.results.hidden=!0}listen(){this.input.addEventListener("input",()=>{let t=this.input.value.trim();t!==this.lastTerm&&(this.lastTerm=t,clearTimeout(this.timer),this.timer=setTimeout(()=>void this.search(t),u.searchDelay))}),this.input.addEventListener("focus",()=>{this.input.value.trim().length>=this.minCharacters&&this.options().length&&this.open(!0)}),this.input.addEventListener("keydown",t=>{this.onKeydown(t)}),document.addEventListener("click",t=>{this.root.contains(t.target)||this.open(!1)})}setState(t){this.root.setAttribute(I("search-state"),t)}open(t){this.root.classList.toggle("is-open",t),this.results.hidden=!t,this.input.setAttribute("aria-expanded",String(t)),t||this.input.removeAttribute("aria-activedescendant")}options(){return h(this.results,'[role="option"]')}async fetchResults(t){let e=this.cache.get(t);if(e)return e;let i=await A(U,{q:t,limit:this.limit},N);return this.cache.set(t,i.predictiveSearch),i.predictiveSearch}async search(t){this.searchNumber+=1;let e=this.searchNumber;if(t.length<this.minCharacters){this.open(!1),this.setState("idle");return}this.setState("loading");try{let i=await this.fetchResults(t);e===this.searchNumber&&this.render(i,t)}catch(i){if(e!==this.searchNumber){y("a superseded search failed",i);return}this.setState("error"),S(i,"search")}}fillList(t,e,i){h(this.results,o(t)).forEach(l=>{x(l,e,i),m(l,e.length>0)})}queryUrl(t){let e=this.root.getAttribute("action")||O,i=e.includes("?")?"&":"?";return`${e}${i}${this.input.name||"q"}=${encodeURIComponent(t)}`}render(t,e){let i=t?.products??[],l=t?.collections??[],c=(t?.queries??[]).filter(s=>s.text.toLowerCase()!==e.toLowerCase());this.fillList("search-products",i,(s,r)=>{let P=M(r.priceRange.minVariantPrice);f(s,{title:r.title,price:P,image:r.featuredImage}),$(s,C(r.handle,r.id)),s.classList.toggle("is-sold-out",!r.availableForSale)}),this.fillList("search-collections",l,(s,r)=>{f(s,{title:r.title,image:r.image}),$(s,`${(u.collectionPath||"/collection").replace(/\/$/,"")}/${r.handle}`)}),this.fillList("search-queries",c,(s,r)=>{f(s,{text:r.text}),H(s)?.setAttribute("href",this.queryUrl(r.text))});let b=i.length+l.length+c.length;this.showCount(b),this.setState(b?"ready":"empty"),this.open(!0),L("search",{term:e,products:i,collections:l,queries:c},this.root)}showCount(t){h(this.root,o("show")).forEach(e=>{let i=d(e,"show");i==="search-empty"&&m(e,t===0),i==="search-results"&&m(e,t>0)}),this.options().forEach((e,i)=>{e.id||(e.id=`${this.resultsId}-${i}`),e.setAttribute("aria-selected","false")})}highlight(t,e){t.forEach((l,c)=>{l.setAttribute("aria-selected",String(c===e))});let i=t[e];i&&(this.input.setAttribute("aria-activedescendant",i.id),i.scrollIntoView?.({block:"nearest"}))}onKeydown(t){let e=this.options(),i=e.findIndex(l=>l.getAttribute("aria-selected")==="true");t.key==="ArrowDown"&&e.length?(t.preventDefault(),this.open(!0),this.highlight(e,(i+1)%e.length)):t.key==="ArrowUp"&&e.length?(t.preventDefault(),this.highlight(e,i<=0?e.length-1:i-1)):t.key==="Enter"&&i>=0?(t.preventDefault(),e[i]?.click()):t.key==="Escape"&&this.open(!1)}};function B(a=document){for(let t of R(a,o("search"))){if(k.has(t))continue;k.add(t);let e=t.querySelector(o("search-input"))??t.querySelector("input"),i=t.querySelector(o("search-results"));e&&i&&new g(t,e,i)}}export{B as mountSearch};