@occluze/tether 0.5.0 → 0.6.1

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 (66) hide show
  1. package/README.md +9 -7
  2. package/dist/esm/astro.js +1 -1
  3. package/dist/esm/chunks/account-JBZJN7X7.js +1 -0
  4. package/dist/esm/chunks/analytics-22NMIVBV.js +1 -0
  5. package/dist/esm/chunks/chunk-4UR45XTC.js +1 -0
  6. package/dist/esm/chunks/chunk-6R752OYZ.js +1 -0
  7. package/dist/esm/chunks/chunk-BGIKQY6H.js +1 -0
  8. package/dist/esm/chunks/chunk-CISGFYOF.js +1 -0
  9. package/dist/esm/chunks/chunk-KARKXC6G.js +1 -0
  10. package/dist/esm/chunks/chunk-YXCXIPQV.js +4 -0
  11. package/dist/esm/chunks/{chunk-RBVRRQIU.js → chunk-YZMBXS6Y.js} +1 -1
  12. package/dist/esm/chunks/chunk-ZVUPVSLF.js +1 -0
  13. package/dist/esm/chunks/diagnose-6ZSK5DGE.js +1 -0
  14. package/dist/esm/chunks/extras-QDCSW6VU.js +1 -0
  15. package/dist/esm/chunks/markets-ui-HJCVLCKJ.js +1 -0
  16. package/dist/esm/chunks/search-LN2H6SXS.js +1 -0
  17. package/dist/esm/index.js +1 -1
  18. package/dist/esm/server.js +1 -1
  19. package/dist/tether.account.js +380 -0
  20. package/dist/tether.account.min.js +1 -0
  21. package/dist/tether.analytics.js +259 -0
  22. package/dist/tether.analytics.min.js +1 -0
  23. package/dist/tether.diagnose.js +11 -2
  24. package/dist/tether.diagnose.min.js +1 -1
  25. package/dist/tether.extras.js +87 -0
  26. package/dist/tether.extras.min.js +1 -0
  27. package/dist/tether.js +268 -75
  28. package/dist/tether.markets.js +3 -3
  29. package/dist/tether.markets.min.js +1 -1
  30. package/dist/tether.min.js +3 -3
  31. package/dist/tether.min.js.map +3 -3
  32. package/dist/tether.search.js +176 -0
  33. package/dist/tether.search.min.js +1 -0
  34. package/package.json +5 -2
  35. package/src/account.js +313 -0
  36. package/src/analytics.js +232 -0
  37. package/src/astro.js +4 -1
  38. package/src/cart.js +74 -11
  39. package/src/client.js +8 -3
  40. package/src/collection.js +15 -10
  41. package/src/config.js +3 -0
  42. package/src/diagnose.js +11 -2
  43. package/src/dom.js +7 -1
  44. package/src/extras.js +63 -0
  45. package/src/fragments.js +1 -1
  46. package/src/index.js +103 -41
  47. package/src/initial.js +13 -4
  48. package/src/lazy.js +9 -1
  49. package/src/loader.js +4 -1
  50. package/src/markets-ui.js +2 -1
  51. package/src/mounting.js +27 -2
  52. package/src/parts/account.js +3 -0
  53. package/src/parts/analytics.js +3 -0
  54. package/src/parts/extras.js +3 -0
  55. package/src/parts/search.js +3 -0
  56. package/src/product.js +19 -5
  57. package/src/search.js +153 -0
  58. package/src/server.js +78 -6
  59. package/src/status.js +2 -2
  60. package/types/index.d.ts +56 -3
  61. package/types/server.d.ts +10 -2
  62. package/dist/esm/chunks/chunk-HHMOPDZG.js +0 -1
  63. package/dist/esm/chunks/chunk-HXKV6QGB.js +0 -4
  64. package/dist/esm/chunks/chunk-RNZMTQTX.js +0 -1
  65. package/dist/esm/chunks/diagnose-J667GHGS.js +0 -1
  66. package/dist/esm/chunks/markets-ui-EGWIEUOZ.js +0 -1
