@occluze/tether 0.9.6 → 0.9.7

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 (45) hide show
  1. package/README.md +1 -1
  2. package/dist/esm/astro.js +1 -1
  3. package/dist/esm/chunks/account-53WAVEJF.js +1 -0
  4. package/dist/esm/chunks/{account-pages-32IFOHYU.js → account-pages-LKNIXA6Q.js} +1 -1
  5. package/dist/esm/chunks/{analytics-OIQ4TFGM.js → analytics-TEU7HS7C.js} +1 -1
  6. package/dist/esm/chunks/{chunk-HZYW2TS3.js → chunk-47OLTPHV.js} +1 -1
  7. package/dist/esm/chunks/{chunk-TES2AUFT.js → chunk-74HC6MR2.js} +1 -1
  8. package/dist/esm/chunks/chunk-BRI56DD5.js +1 -0
  9. package/dist/esm/chunks/chunk-EIPYBAVZ.js +1 -0
  10. package/dist/esm/chunks/chunk-FYGRVUVB.js +1 -0
  11. package/dist/esm/chunks/{chunk-AMCCY6T4.js → chunk-HRRJ7KUG.js} +1 -1
  12. package/dist/esm/chunks/{chunk-NOTL72DB.js → chunk-IG23NTJK.js} +1 -1
  13. package/dist/esm/chunks/{chunk-33IQL4XN.js → chunk-JJRRVUDP.js} +1 -1
  14. package/dist/esm/chunks/{chunk-JJVUNGJZ.js → chunk-KJLA4CVH.js} +1 -1
  15. package/dist/esm/chunks/chunk-NXDME6AM.js +1 -0
  16. package/dist/esm/chunks/{chunk-TUVLYVMF.js → chunk-O6Z6O5NW.js} +1 -1
  17. package/dist/esm/chunks/{chunk-UDJ62MPR.js → chunk-QPSIX4DK.js} +1 -1
  18. package/dist/esm/chunks/{chunk-DQJRQBJG.js → chunk-SVJWBCRY.js} +1 -1
  19. package/dist/esm/chunks/{chunk-ESYKAFMU.js → chunk-X2HBGPFB.js} +1 -1
  20. package/dist/esm/chunks/{chunk-U5BYAOTP.js → chunk-Y5LISDPZ.js} +1 -1
  21. package/dist/esm/chunks/{chunk-KW7UPDXI.js → chunk-YZC4KFT3.js} +1 -1
  22. package/dist/esm/chunks/{diagnose-QTIUBMXT.js → diagnose-YNVDJDSH.js} +1 -1
  23. package/dist/esm/chunks/{extras-56DC6CHI.js → extras-BUH3OWBN.js} +1 -1
  24. package/dist/esm/chunks/{lists-SE5VBQ4K.js → lists-6KQIGAO6.js} +1 -1
  25. package/dist/esm/chunks/{markets-ui-GQOUGLUL.js → markets-ui-YAEXVFRK.js} +1 -1
  26. package/dist/esm/chunks/{search-ZAB5GJOK.js → search-NPGWPFMA.js} +1 -1
  27. package/dist/esm/index.js +1 -1
  28. package/dist/esm/server.js +1 -1
  29. package/dist/tether.account.js +18 -6
  30. package/dist/tether.account.min.js +1 -1
  31. package/dist/tether.js +61 -54
  32. package/dist/tether.min.js +1 -1
  33. package/dist/tether.min.js.map +4 -4
  34. package/dist/types/server/src/shared/serial.d.ts +12 -0
  35. package/dist/types/src/account/server-client.d.ts +3 -1
  36. package/dist/types/src/cart/store.d.ts +4 -4
  37. package/dist/types/src/cart.d.ts +2 -6
  38. package/dist/types/src/config.d.ts +6 -0
  39. package/dist/types/src/version.d.ts +1 -1
  40. package/package.json +1 -1
  41. package/dist/esm/chunks/account-GZLRHV5Z.js +0 -1
  42. package/dist/esm/chunks/chunk-COXH5OXQ.js +0 -1
  43. package/dist/esm/chunks/chunk-HO6SNO3A.js +0 -1
  44. package/dist/esm/chunks/chunk-LZINCBME.js +0 -1
  45. package/dist/esm/chunks/chunk-UU2VVXU2.js +0 -1
