@occluze/tether 0.4.0 → 0.5.0
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.
- package/README.md +7 -5
- package/dist/esm/astro.js +2 -0
- package/dist/esm/chunks/chunk-HHMOPDZG.js +1 -0
- package/dist/esm/chunks/chunk-HXKV6QGB.js +4 -0
- package/dist/esm/chunks/{chunk-KYQ5OGBX.js → chunk-RBVRRQIU.js} +1 -1
- package/dist/esm/chunks/chunk-RNZMTQTX.js +1 -0
- package/dist/esm/chunks/chunk-VC46IEJQ.js +1 -0
- package/dist/esm/chunks/diagnose-J667GHGS.js +1 -0
- package/dist/esm/chunks/markets-ui-EGWIEUOZ.js +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/server.js +1 -0
- package/dist/tether.diagnose.js +4 -3
- package/dist/tether.diagnose.min.js +1 -1
- package/dist/tether.js +229 -61
- package/dist/tether.markets.js +16 -10
- package/dist/tether.markets.min.js +1 -1
- package/dist/tether.min.js +3 -3
- package/dist/tether.min.js.map +3 -3
- package/package.json +27 -4
- package/src/astro.js +73 -0
- package/src/cart.js +47 -7
- package/src/client.js +25 -15
- package/src/config.js +2 -0
- package/src/diagnose.js +1 -1
- package/src/dom.js +32 -9
- package/src/fragments.js +12 -11
- package/src/index.js +18 -6
- package/src/initial.js +66 -0
- package/src/loader.js +49 -6
- package/src/markets-ui.js +13 -5
- package/src/markets.js +1 -1
- package/src/mounting.js +42 -2
- package/src/product.js +33 -9
- package/src/server.js +179 -0
- package/src/status.js +1 -6
- package/types/astro.d.ts +15 -0
- package/types/index.d.ts +17 -2
- package/types/server.d.ts +94 -0
- package/dist/esm/chunks/chunk-GHIUMD5H.js +0 -1
- package/dist/esm/chunks/chunk-LI3YDMGF.js +0 -4
- package/dist/esm/chunks/diagnose-ZXXXJIQE.js +0 -1
- package/dist/esm/chunks/markets-ui-AG6Y5VUE.js +0 -1
package/dist/tether.markets.js
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
// tether-core:client.js
|
|
22
22
|
var m2 = window.Tether.__core["client.js"];
|
|
23
|
-
var { TetherError, endpoint, gql, unwrap, withContext } = m2;
|
|
23
|
+
var { TetherError, endpoint, gql, request, unwrap, withContext } = m2;
|
|
24
24
|
|
|
25
25
|
// tether-core:cart.js
|
|
26
26
|
var m3 = window.Tether.__core["cart.js"];
|
|
@@ -32,15 +32,15 @@
|
|
|
32
32
|
|
|
33
33
|
// tether-core:loader.js
|
|
34
34
|
var m5 = window.Tether.__core["loader.js"];
|
|
35
|
-
var { clearProductCache, getProduct, getProducts, getRecommendations, normalizeProductKey, primeProduct } = m5;
|
|
35
|
+
var { clearProductCache, getProduct, getProducts, getRecommendations, hydrateProducts, normalizeProductKey, primeProduct, refreshProducts, takeStale } = m5;
|
|
36
36
|
|
|
37
37
|
// tether-core:dom.js
|
|
38
38
|
var m6 = window.Tether.__core["dom.js"];
|
|
39
|
-
var { attr, busy, cdnUrl, dataKey, emit, formatDate, formatMoney, get, has, hasTemplate, notifyLayoutChanged, parseJSONAttr, productUrl, qsa, readText, repeat, repeatKeyed, scoped, sel, setImage, setSelected, setText, setTextTracked, show, toAttributes, watchImages } = m6;
|
|
39
|
+
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 } = m6;
|
|
40
40
|
|
|
41
41
|
// tether-core:mounting.js
|
|
42
42
|
var m7 = window.Tether.__core["mounting.js"];
|
|
43
|
-
var { liveLists, liveProducts, mountProduct, mountedLists, mountedProducts, pruneLive, retryFailed, within } = m7;
|
|
43
|
+
var { hydrateFromPage, liveLists, liveProducts, mountProduct, mountedLists, mountedProducts, pruneLive, retryFailed, within } = m7;
|
|
44
44
|
|
|
45
45
|
// src/markets.js
|
|
46
46
|
var COUNTRY = /^[A-Z]{2}$/;
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
function rememberMarket(market) {
|
|
131
131
|
if (cfg.markets?.remember === false) return;
|
|
132
132
|
try {
|
|
133
|
-
localStorage.setItem(storageKey(), JSON.stringify({ country: market.country, language: market.language || void 0 }));
|
|
133
|
+
localStorage.setItem(storageKey(), JSON.stringify({ country: market.country, language: market.language || void 0, locale: market.locale || void 0 }));
|
|
134
134
|
} catch {
|
|
135
135
|
}
|
|
136
136
|
}
|
|
@@ -160,11 +160,13 @@
|
|
|
160
160
|
const fill = (tpl, c) => tpl.replace(/\{name\}/g, c.name).replace(/\{code\}/g, c.isoCode).replace(/\{currency\}/g, c.currency?.isoCode || "").replace(/\{symbol\}/g, c.currency?.symbol || "");
|
|
161
161
|
selects.forEach((s) => {
|
|
162
162
|
const tpl = s.getAttribute(attr("country-label")) || "{name} ({currency})";
|
|
163
|
+
const only = (s.getAttribute(attr("countries")) || "").toUpperCase().split(/[\s,]+/).filter(Boolean);
|
|
164
|
+
const list = only.length ? only.map((c) => countries.find((x) => x.isoCode === c)).filter(Boolean) : countries;
|
|
163
165
|
s.innerHTML = "";
|
|
164
|
-
|
|
166
|
+
list.forEach((c) => s.appendChild(new Option(fill(tpl, c), c.isoCode)));
|
|
165
167
|
s.value = current;
|
|
166
168
|
if (s.value !== current) s.selectedIndex = -1;
|
|
167
|
-
s.disabled =
|
|
169
|
+
s.disabled = list.length < 2 && !s.hasAttribute(attr("always-enabled"));
|
|
168
170
|
});
|
|
169
171
|
binds.forEach((el) => {
|
|
170
172
|
const k = get(el, "country-bind") || "name";
|
|
@@ -173,14 +175,18 @@
|
|
|
173
175
|
});
|
|
174
176
|
}).catch((err) => reportError(err, "country select"));
|
|
175
177
|
}
|
|
176
|
-
async function setCountry(code, { language, remember = true } = {}) {
|
|
178
|
+
async function setCountry(code, { language, locale, remember = true } = {}) {
|
|
177
179
|
const country = toCountry(code);
|
|
178
180
|
if (!country) throw new TetherError(`Not a country code: ${code}`, { code: "INVALID_COUNTRY" });
|
|
181
|
+
const entry = Object.values(cfg.markets?.locales || {}).find((m8) => toCountry(m8?.country) === country);
|
|
182
|
+
const own = locale || entry?.locale;
|
|
183
|
+
const loc = own || cfg.locale;
|
|
179
184
|
const lang = language === void 0 ? cfg.language : toLanguage(language);
|
|
180
|
-
const changed = country !== String(cfg.country || "").toUpperCase() || lang !== cfg.language;
|
|
185
|
+
const changed = country !== String(cfg.country || "").toUpperCase() || lang !== cfg.language || loc !== cfg.locale;
|
|
181
186
|
cfg.country = country;
|
|
182
187
|
cfg.language = lang || void 0;
|
|
183
|
-
|
|
188
|
+
cfg.locale = loc;
|
|
189
|
+
if (remember) rememberMarket({ country, language: lang, locale: own });
|
|
184
190
|
if (!changed) {
|
|
185
191
|
renderCountrySelects();
|
|
186
192
|
return Cart.state;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var
|
|
1
|
+
(()=>{var G=Object.defineProperty;var H=(e,t)=>{for(var r in t)G(e,r,{get:t[r],enumerable:!0})};var P={};H(P,{detectMarket:()=>$,getLocalization:()=>w,renderCountrySelects:()=>x,setCountry:()=>oe});var K=window.Tether.__core["config.js"],{DEFAULTS:ne,cfg:a,configure:ce,isConfigured:ae,log:le,reportError:C,warn:se}=K;var Z=window.Tether.__core["client.js"],{TetherError:E,endpoint:ue,gql:S,request:de,unwrap:me,withContext:fe}=Z;var D=window.Tether.__core["cart.js"],{Cart:f,focusables:pe,toLineInput:ye}=D;var F=window.Tether.__core["collection.js"],{ListScope:we,listSelector:A}=F;var J=window.Tether.__core["loader.js"],{clearProductCache:v,getProduct:be,getProducts:Te,getRecommendations:_e,hydrateProducts:Le,normalizeProductKey:xe,primeProduct:Pe,refreshProducts:Ee,takeStale:Se}=J;var Y=window.Tether.__core["dom.js"],{attr:y,busy:ve,cdnUrl:Ue,dataKey:Ie,emit:U,formatDate:Ne,formatMoney:je,get:I,has:ke,hasTemplate:Oe,imageUrl:ze,notifyLayoutChanged:Re,parseJSONAttr:$e,productUrl:qe,qsa:Me,readText:Be,repeat:Ge,repeatKeyed:He,sameImage:Ke,scoped:Ze,sel:b,setImage:De,setSelected:Fe,setText:Je,setTextTracked:Ye,show:We,toAttributes:Xe,watchImages:Ve}=Y;var W=window.Tether.__core["mounting.js"],{hydrateFromPage:et,liveLists:N,liveProducts:j,mountProduct:k,mountedLists:tt,mountedProducts:O,pruneLive:z,retryFailed:ot,within:T}=W;var X=/^[A-Z]{2}$/,V=new Set(["PT_BR","PT_PT","ZH_CN","ZH_TW"]),R=()=>`${a.prefix}:market:${a.domain}`,Q=()=>({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 h(e){let t=String(e||"").trim().toUpperCase();return X.test(t)&&t!=="XX"&&t!=="T1"?t:null}function L(e){let t=String(e||"").trim().replace("-","_").toUpperCase();if(!t)return null;if(V.has(t))return t;let r=t.split("_")[0];return/^[A-Z]{2,3}$/.test(r)?r:null}function ee(e,t){if(!e||!t)return null;let r=String(e.cookie||"").split(";").map(c=>c.trim()).find(c=>c.startsWith(`${t}=`));return r?decodeURIComponent(r.slice(t.length+1)):null}var _=(e,t)=>{if(!e||!t)return null;let r=String(t).toLowerCase(),c=Object.keys(e).find(o=>o.toLowerCase()===r);return c?e[c]:null},te={saved(e,t){if(e.remember===!1||!t.storage)return null;try{return JSON.parse(t.storage.getItem(R())||"null")}catch{return null}},server(e,t){let r=i=>t.document?.querySelector?.(`meta[name="${i}"]`)?.getAttribute("content"),c=t.global.TETHER_COUNTRY||r("tether-country")||ee(t.document,e.cookie||"tether_country"),o=t.global.TETHER_LANGUAGE||r("tether-language");return{country:c,language:o}},webflow(e,t){let r=(t.location?.pathname||"/").split("/").filter(Boolean)[0],c=_(e.locales,r);if(c)return c;let o=t.document?.documentElement?.getAttribute("lang");if(!o)return null;let i=_(e.locales,o)||_(e.locales,o.split("-")[0]);if(i)return{locale:o,...i};if(e.locales&&e.strict)return null;let l=o.split("-")[1];return{language:o,country:l&&l.length===2?l:null,locale:o}}};function $(e=a.markets,t=Q()){let r=e||{};if(r.detect===!1)return{};let c=r.detect?r.detect===!0?["saved","server","webflow"]:[].concat(r.detect):["saved"];e=r;let o={sources:{}};return c.forEach(i=>{let l=te[i]?.(e,t);if(!l)return;let m={country:h(l.country),language:L(l.language),locale:l.locale||null};Object.entries(m).forEach(([n,s])=>{s&&!o[n]&&(o[n]=s,o.sources[n]=i)})}),o}function q(e){if(a.markets?.remember!==!1)try{localStorage.setItem(R(),JSON.stringify({country:e.country,language:e.language||void 0,locale:e.locale||void 0}))}catch{}}var g=null;function M(){g=null}function w(){return g||(g=S("query TetherLocalization{localization{country{isoCode name currency{isoCode symbol}}language{isoCode name}availableCountries{isoCode name currency{isoCode symbol}availableLanguages{isoCode name}}}}").then(e=>e.localization).catch(e=>{throw g=null,e})),g}function x(e=document){let t=T(e,`select${b("country-select")}`),r=T(e,b("country-bind"));return!t.length&&!r.length?Promise.resolve():w().then(c=>{let o=(a.country||c.country?.isoCode||"").toUpperCase(),i=[...c.availableCountries||[]].sort((n,s)=>n.name.localeCompare(s.name,a.locale||void 0)),l=i.find(n=>n.isoCode===o)||c.country,m=(n,s)=>n.replace(/\{name\}/g,s.name).replace(/\{code\}/g,s.isoCode).replace(/\{currency\}/g,s.currency?.isoCode||"").replace(/\{symbol\}/g,s.currency?.symbol||"");t.forEach(n=>{let s=n.getAttribute(y("country-label"))||"{name} ({currency})",d=(n.getAttribute(y("countries"))||"").toUpperCase().split(/[\s,]+/).filter(Boolean),u=d.length?d.map(p=>i.find(B=>B.isoCode===p)).filter(Boolean):i;n.innerHTML="",u.forEach(p=>n.appendChild(new Option(m(s,p),p.isoCode))),n.value=o,n.value!==o&&(n.selectedIndex=-1),n.disabled=u.length<2&&!n.hasAttribute(y("always-enabled"))}),r.forEach(n=>{let s=I(n,"country-bind")||"name",d={name:l?.name,code:l?.isoCode,currency:l?.currency?.isoCode,symbol:l?.currency?.symbol}[s];n.textContent=d||""})}).catch(c=>C(c,"country select"))}async function oe(e,{language:t,locale:r,remember:c=!0}={}){let o=h(e);if(!o)throw new E(`Not a country code: ${e}`,{code:"INVALID_COUNTRY"});let i=Object.values(a.markets?.locales||{}).find(u=>h(u?.country)===o),l=r||i?.locale,m=l||a.locale,n=t===void 0?a.language:L(t),s=o!==String(a.country||"").toUpperCase()||n!==a.language||m!==a.locale;if(a.country=o,a.language=n||void 0,a.locale=m,c&&q({country:o,language:n,locale:l}),!s)return x(),f.state;v();let d=[];return t!==void 0&&M(),f.id()&&d.push(f.setBuyerIdentity({countryCode:o},{create:!1}).catch(u=>C(u,"cart country"))),z(),N.forEach(u=>d.push(u.load())),j.forEach(u=>{u.closest(A())||(O.delete(u),k(u))}),x(),U("country-changed",{country:o,language:a.language}),await Promise.all(d),f.state}window.Tether.__parts.markets=P;})();
|
package/dist/tether.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(()=>{var
|
|
1
|
+
(()=>{var rr=Object.defineProperty;var F=(t,e)=>{for(var r in e)rr(t,r,{get:e[r],enumerable:!0})};var It={};F(It,{DEFAULTS:()=>Jt,cfg:()=>c,configure:()=>zt,isConfigured:()=>Ct,log:()=>T,reportError:()=>x,warn:()=>L});var Jt={domain:"",token:"",apiVersion:"2026-07",country:void 0,language:void 0,locale:void 0,markets:null,prefix:"tether",productPath:"/product",collectionPath:"/collection",metafields:[],imagesFirst:25,variantsFirst:100,sellingPlanGroupsFirst:10,sellingPlansFirst:25,collectionFirst:24,retries:2,revalidate:!0,storageKey:null,cartDrawerOpenClass:"is-open",openCartOnAdd:!0,cartFocus:!0,checkoutTarget:"_self",defaultPurchase:"one-time",autoMount:!0,observe:!1,astro:!0,partsUrl:null,formatMoney:null,onLayoutChange:null,onCartOpen:null,onCartClose:null,onLineEnter:null,onLineLeave:null,onValueChange:null,onError:null,debug:!1},c={...Jt};function zt(t={}){return Object.keys(c).forEach(e=>delete c[e]),Object.assign(c,Jt,t),c.domain&&(c.domain=String(c.domain).replace(/^https?:\/\//,"").replace(/\/.*$/,"")),c.storageKey||(c.storageKey=`${c.prefix}:cart:${c.domain}`),c.apiVersion==="unstable"&&L('apiVersion "unstable" changes without notice. Pin a dated version (e.g. 2026-07).'),c}var Ct=()=>!!(c.domain&&c.token);function T(...t){c.debug&&console.log(`[${c.prefix}]`,...t)}function L(...t){console.warn(`[${c.prefix}]`,...t)}function x(t,e){if(L(e,t&&t.message?t.message:t),typeof c.onError=="function")try{c.onError(t,e)}catch{}}var Zt={};F(Zt,{TetherError:()=>I,endpoint:()=>Oe,gql:()=>q,request:()=>kt,unwrap:()=>Xt,withContext:()=>Tt});var I=class extends Error{constructor(e,{status:r,errors:n,userErrors:i,code:s}={}){super(e),this.name="TetherError",this.code=s||(r?`HTTP_${r}`:"ERROR"),this.status=r,this.errors=n,this.userErrors=i}};function Oe(t=c){return`https://${t.domain}/api/${t.apiVersion}/graphql.json`}function Tt(t,e=c){let r=[];if(e.country&&r.push(`country: ${String(e.country).toUpperCase()}`),e.language&&r.push(`language: ${String(e.language).toUpperCase().replace("-","_")}`),!r.length||/@inContext/.test(t))return t;let n=`@inContext(${r.join(", ")})`;return/^\s*\{/.test(t)?`query ${n} ${t.trimStart()}`:t.replace(/^(\s*(?:query|mutation)(?:\s+\w+)?\s*(?:\([^)]*\))?)/,`$1 ${n}`)}var Yt=t=>new Promise(e=>setTimeout(e,t));async function kt(t,e,r={},{context:n=!0}={}){if(!t.domain||!t.token)throw new I("Tether is not configured: domain and token are required",{code:"NOT_CONFIGURED"});let i=JSON.stringify({query:n?Tt(e,t):e,variables:r}),s=0;for(;;){let o;try{o=await(t.fetch||fetch)(Oe(t),{method:"POST",headers:{"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":t.token},body:i})}catch(f){if(s++<t.retries){await Yt(300*2**s);continue}throw new I(`Network error: ${f.message}`,{code:"NETWORK"})}if(o.status===430)throw new I("Shopify security rejection (430)",{status:430});if((o.status===429||o.status>=500)&&s++<t.retries){T("retry",o.status,s),await Yt(300*2**s);continue}let p;try{p=await o.json()}catch{throw new I(`Invalid response (${o.status})`,{status:o.status})}if(p.errors?.length){if(p.errors.some(h=>/quantityAvailable/.test(h.message||""))&&/\bquantityAvailable\b/.test(i))return T("no inventory permission, retrying without quantityAvailable"),kt(t,e.replace(/\bquantityAvailable\b/g,""),r,{context:n});if(p.errors.some(h=>/'warnings'/.test(h.message||""))&&/warnings \{ code message \}/.test(e))return kt(t,e.replace(/ warnings \{ code message \}/g,""),r,{context:n});if(p.errors.some(h=>h.extensions?.code==="THROTTLED")&&s++<t.retries){await Yt(500*2**s);continue}throw new I(p.errors.map(h=>h.message).join(" | "),{status:o.status,errors:p.errors})}if(!o.ok)throw new I(`HTTP ${o.status}`,{status:o.status});return p.data}}var q=(t,e,r)=>kt(c,t,e,r);function Xt(t,e){if(!t)throw new I(`${e}: empty response`);let r=t.userErrors||[];if(r.length)throw new I(r.map(n=>n.message).join(" | "),{userErrors:r});return t}var $e={};F($e,{Cart:()=>P,focusables:()=>Ut,toLineInput:()=>Ke});var ee={};F(ee,{ALLOCATION_FIELDS:()=>_e,SELLING_PLAN_FIELDS:()=>Fe,cartFragment:()=>Lt,collectionFields:()=>te,metafieldIdentifiers:()=>Ne,productFragment:()=>ut});var w="amount currencyCode",z="url altText width height";function Ne(t=c){return(t.metafields||[]).map(e=>{if(typeof e=="string"){let r=e.indexOf(".");return{namespace:e.slice(0,r),key:e.slice(r+1)}}return e}).filter(e=>e.namespace&&e.key)}function nr(t=c){let e=Ne(t);return e.length?`metafields(identifiers:[${e.map(n=>`{namespace: ${JSON.stringify(n.namespace)}, key: ${JSON.stringify(n.key)}}`).join(", ")}]){namespace key type value reference{... on MediaImage{image{${z}}}}}`:""}var Fe=` id name description recurringDeliveries options{name value}priceAdjustments{orderCount adjustmentValue{__typename ... on SellingPlanPercentagePriceAdjustment{adjustmentPercentage}... on SellingPlanFixedAmountPriceAdjustment{adjustmentAmount{${w}}}... on SellingPlanFixedPriceAdjustment{price{${w}}}}}`,_e=` sellingPlan{id}checkoutChargeAmount{${w}}remainingBalanceChargeAmount{${w}}priceAdjustments{price{${w}}compareAtPrice{${w}}perDeliveryPrice{${w}}unitPrice{${w}}}`;function ut(t=c){return` fragment TetherProduct on Product{id handle title description descriptionHtml productType vendor tags availableForSale publishedAt onlineStoreUrl requiresSellingPlan seo{title description}featuredImage{${z}}images(first:${t.imagesFirst}){nodes{${z}}}options{name optionValues{name swatch{color image{previewImage{${z}}}}}}priceRange{minVariantPrice{${w}}maxVariantPrice{${w}}}compareAtPriceRange{minVariantPrice{${w}}maxVariantPrice{${w}}}${nr(t)} sellingPlanGroups(first:${t.sellingPlanGroupsFirst}){nodes{name appName options{name values}sellingPlans(first:${t.sellingPlansFirst}){nodes{${Fe}}}}}variants(first:${t.variantsFirst}){nodes{id title availableForSale currentlyNotInStock quantityAvailable sku barcode selectedOptions{name value}image{${z}}price{${w}}compareAtPrice{${w}}unitPrice{${w}}sellingPlanAllocations(first:${t.sellingPlansFirst}){nodes{${_e}}}}}}`}function Lt(){return` fragment TetherCart on Cart{id checkoutUrl totalQuantity note createdAt updatedAt attributes{key value}buyerIdentity{countryCode email}discountCodes{code applicable}cost{subtotalAmount{${w}}totalAmount{${w}}checkoutChargeAmount{${w}}}lines(first:100){nodes{id quantity attributes{key value}cost{totalAmount{${w}}subtotalAmount{${w}}amountPerQuantity{${w}}compareAtAmountPerQuantity{${w}}}discountAllocations{discountedAmount{${w}}}sellingPlanAllocation{sellingPlan{id name description recurringDeliveries options{name value}}checkoutChargeAmount{${w}}priceAdjustments{price{${w}}compareAtPrice{${w}}perDeliveryPrice{${w}}}}merchandise{... on ProductVariant{id title sku availableForSale requiresShipping image{${z}}price{${w}}compareAtPrice{${w}}selectedOptions{name value}product{id title handle vendor featuredImage{${z}}}}}... on ComponentizableCartLine{lineComponents{id quantity merchandise{... on ProductVariant{id title product{title handle}}}}}}}}`}function te(){return`
|
|
2
2
|
id handle title description descriptionHtml
|
|
3
|
-
image { ${
|
|
4
|
-
seo { title description }`}var Xt={};_(Xt,{clearProductCache:()=>Yt,getProduct:()=>V,getProducts:()=>ct,getRecommendations:()=>lt,normalizeProductKey:()=>kt,primeProduct:()=>Z});var J=new Map,Ae=[],Wt=new Map,Jt=!1,at=0,zt=e=>typeof e=="string"&&e.startsWith("gid://");function kt(e){let t=String(e??"").trim();if(!t)return null;if(zt(t))return t;if(/^\d+$/.test(t))return`gid://shopify/Product/${t}`;let r=t.match(/\/products\/([^/?#]+)/);return r?r[1]:t}function Z(e){if(!e)return;let t=Promise.resolve(e);J.set(e.handle,t),J.set(e.id,t)}function V(e){let t=kt(e);if(!t)return Promise.reject(new I("empty product key",{code:"NOT_FOUND"}));if(J.has(t))return J.get(t);let r=new Promise((n,i)=>{Wt.set(t,{resolve:n,reject:i}),Ae.push(t),Jt||(Jt=!0,setTimeout(Ke,0))});return J.set(t,r),r}async function Ke(){Jt=!1;let e=at,t=Ae.splice(0);if(!t.length)return;let r=t.filter(zt),n=t.filter(b=>!zt(b)),i=[],s=[],o={};r.length&&(i.push("$ids: [ID!]!"),o.ids=r,s.push("byId: nodes(ids: $ids) { ... on Product { ...TetherProduct } }")),n.forEach((b,p)=>{i.push(`$h${p}: String!`),o[`h${p}`]=b,s.push(`h${p}: product(handle: $h${p}) { ...TetherProduct }`)});let l=`query TetherProducts(${i.join(",")}){${s.join(" ")}}${ot()}`;L("fetch products",t);let f=(b,p)=>{let m=Wt.get(b);Wt.delete(b),m&&p(m)};try{let b=await T(l,o),p=new Map;(b.byId||[]).forEach(m=>{m&&p.set(m.id,m)}),n.forEach((m,C)=>{b[`h${C}`]&&p.set(m,b[`h${C}`])}),t.forEach(m=>f(m,C=>{p.has(m)?(e===at&&Z(p.get(m)),C.resolve(p.get(m))):(e===at&&J.delete(m),C.reject(new I(`Product not found: ${m}`,{code:"NOT_FOUND"})))}))}catch(b){t.forEach(p=>f(p,m=>{e===at&&J.delete(p),m.reject(b)}))}}function Yt(){J.clear(),at++}async function ct({collection:e,query:t,first:r=c.collectionFirst,after:n=null,sortKey:i,reverse:s=!1,filters:o}={}){let l=ot();if(e){let b=await T(`query TetherCollection($handle:String!,$first:Int!,$after:String,$sortKey:ProductCollectionSortKeys,$reverse:Boolean,$filters:[ProductFilter!]){collection(handle:$handle){${Gt()} products(first:$first,after:$after,sortKey:$sortKey,reverse:$reverse,filters:$filters){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}}${l}`,{handle:e,first:r,after:n,sortKey:i||void 0,reverse:s,filters:o||void 0});if(!b.collection)throw new I(`Collection not found: ${e}`,{code:"NOT_FOUND"});let{products:p,...m}=b.collection;return p.nodes.forEach(Z),{collection:m,products:p.nodes,pageInfo:p.pageInfo}}let f=await T(`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}}}${l}`,{first:r,after:n,query:t||void 0,sortKey:i||void 0,reverse:s});return f.products.nodes.forEach(Z),{collection:null,products:f.products.nodes,pageInfo:f.products.pageInfo}}async function lt(e,t="RELATED"){let n=(await T(`query TetherRecs($id:ID!,$intent:ProductRecommendationIntent){productRecommendations(productId:$id,intent:$intent){...TetherProduct}}${ot()}`,{id:e,intent:t})).productRecommendations||[];return n.forEach(Z),n}var pt={};_(pt,{GID:()=>j,allPlans:()=>R,allocationFor:()=>N,findPlan:()=>dt,hasPlans:()=>Be,planAdjustment:()=>te,planCheckoutCharge:()=>Zt,planPrice:()=>ut,planSavings:()=>Lt,plansForVariant:()=>He,toGid:()=>Tt});var j={product:e=>Tt(e,"Product"),variant:e=>Tt(e,"ProductVariant"),sellingPlan:e=>Tt(e,"SellingPlan")};function Tt(e,t){let r=String(e??"").trim();return r?r.startsWith("gid://")?r:/^\d+$/.test(r)?`gid://shopify/${t}/${r}`:r:null}function R(e){return(e?.sellingPlanGroups?.nodes||[]).flatMap(r=>(r.sellingPlans?.nodes||[]).map(n=>({...n,group:r})))}function Be(e){return R(e).length>0}function N(e,t){return!e||!t?null:(e.sellingPlanAllocations?.nodes||[]).find(r=>r.sellingPlan?.id===t)||null}function He(e,t){return R(e).filter(r=>N(t,r.id))}function ut(e,t){let n=N(e,t)?.priceAdjustments?.[0];return n?.perDeliveryPrice||n?.price||e?.price||null}function Zt(e,t){let r=N(e,t);return r?.checkoutChargeAmount||r?.priceAdjustments?.[0]?.price||e?.price||null}function Lt(e,t){let r=parseFloat(e?.price?.amount),n=parseFloat(ut(e,t)?.amount);return!Number.isFinite(r)||!Number.isFinite(n)||r<=0||n>=r?{amount:null,percentage:0}:{amount:{amount:(r-n).toFixed(2),currencyCode:e.price.currencyCode},percentage:Math.round((1-n/r)*100)}}function te(e){let t=e?.priceAdjustments?.[0]?.adjustmentValue;if(!t)return null;switch(t.__typename){case"SellingPlanPercentagePriceAdjustment":return{type:"percentage",value:t.adjustmentPercentage};case"SellingPlanFixedAmountPriceAdjustment":return{type:"amount",value:t.adjustmentAmount};case"SellingPlanFixedPriceAdjustment":return{type:"price",value:t.price};default:return null}}function dt(e,t){if(!t)return null;let r=R(e),n=j.sellingPlan(t),i=String(t).trim().toLowerCase();return r.find(s=>s.id===n)||r.find(s=>s.name.toLowerCase()===i)||r.find(s=>(s.options||[]).some(o=>String(o.value).toLowerCase()===i))||null}var se={};_(se,{attr:()=>h,busy:()=>M,cdnUrl:()=>Se,dataKey:()=>Ce,emit:()=>w,formatDate:()=>re,formatMoney:()=>q,get:()=>d,has:()=>z,hasTemplate:()=>Ge,notifyLayoutChanged:()=>K,parseJSONAttr:()=>mt,productUrl:()=>ft,qsa:()=>$,readText:()=>ee,repeat:()=>U,repeatKeyed:()=>ne,scoped:()=>Y,sel:()=>a,setImage:()=>F,setSelected:()=>ht,setText:()=>A,setTextTracked:()=>tt,show:()=>D,toAttributes:()=>B,watchImages:()=>ie});var h=e=>`${c.prefix}-${e}`,a=(e,t)=>t===void 0?`[${h(e)}]`:`[${h(e)}="${t}"]`,d=(e,t)=>e.getAttribute(h(t)),z=(e,t)=>e.hasAttribute(h(t)),Ce=()=>`data-${c.prefix}-key`;function ft(e,t){let r=c.productPath||"/product";if(!/\{(handle|id)\}/.test(r))return`${r.replace(/\/$/,"")}/${e}`;let n=t?String(t).split("/").pop():"";return r.replace(/\{handle\}/g,encodeURIComponent(e||"")).replace(/\{id\}/g,encodeURIComponent(n))}var $=(e,t)=>e?[...e.querySelectorAll(t)]:[],Y=(e,t,r)=>$(e,t).filter(n=>n.closest(r)===e);function w(e,t,r=document){r.dispatchEvent(new CustomEvent(`${c.prefix}:${e}`,{detail:t,bubbles:!0}))}function q(e){if(!e)return"";if(typeof c.formatMoney=="function")return c.formatMoney(e,c.locale);let t=parseFloat(e.amount);if(Number.isNaN(t))return"";try{return new Intl.NumberFormat(c.locale||void 0,{style:"currency",currency:e.currencyCode}).format(t)}catch{return`${e.currencyCode} ${t.toFixed(2)}`}}function re(e){if(!e)return"";try{return new Date(e).toLocaleDateString(c.locale||void 0)}catch{return""}}function Se(e,t){if(!e||!t)return e;let r=t.getAttribute("max-width"),n=t.getAttribute("max-height"),i=t.getAttribute("crop");if(!r&&!n)return e;try{let s=new URL(e);return r&&s.searchParams.set("width",r),n&&s.searchParams.set("height",n),i&&s.searchParams.set("crop",i),s.toString()}catch{return e}}function F(e,t,r){if(!t)return;let n=Se(t,e);e.tagName==="IMG"?(e.removeAttribute("srcset"),e.removeAttribute("sizes"),e.setAttribute("src",n),r!=null&&e.setAttribute("alt",r),e.getAttribute("loading")||e.setAttribute("loading","lazy")):e.style.backgroundImage=`url("${n}")`}function A(e,t){let r=t==null?"":String(t);e.tagName==="INPUT"||e.tagName==="TEXTAREA"?e.value=r:e.textContent=r}var ee=e=>e.tagName==="INPUT"||e.tagName==="TEXTAREA"?e.value:e.textContent;function tt(e,t){let r=ee(e);A(e,t);let n=ee(e);if(r!==n&&e.dataset.tetherSeen&&typeof c.onValueChange=="function")try{c.onValueChange(e,r)}catch{}e.dataset.tetherSeen="1"}function D(e,t){let r="tetherPrevDisplay";t?e.dataset[r]!==void 0?(e.style.display=e.dataset[r],delete e.dataset[r]):e.style.display==="none"&&(e.style.display=""):(e.dataset[r]===void 0&&(e.dataset[r]=e.style.display||""),e.style.display="none")}function ht(e,t){e.classList.toggle("is-selected",t),e.setAttribute("aria-pressed",t?"true":"false"),e.tagName==="INPUT"&&(e.type==="radio"||e.type==="checkbox")&&(e.checked=t);let r=e.querySelector?.('input[type="radio"],input[type="checkbox"]');r&&(r.checked=t)}var qt=new WeakMap,Ge=e=>!!qt.get(e);function Ie(e){if(!qt.has(e)){let t=e.firstElementChild?.cloneNode(!0)??null;qt.set(e,t),e.innerHTML=""}return qt.get(e)}function U(e,t,r){let n=Ie(e);if(!n){O("repeater without a template child",e);return}e.innerHTML="",t.forEach((i,s)=>{let o=n.cloneNode(!0);r(o,i,s),e.appendChild(o)})}function ne(e,t,r,n,{onEnter:i,onLeave:s}={}){let o=Ie(e);if(!o){O("repeater without a template child",e);return}let l=Ce(),f=`data-${c.prefix}-leaving`,b=()=>[...e.children].filter(y=>y.hasAttribute(l)&&!y.hasAttribute(f)),p=new Map(b().map(y=>[y.getAttribute(l),y])),m=[],C=new Set;t.forEach((y,u)=>{let g=String(r(y,u)),E=p.get(g);E?p.delete(g):(E=o.cloneNode(!0),E.setAttribute(l,g),C.add(E)),n(E,y,u,C.has(E)),m.push(E)});let S=m.filter(y=>!C.has(y)),st=b().filter(y=>S.includes(y));if(!(st.length===S.length&&st.every((y,u)=>y===S[u]))){p.forEach(y=>y.remove()),m.forEach(y=>e.appendChild(y));return}m.forEach((y,u)=>{if(!C.has(y))return;let g=m[u-1];if(g&&g.parentNode===e?g.after(y):e.prepend(y),i)try{i(y)}catch{}}),p.forEach(y=>{y.setAttribute(f,""),y.removeAttribute(l),y.style.pointerEvents="none",y.inert=!0;let u=()=>y.remove();if(s)try{s(y,u)}catch{u()}else u()})}var Ee=null;function K(e){clearTimeout(Ee),Ee=setTimeout(()=>{typeof c.onLayoutChange=="function"?c.onLayoutChange(e):window.ScrollTrigger?.refresh&&window.ScrollTrigger.refresh(),w("layout-changed",{reason:e})},120)}function ie(e,t){let r=$(e,"img").filter(s=>!s.complete);if(!r.length)return;let n=r.length,i=()=>{--n===0&&K(`${t}:images`)};r.forEach(s=>{s.addEventListener("load",i,{once:!0}),s.addEventListener("error",i,{once:!0})})}function M(e,t){return e.getAttribute("aria-busy")==="true"?Promise.resolve():(e.setAttribute("aria-busy","true"),Promise.resolve().then(t).finally(()=>e.removeAttribute("aria-busy")))}function mt(e,t){let r=e&&d(e,t);if(!r)return null;try{return JSON.parse(r)}catch{return O(`invalid JSON in ${h(t)}`,e),null}}function B(e){return e?Array.isArray(e)?e.map(t=>({key:String(t.key),value:String(t.value??"")})):Object.entries(e).map(([t,r])=>({key:t,value:String(r??"")})):[]}function Te(e,t=1,r={}){let n=typeof e=="object"&&e!==null?e:{variantId:e,quantity:t,...r},i=j.variant(n.merchandiseId||n.variantId||n.id);if(!i)throw new I("add(): variantId is required");let s={merchandiseId:i,quantity:Math.max(1,parseInt(n.quantity??1,10)||1)},o=n.sellingPlanId||n.sellingPlan;o&&(s.sellingPlanId=j.sellingPlan(o));let l=B(n.attributes);return l.length&&(s.attributes=l),s}function ke(e,t,r){return`mutation Tether_${e}(${t}){${e}(${r}){cart{...TetherCart}userErrors{field message}}}${It()}`}var Qe='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',Ot=null,Ft=e=>$(e,Qe).filter(t=>t.offsetParent!==null||t===document.activeElement);function oe(e){$(document,a("cart-open")).forEach(t=>t.setAttribute("aria-expanded",String(e))),$(document,a("cart-drawer")).forEach(t=>{t.hasAttribute("role")||t.setAttribute("role","dialog"),!t.hasAttribute("aria-label")&&!t.hasAttribute("aria-labelledby")&&t.setAttribute("aria-label",d(t,"cart-label")||"Cart"),t.setAttribute("aria-modal",String(e)),t.classList.contains(c.cartDrawerOpenClass)||t.setAttribute("aria-hidden","true")})}var ae=e=>/does not exist|not found|invalid id/i.test(e?.message||""),P={state:null,_chain:Promise.resolve(),id(){try{return localStorage.getItem(c.storageKey)}catch{return null}},_setId(e){try{e?localStorage.setItem(c.storageKey,e):localStorage.removeItem(c.storageKey)}catch{}},get lines(){return this.state?.lines?.nodes||[]},get count(){return this.state?.totalQuantity||0},lastError:null,_queue(e){let t=this._chain.then(e,e).then(r=>(this.lastError&&(this.lastError=null,this.render()),r),r=>{throw this.lastError=r,this.render(),w("cart-error",{error:r}),r});return this._chain=t.catch(()=>{}),t},_commit(e,t){return this.state=e,e?.id&&this._setId(e.id),this.render(),w("cart-updated",{cart:e,reason:t}),e},async init(){let e=this.id();if(!e)return this.state=null,this.render(),null;try{let t=await T(`query TetherCart($id:ID!){cart(id:$id){...TetherCart}}${It()}`,{id:e});t.cart?this.state=t.cart:(this._setId(null),this.state=null)}catch(t){x(t,"cart load failed"),this.lastError=t,ae(t)&&this._setId(null),this.state=null}return this.render(),this.state},async _create(e={}){let t=c.country?{countryCode:String(c.country).toUpperCase()}:void 0,r=await T(ke("cartCreate","$input: CartInput!","input: $input"),{input:{buyerIdentity:t,...e}});return St(r.cartCreate,"cartCreate").cart},async _mutate(e,t,r,n,i){let s=this.id();if(!s)return i?this._create(i):null;try{let o=await T(ke(e,`$cartId: ID!, ${t}`,`cartId: $cartId, ${r}`),{...n,cartId:s});return St(o[e],e).cart}catch(o){if(i&&ae(o))return L("cart expired, creating a new one"),this._setId(null),this._create(i);throw o}},add(e,t=1,r={}){let n=(Array.isArray(e)?e:[e]).map(i=>Te(i,t,r));return this._queue(async()=>{let i=await this._mutate("cartLinesAdd","$lines: [CartLineInput!]!","lines: $lines",{lines:n},{lines:n});return this._commit(i,"add"),w("added",{cart:i,lines:n}),c.openCartOnAdd&&this.open(),i})},updateLine(e,t){let r=typeof t=="number"?{quantity:t}:{...t};if(r.quantity!==void 0&&r.quantity<=0)return this.removeLine(e);let n={id:e};return r.quantity!==void 0&&(n.quantity=r.quantity),"sellingPlanId"in r&&(n.sellingPlanId=r.sellingPlanId?j.sellingPlan(r.sellingPlanId):null),r.attributes&&(n.attributes=B(r.attributes)),(r.merchandiseId||r.variantId)&&(n.merchandiseId=j.variant(r.merchandiseId||r.variantId)),this._queue(async()=>this._commit(await this._mutate("cartLinesUpdate","$lines: [CartLineUpdateInput!]!","lines: $lines",{lines:[n]}),"update"))},removeLine(e){let t=Array.isArray(e)?e:[e];return this._queue(async()=>this._commit(await this._mutate("cartLinesRemove","$lineIds: [ID!]!","lineIds: $lineIds",{lineIds:t}),"remove"))},clear(){let e=this.lines.map(t=>t.id);return e.length?this.removeLine(e):Promise.resolve(this.state)},setNote(e){return this._queue(async()=>this._commit(await this._mutate("cartNoteUpdate","$note: String!","note: $note",{note:e??""},{note:e??""}),"note"))},setAttributes(e){let t=new Map((this.state?.attributes||[]).map(n=>[n.key,n.value]));B(e).forEach(n=>t.set(n.key,n.value));let r=[...t].filter(([,n])=>n!=="").map(([n,i])=>({key:n,value:i}));return this._queue(async()=>this._commit(await this._mutate("cartAttributesUpdate","$attributes: [AttributeInput!]!","attributes: $attributes",{attributes:r},{attributes:r}),"attributes"))},setDiscountCodes(e){let t=(Array.isArray(e)?e:[e]).map(r=>String(r).trim()).filter(Boolean);return this._queue(async()=>this._commit(await this._mutate("cartDiscountCodesUpdate","$discountCodes: [String!]!","discountCodes: $discountCodes",{discountCodes:t},{discountCodes:t}),"discount"))},applyDiscount(e){let t=(this.state?.discountCodes||[]).map(r=>r.code);return this.setDiscountCodes([...new Set([...t,e])])},removeDiscount(e){return this.setDiscountCodes((this.state?.discountCodes||[]).map(t=>t.code).filter(t=>t!==e))},setBuyerIdentity(e,{create:t=!0}={}){return this._queue(async()=>{let r=await this._mutate("cartBuyerIdentityUpdate","$buyerIdentity: CartBuyerIdentityInput!","buyerIdentity: $buyerIdentity",{buyerIdentity:e},t?{buyerIdentity:e}:null).catch(n=>{if(t||!ae(n))throw n;return this._setId(null),null});return this._commit(r,"buyer-identity")})},async checkout(e=c.checkoutTarget){let t=this.id();if(!t)return null;let r=e==="_blank"?window.open("","_blank"):null;if(r)try{r.opener=null}catch{}try{let i=(await T("query TetherCheckout($id: ID!) { cart(id: $id) { checkoutUrl } }",{id:t})).cart?.checkoutUrl;if(!i)throw new I("No checkoutUrl (cart empty or expired)");return w("checkout",{url:i,cart:this.state}),r&&!r.closed?r.location.href=i:window.location.href=i,i}catch(n){return r&&r.close(),x(n,"checkout failed"),null}},drawers(){return $(document,a("cart-drawer"))},isOpen(){return this.drawers().some(e=>e.classList.contains(c.cartDrawerOpenClass))},open(){if(this.isOpen())return;let e=this.drawers().filter(t=>d(t,"cart-drawer")!=="manual");e.forEach(t=>{t.classList.add(c.cartDrawerOpenClass),t.setAttribute("aria-hidden","false")}),oe(!0),c.cartFocus!==!1&&e[0]&&(Ot=document.activeElement,setTimeout(()=>{let t=Ft(e[0])[0]||e[0];t===e[0]&&!e[0].hasAttribute("tabindex")&&(e[0].tabIndex=-1),t.focus?.({preventScroll:!0})},60)),typeof c.onCartOpen=="function"&&c.onCartOpen(e),w("cart-toggled",{open:!0})},close(){if(!this.isOpen())return;let e=this.drawers(),t=e.some(r=>r.contains(document.activeElement));e.forEach(r=>{r.classList.remove(c.cartDrawerOpenClass),r.setAttribute("aria-hidden","true")}),oe(!1),t&&Ot?.isConnected&&Ot.focus({preventScroll:!0}),Ot=null,typeof c.onCartClose=="function"&&c.onCartClose(e),w("cart-toggled",{open:!1})},toggle(){this.isOpen()?this.close():this.open()},render(){let e=this.state,t=e?e.totalQuantity:0,r=s=>e?q(e.cost?.[s]):"";oe(this.isOpen()),$(document,a("cart-count")).forEach(s=>tt(s,t)),$(document,a("cart-subtotal")).forEach(s=>tt(s,r("subtotalAmount"))),$(document,a("cart-total")).forEach(s=>tt(s,r("totalAmount"))),$(document,a("cart-checkout-charge")).forEach(s=>tt(s,r("checkoutChargeAmount")));let n=this.lines.some(s=>s.sellingPlanAllocation),i={"cart-empty":t===0,"cart-filled":t>0,"cart-has-subscription":n,"cart-no-subscription":!n,"cart-has-discount":(e?.discountCodes||[]).some(s=>s.applicable),"cart-error":!!this.lastError};$(document,a("show")).forEach(s=>{let o=d(s,"show");o in i&&!s.closest(a("product"))&&D(s,i[o])}),$(document,`textarea${a("cart-note")},input${a("cart-note")}`).forEach(s=>{document.activeElement!==s&&(s.value=e?.note||"")}),$(document,a("cart-discounts")).forEach(s=>{U(s,e?.discountCodes||[],(o,l)=>{o.setAttribute(h("discount-code"),l.code);let f=o.querySelector(a("discount","code"))||(o.firstElementChild?null:o);f&&A(f,l.code),o.classList.toggle("is-inapplicable",!l.applicable)})}),$(document,a("cart-lines")).forEach(s=>{ne(s,this.lines,o=>o.id,(o,l)=>Je(o,l),{onEnter:c.onLineEnter,onLeave:c.onLineLeave})}),e&&K("cart")}};function We(e,t){let r=e.merchandise||{},n=e.sellingPlanAllocation?.sellingPlan;switch(t){case"title":return r.product?.title;case"product-title":return r.product?.title;case"variant-title":return r.title==="Default Title"?"":r.title;case"options":return(r.selectedOptions||[]).filter(i=>i.value!=="Default Title").map(i=>`${i.name}: ${i.value}`).join(", ");case"vendor":return r.product?.vendor;case"sku":return r.sku;case"price":return q(e.cost?.amountPerQuantity||r.price);case"compare-at-price":return q(e.cost?.compareAtAmountPerQuantity||r.compareAtPrice);case"line-total":return q(e.cost?.totalAmount);case"line-subtotal":return q(e.cost?.subtotalAmount);case"quantity":return e.quantity;case"plan":return n?.name||"";case"plan-description":return n?.description||"";case"components":return(e.lineComponents||[]).map(i=>`${i.quantity} \xD7 ${i.merchandise?.product?.title||""}`).join(", ");default:if(t.startsWith("attribute:")){let i=t.slice(10);return(e.attributes||[]).find(s=>s.key===i)?.value||""}return}}function Je(e,t){let r=t.merchandise||{},n=!!t.sellingPlanAllocation;e.setAttribute(h("line-id"),t.id),e.classList.toggle("is-subscription",n),$(e,a("line")).forEach(s=>{let o=d(s,"line");if(o==="image")return F(s,r.image?.url||r.product?.featuredImage?.url,r.product?.title);if(o==="url")return s.setAttribute("href",ft(r.product?.handle,r.product?.id));let l=We(t,o);l!==void 0&&tt(s,l)});let i={subscription:n,"one-time":!n,"on-sale":parseFloat(t.cost?.compareAtAmountPerQuantity?.amount)>parseFloat(t.cost?.amountPerQuantity?.amount),"has-components":(t.lineComponents||[]).length>0};$(e,a("line-show")).forEach(s=>{let o=d(s,"line-show");o in i&&D(s,i[o])}),$(e,`select${a("line-plan")}`).forEach(s=>{let o=r.product?.handle;o&&V(o).then(l=>{let f=R(l),p=[...!l.requiresSellingPlan&&d(s,"line-plan")!=="subscription-only"?[{value:"",label:s.getAttribute(h("one-time-label"))||"One-time purchase"}]:[],...f.map(C=>({value:C.id,label:C.name}))],m=p.map(C=>C.value).join("|");s.dataset.tetherSig!==m&&(s.innerHTML="",p.forEach(C=>{let S=document.createElement("option");S.value=C.value,S.textContent=C.label,s.appendChild(S)}),s.dataset.tetherSig=m),s.value=t.sellingPlanAllocation?.sellingPlan?.id||"",D(s,f.length>0)}).catch(l=>x(l,"line plan options"))})}var de={};_(de,{ProductScope:()=>bt,scopes:()=>X});var ue={};_(ue,{STATUS_KEYS:()=>Nt,boundary:()=>_t,isNotFound:()=>yt,ownedBy:()=>le,resolveProductKey:()=>gt,setScopeStatus:()=>H});function gt(e,t=window.location){let r=(d(e,"product")||"").trim();if(!r.toLowerCase().startsWith("url:"))return{key:r||null,fromUrl:!1,raw:r};let n=r.slice(4).trim(),i=null;if(n.toLowerCase()==="path"){let s=t.pathname.split("/").filter(Boolean);i=s.length?ze(s[s.length-1]):null}else i=new URLSearchParams(t.search).get(n||"handle");return i=i&&i.trim()?i.trim():null,{key:i,fromUrl:!0,raw:r}}function ze(e){try{return decodeURIComponent(e)}catch{return e}}var Nt=["loading","ready","error","not-found"],yt=e=>e?.code==="NOT_FOUND",_t=()=>["product","collection","products","recommendations"].map(e=>a(e)).join(","),le=(e,t)=>e===t||e.parentElement?.closest(_t())===t;function H(e,t,r){let n=t==="not-found";e.setAttribute(h("state"),n?"error":t),t==="error"||n?e.setAttribute(h("error"),n?"not-found":r?.code||"error"):e.removeAttribute(h("error")),Y(e,a("show"),_t()).forEach(i=>{let s=d(i,"show");if(!Nt.includes(s))return;let o=s===t;D(i,o),o&&typeof getComputedStyle=="function"&&getComputedStyle(i).display==="none"&&(i.style.display=i.getAttribute(h("display"))||"block")}),(t==="error"||n)&&Y(e,a("add-to-cart"),_t()).forEach(i=>{i.classList.add("is-disabled"),i.setAttribute("aria-disabled","true"),"disabled"in i&&(i.disabled=!0)})}var X=new WeakMap,Le=()=>a("product");function Ye(e,t){let r=t.indexOf("."),n=t.slice(0,r),i=t.slice(r+1);return(e.metafields||[]).find(o=>o&&o.namespace===n&&o.key===i)||null}var bt=class{constructor(t,r){this.root=t,this.product=r,this.selected={},this.variant=null,this.quantity=Math.max(0,parseInt(d(t,"quantity")??"1",10)||(z(t,"quantity")?0:1)),this.plans=R(r),this.purchase="one-time",this.planId=null,X.set(t,this),t.setAttribute(h("state"),"ready"),t.removeAttribute(h("error")),this.initSelection(),this.initPurchase(),this.renderProduct(),this.bind(),this.renderVariant(),ie(t,"product"),K("product"),w("product-ready",{product:r,scope:this},t)}update(t){let r=this.variant?.id;this.product=t,this.plans=R(t),this.planId&&!this.plans.some(i=>i.id===this.planId)&&(this.planId=this.plans[0]?.id||null),!this.plans.length&&this.purchase==="subscription"&&(this.purchase="one-time");let n=t.variants.nodes.find(i=>i.id===r);n&&(this.selected={},n.selectedOptions.forEach(i=>{this.selected[i.name]=i.value})),this.root.setAttribute(h("state"),"ready"),this.root.removeAttribute(h("error")),this.renderProduct(),this.renderVariant(),K("product"),w("product-updated",{product:t,scope:this},this.root)}$(t){let r=Y(this.root,t,Le());return this.root.matches(t)?[this.root,...r]:r}initSelection(){let t=this.product.variants.nodes,r=t.find(i=>i.availableForSale)||t[0];r&&r.selectedOptions.forEach(i=>{this.selected[i.name]=i.value});let n=new URLSearchParams(window.location.search).get("variant")||d(this.root,"variant");if(n){let i=j.variant(n),s=t.find(o=>o.id===i);s&&(this.selected={},s.selectedOptions.forEach(o=>{this.selected[o.name]=o.value}))}}initPurchase(){if(!this.plans.length)return;let t=new URLSearchParams(window.location.search),r=dt(this.product,t.get("selling_plan")),n=dt(this.product,d(this.root,"default-plan"));this.planId=(r||n||this.plans[0]).id;let i=r?"subscription":d(this.root,"default-purchase")||c.defaultPurchase;this.purchase=this.product.requiresSellingPlan||i==="subscription"?"subscription":"one-time"}findVariant(){return this.product.variants.nodes.find(t=>t.selectedOptions.every(r=>this.selected[r.name]===r.value))||null}isValueAvailable(t,r){return this.product.variants.nodes.some(n=>n.availableForSale&&n.selectedOptions.every(i=>i.name===t?i.value===r:this.selected[i.name]===i.value))}get plan(){return this.plans.find(t=>t.id===this.planId)||null}get subscriptionAvailable(){return!!(this.variant&&this.plans.some(t=>N(this.variant,t.id)))}get isSubscription(){return this.purchase==="subscription"&&!!N(this.variant,this.planId)}getLine(){if(!this.variant)return null;let t={merchandiseId:this.variant.id,quantity:this.quantity};this.isSubscription&&(t.sellingPlanId=this.planId);let r=this.collectAttributes();return r.length&&(t.attributes=r),t}collectAttributes(){let t=B(mt(this.root,"line-attributes")),r=this.$(a("line-attribute")).map(n=>{let i=d(n,"line-attribute"),s;return n.type==="checkbox"?s=n.checked?n.value&&n.value!=="on"?n.value:"Yes":"":n.type==="radio"?s=n.checked?n.value:null:s=n.value,s==null||s===""?null:{key:i,value:String(s)}}).filter(Boolean);return[...t,...r]}select(t,r){this.selected[t]!==r&&(this.selected[t]=r,this.renderVariant())}selectVariant(t){let r=this.product.variants.nodes.find(n=>n.id===j.variant(t));r&&(this.selected={},r.selectedOptions.forEach(n=>{this.selected[n.name]=n.value}),this.renderVariant())}setPurchase(t){let r=t==="subscription"?"subscription":"one-time";r==="one-time"&&this.product.requiresSellingPlan||this.purchase!==r&&(this.purchase=r,this.renderVariant())}selectPlan(t){let r=dt(this.product,t);r&&(this.planId=r.id,this.purchase="subscription",this.renderVariant())}setQuantity(t){let r=z(this.root,"quantity")?0:1;this.quantity=Math.max(r,parseInt(t,10)||0),this.$(a("qty")).forEach(n=>A(n,this.quantity)),this.renderVariant()}async addToCart(){if(!this.variant?.availableForSale)return null;let t=this.getLine();if(!t||t.quantity<1)return null;let r=await P.add(t);return w("product-added",{product:this.product,variant:this.variant,line:t},this.root),r}bind(){let t=r=>r&&r.closest(Le())===this.root;this.root.addEventListener("click",r=>{let n=r.target;if(!n?.closest)return;let i=n.closest(a("option-value"));if(t(i)&&i.closest(a("option-list"))){r.preventDefault(),this.select(d(i.closest(a("option-list")),"option-list"),d(i,"option-value"));return}let s=n.closest(a("plan-value"));if(t(s)){r.preventDefault(),this.selectPlan(d(s,"plan-value"));return}let o=n.closest(`${a("purchase")}:not(select)`);if(t(o)){o.tagName!=="INPUT"&&r.preventDefault(),this.setPurchase(d(o,"purchase"));return}let l=n.closest(a("qty-plus"));if(t(l)){r.preventDefault(),this.setQuantity(this.quantity+1);return}let f=n.closest(a("qty-minus"));if(t(f)){r.preventDefault(),this.setQuantity(this.quantity-1);return}let b=n.closest(a("add-to-cart"));t(b)&&(r.preventDefault(),this.onAddClick(b))}),this.root.addEventListener("change",r=>{let n=r.target;t(n)&&(n.matches(`select${a("option")}`)?this.select(d(n,"option"),n.value):n.matches(`select${a("variant-select")}`)?this.selectVariant(n.value):n.matches(`select${a("plan")}`)?n.value?this.selectPlan(n.value):this.setPurchase("one-time"):n.matches(`select${a("purchase")}`)?this.setPurchase(n.value):n.matches(a("qty"))&&this.setQuantity(n.value))})}onAddClick(t){let r=t.querySelector(a("add-label"))||t,n=d(t,"adding-text"),i=s=>A(r,s);r.dataset.tetherLabel===void 0&&(r.dataset.tetherLabel=r.tagName==="INPUT"?r.value:r.textContent),M(t,async()=>{n&&i(n);try{await this.addToCart()}catch(s){x(s,"add to cart failed"),w("error",{error:s,context:"add-to-cart"},this.root)}finally{n&&i(r.dataset.tetherLabel)}}).then(()=>{this.renderVariant()})}renderProduct(){let t=this.product;this.$(a("bind")).forEach(r=>{let n=d(r,"bind")||"",i={title:t.title,"description-text":t.description,vendor:t.vendor,type:t.productType,handle:t.handle}[n];if(i!==void 0)return A(r,i);switch(n){case"description":r.innerHTML=t.descriptionHtml||"";return;case"published-at":return A(r,re(t.publishedAt));case"min-price":return A(r,q(t.priceRange.minVariantPrice));case"max-price":return A(r,q(t.priceRange.maxVariantPrice));case"featured-image":return F(r,t.featuredImage?.url,t.featuredImage?.altText||t.title);case"url":case"link":r.setAttribute("href",ft(t.handle,t.id)),n==="url"&&!r.firstElementChild&&!r.textContent.trim()&&A(r,t.title);return;case"images":return U(r,t.images.nodes,(s,o)=>{let l=s.matches(`img,${a("bind","image")}`)?s:s.querySelector("img")||s;F(l,o.url,o.altText||t.title)});case"tags":{let s=(r.getAttribute("exclude")||"").split(",").map(o=>o.trim()).filter(Boolean);return U(r,t.tags.filter(o=>!s.includes(o)),(o,l)=>A(o,l))}default:if(/^image:\d+$/.test(n)){let s=t.images.nodes[n.slice(6)-1]||t.featuredImage;return F(r,s?.url,s?.altText||t.title)}if(n.startsWith("metafield:")){let s=Ye(t,n.slice(10));return s?s.reference?.image?F(r,s.reference.image.url,s.reference.image.altText):(/^(rich_text|multi_line_text)_field$/.test(s.type)&&(r.style.whiteSpace="pre-line"),A(r,s.value)):A(r,"")}return}}),this.$(a("option-list")).forEach(r=>{let n=d(r,"option-list"),i=t.options.find(s=>s.name===n);return!i||i.optionValues.length<=1&&z(r,"hide-single")?D(r,!1):U(r,i.optionValues,(s,o)=>{s.setAttribute(h("option-value"),o.name);let l=s.querySelector(a("bind","option-value"));l?A(l,o.name):s.firstElementChild||A(s,o.name);let f=s.querySelector(a("bind","swatch"));f&&o.swatch?.color&&(f.style.backgroundColor=o.swatch.color),f&&o.swatch?.image?.previewImage&&F(f,o.swatch.image.previewImage.url,o.name)})}),this.$(`select${a("option")}`).forEach(r=>{let n=t.options.find(i=>i.name===d(r,"option"));if(!n)return D(r,!1);r.innerHTML="",n.optionValues.forEach(i=>r.appendChild(new Option(i.name,i.name)))}),this.$(`select${a("variant-select")}`).forEach(r=>{r.innerHTML="",t.variants.nodes.forEach(n=>r.appendChild(new Option(n.title,n.id)))}),this.$(a("plan-list")).forEach(r=>{let n=(d(r,"plan-list")||"").trim(),i=["","true","all","*"].includes(n.toLowerCase())?null:n,s=this.plans.filter(o=>!i||o.group.name===i);U(r,s,(o,l)=>{o.setAttribute(h("plan-value"),l.id),!o.firstElementChild&&!o.querySelector(a("plan-bind"))&&A(o,l.name)})}),this.$(`select${a("plan")}`).forEach(r=>{r.innerHTML="",!t.requiresSellingPlan&&d(r,"plan")!=="subscription-only"&&r.appendChild(new Option(r.getAttribute(h("one-time-label"))||"One-time purchase","")),this.plans.forEach(n=>r.appendChild(new Option(n.name,n.id)))})}renderVariant(){let t=this.product,r=this.findVariant();if(r||([r]=t.variants.nodes,r&&(this.selected={},r.selectedOptions.forEach(u=>{this.selected[u.name]=u.value}))),this.variant=r,!r)return;if(this.plans.length&&!N(r,this.planId)){let u=this.plans.find(g=>N(r,g.id));u&&(this.planId=u.id)}let n=this.isSubscription,i=r.price,s=this.planId?ut(r,this.planId):null,o=n?s:i,l=n&&N(r,this.planId)?.priceAdjustments?.[0]?.compareAtPrice||r.compareAtPrice,f=l&&parseFloat(l.amount)>parseFloat(o.amount),b=f?Math.round((1-parseFloat(o.amount)/parseFloat(l.amount))*100):0,p=this.planId?Lt(r,this.planId):{amount:null,percentage:0},m=this.plan,C={amount:(parseFloat(o.amount)*Math.max(1,this.quantity)).toFixed(2),currencyCode:o.currencyCode},S=q,st=u=>u?`${u}%`:"",Vt={price:()=>S(o),"total-price":()=>S(C),"one-time-price":()=>S(i),"subscription-price":()=>S(s),"subscription-savings":()=>st(p.percentage),"subscription-savings-amount":()=>S(p.amount),"checkout-charge":()=>S(n?Zt(r,this.planId):o),"plan-name":()=>m?.name,"plan-description":()=>m?.description,"plan-group":()=>m?.group?.name,"compare-at-price":()=>f?S(l):"","unit-price":()=>S(r.unitPrice),"discount-percentage":()=>`${b}%`,"discount-amount":()=>f?S({amount:String(parseFloat(l.amount)-parseFloat(o.amount)),currencyCode:o.currencyCode}):"","variant-title":()=>r.title,"variant-id":()=>r.id,sku:()=>r.sku,barcode:()=>r.barcode,stock:()=>r.quantityAvailable,quantity:()=>this.quantity};this.$(a("bind")).forEach(u=>{let g=d(u,"bind");g==="variant-image"?F(u,r.image?.url||t.featuredImage?.url,r.image?.altText||t.title):Vt[g]&&A(u,Vt[g]())}),this.$(a("option-selected")).forEach(u=>A(u,this.selected[d(u,"option-selected")]||"")),this.$(a("option-list")).forEach(u=>{let g=d(u,"option-list");$(u,a("option-value")).forEach(E=>{let G=d(E,"option-value");ht(E,this.selected[g]===G);let k=!this.isValueAvailable(g,G);E.classList.toggle("is-unavailable",k),E.setAttribute("data-unavailable",k?"true":"false")})}),this.$(`select${a("option")}`).forEach(u=>{u.value=this.selected[d(u,"option")]||""}),this.$(`select${a("variant-select")}`).forEach(u=>{u.value=r.id}),this.$(a("purchase")).forEach(u=>{if(u.tagName==="SELECT"){u.value=this.purchase;return}let g=d(u,"purchase");ht(u,g===this.purchase);let E=g==="subscription"?!this.subscriptionAvailable:t.requiresSellingPlan;u.classList.toggle("is-unavailable",E)}),this.$(a("plan-value")).forEach(u=>{let g=d(u,"plan-value"),E=this.plans.find(k=>k.id===g),G=!!N(r,g);ht(u,n&&g===this.planId),u.classList.toggle("is-unavailable",!G),$(u,a("plan-bind")).forEach(k=>{let Q=te(E),be=Lt(r,g),Me=d(k,"plan-bind"),ve={name:()=>E?.name,description:()=>E?.description,price:()=>S(ut(r,g)),savings:()=>st(be.percentage),"savings-amount":()=>S(be.amount),adjustment:()=>Q?Q.type==="percentage"?`${Q.value}%`:S(Q.value):""}[Me];ve&&A(k,ve())})}),this.$(`select${a("plan")}`).forEach(u=>{u.value=n?this.planId:""});let y={"in-stock":r.availableForSale,"out-of-stock":!r.availableForSale,backorder:r.availableForSale&&r.currentlyNotInStock,"on-sale":!!f,"not-on-sale":!f,"has-variants":t.variants.nodes.length>1,"single-variant":t.variants.nodes.length===1,"low-stock":r.quantityAvailable!=null&&r.quantityAvailable>0&&r.quantityAvailable<=5,"subscription-available":this.subscriptionAvailable,"subscription-unavailable":!this.subscriptionAvailable,"subscription-only":!!t.requiresSellingPlan,"one-time-available":!t.requiresSellingPlan,"subscription-selected":n,"one-time-selected":!n,"has-savings":n?p.percentage>0:!!f,loading:!1,ready:!0,error:!1,"not-found":!1};this.$(a("show")).forEach(u=>{let g=d(u,"show");g in y&&(Nt.includes(g)&&!le(u,this.root)||D(u,y[g]))}),this.root.classList.toggle("is-subscription",n),this.root.setAttribute(h("purchase-mode"),n?"subscription":"one-time"),this.$(a("add-to-cart")).forEach(u=>{let g=!r.availableForSale;u.classList.toggle("is-disabled",g),u.setAttribute("aria-disabled",String(g)),"disabled"in u&&(u.disabled=g);let E=d(u,"soldout-text"),G=d(u,"subscribe-text");if(E||G){let k=u.querySelector(a("add-label"))||u;k.dataset.tetherLabel===void 0&&(k.dataset.tetherLabel=k.tagName==="INPUT"?k.value:k.textContent);let Q=k.dataset.tetherLabel;n&&G&&(Q=G),g&&E&&(Q=E),u.getAttribute("aria-busy")!=="true"&&A(k,Q)}}),w("variant-changed",{product:t,variant:r,selected:{...this.selected},purchase:this.purchase,sellingPlanId:n?this.planId:null},this.root)}};var pe={};_(pe,{ListScope:()=>vt,listSelector:()=>et});var et=()=>`${a("collection")},${a("products")},${a("recommendations")}`,vt=class{constructor(t){this.root=t,this.products=[],this.pageInfo=null,this.collection=null,H(t,"loading"),t.addEventListener("click",r=>{let n=r.target.closest?.(a("load-more"));n&&n.closest(et())===t&&(r.preventDefault(),M(n,()=>this.load(!0)))})}$(t){return Y(this.root,t,et())}options(){let t=this.root,r={first:parseInt(d(t,"limit")||"",10)||void 0,sortKey:d(t,"sort")||void 0,reverse:d(t,"reverse")==="true"};return z(t,"collection")?r.collection=d(t,"collection"):r.query=d(t,"products")||"",r}async load(t=!1){let r=this.loadToken=(this.loadToken||0)+1,n=()=>r!==this.loadToken;try{if(z(this.root,"recommendations")){let i=d(this.root,"recommendations"),s=await V(i),o=await lt(s.id,d(this.root,"intent")||"RELATED");if(n())return;let l=parseInt(d(this.root,"limit")||"",10);this.products=l?o.slice(0,l):o}else{let i=await ct({...this.options(),after:t?this.pageInfo?.endCursor:null});if(n())return;this.collection=i.collection,this.pageInfo=i.pageInfo,this.products=t?[...this.products,...i.products]:i.products}this.render(),H(this.root,"ready"),w("list-ready",{products:this.products,collection:this.collection},this.root)}catch(i){if(n())return;t||H(this.root,yt(i)?"not-found":"error",i),x(i,"list load failed"),w("error",{error:i,context:"list"},this.root)}}render(){let t=this.collection;this.$(a("collection-bind")).forEach(n=>{switch(d(n,"collection-bind")){case"title":return A(n,t?.title||"");case"description":n.innerHTML=t?.descriptionHtml||"";return;case"image":return F(n,t?.image?.url,t?.image?.altText||t?.title);case"count":return A(n,this.products.length);default:return}}),this.$(a("list")).forEach(n=>{U(n,this.products,(i,s)=>{i.setAttribute(h("product"),s.handle),i.removeAttribute(h("state"))}),w("list-rendered",{container:n},this.root)});let r=this.products.length===0;this.$(a("show")).forEach(n=>{let i=d(n,"show");i==="list-empty"&&(n.style.display=r?"":"none"),i==="list-filled"&&(n.style.display=r?"none":"")}),this.$(a("load-more")).forEach(n=>{n.style.display=this.pageInfo?.hasNextPage?"":"none"}),K("list")}};var he={};_(he,{liveLists:()=>it,liveProducts:()=>wt,mountProduct:()=>Ut,mountedLists:()=>Dt,mountedProducts:()=>$t,pruneLive:()=>jt,retryFailed:()=>fe,within:()=>Pt});var $t=new WeakSet,Dt=new WeakSet,wt=new Set,it=new Set,qe=new WeakMap;function jt(){wt.forEach(e=>{e.isConnected||wt.delete(e)}),it.forEach(e=>{e.root.isConnected||it.delete(e)})}function Pt(e,t){return[...e.matches?.(t)?[e]:[],...$(e,t)]}function Ut(e){if($t.has(e))return!1;let{key:t,fromUrl:r,raw:n}=gt(e);if(!t)return r?($t.add(e),H(e,"not-found"),w("product-not-found",{key:null,source:n},e)):e.closest(et())||O(`[${h("product")}] without a value. Bind it to the Shopify handle field, or use "url:handle".`,e),!1;$t.add(e),wt.add(e);let i={};qe.set(e,i);let s=()=>qe.get(e)===i;return X.get(e)?e.setAttribute(h("state"),"updating"):H(e,"loading"),V(t).then(o=>{if(!s())return;let l=X.get(e);l?l.update(o):new bt(e,o),Xe(e,o)}).catch(o=>{if(!s())return;let l=yt(o);H(e,l?"not-found":"error",o),l?(w("product-not-found",{key:t,source:n},e),r?L(`product not found: ${t}`):x(o,`product ${t}`)):(x(o,`product ${t}`),w("error",{error:o,context:"product",key:t},e))}),!0}function Xe(e,t){let r=d(e,"page-title");!r||typeof document>"u"||(document.title=r.replace(/\{title\}/g,t.title).replace(/\{vendor\}/g,t.vendor||"").replace(/\{type\}/g,t.productType||""))}function fe(){jt(),wt.forEach(e=>{e.getAttribute(h("state"))!=="error"||e.getAttribute(h("error"))==="not-found"||($t.delete(e),Ut(e))})}var{cfg:Ze}=Et,Oe={"config.js":Et,"client.js":Ht,"dom.js":se,"fragments.js":Qt,"loader.js":Xt,"selling-plans.js":pt,"status.js":ue,"cart.js":ce,"product.js":de,"collection.js":pe,"mounting.js":he},me=typeof document<"u"&&document.currentScript?.src||"",xt={};function rt(e){if(xt[e])return xt[e];let t=Ze.partsUrl||me.replace(/[^/]*$/,""),r=/\.min\.js(\?|$)/.test(me)||!me?".min":"",n=`${t.replace(/\/?$/,"/")}tether.${e}${r}.js`;return xt[e]=new Promise((i,s)=>{let o=document.createElement("script");o.src=n,o.async=!0,o.onload=()=>window.Tether?.__parts?.[e]?i(window.Tether.__parts[e]):s(new Error(`${n} did not register`)),o.onerror=()=>{delete xt[e],s(new Error(`Could not load ${n}. Host it next to the Tether script, or set partsUrl.`))},document.head.appendChild(o)}),xt[e]}var Fe="0.4.0",nt=null,ge=null;function Mt(e=document){if(!At())return 0;let t=0;return jt(),Pt(e,et()).forEach(r=>{if(Dt.has(r))return;Dt.add(r),t++;let n=new vt(r);it.add(n),r.addEventListener(`${c.prefix}:list-rendered`,i=>Mt(i.detail.container)),n.load()}),Pt(e,a("product")).forEach(r=>{Ut(r)&&t++}),Pt(e,`${a("country-select")},${a("country-bind")}`).length&&rt("markets").then(r=>r.renderCountrySelects(e)).catch(r=>x(r,"markets")),$(e,a("account-link")).forEach(r=>{r.setAttribute("href",`https://${c.domain}/account`)}),P.render(),L(`mounted ${t} scope(s)`,e),t}function tr(){P.close()}function er(e){let t=e?.closest?.(a("product"));return t&&X.get(t)||null}var _e=!1;function rr(){_e||(_e=!0,document.addEventListener("click",e=>{let t=e.target;if(!t?.closest)return;if(t.closest(a("cart-open"))){e.preventDefault(),P.toggle();return}if(t.closest(a("cart-close"))){e.preventDefault(),P.close();return}let r=t.closest(a("cart-clear"));if(r){e.preventDefault(),M(r,()=>P.clear().catch(l=>x(l,"cart clear")));return}let n=t.closest(a("checkout"));if(n){e.preventDefault(),M(n,()=>P.checkout());return}let i=t.closest(Ne());if(i&&i.closest(a("cart-lines"))){let l=i.getAttribute(`data-${c.prefix}-key`),f=P.lines.find(p=>p.id===l),b=p=>{e.preventDefault(),p().catch(m=>x(m,"cart line"))};if(t.closest(a("line-remove")))return b(()=>P.removeLine(l));if(f&&t.closest(a("line-plus")))return b(()=>P.updateLine(l,f.quantity+1));if(f&&t.closest(a("line-minus")))return b(()=>P.updateLine(l,f.quantity-1))}let s=t.closest(a("discount-remove"));if(s){e.preventDefault();let l=s.closest(a("discount-code"))?.getAttribute(h("discount-code"));l&&P.removeDiscount(l).catch(f=>x(f,"discount"));return}let o=t.closest(a("group-add"));o&&(e.preventDefault(),M(o,()=>De(o)))}),document.addEventListener("change",e=>{let t=e.target;if(!t?.closest)return;let n=t.closest(Ne())?.getAttribute(`data-${c.prefix}-key`);n&&t.matches(`input${a("line","quantity")}`)?P.updateLine(n,parseInt(t.value,10)||0).catch(i=>x(i,"cart line")):n&&t.matches(`select${a("line-plan")}`)?P.updateLine(n,{sellingPlanId:t.value||null}).catch(i=>x(i,"cart line plan")):t.matches(`select${a("country-select")}`)?t.value&&Ue(t.value).catch(i=>x(i,"country")):t.matches(a("cart-note"))&&P.setNote(t.value).catch(i=>x(i,"cart note"))}),document.addEventListener("submit",e=>{let t=e.target.closest?.(a("discount-form"));if(!t)return;e.preventDefault();let r=t.querySelector(a("discount-input"))||t.querySelector("input"),n=r?.value.trim();n&&M(t,async()=>{try{let s=((await P.applyDiscount(n))?.discountCodes||[]).find(o=>o.code.toLowerCase()===n.toLowerCase())?.applicable;t.classList.toggle("is-invalid",!s),w(s?"discount-applied":"discount-invalid",{code:n},t),s&&r&&(r.value="")}catch(i){t.classList.add("is-invalid"),x(i,"discount")}})}),window.addEventListener("online",()=>{fe(),it.forEach(e=>{e.root.getAttribute(h("state"))==="error"&&e.load()})}),document.addEventListener("keydown",e=>{if(!P.isOpen())return;if(e.key==="Escape"){P.close();return}if(e.key!=="Tab"||c.cartFocus===!1)return;let t=P.drawers().find(s=>s.classList.contains(c.cartDrawerOpenClass)),r=t?Ft(t):[];if(!r.length)return;let n=r[0],i=r[r.length-1];(!t.contains(document.activeElement)||e.shiftKey&&document.activeElement===n||!e.shiftKey&&document.activeElement===i)&&(e.preventDefault(),(e.shiftKey?i:n).focus())}))}function Ne(){return`[data-${c.prefix}-key]`}async function De(e){let t=e.closest(a("group"));if(!t)return null;let r=d(t,"group"),n=B(mt(t,"line-attributes")),i=r?[{key:"_group",value:r},...n]:n,s=$(t,a("product")).map(o=>X.get(o)).filter(o=>o&&o.variant?.availableForSale&&o.quantity>0).map(o=>{let l=o.getLine();return l.attributes=[...l.attributes||[],...i],l});if(!s.length)return O("group-add: nothing selected"),null;try{let o=await P.add(s);return w("group-added",{group:r,lines:s},t),o}catch(o){return x(o,"group add"),null}}function je(e={}){return nt&&!Object.keys(e).length?nt:(Kt({...window.TETHER_CONFIG||{},...e}),At()?(rr(),c.observe&&ir(),nt=nr(e).then(()=>P.init()).then(async t=>{let r=c.country?String(c.country).toUpperCase():null;if(t&&r&&t.buyerIdentity?.countryCode&&t.buyerIdentity.countryCode!==r)try{t=await P.setBuyerIdentity({countryCode:r},{create:!1})}catch(n){x(n,"cart country")}return w("ready",{cart:t}),ye}),nt):(O("TETHER_CONFIG is missing domain or token. Tether is idle."),nt=Promise.resolve(null),nt))}async function nr(e){let t=c.markets||{};if(t.detect===!1)return;let r=null;if(t.detect)try{r=(await rt("markets")).detectMarket(t)}catch(n){x(n,"markets");return}else if(t.remember!==!1){try{r=JSON.parse(localStorage.getItem(`${c.prefix}:market:${c.domain}`)||"null")}catch{}r&&!/^[A-Z]{2}$/.test(r.country||"")&&(r=null)}r&&(r.country&&(c.country=r.country),r.language&&(c.language=r.language),r.locale&&!e.locale&&!window.TETHER_CONFIG?.locale&&(c.locale=r.locale),L("market",r))}function Ue(e,t){return rt("markets").then(r=>r.setCountry(e,t))}function ir(){if(ge||typeof MutationObserver>"u")return;let e=null,t=new Set;ge=new MutationObserver(r=>{r.forEach(n=>n.addedNodes.forEach(i=>{i.nodeType===1&&t.add(i)})),clearTimeout(e),e=setTimeout(()=>{t.forEach(n=>{n.isConnected&&Mt(n)}),t.clear()},50)}),ge.observe(document.body,{childList:!0,subtree:!0})}var ye={VERSION:Fe,init:je,mount:Mt,unmount:tr,get config(){return c},get ready(){return nt||Promise.resolve(null)},query:T,withContext:Ct,cart:P,getProduct:V,getProducts:ct,getRecommendations:lt,getScope:er,addGroup:De,primeProduct:Z,normalizeProductKey:kt,clearProductCache:Yt,formatMoney:q,plans:pt,TetherError:I,resolveProductKey:gt,setCountry:Ue,detectMarket:e=>rt("markets").then(t=>t.detectMarket(e||c.markets)),getLocalization:()=>rt("markets").then(e=>e.getLocalization()),diagnose:e=>rt("diagnose").then(t=>t.diagnose({...e,version:Fe})),__core:Oe,__parts:{},on(e,t){let r=n=>t(n.detail,n);return document.addEventListener(`${c.prefix}:${e}`,r),()=>document.removeEventListener(`${c.prefix}:${e}`,r)}},Gr=ye;if(typeof window<"u"&&typeof document<"u"&&(window.Tether=ye,window.TETHER_CONFIG&&window.TETHER_CONFIG.autoMount!==!1)){let t=()=>je().then(()=>Mt(document));document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()}})();
|
|
3
|
+
image { ${z} }
|
|
4
|
+
seo { title description }`}var le={};F(le,{clearProductCache:()=>se,getProduct:()=>U,getProducts:()=>pt,getRecommendations:()=>ht,hydrateProducts:()=>oe,normalizeProductKey:()=>rt,primeProduct:()=>Y,refreshProducts:()=>ce,takeStale:()=>ae});var _=new Map,De=[],re=new Map,ne=!1,dt=0,ie=t=>typeof t=="string"&&t.startsWith("gid://");function rt(t){let e=String(t??"").trim();if(!e)return null;if(ie(e))return e;if(/^\d+$/.test(e))return`gid://shopify/Product/${e}`;let r=e.match(/\/products\/([^/?#]+)/);return r?r[1]:e}function Y(t){if(!t)return;let e=Promise.resolve(t);_.set(t.handle,e),_.set(t.id,e)}function U(t){let e=rt(t);if(!e)return Promise.reject(new I("empty product key",{code:"NOT_FOUND"}));if(_.has(e))return _.get(e);let r=new Promise((n,i)=>{re.set(e,{resolve:n,reject:i}),De.push(e),ne||(ne=!0,setTimeout(ir,0))});return _.set(e,r),r}async function ir(){ne=!1;let t=dt,e=De.splice(0);if(!e.length)return;let r=e.filter(ie),n=e.filter(f=>!ie(f)),i=[],s=[],o={};r.length&&(i.push("$ids: [ID!]!"),o.ids=r,s.push("byId: nodes(ids: $ids) { ... on Product { ...TetherProduct } }")),n.forEach((f,m)=>{i.push(`$h${m}: String!`),o[`h${m}`]=f,s.push(`h${m}: product(handle: $h${m}) { ...TetherProduct }`)});let l=`query TetherProducts(${i.join(",")}){${s.join(" ")}}${ut()}`;T("fetch products",e);let p=(f,m)=>{let h=re.get(f);re.delete(f),h&&m(h)};try{let f=await q(l,o),m=new Map;(f.byId||[]).forEach(h=>{h&&m.set(h.id,h)}),n.forEach((h,C)=>{f[`h${C}`]&&m.set(h,f[`h${C}`])}),e.forEach(h=>p(h,C=>{if(m.has(h)){let A=m.get(h);t===dt&&(Y(A),qt.set(A.handle,Date.now()),qt.set(A.id,Date.now())),C.resolve(A)}else t===dt&&_.delete(h),C.reject(new I(`Product not found: ${h}`,{code:"NOT_FOUND"}))}))}catch(f){e.forEach(m=>p(m,h=>{t===dt&&_.delete(m),h.reject(f)}))}}function se(){_.clear(),dt++,et.clear(),qt.clear()}var et=new Set,qt=new Map,sr=6e4;function oe(t){(t||[]).forEach(e=>{!e?.id||!e.handle||Date.now()-(qt.get(e.handle)||0)<sr&&_.has(e.handle)||(Y(e),et.add(e.handle),et.add(e.id))})}function ae(t){let e=rt(t);if(!et.has(e))return!1;let r=_.get(e);return et.delete(e),r?.then?.(n=>{et.delete(n.handle),et.delete(n.id)}),!0}function ce(t){return t.forEach(e=>_.delete(rt(e))),t.map(e=>U(e))}async function pt({collection:t,query:e,first:r=c.collectionFirst,after:n=null,sortKey:i,reverse:s=!1,filters:o}={}){let l=ut();if(t){let f=await q(`query TetherCollection($handle:String!,$first:Int!,$after:String,$sortKey:ProductCollectionSortKeys,$reverse:Boolean,$filters:[ProductFilter!]){collection(handle:$handle){${te()} products(first:$first,after:$after,sortKey:$sortKey,reverse:$reverse,filters:$filters){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}}${l}`,{handle:t,first:r,after:n,sortKey:i||void 0,reverse:s,filters:o||void 0});if(!f.collection)throw new I(`Collection not found: ${t}`,{code:"NOT_FOUND"});let{products:m,...h}=f.collection;return m.nodes.forEach(Y),{collection:h,products:m.nodes,pageInfo:m.pageInfo}}let p=await q(`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}}}${l}`,{first:r,after:n,query:e||void 0,sortKey:i||void 0,reverse:s});return p.products.nodes.forEach(Y),{collection:null,products:p.products.nodes,pageInfo:p.products.pageInfo}}async function ht(t,e="RELATED"){let r=rt(typeof t=="object"?t?.id:t),n=r?.startsWith("gid://"),s=(await q(`query TetherRecs(${n?"$id: ID!":"$handle: String!"},$intent:ProductRecommendationIntent){productRecommendations(${n?"productId: $id":"productHandle: $handle"},intent:$intent){...TetherProduct}}${ut()}`,n?{id:r,intent:e}:{handle:r,intent:e})).productRecommendations||[];return s.forEach(Y),s}var gt={};F(gt,{GID:()=>M,allPlans:()=>K,allocationFor:()=>D,findPlan:()=>mt,hasPlans:()=>or,planAdjustment:()=>de,planCheckoutCharge:()=>ue,planPrice:()=>ft,planSavings:()=>Nt,plansForVariant:()=>ar,toGid:()=>Ot});var M={product:t=>Ot(t,"Product"),variant:t=>Ot(t,"ProductVariant"),sellingPlan:t=>Ot(t,"SellingPlan")};function Ot(t,e){let r=String(t??"").trim();return r?r.startsWith("gid://")?r:/^\d+$/.test(r)?`gid://shopify/${e}/${r}`:r:null}function K(t){return(t?.sellingPlanGroups?.nodes||[]).flatMap(r=>(r.sellingPlans?.nodes||[]).map(n=>({...n,group:r})))}function or(t){return K(t).length>0}function D(t,e){return!t||!e?null:(t.sellingPlanAllocations?.nodes||[]).find(r=>r.sellingPlan?.id===e)||null}function ar(t,e){return K(t).filter(r=>D(e,r.id))}function ft(t,e){let n=D(t,e)?.priceAdjustments?.[0];return n?.perDeliveryPrice||n?.price||t?.price||null}function ue(t,e){let r=D(t,e);return r?.checkoutChargeAmount||r?.priceAdjustments?.[0]?.price||t?.price||null}function Nt(t,e){let r=parseFloat(t?.price?.amount),n=parseFloat(ft(t,e)?.amount);return!Number.isFinite(r)||!Number.isFinite(n)||r<=0||n>=r?{amount:null,percentage:0}:{amount:{amount:(r-n).toFixed(2),currencyCode:t.price.currencyCode},percentage:Math.round((1-n/r)*100)}}function de(t){let e=t?.priceAdjustments?.[0]?.adjustmentValue;if(!e)return null;switch(e.__typename){case"SellingPlanPercentagePriceAdjustment":return{type:"percentage",value:e.adjustmentPercentage};case"SellingPlanFixedAmountPriceAdjustment":return{type:"amount",value:e.adjustmentAmount};case"SellingPlanFixedPriceAdjustment":return{type:"price",value:e.price};default:return null}}function mt(t,e){if(!e)return null;let r=K(t),n=M.sellingPlan(e),i=String(e).trim().toLowerCase();return r.find(s=>s.id===n)||r.find(s=>s.name.toLowerCase()===i)||r.find(s=>(s.options||[]).some(o=>String(o.value).toLowerCase()===i))||null}var ye={};F(ye,{attr:()=>y,busy:()=>R,cdnUrl:()=>Me,dataKey:()=>Ue,emit:()=>$,formatDate:()=>he,formatMoney:()=>O,get:()=>d,has:()=>X,hasTemplate:()=>fe,imageUrl:()=>_t,notifyLayoutChanged:()=>B,parseJSONAttr:()=>vt,productUrl:()=>yt,qsa:()=>v,readText:()=>pe,repeat:()=>V,repeatKeyed:()=>me,sameImage:()=>Dt,scoped:()=>Z,sel:()=>a,setImage:()=>N,setSelected:()=>bt,setText:()=>E,setTextTracked:()=>tt,show:()=>j,toAttributes:()=>H,watchImages:()=>ge});var y=t=>`${c.prefix}-${t}`,a=(t,e)=>e===void 0?`[${y(t)}]`:`[${y(t)}="${e}"]`,d=(t,e)=>t.getAttribute(y(e)),X=(t,e)=>t.hasAttribute(y(e)),Ue=()=>`data-${c.prefix}-key`;function yt(t,e){let r=c.productPath||"/product";if(!/\{(handle|id)\}/.test(r))return`${r.replace(/\/$/,"")}/${t}`;let n=e?String(e).split("/").pop():"";return r.replace(/\{handle\}/g,encodeURIComponent(t||"")).replace(/\{id\}/g,encodeURIComponent(n))}var v=(t,e)=>t?[...t.querySelectorAll(e)]:[],Z=(t,e,r)=>v(t,e).filter(n=>n.closest(r)===t);function $(t,e,r=document){r.dispatchEvent(new CustomEvent(`${c.prefix}:${t}`,{detail:e,bubbles:!0}))}function O(t){if(!t)return"";if(typeof c.formatMoney=="function")return c.formatMoney(t,c.locale);let e=parseFloat(t.amount);if(Number.isNaN(e))return"";try{return new Intl.NumberFormat(c.locale||void 0,{style:"currency",currency:t.currencyCode}).format(e)}catch{return`${t.currencyCode} ${e.toFixed(2)}`}}function he(t){if(!t)return"";try{return new Date(t).toLocaleDateString(c.locale||void 0)}catch{return""}}function _t(t,{width:e,height:r,crop:n}={}){if(!t)return t;try{let i=new URL(t);return e&&i.searchParams.set("width",String(e)),r&&i.searchParams.set("height",String(r)),n&&i.searchParams.set("crop",n),i.toString()}catch{return t}}function Me(t,e){if(!t||!e)return t;let r=n=>e.getAttribute(n);return _t(t,{width:r("max-width"),height:r("max-height"),crop:r("max-width")||r("max-height")?r("crop"):null})}var Dt=(t,e)=>!!(t&&e)&&t.split("?")[0]===e.split("?")[0];function N(t,e,r){if(!e)return;let n=Me(e,t);if(t.tagName==="IMG"&&Dt(t.getAttribute("src"),n)){r!=null&&!t.getAttribute("alt")&&t.setAttribute("alt",r);return}t.tagName==="IMG"?(t.removeAttribute("srcset"),t.removeAttribute("sizes"),t.setAttribute("src",n),r!=null&&t.setAttribute("alt",r),t.getAttribute("loading")||t.setAttribute("loading","lazy")):t.style.backgroundImage=`url("${n}")`}function E(t,e){let r=e==null?"":String(e);t.tagName==="INPUT"||t.tagName==="TEXTAREA"?t.value=r:t.textContent=r}var pe=t=>t.tagName==="INPUT"||t.tagName==="TEXTAREA"?t.value:t.textContent;function tt(t,e){let r=pe(t);E(t,e);let n=pe(t);if(r!==n&&t.dataset.tetherSeen&&typeof c.onValueChange=="function")try{c.onValueChange(t,r)}catch{}t.dataset.tetherSeen="1"}function j(t,e){let r="tetherPrevDisplay";if(e){if(t.dataset.tetherShown!==void 0)return;t.dataset.tetherShown="",t.removeAttribute("hidden"),t.dataset[r]!==void 0?(t.style.display=t.dataset[r],delete t.dataset[r]):t.style.display==="none"&&(t.style.display=""),typeof getComputedStyle=="function"&&getComputedStyle(t).display==="none"&&(t.style.display=t.getAttribute(`${c.prefix}-display`)||"block")}else delete t.dataset.tetherShown,t.dataset[r]===void 0&&t.style.display!=="none"&&(t.dataset[r]=t.style.display||""),t.style.display="none"}function bt(t,e){t.classList.toggle("is-selected",e),t.setAttribute("aria-pressed",e?"true":"false"),t.tagName==="INPUT"&&(t.type==="radio"||t.type==="checkbox")&&(t.checked=e);let r=t.querySelector?.('input[type="radio"],input[type="checkbox"]');r&&(r.checked=e)}var Ft=new WeakMap,fe=t=>!!Ft.get(t);function Ve(t){if(!Ft.has(t)){let e=t.firstElementChild?.cloneNode(!0)??null;Ft.set(t,e),t.innerHTML=""}return Ft.get(t)}function V(t,e,r){let n=Ve(t);if(!n){L("repeater without a template child",t);return}t.innerHTML="",e.forEach((i,s)=>{let o=n.cloneNode(!0);r(o,i,s),t.appendChild(o)})}function me(t,e,r,n,{onEnter:i,onLeave:s}={}){let o=Ve(t);if(!o){L("repeater without a template child",t);return}let l=Ue(),p=`data-${c.prefix}-leaving`,f=()=>[...t.children].filter(b=>b.hasAttribute(l)&&!b.hasAttribute(p)),m=new Map(f().map(b=>[b.getAttribute(l),b])),h=[],C=new Set;e.forEach((b,u)=>{let g=String(r(b,u)),S=m.get(g);S?m.delete(g):(S=o.cloneNode(!0),S.setAttribute(l,g),C.add(S)),n(S,b,u,C.has(S)),h.push(S)});let A=h.filter(b=>!C.has(b)),lt=f().filter(b=>A.includes(b));if(!(lt.length===A.length&<.every((b,u)=>b===A[u]))){m.forEach(b=>b.remove()),h.forEach(b=>t.appendChild(b));return}h.forEach((b,u)=>{if(!C.has(b))return;let g=h[u-1];if(g&&g.parentNode===t?g.after(b):t.prepend(b),i)try{i(b)}catch{}}),m.forEach(b=>{b.setAttribute(p,""),b.removeAttribute(l),b.style.pointerEvents="none",b.inert=!0;let u=()=>b.remove();if(s)try{s(b,u)}catch{u()}else u()})}var je=null;function B(t){clearTimeout(je),je=setTimeout(()=>{typeof c.onLayoutChange=="function"?c.onLayoutChange(t):window.ScrollTrigger?.refresh&&window.ScrollTrigger.refresh(),$("layout-changed",{reason:t})},120)}function ge(t,e){let r=v(t,"img").filter(s=>!s.complete);if(!r.length)return;let n=r.length,i=()=>{--n===0&&B(`${e}:images`)};r.forEach(s=>{s.addEventListener("load",i,{once:!0}),s.addEventListener("error",i,{once:!0})})}function R(t,e){return t.getAttribute("aria-busy")==="true"?Promise.resolve():(t.setAttribute("aria-busy","true"),Promise.resolve().then(e).finally(()=>t.removeAttribute("aria-busy")))}function vt(t,e){let r=t&&d(t,e);if(!r)return null;try{return JSON.parse(r)}catch{return L(`invalid JSON in ${y(e)}`,t),null}}function H(t){return t?Array.isArray(t)?t.map(e=>({key:String(e.key),value:String(e.value??"")})):Object.entries(t).map(([e,r])=>({key:e,value:String(r??"")})):[]}function Ke(t,e=1,r={}){let n=typeof t=="object"&&t!==null?t:{variantId:t,quantity:e,...r},i=M.variant(n.merchandiseId||n.variantId||n.id);if(!i)throw new I("add(): variantId is required");let s={merchandiseId:i,quantity:Math.max(1,parseInt(n.quantity??1,10)||1)},o=n.sellingPlanId||n.sellingPlan;o&&(s.sellingPlanId=M.sellingPlan(o));let l=H(n.attributes);return l.length&&(s.attributes=l),s}function Re(t,e,r){return`mutation Tether_${t}(${e}){${t}(${r}){cart{...TetherCart}userErrors{field message}warnings{code message}}}${Lt()}`}var cr='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',jt=null,Ut=t=>v(t,cr).filter(e=>e.offsetParent!==null||e===document.activeElement);function be(t){v(document,a("cart-open")).forEach(e=>e.setAttribute("aria-expanded",String(t))),v(document,a("cart-drawer")).forEach(e=>{e.hasAttribute("role")||e.setAttribute("role","dialog"),!e.hasAttribute("aria-label")&&!e.hasAttribute("aria-labelledby")&&e.setAttribute("aria-label",d(e,"cart-label")||"Cart"),e.setAttribute("aria-modal",String(t)),e.classList.contains(c.cartDrawerOpenClass)||e.setAttribute("aria-hidden","true")})}var ve=t=>/does not exist|not found|invalid id/i.test(t?.message||""),P={state:null,_chain:Promise.resolve(),id(){try{return localStorage.getItem(c.storageKey)}catch{return null}},_setId(t){try{t?localStorage.setItem(c.storageKey,t):localStorage.removeItem(c.storageKey)}catch{}},get lines(){return this.state?.lines?.nodes||[]},get count(){return this.state?.totalQuantity||0},lastError:null,warnings:[],loaded:!1,_take(t,e){let r=Xt(t,e);return this.warnings=r.warnings||[],this.warnings.length&&$("cart-warning",{warnings:this.warnings}),r.cart},_queue(t){let e=this._chain.then(t,t).then(r=>(this.lastError&&(this.lastError=null,this.render()),r),r=>{throw this.lastError=r,this.render(),$("cart-error",{error:r}),r});return this._chain=e.catch(()=>{}),e},_commit(t,e){return this.state=t,t?.id&&this._setId(t.id),this.render(),$("cart-updated",{cart:t,reason:e}),t},async init(){let t=this.id();if(!t)return this.state=null,this.loaded=!0,this.render(),$("cart-updated",{cart:null,reason:"load"}),null;try{let e=await q(`query TetherCart($id:ID!){cart(id:$id){...TetherCart}}${Lt()}`,{id:t});e.cart?this.state=e.cart:(this._setId(null),this.state=null)}catch(e){x(e,"cart load failed"),this.lastError=e,ve(e)&&this._setId(null),this.state=null}return this.loaded=!0,this.render(),$("cart-updated",{cart:this.state,reason:"load"}),this.state},async _create(t={}){let e=c.country?{countryCode:String(c.country).toUpperCase()}:void 0,r=await q(Re("cartCreate","$input: CartInput!","input: $input"),{input:{buyerIdentity:e,...t}});return this._take(r.cartCreate,"cartCreate")},async _mutate(t,e,r,n,i){let s=this.id();if(!s)return i?this._create(i):null;try{let o=await q(Re(t,`$cartId: ID!, ${e}`,`cartId: $cartId, ${r}`),{...n,cartId:s});return this._take(o[t],t)}catch(o){if(i&&ve(o))return T("cart expired, creating a new one"),this._setId(null),this._create(i);throw o}},add(t,e=1,r={}){let n=(Array.isArray(t)?t:[t]).map(i=>Ke(i,e,r));return this._queue(async()=>{let i=await this._mutate("cartLinesAdd","$lines: [CartLineInput!]!","lines: $lines",{lines:n},{lines:n});return this._commit(i,"add"),$("added",{cart:i,lines:n}),c.openCartOnAdd&&this.open(),i})},updateLine(t,e){let r=typeof e=="number"?{quantity:e}:{...e};if(r.quantity!==void 0&&r.quantity<=0)return this.removeLine(t);let n={id:t};return r.quantity!==void 0&&(n.quantity=r.quantity),"sellingPlanId"in r&&(n.sellingPlanId=r.sellingPlanId?M.sellingPlan(r.sellingPlanId):null),r.attributes&&(n.attributes=H(r.attributes)),(r.merchandiseId||r.variantId)&&(n.merchandiseId=M.variant(r.merchandiseId||r.variantId)),this._queue(async()=>this._commit(await this._mutate("cartLinesUpdate","$lines: [CartLineUpdateInput!]!","lines: $lines",{lines:[n]}),"update"))},removeLine(t){let e=Array.isArray(t)?t:[t];return this._queue(async()=>this._commit(await this._mutate("cartLinesRemove","$lineIds: [ID!]!","lineIds: $lineIds",{lineIds:e}),"remove"))},clear(){let t=this.lines.map(e=>e.id);return t.length?this.removeLine(t):Promise.resolve(this.state)},setNote(t){return this._queue(async()=>this._commit(await this._mutate("cartNoteUpdate","$note: String!","note: $note",{note:t??""},{note:t??""}),"note"))},setAttributes(t){let e=new Map((this.state?.attributes||[]).map(n=>[n.key,n.value]));H(t).forEach(n=>e.set(n.key,n.value));let r=[...e].filter(([,n])=>n!=="").map(([n,i])=>({key:n,value:i}));return this._queue(async()=>this._commit(await this._mutate("cartAttributesUpdate","$attributes: [AttributeInput!]!","attributes: $attributes",{attributes:r},{attributes:r}),"attributes"))},setDiscountCodes(t){let e=(Array.isArray(t)?t:[t]).map(r=>String(r).trim()).filter(Boolean);return this._queue(async()=>this._commit(await this._mutate("cartDiscountCodesUpdate","$discountCodes: [String!]!","discountCodes: $discountCodes",{discountCodes:e},{discountCodes:e}),"discount"))},applyDiscount(t){let e=(this.state?.discountCodes||[]).map(r=>r.code);return this.setDiscountCodes([...new Set([...e,t])])},removeDiscount(t){let e=String(t).toLowerCase();return this.setDiscountCodes((this.state?.discountCodes||[]).map(r=>r.code).filter(r=>r.toLowerCase()!==e))},setBuyerIdentity(t,{create:e=!0}={}){return this._queue(async()=>{let r=await this._mutate("cartBuyerIdentityUpdate","$buyerIdentity: CartBuyerIdentityInput!","buyerIdentity: $buyerIdentity",{buyerIdentity:t},e?{buyerIdentity:t}:null).catch(n=>{if(e||!ve(n))throw n;return this._setId(null),null});return this._commit(r,"buyer-identity")})},async checkout(t=c.checkoutTarget){let e=this.id();if(!e||this.state&&!this.count)return null;let r=t==="_blank"?window.open("","_blank"):null;if(r)try{r.opener=null}catch{}try{let i=(await q("query TetherCheckout($id: ID!) { cart(id: $id) { checkoutUrl } }",{id:e})).cart?.checkoutUrl;if(!i)throw new I("No checkoutUrl (cart empty or expired)");return $("checkout",{url:i,cart:this.state}),r&&!r.closed?r.location.href=i:window.location.href=i,i}catch(n){return r&&r.close(),x(n,"checkout failed"),null}},drawers(){return v(document,a("cart-drawer"))},isOpen(){return this.drawers().some(t=>t.classList.contains(c.cartDrawerOpenClass))},open(){if(this.isOpen())return;let t=this.drawers().filter(e=>d(e,"cart-drawer")!=="manual");t.forEach(e=>{e.classList.add(c.cartDrawerOpenClass),e.setAttribute("aria-hidden","false")}),be(!0),c.cartFocus!==!1&&t[0]&&(jt=document.activeElement,setTimeout(()=>{let e=Ut(t[0])[0]||t[0];e===t[0]&&!t[0].hasAttribute("tabindex")&&(t[0].tabIndex=-1),e.focus?.({preventScroll:!0})},60)),typeof c.onCartOpen=="function"&&c.onCartOpen(t),$("cart-toggled",{open:!0})},close(){if(!this.isOpen())return;let t=this.drawers(),e=t.some(r=>r.contains(document.activeElement));t.forEach(r=>{r.classList.remove(c.cartDrawerOpenClass),r.setAttribute("aria-hidden","true")}),be(!1),e&&jt?.isConnected&&jt.focus({preventScroll:!0}),jt=null,typeof c.onCartClose=="function"&&c.onCartClose(t),$("cart-toggled",{open:!1})},toggle(){this.isOpen()?this.close():this.open()},subscribe(t){let e=()=>t(this.state,{open:this.isOpen(),count:this.count,loaded:this.loaded,warnings:this.warnings}),r=()=>e();return["cart-updated","cart-toggled"].forEach(n=>document.addEventListener(`${c.prefix}:${n}`,r)),e(),()=>["cart-updated","cart-toggled"].forEach(n=>document.removeEventListener(`${c.prefix}:${n}`,r))},render(){let t=this.state,e=t?t.totalQuantity:0,r=s=>t?O(t.cost?.[s]):"";be(this.isOpen()),v(document,a("cart-count")).forEach(s=>tt(s,e)),v(document,a("cart-subtotal")).forEach(s=>tt(s,r("subtotalAmount"))),v(document,a("cart-total")).forEach(s=>tt(s,r("totalAmount"))),v(document,a("cart-checkout-charge")).forEach(s=>tt(s,r("checkoutChargeAmount")));let n=this.lines.some(s=>s.sellingPlanAllocation),i={"cart-empty":e===0,"cart-filled":e>0,"cart-has-subscription":n,"cart-no-subscription":!n,"cart-has-discount":(t?.discountCodes||[]).some(s=>s.applicable),"cart-error":!!this.lastError,"cart-warning":this.warnings.length>0};v(document,a("cart-warning")).forEach(s=>tt(s,[...new Set(this.warnings.map(o=>o.message))].join(" "))),v(document,a("show")).forEach(s=>{let o=d(s,"show");o in i&&!s.closest(a("product"))&&j(s,i[o])}),v(document,a("checkout")).forEach(s=>{s.classList.toggle("is-disabled",!e),s.setAttribute("aria-disabled",String(!e))}),v(document,`textarea${a("cart-note")},input${a("cart-note")}`).forEach(s=>{document.activeElement!==s&&(s.value=t?.note||"")}),v(document,a("cart-discounts")).forEach(s=>{V(s,t?.discountCodes||[],(o,l)=>{o.setAttribute(y("discount-code"),l.code);let p=o.querySelector(a("discount","code"))||(o.firstElementChild?null:o);p&&E(p,l.code),o.classList.toggle("is-inapplicable",!l.applicable)})}),v(document,a("cart-lines")).forEach(s=>{me(s,this.lines,o=>o.id,(o,l)=>ur(o,l),{onEnter:c.onLineEnter,onLeave:c.onLineLeave})}),t&&B("cart")}};function lr(t,e){let r=t.merchandise||{},n=t.sellingPlanAllocation?.sellingPlan;switch(e){case"title":return r.product?.title;case"product-title":return r.product?.title;case"variant-title":return r.title==="Default Title"?"":r.title;case"options":return(r.selectedOptions||[]).filter(i=>i.value!=="Default Title").map(i=>`${i.name}: ${i.value}`).join(", ");case"vendor":return r.product?.vendor;case"sku":return r.sku;case"price":return O(t.cost?.amountPerQuantity||r.price);case"compare-at-price":return O(t.cost?.compareAtAmountPerQuantity||r.compareAtPrice);case"line-total":return O(t.cost?.totalAmount);case"line-subtotal":return O(t.cost?.subtotalAmount);case"quantity":return t.quantity;case"plan":return n?.name||"";case"plan-description":return n?.description||"";case"components":return(t.lineComponents||[]).map(i=>`${i.quantity} \xD7 ${i.merchandise?.product?.title||""}`).join(", ");default:if(e.startsWith("attribute:")){let i=e.slice(10);return(t.attributes||[]).find(s=>s.key===i)?.value||""}return}}function ur(t,e){let r=e.merchandise||{},n=!!e.sellingPlanAllocation;t.setAttribute(y("line-id"),e.id),t.classList.toggle("is-subscription",n),v(t,a("line")).forEach(s=>{let o=d(s,"line");if(o==="image")return N(s,r.image?.url||r.product?.featuredImage?.url,r.product?.title);if(o==="url"){let p=yt(r.product?.handle,r.product?.id),f=new URLSearchParams;r.id&&f.set("variant",String(r.id).split("/").pop());let m=e.sellingPlanAllocation?.sellingPlan?.id;m&&f.set("selling_plan",m.split("/").pop());let h=f.toString();return s.setAttribute("href",h?`${p}${p.includes("?")?"&":"?"}${h}`:p)}let l=lr(e,o);l!==void 0&&tt(s,l)});let i={subscription:n,"one-time":!n,"on-sale":parseFloat(e.cost?.compareAtAmountPerQuantity?.amount)>parseFloat(e.cost?.amountPerQuantity?.amount),"has-components":(e.lineComponents||[]).length>0};v(t,a("line-show")).forEach(s=>{let o=d(s,"line-show");o in i&&j(s,i[o])}),v(t,`select${a("line-plan")}`).forEach(s=>{let o=r.product?.handle;o&&U(o).then(l=>{let p=K(l),m=[...!l.requiresSellingPlan&&d(s,"line-plan")!=="subscription-only"?[{value:"",label:s.getAttribute(y("one-time-label"))||"One-time purchase"}]:[],...p.map(C=>({value:C.id,label:C.name}))],h=m.map(C=>C.value).join("|");s.dataset.tetherSig!==h&&(s.innerHTML="",m.forEach(C=>{let A=document.createElement("option");A.value=C.value,A.textContent=C.label,s.appendChild(A)}),s.dataset.tetherSig=h),s.value=e.sellingPlanAllocation?.sellingPlan?.id||"",j(s,p.length>0)}).catch(l=>x(l,"line plan options"))})}var xe={};F(xe,{ProductScope:()=>wt,rememberOptionNames:()=>Kt,scopes:()=>Q});var Pe={};F(Pe,{STATUS_KEYS:()=>Vt,boundary:()=>Mt,isNotFound:()=>$t,ownedBy:()=>we,resolveProductKey:()=>ot,setScopeStatus:()=>G});function ot(t,e=window.location){let r=(d(t,"product")||"").trim();if(!r.toLowerCase().startsWith("url:"))return{key:r||null,fromUrl:!1,raw:r};let n=r.slice(4).trim(),i=null;if(n.toLowerCase()==="path"){let s=e.pathname.split("/").filter(Boolean);i=s.length?dr(s[s.length-1]):null}else i=new URLSearchParams(e.search).get(n||"handle");return i=i&&i.trim()?i.trim():null,{key:i,fromUrl:!0,raw:r}}function dr(t){try{return decodeURIComponent(t)}catch{return t}}var Vt=["loading","ready","error","not-found"],$t=t=>t?.code==="NOT_FOUND",Mt=()=>["product","collection","products","recommendations"].map(t=>a(t)).join(","),we=(t,e)=>t===e||t.parentElement?.closest(Mt())===e;function G(t,e,r){let n=e==="not-found";t.setAttribute(y("state"),n?"error":e),e==="error"||n?t.setAttribute(y("error"),n?"not-found":r?.code||"error"):t.removeAttribute(y("error")),Z(t,a("show"),Mt()).forEach(i=>{let s=d(i,"show");Vt.includes(s)&&j(i,s===e)}),(e==="error"||n)&&Z(t,a("add-to-cart"),Mt()).forEach(i=>{i.classList.add("is-disabled"),i.setAttribute("aria-disabled","true"),"disabled"in i&&(i.disabled=!0)})}var Q=new WeakMap,Be=()=>a("product");function pr(t,e){let r=e.indexOf("."),n=e.slice(0,r),i=e.slice(r+1);return(t.metafields||[]).find(o=>o&&o.namespace===n&&o.key===i)||null}var Rt=new Map;function Kt(t){(t||[]).forEach(e=>{e?.handle&&!Rt.has(e.handle)&&Rt.set(e.handle,(e.options||[]).map(r=>r.name))})}var wt=class{constructor(e,r){this.root=e,this.product=r,this.selected={},this.variant=null,this.quantity=Math.max(0,parseInt(d(e,"quantity")??"1",10)||(X(e,"quantity")?0:1)),this.plans=K(r),this.purchase="one-time",this.planId=null,Q.set(e,this),e.setAttribute(y("state"),"ready"),e.removeAttribute(y("error")),this.initSelection(),this.initPurchase(),this.renderProduct(),this.bind(),this.renderVariant(),ge(e,"product"),B("product"),$("product-ready",{product:r,scope:this},e)}update(e){let r=this.variant?.id;this.product=e,this.plans=K(e),this.planId&&!this.plans.some(i=>i.id===this.planId)&&(this.planId=this.plans[0]?.id||null),!this.plans.length&&this.purchase==="subscription"&&(this.purchase="one-time");let n=e.variants.nodes.find(i=>i.id===r);n&&(this.selected={},n.selectedOptions.forEach(i=>{this.selected[i.name]=i.value})),this.root.setAttribute(y("state"),"ready"),this.root.removeAttribute(y("error")),this.renderProduct(),this.renderVariant(),B("product"),$("product-updated",{product:e,scope:this},this.root)}$(e){let r=Z(this.root,e,Be());return this.root.matches(e)?[this.root,...r]:r}optName(e){let r=this.product?.options||[];if(!e||r.some(i=>i.name===e))return e;let n=(Rt.get(this.product.handle)||[]).indexOf(e);return n>=0&&r[n]?r[n].name:e}initSelection(){let e=this.product.variants.nodes,r=e.find(i=>i.availableForSale)||e[0];r&&r.selectedOptions.forEach(i=>{this.selected[i.name]=i.value});let n=new URLSearchParams(window.location.search).get("variant")||d(this.root,"variant");if(n){let i=M.variant(n),s=e.find(o=>o.id===i);s&&(this.selected={},s.selectedOptions.forEach(o=>{this.selected[o.name]=o.value}))}}initPurchase(){if(!this.plans.length)return;let e=new URLSearchParams(window.location.search),r=mt(this.product,e.get("selling_plan")),n=mt(this.product,d(this.root,"default-plan"));this.planId=(r||n||this.plans[0]).id;let i=r?"subscription":d(this.root,"default-purchase")||c.defaultPurchase;this.purchase=this.product.requiresSellingPlan||i==="subscription"?"subscription":"one-time"}findVariant(){return this.product.variants.nodes.find(e=>e.selectedOptions.every(r=>this.selected[r.name]===r.value))||null}isValueAvailable(e,r){return this.product.variants.nodes.some(n=>n.availableForSale&&n.selectedOptions.every(i=>i.name===e?i.value===r:this.selected[i.name]===i.value))}get plan(){return this.plans.find(e=>e.id===this.planId)||null}get subscriptionAvailable(){return!!(this.variant&&this.plans.some(e=>D(this.variant,e.id)))}get isSubscription(){return this.purchase==="subscription"&&!!D(this.variant,this.planId)}getLine(){if(!this.variant)return null;let e={merchandiseId:this.variant.id,quantity:this.quantity};this.isSubscription&&(e.sellingPlanId=this.planId);let r=this.collectAttributes();return r.length&&(e.attributes=r),e}collectAttributes(){let e=H(vt(this.root,"line-attributes")),r=this.$(a("line-attribute")).map(n=>{let i=d(n,"line-attribute"),s;return n.type==="checkbox"?s=n.checked?n.value&&n.value!=="on"?n.value:"Yes":"":n.type==="radio"?s=n.checked?n.value:null:s=n.value,s==null||s===""?null:{key:i,value:String(s)}}).filter(Boolean);return[...e,...r]}select(e,r){this.selected[e]!==r&&(this.selected[e]=r,this.renderVariant())}selectVariant(e){let r=this.product.variants.nodes.find(n=>n.id===M.variant(e));r&&(this.selected={},r.selectedOptions.forEach(n=>{this.selected[n.name]=n.value}),this.renderVariant())}setPurchase(e){let r=e==="subscription"?"subscription":"one-time";r==="one-time"&&this.product.requiresSellingPlan||this.purchase!==r&&(this.purchase=r,this.renderVariant())}selectPlan(e){let r=mt(this.product,e);r&&(this.planId=r.id,this.purchase="subscription",this.renderVariant())}setQuantity(e){let r=X(this.root,"quantity")?0:1;this.quantity=Math.max(r,parseInt(e,10)||0),this.$(a("qty")).forEach(n=>E(n,this.quantity)),this.renderVariant()}async addToCart(){if(!this.variant?.availableForSale)return null;let e=this.getLine();if(!e||e.quantity<1)return null;let r=await P.add(e);return $("product-added",{product:this.product,variant:this.variant,line:e},this.root),r}bind(){let e=r=>r&&r.closest(Be())===this.root;this.root.addEventListener("click",r=>{let n=r.target;if(!n?.closest)return;let i=n.closest(a("option-value"));if(e(i)&&i.closest(a("option-list"))){r.preventDefault(),this.select(this.optName(d(i.closest(a("option-list")),"option-list")),d(i,"option-value"));return}let s=n.closest(a("plan-value"));if(e(s)){r.preventDefault(),this.selectPlan(d(s,"plan-value"));return}let o=n.closest(`${a("purchase")}:not(select)`);if(e(o)){o.tagName!=="INPUT"&&r.preventDefault(),this.setPurchase(d(o,"purchase"));return}let l=n.closest(a("qty-plus"));if(e(l)){r.preventDefault(),this.setQuantity(this.quantity+1);return}let p=n.closest(a("qty-minus"));if(e(p)){r.preventDefault(),this.setQuantity(this.quantity-1);return}let f=n.closest(a("add-to-cart"));e(f)&&(r.preventDefault(),this.onAddClick(f))}),this.root.addEventListener("change",r=>{let n=r.target;e(n)&&(n.matches(`select${a("option")}`)?this.select(this.optName(d(n,"option")),n.value):n.matches(`select${a("variant-select")}`)?this.selectVariant(n.value):n.matches(`select${a("plan")}`)?n.value?this.selectPlan(n.value):this.setPurchase("one-time"):n.matches(`select${a("purchase")}`)?this.setPurchase(n.value):n.matches(a("qty"))&&this.setQuantity(n.value))})}onAddClick(e){let r=e.querySelector(a("add-label"))||e,n=d(e,"adding-text"),i=s=>E(r,s);r.dataset.tetherLabel===void 0&&(r.dataset.tetherLabel=r.tagName==="INPUT"?r.value:r.textContent),R(e,async()=>{n&&i(n);try{await this.addToCart()}catch(s){x(s,"add to cart failed"),$("error",{error:s,context:"add-to-cart"},this.root)}finally{n&&i(r.dataset.tetherLabel)}}).then(()=>{this.renderVariant()})}renderProduct(){let e=this.product;Rt.has(e.handle)||this.$(`${a("option-list")},select${a("option")}`).map(i=>d(i,"option-list")||d(i,"option")).some(i=>e.options.some(s=>s.name===i))&&Kt([e]);let r=this.product;this.$(a("bind")).forEach(n=>{let i=d(n,"bind")||"",s={title:r.title,"description-text":r.description,vendor:r.vendor,type:r.productType,handle:r.handle}[i];if(s!==void 0)return E(n,s);switch(i){case"description":n.innerHTML=r.descriptionHtml||"";return;case"published-at":return E(n,he(r.publishedAt));case"min-price":return E(n,O(r.priceRange.minVariantPrice));case"max-price":return E(n,O(r.priceRange.maxVariantPrice));case"featured-image":return N(n,r.featuredImage?.url,r.featuredImage?.altText||r.title);case"url":case"link":n.setAttribute("href",yt(r.handle,r.id)),i==="url"&&!n.firstElementChild&&!n.textContent.trim()&&E(n,r.title);return;case"images":{let o=[...n.children].map(l=>l.tagName==="IMG"?l:l.querySelector("img"));if(!fe(n)&&o.length===r.images.nodes.length&&o.every((l,p)=>Dt(l?.getAttribute("src"),r.images.nodes[p].url)))return}return V(n,r.images.nodes,(o,l)=>{let p=o.matches(`img,${a("bind","image")}`)?o:o.querySelector("img")||o;N(p,l.url,l.altText||r.title)});case"tags":{let o=(n.getAttribute("exclude")||"").split(",").map(l=>l.trim()).filter(Boolean);return V(n,r.tags.filter(l=>!o.includes(l)),(l,p)=>E(l,p))}default:if(/^image:\d+$/.test(i)){let o=r.images.nodes[i.slice(6)-1]||r.featuredImage;return N(n,o?.url,o?.altText||r.title)}if(i.startsWith("metafield:")){let o=pr(r,i.slice(10));return o?o.reference?.image?N(n,o.reference.image.url,o.reference.image.altText):(/^(rich_text|multi_line_text)_field$/.test(o.type)&&(n.style.whiteSpace="pre-line"),E(n,o.value)):E(n,"")}return}}),this.$(a("option-list")).forEach(n=>{let i=this.optName(d(n,"option-list")),s=r.options.find(o=>o.name===i);return!s||s.optionValues.length<=1&&X(n,"hide-single")?j(n,!1):V(n,s.optionValues,(o,l)=>{o.setAttribute(y("option-value"),l.name);let p=o.querySelector(a("bind","option-value"));p?E(p,l.name):o.firstElementChild||E(o,l.name);let f=o.querySelector(a("bind","swatch"));f&&l.swatch?.color&&(f.style.backgroundColor=l.swatch.color),f&&l.swatch?.image?.previewImage&&N(f,l.swatch.image.previewImage.url,l.name)})}),this.$(`select${a("option")}`).forEach(n=>{let i=r.options.find(s=>s.name===this.optName(d(n,"option")));if(!i)return j(n,!1);n.innerHTML="",i.optionValues.forEach(s=>n.appendChild(new Option(s.name,s.name)))}),this.$(`select${a("variant-select")}`).forEach(n=>{n.innerHTML="",r.variants.nodes.forEach(i=>n.appendChild(new Option(i.title,i.id)))}),this.$(a("plan-list")).forEach(n=>{let i=(d(n,"plan-list")||"").trim(),s=["","true","all","*"].includes(i.toLowerCase())?null:i,o=this.plans.filter(l=>!s||l.group.name===s);V(n,o,(l,p)=>{l.setAttribute(y("plan-value"),p.id),!l.firstElementChild&&!l.querySelector(a("plan-bind"))&&E(l,p.name)})}),this.$(`select${a("plan")}`).forEach(n=>{n.innerHTML="",!r.requiresSellingPlan&&d(n,"plan")!=="subscription-only"&&n.appendChild(new Option(n.getAttribute(y("one-time-label"))||"One-time purchase","")),this.plans.forEach(i=>n.appendChild(new Option(i.name,i.id)))})}renderVariant(){let e=this.product,r=this.findVariant();if(r||([r]=e.variants.nodes,r&&(this.selected={},r.selectedOptions.forEach(u=>{this.selected[u.name]=u.value}))),this.variant=r,!r)return;if(this.plans.length&&!D(r,this.planId)){let u=this.plans.find(g=>D(r,g.id));u&&(this.planId=u.id)}let n=this.isSubscription,i=r.price,s=this.planId?ft(r,this.planId):null,o=n?s:i,l=n&&D(r,this.planId)?.priceAdjustments?.[0]?.compareAtPrice||r.compareAtPrice,p=l&&parseFloat(l.amount)>parseFloat(o.amount),f=p?Math.round((1-parseFloat(o.amount)/parseFloat(l.amount))*100):0,m=this.planId?Nt(r,this.planId):{amount:null,percentage:0},h=this.plan,C={amount:(parseFloat(o.amount)*Math.max(1,this.quantity)).toFixed(2),currencyCode:o.currencyCode},A=O,lt=u=>u?`${u}%`:"",Wt={price:()=>A(o),"total-price":()=>A(C),"one-time-price":()=>A(i),"subscription-price":()=>A(s),"subscription-savings":()=>lt(m.percentage),"subscription-savings-amount":()=>A(m.amount),"checkout-charge":()=>A(n?ue(r,this.planId):o),"plan-name":()=>h?.name,"plan-description":()=>h?.description,"plan-group":()=>h?.group?.name,"compare-at-price":()=>p?A(l):"","unit-price":()=>A(r.unitPrice),"discount-percentage":()=>`${f}%`,"discount-amount":()=>p?A({amount:String(parseFloat(l.amount)-parseFloat(o.amount)),currencyCode:o.currencyCode}):"","variant-title":()=>r.title,"variant-id":()=>r.id,sku:()=>r.sku,barcode:()=>r.barcode,stock:()=>r.quantityAvailable,quantity:()=>this.quantity};this.$(a("bind")).forEach(u=>{let g=d(u,"bind");g==="variant-image"?N(u,r.image?.url||e.featuredImage?.url,r.image?.altText||e.title):Wt[g]&&E(u,Wt[g]())}),this.$(a("option-selected")).forEach(u=>E(u,this.selected[this.optName(d(u,"option-selected"))]||"")),this.$(a("option-list")).forEach(u=>{let g=this.optName(d(u,"option-list"));v(u,a("option-value")).forEach(S=>{let W=d(S,"option-value");bt(S,this.selected[g]===W);let k=!this.isValueAvailable(g,W);S.classList.toggle("is-unavailable",k),S.setAttribute("data-unavailable",k?"true":"false")})}),this.$(`select${a("option")}`).forEach(u=>{u.value=this.selected[this.optName(d(u,"option"))]||""}),this.$(`select${a("variant-select")}`).forEach(u=>{u.value=r.id}),this.$(a("purchase")).forEach(u=>{if(u.tagName==="SELECT"){u.value=this.purchase;return}let g=d(u,"purchase");bt(u,g===this.purchase);let S=g==="subscription"?!this.subscriptionAvailable:e.requiresSellingPlan;u.classList.toggle("is-unavailable",S)}),this.$(a("plan-value")).forEach(u=>{let g=d(u,"plan-value"),S=this.plans.find(k=>k.id===g),W=!!D(r,g);bt(u,n&&g===this.planId),u.classList.toggle("is-unavailable",!W),v(u,a("plan-bind")).forEach(k=>{let J=de(S),Le=Nt(r,g),er=d(k,"plan-bind"),qe={name:()=>S?.name,description:()=>S?.description,price:()=>A(ft(r,g)),savings:()=>lt(Le.percentage),"savings-amount":()=>A(Le.amount),adjustment:()=>J?J.type==="percentage"?`${J.value}%`:A(J.value):""}[er];qe&&E(k,qe())})}),this.$(`select${a("plan")}`).forEach(u=>{u.value=n?this.planId:""});let b={"in-stock":r.availableForSale,"out-of-stock":!r.availableForSale,backorder:r.availableForSale&&r.currentlyNotInStock,"on-sale":!!p,"not-on-sale":!p,"has-variants":e.variants.nodes.length>1,"single-variant":e.variants.nodes.length===1,"low-stock":r.quantityAvailable!=null&&r.quantityAvailable>0&&r.quantityAvailable<=5,"subscription-available":this.subscriptionAvailable,"subscription-unavailable":!this.subscriptionAvailable,"subscription-only":!!e.requiresSellingPlan,"one-time-available":!e.requiresSellingPlan,"subscription-selected":n,"one-time-selected":!n,"has-savings":n?m.percentage>0:!!p,loading:!1,ready:!0,error:!1,"not-found":!1};this.$(a("show")).forEach(u=>{let g=d(u,"show");g in b&&(Vt.includes(g)&&!we(u,this.root)||j(u,b[g]))}),this.root.classList.toggle("is-subscription",n),this.root.setAttribute(y("purchase-mode"),n?"subscription":"one-time"),this.$(a("add-to-cart")).forEach(u=>{let g=!r.availableForSale;u.classList.toggle("is-disabled",g),u.setAttribute("aria-disabled",String(g)),"disabled"in u&&(u.disabled=g);let S=d(u,"soldout-text"),W=d(u,"subscribe-text");if(S||W){let k=u.querySelector(a("add-label"))||u;k.dataset.tetherLabel===void 0&&(k.dataset.tetherLabel=k.tagName==="INPUT"?k.value:k.textContent);let J=k.dataset.tetherLabel;n&&W&&(J=W),g&&S&&(J=S),u.getAttribute("aria-busy")!=="true"&&E(k,J)}}),$("variant-changed",{product:e,variant:r,selected:{...this.selected},purchase:this.purchase,sellingPlanId:n?this.planId:null},this.root)}};var Ae={};F(Ae,{ListScope:()=>Pt,listSelector:()=>nt});var nt=()=>`${a("collection")},${a("products")},${a("recommendations")}`,Pt=class{constructor(e){this.root=e,this.products=[],this.pageInfo=null,this.collection=null,G(e,"loading"),e.addEventListener("click",r=>{let n=r.target.closest?.(a("load-more"));n&&n.closest(nt())===e&&(r.preventDefault(),R(n,()=>this.load(!0)))})}$(e){return Z(this.root,e,nt())}options(){let e=this.root,r={first:parseInt(d(e,"limit")||"",10)||void 0,sortKey:d(e,"sort")||void 0,reverse:d(e,"reverse")==="true"};return X(e,"collection")?r.collection=d(e,"collection"):r.query=d(e,"products")||"",r}async load(e=!1){let r=this.loadToken=(this.loadToken||0)+1,n=()=>r!==this.loadToken;try{if(X(this.root,"recommendations")){let i=d(this.root,"recommendations"),s=await U(i),o=await ht(s.id,d(this.root,"intent")||"RELATED");if(n())return;let l=parseInt(d(this.root,"limit")||"",10);this.products=l?o.slice(0,l):o}else{let i=await pt({...this.options(),after:e?this.pageInfo?.endCursor:null});if(n())return;this.collection=i.collection,this.pageInfo=i.pageInfo,this.products=e?[...this.products,...i.products]:i.products}this.render(),G(this.root,"ready"),$("list-ready",{products:this.products,collection:this.collection},this.root)}catch(i){if(n())return;e||G(this.root,$t(i)?"not-found":"error",i),x(i,"list load failed"),$("error",{error:i,context:"list"},this.root)}}render(){let e=this.collection;this.$(a("collection-bind")).forEach(n=>{switch(d(n,"collection-bind")){case"title":return E(n,e?.title||"");case"description":n.innerHTML=e?.descriptionHtml||"";return;case"image":return N(n,e?.image?.url,e?.image?.altText||e?.title);case"count":return E(n,this.products.length);default:return}}),this.$(a("list")).forEach(n=>{V(n,this.products,(i,s)=>{i.setAttribute(y("product"),s.handle),i.removeAttribute(y("state"))}),$("list-rendered",{container:n},this.root)});let r=this.products.length===0;this.$(a("show")).forEach(n=>{let i=d(n,"show");i==="list-empty"&&(n.style.display=r?"":"none"),i==="list-filled"&&(n.style.display=r?"none":"")}),this.$(a("load-more")).forEach(n=>{n.style.display=this.pageInfo?.hasNextPage?"":"none"}),B("list")}};var Ce={};F(Ce,{hydrateFromPage:()=>Se,liveLists:()=>ct,liveProducts:()=>at,mountProduct:()=>Qt,mountedLists:()=>Ht,mountedProducts:()=>xt,pruneLive:()=>Gt,retryFailed:()=>Ee,within:()=>At});var xt=new WeakSet,Ht=new WeakSet,at=new Set,ct=new Set,He=new WeakMap;function Gt(){at.forEach(t=>{t.isConnected||at.delete(t)}),ct.forEach(t=>{t.root.isConnected||ct.delete(t)})}function At(t,e){return[...t.matches?.(e)?[t]:[],...v(t,e)]}function Qt(t){if(xt.has(t))return!1;let{key:e,fromUrl:r,raw:n}=ot(t);if(!e)return r?(xt.add(t),G(t,"not-found"),$("product-not-found",{key:null,source:n},t)):t.closest(nt())||L(`[${y("product")}] without a value. Bind it to the Shopify handle field, or use "url:handle".`,t),!1;xt.add(t),at.add(t);let i={};He.set(t,i);let s=()=>He.get(t)===i;return Q.get(t)?t.setAttribute(y("state"),"updating"):G(t,"loading"),U(e).then(o=>{if(!s())return;let l=Q.get(t);l?l.update(o):new wt(t,o),hr(t,o),c.revalidate!==!1&&ae(e)&&fr(e)}).catch(o=>{if(!s())return;let l=$t(o);G(t,l?"not-found":"error",o),l?($("product-not-found",{key:e,source:n},t),r?T(`product not found: ${e}`):x(o,`product ${e}`)):(x(o,`product ${e}`),$("error",{error:o,context:"product",key:e},t))}),!0}function hr(t,e){let r=d(t,"page-title");!r||typeof document>"u"||(document.title=r.replace(/\{title\}/g,e.title).replace(/\{vendor\}/g,e.vendor||"").replace(/\{type\}/g,e.productType||""))}function Ee(){Gt(),at.forEach(t=>{t.getAttribute(y("state"))!=="error"||t.getAttribute(y("error"))==="not-found"||(xt.delete(t),Qt(t))})}var Bt=new Set;function fr(t){Bt.size||setTimeout(mr,0),Bt.add(t)}function mr(){let t=[...Bt];Bt=new Set,ce(t).forEach((e,r)=>e.then(n=>{at.forEach(i=>{let s=Q.get(i);if(!s||!i.isConnected)return;let o=ot(i).key;o!==t[r]&&o!==n.handle&&o!==n.id||JSON.stringify(s.product)!==JSON.stringify(n)&&s.update(n)})}).catch(n=>x(n,`refresh ${t[r]}`)))}var Ge=new WeakSet;function Se(t=document){v(t.ownerDocument||t,'script[type="application/json"][data-tether-hydrate]').forEach(e=>{if(!Ge.has(e)){Ge.add(e);try{let r=JSON.parse(e.textContent);Kt(r.products);let n=(i,s)=>String(i||"").toUpperCase()===String(s||"").toUpperCase();n(r.country,c.country)&&n(r.language,c.language)?oe(r.products):T("hydration skipped: other market")}catch(r){L("bad data-tether-hydrate",r)}}})}var{cfg:gr}=It,Qe={"config.js":It,"client.js":Zt,"dom.js":ye,"fragments.js":ee,"loader.js":le,"selling-plans.js":gt,"status.js":Pe,"cart.js":$e,"product.js":xe,"collection.js":Ae,"mounting.js":Ce},Ie=typeof document<"u"&&document.currentScript?.src||"",Et={};function it(t){if(Et[t])return Et[t];let e=gr.partsUrl||Ie.replace(/[^/]*$/,""),r=/\.min\.js(\?|$)/.test(Ie)||!Ie?".min":"",n=`${e.replace(/\/?$/,"/")}tether.${t}${r}.js`;return Et[t]=new Promise((i,s)=>{let o=document.createElement("script");o.src=n,o.async=!0,o.onload=()=>window.Tether?.__parts?.[t]?i(window.Tether.__parts[t]):s(new Error(`${n} did not register`)),o.onerror=()=>{delete Et[t],s(new Error(`Could not load ${n}. Host it next to the Tether script, or set partsUrl.`))},document.head.appendChild(o)}),Et[t]}var We="0.5.0",st=null,ke=null;function St(t=document){if(!Ct())return 0;let e=0;return Gt(),Se(t),At(t,nt()).forEach(r=>{if(Ht.has(r))return;Ht.add(r),e++;let n=new Pt(r);ct.add(n),r.addEventListener(`${c.prefix}:list-rendered`,i=>St(i.detail.container)),n.load()}),At(t,a("product")).forEach(r=>{Qt(r)&&e++}),At(t,`${a("country-select")},${a("country-bind")}`).length&&it("markets").then(r=>r.renderCountrySelects(t)).catch(r=>x(r,"markets")),v(t,a("account-link")).forEach(r=>{r.setAttribute("href",`https://${c.domain}/account`)}),P.render(),T(`mounted ${e} scope(s)`,t),e}function Ye(){P.close()}function yr(t){let e=t?.closest?.(a("product"));return e&&Q.get(e)||null}var Je=!1;function br(){Je||(Je=!0,document.addEventListener("click",t=>{let e=t.target;if(!e?.closest)return;if(e.closest(a("cart-open"))){t.preventDefault(),P.toggle();return}if(e.closest(a("cart-close"))){t.preventDefault(),P.close();return}let r=e.closest(a("cart-clear"));if(r){t.preventDefault(),R(r,()=>P.clear().catch(l=>x(l,"cart clear")));return}let n=e.closest(a("checkout"));if(n){t.preventDefault(),R(n,()=>P.checkout());return}let i=e.closest(ze());if(i&&i.closest(a("cart-lines"))){let l=i.getAttribute(`data-${c.prefix}-key`),p=P.lines.find(m=>m.id===l),f=m=>{t.preventDefault(),m().catch(h=>x(h,"cart line"))};if(e.closest(a("line-remove")))return f(()=>P.removeLine(l));if(p&&e.closest(a("line-plus")))return f(()=>P.updateLine(l,p.quantity+1));if(p&&e.closest(a("line-minus")))return f(()=>P.updateLine(l,p.quantity-1))}let s=e.closest(a("discount-remove"));if(s){t.preventDefault();let l=s.closest(a("discount-code"))?.getAttribute(y("discount-code"));l&&P.removeDiscount(l).catch(p=>x(p,"discount"));return}let o=e.closest(a("group-add"));o&&(t.preventDefault(),R(o,()=>Xe(o)))}),document.addEventListener("change",t=>{let e=t.target;if(!e?.closest)return;let n=e.closest(ze())?.getAttribute(`data-${c.prefix}-key`);n&&e.matches(`input${a("line","quantity")}`)?P.updateLine(n,parseInt(e.value,10)||0).catch(i=>x(i,"cart line")):n&&e.matches(`select${a("line-plan")}`)?P.updateLine(n,{sellingPlanId:e.value||null}).catch(i=>x(i,"cart line plan")):e.matches(`select${a("country-select")}`)?e.value&&tr(e.value).catch(i=>x(i,"country")):e.matches(a("cart-note"))&&P.setNote(e.value).catch(i=>x(i,"cart note"))}),document.addEventListener("submit",t=>{let e=t.target.closest?.(a("discount-form"));if(!e)return;t.preventDefault();let r=e.querySelector(a("discount-input"))||e.querySelector("input"),n=r?.value.trim();n&&R(e,async()=>{try{let s=((await P.applyDiscount(n))?.discountCodes||[]).find(o=>o.code.toLowerCase()===n.toLowerCase())?.applicable;s||await P.removeDiscount(n).catch(()=>{}),e.classList.toggle("is-invalid",!s),$(s?"discount-applied":"discount-invalid",{code:n},e),s&&r&&(r.value="")}catch(i){e.classList.add("is-invalid"),x(i,"discount")}})},!0),document.addEventListener("input",t=>{t.target.closest?.(a("discount-form"))?.classList.remove("is-invalid")}),c.astro!==!1&&(document.addEventListener("astro:page-load",()=>St(document)),document.addEventListener("astro:before-swap",()=>Ye())),window.addEventListener("online",()=>{Ee(),ct.forEach(t=>{t.root.getAttribute(y("state"))==="error"&&t.load()})}),document.addEventListener("keydown",t=>{if(!P.isOpen())return;if(t.key==="Escape"){P.close();return}if(t.key!=="Tab"||c.cartFocus===!1)return;let e=P.drawers().find(s=>s.classList.contains(c.cartDrawerOpenClass)),r=e?Ut(e):[];if(!r.length)return;let n=r[0],i=r[r.length-1];(!e.contains(document.activeElement)||t.shiftKey&&document.activeElement===n||!t.shiftKey&&document.activeElement===i)&&(t.preventDefault(),(t.shiftKey?i:n).focus())}))}function ze(){return`[data-${c.prefix}-key]`}async function Xe(t){let e=t.closest(a("group"));if(!e)return null;let r=d(e,"group"),n=H(vt(e,"line-attributes")),i=r?[{key:"_group",value:r},...n]:n,s=v(e,a("product")).map(o=>Q.get(o)).filter(o=>o&&o.variant?.availableForSale&&o.quantity>0).map(o=>{let l=o.getLine();return l.attributes=[...l.attributes||[],...i],l});if(!s.length)return L("group-add: nothing selected"),null;try{let o=await P.add(s);return $("group-added",{group:r,lines:s},e),o}catch(o){return x(o,"group add"),null}}function Ze(t={}){return st&&!Object.keys(t).length?st:(zt({...window.TETHER_CONFIG||{},...t}),Ct()?(br(),c.observe&&$r(),st=vr(t).then(()=>P.init()).then(async e=>{let r=c.country?String(c.country).toUpperCase():null;if(e&&r&&e.buyerIdentity?.countryCode&&e.buyerIdentity.countryCode!==r)try{e=await P.setBuyerIdentity({countryCode:r},{create:!1})}catch(n){x(n,"cart country")}return $("ready",{cart:e}),Te}),st):(L("TETHER_CONFIG is missing domain or token. Tether is idle."),st=Promise.resolve(null),st))}async function vr(t){let e=c.markets||{};if(e.detect===!1)return;let r=null;if(e.detect)try{r=(await it("markets")).detectMarket(e)}catch(n){x(n,"markets");return}else if(e.remember!==!1){try{r=JSON.parse(localStorage.getItem(`${c.prefix}:market:${c.domain}`)||"null")}catch{}r&&!/^[A-Z]{2}$/.test(r.country||"")&&(r=null)}r&&(r.country&&(c.country=r.country),r.language&&(c.language=r.language),r.locale&&!t.locale&&(c.locale=r.locale),T("market",r))}function tr(t,e){return it("markets").then(r=>r.setCountry(t,e))}function $r(){if(ke||typeof MutationObserver>"u")return;let t=null,e=new Set;ke=new MutationObserver(r=>{r.forEach(n=>n.addedNodes.forEach(i=>{i.nodeType===1&&e.add(i)})),clearTimeout(t),t=setTimeout(()=>{e.forEach(n=>{n.isConnected&&St(n)}),e.clear()},50)}),ke.observe(document.body,{childList:!0,subtree:!0})}var Te={VERSION:We,init:Ze,mount:St,unmount:Ye,get config(){return c},get ready(){return st||Promise.resolve(null)},query:q,withContext:Tt,cart:P,getProduct:U,getProducts:pt,getRecommendations:ht,getScope:yr,addGroup:Xe,primeProduct:Y,normalizeProductKey:rt,clearProductCache:se,formatMoney:O,imageUrl:_t,plans:gt,TetherError:I,resolveProductKey:ot,setCountry:tr,detectMarket:t=>it("markets").then(e=>e.detectMarket(t||c.markets)),getLocalization:()=>it("markets").then(t=>t.getLocalization()),diagnose:t=>it("diagnose").then(e=>e.diagnose({...t,version:We})),__core:Qe,__parts:{},on(t,e){let r=n=>e(n.detail,n);return document.addEventListener(`${c.prefix}:${t}`,r),()=>document.removeEventListener(`${c.prefix}:${t}`,r)}},cn=Te;if(typeof window<"u"&&typeof document<"u"&&(window.Tether=Te,window.TETHER_CONFIG&&window.TETHER_CONFIG.autoMount!==!1&&!window.TETHER_INTEGRATION)){let e=()=>Ze().then(()=>St(document));document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e,{once:!0}):e()}})();
|
|
5
5
|
//# sourceMappingURL=tether.min.js.map
|