@@ -0,0 +1 @@
1
+ (()=>{var F=Object.defineProperty;var I=(n,t)=>{for(var e in t)F(n,e,{get:t[e],enumerable:!0})};var C={};I(C,{startAnalytics:()=>R});var U=window.Tether.__core["config.js"],{DEFAULTS:J,cfg:a,configure:z,isConfigured:G,log:x,reportError:y,warn:Q}=U;var $=window.Tether.__core["client.js"],{TetherError:Y,endpoint:Z,gql:L,request:tt,unwrap:et,withContext:nt}=$;var M=window.Tether.__core["dom.js"],{attr:it,busy:ct,cdnUrl:rt,dataKey:at,emit:st,formatDate:dt,formatMoney:lt,formatPercent:ut,get:pt,has:ft,hasTemplate:ht,imageUrl:mt,notifyLayoutChanged:yt,parseJSONAttr:gt,productUrl:wt,qsa:_t,readText:vt,repeat:Tt,repeatKeyed:bt,sameImage:kt,scoped:Ct,sel:g,setImage:St,setSelected:xt,setText:Lt,setTextTracked:qt,show:Et,toAttributes:At,watchImages:Pt}=M;var V=window.Tether.__core["cart.js"],{Cart:T,focusables:Dt,toLineInput:Ft}=V;var O=n=>n?parseFloat(n.amount):0,q=n=>String(n||"").split("/").pop();function k(n,t,e=1,o){return{item_id:t?.sku||q(t?.id)||q(n.id),item_name:n.title,item_variant:t?.title==="Default Title"?void 0:t?.title,item_brand:n.vendor||void 0,item_category:n.productType||void 0,price:O(t?.price||n.priceRange?.minVariantPrice),quantity:e,...o!=null?{index:o}:{}}}function _(n,t=n.quantity){let e=n.merchandise||{};return k({...e.product||{},title:e.product?.title},e,t)}var w=n=>Math.round(n.reduce((t,e)=>t+(e.price||0)*(e.quantity||1),0)*100)/100;function B(n,t){let e=typeof a.analytics.dataLayer=="string"?a.analytics.dataLayer:"dataLayer",o=window[e]=window[e]||[];t&&o.push({ecommerce:null}),o.push(t?{event:n,ecommerce:t}:{event:n})}var p=null;function H(n){let t=[],e=[],o=()=>window.Shopify?.customerPrivacy,r=()=>{try{let i=o();return i?.consentStatus==="loaded"&&i.currentVisitorConsent?.()?.analytics!=="no"&&!!i.analyticsProcessingAllowed?.()}catch{return!1}},c={shop:{shopId:n,channel:"headless"},consent:{mode:a.analytics.shopify?.consent||"no-banner"}},d=()=>{r()&&t.forEach(i=>{for(;i.next<e.length;){let{event:l,payload:u}=e[i.next++];(i.subs.get(l)||[]).forEach(v=>{try{v(u,i.context)}catch(s){y(s,`analytics ${i.name}`)}})}})},f={getConfig:()=>c,publish(i,l={}){e.push({event:i,payload:{shop:c.shop,url:window.location.href,...l}}),e.length>500&&(e.shift(),t.forEach(u=>{u.next=Math.max(0,u.next-1)})),d()},addDestination(i){let l=`hydrogen:${i.name}`,u={name:i.name,next:0,subs:new Map,context:{getTrackingValues:()=>{let s=r()?o()?.__internal:null;return{uniqueToken:s?.uniqueToken?.({generateFallback:!0,tag:l})??"",visitToken:s?.visitToken?.({generateFallback:!0,tag:l})??""}}}},v=(s,S)=>(u.subs.has(s)||u.subs.set(s,new Set),u.subs.get(s).add(S),()=>u.subs.get(s)?.delete(S));return Promise.resolve(i.setup?.({subscribe:v,getConfig:f.getConfig})).then(()=>{t.push(u),d()}).catch(s=>y(s,`analytics ${i.name}`)),()=>{let s=t.indexOf(u);s>=0&&t.splice(s,1)}}};return document.addEventListener("consentTrackingApiLoaded",d),document.addEventListener("visitorConsentCollected",d),f}function E(n){let t=document.createElement("script");t.src=n,t.async=!0,document.head.appendChild(t)}async function K(){if(window.Shopify?.analytics){p=window.Shopify.analytics;return}let n=await L("query TetherShopId { shop { id } }",{},{context:!1}),t=String(a.country||"US").toUpperCase(),e=window.Shopify=window.Shopify||{};Object.assign(e,{country:t,locale:(a.locale||"en").split("-")[0].toLowerCase(),shop:a.domain,routes:{root:"/",match:()=>({pageTemplateName:D()?"product":"page"}),...e.routes||{}}});let o=a.analytics.shopify?.proxy;e.customerPrivacy={...e.customerPrivacy||{},config:o?{isHeadless:!0,asyncConsent:!0,asyncVisitorState:!0,consentDomain:window.location.host}:{isHeadless:!0,storefrontAccessToken:a.token,checkoutRootDomain:a.domain}},p=H(n.shop.id),e.analytics=p,E(a.analytics.shopify?.consent==="default-banner"?"https://cdn.shopify.com/shopifycloud/privacy-banner/storefront-banner.js":"https://cdn.shopify.com/shopifycloud/consent-tracking-api/v0.2/consent-tracking-api.js"),E("https://cdn.shopify.com/storefront/analytics/shopify.js"),x("shopify analytics ready",n.shop.id)}var N=(n,t,e=1)=>({id:n.id,title:n.title,price:t.price,vendor:n.vendor||"",variantId:t.id,variantTitle:t.title,quantity:e,sku:t.sku||void 0,productType:n.productType||void 0});function A(n){let t=n.merchandise||{};return{id:n.id,quantity:n.quantity,merchandise:{id:t.id,title:t.title,price:t.price,sku:t.sku,product:{id:t.product?.id,title:t.product?.title,vendor:t.product?.vendor||"",handle:t.product?.handle}}}}function D(){let n=document.querySelector(g("product"));return n&&!n.closest(`${g("collection")},${g("products")},${g("recommendations")}`)?window.Tether?.getScope(n):null}var h=(n,t,e,o)=>{a.analytics.dataLayer&&B(n,t),p&&e&&p.publish(e,o);try{a.analytics.onEvent?.(n,t)}catch(r){y(r,"analytics onEvent")}},m=null,b=new WeakSet;function P(n){let t=n.type.slice(a.prefix.length+1),e=n.detail||{};if(t==="product-ready"){let o=e.scope;if(!o||b.has(o.root)||D()!==o)return;b.add(o.root);let r=o.variant||e.product.variants.nodes[0],c=[k(e.product,r)];h("view_item",{currency:r?.price?.currencyCode,value:w(c),items:c},"product_viewed",{products:[N(e.product,r)]})}else if(t==="list-ready"){let o=(e.products||[]).slice(0,200).map((c,d)=>k(c,c.variants?.nodes?.[0],1,d)),r={item_list_id:e.collection?.handle||"products",item_list_name:e.collection?.title||"Products"};h("view_item_list",{...r,items:o},e.collection?"collection_viewed":null,e.collection?{collection:{id:e.collection.id,handle:e.collection.handle}}:null)}else if(t==="cart-updated"){let o=e.cart,r=new Map((o?.lines?.nodes||[]).map(c=>[c.merchandise?.id,c]));if(m&&e.reason!=="load"&&e.reason!=="pending"){let c=o?.cost?.totalAmount?.currencyCode;r.forEach((d,f)=>{let i=d.quantity-(m.get(f)?.quantity||0);if(i>0){let l=[_(d,i)];h("add_to_cart",{currency:c,value:w(l),items:l},"product_added_to_cart",{cart:o,prevCart:j,currentLine:A(d),prevLine:m.get(f)?A(m.get(f)):void 0})}}),m.forEach((d,f)=>{let i=d.quantity-(r.get(f)?.quantity||0);if(i>0){let l=[_(d,i)];h("remove_from_cart",{currency:c,value:w(l),items:l})}})}m=r,j=o}else if(t==="cart-toggled"&&e.open){let o=T.lines.map(r=>_(r));h("view_cart",{currency:T.state?.cost?.totalAmount?.currencyCode,value:w(o),items:o})}else if(t==="checkout"){let o=(e.cart?.lines?.nodes||[]).map(c=>_(c)),r=(e.cart?.discountCodes||[]).filter(c=>c.applicable).map(c=>c.code).join(",")||void 0;h("begin_checkout",{currency:e.cart?.cost?.totalAmount?.currencyCode,value:w(o),coupon:r,items:o})}else t==="search"&&e.term?h("search",{search_term:e.term},"search_viewed",{searchTerm:e.term}):t==="page"&&(b=new WeakSet,p&&p.publish("page_viewed",{}))}var j=null;async function R(n){a.analytics.shopify&&await K().catch(t=>y(t,"shopify analytics")),p&&p.publish("page_viewed",{}),n.splice(0).forEach(P),n.push=t=>(P(t),0)}window.Tether.__parts.analytics=C;})();
@@ -23,7 +23,7 @@
23
23
 
