@occluze/tether 0.6.7 → 0.6.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/README.md +3 -3
  2. package/dist/esm/astro.js +2 -2
  3. package/dist/esm/chunks/account-C3NP6HFB.js +1 -0
  4. package/dist/esm/chunks/account-pages-WLK374FO.js +1 -0
  5. package/dist/esm/chunks/analytics-G3SAWMNL.js +1 -0
  6. package/dist/esm/chunks/chunk-27PJJZGC.js +1 -0
  7. package/dist/esm/chunks/chunk-2FSXS55U.js +1 -0
  8. package/dist/esm/chunks/chunk-FCSWQDVV.js +1 -0
  9. package/dist/esm/chunks/chunk-FOMSMIAM.js +1 -0
  10. package/dist/esm/chunks/chunk-GZJTCLLW.js +1 -0
  11. package/dist/esm/chunks/chunk-HEQILZVR.js +1 -0
  12. package/dist/esm/chunks/chunk-JOOEXYF3.js +4 -0
  13. package/dist/esm/chunks/chunk-MPTQYLSM.js +1 -0
  14. package/dist/esm/chunks/chunk-NEHZ37TU.js +3 -0
  15. package/dist/esm/chunks/chunk-V74KGEJF.js +1 -0
  16. package/dist/esm/chunks/chunk-VT4CDUJJ.js +1 -0
  17. package/dist/esm/chunks/chunk-YJLWX2HK.js +1 -0
  18. package/dist/esm/chunks/diagnose-6VVGZNTY.js +14 -0
  19. package/dist/esm/chunks/extras-GJVRDFM3.js +1 -0
  20. package/dist/esm/chunks/markets-ui-UNB4PTA7.js +1 -0
  21. package/dist/esm/chunks/search-OU75RNQL.js +1 -0
  22. package/dist/esm/index.js +1 -1
  23. package/dist/esm/server.js +2 -1
  24. package/dist/presets/barba.esm.js +56 -36
  25. package/dist/tether.account-pages.js +773 -442
  26. package/dist/tether.account-pages.min.js +1 -1
  27. package/dist/tether.account.js +648 -318
  28. package/dist/tether.account.min.js +1 -1
  29. package/dist/tether.analytics.js +318 -191
  30. package/dist/tether.analytics.min.js +1 -1
  31. package/dist/tether.diagnose.js +331 -242
  32. package/dist/tether.diagnose.min.js +2 -2
  33. package/dist/tether.extras.js +78 -33
  34. package/dist/tether.extras.min.js +1 -1
  35. package/dist/tether.js +3176 -2015
  36. package/dist/tether.markets.js +231 -126
  37. package/dist/tether.markets.min.js +1 -1
  38. package/dist/tether.min.js +0 -0
  39. package/dist/tether.min.js.map +4 -4
  40. package/dist/tether.search.js +221 -126
  41. package/dist/tether.search.min.js +1 -1
  42. package/package.json +23 -4
  43. package/src/account/addresses-view.js +92 -0
  44. package/src/account/browser-session.js +359 -0
  45. package/src/account/markup.js +48 -0
  46. package/src/account/operations.js +180 -0
  47. package/src/account/order-lines.js +96 -0
  48. package/src/account/order-list.js +91 -0
  49. package/src/account/order-page.js +192 -0
  50. package/src/account/page-events.js +288 -0
  51. package/src/account/server-client.js +172 -0
  52. package/src/account/shared.js +111 -0
  53. package/src/account/shopify-auth.js +150 -0
  54. package/src/account/subscriptions-view.js +158 -0
  55. package/src/account-api.js +118 -0
  56. package/src/account-links.js +35 -0
  57. package/src/account-pages.js +69 -298
  58. package/src/account.js +280 -323
  59. package/src/amounts.js +36 -0
  60. package/src/analytics-shopify.js +241 -0
  61. package/src/analytics.js +304 -184
  62. package/src/api-version.js +75 -25
  63. package/src/astro.js +233 -68
  64. package/src/cart/checkout.js +97 -0
  65. package/src/cart/drawer.js +138 -0
  66. package/src/cart/mutations.js +234 -0
  67. package/src/cart/render.js +294 -0
  68. package/src/cart/store.js +326 -0
  69. package/src/cart.js +320 -488
  70. package/src/client.js +214 -78
  71. package/src/collection.js +126 -57
  72. package/src/config.js +323 -59
  73. package/src/controls/cart-controls.js +155 -0
  74. package/src/controls/discount.js +96 -0
  75. package/src/controls/extras.js +63 -0
  76. package/src/controls/navigation.js +83 -0
  77. package/src/diagnose-markup.js +333 -0
  78. package/src/diagnose.js +251 -202
  79. package/src/dom.js +219 -220
  80. package/src/extras.js +119 -37
  81. package/src/fragments.js +115 -22
  82. package/src/images.js +104 -0
  83. package/src/index.js +245 -287
  84. package/src/initial.js +78 -66
  85. package/src/lazy-iife.js +92 -22
  86. package/src/lazy.js +25 -4
  87. package/src/loader.js +263 -124
  88. package/src/market-codes.js +35 -0
  89. package/src/markets-ui.js +169 -55
  90. package/src/markets.js +286 -85
  91. package/src/markup.js +64 -0
  92. package/src/mounting.js +214 -91
  93. package/src/page-market.js +116 -0
  94. package/src/parts/account-pages.js +4 -1
  95. package/src/parts/account.js +4 -1
  96. package/src/parts/analytics.js +4 -1
  97. package/src/parts/diagnose.js +4 -1
  98. package/src/parts/extras.js +4 -1
  99. package/src/parts/markets.js +4 -1
  100. package/src/parts/search.js +4 -1
  101. package/src/presets/barba.js +120 -30
  102. package/src/product-events.js +130 -0
  103. package/src/product-render.js +257 -0
  104. package/src/product-state.js +318 -0
  105. package/src/product.js +233 -459
  106. package/src/repeaters.js +173 -0
  107. package/src/search.js +277 -107
  108. package/src/selling-plans.js +107 -47
  109. package/src/server.js +168 -205
  110. package/src/shopify-values.js +89 -0
  111. package/src/status.js +99 -39
  112. package/src/store-html.js +0 -0
  113. package/src/storefront/catalog.js +199 -0
  114. package/src/storefront/json-ld.js +167 -0
  115. package/src/variant-render.js +165 -0
  116. package/types/astro.d.ts +13 -2
  117. package/types/index.d.ts +178 -27
  118. package/types/server.d.ts +89 -17
  119. package/dist/esm/chunks/account-Q6E2TFEV.js +0 -1
  120. package/dist/esm/chunks/account-pages-UZXR4R5F.js +0 -1
  121. package/dist/esm/chunks/analytics-IJBKATUP.js +0 -1
  122. package/dist/esm/chunks/chunk-4QJKLPYR.js +0 -1
  123. package/dist/esm/chunks/chunk-64TUD3QR.js +0 -1
  124. package/dist/esm/chunks/chunk-AJLPU2JC.js +0 -4
  125. package/dist/esm/chunks/chunk-FIOZPPC5.js +0 -1
  126. package/dist/esm/chunks/chunk-K2YEQAIH.js +0 -1
  127. package/dist/esm/chunks/chunk-KIDH76B7.js +0 -1
  128. package/dist/esm/chunks/chunk-PAYT5ZD7.js +0 -1
  129. package/dist/esm/chunks/chunk-RREHGH4A.js +0 -1
  130. package/dist/esm/chunks/chunk-SSJT43CJ.js +0 -1
  131. package/dist/esm/chunks/chunk-VC46IEJQ.js +0 -1
  132. package/dist/esm/chunks/diagnose-3WVAWNTX.js +0 -14
  133. package/dist/esm/chunks/extras-7I7WJX35.js +0 -1
  134. package/dist/esm/chunks/markets-ui-545XLFTE.js +0 -1
  135. package/dist/esm/chunks/search-NILMGYXG.js +0 -1
