@occluze/tether 0.9.1 → 0.9.2

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 (36) hide show
  1. package/README.md +1 -1
  2. package/dist/esm/astro.js +1 -1
  3. package/dist/esm/chunks/{account-LCMJ7QU5.js → account-XBGNTM7V.js} +1 -1
  4. package/dist/esm/chunks/{account-pages-3C5KTPQV.js → account-pages-FIXSWJH7.js} +1 -1
  5. package/dist/esm/chunks/{analytics-VWSZOX2D.js → analytics-MO2ZWBOD.js} +1 -1
  6. package/dist/esm/chunks/chunk-2J3MTS3E.js +1 -0
  7. package/dist/esm/chunks/chunk-4FR3CUO2.js +1 -0
  8. package/dist/esm/chunks/{chunk-OURC3H6L.js → chunk-7CRTJV25.js} +1 -1
  9. package/dist/esm/chunks/{chunk-P6DV24RG.js → chunk-7ZXEVDOS.js} +1 -1
  10. package/dist/esm/chunks/{chunk-S5BUUIB6.js → chunk-BVO7KK2M.js} +1 -1
  11. package/dist/esm/chunks/{chunk-2IGCUTG5.js → chunk-CRKJ2VEX.js} +1 -1
  12. package/dist/esm/chunks/{chunk-XU27NSXT.js → chunk-DM5LEAWM.js} +1 -1
  13. package/dist/esm/chunks/{chunk-F2BYVA7V.js → chunk-FI4NIWAD.js} +1 -1
  14. package/dist/esm/chunks/{chunk-ZBV2JSHE.js → chunk-FWMPL6PR.js} +1 -1
  15. package/dist/esm/chunks/{chunk-EUCFOBIT.js → chunk-H6IORH7O.js} +1 -1
  16. package/dist/esm/chunks/{chunk-MJNPD6LB.js → chunk-IJAMRI33.js} +1 -1
  17. package/dist/esm/chunks/{chunk-P73VN3B6.js → chunk-OATTAXPO.js} +1 -1
  18. package/dist/esm/chunks/{chunk-2A2GN3Z7.js → chunk-OENVX4NY.js} +1 -1
  19. package/dist/esm/chunks/{chunk-D3MRWOFI.js → chunk-OJAV2I3C.js} +1 -1
  20. package/dist/esm/chunks/{chunk-3UCVDDK6.js → chunk-SZRDO62E.js} +1 -1
  21. package/dist/esm/chunks/{chunk-HROQXZYN.js → chunk-Y3NKKN2O.js} +1 -1
  22. package/dist/esm/chunks/{diagnose-TE72GNOO.js → diagnose-XSZPWEG7.js} +1 -1
  23. package/dist/esm/chunks/{extras-7GTMJMOZ.js → extras-DZIOTZ3H.js} +1 -1
  24. package/dist/esm/chunks/{lists-ZMVRGD6L.js → lists-OJGSVQMM.js} +1 -1
  25. package/dist/esm/chunks/{markets-ui-AAQM4PEE.js → markets-ui-DEEYV4KT.js} +1 -1
  26. package/dist/esm/chunks/{search-PWF4YZQO.js → search-A6HF5PMJ.js} +1 -1
  27. package/dist/esm/index.js +1 -1
  28. package/dist/esm/server.js +2 -2
  29. package/dist/tether.js +8 -4
  30. package/dist/tether.min.js +1 -1
  31. package/dist/tether.min.js.map +2 -2
  32. package/dist/types/src/server.d.ts +5 -2
  33. package/dist/types/src/version.d.ts +1 -1
  34. package/package.json +2 -2
  35. package/dist/esm/chunks/chunk-SOFWDTR7.js +0 -1
  36. package/dist/esm/chunks/chunk-YJC3CSEG.js +0 -1
package/README.md CHANGED
@@ -17,7 +17,7 @@ Script tag, for Webflow or any page without a build step:
17
17
  <script src="https://cdn.jsdelivr.net/gh/ravi-klaassens/tether@0.9/dist/tether.min.js" defer></script>
