@occluze/tether 0.6.4 → 0.6.6

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.
@@ -8,16 +8,24 @@
8
8
  // src/account.js
9
9
  var account_exports = {};
10
10
  __export(account_exports, {
11
+ addresses: () => addresses,
11
12
  customer: () => customer,
13
+ deleteAddress: () => deleteAddress,
12
14
  getToken: () => getToken,
13
15
  handleCallback: () => handleCallback,
14
16
  isLoggedIn: () => isLoggedIn,
15
17
  login: () => login,
16
18
  logout: () => logout,
17
19
  mountAccount: () => mountAccount,
20
+ order: () => order,
18
21
  orders: () => orders,
19
22
  query: () => query,
20
- render: () => render
23
+ render: () => render,
24
+ requestReturn: () => requestReturn,
25
+ saveAddress: () => saveAddress,
26
+ subscriptionAction: () => subscriptionAction,
27
+ subscriptions: () => subscriptions,
28
+ updateProfile: () => updateProfile
21
29
  });
22
30
 
23
31
  // tether-core:config.js
@@ -36,6 +44,10 @@
36
44
  var m4 = window.Tether.__core["cart.js"];
37
45
  var { Cart, focusables, toLineInput } = m4;
38
46
 
47
+ // tether-core:lazy.js
48
+ var m5 = window.Tether.__core["lazy.js"];
49
+ var { coreModules, loadPart } = m5;
50
+
39
51
  // src/account.js
40
52
  var KEY = () => `${cfg.prefix}:account:${cfg.domain}`;
41
53
  var PENDING = () => `${cfg.prefix}:account-login:${cfg.domain}`;
@@ -73,7 +85,7 @@
73
85
  body: body ? JSON.stringify(body) : void 0
74
86
  });
75
87
  const data = await res.json().catch(() => ({}));
76
- if (!res.ok && res.status !== 401) throw new TetherError(`Customer accounts: ${data.error || res.status}`, { status: res.status });
88
+ if (!res.ok && res.status !== 401) throw new TetherError(`Customer accounts: ${data.error || res.status}`, { status: res.status, userErrors: data.userErrors });
77
89
  return data;
78
90
  }
79
91
  async function serverMe() {
@@ -304,6 +316,11 @@
304
316
  if (k === "logged-in") show(el, logged);
305
317
  if (k === "logged-out") show(el, !logged);
306
318
  });
319
+ qsa(root, sel("account-link")).forEach((a) => {
320
+ const k = get(a, "account-link");
321
+ const u = k === "payment" && (cfg.account?.paymentUrl || cfg.account?.subscriptionsUrl) || k === "subscriptions" && cfg.account?.subscriptionsUrl;
322
+ a.setAttribute("href", u || `https://${cfg.domain}/account`);
323
+ });
307
324
  if (!logged) return;
308
325
  const binds = qsa(root, sel("account-bind"));
309
326
  if (binds.length) {
@@ -336,7 +353,8 @@
336
353
  qsa(node, sel("order-bind")).forEach((el) => {
337
354
  const k = get(el, "order-bind");
338
355
  if (k === "url") {
339
- if (https(o.statusPageUrl)) el.setAttribute("href", o.statusPageUrl);
356
+ const u = orderUrl(o);
357
+ if (u) el.setAttribute("href", u);
340
358
  return;
341
359
  }
342
360
  if (k === "image") {
@@ -347,21 +365,52 @@
347
365
  const v = { name: o.name, date: date(o.processedAt), total: formatMoney(o.totalPrice), status: o.financialStatus?.toLowerCase(), fulfillment: o.fulfillmentStatus?.toLowerCase(), items: items.map((l) => `${l.quantity}\xD7 ${l.title}`).join(", ") }[k];
348
366
  if (v != null) setText(el, v);
349
367
  });
350
- qsa(node, sel("order-lines")).forEach((box) => repeat(box, items, (row, l) => {
351
- qsa(row, sel("order-line")).concat(row.matches(sel("order-line")) ? [row] : []).forEach((el) => {
352
- const k = get(el, "order-line");
353
- if (k === "image") {
354
- if (l.image) setImage(el, l.image.url, l.image.altText || l.title);
355
- return;
356
- }
357
- const v = { title: l.title, "variant-title": l.variantTitle || "", quantity: String(l.quantity) }[k];
358
- if (v != null) setText(el, v);
359
- });
360
- }));
361
- if (get(node, "order-bind") === "url" && https(o.statusPageUrl)) node.setAttribute("href", o.statusPageUrl);
368
+ qsa(node, sel("order-lines")).forEach((box) => fillLines(box, items));
369
+ if (get(node, "order-bind") === "url" && orderUrl(o)) node.setAttribute("href", orderUrl(o));
362
370
  }));
363
371
  }
372
+ if (PAGE_ATTRS.some((n) => qsa(root, sel(n)).length)) await (await pages()).renderPages(root);
373
+ }
374
+ var nid = (g) => String(g || "").split("/").pop().split("?")[0];
375
+ function orderUrl(o) {
376
+ const t = cfg.account?.orderUrl;
377
+ if (t) return String(t).replace("{id}", encodeURIComponent(nid(o.id)));
378
+ return https(o.statusPageUrl) ? o.statusPageUrl : null;
379
+ }
380
+ function fillLines(box, items) {
381
+ repeat(box, items, (row, l) => {
382
+ qsa(row, sel("order-line")).concat(row.matches(sel("order-line")) ? [row] : []).forEach((el) => {
383
+ const k = get(el, "order-line");
384
+ if (k === "image") {
385
+ if (l.image) setImage(el, l.image.url, l.image.altText || l.title);
386
+ return;
387
+ }
388
+ const v = { title: l.title, "variant-title": l.variantTitle || "", quantity: String(l.quantity) }[k];
389
+ if (v != null) setText(el, v);
390
+ });
391
+ });
392
+ }
393
+ var PAGE_ATTRS = ["order", "addresses", "subscriptions", "profile-form", "address-form"];
394
+ var pagesPart = null;
395
+ function pages() {
396
+ pagesPart || (pagesPart = loadPart("account-pages").then((m6) => {
397
+ m6.setup({ server, serverFetch, query, customer, reset: () => {
398
+ customerCache = null;
399
+ serverState = null;
400
+ } });
401
+ return m6;
402
+ }));
403
+ return pagesPart;
364
404
  }
405
+ var viaPages = (name) => (...a) => pages().then((m6) => m6[name](...a));
406
+ var order = viaPages("order");
407
+ var updateProfile = viaPages("updateProfile");
408
+ var addresses = viaPages("addresses");
409
+ var saveAddress = viaPages("saveAddress");
410
+ var deleteAddress = viaPages("deleteAddress");
411
+ var subscriptions = viaPages("subscriptions");
412
+ var subscriptionAction = viaPages("subscriptionAction");
413
+ var requestReturn = viaPages("requestReturn");
365
414
  var bound = false;
