@occluze/tether 0.9.1 → 0.9.3

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 (61) hide show
  1. package/README.md +1 -1
  2. package/dist/esm/astro.js +2 -2
  3. package/dist/esm/chunks/account-3MYRPPTR.js +1 -0
  4. package/dist/esm/chunks/{account-pages-3C5KTPQV.js → account-pages-OZHK5HHY.js} +1 -1
  5. package/dist/esm/chunks/{analytics-VWSZOX2D.js → analytics-QHX2YHZS.js} +1 -1
  6. package/dist/esm/chunks/chunk-24KD36UC.js +1 -0
  7. package/dist/esm/chunks/{chunk-F2BYVA7V.js → chunk-2G6U6ZYV.js} +1 -1
  8. package/dist/esm/chunks/{chunk-MJNPD6LB.js → chunk-74SGIWQE.js} +1 -1
  9. package/dist/esm/chunks/{chunk-3UCVDDK6.js → chunk-A3GZFAB3.js} +1 -1
  10. package/dist/esm/chunks/chunk-A6BZFYZY.js +1 -0
  11. package/dist/esm/chunks/{chunk-HROQXZYN.js → chunk-EYG7QGPA.js} +1 -1
  12. package/dist/esm/chunks/{chunk-P6DV24RG.js → chunk-FX7EJ6RB.js} +1 -1
  13. package/dist/esm/chunks/{chunk-OURC3H6L.js → chunk-GCGRUVYO.js} +1 -1
  14. package/dist/esm/chunks/{chunk-2IGCUTG5.js → chunk-LSB7RVRZ.js} +1 -1
  15. package/dist/esm/chunks/{chunk-S5BUUIB6.js → chunk-NF5H2Q7V.js} +1 -1
  16. package/dist/esm/chunks/chunk-PZERNTCD.js +1 -0
  17. package/dist/esm/chunks/chunk-RVWHBZAF.js +1 -0
  18. package/dist/esm/chunks/chunk-SJNNEEDX.js +1 -0
  19. package/dist/esm/chunks/{chunk-XU27NSXT.js → chunk-SOLTIZAI.js} +1 -1
  20. package/dist/esm/chunks/{chunk-ZBV2JSHE.js → chunk-WHNUPECA.js} +1 -1
  21. package/dist/esm/chunks/{chunk-2A2GN3Z7.js → chunk-ZB4FBE6W.js} +1 -1
  22. package/dist/esm/chunks/{diagnose-TE72GNOO.js → diagnose-O3QCZTHT.js} +1 -1
  23. package/dist/esm/chunks/{extras-7GTMJMOZ.js → extras-O6ZRL5FK.js} +1 -1
  24. package/dist/esm/chunks/lists-XF33XENI.js +1 -0
  25. package/dist/esm/chunks/{markets-ui-AAQM4PEE.js → markets-ui-V2ROBFZP.js} +1 -1
  26. package/dist/esm/chunks/search-ZLKIFARH.js +1 -0
  27. package/dist/esm/index.js +1 -1
  28. package/dist/esm/server.js +2 -2
  29. package/dist/tether.account-pages.js +2 -2
  30. package/dist/tether.account-pages.min.js +1 -1
  31. package/dist/tether.account.js +4 -7
  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.extras.js +1 -1
  38. package/dist/tether.extras.min.js +1 -1
  39. package/dist/tether.js +110 -64
  40. package/dist/tether.lists.js +11 -7
  41. package/dist/tether.lists.min.js +1 -1
  42. package/dist/tether.markets.js +1 -1
  43. package/dist/tether.markets.min.js +1 -1
  44. package/dist/tether.min.js +1 -1
  45. package/dist/tether.min.js.map +4 -4
  46. package/dist/tether.search.js +4 -6
  47. package/dist/tether.search.min.js +1 -1
  48. package/dist/types/server/src/shared/metafield-ref.d.ts +15 -0
  49. package/dist/types/src/dom.d.ts +12 -0
  50. package/dist/types/src/server.d.ts +5 -2
  51. package/dist/types/src/shopify-values.d.ts +2 -0
  52. package/dist/types/src/version.d.ts +1 -1
  53. package/package.json +2 -2
  54. package/dist/esm/chunks/account-LCMJ7QU5.js +0 -1
  55. package/dist/esm/chunks/chunk-D3MRWOFI.js +0 -1
  56. package/dist/esm/chunks/chunk-EUCFOBIT.js +0 -1
  57. package/dist/esm/chunks/chunk-P73VN3B6.js +0 -1
  58. package/dist/esm/chunks/chunk-SOFWDTR7.js +0 -1
  59. package/dist/esm/chunks/chunk-YJC3CSEG.js +0 -1
  60. package/dist/esm/chunks/lists-ZMVRGD6L.js +0 -1
  61. package/dist/esm/chunks/search-PWF4YZQO.js +0 -1
@@ -23,7 +23,7 @@
23
23
 
24
24
  // tether-core:dom.ts
25
25
  var m3 = window.Tether.__core["dom.ts"];
26
- var [ANALYTICS_EVENTS, attr, attributesFromJson, busy, emit, formatDate, formatMoney, get, has, hasTemplate, isOwnEvent, notifyLayoutChanged, parseJSONAttr, productUrl, qsa, repeat, scoped, sel, setImage, setStoreHtml, setText, show] = m3;
26
+ var [ANALYTICS_EVENTS, attr, attributesFromJson, busy, emit, formatDate, formatMoney, get, has, hasTemplate, integerAttribute, isOwnEvent, notifyLayoutChanged, parseJSONAttr, productUrl, qsa, repeat, scoped, sel, setImage, setStoreHtml, setText, show] = m3;
27
27
 
28
28
  // tether-core:mounting.ts
29
29
  var m4 = window.Tether.__core["mounting.ts"];
@@ -39,13 +39,11 @@
39
39
  });
40
40
  var QUERY = `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}}}`;
41
41
  var DEFAULT_LIMIT = 6;
42
+ var MAX_LIMIT = 10;
42
43
  var DEFAULT_MIN_CHARACTERS = 2;
43
44
  var DEFAULT_ACTION = "/search";
44
45
  var mounted = /* @__PURE__ */ new WeakSet();
45
46
  var searchBoxCount = 0;
46
- function integerAttribute(el, name, fallback) {
47
- return parseInt(get(el, name) || "", 10) || fallback;
48
- }
49
47
  var linkIn = (node) => node.tagName === "A" ? node : node.querySelector("a");