18
18
  ```
19
19
 
20
- `@0.9` gets every 0.9.x fix automatically (recommended), `@v0.9.1` pins one release, `@latest`
20
+ `@0.9` gets every 0.9.x fix automatically (recommended), `@v0.9.2` pins one release, `@latest`
21
21
  always takes the newest ([versions and self-hosting](docs/webflow.md#versions-and-self-hosting)).
22
22
 
23
23
  npm, for Astro, Vite or another bundler or framework (TypeScript types included):
package/dist/esm/astro.js CHANGED
@@ -1,2 +1,2 @@
1
- import{A as u,B as d,D as h,q as g}from"./chunks/chunk-D3MRWOFI.js";var w=["src/shop.config.js","src/shop.config.mjs","src/shop.config.ts"],O=new Set(["siteUrl","pageSize"]),y="astro/config",E=/^\s*(?:export\s+)?([\w.-]+)\s*=\s*(.*?)\s*$/,S=/^(["'])(.*?)\1/;function T(n,t=process.argv){let e=n==="dev"?"development":"production",o=t.findIndex(r=>r==="--mode"||r.startsWith("--mode="));if(o<0)return e;let i=t[o]??"";return(i.includes("=")?i.split("=")[1]:t[o+1])??e}var v=n=>n instanceof Error&&"code"in n&&n.code==="ENOENT";async function k(n){let{readFile:t}=await import("node:fs/promises");try{return await t(n,"utf8")}catch(e){if(v(e))return null;throw e}}function _(n,t){for(let e of n.split(/\r?\n/)){let o=E.exec(e);if(!o||e.trim().startsWith("#"))continue;let[,i="",s=""]=o,r=S.exec(s);t[i]=r?r[2]??"":s.replace(/\s+#.*$/,"")}}async function C(n,t){let e=await import("node:path"),o=T(n),i={};for(let s of[".env",".env.local",`.env.${o}`,`.env.${o}.local`]){let r=await k(e.join(t,s));r!==null&&_(r,i)}return{...i,...process.env}}function P(n,t,e){for(let o of["domain","token"]){if(n[o])continue;let i=d[o].find(s=>t[s]);i&&(n[o]=t[i],i.startsWith("PUBLIC_")||e.warn(`${i} is written into every page as Tether's ${o}. Name it PUBLIC_${i} to say so.`))}if(typeof n.token=="string"&&h(n.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 F(n,t,e){let{existsSync:o}=await import("node:fs"),i=await import("node:path");for(let s of t){let r=i.resolve(n,s);o(r)&&e(r)}}async function I(n){try{return await import(n)}catch(t){if(t instanceof Error&&"code"in t&&t.code==="ERR_MODULE_NOT_FOUND")return null;throw t}}var A=n=>typeof n=="object"&&n!==null&&"string"in n&&typeof n.string=="function";async function N(n){if(!n.updateConfig)return;let t=await I(y),e=typeof t=="object"&&t!==null&&"envField"in t?t.envField:null;if(!A(e))return;let o=()=>e.string({context:"client",access:"public",optional:!0});try{n.updateConfig({env:{schema:{PUBLIC_SHOPIFY_DOMAIN:o(),PUBLIC_SHOPIFY_STOREFRONT_TOKEN:o()}}})}catch(i){n.logger.warn(`.env variables not declared in astro:env: ${u(i)}`)}}function R(n,t){let e=Object.keys(n).filter(o=>typeof n[o]=="function");for(let o of e)Reflect.deleteProperty(n,o);e.length&&t.warn(`${e.join(", ")}: functions can't be passed here. Set them in window.TETHER_CONFIG in your layout.`)}function L(n,t){for(let e of Object.keys(n))e in g||(Reflect.deleteProperty(n,e),O.has(e)||t.warn(`${e} is not a Tether option: left out of the page.`))}function b(n,t){n("head-inline",'window.TETHER_INTEGRATION="astro";'),n("page",["import Tether from '@occluze/tether';",`window.TETHER_CONFIG = { ...${JSON.stringify({autoMount:!1,...t})}, ...(window.TETHER_CONFIG || {}) };`,"Tether.init().then(() => Tether.mount(document));"].join(`
1
+ import{A as u,B as d,D as h,q as g}from"./chunks/chunk-OJAV2I3C.js";var w=["src/shop.config.js","src/shop.config.mjs","src/shop.config.ts"],O=new Set(["siteUrl","pageSize"]),y="astro/config",E=/^\s*(?:export\s+)?([\w.-]+)\s*=\s*(.*?)\s*$/,S=/^(["'])(.*?)\1/;function T(n,t=process.argv){let e=n==="dev"?"development":"production",o=t.findIndex(r=>r==="--mode"||r.startsWith("--mode="));if(o<0)return e;let i=t[o]??"";return(i.includes("=")?i.split("=")[1]:t[o+1])??e}var v=n=>n instanceof Error&&"code"in n&&n.code==="ENOENT";async function k(n){let{readFile:t}=await import("node:fs/promises");try{return await t(n,"utf8")}catch(e){if(v(e))return null;throw e}}function _(n,t){for(let e of n.split(/\r?\n/)){let o=E.exec(e);if(!o||e.trim().startsWith("#"))continue;let[,i="",s=""]=o,r=S.exec(s);t[i]=r?r[2]??"":s.replace(/\s+#.*$/,"")}}async function C(n,t){let e=await import("node:path"),o=T(n),i={};for(let s of[".env",".env.local",`.env.${o}`,`.env.${o}.local`]){let r=await k(e.join(t,s));r!==null&&_(r,i)}return{...i,...process.env}}function P(n,t,e){for(let o of["domain","token"]){if(n[o])continue;let i=d[o].find(s=>t[s]);i&&(n[o]=t[i],i.startsWith("PUBLIC_")||e.warn(`${i} is written into every page as Tether's ${o}. Name it PUBLIC_${i} to say so.`))}if(typeof n.token=="string"&&h(n.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 F(n,t,e){let{existsSync:o}=await import("node:fs"),i=await import("node:path");for(let s of t){let r=i.resolve(n,s);o(r)&&e(r)}}async function I(n){try{return await import(n)}catch(t){if(t instanceof Error&&"code"in t&&t.code==="ERR_MODULE_NOT_FOUND")return null;throw t}}var A=n=>typeof n=="object"&&n!==null&&"string"in n&&typeof n.string=="function";async function N(n){if(!n.updateConfig)return;let t=await I(y),e=typeof t=="object"&&t!==null&&"envField"in t?t.envField:null;if(!A(e))return;let o=()=>e.string({context:"client",access:"public",optional:!0});try{n.updateConfig({env:{schema:{PUBLIC_SHOPIFY_DOMAIN:o(),PUBLIC_SHOPIFY_STOREFRONT_TOKEN:o()}}})}catch(i){n.logger.warn(`.env variables not declared in astro:env: ${u(i)}`)}}function R(n,t){let e=Object.keys(n).filter(o=>typeof n[o]=="function");for(let o of e)Reflect.deleteProperty(n,o);e.length&&t.warn(`${e.join(", ")}: functions can't be passed here. Set them in window.TETHER_CONFIG in your layout.`)}function L(n,t){for(let e of Object.keys(n))e in g||(Reflect.deleteProperty(n,e),O.has(e)||t.warn(`${e} is not a Tether option: left out of the page.`))}function b(n,t){n("head-inline",'window.TETHER_INTEGRATION="astro";'),n("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
2
  `))}function U(n={}){let{inject:t=!0,watch:e=w,...o}=n;return{name:"@occluze/tether",hooks:{"astro:config:setup":async i=>{let{injectScript:s,command:r,config:f,logger:a,addWatchFile:p}=i,{fileURLToPath:m}=await import("node:url"),l=f.root?m(f.root):process.cwd();r==="dev"&&p&&await F(l,e??[],p),await N(i);let c={...o};P(c,await C(r,l),a),R(c,a),L(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)."),t&&b(s,c)}}}}export{U as default};
@@ -1 +1 @@
1
- import{f as j,g as V,h as G,i as R,m as v,n as H}from"./chunk-OURC3H6L.js";import{a as O,c as M}from"./chunk-MJNPD6LB.js";import{f as q,g as F,h as P}from"./chunk-P6DV24RG.js";import"./chunk-S5BUUIB6.js";import{a as W}from"./chunk-YJC3CSEG.js";import"./chunk-EUCFOBIT.js";import"./chunk-ZBV2JSHE.js";import{C as $,D as _,F as A,H as L,a as f,m as c,n as l,p as d,t as h,w as N,y as D}from"./chunk-P73VN3B6.js";import{A as T,C as U,d as I,g as y,r as i,x as E,z as m}from"./chunk-D3MRWOFI.js";var g=null;function X(){let e=i.account?.server;if(!e)throw new f("Customer accounts need the Worker: set account.server",{code:"NOT_CONFIGURED"});return new URL(e,window.location.href).href.replace(/\/$/,"")}function B(e){e?q(O(),"1"):F(O())}async function ae(e,t){try{return await fetch(e,t)}catch(r){throw new f(`Network error: ${T(r)}`,{code:"NETWORK"})}}async function ue(e){let t;try{t=await e.json()}catch{return{}}return I(t)?t:{}}async function p(e,{method:t="GET",body:r}={}){let n={method:t,credentials:"include"};t==="POST"&&(n.headers={"Content-Type":"application/json","X-Tether-Account":"1"}),r&&(n.body=JSON.stringify(r));let s=await ae(`${X()}${e}`,n);if(s.status===401)return{kind:"logged-out"};let o=await ue(s);if(!s.ok){let u=y(o.error)??String(s.status),w=G(o.userErrors);throw new f(`Customer accounts: ${u}`,{status:s.status,...w.length>0&&{userErrors:w},...o.code==="INVALID"&&{code:"INVALID"}})}return{kind:"answer",data:o}}async function k(){if(!g){let e=await p("/me");g=e.kind==="answer"&&e.data.loggedIn===!0?{loggedIn:!0,customer:j(e.data.customer)}:{loggedIn:!1}}return B(g.loggedIn),g}var J=()=>g?.loggedIn===!0;function K(){g=null}function z(e){let t=i.account?.navigate;t?t(e):window.location.assign(e)}var de=e=>e||i.account?.locale||(i.locale||"").split("-")[0]||"";function Q({returnTo:e,locale:t}){let r=new URL(`${X()}/login`);r.searchParams.set("returnTo",e);let n=de(t);n&&r.searchParams.set("locale",n),i.country&&r.searchParams.set("country",i.country.toUpperCase()),z(r.toString())}async function Y(){let e=P.id();if(!(await k()).loggedIn||!e)return null;let t=await p("/cart",{method:"POST",body:{cartId:e}});return t.kind==="logged-out"?null:y(t.data.checkoutUrl)}async function Z(e){let t=await p("/logout",{method:"POST",body:{returnTo:e,cartId:P.id()}});g=null,B(!1),h("account-logout",{});let r=t.kind==="answer"?y(t.data.logoutUrl):null;return r?(z(r),"redirected"):"stayed"}var b=10,S=50,ee=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1&&e<=S;function le(e){let t=Number.parseInt(e||String(b),10)||b;return Math.min(Math.max(t,1),S)}var me=e=>e.replace(/\?.*$/,"").replace(/^.*\//,"");function ge(e){let t=i.account?.orderUrl;if(t)return t.replaceAll("{id}",encodeURIComponent(me(e.id)));let r=e.statusPageUrl;return r!==null&&U(r)?r:null}var fe=e=>({name:e.name??"",date:_(e.processedAt),total:$(e.totalPrice),status:e.financialStatus?.toLowerCase(),fulfillment:e.fulfillmentStatus?.toLowerCase(),items:e.lineItems.nodes.map(t=>`${String(t.quantity)}\xD7 ${t.title??""}`).join(", ")});function pe(e,t){let r=t.lineItems.nodes,n=ge(t),s=fe(t);d(e,c("order-bind")).forEach(o=>{let u=l(o,"order-bind")??"";if(u==="url"){n&&o.setAttribute("href",n);return}if(u==="image"){let x=r.find(ce=>ce.image)?.image;x&&N(o,x.url,x.altText||r[0]?.title||"");return}let w=v(s,u);w!==void 0&&A(o,w)}),d(e,c("order-lines")).forEach(o=>{H(o,r,null)}),l(e,"order-bind")==="url"&&n&&e.setAttribute("href",n)}async function te(e,t){let r=d(e,c("orders")),n=r[0];if(!n)return;R(e,"show",{"orders-loading":!0,"orders-empty":!1});let s=le(l(n,"limit")),o;try{o=await t(s)}catch(u){m(u,"orders"),o=null}R(e,"show",{"orders-loading":!1,"orders-empty":o?.length===0}),r.forEach(u=>{D(u,o??[],pe)})}var we=["order","addresses","subscriptions","profile-form","address-form"],he=J;function Pe({returnTo:e=window.location.href,locale:t}={}){return new Promise(r=>{Q({returnTo:e,locale:t}),r()})}async function se(){let e=await k();return e.loggedIn?e.customer:null}async function ye({first:e=b}={}){if(!ee(e))throw new f(`Customer accounts: orders() takes first from 1 to ${String(S)}`,{code:"INVALID"});let t=await p(`/orders?${new URLSearchParams({first:String(e)}).toString()}`);return t.kind==="logged-out"?[]:V(t.data.orders)}async function Ae({returnTo:e=i.account?.logoutUrl||`${window.location.origin}/`}={}){await Z(e)==="stayed"&&await C(document)}async function ve(){try{return(await k()).loggedIn?{kind:"logged-in"}:{kind:"logged-out"}}catch(e){return{kind:"unknown",error:e}}}var re=e=>we.some(t=>d(e,c(t)).length>0);function ke(e){d(e,c("account-link")).forEach(t=>{t.setAttribute("href",be(l(t,"account-link")))})}function be(e){let t=i.account,r=`https://${i.domain}/account`;return e==="payment"?t?.paymentUrl||t?.subscriptionsUrl||r:e==="subscriptions"&&t?.subscriptionsUrl||r}async function C(e=document){let t=await ve();t.kind==="unknown"&&m(t.error,"account");let r=t.kind==="logged-in";if(d(e,c("show")).forEach(n=>{let s=l(n,"show");s==="logged-in"&&L(n,r),s==="logged-out"&&L(n,!r)}),ke(e),t.kind==="unknown"&&re(e)){(await a()).showUnavailable(e);return}r&&(await ie(e),await Promise.all([te(e,n=>ye({first:n})),re(e)?a().then(n=>n.renderPages(e)):null]))}async function ie(e){let t=d(e,c("account-bind"));if(!t.length)return;let r;try{r=await se()}catch(s){m(s,"account");return}if(!r)return;let n={"first-name":r.firstName,"last-name":r.lastName,name:r.displayName,email:r.emailAddress?.emailAddress,address:r.defaultAddress?.formatted.join(", ")};t.forEach(s=>{let o=v(n,l(s,"account-bind")??"");o!=null&&A(s,o)})}var ne=null;function a(){return ne??(ne=W("account-pages").then(e=>(e.setup({serverFetch:p,customer:se,bindCustomer:ie,reset:K}),e))),ne}var Ye=e=>a().then(t=>t.order(e)),Ze=e=>a().then(t=>t.updateProfile(e)),et=()=>a().then(e=>e.addresses()),tt=(e,t)=>a().then(r=>r.saveAddress(e,t)),rt=e=>a().then(t=>t.deleteAddress(e)),nt=()=>a().then(e=>e.subscriptions()),ot=(e,t)=>a().then(r=>r.subscriptionAction(e,t)),st=(e,t)=>a().then(r=>r.requestReturn(e,t));function Se(e){let t=e.target;t instanceof window.Element&&(t.closest(c("account-login"))?(e.preventDefault(),Pe().catch(r=>{m(r,"login")})):t.closest(c("account-logout"))&&(e.preventDefault(),Ae().catch(r=>{m(r,"logout")})))}function xe(){let e=new URL(window.location.href),t=e.searchParams.get("account");if(M(t))switch(e.searchParams.delete("account"),window.history.replaceState(window.history.state,"",e),t){case"in":h("account-login",{});break;case"expired":case"error":h("account-error",{error:t});break}}var oe=!1;async function it(e=document){if(oe){await C(e);return}oe=!0,document.addEventListener("click",Se),xe(),P.setCheckoutResolver(Y),await C(e),E("account",he()?"logged in":"logged out")}export{et as addresses,se as customer,rt as deleteAddress,he as isLoggedIn,Pe as login,Ae as logout,it as mountAccount,Ye as order,ye as orders,C as render,st as requestReturn,tt as saveAddress,ot as subscriptionAction,nt as subscriptions,Ze as updateProfile};
1
+ import{f as j,g as V,h as G,i as R,m as v,n as H}from"./chunk-7CRTJV25.js";import{a as O,c as M}from"./chunk-IJAMRI33.js";import{f as q,g as F,h as P}from"./chunk-7ZXEVDOS.js";import"./chunk-BVO7KK2M.js";import{a as W}from"./chunk-2J3MTS3E.js";import"./chunk-H6IORH7O.js";import"./chunk-FWMPL6PR.js";import{C as $,D as _,F as A,H as L,a as f,m as c,n as l,p as d,t as h,w as N,y as D}from"./chunk-OATTAXPO.js";import{A as T,C as U,d as I,g as y,r as i,x as E,z as m}from"./chunk-OJAV2I3C.js";var g=null;function X(){let e=i.account?.server;if(!e)throw new f("Customer accounts need the Worker: set account.server",{code:"NOT_CONFIGURED"});return new URL(e,window.location.href).href.replace(/\/$/,"")}function B(e){e?q(O(),"1"):F(O())}async function ae(e,t){try{return await fetch(e,t)}catch(r){throw new f(`Network error: ${T(r)}`,{code:"NETWORK"})}}async function ue(e){let t;try{t=await e.json()}catch{return{}}return I(t)?t:{}}async function p(e,{method:t="GET",body:r}={}){let n={method:t,credentials:"include"};t==="POST"&&(n.headers={"Content-Type":"application/json","X-Tether-Account":"1"}),r&&(n.body=JSON.stringify(r));let s=await ae(`${X()}${e}`,n);if(s.status===401)return{kind:"logged-out"};let o=await ue(s);if(!s.ok){let u=y(o.error)??String(s.status),w=G(o.userErrors);throw new f(`Customer accounts: ${u}`,{status:s.status,...w.length>0&&{userErrors:w},...o.code==="INVALID"&&{code:"INVALID"}})}return{kind:"answer",data:o}}async function k(){if(!g){let e=await p("/me");g=e.kind==="answer"&&e.data.loggedIn===!0?{loggedIn:!0,customer:j(e.data.customer)}:{loggedIn:!1}}return B(g.loggedIn),g}var J=()=>g?.loggedIn===!0;function K(){g=null}function z(e){let t=i.account?.navigate;t?t(e):window.location.assign(e)}var de=e=>e||i.account?.locale||(i.locale||"").split("-")[0]||"";function Q({returnTo:e,locale:t}){let r=new URL(`${X()}/login`);r.searchParams.set("returnTo",e);let n=de(t);n&&r.searchParams.set("locale",n),i.country&&r.searchParams.set("country",i.country.toUpperCase()),z(r.toString())}async function Y(){let e=P.id();if(!(await k()).loggedIn||!e)return null;let t=await p("/cart",{method:"POST",body:{cartId:e}});return t.kind==="logged-out"?null:y(t.data.checkoutUrl)}async function Z(e){let t=await p("/logout",{method:"POST",body:{returnTo:e,cartId:P.id()}});g=null,B(!1),h("account-logout",{});let r=t.kind==="answer"?y(t.data.logoutUrl):null;return r?(z(r),"redirected"):"stayed"}var b=10,S=50,ee=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1&&e<=S;function le(e){let t=Number.parseInt(e||String(b),10)||b;return Math.min(Math.max(t,1),S)}var me=e=>e.replace(/\?.*$/,"").replace(/^.*\//,"");function ge(e){let t=i.account?.orderUrl;if(t)return t.replaceAll("{id}",encodeURIComponent(me(e.id)));let r=e.statusPageUrl;return r!==null&&U(r)?r:null}var fe=e=>({name:e.name??"",date:_(e.processedAt),total:$(e.totalPrice),status:e.financialStatus?.toLowerCase(),fulfillment:e.fulfillmentStatus?.toLowerCase(),items:e.lineItems.nodes.map(t=>`${String(t.quantity)}\xD7 ${t.title??""}`).join(", ")});function pe(e,t){let r=t.lineItems.nodes,n=ge(t),s=fe(t);d(e,c("order-bind")).forEach(o=>{let u=l(o,"order-bind")??"";if(u==="url"){n&&o.setAttribute("href",n);return}if(u==="image"){let x=r.find(ce=>ce.image)?.image;x&&N(o,x.url,x.altText||r[0]?.title||"");return}let w=v(s,u);w!==void 0&&A(o,w)}),d(e,c("order-lines")).forEach(o=>{H(o,r,null)}),l(e,"order-bind")==="url"&&n&&e.setAttribute("href",n)}async function te(e,t){let r=d(e,c("orders")),n=r[0];if(!n)return;R(e,"show",{"orders-loading":!0,"orders-empty":!1});let s=le(l(n,"limit")),o;try{o=await t(s)}catch(u){m(u,"orders"),o=null}R(e,"show",{"orders-loading":!1,"orders-empty":o?.length===0}),r.forEach(u=>{D(u,o??[],pe)})}var we=["order","addresses","subscriptions","profile-form","address-form"],he=J;function Pe({returnTo:e=window.location.href,locale:t}={}){return new Promise(r=>{Q({returnTo:e,locale:t}),r()})}async function se(){let e=await k();return e.loggedIn?e.customer:null}async function ye({first:e=b}={}){if(!ee(e))throw new f(`Customer accounts: orders() takes first from 1 to ${String(S)}`,{code:"INVALID"});let t=await p(`/orders?${new URLSearchParams({first:String(e)}).toString()}`);return t.kind==="logged-out"?[]:V(t.data.orders)}async function Ae({returnTo:e=i.account?.logoutUrl||`${window.location.origin}/`}={}){await Z(e)==="stayed"&&await C(document)}async function ve(){try{return(await k()).loggedIn?{kind:"logged-in"}:{kind:"logged-out"}}catch(e){return{kind:"unknown",error:e}}}var re=e=>we.some(t=>d(e,c(t)).length>0);function ke(e){d(e,c("account-link")).forEach(t=>{t.setAttribute("href",be(l(t,"account-link")))})}function be(e){let t=i.account,r=`https://${i.domain}/account`;return e==="payment"?t?.paymentUrl||t?.subscriptionsUrl||r:e==="subscriptions"&&t?.subscriptionsUrl||r}async function C(e=document){let t=await ve();t.kind==="unknown"&&m(t.error,"account");let r=t.kind==="logged-in";if(d(e,c("show")).forEach(n=>{let s=l(n,"show");s==="logged-in"&&L(n,r),s==="logged-out"&&L(n,!r)}),ke(e),t.kind==="unknown"&&re(e)){(await a()).showUnavailable(e);return}r&&(await ie(e),await Promise.all([te(e,n=>ye({first:n})),re(e)?a().then(n=>n.renderPages(e)):null]))}async function ie(e){let t=d(e,c("account-bind"));if(!t.length)return;let r;try{r=await se()}catch(s){m(s,"account");return}if(!r)return;let n={"first-name":r.firstName,"last-name":r.lastName,name:r.displayName,email:r.emailAddress?.emailAddress,address:r.defaultAddress?.formatted.join(", ")};t.forEach(s=>{let o=v(n,l(s,"account-bind")??"");o!=null&&A(s,o)})}var ne=null;function a(){return ne??(ne=W("account-pages").then(e=>(e.setup({serverFetch:p,customer:se,bindCustomer:ie,reset:K}),e))),ne}var Ye=e=>a().then(t=>t.order(e)),Ze=e=>a().then(t=>t.updateProfile(e)),et=()=>a().then(e=>e.addresses()),tt=(e,t)=>a().then(r=>r.saveAddress(e,t)),rt=e=>a().then(t=>t.deleteAddress(e)),nt=()=>a().then(e=>e.subscriptions()),ot=(e,t)=>a().then(r=>r.subscriptionAction(e,t)),st=(e,t)=>a().then(r=>r.requestReturn(e,t));function Se(e){let t=e.target;t instanceof window.Element&&(t.closest(c("account-login"))?(e.preventDefault(),Pe().catch(r=>{m(r,"login")})):t.closest(c("account-logout"))&&(e.preventDefault(),Ae().catch(r=>{m(r,"logout")})))}function xe(){let e=new URL(window.location.href),t=e.searchParams.get("account");if(M(t))switch(e.searchParams.delete("account"),window.history.replaceState(window.history.state,"",e),t){case"in":h("account-login",{});break;case"expired":case"error":h("account-error",{error:t});break}}var oe=!1;async function it(e=document){if(oe){await C(e);return}oe=!0,document.addEventListener("click",Se),xe(),P.setCheckoutResolver(Y),await C(e),E("account",he()?"logged in":"logged out")}export{et as addresses,se as customer,rt as deleteAddress,he as isLoggedIn,Pe as login,Ae as logout,it as mountAccount,Ye as order,ye as orders,C as render,st as requestReturn,tt as saveAddress,ot as subscriptionAction,nt as subscriptions,Ze as updateProfile};
@@ -1 +1 @@
1
- import{a as O,b as ie,c as oe,d as ae,e as S,i as m,j as L,k as E,l as k,m as h,n as de}from"./chunk-OURC3H6L.js";import{C as y,D as C,F as g,H as se,a as H,l as f,m as a,n as p,p as l,t as ne,w as re,y as P}from"./chunk-P73VN3B6.js";import{C as G,d as A,e as i,g as d,h as z,i as M,j as q,k as w,l as te,z as x}from"./chunk-D3MRWOFI.js";var ue={order:{name:"order",method:"GET",path:"/order",fields:{id:!0}},addresses:{name:"addresses",method:"GET",path:"/addresses",fields:{}},subscriptions:{name:"subscriptions",method:"GET",path:"/subscriptions",fields:{}},profile:{name:"profile",method:"POST",path:"/profile",fields:{firstName:!0,lastName:!0}},saveAddress:{name:"saveAddress",method:"POST",path:"/address",fields:{id:!0,address:!0,isDefault:!0}},deleteAddress:{name:"deleteAddress",method:"POST",path:"/address/delete",fields:{id:!0}},subscription:{name:"subscription",method:"POST",path:"/subscription",fields:{id:!0,action:!0}},requestReturn:{name:"requestReturn",method:"POST",path:"/return",fields:{orderId:!0,lines:!0}}},it=new Map(Object.values(ue).map(e=>[`${e.method} ${e.path}`,{...e,fields:Object.keys(e.fields)}]));function le(e,t){let n=ue[e];if(n.method==="POST")return{method:"POST",path:n.path};let r=t,s=new URLSearchParams;for(let u of Object.keys(n.fields)){let c=r[u];(typeof c=="string"||typeof c=="number")&&s.set(u,String(c))}let o=s.toString();return{method:"GET",path:o?`${n.path}?${o}`:n.path}}function me(e){let t=n=>d(i(e,n));return{id:t("id"),firstName:t("firstName"),lastName:t("lastName"),company:t("company"),address1:t("address1"),address2:t("address2"),city:t("city"),province:t("province"),zoneCode:t("zoneCode"),zip:t("zip"),country:t("country"),countryCode:t("countryCode"),phoneNumber:t("phoneNumber"),formatted:te(i(e,"formatted"))}}var ce=e=>A(e)?me(e):null,j=e=>({...me(e),id:S(i(e,"id"),"address id")}),pe=e=>q(e,t=>({...j(t),isDefault:i(t,"isDefault")===!0})),Le=e=>({...oe(e),id:S(i(e,"id"),"line item id"),name:d(i(e,"name")),sku:d(i(e,"sku")),price:O(i(e,"price")),totalPrice:O(i(e,"totalPrice")),suggestedReturnReasonDefinitions:w(i(e,"suggestedReturnReasonDefinitions"),t=>({id:S(i(t,"id"),"return reason id"),name:d(i(t,"name")),handle:d(i(t,"handle"))}))}),Ie=e=>({id:d(i(e,"id")),status:d(i(e,"status")),createdAt:d(i(e,"createdAt")),estimatedDeliveryAt:d(i(e,"estimatedDeliveryAt")),latestShipmentStatus:d(i(e,"latestShipmentStatus")),trackingInformation:q(i(e,"trackingInformation"),t=>({company:d(i(t,"company")),number:d(i(t,"number")),url:d(i(t,"url"))}))});function Re(e){let t=d(i(i(e,"lineItem"),"id"));return{quantity:M(i(e,"quantity")),lineItem:t===null?null:{id:t}}}function Ne(e){return A(e)?{returnableLineItems:w(e.returnableLineItems,Re)}:null}function fe(e){if(!A(e))return null;let t=s=>d(e[s]),n=s=>O(e[s]),r=e.requiresShipping;return{id:S(e.id,"order id"),name:t("name"),number:z(e.number),processedAt:t("processedAt"),cancelledAt:t("cancelledAt"),financialStatus:t("financialStatus"),fulfillmentStatus:t("fulfillmentStatus"),statusPageUrl:t("statusPageUrl"),requiresShipping:typeof r=="boolean"?r:null,totalPrice:n("totalPrice"),subtotal:n("subtotal"),totalShipping:n("totalShipping"),totalTax:n("totalTax"),shippingAddress:ce(e.shippingAddress),billingAddress:ce(e.billingAddress),lineItems:w(e.lineItems,Le),fulfillments:w(e.fulfillments,Ie),returnInformation:Ne(e.returnInformation),returns:w(e.returns,_)}}var ke=e=>({id:d(i(e,"id")),name:d(i(e,"name")),title:d(i(e,"title")),variantTitle:d(i(e,"variantTitle")),quantity:M(i(e,"quantity")),sku:d(i(e,"sku")),currentPrice:O(i(e,"currentPrice")),lineDiscountedPrice:O(i(e,"lineDiscountedPrice")),image:ie(i(e,"image"))}),ge=e=>({cycleIndex:z(i(e,"cycleIndex")),skipped:i(e,"skipped")===!0,billingAttemptExpectedDate:d(i(e,"billingAttemptExpectedDate"))});function De(e){if(!A(e))return null;let t=e.intervalCount;return{interval:d(e.interval),intervalCount:A(t)?{count:M(t.count)}:null}}var ve=e=>({id:S(i(e,"id"),"subscription id"),status:d(i(e,"status")),nextBillingDate:d(i(e,"nextBillingDate")),currencyCode:d(i(e,"currencyCode")),deliveryPrice:O(i(e,"deliveryPrice")),deliveryPolicy:De(i(e,"deliveryPolicy")),lines:w(i(e,"lines"),ke),upcomingBillingCycles:w(i(e,"upcomingBillingCycles"),ge)}),be=e=>q(e,ve);function ye(e){let{contract:t,billingCycle:n}=e;if(A(t))return{contract:{id:d(t.id),status:d(t.status)}};if(A(n)){let{cycleIndex:r,skipped:s}=ge(n);return{billingCycle:{cycleIndex:r,skipped:s}}}throw ae("changed subscription")}function _(e){return{id:S(i(e,"id"),"return id"),status:d(i(e,"status"))}}var he=e=>S(e,"deleted address id"),Ae=e=>({firstName:d(i(e,"firstName")),lastName:d(i(e,"lastName"))});var V=null;function Me(e){V=e}function I(){if(!V)throw new Error("account-pages: loaded without the account part");return V}async function T(e,t){let{serverFetch:n}=I(),{method:r,path:s}=le(e,t),o=await n(s,r==="POST"?{method:r,body:t}:{});if(o.kind==="logged-out")throw new H("Not logged in",{code:"NOT_LOGGED_IN",status:401});return o.data}function D(e){I().reset(),ne("account-updated",{what:e})}async function K(e){let t=await T("order",{id:e});return fe(t.order)}async function Q({firstName:e,lastName:t}={}){let n=await T("profile",{firstName:e,lastName:t});return D("profile"),Ae(n.customer)}async function W(){let e=await T("addresses",{});return pe(e.addresses)}async function F(e,{id:t,isDefault:n}={}){let r=await T("saveAddress",{id:t,address:e,isDefault:n});return D("addresses"),j(r.address)}async function X(e){let t=await T("deleteAddress",{id:e});return D("addresses"),he(t.deleted)}async function Y(){let e=await T("subscriptions",{});return be(e.subscriptions)}async function Z(e,t){let n=await T("subscription",{id:e,action:t});return D("subscriptions"),ye(n)}async function J(e,t){let n=await T("requestReturn",{orderId:e,lines:t});return D("orders"),_(n.return)}function qe(e){let t=p(e,"order")||"";return t.startsWith("url:")?new URL(window.location.href).searchParams.get(t.slice(4)||"id"):t}function v(e,t){e.setAttribute(f("order-state"),t),m(e,"order-show",{loading:t==="loading",ready:!1,"not-found":t==="not-found",error:t==="error"})}var He=e=>({name:e.name??"",date:C(e.processedAt),total:y(e.totalPrice),subtotal:y(e.subtotal),shipping:y(e.totalShipping),tax:y(e.totalTax),status:E(e.financialStatus),fulfillment:E(e.fulfillmentStatus),"shipping-address":k(e.shippingAddress),"billing-address":k(e.billingAddress),items:e.lineItems.nodes.map(t=>`${String(t.quantity)}\xD7 ${t.title||t.name||""}`).join(", "),cancelled:C(e.cancelledAt)});function Fe(e,t){let n=t.trackingInformation[0],r={status:E(t.latestShipmentStatus||t.status),date:C(t.createdAt),eta:C(t.estimatedDeliveryAt),company:n?.company||"",number:n?.number||""};L(e,"fulfillment-bind").forEach(s=>{let o=p(s,"fulfillment-bind")??"";if(o==="url"){let c=n?.url??null,b=c!==null&&G(c);b&&s.setAttribute("href",c),se(s,b);return}let u=h(r,o);u!==void 0&&g(s,u)})}function Be(e,t){let n=new Map((t.returnInformation?.returnableLineItems.nodes??[]).map(u=>[u.lineItem?.id??"",u.quantity])),r=t.fulfillments.nodes,s=He(t);l(e,a("order-bind")).forEach(u=>{let c=p(u,"order-bind")??"";if(c==="url"){let $=t.statusPageUrl;$!==null&&G($)&&u.setAttribute("href",$);return}let b=h(s,c);b!==void 0&&g(u,b)}),l(e,a("order-lines")).forEach(u=>{de(u,t.lineItems.nodes,n)}),l(e,a("order-fulfillments")).forEach(u=>{P(u,r,Fe)});let o=e.dataset.tetherReturned==="1";m(e,"order-show",{loading:!1,ready:!0,error:!1,"not-found":!1,cancelled:!!t.cancelledAt,shipped:r.length>0,returnable:[...n.values()].some(u=>u>0),"has-returns":!o&&t.returns.nodes.length>0,"return-requested":o}),e.setAttribute(f("order-state"),"ready")}async function B(e){let t=qe(e);if(!t){e.setAttribute(f("order-state"),"not-found"),m(e,"order-show",{"not-found":!0});return}v(e,"loading");let n;try{n=await K(t)}catch(r){x(r,"order"),v(e,"error");return}if(!n){v(e,"not-found");return}e.dataset.tetherOrderId=n.id,Be(e,n)}var we=[],xe=e=>we.find(t=>t.id===e),Ue=e=>({formatted:k(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 $e(e,t){e.dataset.tetherAddress=t.id;let n=Ue(t);L(e,"address-bind").forEach(r=>{let s=h(n,p(r,"address-bind")??"");s!==void 0&&g(r,s)}),m(e,"address-show",{default:t.isDefault,"not-default":!t.isDefault})}async function R(e){let t=l(e,a("addresses"));if(!t.length)return;m(e,"show",{"addresses-loading":!0,"addresses-empty":!1});let n;try{n=await W()}catch(r){x(r,"addresses"),m(e,"show",{"addresses-loading":!1,"addresses-error":!0});return}we=n,m(e,"show",{"addresses-loading":!1,"addresses-empty":n.length===0,"addresses-error":!1}),t.forEach(r=>{P(r,n,$e)})}function ze(e){let t=e.upcomingBillingCycles.nodes[0],n=e.status,r=n==="ACTIVE";return{active:r,paused:n==="PAUSED",cancelled:n==="CANCELLED",expired:n==="EXPIRED",failed:n==="FAILED",skipped:!!t?.skipped,"can-pause":r,"can-resume":n==="PAUSED"||n==="FAILED","can-skip":r&&t!==void 0&&!t.skipped,"can-unskip":r&&!!t?.skipped,"can-cancel":r||n==="PAUSED"||n==="FAILED"}}function Ge(e){let t=E(e.deliveryPolicy?.interval);if(!t)return"";let n=e.deliveryPolicy?.intervalCount?.count??1;return n<=1?t:`${String(n)} ${t}s`}function je(e){let t=e.lines.nodes,n=t.reduce((r,s)=>r+Number.parseFloat(s.lineDiscountedPrice?.amount??"0"),0);return{status:E(e.status),next:C(e.nextBillingDate),interval:Ge(e),products:t.map(r=>`${String(r.quantity)}\xD7 ${r.title??""}`).join(", "),total:y(t.length&&e.currencyCode?{amount:String(n),currencyCode:e.currencyCode}:null),delivery:y(e.deliveryPrice)}}function _e(e,t){let n={title:t.title??"","variant-title":t.variantTitle||"",quantity:String(t.quantity),price:y(t.currentPrice)};L(e,"subscription-line").forEach(r=>{let s=p(r,"subscription-line")??"";if(s==="image"){t.image&&re(r,t.image.url,t.image.altText||t.title||"");return}let o=h(n,s);o!==void 0&&g(r,o)})}function Ve(e,t){e.dataset.tetherSubscription=t.id,e.setAttribute(f("subscription-status"),E(t.status));let n=je(t);l(e,a("subscription-bind")).forEach(s=>{let o=h(n,p(s,"subscription-bind")??"");o!==void 0&&g(s,o)}),l(e,a("subscription-lines")).forEach(s=>{P(s,t.lines.nodes,_e)});let r=ze(t);m(e,"subscription-show",r),l(e,a("subscription-action")).forEach(s=>{let o=h(r,`can-${p(s,"subscription-action")??""}`)===!0;"disabled"in s&&(s.disabled=!o),s.classList.toggle("is-disabled",!o)})}async function U(e){let t=l(e,a("subscriptions"));if(!t.length)return;m(e,"show",{"subscriptions-loading":!0,"subscriptions-empty":!1});let n;try{n=await Y()}catch(r){x(r,"subscriptions"),m(e,"show",{"subscriptions-loading":!1,"subscriptions-error":!0});return}m(e,"show",{"subscriptions-loading":!1,"subscriptions-empty":n.length===0,"subscriptions-error":!1}),t.forEach(r=>{P(r,n,Ve)})}var Ke=["pause","resume","skip","unskip","cancel"],Qe=e=>Ke.some(t=>t===e),Ee=e=>e instanceof window.HTMLInputElement||e instanceof window.HTMLSelectElement||e instanceof window.HTMLTextAreaElement,Te=e=>e instanceof window.HTMLFormElement;function Se(e){let t={};for(let n of e.elements)Ee(n)&&(!n.name||n.type==="submit"||n.type==="button"||n.type==="checkbox"||(t[n.name]=n.value));return t}function We(e){let n=(e instanceof H?e.userErrors??[]:[]).map(s=>s.message).join(" ");return n||(e instanceof Error&&e.message?e.message:"Something went wrong").replace(/^Customer accounts: /,"")}async function N(e,t){if(e.getAttribute("aria-busy")==="true")return"busy";e.classList.add("is-busy"),e.setAttribute("aria-busy","true"),e.setAttribute(f("form-state"),"pending");let n=l(e,a("form-error"));n.forEach(r=>{g(r,"")});try{return await t(),e.setAttribute(f("form-state"),"saved"),"saved"}catch(r){return e.setAttribute(f("form-state"),"error"),n.forEach(s=>{g(s,We(r))}),"error"}finally{e.classList.remove("is-busy"),e.removeAttribute("aria-busy")}}var ee=e=>{let t=p(e,"confirm");return!t||window.confirm(t)},Pe=e=>{e.reset(),delete e.dataset.tetherAddressId};function Xe(e){let t=e.target;if(t instanceof window.HTMLFormElement){if(t.matches(a("profile-form")))e.preventDefault(),N(t,async()=>{await Q(Se(t)),await I().bindCustomer(document)});else if(t.matches(a("address-form"))){e.preventDefault();let n=t.dataset.tetherAddressId,r=t.elements.namedItem("isDefault"),s=r instanceof window.HTMLInputElement&&r.checked;N(t,async()=>{await F(Se(t),{id:n,isDefault:s}),Pe(t),await R(document)})}}}function Ye(e){let t=xe(e),n=document.querySelector(a("address-form"));if(!t||!n||!Te(n))return;n.dataset.tetherAddressId=t.id;let r={...t};for(let s of n.elements)if(Ee(s)){if(s.name==="isDefault")s instanceof window.HTMLInputElement&&(s.checked=t.isDefault);else if(s.name&&Object.hasOwn(r,s.name)){let o=r[s.name];s.value=typeof o=="string"?o:""}}n.scrollIntoView({block:"nearest"})}function Ze(e,t){let n=t.closest("[data-tether-address]"),r=n instanceof window.HTMLElement?n.dataset.tetherAddress:void 0;if(t.closest(a("address-new"))){let o=document.querySelector(a("address-form"));return o&&Te(o)&&Pe(o),!0}if(!(n instanceof window.HTMLElement)||!r)return!1;let s=t.closest(a("address-delete"));if(s){if(e.preventDefault(),!ee(s))return!0;N(n,async()=>{await X(r),await R(document)})}else if(t.closest(a("address-default")))e.preventDefault(),N(n,async()=>{await F(null,{id:r,isDefault:!0}),await R(document)});else if(t.closest(a("address-edit")))e.preventDefault(),Ye(r);else return!1;return!0}function Je(e){let t=e.closest("[data-tether-subscription]"),n=p(e,"subscription-action"),r="disabled"in e&&e.disabled===!0||e.classList.contains("is-disabled");if(!(t instanceof window.HTMLElement)||!Qe(n)||r||!ee(e))return;let s=t.dataset.tetherSubscription??"";t.setAttribute(f("subscription-state"),"pending"),N(t,async()=>{await Z(s,n),await U(document)}).then(o=>{let u=o==="error"?"error":"done";l(document,"[data-tether-subscription]").filter(c=>c===t||c.dataset.tetherSubscription===s).forEach(c=>{c.setAttribute(f("subscription-state"),u)})})}function et(e){let t=e.querySelector(a("return-quantity")),n=e.querySelector(a("return-reason")),r=e.querySelector(a("return-note")),s=b=>b&&"value"in b&&typeof b.value=="string"?b.value:"",o={lineItemId:e.dataset.tetherLine??"",quantity:Number.parseInt(s(t)||"0",10)},u=s(n);u&&(o.reasonId=u);let c=s(r);return c&&(o.note=c),o}function tt(e){let t=e.closest(a("order"));if(!(t instanceof window.HTMLElement))return;let n=t.dataset.tetherOrderId;if(!n)return;let r=l(t,"[data-tether-line]").map(et).filter(s=>s.quantity>0);!r.length||!ee(e)||N(t,async()=>{await J(n,r),t.dataset.tetherReturned="1",await B(t)})}function nt(e){let t=e.target;if(!(t instanceof window.Element)||Ze(e,t))return;let n=t.closest(a("subscription-action"));if(n instanceof window.HTMLElement){e.preventDefault(),Je(n);return}let r=t.closest(a("order-return"));r instanceof window.HTMLElement&&(e.preventDefault(),tt(r))}function Ce(){document.addEventListener("submit",Xe,!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",nt)}var rt=["firstName","lastName"];async function st(e){if(!(e instanceof window.HTMLFormElement))return;let t;try{t=await I().customer()}catch(r){x(r,"account");return}if(!t)return;let n=e.elements;rt.forEach(r=>{let s=n.namedItem(r);(s instanceof window.HTMLInputElement||s instanceof window.HTMLTextAreaElement)&&!s.dataset.tetherTouched&&(s.value=t[r]??"")})}var Oe=!1;async function Qt(e=document){Oe||(Oe=!0,Ce()),await Promise.all([...l(e,a("order")).map(t=>B(t)),...l(e,a("profile-form")).map(t=>st(t)),R(e),U(e)])}function Wt(e){l(e,a("order")).forEach(t=>{v(t,"error")}),m(e,"show",{"addresses-loading":!1,"addresses-error":!0,"subscriptions-loading":!1,"subscriptions-error":!0})}export{W as addresses,X as deleteAddress,K as order,Qt as renderPages,J as requestReturn,F as saveAddress,Me as setup,Wt as showUnavailable,Z as subscriptionAction,Y as subscriptions,Q as updateProfile};
1
+ import{a as O,b as ie,c as oe,d as ae,e as S,i as m,j as L,k as E,l as k,m as h,n as de}from"./chunk-7CRTJV25.js";import{C as y,D as C,F as g,H as se,a as H,l as f,m as a,n as p,p as l,t as ne,w as re,y as P}from"./chunk-OATTAXPO.js";import{C as G,d as A,e as i,g as d,h as z,i as M,j as q,k as w,l as te,z as x}from"./chunk-OJAV2I3C.js";var ue={order:{name:"order",method:"GET",path:"/order",fields:{id:!0}},addresses:{name:"addresses",method:"GET",path:"/addresses",fields:{}},subscriptions:{name:"subscriptions",method:"GET",path:"/subscriptions",fields:{}},profile:{name:"profile",method:"POST",path:"/profile",fields:{firstName:!0,lastName:!0}},saveAddress:{name:"saveAddress",method:"POST",path:"/address",fields:{id:!0,address:!0,isDefault:!0}},deleteAddress:{name:"deleteAddress",method:"POST",path:"/address/delete",fields:{id:!0}},subscription:{name:"subscription",method:"POST",path:"/subscription",fields:{id:!0,action:!0}},requestReturn:{name:"requestReturn",method:"POST",path:"/return",fields:{orderId:!0,lines:!0}}},it=new Map(Object.values(ue).map(e=>[`${e.method} ${e.path}`,{...e,fields:Object.keys(e.fields)}]));function le(e,t){let n=ue[e];if(n.method==="POST")return{method:"POST",path:n.path};let r=t,s=new URLSearchParams;for(let u of Object.keys(n.fields)){let c=r[u];(typeof c=="string"||typeof c=="number")&&s.set(u,String(c))}let o=s.toString();return{method:"GET",path:o?`${n.path}?${o}`:n.path}}function me(e){let t=n=>d(i(e,n));return{id:t("id"),firstName:t("firstName"),lastName:t("lastName"),company:t("company"),address1:t("address1"),address2:t("address2"),city:t("city"),province:t("province"),zoneCode:t("zoneCode"),zip:t("zip"),country:t("country"),countryCode:t("countryCode"),phoneNumber:t("phoneNumber"),formatted:te(i(e,"formatted"))}}var ce=e=>A(e)?me(e):null,j=e=>({...me(e),id:S(i(e,"id"),"address id")}),pe=e=>q(e,t=>({...j(t),isDefault:i(t,"isDefault")===!0})),Le=e=>({...oe(e),id:S(i(e,"id"),"line item id"),name:d(i(e,"name")),sku:d(i(e,"sku")),price:O(i(e,"price")),totalPrice:O(i(e,"totalPrice")),suggestedReturnReasonDefinitions:w(i(e,"suggestedReturnReasonDefinitions"),t=>({id:S(i(t,"id"),"return reason id"),name:d(i(t,"name")),handle:d(i(t,"handle"))}))}),Ie=e=>({id:d(i(e,"id")),status:d(i(e,"status")),createdAt:d(i(e,"createdAt")),estimatedDeliveryAt:d(i(e,"estimatedDeliveryAt")),latestShipmentStatus:d(i(e,"latestShipmentStatus")),trackingInformation:q(i(e,"trackingInformation"),t=>({company:d(i(t,"company")),number:d(i(t,"number")),url:d(i(t,"url"))}))});function Re(e){let t=d(i(i(e,"lineItem"),"id"));return{quantity:M(i(e,"quantity")),lineItem:t===null?null:{id:t}}}function Ne(e){return A(e)?{returnableLineItems:w(e.returnableLineItems,Re)}:null}function fe(e){if(!A(e))return null;let t=s=>d(e[s]),n=s=>O(e[s]),r=e.requiresShipping;return{id:S(e.id,"order id"),name:t("name"),number:z(e.number),processedAt:t("processedAt"),cancelledAt:t("cancelledAt"),financialStatus:t("financialStatus"),fulfillmentStatus:t("fulfillmentStatus"),statusPageUrl:t("statusPageUrl"),requiresShipping:typeof r=="boolean"?r:null,totalPrice:n("totalPrice"),subtotal:n("subtotal"),totalShipping:n("totalShipping"),totalTax:n("totalTax"),shippingAddress:ce(e.shippingAddress),billingAddress:ce(e.billingAddress),lineItems:w(e.lineItems,Le),fulfillments:w(e.fulfillments,Ie),returnInformation:Ne(e.returnInformation),returns:w(e.returns,_)}}var ke=e=>({id:d(i(e,"id")),name:d(i(e,"name")),title:d(i(e,"title")),variantTitle:d(i(e,"variantTitle")),quantity:M(i(e,"quantity")),sku:d(i(e,"sku")),currentPrice:O(i(e,"currentPrice")),lineDiscountedPrice:O(i(e,"lineDiscountedPrice")),image:ie(i(e,"image"))}),ge=e=>({cycleIndex:z(i(e,"cycleIndex")),skipped:i(e,"skipped")===!0,billingAttemptExpectedDate:d(i(e,"billingAttemptExpectedDate"))});function De(e){if(!A(e))return null;let t=e.intervalCount;return{interval:d(e.interval),intervalCount:A(t)?{count:M(t.count)}:null}}var ve=e=>({id:S(i(e,"id"),"subscription id"),status:d(i(e,"status")),nextBillingDate:d(i(e,"nextBillingDate")),currencyCode:d(i(e,"currencyCode")),deliveryPrice:O(i(e,"deliveryPrice")),deliveryPolicy:De(i(e,"deliveryPolicy")),lines:w(i(e,"lines"),ke),upcomingBillingCycles:w(i(e,"upcomingBillingCycles"),ge)}),be=e=>q(e,ve);function ye(e){let{contract:t,billingCycle:n}=e;if(A(t))return{contract:{id:d(t.id),status:d(t.status)}};if(A(n)){let{cycleIndex:r,skipped:s}=ge(n);return{billingCycle:{cycleIndex:r,skipped:s}}}throw ae("changed subscription")}function _(e){return{id:S(i(e,"id"),"return id"),status:d(i(e,"status"))}}var he=e=>S(e,"deleted address id"),Ae=e=>({firstName:d(i(e,"firstName")),lastName:d(i(e,"lastName"))});var V=null;function Me(e){V=e}function I(){if(!V)throw new Error("account-pages: loaded without the account part");return V}async function T(e,t){let{serverFetch:n}=I(),{method:r,path:s}=le(e,t),o=await n(s,r==="POST"?{method:r,body:t}:{});if(o.kind==="logged-out")throw new H("Not logged in",{code:"NOT_LOGGED_IN",status:401});return o.data}function D(e){I().reset(),ne("account-updated",{what:e})}async function K(e){let t=await T("order",{id:e});return fe(t.order)}async function Q({firstName:e,lastName:t}={}){let n=await T("profile",{firstName:e,lastName:t});return D("profile"),Ae(n.customer)}async function W(){let e=await T("addresses",{});return pe(e.addresses)}async function F(e,{id:t,isDefault:n}={}){let r=await T("saveAddress",{id:t,address:e,isDefault:n});return D("addresses"),j(r.address)}async function X(e){let t=await T("deleteAddress",{id:e});return D("addresses"),he(t.deleted)}async function Y(){let e=await T("subscriptions",{});return be(e.subscriptions)}async function Z(e,t){let n=await T("subscription",{id:e,action:t});return D("subscriptions"),ye(n)}async function J(e,t){let n=await T("requestReturn",{orderId:e,lines:t});return D("orders"),_(n.return)}function qe(e){let t=p(e,"order")||"";return t.startsWith("url:")?new URL(window.location.href).searchParams.get(t.slice(4)||"id"):t}function v(e,t){e.setAttribute(f("order-state"),t),m(e,"order-show",{loading:t==="loading",ready:!1,"not-found":t==="not-found",error:t==="error"})}var He=e=>({name:e.name??"",date:C(e.processedAt),total:y(e.totalPrice),subtotal:y(e.subtotal),shipping:y(e.totalShipping),tax:y(e.totalTax),status:E(e.financialStatus),fulfillment:E(e.fulfillmentStatus),"shipping-address":k(e.shippingAddress),"billing-address":k(e.billingAddress),items:e.lineItems.nodes.map(t=>`${String(t.quantity)}\xD7 ${t.title||t.name||""}`).join(", "),cancelled:C(e.cancelledAt)});function Fe(e,t){let n=t.trackingInformation[0],r={status:E(t.latestShipmentStatus||t.status),date:C(t.createdAt),eta:C(t.estimatedDeliveryAt),company:n?.company||"",number:n?.number||""};L(e,"fulfillment-bind").forEach(s=>{let o=p(s,"fulfillment-bind")??"";if(o==="url"){let c=n?.url??null,b=c!==null&&G(c);b&&s.setAttribute("href",c),se(s,b);return}let u=h(r,o);u!==void 0&&g(s,u)})}function Be(e,t){let n=new Map((t.returnInformation?.returnableLineItems.nodes??[]).map(u=>[u.lineItem?.id??"",u.quantity])),r=t.fulfillments.nodes,s=He(t);l(e,a("order-bind")).forEach(u=>{let c=p(u,"order-bind")??"";if(c==="url"){let $=t.statusPageUrl;$!==null&&G($)&&u.setAttribute("href",$);return}let b=h(s,c);b!==void 0&&g(u,b)}),l(e,a("order-lines")).forEach(u=>{de(u,t.lineItems.nodes,n)}),l(e,a("order-fulfillments")).forEach(u=>{P(u,r,Fe)});let o=e.dataset.tetherReturned==="1";m(e,"order-show",{loading:!1,ready:!0,error:!1,"not-found":!1,cancelled:!!t.cancelledAt,shipped:r.length>0,returnable:[...n.values()].some(u=>u>0),"has-returns":!o&&t.returns.nodes.length>0,"return-requested":o}),e.setAttribute(f("order-state"),"ready")}async function B(e){let t=qe(e);if(!t){e.setAttribute(f("order-state"),"not-found"),m(e,"order-show",{"not-found":!0});return}v(e,"loading");let n;try{n=await K(t)}catch(r){x(r,"order"),v(e,"error");return}if(!n){v(e,"not-found");return}e.dataset.tetherOrderId=n.id,Be(e,n)}var we=[],xe=e=>we.find(t=>t.id===e),Ue=e=>({formatted:k(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 $e(e,t){e.dataset.tetherAddress=t.id;let n=Ue(t);L(e,"address-bind").forEach(r=>{let s=h(n,p(r,"address-bind")??"");s!==void 0&&g(r,s)}),m(e,"address-show",{default:t.isDefault,"not-default":!t.isDefault})}async function R(e){let t=l(e,a("addresses"));if(!t.length)return;m(e,"show",{"addresses-loading":!0,"addresses-empty":!1});let n;try{n=await W()}catch(r){x(r,"addresses"),m(e,"show",{"addresses-loading":!1,"addresses-error":!0});return}we=n,m(e,"show",{"addresses-loading":!1,"addresses-empty":n.length===0,"addresses-error":!1}),t.forEach(r=>{P(r,n,$e)})}function ze(e){let t=e.upcomingBillingCycles.nodes[0],n=e.status,r=n==="ACTIVE";return{active:r,paused:n==="PAUSED",cancelled:n==="CANCELLED",expired:n==="EXPIRED",failed:n==="FAILED",skipped:!!t?.skipped,"can-pause":r,"can-resume":n==="PAUSED"||n==="FAILED","can-skip":r&&t!==void 0&&!t.skipped,"can-unskip":r&&!!t?.skipped,"can-cancel":r||n==="PAUSED"||n==="FAILED"}}function Ge(e){let t=E(e.deliveryPolicy?.interval);if(!t)return"";let n=e.deliveryPolicy?.intervalCount?.count??1;return n<=1?t:`${String(n)} ${t}s`}function je(e){let t=e.lines.nodes,n=t.reduce((r,s)=>r+Number.parseFloat(s.lineDiscountedPrice?.amount??"0"),0);return{status:E(e.status),next:C(e.nextBillingDate),interval:Ge(e),products:t.map(r=>`${String(r.quantity)}\xD7 ${r.title??""}`).join(", "),total:y(t.length&&e.currencyCode?{amount:String(n),currencyCode:e.currencyCode}:null),delivery:y(e.deliveryPrice)}}function _e(e,t){let n={title:t.title??"","variant-title":t.variantTitle||"",quantity:String(t.quantity),price:y(t.currentPrice)};L(e,"subscription-line").forEach(r=>{let s=p(r,"subscription-line")??"";if(s==="image"){t.image&&re(r,t.image.url,t.image.altText||t.title||"");return}let o=h(n,s);o!==void 0&&g(r,o)})}function Ve(e,t){e.dataset.tetherSubscription=t.id,e.setAttribute(f("subscription-status"),E(t.status));let n=je(t);l(e,a("subscription-bind")).forEach(s=>{let o=h(n,p(s,"subscription-bind")??"");o!==void 0&&g(s,o)}),l(e,a("subscription-lines")).forEach(s=>{P(s,t.lines.nodes,_e)});let r=ze(t);m(e,"subscription-show",r),l(e,a("subscription-action")).forEach(s=>{let o=h(r,`can-${p(s,"subscription-action")??""}`)===!0;"disabled"in s&&(s.disabled=!o),s.classList.toggle("is-disabled",!o)})}async function U(e){let t=l(e,a("subscriptions"));if(!t.length)return;m(e,"show",{"subscriptions-loading":!0,"subscriptions-empty":!1});let n;try{n=await Y()}catch(r){x(r,"subscriptions"),m(e,"show",{"subscriptions-loading":!1,"subscriptions-error":!0});return}m(e,"show",{"subscriptions-loading":!1,"subscriptions-empty":n.length===0,"subscriptions-error":!1}),t.forEach(r=>{P(r,n,Ve)})}var Ke=["pause","resume","skip","unskip","cancel"],Qe=e=>Ke.some(t=>t===e),Ee=e=>e instanceof window.HTMLInputElement||e instanceof window.HTMLSelectElement||e instanceof window.HTMLTextAreaElement,Te=e=>e instanceof window.HTMLFormElement;function Se(e){let t={};for(let n of e.elements)Ee(n)&&(!n.name||n.type==="submit"||n.type==="button"||n.type==="checkbox"||(t[n.name]=n.value));return t}function We(e){let n=(e instanceof H?e.userErrors??[]:[]).map(s=>s.message).join(" ");return n||(e instanceof Error&&e.message?e.message:"Something went wrong").replace(/^Customer accounts: /,"")}async function N(e,t){if(e.getAttribute("aria-busy")==="true")return"busy";e.classList.add("is-busy"),e.setAttribute("aria-busy","true"),e.setAttribute(f("form-state"),"pending");let n=l(e,a("form-error"));n.forEach(r=>{g(r,"")});try{return await t(),e.setAttribute(f("form-state"),"saved"),"saved"}catch(r){return e.setAttribute(f("form-state"),"error"),n.forEach(s=>{g(s,We(r))}),"error"}finally{e.classList.remove("is-busy"),e.removeAttribute("aria-busy")}}var ee=e=>{let t=p(e,"confirm");return!t||window.confirm(t)},Pe=e=>{e.reset(),delete e.dataset.tetherAddressId};function Xe(e){let t=e.target;if(t instanceof window.HTMLFormElement){if(t.matches(a("profile-form")))e.preventDefault(),N(t,async()=>{await Q(Se(t)),await I().bindCustomer(document)});else if(t.matches(a("address-form"))){e.preventDefault();let n=t.dataset.tetherAddressId,r=t.elements.namedItem("isDefault"),s=r instanceof window.HTMLInputElement&&r.checked;N(t,async()=>{await F(Se(t),{id:n,isDefault:s}),Pe(t),await R(document)})}}}function Ye(e){let t=xe(e),n=document.querySelector(a("address-form"));if(!t||!n||!Te(n))return;n.dataset.tetherAddressId=t.id;let r={...t};for(let s of n.elements)if(Ee(s)){if(s.name==="isDefault")s instanceof window.HTMLInputElement&&(s.checked=t.isDefault);else if(s.name&&Object.hasOwn(r,s.name)){let o=r[s.name];s.value=typeof o=="string"?o:""}}n.scrollIntoView({block:"nearest"})}function Ze(e,t){let n=t.closest("[data-tether-address]"),r=n instanceof window.HTMLElement?n.dataset.tetherAddress:void 0;if(t.closest(a("address-new"))){let o=document.querySelector(a("address-form"));return o&&Te(o)&&Pe(o),!0}if(!(n instanceof window.HTMLElement)||!r)return!1;let s=t.closest(a("address-delete"));if(s){if(e.preventDefault(),!ee(s))return!0;N(n,async()=>{await X(r),await R(document)})}else if(t.closest(a("address-default")))e.preventDefault(),N(n,async()=>{await F(null,{id:r,isDefault:!0}),await R(document)});else if(t.closest(a("address-edit")))e.preventDefault(),Ye(r);else return!1;return!0}function Je(e){let t=e.closest("[data-tether-subscription]"),n=p(e,"subscription-action"),r="disabled"in e&&e.disabled===!0||e.classList.contains("is-disabled");if(!(t instanceof window.HTMLElement)||!Qe(n)||r||!ee(e))return;let s=t.dataset.tetherSubscription??"";t.setAttribute(f("subscription-state"),"pending"),N(t,async()=>{await Z(s,n),await U(document)}).then(o=>{let u=o==="error"?"error":"done";l(document,"[data-tether-subscription]").filter(c=>c===t||c.dataset.tetherSubscription===s).forEach(c=>{c.setAttribute(f("subscription-state"),u)})})}function et(e){let t=e.querySelector(a("return-quantity")),n=e.querySelector(a("return-reason")),r=e.querySelector(a("return-note")),s=b=>b&&"value"in b&&typeof b.value=="string"?b.value:"",o={lineItemId:e.dataset.tetherLine??"",quantity:Number.parseInt(s(t)||"0",10)},u=s(n);u&&(o.reasonId=u);let c=s(r);return c&&(o.note=c),o}function tt(e){let t=e.closest(a("order"));if(!(t instanceof window.HTMLElement))return;let n=t.dataset.tetherOrderId;if(!n)return;let r=l(t,"[data-tether-line]").map(et).filter(s=>s.quantity>0);!r.length||!ee(e)||N(t,async()=>{await J(n,r),t.dataset.tetherReturned="1",await B(t)})}function nt(e){let t=e.target;if(!(t instanceof window.Element)||Ze(e,t))return;let n=t.closest(a("subscription-action"));if(n instanceof window.HTMLElement){e.preventDefault(),Je(n);return}let r=t.closest(a("order-return"));r instanceof window.HTMLElement&&(e.preventDefault(),tt(r))}function Ce(){document.addEventListener("submit",Xe,!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",nt)}var rt=["firstName","lastName"];async function st(e){if(!(e instanceof window.HTMLFormElement))return;let t;try{t=await I().customer()}catch(r){x(r,"account");return}if(!t)return;let n=e.elements;rt.forEach(r=>{let s=n.namedItem(r);(s instanceof window.HTMLInputElement||s instanceof window.HTMLTextAreaElement)&&!s.dataset.tetherTouched&&(s.value=t[r]??"")})}var Oe=!1;async function Qt(e=document){Oe||(Oe=!0,Ce()),await Promise.all([...l(e,a("order")).map(t=>B(t)),...l(e,a("profile-form")).map(t=>st(t)),R(e),U(e)])}function Wt(e){l(e,a("order")).forEach(t=>{v(t,"error")}),m(e,"show",{"addresses-loading":!1,"addresses-error":!0,"subscriptions-loading":!1,"subscriptions-error":!0})}export{W as addresses,X as deleteAddress,K as order,Qt as renderPages,J as requestReturn,F as saveAddress,Me as setup,Wt as showUnavailable,Z as subscriptionAction,Y as subscriptions,Q as updateProfile};
@@ -1 +1 @@
1
- import{a as A}from"./chunk-F2BYVA7V.js";import{h}from"./chunk-P6DV24RG.js";import"./chunk-XU27NSXT.js";import"./chunk-S5BUUIB6.js";import"./chunk-2IGCUTG5.js";import"./chunk-EUCFOBIT.js";import"./chunk-ZBV2JSHE.js";import{d as k,h as E,m as p,r as _,s as w}from"./chunk-P73VN3B6.js";import{r as a,x as T,z as l}from"./chunk-D3MRWOFI.js";var F=500,S={"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"},O="https://cdn.shopify.com/storefront/analytics/shopify.js",x=()=>window,m=()=>x().Shopify;function L(){let t=a.analytics?.shopify;return typeof t=="object"?t:{}}function I(){try{let t=m()?.customerPrivacy;return t?.consentStatus==="loaded"&&t.currentVisitorConsent?.()?.analytics!=="no"&&!!t.analyticsProcessingAllowed?.()}catch{return!1}}function j(t){let e=`hydrogen:${t}`;return{getTrackingValues:()=>{let n=I()?m()?.customerPrivacy?.__internal:void 0;return{uniqueToken:n?.uniqueToken?.({generateFallback:!0,tag:e})??"",visitToken:n?.visitToken?.({generateFallback:!0,tag:e})??""}}}}var $=t=>(e,n)=>{let i=t.subscribers.get(e)??new Set;return t.subscribers.set(e,i),i.add(n),()=>t.subscribers.get(e)?.delete(n)};function U(t){let e=[],n=[],i={shop:{shopId:t,channel:"headless"},consent:{mode:L().consent||"no-banner"}},o=()=>{if(I())for(let r of e)for(;r.next<n.length;r.next+=1){let s=n[r.next];s&&G(r,s)}},c={getConfig:()=>i,publish(r,s={}){if(n.push({event:r,payload:{shop:i.shop,url:window.location.href,...s}}),n.length>F){n.shift();for(let d of e)d.next=Math.max(0,d.next-1)}o()},addDestination(r){let s={name:r.name,next:0,subscribers:new Map,context:j(r.name)};return Promise.resolve(r.setup?.({subscribe:$(s),getConfig:c.getConfig})).then(()=>{e.push(s),o()}).catch(d=>{l(d,`analytics ${r.name}`)}),()=>{let d=e.indexOf(s);d>=0&&e.splice(d,1)}}};return document.addEventListener("consentTrackingApiLoaded",o),document.addEventListener("visitorConsentCollected",o),c}function G(t,{event:e,payload:n}){t.subscribers.get(e)?.forEach(i=>{try{i(n,t.context)}catch(o){l(o,`analytics ${t.name}`)}})}function P(t){let e=document.createElement("script");e.src=t,e.async=!0,document.head.appendChild(e)}async function R(t){let e=m();if(e?.analytics)return e.analytics;let n=await E("query TetherShopId { shop { id } }",{},k({shop:{id:"string"}}),{context:!1}),i=m()??{};x().Shopify=i,i.country=a.country??"US";let[o="en"]=(a.locale||"en").split("-");i.locale=o.toLowerCase(),i.shop=a.domain,i.routes={root:"/",match:()=>({pageTemplateName:t()?"product":"page"}),...i.routes};let{proxy:c,consent:r}=L();i.customerPrivacy={...i.customerPrivacy,config:c?{isHeadless:!0,asyncConsent:!0,asyncVisitorState:!0,consentDomain:window.location.host}:{isHeadless:!0,storefrontAccessToken:a.token,checkoutRootDomain:a.domain}};let s=U(n.shop.id);return i.analytics=s,P(r==="default-banner"?S["default-banner"]:S.other),P(O),T("shopify analytics ready",n.shop.id),s}var W="Default Title",V=100,H=200,Y=t=>t?parseFloat(t.amount):0,N=t=>(t??"").split("/").pop()??"";function C(t,e,n=1,i){let o={item_id:e?.sku||N(e?.id)||N(t.id),item_name:t.title,item_variant:e?.title===W?void 0:e?.title,item_brand:t.vendor||void 0,item_category:t.productType||void 0,price:Y(e?.price??t.priceRange?.minVariantPrice),quantity:n};return i!=null&&(o.index=i),o}var g=(t,e=t.quantity)=>C(t.merchandise.product,t.merchandise,e);function f(t){let e=t.reduce((n,i)=>n+i.price*(i.quantity||1),0);return Math.round(e*V)/V}var X=(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}),D=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 Z(){let{dataLayer:t}=a.analytics??{},e=typeof t=="string"?t:"dataLayer",n=Reflect.get(window,e);if(Array.isArray(n))return n;let i=[];return Reflect.set(window,e,i),i}function z(t,e){let n=Z();if(!e){n.push({event:t});return}n.push({ecommerce:null}),n.push({event:t,ecommerce:e})}var y=null,v=null,q=null,b=new WeakSet;function u(t,e,n,i){a.analytics?.dataLayer&&z(t,e),y&&n&&y.publish(n,i);try{a.analytics?.onEvent?.(t,e)}catch(o){l(o,"analytics onEvent")}}function M(){let t=document.querySelector(p("product"));return!t||t.closest(`${p("collection")},${p("products")},${p("recommendations")}`)?null:A.get(t)??null}function J({product:t,scope:e}){if(b.has(e.root)||M()!==e)return;b.add(e.root);let n=e.variant??t.variants.nodes[0],i=[C(t,n)],o=n?[X(t,n)]:[];u("view_item",{currency:n?.price.currencyCode,value:f(i),items:i},"product_viewed",{products:o})}function K({products:t,collection:e}){let n=t.slice(0,H).map((o,c)=>C(o,o.variants.nodes[0],1,c)),i={item_list_id:e?.handle||"products",item_list_name:e?.title||"Products"};if(!e){u("view_item_list",{...i,items:n});return}u("view_item_list",{...i,items:n},"collection_viewed",{collection:{id:e.id,handle:e.handle}})}function Q(t,e,n){let i=t?.cost.totalAmount.currencyCode;e.forEach((o,c)=>{let r=n.get(c),s=o.quantity-(r?.quantity??0);if(s<=0)return;let d=[g(o,s)];u("add_to_cart",{currency:i,value:f(d),items:d},"product_added_to_cart",{cart:t,prevCart:q,currentLine:D(o),prevLine:r?D(r):void 0})}),n.forEach((o,c)=>{let r=o.quantity-(e.get(c)?.quantity??0);if(r<=0)return;let s=[g(o,r)];u("remove_from_cart",{currency:i,value:f(s),items:s})})}function tt({cart:t,reason:e}){let n=new Map((t?.lines.nodes??[]).map(i=>[i.merchandise.id,i]));v&&e!=="load"&&e!=="pending"&&Q(t,n,v),v=n,q=t}function et(){let t=h.lines.map(e=>g(e));u("view_cart",{currency:h.state?.cost.totalAmount.currencyCode,value:f(t),items:t})}function nt({cart:t}){if(!t)return;let e=t.lines.nodes.map(i=>g(i)),n=t.discountCodes.filter(i=>i.applicable).map(i=>i.code);u("begin_checkout",{currency:t.cost.totalAmount.currencyCode,value:f(e),coupon:n.join(",")||void 0,items:e})}var it={"product-ready":J,"list-ready":K,"cart-updated":tt,"cart-toggled":({open:t})=>{t&&et()},checkout:nt,search:({term:t})=>{t&&u("search",{search_term:t},"search_viewed",{searchTerm:t})}};function ot(t,e){it[e](t.detail)}function B(t){if(t.type==="astro:page-load"){b=new WeakSet,y?.publish("page_viewed",{});return}_.forEach(e=>{w(t,e)&&ot(t,e)})}async function ft(t){a.analytics?.shopify&&(y=await R(()=>M()!=null).catch(e=>(l(e,"shopify analytics"),null))),y?.publish("page_viewed",{}),t.splice(0).forEach(B),t.push=(...e)=>(e.forEach(B),t.length)}export{ft as startAnalytics};
1
+ import{a as A}from"./chunk-FI4NIWAD.js";import{h}from"./chunk-7ZXEVDOS.js";import"./chunk-DM5LEAWM.js";import"./chunk-BVO7KK2M.js";import"./chunk-CRKJ2VEX.js";import"./chunk-H6IORH7O.js";import"./chunk-FWMPL6PR.js";import{d as k,h as E,m as p,r as _,s as w}from"./chunk-OATTAXPO.js";import{r as a,x as T,z as l}from"./chunk-OJAV2I3C.js";var F=500,S={"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"},O="https://cdn.shopify.com/storefront/analytics/shopify.js",x=()=>window,m=()=>x().Shopify;function L(){let t=a.analytics?.shopify;return typeof t=="object"?t:{}}function I(){try{let t=m()?.customerPrivacy;return t?.consentStatus==="loaded"&&t.currentVisitorConsent?.()?.analytics!=="no"&&!!t.analyticsProcessingAllowed?.()}catch{return!1}}function j(t){let e=`hydrogen:${t}`;return{getTrackingValues:()=>{let n=I()?m()?.customerPrivacy?.__internal:void 0;return{uniqueToken:n?.uniqueToken?.({generateFallback:!0,tag:e})??"",visitToken:n?.visitToken?.({generateFallback:!0,tag:e})??""}}}}var $=t=>(e,n)=>{let i=t.subscribers.get(e)??new Set;return t.subscribers.set(e,i),i.add(n),()=>t.subscribers.get(e)?.delete(n)};function U(t){let e=[],n=[],i={shop:{shopId:t,channel:"headless"},consent:{mode:L().consent||"no-banner"}},o=()=>{if(I())for(let r of e)for(;r.next<n.length;r.next+=1){let s=n[r.next];s&&G(r,s)}},c={getConfig:()=>i,publish(r,s={}){if(n.push({event:r,payload:{shop:i.shop,url:window.location.href,...s}}),n.length>F){n.shift();for(let d of e)d.next=Math.max(0,d.next-1)}o()},addDestination(r){let s={name:r.name,next:0,subscribers:new Map,context:j(r.name)};return Promise.resolve(r.setup?.({subscribe:$(s),getConfig:c.getConfig})).then(()=>{e.push(s),o()}).catch(d=>{l(d,`analytics ${r.name}`)}),()=>{let d=e.indexOf(s);d>=0&&e.splice(d,1)}}};return document.addEventListener("consentTrackingApiLoaded",o),document.addEventListener("visitorConsentCollected",o),c}function G(t,{event:e,payload:n}){t.subscribers.get(e)?.forEach(i=>{try{i(n,t.context)}catch(o){l(o,`analytics ${t.name}`)}})}function P(t){let e=document.createElement("script");e.src=t,e.async=!0,document.head.appendChild(e)}async function R(t){let e=m();if(e?.analytics)return e.analytics;let n=await E("query TetherShopId { shop { id } }",{},k({shop:{id:"string"}}),{context:!1}),i=m()??{};x().Shopify=i,i.country=a.country??"US";let[o="en"]=(a.locale||"en").split("-");i.locale=o.toLowerCase(),i.shop=a.domain,i.routes={root:"/",match:()=>({pageTemplateName:t()?"product":"page"}),...i.routes};let{proxy:c,consent:r}=L();i.customerPrivacy={...i.customerPrivacy,config:c?{isHeadless:!0,asyncConsent:!0,asyncVisitorState:!0,consentDomain:window.location.host}:{isHeadless:!0,storefrontAccessToken:a.token,checkoutRootDomain:a.domain}};let s=U(n.shop.id);return i.analytics=s,P(r==="default-banner"?S["default-banner"]:S.other),P(O),T("shopify analytics ready",n.shop.id),s}var W="Default Title",V=100,H=200,Y=t=>t?parseFloat(t.amount):0,N=t=>(t??"").split("/").pop()??"";function C(t,e,n=1,i){let o={item_id:e?.sku||N(e?.id)||N(t.id),item_name:t.title,item_variant:e?.title===W?void 0:e?.title,item_brand:t.vendor||void 0,item_category:t.productType||void 0,price:Y(e?.price??t.priceRange?.minVariantPrice),quantity:n};return i!=null&&(o.index=i),o}var g=(t,e=t.quantity)=>C(t.merchandise.product,t.merchandise,e);function f(t){let e=t.reduce((n,i)=>n+i.price*(i.quantity||1),0);return Math.round(e*V)/V}var X=(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}),D=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 Z(){let{dataLayer:t}=a.analytics??{},e=typeof t=="string"?t:"dataLayer",n=Reflect.get(window,e);if(Array.isArray(n))return n;let i=[];return Reflect.set(window,e,i),i}function z(t,e){let n=Z();if(!e){n.push({event:t});return}n.push({ecommerce:null}),n.push({event:t,ecommerce:e})}var y=null,v=null,q=null,b=new WeakSet;function u(t,e,n,i){a.analytics?.dataLayer&&z(t,e),y&&n&&y.publish(n,i);try{a.analytics?.onEvent?.(t,e)}catch(o){l(o,"analytics onEvent")}}function M(){let t=document.querySelector(p("product"));return!t||t.closest(`${p("collection")},${p("products")},${p("recommendations")}`)?null:A.get(t)??null}function J({product:t,scope:e}){if(b.has(e.root)||M()!==e)return;b.add(e.root);let n=e.variant??t.variants.nodes[0],i=[C(t,n)],o=n?[X(t,n)]:[];u("view_item",{currency:n?.price.currencyCode,value:f(i),items:i},"product_viewed",{products:o})}function K({products:t,collection:e}){let n=t.slice(0,H).map((o,c)=>C(o,o.variants.nodes[0],1,c)),i={item_list_id:e?.handle||"products",item_list_name:e?.title||"Products"};if(!e){u("view_item_list",{...i,items:n});return}u("view_item_list",{...i,items:n},"collection_viewed",{collection:{id:e.id,handle:e.handle}})}function Q(t,e,n){let i=t?.cost.totalAmount.currencyCode;e.forEach((o,c)=>{let r=n.get(c),s=o.quantity-(r?.quantity??0);if(s<=0)return;let d=[g(o,s)];u("add_to_cart",{currency:i,value:f(d),items:d},"product_added_to_cart",{cart:t,prevCart:q,currentLine:D(o),prevLine:r?D(r):void 0})}),n.forEach((o,c)=>{let r=o.quantity-(e.get(c)?.quantity??0);if(r<=0)return;let s=[g(o,r)];u("remove_from_cart",{currency:i,value:f(s),items:s})})}function tt({cart:t,reason:e}){let n=new Map((t?.lines.nodes??[]).map(i=>[i.merchandise.id,i]));v&&e!=="load"&&e!=="pending"&&Q(t,n,v),v=n,q=t}function et(){let t=h.lines.map(e=>g(e));u("view_cart",{currency:h.state?.cost.totalAmount.currencyCode,value:f(t),items:t})}function nt({cart:t}){if(!t)return;let e=t.lines.nodes.map(i=>g(i)),n=t.discountCodes.filter(i=>i.applicable).map(i=>i.code);u("begin_checkout",{currency:t.cost.totalAmount.currencyCode,value:f(e),coupon:n.join(",")||void 0,items:e})}var it={"product-ready":J,"list-ready":K,"cart-updated":tt,"cart-toggled":({open:t})=>{t&&et()},checkout:nt,search:({term:t})=>{t&&u("search",{search_term:t},"search_viewed",{searchTerm:t})}};function ot(t,e){it[e](t.detail)}function B(t){if(t.type==="astro:page-load"){b=new WeakSet,y?.publish("page_viewed",{});return}_.forEach(e=>{w(t,e)&&ot(t,e)})}async function ft(t){a.analytics?.shopify&&(y=await R(()=>M()!=null).catch(e=>(l(e,"shopify analytics"),null))),y?.publish("page_viewed",{}),t.splice(0).forEach(B),t.push=(...e)=>(e.forEach(B),t.length)}export{ft as startAnalytics};
@@ -0,0 +1 @@
1
+ var e={diagnose:()=>import("./diagnose-XSZPWEG7.js"),markets:()=>import("./markets-ui-DEEYV4KT.js"),search:()=>import("./search-A6HF5PMJ.js"),lists:()=>import("./lists-OJGSVQMM.js"),extras:()=>import("./extras-DZIOTZ3H.js"),account:()=>import("./account-XBGNTM7V.js"),"account-pages":()=>import("./account-pages-FIXSWJH7.js"),analytics:()=>import("./analytics-MO2ZWBOD.js")},a=t=>e[t](),o=void 0;export{a,o as b};
@@ -0,0 +1 @@
1
+ import{a as n}from"./chunk-2J3MTS3E.js";import{g as r}from"./chunk-CRKJ2VEX.js";import{m as e}from"./chunk-OATTAXPO.js";import{z as i}from"./chunk-OJAV2I3C.js";var d=()=>`${e("collection")},${e("products")},${e("recommendations")}`;function a(t){return r(t,"loading"),{root:t,load:()=>n("lists").then(o=>o.loadList(t)).catch(o=>{r(t,"error",o),i(o,"lists")})}}export{d as a,a as b};
@@ -1 +1 @@
1
- import{C as g,F as E,H as N,a as L,m as l,n as u,p as d,w as k,y as w}from"./chunk-P73VN3B6.js";import{d as x,e as o,f as y,g as i,i as A,j as h,k as T,l as f}from"./chunk-D3MRWOFI.js";function q(t){let e=i(o(t,"amount")),n=i(o(t,"currencyCode"));return e===null||n===null?null:{amount:e,currencyCode:n}}function S(t){let e=i(o(t,"url"));return e===null?null:{url:e,altText:i(o(t,"altText"))}}var U=t=>({title:i(o(t,"title")),variantTitle:i(o(t,"variantTitle")),quantity:A(o(t,"quantity")),image:S(o(t,"image"))}),H=(t,e)=>({id:e,name:i(o(t,"name")),processedAt:i(o(t,"processedAt")),financialStatus:i(o(t,"financialStatus")),fulfillmentStatus:i(o(t,"fulfillmentStatus")),statusPageUrl:i(o(t,"statusPageUrl")),totalPrice:q(o(t,"totalPrice")),lineItems:T(o(t,"lineItems"),U)});function R(t){let e=[];for(let n of y(t)){let r=i(o(n,"id"));if(r===null)return{kind:"missing-id"};e.push(H(n,r))}return{kind:"read",orders:e}}var I=t=>new L(`Customer accounts: the answer has no ${t}`);function G(t,e){let n=i(t);if(!n)throw I(e);return n}function J(t){let e=x(t)?t:{},n=i(e.id),r=i(e.email),s=e.address;return{...n===null?{}:{id:n},firstName:i(e.firstName),lastName:i(e.lastName),displayName:i(e.displayName),emailAddress:r===null?null:{emailAddress:r},defaultAddress:Array.isArray(s)?{formatted:f(s)}:null}}function K(t){let e=R(t);if(e.kind==="missing-id")throw I("order id");return e.orders}function D(t){let e=i(o(t,"message"));if(e===null)return null;let n=o(t,"field");return{message:e,field:Array.isArray(n)?f(n):null,code:i(o(t,"code"))}}var Q=t=>h(t,D).filter(e=>e!==null);function P(t,e,n){d(t,l(e)).forEach(r=>{let s=u(r,e)??"";Object.hasOwn(n,s)&&N(r,n[s]===!0)})}var b=(t,e)=>d(t,l(e)).concat(t.matches(l(e))?[t]:[]),Y=t=>t?t.toLowerCase().replace(/_/g," "):"",v=t=>(t?.formatted??[]).join(", "),M=(t,e)=>Object.hasOwn(t,e)?t[e]:void 0;var j=(t,e)=>({title:t.title||t.name||"","variant-title":t.variantTitle||"",quantity:String(t.quantity),price:g(t.price),total:g(t.totalPrice),sku:t.sku||"",returnable:e===null?void 0:String(e)}),F=t=>t.tagName==="INPUT";function V(t,e,n){P(t,"order-line-show",{returnable:n>0}),d(t,l("return-quantity")).forEach(r=>{F(r)&&(r.max=String(n),r.min="0",r.value||(r.value="0"),r.disabled=n<1)}),d(t,`select${l("return-reason")}`).forEach(r=>{r.dataset.tetherFilled!==e.id&&(r.dataset.tetherFilled=e.id,(e.suggestedReturnReasonDefinitions?.nodes??[]).forEach(s=>{r.appendChild(new Option(s.name??"",s.id))}))})}function rt(t,e,n){w(t,e,(r,s)=>{let a=s.id,c=n&&a?n.get(a)??0:null;a&&(r.dataset.tetherLine=a);let C=j(s,c);b(r,"order-line").forEach(m=>{let p=u(m,"order-line")??"";if(p==="image"){s.image&&k(m,s.image.url,s.image.altText||s.title||"");return}let O=M(C,p);O!==void 0&&E(m,O)}),a&&c!==null&&V(r,{...s,id:a},c)})}export{q as a,S as b,U as c,I as d,G as e,J as f,K as g,Q as h,P as i,b as j,Y as k,v as l,M as m,rt as n};
1
+ import{C as g,F as E,H as N,a as L,m as l,n as u,p as d,w as k,y as w}from"./chunk-OATTAXPO.js";import{d as x,e as o,f as y,g as i,i as A,j as h,k as T,l as f}from"./chunk-OJAV2I3C.js";function q(t){let e=i(o(t,"amount")),n=i(o(t,"currencyCode"));return e===null||n===null?null:{amount:e,currencyCode:n}}function S(t){let e=i(o(t,"url"));return e===null?null:{url:e,altText:i(o(t,"altText"))}}var U=t=>({title:i(o(t,"title")),variantTitle:i(o(t,"variantTitle")),quantity:A(o(t,"quantity")),image:S(o(t,"image"))}),H=(t,e)=>({id:e,name:i(o(t,"name")),processedAt:i(o(t,"processedAt")),financialStatus:i(o(t,"financialStatus")),fulfillmentStatus:i(o(t,"fulfillmentStatus")),statusPageUrl:i(o(t,"statusPageUrl")),totalPrice:q(o(t,"totalPrice")),lineItems:T(o(t,"lineItems"),U)});function R(t){let e=[];for(let n of y(t)){let r=i(o(n,"id"));if(r===null)return{kind:"missing-id"};e.push(H(n,r))}return{kind:"read",orders:e}}var I=t=>new L(`Customer accounts: the answer has no ${t}`);function G(t,e){let n=i(t);if(!n)throw I(e);return n}function J(t){let e=x(t)?t:{},n=i(e.id),r=i(e.email),s=e.address;return{...n===null?{}:{id:n},firstName:i(e.firstName),lastName:i(e.lastName),displayName:i(e.displayName),emailAddress:r===null?null:{emailAddress:r},defaultAddress:Array.isArray(s)?{formatted:f(s)}:null}}function K(t){let e=R(t);if(e.kind==="missing-id")throw I("order id");return e.orders}function D(t){let e=i(o(t,"message"));if(e===null)return null;let n=o(t,"field");return{message:e,field:Array.isArray(n)?f(n):null,code:i(o(t,"code"))}}var Q=t=>h(t,D).filter(e=>e!==null);function P(t,e,n){d(t,l(e)).forEach(r=>{let s=u(r,e)??"";Object.hasOwn(n,s)&&N(r,n[s]===!0)})}var b=(t,e)=>d(t,l(e)).concat(t.matches(l(e))?[t]:[]),Y=t=>t?t.toLowerCase().replace(/_/g," "):"",v=t=>(t?.formatted??[]).join(", "),M=(t,e)=>Object.hasOwn(t,e)?t[e]:void 0;var j=(t,e)=>({title:t.title||t.name||"","variant-title":t.variantTitle||"",quantity:String(t.quantity),price:g(t.price),total:g(t.totalPrice),sku:t.sku||"",returnable:e===null?void 0:String(e)}),F=t=>t.tagName==="INPUT";function V(t,e,n){P(t,"order-line-show",{returnable:n>0}),d(t,l("return-quantity")).forEach(r=>{F(r)&&(r.max=String(n),r.min="0",r.value||(r.value="0"),r.disabled=n<1)}),d(t,`select${l("return-reason")}`).forEach(r=>{r.dataset.tetherFilled!==e.id&&(r.dataset.tetherFilled=e.id,(e.suggestedReturnReasonDefinitions?.nodes??[]).forEach(s=>{r.appendChild(new Option(s.name??"",s.id))}))})}function rt(t,e,n){w(t,e,(r,s)=>{let a=s.id,c=n&&a?n.get(a)??0:null;a&&(r.dataset.tetherLine=a);let C=j(s,c);b(r,"order-line").forEach(m=>{let p=u(m,"order-line")??"";if(p==="image"){s.image&&k(m,s.image.url,s.image.altText||s.title||"");return}let O=M(C,p);O!==void 0&&E(m,O)}),a&&c!==null&&V(r,{...s,id:a},c)})}export{q as a,S as b,U as c,I as d,G as e,J as f,K as g,Q as h,P as i,b as j,Y as k,v as l,M as m,rt as n};
@@ -1 +1 @@
1
- import{a as Pt,d as Q,e as kt}from"./chunk-S5BUUIB6.js";import{c as Et}from"./chunk-EUCFOBIT.js";import{b as Z,d as R}from"./chunk-ZBV2JSHE.js";import{A as W,C as v,D as vt,E as At,F as g,G as k,H as M,K as Lt,P as D,a as b,c as q,d as H,h as V,k as ht,l as L,m as s,n as f,o as yt,p as d,t as y,v as bt,w as P,x as St,y as T,z as wt}from"./chunk-P73VN3B6.js";import{C as Ct,r as l,x as gt,z as w}from"./chunk-D3MRWOFI.js";var ne={id:"string",quantity:"number",attributes:["object"],cost:{totalAmount:R,subtotalAmount:R,amountPerQuantity:R},merchandise:{id:"string",selectedOptions:["object"],product:"object"}},tt={id:"string",checkoutUrl:"string",totalQuantity:"number",attributes:["object"],discountCodes:["object"],cost:{totalAmount:R,subtotalAmount:R},lines:{nodes:[ne]}};var re='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',ie=60,et=!1,K=null,oe=t=>t!==null&&"focus"in t,It=t=>d(t,re).filter(e=>e.offsetParent!==null||e===document.activeElement),$=()=>d(document,s("cart-drawer")),nt=t=>t.classList.contains(l.cartDrawerOpenClass);function S(){let t=$();return t.length?t.some(nt):et}function j(t){d(document,s("cart-open")).forEach(e=>{e.setAttribute("aria-expanded",String(t))}),$().forEach(e=>{e.hasAttribute("role")||e.setAttribute("role","dialog"),!e.hasAttribute("aria-label")&&!e.hasAttribute("aria-labelledby")&&e.setAttribute("aria-label",f(e,"cart-label")||"Cart"),e.setAttribute("aria-modal",String(t)),!nt(e)&&(e.setAttribute("aria-hidden","true"),l.cartFocus&&(e.inert=!0))})}function ae(t){let e=It(t)[0]??t;e===t&&!t.hasAttribute("tabindex")&&(t.tabIndex=-1),e.focus({preventScroll:!0})}function B(){if(S())return;et=!0;let t=$().filter(n=>f(n,"cart-drawer")!=="manual");t.forEach(n=>{n.inert=!1,n.classList.add(l.cartDrawerOpenClass),n.setAttribute("aria-hidden","false")}),j(!0);let[e]=t;l.cartFocus&&e&&(K=oe(document.activeElement)?document.activeElement:null,setTimeout(()=>{ae(e)},ie)),l.onCartOpen?.(t),y("cart-toggled",{open:!0})}function rt(){if(!S())return;et=!1;let t=$(),e=t.some(n=>n.contains(document.activeElement));t.forEach(n=>{n.classList.remove(l.cartDrawerOpenClass),n.setAttribute("aria-hidden","true"),l.cartFocus&&(n.inert=!0)}),j(!1),e&&K?.isConnected&&K.focus({preventScroll:!0}),K=null,l.onCartClose?.(t),y("cart-toggled",{open:!1})}function xt(){S()?rt():B()}function se(t){if(t.key!=="Tab"||!l.cartFocus||!S())return;let e=$().find(nt);if(!e)return;let n=It(e),r=n[0],i=n.at(-1);if(!r||!i)return;let o=document.activeElement,a=t.shiftKey?o===r:o===i;e.contains(o)&&!a||(t.preventDefault(),(t.shiftKey?i:r).focus())}var ue=/^image:(\d+)$/,Tt="metafield:",ce=/^(rich_text|multi_line_text)_field$/,le=["","true","all","*"],ot=t=>t.tagName==="SELECT",it=(t,e)=>t.$(`select${e}`).filter(ot);function de(t,e){let n=e.images.nodes,r=[...t.children].map(o=>o.tagName==="IMG"?o:o.querySelector("img"));!St(t)&&r.length===n.length&&r.every((o,a)=>bt(o?.getAttribute("src"),n[a]?.url))||T(t,n,(o,a)=>{let u=o.matches(`img,${s("bind","image")}`)?o:d(o,"img")[0]??o;P(u,a.url,a.altText||e.title)})}function me(t,e,n){let r=n.indexOf("."),i=n.slice(0,r),o=n.slice(r+1),a=(e.metafields??[]).find(c=>c?.namespace===i&&c.key===o);if(!a){g(t,"");return}let u=a.reference?.image;if(u){P(t,u.url,u.altText);return}ce.test(a.type)&&(t.style.whiteSpace="pre-line"),g(t,a.value)}var pe=new Map(Object.entries({title:t=>t.title,"description-text":t=>t.description,vendor:t=>t.vendor,type:t=>t.productType,handle:t=>t.handle,"published-at":t=>vt(t.publishedAt),"min-price":t=>v(t.priceRange.minVariantPrice),"max-price":t=>v(t.priceRange.maxVariantPrice)}));function fe(t,e){let n=(t.getAttribute("exclude")??"").split(",").map(i=>i.trim()).filter(Boolean),r=e.tags.filter(i=>!n.includes(i));T(t,r,(i,o)=>{g(i,o)})}function ge(t,e,n){let r=pe.get(e);if(r){g(t,r(n));return}switch(e){case"description":At(t,n.descriptionHtml);break;case"featured-image":P(t,n.featuredImage?.url,n.featuredImage?.altText||n.title);break;case"url":case"link":{let i=W(n.handle,n.id);i&&t.setAttribute("href",i),e==="url"&&!t.firstElementChild&&!t.textContent.trim()&&g(t,n.title);break}case"images":de(t,n);break;case"tags":fe(t,n);break;default:he(t,e,n)}}function he(t,e,n){let r=ue.exec(e);if(r){let i=n.images.nodes[Number(r[1])-1]??n.featuredImage;P(t,i?.url,i?.altText||n.title)}else e.startsWith(Tt)&&me(t,n,e.slice(Tt.length))}function ye(t){let{product:e}=t;t.$(s("option-list")).forEach(n=>{let r=t.optName(f(n,"option-list")),i=e.options.find(o=>o.name===r);if(!i||i.optionValues.length<=1&&yt(n,"hide-single")){M(n,!1);return}T(n,i.optionValues,(o,a)=>{o.setAttribute(L("option-value"),a.name);let u=d(o,s("bind","option-value"))[0];u?g(u,a.name):o.firstElementChild||g(o,a.name);let c=d(o,s("bind","swatch"))[0],{swatch:p}=a;!c||!p||(p.color&&(c.style.backgroundColor=p.color),p.image?.previewImage&&P(c,p.image.previewImage.url,a.name))})})}function Ce(t){let{product:e}=t;it(t,s("option")).forEach(n=>{let r=e.options.find(i=>i.name===t.optName(f(n,"option")));if(!r){M(n,!1);return}n.replaceChildren(...r.optionValues.map(i=>new Option(i.name,i.name)))}),it(t,s("variant-select")).forEach(n=>{n.replaceChildren(...e.variants.nodes.map(r=>new Option(r.title,r.id)))}),it(t,s("plan")).forEach(n=>{let r=t.plans.map(a=>new Option(a.name,a.id)),i=!e.requiresSellingPlan&&f(n,"plan")!=="subscription-only",o=n.getAttribute(L("one-time-label"))||"One-time purchase";n.replaceChildren(...i?[new Option(o,"")]:[],...r)})}function be(t){t.$(s("plan-list")).forEach(e=>{let n=(f(e,"plan-list")??"").trim(),r=le.includes(n.toLowerCase())?null:n,i=t.plans.filter(o=>!r||o.group.name===r);T(e,i,(o,a)=>{o.setAttribute(L("plan-value"),a.id),!o.firstElementChild&&!o.querySelector(s("plan-bind"))&&g(o,a.name)})})}function Xe(t){t.$(s("bind")).forEach(e=>{ge(e,f(e,"bind")??"",t.product)}),ye(t),Ce(t),be(t)}var Mt="Default Title",at=(t,e)=>e.get(t.id)?.quantity??t.quantity,$t=t=>t.split("/").pop()??t;function Se(t){let e=t.merchandise,n=W(e.product.handle,e.product.id);if(!n)return null;let r=new URLSearchParams;r.set("variant",$t(e.id));let i=t.sellingPlanAllocation?.sellingPlan.id;return i&&r.set("selling_plan",$t(i)),`${n}${n.includes("?")?"&":"?"}${r.toString()}`}var Ot=t=>t.merchandise.product.title,Rt={title:Ot,"product-title":Ot,"variant-title":t=>t.merchandise.title===Mt?"":t.merchandise.title,options:t=>t.merchandise.selectedOptions.filter(e=>e.value!==Mt).map(e=>`${e.name}: ${e.value}`).join(", "),vendor:t=>t.merchandise.product.vendor,sku:t=>t.merchandise.sku??"",price:t=>v(t.cost.amountPerQuantity),"compare-at-price":t=>v(t.cost.compareAtAmountPerQuantity??t.merchandise.compareAtPrice),"line-total":t=>v(t.cost.totalAmount),"line-subtotal":t=>v(t.cost.subtotalAmount),quantity:(t,e)=>at(t,e.pending),plan:t=>t.sellingPlanAllocation?.sellingPlan.name??"","plan-description":t=>t.sellingPlanAllocation?.sellingPlan.description??"",components:t=>(t.lineComponents??[]).map(e=>`${e.quantity} \xD7 ${e.merchandise.product.title}`).join(", ")},Ut="attribute:";function we(t,e,n){if(Object.hasOwn(Rt,e))return Rt[e]?.(t,n);if(!e.startsWith(Ut))return;let r=e.slice(Ut.length);return t.attributes.find(i=>i.key===r)?.value??""}function ve(t,e,n){let r=kt(n),i=!n.requiresSellingPlan&&f(t,"line-plan")!=="subscription-only",o={value:"",label:t.getAttribute(L("one-time-label"))||"One-time purchase"},a=[...i?[o]:[],...r.map(c=>({value:c.id,label:c.name}))],u=a.map(c=>c.value).join("|");t.dataset.tetherSig!==u&&(t.replaceChildren(...a.map(c=>{let p=document.createElement("option");return p.value=c.value,p.textContent=c.label,p})),t.dataset.tetherSig=u),t.value=e.sellingPlanAllocation?.sellingPlan.id??"",M(t,r.length>0)}function Ae(t,e,n){let r=!!e.sellingPlanAllocation;t.classList.toggle("is-subscription",r);let i=n.warnings.find(u=>u.target===e.id);t.classList.toggle("is-warning",!!i);let o=n.pending.has(e.id);t.classList.toggle("is-busy",o),o?t.setAttribute("aria-busy","true"):t.removeAttribute("aria-busy"),d(t,s("line","warning")).forEach(u=>{k(u,i?.message??"")});let a=new Map([["subscription",r],["one-time",!r],["on-sale",Pt(e.cost.compareAtAmountPerQuantity?.amount,e.cost.amountPerQuantity.amount)],["has-components",(e.lineComponents??[]).length>0],["warning",!!i]]);d(t,s("line-show")).forEach(u=>{let c=f(u,"line-show"),p=c===null?void 0:a.get(c);p!==void 0&&M(u,p)})}function Le(t,e,n){let r=e.merchandise;t.setAttribute(L("line-id"),e.id),d(t,s("line")).forEach(o=>{let a=f(o,"line")??"";if(a==="image"){P(o,r.image?.url??r.product.featuredImage?.url,r.product.title);return}if(a==="url"){let c=Se(e);c&&o.setAttribute("href",c);return}let u=we(e,a,n);u!==void 0&&k(o,u)}),Ae(t,e,n),d(t,s("line-plan")).filter(ot).forEach(o=>{Et(r.product.handle).then(a=>{ve(o,e,a)}).catch(a=>{w(a,"line plan options")})})}function Pe(t,e){let n=t?.totalQuantity??0,r=(t?.lines.nodes??[]).some(o=>o.sellingPlanAllocation),i=new Map([["cart-empty",n===0],["cart-filled",n>0],["cart-has-subscription",r],["cart-no-subscription",!r],["cart-has-discount",(t?.discountCodes??[]).some(o=>o.applicable)],["cart-error",e.failed],["cart-warning",e.warnings.length>0]]);d(document,s("show")).forEach(o=>{let a=f(o,"show"),u=a===null?void 0:i.get(a);u===void 0||o.closest(s("product"))||M(o,u)}),d(document,s("checkout")).forEach(o=>{o.classList.toggle("is-disabled",!n),o.setAttribute("aria-disabled",String(!n))})}function ke(t){d(document,`textarea${s("cart-note")},input${s("cart-note")}`).forEach(e=>{document.activeElement!==e&&g(e,t?.note??"")}),d(document,s("cart-discounts")).forEach(e=>{T(e,t?.discountCodes??[],(n,r)=>{n.setAttribute(L("discount-code"),r.code);let i=n.querySelector(s("discount","code"))??(n.firstElementChild?null:n);i&&g(i,r.code),n.classList.toggle("is-inapplicable",!r.applicable)})})}function qt(t){let{cart:e}=t,n=r=>e?v(e.cost[r]):"";j(S()),d(document,s("cart-count")).forEach(r=>{k(r,e?.totalQuantity??0)}),d(document,s("cart-subtotal")).forEach(r=>{k(r,n("subtotalAmount"))}),d(document,s("cart-total")).forEach(r=>{k(r,n("totalAmount"))}),d(document,s("cart-checkout-charge")).forEach(r=>{k(r,n("checkoutChargeAmount"))}),Pe(e,t),d(document,s("cart-warning")).forEach(r=>{k(r,[...new Set(t.warnings.map(i=>i.message))].join(" "))}),ke(e),d(document,s("cart-lines")).forEach(r=>{wt(r,e?.lines.nodes??[],i=>i.id,(i,o)=>{Le(i,o,t)},{onEnter:l.onLineEnter,onLeave:l.onLineLeave})}),e&&Lt("cart")}function Dt(t){d(document,s("cart-count")).forEach(e=>{/^\s*0?\s*$/.test(e.textContent)&&(e.textContent=String(t))})}function st(t,e="localStorage"){try{return window[e].getItem(t)}catch{return null}}function ut(t,e,n="localStorage"){try{window[n].setItem(t,e)}catch{}}function Qt(t,e="localStorage"){try{window[e].removeItem(t)}catch{}}var Nt=/^gid:\/\/shopify\/Cart\/[\w-]+(\?key=[\w-]+)?$/;var h={kind:"unknown"},U=[],O=new Map,G=()=>h;function m(){switch(h.kind){case"ready":case"error":return h.cart;case"unknown":case"empty":return null}}var Ft=()=>U,ct=t=>t?{kind:"ready",cart:t}:{kind:"empty"},Ht=()=>`${l.storageKey}:seen`;function E(){let t=st(l.storageKey);return t?Nt.test(t)?t:(I(),null):null}function I(){Qt(l.storageKey)}function lt(t){h=ct(t),t&&ut(l.storageKey,t.id)}function N(){qt({cart:m(),warnings:U,pending:O,failed:h.kind==="error"})}function _(t){N(),y("cart-updated",{cart:m(),reason:t})}function C(t,e){return lt(t),ut(Ht(),`${Date.now()}|${t?.totalQuantity??0}`),_(e),t}function F(t){h=t.kind==="loaded"?ct(t.cart):{kind:"error",error:t.error,cart:null},_("load")}function Ee(){let t=st(Ht())?.split("|")[1]??"",e=Number(t);return/^\d+$/.test(t)&&Number.isSafeInteger(e)?e:null}function Vt(){if(h.kind!=="unknown")return;let t=Ee();t!==null&&Dt(t)}function Wt(t){U=t.filter((e,n)=>t.findIndex(r=>r.message===e.message)===n).map(e=>({...e,message:l.warningText?.(e)||e.message})),U.length&&y("cart-warning",{warnings:U})}var _t=()=>{};function Ie(){let t=Promise.resolve();return e=>{let n=t.then(e);return t=n.then(_t,_t),n}}var xe=Ie();function Kt(t){return xe(t).then(e=>(h.kind==="error"&&(h=ct(h.cart),N()),e),e=>{throw h={kind:"error",error:e,cart:m()},N(),y("cart-error",{error:e}),e})}var dt=t=>at(t,O),Te=()=>({open:S(),count:m()?.totalQuantity??0,loaded:h.kind!=="unknown",warnings:[...U]});function jt(t){let e=["cart-updated","cart-toggled"].map(r=>`${l.prefix}:${r}`),n=()=>{t(m(),Te())};return e.forEach(r=>{document.addEventListener(r,n)}),n(),()=>{e.forEach(r=>{document.removeEventListener(r,n)})}}var Me=/does not exist|not found|invalid id/i,$e=t=>H({[t]:q({cart:q(tt)})});function X(t){return t instanceof b?t.userErrors?.some(e=>e.field?.[0]==="cartId")?!0:(t.errors??[]).some(e=>Me.test(e.message)):!1}function Gt(t){if(!(t instanceof b))return!1;let{code:e,status:n=0}=t;return e==="NETWORK"||e==="INVALID_RESPONSE"||e==="SERVER_ERROR"||n>=500}function Xt(t,e=1,n={}){let r=typeof t=="object"&&t!==null?t:{...n,quantity:e,...t==null?{}:{variantId:t}},i=Q.variant(r.merchandiseId||r.variantId||r.id);if(!i)throw new b("add(): variantId is required");let o=parseInt(String(r.quantity??1),10),a={merchandiseId:i,quantity:Math.max(1,o||1)},u=Q.sellingPlan(r.sellingPlanId||r.sellingPlan);u&&(a.sellingPlanId=u);let c=D(r.attributes);return c.length&&(a.attributes=c),a}function Oe(t,e,n){return r=>`mutation Tether_${t}(${e}){${t}(${n}){cart{...TetherCart}userErrors{field message}warnings{code message target}}}${Z(r)}`}async function Yt(t,e,n,r){let i=await V(Oe(t,e,n),r,$e(t),{operation:"mutation"}),o=ht(i[t],t);return Wt(o.warnings??[]),o.cart}function Bt(t){let e=l.country?{buyerIdentity:{countryCode:l.country},...t}:t;return Yt("cartCreate","$input: CartInput!","input: $input",{input:e})}async function x({name:t,args:e,inner:n,variables:r,createInput:i}){let o=E();if(!o)return i?Bt(i):null;try{return await Yt(t,`$cartId: ID!, ${e}`,`cartId: $cartId, ${n}`,{...r,cartId:o})}catch(a){if(!X(a)||(I(),!i))throw a;return gt("cart expired, creating a new one"),Bt(i)}}async function mt(t){return(await V(n=>`query TetherCart($id:ID!){cart(id:$id){...TetherCart}}${Z(n)}`,{id:t},H({cart:q(tt)}))).cart}async function zt(t){return(await V("query TetherCheckout($id:ID!){cart(id:$id){checkoutUrl}}",{id:t},H({cart:q({checkoutUrl:"string"})}))).cart?.checkoutUrl??null}function Jt(t,e){let n=typeof e=="number"?{quantity:e}:e,r={id:t};n.quantity!==void 0&&(r.quantity=n.quantity),"sellingPlanId"in n&&(r.sellingPlanId=n.sellingPlanId?Q.sellingPlan(n.sellingPlanId):null),n.attributes&&(r.attributes=D(n.attributes));let i=n.merchandiseId||n.variantId;return i&&(r.merchandiseId=Q.variant(i)),r}var pt=t=>x({name:"cartLinesUpdate",args:"$lines: [CartLineUpdateInput!]!",inner:"lines: $lines",variables:{lines:t},createInput:null}),Y=t=>x({name:"cartLinesRemove",args:"$lineIds: [ID!]!",inner:"lineIds: $lineIds",variables:{lineIds:t},createInput:null}),Zt=(t,e)=>e>0?pt([{id:t,quantity:e}]):Y([t]);var ft=null;function te(t){ft=t}var Re=t=>zt(t).then(e=>({kind:"url",url:e}),e=>({kind:"failed",error:e}));async function Ue(){if(!ft)return null;try{let t=await ft();return t&&`${t}${t.includes("?")?"&":"?"}logged_in=true`}catch(t){return w(t,"account checkout"),null}}async function qe(t){let e=Re(t),n=await Ue();if(n)return n;let r=await e;if(r.kind==="failed")throw r.error;if(!r.url)throw new b("No checkoutUrl (cart empty or expired)");return r.url}function De(t){try{t.opener=null}catch{}}async function ee(t=l.checkoutTarget){let e=E(),n=m();if(!e||n&&!n.totalQuantity)return null;let r=t==="_blank"?window.open("","_blank"):null;r&&De(r);try{let i=await qe(e);if(!Ct(i))throw new b("The checkout URL is not https: not opened");return y("checkout",{url:i,cart:m()}),r&&!r.closed?r.location.href=i:window.location.href=i,i}catch(i){return r?.close(),w(i,"checkout failed"),null}}var J=()=>m()?.lines.nodes??[];async function Qe(){let t=E();if(t)try{let e=await mt(t);e||I(),C(e,"load")}catch(e){w(e,"cart reload after a failed change")}}function A(t){return Kt(()=>t().catch(async e=>{throw Gt(e)&&await Qe(),e}))}function Ne(t,e){let n=J().find(u=>u.id===t);if(!n)return Promise.resolve(m());let r=Math.max(0,dt(n)+e),i={quantity:r};O.set(t,i),_("pending");let o=()=>O.get(t)===i;return A(async()=>{if(!o())return m();if(J().find(p=>p.id===t)?.quantity===r)return m();let c=await Zt(t,r);return o()?C(c,r>0?"update":"remove"):(lt(c),c)}).finally(()=>{o()&&(O.delete(t),_("settled"))})}function _e(t){let e=(m()?.discountCodes??[]).map(r=>r.code),n=typeof t=="function"?t(e):t;return(Array.isArray(n)?n:[n]).map(r=>r.trim()).filter(Boolean)}function Fe(t){let e=new Map((m()?.attributes??[]).map(n=>[n.key,n.value]));return D(t).forEach(n=>e.set(n.key,n.value)),[...e].filter(([,n])=>n!=="").map(([n,r])=>({key:n,value:r}))}async function He(){let t=E();if(!t)return F({kind:"loaded",cart:null}),null;Vt();try{let e=await mt(t);e||I(),F({kind:"loaded",cart:e})}catch(e){w(e,"cart load failed"),X(e)&&I(),F({kind:"failed",error:e})}return m()}var z={init:He,id:E,get status(){return G()},get state(){return m()},get lines(){return[...J()]},get count(){return m()?.totalQuantity??0},get loaded(){return G().kind!=="unknown"},get lastError(){let t=G();return t.kind!=="error"?null:t.error instanceof Error?t.error:new Error(String(t.error))},get warnings(){return[...Ft()]},get pendingQty(){return O},setCheckoutResolver:te,forgetSaved(){I(),F({kind:"loaded",cart:null})},render:N,subscribe:jt,add(t,e=1,n={}){let r=(Array.isArray(t)?t:[t]).map(i=>Xt(i,e,n));return A(async()=>{let i=await x({name:"cartLinesAdd",args:"$lines: [CartLineInput!]!",inner:"lines: $lines",variables:{lines:r},createInput:{lines:r}});if(!i)throw new b("Shopify answered the add without a cart");return C(i,"add"),y("added",{cart:i,lines:r}),l.openCartOnAdd&&B(),i})},updateLine(t,e){let n=typeof e=="number"?e:e.quantity;if(n!==void 0&&n<=0)return z.removeLine(t);let r=Jt(t,e);return A(async()=>C(await pt([r]),"update"))},changeQuantity:Ne,quantityOf:dt,removeLine(t){let e=Array.isArray(t)?t:[t];return A(async()=>C(await Y(e),"remove"))},clear(){return A(async()=>{let t=J().map(e=>e.id);return t.length?C(await Y(t),"remove"):m()})},setNote(t){let e={note:t??""};return A(async()=>C(await x({name:"cartNoteUpdate",args:"$note: String!",inner:"note: $note",variables:e,createInput:e}),"note"))},setAttributes(t){return A(async()=>{let e={attributes:Fe(t)},n=await x({name:"cartAttributesUpdate",args:"$attributes: [AttributeInput!]!",inner:"attributes: $attributes",variables:e,createInput:e});return C(n,"attributes")})},setDiscountCodes(t){return A(async()=>{let e={discountCodes:_e(t)},n=await x({name:"cartDiscountCodesUpdate",args:"$discountCodes: [String!]!",inner:"discountCodes: $discountCodes",variables:e,createInput:e});return C(n,"discount")})},async applyDiscount(t){let e=await z.setDiscountCodes(i=>[...new Set([...i,t])]),n=t.toLowerCase();if((e?.discountCodes??[]).find(i=>i.code.toLowerCase()===n)?.applicable)return e;try{await z.removeDiscount(t)}catch(i){w(i,"removing a discount code Shopify refused")}throw new b(`Discount code not valid: ${t}`,{code:"INVALID_DISCOUNT"})},removeDiscount(t){let e=t.toLowerCase();return z.setDiscountCodes(n=>n.filter(r=>r.toLowerCase()!==e))},setBuyerIdentity(t,{create:e=!0}={}){return A(async()=>{let n=await x({name:"cartBuyerIdentityUpdate",args:"$buyerIdentity: CartBuyerIdentityInput!",inner:"buyerIdentity: $buyerIdentity",variables:{buyerIdentity:t},createInput:e?{buyerIdentity:t}:null}).catch(r=>{if(e||!X(r))throw r;return null});return C(n,"buyer-identity")})},checkout:ee,drawers:$,isOpen:S,open:B,close:rt,toggle:xt};export{se as a,ot as b,it as c,Xe as d,st as e,ut as f,Qt as g,z as h};
1
+ import{a as Pt,d as Q,e as kt}from"./chunk-BVO7KK2M.js";import{c as Et}from"./chunk-H6IORH7O.js";import{b as Z,d as R}from"./chunk-FWMPL6PR.js";import{A as W,C as v,D as vt,E as At,F as g,G as k,H as M,K as Lt,P as D,a as b,c as q,d as H,h as V,k as ht,l as L,m as s,n as f,o as yt,p as d,t as y,v as bt,w as P,x as St,y as T,z as wt}from"./chunk-OATTAXPO.js";import{C as Ct,r as l,x as gt,z as w}from"./chunk-OJAV2I3C.js";var ne={id:"string",quantity:"number",attributes:["object"],cost:{totalAmount:R,subtotalAmount:R,amountPerQuantity:R},merchandise:{id:"string",selectedOptions:["object"],product:"object"}},tt={id:"string",checkoutUrl:"string",totalQuantity:"number",attributes:["object"],discountCodes:["object"],cost:{totalAmount:R,subtotalAmount:R},lines:{nodes:[ne]}};var re='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',ie=60,et=!1,K=null,oe=t=>t!==null&&"focus"in t,It=t=>d(t,re).filter(e=>e.offsetParent!==null||e===document.activeElement),$=()=>d(document,s("cart-drawer")),nt=t=>t.classList.contains(l.cartDrawerOpenClass);function S(){let t=$();return t.length?t.some(nt):et}function j(t){d(document,s("cart-open")).forEach(e=>{e.setAttribute("aria-expanded",String(t))}),$().forEach(e=>{e.hasAttribute("role")||e.setAttribute("role","dialog"),!e.hasAttribute("aria-label")&&!e.hasAttribute("aria-labelledby")&&e.setAttribute("aria-label",f(e,"cart-label")||"Cart"),e.setAttribute("aria-modal",String(t)),!nt(e)&&(e.setAttribute("aria-hidden","true"),l.cartFocus&&(e.inert=!0))})}function ae(t){let e=It(t)[0]??t;e===t&&!t.hasAttribute("tabindex")&&(t.tabIndex=-1),e.focus({preventScroll:!0})}function B(){if(S())return;et=!0;let t=$().filter(n=>f(n,"cart-drawer")!=="manual");t.forEach(n=>{n.inert=!1,n.classList.add(l.cartDrawerOpenClass),n.setAttribute("aria-hidden","false")}),j(!0);let[e]=t;l.cartFocus&&e&&(K=oe(document.activeElement)?document.activeElement:null,setTimeout(()=>{ae(e)},ie)),l.onCartOpen?.(t),y("cart-toggled",{open:!0})}function rt(){if(!S())return;et=!1;let t=$(),e=t.some(n=>n.contains(document.activeElement));t.forEach(n=>{n.classList.remove(l.cartDrawerOpenClass),n.setAttribute("aria-hidden","true"),l.cartFocus&&(n.inert=!0)}),j(!1),e&&K?.isConnected&&K.focus({preventScroll:!0}),K=null,l.onCartClose?.(t),y("cart-toggled",{open:!1})}function xt(){S()?rt():B()}function se(t){if(t.key!=="Tab"||!l.cartFocus||!S())return;let e=$().find(nt);if(!e)return;let n=It(e),r=n[0],i=n.at(-1);if(!r||!i)return;let o=document.activeElement,a=t.shiftKey?o===r:o===i;e.contains(o)&&!a||(t.preventDefault(),(t.shiftKey?i:r).focus())}var ue=/^image:(\d+)$/,Tt="metafield:",ce=/^(rich_text|multi_line_text)_field$/,le=["","true","all","*"],ot=t=>t.tagName==="SELECT",it=(t,e)=>t.$(`select${e}`).filter(ot);function de(t,e){let n=e.images.nodes,r=[...t.children].map(o=>o.tagName==="IMG"?o:o.querySelector("img"));!St(t)&&r.length===n.length&&r.every((o,a)=>bt(o?.getAttribute("src"),n[a]?.url))||T(t,n,(o,a)=>{let u=o.matches(`img,${s("bind","image")}`)?o:d(o,"img")[0]??o;P(u,a.url,a.altText||e.title)})}function me(t,e,n){let r=n.indexOf("."),i=n.slice(0,r),o=n.slice(r+1),a=(e.metafields??[]).find(c=>c?.namespace===i&&c.key===o);if(!a){g(t,"");return}let u=a.reference?.image;if(u){P(t,u.url,u.altText);return}ce.test(a.type)&&(t.style.whiteSpace="pre-line"),g(t,a.value)}var pe=new Map(Object.entries({title:t=>t.title,"description-text":t=>t.description,vendor:t=>t.vendor,type:t=>t.productType,handle:t=>t.handle,"published-at":t=>vt(t.publishedAt),"min-price":t=>v(t.priceRange.minVariantPrice),"max-price":t=>v(t.priceRange.maxVariantPrice)}));function fe(t,e){let n=(t.getAttribute("exclude")??"").split(",").map(i=>i.trim()).filter(Boolean),r=e.tags.filter(i=>!n.includes(i));T(t,r,(i,o)=>{g(i,o)})}function ge(t,e,n){let r=pe.get(e);if(r){g(t,r(n));return}switch(e){case"description":At(t,n.descriptionHtml);break;case"featured-image":P(t,n.featuredImage?.url,n.featuredImage?.altText||n.title);break;case"url":case"link":{let i=W(n.handle,n.id);i&&t.setAttribute("href",i),e==="url"&&!t.firstElementChild&&!t.textContent.trim()&&g(t,n.title);break}case"images":de(t,n);break;case"tags":fe(t,n);break;default:he(t,e,n)}}function he(t,e,n){let r=ue.exec(e);if(r){let i=n.images.nodes[Number(r[1])-1]??n.featuredImage;P(t,i?.url,i?.altText||n.title)}else e.startsWith(Tt)&&me(t,n,e.slice(Tt.length))}function ye(t){let{product:e}=t;t.$(s("option-list")).forEach(n=>{let r=t.optName(f(n,"option-list")),i=e.options.find(o=>o.name===r);if(!i||i.optionValues.length<=1&&yt(n,"hide-single")){M(n,!1);return}T(n,i.optionValues,(o,a)=>{o.setAttribute(L("option-value"),a.name);let u=d(o,s("bind","option-value"))[0];u?g(u,a.name):o.firstElementChild||g(o,a.name);let c=d(o,s("bind","swatch"))[0],{swatch:p}=a;!c||!p||(p.color&&(c.style.backgroundColor=p.color),p.image?.previewImage&&P(c,p.image.previewImage.url,a.name))})})}function Ce(t){let{product:e}=t;it(t,s("option")).forEach(n=>{let r=e.options.find(i=>i.name===t.optName(f(n,"option")));if(!r){M(n,!1);return}n.replaceChildren(...r.optionValues.map(i=>new Option(i.name,i.name)))}),it(t,s("variant-select")).forEach(n=>{n.replaceChildren(...e.variants.nodes.map(r=>new Option(r.title,r.id)))}),it(t,s("plan")).forEach(n=>{let r=t.plans.map(a=>new Option(a.name,a.id)),i=!e.requiresSellingPlan&&f(n,"plan")!=="subscription-only",o=n.getAttribute(L("one-time-label"))||"One-time purchase";n.replaceChildren(...i?[new Option(o,"")]:[],...r)})}function be(t){t.$(s("plan-list")).forEach(e=>{let n=(f(e,"plan-list")??"").trim(),r=le.includes(n.toLowerCase())?null:n,i=t.plans.filter(o=>!r||o.group.name===r);T(e,i,(o,a)=>{o.setAttribute(L("plan-value"),a.id),!o.firstElementChild&&!o.querySelector(s("plan-bind"))&&g(o,a.name)})})}function Xe(t){t.$(s("bind")).forEach(e=>{ge(e,f(e,"bind")??"",t.product)}),ye(t),Ce(t),be(t)}var Mt="Default Title",at=(t,e)=>e.get(t.id)?.quantity??t.quantity,$t=t=>t.split("/").pop()??t;function Se(t){let e=t.merchandise,n=W(e.product.handle,e.product.id);if(!n)return null;let r=new URLSearchParams;r.set("variant",$t(e.id));let i=t.sellingPlanAllocation?.sellingPlan.id;return i&&r.set("selling_plan",$t(i)),`${n}${n.includes("?")?"&":"?"}${r.toString()}`}var Ot=t=>t.merchandise.product.title,Rt={title:Ot,"product-title":Ot,"variant-title":t=>t.merchandise.title===Mt?"":t.merchandise.title,options:t=>t.merchandise.selectedOptions.filter(e=>e.value!==Mt).map(e=>`${e.name}: ${e.value}`).join(", "),vendor:t=>t.merchandise.product.vendor,sku:t=>t.merchandise.sku??"",price:t=>v(t.cost.amountPerQuantity),"compare-at-price":t=>v(t.cost.compareAtAmountPerQuantity??t.merchandise.compareAtPrice),"line-total":t=>v(t.cost.totalAmount),"line-subtotal":t=>v(t.cost.subtotalAmount),quantity:(t,e)=>at(t,e.pending),plan:t=>t.sellingPlanAllocation?.sellingPlan.name??"","plan-description":t=>t.sellingPlanAllocation?.sellingPlan.description??"",components:t=>(t.lineComponents??[]).map(e=>`${e.quantity} \xD7 ${e.merchandise.product.title}`).join(", ")},Ut="attribute:";function we(t,e,n){if(Object.hasOwn(Rt,e))return Rt[e]?.(t,n);if(!e.startsWith(Ut))return;let r=e.slice(Ut.length);return t.attributes.find(i=>i.key===r)?.value??""}function ve(t,e,n){let r=kt(n),i=!n.requiresSellingPlan&&f(t,"line-plan")!=="subscription-only",o={value:"",label:t.getAttribute(L("one-time-label"))||"One-time purchase"},a=[...i?[o]:[],...r.map(c=>({value:c.id,label:c.name}))],u=a.map(c=>c.value).join("|");t.dataset.tetherSig!==u&&(t.replaceChildren(...a.map(c=>{let p=document.createElement("option");return p.value=c.value,p.textContent=c.label,p})),t.dataset.tetherSig=u),t.value=e.sellingPlanAllocation?.sellingPlan.id??"",M(t,r.length>0)}function Ae(t,e,n){let r=!!e.sellingPlanAllocation;t.classList.toggle("is-subscription",r);let i=n.warnings.find(u=>u.target===e.id);t.classList.toggle("is-warning",!!i);let o=n.pending.has(e.id);t.classList.toggle("is-busy",o),o?t.setAttribute("aria-busy","true"):t.removeAttribute("aria-busy"),d(t,s("line","warning")).forEach(u=>{k(u,i?.message??"")});let a=new Map([["subscription",r],["one-time",!r],["on-sale",Pt(e.cost.compareAtAmountPerQuantity?.amount,e.cost.amountPerQuantity.amount)],["has-components",(e.lineComponents??[]).length>0],["warning",!!i]]);d(t,s("line-show")).forEach(u=>{let c=f(u,"line-show"),p=c===null?void 0:a.get(c);p!==void 0&&M(u,p)})}function Le(t,e,n){let r=e.merchandise;t.setAttribute(L("line-id"),e.id),d(t,s("line")).forEach(o=>{let a=f(o,"line")??"";if(a==="image"){P(o,r.image?.url??r.product.featuredImage?.url,r.product.title);return}if(a==="url"){let c=Se(e);c&&o.setAttribute("href",c);return}let u=we(e,a,n);u!==void 0&&k(o,u)}),Ae(t,e,n),d(t,s("line-plan")).filter(ot).forEach(o=>{Et(r.product.handle).then(a=>{ve(o,e,a)}).catch(a=>{w(a,"line plan options")})})}function Pe(t,e){let n=t?.totalQuantity??0,r=(t?.lines.nodes??[]).some(o=>o.sellingPlanAllocation),i=new Map([["cart-empty",n===0],["cart-filled",n>0],["cart-has-subscription",r],["cart-no-subscription",!r],["cart-has-discount",(t?.discountCodes??[]).some(o=>o.applicable)],["cart-error",e.failed],["cart-warning",e.warnings.length>0]]);d(document,s("show")).forEach(o=>{let a=f(o,"show"),u=a===null?void 0:i.get(a);u===void 0||o.closest(s("product"))||M(o,u)}),d(document,s("checkout")).forEach(o=>{o.classList.toggle("is-disabled",!n),o.setAttribute("aria-disabled",String(!n))})}function ke(t){d(document,`textarea${s("cart-note")},input${s("cart-note")}`).forEach(e=>{document.activeElement!==e&&g(e,t?.note??"")}),d(document,s("cart-discounts")).forEach(e=>{T(e,t?.discountCodes??[],(n,r)=>{n.setAttribute(L("discount-code"),r.code);let i=n.querySelector(s("discount","code"))??(n.firstElementChild?null:n);i&&g(i,r.code),n.classList.toggle("is-inapplicable",!r.applicable)})})}function qt(t){let{cart:e}=t,n=r=>e?v(e.cost[r]):"";j(S()),d(document,s("cart-count")).forEach(r=>{k(r,e?.totalQuantity??0)}),d(document,s("cart-subtotal")).forEach(r=>{k(r,n("subtotalAmount"))}),d(document,s("cart-total")).forEach(r=>{k(r,n("totalAmount"))}),d(document,s("cart-checkout-charge")).forEach(r=>{k(r,n("checkoutChargeAmount"))}),Pe(e,t),d(document,s("cart-warning")).forEach(r=>{k(r,[...new Set(t.warnings.map(i=>i.message))].join(" "))}),ke(e),d(document,s("cart-lines")).forEach(r=>{wt(r,e?.lines.nodes??[],i=>i.id,(i,o)=>{Le(i,o,t)},{onEnter:l.onLineEnter,onLeave:l.onLineLeave})}),e&&Lt("cart")}function Dt(t){d(document,s("cart-count")).forEach(e=>{/^\s*0?\s*$/.test(e.textContent)&&(e.textContent=String(t))})}function st(t,e="localStorage"){try{return window[e].getItem(t)}catch{return null}}function ut(t,e,n="localStorage"){try{window[n].setItem(t,e)}catch{}}function Qt(t,e="localStorage"){try{window[e].removeItem(t)}catch{}}var Nt=/^gid:\/\/shopify\/Cart\/[\w-]+(\?key=[\w-]+)?$/;var h={kind:"unknown"},U=[],O=new Map,G=()=>h;function m(){switch(h.kind){case"ready":case"error":return h.cart;case"unknown":case"empty":return null}}var Ft=()=>U,ct=t=>t?{kind:"ready",cart:t}:{kind:"empty"},Ht=()=>`${l.storageKey}:seen`;function E(){let t=st(l.storageKey);return t?Nt.test(t)?t:(I(),null):null}function I(){Qt(l.storageKey)}function lt(t){h=ct(t),t&&ut(l.storageKey,t.id)}function N(){qt({cart:m(),warnings:U,pending:O,failed:h.kind==="error"})}function _(t){N(),y("cart-updated",{cart:m(),reason:t})}function C(t,e){return lt(t),ut(Ht(),`${Date.now()}|${t?.totalQuantity??0}`),_(e),t}function F(t){h=t.kind==="loaded"?ct(t.cart):{kind:"error",error:t.error,cart:null},_("load")}function Ee(){let t=st(Ht())?.split("|")[1]??"",e=Number(t);return/^\d+$/.test(t)&&Number.isSafeInteger(e)?e:null}function Vt(){if(h.kind!=="unknown")return;let t=Ee();t!==null&&Dt(t)}function Wt(t){U=t.filter((e,n)=>t.findIndex(r=>r.message===e.message)===n).map(e=>({...e,message:l.warningText?.(e)||e.message})),U.length&&y("cart-warning",{warnings:U})}var _t=()=>{};function Ie(){let t=Promise.resolve();return e=>{let n=t.then(e);return t=n.then(_t,_t),n}}var xe=Ie();function Kt(t){return xe(t).then(e=>(h.kind==="error"&&(h=ct(h.cart),N()),e),e=>{throw h={kind:"error",error:e,cart:m()},N(),y("cart-error",{error:e}),e})}var dt=t=>at(t,O),Te=()=>({open:S(),count:m()?.totalQuantity??0,loaded:h.kind!=="unknown",warnings:[...U]});function jt(t){let e=["cart-updated","cart-toggled"].map(r=>`${l.prefix}:${r}`),n=()=>{t(m(),Te())};return e.forEach(r=>{document.addEventListener(r,n)}),n(),()=>{e.forEach(r=>{document.removeEventListener(r,n)})}}var Me=/does not exist|not found|invalid id/i,$e=t=>H({[t]:q({cart:q(tt)})});function X(t){return t instanceof b?t.userErrors?.some(e=>e.field?.[0]==="cartId")?!0:(t.errors??[]).some(e=>Me.test(e.message)):!1}function Gt(t){if(!(t instanceof b))return!1;let{code:e,status:n=0}=t;return e==="NETWORK"||e==="INVALID_RESPONSE"||e==="SERVER_ERROR"||n>=500}function Xt(t,e=1,n={}){let r=typeof t=="object"&&t!==null?t:{...n,quantity:e,...t==null?{}:{variantId:t}},i=Q.variant(r.merchandiseId||r.variantId||r.id);if(!i)throw new b("add(): variantId is required");let o=parseInt(String(r.quantity??1),10),a={merchandiseId:i,quantity:Math.max(1,o||1)},u=Q.sellingPlan(r.sellingPlanId||r.sellingPlan);u&&(a.sellingPlanId=u);let c=D(r.attributes);return c.length&&(a.attributes=c),a}function Oe(t,e,n){return r=>`mutation Tether_${t}(${e}){${t}(${n}){cart{...TetherCart}userErrors{field message}warnings{code message target}}}${Z(r)}`}async function Yt(t,e,n,r){let i=await V(Oe(t,e,n),r,$e(t),{operation:"mutation"}),o=ht(i[t],t);return Wt(o.warnings??[]),o.cart}function Bt(t){let e=l.country?{buyerIdentity:{countryCode:l.country},...t}:t;return Yt("cartCreate","$input: CartInput!","input: $input",{input:e})}async function x({name:t,args:e,inner:n,variables:r,createInput:i}){let o=E();if(!o)return i?Bt(i):null;try{return await Yt(t,`$cartId: ID!, ${e}`,`cartId: $cartId, ${n}`,{...r,cartId:o})}catch(a){if(!X(a)||(I(),!i))throw a;return gt("cart expired, creating a new one"),Bt(i)}}async function mt(t){return(await V(n=>`query TetherCart($id:ID!){cart(id:$id){...TetherCart}}${Z(n)}`,{id:t},H({cart:q(tt)}))).cart}async function zt(t){return(await V("query TetherCheckout($id:ID!){cart(id:$id){checkoutUrl}}",{id:t},H({cart:q({checkoutUrl:"string"})}))).cart?.checkoutUrl??null}function Jt(t,e){let n=typeof e=="number"?{quantity:e}:e,r={id:t};n.quantity!==void 0&&(r.quantity=n.quantity),"sellingPlanId"in n&&(r.sellingPlanId=n.sellingPlanId?Q.sellingPlan(n.sellingPlanId):null),n.attributes&&(r.attributes=D(n.attributes));let i=n.merchandiseId||n.variantId;return i&&(r.merchandiseId=Q.variant(i)),r}var pt=t=>x({name:"cartLinesUpdate",args:"$lines: [CartLineUpdateInput!]!",inner:"lines: $lines",variables:{lines:t},createInput:null}),Y=t=>x({name:"cartLinesRemove",args:"$lineIds: [ID!]!",inner:"lineIds: $lineIds",variables:{lineIds:t},createInput:null}),Zt=(t,e)=>e>0?pt([{id:t,quantity:e}]):Y([t]);var ft=null;function te(t){ft=t}var Re=t=>zt(t).then(e=>({kind:"url",url:e}),e=>({kind:"failed",error:e}));async function Ue(){if(!ft)return null;try{let t=await ft();return t&&`${t}${t.includes("?")?"&":"?"}logged_in=true`}catch(t){return w(t,"account checkout"),null}}async function qe(t){let e=Re(t),n=await Ue();if(n)return n;let r=await e;if(r.kind==="failed")throw r.error;if(!r.url)throw new b("No checkoutUrl (cart empty or expired)");return r.url}function De(t){try{t.opener=null}catch{}}async function ee(t=l.checkoutTarget){let e=E(),n=m();if(!e||n&&!n.totalQuantity)return null;let r=t==="_blank"?window.open("","_blank"):null;r&&De(r);try{let i=await qe(e);if(!Ct(i))throw new b("The checkout URL is not https: not opened");return y("checkout",{url:i,cart:m()}),r&&!r.closed?r.location.href=i:window.location.href=i,i}catch(i){return r?.close(),w(i,"checkout failed"),null}}var J=()=>m()?.lines.nodes??[];async function Qe(){let t=E();if(t)try{let e=await mt(t);e||I(),C(e,"load")}catch(e){w(e,"cart reload after a failed change")}}function A(t){return Kt(()=>t().catch(async e=>{throw Gt(e)&&await Qe(),e}))}function Ne(t,e){let n=J().find(u=>u.id===t);if(!n)return Promise.resolve(m());let r=Math.max(0,dt(n)+e),i={quantity:r};O.set(t,i),_("pending");let o=()=>O.get(t)===i;return A(async()=>{if(!o())return m();if(J().find(p=>p.id===t)?.quantity===r)return m();let c=await Zt(t,r);return o()?C(c,r>0?"update":"remove"):(lt(c),c)}).finally(()=>{o()&&(O.delete(t),_("settled"))})}function _e(t){let e=(m()?.discountCodes??[]).map(r=>r.code),n=typeof t=="function"?t(e):t;return(Array.isArray(n)?n:[n]).map(r=>r.trim()).filter(Boolean)}function Fe(t){let e=new Map((m()?.attributes??[]).map(n=>[n.key,n.value]));return D(t).forEach(n=>e.set(n.key,n.value)),[...e].filter(([,n])=>n!=="").map(([n,r])=>({key:n,value:r}))}async function He(){let t=E();if(!t)return F({kind:"loaded",cart:null}),null;Vt();try{let e=await mt(t);e||I(),F({kind:"loaded",cart:e})}catch(e){w(e,"cart load failed"),X(e)&&I(),F({kind:"failed",error:e})}return m()}var z={init:He,id:E,get status(){return G()},get state(){return m()},get lines(){return[...J()]},get count(){return m()?.totalQuantity??0},get loaded(){return G().kind!=="unknown"},get lastError(){let t=G();return t.kind!=="error"?null:t.error instanceof Error?t.error:new Error(String(t.error))},get warnings(){return[...Ft()]},get pendingQty(){return O},setCheckoutResolver:te,forgetSaved(){I(),F({kind:"loaded",cart:null})},render:N,subscribe:jt,add(t,e=1,n={}){let r=(Array.isArray(t)?t:[t]).map(i=>Xt(i,e,n));return A(async()=>{let i=await x({name:"cartLinesAdd",args:"$lines: [CartLineInput!]!",inner:"lines: $lines",variables:{lines:r},createInput:{lines:r}});if(!i)throw new b("Shopify answered the add without a cart");return C(i,"add"),y("added",{cart:i,lines:r}),l.openCartOnAdd&&B(),i})},updateLine(t,e){let n=typeof e=="number"?e:e.quantity;if(n!==void 0&&n<=0)return z.removeLine(t);let r=Jt(t,e);return A(async()=>C(await pt([r]),"update"))},changeQuantity:Ne,quantityOf:dt,removeLine(t){let e=Array.isArray(t)?t:[t];return A(async()=>C(await Y(e),"remove"))},clear(){return A(async()=>{let t=J().map(e=>e.id);return t.length?C(await Y(t),"remove"):m()})},setNote(t){let e={note:t??""};return A(async()=>C(await x({name:"cartNoteUpdate",args:"$note: String!",inner:"note: $note",variables:e,createInput:e}),"note"))},setAttributes(t){return A(async()=>{let e={attributes:Fe(t)},n=await x({name:"cartAttributesUpdate",args:"$attributes: [AttributeInput!]!",inner:"attributes: $attributes",variables:e,createInput:e});return C(n,"attributes")})},setDiscountCodes(t){return A(async()=>{let e={discountCodes:_e(t)},n=await x({name:"cartDiscountCodesUpdate",args:"$discountCodes: [String!]!",inner:"discountCodes: $discountCodes",variables:e,createInput:e});return C(n,"discount")})},async applyDiscount(t){let e=await z.setDiscountCodes(i=>[...new Set([...i,t])]),n=t.toLowerCase();if((e?.discountCodes??[]).find(i=>i.code.toLowerCase()===n)?.applicable)return e;try{await z.removeDiscount(t)}catch(i){w(i,"removing a discount code Shopify refused")}throw new b(`Discount code not valid: ${t}`,{code:"INVALID_DISCOUNT"})},removeDiscount(t){let e=t.toLowerCase();return z.setDiscountCodes(n=>n.filter(r=>r.toLowerCase()!==e))},setBuyerIdentity(t,{create:e=!0}={}){return A(async()=>{let n=await x({name:"cartBuyerIdentityUpdate",args:"$buyerIdentity: CartBuyerIdentityInput!",inner:"buyerIdentity: $buyerIdentity",variables:{buyerIdentity:t},createInput:e?{buyerIdentity:t}:null}).catch(r=>{if(e||!X(r))throw r;return null});return C(n,"buyer-identity")})},checkout:ee,drawers:$,isOpen:S,open:B,close:rt,toggle:xt};export{se as a,ot as b,it as c,Xe as d,st as e,ut as f,Qt as g,z as h};
@@ -1 +1 @@
1
- import{a as x}from"./chunk-D3MRWOFI.js";var W={};x(W,{GID:()=>y,allPlans:()=>s,allocationFor:()=>a,findPlan:()=>w,hasPlans:()=>S,planAdjustment:()=>G,planCheckoutCharge:()=>b,planPrice:()=>h,planSavings:()=>j,plansForVariant:()=>F,toGid:()=>u});var A=/^(-?)(\d+)(?:\.(\d+))?$/;function d(n,e){let t=A.exec(n.trim());if(!t)return null;let[,l="",r="0",i=""]=t,o=BigInt(`${r}${i.padEnd(e,"0")}`);return l==="-"?-o:o}var p=n=>n.split(".")[1]?.length??0;function I(n,e){if(n==null||e==null)return!1;let t=Math.max(p(n.trim()),p(e.trim())),l=d(n,t),r=d(e,t);return l===null||r===null?!1:l>r}var f=2,g=new Map;function m(n){let e=g.get(n);if(e!==void 0)return e;let t=f;try{t=new Intl.NumberFormat("en",{style:"currency",currency:n}).resolvedOptions().maximumFractionDigits??f}catch{}return g.set(n,t),t}function c(n){return Math.round(parseFloat(n.amount)*10**m(n.currencyCode))}function P(n,e){let t=m(e);return{amount:(n/10**t).toFixed(t),currencyCode:e}}var M=100;function u(n,e){let t=typeof n=="string"||typeof n=="number"?String(n).trim():"";return t?t.startsWith("gid://")?t:/^\d+$/.test(t)?`gid://shopify/${e}/${t}`:t:null}var y={product:n=>u(n,"Product"),variant:n=>u(n,"ProductVariant"),sellingPlan:n=>u(n,"SellingPlan")};function s(n){return(n?.sellingPlanGroups?.nodes??[]).flatMap(t=>t.sellingPlans.nodes.map(l=>({...l,group:t})))}function S(n){return s(n).length>0}function a(n,e){return!n||!e?null:(n.sellingPlanAllocations?.nodes??[]).find(l=>l.sellingPlan.id===e)??null}function F(n,e){return s(n).filter(t=>a(e,t.id))}function h(n,e){let t=a(n,e)?.priceAdjustments[0];return t?.perDeliveryPrice??t?.price??n?.price??null}function b(n,e){let t=a(n,e);return t?.checkoutChargeAmount??t?.priceAdjustments[0]?.price??n?.price??null}function j(n,e){let t=h(n,e);if(!n||!t)return{amount:null,percentage:0};let l=parseFloat(n.price.amount),r=parseFloat(t.amount);if(!Number.isFinite(l)||!Number.isFinite(r)||l<=0||r>=l)return{amount:null,percentage:0};let i=c(n.price)-c(t);return{amount:P(i,n.price.currencyCode),percentage:Math.round((1-r/l)*M)}}function G(n){let e=n?.priceAdjustments[0]?.adjustmentValue;if(!e)return null;switch(e.__typename){case"SellingPlanPercentagePriceAdjustment":return{type:"percentage",value:e.adjustmentPercentage};case"SellingPlanFixedAmountPriceAdjustment":return{type:"amount",value:e.adjustmentAmount};case"SellingPlanFixedPriceAdjustment":return{type:"price",value:e.price};default:return null}}function w(n,e){if(!e)return null;let t=s(n),l=y.sellingPlan(e),r=e.trim().toLowerCase();return t.find(i=>i.id===l)??t.find(i=>i.name.toLowerCase()===r)??t.find(i=>i.options.some(o=>o.value.toLowerCase()===r))??null}export{I as a,c as b,P as c,y as d,s as e,a as f,h as g,b as h,j as i,G as j,w as k,W as l};
1
+ import{a as x}from"./chunk-OJAV2I3C.js";var W={};x(W,{GID:()=>y,allPlans:()=>s,allocationFor:()=>a,findPlan:()=>w,hasPlans:()=>S,planAdjustment:()=>G,planCheckoutCharge:()=>b,planPrice:()=>h,planSavings:()=>j,plansForVariant:()=>F,toGid:()=>u});var A=/^(-?)(\d+)(?:\.(\d+))?$/;function d(n,e){let t=A.exec(n.trim());if(!t)return null;let[,l="",r="0",i=""]=t,o=BigInt(`${r}${i.padEnd(e,"0")}`);return l==="-"?-o:o}var p=n=>n.split(".")[1]?.length??0;function I(n,e){if(n==null||e==null)return!1;let t=Math.max(p(n.trim()),p(e.trim())),l=d(n,t),r=d(e,t);return l===null||r===null?!1:l>r}var f=2,g=new Map;function m(n){let e=g.get(n);if(e!==void 0)return e;let t=f;try{t=new Intl.NumberFormat("en",{style:"currency",currency:n}).resolvedOptions().maximumFractionDigits??f}catch{}return g.set(n,t),t}function c(n){return Math.round(parseFloat(n.amount)*10**m(n.currencyCode))}function P(n,e){let t=m(e);return{amount:(n/10**t).toFixed(t),currencyCode:e}}var M=100;function u(n,e){let t=typeof n=="string"||typeof n=="number"?String(n).trim():"";return t?t.startsWith("gid://")?t:/^\d+$/.test(t)?`gid://shopify/${e}/${t}`:t:null}var y={product:n=>u(n,"Product"),variant:n=>u(n,"ProductVariant"),sellingPlan:n=>u(n,"SellingPlan")};function s(n){return(n?.sellingPlanGroups?.nodes??[]).flatMap(t=>t.sellingPlans.nodes.map(l=>({...l,group:t})))}function S(n){return s(n).length>0}function a(n,e){return!n||!e?null:(n.sellingPlanAllocations?.nodes??[]).find(l=>l.sellingPlan.id===e)??null}function F(n,e){return s(n).filter(t=>a(e,t.id))}function h(n,e){let t=a(n,e)?.priceAdjustments[0];return t?.perDeliveryPrice??t?.price??n?.price??null}function b(n,e){let t=a(n,e);return t?.checkoutChargeAmount??t?.priceAdjustments[0]?.price??n?.price??null}function j(n,e){let t=h(n,e);if(!n||!t)return{amount:null,percentage:0};let l=parseFloat(n.price.amount),r=parseFloat(t.amount);if(!Number.isFinite(l)||!Number.isFinite(r)||l<=0||r>=l)return{amount:null,percentage:0};let i=c(n.price)-c(t);return{amount:P(i,n.price.currencyCode),percentage:Math.round((1-r/l)*M)}}function G(n){let e=n?.priceAdjustments[0]?.adjustmentValue;if(!e)return null;switch(e.__typename){case"SellingPlanPercentagePriceAdjustment":return{type:"percentage",value:e.adjustmentPercentage};case"SellingPlanFixedAmountPriceAdjustment":return{type:"amount",value:e.adjustmentAmount};case"SellingPlanFixedPriceAdjustment":return{type:"price",value:e.price};default:return null}}function w(n,e){if(!e)return null;let t=s(n),l=y.sellingPlan(e),r=e.trim().toLowerCase();return t.find(i=>i.id===l)??t.find(i=>i.name.toLowerCase()===r)??t.find(i=>i.options.some(o=>o.value.toLowerCase()===r))??null}export{I as a,c as b,P as c,y as d,s as e,a as f,h as g,b as h,j as i,G as j,w as k,W as l};
@@ -1 +1 @@
1
- import{H as p,l as c,m as i,n as d,q as u}from"./chunk-P73VN3B6.js";function m(e){try{return decodeURIComponent(e)}catch(o){if(o instanceof URIError)return e;throw o}}var w="url:";function U(e,o=window.location,a="product"){let n=(d(e,a)??"").trim();if(!n.toLowerCase().startsWith(w))return{key:n||null,fromUrl:!1,raw:n};let r=n.slice(w.length).trim(),t;if(r.toLowerCase()==="path"){let s=o.pathname.split("/").filter(Boolean),f=s[s.length-1];t=f===void 0?null:m(f)}else t=new URLSearchParams(o.search).get(r||"handle");return{key:t?.trim()||null,fromUrl:!0,raw:n}}var h=["loading","ready","error","not-found"],y=e=>h.some(o=>o===e),S=e=>typeof e=="object"&&e!==null&&"code"in e?e.code:void 0,x=e=>S(e)==="NOT_FOUND",l=()=>["product","collection","products","recommendations"].map(e=>i(e)).join(","),K=(e,o)=>e===o||e.parentElement?.closest(l())===o;function g(e){let o=S(e);return typeof o=="string"&&o?o:"error"}function L(e,o,a){let n=o==="not-found",r=o==="error"||n;e.setAttribute(c("state"),n?"error":o),r?e.setAttribute(c("error"),n?"not-found":g(a)):e.removeAttribute(c("error")),u(e,i("show"),l()).forEach(t=>{let s=d(t,"show");y(s)&&p(t,s===o)}),r&&u(e,i("add-to-cart"),l()).forEach(t=>{t.classList.add("is-disabled"),t.setAttribute("aria-disabled","true"),"disabled"in t&&(t.disabled=!0)})}export{m as a,U as b,h as c,x as d,l as e,K as f,L as g};
1
+ import{H as p,l as c,m as i,n as d,q as u}from"./chunk-OATTAXPO.js";function m(e){try{return decodeURIComponent(e)}catch(o){if(o instanceof URIError)return e;throw o}}var w="url:";function U(e,o=window.location,a="product"){let n=(d(e,a)??"").trim();if(!n.toLowerCase().startsWith(w))return{key:n||null,fromUrl:!1,raw:n};let r=n.slice(w.length).trim(),t;if(r.toLowerCase()==="path"){let s=o.pathname.split("/").filter(Boolean),f=s[s.length-1];t=f===void 0?null:m(f)}else t=new URLSearchParams(o.search).get(r||"handle");return{key:t?.trim()||null,fromUrl:!0,raw:n}}var h=["loading","ready","error","not-found"],y=e=>h.some(o=>o===e),S=e=>typeof e=="object"&&e!==null&&"code"in e?e.code:void 0,x=e=>S(e)==="NOT_FOUND",l=()=>["product","collection","products","recommendations"].map(e=>i(e)).join(","),K=(e,o)=>e===o||e.parentElement?.closest(l())===o;function g(e){let o=S(e);return typeof o=="string"&&o?o:"error"}function L(e,o,a){let n=o==="not-found",r=o==="error"||n;e.setAttribute(c("state"),n?"error":o),r?e.setAttribute(c("error"),n?"not-found":g(a)):e.removeAttribute(c("error")),u(e,i("show"),l()).forEach(t=>{let s=d(t,"show");y(s)&&p(t,s===o)}),r&&u(e,i("add-to-cart"),l()).forEach(t=>{t.classList.add("is-disabled"),t.setAttribute("aria-disabled","true"),"disabled"in t&&(t.disabled=!0)})}export{m as a,U as b,h as c,x as d,l as e,K as f,L as g};
@@ -1 +1 @@
1
- import{b as P,c as f,d as x,e as v,f as d,g,h as A,i as y,j as I,k as h}from"./chunk-S5BUUIB6.js";var M=100,V=(n,e)=>f(P(n)*e,n.currencyCode),S=n=>Object.fromEntries(n.selectedOptions.map(e=>[e.name,e.value]));function w(n,e){return n.variants.nodes.find(o=>o.selectedOptions.every(r=>e[r.name]===r.value))??null}function T(n,e,o,r){return n.variants.nodes.some(t=>t.availableForSale&&t.selectedOptions.every(i=>i.name===o?i.value===r:e[i.name]===i.value))}var k=n=>n.kind==="subscription"?n.planId:n.offeredPlanId;function F(n,e){return n.kind==="subscription"&&d(e,n.planId)?n:{kind:"one-time"}}function C(n,e,o,r){let t=v(n),i=t.find(s=>s.id===r)??t[0];if(!i)return{kind:"one-time",offeredPlanId:null};let a=d(e,i.id)?i:t.find(s=>d(e,s.id))??i;return n.requiresSellingPlan||o==="subscription"?{kind:"subscription",planId:a.id}:{kind:"one-time",offeredPlanId:a.id}}function B(n,{variant:e,sellingPlan:o,defaultPlan:r,defaultPurchase:t}){let i=n.variants.nodes,a=x.variant(e),s=i.find(l=>l.id===a)??i.find(l=>l.availableForSale)??i[0]??null,c=h(n,o),p=c??h(n,r),m=c||t==="subscription"?"subscription":"one-time";return{selected:s?S(s):{},purchase:C(n,s,m,p?.id??null)}}function j(n,e,o,r,t){let i=n.quantityAvailable,a=i!=null&&i>0&&i<=e,s=r.compareAtPrice!==null,c=r.line.kind==="subscription";return{"in-stock":n.availableForSale,"out-of-stock":!n.availableForSale,backorder:n.availableForSale&&n.currentlyNotInStock,"on-sale":s,"not-on-sale":!s,"has-variants":o>1,"single-variant":o===1,"low-stock":a,"plenty-in-stock":n.availableForSale&&!a,"subscription-available":r.subscriptionAvailable,"subscription-unavailable":!r.subscriptionAvailable,"subscription-only":t,"one-time-available":!t,"subscription-selected":c,"one-time-selected":!c,"has-savings":c?r.savings.percentage>0:s}}function R(n,e,o){let r=w(n,e.selected),t=r??n.variants.nodes[0];if(!t)return null;let i=C(n,t,e.purchase.kind,k(e.purchase)),a=k(i),s=v(n),c=F(i,t),p=c.kind==="subscription"?d(t,c.planId):null,m=p?g(t,a)??t.price:t.price,l=p?.priceAdjustments[0]?.compareAtPrice??t.compareAtPrice,b={line:c,subscriptionAvailable:s.some(u=>d(t,u.id)),compareAtPrice:l&&parseFloat(l.amount)>parseFloat(m.amount)?l:null,savings:y(t,a)};return{...b,variant:t,selected:r?e.selected:S(t),purchase:i,plan:s.find(u=>u.id===a)??null,quantity:e.quantity,price:m,show:j(t,o,n.variants.nodes.length,b,n.requiresSellingPlan)}}function G(n,e){let{variant:o,plan:r,price:t,compareAtPrice:i,quantity:a}=n,s=k(n.purchase),c=u=>V(u,Math.max(1,a)),b={price:()=>e.money(t),"total-price":()=>e.money(c(t)),"one-time-price":()=>e.money(o.price),"subscription-price":()=>e.money(s?g(o,s):null),"subscription-savings":()=>e.percent(n.savings.percentage),"subscription-savings-amount":()=>e.money(n.savings.amount),"checkout-charge":()=>{let u=n.line.kind==="subscription"?A(o,s)??t:t;return e.money(c(u))},"plan-name":()=>r?.name,"plan-description":()=>r?.description,"plan-group":()=>r?.group.name,"compare-at-price":()=>e.money(i),"unit-price":()=>e.money(o.unitPrice),"discount-percentage":()=>i?`${Math.round((1-parseFloat(t.amount)/parseFloat(i.amount))*M)}%`:"0%","discount-amount":()=>i?e.money(f(P(i)-P(t),t.currencyCode)):"","variant-title":()=>o.title,"variant-id":()=>o.id,sku:()=>o.sku,barcode:()=>o.barcode,stock:()=>o.quantityAvailable,quantity:()=>a};return new Map(Object.entries(b))}function E(n,e,o,r){let i={name:()=>o?.name,option:()=>(o?.options??[]).map(a=>a.value).join(", "),description:()=>o?.description,price:()=>r.money(g(n,e)),savings:()=>r.percent(y(n,e).percentage),"savings-amount":()=>r.money(y(n,e).amount),adjustment:()=>{let a=I(o);return a?a.type==="percentage"?`${a.value}%`:r.money(a.value):""}};return new Map(Object.entries(i))}export{S as a,T as b,k as c,F as d,C as e,B as f,R as g,G as h,E as i};
1
+ import{b as P,c as f,d as x,e as v,f as d,g,h as A,i as y,j as I,k as h}from"./chunk-BVO7KK2M.js";var M=100,V=(n,e)=>f(P(n)*e,n.currencyCode),S=n=>Object.fromEntries(n.selectedOptions.map(e=>[e.name,e.value]));function w(n,e){return n.variants.nodes.find(o=>o.selectedOptions.every(r=>e[r.name]===r.value))??null}function T(n,e,o,r){return n.variants.nodes.some(t=>t.availableForSale&&t.selectedOptions.every(i=>i.name===o?i.value===r:e[i.name]===i.value))}var k=n=>n.kind==="subscription"?n.planId:n.offeredPlanId;function F(n,e){return n.kind==="subscription"&&d(e,n.planId)?n:{kind:"one-time"}}function C(n,e,o,r){let t=v(n),i=t.find(s=>s.id===r)??t[0];if(!i)return{kind:"one-time",offeredPlanId:null};let a=d(e,i.id)?i:t.find(s=>d(e,s.id))??i;return n.requiresSellingPlan||o==="subscription"?{kind:"subscription",planId:a.id}:{kind:"one-time",offeredPlanId:a.id}}function B(n,{variant:e,sellingPlan:o,defaultPlan:r,defaultPurchase:t}){let i=n.variants.nodes,a=x.variant(e),s=i.find(l=>l.id===a)??i.find(l=>l.availableForSale)??i[0]??null,c=h(n,o),p=c??h(n,r),m=c||t==="subscription"?"subscription":"one-time";return{selected:s?S(s):{},purchase:C(n,s,m,p?.id??null)}}function j(n,e,o,r,t){let i=n.quantityAvailable,a=i!=null&&i>0&&i<=e,s=r.compareAtPrice!==null,c=r.line.kind==="subscription";return{"in-stock":n.availableForSale,"out-of-stock":!n.availableForSale,backorder:n.availableForSale&&n.currentlyNotInStock,"on-sale":s,"not-on-sale":!s,"has-variants":o>1,"single-variant":o===1,"low-stock":a,"plenty-in-stock":n.availableForSale&&!a,"subscription-available":r.subscriptionAvailable,"subscription-unavailable":!r.subscriptionAvailable,"subscription-only":t,"one-time-available":!t,"subscription-selected":c,"one-time-selected":!c,"has-savings":c?r.savings.percentage>0:s}}function R(n,e,o){let r=w(n,e.selected),t=r??n.variants.nodes[0];if(!t)return null;let i=C(n,t,e.purchase.kind,k(e.purchase)),a=k(i),s=v(n),c=F(i,t),p=c.kind==="subscription"?d(t,c.planId):null,m=p?g(t,a)??t.price:t.price,l=p?.priceAdjustments[0]?.compareAtPrice??t.compareAtPrice,b={line:c,subscriptionAvailable:s.some(u=>d(t,u.id)),compareAtPrice:l&&parseFloat(l.amount)>parseFloat(m.amount)?l:null,savings:y(t,a)};return{...b,variant:t,selected:r?e.selected:S(t),purchase:i,plan:s.find(u=>u.id===a)??null,quantity:e.quantity,price:m,show:j(t,o,n.variants.nodes.length,b,n.requiresSellingPlan)}}function G(n,e){let{variant:o,plan:r,price:t,compareAtPrice:i,quantity:a}=n,s=k(n.purchase),c=u=>V(u,Math.max(1,a)),b={price:()=>e.money(t),"total-price":()=>e.money(c(t)),"one-time-price":()=>e.money(o.price),"subscription-price":()=>e.money(s?g(o,s):null),"subscription-savings":()=>e.percent(n.savings.percentage),"subscription-savings-amount":()=>e.money(n.savings.amount),"checkout-charge":()=>{let u=n.line.kind==="subscription"?A(o,s)??t:t;return e.money(c(u))},"plan-name":()=>r?.name,"plan-description":()=>r?.description,"plan-group":()=>r?.group.name,"compare-at-price":()=>e.money(i),"unit-price":()=>e.money(o.unitPrice),"discount-percentage":()=>i?`${Math.round((1-parseFloat(t.amount)/parseFloat(i.amount))*M)}%`:"0%","discount-amount":()=>i?e.money(f(P(i)-P(t),t.currencyCode)):"","variant-title":()=>o.title,"variant-id":()=>o.id,sku:()=>o.sku,barcode:()=>o.barcode,stock:()=>o.quantityAvailable,quantity:()=>a};return new Map(Object.entries(b))}function E(n,e,o,r){let i={name:()=>o?.name,option:()=>(o?.options??[]).map(a=>a.value).join(", "),description:()=>o?.description,price:()=>r.money(g(n,e)),savings:()=>r.percent(y(n,e).percentage),"savings-amount":()=>r.money(y(n,e).amount),adjustment:()=>{let a=I(o);return a?a.type==="percentage"?`${a.value}%`:r.money(a.value):""}};return new Map(Object.entries(i))}export{S as a,T as b,k as c,F as d,C as e,B as f,R as g,G as h,E as i};
@@ -1 +1 @@
1
- import{b as Q,c as y,d as j,h as J}from"./chunk-P6DV24RG.js";import{a as T,b as K,c as A,d as M,e as W,f as X,g as Y,h as _,i as z}from"./chunk-XU27NSXT.js";import{d as D,e as V,f as E,k as G}from"./chunk-S5BUUIB6.js";import{c as N,f as Z}from"./chunk-2IGCUTG5.js";import{B as C,C as H,F as h,H as O,I as P,K as k,L as F,M as R,N as U,O as B,l as m,m as s,n as l,o as x,p as b,q as w,t as f,w as $}from"./chunk-P73VN3B6.js";import{b as p,r as I,z as L}from"./chunk-D3MRWOFI.js";var tt={money:H,percent:C},lt=e=>e.tagName==="INPUT";function q(e){let t=b(e,s("add-label"))[0]??e,n=t.dataset.tetherLabel??(lt(t)?t.value:t.textContent);return t.dataset.tetherLabel=n,{label:t,original:n}}function ct(e,t){let{product:n}=e,i=r=>t.selected[e.optName(r)]??"";e.$(s("option-selected")).forEach(r=>{h(r,i(l(r,"option-selected")))}),e.$(s("option-list")).forEach(r=>{let a=e.optName(l(r,"option-list"));b(r,s("option-value")).forEach(o=>{let c=l(o,"option-value")??"";P(o,t.selected[a]===c);let u=!K(n,t.selected,a,c);o.classList.toggle("is-unavailable",u),o.setAttribute("data-unavailable",u?"true":"false")})}),y(e,s("option")).forEach(r=>{r.value=i(l(r,"option"))}),y(e,s("variant-select")).forEach(r=>{r.value=t.variant.id})}function ut(e,t){let{variant:n,purchase:i,line:r}=t;e.$(s("purchase")).forEach(a=>{if(Q(a)){a.value=i.kind;return}let o=l(a,"purchase");P(a,o===i.kind);let c=o==="subscription"?!t.subscriptionAvailable:e.product.requiresSellingPlan;a.classList.toggle("is-unavailable",c)}),e.$(s("plan-value")).forEach(a=>{let o=l(a,"plan-value")??"";P(a,r.kind==="subscription"&&o===r.planId),a.classList.toggle("is-unavailable",!E(n,o));let c=e.plans.find(d=>d.id===o),u=z(n,o,c,tt);b(a,s("plan-bind")).forEach(d=>{let v=u.get(l(d,"plan-bind")??"");v&&h(d,v())})}),y(e,s("plan")).forEach(a=>{a.value=r.kind==="subscription"?r.planId:""})}function dt(e,t){let n=new Map(Object.entries(t.show));N.forEach(i=>n.set(i,i==="ready")),e.$(s("show")).forEach(i=>{let r=l(i,"show")??"",a=n.get(r);a!==void 0&&(N.some(o=>o===r)&&!Z(i,e.root)||O(i,a))})}function ht(e,t){let n=!t.variant.availableForSale;e.$(s("add-to-cart")).forEach(i=>{i.classList.toggle("is-disabled",n),i.setAttribute("aria-disabled",String(n)),"disabled"in i&&(i.disabled=n);let r=l(i,"soldout-text"),a=l(i,"subscribe-text");if(!r&&!a)return;let{label:o,original:c}=q(i),u=c;t.line.kind==="subscription"&&a&&(u=a),n&&r&&(u=r),i.getAttribute("aria-busy")!=="true"&&h(o,u)})}function et(e,t){let{variant:n}=t,{product:i}=e,r=_(t,tt);e.$(s("bind")).forEach(a=>{let o=l(a,"bind")??"";if(o==="variant-image"){$(a,n.image?.url||i.featuredImage?.url,n.image?.altText||i.title);return}let c=r.get(o);c&&h(a,c())}),ct(e,t),ut(e,t),dt(e,t),e.root.classList.toggle("is-subscription",t.line.kind==="subscription"),e.root.setAttribute(m("purchase-mode"),t.line.kind),ht(e,t)}var it=()=>s("product"),pt=e=>e.tagName==="INPUT"||e.tagName==="SELECT"||e.tagName==="TEXTAREA",nt=e=>e instanceof window.Element;function g(e,t,n){let i=t.closest(n);return i?.closest(it())===e.root?i:null}function mt(e,t){let{label:n,original:i}=q(t),r=l(t,"adding-text");R(t,async()=>{r&&h(n,r);try{await e.addToCart()}catch(a){L(a,"add to cart failed"),f("error",{error:a,context:"add-to-cart"},e.root)}finally{r&&h(n,i)}}).then(()=>{e.renderVariant()}).catch(a=>{L(a,"add to cart render")})}function ft(e,t,n){let i=g(e,n,s("option-value")),r=i?.closest(s("option-list"));if(i&&r){t.preventDefault(),e.select(e.optName(l(r,"option-list")),l(i,"option-value")??"");return}let a=g(e,n,s("plan-value"));if(a){t.preventDefault(),e.selectPlan(l(a,"plan-value"));return}let o=g(e,n,`${s("purchase")}:not(select)`);if(o){o.tagName!=="INPUT"&&t.preventDefault(),e.setPurchase(rt(l(o,"purchase")));return}let c=g(e,n,s("qty-plus")),u=c?null:g(e,n,s("qty-minus"));if(c||u){t.preventDefault(),e.setQuantity(e.quantity+(c?1:-1));return}let d=g(e,n,s("add-to-cart"));d&&(t.preventDefault(),mt(e,d))}var rt=e=>e==="subscription"?"subscription":"one-time";function vt(e,t){let n=pt(t)?t.value:"";t.matches(`select${s("option")}`)?e.select(e.optName(l(t,"option")),n):t.matches(`select${s("variant-select")}`)?e.selectVariant(n):t.matches(`select${s("plan")}`)?n?e.selectPlan(n):e.setPurchase("one-time"):t.matches(`select${s("purchase")}`)?e.setPurchase(rt(n)):t.matches(s("qty"))&&e.setQuantity(n)}function at(e){e.root.addEventListener("click",t=>{nt(t.target)&&ft(e,t,t.target)}),e.root.addEventListener("change",t=>{let{target:n}=t;nt(n)&&n.closest(it())===e.root&&vt(e,n)})}var gt=new WeakMap,bt=()=>s("product"),S=new Map;function Pt(e){e.forEach(t=>{S.has(t.handle)||S.set(t.handle,t.options.map(n=>n.name))})}var st=e=>e.tagName==="INPUT",Et=e=>e.tagName==="INPUT"||e.tagName==="SELECT"||e.tagName==="TEXTAREA";function yt(e){return st(e)&&e.type==="checkbox"?e.checked?e.value&&e.value!=="on"?e.value:"Yes":null:st(e)&&e.type==="radio"?e.checked?e.value:null:Et(e)&&e.value||null}var ot=class{constructor(t,n){p(this,"root");p(this,"product");p(this,"plans");p(this,"selected");p(this,"purchase");p(this,"variant");p(this,"quantity");this.root=t,this.product=n,this.plans=V(n);let i=new URLSearchParams(window.location.search),r=X(n,{variant:i.get("variant")||l(t,"variant"),sellingPlan:i.get("selling_plan"),defaultPlan:l(t,"default-plan"),defaultPurchase:l(t,"default-purchase")||I.defaultPurchase});this.selected=r.selected,this.purchase=r.purchase,this.variant=null,this.quantity=x(t,"quantity")?Math.max(0,parseInt(l(t,"quantity")??"",10)||0):1,gt.set(t,this),t.setAttribute(m("state"),"ready"),t.removeAttribute(m("error")),this.renderProduct(),at(this),this.renderVariant(),F(t,"product"),k("product"),f("product-ready",{product:n,scope:this},t)}update(t){let n=this.variant?.id;this.product=t,this.plans=V(t);let i=t.variants.nodes.find(r=>r.id===n);i&&(this.selected=T(i)),this.root.setAttribute(m("state"),"ready"),this.root.removeAttribute(m("error")),this.renderProduct(),this.renderVariant(),k("product"),f("product-updated",{product:t,scope:this},this.root)}$(t){let n=w(this.root,t,bt());return this.root.matches(t)?[this.root,...n]:n}optName(t){if(!t)return"";let{options:n}=this.product;if(n.some(r=>r.name===t))return t;let i=(S.get(this.product.handle)??[]).indexOf(t);return n[i]?.name??t}get plan(){let t=A(this.purchase);return this.plans.find(n=>n.id===t)??null}get subscriptionAvailable(){return this.plans.some(t=>E(this.variant,t.id))}get isSubscription(){return M(this.purchase,this.variant).kind==="subscription"}getLine(){if(!this.variant)return null;let t={merchandiseId:this.variant.id,quantity:this.quantity},n=M(this.purchase,this.variant);n.kind==="subscription"&&(t.sellingPlanId=n.planId);let i=this.collectAttributes();return i.length&&(t.attributes=i),t}collectAttributes(){let t=B(U(this.root,"line-attributes")),n=this.$(s("line-attribute")).flatMap(i=>{let r=yt(i);return r===null?[]:[{key:l(i,"line-attribute")??"",value:r}]});return[...t,...n]}select(t,n){if(this.selected[t]===n)return;let i=this.product.variants.nodes.filter(o=>o.selectedOptions.some(c=>c.name===t&&c.value===n)),[r]=i;if(!r)return;let a={...this.selected,[t]:n};if(!i.some(o=>o.selectedOptions.every(c=>a[c.name]===c.value))){let o=u=>u.selectedOptions.filter(v=>v.name!==t&&this.selected[v.name]===v.value).length*2+(u.availableForSale?1:0),c=i.reduce((u,d)=>o(d)>o(u)?d:u,r);Object.assign(a,T(c))}this.selected=a,this.renderVariant()}selectVariant(t){let n=this.product.variants.nodes.find(i=>i.id===D.variant(t));n&&(this.selected=T(n),this.renderVariant())}setPurchase(t){let n=W(this.product,this.variant,t,A(this.purchase));n.kind!==this.purchase.kind&&(this.purchase=n,this.renderVariant())}selectPlan(t){let n=G(this.product,t);n&&(this.purchase={kind:"subscription",planId:n.id},this.renderVariant())}setQuantity(t){let n=x(this.root,"quantity")?0:1;this.quantity=Math.max(n,parseInt(String(t),10)||0),this.$(s("qty")).forEach(i=>{h(i,this.quantity)}),this.renderVariant()}async addToCart(){if(!this.variant?.availableForSale)return null;let t=this.getLine();if(!t||t.quantity<1)return null;let n=await J.add(t);return f("product-added",{product:this.product,variant:this.variant,line:t},this.root),n}renderProduct(){let{product:t}=this;S.has(t.handle)||this.$(`${s("option-list")},select${s("option")}`).map(i=>l(i,"option-list")||l(i,"option")).some(i=>t.options.some(r=>r.name===i))&&Pt([t]),j(this)}renderVariant(){let t=Y(this.product,{selected:this.selected,purchase:this.purchase,quantity:this.quantity},I.lowStock);if(!t){this.variant=null;return}this.variant=t.variant,this.selected=t.selected,this.purchase=t.purchase,et(this,t),f("variant-changed",{product:this.product,variant:t.variant,selected:{...t.selected},purchase:t.purchase.kind,sellingPlanId:t.line.kind==="subscription"?t.line.planId:null},this.root)}};export{gt as a,Pt as b,ot as c};
1
+ import{b as Q,c as y,d as j,h as J}from"./chunk-7ZXEVDOS.js";import{a as T,b as K,c as A,d as M,e as W,f as X,g as Y,h as _,i as z}from"./chunk-DM5LEAWM.js";import{d as D,e as V,f as E,k as G}from"./chunk-BVO7KK2M.js";import{c as N,f as Z}from"./chunk-CRKJ2VEX.js";import{B as C,C as H,F as h,H as O,I as P,K as k,L as F,M as R,N as U,O as B,l as m,m as s,n as l,o as x,p as b,q as w,t as f,w as $}from"./chunk-OATTAXPO.js";import{b as p,r as I,z as L}from"./chunk-OJAV2I3C.js";var tt={money:H,percent:C},lt=e=>e.tagName==="INPUT";function q(e){let t=b(e,s("add-label"))[0]??e,n=t.dataset.tetherLabel??(lt(t)?t.value:t.textContent);return t.dataset.tetherLabel=n,{label:t,original:n}}function ct(e,t){let{product:n}=e,i=r=>t.selected[e.optName(r)]??"";e.$(s("option-selected")).forEach(r=>{h(r,i(l(r,"option-selected")))}),e.$(s("option-list")).forEach(r=>{let a=e.optName(l(r,"option-list"));b(r,s("option-value")).forEach(o=>{let c=l(o,"option-value")??"";P(o,t.selected[a]===c);let u=!K(n,t.selected,a,c);o.classList.toggle("is-unavailable",u),o.setAttribute("data-unavailable",u?"true":"false")})}),y(e,s("option")).forEach(r=>{r.value=i(l(r,"option"))}),y(e,s("variant-select")).forEach(r=>{r.value=t.variant.id})}function ut(e,t){let{variant:n,purchase:i,line:r}=t;e.$(s("purchase")).forEach(a=>{if(Q(a)){a.value=i.kind;return}let o=l(a,"purchase");P(a,o===i.kind);let c=o==="subscription"?!t.subscriptionAvailable:e.product.requiresSellingPlan;a.classList.toggle("is-unavailable",c)}),e.$(s("plan-value")).forEach(a=>{let o=l(a,"plan-value")??"";P(a,r.kind==="subscription"&&o===r.planId),a.classList.toggle("is-unavailable",!E(n,o));let c=e.plans.find(d=>d.id===o),u=z(n,o,c,tt);b(a,s("plan-bind")).forEach(d=>{let v=u.get(l(d,"plan-bind")??"");v&&h(d,v())})}),y(e,s("plan")).forEach(a=>{a.value=r.kind==="subscription"?r.planId:""})}function dt(e,t){let n=new Map(Object.entries(t.show));N.forEach(i=>n.set(i,i==="ready")),e.$(s("show")).forEach(i=>{let r=l(i,"show")??"",a=n.get(r);a!==void 0&&(N.some(o=>o===r)&&!Z(i,e.root)||O(i,a))})}function ht(e,t){let n=!t.variant.availableForSale;e.$(s("add-to-cart")).forEach(i=>{i.classList.toggle("is-disabled",n),i.setAttribute("aria-disabled",String(n)),"disabled"in i&&(i.disabled=n);let r=l(i,"soldout-text"),a=l(i,"subscribe-text");if(!r&&!a)return;let{label:o,original:c}=q(i),u=c;t.line.kind==="subscription"&&a&&(u=a),n&&r&&(u=r),i.getAttribute("aria-busy")!=="true"&&h(o,u)})}function et(e,t){let{variant:n}=t,{product:i}=e,r=_(t,tt);e.$(s("bind")).forEach(a=>{let o=l(a,"bind")??"";if(o==="variant-image"){$(a,n.image?.url||i.featuredImage?.url,n.image?.altText||i.title);return}let c=r.get(o);c&&h(a,c())}),ct(e,t),ut(e,t),dt(e,t),e.root.classList.toggle("is-subscription",t.line.kind==="subscription"),e.root.setAttribute(m("purchase-mode"),t.line.kind),ht(e,t)}var it=()=>s("product"),pt=e=>e.tagName==="INPUT"||e.tagName==="SELECT"||e.tagName==="TEXTAREA",nt=e=>e instanceof window.Element;function g(e,t,n){let i=t.closest(n);return i?.closest(it())===e.root?i:null}function mt(e,t){let{label:n,original:i}=q(t),r=l(t,"adding-text");R(t,async()=>{r&&h(n,r);try{await e.addToCart()}catch(a){L(a,"add to cart failed"),f("error",{error:a,context:"add-to-cart"},e.root)}finally{r&&h(n,i)}}).then(()=>{e.renderVariant()}).catch(a=>{L(a,"add to cart render")})}function ft(e,t,n){let i=g(e,n,s("option-value")),r=i?.closest(s("option-list"));if(i&&r){t.preventDefault(),e.select(e.optName(l(r,"option-list")),l(i,"option-value")??"");return}let a=g(e,n,s("plan-value"));if(a){t.preventDefault(),e.selectPlan(l(a,"plan-value"));return}let o=g(e,n,`${s("purchase")}:not(select)`);if(o){o.tagName!=="INPUT"&&t.preventDefault(),e.setPurchase(rt(l(o,"purchase")));return}let c=g(e,n,s("qty-plus")),u=c?null:g(e,n,s("qty-minus"));if(c||u){t.preventDefault(),e.setQuantity(e.quantity+(c?1:-1));return}let d=g(e,n,s("add-to-cart"));d&&(t.preventDefault(),mt(e,d))}var rt=e=>e==="subscription"?"subscription":"one-time";function vt(e,t){let n=pt(t)?t.value:"";t.matches(`select${s("option")}`)?e.select(e.optName(l(t,"option")),n):t.matches(`select${s("variant-select")}`)?e.selectVariant(n):t.matches(`select${s("plan")}`)?n?e.selectPlan(n):e.setPurchase("one-time"):t.matches(`select${s("purchase")}`)?e.setPurchase(rt(n)):t.matches(s("qty"))&&e.setQuantity(n)}function at(e){e.root.addEventListener("click",t=>{nt(t.target)&&ft(e,t,t.target)}),e.root.addEventListener("change",t=>{let{target:n}=t;nt(n)&&n.closest(it())===e.root&&vt(e,n)})}var gt=new WeakMap,bt=()=>s("product"),S=new Map;function Pt(e){e.forEach(t=>{S.has(t.handle)||S.set(t.handle,t.options.map(n=>n.name))})}var st=e=>e.tagName==="INPUT",Et=e=>e.tagName==="INPUT"||e.tagName==="SELECT"||e.tagName==="TEXTAREA";function yt(e){return st(e)&&e.type==="checkbox"?e.checked?e.value&&e.value!=="on"?e.value:"Yes":null:st(e)&&e.type==="radio"?e.checked?e.value:null:Et(e)&&e.value||null}var ot=class{constructor(t,n){p(this,"root");p(this,"product");p(this,"plans");p(this,"selected");p(this,"purchase");p(this,"variant");p(this,"quantity");this.root=t,this.product=n,this.plans=V(n);let i=new URLSearchParams(window.location.search),r=X(n,{variant:i.get("variant")||l(t,"variant"),sellingPlan:i.get("selling_plan"),defaultPlan:l(t,"default-plan"),defaultPurchase:l(t,"default-purchase")||I.defaultPurchase});this.selected=r.selected,this.purchase=r.purchase,this.variant=null,this.quantity=x(t,"quantity")?Math.max(0,parseInt(l(t,"quantity")??"",10)||0):1,gt.set(t,this),t.setAttribute(m("state"),"ready"),t.removeAttribute(m("error")),this.renderProduct(),at(this),this.renderVariant(),F(t,"product"),k("product"),f("product-ready",{product:n,scope:this},t)}update(t){let n=this.variant?.id;this.product=t,this.plans=V(t);let i=t.variants.nodes.find(r=>r.id===n);i&&(this.selected=T(i)),this.root.setAttribute(m("state"),"ready"),this.root.removeAttribute(m("error")),this.renderProduct(),this.renderVariant(),k("product"),f("product-updated",{product:t,scope:this},this.root)}$(t){let n=w(this.root,t,bt());return this.root.matches(t)?[this.root,...n]:n}optName(t){if(!t)return"";let{options:n}=this.product;if(n.some(r=>r.name===t))return t;let i=(S.get(this.product.handle)??[]).indexOf(t);return n[i]?.name??t}get plan(){let t=A(this.purchase);return this.plans.find(n=>n.id===t)??null}get subscriptionAvailable(){return this.plans.some(t=>E(this.variant,t.id))}get isSubscription(){return M(this.purchase,this.variant).kind==="subscription"}getLine(){if(!this.variant)return null;let t={merchandiseId:this.variant.id,quantity:this.quantity},n=M(this.purchase,this.variant);n.kind==="subscription"&&(t.sellingPlanId=n.planId);let i=this.collectAttributes();return i.length&&(t.attributes=i),t}collectAttributes(){let t=B(U(this.root,"line-attributes")),n=this.$(s("line-attribute")).flatMap(i=>{let r=yt(i);return r===null?[]:[{key:l(i,"line-attribute")??"",value:r}]});return[...t,...n]}select(t,n){if(this.selected[t]===n)return;let i=this.product.variants.nodes.filter(o=>o.selectedOptions.some(c=>c.name===t&&c.value===n)),[r]=i;if(!r)return;let a={...this.selected,[t]:n};if(!i.some(o=>o.selectedOptions.every(c=>a[c.name]===c.value))){let o=u=>u.selectedOptions.filter(v=>v.name!==t&&this.selected[v.name]===v.value).length*2+(u.availableForSale?1:0),c=i.reduce((u,d)=>o(d)>o(u)?d:u,r);Object.assign(a,T(c))}this.selected=a,this.renderVariant()}selectVariant(t){let n=this.product.variants.nodes.find(i=>i.id===D.variant(t));n&&(this.selected=T(n),this.renderVariant())}setPurchase(t){let n=W(this.product,this.variant,t,A(this.purchase));n.kind!==this.purchase.kind&&(this.purchase=n,this.renderVariant())}selectPlan(t){let n=G(this.product,t);n&&(this.purchase={kind:"subscription",planId:n.id},this.renderVariant())}setQuantity(t){let n=x(this.root,"quantity")?0:1;this.quantity=Math.max(n,parseInt(String(t),10)||0),this.$(s("qty")).forEach(i=>{h(i,this.quantity)}),this.renderVariant()}async addToCart(){if(!this.variant?.availableForSale)return null;let t=this.getLine();if(!t||t.quantity<1)return null;let n=await J.add(t);return f("product-added",{product:this.product,variant:this.variant,line:t},this.root),n}renderProduct(){let{product:t}=this;S.has(t.handle)||this.$(`${s("option-list")},select${s("option")}`).map(i=>l(i,"option-list")||l(i,"option")).some(i=>t.options.some(r=>r.name===i))&&Pt([t]),j(this)}renderVariant(){let t=Y(this.product,{selected:this.selected,purchase:this.purchase,quantity:this.quantity},I.lowStock);if(!t){this.variant=null;return}this.variant=t.variant,this.selected=t.selected,this.purchase=t.purchase,et(this,t),f("variant-changed",{product:this.product,variant:t.variant,selected:{...t.selected},purchase:t.purchase.kind,sellingPlanId:t.line.kind==="subscription"?t.line.planId:null},this.root)}};export{gt as a,Pt as b,ot as c};
@@ -1 +1 @@
1
- import{b as c,c as u,d as o}from"./chunk-P73VN3B6.js";import{d as m,e as s,n as g,r as p}from"./chunk-D3MRWOFI.js";var e="amount currencyCode",P={inventory:!0},f=t=>t.inventory?"quantityAvailable":"",n="url altText width height";function A(t){let i=[];for(let l of t){let r=g(l);r&&i.push(r)}return i.length?`metafields(identifiers:[${i.map(({namespace:l,key:r})=>`{namespace: ${JSON.stringify(l)}, key: ${JSON.stringify(r)}}`).join(", ")}]){namespace key type value reference{... on MediaImage{image{${n}}}}}`:""}var h=` id name description recurringDeliveries options{name value}priceAdjustments{orderCount adjustmentValue{__typename ... on SellingPlanPercentagePriceAdjustment{adjustmentPercentage}... on SellingPlanFixedAmountPriceAdjustment{adjustmentAmount{${e}}}... on SellingPlanFixedPriceAdjustment{price{${e}}}}}`,$=` sellingPlan{id}checkoutChargeAmount{${e}}remainingBalanceChargeAmount{${e}}priceAdjustments{price{${e}}compareAtPrice{${e}}perDeliveryPrice{${e}}unitPrice{${e}}}`;function b(t=p,i=P){return` fragment TetherProduct on Product{id handle title description descriptionHtml productType vendor tags availableForSale publishedAt onlineStoreUrl requiresSellingPlan seo{title description}featuredImage{${n}}images(first:${t.imagesFirst}){nodes{${n}}}options{name optionValues{name swatch{color image{previewImage{${n}}}}}}priceRange{minVariantPrice{${e}}maxVariantPrice{${e}}}compareAtPriceRange{minVariantPrice{${e}}maxVariantPrice{${e}}}${A(t.metafields)} sellingPlanGroups(first:${t.sellingPlanGroupsFirst}){nodes{name appName options{name values}sellingPlans(first:${t.sellingPlansFirst}){nodes{${h}}}}}variants(first:${t.variantsFirst}){nodes{id title availableForSale currentlyNotInStock ${f(i)} sku barcode selectedOptions{name value}image{${n}}price{${e}}compareAtPrice{${e}}unitPrice{${e}}sellingPlanAllocations(first:${t.sellingPlansFirst}){nodes{${$}}}}}}`}function x(t=P){return` fragment TetherCart on Cart{id checkoutUrl totalQuantity note createdAt updatedAt attributes{key value}buyerIdentity{countryCode email}discountCodes{code applicable}cost{subtotalAmount{${e}}totalAmount{${e}}checkoutChargeAmount{${e}}}lines(first:100){nodes{id quantity attributes{key value}cost{totalAmount{${e}}subtotalAmount{${e}}amountPerQuantity{${e}}compareAtAmountPerQuantity{${e}}}discountAllocations{discountedAmount{${e}}}sellingPlanAllocation{sellingPlan{id name description recurringDeliveries options{name value}}checkoutChargeAmount{${e}}priceAdjustments{price{${e}}compareAtPrice{${e}}perDeliveryPrice{${e}}}}merchandise{... on ProductVariant{id title sku availableForSale requiresShipping ${f(t)} image{${n}}price{${e}}compareAtPrice{${e}}selectedOptions{name value}product{id title handle vendor featuredImage{${n}}}}}... on ComponentizableCartLine{lineComponents{id quantity merchandise{... on ProductVariant{id title product{title handle}}}}}}}}`}function F(){return` id handle title description descriptionHtml image{${n}}seo{title description}`}var d={amount:"string",currencyCode:"string"},a={id:"string",handle:"string",title:"string",options:["object"],images:{nodes:["object"]},priceRange:{minVariantPrice:d,maxVariantPrice:d},variants:{nodes:[{id:"string",price:d,selectedOptions:["object"]}]}},y={nodes:[a],pageInfo:{hasNextPage:"boolean"}},O=t=>s(t,"id")!==""&&s(t,"handle")!==""&&c(t,a),V=t=>m(t)&&(t.id===void 0||c(t,a)),k=o({collection:u({handle:"string",products:y})}),N=o({products:y}),_=o({productRecommendations:u([a])});export{b as a,x as b,F as c,d,a as e,O as f,V as g,k as h,N as i,_ as j};
1
+ import{b as c,c as u,d as o}from"./chunk-OATTAXPO.js";import{d as m,e as s,n as g,r as p}from"./chunk-OJAV2I3C.js";var e="amount currencyCode",P={inventory:!0},f=t=>t.inventory?"quantityAvailable":"",n="url altText width height";function A(t){let i=[];for(let l of t){let r=g(l);r&&i.push(r)}return i.length?`metafields(identifiers:[${i.map(({namespace:l,key:r})=>`{namespace: ${JSON.stringify(l)}, key: ${JSON.stringify(r)}}`).join(", ")}]){namespace key type value reference{... on MediaImage{image{${n}}}}}`:""}var h=` id name description recurringDeliveries options{name value}priceAdjustments{orderCount adjustmentValue{__typename ... on SellingPlanPercentagePriceAdjustment{adjustmentPercentage}... on SellingPlanFixedAmountPriceAdjustment{adjustmentAmount{${e}}}... on SellingPlanFixedPriceAdjustment{price{${e}}}}}`,$=` sellingPlan{id}checkoutChargeAmount{${e}}remainingBalanceChargeAmount{${e}}priceAdjustments{price{${e}}compareAtPrice{${e}}perDeliveryPrice{${e}}unitPrice{${e}}}`;function b(t=p,i=P){return` fragment TetherProduct on Product{id handle title description descriptionHtml productType vendor tags availableForSale publishedAt onlineStoreUrl requiresSellingPlan seo{title description}featuredImage{${n}}images(first:${t.imagesFirst}){nodes{${n}}}options{name optionValues{name swatch{color image{previewImage{${n}}}}}}priceRange{minVariantPrice{${e}}maxVariantPrice{${e}}}compareAtPriceRange{minVariantPrice{${e}}maxVariantPrice{${e}}}${A(t.metafields)} sellingPlanGroups(first:${t.sellingPlanGroupsFirst}){nodes{name appName options{name values}sellingPlans(first:${t.sellingPlansFirst}){nodes{${h}}}}}variants(first:${t.variantsFirst}){nodes{id title availableForSale currentlyNotInStock ${f(i)} sku barcode selectedOptions{name value}image{${n}}price{${e}}compareAtPrice{${e}}unitPrice{${e}}sellingPlanAllocations(first:${t.sellingPlansFirst}){nodes{${$}}}}}}`}function x(t=P){return` fragment TetherCart on Cart{id checkoutUrl totalQuantity note createdAt updatedAt attributes{key value}buyerIdentity{countryCode email}discountCodes{code applicable}cost{subtotalAmount{${e}}totalAmount{${e}}checkoutChargeAmount{${e}}}lines(first:100){nodes{id quantity attributes{key value}cost{totalAmount{${e}}subtotalAmount{${e}}amountPerQuantity{${e}}compareAtAmountPerQuantity{${e}}}discountAllocations{discountedAmount{${e}}}sellingPlanAllocation{sellingPlan{id name description recurringDeliveries options{name value}}checkoutChargeAmount{${e}}priceAdjustments{price{${e}}compareAtPrice{${e}}perDeliveryPrice{${e}}}}merchandise{... on ProductVariant{id title sku availableForSale requiresShipping ${f(t)} image{${n}}price{${e}}compareAtPrice{${e}}selectedOptions{name value}product{id title handle vendor featuredImage{${n}}}}}... on ComponentizableCartLine{lineComponents{id quantity merchandise{... on ProductVariant{id title product{title handle}}}}}}}}`}function F(){return` id handle title description descriptionHtml image{${n}}seo{title description}`}var d={amount:"string",currencyCode:"string"},a={id:"string",handle:"string",title:"string",options:["object"],images:{nodes:["object"]},priceRange:{minVariantPrice:d,maxVariantPrice:d},variants:{nodes:[{id:"string",price:d,selectedOptions:["object"]}]}},y={nodes:[a],pageInfo:{hasNextPage:"boolean"}},O=t=>s(t,"id")!==""&&s(t,"handle")!==""&&c(t,a),V=t=>m(t)&&(t.id===void 0||c(t,a)),k=o({collection:u({handle:"string",products:y})}),N=o({products:y}),_=o({productRecommendations:u([a])});export{b as a,x as b,F as c,d,a as e,O as f,V as g,k as h,N as i,_ as j};
@@ -1 +1 @@
1
- import{a as D,e as O,g as C}from"./chunk-ZBV2JSHE.js";import{a as p,b as T,c as m,h as x}from"./chunk-P73VN3B6.js";import{G as I,d as w,r as v,x as $}from"./chunk-D3MRWOFI.js";var M=1e4,_=6e4,o=new Map,P=new Map,a=new Set,h=new Map,S=[],y=!1,f=0,N=t=>t.startsWith("gid://"),b=I;function E(t){if(!t)return;let e=Promise.resolve(t);o.set(t.handle,e),o.set(t.id,e)}function j(t){let e=b(t);if(!e)return Promise.reject(new p("empty product key",{code:"NOT_FOUND"}));let r=o.get(e);if(r)return r;let c=new Promise((d,s)=>{P.set(e,{resolve:d,reject:s}),S.push(e),y||(y=!0,setTimeout(()=>void A(),0))});return o.set(e,c),c}var q=t=>e=>`${t}${D(v,e)}`;function F(t){let e=t.filter(N),r=t.filter(l=>!N(l)),c=[],d=[],s={};return e.length&&(c.push("$ids: [ID!]!"),s.ids=e,d.push("byId:nodes(ids:$ids){... on Product{...TetherProduct}}")),r.forEach((l,n)=>{c.push(`$h${n}: String!`),s[`h${n}`]=l,d.push(`h${n}:product(handle:$h${n}){...TetherProduct}`)}),{query:q(`query TetherProducts(${c.join(",")}){${d.join(" ")}}`),variables:s,handles:r}}function R(t,e){let r=P.get(t);P.delete(t),r&&e(r)}function Q(t,e){if(e!==f)return;let r=o.get(t);setTimeout(()=>{o.get(t)===r&&o.delete(t)},M)}function W(t){if(!w(t))return!1;let{byId:e=[],...r}=t;return T(e,[m(C)])&&Object.values(r).every(m(O))}async function A(){y=!1;let t=f,e=S.splice(0);if(!e.length)return;let{query:r,variables:c,handles:d}=F(e);$("fetch products",e);let s;try{s=await x(r,c,W)}catch(n){e.forEach(u=>{R(u,i=>{t===f&&o.delete(u),i.reject(n)})});return}let g=new Map;for(let n of s.byId??[])n?.id&&g.set(n.id,n);d.forEach((n,u)=>{let i=s[`h${u}`];i&&g.set(n,i)});let l=Date.now();e.forEach(n=>{R(n,u=>{let i=g.get(n);if(!i){Q(n,t),u.reject(new p(`Product not found: ${n}`,{code:"NOT_FOUND"}));return}t===f&&(E(i),h.set(i.handle,l),h.set(i.id,l)),u.resolve(i)})})}function L(){o.clear(),f+=1,a.clear(),h.clear()}function J(t){for(let e of t??[])!e.id||!e.handle||Date.now()-(h.get(e.handle)??0)<_&&o.has(e.handle)||(E(e),a.add(e.handle),a.add(e.id))}function V(t){let e=b(t);return!e||!a.has(e)?!1:(a.delete(e),o.get(e)?.then(r=>{a.delete(r.handle),a.delete(r.id)},B),!0)}function B(){}function X(t){let e=b(t);return e&&o.delete(e),j(t)}export{b as a,E as b,j as c,q as d,L as e,J as f,V as g,X as h};
1
+ import{a as D,e as O,g as C}from"./chunk-FWMPL6PR.js";import{a as p,b as T,c as m,h as x}from"./chunk-OATTAXPO.js";import{G as I,d as w,r as v,x as $}from"./chunk-OJAV2I3C.js";var M=1e4,_=6e4,o=new Map,P=new Map,a=new Set,h=new Map,S=[],y=!1,f=0,N=t=>t.startsWith("gid://"),b=I;function E(t){if(!t)return;let e=Promise.resolve(t);o.set(t.handle,e),o.set(t.id,e)}function j(t){let e=b(t);if(!e)return Promise.reject(new p("empty product key",{code:"NOT_FOUND"}));let r=o.get(e);if(r)return r;let c=new Promise((d,s)=>{P.set(e,{resolve:d,reject:s}),S.push(e),y||(y=!0,setTimeout(()=>void A(),0))});return o.set(e,c),c}var q=t=>e=>`${t}${D(v,e)}`;function F(t){let e=t.filter(N),r=t.filter(l=>!N(l)),c=[],d=[],s={};return e.length&&(c.push("$ids: [ID!]!"),s.ids=e,d.push("byId:nodes(ids:$ids){... on Product{...TetherProduct}}")),r.forEach((l,n)=>{c.push(`$h${n}: String!`),s[`h${n}`]=l,d.push(`h${n}:product(handle:$h${n}){...TetherProduct}`)}),{query:q(`query TetherProducts(${c.join(",")}){${d.join(" ")}}`),variables:s,handles:r}}function R(t,e){let r=P.get(t);P.delete(t),r&&e(r)}function Q(t,e){if(e!==f)return;let r=o.get(t);setTimeout(()=>{o.get(t)===r&&o.delete(t)},M)}function W(t){if(!w(t))return!1;let{byId:e=[],...r}=t;return T(e,[m(C)])&&Object.values(r).every(m(O))}async function A(){y=!1;let t=f,e=S.splice(0);if(!e.length)return;let{query:r,variables:c,handles:d}=F(e);$("fetch products",e);let s;try{s=await x(r,c,W)}catch(n){e.forEach(u=>{R(u,i=>{t===f&&o.delete(u),i.reject(n)})});return}let g=new Map;for(let n of s.byId??[])n?.id&&g.set(n.id,n);d.forEach((n,u)=>{let i=s[`h${u}`];i&&g.set(n,i)});let l=Date.now();e.forEach(n=>{R(n,u=>{let i=g.get(n);if(!i){Q(n,t),u.reject(new p(`Product not found: ${n}`,{code:"NOT_FOUND"}));return}t===f&&(E(i),h.set(i.handle,l),h.set(i.id,l)),u.resolve(i)})})}function L(){o.clear(),f+=1,a.clear(),h.clear()}function J(t){for(let e of t??[])!e.id||!e.handle||Date.now()-(h.get(e.handle)??0)<_&&o.has(e.handle)||(E(e),a.add(e.handle),a.add(e.id))}function V(t){let e=b(t);return!e||!a.has(e)?!1:(a.delete(e),o.get(e)?.then(r=>{a.delete(r.handle),a.delete(r.id)},B),!0)}function B(){}function X(t){let e=b(t);return e&&o.delete(e),j(t)}export{b as a,E as b,j as c,q as d,L as e,J as f,V as g,X as h};
@@ -1 +1 @@
1
- import{g as e}from"./chunk-P6DV24RG.js";import{r as o}from"./chunk-D3MRWOFI.js";var c=()=>`${o.prefix}:account-hint:${o.domain}`;function i(r){e(r,"sessionStorage"),e(r,"localStorage")}function m(){i(`${o.prefix}:account:${o.domain}`),i(`${o.prefix}:account-login:${o.domain}`)}var s=r=>r==="in"||r==="expired"||r==="error";export{c as a,m as b,s as c};
1
+ import{g as e}from"./chunk-7ZXEVDOS.js";import{r as o}from"./chunk-OJAV2I3C.js";var c=()=>`${o.prefix}:account-hint:${o.domain}`;function i(r){e(r,"sessionStorage"),e(r,"localStorage")}function m(){i(`${o.prefix}:account:${o.domain}`),i(`${o.prefix}:account-login:${o.domain}`)}var s=r=>r==="in"||r==="expired"||r==="error";export{c as a,m as b,s as c};