366
415
  async function mountAccount(root = document) {
367
416
  if (!bound) {
@@ -1 +1 @@
1
- (()=>{var dt=Object.defineProperty;var ft=(t,e)=>{for(var o in e)dt(t,o,{get:e[o],enumerable:!0})};var X={};ft(X,{customer:()=>it,getToken:()=>$,handleCallback:()=>st,isLoggedIn:()=>V,login:()=>nt,logout:()=>ut,mountAccount:()=>Tt,orders:()=>lt,query:()=>W,render:()=>D});var wt=window.Tether.__core["config.js"],{DEFAULTS:It,cfg:a,configure:At,isConfigured:xt,log:Q,reportError:I,warn:Ut}=wt;var mt=window.Tether.__core["client.js"],{TetherError:_,endpoint:Ct,gql:$t,request:bt,unwrap:Nt,withContext:Pt}=mt;var ht=window.Tether.__core["dom.js"],{attr:Dt,busy:Ot,cdnUrl:Lt,dataKey:qt,emit:A,formatDate:jt,formatMoney:Z,formatPercent:Rt,get:S,has:Jt,hasTemplate:Bt,imageUrl:Gt,notifyLayoutChanged:Kt,parseJSONAttr:Ft,productUrl:Mt,qsa:T,readText:zt,repeat:R,repeatKeyed:Ht,sameImage:Vt,scoped:Wt,sel:h,setImage:J,setSelected:Xt,setText:P,setTextTracked:Yt,show:x,toAttributes:Qt,watchImages:Zt}=ht;var gt=window.Tether.__core["cart.js"],{Cart:f,focusables:ee,toLineInput:oe}=gt;var O=()=>`${a.prefix}:account:${a.domain}`,K=()=>`${a.prefix}:account-login:${a.domain}`,L=()=>a.account?.remember?window.localStorage:window.sessionStorage,ot=t=>btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),B=()=>ot(crypto.getRandomValues(new Uint8Array(32))),pt=async t=>ot(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(t))),C=t=>(a.account?.navigate||(e=>window.location.assign(e)))(t),z=(t,e)=>{try{return JSON.parse(t.getItem(e)||"null")}catch{return null}},q=(t,e,o)=>{try{o?t.setItem(e,JSON.stringify(o)):t.removeItem(e)}catch{}},v=null,c=null,G=null,U=null,g=()=>a.account?.server?new URL(String(a.account.server),window.location.href).href.replace(/\/$/,""):"",F=()=>`${a.prefix}:account-hint:${a.domain}`,E=null;async function j(t,{method:e="GET",body:o}={}){let n=await fetch(`${g()}${t}`,{method:e,credentials:"include",headers:e==="POST"?{"Content-Type":"application/json","X-Tether-Account":"1"}:{},body:o?JSON.stringify(o):void 0}),s=await n.json().catch(()=>({}));if(!n.ok&&n.status!==401)throw new _(`Customer accounts: ${s.error||n.status}`,{status:n.status});return s}async function H(){E||(E=await j("/me"));try{E.loggedIn?window.localStorage.setItem(F(),"1"):window.localStorage.removeItem(F())}catch{}return E}async function b(){if(v)return v;let t=a.account?.shopDomain||a.domain,e=s=>fetch(`https://${t}/.well-known/${s}`).then(r=>{if(!r.ok)throw new _(`Customer accounts: ${s} answered ${r.status}`,{status:r.status});return r.json()}),[o,n]=await Promise.all([e("openid-configuration"),e("customer-account-api")]);return v={...o,graphql:n.graphql_api},v}var yt=()=>a.account?.callbackUrl||`${window.location.origin}${window.location.pathname}`;function V(){return g()?!!E?.loggedIn:!!(c?.refresh||c?.access&&c.expiresAt>Date.now())}async function nt({returnTo:t=window.location.href,locale:e}={}){if(g()){let d=new URL(`${g()}/login`);d.searchParams.set("returnTo",t);let m=e||a.account.locale||(a.locale||"").split("-")[0];m&&d.searchParams.set("locale",m),a.country&&d.searchParams.set("country",String(a.country).toUpperCase()),C(d.toString());return}if(!a.account?.clientId)throw new _("Customer accounts: set account.clientId",{code:"NOT_CONFIGURED"});let o=await b(),n=B(),s=B(),r=B(),u=yt();q(window.sessionStorage,K(),{state:n,nonce:s,verifier:r,redirect:u,returnTo:t,at:Date.now()});let i=new URL(o.authorization_endpoint),w={client_id:a.account.clientId,scope:"openid email customer-account-api:full",response_type:"code",redirect_uri:u,state:n,nonce:s,code_challenge:await pt(r),code_challenge_method:"S256"},l=e||a.account.locale||(a.locale||"").split("-")[0];l&&(w.locale=l),a.country&&(w.region_country=String(a.country).toUpperCase()),Object.entries(w).forEach(([d,m])=>i.searchParams.set(d,m)),C(i.toString())}async function rt(t){let e=await b(),o=await fetch(a.account.tokenUrl||e.token_endpoint,{method:"POST",body:new URLSearchParams(t)}),n=await o.json().catch(()=>({}));if(!o.ok||!n.access_token)throw new _(`Customer accounts: token ${o.status} ${n.error||""}`.trim(),{status:o.status,code:o.status===400||o.status===401?"SESSION_ENDED":"TOKEN_FAILED"});return n}function _t(t){try{return JSON.parse(atob(t.split(".")[1].replace(/-/g,"+").replace(/_/g,"/")))}catch{return null}}function at(t,e=c){c={access:t.access_token,expiresAt:Date.now()+Math.max(0,(Number(t.expires_in)||3600)-120)*1e3,refresh:t.refresh_token||e?.refresh,idToken:t.id_token||e?.idToken},q(L(),O(),c)}async function st(){let t=new URLSearchParams(window.location.search),e=z(window.sessionStorage,K());if(!e||!t.has("code")&&!t.has("error")||t.get("state")!==e.state)return!1;q(window.sessionStorage,K(),null);let o=new URL(window.location.href);if(["code","state","iss","error","error_description"].forEach(w=>o.searchParams.delete(w)),window.history.replaceState(window.history.state,"",o),t.has("error"))return A("account-error",{error:t.get("error")}),!1;if(Date.now()-e.at>10*6e4)throw new _("Customer accounts: the login took too long, please try again");let n=await rt({grant_type:"authorization_code",client_id:a.account.clientId,redirect_uri:e.redirect,code:t.get("code"),code_verifier:e.verifier}),s=await b(),r=_t(n.id_token||""),u=[].concat(r?.aud||[]);if(!r||r.nonce!==e.nonce||r.iss!==s.issuer||!u.includes(a.account.clientId)||r.exp*1e3<Date.now())throw new _("Customer accounts: the login answer did not check out (nonce/issuer/audience)");at(n,null),await ct(),A("account-login",{});let i=e.returnTo&&new URL(e.returnTo,window.location.href);return i&&i.origin===window.location.origin&&i.href!==o.href&&C(i.href),!0}async function $(){return g()||(c||(c=z(L(),O())),!c)?null:c.access&&c.expiresAt>Date.now()?c.access:c.refresh?(G||(G=(async()=>{try{at(await rt({grant_type:"refresh_token",client_id:a.account.clientId,refresh_token:c.refresh})),await ct()}catch(t){if(t.code==="SESSION_ENDED")M();else throw t}finally{G=null}})()),await G,c?.access||null):(M(),null)}function M(){c=null,U=null,q(L(),O(),null),f.customerAccessToken=null}async function ct(){f.customerAccessToken=c?.access||null,f.id()&&c?.access&&await f.setBuyerIdentity({customerAccessToken:c.access},{create:!1}).catch(t=>I(t,"account cart"))}async function W(t,e={}){if(g())throw new _("Customer accounts in server mode only answer customer() and orders()",{code:"NOT_ALLOWED"});let o=await $();if(!o)throw new _("Not logged in",{code:"NOT_LOGGED_IN"});let n=await b(),s=i=>fetch(n.graphql,{method:"POST",headers:{"Content-Type":"application/json",Authorization:i},body:JSON.stringify({query:t,variables:e})}),r=await s(o);r.status===401&&c?.refresh&&(c.expiresAt=0,r=await s(await $()));let u=await r.json().catch(()=>({}));if(!r.ok||u.errors?.length)throw new _(u.errors?.map(i=>i.message).join(" | ")||`Customer accounts: ${r.status}`,{status:r.status});return u.data}async function it(){if(g()){let e=await H();return e.loggedIn?{...e.customer,emailAddress:{emailAddress:e.customer.email},defaultAddress:{formatted:e.customer.address}}:null}return U||(U=(await W("query TetherCustomer{customer{id firstName lastName displayName emailAddress{emailAddress}defaultAddress{formatted}}}")).customer,U)}async function lt({first:t=10}={}){return g()?(await j(`/orders?first=${t}`)).orders||[]:(await W("query TetherOrders($first:Int!){customer{orders(first:$first,sortKey:PROCESSED_AT,reverse:true){nodes{id name processedAt financialStatus fulfillmentStatus statusPageUrl totalPrice{amount currencyCode}lineItems(first:20){nodes{title variantTitle quantity image{url altText}}}}}}}",{first:t})).customer?.orders?.nodes||[]}async function ut({returnTo:t=a.account?.logoutUrl||`${window.location.origin}/`}={}){if(g()){let s=await j("/logout",{method:"POST",body:{returnTo:t,cartId:f.id()}});E={loggedIn:!1};try{window.localStorage.removeItem(F())}catch{}A("account-logout",{}),s.logoutUrl?C(s.logoutUrl):D(document);return}let e=c?.idToken||z(L(),O())?.idToken;if(f.id()&&await f.setBuyerIdentity({customerAccessToken:null},{create:!1}).catch(()=>{}),M(),A("account-logout",{}),!e){D(document);return}let o=await b(),n=new URL(o.end_session_endpoint);n.searchParams.set("id_token_hint",e),n.searchParams.set("post_logout_redirect_uri",t),C(n.toString())}var tt=t=>{try{return new URL(t).protocol==="https:"}catch{return!1}},St=t=>{try{return new Date(t).toLocaleDateString(a.locale||void 0)}catch{return t}};async function D(t=document){let e=g()?!!(await H().catch(()=>({loggedIn:!1}))).loggedIn:V()||!!await $().catch(()=>null);if(T(t,h("show")).forEach(s=>{let r=S(s,"show");r==="logged-in"&&x(s,e),r==="logged-out"&&x(s,!e)}),!e)return;let o=T(t,h("account-bind"));if(o.length){let s=await it().catch(r=>(I(r,"account"),null));o.forEach(r=>{let u={"first-name":s?.firstName,"last-name":s?.lastName,name:s?.displayName,email:s?.emailAddress?.emailAddress,address:s?.defaultAddress?.formatted?.join(", ")}[S(r,"account-bind")];u!=null&&P(r,u)})}let n=T(t,h("orders"));if(n.length){let s=(i,w)=>T(t,h("show")).forEach(l=>{let d=S(l,"show");d==="orders-loading"&&x(l,i),d==="orders-empty"&&x(l,w)});s(!0,!1);let r=!1,u=await lt({first:parseInt(S(n[0],"limit")||"10",10)}).catch(i=>(I(i,"orders"),r=!0,[]));s(!1,!r&&u.length===0),n.forEach(i=>R(i,u,(w,l)=>{let d=l.lineItems?.nodes||[];T(w,h("order-bind")).forEach(m=>{let k=S(m,"order-bind");if(k==="url"){tt(l.statusPageUrl)&&m.setAttribute("href",l.statusPageUrl);return}if(k==="image"){let y=d.find(N=>N.image)?.image;y&&J(m,y.url,y.altText||d[0]?.title||"");return}let p={name:l.name,date:St(l.processedAt),total:Z(l.totalPrice),status:l.financialStatus?.toLowerCase(),fulfillment:l.fulfillmentStatus?.toLowerCase(),items:d.map(y=>`${y.quantity}\xD7 ${y.title}`).join(", ")}[k];p!=null&&P(m,p)}),T(w,h("order-lines")).forEach(m=>R(m,d,(k,p)=>{T(k,h("order-line")).concat(k.matches(h("order-line"))?[k]:[]).forEach(y=>{let N=S(y,"order-line");if(N==="image"){p.image&&J(y,p.image.url,p.image.altText||p.title);return}let Y={title:p.title,"variant-title":p.variantTitle||"",quantity:String(p.quantity)}[N];Y!=null&&P(y,Y)})})),S(w,"order-bind")==="url"&&tt(l.statusPageUrl)&&w.setAttribute("href",l.statusPageUrl)}))}}var et=!1;async function Tt(t=document){if(!et){if(et=!0,document.addEventListener("click",e=>{let o=e.target;o.closest?.(h("account-login"))?(e.preventDefault(),nt().catch(n=>I(n,"login"))):o.closest?.(h("account-logout"))&&(e.preventDefault(),ut().catch(n=>I(n,"logout")))}),g()){let e=new URL(window.location.href);e.searchParams.get("account")&&(e.searchParams.delete("account"),window.history.replaceState(window.history.state,"",e),A("account-login",{})),f.beforeCheckout=async()=>{if(!(await H()).loggedIn||!f.id())return null;let o=await j("/cart",{method:"POST",body:{cartId:f.id()}}).catch(()=>null);return o?.checkoutUrl?`${o.checkoutUrl}${o.checkoutUrl.includes("?")?"&":"?"}logged_in=true`:null}}else{try{await st()}catch(e){I(e,"login")}!f.customerAccessToken&&await $().catch(()=>null)&&(f.customerAccessToken=c.access)}Q("account",V()?"logged in":"logged out")}await D(t)}window.Tether.__parts.account=X;})();
1
+ (()=>{var wt=Object.defineProperty;var ht=(t,e)=>{for(var o in e)wt(t,o,{get:e[o],enumerable:!0})};var Y={};ht(Y,{addresses:()=>$t,customer:()=>X,deleteAddress:()=>Nt,getToken:()=>E,handleCallback:()=>it,isLoggedIn:()=>W,login:()=>st,logout:()=>dt,mountAccount:()=>qt,order:()=>Pt,orders:()=>lt,query:()=>q,render:()=>N,requestReturn:()=>Ot,saveAddress:()=>vt,subscriptionAction:()=>Lt,subscriptions:()=>Dt,updateProfile:()=>Ct});var gt=window.Tether.__core["config.js"],{DEFAULTS:jt,cfg:a,configure:Jt,isConfigured:Bt,log:Z,reportError:k,warn:Gt}=gt;var pt=window.Tether.__core["client.js"],{TetherError:p,endpoint:Mt,gql:zt,request:Ft,unwrap:Ht,withContext:Vt}=pt;var yt=window.Tether.__core["dom.js"],{attr:Xt,busy:Yt,cdnUrl:Qt,dataKey:Zt,emit:A,formatDate:te,formatMoney:tt,formatPercent:ee,get:S,has:oe,hasTemplate:ne,imageUrl:re,notifyLayoutChanged:se,parseJSONAttr:ae,productUrl:ce,qsa:y,readText:ie,repeat:j,repeatKeyed:ue,sameImage:le,scoped:de,sel:f,setImage:J,setSelected:fe,setText:$,setTextTracked:me,show:b,toAttributes:we,watchImages:he}=yt;var _t=window.Tether.__core["cart.js"],{Cart:m,focusables:pe,toLineInput:ye}=_t;var St=window.Tether.__core["lazy.js"],{coreModules:Se,loadPart:et}=St;var D=()=>`${a.prefix}:account:${a.domain}`,M=()=>`${a.prefix}:account-login:${a.domain}`,L=()=>a.account?.remember?window.localStorage:window.sessionStorage,rt=t=>btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),B=()=>rt(crypto.getRandomValues(new Uint8Array(32))),Tt=async t=>rt(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(t))),U=t=>(a.account?.navigate||(e=>window.location.assign(e)))(t),H=(t,e)=>{try{return JSON.parse(t.getItem(e)||"null")}catch{return null}},O=(t,e,o)=>{try{o?t.setItem(e,JSON.stringify(o)):t.removeItem(e)}catch{}},v=null,c=null,G=null,x=null,h=()=>a.account?.server?new URL(String(a.account.server),window.location.href).href.replace(/\/$/,""):"",z=()=>`${a.prefix}:account-hint:${a.domain}`,I=null;async function P(t,{method:e="GET",body:o}={}){let n=await fetch(`${h()}${t}`,{method:e,credentials:"include",headers:e==="POST"?{"Content-Type":"application/json","X-Tether-Account":"1"}:{},body:o?JSON.stringify(o):void 0}),r=await n.json().catch(()=>({}));if(!n.ok&&n.status!==401)throw new p(`Customer accounts: ${r.error||n.status}`,{status:n.status,userErrors:r.userErrors});return r}async function V(){I||(I=await P("/me"));try{I.loggedIn?window.localStorage.setItem(z(),"1"):window.localStorage.removeItem(z())}catch{}return I}async function C(){if(v)return v;let t=a.account?.shopDomain||a.domain,e=r=>fetch(`https://${t}/.well-known/${r}`).then(s=>{if(!s.ok)throw new p(`Customer accounts: ${r} answered ${s.status}`,{status:s.status});return s.json()}),[o,n]=await Promise.all([e("openid-configuration"),e("customer-account-api")]);return v={...o,graphql:n.graphql_api},v}var kt=()=>a.account?.callbackUrl||`${window.location.origin}${window.location.pathname}`;function W(){return h()?!!I?.loggedIn:!!(c?.refresh||c?.access&&c.expiresAt>Date.now())}async function st({returnTo:t=window.location.href,locale:e}={}){if(h()){let d=new URL(`${h()}/login`);d.searchParams.set("returnTo",t);let g=e||a.account.locale||(a.locale||"").split("-")[0];g&&d.searchParams.set("locale",g),a.country&&d.searchParams.set("country",String(a.country).toUpperCase()),U(d.toString());return}if(!a.account?.clientId)throw new p("Customer accounts: set account.clientId",{code:"NOT_CONFIGURED"});let o=await C(),n=B(),r=B(),s=B(),i=kt();O(window.sessionStorage,M(),{state:n,nonce:r,verifier:s,redirect:i,returnTo:t,at:Date.now()});let u=new URL(o.authorization_endpoint),w={client_id:a.account.clientId,scope:"openid email customer-account-api:full",response_type:"code",redirect_uri:i,state:n,nonce:r,code_challenge:await Tt(s),code_challenge_method:"S256"},l=e||a.account.locale||(a.locale||"").split("-")[0];l&&(w.locale=l),a.country&&(w.region_country=String(a.country).toUpperCase()),Object.entries(w).forEach(([d,g])=>u.searchParams.set(d,g)),U(u.toString())}async function at(t){let e=await C(),o=await fetch(a.account.tokenUrl||e.token_endpoint,{method:"POST",body:new URLSearchParams(t)}),n=await o.json().catch(()=>({}));if(!o.ok||!n.access_token)throw new p(`Customer accounts: token ${o.status} ${n.error||""}`.trim(),{status:o.status,code:o.status===400||o.status===401?"SESSION_ENDED":"TOKEN_FAILED"});return n}function At(t){try{return JSON.parse(atob(t.split(".")[1].replace(/-/g,"+").replace(/_/g,"/")))}catch{return null}}function ct(t,e=c){c={access:t.access_token,expiresAt:Date.now()+Math.max(0,(Number(t.expires_in)||3600)-120)*1e3,refresh:t.refresh_token||e?.refresh,idToken:t.id_token||e?.idToken},O(L(),D(),c)}async function it(){let t=new URLSearchParams(window.location.search),e=H(window.sessionStorage,M());if(!e||!t.has("code")&&!t.has("error")||t.get("state")!==e.state)return!1;O(window.sessionStorage,M(),null);let o=new URL(window.location.href);if(["code","state","iss","error","error_description"].forEach(w=>o.searchParams.delete(w)),window.history.replaceState(window.history.state,"",o),t.has("error"))return A("account-error",{error:t.get("error")}),!1;if(Date.now()-e.at>10*6e4)throw new p("Customer accounts: the login took too long, please try again");let n=await at({grant_type:"authorization_code",client_id:a.account.clientId,redirect_uri:e.redirect,code:t.get("code"),code_verifier:e.verifier}),r=await C(),s=At(n.id_token||""),i=[].concat(s?.aud||[]);if(!s||s.nonce!==e.nonce||s.iss!==r.issuer||!i.includes(a.account.clientId)||s.exp*1e3<Date.now())throw new p("Customer accounts: the login answer did not check out (nonce/issuer/audience)");ct(n,null),await ut(),A("account-login",{});let u=e.returnTo&&new URL(e.returnTo,window.location.href);return u&&u.origin===window.location.origin&&u.href!==o.href&&U(u.href),!0}async function E(){return h()||(c||(c=H(L(),D())),!c)?null:c.access&&c.expiresAt>Date.now()?c.access:c.refresh?(G||(G=(async()=>{try{ct(await at({grant_type:"refresh_token",client_id:a.account.clientId,refresh_token:c.refresh})),await ut()}catch(t){if(t.code==="SESSION_ENDED")F();else throw t}finally{G=null}})()),await G,c?.access||null):(F(),null)}function F(){c=null,x=null,O(L(),D(),null),m.customerAccessToken=null}async function ut(){m.customerAccessToken=c?.access||null,m.id()&&c?.access&&await m.setBuyerIdentity({customerAccessToken:c.access},{create:!1}).catch(t=>k(t,"account cart"))}async function q(t,e={}){if(h())throw new p("Customer accounts in server mode only answer customer() and orders()",{code:"NOT_ALLOWED"});let o=await E();if(!o)throw new p("Not logged in",{code:"NOT_LOGGED_IN"});let n=await C(),r=u=>fetch(n.graphql,{method:"POST",headers:{"Content-Type":"application/json",Authorization:u},body:JSON.stringify({query:t,variables:e})}),s=await r(o);s.status===401&&c?.refresh&&(c.expiresAt=0,s=await r(await E()));let i=await s.json().catch(()=>({}));if(!s.ok||i.errors?.length)throw new p(i.errors?.map(u=>u.message).join(" | ")||`Customer accounts: ${s.status}`,{status:s.status});return i.data}async function X(){if(h()){let e=await V();return e.loggedIn?{...e.customer,emailAddress:{emailAddress:e.customer.email},defaultAddress:{formatted:e.customer.address}}:null}return x||(x=(await q("query TetherCustomer{customer{id firstName lastName displayName emailAddress{emailAddress}defaultAddress{formatted}}}")).customer,x)}async function lt({first:t=10}={}){return h()?(await P(`/orders?first=${t}`)).orders||[]:(await q("query TetherOrders($first:Int!){customer{orders(first:$first,sortKey:PROCESSED_AT,reverse:true){nodes{id name processedAt financialStatus fulfillmentStatus statusPageUrl totalPrice{amount currencyCode}lineItems(first:20){nodes{title variantTitle quantity image{url altText}}}}}}}",{first:t})).customer?.orders?.nodes||[]}async function dt({returnTo:t=a.account?.logoutUrl||`${window.location.origin}/`}={}){if(h()){let r=await P("/logout",{method:"POST",body:{returnTo:t,cartId:m.id()}});I={loggedIn:!1};try{window.localStorage.removeItem(z())}catch{}A("account-logout",{}),r.logoutUrl?U(r.logoutUrl):N(document);return}let e=c?.idToken||H(L(),D())?.idToken;if(m.id()&&await m.setBuyerIdentity({customerAccessToken:null},{create:!1}).catch(()=>{}),F(),A("account-logout",{}),!e){N(document);return}let o=await C(),n=new URL(o.end_session_endpoint);n.searchParams.set("id_token_hint",e),n.searchParams.set("post_logout_redirect_uri",t),U(n.toString())}var xt=t=>{try{return new URL(t).protocol==="https:"}catch{return!1}},It=t=>{try{return new Date(t).toLocaleDateString(a.locale||void 0)}catch{return t}};async function N(t=document){let e=h()?!!(await V().catch(()=>({loggedIn:!1}))).loggedIn:W()||!!await E().catch(()=>null);if(y(t,f("show")).forEach(r=>{let s=S(r,"show");s==="logged-in"&&b(r,e),s==="logged-out"&&b(r,!e)}),y(t,f("account-link")).forEach(r=>{let s=S(r,"account-link"),i=s==="payment"&&(a.account?.paymentUrl||a.account?.subscriptionsUrl)||s==="subscriptions"&&a.account?.subscriptionsUrl;r.setAttribute("href",i||`https://${a.domain}/account`)}),!e)return;let o=y(t,f("account-bind"));if(o.length){let r=await X().catch(s=>(k(s,"account"),null));o.forEach(s=>{let i={"first-name":r?.firstName,"last-name":r?.lastName,name:r?.displayName,email:r?.emailAddress?.emailAddress,address:r?.defaultAddress?.formatted?.join(", ")}[S(s,"account-bind")];i!=null&&$(s,i)})}let n=y(t,f("orders"));if(n.length){let r=(u,w)=>y(t,f("show")).forEach(l=>{let d=S(l,"show");d==="orders-loading"&&b(l,u),d==="orders-empty"&&b(l,w)});r(!0,!1);let s=!1,i=await lt({first:parseInt(S(n[0],"limit")||"10",10)}).catch(u=>(k(u,"orders"),s=!0,[]));r(!1,!s&&i.length===0),n.forEach(u=>j(u,i,(w,l)=>{let d=l.lineItems?.nodes||[];y(w,f("order-bind")).forEach(g=>{let R=S(g,"order-bind");if(R==="url"){let _=K(l);_&&g.setAttribute("href",_);return}if(R==="image"){let _=d.find(mt=>mt.image)?.image;_&&J(g,_.url,_.altText||d[0]?.title||"");return}let Q={name:l.name,date:It(l.processedAt),total:tt(l.totalPrice),status:l.financialStatus?.toLowerCase(),fulfillment:l.fulfillmentStatus?.toLowerCase(),items:d.map(_=>`${_.quantity}\xD7 ${_.title}`).join(", ")}[R];Q!=null&&$(g,Q)}),y(w,f("order-lines")).forEach(g=>Ut(g,d)),S(w,"order-bind")==="url"&&K(l)&&w.setAttribute("href",K(l))}))}Et.some(r=>y(t,f(r)).length)&&await(await ft()).renderPages(t)}var bt=t=>String(t||"").split("/").pop().split("?")[0];function K(t){let e=a.account?.orderUrl;return e?String(e).replace("{id}",encodeURIComponent(bt(t.id))):xt(t.statusPageUrl)?t.statusPageUrl:null}function Ut(t,e){j(t,e,(o,n)=>{y(o,f("order-line")).concat(o.matches(f("order-line"))?[o]:[]).forEach(r=>{let s=S(r,"order-line");if(s==="image"){n.image&&J(r,n.image.url,n.image.altText||n.title);return}let i={title:n.title,"variant-title":n.variantTitle||"",quantity:String(n.quantity)}[s];i!=null&&$(r,i)})})}var Et=["order","addresses","subscriptions","profile-form","address-form"],ot=null;function ft(){return ot||(ot=et("account-pages").then(t=>(t.setup({server:h,serverFetch:P,query:q,customer:X,reset:()=>{x=null,I=null}}),t))),ot}var T=t=>(...e)=>ft().then(o=>o[t](...e)),Pt=T("order"),Ct=T("updateProfile"),$t=T("addresses"),vt=T("saveAddress"),Nt=T("deleteAddress"),Dt=T("subscriptions"),Lt=T("subscriptionAction"),Ot=T("requestReturn"),nt=!1;async function qt(t=document){if(!nt){if(nt=!0,document.addEventListener("click",e=>{let o=e.target;o.closest?.(f("account-login"))?(e.preventDefault(),st().catch(n=>k(n,"login"))):o.closest?.(f("account-logout"))&&(e.preventDefault(),dt().catch(n=>k(n,"logout")))}),h()){let e=new URL(window.location.href);e.searchParams.get("account")&&(e.searchParams.delete("account"),window.history.replaceState(window.history.state,"",e),A("account-login",{})),m.beforeCheckout=async()=>{if(!(await V()).loggedIn||!m.id())return null;let o=await P("/cart",{method:"POST",body:{cartId:m.id()}}).catch(()=>null);return o?.checkoutUrl?`${o.checkoutUrl}${o.checkoutUrl.includes("?")?"&":"?"}logged_in=true`:null}}else{try{await it()}catch(e){k(e,"login")}!m.customerAccessToken&&await E().catch(()=>null)&&(m.customerAccessToken=c.access)}Z("account",W()?"logged in":"logged out")}await N(t)}window.Tether.__parts.account=Y;})();
@@ -186,7 +186,11 @@
186
186
  "logged-in",
