@occluze/tether 0.6.6 → 0.6.8

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 (135) hide show
  1. package/README.md +3 -3
  2. package/dist/esm/astro.js +2 -2
  3. package/dist/esm/chunks/account-C3NP6HFB.js +1 -0
  4. package/dist/esm/chunks/account-pages-WLK374FO.js +1 -0
  5. package/dist/esm/chunks/analytics-G3SAWMNL.js +1 -0
  6. package/dist/esm/chunks/chunk-27PJJZGC.js +1 -0
  7. package/dist/esm/chunks/chunk-2FSXS55U.js +1 -0
  8. package/dist/esm/chunks/chunk-FCSWQDVV.js +1 -0
  9. package/dist/esm/chunks/chunk-FOMSMIAM.js +1 -0
  10. package/dist/esm/chunks/chunk-GZJTCLLW.js +1 -0
  11. package/dist/esm/chunks/chunk-HEQILZVR.js +1 -0
  12. package/dist/esm/chunks/chunk-JOOEXYF3.js +4 -0
  13. package/dist/esm/chunks/chunk-MPTQYLSM.js +1 -0
  14. package/dist/esm/chunks/chunk-NEHZ37TU.js +3 -0
  15. package/dist/esm/chunks/chunk-V74KGEJF.js +1 -0
  16. package/dist/esm/chunks/chunk-VT4CDUJJ.js +1 -0
  17. package/dist/esm/chunks/chunk-YJLWX2HK.js +1 -0
  18. package/dist/esm/chunks/diagnose-6VVGZNTY.js +14 -0
  19. package/dist/esm/chunks/extras-GJVRDFM3.js +1 -0
  20. package/dist/esm/chunks/markets-ui-UNB4PTA7.js +1 -0
  21. package/dist/esm/chunks/search-OU75RNQL.js +1 -0
  22. package/dist/esm/index.js +1 -1
  23. package/dist/esm/server.js +2 -1
  24. package/dist/presets/barba.esm.js +56 -36
  25. package/dist/tether.account-pages.js +776 -432
  26. package/dist/tether.account-pages.min.js +1 -1
  27. package/dist/tether.account.js +655 -321
  28. package/dist/tether.account.min.js +1 -1
  29. package/dist/tether.analytics.js +318 -191
  30. package/dist/tether.analytics.min.js +1 -1
  31. package/dist/tether.diagnose.js +334 -243
  32. package/dist/tether.diagnose.min.js +2 -2
  33. package/dist/tether.extras.js +78 -33
  34. package/dist/tether.extras.min.js +1 -1
  35. package/dist/tether.js +3171 -1998
  36. package/dist/tether.markets.js +231 -126
  37. package/dist/tether.markets.min.js +1 -1
  38. package/dist/tether.min.js +0 -0
  39. package/dist/tether.min.js.map +4 -4
  40. package/dist/tether.search.js +221 -126
  41. package/dist/tether.search.min.js +1 -1
  42. package/package.json +23 -4
  43. package/src/account/addresses-view.js +92 -0
  44. package/src/account/browser-session.js +359 -0
  45. package/src/account/markup.js +48 -0
  46. package/src/account/operations.js +180 -0
  47. package/src/account/order-lines.js +96 -0
  48. package/src/account/order-list.js +91 -0
  49. package/src/account/order-page.js +192 -0
  50. package/src/account/page-events.js +288 -0
  51. package/src/account/server-client.js +172 -0
  52. package/src/account/shared.js +111 -0
  53. package/src/account/shopify-auth.js +150 -0
  54. package/src/account/subscriptions-view.js +158 -0
  55. package/src/account-api.js +118 -0
  56. package/src/account-links.js +35 -0
  57. package/src/account-pages.js +68 -284
  58. package/src/account.js +281 -317
  59. package/src/amounts.js +36 -0
  60. package/src/analytics-shopify.js +241 -0
  61. package/src/analytics.js +304 -184
  62. package/src/api-version.js +75 -25
  63. package/src/astro.js +233 -68
  64. package/src/cart/checkout.js +97 -0
  65. package/src/cart/drawer.js +138 -0
  66. package/src/cart/mutations.js +234 -0
  67. package/src/cart/render.js +294 -0
  68. package/src/cart/store.js +326 -0
  69. package/src/cart.js +322 -481
  70. package/src/client.js +214 -78
  71. package/src/collection.js +126 -57
  72. package/src/config.js +323 -59
  73. package/src/controls/cart-controls.js +155 -0
  74. package/src/controls/discount.js +96 -0
  75. package/src/controls/extras.js +63 -0
  76. package/src/controls/navigation.js +83 -0
  77. package/src/diagnose-markup.js +333 -0
  78. package/src/diagnose.js +251 -202
  79. package/src/dom.js +219 -220
  80. package/src/extras.js +119 -37
  81. package/src/fragments.js +115 -22
  82. package/src/images.js +104 -0
  83. package/src/index.js +245 -285
  84. package/src/initial.js +78 -66
  85. package/src/lazy-iife.js +92 -22
  86. package/src/lazy.js +25 -4
  87. package/src/loader.js +263 -124
  88. package/src/market-codes.js +35 -0
  89. package/src/markets-ui.js +169 -55
  90. package/src/markets.js +286 -85
  91. package/src/markup.js +64 -0
  92. package/src/mounting.js +214 -91
  93. package/src/page-market.js +116 -0
  94. package/src/parts/account-pages.js +4 -1
  95. package/src/parts/account.js +4 -1
  96. package/src/parts/analytics.js +4 -1
  97. package/src/parts/diagnose.js +4 -1
  98. package/src/parts/extras.js +4 -1
  99. package/src/parts/markets.js +4 -1
  100. package/src/parts/search.js +4 -1
  101. package/src/presets/barba.js +120 -30
  102. package/src/product-events.js +130 -0
  103. package/src/product-render.js +257 -0
  104. package/src/product-state.js +318 -0
  105. package/src/product.js +233 -459
  106. package/src/repeaters.js +173 -0
  107. package/src/search.js +277 -107
  108. package/src/selling-plans.js +107 -47
  109. package/src/server.js +168 -205
  110. package/src/shopify-values.js +89 -0
  111. package/src/status.js +99 -39
  112. package/src/store-html.js +0 -0
  113. package/src/storefront/catalog.js +199 -0
  114. package/src/storefront/json-ld.js +167 -0
  115. package/src/variant-render.js +165 -0
  116. package/types/astro.d.ts +13 -2
  117. package/types/index.d.ts +178 -27
  118. package/types/server.d.ts +89 -17
  119. package/dist/esm/chunks/account-QUBHQG3C.js +0 -1
  120. package/dist/esm/chunks/account-pages-VWDHF6WA.js +0 -1
  121. package/dist/esm/chunks/analytics-SLATWPLC.js +0 -1
  122. package/dist/esm/chunks/chunk-64TUD3QR.js +0 -1
  123. package/dist/esm/chunks/chunk-AJLPU2JC.js +0 -4
  124. package/dist/esm/chunks/chunk-FIOZPPC5.js +0 -1
  125. package/dist/esm/chunks/chunk-K2YEQAIH.js +0 -1
  126. package/dist/esm/chunks/chunk-L2TRRKYV.js +0 -1
  127. package/dist/esm/chunks/chunk-RREHGH4A.js +0 -1
  128. package/dist/esm/chunks/chunk-VC46IEJQ.js +0 -1
  129. package/dist/esm/chunks/chunk-VCPI7MJ2.js +0 -1
  130. package/dist/esm/chunks/chunk-VPVJPNB4.js +0 -1
  131. package/dist/esm/chunks/chunk-ZIUIWEON.js +0 -1
  132. package/dist/esm/chunks/diagnose-VXQBSD3A.js +0 -14
  133. package/dist/esm/chunks/extras-R4X34VQL.js +0 -1
  134. package/dist/esm/chunks/markets-ui-F3R5T5EL.js +0 -1
  135. package/dist/esm/chunks/search-NILMGYXG.js +0 -1
package/README.md CHANGED
@@ -21,7 +21,7 @@ An open-source, free alternative to Smootify and Storesynk (formerly Shopyflow):
21
21
  - **Astro too:** build-time product pages with live prices and cart, View Transitions included ([Astro guide](docs/astro.md)).
22
22
  - **Hand-over ready:** loading, error and not-found states, `Tether.diagnose()`, error reporting.
23
23
 
24
- MIT licensed · 20 KB gzipped · no dependencies · TypeScript types · [full reference](docs/reference.md) · [comparison](docs/comparison.md) · [changelog](CHANGELOG.md)
24
+ MIT licensed · 25 KB gzipped · no dependencies · TypeScript types · [full reference](docs/reference.md) · [comparison](docs/comparison.md) · [changelog](CHANGELOG.md)
25
25
 
26
26
  ---
27
27
 