24
24
  // tether-core:dom.js
25
25
  var m3 = window.Tether.__core["dom.js"];
26
- var { attr, busy, cdnUrl, dataKey, emit, formatDate, formatMoney, get, has, hasTemplate, imageUrl, notifyLayoutChanged, parseJSONAttr, productUrl, qsa, readText, repeat, repeatKeyed, sameImage, scoped, sel, setImage, setSelected, setText, setTextTracked, show, toAttributes, watchImages } = m3;
26
+ 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 } = m3;
27
27
 
28
28
  // tether-core:loader.js
29
29
  var m4 = window.Tether.__core["loader.js"];
@@ -191,6 +191,7 @@
191
191
  "out-of-stock",
192
192
  "backorder",
193
193
  "low-stock",
194
+ "plenty-in-stock",
194
195
  "on-sale",
195
196
  "not-on-sale",
196
197
  "has-variants",
@@ -256,7 +257,8 @@
256
257
  onError: typeof cfg.onError === "function"
257
258
  },
258
259
  apiVersion: apiVersionStatus(cfg.apiVersion, now),
259
- market: cfg.markets?.detect ? detectMarket(cfg.markets) : null,
260
+ // The market in use (a visitor's choice included), plus what detection would pick.
261
+ market: { country: cfg.country || null, language: cfg.language || null, locale: cfg.locale || null, detected: cfg.markets?.detect ? detectMarket(cfg.markets) : null },
260
262
  reachable: false,
261
263
  shop: null,
262
264
  latencyMs: null,
@@ -286,6 +288,13 @@
286
288
  const plans = allPlans(p);
287
289
  report.products.push({ key: keys[i], handle: p.handle, title: p.title, plans: plans.length, requiresSellingPlan: p.requiresSellingPlan });