@@ -1,4 +1,4 @@
1
- (()=>{var j=Object.defineProperty;var R=(e,t)=>{for(var o in t)j(e,o,{get:t[o],enumerable:!0})};var P={};R(P,{apiVersionStatus:()=>E,checkMarkup:()=>O,diagnose:()=>se,didYouMean:()=>w});var B=window.Tether.__core["config.js"],{DEFAULTS:ce,cfg:l,configure:ue,isConfigured:T,log:de,reportError:pe,warn:me}=B;var z=window.Tether.__core["client.js"],{TetherError:he,endpoint:C,gql:v,request:ge,unwrap:ye,withContext:be}=z;var G=window.Tether.__core["dom.js"],{attr:f,busy:$e,cdnUrl:ke,dataKey:Se,emit:ve,formatDate:Ee,formatMoney:xe,formatPercent:Pe,get:g,has:Te,hasTemplate:_,imageUrl:Ce,notifyLayoutChanged:_e,parseJSONAttr:Ae,productUrl:qe,qsa:d,readText:Ue,repeat:Me,repeatKeyed:De,sameImage:Ne,scoped:Ve,sel:c,setImage:Ie,setSelected:Le,setText:Oe,setTextTracked:je,show:Re,toAttributes:Be,watchImages:ze}=G;var Y=window.Tether.__core["loader.js"],{clearProductCache:Ye,getProduct:A,getProducts:He,getRecommendations:Ke,hydrateProducts:We,normalizeProductKey:Fe,primeProduct:Je,refreshProducts:Ze,takeStale:Xe}=Y;var H=window.Tether.__core["selling-plans.js"],{GID:et,allPlans:q,allocationFor:tt,findPlan:ot,hasPlans:nt,planAdjustment:rt,planCheckoutCharge:at,planPrice:st,planSavings:it,plansForVariant:lt,toGid:ct}=H;var K=window.Tether.__core["status.js"],{STATUS_KEYS:dt,boundary:U,isNotFound:pt,ownedBy:mt,resolveProductKey:$,setScopeStatus:ft}=K;var D=e=>{let t=/^(\d{4})-(01|04|07|10)$/.exec(String(e||""));return t?{y:+t[1],m:+t[2]}:null},W=(e,t)=>`${e}-${String(t).padStart(2,"0")}`;function M(e,t=1){let o=D(e);if(!o)throw new Error(`not a quarterly Shopify API version: ${e}`);let a=o.y*4+(o.m-1)/3+t;return W(Math.floor(a/4),a%4*3+1)}function E(e,t=new Date){if(e==="unstable")return{version:e,ok:!1,note:'"unstable" changes without notice: pin a dated version such as 2026-07'};let o=D(e);if(!o)return{version:e,ok:!1,note:"not a quarterly version (YYYY-01, -04, -07 or -10)"};let a=new Date(Date.UTC(o.y,o.m-1,1)),n=new Date(Date.UTC(o.y+1,o.m-1,1)),p=(n-t)/(30.44*24*3600*1e3),i=`supported until about ${n.toISOString().slice(0,7)}`;return a>t?i="not released yet (release candidate at best)":p<=0?i="no longer supported: Shopify falls back to the oldest supported version. Upgrade (see README)":p<3&&(i=`${i}: plan the upgrade to ${M(e)} or later (see README)`),{version:e,ok:a<=t&&p>0,monthsLeft:Math.round(p),next:M(e),note:i}}var F=/^[A-Z]{2}$/,J=new Set(["PT_BR","PT_PT","ZH_CN","ZH_TW"]),Z=()=>`${l.prefix}:market:${l.domain}`,X=()=>({document:typeof document<"u"?document:null,location:typeof window<"u"?window.location:null,storage:(()=>{try{return window.localStorage}catch{return null}})(),global:typeof window<"u"?window:{}});function Q(e){let t=String(e||"").trim().toUpperCase();return F.test(t)&&t!=="XX"&&t!=="T1"?t:null}function ee(e){let t=String(e||"").trim().replace("-","_").toUpperCase();if(!t)return null;if(J.has(t))return t;let o=t.split("_")[0];return/^[A-Z]{2,3}$/.test(o)?o:null}function te(e,t){if(!e||!t)return null;let o=String(e.cookie||"").split(";").map(a=>a.trim()).find(a=>a.startsWith(`${t}=`));return o?decodeURIComponent(o.slice(t.length+1)):null}var x=(e,t)=>{if(!e||!t)return null;let o=String(t).toLowerCase(),a=Object.keys(e).find(n=>n.toLowerCase()===o);return a?e[a]:null},oe={saved(e,t){if(e.remember===!1||!t.storage)return null;try{return JSON.parse(t.storage.getItem(Z())||"null")}catch{return null}},server(e,t){let o=p=>t.document?.querySelector?.(`meta[name="${p}"]`)?.getAttribute("content"),a=t.global.TETHER_COUNTRY||o("tether-country")||te(t.document,e.cookie||"tether_country"),n=t.global.TETHER_LANGUAGE||o("tether-language");return{country:a,language:n}},webflow(e,t){let o=(t.location?.pathname||"/").split("/").filter(Boolean)[0],a=x(e.locales,o);if(a)return a;let n=t.document?.documentElement?.getAttribute("lang");if(!n)return null;let p=x(e.locales,n)||x(e.locales,n.split("-")[0]);if(p)return{locale:n,...p};if(e.locales&&e.strict)return null;let i=n.split("-")[1];return{language:n,country:i&&i.length===2?i:null,locale:n}}};function N(e=l.markets,t=X()){let o=e||{};if(o.detect===!1)return{};let a=o.detect?o.detect===!0?["saved","server","webflow"]:[].concat(o.detect):["saved"];e=o;let n={sources:{}};return a.forEach(p=>{let i=oe[p]?.(e,t);if(!i)return;let b={country:Q(i.country),language:ee(i.language),locale:i.locale||null};Object.entries(b).forEach(([r,s])=>{s&&!n[r]&&(n[r]=s,n.sources[r]=p)})}),n}var V=new Set(["in-stock","out-of-stock","backorder","low-stock","plenty-in-stock","on-sale","not-on-sale","has-variants","single-variant","subscription-available","subscription-unavailable","subscription-only","one-time-available","subscription-selected","one-time-selected","has-savings","loading","ready","error","not-found","cart-empty","cart-filled","cart-has-subscription","cart-no-subscription","cart-has-discount","cart-error","cart-warning","list-empty","list-filled","search-empty","search-results","logged-in","logged-out","orders-empty","orders-loading","addresses-loading","addresses-empty","addresses-error","subscriptions-loading","subscriptions-empty","subscriptions-error"]),I=new Set(["title","description","description-text","vendor","type","handle","published-at","price","total-price","compare-at-price","unit-price","min-price","max-price","discount-percentage","discount-amount","variant-title","variant-id","sku","barcode","stock","quantity","featured-image","variant-image","images","tags","link","url","one-time-price","subscription-price","subscription-savings","subscription-savings-amount","checkout-charge","plan-name","plan-description","plan-group","option-value","swatch","image"]),L=new Set(`account account-bind account-link account-login account-logout add-label add-to-cart adding-text
1
+ "use strict";(()=>{var q=Object.defineProperty;var H=(e,n)=>{for(var t in n)q(e,t,{get:n[t],enumerable:!0})};var E={};H(E,{apiVersionStatus:()=>b,checkMarkup:()=>w,diagnose:()=>be,didYouMean:()=>f});var j=window.Tether.__core["config.js"],{DEFAULTS:Ee,cfg:i,configure:$e,isConfigured:S,log:Se,reportError:ke,resolveConfig:Pe,toMetafieldIdentifier:Te,warn:_e}=j;var G=window.Tether.__core["client.js"],{TetherError:Ae,endpoint:k,gql:P,request:ve,unwrap:Me,withContext:xe}=G;var Y=window.Tether.__core["dom.js"],{attr:p,busy:De,cdnUrl:Ue,emit:Ie,formatDate:Ce,formatMoney:Oe,formatPercent:Ve,get:h,has:qe,hasTemplate:T,imageUrl:He,notifyLayoutChanged:je,parseJSONAttr:Ge,productUrl:Ye,qsa:d,repeat:Be,repeatKeyed:Ke,sameImage:Le,scoped:Qe,sel:l,setImage:We,setSelected:Fe,setStoreHtml:ze,setText:Je,setTextTracked:Xe,show:Ze,toAttributes:et,watchImages:tt}=Y;var B=window.Tether.__core["loader.js"],{clearProductCache:ot,getProduct:_,getProducts:rt,getRecommendations:st,hydrateProducts:at,normalizeProductKey:it,primeProduct:ct,refreshProducts:lt,takeStale:ut}=B;var K=window.Tether.__core["selling-plans.js"],{GID:pt,allPlans:R,allocationFor:ht,findPlan:ft,hasPlans:mt,planAdjustment:gt,planCheckoutCharge:bt,planPrice:yt,planSavings:wt,plansForVariant:Et,toGid:$t}=K;var L=window.Tether.__core["status.js"],{STATUS_KEYS:kt,boundary:A,isNotFound:Pt,ownedBy:Tt,resolveProductKey:g,setScopeStatus:_t}=L;var Q=/^(\d{4})-(01|04|07|10)$/;function M(e){let n=Q.exec(typeof e=="string"?e:"");return n?{year:Number(n[1]),month:Number(n[2])}:null}var W=(e,n)=>`${e}-${String(n).padStart(2,"0")}`;function v(e,n=1){let t=M(e);if(!t)throw new Error(`not a quarterly Shopify API version: ${e}`);let o=t.year*4+(t.month-1)/3+n;return W(Math.floor(o/4),o%4*3+1)}function b(e,n=new Date){if(e==="unstable")return{version:e,ok:!1,note:'"unstable" changes without notice: pin a dated version such as 2026-07'};let t=M(e);if(!t)return{version:e,ok:!1,note:"not a quarterly version (YYYY-01, -04, -07 or -10)"};let o=new Date(Date.UTC(t.year,t.month-1,1)),s=new Date(Date.UTC(t.year,t.month-1+12,1)),r=(s.getTime()-n.getTime())/2630016e3,a=o<=n,c=`supported until about ${s.toISOString().slice(0,7)}`;return a?r<=0?c="no longer supported: Shopify falls back to the oldest supported version. Upgrade (see README)":r<3&&(c=`${c}: plan the upgrade to ${v(e)} or later (see README)`):c="not released yet (release candidate at best)",{version:e,ok:a&&r>0,monthsLeft:Math.round(r),next:v(e),note:c}}var F=window.Tether.__core["lazy.js"],{coreModules:vt,loadPart:x}=F;var N=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"]),D=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"]),U=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
@@ -11,4 +11,4 @@
11
11
  plan-value product products purchase purchase-mode qty qty-minus qty-plus quantity recommendations reverse search
12
12
  search-bind search-collections search-input search-limit search-min search-products search-queries search-results
13
13
  search-state show soldout-text sort state subscribe-text variant variant-select variant-url max-width max-height crop
14
- sig label hydrated busy`.split(/\s+/).filter(Boolean));function ne(e,t){let o=Array.from({length:e.length+1},(a,n)=>[n,...Array(t.length).fill(0)]);for(let a=1;a<=t.length;a++)o[0][a]=a;for(let a=1;a<=e.length;a++)for(let n=1;n<=t.length;n++)o[a][n]=Math.min(o[a-1][n]+1,o[a][n-1]+1,o[a-1][n-1]+(e[a-1]===t[n-1]?0:1));return o[e.length][t.length]}function w(e,t,o=""){let a=null,n=1/0;for(let p of t){let i=ne(String(e),p);i<n&&(n=i,a=p)}return a&&n<=Math.max(2,Math.floor(String(e).length/4))?` Did you mean "${o}${a}"?`:""}var re=e=>e?`${String(e).slice(0,4)}\u2026${String(e).slice(-4)} (${String(e).length} chars)`:"(missing)";function ae(e){let t=e.id?`#${e.id}`:"",o=e.className&&typeof e.className=="string"?`.${e.className.trim().split(/\s+/).slice(0,2).join(".")}`:"";return`<${e.tagName.toLowerCase()}${t}${o}>`}function O(e=document){let t=[],o=(r,s,u)=>t.push({level:r,message:s,element:u?ae(u):void 0,el:u}),a=r=>!!r.closest(c("product")),n=`${c("collection")},${c("products")},${c("recommendations")}`;d(e,c("product")).forEach(r=>{if(r.closest(n)&&r.closest(c("list")))return;let{key:s,fromUrl:u,raw:y}=$(r);y?u&&!s&&o("warn",`${f("product")}="${y}" but this URL has no value for it (e.g. ?handle=my-product).`,r):o("error",`${f("product")} has no value. Bind it to the Shopify handle (CMS field), or use "url:handle".`,r)}),["bind","option-list","option","variant-select","add-to-cart","purchase","plan-list","plan","qty","line-attribute"].forEach(r=>{d(e,c(r)).forEach(s=>{a(s)||r==="line-attribute"&&s.closest(c("group"))||o("warn",`${f(r)} outside any ${f("product")}: it does nothing here.`,s)})}),d(e,c("group-add")).forEach(r=>{r.closest(c("group"))||o("warn",`${f("group-add")} outside a ${f("group")}.`,r)}),["option-list","plan-list","cart-lines","list"].forEach(r=>d(e,c(r)).forEach(s=>{!s.firstElementChild&&!_(s)&&o("warn",`${f(r)} without a template child: put one example element inside it.`,s)})),d(e,n).forEach(r=>{d(r,c("list")).length||o("error",`List without a ${f("list")} child: products have nowhere to render.`,r)}),d(e,c("show")).forEach(r=>{let s=g(r,"show");V.has(s)||o("warn",`Unknown ${f("show")}="${s}".${w(s,V)}`,r)}),d(e,c("bind")).forEach(r=>{let s=g(r,"bind")||"";!s||I.has(s)||/^image:\d+$/.test(s)||s.startsWith("metafield:")||o("warn",`Unknown ${f("bind")}="${s}": it stays empty.${w(s,I)}`,r)});let i=`${l.prefix}-`,b=new Set;return d(e,"*").forEach(r=>{for(let s of r.attributes){if(!s.name.startsWith(i))continue;let u=s.name.slice(i.length);L.has(u)||b.has(u)||(b.add(u),o("warn",`Unknown attribute ${s.name}: Tether ignores it.${w(u,L,i)}`,r))}}),d(e,c("bind")).forEach(r=>{let s=g(r,"bind")||"";if(!s.startsWith("metafield:"))return;let u=s.slice(10);(l.metafields||[]).some(h=>(typeof h=="string"?h:`${h.namespace}.${h.key}`)===u)||o("error",`${f("bind")}="${s}" but "${u}" is not in config.metafields, so it stays empty.`,r)}),d(e,c("cart-open")).length&&!d(e,c("cart-drawer")).length&&o("warn",`${f("cart-open")} exists but there is no ${f("cart-drawer")} on this page.`),d(e,c("cart-drawer")).length>1&&o("warn",`More than one ${f("cart-drawer")}.`),d(e,`[${f("state")}="error"]`).forEach(r=>{r.matches(U())&&o("error",`Scope failed to load (${g(r,"error")||"error"}).`,r)}),t}async function se({root:e=document,silent:t=!1,version:o,now:a=new Date}={}){let n={version:o,config:{domain:l.domain||"(missing)",token:re(l.token),apiVersion:l.apiVersion,endpoint:l.domain?C():null,country:l.country,language:l.language,locale:l.locale,markets:l.markets||null,prefix:l.prefix,productPath:l.productPath,metafields:l.metafields,autoMount:l.autoMount,observe:l.observe,onError:typeof l.onError=="function"},apiVersion:E(l.apiVersion,a),market:{country:l.country||null,language:l.language||null,locale:l.locale||null,detected:l.markets?.detect?N(l.markets):null},reachable:!1,shop:null,latencyMs:null,products:[],sellingPlans:[],problems:[]};if(!T())n.problems.push({level:"error",message:"TETHER_CONFIG needs domain and token."});else{let p=Date.now();try{let i=await v("query TetherDiagnose { shop { name primaryDomain { url } paymentSettings { currencyCode } } }",{},{context:!1});n.reachable=!0,n.shop={name:i.shop?.name,url:i.shop?.primaryDomain?.url,currency:i.shop?.paymentSettings?.currencyCode}}catch(i){n.problems.push({level:"error",message:`Storefront API not reachable: ${i.message||i.code||"unknown error"}`})}if(n.latencyMs=Date.now()-p,n.reachable){let i=[...new Set(d(e,c("product")).map(r=>$(r).key).filter(Boolean))].slice(0,20);(await Promise.allSettled(i.map(r=>A(r)))).forEach((r,s)=>{if(r.status==="fulfilled"){let u=r.value,y=q(u);n.products.push({key:i[s],handle:u.handle,title:u.title,plans:y.length,requiresSellingPlan:u.requiresSellingPlan}),y.forEach(h=>n.sellingPlans.push({product:u.handle,group:h.group?.name,plan:h.name,id:h.id})),d(e,c("product")).filter(h=>$(h).key===i[s]&&h.querySelector(c("add-to-cart"))).forEach(h=>{let k=new Set(d(h,`${c("option-list")},select${c("option")}`).map(m=>g(m,"option-list")||g(m,"option")));if(!k.size&&d(h,`select${c("variant-select")}`).length)return;let S=(u.options||[]).map(m=>m.name);l.language||[...k].filter(m=>m&&!S.includes(m)).forEach(m=>{n.problems.push({level:"warn",message:`Product "${u.handle}" has no option "${m}" (its options: ${S.join(", ")||"none"}).${w(m,S)}`})}),(u.options||[]).filter(m=>m.optionValues.length>1&&!k.has(m.name)).forEach(m=>{n.problems.push({level:"warn",message:`Product "${u.handle}": option "${m.name}" (${m.optionValues.length} values) has no tether-option-list, so visitors can't choose it.`})})})}else n.products.push({key:i[s],error:r.reason?.message}),n.problems.push({level:"error",message:`Product "${i[s]}": ${r.reason?.message||r.reason?.code||"not loaded"}. Is it published to the Headless channel?`})})}}return(!n.apiVersion.ok||(n.apiVersion.monthsLeft??99)<3)&&n.problems.push({level:n.apiVersion.ok?"warn":"error",message:`apiVersion ${l.apiVersion}: ${n.apiVersion.note}`}),typeof document<"u"&&n.problems.push(...O(e)),t||ie(n),n}function ie(e){let t=console,o=e.problems.filter(a=>a.level==="error").length;t.group?.(`[${l.prefix}] diagnose: ${o?`${o} error(s)`:"no errors"}, ${e.problems.length-o} warning(s)`),t.log("version",e.version,"| API",e.apiVersion.version,`(${e.apiVersion.note})`),t.log("config",e.config),e.market&&t.log("market",`in use: ${[e.market.country,e.market.language].filter(Boolean).join(" / ")||"the store default"}`,e.market.detected?`(detection picks ${JSON.stringify(e.market.detected)})`:""),t.log(e.reachable?`Storefront API reachable: ${e.shop?.name} (${e.latencyMs} ms)`:"Storefront API NOT reachable"),e.products.length&&(t.table||t.log)(e.products),e.sellingPlans.length?(t.table||t.log)(e.sellingPlans):e.reachable&&t.log("No selling plans on the products of this page."),e.problems.forEach(a=>(a.level==="error"?t.error:t.warn)(a.message,a.el||"")),t.groupEnd?.()}window.Tether.__parts.diagnose=P;})();
14
+ sig label hydrated busy`.split(/\s+/).filter(Boolean)),z=["bind","option-list","option","variant-select","add-to-cart","purchase","plan-list","plan","qty","line-attribute"],J=["option-list","plan-list","cart-lines","list"],y="metafield:",X=/^image:\d+$/,Z=2;function ee(e,n){let t=Array.from({length:n.length+1},(o,s)=>s);for(let o=1;o<=e.length;o++){let s=[o];for(let r=1;r<=n.length;r++){let a=(t[r-1]??0)+(e[o-1]===n[r-1]?0:1);s.push(Math.min((t[r]??0)+1,(s[r-1]??0)+1,a))}t=s}return t[n.length]??0}function f(e,n,t=""){let o=null,s=1/0;for(let a of n){let c=ee(e,a);c<s&&(s=c,o=a)}let r=Math.max(2,Math.floor(e.length/4));return o!==null&&s<=r?` Did you mean "${t}${o}"?`:""}function te(e){let n=e.id?`#${e.id}`:"",t=e.className&&typeof e.className=="string"?e.className.trim().split(/\s+/):[],o=t.length?`.${t.slice(0,Z).join(".")}`:"";return`<${e.tagName.toLowerCase()}${n}${o}>`}var I=()=>`${l("collection")},${l("products")},${l("recommendations")}`;function ne(e,n){d(e,l("product")).forEach(t=>{if(t.closest(I())&&t.closest(l("list")))return;let{key:o,fromUrl:s,raw:r}=g(t);r?s&&!o&&n("warn",`${p("product")}="${r}" but this URL has no value for it (e.g. ?handle=my-product).`,t):n("error",`${p("product")} has no value. Bind it to the Shopify handle (CMS field), or use "url:handle".`,t)})}function oe(e,n){for(let t of z)d(e,l(t)).forEach(o=>{o.closest(l("product"))||t==="line-attribute"&&o.closest(l("group"))||n("warn",`${p(t)} outside any ${p("product")}: it does nothing here.`,o)});d(e,l("group-add")).forEach(t=>{t.closest(l("group"))||n("warn",`${p("group-add")} outside a ${p("group")}.`,t)});for(let t of J)d(e,l(t)).forEach(o=>{!o.firstElementChild&&!T(o)&&n("warn",`${p(t)} without a template child: put one example element inside it.`,o)});d(e,I()).forEach(t=>{d(t,l("list")).length||n("error",`List without a ${p("list")} child: products have nowhere to render.`,t)})}function re(e,n){d(e,l("show")).forEach(t=>{let o=h(t,"show")??"";N.has(o)||n("warn",`Unknown ${p("show")}="${o}".${f(o,N)}`,t)}),d(e,l("bind")).forEach(t=>{let o=h(t,"bind")||"";!o||D.has(o)||X.test(o)||o.startsWith(y)||n("warn",`Unknown ${p("bind")}="${o}": it stays empty.${f(o,D)}`,t)})}function se(e,n){d(e,l("bind")).forEach(t=>{let o=h(t,"bind")||"";if(!o.startsWith(y))return;let s=o.slice(y.length);i.metafields.some(a=>(typeof a=="string"?a:`${a.namespace}.${a.key}`)===s)||n("error",`${p("bind")}="${o}" but "${s}" is not in config.metafields, so it stays empty.`,t)})}function ae(e,n){let t=`${i.prefix}-`,o=new Set;d(e,"*").forEach(s=>{for(let{name:r}of s.attributes){if(!r.startsWith(t))continue;let a=r.slice(t.length);U.has(a)||o.has(a)||(o.add(a),n("warn",`Unknown attribute ${r}: Tether ignores it.${f(a,U,t)}`,s))}})}function ie(e,n){let t=d(e,l("cart-drawer")).length;d(e,l("cart-open")).length&&!t&&n("warn",`${p("cart-open")} exists but there is no ${p("cart-drawer")} on this page.`),t>1&&n("warn",`More than one ${p("cart-drawer")}.`),d(e,`[${p("state")}="error"]`).forEach(o=>{o.matches(A())&&n("error",`Scope failed to load (${h(o,"error")||"error"}).`,o)})}function w(e=document){let n=[],t=(o,s,r)=>{n.push(r?{level:o,message:s,element:te(r),el:r}:{level:o,message:s})};return ne(e,t),oe(e,t),re(e,t),ae(e,t),se(e,t),ie(e,t),n}var ce=20,le=3,C=4;function ue(e){return e?`${e.slice(0,C)}\u2026${e.slice(-C)} (${e.length} chars)`:"(missing)"}function O(e,n){if(e instanceof Error&&e.message)return e.message;let t=typeof e=="object"&&e!==null?Reflect.get(e,"code"):void 0;return typeof t=="string"&&t?t:n}function de(){return{domain:i.domain||"(missing)",token:ue(i.token),apiVersion:i.apiVersion,endpoint:i.domain?k():null,country:i.country,language:i.language,locale:i.locale,markets:i.markets,prefix:i.prefix,productPath:i.productPath,metafields:i.metafields,autoMount:i.autoMount,observe:i.observe,onError:typeof i.onError=="function"}}async function pe(){return{country:i.country||null,language:i.language||null,locale:i.locale||null,detected:i.markets?.detect?(await x("markets")).detectMarket(i.markets):null}}function he({ok:e,monthsLeft:n,note:t}){return e&&(n===void 0||n>=le)?null:{level:e?"warn":"error",message:`apiVersion ${i.apiVersion}: ${t}`}}async function fe(){if(!S())return{kind:"not-configured"};let e=Date.now();try{let n=await P("query TetherDiagnose { shop { name primaryDomain { url } paymentSettings { currencyCode } } }",{},{context:!1});return{kind:"reachable",shop:{name:n.shop.name,url:n.shop.primaryDomain.url,currency:n.shop.paymentSettings.currencyCode},latencyMs:Date.now()-e}}catch(n){return{kind:"unreachable",error:n,latencyMs:Date.now()-e}}}function me(e,n,t){let o=[],s=t.options.map(a=>a.name),r=d(e,l("product")).filter(a=>g(a).key===n&&a.querySelector(l("add-to-cart")));for(let a of r){let c=new Set(d(a,`${l("option-list")},select${l("option")}`).map(u=>h(u,"option-list")||h(u,"option")));if(!(!c.size&&d(a,`select${l("variant-select")}`).length)){if(!i.language)for(let u of c)!u||s.includes(u)||o.push({level:"warn",message:`Product "${t.handle}" has no option "${u}" (its options: ${s.join(", ")||"none"}).${f(u,s)}`});for(let u of t.options)u.optionValues.length<=1||c.has(u.name)||o.push({level:"warn",message:`Product "${t.handle}": option "${u.name}" (${u.optionValues.length} values) has no tether-option-list, so visitors can't choose it.`})}}return o}async function ge(e,n){let t=d(e,l("product")).map(r=>g(r).key),o=[...new Set(t.filter(r=>r!==null&&r!==""))].slice(0,ce);(await Promise.allSettled(o.map(r=>_(r)))).forEach((r,a)=>{let c=o[a]??"";if(r.status==="rejected"){let m=O(r.reason,"not loaded");n.products.push({key:c,error:r.reason instanceof Error?r.reason.message:void 0}),n.problems.push({level:"error",message:`Product "${c}": ${m}. Is it published to the Headless channel?`});return}let u=r.value,$=R(u);n.products.push({key:c,handle:u.handle,title:u.title,plans:$.length,requiresSellingPlan:u.requiresSellingPlan});for(let m of $)n.sellingPlans.push({product:u.handle,group:m.group.name,plan:m.name,id:m.id});n.problems.push(...me(e,c,u))})}async function be({root:e=document,silent:n=!1,version:t,now:o=new Date}={}){let s=await fe(),r={version:t,config:de(),apiVersion:b(i.apiVersion,o),market:await pe(),reachable:s.kind==="reachable",shop:s.kind==="reachable"?s.shop:null,latencyMs:s.kind==="not-configured"?null:s.latencyMs,products:[],sellingPlans:[],problems:[]};switch(s.kind){case"not-configured":r.problems.push({level:"error",message:"TETHER_CONFIG needs domain and token."});break;case"unreachable":r.problems.push({level:"error",message:`Storefront API not reachable: ${O(s.error,"unknown error")}`});break;case"reachable":await ge(e,r);break}let a=he(r.apiVersion);return a&&r.problems.push(a),typeof document<"u"&&r.problems.push(...w(e)),n||ye(r),r}function ye(e){let n=e.problems.filter(c=>c.level==="error").length,t=e.problems.length-n;console.group(`[${i.prefix}] diagnose: ${n?`${n} error(s)`:"no errors"}, ${t} warning(s)`),console.log("version",e.version,"| API",e.apiVersion.version,`(${e.apiVersion.note})`),console.log("config",e.config);let{country:o,language:s,detected:r}=e.market,a=[o,s].filter(Boolean).join(" / ")||"the store default";console.log("market",`in use: ${a}`,r?`(detection picks ${JSON.stringify(r)})`:""),console.log(e.shop?`Storefront API reachable: ${e.shop.name} (${e.latencyMs??0} ms)`:"Storefront API NOT reachable"),e.products.length&&console.table(e.products),e.sellingPlans.length?console.table(e.sellingPlans):e.reachable&&console.log("No selling plans on the products of this page.");for(let c of e.problems)c.level==="error"?console.error(c.message,c.el??""):console.warn(c.message,c.el??"");console.groupEnd()}var{Tether:V}=window;if(!V)throw new Error("tether.diagnose.js runs after the Tether script, which loads it");V.__parts.diagnose=E;})();
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  (() => {
2
3
  var __defProp = Object.defineProperty;
3
4
  var __export = (target, all) => {
@@ -15,11 +16,11 @@
15
16
 
16
17
  // tether-core:config.js
17
18
  var m = window.Tether.__core["config.js"];
18
- var { DEFAULTS, cfg, configure, isConfigured, log, reportError, warn } = m;
19
+ var { DEFAULTS, cfg, configure, isConfigured, log, reportError, resolveConfig, toMetafieldIdentifier, warn } = m;
19
20
 
20
21
  // tether-core:dom.js
21
22
  var m2 = window.Tether.__core["dom.js"];
22
- var { attr, busy, cdnUrl, dataKey, emit, formatDate, formatMoney, formatPercent, get, has, hasTemplate, imageUrl, notifyLayoutChanged, parseJSONAttr, productUrl, qsa, readText, repeat, repeatKeyed, sameImage, scoped, sel, setImage, setSelected, setText, setTextTracked, show, toAttributes, watchImages } = m2;
23
+ var { attr, busy, cdnUrl, emit, formatDate, formatMoney, formatPercent, get, has, hasTemplate, imageUrl, notifyLayoutChanged, parseJSONAttr, productUrl, qsa, repeat, repeatKeyed, sameImage, scoped, sel, setImage, setSelected, setStoreHtml, setText, setTextTracked, show, toAttributes, watchImages } = m2;
23
24
 
24
25
  // tether-core:product.js
25
26
  var m3 = window.Tether.__core["product.js"];
@@ -27,19 +28,26 @@
27
28
 
28
29
  // tether-core:cart.js
29
30
  var m4 = window.Tether.__core["cart.js"];
30
- var { Cart, focusables, toLineInput } = m4;
31
+ var { Cart, trapFocus } = m4;
31
32
 
32
33
  // src/extras.js
33
- async function addGroup(btn) {
34
- const group = btn.closest(sel("group"));
34
+ function groupAttributes(group, name) {
35
+ const extra = toAttributes(
36
+ /** @type {Parameters<typeof toAttributes>[0]} */
37
+ parseJSONAttr(group, "line-attributes")
38
+ );
39
+ return name ? [{ key: "_group", value: name }, ...extra] : extra;
40
+ }
41
+ async function addGroup(button) {
42
+ const group = button.closest(sel("group"));
35
43
  if (!group) return null;
36
44
  const name = get(group, "group");
37
- const extra = toAttributes(parseJSONAttr(group, "line-attributes"));
38
- const groupAttrs = name ? [{ key: "_group", value: name }, ...extra] : extra;
39
- const lines = qsa(group, sel("product")).map((el) => scopes.get(el)).filter((s) => s && s.variant?.availableForSale && s.quantity > 0).map((s) => {
40
- const l = s.getLine();
41
- l.attributes = [...l.attributes || [], ...groupAttrs];
42
- return l;
45
+ const attributes = groupAttributes(group, name);
46
+ const lines = qsa(group, sel("product")).flatMap((el) => {
47
+ const scope = scopes.get(el);
48
+ if (!scope?.variant?.availableForSale || scope.quantity <= 0) return [];
49
+ const line = scope.getLine();
50
+ return line ? [{ ...line, attributes: [...line.attributes ?? [], ...attributes] }] : [];
43
51
  });
44
52
  if (!lines.length) {
45
53
  warn("group-add: nothing selected");
@@ -49,39 +57,76 @@
49
57
  const cart = await Cart.add(lines);
50
58
  emit("group-added", { group: name, lines }, group);
51
59
  return cart;
52
- } catch (err) {
53
- reportError(err, "group add");
60
+ } catch (error) {
61
+ reportError(error, "group add");
54
62
  return null;
55
63
  }
56
64
  }
57
- function onStorage(e) {
58
- if (e.key === cfg.storageKey || e.key === `${cfg.storageKey}:seen`) Cart.init();
59
- else if (e.key === `${cfg.prefix}:market:${cfg.domain}` && e.newValue) {
60
- try {
61
- const m5 = JSON.parse(e.newValue);
62
- if (m5?.country) window.Tether?.setCountry(m5.country, { language: m5.language ?? null, locale: m5.locale, remember: false }).catch(() => {
63
- });
64
- } catch {
65
- }
65
+ function parseStoredMarket(text) {
66
+ let value;
67
+ try {
68
+ value = JSON.parse(text);
69
+ } catch {
70
+ return null;
66
71
  }
72
+ if (typeof value !== "object" || value === null) return null;
73
+ const { country, language, locale } = (
74
+ /** @type {Record<string, unknown>} */
75
+ value
76
+ );
77
+ if (typeof country !== "string" || !country) return null;
78
+ return {
79
+ country,
80
+ language: typeof language === "string" ? language : null,
81
+ locale: typeof locale === "string" ? locale : void 0
82
+ };
83
+ }
84
+ function onStorage(event) {
85
+ if (event.key === cfg.storageKey || event.key === `${cfg.storageKey}:seen`) {
86
+ Cart.init().catch((error) => {
87
+ reportError(error, "cart from another tab");
88
+ });
89
+ return;
90
+ }
91
+ if (event.key !== `${cfg.prefix}:market:${cfg.domain}` || !event.newValue) return;
92
+ const market = parseStoredMarket(event.newValue);
93
+ const { Tether: Tether2 } = (
94
+ /** @type {Window & { Tether?: { setCountry: SetCountry } }} */
95
+ window
96
+ );
97
+ if (!market || !Tether2) return;
98
+ const options = { language: market.language, locale: market.locale, remember: false };
99
+ Tether2.setCountry(market.country, options).catch((error) => {
100
+ reportError(error, "market from another tab");
101
+ });
67
102
  }
68
103
  var urlKeys = /* @__PURE__ */ new WeakMap();
104
+ var numericId = (gid) => gid.split("/").pop() ?? gid;
105
+ function replaceUrlIfAllowed(url) {
106
+ try {
107
+ window.history.replaceState(window.history.state, "", url);
108
+ } catch {
109
+ }
110
+ }
69
111
  function writeVariantUrl(root, { variant, sellingPlanId }) {
70
- const key = `${variant.id}|${sellingPlanId || ""}`;
112
+ const key = `${variant.id}|${sellingPlanId ?? ""}`;
71
113
  const before = urlKeys.get(root);
72
114
  urlKeys.set(root, key);
73
115
  if (!before || before === key) return;
74
- if (!has(root, "variant-url") && !(cfg.variantUrl && document.querySelector(sel("product")) === root)) return;
75
- try {
76
- const u = new URL(window.location.href);
77
- u.searchParams.set("variant", variant.id.split("/").pop());
78
- if (sellingPlanId) u.searchParams.set("selling_plan", sellingPlanId.split("/").pop());
79
- else u.searchParams.delete("selling_plan");
80
- window.history.replaceState(window.history.state, "", u);
81
- } catch {
82
- }
116
+ const isMainProduct = cfg.variantUrl && document.querySelector(sel("product")) === root;
117
+ if (!has(root, "variant-url") && !isMainProduct) return;
118
+ const url = new URL(window.location.href);
119
+ url.searchParams.set("variant", numericId(variant.id));
120
+ if (sellingPlanId) url.searchParams.set("selling_plan", numericId(sellingPlanId));
121
+ else url.searchParams.delete("selling_plan");
122
+ replaceUrlIfAllowed(url);
83
123
  }
84
124
 
85
125
  // src/parts/extras.js
86
- window.Tether.__parts.extras = extras_exports;
126
+ var { Tether } = (
127
+ /** @type {Window & { Tether?: { __parts: Record<string, unknown> } }} */
128
+ window
129
+ );
130
+ if (!Tether) throw new Error("tether.extras.js runs after the Tether script, which loads it");
131
+ Tether.__parts["extras"] = extras_exports;
87
132
  })();
@@ -1 +1 @@
1
- (()=>{var b=Object.defineProperty;var S=(t,e)=>{for(var o in e)b(t,o,{get:e[o],enumerable:!0})};var l={};S(l,{addGroup:()=>C,onStorage:()=>K,writeVariantUrl:()=>L});var k=window.Tether.__core["config.js"],{DEFAULTS:j,cfg:n,configure:q,isConfigured:N,log:O,reportError:m,warn:d}=k;var U=window.Tether.__core["dom.js"],{attr:J,busy:P,cdnUrl:V,dataKey:D,emit:g,formatDate:F,formatMoney:I,formatPercent:M,get:f,has:w,hasTemplate:G,imageUrl:R,notifyLayoutChanged:W,parseJSONAttr:y,productUrl:z,qsa:h,readText:B,repeat:H,repeatKeyed:Q,sameImage:X,scoped:Y,sel:i,setImage:Z,setSelected:ee,setText:te,setTextTracked:re,show:oe,toAttributes:x,watchImages:ae}=U;var A=window.Tether.__core["product.js"],{ProductScope:se,rememberOptionNames:ce,scopes:_}=A;var v=window.Tether.__core["cart.js"],{Cart:u,focusables:pe,toLineInput:ue}=v;async function C(t){let e=t.closest(i("group"));if(!e)return null;let o=f(e,"group"),s=x(y(e,"line-attributes")),c=o?[{key:"_group",value:o},...s]:s,a=h(e,i("product")).map(r=>_.get(r)).filter(r=>r&&r.variant?.availableForSale&&r.quantity>0).map(r=>{let p=r.getLine();return p.attributes=[...p.attributes||[],...c],p});if(!a.length)return d("group-add: nothing selected"),null;try{let r=await u.add(a);return g("group-added",{group:o,lines:a},e),r}catch(r){return m(r,"group add"),null}}function K(t){if(t.key===n.storageKey||t.key===`${n.storageKey}:seen`)u.init();else if(t.key===`${n.prefix}:market:${n.domain}`&&t.newValue)try{let e=JSON.parse(t.newValue);e?.country&&window.Tether?.setCountry(e.country,{language:e.language??null,locale:e.locale,remember:!1}).catch(()=>{})}catch{}}var T=new WeakMap;function L(t,{variant:e,sellingPlanId:o}){let s=`${e.id}|${o||""}`,c=T.get(t);if(T.set(t,s),!(!c||c===s)&&!(!w(t,"variant-url")&&!(n.variantUrl&&document.querySelector(i("product"))===t)))try{let a=new URL(window.location.href);a.searchParams.set("variant",e.id.split("/").pop()),o?a.searchParams.set("selling_plan",o.split("/").pop()):a.searchParams.delete("selling_plan"),window.history.replaceState(window.history.state,"",a)}catch{}}window.Tether.__parts.extras=l;})();
1
+ "use strict";(()=>{var k=Object.defineProperty;var U=(e,t)=>{for(var r in t)k(e,r,{get:t[r],enumerable:!0})};var f={};U(f,{addGroup:()=>q,onStorage:()=>I,writeVariantUrl:()=>L});var A=window.Tether.__core["config.js"],{DEFAULTS:O,cfg:c,configure:P,isConfigured:v,log:F,reportError:i,resolveConfig:J,toMetafieldIdentifier:V,warn:d}=A;var j=window.Tether.__core["dom.js"],{attr:G,busy:H,cdnUrl:R,emit:m,formatDate:W,formatMoney:z,formatPercent:B,get:g,has:h,hasTemplate:Q,imageUrl:X,notifyLayoutChanged:Y,parseJSONAttr:w,productUrl:Z,qsa:y,repeat:tt,repeatKeyed:et,sameImage:rt,scoped:ot,sel:u,setImage:nt,setSelected:at,setStoreHtml:st,setText:ct,setTextTracked:it,show:ut,toAttributes:b,watchImages:lt}=j;var C=window.Tether.__core["product.js"],{ProductScope:ft,rememberOptionNames:dt,scopes:x}=C;var M=window.Tether.__core["cart.js"],{Cart:p,trapFocus:gt}=M;function $(e,t){let r=b(w(e,"line-attributes"));return t?[{key:"_group",value:t},...r]:r}async function q(e){let t=e.closest(u("group"));if(!t)return null;let r=g(t,"group"),n=$(t,r),o=y(t,u("product")).flatMap(s=>{let a=x.get(s);if(!a?.variant?.availableForSale||a.quantity<=0)return[];let l=a.getLine();return l?[{...l,attributes:[...l.attributes??[],...n]}]:[]});if(!o.length)return d("group-add: nothing selected"),null;try{let s=await p.add(o);return m("group-added",{group:r,lines:o},t),s}catch(s){return i(s,"group add"),null}}function E(e){let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!="object"||t===null)return null;let{country:r,language:n,locale:o}=t;return typeof r!="string"||!r?null:{country:r,language:typeof n=="string"?n:null,locale:typeof o=="string"?o:void 0}}function I(e){if(e.key===c.storageKey||e.key===`${c.storageKey}:seen`){p.init().catch(o=>{i(o,"cart from another tab")});return}if(e.key!==`${c.prefix}:market:${c.domain}`||!e.newValue)return;let t=E(e.newValue),{Tether:r}=window;if(!t||!r)return;let n={language:t.language,locale:t.locale,remember:!1};r.setCountry(t.country,n).catch(o=>{i(o,"market from another tab")})}var _=new WeakMap,S=e=>e.split("/").pop()??e;function K(e){try{window.history.replaceState(window.history.state,"",e)}catch{}}function L(e,{variant:t,sellingPlanId:r}){let n=`${t.id}|${r??""}`,o=_.get(e);if(_.set(e,n),!o||o===n)return;let s=c.variantUrl&&document.querySelector(u("product"))===e;if(!h(e,"variant-url")&&!s)return;let a=new URL(window.location.href);a.searchParams.set("variant",S(t.id)),r?a.searchParams.set("selling_plan",S(r)):a.searchParams.delete("selling_plan"),K(a)}var{Tether:T}=window;if(!T)throw new Error("tether.extras.js runs after the Tether script, which loads it");T.__parts.extras=f;})();