@occluze/tether 0.9.0 → 0.9.2
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 +1 -1
- package/dist/esm/astro.js +1 -1
- package/dist/esm/chunks/{account-FKLGF264.js → account-XBGNTM7V.js} +1 -1
- package/dist/esm/chunks/{account-pages-PNORWX72.js → account-pages-FIXSWJH7.js} +1 -1
- package/dist/esm/chunks/{analytics-V24XX2J7.js → analytics-MO2ZWBOD.js} +1 -1
- package/dist/esm/chunks/chunk-2J3MTS3E.js +1 -0
- package/dist/esm/chunks/chunk-4FR3CUO2.js +1 -0
- package/dist/esm/chunks/{chunk-CR5IGHCO.js → chunk-7CRTJV25.js} +1 -1
- package/dist/esm/chunks/{chunk-RW23CJDZ.js → chunk-7ZXEVDOS.js} +1 -1
- package/dist/esm/chunks/{chunk-2LYWZ72A.js → chunk-BVO7KK2M.js} +1 -1
- package/dist/esm/chunks/{chunk-YWQWLKFW.js → chunk-CRKJ2VEX.js} +1 -1
- package/dist/esm/chunks/{chunk-2IHA3PVC.js → chunk-DM5LEAWM.js} +1 -1
- package/dist/esm/chunks/{chunk-2NV5PSJ2.js → chunk-FI4NIWAD.js} +1 -1
- package/dist/esm/chunks/{chunk-6ZIOAYKF.js → chunk-FWMPL6PR.js} +1 -1
- package/dist/esm/chunks/{chunk-2X5U24IC.js → chunk-H6IORH7O.js} +1 -1
- package/dist/esm/chunks/{chunk-E3JL6WS3.js → chunk-IJAMRI33.js} +1 -1
- package/dist/esm/chunks/chunk-OATTAXPO.js +1 -0
- package/dist/esm/chunks/{chunk-GOKJQGLG.js → chunk-OENVX4NY.js} +1 -1
- package/dist/esm/chunks/chunk-OJAV2I3C.js +1 -0
- package/dist/esm/chunks/{chunk-F5CLIGSC.js → chunk-SZRDO62E.js} +1 -1
- package/dist/esm/chunks/{chunk-VKKKH75V.js → chunk-Y3NKKN2O.js} +1 -1
- package/dist/esm/chunks/{diagnose-3RTKEBNW.js → diagnose-XSZPWEG7.js} +1 -1
- package/dist/esm/chunks/{extras-O54VUXK6.js → extras-DZIOTZ3H.js} +1 -1
- package/dist/esm/chunks/{lists-MRTI5RXY.js → lists-OJGSVQMM.js} +1 -1
- package/dist/esm/chunks/{markets-ui-P7G33T6Y.js → markets-ui-DEEYV4KT.js} +1 -1
- package/dist/esm/chunks/{search-YSRDFVD7.js → search-A6HF5PMJ.js} +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/server.js +2 -2
- package/dist/tether.js +20 -7
- package/dist/tether.min.js +1 -1
- package/dist/tether.min.js.map +3 -3
- package/dist/types/src/server.d.ts +5 -2
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +5 -4
- package/dist/esm/chunks/chunk-5B36ISJF.js +0 -1
- package/dist/esm/chunks/chunk-6WE7XCHH.js +0 -1
- package/dist/esm/chunks/chunk-TW34GYSL.js +0 -1
- package/dist/esm/chunks/chunk-YYNBHXQF.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var w=Object.defineProperty;var G=(n,e,t)=>e in n?w(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Fn=(n,e)=>{for(var t in e)w(n,t,{get:e[t],enumerable:!0})};var $n=(n,e,t)=>G(n,typeof e!="symbol"?e+"":e,t);var z=/^(\d{4})-(01|04|07|10)$/;function k(n){let e=z.exec(typeof n=="string"?n:"");return e?{year:Number(e[1]),month:Number(e[2])}:null}var S=n=>k(n)!==null,j=(n,e)=>`${n}-${String(e).padStart(2,"0")}`;function A(n,e=1){let t=k(n);if(!t)throw new Error(`not a quarterly Shopify API version: ${n}`);let o=t.year*4+(t.month-1)/3+e;return j(Math.floor(o/4),o%4*3+1)}function Dn(n,e=new Date){if(n==="unstable")return{version:n,ok:!1,note:'"unstable" changes without notice: pin a dated version such as 2026-07'};let t=k(n);if(!t)return{version:n,ok:!1,note:"not a quarterly version (YYYY-01, -04, -07 or -10)"};let o=new Date(Date.UTC(t.year,t.month-1,1)),r=new Date(Date.UTC(t.year,t.month-1+12,1)),i=(r.getTime()-e.getTime())/2630016e3,f=o<=e,c=`supported until about ${r.toISOString().slice(0,7)}`;return f?i<=0?c="no longer supported: Shopify falls back to the oldest supported version. Upgrade (see docs/reference.md)":i<3&&(c=`${c}: plan the upgrade to ${A(n)} or later (see docs/reference.md)`):c="not released yet (release candidate at best)",{version:n,ok:f&&i>0,monthsLeft:Math.round(i),next:A(n),note:c}}function O(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function v(n,e){return O(n)?n[e]:void 0}function Q(n){return Array.isArray(n)?n:[]}function Z(n){return typeof n=="string"&&n!==""?n:null}var B=n=>typeof n=="number"&&Number.isFinite(n)?n:null,Kn=n=>B(n)??0,x=(n,e)=>Q(n).map(t=>e(t)),Yn=(n,e)=>({nodes:x(v(n,"nodes"),e)}),Gn=n=>x(n,Z).filter(e=>e!==null);var q=/^[A-Z]{2}$/,W=new Set(["XX","T1"]),X=new Set(["PT_BR","PT_PT","ZH_CN","ZH_TW"]),J=/^[A-Z]{2,3}$/;function T(n){let e=(typeof n=="string"?n:"").trim().toUpperCase();return!q.test(e)||W.has(e)?null:e}function h(n){let e=(typeof n=="string"?n:"").trim().replace("-","_").toUpperCase();if(X.has(e))return e;let t=e.split("_")[0]??"";return J.test(t)?t:null}var E="2026-07";var nn=/^[A-Za-z0-9_.-]+$/,en=/^(\$app(:[A-Za-z0-9_-]+)?|[A-Za-z0-9_.-]+)$/,tn=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i,on=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,rn=/^[A-Za-z_$][\w$]*$/,R="https://site.invalid",sn=new Set(["localhost","127.0.0.1","[::1]"]),N=["saved","server","webflow"],an=["no-banner","default-banner","custom-banner"],y=n=>typeof n=="string"&&n!=="",un=n=>typeof n=="function";function M(n,e){if(typeof n!="string"||!n)return"";let t=n.replace(/^https?:\/\//,"").replace(/\/.*$/,"");return dn(t)?t:(e("domain",n),"")}function P(n){if(!y(n))return!1;try{let e=new URL(n,`${R}/`);return e.origin===R?!0:e.protocol==="https:"||e.protocol==="http:"&&sn.has(e.hostname)}catch{return!1}}function L(n,e){return n==null||n===""?null:typeof n=="string"&&(P(n)||cn(n))?n:(e("partsUrl",n),null)}function cn(n){if(typeof location>"u")return!1;try{return new URL(n).origin===location.origin}catch{return!1}}function ln(n){if(typeof n!="string")return null;try{let e=new URL(n);return e.protocol==="https:"&&e.href===new URL(e.origin).href?e.origin:null}catch{return null}}function I(n,e){if(!Array.isArray(n))return e("embedOrigins",n),[];let t=[],o=n;for(let r of o){let i=ln(r);i?t.push(i):e("embedOrigin",r)}return t}function fn(n){let e,t;if(typeof n=="string"){let o=n.indexOf(".");e=o>0?n.slice(0,o):"",t=n.slice(o+1)}else typeof n=="object"&&n!==null&&(e=Reflect.get(n,"namespace"),t=Reflect.get(n,"key"));return typeof e!="string"||typeof t!="string"?null:en.test(e)&&nn.test(t)?{namespace:e,key:t}:null}function U(n,e){if(!Array.isArray(n))return e("metafields",n),[];let t=[],o=n;for(let r of o){let i=fn(r);i?t.push(typeof r=="string"?r:i):e("metafield",r)}return t}var d=n=>e=>n(e)?e:void 0,dn=n=>y(n)&&tn.test(n),pn=n=>y(n)&&on.test(n),gn=n=>typeof n=="boolean"||y(n)&&rn.test(n),g=d(P),C=d(y),_=d(n=>typeof n=="boolean"),F=d(un);function m(n,e,t,o){if(e==null)return null;if(!O(e))return o(n,e),null;let r={};for(let i in t){let f=e[i];if(f===void 0)continue;let c=t[i](f);c===void 0?o(`${n}.${i}`,f):r[i]=c}return r}var yn={server:g,orderUrl:g,subscriptionsUrl:g,paymentUrl:g,logoutUrl:g,locale:C,navigate:F},mn="customer accounts need the Worker since 0.7.0: set account.server",On={country:C,language:C,locale:C},Cn={detect:n=>{if(typeof n=="boolean")return n;let e=Array.isArray(n)?n:[n];return typeof n=="string"||Array.isArray(n)?N.filter(t=>e.includes(t)):void 0},locales:n=>{if(!O(n))return;let e={};for(let[t,o]of Object.entries(n)){let r=m(`markets.locales.${t}`,o,On,()=>{});r&&(e[t]=r)}return e},cookie:d(pn),remember:_,strict:_},kn={consent:n=>an.find(e=>e===n),proxy:n=>n!==void 0&&!!n},Tn={dataLayer:d(gn),shopify:n=>typeof n=="boolean"?n:m("analytics.shopify",n,kn,()=>{})??void 0,onEvent:F};function $(n,e,t){let o=m("account",n,yn,e);if(o===null)return null;let{server:r}=o;return r===void 0?(t(mn),null):{...o,server:r}}var b=(n,e)=>m("markets",n,Cn,e),V=(n,e)=>m("analytics",n,Tn,e);var l={domain:"",token:"",apiVersion:E,country:void 0,language:void 0,locale:void 0,markets:null,prefix:"tether",productPath:"/product",collectionPath:"/collection",metafields:[],embedOrigins:[],imagesFirst:25,variantsFirst:100,sellingPlanGroupsFirst:10,sellingPlansFirst:25,collectionFirst:24,retries:2,requestTimeout:15e3,revalidate:!0,storageKey:"",cartDrawerOpenClass:"is-open",openCartOnAdd:!0,cartFocus:!0,checkoutTarget:"_self",defaultPurchase:"one-time",variantUrl:!1,maxAge:60,lowStock:5,searchDelay:150,autoMount:!0,observe:!1,astro:!0,partsUrl:null,analytics:null,account:null,warningText:null,formatMoney:null,onLayoutChange:null,onCartOpen:null,onCartClose:null,onLineEnter:null,onLineLeave:null,onValueChange:null,onError:null,debug:!1},a={...l};function Y(n){let e=t=>(u(`Tether.config is read-only (${String(t)}): pass options to Tether.init() instead`),!1);return new Proxy(n,{get(t,o){let r=Reflect.get(t,o);return typeof r=="object"&&r!==null?Y(r):r},set:(t,o)=>e(o),deleteProperty:(t,o)=>e(o),defineProperty:(t,o)=>e(o)})}var ee=Y(a),hn=/^[a-z][a-z0-9-]*$/,bn=["revalidate","openCartOnAdd","cartFocus","variantUrl","autoMount","observe","astro","debug"],wn=["token","productPath","collectionPath","cartDrawerOpenClass"],An=["imagesFirst","variantsFirst","sellingPlanGroupsFirst","sellingPlansFirst","collectionFirst","retries","requestTimeout","maxAge","lowStock","searchDelay"],Sn=["warningText","formatMoney","onLayoutChange","onCartOpen","onCartClose","onLineEnter","onLineLeave","onValueChange","onError"];function p(n,e,t){return e!==void 0&&u(`invalid ${n} ${JSON.stringify(e)}: using ${JSON.stringify(t)}`),t}function s(n,e){u(`invalid ${n} ${JSON.stringify(e)}: ignored`)}function xn(n){for(let e of Object.keys(n))e in l||u(`unknown option ${JSON.stringify(e)}: ignored`)}function En(n,e,t){typeof t=="function"?n[e]=t:t!=null&&s(e,t)}var D=2147483647,Rn=10,_n={requestTimeout:D,searchDelay:D,retries:Rn};function Nn(n,e){if(typeof e!="number"||!Number.isInteger(e)||e<0)return p(n,e,l[n]);let t=_n[n];return t===void 0||e<=t?e:(u(`${n} ${String(e)} is more than its maximum: using ${String(t)}`),t)}function Mn(n,e){return typeof e=="boolean"?e:p(n,e,l[n])}function Pn(n,e){return typeof e=="string"?e:p(n,e,l[n])}function Ln(n){if(!(n==null||n==="")){try{if(typeof n=="string"&&Intl.getCanonicalLocales(n).length)return n}catch{}s("locale",n)}}function H(n,e,t){return t.find(o=>o===e)??p(n,e,t[0])}function In(n){return n==="unstable"?(u('apiVersion "unstable" changes without notice. Pin a dated version (e.g. 2026-07).'),n):S(n)?n:p("apiVersion",n,l.apiVersion)}function K(n,e,t){if(e==null||e==="")return;let o=t(e);if(o!==null)return o;s(n,e)}function Un(n){xn(n);let e=M(n.domain,s),t=typeof n.prefix=="string"&&hn.test(n.prefix)?n.prefix:p("prefix",n.prefix,l.prefix),o={...l,domain:e,apiVersion:In(n.apiVersion),country:K("country",n.country,T),locale:Ln(n.locale),partsUrl:L(n.partsUrl,s),language:K("language",n.language,h),markets:b(n.markets,s),analytics:V(n.analytics,s),account:$(n.account,s,u),prefix:t,storageKey:typeof n.storageKey=="string"&&n.storageKey?n.storageKey:`${t}:cart:${e}`,metafields:U(n.metafields??[],s),embedOrigins:I(n.embedOrigins??[],s),checkoutTarget:H("checkoutTarget",n.checkoutTarget,["_self","_blank"]),defaultPurchase:H("defaultPurchase",n.defaultPurchase,["one-time","subscription"])};for(let r of An)o[r]=Nn(r,n[r]);for(let r of bn)o[r]=Mn(r,n[r]);for(let r of wn)o[r]=Pn(r,n[r]);for(let r of Sn)En(o,r,n[r]);return o}var te=n=>b(n,s);function oe(n={}){let e=Un(n);for(let t of Object.keys(a))t in e||Reflect.deleteProperty(a,t);return Object.assign(a,e)}var re=()=>!!(a.domain&&a.token);function ie(...n){a.debug&&console.log(`[${a.prefix}]`,...n)}function u(...n){console.warn(`[${a.prefix}]`,...n)}function se(n,e){if(u(e,n instanceof Error&&n.message?n.message:n),!!a.onError)try{a.onError(n,e)}catch(t){u("onError threw",t)}}function ce(n){return n instanceof Error?n.message:String(n)}var fe={domain:["PUBLIC_SHOPIFY_DOMAIN","PUBLIC_SHOPIFY_STORE_DOMAIN","SHOPIFY_DOMAIN"],token:["PUBLIC_SHOPIFY_STOREFRONT_TOKEN","PUBLIC_SHOPIFY_STOREFRONT_ACCESS_TOKEN","SHOPIFY_STOREFRONT_TOKEN"]};function de(n){if(typeof n!="string")return!1;try{return new URL(n).protocol==="https:"}catch{return!1}}function pe(n){return/^shp[a-z]{2}_/.test(n.trim())}function ge(n,e){if(!n)return"";let t=parseFloat(n.amount);if(Number.isNaN(t))return"";try{return new Intl.NumberFormat(e||void 0,{style:"currency",currency:n.currencyCode}).format(t)}catch{return`${n.currencyCode} ${t.toFixed(2)}`}}function ye(n,e,t){if(!/\{(handle|id)\}/.test(n))return e?`${n.replace(/\/$/,"")}/${encodeURIComponent(e)}`:null;let o=t?t.split("/").at(-1)??"":"";return n.includes("{handle}")&&!e||n.includes("{id}")&&!o?null:n.replace(/\{handle\}/g,encodeURIComponent(e??"")).replace(/\{id\}/g,encodeURIComponent(o))}function me(n){let e=String(n??"").trim();return e?e.startsWith("gid://")?e:/^\d+$/.test(e)?`gid://shopify/Product/${e}`:/\/products\/([^/?#]+)/.exec(e)?.[1]??e:null}export{Fn as a,$n as b,Dn as c,O as d,v as e,Q as f,Z as g,B as h,Kn as i,x as j,Yn as k,Gn as l,N as m,fn as n,T as o,h as p,l as q,a as r,ee as s,Un as t,te as u,oe as v,re as w,ie as x,u as y,se as z,ce as A,fe as B,de as C,pe as D,ge as E,ye as F,me as G};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as a}from"./chunk-
|
|
1
|
+
import{c as a}from"./chunk-OENVX4NY.js";import{a as o}from"./chunk-2J3MTS3E.js";import{o as u,p as i,r as n,x as c,z as g}from"./chunk-OJAV2I3C.js";var f={country:void 0,language:void 0,locale:void 0},l=!1;function d(){let t=e=>document.querySelector(`meta[name="${n.prefix}-page-${e}"]`)?.getAttribute("content")||void 0,r=u(t("country"));return r?{country:r,language:i(t("language"))??void 0,locale:t("locale")}:null}async function m(){let t=n.markets??{};if(t.detect===!1)return null;if(!t.detect)return t.remember===!1?null:a();try{return(await o("markets")).detectMarket(t)}catch(r){return g(r,"markets"),null}}async function C(t){f={country:n.country,language:n.language,locale:n.locale};let r=d();if(l=r!==null,r){n.country=r.country,n.language=r.language,r.locale&&(n.locale=r.locale);return}let e=await m();e&&(e.country&&(n.country=e.country),e.language&&(n.language=e.language),e.locale&&!t.locale&&(n.locale=e.locale),c("market",e))}var s=(t,r)=>(t??"").toUpperCase()===(r??"").toUpperCase();function P(){let t=d(),r=t===null&&l;l=t!==null;let e=t??(r?a()??f:null);return!e?.country||s(e.country,n.country)&&s(e.language,n.language)?null:{country:e.country,language:e.language,locale:e.locale}}function S(t,r){return o("markets").then(e=>e.setCountry(t,r))}export{C as a,P as b,S as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as A}from"./chunk-
|
|
1
|
+
import{a as A}from"./chunk-4FR3CUO2.js";import{a as l,b as K,c as $}from"./chunk-FI4NIWAD.js";import{b as E,d as b,g as m}from"./chunk-CRKJ2VEX.js";import{c as C,f as M,g as H,h as R}from"./chunk-H6IORH7O.js";import{f as T}from"./chunk-FWMPL6PR.js";import{l as c,n as L,p as x,t as p}from"./chunk-OATTAXPO.js";import{d as w,o as k,p as v,r as a,x as h,y as P,z as f}from"./chunk-OJAV2I3C.js";var W='script[type="application/json"][data-tether-hydrate]',g=new WeakSet,ut=new WeakSet,s=new Set,N=new Set,F=new WeakMap;function q(){s.forEach(t=>{t.isConnected||s.delete(t)}),N.forEach(t=>{t.root.isConnected||N.delete(t)})}function J(t,e){return[...t.matches?.(e)?[t]:[],...x(t,e)]}function z(t,e){let n=L(t,"page-title");!n||typeof document>"u"||(document.title=n.replace(/\{title\}/g,e.title).replace(/\{vendor\}/g,e.vendor||"").replace(/\{type\}/g,e.productType||""))}function D(t,{fromUrl:e,raw:n}){e?(g.add(t),m(t,"not-found"),p("product-not-found",{key:null,source:n},t)):t.closest(A())||P(`[${c("product")}] without a value. Bind it to the Shopify handle field, or use "url:handle".`,t)}function B(t,e,{fromUrl:n,raw:r},o){let d=b(o);if(m(t,d?"not-found":"error",o),!d){f(o,`product ${e}`),p("error",{error:o,context:"product",key:e},t);return}p("product-not-found",{key:e,source:r},t),n?h(`product not found: ${e}`):f(o,`product ${e}`)}function Q(t){if(g.has(t))return!1;let{key:e,...n}=E(t);if(!e)return D(t,n),!1;g.add(t),s.add(t);let r={};F.set(t,r);let o=()=>F.get(t)===r;return l.get(t)?t.setAttribute(c("state"),"updating"):m(t,"loading"),j(C(e)).then(u=>{if(!o())return;let S=l.get(t);S?S.update(u):new $(t,u),z(t,u),a.revalidate&&H(e)&&U(e)}).catch(u=>{o()&&B(t,e,n,u)}),!0}function dt(){q(),s.forEach(t=>{t.getAttribute(c("state"))!=="error"||t.getAttribute(c("error"))==="not-found"||(g.delete(t),Q(t))})}var y=new Set;function U(t){y.size||setTimeout(_,0),y.add(t)}function Y(t,e){s.forEach(n=>{let r=l.get(n);if(!r||!n.isConnected)return;let o=E(n).key;o!==t&&o!==e.handle&&o!==e.id||JSON.stringify(r.product)!==JSON.stringify(e)&&r.update(e)})}function _(){let t=[...y];y=new Set,t.forEach(e=>{R(e).then(n=>{Y(e,n)}).catch(n=>{f(n,`refresh ${e}`)})})}var i=null,j=t=>(i?.add(t),t);function G(){if(!i)return;let t=[...i];Promise.allSettled(t).then(()=>{if(!(!i||t.some(e=>!i?.has(e)))){if(t.length!==i.size){G();return}i=null,document.documentElement.classList.remove(`${a.prefix}-market-pending`)}})}function I(t){if(!w(t))return{country:void 0,language:void 0,products:[]};let{products:e}=t,n=Array.isArray(e)?e:[];return{country:k(t.country)??void 0,language:v(t.language)??void 0,products:n.filter(T)}}var O=new WeakSet;function at(t=document){J(t,W).forEach(e=>{if(O.has(e))return;O.add(e);let n;try{n=JSON.parse(e.textContent)}catch(u){P("bad data-tether-hydrate",u);return}let{country:r,language:o,products:d}=I(n);if(K(d),r===a.country&&o===a.language){M(d);return}h("hydration skipped: other market"),i||(i=new Set,document.documentElement.classList.add(`${a.prefix}-market-pending`))})}export{g as a,ut as b,s as c,N as d,q as e,J as f,Q as g,dt as h,j as i,G as j,at as k};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{e as E}from"./chunk-
|
|
1
|
+
import{e as E}from"./chunk-BVO7KK2M.js";import{a as M}from"./chunk-2J3MTS3E.js";import{b as h,e as A}from"./chunk-CRKJ2VEX.js";import{c as D}from"./chunk-H6IORH7O.js";import"./chunk-FWMPL6PR.js";import{d as P,e as $,h as v,l as p,m as l,n as m,p as d,x as S}from"./chunk-OATTAXPO.js";import{c as k,r as a,w}from"./chunk-OJAV2I3C.js";var R=new Set(["in-stock","out-of-stock","backorder","low-stock","plenty-in-stock","on-sale","not-on-sale","has-variants","single-variant","subscription-available","subscription-unavailable","subscription-only","one-time-available","subscription-selected","one-time-selected","has-savings","loading","ready","error","not-found","cart-empty","cart-filled","cart-has-subscription","cart-no-subscription","cart-has-discount","cart-error","cart-warning","list-empty","list-filled","search-empty","search-results","logged-in","logged-out","orders-empty","orders-loading","addresses-loading","addresses-empty","addresses-error","subscriptions-loading","subscriptions-empty","subscriptions-error"]),N=new Set(["title","description","description-text","vendor","type","handle","published-at","price","total-price","compare-at-price","unit-price","min-price","max-price","discount-percentage","discount-amount","variant-title","variant-id","sku","barcode","stock","quantity","featured-image","variant-image","images","tags","link","url","one-time-price","subscription-price","subscription-savings","subscription-savings-amount","checkout-charge","plan-name","plan-description","plan-group","option-value","swatch","image"]),x=new Set(`account account-bind account-link account-login account-logout add-label add-to-cart adding-text
|
|
2
2
|
always-enabled bind cart-checkout-charge cart-clear cart-close cart-count cart-discounts cart-drawer cart-label cart-lines
|
|
3
3
|
cart-note cart-open cart-subtotal cart-total cart-warning checkout code collection collection-bind countries country
|
|
4
4
|
country-bind country-label country-select default-plan default-purchase discount discount-code discount-form discount-input
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as v}from"./chunk-
|
|
1
|
+
import{c as v}from"./chunk-SZRDO62E.js";import{a as b,b as S}from"./chunk-OENVX4NY.js";import{a as k}from"./chunk-FI4NIWAD.js";import{h as p}from"./chunk-7ZXEVDOS.js";import"./chunk-DM5LEAWM.js";import"./chunk-BVO7KK2M.js";import"./chunk-2J3MTS3E.js";import"./chunk-CRKJ2VEX.js";import"./chunk-H6IORH7O.js";import"./chunk-FWMPL6PR.js";import{N as h,O as w,m as l,n as f,o as g,p as d,t as y}from"./chunk-OATTAXPO.js";import{r as s,y as m,z as u}from"./chunk-OJAV2I3C.js";function U(t,r){let e=w(h(t,"line-attributes"));return r?[{key:"_group",value:r},...e]:e}async function V(t){let r=t.closest(l("group"));if(!r)return null;let e=f(r,"group"),n=U(r,e),i=d(r,l("product")).flatMap(a=>{let o=k.get(a);if(!o?.variant?.availableForSale||o.quantity<=0)return[];let c=o.getLine();return c?[{...c,attributes:[...c.attributes??[],...n]}]:[]});if(!i.length)return m("group-add: nothing selected"),null;try{let a=await p.add(i);return y("group-added",{group:e,lines:i},r),a}catch(a){return u(a,"group add"),null}}function _(t){if(t.key===s.storageKey||t.key===`${s.storageKey}:seen`){p.init().catch(n=>{u(n,"cart from another tab")});return}if(t.key!==b()||!t.newValue)return;let r=S(t.newValue);if(!r)return;let e={language:r.language??null,locale:r.locale,remember:!1};v(r.country,e).catch(n=>{u(n,"market from another tab")})}var E=new WeakMap,K=t=>t.split("/").pop()??t;function x(t){try{window.history.replaceState(window.history.state,"",t)}catch{}}function $(t,{variant:r,sellingPlanId:e}){let n=`${r.id}|${e??""}`,i=E.get(t);if(E.set(t,n),!i||i===n)return;let a=s.variantUrl&&document.querySelector(l("product"))===t;if(!g(t,"variant-url")&&!a)return;let o=new URL(window.location.href);o.searchParams.set("variant",K(r.id)),e?o.searchParams.set("selling_plan",K(e)):o.searchParams.delete("selling_plan"),x(o)}export{V as addGroup,_ as onStorage,$ as writeVariantUrl};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as T}from"./chunk-
|
|
1
|
+
import{a as T}from"./chunk-4FR3CUO2.js";import"./chunk-2J3MTS3E.js";import{b as E,d as w,g as I}from"./chunk-CRKJ2VEX.js";import{a as H,b as m,d as h}from"./chunk-H6IORH7O.js";import{c as A,h as x,i as M,j as O}from"./chunk-FWMPL6PR.js";import{E as b,F as $,H as f,K as N,M as q,a as y,h as a,l as P,m as c,n as i,o as d,q as k,t as u,w as v,y as K}from"./chunk-OATTAXPO.js";import{b as l,r as L,z as S}from"./chunk-OJAV2I3C.js";var U="url:",Y=`query TetherCollection($handle:String!,$first:Int!,$after:String,$sortKey:ProductCollectionSortKeys,$reverse:Boolean,$filters:[ProductFilter!]){collection(handle:$handle){${A()} products(first:$first,after:$after,sortKey:$sortKey,reverse:$reverse,filters:$filters){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}}`,B="query TetherSearch($first:Int!,$after:String,$query:String,$sortKey:ProductSortKeys,$reverse:Boolean){products(first:$first,after:$after,query:$query,sortKey:$sortKey,reverse:$reverse){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}";async function W({collection:n,query:t,first:o=L.collectionFirst,after:e=null,sortKey:r,reverse:s=!1,filters:D}={}){if(n){let C=await a(h(Y),{handle:n,first:o,after:e,sortKey:r||void 0,reverse:s,filters:D??void 0},x);if(!C.collection)throw new y(`Collection not found: ${n}`,{code:"NOT_FOUND"});let{products:g,..._}=C.collection;return g.nodes.forEach(m),{collection:_,products:g.nodes,pageInfo:g.pageInfo}}let p=await a(h(B),{first:o,after:e,query:t||void 0,sortKey:r||void 0,reverse:s},M);return p.products.nodes.forEach(m),{collection:null,products:p.products.nodes,pageInfo:p.products.pageInfo}}async function j(n,t="RELATED"){let o=H(typeof n=="object"?n?.id:n);if(!o)throw new y("No product for recommendations",{code:"NOT_FOUND"});let e=o.startsWith("gid://"),s=(await a(h(`query TetherRecs(${e?"$id: ID!":"$handle: String!"},$intent:ProductRecommendationIntent){productRecommendations(${e?"productId: $id":"productHandle: $handle"},intent:$intent){...TetherProduct}}`),e?{id:o,intent:t}:{handle:o,intent:t},O)).productRecommendations??[];return s.forEach(m),s}var z=n=>n instanceof window.Element,F=n=>parseInt(n??"",10)||void 0,G=n=>n==="COMPLEMENTARY"?"COMPLEMENTARY":"RELATED",R=class{constructor(t){l(this,"root");l(this,"products",[]);l(this,"pageInfo",null);l(this,"collection",null);l(this,"loadToken",0);this.root=t,t.addEventListener("click",o=>{if(!z(o.target))return;let e=o.target.closest(c("load-more"));e?.closest(T())===t&&(o.preventDefault(),q(e,()=>this.load(!0)))})}$(t){return k(this.root,t,T())}options(){let{root:t}=this,o={reverse:i(t,"reverse")==="true"},e=F(i(t,"limit"));e&&(o.first=e);let r=i(t,"sort");if(r&&(o.sortKey=r),d(t,"collection"))return o.collection=i(t,"collection")??"",o;let s=i(t,"products")??"";return o.query=s.startsWith(U)?new URL(window.location.href).searchParams.get(s.slice(U.length))||"":s,o}async loadRecommendations(){let{key:t}=E(this.root,window.location,"recommendations"),o=this.root.closest(c("product"));return!t&&o&&({key:t}=E(o)),j(t,G(i(this.root,"intent")))}async load(t=!1){this.loadToken+=1;let o=this.loadToken,e=()=>o!==this.loadToken;try{if(d(this.root,"recommendations")){let r=await this.loadRecommendations();if(e())return;let s=F(i(this.root,"limit"));this.products=s?r.slice(0,s):r}else{let r=await W({...this.options(),after:t?this.pageInfo?.endCursor??null:null});if(e())return;this.collection=r.collection,this.pageInfo=r.pageInfo,this.products=t?[...this.products,...r.products]:r.products}this.render(),I(this.root,"ready"),u("list-ready",{products:this.products,collection:this.collection},this.root)}catch(r){if(e())return;t||I(this.root,w(r)?"not-found":"error",r),w(r)&&d(this.root,"recommendations")||S(r,"list load failed"),u("error",{error:r,context:"list"},this.root)}}render(){let{collection:t}=this;this.$(c("collection-bind")).forEach(e=>{switch(i(e,"collection-bind")??""){case"title":$(e,t?.title??"");break;case"description":b(e,t?.descriptionHtml);break;case"image":v(e,t?.image?.url,t?.image?.altText||t?.title);break;case"count":$(e,this.products.length);break}}),this.$(c("list")).forEach(e=>{K(e,this.products,(r,s)=>{r.setAttribute(P("product"),s.handle),r.removeAttribute(P("state"))}),u("list-rendered",{container:e},this.root)});let o=this.products.length===0;this.$(c("show")).forEach(e=>{let r=i(e,"show");r==="list-empty"&&f(e,o),r==="list-filled"&&f(e,!o)}),this.$(c("load-more")).forEach(e=>{f(e,!!this.pageInfo?.hasNextPage)}),N("list")}},Q=new WeakMap;function nt(n){let t=Q.get(n);return t||(t=new R(n),Q.set(n,t)),t.load()}export{W as getProducts,j as getRecommendations,nt as loadList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as E,c as P,d as k,e as T,f as p,g as A}from"./chunk-
|
|
1
|
+
import{a as E,c as P,d as k,e as T,f as p,g as A}from"./chunk-Y3NKKN2O.js";import{a as I}from"./chunk-4FR3CUO2.js";import{d as F,e as x}from"./chunk-OENVX4NY.js";import"./chunk-FI4NIWAD.js";import{h as u}from"./chunk-7ZXEVDOS.js";import"./chunk-DM5LEAWM.js";import"./chunk-BVO7KK2M.js";import"./chunk-2J3MTS3E.js";import"./chunk-CRKJ2VEX.js";import{e as w}from"./chunk-H6IORH7O.js";import"./chunk-FWMPL6PR.js";import{a as L,d as h,h as b,l as s,m as C,n as v,t as z}from"./chunk-OATTAXPO.js";import{o as f,p as g,r as a,z as y}from"./chunk-OJAV2I3C.js";var _="{name} ({currency})",j="name",d=null;function B(){d=null}var D="query TetherLocalization{localization{country{isoCode name currency{isoCode symbol}}language{isoCode name}availableCountries{isoCode name currency{isoCode symbol}availableLanguages{isoCode name}}}}",O={isoCode:"string",name:"string",currency:"object"},H=h({localization:{country:O,availableCountries:[O]}});function R(){return d??(d=b(D,{},H).then(e=>e.localization,e=>{throw d=null,e})),d}function U(e,n){switch(n){case"name":return e.name;case"code":return e.isoCode;case"currency":return e.currency.isoCode;case"symbol":return e.currency.symbol;default:return""}}var Y=(e,n)=>e.replace(/\{(name|code|currency|symbol)\}/g,(o,i)=>U(n,i));function q(e,n,o){let i=e.getAttribute(s("country-label"))||_,r=(e.getAttribute(s("countries"))||"").toUpperCase().split(/[\s,]+/).filter(Boolean),c=r.length?r.map(t=>n.find(l=>l.isoCode===t)).filter(t=>t!==void 0):n;e.replaceChildren(...c.map(t=>new Option(Y(i,t),t.isoCode))),e.value=o,e.value!==o&&(e.selectedIndex=-1),e.disabled=c.length<2&&!e.hasAttribute(s("always-enabled"))}function $(e,n,o){let i=(a.country||o.country.isoCode).toUpperCase(),r=[...o.availableCountries].sort((t,l)=>t.name.localeCompare(l.name,a.locale||void 0)),c=r.find(t=>t.isoCode===i)??o.country;e.forEach(t=>{q(t,r,i)}),n.forEach(t=>{t.textContent=U(c,v(t,"country-bind")||j)})}function S(e=document){let n=p(e,`select${C("country-select")}`),o=p(e,C("country-bind"));return!n.length&&!o.length?Promise.resolve():R().then(i=>{$(n,o,i)}).catch(i=>{y(i,"country select")})}var Q=e=>Object.values(a.markets?.locales??{}).find(n=>f(n.country)===e);function V(e,n){return e!==void 0?g(e):n?n.language?g(n.language):void 0:a.language}function Z(e){w();let n=[];return u.id()&&n.push(u.setBuyerIdentity({countryCode:e},{create:!1}).catch(o=>{y(o,"cart country")})),T(),k.forEach(o=>n.push(o.load())),P.forEach(o=>{o.closest(I())||(E.delete(o),A(o))}),n}async function re(e,{language:n,locale:o,remember:i=!0}={}){let r=f(e);if(!r)throw new L(`Not a country code: ${e}`,{code:"INVALID_COUNTRY"});let c=Q(r),t=o||c?.locale,l=t||a.locale,m=V(n,c),M=r!==a.country||m!==a.language||l!==a.locale;if(a.country=r,a.language=m||void 0,a.locale=l,i&&x({country:r,language:m,locale:t}),!M)return S(),u.state;n!==void 0&&B();let N=Z(r);return S(),z("country-changed",{country:r,language:a.language}),await Promise.all(N),u.state}export{F as detectMarket,R as getLocalization,S as renderCountrySelects,re as setCountry};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as M}from"./chunk-
|
|
1
|
+
import{f as M}from"./chunk-Y3NKKN2O.js";import"./chunk-4FR3CUO2.js";import"./chunk-FI4NIWAD.js";import"./chunk-7ZXEVDOS.js";import"./chunk-DM5LEAWM.js";import"./chunk-BVO7KK2M.js";import"./chunk-2J3MTS3E.js";import"./chunk-CRKJ2VEX.js";import"./chunk-H6IORH7O.js";import"./chunk-FWMPL6PR.js";import{A as x,C,F as q,H as d,c as S,d as E,h as T,l as A,m as o,n as m,p as h,t as I,w as L,y as w}from"./chunk-OATTAXPO.js";import{b as a,r as u,x as b,z as y}from"./chunk-OJAV2I3C.js";var N=E({predictiveSearch:S({products:[{priceRange:"object"}],collections:["object"],queries:[{text:"string"}]})}),U="query TetherPredictive($q:String!,$limit:Int!){predictiveSearch(query:$q,limit:$limit,limitScope:EACH,types:[PRODUCT,COLLECTION,QUERY]){products{id handle title availableForSale featuredImage{url altText}priceRange{minVariantPrice{amount currencyCode}}}collections{handle title image{url altText}}queries{text}}}",D=6,V=2,F="/search",R=new WeakSet,v=0;function $(s,t,e){return parseInt(m(s,t)||"",10)||e}var H=s=>s.tagName==="A"?s:s.querySelector("a");function p(s,t){h(s,o("search-bind")).forEach(e=>{let i=m(e,"search-bind");i==="image"?L(e,t.image?.url,t.image?.altText||t.title):(i==="title"||i==="price"||i==="text")&&t[i]!=null&&q(e,t[i])})}function k(s,t){let e=H(s);e&&(t&&e.setAttribute("href",t),e.setAttribute("role","option"))}var f=class{constructor(t,e,i){a(this,"root");a(this,"input");a(this,"results");a(this,"limit");a(this,"minCharacters");a(this,"resultsId");a(this,"searchNumber",0);a(this,"timer");a(this,"lastTerm","");a(this,"cache",new Map);this.root=t,this.input=e,this.results=i,this.limit=$(t,"search-limit",D),this.minCharacters=$(t,"search-min",V),i.id||(v+=1,i.id=`${u.prefix}-search-${v}`),this.resultsId=i.id,this.setUpAria(),this.listen()}setUpAria(){this.input.setAttribute("role","combobox"),this.input.setAttribute("aria-autocomplete","list"),this.input.setAttribute("aria-controls",this.resultsId),this.input.setAttribute("aria-expanded","false"),this.input.setAttribute("autocomplete","off"),this.results.hasAttribute("role")||this.results.setAttribute("role","listbox"),this.results.hidden=!0}listen(){this.input.addEventListener("input",()=>{let t=this.input.value.trim();t!==this.lastTerm&&(this.lastTerm=t,clearTimeout(this.timer),this.timer=setTimeout(()=>void this.search(t),u.searchDelay))}),this.input.addEventListener("focus",()=>{this.input.value.trim().length>=this.minCharacters&&this.options().length&&this.open(!0)}),this.input.addEventListener("keydown",t=>{this.onKeydown(t)}),document.addEventListener("click",t=>{this.root.contains(t.target)||this.open(!1)})}setState(t){this.root.setAttribute(A("search-state"),t)}open(t){this.root.classList.toggle("is-open",t),this.results.hidden=!t,this.input.setAttribute("aria-expanded",String(t)),t||this.input.removeAttribute("aria-activedescendant")}options(){return h(this.results,'[role="option"]')}async fetchResults(t){let e=this.cache.get(t);if(e)return e;let i=await T(U,{q:t,limit:this.limit},N);return this.cache.set(t,i.predictiveSearch),i.predictiveSearch}async search(t){this.searchNumber+=1;let e=this.searchNumber;if(t.length<this.minCharacters){this.open(!1),this.setState("idle");return}this.setState("loading");try{let i=await this.fetchResults(t);e===this.searchNumber&&this.render(i,t)}catch(i){if(e!==this.searchNumber){b("a superseded search failed",i);return}this.setState("error"),y(i,"search")}}fillList(t,e,i){h(this.results,o(t)).forEach(l=>{w(l,e,i),d(l,e.length>0)})}queryUrl(t){let e=this.root.getAttribute("action")||F,i=e.includes("?")?"&":"?";return`${e}${i}${this.input.name||"q"}=${encodeURIComponent(t)}`}render(t,e){let i=t?.products??[],l=t?.collections??[],c=(t?.queries??[]).filter(n=>n.text.toLowerCase()!==e.toLowerCase());this.fillList("search-products",i,(n,r)=>{let P=C(r.priceRange.minVariantPrice);p(n,{title:r.title,price:P,image:r.featuredImage}),k(n,x(r.handle,r.id)),n.classList.toggle("is-sold-out",!r.availableForSale)}),this.fillList("search-collections",l,(n,r)=>{p(n,{title:r.title,image:r.image}),k(n,`${(u.collectionPath||"/collection").replace(/\/$/,"")}/${r.handle}`)}),this.fillList("search-queries",c,(n,r)=>{p(n,{text:r.text}),H(n)?.setAttribute("href",this.queryUrl(r.text))});let g=i.length+l.length+c.length;this.showCount(g),this.setState(g?"ready":"empty"),this.open(!0),I("search",{term:e,products:i,collections:l,queries:c},this.root)}showCount(t){h(this.root,o("show")).forEach(e=>{let i=m(e,"show");i==="search-empty"&&d(e,t===0),i==="search-results"&&d(e,t>0)}),this.options().forEach((e,i)=>{e.id||(e.id=`${this.resultsId}-${i}`),e.setAttribute("aria-selected","false")})}highlight(t,e){t.forEach((l,c)=>{l.setAttribute("aria-selected",String(c===e))});let i=t[e];i&&(this.input.setAttribute("aria-activedescendant",i.id),i.scrollIntoView?.({block:"nearest"}))}onKeydown(t){let e=this.options(),i=e.findIndex(l=>l.getAttribute("aria-selected")==="true");t.key==="ArrowDown"&&e.length?(t.preventDefault(),this.open(!0),this.highlight(e,(i+1)%e.length)):t.key==="ArrowUp"&&e.length?(t.preventDefault(),this.highlight(e,i<=0?e.length-1:i-1)):t.key==="Enter"&&i>=0?(t.preventDefault(),e[i]?.click()):t.key==="Escape"&&this.open(!1)}};function j(s=document){for(let t of M(s,o("search"))){if(R.has(t))continue;R.add(t);let e=t.querySelector(o("search-input"))??t.querySelector("input"),i=t.querySelector(o("search-results"));e&&i&&new f(t,e,i)}}export{j as mountSearch};
|
package/dist/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as st,b as at,c as ct}from"./chunks/chunk-E3JL6WS3.js";import{b as C,d as w,e as T,f as p,g as et,h as nt,i as ot,j as k,k as S}from"./chunks/chunk-VKKKH75V.js";import{a as lt,b as dt}from"./chunks/chunk-6WE7XCHH.js";import{a as rt,b as it,c as h}from"./chunks/chunk-F5CLIGSC.js";import"./chunks/chunk-GOKJQGLG.js";import{a as tt}from"./chunks/chunk-2NV5PSJ2.js";import{a as z,e as X,h as s}from"./chunks/chunk-RW23CJDZ.js";import"./chunks/chunk-2IHA3PVC.js";import{l as Q}from"./chunks/chunk-2LYWZ72A.js";import{a as u,b as ut}from"./chunks/chunk-5B36ISJF.js";import{b as Z}from"./chunks/chunk-YWQWLKFW.js";import{a as K,b as W,c as Y,e as J}from"./chunks/chunk-2X5U24IC.js";import"./chunks/chunk-6ZIOAYKF.js";import{C as q,J as P,M as f,a as v,f as G,j as U,l as d,m as r,r as B,s as g,t as y,u as j}from"./chunks/chunk-TW34GYSL.js";import{e as $,r as c,s as V,v as F,w as E,x as L,y as _,z as a}from"./chunks/chunk-YYNBHXQF.js";var x="0.9.0";var Mt=["account-login","account-bind","account-link","orders","order","addresses","subscriptions","profile-form","address-form"],It=()=>[...Mt.map(t=>`[${d(t)}]`),`[${d("show")}^="logged-"]`].join(",");function Nt(){return!!X(st())}function mt(t){!c.account||!(p(t,It()).length>0||ct(new URLSearchParams(window.location.search).get("account"))||Nt())||u("account").then(n=>n.mountAccount(t)).catch(n=>{a(n,"account")})}function l(t){return(...e)=>u("account").then(n=>{let o=n[t];return o(...e)})}var ft={login:l("login"),logout:l("logout"),isLoggedIn:l("isLoggedIn"),customer:l("customer"),orders:l("orders"),order:l("order"),updateProfile:l("updateProfile"),addresses:l("addresses"),saveAddress:l("saveAddress"),deleteAddress:l("deleteAddress"),subscriptions:l("subscriptions"),subscriptionAction:l("subscriptionAction"),requestReturn:l("requestReturn"),render:l("render"),mountAccount:l("mountAccount")};var pt=()=>`data-${c.prefix}-key`,yt=t=>t instanceof window.Element;function ht(t){let e=t.closest(`[${pt()}]`),n=e?.getAttribute(pt());return e&&n?{line:e,id:n}:null}function A(t,e){t.catch(n=>{a(n,e)})}function Ot(t,e){let n=ht(e);if(!n?.line.closest(r("cart-lines")))return;let{line:o,id:i}=n;if(e.closest(r("line-remove"))){t.preventDefault(),o.classList.add("is-busy"),A(s.removeLine(i),"cart line");return}let H=Dt(e);!H||!s.lines.some(xt=>xt.id===i)||(t.preventDefault(),A(s.changeQuantity(i,H),"cart line"))}function Dt(t){return t.closest(r("line-plus"))?1:t.closest(r("line-minus"))?-1:0}function Rt(t){let{target:e}=t;if(!yt(e))return;if(e.closest(r("cart-open"))){t.preventDefault(),s.toggle();return}if(e.closest(r("cart-close"))){t.preventDefault(),s.close();return}let n=e.closest(r("cart-clear"));if(n){t.preventDefault(),f(n,()=>s.clear().catch(i=>{a(i,"cart clear")}));return}let o=e.closest(r("checkout"));if(o){t.preventDefault(),f(o,()=>s.checkout());return}Ot(t,e)}function gt(t,e,n){t.classList.add("is-busy"),t.setAttribute("aria-busy","true"),A(e,n)}function Ht(t){let{target:e}=t;if(!yt(e))return;let n=ht(e);n&&e instanceof window.HTMLInputElement&&e.matches(r("line","quantity"))?gt(n.line,s.updateLine(n.id,parseInt(e.value,10)||0),"cart line"):n&&e instanceof window.HTMLSelectElement&&e.matches(r("line-plan"))?gt(n.line,s.updateLine(n.id,{sellingPlanId:e.value||null}),"cart line plan"):$t(e)&&e.matches(r("cart-note"))&&A(s.setNote(e.value),"cart note")}var $t=t=>t instanceof window.HTMLInputElement||t instanceof window.HTMLTextAreaElement||t instanceof window.HTMLSelectElement;function Vt(t){if(s.isOpen()){if(t.key==="Escape"){s.close();return}z(t)}}function Et(){document.addEventListener("click",Rt),document.addEventListener("change",Ht),document.addEventListener("keydown",Vt)}var M=t=>t instanceof window.Element;function Ft(t){let e=t.querySelector(r("discount-input"))??t.querySelector("input");return e instanceof window.HTMLInputElement?e:null}function vt(t,e,n){t.classList.toggle("is-invalid",n),n?e?.setAttribute("aria-invalid","true"):e?.removeAttribute("aria-invalid")}async function _t(t,e,n){try{await s.applyDiscount(n),vt(t,e,!1),y("discount-applied",{code:n},t),e&&(e.value="")}catch(o){vt(t,e,!0),o instanceof v&&o.code==="INVALID_DISCOUNT"?y("discount-invalid",{code:n},t):a(o,"discount")}}function Gt(t){let{target:e}=t,n=M(e)?e.closest(r("discount-form")):null;if(!n)return;t.preventDefault();let o=Ft(n),i=o?.value.trim();i&&f(n,()=>_t(n,o,i))}function Ut(t){let{target:e}=t;if(!M(e))return;let n=e.closest(r("discount-form"));n&&(n.classList.remove("is-invalid"),e.removeAttribute("aria-invalid"))}function Bt(t){let{target:e}=t,n=M(e)?e.closest(r("discount-remove")):null;if(!n)return;t.preventDefault();let o=n.closest(r("discount-code"))?.getAttribute(d("discount-code"));o&&s.removeDiscount(o).catch(i=>{a(i,"discount")})}function Pt(){document.addEventListener("submit",Gt,!0),document.addEventListener("input",Ut),document.addEventListener("click",Bt)}var I=t=>u("extras").then(e=>e.addGroup(t)),N=t=>{a(t,"extras")};function jt(t){let{target:e}=t,n=e instanceof window.Element?e.closest(r("group-add")):null;n&&(t.preventDefault(),f(n,()=>I(n)).catch(N))}function qt(t){!c.domain||!t.key?.startsWith(`${c.prefix}:`)||u("extras").then(e=>{e.onStorage(t)}).catch(N)}function Qt(t){if(!g(t,"variant-changed"))return;let{target:e}=t;e instanceof window.Element&&(!c.variantUrl&&!e.hasAttribute(d("variant-url"))||u("extras").then(n=>{n.writeVariantUrl(e,t.detail)}).catch(N))}function wt(){document.addEventListener("click",jt),window.addEventListener("storage",qt),document.addEventListener(`${c.prefix}:variant-changed`,Qt)}var O=null;function At(){O=document.body}async function zt(t){await t.ready();let e=it();if(!e){O!==document.body&&t.mount(document);return}try{await h(e.country,{language:e.language??null,locale:e.locale,remember:!1})}catch(n){a(n,"country")}t.mount(document)}function Kt(t){document.addEventListener("astro:page-load",()=>{zt(t).catch(e=>{a(e,"page mount")})}),document.addEventListener("astro:before-swap",()=>{O=null,t.unmount()})}function Wt(t){let{target:e}=t;!(e instanceof window.HTMLSelectElement)||!e.matches(r("country-select"))||e.value&&h(e.value).catch(n=>{a(n,"country")})}function Yt(){nt(),w.forEach(t=>{t.root.getAttribute(d("state"))==="error"&&t.load()})}function bt(t){c.astro&&Kt(t),document.addEventListener("change",Wt),window.addEventListener("online",Yt)}var Jt=50;function Xt(){let t=P("TETHER_CONFIG");return typeof t=="object"&&t!==null?Object.fromEntries(Object.entries(t)):{}}var m=null,D=null,Ct=null,Lt=!1;function Zt(t){let e=0;return p(t,lt()).forEach(n=>{if(C.has(n))return;C.add(n),e++;let o=dt(n);w.add(o),n.addEventListener(`${c.prefix}:list-rendered`,i=>{g(i,"list-rendered")&&b(i.detail.container)}),ot(o.load())}),e}function te(t){p(t,`${r("country-select")},${r("country-bind")}`).length&&u("markets").then(e=>e.renderCountrySelects(t)).catch(e=>{a(e,"markets")}),mt(t),p(t,r("search")).length&&u("search").then(e=>{e.mountSearch(t)}).catch(e=>{a(e,"search")})}function Tt(t){let e=Zt(t);return p(t,r("product")).forEach(n=>{et(n)&&e++}),te(t),e}function b(t=document){if(!E())return 0;t===document&&At(),T(),S(t.ownerDocument??document);let e=Tt(t);return k(),s.render(),L(`mounted ${e} scope(s)`,t),e}function ee(t){let e=t.filter(o=>o.isConnected&&!t.some(i=>i!==o&&i.contains(o)));if(!e.length||!E())return;T(),e.forEach(o=>{S(o)});let n=e.reduce((o,i)=>o+Tt(i),0);k(),s.render(),L(`mounted ${n} scope(s) in ${e.length} added element(s)`)}function kt(){s.close()}function ne(t){let e=t?.closest(r("product"));return e?tt.get(e)??null:null}function oe(){Lt||(Lt=!0,Et(),Pt(),wt(),bt({ready:()=>m??Promise.resolve(null),mount:b,unmount:kt}))}function re(){let t=[];Ct=t,B.forEach(e=>{document.addEventListener(`${c.prefix}:${e}`,n=>t.push(n))}),document.addEventListener("astro:page-load",e=>t.push(e)),u("analytics").then(e=>e.startAnalytics(t)).catch(e=>{a(e,"analytics")})}async function ie(t){let e=c.country,n=t?.buyerIdentity.countryCode;if(!t||!e||!n||n===e)return t;try{return await s.setBuyerIdentity({countryCode:e},{create:!1})}catch(o){return a(o,"cart country"),t}}function St(t={}){return m&&!Object.keys(t).length?m:(F({...Xt(),...t}),E()?(at(),oe(),c.observe&&se(),c.analytics&&!Ct&&re(),m=rt(t).then(()=>s.init()).then(ie).then(e=>(y("ready",{cart:e}),R)),m):(_("TETHER_CONFIG is missing domain or token. Tether is idle."),m=Promise.resolve(null),m))}function se(){if(D||typeof MutationObserver>"u")return;let t,e=new Set;D=new MutationObserver(n=>{n.forEach(o=>{o.addedNodes.forEach(i=>{i instanceof window.Element&&e.add(i)})}),clearTimeout(t),t=setTimeout(()=>{let o=[...e];e.clear(),ee(o)},Jt)}),D.observe(document.body,{childList:!0,subtree:!0})}var ae=t=>u("markets").then(e=>e.detectMarket(t??c.markets)),ce=t=>u("lists").then(e=>e.getProducts(t)),ue=(t,e)=>u("lists").then(n=>n.getRecommendations(t,e)),le=()=>u("markets").then(t=>t.getLocalization()),de=t=>u("diagnose").then(e=>e.diagnose({...t,version:x}));function me(t,e){let n=`${c.prefix}:${t}`,o=i=>{g(i,t)&&e(i.detail,i)};return document.addEventListener(n,o),()=>{document.removeEventListener(n,o)}}var fe={VERSION:x,init:St,mount:b,unmount:kt,get config(){return V},get ready(){return m??Promise.resolve(null)},query:U,withContext:G,cart:s,getProduct:Y,getProducts:ce,getRecommendations:ue,getScope:ne,addGroup:I,account:ft,primeProduct:W,normalizeProductKey:K,clearProductCache:J,formatMoney:q,imageUrl:j,plans:Q,TetherError:v,resolveProductKey:Z,setCountry:h,detectMarket:ae,getLocalization:le,diagnose:de,on:me},pe={__core:ut,__parts:{}},R=Object.assign(fe,pe),cn=R;function ge(){Reflect.set(window,"Tether",R);let t=P("TETHER_CONFIG");if(!t||$(t,"autoMount")===!1||P("TETHER_INTEGRATION"))return;let e=()=>{St().then(()=>b(document)).catch(n=>{a(n,"init")})};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e,{once:!0}):e()}typeof window<"u"&&typeof document<"u"&&ge();export{x as VERSION,I as addGroup,R as api,cn as default,ne as getScope,St as init,b as mount,h as setCountry,kt as unmount};
|
|
1
|
+
import{a as st,b as at,c as ct}from"./chunks/chunk-IJAMRI33.js";import{b as C,d as w,e as T,f as p,g as et,h as nt,i as ot,j as k,k as S}from"./chunks/chunk-Y3NKKN2O.js";import{a as lt,b as dt}from"./chunks/chunk-4FR3CUO2.js";import{a as rt,b as it,c as h}from"./chunks/chunk-SZRDO62E.js";import"./chunks/chunk-OENVX4NY.js";import{a as tt}from"./chunks/chunk-FI4NIWAD.js";import{a as z,e as X,h as s}from"./chunks/chunk-7ZXEVDOS.js";import"./chunks/chunk-DM5LEAWM.js";import{l as Q}from"./chunks/chunk-BVO7KK2M.js";import{a as u,b as ut}from"./chunks/chunk-2J3MTS3E.js";import{b as Z}from"./chunks/chunk-CRKJ2VEX.js";import{a as K,b as W,c as Y,e as J}from"./chunks/chunk-H6IORH7O.js";import"./chunks/chunk-FWMPL6PR.js";import{C as q,J as P,M as f,a as v,f as G,j as U,l as d,m as r,r as B,s as g,t as y,u as j}from"./chunks/chunk-OATTAXPO.js";import{e as $,r as c,s as V,v as F,w as E,x as L,y as _,z as a}from"./chunks/chunk-OJAV2I3C.js";var x="0.9.2";var Mt=["account-login","account-bind","account-link","orders","order","addresses","subscriptions","profile-form","address-form"],It=()=>[...Mt.map(t=>`[${d(t)}]`),`[${d("show")}^="logged-"]`].join(",");function Nt(){return!!X(st())}function mt(t){!c.account||!(p(t,It()).length>0||ct(new URLSearchParams(window.location.search).get("account"))||Nt())||u("account").then(n=>n.mountAccount(t)).catch(n=>{a(n,"account")})}function l(t){return(...e)=>u("account").then(n=>{let o=n[t];return o(...e)})}var ft={login:l("login"),logout:l("logout"),isLoggedIn:l("isLoggedIn"),customer:l("customer"),orders:l("orders"),order:l("order"),updateProfile:l("updateProfile"),addresses:l("addresses"),saveAddress:l("saveAddress"),deleteAddress:l("deleteAddress"),subscriptions:l("subscriptions"),subscriptionAction:l("subscriptionAction"),requestReturn:l("requestReturn"),render:l("render"),mountAccount:l("mountAccount")};var pt=()=>`data-${c.prefix}-key`,yt=t=>t instanceof window.Element;function ht(t){let e=t.closest(`[${pt()}]`),n=e?.getAttribute(pt());return e&&n?{line:e,id:n}:null}function A(t,e){t.catch(n=>{a(n,e)})}function Ot(t,e){let n=ht(e);if(!n?.line.closest(r("cart-lines")))return;let{line:o,id:i}=n;if(e.closest(r("line-remove"))){t.preventDefault(),o.classList.add("is-busy"),A(s.removeLine(i),"cart line");return}let H=Dt(e);!H||!s.lines.some(xt=>xt.id===i)||(t.preventDefault(),A(s.changeQuantity(i,H),"cart line"))}function Dt(t){return t.closest(r("line-plus"))?1:t.closest(r("line-minus"))?-1:0}function Rt(t){let{target:e}=t;if(!yt(e))return;if(e.closest(r("cart-open"))){t.preventDefault(),s.toggle();return}if(e.closest(r("cart-close"))){t.preventDefault(),s.close();return}let n=e.closest(r("cart-clear"));if(n){t.preventDefault(),f(n,()=>s.clear().catch(i=>{a(i,"cart clear")}));return}let o=e.closest(r("checkout"));if(o){t.preventDefault(),f(o,()=>s.checkout());return}Ot(t,e)}function gt(t,e,n){t.classList.add("is-busy"),t.setAttribute("aria-busy","true"),A(e,n)}function Ht(t){let{target:e}=t;if(!yt(e))return;let n=ht(e);n&&e instanceof window.HTMLInputElement&&e.matches(r("line","quantity"))?gt(n.line,s.updateLine(n.id,parseInt(e.value,10)||0),"cart line"):n&&e instanceof window.HTMLSelectElement&&e.matches(r("line-plan"))?gt(n.line,s.updateLine(n.id,{sellingPlanId:e.value||null}),"cart line plan"):$t(e)&&e.matches(r("cart-note"))&&A(s.setNote(e.value),"cart note")}var $t=t=>t instanceof window.HTMLInputElement||t instanceof window.HTMLTextAreaElement||t instanceof window.HTMLSelectElement;function Vt(t){if(s.isOpen()){if(t.key==="Escape"){s.close();return}z(t)}}function Et(){document.addEventListener("click",Rt),document.addEventListener("change",Ht),document.addEventListener("keydown",Vt)}var M=t=>t instanceof window.Element;function Ft(t){let e=t.querySelector(r("discount-input"))??t.querySelector("input");return e instanceof window.HTMLInputElement?e:null}function vt(t,e,n){t.classList.toggle("is-invalid",n),n?e?.setAttribute("aria-invalid","true"):e?.removeAttribute("aria-invalid")}async function _t(t,e,n){try{await s.applyDiscount(n),vt(t,e,!1),y("discount-applied",{code:n},t),e&&(e.value="")}catch(o){vt(t,e,!0),o instanceof v&&o.code==="INVALID_DISCOUNT"?y("discount-invalid",{code:n},t):a(o,"discount")}}function Gt(t){let{target:e}=t,n=M(e)?e.closest(r("discount-form")):null;if(!n)return;t.preventDefault();let o=Ft(n),i=o?.value.trim();i&&f(n,()=>_t(n,o,i))}function Ut(t){let{target:e}=t;if(!M(e))return;let n=e.closest(r("discount-form"));n&&(n.classList.remove("is-invalid"),e.removeAttribute("aria-invalid"))}function Bt(t){let{target:e}=t,n=M(e)?e.closest(r("discount-remove")):null;if(!n)return;t.preventDefault();let o=n.closest(r("discount-code"))?.getAttribute(d("discount-code"));o&&s.removeDiscount(o).catch(i=>{a(i,"discount")})}function Pt(){document.addEventListener("submit",Gt,!0),document.addEventListener("input",Ut),document.addEventListener("click",Bt)}var I=t=>u("extras").then(e=>e.addGroup(t)),N=t=>{a(t,"extras")};function jt(t){let{target:e}=t,n=e instanceof window.Element?e.closest(r("group-add")):null;n&&(t.preventDefault(),f(n,()=>I(n)).catch(N))}function qt(t){!c.domain||!t.key?.startsWith(`${c.prefix}:`)||u("extras").then(e=>{e.onStorage(t)}).catch(N)}function Qt(t){if(!g(t,"variant-changed"))return;let{target:e}=t;e instanceof window.Element&&(!c.variantUrl&&!e.hasAttribute(d("variant-url"))||u("extras").then(n=>{n.writeVariantUrl(e,t.detail)}).catch(N))}function wt(){document.addEventListener("click",jt),window.addEventListener("storage",qt),document.addEventListener(`${c.prefix}:variant-changed`,Qt)}var O=null;function At(){O=document.body}async function zt(t){await t.ready();let e=it();if(!e){O!==document.body&&t.mount(document);return}try{await h(e.country,{language:e.language??null,locale:e.locale,remember:!1})}catch(n){a(n,"country")}t.mount(document)}function Kt(t){document.addEventListener("astro:page-load",()=>{zt(t).catch(e=>{a(e,"page mount")})}),document.addEventListener("astro:before-swap",()=>{O=null,t.unmount()})}function Wt(t){let{target:e}=t;!(e instanceof window.HTMLSelectElement)||!e.matches(r("country-select"))||e.value&&h(e.value).catch(n=>{a(n,"country")})}function Yt(){nt(),w.forEach(t=>{t.root.getAttribute(d("state"))==="error"&&t.load()})}function bt(t){c.astro&&Kt(t),document.addEventListener("change",Wt),window.addEventListener("online",Yt)}var Jt=50;function Xt(){let t=P("TETHER_CONFIG");return typeof t=="object"&&t!==null?Object.fromEntries(Object.entries(t)):{}}var m=null,D=null,Ct=null,Lt=!1;function Zt(t){let e=0;return p(t,lt()).forEach(n=>{if(C.has(n))return;C.add(n),e++;let o=dt(n);w.add(o),n.addEventListener(`${c.prefix}:list-rendered`,i=>{g(i,"list-rendered")&&b(i.detail.container)}),ot(o.load())}),e}function te(t){p(t,`${r("country-select")},${r("country-bind")}`).length&&u("markets").then(e=>e.renderCountrySelects(t)).catch(e=>{a(e,"markets")}),mt(t),p(t,r("search")).length&&u("search").then(e=>{e.mountSearch(t)}).catch(e=>{a(e,"search")})}function Tt(t){let e=Zt(t);return p(t,r("product")).forEach(n=>{et(n)&&e++}),te(t),e}function b(t=document){if(!E())return 0;t===document&&At(),T(),S(t.ownerDocument??document);let e=Tt(t);return k(),s.render(),L(`mounted ${e} scope(s)`,t),e}function ee(t){let e=t.filter(o=>o.isConnected&&!t.some(i=>i!==o&&i.contains(o)));if(!e.length||!E())return;T(),e.forEach(o=>{S(o)});let n=e.reduce((o,i)=>o+Tt(i),0);k(),s.render(),L(`mounted ${n} scope(s) in ${e.length} added element(s)`)}function kt(){s.close()}function ne(t){let e=t?.closest(r("product"));return e?tt.get(e)??null:null}function oe(){Lt||(Lt=!0,Et(),Pt(),wt(),bt({ready:()=>m??Promise.resolve(null),mount:b,unmount:kt}))}function re(){let t=[];Ct=t,B.forEach(e=>{document.addEventListener(`${c.prefix}:${e}`,n=>t.push(n))}),document.addEventListener("astro:page-load",e=>t.push(e)),u("analytics").then(e=>e.startAnalytics(t)).catch(e=>{a(e,"analytics")})}async function ie(t){let e=c.country,n=t?.buyerIdentity.countryCode;if(!t||!e||!n||n===e)return t;try{return await s.setBuyerIdentity({countryCode:e},{create:!1})}catch(o){return a(o,"cart country"),t}}function St(t={}){return m&&!Object.keys(t).length?m:(F({...Xt(),...t}),E()?(at(),oe(),c.observe&&se(),c.analytics&&!Ct&&re(),m=rt(t).then(()=>s.init()).then(ie).then(e=>(y("ready",{cart:e}),R)),m):(_("TETHER_CONFIG is missing domain or token. Tether is idle."),m=Promise.resolve(null),m))}function se(){if(D||typeof MutationObserver>"u")return;let t,e=new Set;D=new MutationObserver(n=>{n.forEach(o=>{o.addedNodes.forEach(i=>{i instanceof window.Element&&e.add(i)})}),clearTimeout(t),t=setTimeout(()=>{let o=[...e];e.clear(),ee(o)},Jt)}),D.observe(document.body,{childList:!0,subtree:!0})}var ae=t=>u("markets").then(e=>e.detectMarket(t??c.markets)),ce=t=>u("lists").then(e=>e.getProducts(t)),ue=(t,e)=>u("lists").then(n=>n.getRecommendations(t,e)),le=()=>u("markets").then(t=>t.getLocalization()),de=t=>u("diagnose").then(e=>e.diagnose({...t,version:x}));function me(t,e){let n=`${c.prefix}:${t}`,o=i=>{g(i,t)&&e(i.detail,i)};return document.addEventListener(n,o),()=>{document.removeEventListener(n,o)}}var fe={VERSION:x,init:St,mount:b,unmount:kt,get config(){return V},get ready(){return m??Promise.resolve(null)},query:U,withContext:G,cart:s,getProduct:Y,getProducts:ce,getRecommendations:ue,getScope:ne,addGroup:I,account:ft,primeProduct:W,normalizeProductKey:K,clearProductCache:J,formatMoney:q,imageUrl:j,plans:Q,TetherError:v,resolveProductKey:Z,setCountry:h,detectMarket:ae,getLocalization:le,diagnose:de,on:me},pe={__core:ut,__parts:{}},R=Object.assign(fe,pe),cn=R;function ge(){Reflect.set(window,"Tether",R);let t=P("TETHER_CONFIG");if(!t||$(t,"autoMount")===!1||P("TETHER_INTEGRATION"))return;let e=()=>{St().then(()=>b(document)).catch(n=>{a(n,"init")})};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e,{once:!0}):e()}typeof window<"u"&&typeof document<"u"&&ge();export{x as VERSION,I as addGroup,R as api,cn as default,ne as getScope,St as init,b as mount,h as setCountry,kt as unmount};
|
package/dist/esm/server.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as
|
|
2
|
-
${
|
|
1
|
+
import{b as G,f as Q,g as H}from"./chunks/chunk-DM5LEAWM.js";import{e as O,f as v,g as w,i as F,l as q}from"./chunks/chunk-BVO7KK2M.js";import{a as M,c as R,e as V,g as J,h as B,i as K,j}from"./chunks/chunk-FWMPL6PR.js";import{B as D,a as y,c as b,d as S,f as ot,g as k,i as U,u as L}from"./chunks/chunk-OATTAXPO.js";import{B as E,E as _,F as C,G as I,q as g,t as N,y as A}from"./chunks/chunk-OJAV2I3C.js";function z(t,e={}){if(!t)return null;let{variant:r,sellingPlan:a,defaultPurchase:c=g.defaultPurchase,lowStock:u=g.lowStock}=e,d=Q(t,{variant:r,sellingPlan:a,defaultPurchase:c}),n=H(t,{...d,quantity:1},u);if(!n)throw new y(`Product ${t.handle} has no variants`);let{selected:l,line:p}=n,i=(o,s)=>!G(t,l,o,s);return{variant:n.variant,selected:l,purchase:n.purchase.kind,plan:p.kind==="subscription"?n.plan:null,plans:O(t).map(o=>({id:o.id,name:o.name,price:w(n.variant,o.id),savings:F(n.variant,o.id).percentage,selected:p.kind==="subscription"&&o.id===p.planId,available:!!v(n.variant,o.id)})),savings:n.savings.percentage,price:n.price,compareAtPrice:n.compareAtPrice,available:n.variant.availableForSale,show:n.show,unavailable:Object.fromEntries(t.options.map(o=>[o.name,o.optionValues.map(s=>s.name).filter(s=>i(o.name,s))])),isUnavailable:i}}var it=500,at=100,st=100,lt="query TetherServerProductById($id:ID!){node(id:$id){... on Product{...TetherProduct}}}",ct="query TetherServerProduct($handle:String!){product(handle:$handle){...TetherProduct}}",ut=()=>`query TetherServerCollection($handle:String!,$first:Int!,$after:String,$sortKey:ProductCollectionSortKeys,$reverse:Boolean,$filters:[ProductFilter!]){collection(handle:$handle){${R()} products(first:$first,after:$after,sortKey:$sortKey,reverse:$reverse,filters:$filters){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}}`,dt="query TetherServerProducts($first:Int!,$after:String,$query:String,$sortKey:ProductSortKeys,$reverse:Boolean){products(first:$first,after:$after,query:$query,sortKey:$sortKey,reverse:$reverse){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}",ft=()=>`query TetherServerCollections($first:Int!,$after:String){collections(first:$first,after:$after){nodes{${R()}}pageInfo{hasNextPage endCursor}}}`,pt=t=>`query TetherServerRecs(${t?"$id: ID!":"$handle: String!"},$intent:ProductRecommendationIntent){productRecommendations(${t?"productId: $id":"productHandle: $handle"},intent:$intent){...TetherProduct}}`,mt=S({product:b(V)}),gt=S({node:b(J)}),yt=S({collections:{nodes:[{handle:"string"}],pageInfo:{hasNextPage:"boolean"}}});async function Pt(t){let e=[],r=null;for(let a=0;a<st;a++){let c=await k(t,ft(),{first:at,after:r},yt);if(e.push(...c.collections.nodes),!c.collections.pageInfo.hasNextPage)break;r=c.collections.pageInfo.endCursor}return e}function Y(t,e){let r=(i,o,s)=>k(t,f=>`${i}
|
|
2
|
+
${M(t,f)}`,o,s);async function a(i){let o=I(i);if(!o)return null;if(o.startsWith("gid://")){let{node:f}=await r(lt,{id:o},gt);return f?.id?f:null}return(await r(ct,{handle:o},mt)).product}async function c(i,{first:o=e,after:s=null,sortKey:f,reverse:m=!1,filters:$}){let h=await r(ut(),{handle:i,first:o,after:s,sortKey:f||void 0,reverse:m,filters:$??void 0},B);if(!h.collection)return{collection:null,products:[],pageInfo:{hasNextPage:!1,endCursor:null}};let{products:P,...rt}=h.collection;return{collection:rt,products:P.nodes,pageInfo:P.pageInfo}}async function u(i={}){let{collection:o,query:s,first:f=e,after:m=null,sortKey:$,reverse:h=!1}=i;if(o)return c(o,i);let P=await r(dt,{first:f,after:m,query:s||void 0,sortKey:$||void 0,reverse:h},K);return{collection:null,products:P.products.nodes,pageInfo:P.products.pageInfo}}async function d(i={}){let o=[],s=null;for(let f=0;f<it;f++){let m=await u({...i,first:e,after:s});if(o.push(...m.products),!m.pageInfo.hasNextPage)break;s=m.pageInfo.endCursor}return o}async function n(i,o={}){let s=await u({...o,collection:i});return s.collection?{...s.collection,products:s.products,pageInfo:s.pageInfo}:null}async function l(i,o="RELATED"){let s=I(typeof i=="object"?i?.id:i);if(!s)throw new y("No product for recommendations",{code:"NOT_FOUND"});let f=s.startsWith("gid://");return(await r(pt(f),f?{id:s,intent:o}:{handle:s,intent:o},j)).productRecommendations??[]}return{getProduct:a,getProducts:u,allProducts:d,getCollection:n,allCollections:()=>Pt(t),getRecommendations:l}}var X={size:"https://schema.org/size",color:"https://schema.org/color",colour:"https://schema.org/color",material:"https://schema.org/material"},T=t=>JSON.stringify(t).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029");function W(t){return JSON.parse(JSON.stringify(t))}var Z=t=>t.split("/").pop()??t;function ht(t){return t.availableForSale?t.currentlyNotInStock?"https://schema.org/BackOrder":"https://schema.org/InStock":"https://schema.org/OutOfStock"}function St(t,e){if(!t.requiresSellingPlan)return e.price;let r=O(t).find(a=>v(e,a.id));return(r&&w(e,r.id))??e.price}function tt(t,e,r){let a=St(t,e),c=r?.includes("?")?"&":"?";return{"@type":"Offer",price:a.amount,priceCurrency:a.currencyCode,availability:ht(e),url:r?`${r}${c}variant=${Z(e.id)}`:void 0}}function Ct(t,e,r,a){let c=e.selectedOptions.flatMap(u=>{let d=X[u.name.toLowerCase()];return d?[[d.split("/").pop()??d,u.value]]:[]});return{"@type":"Product",name:`${t.title} - ${e.title}`,sku:e.sku||void 0,image:e.image?.url||a[0],...Object.fromEntries(c),offers:tt(t,e,r)}}function It(t,{url:e},r){if(e)return e;let a=C(r.productPath,t.handle,t.id);if(!(!r.siteUrl||!a))return new URL(a,r.siteUrl).toString()}function x(t,e,r){if(!t)return null;let a=It(t,e,r),c=t.images.nodes.map(i=>i.url).filter(Boolean),u=e.brand||t.vendor,d=u?{"@type":"Brand",name:u}:void 0,n=t.description.trim()||void 0,l=t.variants.nodes;if(l.length<=1){let[i]=l;return W({"@context":"https://schema.org","@type":"Product",name:t.title,description:n,url:a,image:c,sku:i?.sku||void 0,brand:d,offers:i?tt(t,i,a):void 0})}let p=t.options.map(i=>X[i.name.toLowerCase()]).filter(Boolean);return W({"@context":"https://schema.org","@type":"ProductGroup",name:t.title,description:n,url:a,productGroupID:Z(t.id),image:c,brand:d,variesBy:[...new Set(p)],hasVariant:l.map(i=>Ct(t,i,a,c))})}var et=25,Ot=250,vt=2,wt=1;function $t(t,{productPath:e=g.productPath,id:r}={}){return C(e,t,r)}function nt(t,e){for(let r of e){let a=t[r];if(typeof a=="string"&&a)return a}return""}function bt(t){let e={};for(let[u,d]of Object.entries(t))u in g&&(e[u]=d);let r=typeof t.domain=="string"&&t.domain?t.domain:"",a=typeof t.token=="string"&&t.token?t.token:"",c={...N({...e,domain:r||nt(t,E.domain),token:a||nt(t,E.token)}),pageSize:kt(t.pageSize)};return t.fetch&&(c.fetch=t.fetch),t.siteUrl!==void 0&&(c.siteUrl=t.siteUrl),c}function kt(t){return typeof t=="number"&&Number.isInteger(t)&&t>=1&&t<=Ot?t:(t!==void 0&&A(`invalid pageSize ${JSON.stringify(t)}: using ${String(et)}`),et)}function Et(t,e){return{...t,description:"",descriptionHtml:"",images:{nodes:t.images.nodes.slice(0,Math.max(1,e))},variants:{nodes:t.variants.nodes.map(r=>({...r,image:null}))}}}function zt(t={}){let e=bt(t);if(!e.domain||!e.token)throw new y("createStorefront needs domain and token: pass them, or import.meta.env with PUBLIC_SHOPIFY_DOMAIN and PUBLIC_SHOPIFY_STOREFRONT_TOKEN",{code:"NOT_CONFIGURED"});let r=Y(e,e.pageSize),a={productPath:e.productPath,siteUrl:e.siteUrl};function c(n,{card:l=!1,images:p=vt}={}){let i=(Array.isArray(n)?n:[n]).filter(s=>s!=null),o={v:wt,at:new Date().toISOString(),country:e.country||null,language:e.language||null,products:l?i.map(s=>Et(s,p)):i};return`<script type="application/json" data-tether-hydrate>${T(o)}<\/script>`}function u(n,l={}){return n?`<script type="application/ld+json">${T(x(n,l,a))}<\/script>`:""}function d(n,l={}){return z(n,{defaultPurchase:e.defaultPurchase,lowStock:e.lowStock,...l})}return{config:e,query:(n,l,p)=>U(e,n,l,p),...r,hydrate:c,formatMoney:(n,l=e.locale)=>_(n,l),formatPercent:(n,l=e.locale)=>D(n,l),imageUrl:L,jsonLd:u,jsonLdData:(n,l={})=>x(n,l,a),initialState:d,productUrl:(n,l={})=>$t(n,{productPath:e.productPath,...l}),plans:q}}export{y as TetherError,zt as createStorefront,_ as formatMoney,D as formatPercent,L as imageUrl,z as initialState,q as plans,I as productKey,$t as productUrl,ot as withContext};
|
package/dist/tether.js
CHANGED
|
@@ -340,12 +340,21 @@
|
|
|
340
340
|
dropped(name, value);
|
|
341
341
|
}
|
|
342
342
|
}
|
|
343
|
-
var DELAY_OPTIONS = /* @__PURE__ */ new Set(["requestTimeout", "searchDelay"]);
|
|
344
343
|
var MAX_TIMER_MS = 2147483647;
|
|
344
|
+
var MAX_RETRIES = 10;
|
|
345
|
+
var COUNT_MAXIMUMS = {
|
|
346
|
+
requestTimeout: MAX_TIMER_MS,
|
|
347
|
+
searchDelay: MAX_TIMER_MS,
|
|
348
|
+
retries: MAX_RETRIES
|
|
349
|
+
};
|
|
345
350
|
function countOption(name, value) {
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
351
|
+
if (typeof value !== "number" || !Number.isInteger(value) || value < 0) {
|
|
352
|
+
return invalidOption(name, value, DEFAULTS[name]);
|
|
353
|
+
}
|
|
354
|
+
const maximum = COUNT_MAXIMUMS[name];
|
|
355
|
+
if (maximum === void 0 || value <= maximum) return value;
|
|
356
|
+
warn(`${name} ${String(value)} is more than its maximum: using ${String(maximum)}`);
|
|
357
|
+
return maximum;
|
|
349
358
|
}
|
|
350
359
|
function switchOption(name, value) {
|
|
351
360
|
return typeof value === "boolean" ? value : invalidOption(name, value, DEFAULTS[name]);
|
|
@@ -491,6 +500,7 @@
|
|
|
491
500
|
}
|
|
492
501
|
var RETRY_BACKOFF_MS = 300;
|
|
493
502
|
var THROTTLE_BACKOFF_MS = 500;
|
|
503
|
+
var MAX_BACKOFF_MS = 3e4;
|
|
494
504
|
var SECURITY_REJECTION = 430;
|
|
495
505
|
var MS_PER_SECOND = 1e3;
|
|
496
506
|
var INVENTORY_FIELD = "quantityAvailable";
|
|
@@ -620,7 +630,7 @@
|
|
|
620
630
|
storesWithoutInventory.add(store);
|
|
621
631
|
break;
|
|
622
632
|
case "retry":
|
|
623
|
-
await sleep(outcome.backoffMs * 2 ** retries);
|
|
633
|
+
await sleep(Math.min(outcome.backoffMs * 2 ** retries, MAX_BACKOFF_MS));
|
|
624
634
|
retries += 1;
|
|
625
635
|
log("retry", retries);
|
|
626
636
|
break;
|
|
@@ -827,6 +837,7 @@
|
|
|
827
837
|
if (cleaned === "") element.removeAttribute("style");
|
|
828
838
|
else element.setAttribute("style", cleaned);
|
|
829
839
|
}
|
|
840
|
+
var SAME_TAB_TARGETS = /* @__PURE__ */ new Set(["", "_self", "_parent", "_top"]);
|
|
830
841
|
function hardenEmbedsAndLinks(element) {
|
|
831
842
|
if (element.localName === "iframe") {
|
|
832
843
|
const allow = allowedFeatures(element.getAttribute("allow") ?? "");
|
|
@@ -836,7 +847,9 @@
|
|
|
836
847
|
element.setAttribute("referrerpolicy", IFRAME_REFERRER_POLICY);
|
|
837
848
|
return;
|
|
838
849
|
}
|
|
839
|
-
if (element.localName !== "a"
|
|
850
|
+
if (element.localName !== "a") return;
|
|
851
|
+
const target = element.getAttribute("target");
|
|
852
|
+
if (target === null || SAME_TAB_TARGETS.has(target.toLowerCase())) return;
|
|
840
853
|
const rel = new Set((element.getAttribute("rel") ?? "").split(/\s+/).filter(Boolean));
|
|
841
854
|
rel.add("noopener");
|
|
842
855
|
rel.add("noreferrer");
|
|
@@ -3435,7 +3448,7 @@
|
|
|
3435
3448
|
}
|
|
3436
3449
|
|
|
3437
3450
|
// src/version.ts
|
|
3438
|
-
var VERSION = "0.9.
|
|
3451
|
+
var VERSION = "0.9.2";
|
|
3439
3452
|
|
|
3440
3453
|
// src/lazy-iife.ts
|
|
3441
3454
|
var coreModules = {
|