288
290
  plans.forEach((pl) => report.sellingPlans.push({ product: p.handle, group: pl.group?.name, plan: pl.name, id: pl.id }));
291
+ qsa(root, sel("product")).filter((el) => resolveProductKey(el).key === keys[i] && el.querySelector(sel("add-to-cart"))).forEach((el) => {
292
+ const shown = new Set(qsa(el, `${sel("option-list")},select${sel("option")}`).map((x) => get(x, "option-list") || get(x, "option")));
293
+ if (!shown.size && qsa(el, `select${sel("variant-select")}`).length) return;
294
+ (p.options || []).filter((o) => o.optionValues.length > 1 && !shown.has(o.name)).forEach((o) => {
295
+ report.problems.push({ level: "warn", message: `Product "${p.handle}": option "${o.name}" (${o.optionValues.length} values) has no tether-option-list, so visitors can't choose it.` });
296
+ });
297
+ });
289
298
  } else {
290
299
  report.products.push({ key: keys[i], error: r.reason?.message });
291
300
  report.problems.push({ level: "error", message: `Product "${keys[i]}": ${r.reason?.message}. Is it published to the Headless channel?` });
@@ -1 +1 @@
1
- (()=>{var V=Object.defineProperty;var D=(e,t)=>{for(var o in t)V(e,o,{get:t[o],enumerable:!0})};var k={};D(k,{apiVersionStatus:()=>$,checkMarkup:()=>L,diagnose:()=>X});var I=window.Tether.__core["config.js"],{DEFAULTS:te,cfg:l,configure:oe,isConfigured:E,log:ne,reportError:re,warn:ae}=I;var N=window.Tether.__core["client.js"],{TetherError:ie,endpoint:P,gql:w,request:le,unwrap:ce,withContext:ue}=N;var M=window.Tether.__core["dom.js"],{attr:f,busy:pe,cdnUrl:fe,dataKey:me,emit:ge,formatDate:he,formatMoney:ye,get:h,has:we,hasTemplate:T,imageUrl:be,notifyLayoutChanged:$e,parseJSONAttr:Se,productUrl:ke,qsa:u,readText:Ee,repeat:Pe,repeatKeyed:Te,sameImage:xe,scoped:Ce,sel:c,setImage:ve,setSelected:_e,setText:Ae,setTextTracked:Ue,show:Le,toAttributes:Ve,watchImages:De}=M;var q=window.Tether.__core["loader.js"],{clearProductCache:Ne,getProduct:x,getProducts:Me,getRecommendations:qe,hydrateProducts:Oe,normalizeProductKey:Re,primeProduct:je,refreshProducts:Ge,takeStale:ze}=q;var O=window.Tether.__core["selling-plans.js"],{GID:He,allPlans:C,allocationFor:Ke,findPlan:Ye,hasPlans:Fe,planAdjustment:Ze,planCheckoutCharge:Je,planPrice:We,planSavings:Xe,plansForVariant:Qe,toGid:et}=O;var R=window.Tether.__core["status.js"],{STATUS_KEYS:ot,boundary:v,isNotFound:nt,ownedBy:rt,resolveProductKey:b,setScopeStatus:at}=R;var A=e=>{let t=/^(\d{4})-(01|04|07|10)$/.exec(String(e||""));return t?{y:+t[1],m:+t[2]}:null},j=(e,t)=>`${e}-${String(t).padStart(2,"0")}`;function _(e,t=1){let o=A(e);if(!o)throw new Error(`not a quarterly Shopify API version: ${e}`);let s=o.y*4+(o.m-1)/3+t;return j(Math.floor(s/4),s%4*3+1)}function $(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=A(e);if(!o)return{version:e,ok:!1,note:"not a quarterly version (YYYY-01, -04, -07 or -10)"};let s=new Date(Date.UTC(o.y,o.m-1,1)),n=new Date(Date.UTC(o.y+1,o.m-1,1)),d=(n-t)/(30.44*24*3600*1e3),a=`supported until about ${n.toISOString().slice(0,7)}`;return s>t?a="not released yet (release candidate at best)":d<=0?a="no longer supported: Shopify falls back to the oldest supported version. Upgrade (see README)":d<3&&(a=`${a}: plan the upgrade to ${_(e)} or later (see README)`),{version:e,ok:s<=t&&d>0,monthsLeft:Math.round(d),next:_(e),note:a}}var G=/^[A-Z]{2}$/,z=new Set(["PT_BR","PT_PT","ZH_CN","ZH_TW"]),B=()=>`${l.prefix}:market:${l.domain}`,H=()=>({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 K(e){let t=String(e||"").trim().toUpperCase();return G.test(t)&&t!=="XX"&&t!=="T1"?t:null}function Y(e){let t=String(e||"").trim().replace("-","_").toUpperCase();if(!t)return null;if(z.has(t))return t;let o=t.split("_")[0];return/^[A-Z]{2,3}$/.test(o)?o:null}function F(e,t){if(!e||!t)return null;let o=String(e.cookie||"").split(";").map(s=>s.trim()).find(s=>s.startsWith(`${t}=`));return o?decodeURIComponent(o.slice(t.length+1)):null}var S=(e,t)=>{if(!e||!t)return null;let o=String(t).toLowerCase(),s=Object.keys(e).find(n=>n.toLowerCase()===o);return s?e[s]:null},Z={saved(e,t){if(e.remember===!1||!t.storage)return null;try{return JSON.parse(t.storage.getItem(B())||"null")}catch{return null}},server(e,t){let o=d=>t.document?.querySelector?.(`meta[name="${d}"]`)?.getAttribute("content"),s=t.global.TETHER_COUNTRY||o("tether-country")||F(t.document,e.cookie||"tether_country"),n=t.global.TETHER_LANGUAGE||o("tether-language");return{country:s,language:n}},webflow(e,t){let o=(t.location?.pathname||"/").split("/").filter(Boolean)[0],s=S(e.locales,o);if(s)return s;let n=t.document?.documentElement?.getAttribute("lang");if(!n)return null;let d=S(e.locales,n)||S(e.locales,n.split("-")[0]);if(d)return{locale:n,...d};if(e.locales&&e.strict)return null;let a=n.split("-")[1];return{language:n,country:a&&a.length===2?a:null,locale:n}}};function U(e=l.markets,t=H()){let o=e||{};if(o.detect===!1)return{};let s=o.detect?o.detect===!0?["saved","server","webflow"]:[].concat(o.detect):["saved"];e=o;let n={sources:{}};return s.forEach(d=>{let a=Z[d]?.(e,t);if(!a)return;let r={country:K(a.country),language:Y(a.language),locale:a.locale||null};Object.entries(r).forEach(([i,p])=>{p&&!n[i]&&(n[i]=p,n.sources[i]=d)})}),n}var J=e=>e?`${String(e).slice(0,4)}\u2026${String(e).slice(-4)} (${String(e).length} chars)`:"(missing)";function W(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 L(e=document){let t=[],o=(r,i,p)=>t.push({level:r,message:i,element:p?W(p):void 0,el:p}),s=r=>!!r.closest(c("product")),n=`${c("collection")},${c("products")},${c("recommendations")}`;u(e,c("product")).forEach(r=>{if(r.closest(n)&&r.closest(c("list")))return;let{key:i,fromUrl:p,raw:m}=b(r);m?p&&!i&&o("warn",`${f("product")}="${m}" 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=>{u(e,c(r)).forEach(i=>{s(i)||r==="line-attribute"&&i.closest(c("group"))||o("warn",`${f(r)} outside any ${f("product")}: it does nothing here.`,i)})}),u(e,c("group-add")).forEach(r=>{r.closest(c("group"))||o("warn",`${f("group-add")} outside a ${f("group")}.`,r)}),[...u(e,c("option-list")),...u(e,c("plan-list")),...u(e,c("cart-lines")),...u(e,c("list"))].forEach(r=>{!r.firstElementChild&&!T(r)&&o("warn","Repeater without a template child: put one example element inside it.",r)}),u(e,n).forEach(r=>{u(r,c("list")).length||o("error",`List without a ${f("list")} child: products have nowhere to render.`,r)});let a=new Set(["in-stock","out-of-stock","backorder","low-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"]);return u(e,c("show")).forEach(r=>{let i=h(r,"show");a.has(i)||o("warn",`Unknown ${f("show")}="${i}".`,r)}),u(e,c("bind")).forEach(r=>{let i=h(r,"bind")||"";if(!i.startsWith("metafield:"))return;let p=i.slice(10);(l.metafields||[]).some(g=>(typeof g=="string"?g:`${g.namespace}.${g.key}`)===p)||o("error",`${f("bind")}="${i}" but "${p}" is not in config.metafields, so it stays empty.`,r)}),u(e,c("cart-open")).length&&!u(e,c("cart-drawer")).length&&o("warn",`${f("cart-open")} exists but there is no ${f("cart-drawer")} on this page.`),u(e,c("cart-drawer")).length>1&&o("warn",`More than one ${f("cart-drawer")}.`),u(e,`[${f("state")}="error"]`).forEach(r=>{r.matches(v())&&o("error",`Scope failed to load (${h(r,"error")||"error"}).`,r)}),t}async function X({root:e=document,silent:t=!1,version:o,now:s=new Date}={}){let n={version:o,config:{domain:l.domain||"(missing)",token:J(l.token),apiVersion:l.apiVersion,endpoint:l.domain?P():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:$(l.apiVersion,s),market:l.markets?.detect?U(l.markets):null,reachable:!1,shop:null,latencyMs:null,products:[],sellingPlans:[],problems:[]};if(!E())n.problems.push({level:"error",message:"TETHER_CONFIG needs domain and token."});else{let d=Date.now();try{let a=await w("query TetherDiagnose { shop { name primaryDomain { url } paymentSettings { currencyCode } } }",{},{context:!1});n.reachable=!0,n.shop={name:a.shop?.name,url:a.shop?.primaryDomain?.url,currency:a.shop?.paymentSettings?.currencyCode}}catch(a){let r=a.status===401||a.status===403?"Token rejected: use the public Storefront token from the Headless channel, not an Admin token.":a.status===404?"Store or API version not found: check domain (x.myshopify.com) and apiVersion.":"";n.problems.push({level:"error",message:`Storefront API not reachable: ${a.message}${r?`. ${r}`:""}`})}if(n.latencyMs=Date.now()-d,n.reachable){let a=[...new Set(u(e,c("product")).map(i=>b(i).key).filter(Boolean))].slice(0,20);(await Promise.allSettled(a.map(i=>x(i)))).forEach((i,p)=>{if(i.status==="fulfilled"){let m=i.value,g=C(m);n.products.push({key:a[p],handle:m.handle,title:m.title,plans:g.length,requiresSellingPlan:m.requiresSellingPlan}),g.forEach(y=>n.sellingPlans.push({product:m.handle,group:y.group?.name,plan:y.name,id:y.id}))}else n.products.push({key:a[p],error:i.reason?.message}),n.problems.push({level:"error",message:`Product "${a[p]}": ${i.reason?.message}. 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(...L(e)),t||Q(n),n}function Q(e){let t=console,o=e.problems.filter(s=>s.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 detected",e.market,"(in use:",e.config.country,e.config.language,")"),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(s=>(s.level==="error"?t.error:t.warn)(s.message,s.el||"")),t.groupEnd?.()}window.Tether.__parts.diagnose=k;})();
1
+ (()=>{var I=Object.defineProperty;var N=(e,t)=>{for(var o in t)I(e,o,{get:t[o],enumerable:!0})};var E={};N(E,{apiVersionStatus:()=>S,checkMarkup:()=>D,diagnose:()=>ee});var q=window.Tether.__core["config.js"],{DEFAULTS:ne,cfg:i,configure:re,isConfigured:T,log:ae,reportError:se,warn:ie}=q;var M=window.Tether.__core["client.js"],{TetherError:ce,endpoint:x,gql:$,request:ue,unwrap:pe,withContext:de}=M;var O=window.Tether.__core["dom.js"],{attr:f,busy:me,cdnUrl:he,dataKey:ge,emit:ye,formatDate:we,formatMoney:be,formatPercent:$e,get:w,has:Se,hasTemplate:C,imageUrl:ke,notifyLayoutChanged:Ee,parseJSONAttr:Pe,productUrl:Te,qsa:u,readText:xe,repeat:Ce,repeatKeyed:ve,sameImage:_e,scoped:Ae,sel:c,setImage:Ve,setSelected:Ue,setText:Le,setTextTracked:De,show:Ie,toAttributes:Ne,watchImages:qe}=O;var R=window.Tether.__core["loader.js"],{clearProductCache:Oe,getProduct:v,getProducts:Re,getRecommendations:je,hydrateProducts:ze,normalizeProductKey:Ge,primeProduct:Be,refreshProducts:He,takeStale:Ke}=R;var j=window.Tether.__core["selling-plans.js"],{GID:Fe,allPlans:_,allocationFor:Ze,findPlan:Je,hasPlans:We,planAdjustment:Xe,planCheckoutCharge:Qe,planPrice:et,planSavings:tt,plansForVariant:ot,toGid:nt}=j;var z=window.Tether.__core["status.js"],{STATUS_KEYS:at,boundary:A,isNotFound:st,ownedBy:it,resolveProductKey:b,setScopeStatus:lt}=z;var U=e=>{let t=/^(\d{4})-(01|04|07|10)$/.exec(String(e||""));return t?{y:+t[1],m:+t[2]}:null},G=(e,t)=>`${e}-${String(t).padStart(2,"0")}`;function V(e,t=1){let o=U(e);if(!o)throw new Error(`not a quarterly Shopify API version: ${e}`);let s=o.y*4+(o.m-1)/3+t;return G(Math.floor(s/4),s%4*3+1)}function S(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=U(e);if(!o)return{version:e,ok:!1,note:"not a quarterly version (YYYY-01, -04, -07 or -10)"};let s=new Date(Date.UTC(o.y,o.m-1,1)),n=new Date(Date.UTC(o.y+1,o.m-1,1)),d=(n-t)/(30.44*24*3600*1e3),a=`supported until about ${n.toISOString().slice(0,7)}`;return s>t?a="not released yet (release candidate at best)":d<=0?a="no longer supported: Shopify falls back to the oldest supported version. Upgrade (see README)":d<3&&(a=`${a}: plan the upgrade to ${V(e)} or later (see README)`),{version:e,ok:s<=t&&d>0,monthsLeft:Math.round(d),next:V(e),note:a}}var B=/^[A-Z]{2}$/,H=new Set(["PT_BR","PT_PT","ZH_CN","ZH_TW"]),K=()=>`${i.prefix}:market:${i.domain}`,Y=()=>({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 F(e){let t=String(e||"").trim().toUpperCase();return B.test(t)&&t!=="XX"&&t!=="T1"?t:null}function Z(e){let t=String(e||"").trim().replace("-","_").toUpperCase();if(!t)return null;if(H.has(t))return t;let o=t.split("_")[0];return/^[A-Z]{2,3}$/.test(o)?o:null}function J(e,t){if(!e||!t)return null;let o=String(e.cookie||"").split(";").map(s=>s.trim()).find(s=>s.startsWith(`${t}=`));return o?decodeURIComponent(o.slice(t.length+1)):null}var k=(e,t)=>{if(!e||!t)return null;let o=String(t).toLowerCase(),s=Object.keys(e).find(n=>n.toLowerCase()===o);return s?e[s]:null},W={saved(e,t){if(e.remember===!1||!t.storage)return null;try{return JSON.parse(t.storage.getItem(K())||"null")}catch{return null}},server(e,t){let o=d=>t.document?.querySelector?.(`meta[name="${d}"]`)?.getAttribute("content"),s=t.global.TETHER_COUNTRY||o("tether-country")||J(t.document,e.cookie||"tether_country"),n=t.global.TETHER_LANGUAGE||o("tether-language");return{country:s,language:n}},webflow(e,t){let o=(t.location?.pathname||"/").split("/").filter(Boolean)[0],s=k(e.locales,o);if(s)return s;let n=t.document?.documentElement?.getAttribute("lang");if(!n)return null;let d=k(e.locales,n)||k(e.locales,n.split("-")[0]);if(d)return{locale:n,...d};if(e.locales&&e.strict)return null;let a=n.split("-")[1];return{language:n,country:a&&a.length===2?a:null,locale:n}}};function L(e=i.markets,t=Y()){let o=e||{};if(o.detect===!1)return{};let s=o.detect?o.detect===!0?["saved","server","webflow"]:[].concat(o.detect):["saved"];e=o;let n={sources:{}};return s.forEach(d=>{let a=W[d]?.(e,t);if(!a)return;let r={country:F(a.country),language:Z(a.language),locale:a.locale||null};Object.entries(r).forEach(([l,p])=>{p&&!n[l]&&(n[l]=p,n.sources[l]=d)})}),n}var X=e=>e?`${String(e).slice(0,4)}\u2026${String(e).slice(-4)} (${String(e).length} chars)`:"(missing)";function Q(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 D(e=document){let t=[],o=(r,l,p)=>t.push({level:r,message:l,element:p?Q(p):void 0,el:p}),s=r=>!!r.closest(c("product")),n=`${c("collection")},${c("products")},${c("recommendations")}`;u(e,c("product")).forEach(r=>{if(r.closest(n)&&r.closest(c("list")))return;let{key:l,fromUrl:p,raw:m}=b(r);m?p&&!l&&o("warn",`${f("product")}="${m}" 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=>{u(e,c(r)).forEach(l=>{s(l)||r==="line-attribute"&&l.closest(c("group"))||o("warn",`${f(r)} outside any ${f("product")}: it does nothing here.`,l)})}),u(e,c("group-add")).forEach(r=>{r.closest(c("group"))||o("warn",`${f("group-add")} outside a ${f("group")}.`,r)}),[...u(e,c("option-list")),...u(e,c("plan-list")),...u(e,c("cart-lines")),...u(e,c("list"))].forEach(r=>{!r.firstElementChild&&!C(r)&&o("warn","Repeater without a template child: put one example element inside it.",r)}),u(e,n).forEach(r=>{u(r,c("list")).length||o("error",`List without a ${f("list")} child: products have nowhere to render.`,r)});let a=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"]);return u(e,c("show")).forEach(r=>{let l=w(r,"show");a.has(l)||o("warn",`Unknown ${f("show")}="${l}".`,r)}),u(e,c("bind")).forEach(r=>{let l=w(r,"bind")||"";if(!l.startsWith("metafield:"))return;let p=l.slice(10);(i.metafields||[]).some(y=>(typeof y=="string"?y:`${y.namespace}.${y.key}`)===p)||o("error",`${f("bind")}="${l}" but "${p}" is not in config.metafields, so it stays empty.`,r)}),u(e,c("cart-open")).length&&!u(e,c("cart-drawer")).length&&o("warn",`${f("cart-open")} exists but there is no ${f("cart-drawer")} on this page.`),u(e,c("cart-drawer")).length>1&&o("warn",`More than one ${f("cart-drawer")}.`),u(e,`[${f("state")}="error"]`).forEach(r=>{r.matches(A())&&o("error",`Scope failed to load (${w(r,"error")||"error"}).`,r)}),t}async function ee({root:e=document,silent:t=!1,version:o,now:s=new Date}={}){let n={version:o,config:{domain:i.domain||"(missing)",token:X(i.token),apiVersion:i.apiVersion,endpoint:i.domain?x():null,country:i.country,language:i.language,locale:i.locale,markets:i.markets||null,prefix:i.prefix,productPath:i.productPath,metafields:i.metafields,autoMount:i.autoMount,observe:i.observe,onError:typeof i.onError=="function"},apiVersion:S(i.apiVersion,s),market:{country:i.country||null,language:i.language||null,locale:i.locale||null,detected:i.markets?.detect?L(i.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 d=Date.now();try{let a=await $("query TetherDiagnose { shop { name primaryDomain { url } paymentSettings { currencyCode } } }",{},{context:!1});n.reachable=!0,n.shop={name:a.shop?.name,url:a.shop?.primaryDomain?.url,currency:a.shop?.paymentSettings?.currencyCode}}catch(a){let r=a.status===401||a.status===403?"Token rejected: use the public Storefront token from the Headless channel, not an Admin token.":a.status===404?"Store or API version not found: check domain (x.myshopify.com) and apiVersion.":"";n.problems.push({level:"error",message:`Storefront API not reachable: ${a.message}${r?`. ${r}`:""}`})}if(n.latencyMs=Date.now()-d,n.reachable){let a=[...new Set(u(e,c("product")).map(l=>b(l).key).filter(Boolean))].slice(0,20);(await Promise.allSettled(a.map(l=>v(l)))).forEach((l,p)=>{if(l.status==="fulfilled"){let m=l.value,y=_(m);n.products.push({key:a[p],handle:m.handle,title:m.title,plans:y.length,requiresSellingPlan:m.requiresSellingPlan}),y.forEach(h=>n.sellingPlans.push({product:m.handle,group:h.group?.name,plan:h.name,id:h.id})),u(e,c("product")).filter(h=>b(h).key===a[p]&&h.querySelector(c("add-to-cart"))).forEach(h=>{let P=new Set(u(h,`${c("option-list")},select${c("option")}`).map(g=>w(g,"option-list")||w(g,"option")));!P.size&&u(h,`select${c("variant-select")}`).length||(m.options||[]).filter(g=>g.optionValues.length>1&&!P.has(g.name)).forEach(g=>{n.problems.push({level:"warn",message:`Product "${m.handle}": option "${g.name}" (${g.optionValues.length} values) has no tether-option-list, so visitors can't choose it.`})})})}else n.products.push({key:a[p],error:l.reason?.message}),n.problems.push({level:"error",message:`Product "${a[p]}": ${l.reason?.message}. 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 ${i.apiVersion}: ${n.apiVersion.note}`}),typeof document<"u"&&n.problems.push(...D(e)),t||te(n),n}function te(e){let t=console,o=e.problems.filter(s=>s.level==="error").length;t.group?.(`[${i.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 detected",e.market,"(in use:",e.config.country,e.config.language,")"),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(s=>(s.level==="error"?t.error:t.warn)(s.message,s.el||"")),t.groupEnd?.()}window.Tether.__parts.diagnose=E;})();
@@ -0,0 +1,87 @@
1
+ (() => {
2
+ var __defProp = Object.defineProperty;
3
+ var __export = (target, all) => {
4
+ for (var name in all)
5
+ __defProp(target, name, { get: all[name], enumerable: true });
6
+ };
7
+
8
+ // src/extras.js
9
+ var extras_exports = {};
10
+ __export(extras_exports, {
11
+ addGroup: () => addGroup,
12
+ onStorage: () => onStorage,
13
+ writeVariantUrl: () => writeVariantUrl
14
+ });
15
+
16
+ // tether-core:config.js
17
+ var m = window.Tether.__core["config.js"];
18
+ var { DEFAULTS, cfg, configure, isConfigured, log, reportError, warn } = m;
19
+
20
+ // tether-core:dom.js
21
+ 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
+
24
+ // tether-core:product.js
25
+ var m3 = window.Tether.__core["product.js"];
26
+ var { ProductScope, rememberOptionNames, scopes } = m3;
27
+
28
+ // tether-core:cart.js
29
+ var m4 = window.Tether.__core["cart.js"];
30
+ var { Cart, focusables, toLineInput } = m4;
31
+
32
+ // src/extras.js
33
+ async function addGroup(btn) {
34
+ const group = btn.closest(sel("group"));
35
+ if (!group) return null;
36
+ 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;
43
+ });
44
+ if (!lines.length) {
45
+ warn("group-add: nothing selected");
46
+ return null;
47
+ }
48
+ try {
49
+ const cart = await Cart.add(lines);
50
+ emit("group-added", { group: name, lines }, group);
51
+ return cart;
52
+ } catch (err) {
53
+ reportError(err, "group add");
54
+ return null;
55
+ }
56
+ }
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
+ }
66
+ }
67
+ }
68
+ var urlKeys = /* @__PURE__ */ new WeakMap();
69
+ function writeVariantUrl(root, { variant, sellingPlanId }) {
70
+ const key = `${variant.id}|${sellingPlanId || ""}`;
71
+ const before = urlKeys.get(root);
72
+ urlKeys.set(root, key);
73
+ 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
+ }
83
+ }
84
+
85
+ // src/parts/extras.js
86
+ window.Tether.__parts.extras = extras_exports;
87
+ })();
@@ -0,0 +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;})();