@@ -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-DQJRQBJG.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-SVJWBCRY.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,4 +1,4 @@
1
- import{e as E}from"./chunk-DQJRQBJG.js";import{a as M}from"./chunk-UU2VVXU2.js";import{b as h,e as A}from"./chunk-HZYW2TS3.js";import{c as D}from"./chunk-AMCCY6T4.js";import"./chunk-NOTL72DB.js";import{d as P,e as $,i as v,m as p,n as l,o as m,q as d,y as S}from"./chunk-HO6SNO3A.js";import{C as w,c as k,x as a}from"./chunk-ESYKAFMU.js";var R=new Set(["in-stock","out-of-stock","backorder","low-stock","plenty-in-stock","on-sale","not-on-sale","has-variants","single-variant","subscription-available","subscription-unavailable","subscription-only","one-time-available","subscription-selected","one-time-selected","has-savings","loading","ready","error","not-found","cart-empty","cart-filled","cart-has-subscription","cart-no-subscription","cart-has-discount","cart-error","cart-warning","list-empty","list-filled","search-empty","search-results","logged-in","logged-out","orders-empty","orders-loading","addresses-loading","addresses-empty","addresses-error","subscriptions-loading","subscriptions-empty","subscriptions-error"]),N=new Set(["title","description","description-text","vendor","type","handle","published-at","price","total-price","compare-at-price","unit-price","min-price","max-price","discount-percentage","discount-amount","variant-title","variant-id","sku","barcode","stock","quantity","featured-image","variant-image","images","tags","link","url","one-time-price","subscription-price","subscription-savings","subscription-savings-amount","checkout-charge","plan-name","plan-description","plan-group","option-value","swatch","image"]),x=new Set(`account account-bind account-link account-login account-logout add-label add-to-cart adding-text
1
+ import{e as E}from"./chunk-SVJWBCRY.js";import{a as M}from"./chunk-EIPYBAVZ.js";import{b as h,e as A}from"./chunk-47OLTPHV.js";import{c as D}from"./chunk-HRRJ7KUG.js";import"./chunk-IG23NTJK.js";import{d as P,e as $,i as v,m as p,n as l,o as m,q as d,y as S}from"./chunk-BRI56DD5.js";import{C as w,c as k,x as a}from"./chunk-X2HBGPFB.js";var R=new Set(["in-stock","out-of-stock","backorder","low-stock","plenty-in-stock","on-sale","not-on-sale","has-variants","single-variant","subscription-available","subscription-unavailable","subscription-only","one-time-available","subscription-selected","one-time-selected","has-savings","loading","ready","error","not-found","cart-empty","cart-filled","cart-has-subscription","cart-no-subscription","cart-has-discount","cart-error","cart-warning","list-empty","list-filled","search-empty","search-results","logged-in","logged-out","orders-empty","orders-loading","addresses-loading","addresses-empty","addresses-error","subscriptions-loading","subscriptions-empty","subscriptions-error"]),N=new Set(["title","description","description-text","vendor","type","handle","published-at","price","total-price","compare-at-price","unit-price","min-price","max-price","discount-percentage","discount-amount","variant-title","variant-id","sku","barcode","stock","quantity","featured-image","variant-image","images","tags","link","url","one-time-price","subscription-price","subscription-savings","subscription-savings-amount","checkout-charge","plan-name","plan-description","plan-group","option-value","swatch","image"]),x=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
@@ -1 +1 @@
1
- import{c as S}from"./chunk-UDJ62MPR.js";import{a as k,b as E}from"./chunk-TUVLYVMF.js";import{a as v}from"./chunk-33IQL4XN.js";import{h as p}from"./chunk-COXH5OXQ.js";import"./chunk-KW7UPDXI.js";import"./chunk-DQJRQBJG.js";import"./chunk-UU2VVXU2.js";import"./chunk-HZYW2TS3.js";import"./chunk-AMCCY6T4.js";import"./chunk-NOTL72DB.js";import{P as w,S as b,a as f,n as u,o as g,p as y,q as h,u as c}from"./chunk-HO6SNO3A.js";import{E as d,F as s,x as l}from"./chunk-ESYKAFMU.js";function C(t,e){let r=b(w(t,"line-attributes"));return e?[{key:"_group",value:e},...r]:r}async function _(t){let e=t.closest(u("group"));if(!e)return null;let r=g(e,"group"),n=C(e,r),i=h(e,u("product")).flatMap(o=>{let a=v.get(o);if(!a?.variant?.availableForSale||a.quantity<=0)return[];let m=a.getLine();return m?[{...m,attributes:[...m.attributes??[],...n]}]:[]});if(!i.length)return d("group-add: nothing selected"),null;try{let o=await p.add(i);return c("group-added",{group:r,lines:i},e),o}catch(o){return s(o,"group add"),null}}function I(t,e,r){t.classList.toggle("is-invalid",r),r?e?.setAttribute("aria-invalid","true"):e?.removeAttribute("aria-invalid")}async function q(t,e,r){try{await p.applyDiscount(r),I(t,e,!1),c("discount-applied",{code:r},t),e&&(e.value="")}catch(n){I(t,e,!0),n instanceof f&&n.code==="INVALID_DISCOUNT"?c("discount-invalid",{code:r},t):s(n,"discount")}}function N(t){if(t.key===l.storageKey||t.key===`${l.storageKey}:seen`){p.init().catch(n=>{s(n,"cart from another tab")});return}if(t.key!==k()||!t.newValue)return;let e=E(t.newValue);if(!e)return;let r={language:e.language??null,locale:e.locale,remember:!1};S(e.country,r).catch(n=>{s(n,"market from another tab")})}var L=new WeakMap,A=t=>t.split("/").pop()??t;function M(t){try{window.history.replaceState(window.history.state,"",t)}catch{}}function $(t,{variant:e,sellingPlanId:r}){let n=`${e.id}|${r??""}`,i=L.get(t);if(L.set(t,n),!i||i===n)return;let o=l.variantUrl&&document.querySelector(u("product"))===t;if(!y(t,"variant-url")&&!o)return;let a=new URL(window.location.href);a.searchParams.set("variant",A(e.id)),r?a.searchParams.set("selling_plan",A(r)):a.searchParams.delete("selling_plan"),M(a)}export{_ as addGroup,q as applyDiscountCode,N as onStorage,$ as writeVariantUrl};
1
+ import{c as S}from"./chunk-QPSIX4DK.js";import{a as k,b as E}from"./chunk-O6Z6O5NW.js";import{a as v}from"./chunk-JJRRVUDP.js";import{h as p}from"./chunk-NXDME6AM.js";import"./chunk-YZC4KFT3.js";import"./chunk-SVJWBCRY.js";import"./chunk-EIPYBAVZ.js";import"./chunk-47OLTPHV.js";import"./chunk-HRRJ7KUG.js";import"./chunk-IG23NTJK.js";import{P as w,S as b,a as f,n as u,o as g,p as y,q as h,u as c}from"./chunk-BRI56DD5.js";import{E as d,F as s,x as l}from"./chunk-X2HBGPFB.js";function C(t,e){let r=b(w(t,"line-attributes"));return e?[{key:"_group",value:e},...r]:r}async function _(t){let e=t.closest(u("group"));if(!e)return null;let r=g(e,"group"),n=C(e,r),i=h(e,u("product")).flatMap(o=>{let a=v.get(o);if(!a?.variant?.availableForSale||a.quantity<=0)return[];let m=a.getLine();return m?[{...m,attributes:[...m.attributes??[],...n]}]:[]});if(!i.length)return d("group-add: nothing selected"),null;try{let o=await p.add(i);return c("group-added",{group:r,lines:i},e),o}catch(o){return s(o,"group add"),null}}function I(t,e,r){t.classList.toggle("is-invalid",r),r?e?.setAttribute("aria-invalid","true"):e?.removeAttribute("aria-invalid")}async function q(t,e,r){try{await p.applyDiscount(r),I(t,e,!1),c("discount-applied",{code:r},t),e&&(e.value="")}catch(n){I(t,e,!0),n instanceof f&&n.code==="INVALID_DISCOUNT"?c("discount-invalid",{code:r},t):s(n,"discount")}}function N(t){if(t.key===l.storageKey||t.key===`${l.storageKey}:seen`){p.init().catch(n=>{s(n,"cart from another tab")});return}if(t.key!==k()||!t.newValue)return;let e=E(t.newValue);if(!e)return;let r={language:e.language??null,locale:e.locale,remember:!1};S(e.country,r).catch(n=>{s(n,"market from another tab")})}var L=new WeakMap,A=t=>t.split("/").pop()??t;function M(t){try{window.history.replaceState(window.history.state,"",t)}catch{}}function $(t,{variant:e,sellingPlanId:r}){let n=`${e.id}|${r??""}`,i=L.get(t);if(L.set(t,n),!i||i===n)return;let o=l.variantUrl&&document.querySelector(u("product"))===t;if(!y(t,"variant-url")&&!o)return;let a=new URL(window.location.href);a.searchParams.set("variant",A(e.id)),r?a.searchParams.set("selling_plan",A(r)):a.searchParams.delete("selling_plan"),M(a)}export{_ as addGroup,q as applyDiscountCode,N as onStorage,$ as writeVariantUrl};
@@ -1 +1 @@
1
- import{a as R}from"./chunk-LZINCBME.js";import"./chunk-UU2VVXU2.js";import{b as w,d as I,g as T}from"./chunk-HZYW2TS3.js";import{a as H,b as m,d as h}from"./chunk-AMCCY6T4.js";import{c as q,h as x,i as M,j as F}from"./chunk-NOTL72DB.js";import{F as v,G as E,I as f,M as K,O as A,R as O,a as P,i as a,m as $,n as c,o as s,p as d,r as N,u,x as b,z as k}from"./chunk-HO6SNO3A.js";import{F as L,b as l,x as y}from"./chunk-ESYKAFMU.js";var U="url:",W=`query TetherCollection($handle:String!,$first:Int!,$after:String,$sortKey:ProductCollectionSortKeys,$reverse:Boolean,$filters:[ProductFilter!]){collection(handle:$handle){${q()} products(first:$first,after:$after,sortKey:$sortKey,reverse:$reverse,filters:$filters){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}}`,j="query TetherSearch($first:Int!,$after:String,$query:String,$sortKey:ProductSortKeys,$reverse:Boolean){products(first:$first,after:$after,query:$query,sortKey:$sortKey,reverse:$reverse){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}";async function z({collection:n,query:t,first:r=y.collectionFirst,after:e=null,sortKey:o,reverse:i=!1,filters:D}={}){if(n){let S=await a(h(W),{handle:n,first:r,after:e,sortKey:o||void 0,reverse:i,filters:D??void 0},x);if(!S.collection)throw new P(`Collection not found: ${n}`,{code:"NOT_FOUND"});let{products:g,...Y}=S.collection;return g.nodes.forEach(m),{collection:Y,products:g.nodes,pageInfo:g.pageInfo}}let p=await a(h(j),{first:r,after:e,query:t||void 0,sortKey:o||void 0,reverse:i},M);return p.products.nodes.forEach(m),{collection:null,products:p.products.nodes,pageInfo:p.products.pageInfo}}async function X(n,t="RELATED"){let r=H(typeof n=="object"?n?.id:n);if(!r)throw new P("No product for recommendations",{code:"NOT_FOUND"});let e=r.startsWith("gid://"),i=(await a(h(`query TetherRecs(${e?"$id: ID!":"$handle: String!"},$intent:ProductRecommendationIntent){productRecommendations(${e?"productId: $id":"productHandle: $handle"},intent:$intent){...TetherProduct}}`),e?{id:r,intent:t}:{handle:r,intent:t},F)).productRecommendations??[];return i.forEach(m),i}var Z=n=>n instanceof window.Element,_=(n,t)=>O(n,"limit",{min:1,max:250,fallback:t}),G=n=>n==="COMPLEMENTARY"?"COMPLEMENTARY":"RELATED",C=class{constructor(t){l(this,"root");l(this,"products",[]);l(this,"pageInfo",null);l(this,"collection",null);l(this,"loadToken",0);this.root=t,t.addEventListener("click",r=>{if(!Z(r.target))return;let e=r.target.closest(c("load-more"));e?.closest(R())===t&&(r.preventDefault(),A(e,()=>this.load(!0)))})}$(t){return N(this.root,t,R())}options(){let{root:t}=this,r={reverse:s(t,"reverse")==="true",first:_(t,y.collectionFirst)},e=s(t,"sort");if(e&&(r.sortKey=e),d(t,"collection"))return r.collection=s(t,"collection")??"",r;let o=s(t,"products")??"";return r.query=o.startsWith(U)?new URL(window.location.href).searchParams.get(o.slice(U.length))||"":o,r}async loadRecommendations(){let{key:t}=w(this.root,window.location,"recommendations"),r=this.root.closest(c("product"));return!t&&r&&({key:t}=w(r)),X(t,G(s(this.root,"intent")))}async load(t=!1){this.loadToken+=1;let r=this.loadToken,e=()=>r!==this.loadToken;try{if(d(this.root,"recommendations")){let o=await this.loadRecommendations();if(e())return;this.products=o.slice(0,_(this.root,o.length))}else{let o=await z({...this.options(),after:t?this.pageInfo?.endCursor??null:null});if(e())return;this.collection=o.collection,this.pageInfo=o.pageInfo,this.products=t?[...this.products,...o.products]:o.products}this.render(),T(this.root,"ready"),u("list-ready",{products:this.products,collection:this.collection},this.root)}catch(o){if(e())return;t||T(this.root,I(o)?"not-found":"error",o),I(o)&&d(this.root,"recommendations")||L(o,"list load failed"),u("error",{error:o,context:"list"},this.root)}}render(){let{collection:t}=this;this.$(c("collection-bind")).forEach(e=>{switch(s(e,"collection-bind")??""){case"title":E(e,t?.title??"");break;case"description":v(e,t?.descriptionHtml);break;case"image":b(e,t?.image?.url,t?.image?.altText||t?.title);break;case"count":E(e,this.products.length);break}}),this.$(c("list")).forEach(e=>{k(e,this.products,(o,i)=>{o.setAttribute($("product"),i.handle),o.removeAttribute($("state"))}),u("list-rendered",{container:e},this.root)});let r=this.products.length===0;this.$(c("show")).forEach(e=>{let o=s(e,"show");o==="list-empty"&&f(e,r),o==="list-filled"&&f(e,!r)}),this.$(c("load-more")).forEach(e=>{f(e,!!this.pageInfo?.hasNextPage)}),K("list")}},Q=new WeakMap;function ct(n){let t=Q.get(n);return t||(t=new C(n),Q.set(n,t)),t.load()}export{z as getProducts,X as getRecommendations,ct as loadList};
1
+ import{a as R}from"./chunk-FYGRVUVB.js";import"./chunk-EIPYBAVZ.js";import{b as w,d as I,g as T}from"./chunk-47OLTPHV.js";import{a as H,b as m,d as h}from"./chunk-HRRJ7KUG.js";import{c as q,h as x,i as M,j as F}from"./chunk-IG23NTJK.js";import{F as v,G as E,I as f,M as K,O as A,R as O,a as P,i as a,m as $,n as c,o as s,p as d,r as N,u,x as b,z as k}from"./chunk-BRI56DD5.js";import{F as L,b as l,x as y}from"./chunk-X2HBGPFB.js";var U="url:",W=`query TetherCollection($handle:String!,$first:Int!,$after:String,$sortKey:ProductCollectionSortKeys,$reverse:Boolean,$filters:[ProductFilter!]){collection(handle:$handle){${q()} products(first:$first,after:$after,sortKey:$sortKey,reverse:$reverse,filters:$filters){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}}`,j="query TetherSearch($first:Int!,$after:String,$query:String,$sortKey:ProductSortKeys,$reverse:Boolean){products(first:$first,after:$after,query:$query,sortKey:$sortKey,reverse:$reverse){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}";async function z({collection:n,query:t,first:r=y.collectionFirst,after:e=null,sortKey:o,reverse:i=!1,filters:D}={}){if(n){let S=await a(h(W),{handle:n,first:r,after:e,sortKey:o||void 0,reverse:i,filters:D??void 0},x);if(!S.collection)throw new P(`Collection not found: ${n}`,{code:"NOT_FOUND"});let{products:g,...Y}=S.collection;return g.nodes.forEach(m),{collection:Y,products:g.nodes,pageInfo:g.pageInfo}}let p=await a(h(j),{first:r,after:e,query:t||void 0,sortKey:o||void 0,reverse:i},M);return p.products.nodes.forEach(m),{collection:null,products:p.products.nodes,pageInfo:p.products.pageInfo}}async function X(n,t="RELATED"){let r=H(typeof n=="object"?n?.id:n);if(!r)throw new P("No product for recommendations",{code:"NOT_FOUND"});let e=r.startsWith("gid://"),i=(await a(h(`query TetherRecs(${e?"$id: ID!":"$handle: String!"},$intent:ProductRecommendationIntent){productRecommendations(${e?"productId: $id":"productHandle: $handle"},intent:$intent){...TetherProduct}}`),e?{id:r,intent:t}:{handle:r,intent:t},F)).productRecommendations??[];return i.forEach(m),i}var Z=n=>n instanceof window.Element,_=(n,t)=>O(n,"limit",{min:1,max:250,fallback:t}),G=n=>n==="COMPLEMENTARY"?"COMPLEMENTARY":"RELATED",C=class{constructor(t){l(this,"root");l(this,"products",[]);l(this,"pageInfo",null);l(this,"collection",null);l(this,"loadToken",0);this.root=t,t.addEventListener("click",r=>{if(!Z(r.target))return;let e=r.target.closest(c("load-more"));e?.closest(R())===t&&(r.preventDefault(),A(e,()=>this.load(!0)))})}$(t){return N(this.root,t,R())}options(){let{root:t}=this,r={reverse:s(t,"reverse")==="true",first:_(t,y.collectionFirst)},e=s(t,"sort");if(e&&(r.sortKey=e),d(t,"collection"))return r.collection=s(t,"collection")??"",r;let o=s(t,"products")??"";return r.query=o.startsWith(U)?new URL(window.location.href).searchParams.get(o.slice(U.length))||"":o,r}async loadRecommendations(){let{key:t}=w(this.root,window.location,"recommendations"),r=this.root.closest(c("product"));return!t&&r&&({key:t}=w(r)),X(t,G(s(this.root,"intent")))}async load(t=!1){this.loadToken+=1;let r=this.loadToken,e=()=>r!==this.loadToken;try{if(d(this.root,"recommendations")){let o=await this.loadRecommendations();if(e())return;this.products=o.slice(0,_(this.root,o.length))}else{let o=await z({...this.options(),after:t?this.pageInfo?.endCursor??null:null});if(e())return;this.collection=o.collection,this.pageInfo=o.pageInfo,this.products=t?[...this.products,...o.products]:o.products}this.render(),T(this.root,"ready"),u("list-ready",{products:this.products,collection:this.collection},this.root)}catch(o){if(e())return;t||T(this.root,I(o)?"not-found":"error",o),I(o)&&d(this.root,"recommendations")||L(o,"list load failed"),u("error",{error:o,context:"list"},this.root)}}render(){let{collection:t}=this;this.$(c("collection-bind")).forEach(e=>{switch(s(e,"collection-bind")??""){case"title":E(e,t?.title??"");break;case"description":v(e,t?.descriptionHtml);break;case"image":b(e,t?.image?.url,t?.image?.altText||t?.title);break;case"count":E(e,this.products.length);break}}),this.$(c("list")).forEach(e=>{k(e,this.products,(o,i)=>{o.setAttribute($("product"),i.handle),o.removeAttribute($("state"))}),u("list-rendered",{container:e},this.root)});let r=this.products.length===0;this.$(c("show")).forEach(e=>{let o=s(e,"show");o==="list-empty"&&f(e,r),o==="list-filled"&&f(e,!r)}),this.$(c("load-more")).forEach(e=>{f(e,!!this.pageInfo?.hasNextPage)}),K("list")}},Q=new WeakMap;function ct(n){let t=Q.get(n);return t||(t=new C(n),Q.set(n,t)),t.load()}export{z as getProducts,X as getRecommendations,ct as loadList};
@@ -1 +1 @@
1
- import{a as E,c as P,d as k,e as T,f as p,g as A}from"./chunk-JJVUNGJZ.js";import{a as I}from"./chunk-LZINCBME.js";import{d as F,e as x}from"./chunk-TUVLYVMF.js";import"./chunk-33IQL4XN.js";import{h as u}from"./chunk-COXH5OXQ.js";import"./chunk-KW7UPDXI.js";import"./chunk-DQJRQBJG.js";import"./chunk-UU2VVXU2.js";import"./chunk-HZYW2TS3.js";import{e as w}from"./chunk-AMCCY6T4.js";import"./chunk-NOTL72DB.js";import{a as L,d as h,i as b,m as s,n as C,o as v,u as z}from"./chunk-HO6SNO3A.js";import{F as y,o as f,p as g,x as a}from"./chunk-ESYKAFMU.js";var _="{name} ({currency})",j="name",d=null;function B(){d=null}var D="query TetherLocalization{localization{country{isoCode name currency{isoCode symbol}}language{isoCode name}availableCountries{isoCode name currency{isoCode symbol}availableLanguages{isoCode name}}}}",O={isoCode:"string",name:"string",currency:"object"},H=h({localization:{country:O,availableCountries:[O]}});function R(){return d??(d=b(D,{},H).then(e=>e.localization,e=>{throw d=null,e})),d}function U(e,n){switch(n){case"name":return e.name;case"code":return e.isoCode;case"currency":return e.currency.isoCode;case"symbol":return e.currency.symbol;default:return""}}var Y=(e,n)=>e.replace(/\{(name|code|currency|symbol)\}/g,(o,i)=>U(n,i));function q(e,n,o){let i=e.getAttribute(s("country-label"))||_,r=(e.getAttribute(s("countries"))||"").toUpperCase().split(/[\s,]+/).filter(Boolean),c=r.length?r.map(t=>n.find(l=>l.isoCode===t)).filter(t=>t!==void 0):n;e.replaceChildren(...c.map(t=>new Option(Y(i,t),t.isoCode))),e.value=o,e.value!==o&&(e.selectedIndex=-1),e.disabled=c.length<2&&!e.hasAttribute(s("always-enabled"))}function $(e,n,o){let i=(a.country||o.country.isoCode).toUpperCase(),r=[...o.availableCountries].sort((t,l)=>t.name.localeCompare(l.name,a.locale||void 0)),c=r.find(t=>t.isoCode===i)??o.country;e.forEach(t=>{q(t,r,i)}),n.forEach(t=>{t.textContent=U(c,v(t,"country-bind")||j)})}function S(e=document){let n=p(e,`select${C("country-select")}`),o=p(e,C("country-bind"));return!n.length&&!o.length?Promise.resolve():R().then(i=>{$(n,o,i)}).catch(i=>{y(i,"country select")})}var Q=e=>Object.values(a.markets?.locales??{}).find(n=>f(n.country)===e);function V(e,n){return e!==void 0?g(e):n?n.language?g(n.language):void 0:a.language}function Z(e){w();let n=[];return u.id()&&n.push(u.setBuyerIdentity({countryCode:e},{create:!1}).catch(o=>{y(o,"cart country")})),T(),k.forEach(o=>n.push(o.load())),P.forEach(o=>{o.closest(I())||(E.delete(o),A(o))}),n}async function re(e,{language:n,locale:o,remember:i=!0}={}){let r=f(e);if(!r)throw new L(`Not a country code: ${e}`,{code:"INVALID_COUNTRY"});let c=Q(r),t=o||c?.locale,l=t||a.locale,m=V(n,c),M=r!==a.country||m!==a.language||l!==a.locale;if(a.country=r,a.language=m||void 0,a.locale=l,i&&x({country:r,language:m,locale:t}),!M)return S(),u.state;n!==void 0&&B();let N=Z(r);return S(),z("country-changed",{country:r,language:a.language}),await Promise.all(N),u.state}export{F as detectMarket,R as getLocalization,S as renderCountrySelects,re as setCountry};
1
+ import{a as E,c as P,d as k,e as T,f as p,g as A}from"./chunk-KJLA4CVH.js";import{a as I}from"./chunk-FYGRVUVB.js";import{d as F,e as x}from"./chunk-O6Z6O5NW.js";import"./chunk-JJRRVUDP.js";import{h as u}from"./chunk-NXDME6AM.js";import"./chunk-YZC4KFT3.js";import"./chunk-SVJWBCRY.js";import"./chunk-EIPYBAVZ.js";import"./chunk-47OLTPHV.js";import{e as w}from"./chunk-HRRJ7KUG.js";import"./chunk-IG23NTJK.js";import{a as L,d as h,i as b,m as s,n as C,o as v,u as z}from"./chunk-BRI56DD5.js";import{F as y,o as f,p as g,x as a}from"./chunk-X2HBGPFB.js";var _="{name} ({currency})",j="name",d=null;function B(){d=null}var D="query TetherLocalization{localization{country{isoCode name currency{isoCode symbol}}language{isoCode name}availableCountries{isoCode name currency{isoCode symbol}availableLanguages{isoCode name}}}}",O={isoCode:"string",name:"string",currency:"object"},H=h({localization:{country:O,availableCountries:[O]}});function R(){return d??(d=b(D,{},H).then(e=>e.localization,e=>{throw d=null,e})),d}function U(e,n){switch(n){case"name":return e.name;case"code":return e.isoCode;case"currency":return e.currency.isoCode;case"symbol":return e.currency.symbol;default:return""}}var Y=(e,n)=>e.replace(/\{(name|code|currency|symbol)\}/g,(o,i)=>U(n,i));function q(e,n,o){let i=e.getAttribute(s("country-label"))||_,r=(e.getAttribute(s("countries"))||"").toUpperCase().split(/[\s,]+/).filter(Boolean),c=r.length?r.map(t=>n.find(l=>l.isoCode===t)).filter(t=>t!==void 0):n;e.replaceChildren(...c.map(t=>new Option(Y(i,t),t.isoCode))),e.value=o,e.value!==o&&(e.selectedIndex=-1),e.disabled=c.length<2&&!e.hasAttribute(s("always-enabled"))}function $(e,n,o){let i=(a.country||o.country.isoCode).toUpperCase(),r=[...o.availableCountries].sort((t,l)=>t.name.localeCompare(l.name,a.locale||void 0)),c=r.find(t=>t.isoCode===i)??o.country;e.forEach(t=>{q(t,r,i)}),n.forEach(t=>{t.textContent=U(c,v(t,"country-bind")||j)})}function S(e=document){let n=p(e,`select${C("country-select")}`),o=p(e,C("country-bind"));return!n.length&&!o.length?Promise.resolve():R().then(i=>{$(n,o,i)}).catch(i=>{y(i,"country select")})}var Q=e=>Object.values(a.markets?.locales??{}).find(n=>f(n.country)===e);function V(e,n){return e!==void 0?g(e):n?n.language?g(n.language):void 0:a.language}function Z(e){w();let n=[];return u.id()&&n.push(u.setBuyerIdentity({countryCode:e},{create:!1}).catch(o=>{y(o,"cart country")})),T(),k.forEach(o=>n.push(o.load())),P.forEach(o=>{o.closest(I())||(E.delete(o),A(o))}),n}async function re(e,{language:n,locale:o,remember:i=!0}={}){let r=f(e);if(!r)throw new L(`Not a country code: ${e}`,{code:"INVALID_COUNTRY"});let c=Q(r),t=o||c?.locale,l=t||a.locale,m=V(n,c),M=r!==a.country||m!==a.language||l!==a.locale;if(a.country=r,a.language=m||void 0,a.locale=l,i&&x({country:r,language:m,locale:t}),!M)return S(),u.state;n!==void 0&&B();let N=Z(r);return S(),z("country-changed",{country:r,language:a.language}),await Promise.all(N),u.state}export{F as detectMarket,R as getLocalization,S as renderCountrySelects,re as setCountry};
@@ -1 +1 @@
1
- import{f as k}from"./chunk-JJVUNGJZ.js";import"./chunk-LZINCBME.js";import"./chunk-33IQL4XN.js";import"./chunk-COXH5OXQ.js";import"./chunk-KW7UPDXI.js";import"./chunk-DQJRQBJG.js";import"./chunk-UU2VVXU2.js";import"./chunk-HZYW2TS3.js";import"./chunk-AMCCY6T4.js";import"./chunk-NOTL72DB.js";import{B as q,D as v,G as R,I as d,R as p,c as T,d as I,i as L,m as w,n as o,o as m,q as h,u as x,x as C,z as M}from"./chunk-HO6SNO3A.js";import{D as E,F as A,b as s,x as u}from"./chunk-ESYKAFMU.js";var U=I({predictiveSearch:T({products:[{priceRange:"object"}],collections:["object"],queries:[{text:"string"}]})}),D="query TetherPredictive($q:String!,$limit:Int!){predictiveSearch(query:$q,limit:$limit,limitScope:EACH,types:[PRODUCT,COLLECTION,QUERY]){products{id handle title availableForSale featuredImage{url altText}priceRange{minVariantPrice{amount currencyCode}}}collections{handle title image{url altText}}queries{text}}}",V=6,F=10,O=2,_="/search",g=new WeakSet,$=0,b=new Set,P=a=>a.tagName==="A"?a:a.querySelector("a");function f(a,t){h(a,o("search-bind")).forEach(e=>{let i=m(e,"search-bind");i==="image"?C(e,t.image?.url,t.image?.altText||t.title):(i==="title"||i==="price"||i==="text")&&t[i]!=null&&R(e,t[i])})}function H(a,t){let e=P(a);e&&(t&&e.setAttribute("href",t),e.setAttribute("role","option"))}var y=class{constructor(t,e,i){s(this,"root");s(this,"input");s(this,"results");s(this,"limit");s(this,"minCharacters");s(this,"resultsId");s(this,"searchNumber",0);s(this,"timer");s(this,"lastTerm","");s(this,"cache",new Map);s(this,"listening",new window.AbortController);this.root=t,this.input=e,this.results=i,this.limit=p(t,"search-limit",{min:1,max:F,fallback:V}),this.minCharacters=p(t,"search-min",{min:1,fallback:O}),i.id||($+=1,i.id=`${u.prefix}-search-${$}`),this.resultsId=i.id,this.setUpAria(),this.listen(),b.add(this)}stop(){this.listening.abort(),clearTimeout(this.timer),b.delete(this),g.delete(this.root)}setUpAria(){this.input.setAttribute("role","combobox"),this.input.setAttribute("aria-autocomplete","list"),this.input.setAttribute("aria-controls",this.resultsId),this.input.setAttribute("aria-expanded","false"),this.input.setAttribute("autocomplete","off"),this.results.hasAttribute("role")||this.results.setAttribute("role","listbox"),this.results.hidden=!0}listen(){let{signal:t}=this.listening;this.input.addEventListener("input",()=>{let e=this.input.value.trim();e!==this.lastTerm&&(this.lastTerm=e,clearTimeout(this.timer),this.timer=setTimeout(()=>void this.search(e),u.searchDelay))},{signal:t}),this.input.addEventListener("focus",()=>{this.input.value.trim().length>=this.minCharacters&&this.options().length&&this.open(!0)},{signal:t}),this.input.addEventListener("keydown",e=>{this.onKeydown(e)},{signal:t}),document.addEventListener("click",e=>{if(!this.root.isConnected){this.stop();return}this.root.contains(e.target)||this.open(!1)},{signal:t})}setState(t){this.root.setAttribute(w("search-state"),t)}open(t){this.root.classList.toggle("is-open",t),this.results.hidden=!t,this.input.setAttribute("aria-expanded",String(t)),t||this.input.removeAttribute("aria-activedescendant")}options(){return h(this.results,'[role="option"]')}async fetchResults(t){let e=this.cache.get(t);if(e)return e;let i=await L(D,{q:t,limit:this.limit},U);return this.cache.set(t,i.predictiveSearch),i.predictiveSearch}async search(t){this.searchNumber+=1;let e=this.searchNumber;if(t.length<this.minCharacters){this.open(!1),this.setState("idle");return}this.setState("loading");try{let i=await this.fetchResults(t);e===this.searchNumber&&this.render(i,t)}catch(i){if(e!==this.searchNumber){E("a superseded search failed",i);return}this.setState("error"),A(i,"search")}}fillList(t,e,i){h(this.results,o(t)).forEach(l=>{M(l,e,i),d(l,e.length>0)})}queryUrl(t){let e=this.root.getAttribute("action")||_,i=e.includes("?")?"&":"?";return`${e}${i}${this.input.name||"q"}=${encodeURIComponent(t)}`}render(t,e){let i=t?.products??[],l=t?.collections??[],c=(t?.queries??[]).filter(n=>n.text.toLowerCase()!==e.toLowerCase());this.fillList("search-products",i,(n,r)=>{let N=v(r.priceRange.minVariantPrice);f(n,{title:r.title,price:N,image:r.featuredImage}),H(n,q(r.handle,r.id)),n.classList.toggle("is-sold-out",!r.availableForSale)}),this.fillList("search-collections",l,(n,r)=>{f(n,{title:r.title,image:r.image}),H(n,`${(u.collectionPath||"/collection").replace(/\/$/,"")}/${r.handle}`)}),this.fillList("search-queries",c,(n,r)=>{f(n,{text:r.text}),P(n)?.setAttribute("href",this.queryUrl(r.text))});let S=i.length+l.length+c.length;this.showCount(S),this.setState(S?"ready":"empty"),this.open(!0),x("search",{term:e,products:i,collections:l,queries:c},this.root)}showCount(t){h(this.root,o("show")).forEach(e=>{let i=m(e,"show");i==="search-empty"&&d(e,t===0),i==="search-results"&&d(e,t>0)}),this.options().forEach((e,i)=>{e.id||(e.id=`${this.resultsId}-${i}`),e.setAttribute("aria-selected","false")}),this.input.removeAttribute("aria-activedescendant")}highlight(t,e){t.forEach((l,c)=>{l.setAttribute("aria-selected",String(c===e))});let i=t[e];i&&(this.input.setAttribute("aria-activedescendant",i.id),i.scrollIntoView?.({block:"nearest"}))}onKeydown(t){let e=this.options(),i=e.findIndex(l=>l.getAttribute("aria-selected")==="true");t.key==="ArrowDown"&&e.length?(t.preventDefault(),this.open(!0),this.highlight(e,(i+1)%e.length)):t.key==="ArrowUp"&&e.length?(t.preventDefault(),this.highlight(e,i<=0?e.length-1:i-1)):t.key==="Enter"&&i>=0?(t.preventDefault(),e[i]?.click()):t.key==="Escape"&&this.open(!1)}};function Y(a=document){b.forEach(t=>{t.root.isConnected||t.stop()});for(let t of k(a,o("search"))){if(g.has(t))continue;g.add(t);let e=t.querySelector(o("search-input"))??t.querySelector("input"),i=t.querySelector(o("search-results"));e&&i&&new y(t,e,i)}}export{Y as mountSearch};
1
+ import{f as k}from"./chunk-KJLA4CVH.js";import"./chunk-FYGRVUVB.js";import"./chunk-JJRRVUDP.js";import"./chunk-NXDME6AM.js";import"./chunk-YZC4KFT3.js";import"./chunk-SVJWBCRY.js";import"./chunk-EIPYBAVZ.js";import"./chunk-47OLTPHV.js";import"./chunk-HRRJ7KUG.js";import"./chunk-IG23NTJK.js";import{B as q,D as v,G as R,I as d,R as p,c as T,d as I,i as L,m as w,n as o,o as m,q as h,u as x,x as C,z as M}from"./chunk-BRI56DD5.js";import{D as E,F as A,b as s,x as u}from"./chunk-X2HBGPFB.js";var U=I({predictiveSearch:T({products:[{priceRange:"object"}],collections:["object"],queries:[{text:"string"}]})}),D="query TetherPredictive($q:String!,$limit:Int!){predictiveSearch(query:$q,limit:$limit,limitScope:EACH,types:[PRODUCT,COLLECTION,QUERY]){products{id handle title availableForSale featuredImage{url altText}priceRange{minVariantPrice{amount currencyCode}}}collections{handle title image{url altText}}queries{text}}}",V=6,F=10,O=2,_="/search",g=new WeakSet,$=0,b=new Set,P=a=>a.tagName==="A"?a:a.querySelector("a");function f(a,t){h(a,o("search-bind")).forEach(e=>{let i=m(e,"search-bind");i==="image"?C(e,t.image?.url,t.image?.altText||t.title):(i==="title"||i==="price"||i==="text")&&t[i]!=null&&R(e,t[i])})}function H(a,t){let e=P(a);e&&(t&&e.setAttribute("href",t),e.setAttribute("role","option"))}var y=class{constructor(t,e,i){s(this,"root");s(this,"input");s(this,"results");s(this,"limit");s(this,"minCharacters");s(this,"resultsId");s(this,"searchNumber",0);s(this,"timer");s(this,"lastTerm","");s(this,"cache",new Map);s(this,"listening",new window.AbortController);this.root=t,this.input=e,this.results=i,this.limit=p(t,"search-limit",{min:1,max:F,fallback:V}),this.minCharacters=p(t,"search-min",{min:1,fallback:O}),i.id||($+=1,i.id=`${u.prefix}-search-${$}`),this.resultsId=i.id,this.setUpAria(),this.listen(),b.add(this)}stop(){this.listening.abort(),clearTimeout(this.timer),b.delete(this),g.delete(this.root)}setUpAria(){this.input.setAttribute("role","combobox"),this.input.setAttribute("aria-autocomplete","list"),this.input.setAttribute("aria-controls",this.resultsId),this.input.setAttribute("aria-expanded","false"),this.input.setAttribute("autocomplete","off"),this.results.hasAttribute("role")||this.results.setAttribute("role","listbox"),this.results.hidden=!0}listen(){let{signal:t}=this.listening;this.input.addEventListener("input",()=>{let e=this.input.value.trim();e!==this.lastTerm&&(this.lastTerm=e,clearTimeout(this.timer),this.timer=setTimeout(()=>void this.search(e),u.searchDelay))},{signal:t}),this.input.addEventListener("focus",()=>{this.input.value.trim().length>=this.minCharacters&&this.options().length&&this.open(!0)},{signal:t}),this.input.addEventListener("keydown",e=>{this.onKeydown(e)},{signal:t}),document.addEventListener("click",e=>{if(!this.root.isConnected){this.stop();return}this.root.contains(e.target)||this.open(!1)},{signal:t})}setState(t){this.root.setAttribute(w("search-state"),t)}open(t){this.root.classList.toggle("is-open",t),this.results.hidden=!t,this.input.setAttribute("aria-expanded",String(t)),t||this.input.removeAttribute("aria-activedescendant")}options(){return h(this.results,'[role="option"]')}async fetchResults(t){let e=this.cache.get(t);if(e)return e;let i=await L(D,{q:t,limit:this.limit},U);return this.cache.set(t,i.predictiveSearch),i.predictiveSearch}async search(t){this.searchNumber+=1;let e=this.searchNumber;if(t.length<this.minCharacters){this.open(!1),this.setState("idle");return}this.setState("loading");try{let i=await this.fetchResults(t);e===this.searchNumber&&this.render(i,t)}catch(i){if(e!==this.searchNumber){E("a superseded search failed",i);return}this.setState("error"),A(i,"search")}}fillList(t,e,i){h(this.results,o(t)).forEach(l=>{M(l,e,i),d(l,e.length>0)})}queryUrl(t){let e=this.root.getAttribute("action")||_,i=e.includes("?")?"&":"?";return`${e}${i}${this.input.name||"q"}=${encodeURIComponent(t)}`}render(t,e){let i=t?.products??[],l=t?.collections??[],c=(t?.queries??[]).filter(n=>n.text.toLowerCase()!==e.toLowerCase());this.fillList("search-products",i,(n,r)=>{let N=v(r.priceRange.minVariantPrice);f(n,{title:r.title,price:N,image:r.featuredImage}),H(n,q(r.handle,r.id)),n.classList.toggle("is-sold-out",!r.availableForSale)}),this.fillList("search-collections",l,(n,r)=>{f(n,{title:r.title,image:r.image}),H(n,`${(u.collectionPath||"/collection").replace(/\/$/,"")}/${r.handle}`)}),this.fillList("search-queries",c,(n,r)=>{f(n,{text:r.text}),P(n)?.setAttribute("href",this.queryUrl(r.text))});let S=i.length+l.length+c.length;this.showCount(S),this.setState(S?"ready":"empty"),this.open(!0),x("search",{term:e,products:i,collections:l,queries:c},this.root)}showCount(t){h(this.root,o("show")).forEach(e=>{let i=m(e,"show");i==="search-empty"&&d(e,t===0),i==="search-results"&&d(e,t>0)}),this.options().forEach((e,i)=>{e.id||(e.id=`${this.resultsId}-${i}`),e.setAttribute("aria-selected","false")}),this.input.removeAttribute("aria-activedescendant")}highlight(t,e){t.forEach((l,c)=>{l.setAttribute("aria-selected",String(c===e))});let i=t[e];i&&(this.input.setAttribute("aria-activedescendant",i.id),i.scrollIntoView?.({block:"nearest"}))}onKeydown(t){let e=this.options(),i=e.findIndex(l=>l.getAttribute("aria-selected")==="true");t.key==="ArrowDown"&&e.length?(t.preventDefault(),this.open(!0),this.highlight(e,(i+1)%e.length)):t.key==="ArrowUp"&&e.length?(t.preventDefault(),this.highlight(e,i<=0?e.length-1:i-1)):t.key==="Enter"&&i>=0?(t.preventDefault(),e[i]?.click()):t.key==="Escape"&&this.open(!1)}};function Y(a=document){b.forEach(t=>{t.root.isConnected||t.stop()});for(let t of k(a,o("search"))){if(g.has(t))continue;g.add(t);let e=t.querySelector(o("search-input"))??t.querySelector("input"),i=t.querySelector(o("search-results"));e&&i&&new y(t,e,i)}}export{Y as mountSearch};
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- import{a as at,b as ct,c as ut}from"./chunks/chunk-U5BYAOTP.js";import{b as C,d as P,e as T,f as g,g as nt,h as ot,i as rt,j as L,k}from"./chunks/chunk-JJVUNGJZ.js";import{a as dt,b as mt}from"./chunks/chunk-LZINCBME.js";import{a as it,b as st,c as h}from"./chunks/chunk-UDJ62MPR.js";import"./chunks/chunk-TUVLYVMF.js";import{a as et}from"./chunks/chunk-33IQL4XN.js";import{a as K,e as Z,h as s}from"./chunks/chunk-COXH5OXQ.js";import"./chunks/chunk-KW7UPDXI.js";import{l as Q}from"./chunks/chunk-DQJRQBJG.js";import{a as u,b as lt}from"./chunks/chunk-UU2VVXU2.js";import{b as tt}from"./chunks/chunk-HZYW2TS3.js";import{a as W,b as X,c as Y,e as J}from"./chunks/chunk-AMCCY6T4.js";import"./chunks/chunk-NOTL72DB.js";import{D as j,L as v,O as p,Q as z,a as F,f as G,k as _,m,n as i,s as q,t as y,u as U,v as B}from"./chunks/chunk-HO6SNO3A.js";import{B as $,C as E,D as b,E as V,F as a,e as D,x as c,y as H}from"./chunks/chunk-ESYKAFMU.js";function ft(t){let e=[],n=new window.AbortController,o={signal:n.signal};return q.forEach(r=>{document.addEventListener(`${c.prefix}:${r}`,d=>e.push(d),o)}),document.addEventListener("astro:page-load",r=>e.push(r),o),t().then(r=>r.startAnalytics(e)).catch(r=>{n.abort(),e.length=0,a(r,"analytics")}),e}var S="0.9.6";var Mt=["account-login","account-bind","account-link","orders","order","addresses","subscriptions","profile-form","address-form"],Nt=()=>[...Mt.map(t=>`[${m(t)}]`),`[${m("show")}^="logged-"]`].join(",");function Ot(){return!!Z(at())}function pt(t){!c.account||!(g(t,Nt()).length>0||ut(new URLSearchParams(window.location.search).get("account"))||Ot())||u("account").then(n=>n.mountAccount(t)).catch(n=>{a(n,"account")})}function l(t){return(...e)=>u("account").then(n=>{let o=n[t];return o(...e)})}var gt={login:l("login"),logout:l("logout"),isLoggedIn:l("isLoggedIn"),customer:l("customer"),orders:l("orders"),order:l("order"),updateProfile:l("updateProfile"),addresses:l("addresses"),saveAddress:l("saveAddress"),deleteAddress:l("deleteAddress"),subscriptions:l("subscriptions"),subscriptionAction:l("subscriptionAction"),requestReturn:l("requestReturn"),render:l("render"),mountAccount:l("mountAccount")};var yt=()=>`data-${c.prefix}-key`,ht=t=>t instanceof window.Element;function Et(t){let e=t.closest(`[${yt()}]`),n=e?.getAttribute(yt());return e&&n?{line:e,id:n}:null}function w(t,e){t.catch(n=>{a(n,e)})}function It(t,e){let n=Et(e);if(!n?.line.closest(i("cart-lines")))return;let{line:o,id:r}=n;if(e.closest(i("line-remove"))){t.preventDefault(),o.classList.add("is-busy"),w(s.removeLine(r),"cart line");return}let d=Rt(e);!d||!s.lines.some(xt=>xt.id===r)||(t.preventDefault(),w(s.changeQuantity(r,d),"cart line"))}function Rt(t){return t.closest(i("line-plus"))?1:t.closest(i("line-minus"))?-1:0}function Dt(t){let{target:e}=t;if(!ht(e))return;if(e.closest(i("cart-open"))){t.preventDefault(),s.toggle();return}if(e.closest(i("cart-close"))){t.preventDefault(),s.close();return}let n=e.closest(i("cart-clear"));if(n){t.preventDefault(),p(n,()=>s.clear().catch(r=>{a(r,"cart clear")}));return}let o=e.closest(i("checkout"));if(o){t.preventDefault(),p(o,()=>s.checkout());return}It(t,e)}function vt(t,e,n){t.classList.add("is-busy"),t.setAttribute("aria-busy","true"),w(e,n)}function Ht(t,{line:e,id:n}){let o=t.value.trim();if(z.test(o)){vt(e,s.updateLine(n,Number(o)),"cart line");return}let r=s.lines.find(d=>d.id===n);r&&(t.value=String(s.quantityOf(r)))}function $t(t){let{target:e}=t;if(!ht(e))return;let n=Et(e);n&&e instanceof window.HTMLInputElement&&e.matches(i("line","quantity"))?Ht(e,n):n&&e instanceof window.HTMLSelectElement&&e.matches(i("line-plan"))?vt(n.line,s.updateLine(n.id,{sellingPlanId:e.value||null}),"cart line plan"):Vt(e)&&e.matches(i("cart-note"))&&w(s.setNote(e.value),"cart note")}var Vt=t=>t instanceof window.HTMLInputElement||t instanceof window.HTMLTextAreaElement||t instanceof window.HTMLSelectElement;function Ft(t){if(s.isOpen()){if(t.key==="Escape"){s.close();return}K(t)}}function Pt(){document.addEventListener("click",Dt),document.addEventListener("change",$t),document.addEventListener("keydown",Ft)}var x=t=>t instanceof window.Element;function Gt(t){let e=t.querySelector(i("discount-input"))??t.querySelector("input");return e instanceof window.HTMLInputElement?e:null}function _t(t){let{target:e}=t,n=x(e)?e.closest(i("discount-form")):null;if(!n)return;t.preventDefault();let o=Gt(n),r=o?.value.trim();r&&p(n,()=>u("extras").then(d=>d.applyDiscountCode(n,o,r))).catch(d=>{a(d,"discount")})}function qt(t){let{target:e}=t;if(!x(e))return;let n=e.closest(i("discount-form"));n&&(n.classList.remove("is-invalid"),e.removeAttribute("aria-invalid"))}function Ut(t){let{target:e}=t,n=x(e)?e.closest(i("discount-remove")):null;if(!n)return;t.preventDefault();let o=n.closest(i("discount-code"))?.getAttribute(m("discount-code"));o&&s.removeDiscount(o).catch(r=>{a(r,"discount")})}function wt(){document.addEventListener("submit",_t,!0),document.addEventListener("input",qt),document.addEventListener("click",Ut)}var M=t=>u("extras").then(e=>e.addGroup(t)),N=t=>{a(t,"extras")};function Bt(t){let{target:e}=t,n=e instanceof window.Element?e.closest(i("group-add")):null;n&&(t.preventDefault(),p(n,()=>M(n)).catch(N))}function jt(t){!c.domain||!t.key?.startsWith(`${c.prefix}:`)||u("extras").then(e=>{e.onStorage(t)}).catch(N)}function zt(t){if(!y(t,"variant-changed"))return;let{target:e}=t;e instanceof window.Element&&(!c.variantUrl&&!e.hasAttribute(m("variant-url"))||u("extras").then(n=>{n.writeVariantUrl(e,t.detail)}).catch(N))}function At(){document.addEventListener("click",Bt),window.addEventListener("storage",jt),document.addEventListener(`${c.prefix}:variant-changed`,zt)}var O=null;function bt(){O=document.body}async function Qt(t){await t.ready();let e=st();if(!e){O!==document.body&&t.mount(document);return}try{await h(e.country,{language:e.language??null,locale:e.locale,remember:!1})}catch(n){a(n,"country")}t.mount(document)}function Kt(t){document.addEventListener("astro:page-load",()=>{Qt(t).catch(e=>{a(e,"page mount")})}),document.addEventListener("astro:before-swap",()=>{O=null,t.unmount()})}function Wt(t){let{target:e}=t;!(e instanceof window.HTMLSelectElement)||!e.matches(i("country-select"))||e.value&&h(e.value).catch(n=>{a(n,"country")})}function Xt(){ot(),P.forEach(t=>{t.root.getAttribute(m("state"))==="error"&&t.load()})}function Ct(t){c.astro&&Kt(t),document.addEventListener("change",Wt),window.addEventListener("online",Xt)}var Yt=50;function Jt(){let t=v("TETHER_CONFIG");return typeof t=="object"&&t!==null?Object.fromEntries(Object.entries(t)):{}}var f=null,I=null,Zt=null,Tt=!1;function te(t){let e=0;return g(t,dt()).forEach(n=>{if(C.has(n))return;C.add(n),e++;let o=mt(n);P.add(o),n.addEventListener(`${c.prefix}:list-rendered`,r=>{y(r,"list-rendered")&&A(r.detail.container)}),rt(o.load())}),e}function ee(t){g(t,`${i("country-select")},${i("country-bind")}`).length&&u("markets").then(e=>e.renderCountrySelects(t)).catch(e=>{a(e,"markets")}),pt(t),g(t,i("search")).length&&u("search").then(e=>{e.mountSearch(t)}).catch(e=>{a(e,"search")})}function Lt(t){let e=te(t);return g(t,i("product")).forEach(n=>{nt(n)&&e++}),ee(t),e}function A(t=document){if(!E())return 0;t===document&&bt(),T(),k(t.ownerDocument??document);let e=Lt(t);return L(),s.render(),b(`mounted ${e} scope(s)`,t),e}function ne(t){let e=t.filter(o=>o.isConnected&&!t.some(r=>r!==o&&r.contains(o)));if(!e.length||!E())return;T(),e.forEach(o=>{k(o)});let n=e.reduce((o,r)=>o+Lt(r),0);L(),s.render(),b(`mounted ${n} scope(s) in ${e.length} added element(s)`)}function kt(){s.close()}function oe(t){let e=t?.closest(i("product"));return e?et.get(e)??null:null}function re(){Tt||(Tt=!0,Pt(),wt(),At(),Ct({ready:()=>f??Promise.resolve(null),mount:A,unmount:kt}))}async function ie(t){let e=c.country,n=t?.buyerIdentity.countryCode;if(!t||!e||!n||n===e)return t;try{return await s.setBuyerIdentity({countryCode:e},{create:!1})}catch(o){return a(o,"cart country"),t}}function St(t={}){return f&&!Object.keys(t).length?f:($({...Jt(),...t}),E()?(ct(),re(),c.observe&&se(),c.analytics&&(Zt??(Zt=ft(()=>u("analytics")))),f=it(t).then(()=>s.init()).then(ie).then(e=>(U("ready",{cart:e}),R)),f):(V("TETHER_CONFIG is missing domain or token. Tether is idle."),f=Promise.resolve(null),f))}function se(){if(I||typeof MutationObserver>"u")return;let t,e=new Set;I=new MutationObserver(n=>{n.forEach(o=>{o.addedNodes.forEach(r=>{r instanceof window.Element&&e.add(r)})}),clearTimeout(t),t=setTimeout(()=>{let o=[...e];e.clear(),ne(o)},Yt)}),I.observe(document.body,{childList:!0,subtree:!0})}var ae=t=>u("markets").then(e=>e.detectMarket(t??c.markets)),ce=t=>u("lists").then(e=>e.getProducts(t)),ue=(t,e)=>u("lists").then(n=>n.getRecommendations(t,e)),le=()=>u("markets").then(t=>t.getLocalization()),de=t=>u("diagnose").then(e=>e.diagnose({...t,version:S}));function me(t,e){let n=`${c.prefix}:${t}`,o=r=>{y(r,t)&&e(r.detail,r)};return document.addEventListener(n,o),()=>{document.removeEventListener(n,o)}}var fe={VERSION:S,init:St,mount:A,unmount:kt,get config(){return H},get ready(){return f??Promise.resolve(null)},query:_,withContext:G,cart:s,getProduct:Y,getProducts:ce,getRecommendations:ue,getScope:oe,addGroup:M,account:gt,primeProduct:X,normalizeProductKey:W,clearProductCache:J,formatMoney:j,imageUrl:B,plans:Q,TetherError:F,resolveProductKey:tt,setCountry:h,detectMarket:ae,getLocalization:le,diagnose:de,on:me},pe={__core:lt,__parts:{}},R=Object.assign(fe,pe),mn=R;function ge(){Reflect.set(window,"Tether",R);let t=v("TETHER_CONFIG");if(!t||D(t,"autoMount")===!1||v("TETHER_INTEGRATION"))return;let e=()=>{St().then(()=>A(document)).catch(n=>{a(n,"init")})};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e,{once:!0}):e()}typeof window<"u"&&typeof document<"u"&&ge();export{S as VERSION,M as addGroup,R as api,mn as default,oe as getScope,St as init,A as mount,h as setCountry,kt as unmount};
1
+ import{a as at,b as ct,c as ut}from"./chunks/chunk-Y5LISDPZ.js";import{b as C,d as P,e as T,f as g,g as nt,h as ot,i as rt,j as L,k}from"./chunks/chunk-KJLA4CVH.js";import{a as dt,b as mt}from"./chunks/chunk-FYGRVUVB.js";import{a as it,b as st,c as h}from"./chunks/chunk-QPSIX4DK.js";import"./chunks/chunk-O6Z6O5NW.js";import{a as et}from"./chunks/chunk-JJRRVUDP.js";import{a as K,e as Z,h as s}from"./chunks/chunk-NXDME6AM.js";import"./chunks/chunk-YZC4KFT3.js";import{l as Q}from"./chunks/chunk-SVJWBCRY.js";import{a as u,b as lt}from"./chunks/chunk-EIPYBAVZ.js";import{b as tt}from"./chunks/chunk-47OLTPHV.js";import{a as W,b as X,c as Y,e as J}from"./chunks/chunk-HRRJ7KUG.js";import"./chunks/chunk-IG23NTJK.js";import{D as j,L as v,O as p,Q as z,a as F,f as G,k as _,m,n as i,s as q,t as y,u as U,v as B}from"./chunks/chunk-BRI56DD5.js";import{B as $,C as E,D as b,E as V,F as a,e as D,x as c,y as H}from"./chunks/chunk-X2HBGPFB.js";function ft(t){let e=[],n=new window.AbortController,o={signal:n.signal};return q.forEach(r=>{document.addEventListener(`${c.prefix}:${r}`,d=>e.push(d),o)}),document.addEventListener("astro:page-load",r=>e.push(r),o),t().then(r=>r.startAnalytics(e)).catch(r=>{n.abort(),e.length=0,a(r,"analytics")}),e}var S="0.9.7";var Mt=["account-login","account-bind","account-link","orders","order","addresses","subscriptions","profile-form","address-form"],Nt=()=>[...Mt.map(t=>`[${m(t)}]`),`[${m("show")}^="logged-"]`].join(",");function Ot(){return!!Z(at())}function pt(t){!c.account||!(g(t,Nt()).length>0||ut(new URLSearchParams(window.location.search).get("account"))||Ot())||u("account").then(n=>n.mountAccount(t)).catch(n=>{a(n,"account")})}function l(t){return(...e)=>u("account").then(n=>{let o=n[t];return o(...e)})}var gt={login:l("login"),logout:l("logout"),isLoggedIn:l("isLoggedIn"),customer:l("customer"),orders:l("orders"),order:l("order"),updateProfile:l("updateProfile"),addresses:l("addresses"),saveAddress:l("saveAddress"),deleteAddress:l("deleteAddress"),subscriptions:l("subscriptions"),subscriptionAction:l("subscriptionAction"),requestReturn:l("requestReturn"),render:l("render"),mountAccount:l("mountAccount")};var yt=()=>`data-${c.prefix}-key`,ht=t=>t instanceof window.Element;function Et(t){let e=t.closest(`[${yt()}]`),n=e?.getAttribute(yt());return e&&n?{line:e,id:n}:null}function w(t,e){t.catch(n=>{a(n,e)})}function It(t,e){let n=Et(e);if(!n?.line.closest(i("cart-lines")))return;let{line:o,id:r}=n;if(e.closest(i("line-remove"))){t.preventDefault(),o.classList.add("is-busy"),w(s.removeLine(r),"cart line");return}let d=Rt(e);!d||!s.lines.some(xt=>xt.id===r)||(t.preventDefault(),w(s.changeQuantity(r,d),"cart line"))}function Rt(t){return t.closest(i("line-plus"))?1:t.closest(i("line-minus"))?-1:0}function Dt(t){let{target:e}=t;if(!ht(e))return;if(e.closest(i("cart-open"))){t.preventDefault(),s.toggle();return}if(e.closest(i("cart-close"))){t.preventDefault(),s.close();return}let n=e.closest(i("cart-clear"));if(n){t.preventDefault(),p(n,()=>s.clear().catch(r=>{a(r,"cart clear")}));return}let o=e.closest(i("checkout"));if(o){t.preventDefault(),p(o,()=>s.checkout());return}It(t,e)}function vt(t,e,n){t.classList.add("is-busy"),t.setAttribute("aria-busy","true"),w(e,n)}function Ht(t,{line:e,id:n}){let o=t.value.trim();if(z.test(o)){vt(e,s.updateLine(n,Number(o)),"cart line");return}let r=s.lines.find(d=>d.id===n);r&&(t.value=String(s.quantityOf(r)))}function $t(t){let{target:e}=t;if(!ht(e))return;let n=Et(e);n&&e instanceof window.HTMLInputElement&&e.matches(i("line","quantity"))?Ht(e,n):n&&e instanceof window.HTMLSelectElement&&e.matches(i("line-plan"))?vt(n.line,s.updateLine(n.id,{sellingPlanId:e.value||null}),"cart line plan"):Vt(e)&&e.matches(i("cart-note"))&&w(s.setNote(e.value),"cart note")}var Vt=t=>t instanceof window.HTMLInputElement||t instanceof window.HTMLTextAreaElement||t instanceof window.HTMLSelectElement;function Ft(t){if(s.isOpen()){if(t.key==="Escape"){s.close();return}K(t)}}function Pt(){document.addEventListener("click",Dt),document.addEventListener("change",$t),document.addEventListener("keydown",Ft)}var x=t=>t instanceof window.Element;function Gt(t){let e=t.querySelector(i("discount-input"))??t.querySelector("input");return e instanceof window.HTMLInputElement?e:null}function _t(t){let{target:e}=t,n=x(e)?e.closest(i("discount-form")):null;if(!n)return;t.preventDefault();let o=Gt(n),r=o?.value.trim();r&&p(n,()=>u("extras").then(d=>d.applyDiscountCode(n,o,r))).catch(d=>{a(d,"discount")})}function qt(t){let{target:e}=t;if(!x(e))return;let n=e.closest(i("discount-form"));n&&(n.classList.remove("is-invalid"),e.removeAttribute("aria-invalid"))}function Ut(t){let{target:e}=t,n=x(e)?e.closest(i("discount-remove")):null;if(!n)return;t.preventDefault();let o=n.closest(i("discount-code"))?.getAttribute(m("discount-code"));o&&s.removeDiscount(o).catch(r=>{a(r,"discount")})}function wt(){document.addEventListener("submit",_t,!0),document.addEventListener("input",qt),document.addEventListener("click",Ut)}var M=t=>u("extras").then(e=>e.addGroup(t)),N=t=>{a(t,"extras")};function Bt(t){let{target:e}=t,n=e instanceof window.Element?e.closest(i("group-add")):null;n&&(t.preventDefault(),p(n,()=>M(n)).catch(N))}function jt(t){!c.domain||!t.key?.startsWith(`${c.prefix}:`)||u("extras").then(e=>{e.onStorage(t)}).catch(N)}function zt(t){if(!y(t,"variant-changed"))return;let{target:e}=t;e instanceof window.Element&&(!c.variantUrl&&!e.hasAttribute(m("variant-url"))||u("extras").then(n=>{n.writeVariantUrl(e,t.detail)}).catch(N))}function At(){document.addEventListener("click",Bt),window.addEventListener("storage",jt),document.addEventListener(`${c.prefix}:variant-changed`,zt)}var O=null;function bt(){O=document.body}async function Qt(t){await t.ready();let e=st();if(!e){O!==document.body&&t.mount(document);return}try{await h(e.country,{language:e.language??null,locale:e.locale,remember:!1})}catch(n){a(n,"country")}t.mount(document)}function Kt(t){document.addEventListener("astro:page-load",()=>{Qt(t).catch(e=>{a(e,"page mount")})}),document.addEventListener("astro:before-swap",()=>{O=null,t.unmount()})}function Wt(t){let{target:e}=t;!(e instanceof window.HTMLSelectElement)||!e.matches(i("country-select"))||e.value&&h(e.value).catch(n=>{a(n,"country")})}function Xt(){ot(),P.forEach(t=>{t.root.getAttribute(m("state"))==="error"&&t.load()})}function Ct(t){c.astro&&Kt(t),document.addEventListener("change",Wt),window.addEventListener("online",Xt)}var Yt=50;function Jt(){let t=v("TETHER_CONFIG");return typeof t=="object"&&t!==null?Object.fromEntries(Object.entries(t)):{}}var f=null,I=null,Zt=null,Tt=!1;function te(t){let e=0;return g(t,dt()).forEach(n=>{if(C.has(n))return;C.add(n),e++;let o=mt(n);P.add(o),n.addEventListener(`${c.prefix}:list-rendered`,r=>{y(r,"list-rendered")&&A(r.detail.container)}),rt(o.load())}),e}function ee(t){g(t,`${i("country-select")},${i("country-bind")}`).length&&u("markets").then(e=>e.renderCountrySelects(t)).catch(e=>{a(e,"markets")}),pt(t),g(t,i("search")).length&&u("search").then(e=>{e.mountSearch(t)}).catch(e=>{a(e,"search")})}function Lt(t){let e=te(t);return g(t,i("product")).forEach(n=>{nt(n)&&e++}),ee(t),e}function A(t=document){if(!E())return 0;t===document&&bt(),T(),k(t.ownerDocument??document);let e=Lt(t);return L(),s.render(),b(`mounted ${e} scope(s)`,t),e}function ne(t){let e=t.filter(o=>o.isConnected&&!t.some(r=>r!==o&&r.contains(o)));if(!e.length||!E())return;T(),e.forEach(o=>{k(o)});let n=e.reduce((o,r)=>o+Lt(r),0);L(),s.render(),b(`mounted ${n} scope(s) in ${e.length} added element(s)`)}function kt(){s.close()}function oe(t){let e=t?.closest(i("product"));return e?et.get(e)??null:null}function re(){Tt||(Tt=!0,Pt(),wt(),At(),Ct({ready:()=>f??Promise.resolve(null),mount:A,unmount:kt}))}async function ie(t){let e=c.country,n=t?.buyerIdentity.countryCode;if(!t||!e||!n||n===e)return t;try{return await s.setBuyerIdentity({countryCode:e},{create:!1})}catch(o){return a(o,"cart country"),t}}function St(t={}){return f&&!Object.keys(t).length?f:($({...Jt(),...t}),E()?(ct(),re(),c.observe&&se(),c.analytics&&(Zt??(Zt=ft(()=>u("analytics")))),f=it(t).then(()=>s.init()).then(ie).then(e=>(U("ready",{cart:e}),R)),f):(V("TETHER_CONFIG is missing domain or token. Tether is idle."),f=Promise.resolve(null),f))}function se(){if(I||typeof MutationObserver>"u")return;let t,e=new Set;I=new MutationObserver(n=>{n.forEach(o=>{o.addedNodes.forEach(r=>{r instanceof window.Element&&e.add(r)})}),clearTimeout(t),t=setTimeout(()=>{let o=[...e];e.clear(),ne(o)},Yt)}),I.observe(document.body,{childList:!0,subtree:!0})}var ae=t=>u("markets").then(e=>e.detectMarket(t??c.markets)),ce=t=>u("lists").then(e=>e.getProducts(t)),ue=(t,e)=>u("lists").then(n=>n.getRecommendations(t,e)),le=()=>u("markets").then(t=>t.getLocalization()),de=t=>u("diagnose").then(e=>e.diagnose({...t,version:S}));function me(t,e){let n=`${c.prefix}:${t}`,o=r=>{y(r,t)&&e(r.detail,r)};return document.addEventListener(n,o),()=>{document.removeEventListener(n,o)}}var fe={VERSION:S,init:St,mount:A,unmount:kt,get config(){return H},get ready(){return f??Promise.resolve(null)},query:_,withContext:G,cart:s,getProduct:Y,getProducts:ce,getRecommendations:ue,getScope:oe,addGroup:M,account:gt,primeProduct:X,normalizeProductKey:W,clearProductCache:J,formatMoney:j,imageUrl:B,plans:Q,TetherError:F,resolveProductKey:tt,setCountry:h,detectMarket:ae,getLocalization:le,diagnose:de,on:me},pe={__core:lt,__parts:{}},R=Object.assign(fe,pe),mn=R;function ge(){Reflect.set(window,"Tether",R);let t=v("TETHER_CONFIG");if(!t||D(t,"autoMount")===!1||v("TETHER_INTEGRATION"))return;let e=()=>{St().then(()=>A(document)).catch(n=>{a(n,"init")})};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e,{once:!0}):e()}typeof window<"u"&&typeof document<"u"&&ge();export{S as VERSION,M as addGroup,R as api,mn as default,oe as getScope,St as init,A as mount,h as setCountry,kt as unmount};
@@ -1,2 +1,2 @@
1
- import{b as Q,f as G,g as H}from"./chunks/chunk-KW7UPDXI.js";import{e as O,f as v,g as w,i as F,l as q}from"./chunks/chunk-DQJRQBJG.js";import{a as M,c as T,e as V,g as J,h as B,i as K,j}from"./chunks/chunk-NOTL72DB.js";import{C as D,a as y,c as k,d as I,f as ot,h as E,j as _,v as L}from"./chunks/chunk-HO6SNO3A.js";import{E as U,q as $,t as x,u as S,v as C,w as g,z as A}from"./chunks/chunk-ESYKAFMU.js";function z(t,e={}){if(!t)return null;let{variant:r,sellingPlan:a,defaultPurchase:c=g.defaultPurchase,lowStock:u=g.lowStock}=e,d=G(t,{variant:r,sellingPlan:a,defaultPurchase:c}),n=H(t,{...d,quantity:1},u);if(!n)throw new y(`Product ${t.handle} has no variants`);let{selected:l,line:p}=n,i=(o,s)=>!Q(t,l,o,s);return{variant:n.variant,selected:l,purchase:n.purchase.kind,plan:p.kind==="subscription"?n.plan:null,plans:O(t).map(o=>({id:o.id,name:o.name,price:w(n.variant,o.id),savings:F(n.variant,o.id).percentage,selected:p.kind==="subscription"&&o.id===p.planId,available:!!v(n.variant,o.id)})),savings:n.savings.percentage,price:n.price,compareAtPrice:n.compareAtPrice,available:n.variant.availableForSale,show:n.show,unavailable:Object.fromEntries(t.options.map(o=>[o.name,o.optionValues.map(s=>s.name).filter(s=>i(o.name,s))])),isUnavailable:i}}var it=500,at=100,st=100,lt="query TetherServerProductById($id:ID!){node(id:$id){... on Product{...TetherProduct}}}",ct="query TetherServerProduct($handle:String!){product(handle:$handle){...TetherProduct}}",ut=()=>`query TetherServerCollection($handle:String!,$first:Int!,$after:String,$sortKey:ProductCollectionSortKeys,$reverse:Boolean,$filters:[ProductFilter!]){collection(handle:$handle){${T()} products(first:$first,after:$after,sortKey:$sortKey,reverse:$reverse,filters:$filters){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}}`,dt="query TetherServerProducts($first:Int!,$after:String,$query:String,$sortKey:ProductSortKeys,$reverse:Boolean){products(first:$first,after:$after,query:$query,sortKey:$sortKey,reverse:$reverse){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}",ft=()=>`query TetherServerCollections($first:Int!,$after:String){collections(first:$first,after:$after){nodes{${T()}}pageInfo{hasNextPage endCursor}}}`,pt=t=>`query TetherServerRecs(${t?"$id: ID!":"$handle: String!"},$intent:ProductRecommendationIntent){productRecommendations(${t?"productId: $id":"productHandle: $handle"},intent:$intent){...TetherProduct}}`,mt=I({product:k(V)}),gt=I({node:k(J)}),yt=I({collections:{nodes:[{handle:"string"}],pageInfo:{hasNextPage:"boolean"}}});async function Pt(t){let e=[],r=null;for(let a=0;a<st;a++){let c=await E(t,ft(),{first:at,after:r},yt);if(e.push(...c.collections.nodes),!c.collections.pageInfo.hasNextPage)break;r=c.collections.pageInfo.endCursor}return e}function Y(t,e){let r=(i,o,s)=>E(t,f=>`${i}
1
+ import{b as Q,f as G,g as H}from"./chunks/chunk-YZC4KFT3.js";import{e as O,f as v,g as w,i as F,l as q}from"./chunks/chunk-SVJWBCRY.js";import{a as M,c as T,e as V,g as J,h as B,i as K,j}from"./chunks/chunk-IG23NTJK.js";import{C as D,a as y,c as k,d as I,f as ot,h as E,j as _,v as L}from"./chunks/chunk-BRI56DD5.js";import{E as U,q as $,t as x,u as S,v as C,w as g,z as A}from"./chunks/chunk-X2HBGPFB.js";function z(t,e={}){if(!t)return null;let{variant:r,sellingPlan:a,defaultPurchase:c=g.defaultPurchase,lowStock:u=g.lowStock}=e,d=G(t,{variant:r,sellingPlan:a,defaultPurchase:c}),n=H(t,{...d,quantity:1},u);if(!n)throw new y(`Product ${t.handle} has no variants`);let{selected:l,line:p}=n,i=(o,s)=>!Q(t,l,o,s);return{variant:n.variant,selected:l,purchase:n.purchase.kind,plan:p.kind==="subscription"?n.plan:null,plans:O(t).map(o=>({id:o.id,name:o.name,price:w(n.variant,o.id),savings:F(n.variant,o.id).percentage,selected:p.kind==="subscription"&&o.id===p.planId,available:!!v(n.variant,o.id)})),savings:n.savings.percentage,price:n.price,compareAtPrice:n.compareAtPrice,available:n.variant.availableForSale,show:n.show,unavailable:Object.fromEntries(t.options.map(o=>[o.name,o.optionValues.map(s=>s.name).filter(s=>i(o.name,s))])),isUnavailable:i}}var it=500,at=100,st=100,lt="query TetherServerProductById($id:ID!){node(id:$id){... on Product{...TetherProduct}}}",ct="query TetherServerProduct($handle:String!){product(handle:$handle){...TetherProduct}}",ut=()=>`query TetherServerCollection($handle:String!,$first:Int!,$after:String,$sortKey:ProductCollectionSortKeys,$reverse:Boolean,$filters:[ProductFilter!]){collection(handle:$handle){${T()} products(first:$first,after:$after,sortKey:$sortKey,reverse:$reverse,filters:$filters){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}}`,dt="query TetherServerProducts($first:Int!,$after:String,$query:String,$sortKey:ProductSortKeys,$reverse:Boolean){products(first:$first,after:$after,query:$query,sortKey:$sortKey,reverse:$reverse){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}",ft=()=>`query TetherServerCollections($first:Int!,$after:String){collections(first:$first,after:$after){nodes{${T()}}pageInfo{hasNextPage endCursor}}}`,pt=t=>`query TetherServerRecs(${t?"$id: ID!":"$handle: String!"},$intent:ProductRecommendationIntent){productRecommendations(${t?"productId: $id":"productHandle: $handle"},intent:$intent){...TetherProduct}}`,mt=I({product:k(V)}),gt=I({node:k(J)}),yt=I({collections:{nodes:[{handle:"string"}],pageInfo:{hasNextPage:"boolean"}}});async function Pt(t){let e=[],r=null;for(let a=0;a<st;a++){let c=await E(t,ft(),{first:at,after:r},yt);if(e.push(...c.collections.nodes),!c.collections.pageInfo.hasNextPage)break;r=c.collections.pageInfo.endCursor}return e}function Y(t,e){let r=(i,o,s)=>E(t,f=>`${i}
2
2
  ${M(t,f)}`,o,s);async function a(i){let o=C(i);if(!o)return null;if(o.startsWith("gid://")){let{node:f}=await r(lt,{id:o},gt);return f?.id?f:null}return(await r(ct,{handle:o},mt)).product}async function c(i,{first:o=e,after:s=null,sortKey:f,reverse:m=!1,filters:b}){let h=await r(ut(),{handle:i,first:o,after:s,sortKey:f||void 0,reverse:m,filters:b??void 0},B);if(!h.collection)return{collection:null,products:[],pageInfo:{hasNextPage:!1,endCursor:null}};let{products:P,...rt}=h.collection;return{collection:rt,products:P.nodes,pageInfo:P.pageInfo}}async function u(i={}){let{collection:o,query:s,first:f=e,after:m=null,sortKey:b,reverse:h=!1}=i;if(o)return c(o,i);let P=await r(dt,{first:f,after:m,query:s||void 0,sortKey:b||void 0,reverse:h},K);return{collection:null,products:P.products.nodes,pageInfo:P.products.pageInfo}}async function d(i={}){let o=[],s=null;for(let f=0;f<it;f++){let m=await u({...i,first:e,after:s});if(o.push(...m.products),!m.pageInfo.hasNextPage)break;s=m.pageInfo.endCursor}return o}async function n(i,o={}){let s=await u({...o,collection:i});return s.collection?{...s.collection,products:s.products,pageInfo:s.pageInfo}:null}async function l(i,o="RELATED"){let s=C(typeof i=="object"?i?.id:i);if(!s)throw new y("No product for recommendations",{code:"NOT_FOUND"});let f=s.startsWith("gid://");return(await r(pt(f),f?{id:s,intent:o}:{handle:s,intent:o},j)).productRecommendations??[]}return{getProduct:a,getProducts:u,allProducts:d,getCollection:n,allCollections:()=>Pt(t),getRecommendations:l}}var X={size:"https://schema.org/size",color:"https://schema.org/color",colour:"https://schema.org/color",material:"https://schema.org/material"},R=t=>JSON.stringify(t).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029");function W(t){return JSON.parse(JSON.stringify(t))}var Z=t=>t.split("/").pop()??t;function ht(t){return t.availableForSale?t.currentlyNotInStock?"https://schema.org/BackOrder":"https://schema.org/InStock":"https://schema.org/OutOfStock"}function St(t,e){if(!t.requiresSellingPlan)return e.price;let r=O(t).find(a=>v(e,a.id));return(r&&w(e,r.id))??e.price}function tt(t,e,r){let a=St(t,e),c=r?.includes("?")?"&":"?";return{"@type":"Offer",price:a.amount,priceCurrency:a.currencyCode,availability:ht(e),url:r?`${r}${c}variant=${Z(e.id)}`:void 0}}function Ct(t,e,r,a){let c=e.selectedOptions.flatMap(u=>{let d=X[u.name.toLowerCase()];return d?[[d.split("/").pop()??d,u.value]]:[]});return{"@type":"Product",name:`${t.title} - ${e.title}`,sku:e.sku||void 0,image:e.image?.url||a[0],...Object.fromEntries(c),offers:tt(t,e,r)}}function It(t,{url:e},r){if(e)return e;let a=S(r.productPath,t.handle,t.id);if(!(!r.siteUrl||!a))return new URL(a,r.siteUrl).toString()}function N(t,e,r){if(!t)return null;let a=It(t,e,r),c=t.images.nodes.map(i=>i.url).filter(Boolean),u=e.brand||t.vendor,d=u?{"@type":"Brand",name:u}:void 0,n=t.description.trim()||void 0,l=t.variants.nodes;if(l.length<=1){let[i]=l;return W({"@context":"https://schema.org","@type":"Product",name:t.title,description:n,url:a,image:c,sku:i?.sku||void 0,brand:d,offers:i?tt(t,i,a):void 0})}let p=t.options.map(i=>X[i.name.toLowerCase()]).filter(Boolean);return W({"@context":"https://schema.org","@type":"ProductGroup",name:t.title,description:n,url:a,productGroupID:Z(t.id),image:c,brand:d,variesBy:[...new Set(p)],hasVariant:l.map(i=>Ct(t,i,a,c))})}var et=25,vt=2,wt=1;function bt(t,{productPath:e=g.productPath,id:r}={}){return S(e,t,r)}function nt(t,e){for(let r of e){let a=t[r];if(typeof a=="string"&&a)return a}return""}function $t(t){let e={};for(let[u,d]of Object.entries(t))Object.hasOwn(g,u)&&(e[u]=d);let r=typeof t.domain=="string"&&t.domain?t.domain:"",a=typeof t.token=="string"&&t.token?t.token:"",c={...A({...e,domain:r||nt(t,$.domain),token:a||nt(t,$.token)}),pageSize:kt(t.pageSize)};return t.fetch&&(c.fetch=t.fetch),t.siteUrl!==void 0&&(c.siteUrl=t.siteUrl),c}function kt(t){return typeof t=="number"&&Number.isInteger(t)&&t>=1&&t<=250?t:(t!==void 0&&U(`invalid pageSize ${JSON.stringify(t)}: using ${String(et)}`),et)}function Et(t,e){return{...t,description:"",descriptionHtml:"",images:{nodes:t.images.nodes.slice(0,Math.max(1,e))},variants:{nodes:t.variants.nodes.map(r=>({...r,image:null}))}}}function zt(t={}){let e=$t(t);if(!e.domain||!e.token)throw new y("createStorefront needs domain and token: pass them, or import.meta.env with PUBLIC_SHOPIFY_DOMAIN and PUBLIC_SHOPIFY_STOREFRONT_TOKEN",{code:"NOT_CONFIGURED"});let r=Y(e,e.pageSize),a={productPath:e.productPath,siteUrl:e.siteUrl};function c(n,{card:l=!1,images:p=vt}={}){let i=(Array.isArray(n)?n:[n]).filter(s=>s!=null),o={v:wt,at:new Date().toISOString(),country:e.country||null,language:e.language||null,products:l?i.map(s=>Et(s,p)):i};return`<script type="application/json" data-tether-hydrate>${R(o)}<\/script>`}function u(n,l={}){return n?`<script type="application/ld+json">${R(N(n,l,a))}<\/script>`:""}function d(n,l={}){return z(n,{defaultPurchase:e.defaultPurchase,lowStock:e.lowStock,...l})}return{config:e,query:(n,l,p)=>_(e,n,l,p),...r,hydrate:c,formatMoney:(n,l=e.locale)=>x(n,l),formatPercent:(n,l=e.locale)=>D(n,l),imageUrl:L,jsonLd:u,jsonLdData:(n,l={})=>N(n,l,a),initialState:d,productUrl:(n,l={})=>bt(n,{productPath:e.productPath,...l}),plans:q}}export{y as TetherError,zt as createStorefront,x as formatMoney,D as formatPercent,L as imageUrl,z as initialState,q as plans,C as productKey,bt as productUrl,ot as withContext};
@@ -160,6 +160,7 @@
160
160
 
161
161
  // src/account/server-client.ts
162
162
  var known = null;
163
+ var asking = null;
163
164
  function serverBase() {
164
165
  const server = cfg.account?.server;
165
166
  if (!server) {
@@ -211,17 +212,28 @@
211
212
  }
212
213
  return { kind: "answer", data };
213
214
  }
215
+ async function askWhoIsLoggedIn() {
216
+ const answer = await serverFetch("/me");
217
+ return answer.kind === "answer" && answer.data["loggedIn"] === true ? { loggedIn: true, customer: toAccountCustomer(answer.data["customer"]) } : { loggedIn: false };
218
+ }
214
219
  async function serverLogin() {
215
- if (!known) {
216
- const answer = await serverFetch("/me");
217
- known = answer.kind === "answer" && answer.data["loggedIn"] === true ? { loggedIn: true, customer: toAccountCustomer(answer.data["customer"]) } : { loggedIn: false };
220
+ const request = asking ?? (asking = askWhoIsLoggedIn());
221
+ let login2;
222
+ try {
223
+ login2 = await request;
224
+ } catch (error) {
225
+ if (asking === request) asking = null;
226
+ throw error;
218
227
  }
219
- setLoginHint(known.loggedIn);
220
- return known;
228
+ if (asking !== request) return serverLogin();
229
+ known = login2;
230
+ setLoginHint(login2.loggedIn);
231
+ return login2;
221
232
  }
222
233
  var isServerLoggedIn = () => known?.loggedIn === true;
223
234
  function forgetServerLogin() {
224
235
  known = null;
236
+ asking = null;
225
237
  }
226
238
  function navigate(url) {
227
239
  const replacement = cfg.account?.navigate;
@@ -246,7 +258,7 @@
246
258
  }
247
259
  async function serverLogout(returnTo) {
248
260
  const answer = await serverFetch("/logout", { method: "POST", body: { returnTo, cartId: Cart.id() } });
249
- known = null;
261
+ forgetServerLogin();
250
262
  setLoginHint(false);
251
263
  emit("account-logout", {});
252
264
  const logoutUrl = answer.kind === "answer" ? textOrNull(answer.data["logoutUrl"]) : null;
@@ -1 +1 @@
1
- (()=>{var St=Object.defineProperty;var Lt=(t,e)=>{for(var r in e)St(t,r,{get:e[r],enumerable:!0})};var j={};Lt(j,{addresses:()=>ne,customer:()=>F,deleteAddress:()=>se,isLoggedIn:()=>xt,login:()=>At,logout:()=>kt,mountAccount:()=>le,order:()=>ee,orders:()=>Ot,render:()=>U,requestReturn:()=>ce,saveAddress:()=>oe,subscriptionAction:()=>ae,subscriptions:()=>ie,updateProfile:()=>re});var bt=window.Tether.__core["config.ts"],[u,ge,V,pe,we,y,he]=bt;var Et=window.Tether.__core["client.ts"],[xe,Ae,Oe,ke,Te,p,B]=Et;var Rt=window.Tether.__core["dom.ts"],[Se,Le,be,Ee,T,G,P,m,Re,Ie,J,Ne,Ce,ve,Ue,d,R,_e,c,I,$e,A,S]=Rt;var It=window.Tether.__core["cart.ts"],[L]=It;var Nt=window.Tether.__core["lazy.ts"],[K]=Nt;function g(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function a(t,e){return g(t)?t[e]:void 0}function _(t){return Array.isArray(t)?t:[]}function i(t){return typeof t=="string"&&t!==""?t:null}var Ct=t=>typeof t=="number"&&Number.isFinite(t)?t:null,X=t=>Ct(t)??0,N=(t,e)=>_(t).map(r=>e(r)),z=(t,e)=>({nodes:N(a(t,"nodes"),e)}),$=t=>N(t,i).filter(e=>e!==null);function W(t){return t instanceof Error?t.message:String(t)}function Z(t,e,r="localStorage"){try{window[r].setItem(t,e)}catch{}}function q(t,e="localStorage"){try{window[e].removeItem(t)}catch{}}var D=()=>`${u.prefix}:account-hint:${u.domain}`;var Y=t=>t==="in"||t==="expired"||t==="error";function vt(t){let e=i(a(t,"amount")),r=i(a(t,"currencyCode"));return e===null||r===null?null:{amount:e,currencyCode:r}}function Ut(t){let e=i(a(t,"url"));return e===null?null:{url:e,altText:i(a(t,"altText"))}}var _t=t=>({title:i(a(t,"title")),variantTitle:i(a(t,"variantTitle")),quantity:X(a(t,"quantity")),image:Ut(a(t,"image"))}),$t=(t,e)=>({id:e,name:i(a(t,"name")),processedAt:i(a(t,"processedAt")),financialStatus:i(a(t,"financialStatus")),fulfillmentStatus:i(a(t,"fulfillmentStatus")),statusPageUrl:i(a(t,"statusPageUrl")),totalPrice:vt(a(t,"totalPrice")),lineItems:z(a(t,"lineItems"),_t)});function Q(t){let e=[];for(let r of _(t)){let n=i(a(r,"id"));if(n===null)return{kind:"missing-id"};e.push($t(r,n))}return{kind:"read",orders:e}}var qt=t=>new p(`Customer accounts: the answer has no ${t}`);function tt(t){let e=g(t)?t:{},r=i(e.id),n=i(e.email),o=e.address;return{...r===null?{}:{id:r},firstName:i(e.firstName),lastName:i(e.lastName),displayName:i(e.displayName),emailAddress:n===null?null:{emailAddress:n},defaultAddress:Array.isArray(o)?{formatted:$(o)}:null}}function et(t){let e=Q(t);if(e.kind==="missing-id")throw qt("order id");return e.orders}function Dt(t){let e=i(a(t,"message"));if(e===null)return null;let r=a(t,"field");return{message:e,field:Array.isArray(r)?$(r):null,code:i(a(t,"code"))}}var rt=t=>N(t,Dt).filter(e=>e!==null);var x=null;function nt(){let t=u.account?.server;if(!t)throw new p("Customer accounts need the Worker: set account.server",{code:"NOT_CONFIGURED"});return new URL(t,window.location.href).href.replace(/\/$/,"")}function ot(t){t?Z(D(),"1"):q(D())}async function Mt(t){let e;try{e=await t.json()}catch(r){if(r instanceof SyntaxError)return{};throw r}return g(e)?e:{}}async function Ft(t,e){try{return await B(u.requestTimeout,async r=>{let n=await fetch(t,{...e,signal:r});return{response:n,data:await Mt(n)}})}catch(r){throw new p(`Network error: ${W(r)}`,{code:"NETWORK"})}}async function O(t,{method:e="GET",body:r}={}){let n={method:e,credentials:"include"};e==="POST"&&(n.headers={"Content-Type":"application/json","X-Tether-Account":"1"}),r&&(n.body=JSON.stringify(r));let{response:o,data:s}=await Ft(`${nt()}${t}`,n);if(o.status===401)return{kind:"logged-out"};if(!o.ok){let l=i(s.error)??String(o.status),w=rt(s.userErrors);throw new p(`Customer accounts: ${l}`,{status:o.status,...w.length>0&&{userErrors:w},...s.code==="INVALID"&&{code:"INVALID"}})}return{kind:"answer",data:s}}async function C(){if(!x){let t=await O("/me");x=t.kind==="answer"&&t.data.loggedIn===!0?{loggedIn:!0,customer:tt(t.data.customer)}:{loggedIn:!1}}return ot(x.loggedIn),x}var st=()=>x?.loggedIn===!0;function it(){x=null}function at(t){let e=u.account?.navigate;e?e(t):window.location.assign(t)}var jt=t=>t||u.account?.locale||(u.locale||"").split("-")[0]||"";function ct({returnTo:t,locale:e}){let r=new URL(`${nt()}/login`);r.searchParams.set("returnTo",t);let n=jt(e);n&&r.searchParams.set("locale",n),u.country&&r.searchParams.set("country",u.country.toUpperCase()),at(r.toString())}async function ut(){let t=L.id();if(!(await C()).loggedIn||!t)return null;let e=await O("/cart",{method:"POST",body:{cartId:t}});return e.kind==="logged-out"?null:i(e.data.checkoutUrl)}async function dt(t){let e=await O("/logout",{method:"POST",body:{returnTo:t,cartId:L.id()}});x=null,ot(!1),T("account-logout",{});let r=e.kind==="answer"?i(e.data.logoutUrl):null;return r?(at(r),"redirected"):"stayed"}var Ht=window.Tether.__core["shopify-values.ts"],[lt,cr]=Ht;function b(t,e,r){d(t,c(e)).forEach(n=>{let o=m(n,e)??"";Object.hasOwn(r,o)&&S(n,r[o]===!0)})}var mt=(t,e)=>d(t,c(e)).concat(t.matches(c(e))?[t]:[]);var k=(t,e)=>Object.hasOwn(t,e)?t[e]:void 0;var Vt=(t,e)=>({title:t.title||t.name||"","variant-title":t.variantTitle||"",quantity:String(t.quantity),price:P(t.price),total:P(t.totalPrice),sku:t.sku||"",returnable:e===null?void 0:String(e)}),Bt=t=>t.tagName==="INPUT";function Gt(t,e,r){b(t,"order-line-show",{returnable:r>0}),d(t,c("return-quantity")).forEach(n=>{Bt(n)&&(n.max=String(r),n.min="0",n.value||(n.value="0"),n.disabled=r<1)}),d(t,`select${c("return-reason")}`).forEach(n=>{n.dataset.tetherFilled!==e.id&&(n.dataset.tetherFilled=e.id,(e.suggestedReturnReasonDefinitions?.nodes??[]).forEach(o=>{n.appendChild(new Option(o.name??"",o.id))}))})}function ft(t,e,r){R(t,e,(n,o)=>{let s=o.id,l=r&&s?r.get(s)??0:null;s&&(n.dataset.tetherLine=s);let w=Vt(o,l);mt(n,"order-line").forEach(h=>{let E=m(h,"order-line")??"";if(E==="image"){o.image&&I(h,o.image.url,o.image.altText||o.title||"");return}let H=k(w,E);H!==void 0&&A(h,H)}),s&&l!==null&&Gt(n,{...o,id:s},l)})}var M=10,v=50,gt=t=>typeof t=="number"&&Number.isInteger(t)&&t>=1&&t<=v,Jt=t=>J(t,"limit",{min:1,max:v,fallback:M}),Kt=t=>t.replace(/\?.*$/,"").replace(/^.*\//,"");function Xt(t){let e=u.account?.orderUrl;if(e)return e.replaceAll("{id}",encodeURIComponent(Kt(t.id)));let r=t.statusPageUrl;return r!==null&&lt(r)?r:null}var zt=t=>({name:t.name??"",date:G(t.processedAt),total:P(t.totalPrice),status:t.financialStatus?.toLowerCase(),fulfillment:t.fulfillmentStatus?.toLowerCase(),items:t.lineItems.nodes.map(e=>`${String(e.quantity)}\xD7 ${e.title??""}`).join(", ")});function Wt(t,e){let r=e.lineItems.nodes,n=Xt(e),o=zt(e);d(t,c("order-bind")).forEach(s=>{let l=m(s,"order-bind")??"";if(l==="url"){n&&s.setAttribute("href",n);return}if(l==="image"){let h=r.find(E=>E.image)?.image;h&&I(s,h.url,h.altText||r[0]?.title||"");return}let w=k(o,l);w!==void 0&&A(s,w)}),d(t,c("order-lines")).forEach(s=>{ft(s,r,null)}),m(t,"order-bind")==="url"&&n&&t.setAttribute("href",n)}async function pt(t,e){let r=d(t,c("orders")),n=r[0];if(!n)return;b(t,"show",{"orders-loading":!0,"orders-empty":!1});let o=Jt(n),s;try{s=await e(o)}catch(l){y(l,"orders"),s=null}b(t,"show",{"orders-loading":!1,"orders-empty":s?.length===0}),r.forEach(l=>{R(l,s??[],Wt)})}var Zt=["order","addresses","subscriptions","profile-form","address-form"],xt=st;function At({returnTo:t=window.location.href,locale:e}={}){return new Promise(r=>{ct({returnTo:t,locale:e}),r()})}async function F(){let t=await C();return t.loggedIn?t.customer:null}async function Ot({first:t=M}={}){if(!gt(t))throw new p(`Customer accounts: orders() takes first from 1 to ${String(v)}`,{code:"INVALID"});let e=await O(`/orders?${new URLSearchParams({first:String(t)}).toString()}`);return e.kind==="logged-out"?[]:et(e.data.orders)}async function kt({returnTo:t=u.account?.logoutUrl||`${window.location.origin}/`}={}){await dt(t)==="stayed"&&await U(document)}async function Yt(){try{return(await C()).loggedIn?{kind:"logged-in"}:{kind:"logged-out"}}catch(t){return{kind:"unknown",error:t}}}var wt=t=>Zt.some(e=>d(t,c(e)).length>0);function Qt(t){d(t,c("account-link")).forEach(e=>{e.setAttribute("href",te(m(e,"account-link")))})}function te(t){let e=u.account,r=`https://${u.domain}/account`;return t==="payment"?e?.paymentUrl||e?.subscriptionsUrl||r:t==="subscriptions"&&e?.subscriptionsUrl||r}async function U(t=document){let e=await Yt();e.kind==="unknown"&&y(e.error,"account");let r=e.kind==="logged-in";if(d(t,c("show")).forEach(n=>{let o=m(n,"show");o==="logged-in"&&S(n,r),o==="logged-out"&&S(n,!r)}),Qt(t),e.kind==="unknown"&&wt(t)){(await f()).showUnavailable(t);return}r&&(await Tt(t),await Promise.all([pt(t,n=>Ot({first:n})),wt(t)?f().then(n=>n.renderPages(t)):null]))}async function Tt(t){let e=d(t,c("account-bind"));if(!e.length)return;let r;try{r=await F()}catch(o){y(o,"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(", ")};e.forEach(o=>{let s=k(n,m(o,"account-bind")??"");s!=null&&A(o,s)})}var ht=null;function f(){return ht??(ht=K("account-pages").then(t=>(t.setup({serverFetch:O,customer:F,bindCustomer:Tt,reset:it}),t))),ht}var ee=t=>f().then(e=>e.order(t)),re=t=>f().then(e=>e.updateProfile(t)),ne=()=>f().then(t=>t.addresses()),oe=(t,e)=>f().then(r=>r.saveAddress(t,e)),se=t=>f().then(e=>e.deleteAddress(t)),ie=()=>f().then(t=>t.subscriptions()),ae=(t,e)=>f().then(r=>r.subscriptionAction(t,e)),ce=(t,e)=>f().then(r=>r.requestReturn(t,e));function ue(t){let e=t.target;e instanceof window.Element&&(e.closest(c("account-login"))?(t.preventDefault(),At().catch(r=>{y(r,"login")})):e.closest(c("account-logout"))&&(t.preventDefault(),kt().catch(r=>{y(r,"logout")})))}function de(){let t=new URL(window.location.href),e=t.searchParams.get("account");if(Y(e))switch(t.searchParams.delete("account"),window.history.replaceState(window.history.state,"",t),e){case"in":T("account-login",{});break;case"expired":case"error":T("account-error",{error:e});break}}var yt=!1;async function le(t=document){if(yt){await U(t);return}yt=!0,document.addEventListener("click",ue),de(),L.setCheckoutResolver(ut),await U(t),V("account",xt()?"logged in":"logged out")}function me(t){return g(t)&&g(t.__core)&&g(t.__parts)}function Pt(t,e){let r=Reflect.get(window,"Tether");if(!me(r))throw new Error(`tether.${t}.js runs after the Tether script, which loads it, and needs its window.Tether`);r.__parts[t]=e}Pt("account",j);})();
1
+ (()=>{var Lt=Object.defineProperty;var bt=(t,e)=>{for(var r in e)Lt(t,r,{get:e[r],enumerable:!0})};var V={};bt(V,{addresses:()=>se,customer:()=>H,deleteAddress:()=>ae,isLoggedIn:()=>At,login:()=>kt,logout:()=>Pt,mountAccount:()=>fe,order:()=>ne,orders:()=>Ot,render:()=>U,requestReturn:()=>le,saveAddress:()=>ie,subscriptionAction:()=>ue,subscriptions:()=>ce,updateProfile:()=>oe});var Et=window.Tether.__core["config.ts"],[u,we,G,he,ye,y,xe]=Et;var It=window.Tether.__core["client.ts"],[ke,Oe,Pe,Te,Se,p,J]=It;var Rt=window.Tether.__core["dom.ts"],[be,Ee,Ie,Re,O,K,P,m,Ne,ve,W,Ce,Ue,_e,qe,l,R,$e,c,N,De,x,T]=Rt;var Nt=window.Tether.__core["cart.ts"],[S]=Nt;var vt=window.Tether.__core["lazy.ts"],[X]=vt;function g(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function a(t,e){return g(t)?t[e]:void 0}function _(t){return Array.isArray(t)?t:[]}function i(t){return typeof t=="string"&&t!==""?t:null}var Ct=t=>typeof t=="number"&&Number.isFinite(t)?t:null,z=t=>Ct(t)??0,v=(t,e)=>_(t).map(r=>e(r)),Z=(t,e)=>({nodes:v(a(t,"nodes"),e)}),q=t=>v(t,i).filter(e=>e!==null);function Y(t){return t instanceof Error?t.message:String(t)}function Q(t,e,r="localStorage"){try{window[r].setItem(t,e)}catch{}}function $(t,e="localStorage"){try{window[e].removeItem(t)}catch{}}var D=()=>`${u.prefix}:account-hint:${u.domain}`;var tt=t=>t==="in"||t==="expired"||t==="error";function Ut(t){let e=i(a(t,"amount")),r=i(a(t,"currencyCode"));return e===null||r===null?null:{amount:e,currencyCode:r}}function _t(t){let e=i(a(t,"url"));return e===null?null:{url:e,altText:i(a(t,"altText"))}}var qt=t=>({title:i(a(t,"title")),variantTitle:i(a(t,"variantTitle")),quantity:z(a(t,"quantity")),image:_t(a(t,"image"))}),$t=(t,e)=>({id:e,name:i(a(t,"name")),processedAt:i(a(t,"processedAt")),financialStatus:i(a(t,"financialStatus")),fulfillmentStatus:i(a(t,"fulfillmentStatus")),statusPageUrl:i(a(t,"statusPageUrl")),totalPrice:Ut(a(t,"totalPrice")),lineItems:Z(a(t,"lineItems"),qt)});function et(t){let e=[];for(let r of _(t)){let n=i(a(r,"id"));if(n===null)return{kind:"missing-id"};e.push($t(r,n))}return{kind:"read",orders:e}}var Dt=t=>new p(`Customer accounts: the answer has no ${t}`);function rt(t){let e=g(t)?t:{},r=i(e.id),n=i(e.email),o=e.address;return{...r===null?{}:{id:r},firstName:i(e.firstName),lastName:i(e.lastName),displayName:i(e.displayName),emailAddress:n===null?null:{emailAddress:n},defaultAddress:Array.isArray(o)?{formatted:q(o)}:null}}function nt(t){let e=et(t);if(e.kind==="missing-id")throw Dt("order id");return e.orders}function Mt(t){let e=i(a(t,"message"));if(e===null)return null;let r=a(t,"field");return{message:e,field:Array.isArray(r)?q(r):null,code:i(a(t,"code"))}}var ot=t=>v(t,Mt).filter(e=>e!==null);var M=null,L=null;function st(){let t=u.account?.server;if(!t)throw new p("Customer accounts need the Worker: set account.server",{code:"NOT_CONFIGURED"});return new URL(t,window.location.href).href.replace(/\/$/,"")}function it(t){t?Q(D(),"1"):$(D())}async function Ft(t){let e;try{e=await t.json()}catch(r){if(r instanceof SyntaxError)return{};throw r}return g(e)?e:{}}async function jt(t,e){try{return await J(u.requestTimeout,async r=>{let n=await fetch(t,{...e,signal:r});return{response:n,data:await Ft(n)}})}catch(r){throw new p(`Network error: ${Y(r)}`,{code:"NETWORK"})}}async function A(t,{method:e="GET",body:r}={}){let n={method:e,credentials:"include"};e==="POST"&&(n.headers={"Content-Type":"application/json","X-Tether-Account":"1"}),r&&(n.body=JSON.stringify(r));let{response:o,data:s}=await jt(`${st()}${t}`,n);if(o.status===401)return{kind:"logged-out"};if(!o.ok){let d=i(s.error)??String(o.status),w=ot(s.userErrors);throw new p(`Customer accounts: ${d}`,{status:o.status,...w.length>0&&{userErrors:w},...s.code==="INVALID"&&{code:"INVALID"}})}return{kind:"answer",data:s}}async function Ht(){let t=await A("/me");return t.kind==="answer"&&t.data.loggedIn===!0?{loggedIn:!0,customer:rt(t.data.customer)}:{loggedIn:!1}}async function b(){let t=L??(L=Ht()),e;try{e=await t}catch(r){throw L===t&&(L=null),r}return L!==t?b():(M=e,it(e.loggedIn),e)}var at=()=>M?.loggedIn===!0;function F(){M=null,L=null}function ct(t){let e=u.account?.navigate;e?e(t):window.location.assign(t)}var Vt=t=>t||u.account?.locale||(u.locale||"").split("-")[0]||"";function ut({returnTo:t,locale:e}){let r=new URL(`${st()}/login`);r.searchParams.set("returnTo",t);let n=Vt(e);n&&r.searchParams.set("locale",n),u.country&&r.searchParams.set("country",u.country.toUpperCase()),ct(r.toString())}async function lt(){let t=S.id();if(!(await b()).loggedIn||!t)return null;let e=await A("/cart",{method:"POST",body:{cartId:t}});return e.kind==="logged-out"?null:i(e.data.checkoutUrl)}async function dt(t){let e=await A("/logout",{method:"POST",body:{returnTo:t,cartId:S.id()}});F(),it(!1),O("account-logout",{});let r=e.kind==="answer"?i(e.data.logoutUrl):null;return r?(ct(r),"redirected"):"stayed"}var Bt=window.Tether.__core["shopify-values.ts"],[mt,lr]=Bt;function E(t,e,r){l(t,c(e)).forEach(n=>{let o=m(n,e)??"";Object.hasOwn(r,o)&&T(n,r[o]===!0)})}var ft=(t,e)=>l(t,c(e)).concat(t.matches(c(e))?[t]:[]);var k=(t,e)=>Object.hasOwn(t,e)?t[e]:void 0;var Gt=(t,e)=>({title:t.title||t.name||"","variant-title":t.variantTitle||"",quantity:String(t.quantity),price:P(t.price),total:P(t.totalPrice),sku:t.sku||"",returnable:e===null?void 0:String(e)}),Jt=t=>t.tagName==="INPUT";function Kt(t,e,r){E(t,"order-line-show",{returnable:r>0}),l(t,c("return-quantity")).forEach(n=>{Jt(n)&&(n.max=String(r),n.min="0",n.value||(n.value="0"),n.disabled=r<1)}),l(t,`select${c("return-reason")}`).forEach(n=>{n.dataset.tetherFilled!==e.id&&(n.dataset.tetherFilled=e.id,(e.suggestedReturnReasonDefinitions?.nodes??[]).forEach(o=>{n.appendChild(new Option(o.name??"",o.id))}))})}function gt(t,e,r){R(t,e,(n,o)=>{let s=o.id,d=r&&s?r.get(s)??0:null;s&&(n.dataset.tetherLine=s);let w=Gt(o,d);ft(n,"order-line").forEach(h=>{let I=m(h,"order-line")??"";if(I==="image"){o.image&&N(h,o.image.url,o.image.altText||o.title||"");return}let B=k(w,I);B!==void 0&&x(h,B)}),s&&d!==null&&Kt(n,{...o,id:s},d)})}var j=10,C=50,pt=t=>typeof t=="number"&&Number.isInteger(t)&&t>=1&&t<=C,Wt=t=>W(t,"limit",{min:1,max:C,fallback:j}),Xt=t=>t.replace(/\?.*$/,"").replace(/^.*\//,"");function zt(t){let e=u.account?.orderUrl;if(e)return e.replaceAll("{id}",encodeURIComponent(Xt(t.id)));let r=t.statusPageUrl;return r!==null&&mt(r)?r:null}var Zt=t=>({name:t.name??"",date:K(t.processedAt),total:P(t.totalPrice),status:t.financialStatus?.toLowerCase(),fulfillment:t.fulfillmentStatus?.toLowerCase(),items:t.lineItems.nodes.map(e=>`${String(e.quantity)}\xD7 ${e.title??""}`).join(", ")});function Yt(t,e){let r=e.lineItems.nodes,n=zt(e),o=Zt(e);l(t,c("order-bind")).forEach(s=>{let d=m(s,"order-bind")??"";if(d==="url"){n&&s.setAttribute("href",n);return}if(d==="image"){let h=r.find(I=>I.image)?.image;h&&N(s,h.url,h.altText||r[0]?.title||"");return}let w=k(o,d);w!==void 0&&x(s,w)}),l(t,c("order-lines")).forEach(s=>{gt(s,r,null)}),m(t,"order-bind")==="url"&&n&&t.setAttribute("href",n)}async function wt(t,e){let r=l(t,c("orders")),n=r[0];if(!n)return;E(t,"show",{"orders-loading":!0,"orders-empty":!1});let o=Wt(n),s;try{s=await e(o)}catch(d){y(d,"orders"),s=null}E(t,"show",{"orders-loading":!1,"orders-empty":s?.length===0}),r.forEach(d=>{R(d,s??[],Yt)})}var Qt=["order","addresses","subscriptions","profile-form","address-form"],At=at;function kt({returnTo:t=window.location.href,locale:e}={}){return new Promise(r=>{ut({returnTo:t,locale:e}),r()})}async function H(){let t=await b();return t.loggedIn?t.customer:null}async function Ot({first:t=j}={}){if(!pt(t))throw new p(`Customer accounts: orders() takes first from 1 to ${String(C)}`,{code:"INVALID"});let e=await A(`/orders?${new URLSearchParams({first:String(t)}).toString()}`);return e.kind==="logged-out"?[]:nt(e.data.orders)}async function Pt({returnTo:t=u.account?.logoutUrl||`${window.location.origin}/`}={}){await dt(t)==="stayed"&&await U(document)}async function te(){try{return(await b()).loggedIn?{kind:"logged-in"}:{kind:"logged-out"}}catch(t){return{kind:"unknown",error:t}}}var ht=t=>Qt.some(e=>l(t,c(e)).length>0);function ee(t){l(t,c("account-link")).forEach(e=>{e.setAttribute("href",re(m(e,"account-link")))})}function re(t){let e=u.account,r=`https://${u.domain}/account`;return t==="payment"?e?.paymentUrl||e?.subscriptionsUrl||r:t==="subscriptions"&&e?.subscriptionsUrl||r}async function U(t=document){let e=await te();e.kind==="unknown"&&y(e.error,"account");let r=e.kind==="logged-in";if(l(t,c("show")).forEach(n=>{let o=m(n,"show");o==="logged-in"&&T(n,r),o==="logged-out"&&T(n,!r)}),ee(t),e.kind==="unknown"&&ht(t)){(await f()).showUnavailable(t);return}r&&(await Tt(t),await Promise.all([wt(t,n=>Ot({first:n})),ht(t)?f().then(n=>n.renderPages(t)):null]))}async function Tt(t){let e=l(t,c("account-bind"));if(!e.length)return;let r;try{r=await H()}catch(o){y(o,"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(", ")};e.forEach(o=>{let s=k(n,m(o,"account-bind")??"");s!=null&&x(o,s)})}var yt=null;function f(){return yt??(yt=X("account-pages").then(t=>(t.setup({serverFetch:A,customer:H,bindCustomer:Tt,reset:F}),t))),yt}var ne=t=>f().then(e=>e.order(t)),oe=t=>f().then(e=>e.updateProfile(t)),se=()=>f().then(t=>t.addresses()),ie=(t,e)=>f().then(r=>r.saveAddress(t,e)),ae=t=>f().then(e=>e.deleteAddress(t)),ce=()=>f().then(t=>t.subscriptions()),ue=(t,e)=>f().then(r=>r.subscriptionAction(t,e)),le=(t,e)=>f().then(r=>r.requestReturn(t,e));function de(t){let e=t.target;e instanceof window.Element&&(e.closest(c("account-login"))?(t.preventDefault(),kt().catch(r=>{y(r,"login")})):e.closest(c("account-logout"))&&(t.preventDefault(),Pt().catch(r=>{y(r,"logout")})))}function me(){let t=new URL(window.location.href),e=t.searchParams.get("account");if(tt(e))switch(t.searchParams.delete("account"),window.history.replaceState(window.history.state,"",t),e){case"in":O("account-login",{});break;case"expired":case"error":O("account-error",{error:e});break}}var xt=!1;async function fe(t=document){if(xt){await U(t);return}xt=!0,document.addEventListener("click",de),me(),S.setCheckoutResolver(lt),await U(t),G("account",At()?"logged in":"logged out")}function ge(t){return g(t)&&g(t.__core)&&g(t.__parts)}function St(t,e){let r=Reflect.get(window,"Tether");if(!ge(r))throw new Error(`tether.${t}.js runs after the Tether script, which loads it, and needs its window.Tether`);r.__parts[t]=e}St("account",V);})();
package/dist/tether.js CHANGED
@@ -507,6 +507,14 @@
507
507
  warn("onError threw", hookError);
508
508
  }
509
509
  }
510
+ function callHook(name, hook2, fallback) {
511
+ try {
512
+ return hook2();
513
+ } catch (error) {
514
+ reportError(error, name);
515
+ return fallback?.();
516
+ }
517
+ }
510
518
 
511
519
  // server/src/shared/error-message.ts
512
520
  function messageOf(error) {
@@ -1035,12 +1043,13 @@
1035
1043
  done();
1036
1044
  return;
1037
1045
  }
1038
- try {
1039
- onLeave(node, done);
1040
- } catch (error) {
1041
- reportError(error, "repeater onLeave");
1042
- done();
1043
- }
1046
+ callHook(
1047
+ "repeater onLeave",
1048
+ () => {
1049
+ onLeave(node, done);
1050
+ },
1051
+ done
1052
+ );
1044
1053
  }
1045
1054
  function insertFresh(container, wanted, fresh, onEnter) {
1046
1055
  wanted.forEach((node, index) => {
@@ -1049,11 +1058,9 @@
1049
1058
  if (previous?.parentNode === container) previous.after(node);
1050
1059
  else container.prepend(node);
1051
1060
  if (!onEnter) return;
1052
- try {
1061
+ callHook("repeater onEnter", () => {
1053
1062
  onEnter(node);
1054
- } catch (error) {
1055
- reportError(error, "repeater onEnter");
1056
- }
1063
+ });
1057
1064
  });
1058
1065
  }
1059
1066
  function repeatKeyed(container, items, keyOf, render2, { onEnter, onLeave } = {}) {
@@ -1125,8 +1132,9 @@
1125
1132
  }
1126
1133
  function formatMoney2(money) {
1127
1134
  if (!money) return "";
1128
- if (cfg.formatMoney) return cfg.formatMoney(money, cfg.locale);
1129
- return formatMoney(money, cfg.locale);
1135
+ const { formatMoney: siteFormat, locale } = cfg;
1136
+ const builtIn = () => formatMoney(money, locale);
1137
+ return siteFormat ? callHook("formatMoney", () => siteFormat(money, locale), builtIn) : builtIn();
1130
1138
  }
1131
1139
  function formatDate(iso) {
1132
1140
  if (!iso) return "";
@@ -1146,13 +1154,8 @@
1146
1154
  function setTextTracked(el, value) {
1147
1155
  const before = readText(el);
1148
1156
  setText(el, value);
1149
- if (before !== readText(el) && el.hasAttribute(SEEN) && cfg.onValueChange) {
1150
- try {
1151
- cfg.onValueChange(el, before);
1152
- } catch (error) {
1153
- reportError(error, "onValueChange");
1154
- }
1155
- }
1157
+ if (before !== readText(el) && el.hasAttribute(SEEN))
1158
+ callHook("onValueChange", () => cfg.onValueChange?.(el, before));
1156
1159
  el.setAttribute(SEEN, "1");
1157
1160
  }
1158
1161
  function reveal(el) {
@@ -1238,12 +1241,10 @@
1238
1241
  function notifyLayoutChanged(reason) {
1239
1242
  clearTimeout(layoutTimer);
1240
1243
  layoutTimer = setTimeout(() => {
1241
- try {
1244
+ callHook("layout-changed", () => {
1242
1245
  if (cfg.onLayoutChange) cfg.onLayoutChange(reason);
1243
1246
  else refreshScrollTrigger();
1244
- } catch (error) {
1245
- reportError(error, "layout-changed");
1246
- }
1247
+ });
1247
1248
  emit("layout-changed", { reason });
1248
1249
  }, LAYOUT_DEBOUNCE_MS);
1249
1250
  }
@@ -1530,13 +1531,6 @@
1530
1531
  var announcedOpen = false;
1531
1532
  var returnFocus = null;
1532
1533
  var classWatcher = null;
1533
- function callHook(hook2, drawers2, name) {
1534
- try {
1535
- hook2?.(drawers2);
1536
- } catch (error) {
1537
- reportError(error, name);
1538
- }
1539
- }
1540
1534
  var isFocusable = (el) => el !== null && "focus" in el;
1541
1535
  var focusables = (drawer) => qsa(drawer, FOCUSABLE).filter((el) => el.offsetParent !== null || el === document.activeElement);
1542
1536
  var drawers = () => qsa(document, sel("cart-drawer"));
@@ -1588,7 +1582,7 @@
1588
1582
  focusInto(first);
1589
1583
  }, FOCUS_AFTER_OPEN_MS);
1590
1584
  }
1591
- callHook(cfg.onCartOpen, opened, "onCartOpen");
1585
+ callHook("onCartOpen", () => cfg.onCartOpen?.(opened));
1592
1586
  emit("cart-toggled", { open: true });
1593
1587
  }
1594
1588
  function announceClosed(all, hadFocus) {
@@ -1596,7 +1590,7 @@
1596
1590
  syncDrawerAria();
1597
1591
  if (hadFocus && returnFocus?.isConnected) returnFocus.focus({ preventScroll: true });
1598
1592
  returnFocus = null;
1599
- callHook(cfg.onCartClose, all, "onCartClose");
1593
+ callHook("onCartClose", () => cfg.onCartClose?.(all));
1600
1594
  emit("cart-toggled", { open: false });
1601
1595
  }
1602
1596
  function openCart() {
@@ -1604,7 +1598,7 @@
1604
1598
  const all = drawers();
1605
1599
  const opened = all.filter((drawer) => !isManual(drawer));
1606
1600
  if (all.length && !opened.length) return;
1607
- openWithoutDrawer = true;
1601
+ openWithoutDrawer = !all.length;
1608
1602
  opened.forEach((drawer) => {
1609
1603
  drawer.classList.add(cfg.cartDrawerOpenClass);
1610
1604
  });
@@ -2151,6 +2145,22 @@
2151
2145
  // server/src/shared/cart-id.ts
2152
2146
  var CART_ID = /^gid:\/\/shopify\/Cart\/[\w-]+(\?key=[\w-]+)?$/;
2153
2147
 
2148
+ // server/src/shared/serial.ts
2149
+ function createSerialQueue() {
2150
+ let tail = Promise.resolve();
2151
+ let pending2 = 0;
2152
+ const settled = () => {
2153
+ pending2--;
2154
+ };
2155
+ const run = (task) => {
2156
+ pending2++;
2157
+ const result = tail.then(task);
2158
+ tail = result.then(settled, settled);
2159
+ return result;
2160
+ };
2161
+ return Object.assign(run, { idle: () => !pending2 });
2162
+ }
2163
+
2154
2164
  // src/cart/store.ts
2155
2165
  var status = { kind: "unknown" };
2156
2166
  var warnings = [];
@@ -2216,19 +2226,15 @@
2216
2226
  if (count !== null) showSavedCount(count);
2217
2227
  }
2218
2228
  function setWarnings(notes) {
2219
- warnings = notes.filter((note, index) => notes.findIndex((other) => other.message === note.message) === index).map((note) => ({ ...note, message: cfg.warningText?.(note) || note.message }));
2229
+ const siteText = (note) => callHook(
2230
+ "warningText",
2231
+ () => cfg.warningText?.(note),
2232
+ () => null
2233
+ );
2234
+ warnings = notes.filter((note, index) => notes.findIndex((other) => other.message === note.message) === index).map((note) => ({ ...note, message: siteText(note) || note.message }));
2220
2235
  if (warnings.length) emit("cart-warning", { warnings });
2221
2236
  }
2222
- var waitOnly = () => void 0;
2223
- function serial() {
2224
- let previous = Promise.resolve();
2225
- return (task) => {
2226
- const run = previous.then(task);
2227
- previous = run.then(waitOnly, waitOnly);
2228
- return run;
2229
- };
2230
- }
2231
- var runInOrder = serial();
2237
+ var runInOrder = createSerialQueue();
2232
2238
  function enqueue(task) {
2233
2239
  return runInOrder(task).then(
2234
2240
  (value) => {
@@ -2408,7 +2414,7 @@
2408
2414
  return cart && !cart.totalQuantity ? null : savedCartId();
2409
2415
  }
2410
2416
  async function checkout(target = cfg.checkoutTarget) {
2411
- if (!cartToCheckOut()) return null;
2417
+ if (runInOrder.idle() && !cartToCheckOut()) return null;
2412
2418
  const tab = target === "_blank" ? window.open("", "_blank") : null;
2413
2419
  if (tab) detachOpenerIfAllowed(tab);
2414
2420
  try {
@@ -2487,7 +2493,7 @@
2487
2493
  toAttributes(attributes).forEach((attribute) => merged.set(attribute.key, attribute.value));
2488
2494
  return [...merged].filter(([, value]) => value !== "").map(([key, value]) => ({ key, value }));
2489
2495
  }
2490
- async function init() {
2496
+ async function load() {
2491
2497
  const id = savedCartId();
2492
2498
  if (!id) {
2493
2499
  settleLoad({ kind: "loaded", cart: null });
@@ -2506,7 +2512,8 @@
2506
2512
  return currentCart();
2507
2513
  }
2508
2514
  var Cart = {
2509
- init,
2515
+ /** Loads the saved cart in the queue, so a change Shopify answers meanwhile isn't replaced by an older answer. */
2516
+ init: () => runInOrder(load),
2510
2517
  /** The saved cart's id. */
2511
2518
  id: savedCartId,
2512
2519
  get status() {
@@ -3590,7 +3597,7 @@
3590
3597
  }
3591
3598
 
3592
3599
  // src/part-integrity.ts
3593
- var PART_INTEGRITY = { "tether.diagnose.js": "sha384-CqtXzvWbLD8aIgyTM43+KMXEFA7r7lhG+0XyQAw3Sp7B5qrzPsxlA9QfzBjoPqZz", "tether.markets.js": "sha384-WjowbRhM7OzzZOrCPZWSZqN7EjIiiR7u9cGmdI+9kgFVgmEQS8lVGWjgx+8jILOf", "tether.search.js": "sha384-fLQ7eKc5XOv0Cg2FfrZyeFAkRR4wDMjUWFpwvKrfPRnT2NvTuhKg80+KVu8Qce/G", "tether.lists.js": "sha384-l2uyr96zTetjo2WWhGsBamd1ZYkC3OB3G3+OScLEvxdok0c8k9GXLAh1WRALUr4S", "tether.extras.js": "sha384-qx7paZ/rjwtn1Yy9TgszulmBuJsIQ9y4eZ590AArnZ+IDB8IzwJ5dNOFJ+yMHPdb", "tether.account.js": "sha384-XUPSX/7R9chq2KlQ1RzLiV7jYcWGe7o5tj4rLZMnf8MEa2aDOOCW2269Bj/ZkbmX", "tether.account-pages.js": "sha384-ND3kIaRypgnHG3QMDb8CqDxt7fuukDCdHsIAHoOUUsz3+FjvBqXgRDV4Mjp6x8jr", "tether.analytics.js": "sha384-jnLesn/+edWBSPuXLj7VX1kSAGwEqtb0VbHjuU//ofqgxkndHlDFsS8Bc8htlGt8" };
3600
+ var PART_INTEGRITY = { "tether.diagnose.js": "sha384-CqtXzvWbLD8aIgyTM43+KMXEFA7r7lhG+0XyQAw3Sp7B5qrzPsxlA9QfzBjoPqZz", "tether.markets.js": "sha384-WjowbRhM7OzzZOrCPZWSZqN7EjIiiR7u9cGmdI+9kgFVgmEQS8lVGWjgx+8jILOf", "tether.search.js": "sha384-fLQ7eKc5XOv0Cg2FfrZyeFAkRR4wDMjUWFpwvKrfPRnT2NvTuhKg80+KVu8Qce/G", "tether.lists.js": "sha384-l2uyr96zTetjo2WWhGsBamd1ZYkC3OB3G3+OScLEvxdok0c8k9GXLAh1WRALUr4S", "tether.extras.js": "sha384-qx7paZ/rjwtn1Yy9TgszulmBuJsIQ9y4eZ590AArnZ+IDB8IzwJ5dNOFJ+yMHPdb", "tether.account.js": "sha384-82dpAxK4rPlXuNxSk/dvaItjRQf+Z79EJnUqXtT9D8HjpF9XwoTIUxDViiV1dIhz", "tether.account-pages.js": "sha384-ND3kIaRypgnHG3QMDb8CqDxt7fuukDCdHsIAHoOUUsz3+FjvBqXgRDV4Mjp6x8jr", "tether.analytics.js": "sha384-jnLesn/+edWBSPuXLj7VX1kSAGwEqtb0VbHjuU//ofqgxkndHlDFsS8Bc8htlGt8" };
3594
3601
 
3595
3602
  // src/part-registry.ts
3596
3603
  function isTetherInternals(value) {
@@ -3598,7 +3605,7 @@
3598
3605
  }
3599
3606
 
3600
3607
  // src/version.ts
3601
- var VERSION = "0.9.6";
3608
+ var VERSION = "0.9.7";
3602
3609
 
3603
3610
  // src/lazy-iife.ts
3604
3611
  var coreModules = {
@@ -3757,7 +3764,7 @@
3757
3764
  }
3758
3765
 
3759
3766
  // src/analytics-queue.ts
3760
- function queueAnalyticsEvents(load) {
3767
+ function queueAnalyticsEvents(load2) {
3761
3768
  const queue = [];
3762
3769
  const listening = new window.AbortController();
3763
3770
  const options = { signal: listening.signal };
@@ -3765,7 +3772,7 @@
3765
3772
  document.addEventListener(`${cfg.prefix}:${name}`, (event) => queue.push(event), options);
3766
3773
  });
3767
3774
  document.addEventListener("astro:page-load", (event) => queue.push(event), options);
3768
- load().then((part) => part.startAnalytics(queue)).catch((error) => {
3775
+ load2().then((part) => part.startAnalytics(queue)).catch((error) => {
3769
3776
  listening.abort();
3770
3777
  queue.length = 0;
3771
3778
  reportError(error, "analytics");
@@ -4166,7 +4173,7 @@
4166
4173
  return cart;
4167
4174
  }
4168
4175
  }
4169
- function init2(overrides = {}) {
4176
+ function init(overrides = {}) {
4170
4177
  if (initPromise && !Object.keys(overrides).length) return initPromise;
4171
4178
  configure({ ...pageConfig(), ...overrides });
4172
4179
  if (!isConfigured()) {
@@ -4220,7 +4227,7 @@
4220
4227
  }
4221
4228
  var publicApi = {
4222
4229
  VERSION,
4223
- init: init2,
4230
+ init,
4224
4231
  mount,
4225
4232
  unmount,
4226
4233
  /** The live config, read-only. */
@@ -4261,7 +4268,7 @@
4261
4268
  const config = pageGlobal("TETHER_CONFIG");
4262
4269
  if (!config || field(config, "autoMount") === false || pageGlobal("TETHER_INTEGRATION")) return;
4263
4270
  const start = () => {
4264
- init2().then(() => mount(document)).catch((error) => {
4271
+ init().then(() => mount(document)).catch((error) => {
4265
4272
  reportError(error, "init");
4266
4273
  });
4267
4274
  };