50
48
  function bindValues(node, values) {
51
49
  qsa(node, sel("search-bind")).forEach((el) => {
@@ -79,8 +77,8 @@
79
77
  this.root = root;
80
78
  this.input = input;
81
79
  this.results = results;
82
- this.limit = integerAttribute(root, "search-limit", DEFAULT_LIMIT);
83
- this.minCharacters = integerAttribute(root, "search-min", DEFAULT_MIN_CHARACTERS);
80
+ this.limit = integerAttribute(root, "search-limit", { min: 1, max: MAX_LIMIT, fallback: DEFAULT_LIMIT });
81
+ this.minCharacters = integerAttribute(root, "search-min", { min: 1, fallback: DEFAULT_MIN_CHARACTERS });
84
82
  if (!results.id) {
85
83
  searchBoxCount += 1;
86
84
  results.id = `${cfg.prefix}-search-${searchBoxCount}`;
@@ -1 +1 @@
1
- (()=>{var T=Object.defineProperty;var D=(i,t,e)=>t in i?T(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var V=(i,t)=>{for(var e in t)T(i,e,{get:t[e],enumerable:!0})};var o=(i,t,e)=>D(i,typeof t!="symbol"?t+"":t,e);var w={};V(w,{mountSearch:()=>Z});var F=window.Tether.__core["config.ts"],[u,tt,b,et,rt,S,it]=F;var j=window.Tether.__core["client.ts"],[st,E,ot,x,A,at]=j;var K=window.Tether.__core["dom.ts"],[ct,L,ht,ut,I,mt,k,m,dt,pt,ft,gt,wt,N,h,C,yt,l,R,Tt,P,d]=K;var Q=window.Tether.__core["mounting.ts"],[St,Et,xt,At,Lt,q]=Q;var Y=A({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=2,W="/search",M=new WeakSet,_=0;function $(i,t,e){return parseInt(m(i,t)||"",10)||e}var U=i=>i.tagName==="A"?i:i.querySelector("a");function f(i,t){h(i,l("search-bind")).forEach(e=>{let r=m(e,"search-bind");r==="image"?R(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 g=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=$(t,"search-limit",J),this.minCharacters=$(t,"search-min",z),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(L("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 E(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){b("a superseded search failed",r);return}this.setState("error"),S(r,"search")}}fillList(t,e,r){h(this.results,l(t)).forEach(a=>{C(a,e,r),d(a,e.length>0)})}queryUrl(t){let e=this.root.getAttribute("action")||W,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=k(n.priceRange.minVariantPrice);f(s,{title:n.title,price:O,image:n.featuredImage}),H(s,N(n.handle,n.id)),s.classList.toggle("is-sold-out",!n.availableForSale)}),this.fillList("search-collections",a,(s,n)=>{f(s,{title:n.title,image:n.image}),H(s,`${(u.collectionPath||"/collection").replace(/\/$/,"")}/${n.handle}`)}),this.fillList("search-queries",c,(s,n)=>{f(s,{text:n.text}),U(s)?.setAttribute("href",this.queryUrl(n.text))});let y=r.length+a.length+c.length;this.showCount(y),this.setState(y?"ready":"empty"),this.open(!0),I("search",{term:e,products:r,collections:a,queries:c},this.root)}showCount(t){h(this.root,l("show")).forEach(e=>{let r=m(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")})}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(M.has(t))continue;M.add(t);let e=t.querySelector(l("search-input"))??t.querySelector("input"),r=t.querySelector(l("search-results"));e&&r&&new g(t,e,r)}}function p(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)}function G(i){return p(i)&&p(i.__core)&&p(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",w);})();
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);})();
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Metafield references (`namespace.key`), which the browser's product fragment and the sync's product query write
3
+ * into their text: a GraphQL fragment can't declare variables, so they can't be sent as variables. Only these
4
+ * characters are let through, which covers Shopify's namespaces and keys.
5
+ */
6
+ /** @returns True when both parts are ones a query may hold. */
7
+ export declare const isMetafieldIdentifier: (namespace: string, key: string) => boolean;
8
+ /**
9
+ * @param ref `namespace.key`: the namespace ends at the first dot, and the key may hold more.
10
+ * @returns Its parts, `null` when there is no namespace or either part isn't valid.
11
+ */
12
+ export declare function metafieldIdentifierOf(ref: string): {
13
+ namespace: string;
14
+ key: string;
15
+ } | null;
@@ -58,6 +58,18 @@ export declare function watchImages(root: ParentNode, reason: string): void;
58
58
  export declare function busy<T>(el: Element, task: () => T | Promise<T>): Promise<T | undefined>;
59
59
  /** @returns The attribute's JSON, `null` when it is missing or not JSON (with a warning). */
60
60
  export declare function parseJSONAttr(el: Element | null | undefined, name: string): unknown;
61
+ /** The integers a count attribute takes, and the value it has when it is missing or invalid. */
62
+ interface IntegerRange {
63
+ min: number;
64
+ max?: number;
65
+ fallback: number;
66
+ }
67
+ /**
68
+ * Parses a count attribute with the config's count-option rules: an integer above `max` is the site asking for as
69
+ * much as there is, so it gets `max`; a missing or empty attribute is `fallback`, and so, with a warning, is one that
70
+ * isn't an integer or is below `min`. An element warns once per attribute.
71
+ */
72
+ export declare function integerAttribute(el: Element, name: string, { min, max, fallback }: IntegerRange): number;
61
73
  export type AttributeValue = string | number | boolean | null | undefined;
62
74
  /**
63
75
  * `tether-line-attributes`, JSON the site writes: `{ a: 1 }` or `[{ key, value }]`. An array entry that isn't an
@@ -27,7 +27,7 @@ interface ServerOptions {
27
27
  * stalled request through that signal, and a request that ignores it is never ended.
28
28
  */
29
29
  fetch?: typeof fetch;
30
- /** Products per request for `allProducts()` (default 25). */
30
+ /** Products per request for `allProducts()`: an integer from 1 to 250 (default 25). */
31
31
  pageSize?: number;
32
32
  /** The site's address, for product URLs in `jsonLd()` without `url`. */
33
33
  siteUrl?: string;
@@ -39,7 +39,10 @@ interface ServerOptions {
39
39
  type StorefrontOptions = TetherOptions & ServerOptions & StoreEnv;
40
40
  /** The environment names that give the domain and the token. */
41
41
  type StoreEnv = Partial<Record<(typeof STORE_ENV_NAMES)['domain' | 'token'][number], string>>;
42
- type ServerConfig = TetherConfig & ServerOptions;
42
+ /** The options as parsed: `pageSize` always set. */
43
+ type ServerConfig = TetherConfig & Omit<ServerOptions, 'pageSize'> & {
44
+ pageSize: number;
45
+ };
43
46
  interface HydrateOptions {
44
47
  card?: boolean;
45
48
  images?: number;
@@ -7,6 +7,8 @@ export interface Money {
7
7
  amount: string;
8
8
  currencyCode: string;
9
9
  }
10
+ /** The largest `first` the Storefront API takes for a connection: a larger one fails the whole query. */
11
+ export declare const MAX_CONNECTION_SIZE = 250;
10
12
  /** The `.env` names a store's domain and public Storefront token are read from, first match wins. */
11
13
  export declare const STORE_ENV_NAMES: {
12
14
  readonly domain: readonly ["PUBLIC_SHOPIFY_DOMAIN", "PUBLIC_SHOPIFY_STORE_DOMAIN", "SHOPIFY_DOMAIN"];
@@ -1 +1 @@
1
- export declare const VERSION = "0.9.1";
1
+ export declare const VERSION = "0.9.3";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@occluze/tether",
3
- "version": "0.9.1",
3
+ "version": "0.9.3",
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",
@@ -45,7 +45,7 @@
45
45
  "test:types": "tsc -p test/types/tsconfig.json",
46
46
  "smoke": "node --experimental-strip-types scripts/smoke.ts",
47
47
  "pretest": "node --experimental-strip-types scripts/build.ts --out .test-dist",
48
- "presmoke": "node --experimental-strip-types scripts/build.ts",
48
+ "presmoke": "node --experimental-strip-types scripts/build.ts --out .test-dist",
49
49
  "release": "node --experimental-strip-types scripts/release.ts",
50
50
  "e2e:build": "npm run build && node --experimental-strip-types scripts/e2e-build.ts && cd examples/astro && npm install --no-save --no-audit --no-fund --ignore-scripts ../.. && npx astro build",
51
51
  "e2e": "npm run e2e:build && playwright test -c test/e2e/playwright.config.js"
@@ -1 +0,0 @@
1
- import{f as j,g as V,h as G,i as R,m as v,n as H}from"./chunk-OURC3H6L.js";import{a as O,c as M}from"./chunk-MJNPD6LB.js";import{f as q,g as F,h as P}from"./chunk-P6DV24RG.js";import"./chunk-S5BUUIB6.js";import{a as W}from"./chunk-YJC3CSEG.js";import"./chunk-EUCFOBIT.js";import"./chunk-ZBV2JSHE.js";import{C as $,D as _,F as A,H as L,a as f,m as c,n as l,p as d,t as h,w as N,y as D}from"./chunk-P73VN3B6.js";import{A as T,C as U,d as I,g as y,r as i,x as E,z as m}from"./chunk-D3MRWOFI.js";var g=null;function X(){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 B(e){e?q(O(),"1"):F(O())}async function ae(e,t){try{return await fetch(e,t)}catch(r){throw new f(`Network error: ${T(r)}`,{code:"NETWORK"})}}async function ue(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 ae(`${X()}${e}`,n);if(s.status===401)return{kind:"logged-out"};let o=await ue(s);if(!s.ok){let u=y(o.error)??String(s.status),w=G(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:j(e.data.customer)}:{loggedIn:!1}}return B(g.loggedIn),g}var J=()=>g?.loggedIn===!0;function K(){g=null}function z(e){let t=i.account?.navigate;t?t(e):window.location.assign(e)}var de=e=>e||i.account?.locale||(i.locale||"").split("-")[0]||"";function Q({returnTo:e,locale:t}){let r=new URL(`${X()}/login`);r.searchParams.set("returnTo",e);let n=de(t);n&&r.searchParams.set("locale",n),i.country&&r.searchParams.set("country",i.country.toUpperCase()),z(r.toString())}async function Y(){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 Z(e){let t=await p("/logout",{method:"POST",body:{returnTo:e,cartId:P.id()}});g=null,B(!1),h("account-logout",{});let r=t.kind==="answer"?y(t.data.logoutUrl):null;return r?(z(r),"redirected"):"stayed"}var b=10,S=50,ee=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1&&e<=S;function le(e){let t=Number.parseInt(e||String(b),10)||b;return Math.min(Math.max(t,1),S)}var me=e=>e.replace(/\?.*$/,"").replace(/^.*\//,"");function ge(e){let t=i.account?.orderUrl;if(t)return t.replaceAll("{id}",encodeURIComponent(me(e.id)));let r=e.statusPageUrl;return r!==null&&U(r)?r:null}var fe=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 pe(e,t){let r=t.lineItems.nodes,n=ge(t),s=fe(t);d(e,c("order-bind")).forEach(o=>{let u=l(o,"order-bind")??"";if(u==="url"){n&&o.setAttribute("href",n);return}if(u==="image"){let x=r.find(ce=>ce.image)?.image;x&&N(o,x.url,x.altText||r[0]?.title||"");return}let w=v(s,u);w!==void 0&&A(o,w)}),d(e,c("order-lines")).forEach(o=>{H(o,r,null)}),l(e,"order-bind")==="url"&&n&&e.setAttribute("href",n)}async function te(e,t){let r=d(e,c("orders")),n=r[0];if(!n)return;R(e,"show",{"orders-loading":!0,"orders-empty":!1});let s=le(l(n,"limit")),o;try{o=await t(s)}catch(u){m(u,"orders"),o=null}R(e,"show",{"orders-loading":!1,"orders-empty":o?.length===0}),r.forEach(u=>{D(u,o??[],pe)})}var we=["order","addresses","subscriptions","profile-form","address-form"],he=J;function Pe({returnTo:e=window.location.href,locale:t}={}){return new Promise(r=>{Q({returnTo:e,locale:t}),r()})}async function se(){let e=await k();return e.loggedIn?e.customer:null}async function ye({first:e=b}={}){if(!ee(e))throw new f(`Customer accounts: orders() takes first from 1 to ${String(S)}`,{code:"INVALID"});let t=await p(`/orders?${new URLSearchParams({first:String(e)}).toString()}`);return t.kind==="logged-out"?[]:V(t.data.orders)}async function Ae({returnTo:e=i.account?.logoutUrl||`${window.location.origin}/`}={}){await Z(e)==="stayed"&&await C(document)}async function ve(){try{return(await k()).loggedIn?{kind:"logged-in"}:{kind:"logged-out"}}catch(e){return{kind:"unknown",error:e}}}var re=e=>we.some(t=>d(e,c(t)).length>0);function ke(e){d(e,c("account-link")).forEach(t=>{t.setAttribute("href",be(l(t,"account-link")))})}function be(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 ve();t.kind==="unknown"&&m(t.error,"account");let r=t.kind==="logged-in";if(d(e,c("show")).forEach(n=>{let s=l(n,"show");s==="logged-in"&&L(n,r),s==="logged-out"&&L(n,!r)}),ke(e),t.kind==="unknown"&&re(e)){(await a()).showUnavailable(e);return}r&&(await ie(e),await Promise.all([te(e,n=>ye({first:n})),re(e)?a().then(n=>n.renderPages(e)):null]))}async function ie(e){let t=d(e,c("account-bind"));if(!t.length)return;let r;try{r=await se()}catch(s){m(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,l(s,"account-bind")??"");o!=null&&A(s,o)})}var ne=null;function a(){return ne??(ne=W("account-pages").then(e=>(e.setup({serverFetch:p,customer:se,bindCustomer:ie,reset:K}),e))),ne}var Ye=e=>a().then(t=>t.order(e)),Ze=e=>a().then(t=>t.updateProfile(e)),et=()=>a().then(e=>e.addresses()),tt=(e,t)=>a().then(r=>r.saveAddress(e,t)),rt=e=>a().then(t=>t.deleteAddress(e)),nt=()=>a().then(e=>e.subscriptions()),ot=(e,t)=>a().then(r=>r.subscriptionAction(e,t)),st=(e,t)=>a().then(r=>r.requestReturn(e,t));function Se(e){let t=e.target;t instanceof window.Element&&(t.closest(c("account-login"))?(e.preventDefault(),Pe().catch(r=>{m(r,"login")})):t.closest(c("account-logout"))&&(e.preventDefault(),Ae().catch(r=>{m(r,"logout")})))}function xe(){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 oe=!1;async function it(e=document){if(oe){await C(e);return}oe=!0,document.addEventListener("click",Se),xe(),P.setCheckoutResolver(Y),await C(e),E("account",he()?"logged in":"logged out")}export{et as addresses,se as customer,rt as deleteAddress,he as isLoggedIn,Pe as login,Ae as logout,it as mountAccount,Ye as order,ye as orders,C as render,st as requestReturn,tt as saveAddress,ot as subscriptionAction,nt as subscriptions,Ze as updateProfile};
@@ -1 +0,0 @@
1
- var w=Object.defineProperty;var G=(n,e,t)=>e in n?w(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Fn=(n,e)=>{for(var t in e)w(n,t,{get:e[t],enumerable:!0})};var $n=(n,e,t)=>G(n,typeof e!="symbol"?e+"":e,t);var z=/^(\d{4})-(01|04|07|10)$/;function T(n){let e=z.exec(typeof n=="string"?n:"");return e?{year:Number(e[1]),month:Number(e[2])}:null}var S=n=>T(n)!==null,j=(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 j(Math.floor(o/4),o%4*3+1)}function Dn(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,f=o<=e,u=`supported until about ${r.toISOString().slice(0,7)}`;return f?i<=0?u="no longer supported: Shopify falls back to the oldest supported version. Upgrade (see docs/reference.md)":i<3&&(u=`${u}: plan the upgrade to ${A(n)} or later (see docs/reference.md)`):u="not released yet (release candidate at best)",{version:n,ok:f&&i>0,monthsLeft:Math.round(i),next:A(n),note:u}}function O(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function v(n,e){return O(n)?n[e]:void 0}function Q(n){return Array.isArray(n)?n:[]}function Z(n){return typeof n=="string"&&n!==""?n:null}var B=n=>typeof n=="number"&&Number.isFinite(n)?n:null,Kn=n=>B(n)??0,x=(n,e)=>Q(n).map(t=>e(t)),Yn=(n,e)=>({nodes:x(v(n,"nodes"),e)}),Gn=n=>x(n,Z).filter(e=>e!==null);var q=/^[A-Z]{2}$/,W=new Set(["XX","T1"]),X=new Set(["PT_BR","PT_PT","ZH_CN","ZH_TW"]),J=/^[A-Z]{2,3}$/;function k(n){let e=(typeof n=="string"?n:"").trim().toUpperCase();return!q.test(e)||W.has(e)?null:e}function h(n){let e=(typeof n=="string"?n:"").trim().replace("-","_").toUpperCase();if(X.has(e))return e;let t=e.split("_")[0]??"";return J.test(t)?t:null}var E="2026-07";var nn=/^[A-Za-z0-9_.-]+$/,en=/^(\$app(:[A-Za-z0-9_-]+)?|[A-Za-z0-9_.-]+)$/,tn=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i,on=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,rn=/^[A-Za-z_$][\w$]*$/,R="https://site.invalid",sn=new Set(["localhost","127.0.0.1","[::1]"]),N=["saved","server","webflow"],an=["no-banner","default-banner","custom-banner"],y=n=>typeof n=="string"&&n!=="",un=n=>typeof n=="function";function M(n,e){if(typeof n!="string"||!n)return"";let t=n.replace(/^https?:\/\//,"").replace(/\/.*$/,"");return dn(t)?t:(e("domain",n),"")}function P(n){if(!y(n))return!1;try{let e=new URL(n,`${R}/`);return e.origin===R?!0:e.protocol==="https:"||e.protocol==="http:"&&sn.has(e.hostname)}catch{return!1}}function I(n,e){return n==null||n===""?null:typeof n=="string"&&(P(n)||cn(n))?n:(e("partsUrl",n),null)}function cn(n){if(typeof location>"u")return!1;try{return new URL(n).origin===location.origin}catch{return!1}}function ln(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 L(n,e){if(!Array.isArray(n))return e("embedOrigins",n),[];let t=[],o=n;for(let r of o){let i=ln(r);i?t.push(i):e("embedOrigin",r)}return t}function fn(n){let e,t;if(typeof n=="string"){let o=n.indexOf(".");e=o>0?n.slice(0,o):"",t=n.slice(o+1)}else typeof n=="object"&&n!==null&&(e=Reflect.get(n,"namespace"),t=Reflect.get(n,"key"));return typeof e!="string"||typeof t!="string"?null:en.test(e)&&nn.test(t)?{namespace:e,key:t}:null}function U(n,e){if(!Array.isArray(n))return e("metafields",n),[];let t=[],o=n;for(let r of o){let i=fn(r);i?t.push(typeof r=="string"?r:i):e("metafield",r)}return t}var d=n=>e=>n(e)?e:void 0,dn=n=>y(n)&&tn.test(n),pn=n=>y(n)&&on.test(n),gn=n=>typeof n=="boolean"||y(n)&&rn.test(n),g=d(P),C=d(y),_=d(n=>typeof n=="boolean"),F=d(un);function m(n,e,t,o){if(e==null)return null;if(!O(e))return o(n,e),null;let r={};for(let i in t){let f=e[i];if(f===void 0)continue;let u=t[i](f);u===void 0?o(`${n}.${i}`,f):r[i]=u}return r}var yn={server:g,orderUrl:g,subscriptionsUrl:g,paymentUrl:g,logoutUrl:g,locale:C,navigate:F},mn="customer accounts need the Worker since 0.7.0: set account.server",On={country:C,language:C,locale:C},Cn={detect:n=>{if(typeof n=="boolean")return n;let e=Array.isArray(n)?n:[n];return typeof n=="string"||Array.isArray(n)?N.filter(t=>e.includes(t)):void 0},locales:n=>{if(!O(n))return;let e={};for(let[t,o]of Object.entries(n)){let r=m(`markets.locales.${t}`,o,On,()=>{});r&&(e[t]=r)}return e},cookie:d(pn),remember:_,strict:_},Tn={consent:n=>an.find(e=>e===n),proxy:n=>n!==void 0&&!!n},kn={dataLayer:d(gn),shopify:n=>typeof n=="boolean"?n:m("analytics.shopify",n,Tn,()=>{})??void 0,onEvent:F};function $(n,e,t){let o=m("account",n,yn,e);if(o===null)return null;let{server:r}=o;return r===void 0?(t(mn),null):{...o,server:r}}var b=(n,e)=>m("markets",n,Cn,e),V=(n,e)=>m("analytics",n,kn,e);var c={domain:"",token:"",apiVersion:E,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={...c};function Y(n){let e=t=>(l(`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?Y(r):r},set:(t,o)=>e(o),deleteProperty:(t,o)=>e(o),defineProperty:(t,o)=>e(o)})}var ee=Y(a),hn=/^[a-z][a-z0-9-]*$/,bn=["revalidate","openCartOnAdd","cartFocus","variantUrl","autoMount","observe","astro","debug"],wn=["token","productPath","collectionPath","cartDrawerOpenClass"],An=["imagesFirst","variantsFirst","sellingPlanGroupsFirst","sellingPlansFirst","collectionFirst","retries","requestTimeout","maxAge","lowStock","searchDelay"],Sn=["warningText","formatMoney","onLayoutChange","onCartOpen","onCartClose","onLineEnter","onLineLeave","onValueChange","onError"];function p(n,e,t){return e!==void 0&&l(`invalid ${n} ${JSON.stringify(e)}: using ${JSON.stringify(t)}`),t}function s(n,e){l(`invalid ${n} ${JSON.stringify(e)}: ignored`)}function xn(n){for(let e of Object.keys(n))e in c||l(`unknown option ${JSON.stringify(e)}: ignored`)}function En(n,e,t){typeof t=="function"?n[e]=t:t!=null&&s(e,t)}var D=2147483647,Rn=10,_n={requestTimeout:D,searchDelay:D,retries:Rn};function Nn(n,e){let t=_n[n]??Number.POSITIVE_INFINITY;return typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=t?e:p(n,e,c[n])}function Mn(n,e){return typeof e=="boolean"?e:p(n,e,c[n])}function Pn(n,e){return typeof e=="string"?e:p(n,e,c[n])}function In(n){if(!(n==null||n==="")){try{if(typeof n=="string"&&Intl.getCanonicalLocales(n).length)return n}catch{}s("locale",n)}}function H(n,e,t){return t.find(o=>o===e)??p(n,e,t[0])}function Ln(n){return n==="unstable"?(l('apiVersion "unstable" changes without notice. Pin a dated version (e.g. 2026-07).'),n):S(n)?n:p("apiVersion",n,c.apiVersion)}function K(n,e,t){if(e==null||e==="")return;let o=t(e);if(o!==null)return o;s(n,e)}function Un(n){xn(n);let e=M(n.domain,s),t=typeof n.prefix=="string"&&hn.test(n.prefix)?n.prefix:p("prefix",n.prefix,c.prefix),o={...c,domain:e,apiVersion:Ln(n.apiVersion),country:K("country",n.country,k),locale:In(n.locale),partsUrl:I(n.partsUrl,s),language:K("language",n.language,h),markets:b(n.markets,s),analytics:V(n.analytics,s),account:$(n.account,s,l),prefix:t,storageKey:typeof n.storageKey=="string"&&n.storageKey?n.storageKey:`${t}:cart:${e}`,metafields:U(n.metafields??[],s),embedOrigins:L(n.embedOrigins??[],s),checkoutTarget:H("checkoutTarget",n.checkoutTarget,["_self","_blank"]),defaultPurchase:H("defaultPurchase",n.defaultPurchase,["one-time","subscription"])};for(let r of An)o[r]=Nn(r,n[r]);for(let r of bn)o[r]=Mn(r,n[r]);for(let r of wn)o[r]=Pn(r,n[r]);for(let r of Sn)En(o,r,n[r]);return o}var te=n=>b(n,s);function oe(n={}){let e=Un(n);for(let t of Object.keys(a))t in e||Reflect.deleteProperty(a,t);return Object.assign(a,e)}var re=()=>!!(a.domain&&a.token);function ie(...n){a.debug&&console.log(`[${a.prefix}]`,...n)}function l(...n){console.warn(`[${a.prefix}]`,...n)}function se(n,e){if(l(e,n instanceof Error&&n.message?n.message:n),!!a.onError)try{a.onError(n,e)}catch(t){l("onError threw",t)}}function ce(n){return n instanceof Error?n.message:String(n)}var fe={domain:["PUBLIC_SHOPIFY_DOMAIN","PUBLIC_SHOPIFY_STORE_DOMAIN","SHOPIFY_DOMAIN"],token:["PUBLIC_SHOPIFY_STOREFRONT_TOKEN","PUBLIC_SHOPIFY_STOREFRONT_ACCESS_TOKEN","SHOPIFY_STOREFRONT_TOKEN"]};function de(n){if(typeof n!="string")return!1;try{return new URL(n).protocol==="https:"}catch{return!1}}function pe(n){return/^shp[a-z]{2}_/.test(n.trim())}function ge(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 ye(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 me(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}export{Fn as a,$n as b,Dn as c,O as d,v as e,Q as f,Z as g,B as h,Kn as i,x as j,Yn as k,Gn as l,N as m,fn as n,k as o,h as p,c as q,a as r,ee as s,Un as t,te as u,oe as v,re as w,ie as x,l as y,se as z,ce as A,fe as B,de as C,pe as D,ge as E,ye as F,me as G};
@@ -1 +0,0 @@
1
- import{a as D,e as O,g as C}from"./chunk-ZBV2JSHE.js";import{a as p,b as T,c as m,h as x}from"./chunk-P73VN3B6.js";import{G as I,d as w,r as v,x as $}from"./chunk-D3MRWOFI.js";var M=1e4,_=6e4,o=new Map,P=new Map,a=new Set,h=new Map,S=[],y=!1,f=0,N=t=>t.startsWith("gid://"),b=I;function E(t){if(!t)return;let e=Promise.resolve(t);o.set(t.handle,e),o.set(t.id,e)}function j(t){let e=b(t);if(!e)return Promise.reject(new p("empty product key",{code:"NOT_FOUND"}));let r=o.get(e);if(r)return r;let c=new Promise((d,s)=>{P.set(e,{resolve:d,reject:s}),S.push(e),y||(y=!0,setTimeout(()=>void A(),0))});return o.set(e,c),c}var q=t=>e=>`${t}${D(v,e)}`;function F(t){let e=t.filter(N),r=t.filter(l=>!N(l)),c=[],d=[],s={};return e.length&&(c.push("$ids: [ID!]!"),s.ids=e,d.push("byId:nodes(ids:$ids){... on Product{...TetherProduct}}")),r.forEach((l,n)=>{c.push(`$h${n}: String!`),s[`h${n}`]=l,d.push(`h${n}:product(handle:$h${n}){...TetherProduct}`)}),{query:q(`query TetherProducts(${c.join(",")}){${d.join(" ")}}`),variables:s,handles:r}}function R(t,e){let r=P.get(t);P.delete(t),r&&e(r)}function Q(t,e){if(e!==f)return;let r=o.get(t);setTimeout(()=>{o.get(t)===r&&o.delete(t)},M)}function W(t){if(!w(t))return!1;let{byId:e=[],...r}=t;return T(e,[m(C)])&&Object.values(r).every(m(O))}async function A(){y=!1;let t=f,e=S.splice(0);if(!e.length)return;let{query:r,variables:c,handles:d}=F(e);$("fetch products",e);let s;try{s=await x(r,c,W)}catch(n){e.forEach(u=>{R(u,i=>{t===f&&o.delete(u),i.reject(n)})});return}let g=new Map;for(let n of s.byId??[])n?.id&&g.set(n.id,n);d.forEach((n,u)=>{let i=s[`h${u}`];i&&g.set(n,i)});let l=Date.now();e.forEach(n=>{R(n,u=>{let i=g.get(n);if(!i){Q(n,t),u.reject(new p(`Product not found: ${n}`,{code:"NOT_FOUND"}));return}t===f&&(E(i),h.set(i.handle,l),h.set(i.id,l)),u.resolve(i)})})}function L(){o.clear(),f+=1,a.clear(),h.clear()}function J(t){for(let e of t??[])!e.id||!e.handle||Date.now()-(h.get(e.handle)??0)<_&&o.has(e.handle)||(E(e),a.add(e.handle),a.add(e.id))}function V(t){let e=b(t);return!e||!a.has(e)?!1:(a.delete(e),o.get(e)?.then(r=>{a.delete(r.handle),a.delete(r.id)},B),!0)}function B(){}function X(t){let e=b(t);return e&&o.delete(e),j(t)}export{b as a,E as b,j as c,q as d,L as e,J as f,V as g,X as h};
@@ -1 +0,0 @@
1
- import{A as j,E as q,F as Q,b as T,d as E,e as x,o as V,p as G,r as c,x as O,y as S,z as b}from"./chunk-D3MRWOFI.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:Et(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 Et=t=>Array.isArray(t),He=t=>e=>e===null||v(e,t),$e=t=>e=>v(e,t);function Tt(t=c){return`https://${t.domain}/api/${t.apiVersion}/graphql.json`}var Y=/"(?:\\.|[^"\\\n])*"|#[^\n]*/g,bt=/^\s*(?:query|mutation)(?:\s+\w+)?\s*(?:\([^)]*\))?/;function wt(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=bt.exec(i);if(!a)return t;let l=a[0].length;return`${t.slice(0,l).trimEnd()} ${o} ${t.slice(l).trimStart()}`}function De(t,e=c){let r=V(e.country)??void 0,n=G(e.language)??void 0;return J(t,{country:r,language:n})}var N=300,St=500,At=3e4,W=430,xt=1e3,L="quantityAvailable",B=new Set,vt=t=>`${t.domain} ${t.apiVersion} ${t.token}`;function kt(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*xt))}`}var Rt=t=>new Promise(e=>setTimeout(e,t));function I(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 Ot(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 Ct(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(Ot)}:null}function C(t,e){return t.ok?new g(`Invalid response (${t.status})`,{code:"INVALID_RESPONSE",status:t.status}):new g(I(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?I(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:N};throw new g(`Network error: ${j(t)}`,{code:"NETWORK"})}function Lt(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:St};let l=a.includes("INTERNAL_SERVER_ERROR");if(i==="any"&&l)return{kind:"retry",backoffMs:N};let p=t.ok&&(l||s==="mutation"&&o==null);throw K(t,n,e,p?"SERVER_ERROR":void 0)}async function Nt(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 It(t,e,r,n,o,i,s){let a;try{a=await(t.fetch??fetch)(Tt(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:N};let l;try{l=await a.json()}catch(f){if(f instanceof SyntaxError)throw C(a,t);return z(f,o)}let p=Ct(l);if(!p)throw C(a,t);let{data:d,errors:h=[]}=p;if(h.length)return Lt(a,t,e,h,d,o,i);if(!a.ok)throw new g(I(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=vt(t),a=i==="mutation"?"not-run":"any",l=0;for(;;){let p={inventory:!B.has(s)},d=kt(t,e,p,{context:o,operation:i}),h=l<t.retries?a:"none",f=await Nt(t.requestTimeout,w=>It(t,d,r,n,h,i,w));switch(f.kind){case"data":return f.data;case"inventory-refused":if(typeof e=="string"||!p.inventory)throw f.error;O(`the token can't read inventory: ${L} is left out from now on`),B.add(s);break;case"retry":await Rt(Math.min(f.backoffMs*2**l,At)),l+=1,O("retry",l);break}}}function Fe(t,e,r,n){return X(c,t,e,r,n)}var Pt=t=>typeof t=="object"&&t!==null;function Mt(t,e,r={},n){return X(t,e,r,Pt,{...n,operation:wt(e)})}function Ve(t,e,r){return Mt(c,t,e,r)}function Ge(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}`,_t=(t,e)=>e===void 0?`[${m(t)}]`:`[${m(t)}="${e}"]`,P=(t,e)=>t.getAttribute(m(e)),Ut=(t,e)=>t.hasAttribute(m(e));function Z(t,e){return t?[...t.querySelectorAll(e)]:[]}var Ht=(t,e,r)=>Z(t,e).filter(n=>n.closest(r)===t),$t=["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 Dt(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 Ft(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 Vt(t,e,r){if(!e)return;let n=ot(e,t);if(t.tagName!=="IMG"){t.style.backgroundImage=Ft(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,Gt=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 jt(t,e,r){let n=st(t);if(!n){e.length&&S("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 qt(t,e){let r=()=>{t.remove()};if(!e){r();return}try{e(t,r)}catch(n){b(n,"repeater onLeave"),r()}}function Qt(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){b(a,"repeater onEnter")}})}function Wt(t,e,r,n,{onEnter:o,onLeave:i}={}){let s=st(t);if(!s){S("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 R=String(r(u,A)),y=d.get(R);y?d.delete(R):(y=H(s),y.setAttribute(a,R),f.add(y)),n(y,u,A,f.has(y)),h.push(y)});let w=h.filter(u=>!f.has(u)),F=p().filter(u=>w.includes(u));if(!(F.length===w.length&&F.every((u,A)=>u===w[A]))){d.forEach(u=>{u.remove()}),h.forEach(u=>t.appendChild(u));return}Qt(t,h,f,o),d.forEach(u=>{u.setAttribute(l,""),u.removeAttribute(a),u.style.pointerEvents="none",u.inert=!0,qt(u,i)})}var Bt="http://www.w3.org/1999/xhtml",Kt=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"]),zt=new Set(["script","style","template","noscript","textarea","select","title"]),Yt=new Set(["style","title","lang","dir","role","align","width","height"]),Jt=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"])]]),Xt=new Set(["href","src","poster","cite"]),Zt=/^(javascript|vbscript|data):/i,te=/^data:image\/(png|gif|jpeg|webp|avif);/i,ee=new Set(["position","top","right","bottom","left","z-index","-webkit-box-reflect"]),re=["inset","transform","translate","rotate","scale","offset"],ne=/\d(?:[sld]?v|cq)(?:w|h|i|b|min|max)\b/i,oe=/^(?:outline|box-shadow|text-shadow|filter|text-decoration|text-underline-offset|text-stroke)|^(?:border-image|mask-border|mask-box-image)(?:-outset)?$/,at=40,ie=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,se=/(?<![\w-])(?!drop-shadow\(|blur\()[\w-]+\([^()]*\)/g,ct=/(?:var|calc|min|max|clamp|env|attr)\(/i,ae=/url\(|expression\(|@import/i,ue=/[\u0000- ]/g,ce="allow-scripts allow-same-origin allow-popups allow-presentation",le=new Set(["autoplay","encrypted-media","picture-in-picture","fullscreen","clipboard-write","accelerometer","gyroscope","web-share"]),de="strict-origin-when-cross-origin",fe=["https://www.youtube.com","https://www.youtube-nocookie.com","https://player.vimeo.com","https://www.loom.com","https://fast.wistia.net"];function pe(t,e){return Yt.has(e)||e.startsWith("aria-")||(Jt.get(t)?.has(e)??!1)}function ge(t,e,r){let n=r.replace(ue,"");return Zt.test(n)?t==="img"&&e==="src"&&te.test(n):!0}function lt(t,e){try{return new URL(t,e)}catch{return null}}function me(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([...fe,...r])}}function he(t,e){let r=lt(t.trim(),e.baseUrl);return r!==null&&r.origin!==e.origin&&e.embedOrigins.has(r.origin)}function ye(t){let e=t.split(";").map(r=>r.trim().split(/\s+/)[0]?.toLowerCase()??"");return[...new Set(e.filter(r=>le.has(r)))].join("; ")}function Ee(t,e){if(ee.has(t)||re.some(n=>t.startsWith(n))||ne.test(e))return!0;let r=ie.get(t);return r?ct.test(e)||Te(e,r):t.startsWith("margin")&&e.includes("-")}function Te(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 be(t,e){return oe.test(t.replace(/^-webkit-/,""))?ct.test(e)?!0:[...e.replace(se,"").matchAll(ut)].some(([r="",n=""])=>{let o=Math.abs(parseFloat(r));return o!==0&&(n.toLowerCase()!=="px"||o>at)}):!1}function we(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);(Ee(i,s)||be(i,s)||ae.test(s))&&r.removeProperty(i)}let o=r.cssText;return e.removeAttribute("style"),o}function Se(t,e){let r=t.localName;for(let i of[...t.attributes]){let s=i.name.toLowerCase(),a=Xt.has(s);pe(r,s)&&(!a||ge(r,s,i.value))||t.removeAttribute(i.name)}let n=t.getAttribute("style");if(n===null)return;let o=we(n,e.styleParser);o===""?t.removeAttribute("style"):t.setAttribute("style",o)}var Ae=new Set(["","_self","_parent","_top"]);function xe(t){if(t.localName==="iframe"){let n=ye(t.getAttribute("allow")??"");n===""?t.removeAttribute("allow"):t.setAttribute("allow",n),t.setAttribute("sandbox",ce),t.setAttribute("referrerpolicy",de);return}if(t.localName!=="a")return;let e=t.getAttribute("target");if(e===null||Ae.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 ve(t,e){let r=t.localName,n=t.namespaceURI===Bt;if(n&&zt.has(r)){t.remove();return}if(!n||!Kt.has(r)){t.replaceWith(...t.childNodes);return}if(r==="iframe"&&!he(t.getAttribute("src")??"",e)){t.remove();return}Se(t,e),xe(t)}function dt(t,e=globalThis.document,r=[]){let n=e.createElement("template");n.innerHTML=t??"";let o=me(e,n,r);for(let i of[...n.content.querySelectorAll("*")])ve(i,o);return n.content}var ft="data-tether-seen",D="data-tether-shown",k="data-tether-prev-display",ke=120;function nr(t,e){return Q(c.productPath||"/product",t,e)}function ht(t,e){try{return t()}catch(r){if(r instanceof RangeError)return e;throw r}}function or(t,e=c.locale){return t?ht(()=>new Intl.NumberFormat(e||void 0,{style:"percent",maximumFractionDigits:0}).format(t/100),`${t}%`):""}function ir(t){return t?c.formatMoney?c.formatMoney(t,c.locale):q(t,c.locale):""}function sr(t){return t?ht(()=>new Date(t).toLocaleDateString(c.locale||void 0),""):""}function ar(t,e){t.replaceChildren(dt(e,t.ownerDocument,c.embedOrigins))}var yt=t=>t.tagName==="INPUT"||t.tagName==="TEXTAREA",pt=t=>t.tagName==="INPUT";function Re(t,e){let r=e==null?"":String(e);yt(t)?t.value=r:t.textContent=r}var gt=t=>yt(t)?t.value:t.textContent;function ur(t,e){let r=gt(t);if(Re(t,e),r!==gt(t)&&t.hasAttribute(ft)&&c.onValueChange)try{c.onValueChange(t,r)}catch(n){b(n,"onValueChange")}t.setAttribute(ft,"1")}function Oe(t){if(t.hasAttribute(D))return;t.setAttribute(D,""),t.removeAttribute("hidden");let e=t.getAttribute(k);e!==null?(t.style.display=e,t.removeAttribute(k)):t.style.display==="none"&&(t.style.display=""),typeof getComputedStyle=="function"&&getComputedStyle(t).display==="none"&&(t.style.display=t.getAttribute(m("display"))||"block")}function cr(t,e){if(e){Oe(t);return}t.removeAttribute(D),!t.hasAttribute(k)&&t.style.display!=="none"&&t.setAttribute(k,t.style.display),t.style.display="none"}function lr(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,Ce=t=>Reflect.get(window,t);function Le(){let t=Ce("ScrollTrigger");if(typeof t!="function")return;let e=Reflect.get(t,"refresh");typeof e=="function"&&Reflect.apply(e,t,[])}function Ne(t){clearTimeout(mt),mt=setTimeout(()=>{try{c.onLayoutChange?c.onLayoutChange(t):Le()}catch(e){b(e,"layout-changed")}M("layout-changed",{reason:t})},ke)}function dr(t,e){let r=[...t.querySelectorAll("img")].filter(i=>!i.complete),n=r.length,o=()=>{n-=1,n===0&&Ne(`${e}:images`)};r.forEach(i=>{i.addEventListener("load",o,{once:!0}),i.addEventListener("error",o,{once:!0})})}function fr(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 pr(t,e){let r=t?P(t,e):null;if(!r)return null;try{return JSON.parse(r)}catch{return S(`invalid JSON in ${m(e)}`,t),null}}function $(t){return t==null?"":typeof t=="string"?t:typeof t=="number"||typeof t=="boolean"?String(t):JSON.stringify(t)}function gr(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 mr(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,He as c,$e as d,Tt as e,De as f,X as g,Fe as h,Mt as i,Ve as j,Ge as k,m as l,_t as m,P as n,Ut as o,Z as p,Ht as q,$t as r,Dt as s,M as t,nt as u,it as v,Vt as w,Gt as x,jt as y,Wt as z,nr as A,or as B,ir as C,sr as D,ar as E,Re as F,ur as G,cr as H,lr as I,Ce as J,Ne as K,dr as L,fr as M,pr as N,gr as O,mr as P};
@@ -1 +0,0 @@
1
- import{a as n}from"./chunk-YJC3CSEG.js";import{g as r}from"./chunk-2IGCUTG5.js";import{m as e}from"./chunk-P73VN3B6.js";import{z as i}from"./chunk-D3MRWOFI.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
- var e={diagnose:()=>import("./diagnose-TE72GNOO.js"),markets:()=>import("./markets-ui-AAQM4PEE.js"),search:()=>import("./search-PWF4YZQO.js"),lists:()=>import("./lists-ZMVRGD6L.js"),extras:()=>import("./extras-7GTMJMOZ.js"),account:()=>import("./account-LCMJ7QU5.js"),"account-pages":()=>import("./account-pages-3C5KTPQV.js"),analytics:()=>import("./analytics-VWSZOX2D.js")},a=t=>e[t](),o=void 0;export{a,o as b};
@@ -1 +0,0 @@
1
- import{a as T}from"./chunk-SOFWDTR7.js";import"./chunk-YJC3CSEG.js";import{b as E,d as w,g as I}from"./chunk-2IGCUTG5.js";import{a as H,b as m,d as h}from"./chunk-EUCFOBIT.js";import{c as A,h as x,i as M,j as O}from"./chunk-ZBV2JSHE.js";import{E as b,F as $,H as f,K as N,M as q,a as y,h as a,l as P,m as c,n as i,o as d,q as k,t as u,w as v,y as K}from"./chunk-P73VN3B6.js";import{b as l,r as L,z as S}from"./chunk-D3MRWOFI.js";var U="url:",Y=`query TetherCollection($handle:String!,$first:Int!,$after:String,$sortKey:ProductCollectionSortKeys,$reverse:Boolean,$filters:[ProductFilter!]){collection(handle:$handle){${A()} products(first:$first,after:$after,sortKey:$sortKey,reverse:$reverse,filters:$filters){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}}`,B="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 W({collection:n,query:t,first:o=L.collectionFirst,after:e=null,sortKey:r,reverse:s=!1,filters:D}={}){if(n){let C=await a(h(Y),{handle:n,first:o,after:e,sortKey:r||void 0,reverse:s,filters:D??void 0},x);if(!C.collection)throw new y(`Collection not found: ${n}`,{code:"NOT_FOUND"});let{products:g,..._}=C.collection;return g.nodes.forEach(m),{collection:_,products:g.nodes,pageInfo:g.pageInfo}}let p=await a(h(B),{first:o,after:e,query:t||void 0,sortKey:r||void 0,reverse:s},M);return p.products.nodes.forEach(m),{collection:null,products:p.products.nodes,pageInfo:p.products.pageInfo}}async function j(n,t="RELATED"){let o=H(typeof n=="object"?n?.id:n);if(!o)throw new y("No product for recommendations",{code:"NOT_FOUND"});let e=o.startsWith("gid://"),s=(await a(h(`query TetherRecs(${e?"$id: ID!":"$handle: String!"},$intent:ProductRecommendationIntent){productRecommendations(${e?"productId: $id":"productHandle: $handle"},intent:$intent){...TetherProduct}}`),e?{id:o,intent:t}:{handle:o,intent:t},O)).productRecommendations??[];return s.forEach(m),s}var z=n=>n instanceof window.Element,F=n=>parseInt(n??"",10)||void 0,G=n=>n==="COMPLEMENTARY"?"COMPLEMENTARY":"RELATED",R=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",o=>{if(!z(o.target))return;let e=o.target.closest(c("load-more"));e?.closest(T())===t&&(o.preventDefault(),q(e,()=>this.load(!0)))})}$(t){return k(this.root,t,T())}options(){let{root:t}=this,o={reverse:i(t,"reverse")==="true"},e=F(i(t,"limit"));e&&(o.first=e);let r=i(t,"sort");if(r&&(o.sortKey=r),d(t,"collection"))return o.collection=i(t,"collection")??"",o;let s=i(t,"products")??"";return o.query=s.startsWith(U)?new URL(window.location.href).searchParams.get(s.slice(U.length))||"":s,o}async loadRecommendations(){let{key:t}=E(this.root,window.location,"recommendations"),o=this.root.closest(c("product"));return!t&&o&&({key:t}=E(o)),j(t,G(i(this.root,"intent")))}async load(t=!1){this.loadToken+=1;let o=this.loadToken,e=()=>o!==this.loadToken;try{if(d(this.root,"recommendations")){let r=await this.loadRecommendations();if(e())return;let s=F(i(this.root,"limit"));this.products=s?r.slice(0,s):r}else{let r=await W({...this.options(),after:t?this.pageInfo?.endCursor??null:null});if(e())return;this.collection=r.collection,this.pageInfo=r.pageInfo,this.products=t?[...this.products,...r.products]:r.products}this.render(),I(this.root,"ready"),u("list-ready",{products:this.products,collection:this.collection},this.root)}catch(r){if(e())return;t||I(this.root,w(r)?"not-found":"error",r),w(r)&&d(this.root,"recommendations")||S(r,"list load failed"),u("error",{error:r,context:"list"},this.root)}}render(){let{collection:t}=this;this.$(c("collection-bind")).forEach(e=>{switch(i(e,"collection-bind")??""){case"title":$(e,t?.title??"");break;case"description":b(e,t?.descriptionHtml);break;case"image":v(e,t?.image?.url,t?.image?.altText||t?.title);break;case"count":$(e,this.products.length);break}}),this.$(c("list")).forEach(e=>{K(e,this.products,(r,s)=>{r.setAttribute(P("product"),s.handle),r.removeAttribute(P("state"))}),u("list-rendered",{container:e},this.root)});let o=this.products.length===0;this.$(c("show")).forEach(e=>{let r=i(e,"show");r==="list-empty"&&f(e,o),r==="list-filled"&&f(e,!o)}),this.$(c("load-more")).forEach(e=>{f(e,!!this.pageInfo?.hasNextPage)}),N("list")}},Q=new WeakMap;function nt(n){let t=Q.get(n);return t||(t=new R(n),Q.set(n,t)),t.load()}export{W as getProducts,j as getRecommendations,nt as loadList};
@@ -1 +0,0 @@
1
- import{f as M}from"./chunk-HROQXZYN.js";import"./chunk-SOFWDTR7.js";import"./chunk-F2BYVA7V.js";import"./chunk-P6DV24RG.js";import"./chunk-XU27NSXT.js";import"./chunk-S5BUUIB6.js";import"./chunk-YJC3CSEG.js";import"./chunk-2IGCUTG5.js";import"./chunk-EUCFOBIT.js";import"./chunk-ZBV2JSHE.js";import{A as x,C,F as q,H as d,c as S,d as E,h as T,l as A,m as o,n as m,p as h,t as I,w as L,y as w}from"./chunk-P73VN3B6.js";import{b as a,r as u,x as b,z as y}from"./chunk-D3MRWOFI.js";var N=E({predictiveSearch:S({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=2,F="/search",R=new WeakSet,v=0;function $(s,t,e){return parseInt(m(s,t)||"",10)||e}var H=s=>s.tagName==="A"?s:s.querySelector("a");function p(s,t){h(s,o("search-bind")).forEach(e=>{let i=m(e,"search-bind");i==="image"?L(e,t.image?.url,t.image?.altText||t.title):(i==="title"||i==="price"||i==="text")&&t[i]!=null&&q(e,t[i])})}function k(s,t){let e=H(s);e&&(t&&e.setAttribute("href",t),e.setAttribute("role","option"))}var f=class{constructor(t,e,i){a(this,"root");a(this,"input");a(this,"results");a(this,"limit");a(this,"minCharacters");a(this,"resultsId");a(this,"searchNumber",0);a(this,"timer");a(this,"lastTerm","");a(this,"cache",new Map);this.root=t,this.input=e,this.results=i,this.limit=$(t,"search-limit",D),this.minCharacters=$(t,"search-min",V),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(A("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 T(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){b("a superseded search failed",i);return}this.setState("error"),y(i,"search")}}fillList(t,e,i){h(this.results,o(t)).forEach(l=>{w(l,e,i),d(l,e.length>0)})}queryUrl(t){let e=this.root.getAttribute("action")||F,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(n=>n.text.toLowerCase()!==e.toLowerCase());this.fillList("search-products",i,(n,r)=>{let P=C(r.priceRange.minVariantPrice);p(n,{title:r.title,price:P,image:r.featuredImage}),k(n,x(r.handle,r.id)),n.classList.toggle("is-sold-out",!r.availableForSale)}),this.fillList("search-collections",l,(n,r)=>{p(n,{title:r.title,image:r.image}),k(n,`${(u.collectionPath||"/collection").replace(/\/$/,"")}/${r.handle}`)}),this.fillList("search-queries",c,(n,r)=>{p(n,{text:r.text}),H(n)?.setAttribute("href",this.queryUrl(r.text))});let g=i.length+l.length+c.length;this.showCount(g),this.setState(g?"ready":"empty"),this.open(!0),I("search",{term:e,products:i,collections:l,queries:c},this.root)}showCount(t){h(this.root,o("show")).forEach(e=>{let i=m(e,"show");i==="search-empty"&&d(e,t===0),i==="search-results"&&d(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 j(s=document){for(let t of M(s,o("search"))){if(R.has(t))continue;R.add(t);let e=t.querySelector(o("search-input"))??t.querySelector("input"),i=t.querySelector(o("search-results"));e&&i&&new f(t,e,i)}}export{j as mountSearch};