187
187
  "logged-out",
188
188
  "orders-empty",
189
- "orders-loading"
189
+ "orders-loading",
190
+ "addresses-loading",
191
+ "addresses-empty",
192
+ "subscriptions-loading",
193
+ "subscriptions-empty"
190
194
  ]);
191
195
  var BIND = /* @__PURE__ */ new Set([
192
196
  "title",
@@ -234,7 +238,10 @@
234
238
  country-bind country-label country-select default-plan default-purchase discount discount-code discount-form discount-input
235
239
  discount-remove display error group group-add hide-single language limit line line-attribute line-attributes line-id
236
240
  line-minus line-plan line-plus line-remove line-show list load-more market-pending one-time-label option option-list
237
- option-selected option-value order-bind order-line order-lines orders page-country page-language page-locale page-title plan plan-bind plan-list
241
+ option-selected option-value order order-bind order-line order-lines order-line-show order-show order-state order-fulfillments
242
+ fulfillment-bind order-return return-quantity return-reason return-note orders profile-form address-form addresses address-bind
243
+ address-show address-edit address-new address-delete address-default subscriptions subscription-bind subscription-lines
244
+ subscription-line subscription-show subscription-action subscription-status subscription-state confirm form-state form-error page-country page-language page-locale page-title plan plan-bind plan-list
238
245
  plan-value product products purchase purchase-mode qty qty-minus qty-plus quantity recommendations reverse search
239
246
  search-bind search-collections search-input search-limit search-min search-products search-queries search-results
240
247
  search-state show soldout-text sort state subscribe-text variant variant-select variant-url max-width max-height crop
@@ -1,11 +1,14 @@
1
- (()=>{var j=Object.defineProperty;var R=(e,t)=>{for(var o in t)j(e,o,{get:t[o],enumerable:!0})};var P={};R(P,{apiVersionStatus:()=>E,checkMarkup:()=>O,diagnose:()=>se,didYouMean:()=>w});var B=window.Tether.__core["config.js"],{DEFAULTS:ce,cfg:l,configure:ue,isConfigured:T,log:de,reportError:pe,warn:he}=B;var z=window.Tether.__core["client.js"],{TetherError:me,endpoint:C,gql:v,request:fe,unwrap:ye,withContext:be}=z;var G=window.Tether.__core["dom.js"],{attr:g,busy:$e,cdnUrl:ke,dataKey:Se,emit:ve,formatDate:Ee,formatMoney:xe,formatPercent:Pe,get:f,has:Te,hasTemplate:_,imageUrl:Ce,notifyLayoutChanged:_e,parseJSONAttr:Ae,productUrl:qe,qsa:d,readText:Ue,repeat:Me,repeatKeyed:De,sameImage:Ne,scoped:Ve,sel:c,setImage:Ie,setSelected:Le,setText:Oe,setTextTracked:je,show:Re,toAttributes:Be,watchImages:ze}=G;var Y=window.Tether.__core["loader.js"],{clearProductCache:Ye,getProduct:A,getProducts:He,getRecommendations:Ke,hydrateProducts:We,normalizeProductKey:Fe,primeProduct:Je,refreshProducts:Ze,takeStale:Xe}=Y;var H=window.Tether.__core["selling-plans.js"],{GID:et,allPlans:q,allocationFor:tt,findPlan:ot,hasPlans:nt,planAdjustment:rt,planCheckoutCharge:at,planPrice:st,planSavings:it,plansForVariant:lt,toGid:ct}=H;var K=window.Tether.__core["status.js"],{STATUS_KEYS:dt,boundary:U,isNotFound:pt,ownedBy:ht,resolveProductKey:$,setScopeStatus:gt}=K;var D=e=>{let t=/^(\d{4})-(01|04|07|10)$/.exec(String(e||""));return t?{y:+t[1],m:+t[2]}:null},W=(e,t)=>`${e}-${String(t).padStart(2,"0")}`;function M(e,t=1){let o=D(e);if(!o)throw new Error(`not a quarterly Shopify API version: ${e}`);let a=o.y*4+(o.m-1)/3+t;return W(Math.floor(a/4),a%4*3+1)}function E(e,t=new Date){if(e==="unstable")return{version:e,ok:!1,note:'"unstable" changes without notice: pin a dated version such as 2026-07'};let o=D(e);if(!o)return{version:e,ok:!1,note:"not a quarterly version (YYYY-01, -04, -07 or -10)"};let a=new Date(Date.UTC(o.y,o.m-1,1)),n=new Date(Date.UTC(o.y+1,o.m-1,1)),p=(n-t)/(30.44*24*3600*1e3),i=`supported until about ${n.toISOString().slice(0,7)}`;return a>t?i="not released yet (release candidate at best)":p<=0?i="no longer supported: Shopify falls back to the oldest supported version. Upgrade (see README)":p<3&&(i=`${i}: plan the upgrade to ${M(e)} or later (see README)`),{version:e,ok:a<=t&&p>0,monthsLeft:Math.round(p),next:M(e),note:i}}var F=/^[A-Z]{2}$/,J=new Set(["PT_BR","PT_PT","ZH_CN","ZH_TW"]),Z=()=>`${l.prefix}:market:${l.domain}`,X=()=>({document:typeof document<"u"?document:null,location:typeof window<"u"?window.location:null,storage:(()=>{try{return window.localStorage}catch{return null}})(),global:typeof window<"u"?window:{}});function Q(e){let t=String(e||"").trim().toUpperCase();return F.test(t)&&t!=="XX"&&t!=="T1"?t:null}function ee(e){let t=String(e||"").trim().replace("-","_").toUpperCase();if(!t)return null;if(J.has(t))return t;let o=t.split("_")[0];return/^[A-Z]{2,3}$/.test(o)?o:null}function te(e,t){if(!e||!t)return null;let o=String(e.cookie||"").split(";").map(a=>a.trim()).find(a=>a.startsWith(`${t}=`));return o?decodeURIComponent(o.slice(t.length+1)):null}var x=(e,t)=>{if(!e||!t)return null;let o=String(t).toLowerCase(),a=Object.keys(e).find(n=>n.toLowerCase()===o);return a?e[a]:null},oe={saved(e,t){if(e.remember===!1||!t.storage)return null;try{return JSON.parse(t.storage.getItem(Z())||"null")}catch{return null}},server(e,t){let o=p=>t.document?.querySelector?.(`meta[name="${p}"]`)?.getAttribute("content"),a=t.global.TETHER_COUNTRY||o("tether-country")||te(t.document,e.cookie||"tether_country"),n=t.global.TETHER_LANGUAGE||o("tether-language");return{country:a,language:n}},webflow(e,t){let o=(t.location?.pathname||"/").split("/").filter(Boolean)[0],a=x(e.locales,o);if(a)return a;let n=t.document?.documentElement?.getAttribute("lang");if(!n)return null;let p=x(e.locales,n)||x(e.locales,n.split("-")[0]);if(p)return{locale:n,...p};if(e.locales&&e.strict)return null;let i=n.split("-")[1];return{language:n,country:i&&i.length===2?i:null,locale:n}}};function N(e=l.markets,t=X()){let o=e||{};if(o.detect===!1)return{};let a=o.detect?o.detect===!0?["saved","server","webflow"]:[].concat(o.detect):["saved"];e=o;let n={sources:{}};return a.forEach(p=>{let i=oe[p]?.(e,t);if(!i)return;let b={country:Q(i.country),language:ee(i.language),locale:i.locale||null};Object.entries(b).forEach(([r,s])=>{s&&!n[r]&&(n[r]=s,n.sources[r]=p)})}),n}var V=new Set(["in-stock","out-of-stock","backorder","low-stock","plenty-in-stock","on-sale","not-on-sale","has-variants","single-variant","subscription-available","subscription-unavailable","subscription-only","one-time-available","subscription-selected","one-time-selected","has-savings","loading","ready","error","not-found","cart-empty","cart-filled","cart-has-subscription","cart-no-subscription","cart-has-discount","cart-error","cart-warning","list-empty","list-filled","search-empty","search-results","logged-in","logged-out","orders-empty","orders-loading"]),I=new Set(["title","description","description-text","vendor","type","handle","published-at","price","total-price","compare-at-price","unit-price","min-price","max-price","discount-percentage","discount-amount","variant-title","variant-id","sku","barcode","stock","quantity","featured-image","variant-image","images","tags","link","url","one-time-price","subscription-price","subscription-savings","subscription-savings-amount","checkout-charge","plan-name","plan-description","plan-group","option-value","swatch","image"]),L=new Set(`account account-bind account-link account-login account-logout add-label add-to-cart adding-text
1
+ (()=>{var j=Object.defineProperty;var R=(e,t)=>{for(var o in t)j(e,o,{get:t[o],enumerable:!0})};var P={};R(P,{apiVersionStatus:()=>E,checkMarkup:()=>O,diagnose:()=>se,didYouMean:()=>w});var B=window.Tether.__core["config.js"],{DEFAULTS:ce,cfg:l,configure:ue,isConfigured:T,log:de,reportError:pe,warn:me}=B;var z=window.Tether.__core["client.js"],{TetherError:he,endpoint:C,gql:v,request:ge,unwrap:ye,withContext:be}=z;var G=window.Tether.__core["dom.js"],{attr:f,busy:$e,cdnUrl:ke,dataKey:Se,emit:ve,formatDate:Ee,formatMoney:xe,formatPercent:Pe,get:g,has:Te,hasTemplate:_,imageUrl:Ce,notifyLayoutChanged:_e,parseJSONAttr:Ae,productUrl:qe,qsa:d,readText:Ue,repeat:Me,repeatKeyed:De,sameImage:Ne,scoped:Ve,sel:c,setImage:Ie,setSelected:Le,setText:Oe,setTextTracked:je,show:Re,toAttributes:Be,watchImages:ze}=G;var Y=window.Tether.__core["loader.js"],{clearProductCache:Ye,getProduct:A,getProducts:He,getRecommendations:Ke,hydrateProducts:We,normalizeProductKey:Fe,primeProduct:Je,refreshProducts:Ze,takeStale:Xe}=Y;var H=window.Tether.__core["selling-plans.js"],{GID:et,allPlans:q,allocationFor:tt,findPlan:ot,hasPlans:nt,planAdjustment:rt,planCheckoutCharge:at,planPrice:st,planSavings:it,plansForVariant:lt,toGid:ct}=H;var K=window.Tether.__core["status.js"],{STATUS_KEYS:dt,boundary:U,isNotFound:pt,ownedBy:mt,resolveProductKey:$,setScopeStatus:ft}=K;var D=e=>{let t=/^(\d{4})-(01|04|07|10)$/.exec(String(e||""));return t?{y:+t[1],m:+t[2]}:null},W=(e,t)=>`${e}-${String(t).padStart(2,"0")}`;function M(e,t=1){let o=D(e);if(!o)throw new Error(`not a quarterly Shopify API version: ${e}`);let a=o.y*4+(o.m-1)/3+t;return W(Math.floor(a/4),a%4*3+1)}function E(e,t=new Date){if(e==="unstable")return{version:e,ok:!1,note:'"unstable" changes without notice: pin a dated version such as 2026-07'};let o=D(e);if(!o)return{version:e,ok:!1,note:"not a quarterly version (YYYY-01, -04, -07 or -10)"};let a=new Date(Date.UTC(o.y,o.m-1,1)),n=new Date(Date.UTC(o.y+1,o.m-1,1)),p=(n-t)/(30.44*24*3600*1e3),i=`supported until about ${n.toISOString().slice(0,7)}`;return a>t?i="not released yet (release candidate at best)":p<=0?i="no longer supported: Shopify falls back to the oldest supported version. Upgrade (see README)":p<3&&(i=`${i}: plan the upgrade to ${M(e)} or later (see README)`),{version:e,ok:a<=t&&p>0,monthsLeft:Math.round(p),next:M(e),note:i}}var F=/^[A-Z]{2}$/,J=new Set(["PT_BR","PT_PT","ZH_CN","ZH_TW"]),Z=()=>`${l.prefix}:market:${l.domain}`,X=()=>({document:typeof document<"u"?document:null,location:typeof window<"u"?window.location:null,storage:(()=>{try{return window.localStorage}catch{return null}})(),global:typeof window<"u"?window:{}});function Q(e){let t=String(e||"").trim().toUpperCase();return F.test(t)&&t!=="XX"&&t!=="T1"?t:null}function ee(e){let t=String(e||"").trim().replace("-","_").toUpperCase();if(!t)return null;if(J.has(t))return t;let o=t.split("_")[0];return/^[A-Z]{2,3}$/.test(o)?o:null}function te(e,t){if(!e||!t)return null;let o=String(e.cookie||"").split(";").map(a=>a.trim()).find(a=>a.startsWith(`${t}=`));return o?decodeURIComponent(o.slice(t.length+1)):null}var x=(e,t)=>{if(!e||!t)return null;let o=String(t).toLowerCase(),a=Object.keys(e).find(n=>n.toLowerCase()===o);return a?e[a]:null},oe={saved(e,t){if(e.remember===!1||!t.storage)return null;try{return JSON.parse(t.storage.getItem(Z())||"null")}catch{return null}},server(e,t){let o=p=>t.document?.querySelector?.(`meta[name="${p}"]`)?.getAttribute("content"),a=t.global.TETHER_COUNTRY||o("tether-country")||te(t.document,e.cookie||"tether_country"),n=t.global.TETHER_LANGUAGE||o("tether-language");return{country:a,language:n}},webflow(e,t){let o=(t.location?.pathname||"/").split("/").filter(Boolean)[0],a=x(e.locales,o);if(a)return a;let n=t.document?.documentElement?.getAttribute("lang");if(!n)return null;let p=x(e.locales,n)||x(e.locales,n.split("-")[0]);if(p)return{locale:n,...p};if(e.locales&&e.strict)return null;let i=n.split("-")[1];return{language:n,country:i&&i.length===2?i:null,locale:n}}};function N(e=l.markets,t=X()){let o=e||{};if(o.detect===!1)return{};let a=o.detect?o.detect===!0?["saved","server","webflow"]:[].concat(o.detect):["saved"];e=o;let n={sources:{}};return a.forEach(p=>{let i=oe[p]?.(e,t);if(!i)return;let b={country:Q(i.country),language:ee(i.language),locale:i.locale||null};Object.entries(b).forEach(([r,s])=>{s&&!n[r]&&(n[r]=s,n.sources[r]=p)})}),n}var V=new Set(["in-stock","out-of-stock","backorder","low-stock","plenty-in-stock","on-sale","not-on-sale","has-variants","single-variant","subscription-available","subscription-unavailable","subscription-only","one-time-available","subscription-selected","one-time-selected","has-savings","loading","ready","error","not-found","cart-empty","cart-filled","cart-has-subscription","cart-no-subscription","cart-has-discount","cart-error","cart-warning","list-empty","list-filled","search-empty","search-results","logged-in","logged-out","orders-empty","orders-loading","addresses-loading","addresses-empty","subscriptions-loading","subscriptions-empty"]),I=new Set(["title","description","description-text","vendor","type","handle","published-at","price","total-price","compare-at-price","unit-price","min-price","max-price","discount-percentage","discount-amount","variant-title","variant-id","sku","barcode","stock","quantity","featured-image","variant-image","images","tags","link","url","one-time-price","subscription-price","subscription-savings","subscription-savings-amount","checkout-charge","plan-name","plan-description","plan-group","option-value","swatch","image"]),L=new Set(`account account-bind account-link account-login account-logout add-label add-to-cart adding-text
2
2
  always-enabled bind cart-checkout-charge cart-clear cart-close cart-count cart-discounts cart-drawer cart-label cart-lines
3
3
  cart-note cart-open cart-subtotal cart-total cart-warning checkout code collection collection-bind countries country
4
4
  country-bind country-label country-select default-plan default-purchase discount discount-code discount-form discount-input
5
5
  discount-remove display error group group-add hide-single language limit line line-attribute line-attributes line-id
6
6
  line-minus line-plan line-plus line-remove line-show list load-more market-pending one-time-label option option-list
7
- option-selected option-value order-bind order-line order-lines orders page-country page-language page-locale page-title plan plan-bind plan-list
7
+ option-selected option-value order order-bind order-line order-lines order-line-show order-show order-state order-fulfillments
8
+ fulfillment-bind order-return return-quantity return-reason return-note orders profile-form address-form addresses address-bind
9
+ address-show address-edit address-new address-delete address-default subscriptions subscription-bind subscription-lines
10
+ subscription-line subscription-show subscription-action subscription-status subscription-state confirm form-state form-error page-country page-language page-locale page-title plan plan-bind plan-list
8
11
  plan-value product products purchase purchase-mode qty qty-minus qty-plus quantity recommendations reverse search
9
12
  search-bind search-collections search-input search-limit search-min search-products search-queries search-results
10
13
  search-state show soldout-text sort state subscribe-text variant variant-select variant-url max-width max-height crop
11
- sig label hydrated busy`.split(/\s+/).filter(Boolean));function ne(e,t){let o=Array.from({length:e.length+1},(a,n)=>[n,...Array(t.length).fill(0)]);for(let a=1;a<=t.length;a++)o[0][a]=a;for(let a=1;a<=e.length;a++)for(let n=1;n<=t.length;n++)o[a][n]=Math.min(o[a-1][n]+1,o[a][n-1]+1,o[a-1][n-1]+(e[a-1]===t[n-1]?0:1));return o[e.length][t.length]}function w(e,t,o=""){let a=null,n=1/0;for(let p of t){let i=ne(String(e),p);i<n&&(n=i,a=p)}return a&&n<=Math.max(2,Math.floor(String(e).length/4))?` Did you mean "${o}${a}"?`:""}var re=e=>e?`${String(e).slice(0,4)}\u2026${String(e).slice(-4)} (${String(e).length} chars)`:"(missing)";function ae(e){let t=e.id?`#${e.id}`:"",o=e.className&&typeof e.className=="string"?`.${e.className.trim().split(/\s+/).slice(0,2).join(".")}`:"";return`<${e.tagName.toLowerCase()}${t}${o}>`}function O(e=document){let t=[],o=(r,s,u)=>t.push({level:r,message:s,element:u?ae(u):void 0,el:u}),a=r=>!!r.closest(c("product")),n=`${c("collection")},${c("products")},${c("recommendations")}`;d(e,c("product")).forEach(r=>{if(r.closest(n)&&r.closest(c("list")))return;let{key:s,fromUrl:u,raw:y}=$(r);y?u&&!s&&o("warn",`${g("product")}="${y}" but this URL has no value for it (e.g. ?handle=my-product).`,r):o("error",`${g("product")} has no value. Bind it to the Shopify handle (CMS field), or use "url:handle".`,r)}),["bind","option-list","option","variant-select","add-to-cart","purchase","plan-list","plan","qty","line-attribute"].forEach(r=>{d(e,c(r)).forEach(s=>{a(s)||r==="line-attribute"&&s.closest(c("group"))||o("warn",`${g(r)} outside any ${g("product")}: it does nothing here.`,s)})}),d(e,c("group-add")).forEach(r=>{r.closest(c("group"))||o("warn",`${g("group-add")} outside a ${g("group")}.`,r)}),["option-list","plan-list","cart-lines","list"].forEach(r=>d(e,c(r)).forEach(s=>{!s.firstElementChild&&!_(s)&&o("warn",`${g(r)} without a template child: put one example element inside it.`,s)})),d(e,n).forEach(r=>{d(r,c("list")).length||o("error",`List without a ${g("list")} child: products have nowhere to render.`,r)}),d(e,c("show")).forEach(r=>{let s=f(r,"show");V.has(s)||o("warn",`Unknown ${g("show")}="${s}".${w(s,V)}`,r)}),d(e,c("bind")).forEach(r=>{let s=f(r,"bind")||"";!s||I.has(s)||/^image:\d+$/.test(s)||s.startsWith("metafield:")||o("warn",`Unknown ${g("bind")}="${s}": it stays empty.${w(s,I)}`,r)});let i=`${l.prefix}-`,b=new Set;return d(e,"*").forEach(r=>{for(let s of r.attributes){if(!s.name.startsWith(i))continue;let u=s.name.slice(i.length);L.has(u)||b.has(u)||(b.add(u),o("warn",`Unknown attribute ${s.name}: Tether ignores it.${w(u,L,i)}`,r))}}),d(e,c("bind")).forEach(r=>{let s=f(r,"bind")||"";if(!s.startsWith("metafield:"))return;let u=s.slice(10);(l.metafields||[]).some(m=>(typeof m=="string"?m:`${m.namespace}.${m.key}`)===u)||o("error",`${g("bind")}="${s}" but "${u}" is not in config.metafields, so it stays empty.`,r)}),d(e,c("cart-open")).length&&!d(e,c("cart-drawer")).length&&o("warn",`${g("cart-open")} exists but there is no ${g("cart-drawer")} on this page.`),d(e,c("cart-drawer")).length>1&&o("warn",`More than one ${g("cart-drawer")}.`),d(e,`[${g("state")}="error"]`).forEach(r=>{r.matches(U())&&o("error",`Scope failed to load (${f(r,"error")||"error"}).`,r)}),t}async function se({root:e=document,silent:t=!1,version:o,now:a=new Date}={}){let n={version:o,config:{domain:l.domain||"(missing)",token:re(l.token),apiVersion:l.apiVersion,endpoint:l.domain?C():null,country:l.country,language:l.language,locale:l.locale,markets:l.markets||null,prefix:l.prefix,productPath:l.productPath,metafields:l.metafields,autoMount:l.autoMount,observe:l.observe,onError:typeof l.onError=="function"},apiVersion:E(l.apiVersion,a),market:{country:l.country||null,language:l.language||null,locale:l.locale||null,detected:l.markets?.detect?N(l.markets):null},reachable:!1,shop:null,latencyMs:null,products:[],sellingPlans:[],problems:[]};if(!T())n.problems.push({level:"error",message:"TETHER_CONFIG needs domain and token."});else{let p=Date.now();try{let i=await v("query TetherDiagnose { shop { name primaryDomain { url } paymentSettings { currencyCode } } }",{},{context:!1});n.reachable=!0,n.shop={name:i.shop?.name,url:i.shop?.primaryDomain?.url,currency:i.shop?.paymentSettings?.currencyCode}}catch(i){n.problems.push({level:"error",message:`Storefront API not reachable: ${i.message||i.code||"unknown error"}`})}if(n.latencyMs=Date.now()-p,n.reachable){let i=[...new Set(d(e,c("product")).map(r=>$(r).key).filter(Boolean))].slice(0,20);(await Promise.allSettled(i.map(r=>A(r)))).forEach((r,s)=>{if(r.status==="fulfilled"){let u=r.value,y=q(u);n.products.push({key:i[s],handle:u.handle,title:u.title,plans:y.length,requiresSellingPlan:u.requiresSellingPlan}),y.forEach(m=>n.sellingPlans.push({product:u.handle,group:m.group?.name,plan:m.name,id:m.id})),d(e,c("product")).filter(m=>$(m).key===i[s]&&m.querySelector(c("add-to-cart"))).forEach(m=>{let k=new Set(d(m,`${c("option-list")},select${c("option")}`).map(h=>f(h,"option-list")||f(h,"option")));if(!k.size&&d(m,`select${c("variant-select")}`).length)return;let S=(u.options||[]).map(h=>h.name);l.language||[...k].filter(h=>h&&!S.includes(h)).forEach(h=>{n.problems.push({level:"warn",message:`Product "${u.handle}" has no option "${h}" (its options: ${S.join(", ")||"none"}).${w(h,S)}`})}),(u.options||[]).filter(h=>h.optionValues.length>1&&!k.has(h.name)).forEach(h=>{n.problems.push({level:"warn",message:`Product "${u.handle}": option "${h.name}" (${h.optionValues.length} values) has no tether-option-list, so visitors can't choose it.`})})})}else n.products.push({key:i[s],error:r.reason?.message}),n.problems.push({level:"error",message:`Product "${i[s]}": ${r.reason?.message||r.reason?.code||"not loaded"}. Is it published to the Headless channel?`})})}}return(!n.apiVersion.ok||(n.apiVersion.monthsLeft??99)<3)&&n.problems.push({level:n.apiVersion.ok?"warn":"error",message:`apiVersion ${l.apiVersion}: ${n.apiVersion.note}`}),typeof document<"u"&&n.problems.push(...O(e)),t||ie(n),n}function ie(e){let t=console,o=e.problems.filter(a=>a.level==="error").length;t.group?.(`[${l.prefix}] diagnose: ${o?`${o} error(s)`:"no errors"}, ${e.problems.length-o} warning(s)`),t.log("version",e.version,"| API",e.apiVersion.version,`(${e.apiVersion.note})`),t.log("config",e.config),e.market&&t.log("market",`in use: ${[e.market.country,e.market.language].filter(Boolean).join(" / ")||"the store default"}`,e.market.detected?`(detection picks ${JSON.stringify(e.market.detected)})`:""),t.log(e.reachable?`Storefront API reachable: ${e.shop?.name} (${e.latencyMs} ms)`:"Storefront API NOT reachable"),e.products.length&&(t.table||t.log)(e.products),e.sellingPlans.length?(t.table||t.log)(e.sellingPlans):e.reachable&&t.log("No selling plans on the products of this page."),e.problems.forEach(a=>(a.level==="error"?t.error:t.warn)(a.message,a.el||"")),t.groupEnd?.()}window.Tether.__parts.diagnose=P;})();
14
+ sig label hydrated busy`.split(/\s+/).filter(Boolean));function ne(e,t){let o=Array.from({length:e.length+1},(a,n)=>[n,...Array(t.length).fill(0)]);for(let a=1;a<=t.length;a++)o[0][a]=a;for(let a=1;a<=e.length;a++)for(let n=1;n<=t.length;n++)o[a][n]=Math.min(o[a-1][n]+1,o[a][n-1]+1,o[a-1][n-1]+(e[a-1]===t[n-1]?0:1));return o[e.length][t.length]}function w(e,t,o=""){let a=null,n=1/0;for(let p of t){let i=ne(String(e),p);i<n&&(n=i,a=p)}return a&&n<=Math.max(2,Math.floor(String(e).length/4))?` Did you mean "${o}${a}"?`:""}var re=e=>e?`${String(e).slice(0,4)}\u2026${String(e).slice(-4)} (${String(e).length} chars)`:"(missing)";function ae(e){let t=e.id?`#${e.id}`:"",o=e.className&&typeof e.className=="string"?`.${e.className.trim().split(/\s+/).slice(0,2).join(".")}`:"";return`<${e.tagName.toLowerCase()}${t}${o}>`}function O(e=document){let t=[],o=(r,s,u)=>t.push({level:r,message:s,element:u?ae(u):void 0,el:u}),a=r=>!!r.closest(c("product")),n=`${c("collection")},${c("products")},${c("recommendations")}`;d(e,c("product")).forEach(r=>{if(r.closest(n)&&r.closest(c("list")))return;let{key:s,fromUrl:u,raw:y}=$(r);y?u&&!s&&o("warn",`${f("product")}="${y}" but this URL has no value for it (e.g. ?handle=my-product).`,r):o("error",`${f("product")} has no value. Bind it to the Shopify handle (CMS field), or use "url:handle".`,r)}),["bind","option-list","option","variant-select","add-to-cart","purchase","plan-list","plan","qty","line-attribute"].forEach(r=>{d(e,c(r)).forEach(s=>{a(s)||r==="line-attribute"&&s.closest(c("group"))||o("warn",`${f(r)} outside any ${f("product")}: it does nothing here.`,s)})}),d(e,c("group-add")).forEach(r=>{r.closest(c("group"))||o("warn",`${f("group-add")} outside a ${f("group")}.`,r)}),["option-list","plan-list","cart-lines","list"].forEach(r=>d(e,c(r)).forEach(s=>{!s.firstElementChild&&!_(s)&&o("warn",`${f(r)} without a template child: put one example element inside it.`,s)})),d(e,n).forEach(r=>{d(r,c("list")).length||o("error",`List without a ${f("list")} child: products have nowhere to render.`,r)}),d(e,c("show")).forEach(r=>{let s=g(r,"show");V.has(s)||o("warn",`Unknown ${f("show")}="${s}".${w(s,V)}`,r)}),d(e,c("bind")).forEach(r=>{let s=g(r,"bind")||"";!s||I.has(s)||/^image:\d+$/.test(s)||s.startsWith("metafield:")||o("warn",`Unknown ${f("bind")}="${s}": it stays empty.${w(s,I)}`,r)});let i=`${l.prefix}-`,b=new Set;return d(e,"*").forEach(r=>{for(let s of r.attributes){if(!s.name.startsWith(i))continue;let u=s.name.slice(i.length);L.has(u)||b.has(u)||(b.add(u),o("warn",`Unknown attribute ${s.name}: Tether ignores it.${w(u,L,i)}`,r))}}),d(e,c("bind")).forEach(r=>{let s=g(r,"bind")||"";if(!s.startsWith("metafield:"))return;let u=s.slice(10);(l.metafields||[]).some(h=>(typeof h=="string"?h:`${h.namespace}.${h.key}`)===u)||o("error",`${f("bind")}="${s}" but "${u}" is not in config.metafields, so it stays empty.`,r)}),d(e,c("cart-open")).length&&!d(e,c("cart-drawer")).length&&o("warn",`${f("cart-open")} exists but there is no ${f("cart-drawer")} on this page.`),d(e,c("cart-drawer")).length>1&&o("warn",`More than one ${f("cart-drawer")}.`),d(e,`[${f("state")}="error"]`).forEach(r=>{r.matches(U())&&o("error",`Scope failed to load (${g(r,"error")||"error"}).`,r)}),t}async function se({root:e=document,silent:t=!1,version:o,now:a=new Date}={}){let n={version:o,config:{domain:l.domain||"(missing)",token:re(l.token),apiVersion:l.apiVersion,endpoint:l.domain?C():null,country:l.country,language:l.language,locale:l.locale,markets:l.markets||null,prefix:l.prefix,productPath:l.productPath,metafields:l.metafields,autoMount:l.autoMount,observe:l.observe,onError:typeof l.onError=="function"},apiVersion:E(l.apiVersion,a),market:{country:l.country||null,language:l.language||null,locale:l.locale||null,detected:l.markets?.detect?N(l.markets):null},reachable:!1,shop:null,latencyMs:null,products:[],sellingPlans:[],problems:[]};if(!T())n.problems.push({level:"error",message:"TETHER_CONFIG needs domain and token."});else{let p=Date.now();try{let i=await v("query TetherDiagnose { shop { name primaryDomain { url } paymentSettings { currencyCode } } }",{},{context:!1});n.reachable=!0,n.shop={name:i.shop?.name,url:i.shop?.primaryDomain?.url,currency:i.shop?.paymentSettings?.currencyCode}}catch(i){n.problems.push({level:"error",message:`Storefront API not reachable: ${i.message||i.code||"unknown error"}`})}if(n.latencyMs=Date.now()-p,n.reachable){let i=[...new Set(d(e,c("product")).map(r=>$(r).key).filter(Boolean))].slice(0,20);(await Promise.allSettled(i.map(r=>A(r)))).forEach((r,s)=>{if(r.status==="fulfilled"){let u=r.value,y=q(u);n.products.push({key:i[s],handle:u.handle,title:u.title,plans:y.length,requiresSellingPlan:u.requiresSellingPlan}),y.forEach(h=>n.sellingPlans.push({product:u.handle,group:h.group?.name,plan:h.name,id:h.id})),d(e,c("product")).filter(h=>$(h).key===i[s]&&h.querySelector(c("add-to-cart"))).forEach(h=>{let k=new Set(d(h,`${c("option-list")},select${c("option")}`).map(m=>g(m,"option-list")||g(m,"option")));if(!k.size&&d(h,`select${c("variant-select")}`).length)return;let S=(u.options||[]).map(m=>m.name);l.language||[...k].filter(m=>m&&!S.includes(m)).forEach(m=>{n.problems.push({level:"warn",message:`Product "${u.handle}" has no option "${m}" (its options: ${S.join(", ")||"none"}).${w(m,S)}`})}),(u.options||[]).filter(m=>m.optionValues.length>1&&!k.has(m.name)).forEach(m=>{n.problems.push({level:"warn",message:`Product "${u.handle}": option "${m.name}" (${m.optionValues.length} values) has no tether-option-list, so visitors can't choose it.`})})})}else n.products.push({key:i[s],error:r.reason?.message}),n.problems.push({level:"error",message:`Product "${i[s]}": ${r.reason?.message||r.reason?.code||"not loaded"}. Is it published to the Headless channel?`})})}}return(!n.apiVersion.ok||(n.apiVersion.monthsLeft??99)<3)&&n.problems.push({level:n.apiVersion.ok?"warn":"error",message:`apiVersion ${l.apiVersion}: ${n.apiVersion.note}`}),typeof document<"u"&&n.problems.push(...O(e)),t||ie(n),n}function ie(e){let t=console,o=e.problems.filter(a=>a.level==="error").length;t.group?.(`[${l.prefix}] diagnose: ${o?`${o} error(s)`:"no errors"}, ${e.problems.length-o} warning(s)`),t.log("version",e.version,"| API",e.apiVersion.version,`(${e.apiVersion.note})`),t.log("config",e.config),e.market&&t.log("market",`in use: ${[e.market.country,e.market.language].filter(Boolean).join(" / ")||"the store default"}`,e.market.detected?`(detection picks ${JSON.stringify(e.market.detected)})`:""),t.log(e.reachable?`Storefront API reachable: ${e.shop?.name} (${e.latencyMs} ms)`:"Storefront API NOT reachable"),e.products.length&&(t.table||t.log)(e.products),e.sellingPlans.length?(t.table||t.log)(e.sellingPlans):e.reachable&&t.log("No selling plans on the products of this page."),e.problems.forEach(a=>(a.level==="error"?t.error:t.warn)(a.message,a.el||"")),t.groupEnd?.()}window.Tether.__parts.diagnose=P;})();
package/dist/tether.js CHANGED
@@ -2253,9 +2253,10 @@
2253
2253
  });
2254
2254
  return parts[name];
2255
2255
  }
2256
+ coreModules["lazy.js"] = { loadPart, coreModules };
2256
2257
 
2257
2258
  // src/index.js
2258
- var VERSION = "0.6.4";
2259
+ var VERSION = "0.6.6";
2259
2260
  var initPromise = null;
2260
2261
  var observer = null;
2261
2262
  function mount(root = document) {
@@ -2278,15 +2279,12 @@
2278
2279
  if (within(root, `${sel("country-select")},${sel("country-bind")}`).length) {
2279
2280
  loadPart("markets").then((m) => m.renderCountrySelects(root)).catch((err) => reportError(err, "markets"));
2280
2281
  }
2281
- if ((cfg.account?.clientId || cfg.account?.server) && (within(root, `[${attr("account-login")}],[${attr("account-bind")}],[${attr("orders")}],[${attr("show")}^="logged-"]`).length || /[?&]code=/.test(window.location.search) || hasAccountSession())) {
2282
+ if ((cfg.account?.clientId || cfg.account?.server) && (within(root, ["account-login", "account-bind", "account-link", "orders", "order", "addresses", "subscriptions", "profile-form", "address-form"].map((n) => `[${attr(n)}]`).join(",") + `,[${attr("show")}^="logged-"]`).length || /[?&]code=/.test(window.location.search) || hasAccountSession())) {
2282
2283
  loadPart("account").then((m) => m.mountAccount(root)).catch((err) => reportError(err, "account"));
2283
2284
  }
2284
2285
  if (within(root, sel("search")).length) {
2285
2286
  loadPart("search").then((m) => m.mountSearch(root)).catch((err) => reportError(err, "search"));
2286
2287
  }
2287
- qsa(root, sel("account-link")).forEach((a) => {
2288
- a.setAttribute("href", `https://${cfg.domain}/account`);
2289
- });
2290
2288
  settleMarket();
2291
2289
  Cart.render();
2292
2290
  log(`mounted ${count} scope(s)`, root);