@@ -33,7 +33,7 @@ MIT licensed · 20 KB gzipped · no dependencies · TypeScript types · [full re
33
33
  | **npm** | Astro, Vite or another bundler or framework | `npm install @occluze/tether` ([Astro guide](docs/astro.md), [other frameworks](docs/frameworks.md)) |
34
34
  | **With the Worker** | you also want the CMS sync, rebuilds when products change, or secure customer accounts | either of the above, plus your own free Cloudflare Worker ([Worker](server/README.md), [accounts](docs/accounts.md)) |
35
35
 
36
- The script tag pinned to one release: `…/tether@v0.6.6/dist/tether.min.js`. Its optional parts
36
+ The script tag pinned to one release: `…/tether@v0.6.8/dist/tether.min.js`. Its optional parts
37
37
  (search, accounts, markets, analytics) load from the same folder when a page uses them; host the
38
38
  files yourself and set `partsUrl` if they live somewhere else. Customer accounts without the Worker
39
39
  run in browser mode; [server mode](docs/accounts.md#server-mode) (recommended for live shops)
@@ -64,7 +64,7 @@ Site settings → Custom code → **Head**:
64
64
  <script src="https://cdn.jsdelivr.net/gh/ravi-klaassens/tether@0.6/dist/tether.min.js" defer></script>
65
65
  ```
66
66
 
67
- **Versions:** `@0.6` gets every 0.6.x fix automatically (recommended), `@v0.6.6` pins one release,
67
+ **Versions:** `@0.6` gets every 0.6.x fix automatically (recommended), `@v0.6.8` pins one release,
68
68
  `@latest` always takes the newest. Hosting the file yourself? Put the optional parts next to it (`tether.markets.min.js`,
69
69
  `tether.search.min.js`, `tether.account.min.js`, `tether.account-pages.min.js`, `tether.analytics.min.js`, `tether.extras.min.js`,
70
70
  `tether.diagnose.min.js`): each loads only when a page uses it.
package/dist/esm/astro.js CHANGED
@@ -1,2 +1,2 @@
1
- import"./chunks/chunk-VC46IEJQ.js";var l={domain:["PUBLIC_SHOPIFY_DOMAIN","PUBLIC_SHOPIFY_STORE_DOMAIN","SHOPIFY_DOMAIN"],token:["PUBLIC_SHOPIFY_STOREFRONT_TOKEN","PUBLIC_SHOPIFY_STOREFRONT_ACCESS_TOKEN","SHOPIFY_STOREFRONT_TOKEN"]};function T(a,o=process.argv){let n=o.findIndex(t=>t==="--mode"||t.startsWith("--mode="));return n>=0?o[n].includes("=")?o[n].split("=")[1]:o[n+1]:a==="dev"?"development":"production"}async function m(a,o){let n=T(a),t={};try{let{readFile:I}=await import("node:fs/promises"),{join:p}=await import("node:path");for(let u of[".env",".env.local",`.env.${n}`,`.env.${n}.local`]){let f;try{f=await I(p(o,u),"utf8")}catch{continue}for(let O of f.split(/\r?\n/)){let s=/^\s*(?:export\s+)?([\w.-]+)\s*=\s*(.*?)\s*$/.exec(O);if(!s||O.trim().startsWith("#"))continue;let i=s[2],_=/^(["'])(.*?)\1/.exec(i);i=_?_[2]:i.replace(/\s+#.*$/,""),t[s[1]]=i}}}catch{}return{...t,...process.env}}function h(a={}){let{inject:o=!0,watch:n=["src/shop.config.js","src/shop.config.mjs","src/shop.config.ts"],...t}=a;return{name:"@occluze/tether",hooks:{"astro:config:setup":async({injectScript:I,command:p,config:u,logger:f,addWatchFile:O,updateConfig:s})=>{let i=u?.root?decodeURIComponent(new URL(u.root).pathname):process.cwd();if(p==="dev"&&O){let{existsSync:e}=await import("node:fs"),{resolve:r}=await import("node:path");[].concat(n||[]).map(c=>r(i,c)).filter(c=>e(c)).forEach(c=>O(c))}if(s)try{let{envField:e}=await import("astro/config");if(e){let r=()=>e.string({context:"client",access:"public",optional:!0});s({env:{schema:{PUBLIC_SHOPIFY_DOMAIN:r(),PUBLIC_SHOPIFY_STOREFRONT_TOKEN:r()}}})}}catch{}let _=await m(p,i);for(let[e,r]of Object.entries(l))t[e]||(t[e]=r.map(c=>_[c]).find(Boolean));let d=Object.entries(t).filter(([,e])=>typeof e=="function").map(([e])=>e);d.forEach(e=>delete t[e]),d.length&&f.warn(`${d.join(", ")}: functions can't be passed here. Set them in window.TETHER_CONFIG in your layout.`),(!t.domain||!t.token)&&f.warn("No Shopify store configured: set PUBLIC_SHOPIFY_DOMAIN and PUBLIC_SHOPIFY_STOREFRONT_TOKEN in .env (the public Storefront API token)."),o&&(I("head-inline",'window.TETHER_INTEGRATION="astro";'),I("page",["import Tether from '@occluze/tether';",`window.TETHER_CONFIG = { ...${JSON.stringify({autoMount:!1,...t})}, ...(window.TETHER_CONFIG || {}) };`,"Tether.init().then(() => Tether.mount(document));"].join(`
2
- `)))}}}}export{h as default};
1
+ import{b as p,d}from"./chunks/chunk-FOMSMIAM.js";var w=["src/shop.config.js","src/shop.config.mjs","src/shop.config.ts"],m="astro/config",E=/^\s*(?:export\s+)?([\w.-]+)\s*=\s*(.*?)\s*$/,T=/^(["'])(.*?)\1/;function O(t,e=process.argv){let o=t==="dev"?"development":"production",n=e.findIndex(s=>s==="--mode"||s.startsWith("--mode="));if(n<0)return o;let i=e[n]??"";return(i.includes("=")?i.split("=")[1]:e[n+1])??o}var y=t=>t instanceof Error&&Reflect.get(t,"code")==="ENOENT";async function _(t){let{readFile:e}=await import("node:fs/promises");try{return await e(t,"utf8")}catch(o){if(y(o))return null;throw o}}function I(t,e){for(let o of t.split(/\r?\n/)){let n=E.exec(o);if(!n||o.trim().startsWith("#"))continue;let[,i="",r=""]=n,s=T.exec(r);e[i]=s?s[2]??"":r.replace(/\s+#.*$/,"")}}async function N(t,e){let o=await import("node:path"),n=O(t),i={};for(let r of[".env",".env.local",`.env.${n}`,`.env.${n}.local`]){let s=await _(o.join(e,r));s!==null&&I(s,i)}return{...i,...process.env}}function v(t,e,o){for(let n of["domain","token"]){if(t[n])continue;let i=p[n].find(r=>e[r]);i&&(t[n]=e[i],i.startsWith("PUBLIC_")||o.warn(`${i} is written into every page as Tether's ${n}. Name it PUBLIC_${i} to say so.`))}if(typeof t.token=="string"&&d(t.token))throw new Error("The Shopify token for Tether is a secret token (shpat_/shpss_/\u2026), which would be published in every page. Use the public Storefront API token from the Headless channel.")}async function S(t,e,o){let{existsSync:n}=await import("node:fs"),i=await import("node:path");for(let r of e){let s=i.resolve(t,r);n(s)&&o(s)}}async function F(t){try{return await import(t)}catch(e){if(e instanceof Error&&Reflect.get(e,"code")==="ERR_MODULE_NOT_FOUND")return null;throw e}}async function R(t,e){let o=await F(m),n=typeof o=="object"&&o!==null?Reflect.get(o,"envField"):null;if(typeof n!="object"||n===null||typeof Reflect.get(n,"string")!="function")return;let i=n,r=()=>i.string({context:"client",access:"public",optional:!0});try{t({env:{schema:{PUBLIC_SHOPIFY_DOMAIN:r(),PUBLIC_SHOPIFY_STOREFRONT_TOKEN:r()}}})}catch(s){e.warn(`.env variables not declared in astro:env: ${s instanceof Error?s.message:String(s)}`)}}function P(t,e){let o=Object.keys(t).filter(n=>typeof t[n]=="function");for(let n of o)Reflect.deleteProperty(t,n);o.length&&e.warn(`${o.join(", ")}: functions can't be passed here. Set them in window.TETHER_CONFIG in your layout.`)}function U(t,e){t("head-inline",'window.TETHER_INTEGRATION="astro";'),t("page",["import Tether from '@occluze/tether';",`window.TETHER_CONFIG = { ...${JSON.stringify({autoMount:!1,...e})}, ...(window.TETHER_CONFIG || {}) };`,"Tether.init().then(() => Tether.mount(document));"].join(`
2
+ `))}function k(t={}){let{inject:e=!0,watch:o=w,...n}=t;return{name:"@occluze/tether",hooks:{"astro:config:setup":async({injectScript:i,command:r,config:s,logger:a,addWatchFile:f,updateConfig:l})=>{let{fileURLToPath:h}=await import("node:url"),u=s.root?h(s.root):process.cwd();r==="dev"&&f&&await S(u,o??[],f),l&&await R(l,a);let c={...n};v(c,await N(r,u),a),P(c,a),(!c.domain||!c.token)&&a.warn("No Shopify store configured: set PUBLIC_SHOPIFY_DOMAIN and PUBLIC_SHOPIFY_STOREFRONT_TOKEN in .env (the public Storefront API token)."),e&&U(i,c)}}}}export{k as default};
@@ -0,0 +1 @@
1
+ import{a as oe,b as se,c as F,g as R,h as ie}from"./chunk-GZJTCLLW.js";import{a as ae}from"./chunk-VT4CDUJJ.js";import{b as f}from"./chunk-MPTQYLSM.js";import"./chunk-NEHZ37TU.js";import"./chunk-JOOEXYF3.js";import{A as te,C as re,G as ne,J as N,L as K,b as i,g as ee,i as p,l as d,s as w,t as k,v as x,x as E}from"./chunk-YJLWX2HK.js";import"./chunk-FOMSMIAM.js";var ve="amount currencyCode",ce="query TetherCustomer { customer { id firstName lastName displayName emailAddress { emailAddress } defaultAddress { formatted } } }",ue=`query TetherOrders($first:Int!){customer{orders(first:$first,sortKey:PROCESSED_AT,reverse:true){nodes{id name processedAt financialStatus fulfillmentStatus statusPageUrl totalPrice{${ve}}lineItems(first:20){nodes{title variantTitle quantity image{url altText}}}}}}}`;function G(e){return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function le(e){let t=e.replace(/-/g,"+").replace(/_/g,"/").padEnd(Math.ceil(e.length/4)*4,"=");return Uint8Array.from(atob(t),r=>r.charCodeAt(0))}function P(e=32){return G(crypto.getRandomValues(new Uint8Array(e)))}var $=()=>`${i.prefix}:account:${i.domain}`,v=()=>`${i.prefix}:account-login:${i.domain}`,De=()=>`${i.prefix}:account-hint:${i.domain}`,D=()=>i.account?.remember?"local":"session",z=e=>e==="local"?window.localStorage:window.sessionStorage;function Q(e,t){try{return JSON.parse(z(e).getItem(t)??"null")}catch{return null}}function A(e,t,r){try{r===null?z(e).removeItem(t):z(e).setItem(t,JSON.stringify(r))}catch{}}function Y(e){A("local",De(),e?1:null)}var h=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),u=e=>typeof e=="string"?e:null;async function b(e){let t;try{t=await e.json()}catch{return{}}return h(t)?t:{}}function S(e){let t=i.account?.navigate;t?t(e):window.location.assign(e)}var q=e=>e||i.account?.locale||(i.locale||"").split("-")[0]||"",j=()=>i.country?i.country.toUpperCase():"";var qe=3600,B=null;async function de(e){let t=i.account?.shopDomain||i.domain,r=await fetch(`https://${t}/.well-known/${e}`);if(!r.ok)throw new d(`Customer accounts: ${e} answered ${r.status}`,{status:r.status});let n=await r.json();return h(n)?n:{}}function I(e,t){let r=u(e[t]);if(!r)throw new d(`Customer accounts: Shopify named no ${t}`);return r}async function C(){if(B)return B;let[e,t]=await Promise.all([de("openid-configuration"),de("customer-account-api")]);return B={issuer:I(e,"issuer"),authorizationEndpoint:I(e,"authorization_endpoint"),tokenEndpoint:I(e,"token_endpoint"),endSessionEndpoint:I(e,"end_session_endpoint"),graphql:I(t,"graphql_api")},B}async function H(e){let{tokenEndpoint:t}=await C(),r=await fetch(i.account?.tokenUrl||t,{method:"POST",body:new URLSearchParams(e)}),n=await b(r),o=u(n.access_token);if(!r.ok||!o){let s=r.status===400||r.status===401;throw new d(`Customer accounts: token ${r.status} ${u(n.error)??""}`.trim(),{status:r.status,code:s?"SESSION_ENDED":"TOKEN_FAILED"})}return{access:o,refresh:u(n.refresh_token)||null,idToken:u(n.id_token)||null,expiresInSeconds:Number(n.expires_in)||qe}}function je(e){let t=e.split(".")[1];if(!t)return null;let r;try{r=JSON.parse(new TextDecoder().decode(le(t)))}catch{return null}return h(r)?r:null}function fe(e,{nonce:t,issuer:r,client:n}){let o=e?je(e):null;if(!o)return!1;let s=o.aud,a=Array.isArray(s)?s:[s],c=o.exp;return o.nonce===t&&o.iss===r&&a.includes(n)&&typeof c=="number"&&c*1e3>=Date.now()}var Be=120,Je=600*1e3,l=null,O=null,V=null;function Me(e){if(!h(e))return null;let t=e.access,r=e.expiresAt;return typeof t!="string"||typeof r!="number"?null:{access:t,expiresAt:r,refresh:u(e.refresh),idToken:u(e.idToken)}}function Ke(e){if(!h(e))return null;let{state:t,nonce:r,verifier:n,redirect:o,returnTo:s,at:a}=e;return typeof t!="string"||typeof r!="string"||typeof n!="string"||typeof o!="string"||typeof s!="string"||typeof a!="number"?null:{state:t,nonce:r,verifier:n,redirect:o,returnTo:s,at:a}}var me=()=>l??Me(Q(D(),$())),pe=()=>l?.access??null,W=()=>!!(l&&(l.refresh||l.access&&l.expiresAt>Date.now()));function X(){let e=i.account?.clientId;if(!e)throw new d("Customer accounts: set account.clientId",{code:"NOT_CONFIGURED"});return e}var Fe=async e=>G(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e)));async function ge({returnTo:e,locale:t}){let r=X(),n=await C(),o={state:P(),nonce:P(),verifier:P(),redirect:i.account?.callbackUrl||`${window.location.origin}${window.location.pathname}`,returnTo:e,at:Date.now()};A("session",v(),o);let s=new URL(n.authorizationEndpoint),a={client_id:r,scope:"openid email customer-account-api:full",response_type:"code",redirect_uri:o.redirect,state:o.state,nonce:o.nonce,code_challenge:await Fe(o.verifier),code_challenge_method:"S256"},c=q(t);c&&(a.locale=c);let m=j();m&&(a.region_country=m),Object.entries(a).forEach(([_,$e])=>{s.searchParams.set(_,$e)}),S(s.toString())}function we(e,t){l={access:e.access,expiresAt:Date.now()+Math.max(0,e.expiresInSeconds-Be)*1e3,refresh:e.refresh??t?.refresh??null,idToken:e.idToken??t?.idToken??null},A(D(),$(),l)}async function he(){let e=new URLSearchParams(window.location.search),t=Ke(Q("session",v()));if(!t||!e.has("code")&&!e.has("error")||e.get("state")!==t.state)return!1;A("session",v(),null);let r=new URL(window.location.href);["code","state","iss","error","error_description"].forEach(m=>{r.searchParams.delete(m)}),window.history.replaceState(window.history.state,"",r);let n=e.get("error");if(n!==null)return E("account-error",{error:n}),!1;if(Date.now()-t.at>Je)throw new d("Customer accounts: the login took too long, please try again");let o=X(),s=await H({grant_type:"authorization_code",client_id:o,redirect_uri:t.redirect,code:e.get("code")??"",code_verifier:t.verifier}),{issuer:a}=await C();if(!fe(s.idToken,{nonce:t.nonce,issuer:a,client:o}))throw new d("Customer accounts: the login answer did not check out (nonce/issuer/audience)");we(s,null),await ye(),E("account-login",{});let c=t.returnTo?new URL(t.returnTo,window.location.href):null;return c?.origin===window.location.origin&&c.href!==r.href&&S(c.href),!0}function Z(){l=null,O=null,A(D(),$(),null),f.setCustomer({accessToken:null})}async function Ge(e){try{let t=await H({grant_type:"refresh_token",client_id:X(),refresh_token:e.refresh??""});we(t,e),await ye()}catch(t){if(t instanceof d&&t.code==="SESSION_ENDED")Z();else throw t}}async function U(){return l=me(),l?l.access&&l.expiresAt>Date.now()?l.access:l.refresh?(V??(V=Ge(l).finally(()=>{V=null})),await V,pe()):(Z(),null):null}async function ye(){let e=pe();if(f.setCustomer({accessToken:e}),!(!f.id()||!e))try{await f.setBuyerIdentity({customerAccessToken:e},{create:!1})}catch(t){p(t,"account cart")}}async function ze(){if(f.id())try{await f.setBuyerIdentity({customerAccessToken:null},{create:!1})}catch(e){p(e,"account cart unlink"),A("local",i.storageKey,null)}}async function xe(e){let t=me()?.idToken??null;if(await ze(),Z(),E("account-logout",{}),!t)return"stayed";let r=new URL((await C()).endSessionEndpoint);return r.searchParams.set("id_token_hint",t),r.searchParams.set("post_logout_redirect_uri",e),S(r.toString()),"redirected"}async function J(e,t={}){let r=await U();if(!r)throw new d("Not logged in",{code:"NOT_LOGGED_IN"});let{graphql:n}=await C(),o=m=>fetch(n,{method:"POST",headers:{"Content-Type":"application/json",Authorization:m},body:JSON.stringify({query:e,variables:t})}),s=await o(r);s.status===401&&l?.refresh&&(l.expiresAt=0,s=await o(await U()??""));let a=await b(s),c=Array.isArray(a.errors)?a.errors:[];if(!s.ok||c.length){let m=c.map(_=>h(_)?u(_.message):null).filter(Boolean);throw new d(m.join(" | ")||`Customer accounts: ${s.status}`,{status:s.status})}return a.data}async function ke(){return O||(O=(await J(ce)).customer,O)}function Ee(){O=null}var T=null;function g(){let e=i.account?.server;return e?new URL(e,window.location.href).href.replace(/\/$/,""):""}async function L(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 o=await fetch(`${g()}${e}`,n);if(o.status===401)return{kind:"logged-out"};let s=await b(o);if(!o.ok){let a=u(s.error)??String(o.status),c=Array.isArray(s.userErrors)?s.userErrors:void 0;throw new d(`Customer accounts: ${a}`,{status:o.status,...c&&{userErrors:c}})}return{kind:"answer",data:s}}function Qe(e){let t=h(e)?e:{},r=t.address;return{firstName:u(t.firstName),lastName:u(t.lastName),displayName:u(t.displayName),email:u(t.email),address:Array.isArray(r)?r.filter(n=>typeof n=="string"):null}}async function M(){if(!T){let e=await L("/me");T=e.kind==="answer"&&e.data.loggedIn===!0?{loggedIn:!0,customer:Qe(e.data.customer)}:{loggedIn:!1}}return Y(T.loggedIn),T}var Ae=()=>T?.loggedIn===!0;function Se(){T=null}function Te({returnTo:e,locale:t}){let r=new URL(`${g()}/login`);r.searchParams.set("returnTo",e);let n=q(t);n&&r.searchParams.set("locale",n);let o=j();o&&r.searchParams.set("country",o),S(r.toString())}async function _e(){let e=f.id();if(!(await M()).loggedIn||!e)return null;let t=await L("/cart",{method:"POST",body:{cartId:e}});if(t.kind==="logged-out")return null;let r=u(t.data.checkoutUrl);return r?`${r}${r.includes("?")?"&":"?"}logged_in=true`:null}async function be(e){let t=await L("/logout",{method:"POST",body:{returnTo:e,cartId:f.id()}});T=null,Y(!1),E("account-logout",{});let r=t.kind==="answer"?u(t.data.logoutUrl):null;return r?(S(r),"redirected"):"stayed"}var Ce=10,Ye=e=>({name:e.name,date:oe(e.processedAt),total:ne(e.totalPrice),status:e.financialStatus?.toLowerCase(),fulfillment:e.fulfillmentStatus?.toLowerCase(),items:e.lineItems.nodes.map(t=>`${t.quantity}\xD7 ${t.title}`).join(", ")});function He(e,t){let r=t.lineItems.nodes,n=se(t),o=Ye(t);x(e,w("order-bind")).forEach(s=>{let a=k(s,"order-bind")??"";if(a==="url"){n&&s.setAttribute("href",n);return}if(a==="image"){let m=r.find(_=>_.image)?.image;m&&te(s,m.url,m.altText||r[0]?.title||"");return}let c=R(o,a);c!==void 0&&N(s,c)}),x(e,w("order-lines")).forEach(s=>{ie(s,r,null)}),k(e,"order-bind")==="url"&&n&&e.setAttribute("href",n)}async function Oe(e,t){let r=x(e,w("orders")),n=r[0];if(!n)return;F(e,"show",{"orders-loading":!0,"orders-empty":!1});let o=Number.parseInt(k(n,"limit")||String(Ce),10)||Ce,s=await t(o).catch(a=>(p(a,"orders"),null));F(e,"show",{"orders-loading":!1,"orders-empty":s?.length===0}),r.forEach(a=>{re(a,s??[],He)})}var Ve=["order","addresses","subscriptions","profile-form","address-form"];function We(){return g()?Ae():W()}async function Xe({returnTo:e=window.location.href,locale:t}={}){g()?Te({returnTo:e,locale:t}):await ge({returnTo:e,locale:t})}async function Ze(e,t={}){if(g())throw new d("Customer accounts in server mode only answer customer() and orders()",{code:"NOT_ALLOWED"});return J(e,t)}async function Ne(){if(!g())return ke();let e=await M();return e.loggedIn?{...e.customer,emailAddress:{emailAddress:e.customer.email},defaultAddress:{formatted:e.customer.address}}:null}async function et({first:e=10}={}){if(g()){let r=await L(`/orders?first=${e}`);if(r.kind==="logged-out")return[];let n=r.data.orders;return Array.isArray(n)?n:[]}return(await J(ue,{first:e})).customer?.orders.nodes??[]}async function tt({returnTo:e=i.account?.logoutUrl||`${window.location.origin}/`}={}){(g()?await be(e):await xe(e))==="stayed"&&await Re(document)}async function rt(){try{return g()?(await M()).loggedIn?{kind:"logged-in"}:{kind:"logged-out"}:W()||await U()?{kind:"logged-in"}:{kind:"logged-out"}}catch(e){return{kind:"unknown",error:e}}}var Le=e=>Ve.some(t=>x(e,w(t)).length>0);function nt(e){let t=i.account;x(e,w("account-link")).forEach(r=>{let n=k(r,"account-link"),o=t?.subscriptionsUrl,s=n==="payment"&&(t?.paymentUrl||o)||n==="subscriptions"&&o;r.setAttribute("href",s||`https://${i.domain}/account`)})}async function Re(e=document){let t=await rt();t.kind==="unknown"&&p(t.error,"account");let r=t.kind==="logged-in";if(x(e,w("show")).forEach(n=>{let o=k(n,"show");o==="logged-in"&&K(n,r),o==="logged-out"&&K(n,!r)}),nt(e),t.kind==="unknown"&&Le(e)){(await y()).showUnavailable(e);return}r&&(await Pe(e),await Promise.all([Oe(e,n=>et({first:n})),Le(e)?y().then(n=>n.renderPages(e)):null]))}async function Pe(e){let t=x(e,w("account-bind"));if(!t.length)return;let r=await Ne().catch(o=>(p(o,"account"),null)),n={"first-name":r?.firstName,"last-name":r?.lastName,name:r?.displayName,email:r?.emailAddress?.emailAddress,address:r?.defaultAddress?.formatted?.join(", ")};t.forEach(o=>{let s=R(n,k(o,"account-bind")??"");s!=null&&N(o,s)})}var Ie=null;function y(){return Ie??(Ie=ae("account-pages").then(e=>(e.setup({serverBase:g,serverFetch:L,query:Ze,customer:Ne,bindCustomer:Pe,reset:()=>{Ee(),Se()}}),e))),Ie}var Qt=e=>y().then(t=>t.order(e)),Yt=e=>y().then(t=>t.updateProfile(e)),Ht=()=>y().then(e=>e.addresses()),Vt=(e,t)=>y().then(r=>r.saveAddress(e,t)),Wt=e=>y().then(t=>t.deleteAddress(e)),Xt=()=>y().then(e=>e.subscriptions()),Zt=(e,t)=>y().then(r=>r.subscriptionAction(e,t)),er=(e,t)=>y().then(r=>r.requestReturn(e,t));function ot(e){let t=e.target;t instanceof window.Element&&(t.closest(w("account-login"))?(e.preventDefault(),Xe().catch(r=>{p(r,"login")})):t.closest(w("account-logout"))&&(e.preventDefault(),tt().catch(r=>{p(r,"logout")})))}function st(){let e=new URL(window.location.href);e.searchParams.get("account")&&(e.searchParams.delete("account"),window.history.replaceState(window.history.state,"",e),E("account-login",{})),f.setCustomer({beforeCheckout:_e})}async function it(){try{await he()}catch(e){p(e,"login")}if(!f.customerAccessToken)try{let e=await U();e&&f.setCustomer({accessToken:e})}catch(e){p(e,"account")}}var Ue=!1;async function tr(e=document){Ue||(Ue=!0,document.addEventListener("click",ot),g()?st():await it(),ee("account",We()?"logged in":"logged out")),await Re(e)}export{Ht as addresses,Ne as customer,Wt as deleteAddress,U as getToken,he as handleCallback,We as isLoggedIn,Xe as login,tt as logout,tr as mountAccount,Qt as order,et as orders,Ze as query,Re as render,er as requestReturn,Vt as saveAddress,Zt as subscriptionAction,Xt as subscriptions,Yt as updateProfile};
@@ -0,0 +1 @@
1
+ import{a as C,c as f,d as O,e as E,f as N,g as w,h as oe}from"./chunk-GZJTCLLW.js";import{A as re,C as x,G as g,J as h,L as ne,i as I,l as D,r as y,s as a,t as m,v as l,x as se}from"./chunk-YJLWX2HK.js";import{c as z}from"./chunk-FOMSMIAM.js";var p=class extends Error{constructor(t,{status:s=400,userErrors:r=[]}={}){super(t),this.name="InputError",this.status=s,this.userErrors=r}},A="amount currencyCode",U="id firstName lastName company address1 address2 city province zoneCode zip country countryCode phoneNumber formatted",b="userErrors { field message }",_={order:`query TetherOrder($id:ID!){order(id:$id){id name number processedAt cancelledAt financialStatus fulfillmentStatus statusPageUrl requiresShipping totalPrice{${A}}subtotal{${A}}totalShipping{${A}}totalTax{${A}}shippingAddress{${U}}billingAddress{${U}}lineItems(first:50){nodes{id name title variantTitle quantity sku image{url altText}price{${A}}totalPrice{${A}}suggestedReturnReasonDefinitions(first:10){nodes{id name handle}}}}fulfillments(first:10){nodes{id status createdAt estimatedDeliveryAt latestShipmentStatus trackingInformation{company number url}}}returnInformation{returnableLineItems(first:50){nodes{quantity lineItem{id}}}}returns(first:10){nodes{id status}}}}`,addresses:`query TetherAddresses{customer{defaultAddress{id}addresses(first:20){nodes{${U}}}}}`,subscriptions:`query TetherSubscriptions{customer{subscriptionContracts(first:20,reverse:true){nodes{id status nextBillingDate currencyCode deliveryPrice{${A}}deliveryPolicy{interval intervalCount{count}}lines(first:20){nodes{id name title variantTitle quantity sku currentPrice{${A}}lineDiscountedPrice{${A}}image{url altText}}}upcomingBillingCycles(first:3){nodes{cycleIndex skipped billingAttemptExpectedDate}}}}}}`,contract:"query TetherContract($id:ID!){customer{subscriptionContract(id:$id){id status upcomingBillingCycles(first:3){nodes{cycleIndex skipped}}}}}"},L={profile:`mutation TetherProfile($input:CustomerUpdateInput!){customerUpdate(input:$input){customer{firstName lastName}${b}}}`,addressCreate:`mutation TetherAddressCreate($address:CustomerAddressInput!,$default:Boolean){customerAddressCreate(address:$address,defaultAddress:$default){customerAddress{${U}}${b}}}`,addressUpdate:`mutation TetherAddressUpdate($id:ID!,$address:CustomerAddressInput,$default:Boolean){customerAddressUpdate(addressId:$id,address:$address,defaultAddress:$default){customerAddress{${U}}${b}}}`,addressDelete:`mutation TetherAddressDelete($id:ID!){customerAddressDelete(addressId:$id){deletedAddressId ${b}}}`,returnRequest:`mutation TetherReturn($orderId:ID!,$lines:[RequestedLineItemInput!]!){orderRequestReturn(orderId:$orderId,requestedLineItems:$lines){return{id status}${b}}}`},ie={pause:{document:`mutation TetherPause($id:ID!){subscriptionContractPause(subscriptionContractId:$id){contract{id status}${b}}}`,payload:"subscriptionContractPause",input:"contract"},resume:{document:`mutation TetherResume($id:ID!){subscriptionContractActivate(subscriptionContractId:$id){contract{id status}${b}}}`,payload:"subscriptionContractActivate",input:"contract"},cancel:{document:`mutation TetherCancel($id:ID!){subscriptionContractCancel(subscriptionContractId:$id){contract{id status}${b}}}`,payload:"subscriptionContractCancel",input:"contract"},skip:{document:`mutation TetherSkip($input:SubscriptionBillingCycleInput!){subscriptionBillingCycleSkip(billingCycleInput:$input){billingCycle{cycleIndex skipped}${b}}}`,payload:"subscriptionBillingCycleSkip",input:"billingCycle"},unskip:{document:`mutation TetherUnskip($input:SubscriptionBillingCycleInput!){subscriptionBillingCycleUnskip(billingCycleInput:$input){billingCycle{cycleIndex skipped}${b}}}`,payload:"subscriptionBillingCycleUnskip",input:"billingCycle"}};function ge(e){return typeof e=="string"&&Object.hasOwn(ie,e)}function u(e,t){if(!(e===null||typeof e!="object"))return e[t]}function V(e){let t=u(e,"nodes");return Array.isArray(t)?t:[]}var we=/^\d{1,20}$/;function S(e,t){let s=typeof t=="string"||typeof t=="number"?String(t):"",r=we.test(s)?`gid://shopify/${e}/${s}`:s;if(!new RegExp(`^gid://shopify/${e}/\\d+(\\?[\\w=&.-]{1,80})?$`).test(r))throw new p(`${e} id`);return r}var Ae=/[\u0000-\u001f\u007f]/g;function B(e,t=255){if(e==null||e==="")return;if(typeof e!="string"&&typeof e!="number")throw new p("text");let s=String(e).replace(Ae,"").trim();if(s.length>t)throw new p("too long");return s}var Ie=["firstName","lastName","company","address1","address2","city","zip","zoneCode","phoneNumber"];function Ee(e,{clear:t=!1}={}){if(e===null||typeof e!="object"||Array.isArray(e))throw new p("address");let s=e,r={};for(let o of Ie){let i=B(s[o]);i!==void 0?r[o]=i:t&&o in s&&(s[o]===""||s[o]===null)&&(r[o]="")}let n=B(s.countryCode);if(n!==void 0){let o=n.toUpperCase();if(!/^[A-Z]{2}$/.test(o))throw new p("countryCode");r.countryCode=o}return r}function $(e,t){let s=u(e,t),r=u(s,"userErrors");if(Array.isArray(r)&&r.length){let n=r;throw new p(n.map(o=>o.message).join(" | "),{userErrors:n})}return s}var ae={async order(e,{id:t}){let s=await e(_.order,{id:S("Order",t)});return{order:u(s,"order")??null}},async profile(e,{firstName:t,lastName:s}){let r={};if(t!==void 0&&(r.firstName=B(t,100)??""),s!==void 0&&(r.lastName=B(s,100)??""),!Object.keys(r).length)throw new p("nothing to change");let n=$(await e(L.profile,{input:r}),"customerUpdate");return{customer:u(n,"customer")}},async addresses(e){let t=u(await e(_.addresses,{}),"customer"),s=u(u(t,"defaultAddress"),"id")??null;return{addresses:V(u(t,"addresses")).map(n=>({...n,isDefault:u(n,"id")===s}))}},async saveAddress(e,{id:t,address:s,isDefault:r}){let n=Ee(s??{},{clear:!!t}),o=r===!0;if(!t){let d=await e(L.addressCreate,{address:n,default:o});return{address:u($(d,"customerAddressCreate"),"customerAddress")}}let i=await e(L.addressUpdate,{id:S("CustomerAddress",t),address:Object.keys(n).length?n:null,default:o?!0:null});return{address:u($(i,"customerAddressUpdate"),"customerAddress")}},async deleteAddress(e,{id:t}){let s=await e(L.addressDelete,{id:S("CustomerAddress",t)});return{deleted:u($(s,"customerAddressDelete"),"deletedAddressId")}},async subscriptions(e){let t=u(u(await e(_.subscriptions,{}),"customer"),"subscriptionContracts");return{subscriptions:V(t)}},async subscription(e,{id:t,action:s}){if(!ge(s))throw new p("action");let r=S("SubscriptionContract",t),n=u(u(await e(_.contract,{id:r}),"customer"),"subscriptionContract");if(!n)throw new p("not found",{status:404});let{document:o,payload:i,input:d}=ie[s];if(d==="contract")return{contract:u($(await e(o,{id:r}),i),"contract")};let c=V(u(n,"upcomingBillingCycles")),P=s==="unskip",k=c.find(be=>!!u(be,"skipped")===P);if(!k)throw new p(P?"nothing skipped":"no upcoming delivery to skip");let he={input:{contractId:r,selector:{index:u(k,"cycleIndex")}}};return{billingCycle:u($(await e(o,he),i),"billingCycle")}},async requestReturn(e,{orderId:t,lines:s}){let r=S("Order",t);if(!Array.isArray(s)||!s.length||s.length>50)throw new p("lines");let n=s.map(i=>{let d=Number(u(i,"quantity"));if(!Number.isInteger(d)||d<1||d>1e3)throw new p("quantity");let c={lineItemId:S("LineItem",u(i,"lineItemId")),quantity:d},P=u(i,"reasonId");P&&(c.returnReasonDefinitionId=S("ReturnReasonDefinition",P));let k=B(u(i,"note"),300);return k&&(c.customerNote=k),c}),o=await e(L.returnRequest,{orderId:r,lines:n});return{return:u($(o,"orderRequestReturn"),"return")}}};var X=null;function Te(e){X=e}function v(){if(!X)throw new Error("account-pages: loaded without the account part");return X}var xe={order:e=>["GET",`/order?id=${encodeURIComponent(String(e.id))}`],addresses:()=>["GET","/addresses"],subscriptions:()=>["GET","/subscriptions"],profile:()=>["POST","/profile"],saveAddress:()=>["POST","/address"],deleteAddress:()=>["POST","/address/delete"],subscription:()=>["POST","/subscription"],requestReturn:()=>["POST","/return"]};async function T(e,t={}){let{serverBase:s,serverFetch:r,query:n}=v();if(s()){let[i,d]=xe[e](t),c=await r(d,i==="POST"?{method:i,body:t}:{});if(c.kind==="logged-out")throw new D("Not logged in",{code:"NOT_LOGGED_IN",status:401});return c.data}let o=ae[e];if(!o)throw new D(`Customer accounts: no operation ${e}`);try{return await o(async(i,d)=>await n(i,d),t)}catch(i){throw i instanceof p?new D(i.message,{code:"INVALID",userErrors:i.userErrors}):i}}function M(e){v().reset(),se("account-updated",{what:e})}async function K(e){return(await T("order",{id:e})).order??null}async function Q({firstName:e,lastName:t}={}){let s=await T("profile",{firstName:e,lastName:t});return M("profile"),s.customer}async function W(){return(await T("addresses")).addresses}async function H(e,{id:t,isDefault:s}={}){let r=await T("saveAddress",{id:t,address:e,isDefault:s});return M("addresses"),r.address}async function Y(e){let t=await T("deleteAddress",{id:e});return M("addresses"),t.deleted}async function Z(){return(await T("subscriptions")).subscriptions}async function J(e,t){let s=await T("subscription",{id:e,action:t});return M("subscriptions"),s}async function ee(e,t){let s=await T("requestReturn",{orderId:e,lines:t});return M("orders"),s.return}function Ce(e){let t=m(e,"order")||"";return t.startsWith("url:")?new URL(window.location.href).searchParams.get(t.slice(4)||"id"):t}function F(e,t){e.setAttribute(y("order-state"),t),f(e,"order-show",{loading:t==="loading",ready:!1,"not-found":t==="not-found",error:t==="error"})}var Se=e=>({name:e.name,date:C(e.processedAt),total:g(e.totalPrice),subtotal:g(e.subtotal),shipping:g(e.totalShipping),tax:g(e.totalTax),status:E(e.financialStatus),fulfillment:E(e.fulfillmentStatus),"shipping-address":N(e.shippingAddress),"billing-address":N(e.billingAddress),items:e.lineItems.nodes.map(t=>`${t.quantity}\xD7 ${t.title||t.name}`).join(", "),cancelled:e.cancelledAt?C(e.cancelledAt):""});function $e(e,t){let s=t.trackingInformation[0],r={status:E(t.latestShipmentStatus||t.status),date:C(t.createdAt),eta:t.estimatedDeliveryAt?C(t.estimatedDeliveryAt):"",company:s?.company||"",number:s?.number||""};O(e,"fulfillment-bind").forEach(n=>{let o=m(n,"fulfillment-bind")??"";if(o==="url"){let d=s?.url,c=z(d);c&&d&&n.setAttribute("href",d),ne(n,c);return}let i=w(r,o);i!==void 0&&h(n,i)})}function De(e,t){let s=new Map((t.returnInformation?.returnableLineItems.nodes??[]).map(i=>[i.lineItem?.id??"",i.quantity])),r=t.fulfillments.nodes,n=Se(t);l(e,a("order-bind")).forEach(i=>{let d=m(i,"order-bind")??"";if(d==="url"){t.statusPageUrl&&z(t.statusPageUrl)&&i.setAttribute("href",t.statusPageUrl);return}let c=w(n,d);c!==void 0&&h(i,c)}),l(e,a("order-lines")).forEach(i=>{oe(i,t.lineItems.nodes,s)}),l(e,a("order-fulfillments")).forEach(i=>{x(i,r,$e)});let o=e.dataset.tetherReturned==="1";f(e,"order-show",{loading:!1,ready:!0,error:!1,"not-found":!1,cancelled:!!t.cancelledAt,shipped:r.length>0,returnable:[...s.values()].some(i=>i>0),"has-returns":!o&&t.returns.nodes.length>0,"return-requested":o}),e.setAttribute(y("order-state"),"ready")}async function j(e){let t=Ce(e);if(!t){e.setAttribute(y("order-state"),"not-found"),f(e,"order-show",{"not-found":!0});return}F(e,"loading");let s;try{s=await K(t)}catch(r){I(r,"order"),F(e,"error");return}if(!s){F(e,"not-found");return}e.dataset.tetherOrderId=s.id,De(e,s)}var de=[],ue=e=>de.find(t=>t.id===e),Oe=e=>({formatted:N(e),name:[e.firstName,e.lastName].filter(Boolean).join(" "),company:e.company||"",address1:e.address1||"",address2:e.address2||"",city:e.city||"",zip:e.zip||"",province:e.province||"",country:e.country||"",phone:e.phoneNumber||""});function ve(e,t){e.dataset.tetherAddress=t.id;let s=Oe(t);O(e,"address-bind").forEach(r=>{let n=w(s,m(r,"address-bind")??"");n!==void 0&&h(r,n)}),f(e,"address-show",{default:t.isDefault,"not-default":!t.isDefault})}async function R(e){let t=l(e,a("addresses"));if(!t.length)return;f(e,"show",{"addresses-loading":!0,"addresses-empty":!1});let s;try{s=await W()}catch(r){I(r,"addresses"),f(e,"show",{"addresses-loading":!1,"addresses-error":!0});return}de=s,f(e,"show",{"addresses-loading":!1,"addresses-empty":s.length===0,"addresses-error":!1}),t.forEach(r=>{x(r,s,ve)})}function Re(e){let t=e.upcomingBillingCycles.nodes[0],s=e.status,r=s==="ACTIVE";return{active:r,paused:s==="PAUSED",cancelled:s==="CANCELLED",expired:s==="EXPIRED",failed:s==="FAILED",skipped:!!t?.skipped,"can-pause":r,"can-resume":s==="PAUSED"||s==="FAILED","can-skip":r&&t!==void 0&&!t.skipped,"can-unskip":r&&!!t?.skipped,"can-cancel":r||s==="PAUSED"||s==="FAILED"}}function qe(e){let t=E(e.deliveryPolicy?.interval);if(!t)return"";let s=e.deliveryPolicy?.intervalCount?.count??1;return s<=1?t:`${s} ${t}s`}function Pe(e){let t=e.lines.nodes,s=t.reduce((r,n)=>r+Number.parseFloat(n.lineDiscountedPrice?.amount??"0"),0);return{status:E(e.status),next:e.nextBillingDate?C(e.nextBillingDate):"",interval:qe(e),products:t.map(r=>`${r.quantity}\xD7 ${r.title}`).join(", "),total:t.length?g({amount:String(s),currencyCode:e.currencyCode}):"",delivery:g(e.deliveryPrice)}}function ke(e,t){let s={title:t.title,"variant-title":t.variantTitle||"",quantity:String(t.quantity),price:g(t.currentPrice)};O(e,"subscription-line").forEach(r=>{let n=m(r,"subscription-line")??"";if(n==="image"){t.image&&re(r,t.image.url,t.image.altText||t.title);return}let o=w(s,n);o!==void 0&&h(r,o)})}function Ne(e,t){e.dataset.tetherSubscription=t.id,e.setAttribute(y("subscription-status"),E(t.status));let s=Pe(t);l(e,a("subscription-bind")).forEach(n=>{let o=w(s,m(n,"subscription-bind")??"");o!==void 0&&h(n,o)}),l(e,a("subscription-lines")).forEach(n=>{x(n,t.lines.nodes,ke)});let r=Re(t);f(e,"subscription-show",r),l(e,a("subscription-action")).forEach(n=>{let o=w(r,`can-${m(n,"subscription-action")??""}`)===!0;"disabled"in n&&(n.disabled=!o),n.classList.toggle("is-disabled",!o)})}async function G(e){let t=l(e,a("subscriptions"));if(!t.length)return;f(e,"show",{"subscriptions-loading":!0,"subscriptions-empty":!1});let s;try{s=await Z()}catch(r){I(r,"subscriptions"),f(e,"show",{"subscriptions-loading":!1,"subscriptions-error":!0});return}f(e,"show",{"subscriptions-loading":!1,"subscriptions-empty":s.length===0,"subscriptions-error":!1}),t.forEach(r=>{x(r,s,Ne)})}var Le=["pause","resume","skip","unskip","cancel"],Ue=e=>Le.some(t=>t===e),le=e=>e.tagName==="INPUT",fe=e=>e.tagName==="FORM";function ce(e){let t={};for(let s of e.elements){if(!le(s)&&s.tagName!=="SELECT"&&s.tagName!=="TEXTAREA")continue;let r=s;!r.name||r.type==="submit"||r.type==="button"||r.type==="checkbox"||(t[r.name]=r.value)}return t}function Be(e){let s=(e instanceof D?e.userErrors??[]:[]).map(n=>n.message).join(" ");return s||(e instanceof Error&&e.message?e.message:"Something went wrong").replace(/^Customer accounts: /,"")}async function q(e,t){if(e.getAttribute("aria-busy")==="true")return"busy";e.classList.add("is-busy"),e.setAttribute("aria-busy","true"),e.setAttribute(y("form-state"),"pending");let s=l(e,a("form-error"));s.forEach(r=>{h(r,"")});try{return await t(),e.setAttribute(y("form-state"),"saved"),"saved"}catch(r){return e.setAttribute(y("form-state"),"error"),s.forEach(n=>{h(n,Be(r))}),"error"}finally{e.classList.remove("is-busy"),e.removeAttribute("aria-busy")}}var te=e=>{let t=m(e,"confirm");return!t||window.confirm(t)},pe=e=>{e.reset(),delete e.dataset.tetherAddressId};function Me(e){let t=e.target;if(t instanceof window.HTMLFormElement){if(t.matches(a("profile-form")))e.preventDefault(),q(t,async()=>{await Q(ce(t)),await v().bindCustomer(document)});else if(t.matches(a("address-form"))){e.preventDefault();let s=t.dataset.tetherAddressId,r=t.elements.namedItem("isDefault"),n=r instanceof window.HTMLInputElement&&r.checked;q(t,async()=>{await H(ce(t),{id:s,isDefault:n}),pe(t),await R(document)})}}}function Fe(e){let t=ue(e),s=document.querySelector(a("address-form"));if(!(!t||!s||!fe(s))){s.dataset.tetherAddressId=t.id;for(let r of s.elements){if(!le(r)&&r.tagName!=="SELECT"&&r.tagName!=="TEXTAREA")continue;let n=r;if(n.name==="isDefault")n.checked=t.isDefault;else if(n.name&&Object.hasOwn(t,n.name)){let o=Object.entries(t).find(([i])=>i===n.name)?.[1];n.value=typeof o=="string"?o:""}}s.scrollIntoView({block:"nearest"})}}function _e(e,t){let s=t.closest("[data-tether-address]"),r=s instanceof window.HTMLElement?s.dataset.tetherAddress:void 0;if(t.closest(a("address-new"))){let o=document.querySelector(a("address-form"));return o&&fe(o)&&pe(o),!0}if(!(s instanceof window.HTMLElement)||!r)return!1;let n=t.closest(a("address-delete"));if(n){if(e.preventDefault(),!te(n))return!0;q(s,async()=>{await Y(r),await R(document)})}else if(t.closest(a("address-default")))e.preventDefault(),q(s,async()=>{await H(null,{id:r,isDefault:!0}),await R(document)});else if(t.closest(a("address-edit")))e.preventDefault(),Fe(r);else return!1;return!0}function He(e){let t=e.closest("[data-tether-subscription]"),s=m(e,"subscription-action"),r="disabled"in e&&e.disabled===!0||e.classList.contains("is-disabled");if(!(t instanceof window.HTMLElement)||!Ue(s)||r||!te(e))return;let n=t.dataset.tetherSubscription??"";t.setAttribute(y("subscription-state"),"pending"),q(t,async()=>{await J(n,s),await G(document)}).then(o=>{let i=o==="error"?"error":"done";l(document,"[data-tether-subscription]").filter(d=>d===t||d.dataset.tetherSubscription===n).forEach(d=>{d.setAttribute(y("subscription-state"),i)})})}function je(e){let t=e.querySelector(a("return-quantity")),s=e.querySelector(a("return-reason")),r=e.querySelector(a("return-note")),n=c=>c&&"value"in c&&typeof c.value=="string"?c.value:"",o={lineItemId:e.dataset.tetherLine??"",quantity:Number.parseInt(n(t)||"0",10)},i=n(s);i&&(o.reasonId=i);let d=n(r);return d&&(o.note=d),o}function Ge(e){let t=e.closest(a("order"));if(!(t instanceof window.HTMLElement))return;let s=t.dataset.tetherOrderId;if(!s)return;let r=l(t,"[data-tether-line]").map(je).filter(n=>n.quantity>0);!r.length||!te(e)||q(t,async()=>{await ee(s,r),t.dataset.tetherReturned="1",await j(t)})}function ze(e){let t=e.target;if(!(t instanceof window.Element)||_e(e,t))return;let s=t.closest(a("subscription-action"));if(s instanceof window.HTMLElement){e.preventDefault(),He(s);return}let r=t.closest(a("order-return"));r instanceof window.HTMLElement&&(e.preventDefault(),Ge(r))}function me(){document.addEventListener("submit",Me,!0),document.addEventListener("input",e=>{let t=e.target;t instanceof window.HTMLElement&&t.closest(a("profile-form"))&&(t.dataset.tetherTouched="1")}),document.addEventListener("click",ze)}var Ve=["firstName","lastName"];async function Xe(e){let t=await v().customer().catch(r=>(I(r,"account"),null));if(!t||e.tagName!=="FORM")return;let s=e.elements;Ve.forEach(r=>{let n=s.namedItem(r);(n instanceof window.HTMLInputElement||n instanceof window.HTMLTextAreaElement)&&!n.dataset.tetherTouched&&(n.value=t[r]??"")})}var ye=!1;async function qt(e=document){ye||(ye=!0,me()),await Promise.all([...l(e,a("order")).map(t=>j(t)),...l(e,a("profile-form")).map(t=>Xe(t)),R(e),G(e)])}function Pt(e){l(e,a("order")).forEach(t=>{F(t,"error")}),f(e,"show",{"addresses-loading":!1,"addresses-error":!0,"subscriptions-loading":!1,"subscriptions-error":!0})}export{W as addresses,Y as deleteAddress,K as order,qt as renderPages,ee as requestReturn,H as saveAddress,Te as setup,Pt as showUnavailable,J as subscriptionAction,Z as subscriptions,Q as updateProfile};
@@ -0,0 +1 @@
1
+ import{b as g}from"./chunk-MPTQYLSM.js";import"./chunk-NEHZ37TU.js";import"./chunk-JOOEXYF3.js";import{b as c,g as w,i as l,p as k,s as f}from"./chunk-YJLWX2HK.js";import"./chunk-FOMSMIAM.js";var F=500,T={"default-banner":"https://cdn.shopify.com/shopifycloud/privacy-banner/storefront-banner.js",other:"https://cdn.shopify.com/shopifycloud/consent-tracking-api/v0.2/consent-tracking-api.js"},N="https://cdn.shopify.com/storefront/analytics/shopify.js";function y(){return Reflect.get(window,"Shopify")}function S(){let t=c.analytics?.shopify;return typeof t=="object"?t:{}}function x(){try{let t=y()?.customerPrivacy;return t?.consentStatus==="loaded"&&t.currentVisitorConsent?.()?.analytics!=="no"&&!!t.analyticsProcessingAllowed?.()}catch{return!1}}function V(t){let e=`hydrogen:${t}`;return{getTrackingValues:()=>{let n=x()?y()?.customerPrivacy?.__internal:void 0;return{uniqueToken:n?.uniqueToken?.({generateFallback:!0,tag:e})??"",visitToken:n?.visitToken?.({generateFallback:!0,tag:e})??""}}}}var D=t=>(e,n)=>{let o=t.subscribers.get(e)??new Set;return t.subscribers.set(e,o),o.add(n),()=>t.subscribers.get(e)?.delete(n)};function M(t){let e=[],n=[],o={shop:{shopId:t,channel:"headless"},consent:{mode:S().consent||"no-banner"}},r=()=>{if(x())for(let i of e)for(;i.next<n.length;i.next+=1){let s=n[i.next];s&&O(i,s)}},a={getConfig:()=>o,publish(i,s={}){if(n.push({event:i,payload:{shop:o.shop,url:window.location.href,...s}}),n.length>F){n.shift();for(let d of e)d.next=Math.max(0,d.next-1)}r()},addDestination(i){let s={name:i.name,next:0,subscribers:new Map,context:V(i.name)};return Promise.resolve(i.setup?.({subscribe:D(s),getConfig:a.getConfig})).then(()=>{e.push(s),r()}).catch(d=>{l(d,`analytics ${i.name}`)}),()=>{let d=e.indexOf(s);d>=0&&e.splice(d,1)}}};return document.addEventListener("consentTrackingApiLoaded",r),document.addEventListener("visitorConsentCollected",r),a}function O(t,{event:e,payload:n}){t.subscribers.get(e)?.forEach(o=>{try{o(n,t.context)}catch(r){l(r,`analytics ${t.name}`)}})}function C(t){let e=document.createElement("script");e.src=t,e.async=!0,document.head.appendChild(e)}async function E(t){let e=y();if(e?.analytics)return e.analytics;let n=await k("query TetherShopId { shop { id } }",{},{context:!1}),o=y()??{};Reflect.set(window,"Shopify",o),o.country=(c.country||"US").toUpperCase(),o.locale=(c.locale||"en").split("-")[0]?.toLowerCase()??"en",o.shop=c.domain,o.routes={root:"/",match:()=>({pageTemplateName:t()?"product":"page"}),...o.routes};let{proxy:r,consent:a}=S();o.customerPrivacy={...o.customerPrivacy,config:r?{isHeadless:!0,asyncConsent:!0,asyncVisitorState:!0,consentDomain:window.location.host}:{isHeadless:!0,storefrontAccessToken:c.token,checkoutRootDomain:c.domain}};let i=M(n.shop.id);return o.analytics=i,C(a==="default-banner"?T["default-banner"]:T.other),C(N),w("shopify analytics ready",n.shop.id),i}var U="Default Title",A=100,$=200,j=t=>t?parseFloat(t.amount):0,L=t=>(t??"").split("/").pop()??"";function v(t,e,n=1,o){let r={item_id:e?.sku||L(e?.id)||L(t.id),item_name:t.title,item_variant:e?.title===U?void 0:e?.title,item_brand:t.vendor||void 0,item_category:t.productType||void 0,price:j(e?.price??t.priceRange?.minVariantPrice),quantity:n};return o!=null&&(r.index=o),r}var m=(t,e=t.quantity)=>v(t.merchandise.product,t.merchandise,e);function p(t){let e=t.reduce((n,o)=>n+o.price*(o.quantity||1),0);return Math.round(e*A)/A}var B=(t,e,n=1)=>({id:t.id,title:t.title,price:e.price,vendor:t.vendor||"",variantId:e.id,variantTitle:e.title,quantity:n,sku:e.sku||void 0,productType:t.productType||void 0}),P=t=>({id:t.id,quantity:t.quantity,merchandise:{id:t.merchandise.id,title:t.merchandise.title,price:t.merchandise.price,sku:t.merchandise.sku,product:{id:t.merchandise.product.id,title:t.merchandise.product.title,vendor:t.merchandise.product.vendor||"",handle:t.merchandise.product.handle}}});function H(){let{dataLayer:t}=c.analytics??{},e=typeof t=="string"?t:"dataLayer",n=Reflect.get(window,e);if(Array.isArray(n))return n;let o=[];return Reflect.set(window,e,o),o}function W(t,e){let n=H();if(!e){n.push({event:t});return}n.push({ecommerce:null}),n.push({event:t,ecommerce:e})}var h=null,b=null,I=null,_=new WeakSet;function u(t,e,n,o){c.analytics?.dataLayer&&W(t,e),h&&n&&h.publish(n,o);try{c.analytics?.onEvent?.(t,e)}catch(r){l(r,"analytics onEvent")}}function q(){let t=document.querySelector(f("product"));return!t||t.closest(`${f("collection")},${f("products")},${f("recommendations")}`)?null:Reflect.get(window,"Tether").getScope(t)}function G({product:t,scope:e}){if(!e||_.has(e.root)||q()!==e)return;_.add(e.root);let n=e.variant??t.variants.nodes[0],o=[v(t,n)],r=n?[B(t,n)]:[];u("view_item",{currency:n?.price.currencyCode,value:p(o),items:o},"product_viewed",{products:r})}function X({products:t=[],collection:e}){let n=t.slice(0,$).map((r,a)=>v(r,r.variants.nodes[0],1,a)),o={item_list_id:e?.handle||"products",item_list_name:e?.title||"Products"};if(!e){u("view_item_list",{...o,items:n});return}u("view_item_list",{...o,items:n},"collection_viewed",{collection:{id:e.id,handle:e.handle}})}function Y(t,e,n){let o=t?.cost.totalAmount.currencyCode;e.forEach((r,a)=>{let i=n.get(a),s=r.quantity-(i?.quantity??0);if(s<=0)return;let d=[m(r,s)];u("add_to_cart",{currency:o,value:p(d),items:d},"product_added_to_cart",{cart:t,prevCart:I,currentLine:P(r),prevLine:i?P(i):void 0})}),n.forEach((r,a)=>{let i=r.quantity-(e.get(a)?.quantity??0);if(i<=0)return;let s=[m(r,i)];u("remove_from_cart",{currency:o,value:p(s),items:s})})}function Z({cart:t,reason:e}){let n=new Map((t?.lines.nodes??[]).map(o=>[o.merchandise.id,o]));b&&e!=="load"&&e!=="pending"&&Y(t,n,b),b=n,I=t}function z(){let t=g.lines.map(e=>m(e));u("view_cart",{currency:g.state?.cost.totalAmount.currencyCode,value:p(t),items:t})}function J({cart:t}){let e=t.lines.nodes.map(o=>m(o)),n=t.discountCodes.filter(o=>o.applicable).map(o=>o.code);u("begin_checkout",{currency:t.cost.totalAmount.currencyCode,value:p(e),coupon:n.join(",")||void 0,items:e})}function R(t){let e=t.type.slice(c.prefix.length+1),n=Reflect.get(t,"detail");switch(e){case"product-ready":G(n);break;case"list-ready":X(n);break;case"cart-updated":Z(n);break;case"cart-toggled":n.open&&z();break;case"checkout":J(n);break;case"search":{let{term:o}=n;o&&u("search",{search_term:o},"search_viewed",{searchTerm:o});break}case"page":_=new WeakSet,h?.publish("page_viewed",{});break;default:break}}async function it(t){c.analytics?.shopify&&(h=await E(()=>q()!=null).catch(e=>(l(e,"shopify analytics"),null))),h?.publish("page_viewed",{}),t.splice(0).forEach(R),t.push=(...e)=>(e.forEach(R),t.length)}export{it as startAnalytics};
@@ -0,0 +1 @@
1
+ import{b as u,j as s,k as f,p as y}from"./chunk-YJLWX2HK.js";var p=["saved","server","webflow"],b="tether_country",w=()=>`${u.prefix}:market:${u.domain}`;function h(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function C(){let e=typeof window<"u";return{document:typeof document<"u"?document:null,location:e?window.location:null,storage:h(),global:e?window:{}}}function L(e){try{return JSON.parse(e)}catch(t){if(t instanceof SyntaxError)return null;throw t}}function S(e){if(typeof e!="object"||e===null)return null;let t=s(Reflect.get(e,"country"));if(!t)return null;let n=Reflect.get(e,"locale");return{country:t,language:f(Reflect.get(e,"language"))??void 0,locale:typeof n=="string"&&n?n:void 0}}function E(e=h()){let t=e?.getItem(w());return t?S(L(t)):null}function R(e,t){if(!e||!t)return null;let n=e.cookie.split(";").map(r=>r.trim()).find(r=>r.startsWith(`${t}=`));return n?decodeURIComponent(n.slice(t.length+1)):null}function g(e,t){if(!e||!t)return null;let n=t.toLowerCase(),r=Object.keys(e).find(o=>o.toLowerCase()===n);return r?e[r]??null:null}function A(e,t){let n=r=>t.document?.querySelector(`meta[name="${r}"]`)?.getAttribute("content");return{country:Reflect.get(t.global,"TETHER_COUNTRY")||n("tether-country")||R(t.document,e.cookie||b),language:Reflect.get(t.global,"TETHER_LANGUAGE")||n("tether-language")}}function O(e,t){let n=(t.location?.pathname??"/").split("/").find(i=>i!==""),r=g(e.locales,n);if(r)return r;let o=t.document?.documentElement.getAttribute("lang");if(!o)return null;let c=g(e.locales,o)??g(e.locales,o.split("-")[0]);if(c)return{locale:o,...c};if(e.locales&&e.strict)return null;let l=o.split("-")[1];return{language:o,country:l?.length===2?l:null,locale:o}}function x(e,t,n){switch(e){case"saved":return t.remember===!1?null:E(n.storage);case"server":return A(t,n);case"webflow":return O(t,n)}}var I=e=>p.some(t=>t===e);function T(e){return e?e===!0?p:[e].flat().filter(I):["saved"]}function M(e=u.markets,t=C()){let n=e??{};if(n.detect===!1)return{};let r={},o={sources:r};for(let c of T(n.detect)){let l=x(c,n,t);if(!l)continue;let i=s(l.country),d=f(l.language),m=typeof l.locale=="string"&&l.locale?l.locale:null;i&&!o.country&&(o.country=i,r.country=c),d&&!o.language&&(o.language=d,r.language=c),m&&!o.locale&&(o.locale=m,r.locale=c)}return o}function z(e,t){try{localStorage.setItem(e,t)}catch{return}}function $(e){if(u.markets?.remember===!1)return;let t={country:e.country,language:e.language||void 0,locale:e.locale||void 0};z(w(),JSON.stringify(t))}var a=null;function q(){a=null}var N="query TetherLocalization{localization{country{isoCode name currency{isoCode symbol}}language{isoCode name}availableCountries{isoCode name currency{isoCode symbol}availableLanguages{isoCode name}}}}";function H(){return a||(a=y(N).then(t=>t.localization,t=>{throw a=null,t})),a}export{E as a,M as b,$ as c,q as d,H as e};
@@ -0,0 +1 @@
1
+ import{a as S,b as J,c as C,d as K,e as z,f as Z,g as tt}from"./chunk-HEQILZVR.js";import{b as $,e as et}from"./chunk-FCSWQDVV.js";import{b as Y}from"./chunk-MPTQYLSM.js";import{d as W,e as k,f as P,k as X}from"./chunk-JOOEXYF3.js";import{A as m,B as D,C as E,E as B,F as U,G as y,H as F,I as R,J as d,L as T,M as A,N as L,O as G,P as j,Q as H,R as Q,b as w,i as q,r as p,s as o,t as l,u as I,v as f,w as M,x as g,z as _}from"./chunk-YJLWX2HK.js";var dt=/^image:(\d+)$/,it="metafield:",ht=/^(rich_text|multi_line_text)_field$/,pt=["","true","all","*"],V=e=>e.tagName==="SELECT",b=(e,t)=>e.$(`select${t}`).filter(V);function ft(e,t){let i=t.images.nodes,n=[...e.children].map(s=>s.tagName==="IMG"?s:s.querySelector("img"));!D(e)&&n.length===i.length&&n.every((s,r)=>_(s?.getAttribute("src"),i[r]?.url))||E(e,i,(s,r)=>{let c=s.matches(`img,${o("bind","image")}`)?s:f(s,"img")[0]??s;m(c,r.url,r.altText||t.title)})}function mt(e,t,i){let n=i.indexOf("."),a=i.slice(0,n),s=i.slice(n+1),r=(t.metafields??[]).find(u=>u?.namespace===a&&u.key===s);if(!r){d(e,"");return}let c=r.reference?.image;if(c){m(e,c.url,c.altText);return}ht.test(r.type)&&(e.style.whiteSpace="pre-line"),d(e,r.value)}var gt=new Map(Object.entries({title:e=>e.title,"description-text":e=>e.description,vendor:e=>e.vendor,type:e=>e.productType,handle:e=>e.handle,"published-at":e=>F(e.publishedAt),"min-price":e=>y(e.priceRange.minVariantPrice),"max-price":e=>y(e.priceRange.maxVariantPrice)}));function bt(e,t){let i=(e.getAttribute("exclude")??"").split(",").map(a=>a.trim()).filter(Boolean),n=t.tags.filter(a=>!i.includes(a));E(e,n,(a,s)=>{d(a,s)})}function vt(e,t,i){let n=gt.get(t);if(n){d(e,n(i));return}switch(t){case"description":R(e,i.descriptionHtml);break;case"featured-image":m(e,i.featuredImage?.url,i.featuredImage?.altText||i.title);break;case"url":case"link":e.setAttribute("href",B(i.handle,i.id)),t==="url"&&!e.firstElementChild&&!e.textContent.trim()&&d(e,i.title);break;case"images":ft(e,i);break;case"tags":bt(e,i);break;default:xt(e,t,i)}}function xt(e,t,i){let n=dt.exec(t);if(n){let a=i.images.nodes[Number(n[1])-1]??i.featuredImage;m(e,a?.url,a?.altText||i.title)}else t.startsWith(it)&&mt(e,i,t.slice(it.length))}function It(e){let{product:t}=e;e.$(o("option-list")).forEach(i=>{let n=e.optName(l(i,"option-list")),a=t.options.find(s=>s.name===n);if(!a||a.optionValues.length<=1&&I(i,"hide-single")){T(i,!1);return}E(i,a.optionValues,(s,r)=>{s.setAttribute(p("option-value"),r.name);let c=f(s,o("bind","option-value"))[0];c?d(c,r.name):s.firstElementChild||d(s,r.name);let u=f(s,o("bind","swatch"))[0],h=r.swatch;!u||!h||(h.color&&(u.style.backgroundColor=h.color),h.image?.previewImage&&m(u,h.image.previewImage.url,r.name))})})}function Et(e){let{product:t}=e;b(e,o("option")).forEach(i=>{let n=t.options.find(a=>a.name===e.optName(l(i,"option")));if(!n){T(i,!1);return}i.replaceChildren(...n.optionValues.map(a=>new Option(a.name,a.name)))}),b(e,o("variant-select")).forEach(i=>{i.replaceChildren(...t.variants.nodes.map(n=>new Option(n.title,n.id)))}),b(e,o("plan")).forEach(i=>{let n=e.plans.map(r=>new Option(r.name,r.id)),a=!t.requiresSellingPlan&&l(i,"plan")!=="subscription-only",s=i.getAttribute(p("one-time-label"))||"One-time purchase";i.replaceChildren(...a?[new Option(s,"")]:[],...n)})}function yt(e){e.$(o("plan-list")).forEach(t=>{let i=(l(t,"plan-list")??"").trim(),n=pt.includes(i.toLowerCase())?null:i,a=e.plans.filter(s=>!n||s.group.name===n);E(t,a,(s,r)=>{s.setAttribute(p("plan-value"),r.id),!s.firstElementChild&&!s.querySelector(o("plan-bind"))&&d(s,r.name)})})}function nt(e){e.$(o("bind")).forEach(t=>{vt(t,l(t,"bind")??"",e.product)}),It(e),Et(e),yt(e)}var at={money:y,percent:U},Tt=e=>e.tagName==="INPUT";function O(e){let t=f(e,o("add-label"))[0]??e,i=t.dataset.tetherLabel??(Tt(t)?t.value:t.textContent);return t.dataset.tetherLabel=i,{label:t,original:i}}function Pt(e,t){let{product:i}=e,n=a=>t.selected[e.optName(a)]??"";e.$(o("option-selected")).forEach(a=>{d(a,n(l(a,"option-selected")))}),e.$(o("option-list")).forEach(a=>{let s=e.optName(l(a,"option-list"));f(a,o("option-value")).forEach(r=>{let c=l(r,"option-value")??"";A(r,t.selected[s]===c);let u=!J(i,t.selected,s,c);r.classList.toggle("is-unavailable",u),r.setAttribute("data-unavailable",u?"true":"false")})}),b(e,o("option")).forEach(a=>{a.value=n(l(a,"option"))}),b(e,o("variant-select")).forEach(a=>{a.value=t.variant.id})}function At(e,t){let{variant:i,purchase:n,isSubscription:a}=t;e.$(o("purchase")).forEach(s=>{if(V(s)){s.value=n.kind;return}let r=l(s,"purchase");A(s,r===n.kind);let c=r==="subscription"?!t.subscriptionAvailable:e.product.requiresSellingPlan;s.classList.toggle("is-unavailable",c)}),e.$(o("plan-value")).forEach(s=>{let r=l(s,"plan-value")??"";A(s,a&&r===n.planId),s.classList.toggle("is-unavailable",!P(i,r));let c=e.plans.find(h=>h.id===r),u=tt(i,r,c,at);f(s,o("plan-bind")).forEach(h=>{let v=u.get(l(h,"plan-bind")??"");v&&d(h,v())})}),b(e,o("plan")).forEach(s=>{s.value=a?n.planId??"":""})}function St(e,t){let i=new Map(Object.entries(t.show));$.forEach(n=>i.set(n,n==="ready")),e.$(o("show")).forEach(n=>{let a=l(n,"show")??"",s=i.get(a);s!==void 0&&($.some(r=>r===a)&&!et(n,e.root)||T(n,s))})}function Ct(e,t){let i=!t.variant.availableForSale;e.$(o("add-to-cart")).forEach(n=>{n.classList.toggle("is-disabled",i),n.setAttribute("aria-disabled",String(i)),"disabled"in n&&(n.disabled=i);let a=l(n,"soldout-text"),s=l(n,"subscribe-text");if(!a&&!s)return;let{label:r,original:c}=O(n),u=c;t.isSubscription&&s&&(u=s),i&&a&&(u=a),n.getAttribute("aria-busy")!=="true"&&d(r,u)})}function st(e,t){let{variant:i}=t,{product:n}=e,a=Z(t,at);e.$(o("bind")).forEach(s=>{let r=l(s,"bind")??"";if(r==="variant-image"){m(s,i.image?.url||n.featuredImage?.url,i.image?.altText||n.title);return}let c=a.get(r);c&&d(s,c())}),Pt(e,t),At(e,t),St(e,t),e.root.classList.toggle("is-subscription",t.isSubscription),e.root.setAttribute(p("purchase-mode"),t.isSubscription?"subscription":"one-time"),Ct(e,t)}var ot=()=>o("product"),Nt=e=>e.tagName==="INPUT"||e.tagName==="SELECT"||e.tagName==="TEXTAREA",rt=e=>e instanceof window.Element;function x(e,t,i){let n=t.closest(i);return n?.closest(ot())===e.root?n:null}function wt(e,t){let{label:i,original:n}=O(t),a=l(t,"adding-text");j(t,async()=>{a&&d(i,a);try{await e.addToCart()}catch(s){q(s,"add to cart failed"),g("error",{error:s,context:"add-to-cart"},e.root)}finally{a&&d(i,n)}}).then(()=>{e.renderVariant()})}function Lt(e,t,i){let n=x(e,i,o("option-value")),a=n?.closest(o("option-list"));if(n&&a){t.preventDefault(),e.select(e.optName(l(a,"option-list")),l(n,"option-value")??"");return}let s=x(e,i,o("plan-value"));if(s){t.preventDefault(),e.selectPlan(l(s,"plan-value"));return}let r=x(e,i,`${o("purchase")}:not(select)`);if(r){r.tagName!=="INPUT"&&t.preventDefault(),e.setPurchase(l(r,"purchase"));return}let c=x(e,i,o("qty-plus")),u=c?null:x(e,i,o("qty-minus"));if(c||u){t.preventDefault(),e.setQuantity(e.quantity+(c?1:-1));return}let h=x(e,i,o("add-to-cart"));h&&(t.preventDefault(),wt(e,h))}function kt(e,t){let i=Nt(t)?t.value:"";t.matches(`select${o("option")}`)?e.select(e.optName(l(t,"option")),i):t.matches(`select${o("variant-select")}`)?e.selectVariant(i):t.matches(`select${o("plan")}`)?i?e.selectPlan(i):e.setPurchase("one-time"):t.matches(`select${o("purchase")}`)?e.setPurchase(i):t.matches(o("qty"))&&e.setQuantity(i)}function lt(e){e.root.addEventListener("click",t=>{rt(t.target)&&Lt(e,t,t.target)}),e.root.addEventListener("change",t=>{let{target:i}=t;rt(i)&&i.closest(ot())===e.root&&kt(e,i)})}var $t=new WeakMap,Vt=()=>o("product"),N=new Map;function Ot(e){e.forEach(t=>{N.has(t.handle)||N.set(t.handle,t.options.map(i=>i.name))})}var ct=e=>e.tagName==="INPUT",qt=e=>e.tagName==="INPUT"||e.tagName==="SELECT"||e.tagName==="TEXTAREA";function Mt(e){return ct(e)&&e.type==="checkbox"?e.checked?e.value&&e.value!=="on"?e.value:"Yes":null:ct(e)&&e.type==="radio"?e.checked?e.value:null:qt(e)&&e.value||null}var ut=class{constructor(t,i){this.root=t,this.product=i,this.plans=k(i);let n=new URLSearchParams(window.location.search),a=K(i,{variant:n.get("variant")||l(t,"variant"),sellingPlan:n.get("selling_plan"),defaultPlan:l(t,"default-plan"),defaultPurchase:l(t,"default-purchase")||w.defaultPurchase});this.selected=a.selected,this.purchaseChoice=a.purchase,this.variant=null,this.quantity=I(t,"quantity")?Math.max(0,parseInt(l(t,"quantity")??"",10)||0):1,$t.set(t,this),t.setAttribute(p("state"),"ready"),t.removeAttribute(p("error")),this.renderProduct(),lt(this),this.renderVariant(),G(t,"product"),L("product"),g("product-ready",{product:i,scope:this},t)}update(t){let i=this.variant?.id;this.product=t,this.plans=k(t);let n=t.variants.nodes.find(a=>a.id===i);n&&(this.selected=S(n)),this.root.setAttribute(p("state"),"ready"),this.root.removeAttribute(p("error")),this.renderProduct(),this.renderVariant(),L("product"),g("product-updated",{product:t,scope:this},this.root)}$(t){let i=M(this.root,t,Vt());return this.root.matches(t)?[this.root,...i]:i}optName(t){if(!t)return"";let{options:i}=this.product;if(i.some(a=>a.name===t))return t;let n=(N.get(this.product.handle)??[]).indexOf(t);return i[n]?.name??t}get purchase(){return this.purchaseChoice.kind}set purchase(t){let i=t==="subscription"?"subscription":"one-time";this.purchaseChoice=C(this.product,this.variant,{kind:i,planId:this.planId})}get planId(){return this.purchaseChoice.planId}set planId(t){this.purchaseChoice=C(this.product,this.variant,{kind:this.purchase,planId:t})}get plan(){return this.plans.find(t=>t.id===this.planId)??null}get subscriptionAvailable(){return this.plans.some(t=>P(this.variant,t.id))}get isSubscription(){return this.purchase==="subscription"&&P(this.variant,this.planId)!==null}getLine(){if(!this.variant)return null;let t={merchandiseId:this.variant.id,quantity:this.quantity};this.isSubscription&&this.planId&&(t.sellingPlanId=this.planId);let i=this.collectAttributes();return i.length&&(t.attributes=i),t}collectAttributes(){let t=H(this.root,"line-attributes"),i=Q(t),n=this.$(o("line-attribute")).flatMap(a=>{let s=Mt(a);return s===null?[]:[{key:l(a,"line-attribute")??"",value:s}]});return[...i,...n]}select(t,i){if(this.selected[t]===i)return;let n=this.product.variants.nodes.filter(r=>r.selectedOptions.some(c=>c.name===t&&c.value===i)),[a]=n;if(!a)return;let s={...this.selected,[t]:i};if(!n.some(r=>r.selectedOptions.every(c=>s[c.name]===c.value))){let r=u=>u.selectedOptions.filter(v=>v.name!==t&&this.selected[v.name]===v.value).length*2+(u.availableForSale?1:0),c=n.reduce((u,h)=>r(h)>r(u)?h:u,a);Object.assign(s,S(c))}this.selected=s,this.renderVariant()}selectVariant(t){let i=this.product.variants.nodes.find(n=>n.id===W.variant(t));i&&(this.selected=S(i),this.renderVariant())}setPurchase(t){let i=t==="subscription"?"subscription":"one-time",n=C(this.product,this.variant,{kind:i,planId:this.planId});n.kind!==this.purchase&&(this.purchaseChoice=n,this.renderVariant())}selectPlan(t){let i=X(this.product,t);i&&(this.purchaseChoice={kind:"subscription",planId:i.id},this.renderVariant())}setQuantity(t){let i=I(this.root,"quantity")?0:1;this.quantity=Math.max(i,parseInt(String(t),10)||0),this.$(o("qty")).forEach(n=>{d(n,this.quantity)}),this.renderVariant()}async addToCart(){if(!this.variant?.availableForSale)return null;let t=this.getLine();if(!t||t.quantity<1)return null;let i=await Y.add(t);return g("product-added",{product:this.product,variant:this.variant,line:t},this.root),i}renderProduct(){let{product:t}=this;N.has(t.handle)||this.$(`${o("option-list")},select${o("option")}`).map(n=>l(n,"option-list")||l(n,"option")).some(n=>t.options.some(a=>a.name===n))&&Ot([t]),nt(this)}renderVariant(){let t=z(this.product,{selected:this.selected,purchase:this.purchaseChoice,quantity:this.quantity},w.lowStock);if(!t){this.variant=null;return}this.variant=t.variant,this.selected=t.selected,this.purchaseChoice=t.purchase,st(this,t),g("variant-changed",{product:this.product,variant:t.variant,selected:{...t.selected},purchase:t.purchase.kind,sellingPlanId:t.isSubscription?t.purchase.planId:null},this.root)}};export{$t as a,Ot as b,ut as c};
@@ -0,0 +1 @@
1
+ import{L as p,r as c,s as i,t as a,w as l}from"./chunk-YJLWX2HK.js";var m="url:";function w(e){try{return decodeURIComponent(e)}catch(t){if(t instanceof URIError)return e;throw t}}function b(e,t=window.location,d="product"){let r=(a(e,d)??"").trim();if(!r.toLowerCase().startsWith(m))return{key:r||null,fromUrl:!1,raw:r};let n=r.slice(m.length).trim(),o;if(n.toLowerCase()==="path"){let s=t.pathname.split("/").filter(Boolean),f=s[s.length-1];o=f===void 0?null:w(f)}else o=new URLSearchParams(t.search).get(n||"handle");return{key:o?.trim()||null,fromUrl:!0,raw:r}}var y=["loading","ready","error","not-found"],S=e=>y.some(t=>t===e),h=e=>typeof e=="object"&&e!==null&&"code"in e?e.code:void 0,x=e=>h(e)==="NOT_FOUND",u=()=>["product","collection","products","recommendations"].map(e=>i(e)).join(","),E=(e,t)=>e===t||e.parentElement?.closest(u())===t;function U(e){let t=h(e);return typeof t=="string"&&t?t:"error"}function A(e,t,d){let r=t==="not-found",n=t==="error"||r;e.setAttribute(c("state"),r?"error":t),n?e.setAttribute(c("error"),r?"not-found":U(d)):e.removeAttribute(c("error")),l(e,i("show"),u()).forEach(o=>{let s=a(o,"show");S(s)&&p(o,s===t)}),n&&l(e,i("add-to-cart"),u()).forEach(o=>{o.classList.add("is-disabled"),o.setAttribute("aria-disabled","true"),"disabled"in o&&(o.disabled=!0)})}export{b as a,y as b,x as c,u as d,E as e,A as f};
@@ -0,0 +1 @@
1
+ var o=Object.defineProperty;var c=(t,r)=>{for(var e in r)o(t,e,{get:r[e],enumerable:!0})};var i={domain:["PUBLIC_SHOPIFY_DOMAIN","PUBLIC_SHOPIFY_STORE_DOMAIN","SHOPIFY_DOMAIN"],token:["PUBLIC_SHOPIFY_STOREFRONT_TOKEN","PUBLIC_SHOPIFY_STOREFRONT_ACCESS_TOKEN","SHOPIFY_STOREFRONT_TOKEN"]};function p(t){if(typeof t!="string")return!1;try{return new URL(t).protocol==="https:"}catch{return!1}}function s(t){return/^shp[a-z]{2}_/.test(t.trim())}function f(t,r){if(!t)return"";let e=parseFloat(t.amount);if(Number.isNaN(e))return"";try{return new Intl.NumberFormat(r||void 0,{style:"currency",currency:t.currencyCode}).format(e)}catch{return`${t.currencyCode} ${e.toFixed(2)}`}}function O(t,r,e){if(!/\{(handle|id)\}/.test(t))return`${t.replace(/\/$/,"")}/${r??String(r)}`;let n=e?e.split("/").pop()??"":"";return t.replace(/\{handle\}/g,encodeURIComponent(r??"")).replace(/\{id\}/g,encodeURIComponent(n))}function S(t){let r=String(t??"").trim();return r?r.startsWith("gid://")?r:/^\d+$/.test(r)?`gid://shopify/Product/${r}`:/\/products\/([^/?#]+)/.exec(r)?.[1]??r:null}export{c as a,i as b,p as c,s as d,f as e,O as f,S as g};
@@ -0,0 +1 @@
1
+ import{A as h,C as x,G as d,J as I,L as T,b as u,s as a,t as c,v as s}from"./chunk-YJLWX2HK.js";import{c as g}from"./chunk-FOMSMIAM.js";function U(t,e,o){s(t,a(e)).forEach(r=>{let n=c(r,e)??"";Object.hasOwn(o,n)&&T(r,o[n]===!0)})}var w=(t,e)=>s(t,a(e)).concat(t.matches(a(e))?[t]:[]),C=t=>t?t.toLowerCase().replace(/_/g," "):"",D=t=>(t?.formatted??[]).join(", "),y=(t,e)=>Object.hasOwn(t,e)?t[e]:void 0;function j(t){try{return new Date(t).toLocaleDateString(u.locale)}catch(e){if(e instanceof RangeError)return t;throw e}}function k(t){let e=u.account?.orderUrl;if(e){let o=t.id.split("/").pop()?.split("?")[0]??"";return e.replace("{id}",encodeURIComponent(o))}return g(t.statusPageUrl)?t.statusPageUrl??null:null}var b=(t,e)=>({title:t.title||t.name,"variant-title":t.variantTitle||"",quantity:String(t.quantity),price:d(t.price),total:d(t.totalPrice),sku:t.sku||"",returnable:e===null?void 0:String(e)}),q=t=>t.tagName==="INPUT";function O(t,e,o){U(t,"order-line-show",{returnable:o>0}),s(t,a("return-quantity")).forEach(r=>{q(r)&&(r.max=String(o),r.min="0",r.value||(r.value="0"),r.disabled=o<1)}),s(t,`select${a("return-reason")}`).forEach(r=>{r.dataset.tetherFilled!==e.id&&(r.dataset.tetherFilled=e.id,(e.suggestedReturnReasonDefinitions?.nodes??[]).forEach(n=>{r.appendChild(new Option(n.name,n.id))}))})}function V(t,e,o){x(t,e,(r,n)=>{let i=n.id,f=o&&i?o.get(i)??0:null;i&&(r.dataset.tetherLine=i);let E=b(n,f);w(r,"order-line").forEach(l=>{let m=c(l,"order-line")??"";if(m==="image"){n.image&&h(l,n.image.url,n.image.altText||n.title);return}let p=y(E,m);p!==void 0&&I(l,p)}),i&&f!==null&&O(r,{...n,id:i},f)})}export{j as a,k as b,U as c,w as d,C as e,D as f,y as g,V as h};
@@ -0,0 +1 @@
1
+ import{d as f,e as y,f as m,g as b,h as x,i as v,j as A,k}from"./chunk-JOOEXYF3.js";var S=100,j=100,h=n=>Math.round(parseFloat(n.amount)*S),P=(n,e)=>({amount:(n/S).toFixed(2),currencyCode:e}),C=(n,e)=>P(h(n)*e,n.currencyCode),F=n=>Object.fromEntries(n.selectedOptions.map(e=>[e.name,e.value]));function M(n,e){return n.variants.nodes.find(s=>s.selectedOptions.every(i=>e[i.name]===i.value))??null}function T(n,e,s,i){return n.variants.nodes.some(t=>t.availableForSale&&t.selectedOptions.every(a=>a.name===s?a.value===i:e[a.name]===a.value))}function I(n,e,s){let i=y(n),t=i.find(o=>o.id===s.planId)??i[0];if(!t)return{kind:"one-time",planId:null};let a=m(e,t.id)?t:i.find(o=>m(e,o.id))??t;return n.requiresSellingPlan||s.kind==="subscription"?{kind:"subscription",planId:a.id}:{kind:"one-time",planId:a.id}}function N(n,{variant:e,sellingPlan:s,defaultPlan:i,defaultPurchase:t}){let a=n.variants.nodes,o=f.variant(e),c=a.find(l=>l.id===o)??a.find(l=>l.availableForSale)??a[0]??null,r=k(n,s),p=r??k(n,i),u=r||t==="subscription"?"subscription":"one-time";return{selected:c?F(c):{},purchase:I(n,c,{kind:u,planId:p?.id??null})}}function O(n,e,s,i,t){let a=n.quantityAvailable,o=a!=null&&a>0&&a<=e,c=i.compareAtPrice!==null;return{"in-stock":n.availableForSale,"out-of-stock":!n.availableForSale,backorder:n.availableForSale&&n.currentlyNotInStock,"on-sale":c,"not-on-sale":!c,"has-variants":s>1,"single-variant":s===1,"low-stock":o,"plenty-in-stock":n.availableForSale&&!o,"subscription-available":i.subscriptionAvailable,"subscription-unavailable":!i.subscriptionAvailable,"subscription-only":t,"one-time-available":!t,"subscription-selected":i.isSubscription,"one-time-selected":!i.isSubscription,"has-savings":i.isSubscription?i.savings.percentage>0:c}}function U(n,e,s){let i=M(n,e.selected),t=i??n.variants.nodes[0];if(!t)return null;let a=I(n,t,e.purchase),{planId:o}=a,c=y(n),r=a.kind==="subscription"?m(t,o):null,p=r?b(t,o)??t.price:t.price,u=r?.priceAdjustments[0]?.compareAtPrice??t.compareAtPrice,l={isSubscription:r!==null,subscriptionAvailable:c.some(d=>m(t,d.id)),compareAtPrice:u&&parseFloat(u.amount)>parseFloat(p.amount)?u:null,savings:v(t,o)};return{...l,variant:t,selected:i?e.selected:F(t),purchase:a,plan:c.find(d=>d.id===o)??null,quantity:e.quantity,price:p,show:O(t,s,n.variants.nodes.length,l,n.requiresSellingPlan)}}function w(n,e){let{variant:s,plan:i,price:t,compareAtPrice:a,quantity:o}=n,c=n.purchase.planId,r=g=>C(g,Math.max(1,o)),d={price:()=>e.money(t),"total-price":()=>e.money(r(t)),"one-time-price":()=>e.money(s.price),"subscription-price":()=>e.money(c?b(s,c):null),"subscription-savings":()=>e.percent(n.savings.percentage),"subscription-savings-amount":()=>e.money(n.savings.amount),"checkout-charge":()=>{let g=n.isSubscription?x(s,c)??t:t;return e.money(r(g))},"plan-name":()=>i?.name,"plan-description":()=>i?.description,"plan-group":()=>i?.group.name,"compare-at-price":()=>e.money(a),"unit-price":()=>e.money(s.unitPrice),"discount-percentage":()=>a?`${Math.round((1-parseFloat(t.amount)/parseFloat(a.amount))*j)}%`:"0%","discount-amount":()=>a?e.money(P(h(a)-h(t),t.currencyCode)):"","variant-title":()=>s.title,"variant-id":()=>s.id,sku:()=>s.sku,barcode:()=>s.barcode,stock:()=>s.quantityAvailable,quantity:()=>o};return new Map(Object.entries(d))}function E(n,e,s,i){let a={name:()=>s?.name,option:()=>(s?.options??[]).map(o=>o.value).join(", "),description:()=>s?.description,price:()=>i.money(b(n,e)),savings:()=>i.percent(v(n,e).percentage),"savings-amount":()=>i.money(v(n,e).amount),adjustment:()=>{let o=A(s);return o?o.type==="percentage"?`${o.value}%`:i.money(o.value):""}};return new Map(Object.entries(a))}export{F as a,T as b,I as c,N as d,U as e,w as f,E as g};
@@ -0,0 +1,4 @@
1
+ import{b as d,c as m}from"./chunk-YJLWX2HK.js";import{a as f}from"./chunk-FOMSMIAM.js";var v={};f(v,{GID:()=>p,allPlans:()=>u,allocationFor:()=>c,findPlan:()=>x,hasPlans:()=>$,planAdjustment:()=>F,planCheckoutCharge:()=>h,planPrice:()=>g,planSavings:()=>y,plansForVariant:()=>A,toGid:()=>s});function s(e,i){let t=typeof e=="string"||typeof e=="number"?String(e).trim():"";return t?t.startsWith("gid://")?t:/^\d+$/.test(t)?`gid://shopify/${i}/${t}`:t:null}var p={product:e=>s(e,"Product"),variant:e=>s(e,"ProductVariant"),sellingPlan:e=>s(e,"SellingPlan")};function u(e){return(e?.sellingPlanGroups?.nodes??[]).flatMap(t=>t.sellingPlans.nodes.map(r=>({...r,group:t})))}function $(e){return u(e).length>0}function c(e,i){return!e||!i?null:(e.sellingPlanAllocations?.nodes??[]).find(r=>r.sellingPlan.id===i)??null}function A(e,i){return u(e).filter(t=>c(i,t.id))}function g(e,i){let t=c(e,i)?.priceAdjustments[0];return t?.perDeliveryPrice??t?.price??e?.price??null}function h(e,i){let t=c(e,i);return t?.checkoutChargeAmount??t?.priceAdjustments[0]?.price??e?.price??null}function y(e,i){let t=parseFloat(e?.price.amount??""),r=parseFloat(g(e,i)?.amount??"");return!e||!Number.isFinite(t)||!Number.isFinite(r)||t<=0||r>=t?{amount:null,percentage:0}:{amount:{amount:(t-r).toFixed(2),currencyCode:e.price.currencyCode},percentage:Math.round((1-r/t)*100)}}function F(e){let i=e?.priceAdjustments[0]?.adjustmentValue;if(!i)return null;switch(i.__typename){case"SellingPlanPercentagePriceAdjustment":return{type:"percentage",value:i.adjustmentPercentage};case"SellingPlanFixedAmountPriceAdjustment":return{type:"amount",value:i.adjustmentAmount};case"SellingPlanFixedPriceAdjustment":return{type:"price",value:i.price};default:return null}}function x(e,i){if(!i)return null;let t=u(e),r=p.sellingPlan(i),o=i.trim().toLowerCase();return t.find(l=>l.id===r)??t.find(l=>l.name.toLowerCase()===o)??t.find(l=>l.options.some(P=>P.value.toLowerCase()===o))??null}var n="amount currencyCode",a="url altText width height";function C(e){let i=[];for(let r of e){let o=m(r);o&&i.push(o)}return i.length?`metafields(identifiers:[${i.map(({namespace:r,key:o})=>`{namespace: ${JSON.stringify(r)}, key: ${JSON.stringify(o)}}`).join(", ")}]){namespace key type value reference{... on MediaImage{image{${a}}}}}`:""}var j=` id name description recurringDeliveries options{name value}priceAdjustments{orderCount adjustmentValue{__typename ... on SellingPlanPercentagePriceAdjustment{adjustmentPercentage}... on SellingPlanFixedAmountPriceAdjustment{adjustmentAmount{${n}}}... on SellingPlanFixedPriceAdjustment{price{${n}}}}}`,S=` sellingPlan{id}checkoutChargeAmount{${n}}remainingBalanceChargeAmount{${n}}priceAdjustments{price{${n}}compareAtPrice{${n}}perDeliveryPrice{${n}}unitPrice{${n}}}`;function k(e=d){return` fragment TetherProduct on Product{id handle title description descriptionHtml productType vendor tags availableForSale publishedAt onlineStoreUrl requiresSellingPlan seo{title description}featuredImage{${a}}images(first:${e.imagesFirst}){nodes{${a}}}options{name optionValues{name swatch{color image{previewImage{${a}}}}}}priceRange{minVariantPrice{${n}}maxVariantPrice{${n}}}compareAtPriceRange{minVariantPrice{${n}}maxVariantPrice{${n}}}${C(e.metafields)} sellingPlanGroups(first:${e.sellingPlanGroupsFirst}){nodes{name appName options{name values}sellingPlans(first:${e.sellingPlansFirst}){nodes{${j}}}}}variants(first:${e.variantsFirst}){nodes{id title availableForSale currentlyNotInStock quantityAvailable sku barcode selectedOptions{name value}image{${a}}price{${n}}compareAtPrice{${n}}unitPrice{${n}}sellingPlanAllocations(first:${e.sellingPlansFirst}){nodes{${S}}}}}}`}function I(){return` fragment TetherCart on Cart{id checkoutUrl totalQuantity note createdAt updatedAt attributes{key value}buyerIdentity{countryCode email}discountCodes{code applicable}cost{subtotalAmount{${n}}totalAmount{${n}}checkoutChargeAmount{${n}}}lines(first:100){nodes{id quantity attributes{key value}cost{totalAmount{${n}}subtotalAmount{${n}}amountPerQuantity{${n}}compareAtAmountPerQuantity{${n}}}discountAllocations{discountedAmount{${n}}}sellingPlanAllocation{sellingPlan{id name description recurringDeliveries options{name value}}checkoutChargeAmount{${n}}priceAdjustments{price{${n}}compareAtPrice{${n}}perDeliveryPrice{${n}}}}merchandise{... on ProductVariant{id title sku availableForSale requiresShipping quantityAvailable image{${a}}price{${n}}compareAtPrice{${n}}selectedOptions{name value}product{id title handle vendor featuredImage{${a}}}}}... on ComponentizableCartLine{lineComponents{id quantity merchandise{... on ProductVariant{id title product{title handle}}}}}}}}`}function L(){return`
2
+ id handle title description descriptionHtml
3
+ image { ${a} }
4
+ seo { title description }`}export{k as a,I as b,L as c,p as d,u as e,c as f,g,h,y as i,F as j,x as k,v as l};
@@ -0,0 +1 @@
1
+ import{c as pt}from"./chunk-NEHZ37TU.js";import{b as H,d as O,e as ft}from"./chunk-JOOEXYF3.js";import{A as st,C as ct,D as ut,E as lt,G as L,J as V,K as v,L as _,N as dt,R as S,b as i,g as ot,i as C,l as w,p as Q,q as at,r as F,s as c,t as k,v as u,x as g}from"./chunk-YJLWX2HK.js";import{c as it}from"./chunk-FOMSMIAM.js";var Nt='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',Mt=60,X=!1,K=null,Wt=t=>t!==null&&"focus"in t,mt=t=>u(t,Nt).filter(e=>e.offsetParent!==null||e===document.activeElement),I=()=>u(document,c("cart-drawer")),Y=t=>t.classList.contains(i.cartDrawerOpenClass);function h(){let t=I();return t.length?t.some(Y):X}function j(t){u(document,c("cart-open")).forEach(e=>{e.setAttribute("aria-expanded",String(t))}),I().forEach(e=>{e.hasAttribute("role")||e.setAttribute("role","dialog"),!e.hasAttribute("aria-label")&&!e.hasAttribute("aria-labelledby")&&e.setAttribute("aria-label",k(e,"cart-label")||"Cart"),e.setAttribute("aria-modal",String(t)),!Y(e)&&(e.setAttribute("aria-hidden","true"),i.cartFocus&&(e.inert=!0))})}function Gt(t){let e=mt(t)[0]??t;e===t&&!t.hasAttribute("tabindex")&&(t.tabIndex=-1),e.focus({preventScroll:!0})}function B(){if(h())return;X=!0;let t=I().filter(n=>k(n,"cart-drawer")!=="manual");t.forEach(n=>{n.inert=!1,n.classList.add(i.cartDrawerOpenClass),n.setAttribute("aria-hidden","false")}),j(!0);let[e]=t;i.cartFocus&&e&&(K=Wt(document.activeElement)?document.activeElement:null,setTimeout(()=>{Gt(e)},Mt)),i.onCartOpen?.(t),g("cart-toggled",{open:!0})}function z(){if(!h())return;X=!1;let t=I(),e=t.some(n=>n.contains(document.activeElement));t.forEach(n=>{n.classList.remove(i.cartDrawerOpenClass),n.setAttribute("aria-hidden","true"),i.cartFocus&&(n.inert=!0)}),j(!1),e&&K?.isConnected&&K.focus({preventScroll:!0}),K=null,i.onCartClose?.(t),g("cart-toggled",{open:!1})}function gt(){h()?z():B()}function Rt(t){if(t.key!=="Tab"||!i.cartFocus||!h())return;let e=I().find(Y);if(!e)return;let n=mt(e),r=n[0],o=n.at(-1);if(!r||!o)return;let a=document.activeElement,s=t.shiftKey?a===r:a===o;e.contains(a)&&!s||(t.preventDefault(),(t.shiftKey?o:r).focus())}var Vt=/^(-?)(\d+)(?:\.(\d+))?$/;function ht(t,e){let n=Vt.exec(t.trim());if(!n)return null;let[,r="",o="0",a=""]=n,s=BigInt(`${o}${a.padEnd(e,"0")}`);return r==="-"?-s:s}var yt=t=>t.split(".")[1]?.length??0;function bt(t,e){if(t==null||e==null)return!1;let n=Math.max(yt(t.trim()),yt(e.trim())),r=ht(t,n),o=ht(e,n);return r===null||o===null?!1:r>o}var Ct="Default Title",J=(t,e)=>e.get(t.id)?.quantity??t.quantity,wt=t=>t.split("/").pop()??t;function Ht(t){let e=t.merchandise,n=lt(e.product.handle,e.product.id),r=new URLSearchParams;r.set("variant",wt(e.id));let o=t.sellingPlanAllocation?.sellingPlan.id;return o&&r.set("selling_plan",wt(o)),`${n}${n.includes("?")?"&":"?"}${r.toString()}`}var kt=t=>t.merchandise.product.title,vt={title:kt,"product-title":kt,"variant-title":t=>t.merchandise.title===Ct?"":t.merchandise.title,options:t=>t.merchandise.selectedOptions.filter(e=>e.value!==Ct).map(e=>`${e.name}: ${e.value}`).join(", "),vendor:t=>t.merchandise.product.vendor,sku:t=>t.merchandise.sku??"",price:t=>L(t.cost.amountPerQuantity),"compare-at-price":t=>L(t.cost.compareAtAmountPerQuantity??t.merchandise.compareAtPrice),"line-total":t=>L(t.cost.totalAmount),"line-subtotal":t=>L(t.cost.subtotalAmount),quantity:(t,e)=>J(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(", ")},At="attribute:";function Xt(t,e,n){if(Object.hasOwn(vt,e))return vt[e]?.(t,n);if(!e.startsWith(At))return;let r=e.slice(At.length);return t.attributes.find(o=>o.key===r)?.value??""}function Yt(t,e,n){let r=ft(n),o=!n.requiresSellingPlan&&k(t,"line-plan")!=="subscription-only",a={value:"",label:t.getAttribute(F("one-time-label"))||"One-time purchase"},s=[...o?[a]:[],...r.map(d=>({value:d.id,label:d.name}))],f=s.map(d=>d.value).join("|");t.dataset.tetherSig!==f&&(t.replaceChildren(...s.map(d=>{let T=document.createElement("option");return T.value=d.value,T.textContent=d.label,T})),t.dataset.tetherSig=f),t.value=e.sellingPlanAllocation?.sellingPlan.id??"",_(t,r.length>0)}function zt(t,e,n){let r=!!e.sellingPlanAllocation;t.classList.toggle("is-subscription",r);let o=n.warnings.find(f=>f.target===e.id);t.classList.toggle("is-warning",!!o);let a=n.pending.has(e.id);t.classList.toggle("is-busy",a),a?t.setAttribute("aria-busy","true"):t.removeAttribute("aria-busy"),u(t,c("line","warning")).forEach(f=>{v(f,o?.message??"")});let s={subscription:r,"one-time":!r,"on-sale":bt(e.cost.compareAtAmountPerQuantity?.amount,e.cost.amountPerQuantity.amount),"has-components":(e.lineComponents??[]).length>0,warning:!!o};u(t,c("line-show")).forEach(f=>{let d=k(f,"line-show");d!==null&&Object.hasOwn(s,d)&&_(f,s[d])})}function Jt(t,e,n){let r=e.merchandise;t.setAttribute(F("line-id"),e.id),u(t,c("line")).forEach(o=>{let a=k(o,"line")??"";if(a==="image"){st(o,r.image?.url??r.product.featuredImage?.url,r.product.title);return}if(a==="url"){o.setAttribute("href",Ht(e));return}let s=Xt(e,a,n);s!==void 0&&v(o,s)}),zt(t,e,n),u(t,`select${c("line-plan")}`).forEach(o=>{pt(r.product.handle).then(a=>{Yt(o,e,a)}).catch(a=>{C(a,"line plan options")})})}function Zt(t,e){let n=t?.totalQuantity??0,r=(t?.lines.nodes??[]).some(a=>a.sellingPlanAllocation),o={"cart-empty":n===0,"cart-filled":n>0,"cart-has-subscription":r,"cart-no-subscription":!r,"cart-has-discount":(t?.discountCodes??[]).some(a=>a.applicable),"cart-error":e.failed,"cart-warning":e.warnings.length>0};u(document,c("show")).forEach(a=>{let s=k(a,"show");s===null||!Object.hasOwn(o,s)||a.closest(c("product"))||_(a,o[s])}),u(document,c("checkout")).forEach(a=>{a.classList.toggle("is-disabled",!n),a.setAttribute("aria-disabled",String(!n))})}function te(t){u(document,`textarea${c("cart-note")},input${c("cart-note")}`).forEach(e=>{document.activeElement!==e&&V(e,t?.note??"")}),u(document,c("cart-discounts")).forEach(e=>{ct(e,t?.discountCodes??[],(n,r)=>{n.setAttribute(F("discount-code"),r.code);let o=n.querySelector(c("discount","code"))??(n.firstElementChild?null:n);o&&V(o,r.code),n.classList.toggle("is-inapplicable",!r.applicable)})})}function It(t){let{cart:e}=t,n=r=>e?L(e.cost[r]):"";j(h()),u(document,c("cart-count")).forEach(r=>{v(r,e?.totalQuantity??0)}),u(document,c("cart-subtotal")).forEach(r=>{v(r,n("subtotalAmount"))}),u(document,c("cart-total")).forEach(r=>{v(r,n("totalAmount"))}),u(document,c("cart-checkout-charge")).forEach(r=>{v(r,n("checkoutChargeAmount"))}),Zt(e,t),u(document,c("cart-warning")).forEach(r=>{v(r,[...new Set(t.warnings.map(o=>o.message))].join(" "))}),te(e),u(document,c("cart-lines")).forEach(r=>{ut(r,e?.lines.nodes??[],o=>o.id,(o,a)=>{Jt(o,a,t)},{onEnter:i.onLineEnter,onLeave:i.onLineLeave})}),e&&dt("cart")}function xt(t){u(document,c("cart-count")).forEach(e=>{/^\s*0?\s*$/.test(e.textContent)&&(e.textContent=t)})}var m={kind:"unknown"},$=[],x=new Map,p={accessToken:null,beforeCheckout:null},N=()=>m;function l(){switch(m.kind){case"ready":case"error":return m.cart;case"unknown":case"empty":return null}}var Lt=()=>$,M=t=>t?{kind:"ready",cart:t}:{kind:"empty"},$t=()=>`${i.storageKey}:seen`;function Tt(t){try{return localStorage.getItem(t)}catch{return null}}function Z(t,e){try{e===null?localStorage.removeItem(t):localStorage.setItem(t,e)}catch{}}var E=()=>Tt(i.storageKey)||null;function q(){Z(i.storageKey,null)}function tt(t){m=M(t),t&&Z(i.storageKey,t.id)}function P(){It({cart:l(),warnings:$,pending:x,failed:m.kind==="error"})}function D(t){P(),g("cart-updated",{cart:l(),reason:t})}function y(t,e){return tt(t),Z($t(),`${Date.now()}|${t?.totalQuantity??0}`),D(e),t}function W(t){m=t.kind==="loaded"?M(t.cart):{kind:"error",error:t.error,cart:null},D("load")}function St(t){let e=l();m=t==null?M(e):{kind:"error",error:t,cart:e}}function Ot(){if(m.kind!=="unknown")return;let t=Tt($t())?.split("|")[1];t&&xt(t)}function Pt(t){$=t.filter((e,n)=>t.findIndex(r=>r.message===e.message)===n).map(e=>({...e,message:i.warningText?.(e)||e.message})),$.length&&g("cart-warning",{warnings:$})}var Et=()=>{};function ee(){let t=Promise.resolve();return e=>{let n=t.then(e);return t=n.then(Et,Et),n}}var ne=ee();function b(t){return ne(t).then(e=>(m.kind==="error"&&(m=M(m.cart),P()),e),e=>{throw m={kind:"error",error:e,cart:l()},P(),g("cart-error",{error:e}),e})}var et=t=>J(t,x),re=()=>({open:h(),count:l()?.totalQuantity??0,loaded:m.kind!=="unknown",warnings:$});function qt(t){let e=["cart-updated","cart-toggled"].map(r=>`${i.prefix}:${r}`),n=()=>{t(l(),re())};return e.forEach(r=>{document.addEventListener(r,n)}),n(),()=>{e.forEach(r=>{document.removeEventListener(r,n)})}}var oe=/does not exist|not found|invalid id/i;function G(t){return t instanceof w?t.userErrors?.some(e=>e.field?.[0]==="cartId")?!0:(t.errors??[]).some(e=>oe.test(e.message)):!1}function Ut(t,e=1,n={}){let r=typeof t=="object"&&t!==null?t:{...n,variantId:t,quantity:e},o=O.variant(r.merchandiseId||r.variantId||r.id);if(!o)throw new w("add(): variantId is required");let a=parseInt(String(r.quantity??1),10),s={merchandiseId:o,quantity:Math.max(1,a||1)},f=O.sellingPlan(r.sellingPlanId||r.sellingPlan);f&&(s.sellingPlanId=f);let d=S(r.attributes);return d.length&&(s.attributes=d),s}function ae(t,e,n){return`mutation Tether_${t}(${e}){${t}(${n}){cart{...TetherCart}userErrors{field message}warnings{code message target}}}${H()}`}async function Qt(t,e,n,r){let o=await Q(ae(t,e,n),r),a=at(o[t],t);return Pt(a.warnings??[]),a.cart}function Dt(t){let e={...i.country?{countryCode:i.country.toUpperCase()}:{},...p.accessToken?{customerAccessToken:p.accessToken}:{}},n=Object.keys(e).length?{buyerIdentity:e,...t}:t;return Qt("cartCreate","$input: CartInput!","input: $input",{input:n})}async function A({name:t,args:e,inner:n,variables:r,createInput:o}){let a=E();if(!a)return o?Dt(o):null;try{return await Qt(t,`$cartId: ID!, ${e}`,`cartId: $cartId, ${n}`,{...r,cartId:a})}catch(s){if(!G(s)||(q(),!o))throw s;return ot("cart expired, creating a new one"),Dt(o)}}async function Ft(t){return(await Q(`query TetherCart($id:ID!){cart(id:$id){...TetherCart}}${H()}`,{id:t})).cart}async function _t(t){return(await Q("query TetherCheckout($id: ID!) { cart(id: $id) { checkoutUrl } }",{id:t})).cart?.checkoutUrl??null}function Kt(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?O.sellingPlan(n.sellingPlanId):null),n.attributes&&(r.attributes=S(n.attributes));let o=n.merchandiseId||n.variantId;return o&&(r.merchandiseId=O.variant(o)),r}var nt=t=>A({name:"cartLinesUpdate",args:"$lines: [CartLineUpdateInput!]!",inner:"lines: $lines",variables:{lines:t},createInput:null}),rt=t=>A({name:"cartLinesRemove",args:"$lineIds: [ID!]!",inner:"lineIds: $lineIds",variables:{lineIds:t},createInput:null}),jt=(t,e)=>e>0?nt([{id:t,quantity:e}]):rt([t]);var ie=t=>_t(t).then(e=>({kind:"url",url:e}),e=>({kind:"failed",error:e}));async function se(){if(!p.beforeCheckout)return null;try{return await p.beforeCheckout()}catch(t){return C(t,"account checkout"),null}}async function ce(t){let e=ie(t),n=await se();if(!n){let r=await e;if(r.kind==="failed")throw r.error;n=r.url}if(!n)throw new w("No checkoutUrl (cart empty or expired)");return p.accessToken?`${n}${n.includes("?")?"&":"?"}logged_in=true`:n}function ue(t){try{t.opener=null}catch{}}async function Bt(t=i.checkoutTarget){let e=E(),n=l();if(!e||n&&!n.totalQuantity)return null;let r=t==="_blank"?window.open("","_blank"):null;r&&ue(r);try{let o=await ce(e);if(!it(o))throw new w("The checkout URL is not https: not opened");return g("checkout",{url:o,cart:l()}),r&&!r.closed?r.location.href=o:window.location.href=o,o}catch(o){return r?.close(),C(o,"checkout failed"),null}}var R=()=>l()?.lines.nodes??[];function le(t,e){let n=R().find(f=>f.id===t);if(!n)return Promise.resolve(l());let r=Math.max(0,et(n)+e),o={quantity:r};x.set(t,o),D("pending");let a=()=>x.get(t)===o;return b(async()=>{if(!a())return l();if(R().find(T=>T.id===t)?.quantity===r)return l();let d=await jt(t,r);return a()?y(d,r>0?"update":"remove"):(tt(d),d)}).finally(()=>{a()&&(x.delete(t),D("settled"))})}function de(t){let e=(l()?.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((l()?.attributes??[]).map(n=>[n.key,n.value]));return S(t).forEach(n=>e.set(n.key,n.value)),[...e].filter(([,n])=>n!=="").map(([n,r])=>({key:n,value:r}))}async function pe(){let t=E();if(!t)return W({kind:"loaded",cart:null}),null;Ot();try{let e=await Ft(t);e||q(),W({kind:"loaded",cart:e})}catch(e){C(e,"cart load failed"),G(e)&&q(),W({kind:"failed",error:e})}return l()}var U={init:pe,id:E,get status(){return N()},get state(){return l()},get lines(){return R()},get count(){return l()?.totalQuantity??0},get loaded(){return N().kind!=="unknown"},get lastError(){let t=N();return t.kind==="error"?t.error:null},set lastError(t){St(t)},get warnings(){return Lt()},get pendingQty(){return x},get customerAccessToken(){return p.accessToken},set customerAccessToken(t){p.accessToken=t||null},get beforeCheckout(){return p.beforeCheckout},set beforeCheckout(t){p.beforeCheckout=typeof t=="function"?t:null},setCustomer(t){t.accessToken!==void 0&&(p.accessToken=t.accessToken),t.beforeCheckout!==void 0&&(p.beforeCheckout=t.beforeCheckout)},_commit:y,render:P,subscribe:qt,add(t,e=1,n={}){let r=(Array.isArray(t)?t:[t]).map(o=>Ut(o,e,n));return b(async()=>{let o=await A({name:"cartLinesAdd",args:"$lines: [CartLineInput!]!",inner:"lines: $lines",variables:{lines:r},createInput:{lines:r}});return y(o,"add"),g("added",{cart:o,lines:r}),i.openCartOnAdd&&B(),o})},updateLine(t,e){let n=typeof e=="number"?e:e.quantity;if(n!==void 0&&n<=0)return U.removeLine(t);let r=Kt(t,e);return b(async()=>y(await nt([r]),"update"))},changeQuantity:le,quantityOf:et,removeLine(t){let e=Array.isArray(t)?t:[t];return b(async()=>y(await rt(e),"remove"))},clear(){let t=R().map(e=>e.id);return t.length?U.removeLine(t):Promise.resolve(l())},setNote(t){let e={note:t??""};return b(async()=>y(await A({name:"cartNoteUpdate",args:"$note: String!",inner:"note: $note",variables:e,createInput:e}),"note"))},setAttributes(t){return b(async()=>{let e={attributes:fe(t)},n=await A({name:"cartAttributesUpdate",args:"$attributes: [AttributeInput!]!",inner:"attributes: $attributes",variables:e,createInput:e});return y(n,"attributes")})},setDiscountCodes(t){return b(async()=>{let e={discountCodes:de(t)},n=await A({name:"cartDiscountCodesUpdate",args:"$discountCodes: [String!]!",inner:"discountCodes: $discountCodes",variables:e,createInput:e});return y(n,"discount")})},async applyDiscount(t){let e=await U.setDiscountCodes(o=>[...new Set([...o,t])]),n=t.toLowerCase();if((e?.discountCodes??[]).find(o=>o.code.toLowerCase()===n)?.applicable)return e;try{await U.removeDiscount(t)}catch(o){C(o,"removing a discount code Shopify refused")}throw new w(`Discount code not valid: ${t}`,{code:"INVALID_DISCOUNT"})},removeDiscount(t){let e=t.toLowerCase();return U.setDiscountCodes(n=>n.filter(r=>r.toLowerCase()!==e))},setBuyerIdentity(t,{create:e=!0}={}){return b(async()=>{let n=await A({name:"cartBuyerIdentityUpdate",args:"$buyerIdentity: CartBuyerIdentityInput!",inner:"buyerIdentity: $buyerIdentity",variables:{buyerIdentity:t},createInput:e?{buyerIdentity:t}:null}).catch(r=>{if(e||!G(r))throw r;return null});return y(n,"buyer-identity")})},checkout:Bt,drawers:I,isOpen:h,open:B,close:z,toggle:gt};export{Rt as a,U as b};
@@ -0,0 +1,3 @@
1
+ import{a as y,c as q}from"./chunk-JOOEXYF3.js";import{b as I,g as T,l as g,p as h}from"./chunk-YJLWX2HK.js";import{g as E}from"./chunk-FOMSMIAM.js";var _=1e4,N=6e4,d=new Map,w=new Map,f=new Set,m=new Map,K=[],S=!1,p=0,C=t=>t.startsWith("gid://"),P=E;function $(t){if(!t)return;let e=Promise.resolve(t);d.set(t.handle,e),d.set(t.id,e)}function b(t){let e=P(t);if(!e)return Promise.reject(new g("empty product key",{code:"NOT_FOUND"}));let o=d.get(e);if(o)return o;let r=new Promise((i,s)=>{w.set(e,{resolve:i,reject:s}),K.push(e),S||(S=!0,setTimeout(()=>void F(),0))});return d.set(e,r),r}function x(t){let e=t.filter(C),o=t.filter(u=>!C(u)),r=[],i=[],s={};return e.length&&(r.push("$ids: [ID!]!"),s.ids=e,i.push("byId: nodes(ids: $ids) { ... on Product { ...TetherProduct } }")),o.forEach((u,n)=>{r.push(`$h${n}: String!`),s[`h${n}`]=u,i.push(`h${n}: product(handle: $h${n}) { ...TetherProduct }`)}),{query:`query TetherProducts(${r.join(",")}){${i.join(" ")}}${y()}`,variables:s,handles:o}}function v(t,e){let o=w.get(t);w.delete(t),o&&e(o)}function D(t,e){if(e!==p)return;let o=d.get(t);setTimeout(()=>{d.get(t)===o&&d.delete(t)},_)}async function F(){S=!1;let t=p,e=K.splice(0);if(!e.length)return;let{query:o,variables:r,handles:i}=x(e);T("fetch products",e);let s;try{s=await h(o,r)}catch(n){e.forEach(a=>{v(a,c=>{t===p&&d.delete(a),c.reject(n)})});return}let l=new Map;for(let n of s.byId??[])n&&l.set(n.id,n);i.forEach((n,a)=>{let c=s[`h${a}`];c&&l.set(n,c)});let u=Date.now();e.forEach(n=>{v(n,a=>{let c=l.get(n);if(!c){D(n,t),a.reject(new g(`Product not found: ${n}`,{code:"NOT_FOUND"}));return}t===p&&($(c),m.set(c.handle,u),m.set(c.id,u)),a.resolve(c)})})}function L(){d.clear(),p+=1,f.clear(),m.clear()}function Q(t){for(let e of t??[])!e.id||!e.handle||Date.now()-(m.get(e.handle)??0)<N&&d.has(e.handle)||($(e),f.add(e.handle),f.add(e.id))}function W(t){let e=P(t);return!e||!f.has(e)?!1:(f.delete(e),d.get(e)?.then(o=>{f.delete(o.handle),f.delete(o.id)}),!0)}function z(t){for(let e of t){let o=P(e);o&&d.delete(o)}return t.map(e=>b(e))}var M=`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}}}}`,O="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 B({collection:t,query:e,first:o=I.collectionFirst,after:r=null,sortKey:i,reverse:s=!1,filters:l}={}){let u=y();if(t){let a=await h(`${M}
2
+ ${u}`,{handle:t,first:o,after:r,sortKey:i||void 0,reverse:s,filters:l??void 0});if(!a.collection)throw new g(`Collection not found: ${t}`,{code:"NOT_FOUND"});let{products:c,...R}=a.collection;return c.nodes.forEach($),{collection:R,products:c.nodes,pageInfo:c.pageInfo}}let n=await h(`${O}
3
+ ${u}`,{first:o,after:r,query:e||void 0,sortKey:i||void 0,reverse:s});return n.products.nodes.forEach($),{collection:null,products:n.products.nodes,pageInfo:n.products.pageInfo}}async function G(t,e="RELATED"){let o=P(typeof t=="object"?t?.id:t),r=o?.startsWith("gid://")??!1,s=(await h(`query TetherRecs(${r?"$id: ID!":"$handle: String!"},$intent:ProductRecommendationIntent){productRecommendations(${r?"productId: $id":"productHandle: $handle"},intent:$intent){...TetherProduct}}${y()}`,r?{id:o,intent:e}:{handle:o,intent:e})).productRecommendations??[];return s.forEach($),s}export{P as a,$ as b,b as c,L as d,Q as e,W as f,z as g,B as h,G as i};
@@ -0,0 +1 @@
1
+ import{a as S,b as Y,c as _}from"./chunk-2FSXS55U.js";import{a as m,c as g,f}from"./chunk-FCSWQDVV.js";import{c as F,e as M,f as q,g as K,h as W,i as D}from"./chunk-NEHZ37TU.js";import{A as N,C as A,I as O,J as L,L as k,N as I,P as U,b as h,g as R,h as T,i as p,l as $,r as u,s as c,t as i,u as E,v,w as C,x as l}from"./chunk-YJLWX2HK.js";var B="url:",x=()=>`${c("collection")},${c("products")},${c("recommendations")}`,V=t=>t instanceof window.Element,H=t=>parseInt(t??"",10)||void 0,X=t=>t==="COMPLEMENTARY"?"COMPLEMENTARY":"RELATED",J=class{constructor(e){this.root=e,this.products=[],this.pageInfo=null,this.collection=null,this.loadToken=0,f(e,"loading"),e.addEventListener("click",r=>{if(!V(r.target))return;let n=r.target.closest(c("load-more"));n?.closest(x())===e&&(r.preventDefault(),U(n,()=>this.load(!0)))})}$(e){return C(this.root,e,x())}options(){let{root:e}=this,r={reverse:i(e,"reverse")==="true"},n=H(i(e,"limit"));n&&(r.first=n);let o=i(e,"sort");if(o&&(r.sortKey=o),E(e,"collection"))return r.collection=i(e,"collection")??"",r;let s=i(e,"products")??"";return r.query=s.startsWith(B)?new URL(window.location.href).searchParams.get(s.slice(B.length))||"":s,r}async loadRecommendations(){let{key:e}=m(this.root,window.location,"recommendations"),r=this.root.closest(c("product"));if(!e&&r&&({key:e}=m(r)),!e)throw new $("No product for recommendations",{code:"NOT_FOUND"});return D(e,X(i(this.root,"intent")))}async load(e=!1){this.loadToken+=1;let r=this.loadToken,n=()=>r!==this.loadToken;try{if(E(this.root,"recommendations")){let o=await this.loadRecommendations();if(n())return;let s=H(i(this.root,"limit"));this.products=s?o.slice(0,s):o}else{let o=await W({...this.options(),after:e?this.pageInfo?.endCursor??null:null});if(n())return;this.collection=o.collection,this.pageInfo=o.pageInfo,this.products=e?[...this.products,...o.products]:o.products}this.render(),f(this.root,"ready"),l("list-ready",{products:this.products,collection:this.collection},this.root)}catch(o){if(n())return;e||f(this.root,g(o)?"not-found":"error",o),g(o)&&E(this.root,"recommendations")||p(o,"list load failed"),l("error",{error:o,context:"list"},this.root)}}render(){let{collection:e}=this;this.$(c("collection-bind")).forEach(n=>{switch(i(n,"collection-bind")??""){case"title":L(n,e?.title??"");break;case"description":O(n,e?.descriptionHtml);break;case"image":N(n,e?.image?.url,e?.image?.altText||e?.title);break;case"count":L(n,this.products.length);break}}),this.$(c("list")).forEach(n=>{A(n,this.products,(o,s)=>{o.setAttribute(u("product"),s.handle),o.removeAttribute(u("state"))}),l("list-rendered",{container:n},this.root)});let r=this.products.length===0;this.$(c("show")).forEach(n=>{let o=i(n,"show");o==="list-empty"&&k(n,r),o==="list-filled"&&k(n,!r)}),this.$(c("load-more")).forEach(n=>{k(n,!!this.pageInfo?.hasNextPage)}),I("list")}};var Z='script[type="application/json"][data-tether-hydrate]',P=new WeakSet,Pt=new WeakSet,y=new Set,j=new Set,z=new WeakMap;function tt(){y.forEach(t=>{t.isConnected||y.delete(t)}),j.forEach(t=>{t.root.isConnected||j.delete(t)})}function bt(t,e){return[...t.matches?.(e)?[t]:[],...v(t,e)]}function et(t,e){let r=i(t,"page-title");!r||typeof document>"u"||(document.title=r.replace(/\{title\}/g,e.title).replace(/\{vendor\}/g,e.vendor||"").replace(/\{type\}/g,e.productType||""))}function ot(t,{fromUrl:e,raw:r}){e?(P.add(t),f(t,"not-found"),l("product-not-found",{key:null,source:r},t)):t.closest(x())||T(`[${u("product")}] without a value. Bind it to the Shopify handle field, or use "url:handle".`,t)}function rt(t,e,{fromUrl:r,raw:n},o){let s=g(o);if(f(t,s?"not-found":"error",o),!s){p(o,`product ${e}`),l("error",{error:o,context:"product",key:e},t);return}l("product-not-found",{key:e,source:n},t),r?R(`product not found: ${e}`):p(o,`product ${e}`)}function nt(t){if(P.has(t))return!1;let{key:e,...r}=m(t);if(!e)return ot(t,r),!1;P.add(t),y.add(t);let n={};z.set(t,n);let o=()=>z.get(t)===n;return S.get(t)?t.setAttribute(u("state"),"updating"):f(t,"loading"),at(F(e)).then(d=>{if(!o())return;let w=S.get(t);w?w.update(d):new _(t,d),et(t,d),h.revalidate&&q(e)&&st(e)}).catch(d=>{o()&&rt(t,e,r,d)}),!0}function Rt(){tt(),y.forEach(t=>{t.getAttribute(u("state"))!=="error"||t.getAttribute(u("error"))==="not-found"||(P.delete(t),nt(t))})}var b=new Set;function st(t){b.size||setTimeout(ct,0),b.add(t)}function it(t,e){y.forEach(r=>{let n=S.get(r);if(!n||!r.isConnected)return;let o=m(r).key;o!==t&&o!==e.handle&&o!==e.id||JSON.stringify(n.product)!==JSON.stringify(e)&&n.update(e)})}function ct(){let t=[...b];b=new Set,K(t).forEach((e,r)=>{let n=t[r];e.then(o=>{it(n,o)}).catch(o=>{p(o,`refresh ${n}`)})})}var a=null,at=t=>(a?.add(t),t);function dt(){if(!a)return;let t=[...a];Promise.allSettled(t).then(()=>{if(!(!a||t.some(e=>!a?.has(e)))){if(t.length!==a.size){dt();return}a=null,document.documentElement.classList.remove(`${h.prefix}-market-pending`)}})}var ut=t=>!!(t?.id&&t.handle),Q=(t,e)=>(t??"").toUpperCase()===(e??"").toUpperCase(),G=new WeakSet;function Tt(t=document){v(t.ownerDocument??t,Z).forEach(e=>{if(G.has(e))return;G.add(e);let r;try{r=JSON.parse(e.textContent)}catch(w){T("bad data-tether-hydrate",w);return}let{country:n,language:o,products:s}=r??{},d=Array.isArray(s)?s.filter(ut):[];if(Y(d),Q(n,h.country)&&Q(o,h.language)){M(d);return}R("hydration skipped: other market"),a||(a=new Set,document.documentElement.classList.add(`${h.prefix}-market-pending`))})}export{x as a,J as b,P as c,Pt as d,y as e,j as f,tt as g,bt as h,nt as i,Rt as j,at as k,dt as l,Tt as m};
@@ -0,0 +1 @@
1
+ var t={diagnose:()=>import("./diagnose-6VVGZNTY.js"),markets:()=>import("./markets-ui-UNB4PTA7.js"),search:()=>import("./search-OU75RNQL.js"),extras:()=>import("./extras-GJVRDFM3.js"),account:()=>import("./account-C3NP6HFB.js"),"account-pages":()=>import("./account-pages-WLK374FO.js"),analytics:()=>import("./analytics-G3SAWMNL.js")},r=o=>t[o](),a=void 0;export{r as a,a as b};
@@ -0,0 +1 @@
1
+ import{e as U,f as R}from"./chunk-FOMSMIAM.js";var b={domain:"",token:"",apiVersion:"2026-07",country:void 0,language:void 0,locale:void 0,markets:null,prefix:"tether",productPath:"/product",collectionPath:"/collection",metafields:[],imagesFirst:25,variantsFirst:100,sellingPlanGroupsFirst:10,sellingPlansFirst:25,collectionFirst:24,retries:2,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},i={...b},rt=/^[a-z][a-z0-9-]*$/,nt=/^[A-Za-z0-9_.-]+$/,ot=/^(\$app(:[A-Za-z0-9_-]+)?|[A-Za-z0-9_.-]+)$/,it=["imagesFirst","variantsFirst","sellingPlanGroupsFirst","sellingPlansFirst","collectionFirst","retries","maxAge","lowStock"],st=["warningText","formatMoney","onLayoutChange","onCartOpen","onCartClose","onLineEnter","onLineLeave","onValueChange","onError"];function g(t,e,r){return e!==void 0&&d(`invalid ${t} ${JSON.stringify(e)}: using ${JSON.stringify(r)}`),r}function at(t,e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:g(t,e,b[t])}function F(t,e,r){return r.find(n=>n===e)??g(t,e,r[0])}function ut(t){return typeof t!="string"?"":t.replace(/^https?:\/\//,"").replace(/\/.*$/,"")}function ct(t){let e,r;if(typeof t=="string"){let n=t.indexOf(".");e=n>0?t.slice(0,n):"",r=t.slice(n+1)}else typeof t=="object"&&t!==null&&(e=Reflect.get(t,"namespace"),r=Reflect.get(t,"key"));return typeof e!="string"||typeof r!="string"?null:ot.test(e)&&nt.test(r)?{namespace:e,key:r}:null}function ft(t){if(!Array.isArray(t))return g("metafields",t,[]);let e=[];for(let r of t){let n=ct(r);n?e.push(typeof r=="string"?r:n):g("metafield",r,null)}return e}function lt(t){let e=ut(t.domain),r=typeof t.prefix=="string"&&rt.test(t.prefix)?t.prefix:g("prefix",t.prefix,b.prefix),n={...b,...t,domain:e,prefix:r,storageKey:t.storageKey||`${r}:cart:${e}`,metafields:ft(t.metafields??[]),checkoutTarget:F("checkoutTarget",t.checkoutTarget,["_self","_blank"]),defaultPurchase:F("defaultPurchase",t.defaultPurchase,["one-time","subscription"])};for(let o of it)n[o]=at(o,t[o]);for(let o of st)typeof n[o]!="function"&&(n[o]=null);return n.apiVersion==="unstable"&&d('apiVersion "unstable" changes without notice. Pin a dated version (e.g. 2026-07).'),n}function zt(t={}){let e=lt(t);for(let r of Object.keys(i))r in e||Reflect.deleteProperty(i,r);return Object.assign(i,e)}var Jt=()=>!!(i.domain&&i.token);function k(...t){i.debug&&console.log(`[${i.prefix}]`,...t)}function d(...t){console.warn(`[${i.prefix}]`,...t)}function h(t,e){if(d(e,t instanceof Error&&t.message?t.message:t),!!i.onError)try{i.onError(t,e)}catch(r){d("onError threw",r)}}var pt=/^[A-Z]{2}$/,dt=new Set(["XX","T1"]),mt=new Set(["PT_BR","PT_PT","ZH_CN","ZH_TW"]),gt=/^[A-Z]{2,3}$/;function D(t){let e=(typeof t=="string"?t:"").trim().toUpperCase();return!pt.test(e)||dt.has(e)?null:e}function j(t){let e=(typeof t=="string"?t:"").trim().replace("-","_").toUpperCase();if(mt.has(e))return e;let r=e.split("_")[0]??"";return gt.test(r)?r:null}var l=class extends Error{constructor(e,{status:r,errors:n,userErrors:o,code:s}={}){super(e),this.name="TetherError",this.code=s??(r?`HTTP_${r}`:"ERROR"),this.status=r,this.errors=n,this.userErrors=o}};function ht(t=i){return`https://${t.domain}/api/${t.apiVersion}/graphql.json`}function yt(t,e=i){let r=[],n=D(e.country),o=j(e.language);if(n&&r.push(`country: ${n}`),o&&r.push(`language: ${o}`),!r.length||t.includes("@inContext"))return t;let s=`@inContext(${r.join(", ")})`;return/^\s*\{/.test(t)?`query ${s} ${t.trimStart()}`:t.replace(/^(\s*(?:query|mutation)(?:\s+\w+)?\s*(?:\([^)]*\))?)/,`$1 ${s}`)}var H=300,At=500,V=430,T="quantityAvailable",B=new Set,xt=t=>`${t.domain} ${t.apiVersion} ${t.token}`,Et=t=>new Promise(e=>setTimeout(e,t));function O(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 bt(t,e,r){let n=e.map(s=>s.message).filter(Boolean).join(" | "),o=n||"Storefront API error";return t.ok||(o=t.status===401||t.status===403||!n?O(t.status,r):n),new l(o,{status:t.status,errors:e})}async function Tt(t,e,r,n){let o;try{o=await(t.fetch??fetch)(ht(t),{method:"POST",headers:{"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":t.token},body:JSON.stringify({query:e,variables:r})})}catch(u){if(n)return{kind:"retry",backoffMs:H};throw new l(`Network error: ${u instanceof Error?u.message:String(u)}`,{code:"NETWORK"})}if(o.status===V)throw new l("Shopify security rejection (430)",{status:V});if(n&&(o.status===429||o.status>=500))return{kind:"retry",backoffMs:H};let s;try{s=await o.json()}catch{let u=o.ok?`Invalid response (${o.status})`:O(o.status,t);throw new l(u,{status:o.status})}let{data:c,errors:f=[]}=s??{};if(f.length){if(e.includes(T)&&f.some(u=>u.message.includes(T)))return{kind:"inventory-refused"};if(n&&f.some(u=>u.extensions?.code==="THROTTLED"))return{kind:"retry",backoffMs:At};throw bt(o,f,t)}if(!o.ok)throw new l(O(o.status,t),{status:o.status});return{kind:"data",data:c}}async function wt(t,e,r={},{context:n=!0}={}){if(!t.domain||!t.token)throw new l("Tether is not configured: domain and token are required",{code:"NOT_CONFIGURED"});let o=n?yt(e,t):e;t.maxAge>0&&!/^\s*mutation\b/.test(o)&&(o+=` #${Math.floor(Date.now()/(t.maxAge*1e3))}`);let s=xt(t),c=0;for(;;){let f=B.has(s)?o.replaceAll(T,""):o,u=await Tt(t,f,r,c<t.retries);switch(u.kind){case"data":return u.data;case"inventory-refused":k(`the token can't read inventory: ${T} is left out from now on`),B.add(s);break;case"retry":c+=1,k("retry",c),await Et(u.backoffMs*2**c);break}}}var Xt=(t,e,r)=>wt(i,t,e,r);function Qt(t,e){if(!t)throw new l(`${e}: empty response`);let r=t.userErrors??[];if(r.length)throw new l(r.map(n=>n.message).join(" | "),{userErrors:r});return t}var p=t=>`${i.prefix}-${t}`,St=(t,e)=>e===void 0?`[${p(t)}]`:`[${p(t)}="${e}"]`,$=(t,e)=>t.getAttribute(p(e)),Ct=(t,e)=>t.hasAttribute(p(e));function G(t,e){return t?[...t.querySelectorAll(e)]:[]}var kt=(t,e,r)=>G(t,e).filter(n=>n.closest(r)===t);function N(t,e,r=document){r.dispatchEvent(new CustomEvent(`${i.prefix}:${t}`,{detail:e,bubbles:!0}))}function K(t,{width:e,height:r,crop:n}={}){if(!t)return t;let o;try{o=new URL(t)}catch(s){if(s instanceof TypeError)return t;throw s}return e&&o.searchParams.set("width",String(e)),r&&o.searchParams.set("height",String(r)),n&&o.searchParams.set("crop",n),o.toString()}function v(t,e){return t.getAttribute(e)??t.getAttribute(p(e))??t.getAttribute(`data-${e}`)}function z(t,e){if(!t||!e)return t;let r=v(e,"max-width"),n=v(e,"max-height");return K(t,{width:r,height:n,crop:r||n?v(e,"crop"):null})}var J=(t,e)=>!!(t&&e)&&t?.split("?")[0]===e?.split("?")[0];function Ot(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 $t(t,e,r){if(!e)return;let n=z(e,t);if(t.tagName!=="IMG"){t.style.backgroundImage=Ot(n);return}if(J(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 I=new WeakMap,Nt=t=>!!I.get(t),P=t=>t.cloneNode(!0);function q(t){let e=I.get(t);if(e!==void 0)return e;let r=t.firstElementChild,n=r?P(r):null;return I.set(t,n),t.replaceChildren(),n}function vt(t,e,r){let n=q(t);if(!n){e.length&&d("repeater without a template child",t);return}t.replaceChildren(),e.forEach((o,s)=>{let c=P(n);r(c,o,s),t.appendChild(c)})}function It(t,e){let r=()=>{t.remove()};if(!e){r();return}try{e(t,r)}catch(n){h(n,"repeater onLeave"),r()}}function Pt(t,e,r,n){e.forEach((o,s)=>{if(!r.has(o))return;let c=e[s-1];if(c?.parentNode===t?c.after(o):t.prepend(o),!!n)try{n(o)}catch(f){h(f,"repeater onEnter")}})}function Lt(t,e,r,n,{onEnter:o,onLeave:s}={}){let c=q(t);if(!c){d("repeater without a template child",t);return}let f=`data-${i.prefix}-key`,u=`data-${i.prefix}-leaving`,_=()=>[...t.children].filter(a=>a.hasAttribute(f)&&!a.hasAttribute(u)),y=new Map(_().map(a=>[a.getAttribute(f),a])),A=[],x=new Set;e.forEach((a,E)=>{let C=String(r(a,E)),m=y.get(C);m?y.delete(C):(m=P(c),m.setAttribute(f,C),x.add(m)),n(m,a,E,x.has(m)),A.push(m)});let S=A.filter(a=>!x.has(a)),M=_().filter(a=>S.includes(a));if(!(M.length===S.length&&M.every((a,E)=>a===S[E]))){y.forEach(a=>{a.remove()}),A.forEach(a=>t.appendChild(a));return}Pt(t,A,x,o),y.forEach(a=>{a.setAttribute(u,""),a.removeAttribute(f),a.style.pointerEvents="none",a.inert=!0,It(a,s)})}var _t=new Set(["SCRIPT","OBJECT","EMBED","BASE","META","LINK","NOSCRIPT","TEMPLATE","ANIMATE","SET"]),Mt=new Set(["href","src","action","formaction","xlink:href","poster","data","background"]),Ut=/^\s*(javascript|vbscript|data):/i,Rt=/^\s*data:image\/(png|gif|jpeg|webp|avif);/i,Ft=/[- ]/g;function Dt(t,e){let r=e.name.toLowerCase();if(r.startsWith("on")||r==="srcdoc")return!0;let n=e.value.replace(Ft,"");return!Mt.has(r)||!Ut.test(n)?!1:!(t.tagName==="IMG"&&r==="src"&&Rt.test(n))}function jt(t){for(let e of[...t.querySelectorAll("*")]){if(_t.has(e.tagName.toUpperCase())){e.remove();continue}for(let r of[...e.attributes])Dt(e,r)&&e.removeAttribute(r.name)}}function W(t,e=globalThis.document){let r=e.createElement("template");return r.innerHTML=t??"",jt(r.content),r.content}var Y="data-tether-seen",L="data-tether-shown",w="data-tether-prev-display",Ht=120;function pe(t,e){return R(i.productPath||"/product",t,e)}function tt(t,e){try{return t()}catch(r){if(r instanceof RangeError)return e;throw r}}function de(t,e=i.locale){return t?tt(()=>new Intl.NumberFormat(e||void 0,{style:"percent",maximumFractionDigits:0}).format(t/100),`${t}%`):""}function me(t){return t?i.formatMoney?i.formatMoney(t,i.locale):U(t,i.locale):""}function ge(t){return t?tt(()=>new Date(t).toLocaleDateString(i.locale||void 0),""):""}function he(t,e){t.replaceChildren(W(e,t.ownerDocument))}var et=t=>t.tagName==="INPUT"||t.tagName==="TEXTAREA",Z=t=>t.tagName==="INPUT";function Vt(t,e){let r=e==null?"":String(e);et(t)?t.value=r:t.textContent=r}var X=t=>et(t)?t.value:t.textContent;function ye(t,e){let r=X(t);if(Vt(t,e),r!==X(t)&&t.hasAttribute(Y)&&i.onValueChange)try{i.onValueChange(t,r)}catch(n){h(n,"onValueChange")}t.setAttribute(Y,"1")}function Bt(t){if(t.hasAttribute(L))return;t.setAttribute(L,""),t.removeAttribute("hidden");let e=t.getAttribute(w);e!==null?(t.style.display=e,t.removeAttribute(w)):t.style.display==="none"&&(t.style.display=""),typeof getComputedStyle=="function"&&getComputedStyle(t).display==="none"&&(t.style.display=t.getAttribute(p("display"))||"block")}function Ae(t,e){if(e){Bt(t);return}t.removeAttribute(L),!t.hasAttribute(w)&&t.style.display!=="none"&&t.setAttribute(w,t.style.display),t.style.display="none"}function xe(t,e){t.classList.toggle("is-selected",e),t.setAttribute("aria-pressed",e?"true":"false"),Z(t)&&(t.type==="radio"||t.type==="checkbox")&&(t.checked=e);let r=t.querySelector('input[type="radio"],input[type="checkbox"]');r&&Z(r)&&(r.checked=e)}var Q;function Gt(t){clearTimeout(Q),Q=setTimeout(()=>{let{ScrollTrigger:e}=window;i.onLayoutChange?i.onLayoutChange(t):e?.refresh?.(),N("layout-changed",{reason:t})},Ht)}function Ee(t,e){let r=[...t.querySelectorAll("img")].filter(s=>!s.complete),n=r.length,o=()=>{n-=1,n===0&&Gt(`${e}:images`)};r.forEach(s=>{s.addEventListener("load",o,{once:!0}),s.addEventListener("error",o,{once:!0})})}function be(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 Te(t,e){let r=t?$(t,e):null;if(!r)return null;try{return JSON.parse(r)}catch{return d(`invalid JSON in ${p(e)}`,t),null}}function we(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{b as a,i as b,ct as c,lt as d,zt as e,Jt as f,k as g,d as h,h as i,D as j,j as k,l,ht as m,yt as n,wt as o,Xt as p,Qt as q,p as r,St as s,$ as t,Ct as u,G as v,kt as w,N as x,K as y,J as z,$t as A,Nt as B,vt as C,Lt as D,pe as E,de as F,me as G,ge as H,he as I,Vt as J,ye as K,Ae as L,xe as M,Gt as N,Ee as O,be as P,Te as Q,we as R};
@@ -0,0 +1,14 @@
1
+ import{a as m,d as P}from"./chunk-FCSWQDVV.js";import{a as v}from"./chunk-VT4CDUJJ.js";import{c as R}from"./chunk-NEHZ37TU.js";import{e as S}from"./chunk-JOOEXYF3.js";import{B as k,b as i,f as $,m as E,p as w,r as p,s as l,t as f,v as d}from"./chunk-YJLWX2HK.js";import"./chunk-FOMSMIAM.js";var V=/^(\d{4})-(01|04|07|10)$/;function T(e){let n=V.exec(typeof e=="string"?e:"");return n?{year:Number(n[1]),month:Number(n[2])}:null}var q=(e,n)=>`${e}-${String(n).padStart(2,"0")}`;function A(e,n=1){let t=T(e);if(!t)throw new Error(`not a quarterly Shopify API version: ${e}`);let o=t.year*4+(t.month-1)/3+n;return q(Math.floor(o/4),o%4*3+1)}function _(e,n=new Date){if(e==="unstable")return{version:e,ok:!1,note:'"unstable" changes without notice: pin a dated version such as 2026-07'};let t=T(e);if(!t)return{version:e,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)),s=(r.getTime()-n.getTime())/2630016e3,a=o<=n,c=`supported until about ${r.toISOString().slice(0,7)}`;return a?s<=0?c="no longer supported: Shopify falls back to the oldest supported version. Upgrade (see README)":s<3&&(c=`${c}: plan the upgrade to ${A(e)} or later (see README)`):c="not released yet (release candidate at best)",{version:e,ok:a&&s>0,monthsLeft:Math.round(s),next:A(e),note:c}}var M=new Set(["in-stock","out-of-stock","backorder","low-stock","plenty-in-stock","on-sale","not-on-sale","has-variants","single-variant","subscription-available","subscription-unavailable","subscription-only","one-time-available","subscription-selected","one-time-selected","has-savings","loading","ready","error","not-found","cart-empty","cart-filled","cart-has-subscription","cart-no-subscription","cart-has-discount","cart-error","cart-warning","list-empty","list-filled","search-empty","search-results","logged-in","logged-out","orders-empty","orders-loading","addresses-loading","addresses-empty","addresses-error","subscriptions-loading","subscriptions-empty","subscriptions-error"]),N=new Set(["title","description","description-text","vendor","type","handle","published-at","price","total-price","compare-at-price","unit-price","min-price","max-price","discount-percentage","discount-amount","variant-title","variant-id","sku","barcode","stock","quantity","featured-image","variant-image","images","tags","link","url","one-time-price","subscription-price","subscription-savings","subscription-savings-amount","checkout-charge","plan-name","plan-description","plan-group","option-value","swatch","image"]),D=new Set(`account account-bind account-link account-login account-logout add-label add-to-cart adding-text
2
+ always-enabled bind cart-checkout-charge cart-clear cart-close cart-count cart-discounts cart-drawer cart-label cart-lines
3
+ cart-note cart-open cart-subtotal cart-total cart-warning checkout code collection collection-bind countries country
4
+ country-bind country-label country-select default-plan default-purchase discount discount-code discount-form discount-input
5
+ discount-remove display error group group-add hide-single language limit line line-attribute line-attributes line-id
6
+ line-minus line-plan line-plus line-remove line-show list load-more market-pending one-time-label option option-list
7
+ option-selected option-value order order-bind order-line order-lines order-line-show order-show order-state order-fulfillments
8
+ fulfillment-bind order-return return-quantity return-reason return-note orders profile-form address-form addresses address-bind
9
+ address-show address-edit address-new address-delete address-default subscriptions subscription-bind subscription-lines
10
+ subscription-line subscription-show subscription-action subscription-status subscription-state confirm form-state form-error page-country page-language page-locale page-title plan plan-bind plan-list
11
+ plan-value product products purchase purchase-mode qty qty-minus qty-plus quantity recommendations reverse search
12
+ search-bind search-collections search-input search-limit search-min search-products search-queries search-results
13
+ search-state show soldout-text sort state subscribe-text variant variant-select variant-url max-width max-height crop
14
+ sig label hydrated busy`.split(/\s+/).filter(Boolean)),C=["bind","option-list","option","variant-select","add-to-cart","purchase","plan-list","plan","qty","line-attribute"],H=["option-list","plan-list","cart-lines","list"],b="metafield:",Y=/^image:\d+$/,G=2;function B(e,n){let t=Array.from({length:n.length+1},(o,r)=>r);for(let o=1;o<=e.length;o++){let r=[o];for(let s=1;s<=n.length;s++){let a=(t[s-1]??0)+(e[o-1]===n[s-1]?0:1);r.push(Math.min((t[s]??0)+1,(r[s-1]??0)+1,a))}t=r}return t[n.length]??0}function g(e,n,t=""){let o=null,r=1/0;for(let a of n){let c=B(e,a);c<r&&(r=c,o=a)}let s=Math.max(2,Math.floor(e.length/4));return o!==null&&r<=s?` Did you mean "${t}${o}"?`:""}function L(e){let n=e.id?`#${e.id}`:"",t=e.className&&typeof e.className=="string"?e.className.trim().split(/\s+/):[],o=t.length?`.${t.slice(0,G).join(".")}`:"";return`<${e.tagName.toLowerCase()}${n}${o}>`}var x=()=>`${l("collection")},${l("products")},${l("recommendations")}`;function Q(e,n){d(e,l("product")).forEach(t=>{if(t.closest(x())&&t.closest(l("list")))return;let{key:o,fromUrl:r,raw:s}=m(t);s?r&&!o&&n("warn",`${p("product")}="${s}" but this URL has no value for it (e.g. ?handle=my-product).`,t):n("error",`${p("product")} has no value. Bind it to the Shopify handle (CMS field), or use "url:handle".`,t)})}function W(e,n){for(let t of C)d(e,l(t)).forEach(o=>{o.closest(l("product"))||t==="line-attribute"&&o.closest(l("group"))||n("warn",`${p(t)} outside any ${p("product")}: it does nothing here.`,o)});d(e,l("group-add")).forEach(t=>{t.closest(l("group"))||n("warn",`${p("group-add")} outside a ${p("group")}.`,t)});for(let t of H)d(e,l(t)).forEach(o=>{!o.firstElementChild&&!k(o)&&n("warn",`${p(t)} without a template child: put one example element inside it.`,o)});d(e,x()).forEach(t=>{d(t,l("list")).length||n("error",`List without a ${p("list")} child: products have nowhere to render.`,t)})}function j(e,n){d(e,l("show")).forEach(t=>{let o=f(t,"show")??"";M.has(o)||n("warn",`Unknown ${p("show")}="${o}".${g(o,M)}`,t)}),d(e,l("bind")).forEach(t=>{let o=f(t,"bind")||"";!o||N.has(o)||Y.test(o)||o.startsWith(b)||n("warn",`Unknown ${p("bind")}="${o}": it stays empty.${g(o,N)}`,t)})}function K(e,n){d(e,l("bind")).forEach(t=>{let o=f(t,"bind")||"";if(!o.startsWith(b))return;let r=o.slice(b.length);i.metafields.some(a=>(typeof a=="string"?a:`${a.namespace}.${a.key}`)===r)||n("error",`${p("bind")}="${o}" but "${r}" is not in config.metafields, so it stays empty.`,t)})}function F(e,n){let t=`${i.prefix}-`,o=new Set;d(e,"*").forEach(r=>{for(let{name:s}of r.attributes){if(!s.startsWith(t))continue;let a=s.slice(t.length);D.has(a)||o.has(a)||(o.add(a),n("warn",`Unknown attribute ${s}: Tether ignores it.${g(a,D,t)}`,r))}})}function z(e,n){let t=d(e,l("cart-drawer")).length;d(e,l("cart-open")).length&&!t&&n("warn",`${p("cart-open")} exists but there is no ${p("cart-drawer")} on this page.`),t>1&&n("warn",`More than one ${p("cart-drawer")}.`),d(e,`[${p("state")}="error"]`).forEach(o=>{o.matches(P())&&n("error",`Scope failed to load (${f(o,"error")||"error"}).`,o)})}function U(e=document){let n=[],t=(o,r,s)=>{n.push(s?{level:o,message:r,element:L(s),el:s}:{level:o,message:r})};return Q(e,t),W(e,t),j(e,t),F(e,t),K(e,t),z(e,t),n}var J=20,X=3,O=4;function Z(e){return e?`${e.slice(0,O)}\u2026${e.slice(-O)} (${e.length} chars)`:"(missing)"}function I(e,n){if(e instanceof Error&&e.message)return e.message;let t=typeof e=="object"&&e!==null?Reflect.get(e,"code"):void 0;return typeof t=="string"&&t?t:n}function ee(){return{domain:i.domain||"(missing)",token:Z(i.token),apiVersion:i.apiVersion,endpoint:i.domain?E():null,country:i.country,language:i.language,locale:i.locale,markets:i.markets,prefix:i.prefix,productPath:i.productPath,metafields:i.metafields,autoMount:i.autoMount,observe:i.observe,onError:typeof i.onError=="function"}}async function te(){return{country:i.country||null,language:i.language||null,locale:i.locale||null,detected:i.markets?.detect?(await v("markets")).detectMarket(i.markets):null}}function ne({ok:e,monthsLeft:n,note:t}){return e&&(n===void 0||n>=X)?null:{level:e?"warn":"error",message:`apiVersion ${i.apiVersion}: ${t}`}}async function oe(){if(!$())return{kind:"not-configured"};let e=Date.now();try{let n=await w("query TetherDiagnose { shop { name primaryDomain { url } paymentSettings { currencyCode } } }",{},{context:!1});return{kind:"reachable",shop:{name:n.shop.name,url:n.shop.primaryDomain.url,currency:n.shop.paymentSettings.currencyCode},latencyMs:Date.now()-e}}catch(n){return{kind:"unreachable",error:n,latencyMs:Date.now()-e}}}function se(e,n,t){let o=[],r=t.options.map(a=>a.name),s=d(e,l("product")).filter(a=>m(a).key===n&&a.querySelector(l("add-to-cart")));for(let a of s){let c=new Set(d(a,`${l("option-list")},select${l("option")}`).map(u=>f(u,"option-list")||f(u,"option")));if(!(!c.size&&d(a,`select${l("variant-select")}`).length)){if(!i.language)for(let u of c)!u||r.includes(u)||o.push({level:"warn",message:`Product "${t.handle}" has no option "${u}" (its options: ${r.join(", ")||"none"}).${g(u,r)}`});for(let u of t.options)u.optionValues.length<=1||c.has(u.name)||o.push({level:"warn",message:`Product "${t.handle}": option "${u.name}" (${u.optionValues.length} values) has no tether-option-list, so visitors can't choose it.`})}}return o}async function re(e,n){let t=d(e,l("product")).map(s=>m(s).key),o=[...new Set(t.filter(s=>s!==null&&s!==""))].slice(0,J);(await Promise.allSettled(o.map(s=>R(s)))).forEach((s,a)=>{let c=o[a]??"";if(s.status==="rejected"){let h=I(s.reason,"not loaded");n.products.push({key:c,error:s.reason instanceof Error?s.reason.message:void 0}),n.problems.push({level:"error",message:`Product "${c}": ${h}. Is it published to the Headless channel?`});return}let u=s.value,y=S(u);n.products.push({key:c,handle:u.handle,title:u.title,plans:y.length,requiresSellingPlan:u.requiresSellingPlan});for(let h of y)n.sellingPlans.push({product:u.handle,group:h.group.name,plan:h.name,id:h.id});n.problems.push(...se(e,c,u))})}async function we({root:e=document,silent:n=!1,version:t,now:o=new Date}={}){let r=await oe(),s={version:t,config:ee(),apiVersion:_(i.apiVersion,o),market:await te(),reachable:r.kind==="reachable",shop:r.kind==="reachable"?r.shop:null,latencyMs:r.kind==="not-configured"?null:r.latencyMs,products:[],sellingPlans:[],problems:[]};switch(r.kind){case"not-configured":s.problems.push({level:"error",message:"TETHER_CONFIG needs domain and token."});break;case"unreachable":s.problems.push({level:"error",message:`Storefront API not reachable: ${I(r.error,"unknown error")}`});break;case"reachable":await re(e,s);break}let a=ne(s.apiVersion);return a&&s.problems.push(a),typeof document<"u"&&s.problems.push(...U(e)),n||ae(s),s}function ae(e){let n=e.problems.filter(c=>c.level==="error").length,t=e.problems.length-n;console.group(`[${i.prefix}] diagnose: ${n?`${n} error(s)`:"no errors"}, ${t} warning(s)`),console.log("version",e.version,"| API",e.apiVersion.version,`(${e.apiVersion.note})`),console.log("config",e.config);let{country:o,language:r,detected:s}=e.market,a=[o,r].filter(Boolean).join(" / ")||"the store default";console.log("market",`in use: ${a}`,s?`(detection picks ${JSON.stringify(s)})`:""),console.log(e.shop?`Storefront API reachable: ${e.shop.name} (${e.latencyMs??0} ms)`:"Storefront API NOT reachable"),e.products.length&&console.table(e.products),e.sellingPlans.length?console.table(e.sellingPlans):e.reachable&&console.log("No selling plans on the products of this page.");for(let c of e.problems)c.level==="error"?console.error(c.message,c.el??""):console.warn(c.message,c.el??"");console.groupEnd()}export{_ as apiVersionStatus,U as checkMarkup,we as diagnose,g as didYouMean};
@@ -0,0 +1 @@
1
+ import{a as b}from"./chunk-2FSXS55U.js";import"./chunk-HEQILZVR.js";import"./chunk-FCSWQDVV.js";import{b as p}from"./chunk-MPTQYLSM.js";import"./chunk-NEHZ37TU.js";import"./chunk-JOOEXYF3.js";import{Q as h,R as w,b as s,h as f,i,s as c,t as g,u as d,v as y,x as m}from"./chunk-YJLWX2HK.js";import"./chunk-FOMSMIAM.js";function x(t,r){let e=w(h(t,"line-attributes"));return r?[{key:"_group",value:r},...e]:e}async function V(t){let r=t.closest(c("group"));if(!r)return null;let e=g(r,"group"),a=x(r,e),n=y(r,c("product")).flatMap(u=>{let o=b.get(u);if(!o?.variant?.availableForSale||o.quantity<=0)return[];let l=o.getLine();return l?[{...l,attributes:[...l.attributes??[],...a]}]:[]});if(!n.length)return f("group-add: nothing selected"),null;try{let u=await p.add(n);return m("group-added",{group:e,lines:n},r),u}catch(u){return i(u,"group add"),null}}function $(t){let r;try{r=JSON.parse(t)}catch{return null}if(typeof r!="object"||r===null)return null;let{country:e,language:a,locale:n}=r;return typeof e!="string"||!e?null:{country:e,language:typeof a=="string"?a:null,locale:typeof n=="string"?n:void 0}}function _(t){if(t.key===s.storageKey||t.key===`${s.storageKey}:seen`){p.init().catch(n=>{i(n,"cart from another tab")});return}if(t.key!==`${s.prefix}:market:${s.domain}`||!t.newValue)return;let r=$(t.newValue),{Tether:e}=window;if(!r||!e)return;let a={language:r.language,locale:r.locale,remember:!1};e.setCountry(r.country,a).catch(n=>{i(n,"market from another tab")})}var k=new WeakMap,S=t=>t.split("/").pop()??t;function A(t){try{window.history.replaceState(window.history.state,"",t)}catch{}}function v(t,{variant:r,sellingPlanId:e}){let a=`${r.id}|${e??""}`,n=k.get(t);if(k.set(t,a),!n||n===a)return;let u=s.variantUrl&&document.querySelector(c("product"))===t;if(!d(t,"variant-url")&&!u)return;let o=new URL(window.location.href);o.searchParams.set("variant",S(r.id)),e?o.searchParams.set("selling_plan",S(e)):o.searchParams.delete("selling_plan"),A(o)}export{V as addGroup,_ as onStorage,v as writeVariantUrl};
@@ -0,0 +1 @@
1
+ import{b as T,c as P,d as F,e as h}from"./chunk-27PJJZGC.js";import{a as E,c as w,e as x,f as A,g as U,h as y,i as I}from"./chunk-V74KGEJF.js";import"./chunk-2FSXS55U.js";import"./chunk-HEQILZVR.js";import"./chunk-FCSWQDVV.js";import{b as l}from"./chunk-MPTQYLSM.js";import{d as v}from"./chunk-NEHZ37TU.js";import"./chunk-JOOEXYF3.js";import{b as c,i as f,j as m,k as g,l as C,r as s,s as p,t as b,x as L}from"./chunk-YJLWX2HK.js";import"./chunk-FOMSMIAM.js";var _="{name} ({currency})",j="name";function B(e,t){switch(t){case"name":return e.name;case"code":return e.isoCode;case"currency":return e.currency.isoCode;case"symbol":return e.currency.symbol;default:return""}}var M=(e,t)=>e.replace(/\{(name|code|currency|symbol)\}/g,(o,a)=>B(t,a));function O(e,t,o){let a=e.getAttribute(s("country-label"))||_,r=(e.getAttribute(s("countries"))||"").toUpperCase().split(/[\s,]+/).filter(Boolean),i=r.length?r.map(n=>t.find(u=>u.isoCode===n)).filter(n=>n!==void 0):t;e.replaceChildren(...i.map(n=>new Option(M(a,n),n.isoCode))),e.value=o,e.value!==o&&(e.selectedIndex=-1),e.disabled=i.length<2&&!e.hasAttribute(s("always-enabled"))}function S(e,t,o){let a=(c.country||o.country.isoCode).toUpperCase(),r=[...o.availableCountries].sort((n,u)=>n.name.localeCompare(u.name,c.locale||void 0)),i=r.find(n=>n.isoCode===a)??o.country;e.forEach(n=>{O(n,r,a)}),t.forEach(n=>{n.textContent=B(i,b(n,"country-bind")||j)})}function k(e=document){let t=y(e,`select${p("country-select")}`),o=y(e,p("country-bind"));return!t.length&&!o.length?Promise.resolve():h().then(a=>{S(t,o,a)}).catch(a=>{f(a,"country select")})}var $=e=>Object.values(c.markets?.locales??{}).find(t=>m(t.country)===e);function z(e,t){return e!==void 0?g(e):t?t.language?g(t.language):void 0:c.language}function R(e){v();let t=[];return l.id()&&t.push(l.setBuyerIdentity({countryCode:e},{create:!1}).catch(o=>{f(o,"cart country")})),U(),A.forEach(o=>t.push(o.load())),x.forEach(o=>{o.closest(E())||(w.delete(o),I(o))}),t}async function X(e,{language:t,locale:o,remember:a=!0}={}){let r=m(e);if(!r)throw new C(`Not a country code: ${e}`,{code:"INVALID_COUNTRY"});let i=$(r),n=o||i?.locale,u=n||c.locale,d=z(t,i),D=r!==c.country?.toUpperCase()||d!==c.language||u!==c.locale;if(c.country=r,c.language=d||void 0,c.locale=u,a&&P({country:r,language:d,locale:n}),!D)return k(),l.state;t!==void 0&&F();let N=R(r);return k(),L("country-changed",{country:r,language:c.language}),await Promise.all(N),l.state}export{T as detectMarket,h as getLocalization,k as renderCountrySelects,X as setCountry};
@@ -0,0 +1 @@
1
+ import{h as C}from"./chunk-V74KGEJF.js";import"./chunk-2FSXS55U.js";import"./chunk-HEQILZVR.js";import"./chunk-FCSWQDVV.js";import"./chunk-MPTQYLSM.js";import"./chunk-NEHZ37TU.js";import"./chunk-JOOEXYF3.js";import{A as E,C as S,E as L,G as T,J as q,L as d,b as l,g,i as b,p as A,r as y,s as h,t as u,v as c,x as w}from"./chunk-YJLWX2HK.js";import"./chunk-FOMSMIAM.js";var R="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}}}",v=6,D=2,F="/search",I=new WeakSet,x=0;function $(r,t,e){return parseInt(u(r,t)||"",10)||e}var k=r=>r.tagName==="A"?r:r.querySelector("a");function f(r,t){c(r,h("search-bind")).forEach(e=>{let i=u(e,"search-bind");i==="image"?E(e,t.image?.url,t.image?.altText||t.title):(i==="title"||i==="price"||i==="text")&&t[i]!=null&&q(e,t[i])})}function U(r,t){let e=k(r);e&&(e.setAttribute("href",t),e.setAttribute("role","option"))}var p=class{constructor(t,e,i){this.root=t,this.input=e,this.results=i,this.limit=$(t,"search-limit",v),this.minCharacters=$(t,"search-min",D),i.id||(x+=1,i.id=`${l.prefix}-search-${x}`),this.resultsId=i.id,this.searchNumber=0,this.timer=void 0,this.lastTerm="",this.cache=new Map,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),l.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(y("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 c(this.results,'[role="option"]')}async fetchResults(t){let e=this.cache.get(t);if(e)return e;let i=await A(R,{q:t,limit:this.limit});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){g("a superseded search failed",i);return}this.setState("error"),b(i,"search")}}fillList(t,e,i){c(this.results,h(t)).forEach(n=>{S(n,e,i),d(n,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??[],n=t?.collections??[],o=(t?.queries??[]).filter(a=>a.text.toLowerCase()!==e.toLowerCase());this.fillList("search-products",i,(a,s)=>{let N=T(s.priceRange.minVariantPrice);f(a,{title:s.title,price:N,image:s.featuredImage}),U(a,L(s.handle,s.id)),a.classList.toggle("is-sold-out",!s.availableForSale)}),this.fillList("search-collections",n,(a,s)=>{f(a,{title:s.title,image:s.image}),U(a,`${(l.collectionPath||"/collection").replace(/\/$/,"")}/${s.handle}`)}),this.fillList("search-queries",o,(a,s)=>{f(a,{text:s.text}),k(a)?.setAttribute("href",this.queryUrl(s.text))});let m=i.length+n.length+o.length;this.showCount(m),this.setState(m?"ready":"empty"),this.open(!0),w("search",{term:e,products:i,collections:n,queries:o},this.root)}showCount(t){c(this.root,h("show")).forEach(e=>{let i=u(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((n,o)=>{n.setAttribute("aria-selected",String(o===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(n=>n.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 _(r=document){for(let t of C(r,h("search"))){if(I.has(t))continue;I.add(t);let e=t.querySelector(h("search-input"))??t.querySelector("input"),i=t.querySelector(h("search-results"));e&&i&&new p(t,e,i)}}export{_ as mountSearch};
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- import{a as j,b as W,d as x,f as C,g as Z,h as g,i as X,j as Y,k as ee,l as te,m as ne}from"./chunks/chunk-VCPI7MJ2.js";import{a as V}from"./chunks/chunk-ZIUIWEON.js";import{a as Q}from"./chunks/chunk-RREHGH4A.js";import{a as l,b as re}from"./chunks/chunk-VPVJPNB4.js";import{a as J,b as c}from"./chunks/chunk-L2TRRKYV.js";import{a as _,b as q,c as R,d as F,h as G,i as B}from"./chunks/chunk-FIOZPPC5.js";import{l as K}from"./chunks/chunk-AJLPU2JC.js";import{K as h,b as r,c as P,d as L,e as $,f as D,g as u,h as M,j as N,l as U,n as p,o as a,u as k,w as H,y as z}from"./chunks/chunk-K2YEQAIH.js";import"./chunks/chunk-VC46IEJQ.js";var oe="0.6.6",f=null,S=null;function m(t=document){if(!L())return 0;let e=0;return Z(),ne(t),g(t,j()).forEach(n=>{if(x.has(n))return;x.add(n),e++;let o=new W(n);C.add(o),n.addEventListener(`${r.prefix}:list-rendered`,i=>m(i.detail.container)),ee(o.load())}),g(t,a("product")).forEach(n=>{X(n)&&e++}),g(t,`${a("country-select")},${a("country-bind")}`).length&&l("markets").then(n=>n.renderCountrySelects(t)).catch(n=>u(n,"markets")),(r.account?.clientId||r.account?.server)&&(g(t,["account-login","account-bind","account-link","orders","order","addresses","subscriptions","profile-form","address-form"].map(n=>`[${p(n)}]`).join(",")+`,[${p("show")}^="logged-"]`).length||/[?&]code=/.test(window.location.search)||ge())&&l("account").then(n=>n.mountAccount(t)).catch(n=>u(n,"account")),g(t,a("search")).length&&l("search").then(n=>n.mountSearch(t)).catch(n=>u(n,"search")),te(),c.render(),$(`mounted ${e} scope(s)`,t),e}function ie(){c.close()}function fe(t){let e=t?.closest?.(a("product"));return e&&V.get(e)||null}var ae=!1;function me(){ae||(ae=!0,document.addEventListener("click",t=>{let e=t.target;if(!e?.closest)return;if(e.closest(a("cart-open"))){t.preventDefault(),c.toggle();return}if(e.closest(a("cart-close"))){t.preventDefault(),c.close();return}let n=e.closest(a("cart-clear"));if(n){t.preventDefault(),h(n,()=>c.clear().catch(d=>u(d,"cart clear")));return}let o=e.closest(a("checkout"));if(o){t.preventDefault(),h(o,()=>c.checkout());return}let i=e.closest(ce());if(i&&i.closest(a("cart-lines"))){let d=i.getAttribute(`data-${r.prefix}-key`),E=c.lines.find(w=>w.id===d),b=w=>{t.preventDefault(),w().catch(de=>u(de,"cart line"))};if(e.closest(a("line-remove")))return i.classList.add("is-busy"),b(()=>c.removeLine(d));if(E&&e.closest(a("line-plus")))return b(()=>c.changeQuantity(d,1));if(E&&e.closest(a("line-minus")))return b(()=>c.changeQuantity(d,-1))}let s=e.closest(a("discount-remove"));if(s){t.preventDefault();let d=s.closest(a("discount-code"))?.getAttribute(p("discount-code"));d&&c.removeDiscount(d).catch(E=>u(E,"discount"));return}let y=e.closest(a("group-add"));y&&(t.preventDefault(),h(y,()=>se(y)))}),document.addEventListener("change",t=>{let e=t.target;if(!e?.closest)return;let n=e.closest(ce()),o=n?.getAttribute(`data-${r.prefix}-key`),i=(s,y)=>{n.classList.add("is-busy"),n.setAttribute("aria-busy","true"),s.catch(d=>u(d,y))};o&&e.matches(`input${a("line","quantity")}`)?i(c.updateLine(o,parseInt(e.value,10)||0),"cart line"):o&&e.matches(`select${a("line-plan")}`)?i(c.updateLine(o,{sellingPlanId:e.value||null}),"cart line plan"):e.matches(`select${a("country-select")}`)?e.value&&I(e.value).catch(s=>u(s,"country")):e.matches(a("cart-note"))&&c.setNote(e.value).catch(s=>u(s,"cart note"))}),document.addEventListener("submit",t=>{let e=t.target.closest?.(a("discount-form"));if(!e)return;t.preventDefault();let n=e.querySelector(a("discount-input"))||e.querySelector("input"),o=n?.value.trim();o&&h(e,async()=>{let i=s=>{e.classList.toggle("is-invalid",s),n&&(s?n.setAttribute("aria-invalid","true"):n.removeAttribute("aria-invalid"))};try{await c.applyDiscount(o),i(!1),k("discount-applied",{code:o},e),n&&(n.value="")}catch(s){i(!0),s?.code==="INVALID_DISCOUNT"?k("discount-invalid",{code:o},e):u(s,"discount")}})},!0),document.addEventListener("input",t=>{let e=t.target.closest?.(a("discount-form"));e&&(e.classList.remove("is-invalid"),t.target.removeAttribute?.("aria-invalid"))}),window.addEventListener("storage",t=>{r.domain&&t.key?.startsWith(`${r.prefix}:`)&&l("extras").then(e=>e.onStorage(t)).catch(()=>{})}),document.addEventListener(`${r.prefix}:variant-changed`,t=>{let e=t.target;(r.variantUrl||e.hasAttribute?.(p("variant-url")))&&l("extras").then(n=>n.writeVariantUrl(e,t.detail)).catch(()=>{})}),r.astro!==!1&&(document.addEventListener("astro:page-load",()=>(f||Promise.resolve()).then(()=>{let t=T();if(!t&&A){try{t=JSON.parse(localStorage.getItem(`${r.prefix}:market:${r.domain}`)||"null")}catch{t=null}t=t?.country?t:le}A=!!T(),t?.country&&(String(t.country).toUpperCase()!==String(r.country||"").toUpperCase()||String(t.language||"").toUpperCase()!==String(r.language||"").toUpperCase())?I(t.country,{language:t.language??null,locale:t.locale,remember:!1}).then(()=>m(document),()=>m(document)):m(document)})),document.addEventListener("astro:before-swap",()=>ie())),window.addEventListener("online",()=>{Y(),C.forEach(t=>{t.root.getAttribute(p("state"))==="error"&&t.load()})}),document.addEventListener("keydown",t=>{if(!c.isOpen())return;if(t.key==="Escape"){c.close();return}if(t.key!=="Tab"||r.cartFocus===!1)return;let e=c.drawers().find(s=>s.classList.contains(r.cartDrawerOpenClass)),n=e?J(e):[];if(!n.length)return;let o=n[0],i=n[n.length-1];(!e.contains(document.activeElement)||t.shiftKey&&document.activeElement===o||!t.shiftKey&&document.activeElement===i)&&(t.preventDefault(),(t.shiftKey?i:o).focus())}))}function ce(){return`[data-${r.prefix}-key]`}var se=t=>l("extras").then(e=>e.addGroup(t)),v=null;function ue(t={}){return f&&!Object.keys(t).length?f:(P({...window.TETHER_CONFIG||{},...t}),L()?(me(),r.observe&&he(),r.analytics&&!v&&(v=[],["product-ready","list-ready","cart-updated","cart-toggled","checkout","search"].forEach(e=>document.addEventListener(`${r.prefix}:${e}`,n=>v.push(n))),document.addEventListener("astro:page-load",()=>v.push(new CustomEvent(`${r.prefix}:page`))),l("analytics").then(e=>e.startAnalytics(v)).catch(e=>u(e,"analytics"))),f=pe(t).then(()=>c.init()).then(async e=>{let n=r.country?String(r.country).toUpperCase():null;if(e&&n&&e.buyerIdentity?.countryCode&&e.buyerIdentity.countryCode!==n)try{e=await c.setBuyerIdentity({countryCode:n},{create:!1})}catch(o){u(o,"cart country")}return k("ready",{cart:e}),O}),f):(D("TETHER_CONFIG is missing domain or token. Tether is idle."),f=Promise.resolve(null),f))}function T(t=document){let e=o=>t.querySelector(`meta[name="${r.prefix}-page-${o}"]`)?.getAttribute("content")||void 0,n=e("country");return n?{country:n.toUpperCase(),language:e("language"),locale:e("locale")}:null}var le=null,A=!1;async function pe(t){let e=r.markets||{};le={country:r.country,language:r.language,locale:r.locale};let n=T();if(A=!!n,n){r.country=n.country,r.language=n.language?n.language.toUpperCase():void 0,n.locale&&(r.locale=n.locale);return}if(e.detect===!1)return;let o=null;if(e.detect)try{o=(await l("markets")).detectMarket(e)}catch(i){u(i,"markets");return}else if(e.remember!==!1){try{o=JSON.parse(localStorage.getItem(`${r.prefix}:market:${r.domain}`)||"null")}catch{}o&&!/^[A-Z]{2}$/.test(o.country||"")&&(o=null)}o&&(o.country&&(r.country=o.country),o.language&&(r.language=o.language),o.locale&&!t.locale&&(r.locale=o.locale),$("market",o))}function ge(){try{return!!(sessionStorage[`${r.prefix}:account:${r.domain}`]||localStorage[`${r.prefix}:account:${r.domain}`]||localStorage[`${r.prefix}:account-hint:${r.domain}`])}catch{return!1}}var ye=new Proxy({},{get:(t,e)=>(...n)=>l("account").then(o=>o[e](...n))});function I(t,e){return l("markets").then(n=>n.setCountry(t,e))}function he(){if(S||typeof MutationObserver>"u")return;let t=null,e=new Set;S=new MutationObserver(n=>{n.forEach(o=>o.addedNodes.forEach(i=>{i.nodeType===1&&e.add(i)})),clearTimeout(t),t=setTimeout(()=>{e.forEach(o=>{o.isConnected&&m(o)}),e.clear()},50)}),S.observe(document.body,{childList:!0,subtree:!0})}var O={VERSION:oe,init:ue,mount:m,unmount:ie,get config(){return r},get ready(){return f||Promise.resolve(null)},query:U,withContext:N,cart:c,getProduct:R,getProducts:G,getRecommendations:B,getScope:fe,addGroup:se,account:ye,primeProduct:q,normalizeProductKey:_,clearProductCache:F,formatMoney:H,imageUrl:z,plans:K,TetherError:M,resolveProductKey:Q,setCountry:I,detectMarket:t=>l("markets").then(e=>e.detectMarket(t||r.markets)),getLocalization:()=>l("markets").then(t=>t.getLocalization()),diagnose:t=>l("diagnose").then(e=>e.diagnose({...t,version:oe})),__core:re,__parts:{},on(t,e){let n=o=>e(o.detail,o);return document.addEventListener(`${r.prefix}:${t}`,n),()=>document.removeEventListener(`${r.prefix}:${t}`,n)}},Pe=O;if(typeof window<"u"&&typeof document<"u"&&(window.Tether=O,window.TETHER_CONFIG&&window.TETHER_CONFIG.autoMount!==!1&&!window.TETHER_INTEGRATION)){let e=()=>ue().then(()=>m(document));document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e,{once:!0}):e()}export{oe as VERSION,se as addGroup,O as api,Pe as default,fe as getScope,ue as init,m as mount,I as setCountry,ie as unmount};
1
+ import{a as k}from"./chunks/chunk-27PJJZGC.js";import{a as J,b as X,d as C,f as b,g as Z,h as p,i as tt,j as et,k as nt,l as rt,m as ot}from"./chunks/chunk-V74KGEJF.js";import{a as Y}from"./chunks/chunk-2FSXS55U.js";import"./chunks/chunk-HEQILZVR.js";import{a as W}from"./chunks/chunk-FCSWQDVV.js";import{a as l,b as it}from"./chunks/chunk-VT4CDUJJ.js";import{a as G,b as c}from"./chunks/chunk-MPTQYLSM.js";import{a as B,b as V,c as K,d as z,h as Q,i as j}from"./chunks/chunk-NEHZ37TU.js";import{l as F}from"./chunks/chunk-JOOEXYF3.js";import{G as U,P as m,b as r,e as D,f as L,g as E,h as O,i as a,j as N,k as _,l as v,n as H,p as R,r as d,s as i,x as g,y as q}from"./chunks/chunk-YJLWX2HK.js";import"./chunks/chunk-FOMSMIAM.js";var at={country:void 0,language:void 0,locale:void 0},x=!1;function ut(){let t=n=>document.querySelector(`meta[name="${r.prefix}-page-${n}"]`)?.getAttribute("content")||void 0,e=N(t("country"));return e?{country:e,language:_(t("language"))??void 0,locale:t("locale")}:null}async function Mt(){let t=r.markets??{};if(t.detect===!1)return null;if(!t.detect)return t.remember===!1?null:k();try{return(await l("markets")).detectMarket(t)}catch(e){return a(e,"markets"),null}}async function st(t){at={country:r.country,language:r.language,locale:r.locale};let e=ut();if(x=e!==null,e){r.country=e.country,r.language=e.language,e.locale&&(r.locale=e.locale);return}let n=await Mt();n&&(n.country&&(r.country=n.country),n.language&&(r.language=n.language),n.locale&&!t.locale&&(r.locale=n.locale),E("market",n))}var ct=(t,e)=>(t??"").toUpperCase()===(e??"").toUpperCase();function lt(){let t=ut(),e=t===null&&x;x=t!==null;let n=t??(e?k()??at:null);return!n?.country||ct(n.country,r.country)&&ct(n.language,r.language)?null:{country:n.country,language:n.language,locale:n.locale}}function y(t,e){return l("markets").then(n=>n.setCountry(t,e))}var Pt=["account-login","account-bind","account-link","orders","order","addresses","subscriptions","profile-form","address-form"],$t=()=>[...Pt.map(t=>`[${d(t)}]`),`[${d("show")}^="logged-"]`].join(",");function Dt(){let t=`${r.prefix}:account:${r.domain}`,e=`${r.prefix}:account-hint:${r.domain}`;try{return!!(sessionStorage.getItem(t)||localStorage.getItem(t)||localStorage.getItem(e))}catch{return!1}}function dt(t){!r.account?.clientId&&!r.account?.server||!(p(t,$t()).length>0||/[?&]code=/.test(window.location.search)||Dt())||l("account").then(n=>n.mountAccount(t)).catch(n=>{a(n,"account")})}function s(t){return(...e)=>l("account").then(n=>{let o=n[t];return o(...e)})}var ft={login:s("login"),logout:s("logout"),handleCallback:s("handleCallback"),getToken:s("getToken"),isLoggedIn:s("isLoggedIn"),query:s("query"),customer:s("customer"),orders:s("orders"),order:s("order"),updateProfile:s("updateProfile"),addresses:s("addresses"),saveAddress:s("saveAddress"),deleteAddress:s("deleteAddress"),subscriptions:s("subscriptions"),subscriptionAction:s("subscriptionAction"),requestReturn:s("requestReturn"),render:s("render"),mountAccount:s("mountAccount")};var mt=()=>`data-${r.prefix}-key`,gt=t=>t instanceof window.Element;function yt(t){let e=t.closest(`[${mt()}]`),n=e?.getAttribute(mt());return e&&n?{line:e,id:n}:null}function w(t,e){t.catch(n=>{a(n,e)})}function Ot(t,e){let n=yt(e);if(!n?.line.closest(i("cart-lines")))return;let{line:o,id:u}=n;if(e.closest(i("line-remove"))){t.preventDefault(),o.classList.add("is-busy"),w(c.removeLine(u),"cart line");return}let $=Nt(e);!$||!c.lines.some(It=>It.id===u)||(t.preventDefault(),w(c.changeQuantity(u,$),"cart line"))}function Nt(t){return t.closest(i("line-plus"))?1:t.closest(i("line-minus"))?-1:0}function _t(t){let{target:e}=t;if(!gt(e))return;if(e.closest(i("cart-open"))){t.preventDefault(),c.toggle();return}if(e.closest(i("cart-close"))){t.preventDefault(),c.close();return}let n=e.closest(i("cart-clear"));if(n){t.preventDefault(),m(n,()=>c.clear().catch(u=>{a(u,"cart clear")}));return}let o=e.closest(i("checkout"));if(o){t.preventDefault(),m(o,()=>c.checkout());return}Ot(t,e)}function pt(t,e,n){t.classList.add("is-busy"),t.setAttribute("aria-busy","true"),w(e,n)}function Ht(t){let{target:e}=t;if(!gt(e))return;let n=yt(e);n&&e instanceof window.HTMLInputElement&&e.matches(i("line","quantity"))?pt(n.line,c.updateLine(n.id,parseInt(e.value,10)||0),"cart line"):n&&e instanceof window.HTMLSelectElement&&e.matches(i("line-plan"))?pt(n.line,c.updateLine(n.id,{sellingPlanId:e.value||null}),"cart line plan"):Rt(e)&&e.matches(i("cart-note"))&&w(c.setNote(e.value),"cart note")}var Rt=t=>t instanceof window.HTMLInputElement||t instanceof window.HTMLTextAreaElement||t instanceof window.HTMLSelectElement;function qt(t){if(c.isOpen()){if(t.key==="Escape"){c.close();return}G(t)}}function ht(){document.addEventListener("click",_t),document.addEventListener("change",Ht),document.addEventListener("keydown",qt)}var A=t=>t instanceof window.Element;function Ut(t){let e=t.querySelector(i("discount-input"))??t.querySelector("input");return e instanceof window.HTMLInputElement?e:null}function Et(t,e,n){t.classList.toggle("is-invalid",n),n?e?.setAttribute("aria-invalid","true"):e?.removeAttribute("aria-invalid")}async function Ft(t,e,n){try{await c.applyDiscount(n),Et(t,e,!1),g("discount-applied",{code:n},t),e&&(e.value="")}catch(o){Et(t,e,!0),o instanceof v&&o.code==="INVALID_DISCOUNT"?g("discount-invalid",{code:n},t):a(o,"discount")}}function Gt(t){let{target:e}=t,n=A(e)?e.closest(i("discount-form")):null;if(!n)return;t.preventDefault();let o=Ut(n),u=o?.value.trim();u&&m(n,()=>Ft(n,o,u))}function Bt(t){let{target:e}=t;if(!A(e))return;let n=e.closest(i("discount-form"));n&&(n.classList.remove("is-invalid"),e.removeAttribute("aria-invalid"))}function Vt(t){let{target:e}=t,n=A(e)?e.closest(i("discount-remove")):null;if(!n)return;t.preventDefault();let o=n.closest(i("discount-code"))?.getAttribute(d("discount-code"));o&&c.removeDiscount(o).catch(u=>{a(u,"discount")})}function vt(){document.addEventListener("submit",Gt,!0),document.addEventListener("input",Bt),document.addEventListener("click",Vt)}var T=t=>l("extras").then(e=>e.addGroup(t)),S=t=>{a(t,"extras")};function Kt(t){let{target:e}=t,n=e instanceof window.Element?e.closest(i("group-add")):null;n&&(t.preventDefault(),m(n,()=>T(n)).catch(S))}function zt(t){!r.domain||!t.key?.startsWith(`${r.prefix}:`)||l("extras").then(e=>{e.onStorage(t)}).catch(S)}function Qt(t){let{target:e}=t;e instanceof window.Element&&(!r.variantUrl&&!e.hasAttribute(d("variant-url"))||l("extras").then(n=>{n.writeVariantUrl(e,t.detail)}).catch(S))}function bt(){document.addEventListener("click",Kt),window.addEventListener("storage",zt),document.addEventListener(`${r.prefix}:variant-changed`,Qt)}var I=null;function wt(){I=document.body}async function jt(t){await t.ready();let e=lt();if(!e){I!==document.body&&t.mount(document);return}try{await y(e.country,{language:e.language??null,locale:e.locale,remember:!1})}catch(n){a(n,"country")}t.mount(document)}function Wt(t){document.addEventListener("astro:page-load",()=>{jt(t)}),document.addEventListener("astro:before-swap",()=>{I=null,t.unmount()})}function Yt(t){let{target:e}=t;!(e instanceof window.HTMLSelectElement)||!e.matches(i("country-select"))||e.value&&y(e.value).catch(n=>{a(n,"country")})}function Jt(){et(),b.forEach(t=>{t.root.getAttribute(d("state"))==="error"&&t.load()})}function Lt(t){r.astro&&Wt(t),document.addEventListener("change",Yt),window.addEventListener("online",Jt)}var kt="0.6.8",Xt=["product-ready","list-ready","cart-updated","cart-toggled","checkout","search"],Zt=50,xt=()=>window,f=null,M=null,At=null,Ct=!1;function te(t){let e=0;return p(t,J()).forEach(n=>{if(C.has(n))return;C.add(n),e++;let o=new X(n);b.add(o),n.addEventListener(`${r.prefix}:list-rendered`,u=>{h(u.detail.container)}),nt(o.load())}),e}function ee(t){p(t,`${i("country-select")},${i("country-bind")}`).length&&l("markets").then(e=>e.renderCountrySelects(t)).catch(e=>{a(e,"markets")}),dt(t),p(t,i("search")).length&&l("search").then(e=>{e.mountSearch(t)}).catch(e=>{a(e,"search")})}function h(t=document){if(!L())return 0;t===document&&wt(),Z(),ot(t.ownerDocument??document);let e=te(t);return p(t,i("product")).forEach(n=>{tt(n)&&e++}),ee(t),rt(),c.render(),E(`mounted ${e} scope(s)`,t),e}function Tt(){c.close()}function ne(t){let e=t?.closest(i("product"));return e?Y.get(e)??null:null}function re(){Ct||(Ct=!0,ht(),vt(),bt(),Lt({ready:()=>f??Promise.resolve(null),mount:h,unmount:Tt}))}function oe(){let t=[];At=t,Xt.forEach(e=>{document.addEventListener(`${r.prefix}:${e}`,n=>t.push(n))}),document.addEventListener("astro:page-load",()=>t.push(new CustomEvent(`${r.prefix}:page`))),l("analytics").then(e=>e.startAnalytics(t)).catch(e=>{a(e,"analytics")})}async function ie(t){let e=r.country?.toUpperCase(),n=t?.buyerIdentity.countryCode;if(!t||!e||!n||n===e)return t;try{return await c.setBuyerIdentity({countryCode:e},{create:!1})}catch(o){return a(o,"cart country"),t}}function St(t={}){return f&&!Object.keys(t).length?f:(D({...xt().TETHER_CONFIG,...t}),L()?(re(),r.observe&&ce(),r.analytics&&!At&&oe(),f=st(t).then(()=>c.init()).then(ie).then(e=>(g("ready",{cart:e}),P)),f):(O("TETHER_CONFIG is missing domain or token. Tether is idle."),f=Promise.resolve(null),f))}function ce(){if(M||typeof MutationObserver>"u")return;let t,e=new Set;M=new MutationObserver(n=>{n.forEach(o=>{o.addedNodes.forEach(u=>{u instanceof window.Element&&e.add(u)})}),clearTimeout(t),t=setTimeout(()=>{e.forEach(o=>{o.isConnected&&h(o)}),e.clear()},Zt)}),M.observe(document.body,{childList:!0,subtree:!0})}var ae=t=>l("markets").then(e=>e.detectMarket(t??r.markets)),ue=()=>l("markets").then(t=>t.getLocalization()),se=t=>l("diagnose").then(e=>e.diagnose({...t,version:kt}));function le(t,e){let n=o=>{let u=o;e(u.detail,u)};return document.addEventListener(`${r.prefix}:${t}`,n),()=>{document.removeEventListener(`${r.prefix}:${t}`,n)}}var P={VERSION:kt,init:St,mount:h,unmount:Tt,get config(){return r},get ready(){return f??Promise.resolve(null)},query:R,withContext:H,cart:c,getProduct:K,getProducts:Q,getRecommendations:j,getScope:ne,addGroup:T,account:ft,primeProduct:V,normalizeProductKey:B,clearProductCache:z,formatMoney:U,imageUrl:q,plans:F,TetherError:v,resolveProductKey:W,setCountry:y,detectMarket:ae,getLocalization:ue,diagnose:se,__core:it,__parts:{},on:le},nn=P;function de(){let t=xt();if(t.Tether=P,!t.TETHER_CONFIG||t.TETHER_CONFIG.autoMount===!1||t.TETHER_INTEGRATION)return;let e=()=>{St().then(()=>h(document)).catch(n=>{a(n,"init")})};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e,{once:!0}):e()}typeof window<"u"&&typeof document<"u"&&de();export{kt as VERSION,T as addGroup,P as api,nn as default,ne as getScope,St as init,h as mount,y as setCountry,Tt as unmount};
@@ -1 +1,2 @@
1
- import{a as D,c as R,d as j,e as k,f as P,g as b,i as B,k as H,l as Y}from"./chunks/chunk-AJLPU2JC.js";import{a as q,h as K,j as X,k as L,v as M,y as z}from"./chunks/chunk-K2YEQAIH.js";import"./chunks/chunk-VC46IEJQ.js";function G(l,{variant:c,sellingPlan:o,defaultPurchase:F="one-time",lowStock:g=5}={}){let f=l?.variants?.nodes||[],N=c?j.variant(c):null,s=N&&f.find(r=>r.id===N)||f.find(r=>r.availableForSale)||f[0]||null;if(!s)return null;let C=Object.fromEntries((s.selectedOptions||[]).map(r=>[r.name,r.value])),S=k(l),w=H(l,o),p=S.length?w||S[0]:null;p&&!P(s,p.id)&&(p=S.find(r=>P(s,r.id))||p);let U=l.requiresSellingPlan||w||F==="subscription",O=S.some(r=>P(s,r.id)),T=S.length&&U?"subscription":"one-time",m=T==="subscription"&&O,e=m?b(s,p.id):s.price,t=m&&P(s,p.id)?.priceAdjustments?.[0]?.compareAtPrice||s.compareAtPrice,n=!!(t&&parseFloat(t.amount)>parseFloat(e.amount)),a=s.quantityAvailable,d=a!=null&&a>0&&a<=g,y=m?B(s,p.id).percentage:0;return{variant:s,selected:C,purchase:T,plan:m?p:null,plans:S.map(r=>({id:r.id,name:r.name,price:b(s,r.id),savings:B(s,r.id).percentage,selected:m&&r.id===p.id,available:!!P(s,r.id)})),savings:p?B(s,p.id).percentage:0,price:e,compareAtPrice:n?t:null,available:s.availableForSale,show:{"in-stock":s.availableForSale,"out-of-stock":!s.availableForSale,backorder:!!(s.availableForSale&&s.currentlyNotInStock),"on-sale":n,"not-on-sale":!n,"has-variants":f.length>1,"single-variant":f.length===1,"low-stock":d,"plenty-in-stock":s.availableForSale&&!d,"subscription-available":O,"subscription-unavailable":!O,"subscription-only":!!l.requiresSellingPlan,"one-time-available":!l.requiresSellingPlan,"subscription-selected":m,"one-time-selected":!m,"has-savings":m?y>0:n},unavailable:Object.fromEntries((l.options||[]).map(r=>[r.name,r.optionValues.map(u=>u.name).filter(u=>I(r.name,u))])),isUnavailable:(r,u)=>I(r,u)};function I(r,u){return!f.some($=>$.availableForSale&&$.selectedOptions.every(h=>h.name===r?h.value===u:C[h.name]===h.value))}}var x=l=>typeof l=="string"&&l.startsWith("gid://");function J(l){let c=String(l??"").trim();if(!c)return null;if(x(c))return c;if(/^\d+$/.test(c))return`gid://shopify/Product/${c}`;let o=c.match(/\/products\/([^/?#]+)/);return o?o[1]:c}function Z(l,c){if(!l)return"";let o=parseFloat(l.amount);if(Number.isNaN(o))return"";try{return new Intl.NumberFormat(c||void 0,{style:"currency",currency:l.currencyCode}).format(o)}catch{return`${l.currencyCode} ${o.toFixed(2)}`}}function V(l,{productPath:c="/product",id:o}={}){return/\{(handle|id)\}/.test(c)?c.replace(/\{handle\}/g,encodeURIComponent(l||"")).replace(/\{id\}/g,encodeURIComponent(o?String(o).split("/").pop():"")):`${c.replace(/\/$/,"")}/${l}`}var W=l=>JSON.stringify(l).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029"),ee={domain:["PUBLIC_SHOPIFY_DOMAIN","PUBLIC_SHOPIFY_STORE_DOMAIN","SHOPIFY_DOMAIN"],token:["PUBLIC_SHOPIFY_STOREFRONT_TOKEN","PUBLIC_SHOPIFY_STOREFRONT_ACCESS_TOKEN","SHOPIFY_STOREFRONT_TOKEN"]};function le(l={}){let c=Object.fromEntries(Object.entries(l).filter(([e])=>e in q||e==="fetch"||e==="pageSize"||e==="siteUrl")),o={...q,...c};for(let[e,t]of Object.entries(ee))o[e]||(o[e]=t.map(n=>l[n]).find(Boolean)||"");if(o.domain=String(o.domain||"").replace(/^https?:\/\//,"").replace(/\/.*$/,""),!o.domain||!o.token)throw new K("createStorefront needs domain and token: pass them, or import.meta.env with PUBLIC_SHOPIFY_DOMAIN and PUBLIC_SHOPIFY_STOREFRONT_TOKEN",{code:"NOT_CONFIGURED"});let F=l.pageSize||25,g=(e,t,n)=>L(o,e,t,n),f=()=>D(o);async function N(e){let t=J(e);if(!t)return null;let n=x(t)?await g(`query TetherServerProductById($id:ID!){node(id:$id){... on Product{...TetherProduct}}}${f()}`,{id:t}):await g(`query TetherServerProduct($handle:String!){product(handle:$handle){...TetherProduct}}${f()}`,{handle:t}),a=x(t)?n.node:n.product;return a&&a.id?a:null}async function s({collection:e,query:t,first:n=F,after:a=null,sortKey:d,reverse:y=!1,filters:I}={}){if(e){let u=await g(`query TetherServerCollection($handle:String!,$first:Int!,$after:String,$sortKey:ProductCollectionSortKeys,$reverse:Boolean,$filters:[ProductFilter!]){collection(handle:$handle){${R()} products(first:$first,after:$after,sortKey:$sortKey,reverse:$reverse,filters:$filters){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}}${f()}`,{handle:e,first:n,after:a,sortKey:d||void 0,reverse:y,filters:I||void 0});if(!u.collection)return{collection:null,products:[],pageInfo:{hasNextPage:!1,endCursor:null}};let{products:$,...h}=u.collection;return{collection:h,products:$.nodes,pageInfo:$.pageInfo}}let r=await g(`query TetherServerProducts($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}}}${f()}`,{first:n,after:a,query:t||void 0,sortKey:d||void 0,reverse:y});return{collection:null,products:r.products.nodes,pageInfo:r.products.pageInfo}}async function C(e={}){let t=[],n=null;for(let a=0;a<500;a++){let d=await s({...e,first:F,after:n});if(t.push(...d.products),!d.pageInfo.hasNextPage)break;n=d.pageInfo.endCursor}return t}async function S(e,t={}){let n=await s({...t,collection:e});return n.collection?{...n.collection,products:n.products,pageInfo:n.pageInfo}:null}async function w(){let e=[],t=null;for(let n=0;n<100;n++){let a=await g(`query TetherServerCollections($first:Int!,$after:String){collections(first:$first,after:$after){nodes{${R()}}pageInfo{hasNextPage endCursor}}}`,{first:100,after:t});if(e.push(...a.collections.nodes),!a.collections.pageInfo.hasNextPage)break;t=a.collections.pageInfo.endCursor}return e}async function p(e,t="RELATED"){let n=J(typeof e=="object"?e?.id:e),a=n?.startsWith("gid://");return(await g(`query TetherServerRecs(${a?"$id: ID!":"$handle: String!"},$intent:ProductRecommendationIntent){productRecommendations(${a?"productId: $id":"productHandle: $handle"},intent:$intent){...TetherProduct}}${f()}`,a?{id:n,intent:t}:{handle:n,intent:t})).productRecommendations||[]}function U(e,{card:t=!1,images:n=2}={}){let a=(Array.isArray(e)?e:[e]).filter(Boolean);t&&(a=a.map(y=>m(y,n)));let d={v:1,at:new Date().toISOString(),country:o.country||null,language:o.language||null,products:a};return`<script type="application/json" data-tether-hydrate>${W(d)}<\/script>`}function O(e,{url:t,brand:n}={}){if(!e)return null;let a=t||(o.siteUrl?new URL(V(e.handle,{productPath:o.productPath,id:e.id}),o.siteUrl).toString():void 0),d=i=>String(i.id).split("/").pop(),y=i=>a?`${a}${a.includes("?")?"&":"?"}variant=${d(i)}`:void 0,I=(e.description||"").trim()||void 0,r=(e.images?.nodes||[]).map(i=>i.url).filter(Boolean),u=n||e.vendor,$=i=>{if(!e.requiresSellingPlan)return i.price;let v=k(e).find(Q=>P(i,Q.id));return v?b(i,v.id):i.price},h=i=>({"@type":"Offer",price:$(i)?.amount,priceCurrency:$(i)?.currencyCode,availability:`https://schema.org/${i.availableForSale?i.currentlyNotInStock?"BackOrder":"InStock":"OutOfStock"}`,url:y(i)}),_=e.variants?.nodes||[],A=i=>JSON.parse(JSON.stringify(i));if(_.length<=1){let i=_[0];return A({"@context":"https://schema.org","@type":"Product",name:e.title,description:I,url:a,image:r,sku:i?.sku||void 0,brand:u?{"@type":"Brand",name:u}:void 0,offers:i?h(i):void 0})}let E={size:"https://schema.org/size",color:"https://schema.org/color",colour:"https://schema.org/color",material:"https://schema.org/material"};return A({"@context":"https://schema.org","@type":"ProductGroup",name:e.title,description:I,url:a,productGroupID:String(e.id).split("/").pop(),image:r,brand:u?{"@type":"Brand",name:u}:void 0,variesBy:[...new Set((e.options||[]).map(i=>E[i.name.toLowerCase()]).filter(Boolean))],hasVariant:_.map(i=>({"@type":"Product",name:`${e.title} - ${i.title}`,sku:i.sku||void 0,image:i.image?.url||r[0],...Object.fromEntries((i.selectedOptions||[]).filter(v=>E[v.name.toLowerCase()]).map(v=>[E[v.name.toLowerCase()].split("/").pop(),v.value])),offers:h(i)}))})}let T=(e,t)=>e?`<script type="application/ld+json">${W(O(e,t))}<\/script>`:"";function m(e,t=2){return{...e,description:"",descriptionHtml:"",images:{nodes:(e.images?.nodes||[]).slice(0,Math.max(1,t))},variants:{nodes:(e.variants?.nodes||[]).map(n=>({...n,image:null}))}}}return{config:o,query:g,getProduct:N,getProducts:s,allProducts:C,getCollection:S,allCollections:w,getRecommendations:p,hydrate:U,formatMoney:(e,t=o.locale)=>Z(e,t),formatPercent:(e,t=o.locale)=>M(e,t),imageUrl:z,jsonLd:T,jsonLdData:O,initialState:(e,t={})=>G(e,{defaultPurchase:o.defaultPurchase,lowStock:o.lowStock,...t}),productUrl:(e,t={})=>V(e,{productPath:o.productPath,...t}),plans:Y}}export{K as TetherError,le as createStorefront,Z as formatMoney,M as formatPercent,z as imageUrl,G as initialState,Y as plans,J as productKey,V as productUrl,X as withContext};
1
+ import{b as x,d as q,e as F}from"./chunks/chunk-HEQILZVR.js";import{a as D,c as T,e as v,f as I,g as C,i as R,l as L}from"./chunks/chunk-JOOEXYF3.js";import{F as b,a as g,d as U,l as _,n as J,o as y,y as N}from"./chunks/chunk-YJLWX2HK.js";import{b as O,e as A,f as S,g as $}from"./chunks/chunk-FOMSMIAM.js";function B(e,t={}){if(!e)return null;let{variant:a,sellingPlan:c,defaultPurchase:l=g.defaultPurchase,lowStock:u=g.lowStock}=t,i=q(e,{variant:a,sellingPlan:c,defaultPurchase:l}),n=F(e,{...i,quantity:1},u);if(!n)return null;let{selected:f,isSubscription:p}=n,o=(r,s)=>!x(e,f,r,s);return{variant:n.variant,selected:f,purchase:n.purchase.kind,plan:p?n.plan:null,plans:v(e).map(r=>({id:r.id,name:r.name,price:C(n.variant,r.id),savings:R(n.variant,r.id).percentage,selected:p&&r.id===n.purchase.planId,available:!!I(n.variant,r.id)})),savings:n.savings.percentage,price:n.price,compareAtPrice:n.compareAtPrice,available:n.variant.availableForSale,show:n.show,unavailable:Object.fromEntries(e.options.map(r=>[r.name,r.optionValues.map(s=>s.name).filter(s=>o(r.name,s))])),isUnavailable:o}}var Q=500,z=100,W=100,X="query TetherServerProductById($id:ID!){node(id:$id){... on Product{...TetherProduct}}}",Z="query TetherServerProduct($handle:String!){product(handle:$handle){...TetherProduct}}",ee=()=>`query TetherServerCollection($handle:String!,$first:Int!,$after:String,$sortKey:ProductCollectionSortKeys,$reverse:Boolean,$filters:[ProductFilter!]){collection(handle:$handle){${T()} products(first:$first,after:$after,sortKey:$sortKey,reverse:$reverse,filters:$filters){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}}`,te="query TetherServerProducts($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}}}",re=()=>`query TetherServerCollections($first:Int!,$after:String){collections(first:$first,after:$after){nodes{${T()}}pageInfo{hasNextPage endCursor}}}`,ne=e=>`query TetherServerRecs(${e?"$id: ID!":"$handle: String!"},$intent:ProductRecommendationIntent){productRecommendations(${e?"productId: $id":"productHandle: $handle"},intent:$intent){...TetherProduct}}`;function K(e,t){let a=(o,r)=>y(e,`${o}
2
+ ${D(e)}`,r);async function c(o){let r=$(o);if(!r)return null;if(r.startsWith("gid://")){let d=await a(X,{id:r});return d.node?.id?d.node:null}return(await a(Z,{handle:r})).product}async function l(o,{first:r=t,after:s=null,sortKey:d,reverse:m=!1,filters:E}){let P=await a(ee(),{handle:o,first:r,after:s,sortKey:d||void 0,reverse:m,filters:E??void 0});if(!P.collection)return{collection:null,products:[],pageInfo:{hasNextPage:!1,endCursor:null}};let{products:h,...Y}=P.collection;return{collection:Y,products:h.nodes,pageInfo:h.pageInfo}}async function u(o={}){let{collection:r,query:s,first:d=t,after:m=null,sortKey:E,reverse:P=!1}=o;if(r)return l(r,o);let h=await a(te,{first:d,after:m,query:s||void 0,sortKey:E||void 0,reverse:P});return{collection:null,products:h.products.nodes,pageInfo:h.products.pageInfo}}async function i(o={}){let r=[],s=null;for(let d=0;d<Q;d++){let m=await u({...o,first:t,after:s});if(r.push(...m.products),!m.pageInfo.hasNextPage)break;s=m.pageInfo.endCursor}return r}async function n(o,r={}){let s=await u({...r,collection:o});return s.collection?{...s.collection,products:s.products,pageInfo:s.pageInfo}:null}async function f(){let o=[],r=null;for(let s=0;s<W;s++){let d=await y(e,re(),{first:z,after:r});if(o.push(...d.collections.nodes),!d.collections.pageInfo.hasNextPage)break;r=d.collections.pageInfo.endCursor}return o}async function p(o,r="RELATED"){let s=$(typeof o=="object"?o?.id:o),d=s?.startsWith("gid://")??!1;return(await a(ne(d),d?{id:s,intent:r}:{handle:s,intent:r})).productRecommendations??[]}return{getProduct:c,getProducts:u,allProducts:i,getCollection:n,allCollections:f,getRecommendations:p}}var M={size:"https://schema.org/size",color:"https://schema.org/color",colour:"https://schema.org/color",material:"https://schema.org/material"},k=e=>JSON.stringify(e).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029");function j(e){return JSON.parse(JSON.stringify(e))}var G=e=>e.split("/").pop()??e;function oe(e){return e.availableForSale?e.currentlyNotInStock?"https://schema.org/BackOrder":"https://schema.org/InStock":"https://schema.org/OutOfStock"}function ae(e,t){if(!e.requiresSellingPlan)return t.price;let a=v(e).find(c=>I(t,c.id));return(a&&C(t,a.id))??t.price}function H(e,t,a){let c=ae(e,t),l=a?.includes("?")?"&":"?";return{"@type":"Offer",price:c.amount,priceCurrency:c.currencyCode,availability:oe(t),url:a?`${a}${l}variant=${G(t.id)}`:void 0}}function ie(e,t,a,c){let l=t.selectedOptions.flatMap(u=>{let i=M[u.name.toLowerCase()];return i?[[i.split("/").pop()??i,u.value]]:[]});return{"@type":"Product",name:`${e.title} - ${t.title}`,sku:t.sku||void 0,image:t.image?.url||c[0],...Object.fromEntries(l),offers:H(e,t,a)}}function se(e,{url:t},a){if(t)return t;if(a.siteUrl)return new URL(S(a.productPath,e.handle,e.id),a.siteUrl).toString()}function w(e,t,a){if(!e)return null;let c=se(e,t,a),l=e.images.nodes.map(o=>o.url).filter(Boolean),u=t.brand||e.vendor,i=u?{"@type":"Brand",name:u}:void 0,n=e.description.trim()||void 0,f=e.variants.nodes;if(f.length<=1){let[o]=f;return j({"@context":"https://schema.org","@type":"Product",name:e.title,description:n,url:c,image:l,sku:o?.sku||void 0,brand:i,offers:o?H(e,o,c):void 0})}let p=e.options.map(o=>M[o.name.toLowerCase()]).filter(Boolean);return j({"@context":"https://schema.org","@type":"ProductGroup",name:e.title,description:n,url:c,productGroupID:G(e.id),image:l,brand:i,variesBy:[...new Set(p)],hasVariant:f.map(o=>ie(e,o,c,l))})}var ce=25,le=2,ue=1;function de(e,{productPath:t=g.productPath,id:a}={}){return S(t,e,a)}function V(e,t){for(let a of t){let c=e[a];if(typeof c=="string"&&c)return c}return""}function fe(e){let t={};for(let[u,i]of Object.entries(e))u in g&&(t[u]=i);let a=typeof e.domain=="string"&&e.domain?e.domain:"",c=typeof e.token=="string"&&e.token?e.token:"",l=U({...t,domain:a||V(e,O.domain),token:c||V(e,O.token)});return e.fetch&&(l.fetch=e.fetch),e.pageSize!==void 0&&(l.pageSize=e.pageSize),e.siteUrl!==void 0&&(l.siteUrl=e.siteUrl),l}var pe=e=>typeof e=="number"&&Number.isInteger(e)&&e>0?e:ce;function me(e,t){return{...e,description:"",descriptionHtml:"",images:{nodes:e.images.nodes.slice(0,Math.max(1,t))},variants:{nodes:e.variants.nodes.map(a=>({...a,image:null}))}}}function be(e={}){let t=fe(e);if(!t.domain||!t.token)throw new _("createStorefront needs domain and token: pass them, or import.meta.env with PUBLIC_SHOPIFY_DOMAIN and PUBLIC_SHOPIFY_STOREFRONT_TOKEN",{code:"NOT_CONFIGURED"});let a=K(t,pe(t.pageSize)),c={productPath:t.productPath,siteUrl:t.siteUrl};function l(i,{card:n=!1,images:f=le}={}){let p=(Array.isArray(i)?i:[i]).filter(r=>r!=null),o={v:ue,at:new Date().toISOString(),country:t.country||null,language:t.language||null,products:n?p.map(r=>me(r,f)):p};return`<script type="application/json" data-tether-hydrate>${k(o)}<\/script>`}function u(i,n={}){return i?`<script type="application/ld+json">${k(w(i,n,c))}<\/script>`:""}return{config:t,query:(i,n,f)=>y(t,i,n,f),...a,hydrate:l,formatMoney:(i,n=t.locale)=>A(i,n),formatPercent:(i,n=t.locale)=>b(i,n),imageUrl:N,jsonLd:u,jsonLdData:(i,n={})=>w(i,n,c),initialState:(i,n={})=>B(i,{defaultPurchase:t.defaultPurchase,lowStock:t.lowStock,...n}),productUrl:(i,n={})=>de(i,{productPath:t.productPath,...n}),plans:L}}export{_ as TetherError,be as createStorefront,A as formatMoney,b as formatPercent,N as imageUrl,B as initialState,L as plans,$ as productKey,de as productUrl,J as withContext};