@occluze/tether 0.6.6 → 0.6.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/esm/astro.js +2 -2
- package/dist/esm/chunks/account-C3NP6HFB.js +1 -0
- package/dist/esm/chunks/account-pages-WLK374FO.js +1 -0
- package/dist/esm/chunks/analytics-G3SAWMNL.js +1 -0
- package/dist/esm/chunks/chunk-27PJJZGC.js +1 -0
- package/dist/esm/chunks/chunk-2FSXS55U.js +1 -0
- package/dist/esm/chunks/chunk-FCSWQDVV.js +1 -0
- package/dist/esm/chunks/chunk-FOMSMIAM.js +1 -0
- package/dist/esm/chunks/chunk-GZJTCLLW.js +1 -0
- package/dist/esm/chunks/chunk-HEQILZVR.js +1 -0
- package/dist/esm/chunks/chunk-JOOEXYF3.js +4 -0
- package/dist/esm/chunks/chunk-MPTQYLSM.js +1 -0
- package/dist/esm/chunks/chunk-NEHZ37TU.js +3 -0
- package/dist/esm/chunks/chunk-V74KGEJF.js +1 -0
- package/dist/esm/chunks/chunk-VT4CDUJJ.js +1 -0
- package/dist/esm/chunks/chunk-YJLWX2HK.js +1 -0
- package/dist/esm/chunks/diagnose-6VVGZNTY.js +14 -0
- package/dist/esm/chunks/extras-GJVRDFM3.js +1 -0
- package/dist/esm/chunks/markets-ui-UNB4PTA7.js +1 -0
- package/dist/esm/chunks/search-OU75RNQL.js +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/server.js +2 -1
- package/dist/presets/barba.esm.js +56 -36
- package/dist/tether.account-pages.js +776 -432
- package/dist/tether.account-pages.min.js +1 -1
- package/dist/tether.account.js +655 -321
- package/dist/tether.account.min.js +1 -1
- package/dist/tether.analytics.js +318 -191
- package/dist/tether.analytics.min.js +1 -1
- package/dist/tether.diagnose.js +334 -243
- package/dist/tether.diagnose.min.js +2 -2
- package/dist/tether.extras.js +78 -33
- package/dist/tether.extras.min.js +1 -1
- package/dist/tether.js +3171 -1998
- package/dist/tether.markets.js +231 -126
- package/dist/tether.markets.min.js +1 -1
- package/dist/tether.min.js +0 -0
- package/dist/tether.min.js.map +4 -4
- package/dist/tether.search.js +221 -126
- package/dist/tether.search.min.js +1 -1
- package/package.json +23 -4
- package/src/account/addresses-view.js +92 -0
- package/src/account/browser-session.js +359 -0
- package/src/account/markup.js +48 -0
- package/src/account/operations.js +180 -0
- package/src/account/order-lines.js +96 -0
- package/src/account/order-list.js +91 -0
- package/src/account/order-page.js +192 -0
- package/src/account/page-events.js +288 -0
- package/src/account/server-client.js +172 -0
- package/src/account/shared.js +111 -0
- package/src/account/shopify-auth.js +150 -0
- package/src/account/subscriptions-view.js +158 -0
- package/src/account-api.js +118 -0
- package/src/account-links.js +35 -0
- package/src/account-pages.js +68 -284
- package/src/account.js +281 -317
- package/src/amounts.js +36 -0
- package/src/analytics-shopify.js +241 -0
- package/src/analytics.js +304 -184
- package/src/api-version.js +75 -25
- package/src/astro.js +233 -68
- package/src/cart/checkout.js +97 -0
- package/src/cart/drawer.js +138 -0
- package/src/cart/mutations.js +234 -0
- package/src/cart/render.js +294 -0
- package/src/cart/store.js +326 -0
- package/src/cart.js +322 -481
- package/src/client.js +214 -78
- package/src/collection.js +126 -57
- package/src/config.js +323 -59
- package/src/controls/cart-controls.js +155 -0
- package/src/controls/discount.js +96 -0
- package/src/controls/extras.js +63 -0
- package/src/controls/navigation.js +83 -0
- package/src/diagnose-markup.js +333 -0
- package/src/diagnose.js +251 -202
- package/src/dom.js +219 -220
- package/src/extras.js +119 -37
- package/src/fragments.js +115 -22
- package/src/images.js +104 -0
- package/src/index.js +245 -285
- package/src/initial.js +78 -66
- package/src/lazy-iife.js +92 -22
- package/src/lazy.js +25 -4
- package/src/loader.js +263 -124
- package/src/market-codes.js +35 -0
- package/src/markets-ui.js +169 -55
- package/src/markets.js +286 -85
- package/src/markup.js +64 -0
- package/src/mounting.js +214 -91
- package/src/page-market.js +116 -0
- package/src/parts/account-pages.js +4 -1
- package/src/parts/account.js +4 -1
- package/src/parts/analytics.js +4 -1
- package/src/parts/diagnose.js +4 -1
- package/src/parts/extras.js +4 -1
- package/src/parts/markets.js +4 -1
- package/src/parts/search.js +4 -1
- package/src/presets/barba.js +120 -30
- package/src/product-events.js +130 -0
- package/src/product-render.js +257 -0
- package/src/product-state.js +318 -0
- package/src/product.js +233 -459
- package/src/repeaters.js +173 -0
- package/src/search.js +277 -107
- package/src/selling-plans.js +107 -47
- package/src/server.js +168 -205
- package/src/shopify-values.js +89 -0
- package/src/status.js +99 -39
- package/src/store-html.js +0 -0
- package/src/storefront/catalog.js +199 -0
- package/src/storefront/json-ld.js +167 -0
- package/src/variant-render.js +165 -0
- package/types/astro.d.ts +13 -2
- package/types/index.d.ts +178 -27
- package/types/server.d.ts +89 -17
- package/dist/esm/chunks/account-QUBHQG3C.js +0 -1
- package/dist/esm/chunks/account-pages-VWDHF6WA.js +0 -1
- package/dist/esm/chunks/analytics-SLATWPLC.js +0 -1
- package/dist/esm/chunks/chunk-64TUD3QR.js +0 -1
- package/dist/esm/chunks/chunk-AJLPU2JC.js +0 -4
- package/dist/esm/chunks/chunk-FIOZPPC5.js +0 -1
- package/dist/esm/chunks/chunk-K2YEQAIH.js +0 -1
- package/dist/esm/chunks/chunk-L2TRRKYV.js +0 -1
- package/dist/esm/chunks/chunk-RREHGH4A.js +0 -1
- package/dist/esm/chunks/chunk-VC46IEJQ.js +0 -1
- package/dist/esm/chunks/chunk-VCPI7MJ2.js +0 -1
- package/dist/esm/chunks/chunk-VPVJPNB4.js +0 -1
- package/dist/esm/chunks/chunk-ZIUIWEON.js +0 -1
- package/dist/esm/chunks/diagnose-VXQBSD3A.js +0 -14
- package/dist/esm/chunks/extras-R4X34VQL.js +0 -1
- package/dist/esm/chunks/markets-ui-F3R5T5EL.js +0 -1
- package/dist/esm/chunks/search-NILMGYXG.js +0 -1
package/types/server.d.ts
CHANGED
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
import type { ShopifyProduct, ShopifyVariant, Money, TetherError, SellingPlanHelpers, TetherConfig } from './index.js';
|
|
2
2
|
export type { ShopifyProduct, ShopifyVariant, ShopifyCart, ShopifyCartLine, Money } from './index.js';
|
|
3
3
|
|
|
4
|
-
export interface StorefrontOptions extends Partial<
|
|
5
|
-
|
|
4
|
+
export interface StorefrontOptions extends Partial<
|
|
5
|
+
Pick<
|
|
6
|
+
TetherConfig,
|
|
7
|
+
| 'apiVersion'
|
|
8
|
+
| 'country'
|
|
9
|
+
| 'language'
|
|
10
|
+
| 'locale'
|
|
11
|
+
| 'productPath'
|
|
12
|
+
| 'maxAge'
|
|
13
|
+
| 'lowStock'
|
|
14
|
+
| 'defaultPurchase'
|
|
15
|
+
| 'metafields'
|
|
16
|
+
| 'imagesFirst'
|
|
17
|
+
| 'variantsFirst'
|
|
18
|
+
| 'sellingPlanGroupsFirst'
|
|
19
|
+
| 'sellingPlansFirst'
|
|
20
|
+
| 'retries'
|
|
21
|
+
>
|
|
22
|
+
> {
|
|
6
23
|
/** your-store.myshopify.com (or pass import.meta.env with PUBLIC_SHOPIFY_DOMAIN). */
|
|
7
24
|
domain?: string;
|
|
8
25
|
/** Public Storefront API token (or PUBLIC_SHOPIFY_STOREFRONT_TOKEN in import.meta.env). */
|
|
@@ -16,11 +33,21 @@ export interface StorefrontOptions extends Partial<Pick<TetherConfig,
|
|
|
16
33
|
PUBLIC_SHOPIFY_DOMAIN?: string;
|
|
17
34
|
PUBLIC_SHOPIFY_STOREFRONT_TOKEN?: string;
|
|
18
35
|
/** Astro's import.meta.env carries these too; ignored. */
|
|
19
|
-
MODE?: string;
|
|
36
|
+
MODE?: string;
|
|
37
|
+
BASE_URL?: string;
|
|
38
|
+
PROD?: boolean;
|
|
39
|
+
DEV?: boolean;
|
|
40
|
+
SSR?: boolean;
|
|
41
|
+
SITE?: string;
|
|
42
|
+
ASSETS_PREFIX?: string;
|
|
20
43
|
}
|
|
21
44
|
|
|
22
45
|
export interface ShopifyCollection {
|
|
23
|
-
id: string;
|
|
46
|
+
id: string;
|
|
47
|
+
handle: string;
|
|
48
|
+
title: string;
|
|
49
|
+
description: string;
|
|
50
|
+
descriptionHtml: string;
|
|
24
51
|
image?: { url: string; altText?: string | null } | null;
|
|
25
52
|
seo?: { title?: string | null; description?: string | null };
|
|
26
53
|
}
|
|
@@ -41,24 +68,40 @@ export interface Storefront {
|
|
|
41
68
|
query<T = any>(query: string, variables?: Record<string, unknown>, opts?: { context?: boolean }): Promise<T>;
|
|
42
69
|
/** By handle, numeric id, gid or product URL. null when it doesn't exist. */
|
|
43
70
|
getProduct(handleOrId: string | number | null | undefined): Promise<ShopifyProduct | null>;
|
|
44
|
-
getProducts(opts?: ProductQuery): Promise<{
|
|
71
|
+
getProducts(opts?: ProductQuery): Promise<{
|
|
72
|
+
collection: ShopifyCollection | null;
|
|
73
|
+
products: ShopifyProduct[];
|
|
74
|
+
pageInfo: { hasNextPage: boolean; endCursor: string | null };
|
|
75
|
+
}>;
|
|
45
76
|
/** Every product (of a collection or a search query), page by page. For getStaticPaths(). */
|
|
46
77
|
allProducts(opts?: Omit<ProductQuery, 'first' | 'after'>): Promise<ShopifyProduct[]>;
|
|
47
|
-
getCollection(
|
|
78
|
+
getCollection(
|
|
79
|
+
handle: string,
|
|
80
|
+
opts?: Omit<ProductQuery, 'collection'>,
|
|
81
|
+
): Promise<
|
|
82
|
+
| (ShopifyCollection & { products: ShopifyProduct[]; pageInfo: { hasNextPage: boolean; endCursor: string | null } })
|
|
83
|
+
| null
|
|
84
|
+
>;
|
|
48
85
|
allCollections(): Promise<ShopifyCollection[]>;
|
|
49
86
|
/** By handle, id or product (runs in parallel with getProduct when you pass the handle). */
|
|
50
|
-
getRecommendations(
|
|
87
|
+
getRecommendations(
|
|
88
|
+
product: string | number | Pick<ShopifyProduct, 'id'>,
|
|
89
|
+
intent?: 'RELATED' | 'COMPLEMENTARY',
|
|
90
|
+
): Promise<ShopifyProduct[]>;
|
|
51
91
|
/**
|
|
52
92
|
* A <script type="application/json" data-tether-hydrate> tag: the browser script renders these
|
|
53
93
|
* products without its own request, then refreshes prices and stock once in the background.
|
|
54
94
|
* Astro: <Fragment set:html={shop.hydrate(product)} />
|
|
55
95
|
*/
|
|
56
|
-
hydrate(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
96
|
+
hydrate(
|
|
97
|
+
products: ShopifyProduct | ShopifyProduct[],
|
|
98
|
+
opts?: {
|
|
99
|
+
/** For lists: without descriptions and variant images, about 40% smaller. */
|
|
100
|
+
card?: boolean;
|
|
101
|
+
/** Images a card keeps (default 2: the main one and a hover image). */
|
|
102
|
+
images?: number;
|
|
103
|
+
},
|
|
104
|
+
): string;
|
|
62
105
|
formatMoney(money: Money | null | undefined, locale?: string): string;
|
|
63
106
|
/** 30 -> '30%' (nl, en) / '30 %' (de, fr), the way Tether shows savings. '' for 0. */
|
|
64
107
|
formatPercent(n: number, locale?: string): string;
|
|
@@ -91,15 +134,44 @@ export interface InitialState {
|
|
|
91
134
|
compareAtPrice: Money | null;
|
|
92
135
|
available: boolean;
|
|
93
136
|
/** tether-show conditions: hidden={!state.show['out-of-stock']}. */
|
|
94
|
-
show: Record<
|
|
137
|
+
show: Record<
|
|
138
|
+
| 'in-stock'
|
|
139
|
+
| 'out-of-stock'
|
|
140
|
+
| 'backorder'
|
|
141
|
+
| 'on-sale'
|
|
142
|
+
| 'not-on-sale'
|
|
143
|
+
| 'has-variants'
|
|
144
|
+
| 'single-variant'
|
|
145
|
+
| 'low-stock'
|
|
146
|
+
| 'subscription-available'
|
|
147
|
+
| 'subscription-unavailable'
|
|
148
|
+
| 'subscription-only'
|
|
149
|
+
| 'one-time-available'
|
|
150
|
+
| 'subscription-selected'
|
|
151
|
+
| 'one-time-selected'
|
|
152
|
+
| 'plenty-in-stock'
|
|
153
|
+
| 'has-savings',
|
|
154
|
+
boolean
|
|
155
|
+
>;
|
|
95
156
|
/** true for option values without an available variant: class is-unavailable. */
|
|
96
157
|
isUnavailable(optionName: string, value: string): boolean;
|
|
97
158
|
}
|
|
98
|
-
export interface InitialOptions {
|
|
159
|
+
export interface InitialOptions {
|
|
160
|
+
variant?: string | null;
|
|
161
|
+
sellingPlan?: string | null;
|
|
162
|
+
defaultPurchase?: 'one-time' | 'subscription';
|
|
163
|
+
}
|
|
99
164
|
export declare function initialState(product: ShopifyProduct, opts?: InitialOptions): InitialState;
|
|
100
|
-
export declare function initialState(
|
|
165
|
+
export declare function initialState(
|
|
166
|
+
product: ShopifyProduct | null | undefined,
|
|
167
|
+
opts?: InitialOptions,
|
|
168
|
+
): InitialState | null;
|
|
101
169
|
|
|
102
|
-
export interface ImageSize {
|
|
170
|
+
export interface ImageSize {
|
|
171
|
+
width?: number;
|
|
172
|
+
height?: number;
|
|
173
|
+
crop?: 'center' | 'top' | 'bottom' | 'left' | 'right';
|
|
174
|
+
}
|
|
103
175
|
export declare function imageUrl(url: string | null | undefined, size?: ImageSize): string;
|
|
104
176
|
export declare function createStorefront(options?: StorefrontOptions): Storefront;
|
|
105
177
|
export declare function formatMoney(money: Money | null | undefined, locale?: string): string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as Q}from"./chunk-VPVJPNB4.js";import{b as h}from"./chunk-L2TRRKYV.js";import"./chunk-FIOZPPC5.js";import"./chunk-AJLPU2JC.js";import{A as R,B as $,D as x,G as q,b as a,e as X,g as A,h as p,o as f,p as k,s as y,u as T,w as Y}from"./chunk-K2YEQAIH.js";import"./chunk-VC46IEJQ.js";var N=()=>`${a.prefix}:account:${a.domain}`,J=()=>`${a.prefix}:account-login:${a.domain}`,O=()=>a.account?.remember?window.localStorage:window.sessionStorage,et=t=>btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),j=()=>et(crypto.getRandomValues(new Uint8Array(32))),ut=async t=>et(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(t))),E=t=>(a.account?.navigate||(e=>window.location.assign(e)))(t),M=(t,e)=>{try{return JSON.parse(t.getItem(e)||"null")}catch{return null}},D=(t,e,n)=>{try{n?t.setItem(e,JSON.stringify(n)):t.removeItem(e)}catch{}},v=null,c=null,B=null,I=null,w=()=>a.account?.server?new URL(String(a.account.server),window.location.href).href.replace(/\/$/,""):"",z=()=>`${a.prefix}:account-hint:${a.domain}`,b=null;async function U(t,{method:e="GET",body:n}={}){let o=await fetch(`${w()}${t}`,{method:e,credentials:"include",headers:e==="POST"?{"Content-Type":"application/json","X-Tether-Account":"1"}:{},body:n?JSON.stringify(n):void 0}),r=await o.json().catch(()=>({}));if(!o.ok&&o.status!==401)throw new p(`Customer accounts: ${r.error||o.status}`,{status:o.status,userErrors:r.userErrors});return r}async function H(){b||(b=await U("/me"));try{b.loggedIn?window.localStorage.setItem(z(),"1"):window.localStorage.removeItem(z())}catch{}return b}async function P(){if(v)return v;let t=a.account?.shopDomain||a.domain,e=r=>fetch(`https://${t}/.well-known/${r}`).then(s=>{if(!s.ok)throw new p(`Customer accounts: ${r} answered ${s.status}`,{status:s.status});return s.json()}),[n,o]=await Promise.all([e("openid-configuration"),e("customer-account-api")]);return v={...n,graphql:o.graphql_api},v}var lt=()=>a.account?.callbackUrl||`${window.location.origin}${window.location.pathname}`;function nt(){return w()?!!b?.loggedIn:!!(c?.refresh||c?.access&&c.expiresAt>Date.now())}async function dt({returnTo:t=window.location.href,locale:e}={}){if(w()){let d=new URL(`${w()}/login`);d.searchParams.set("returnTo",t);let g=e||a.account.locale||(a.locale||"").split("-")[0];g&&d.searchParams.set("locale",g),a.country&&d.searchParams.set("country",String(a.country).toUpperCase()),E(d.toString());return}if(!a.account?.clientId)throw new p("Customer accounts: set account.clientId",{code:"NOT_CONFIGURED"});let n=await P(),o=j(),r=j(),s=j(),i=lt();D(window.sessionStorage,J(),{state:o,nonce:r,verifier:s,redirect:i,returnTo:t,at:Date.now()});let u=new URL(n.authorization_endpoint),m={client_id:a.account.clientId,scope:"openid email customer-account-api:full",response_type:"code",redirect_uri:i,state:o,nonce:r,code_challenge:await ut(s),code_challenge_method:"S256"},l=e||a.account.locale||(a.locale||"").split("-")[0];l&&(m.locale=l),a.country&&(m.region_country=String(a.country).toUpperCase()),Object.entries(m).forEach(([d,g])=>u.searchParams.set(d,g)),E(u.toString())}async function ot(t){let e=await P(),n=await fetch(a.account.tokenUrl||e.token_endpoint,{method:"POST",body:new URLSearchParams(t)}),o=await n.json().catch(()=>({}));if(!n.ok||!o.access_token)throw new p(`Customer accounts: token ${n.status} ${o.error||""}`.trim(),{status:n.status,code:n.status===400||n.status===401?"SESSION_ENDED":"TOKEN_FAILED"});return o}function ft(t){try{return JSON.parse(atob(t.split(".")[1].replace(/-/g,"+").replace(/_/g,"/")))}catch{return null}}function rt(t,e=c){c={access:t.access_token,expiresAt:Date.now()+Math.max(0,(Number(t.expires_in)||3600)-120)*1e3,refresh:t.refresh_token||e?.refresh,idToken:t.id_token||e?.idToken},D(O(),N(),c)}async function ht(){let t=new URLSearchParams(window.location.search),e=M(window.sessionStorage,J());if(!e||!t.has("code")&&!t.has("error")||t.get("state")!==e.state)return!1;D(window.sessionStorage,J(),null);let n=new URL(window.location.href);if(["code","state","iss","error","error_description"].forEach(m=>n.searchParams.delete(m)),window.history.replaceState(window.history.state,"",n),t.has("error"))return T("account-error",{error:t.get("error")}),!1;if(Date.now()-e.at>10*6e4)throw new p("Customer accounts: the login took too long, please try again");let o=await ot({grant_type:"authorization_code",client_id:a.account.clientId,redirect_uri:e.redirect,code:t.get("code"),code_verifier:e.verifier}),r=await P(),s=ft(o.id_token||""),i=[].concat(s?.aud||[]);if(!s||s.nonce!==e.nonce||s.iss!==r.issuer||!i.includes(a.account.clientId)||s.exp*1e3<Date.now())throw new p("Customer accounts: the login answer did not check out (nonce/issuer/audience)");rt(o,null),await st(),T("account-login",{});let u=e.returnTo&&new URL(e.returnTo,window.location.href);return u&&u.origin===window.location.origin&&u.href!==n.href&&E(u.href),!0}async function C(){return w()||(c||(c=M(O(),N())),!c)?null:c.access&&c.expiresAt>Date.now()?c.access:c.refresh?(B||(B=(async()=>{try{rt(await ot({grant_type:"refresh_token",client_id:a.account.clientId,refresh_token:c.refresh})),await st()}catch(t){if(t.code==="SESSION_ENDED")F();else throw t}finally{B=null}})()),await B,c?.access||null):(F(),null)}function F(){c=null,I=null,D(O(),N(),null),h.customerAccessToken=null}async function st(){h.customerAccessToken=c?.access||null,h.id()&&c?.access&&await h.setBuyerIdentity({customerAccessToken:c.access},{create:!1}).catch(t=>A(t,"account cart"))}async function V(t,e={}){if(w())throw new p("Customer accounts in server mode only answer customer() and orders()",{code:"NOT_ALLOWED"});let n=await C();if(!n)throw new p("Not logged in",{code:"NOT_LOGGED_IN"});let o=await P(),r=u=>fetch(o.graphql,{method:"POST",headers:{"Content-Type":"application/json",Authorization:u},body:JSON.stringify({query:t,variables:e})}),s=await r(n);s.status===401&&c?.refresh&&(c.expiresAt=0,s=await r(await C()));let i=await s.json().catch(()=>({}));if(!s.ok||i.errors?.length)throw new p(i.errors?.map(u=>u.message).join(" | ")||`Customer accounts: ${s.status}`,{status:s.status});return i.data}async function at(){if(w()){let e=await H();return e.loggedIn?{...e.customer,emailAddress:{emailAddress:e.customer.email},defaultAddress:{formatted:e.customer.address}}:null}return I||(I=(await V("query TetherCustomer{customer{id firstName lastName displayName emailAddress{emailAddress}defaultAddress{formatted}}}")).customer,I)}async function mt({first:t=10}={}){return w()?(await U(`/orders?first=${t}`)).orders||[]:(await V("query TetherOrders($first:Int!){customer{orders(first:$first,sortKey:PROCESSED_AT,reverse:true){nodes{id name processedAt financialStatus fulfillmentStatus statusPageUrl totalPrice{amount currencyCode}lineItems(first:20){nodes{title variantTitle quantity image{url altText}}}}}}}",{first:t})).customer?.orders?.nodes||[]}async function wt({returnTo:t=a.account?.logoutUrl||`${window.location.origin}/`}={}){if(w()){let r=await U("/logout",{method:"POST",body:{returnTo:t,cartId:h.id()}});b={loggedIn:!1};try{window.localStorage.removeItem(z())}catch{}T("account-logout",{}),r.logoutUrl?E(r.logoutUrl):K(document);return}let e=c?.idToken||M(O(),N())?.idToken;if(h.id()&&await h.setBuyerIdentity({customerAccessToken:null},{create:!1}).catch(()=>{}),F(),T("account-logout",{}),!e){K(document);return}let n=await P(),o=new URL(n.end_session_endpoint);o.searchParams.set("id_token_hint",e),o.searchParams.set("post_logout_redirect_uri",t),E(o.toString())}var gt=t=>{try{return new URL(t).protocol==="https:"}catch{return!1}},pt=t=>{try{return new Date(t).toLocaleDateString(a.locale||void 0)}catch{return t}};async function K(t=document){let e=w()?!!(await H().catch(()=>({loggedIn:!1}))).loggedIn:nt()||!!await C().catch(()=>null);if(y(t,f("show")).forEach(r=>{let s=k(r,"show");s==="logged-in"&&x(r,e),s==="logged-out"&&x(r,!e)}),y(t,f("account-link")).forEach(r=>{let s=k(r,"account-link"),i=s==="payment"&&(a.account?.paymentUrl||a.account?.subscriptionsUrl)||s==="subscriptions"&&a.account?.subscriptionsUrl;r.setAttribute("href",i||`https://${a.domain}/account`)}),!e)return;let n=y(t,f("account-bind"));if(n.length){let r=await at().catch(s=>(A(s,"account"),null));n.forEach(s=>{let i={"first-name":r?.firstName,"last-name":r?.lastName,name:r?.displayName,email:r?.emailAddress?.emailAddress,address:r?.defaultAddress?.formatted?.join(", ")}[k(s,"account-bind")];i!=null&&$(s,i)})}let o=y(t,f("orders"));if(o.length){let r=(u,m)=>y(t,f("show")).forEach(l=>{let d=k(l,"show");d==="orders-loading"&&x(l,u),d==="orders-empty"&&x(l,m)});r(!0,!1);let s=!1,i=await mt({first:parseInt(k(o[0],"limit")||"10",10)}).catch(u=>(A(u,"orders"),s=!0,[]));r(!1,!s&&i.length===0),o.forEach(u=>q(u,i,(m,l)=>{let d=l.lineItems?.nodes||[];y(m,f("order-bind")).forEach(g=>{let L=k(g,"order-bind");if(L==="url"){let S=G(l);S&&g.setAttribute("href",S);return}if(L==="image"){let S=d.find(it=>it.image)?.image;S&&R(g,S.url,S.altText||d[0]?.title||"");return}let W={name:l.name,date:pt(l.processedAt),total:Y(l.totalPrice),status:l.financialStatus?.toLowerCase(),fulfillment:l.fulfillmentStatus?.toLowerCase(),items:d.map(S=>`${S.quantity}\xD7 ${S.title}`).join(", ")}[L];W!=null&&$(g,W)}),y(m,f("order-lines")).forEach(g=>St(g,d)),k(m,"order-bind")==="url"&&G(l)&&m.setAttribute("href",G(l))}))}kt.some(r=>y(t,f(r)).length)&&await(await ct()).renderPages(t)}var yt=t=>String(t||"").split("/").pop().split("?")[0];function G(t){let e=a.account?.orderUrl;return e?String(e).replace("{id}",encodeURIComponent(yt(t.id))):gt(t.statusPageUrl)?t.statusPageUrl:null}function St(t,e){q(t,e,(n,o)=>{y(n,f("order-line")).concat(n.matches(f("order-line"))?[n]:[]).forEach(r=>{let s=k(r,"order-line");if(s==="image"){o.image&&R(r,o.image.url,o.image.altText||o.title);return}let i={title:o.title,"variant-title":o.variantTitle||"",quantity:String(o.quantity)}[s];i!=null&&$(r,i)})})}var kt=["order","addresses","subscriptions","profile-form","address-form"],Z=null;function ct(){return Z||(Z=Q("account-pages").then(t=>(t.setup({server:w,serverFetch:U,query:V,customer:at,reset:()=>{I=null,b=null}}),t))),Z}var _=t=>(...e)=>ct().then(n=>n[t](...e)),Et=_("order"),Ut=_("updateProfile"),Pt=_("addresses"),$t=_("saveAddress"),vt=_("deleteAddress"),Ct=_("subscriptions"),Nt=_("subscriptionAction"),Ot=_("requestReturn"),tt=!1;async function Dt(t=document){if(!tt){if(tt=!0,document.addEventListener("click",e=>{let n=e.target;n.closest?.(f("account-login"))?(e.preventDefault(),dt().catch(o=>A(o,"login"))):n.closest?.(f("account-logout"))&&(e.preventDefault(),wt().catch(o=>A(o,"logout")))}),w()){let e=new URL(window.location.href);e.searchParams.get("account")&&(e.searchParams.delete("account"),window.history.replaceState(window.history.state,"",e),T("account-login",{})),h.beforeCheckout=async()=>{if(!(await H()).loggedIn||!h.id())return null;let n=await U("/cart",{method:"POST",body:{cartId:h.id()}}).catch(()=>null);return n?.checkoutUrl?`${n.checkoutUrl}${n.checkoutUrl.includes("?")?"&":"?"}logged_in=true`:null}}else{try{await ht()}catch(e){A(e,"login")}!h.customerAccessToken&&await C().catch(()=>null)&&(h.customerAccessToken=c.access)}X("account",nt()?"logged in":"logged out")}await K(t)}export{Pt as addresses,at as customer,vt as deleteAddress,C as getToken,ht as handleCallback,nt as isLoggedIn,dt as login,wt as logout,Dt as mountAccount,Et as order,mt as orders,V as query,K as render,Ot as requestReturn,$t as saveAddress,Nt as subscriptionAction,Ct as subscriptions,Ut as updateProfile};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{A as V,B as I,D as X,G as T,b as Q,g as P,h as F,n as A,o as d,p as y,s as c,u as W,w as b}from"./chunk-K2YEQAIH.js";import"./chunk-VC46IEJQ.js";var C="amount currencyCode",R="id firstName lastName company address1 address2 city province zoneCode zip country countryCode phoneNumber formatted",L={order:`query TetherOrder($id:ID!){order(id:$id){id name number processedAt cancelledAt financialStatus fulfillmentStatus statusPageUrl requiresShipping totalPrice{${C}}subtotal{${C}}totalShipping{${C}}totalTax{${C}}shippingAddress{${R}}billingAddress{${R}}lineItems(first:50){nodes{id name title variantTitle quantity sku image{url altText}price{${C}}totalPrice{${C}}suggestedReturnReasonDefinitions(first:10){nodes{id name handle}}}}fulfillments(first:10){nodes{id status createdAt estimatedDeliveryAt latestShipmentStatus trackingInformation{company number url}}}returnInformation{returnableLineItems(first:50){nodes{quantity lineItem{id}}}}returns(first:10){nodes{id status}}}}`,addresses:`query TetherAddresses{customer{defaultAddress{id}addresses(first:20){nodes{${R}}}}}`,subscriptions:`query TetherSubscriptions{customer{subscriptionContracts(first:20,reverse:true){nodes{id status nextBillingDate currencyCode deliveryPrice{${C}}deliveryPolicy{interval intervalCount{count}}lines(first:20){nodes{id name title variantTitle quantity sku currentPrice{${C}}lineDiscountedPrice{${C}}image{url altText}}}upcomingBillingCycles(first:3){nodes{cycleIndex skipped billingAttemptExpectedDate}}}}}}`,contract:"query TetherContract($id:ID!){customer{subscriptionContract(id:$id){id status upcomingBillingCycles(first:3){nodes{cycleIndex skipped}}}}}"},S={profile:"mutation TetherProfile($input: CustomerUpdateInput!) { customerUpdate(input: $input) { customer { firstName lastName } userErrors { field message } } }",addressCreate:`mutation TetherAddressCreate($address:CustomerAddressInput!,$default:Boolean){customerAddressCreate(address:$address,defaultAddress:$default){customerAddress{${R}}userErrors{field message}}}`,addressUpdate:`mutation TetherAddressUpdate($id:ID!,$address:CustomerAddressInput,$default:Boolean){customerAddressUpdate(addressId:$id,address:$address,defaultAddress:$default){customerAddress{${R}}userErrors{field message}}}`,addressDelete:"mutation TetherAddressDelete($id: ID!) { customerAddressDelete(addressId: $id) { deletedAddressId userErrors { field message } } }",pause:"mutation TetherPause($id: ID!) { subscriptionContractPause(subscriptionContractId: $id) { contract { id status } userErrors { field message } } }",resume:"mutation TetherResume($id: ID!) { subscriptionContractActivate(subscriptionContractId: $id) { contract { id status } userErrors { field message } } }",cancel:"mutation TetherCancel($id: ID!) { subscriptionContractCancel(subscriptionContractId: $id) { contract { id status } userErrors { field message } } }",skip:"mutation TetherSkip($input: SubscriptionBillingCycleInput!) { subscriptionBillingCycleSkip(billingCycleInput: $input) { billingCycle { cycleIndex skipped } userErrors { field message } } }",unskip:"mutation TetherUnskip($input: SubscriptionBillingCycleInput!) { subscriptionBillingCycleUnskip(billingCycleInput: $input) { billingCycle { cycleIndex skipped } userErrors { field message } } }",returnRequest:"mutation TetherReturn($orderId: ID!, $lines: [RequestedLineItemInput!]!) { orderRequestReturn(orderId: $orderId, requestedLineItems: $lines) { return { id status } userErrors { field message } } }"},p=class extends Error{},q=e=>new RegExp(`^gid://shopify/${e}/\\d+(\\?[\\w=&.-]{1,80})?$`),re={Order:q("Order"),CustomerAddress:q("CustomerAddress"),SubscriptionContract:q("SubscriptionContract"),LineItem:q("LineItem"),ReturnReasonDefinition:q("ReturnReasonDefinition")};function D(e,t){let s=/^\d{1,20}$/.test(String(t??""))?`gid://shopify/${e}/${t}`:String(t??"");if(!re[e].test(s))throw new p(`${e} id`);return s}var N=(e,t=255)=>{if(e==null||e==="")return;if(typeof e!="string"&&typeof e!="number")throw new p("text");let s=String(e).replace(/[\u0000-\u001f\u007f]/g,"").trim();if(s.length>t)throw new p("too long");return s},ne=["firstName","lastName","company","address1","address2","city","zip","zoneCode","phoneNumber"];function ie(e={}){if(!e||typeof e!="object"||Array.isArray(e))throw new p("address");let t={};if(ne.forEach(s=>{let i=N(e[s]);i!==void 0&&(t[s]=i)}),e.countryCode!=null&&e.countryCode!==""){let s=String(e.countryCode).toUpperCase();if(!/^[A-Z]{2}$/.test(s))throw new p("countryCode");t.countryCode=s}return t}var $=e=>{let t=e?.userErrors||[];if(t.length){let s=new p(t.map(i=>i.message).join(" | "));throw s.userErrors=t,s}return e},Y={async order(e,{id:t}){return{order:(await e(L.order,{id:D("Order",t)}))?.order||null}},async profile(e,{firstName:t,lastName:s}){let i={};if(t!==void 0&&(i.firstName=N(t,100)??""),s!==void 0&&(i.lastName=N(s,100)??""),!Object.keys(i).length)throw new p("nothing to change");return{customer:$((await e(S.profile,{input:i}))?.customerUpdate).customer}},async addresses(e){let t=(await e(L.addresses,{}))?.customer,s=t?.defaultAddress?.id||null;return{addresses:(t?.addresses?.nodes||[]).map(i=>({...i,isDefault:i.id===s}))}},async saveAddress(e,{id:t,address:s,isDefault:i}){let r=ie(s||{}),n=i===!0?!0:void 0;return{address:$(t?(await e(S.addressUpdate,{id:D("CustomerAddress",t),address:Object.keys(r).length?r:null,default:n??null}))?.customerAddressUpdate:(await e(S.addressCreate,{address:r,default:n??!1}))?.customerAddressCreate).customerAddress}},async deleteAddress(e,{id:t}){return{deleted:$((await e(S.addressDelete,{id:D("CustomerAddress",t)}))?.customerAddressDelete).deletedAddressId}},async subscriptions(e){return{subscriptions:(await e(L.subscriptions,{}))?.customer?.subscriptionContracts?.nodes||[]}},async subscription(e,{id:t,action:s}){if(!["pause","resume","skip","unskip","cancel"].includes(s))throw new p("action");let i=D("SubscriptionContract",t),r=(await e(L.contract,{id:i}))?.customer?.subscriptionContract;if(!r){let o=new p("not found");throw o.status=404,o}if(s==="skip"||s==="unskip"){let o=r.upcomingBillingCycles?.nodes||[],u=s==="skip"?o.find(m=>!m.skipped):o.find(m=>m.skipped);if(!u)throw new p(s==="skip"?"no upcoming delivery to skip":"nothing skipped");return{billingCycle:$((await e(S[s],{input:{contractId:i,selector:{index:u.cycleIndex}}}))?.[s==="skip"?"subscriptionBillingCycleSkip":"subscriptionBillingCycleUnskip"]).billingCycle}}let n={pause:"subscriptionContractPause",resume:"subscriptionContractActivate",cancel:"subscriptionContractCancel"}[s];return{contract:$((await e(S[s],{id:i}))?.[n]).contract}},async requestReturn(e,{orderId:t,lines:s}){let i=D("Order",t);if(!Array.isArray(s)||!s.length||s.length>50)throw new p("lines");let r=s.map(a=>{let o=Number(a?.quantity);if(!Number.isInteger(o)||o<1||o>1e3)throw new p("quantity");let u={lineItemId:D("LineItem",a.lineItemId),quantity:o};a.reasonId&&(u.returnReasonDefinitionId=D("ReturnReasonDefinition",a.reasonId));let f=N(a.note,300);return f&&(u.customerNote=f),u});return{return:$((await e(S.returnRequest,{orderId:i,lines:r}))?.orderRequestReturn).return}}};var G=null,Z=!1;function De(e){G=e}var H=e=>{try{return new URL(e).protocol==="https:"}catch{return!1}},O=e=>{try{return new Date(e).toLocaleDateString(Q.locale||void 0)}catch{return e}},oe={order:e=>["GET",`/order?id=${encodeURIComponent(e.id)}`],addresses:()=>["GET","/addresses"],subscriptions:()=>["GET","/subscriptions"],profile:()=>["POST","/profile"],saveAddress:()=>["POST","/address"],deleteAddress:()=>["POST","/address/delete"],subscription:()=>["POST","/subscription"],requestReturn:()=>["POST","/return"]};async function w(e,t={}){let{server:s,serverFetch:i,query:r}=G;if(s()){let[n,a]=oe[e](t),o=await i(a,n==="POST"?{method:n,body:t}:{});if(o.loggedIn===!1)throw new F("Not logged in",{code:"NOT_LOGGED_IN",status:401});return o}try{return await Y[e]((n,a)=>r(n,a),t)}catch(n){throw n instanceof p?new F(n.message,{code:"INVALID",userErrors:n.userErrors}):n}}var U=e=>{G.reset(),W("account-updated",{what:e})},ae=e=>w("order",{id:e}).then(t=>t.order),de=({firstName:e,lastName:t}={})=>w("profile",{firstName:e,lastName:t}).then(s=>(U("profile"),s.customer)),ue=()=>w("addresses").then(e=>e.addresses),J=(e,{id:t,isDefault:s}={})=>w("saveAddress",{id:t,address:e,isDefault:s}).then(i=>(U("addresses"),i.address)),ce=e=>w("deleteAddress",{id:e}).then(t=>(U("addresses"),t.deleted)),le=()=>w("subscriptions").then(e=>e.subscriptions),pe=(e,t)=>w("subscription",{id:e,action:t}).then(s=>(U("subscriptions"),s)),fe=(e,t)=>w("requestReturn",{orderId:e,lines:t}).then(s=>(U("orders"),s.return));var x=e=>e?String(e).toLowerCase().replace(/_/g," "):"",z=e=>(e?.formatted||[]).join(", "),E=(e,t,s)=>c(e,d(t)).forEach(i=>{let r=y(i,t);r in s&&X(i,!!s[r])}),j=(e,t)=>E(e,"show",t);function me(e,t,s=null){T(e,t,(i,r)=>{let n=s&&s.get(r.id)||0;i.dataset.tetherLine=r.id,c(i,d("order-line")).concat(i.matches(d("order-line"))?[i]:[]).forEach(a=>{let o=y(a,"order-line");if(o==="image"){r.image&&V(a,r.image.url,r.image.altText||r.title);return}let u={title:r.title||r.name,"variant-title":r.variantTitle||"",quantity:String(r.quantity),price:r.price?b(r.price):"",total:r.totalPrice?b(r.totalPrice):"",sku:r.sku||"",returnable:String(n)}[o];u!=null&&I(a,u)}),E(i,"order-line-show",{returnable:n>0}),c(i,d("return-quantity")).forEach(a=>{a.max=String(n),a.min="0",a.value||(a.value="0"),a.disabled=n<1}),c(i,`select${d("return-reason")}`).forEach(a=>{let o=r.suggestedReturnReasonDefinitions?.nodes||[];a.dataset.tetherFilled!==r.id&&(a.dataset.tetherFilled=r.id,o.forEach(u=>a.appendChild(new Option(u.name,u.id))))})})}var he={order:d("order")};async function ee(e){let t=y(e,"order")||"",s=t.startsWith("url:")?new URL(window.location.href).searchParams.get(t.slice(4)||"id"):t,i=o=>e.setAttribute(A("order-state"),o);if(!s){i("not-found"),E(e,"order-show",{"not-found":!0});return}i("loading"),E(e,"order-show",{loading:!0,ready:!1,"not-found":!1,error:!1});let r;try{r=await ae(s)}catch(o){P(o,"order"),i("error"),E(e,"order-show",{loading:!1,error:!0});return}if(!r){i("not-found"),E(e,"order-show",{loading:!1,"not-found":!0});return}e.dataset.tetherOrderId=r.id;let n=new Map((r.returnInformation?.returnableLineItems?.nodes||[]).map(o=>[o.lineItem?.id,o.quantity])),a=r.fulfillments?.nodes||[];c(e,d("order-bind")).forEach(o=>{let u=y(o,"order-bind");if(u==="url"){H(r.statusPageUrl)&&o.setAttribute("href",r.statusPageUrl);return}let f={name:r.name,date:O(r.processedAt),total:b(r.totalPrice),subtotal:r.subtotal?b(r.subtotal):"",shipping:r.totalShipping?b(r.totalShipping):"",tax:r.totalTax?b(r.totalTax):"",status:x(r.financialStatus),fulfillment:x(r.fulfillmentStatus),"shipping-address":z(r.shippingAddress),"billing-address":z(r.billingAddress),items:(r.lineItems?.nodes||[]).map(m=>`${m.quantity}\xD7 ${m.title||m.name}`).join(", "),cancelled:r.cancelledAt?O(r.cancelledAt):""}[u];f!=null&&I(o,f)}),c(e,d("order-lines")).forEach(o=>me(o,r.lineItems?.nodes||[],n)),c(e,d("order-fulfillments")).forEach(o=>T(o,a,(u,f)=>{let m=f.trackingInformation?.[0]||{};c(u,d("fulfillment-bind")).concat(u.matches(d("fulfillment-bind"))?[u]:[]).forEach(h=>{let g=y(h,"fulfillment-bind");if(g==="url"){H(m.url)&&h.setAttribute("href",m.url);return}let l={status:x(f.latestShipmentStatus||f.status),date:O(f.createdAt),eta:f.estimatedDeliveryAt?O(f.estimatedDeliveryAt):"",company:m.company||"",number:m.number||""}[g];l!=null&&I(h,l)})})),E(e,"order-show",{loading:!1,ready:!0,error:!1,"not-found":!1,cancelled:!!r.cancelledAt,shipped:a.length>0,returnable:[...n.values()].some(o=>o>0),"has-returns":(r.returns?.nodes||[]).length>0,"return-requested":e.dataset.tetherReturned==="1"}),i("ready")}async function ge(e){let t=await G.customer().catch(()=>null);t&&["firstName","lastName"].forEach(s=>{let i=e.elements?.[s];i&&!i.dataset.tetherTouched&&(i.value=t[s]||"")})}var te=null;async function B(e){let t=c(e,d("addresses"));if(!t.length)return;j(e,{"addresses-loading":!0,"addresses-empty":!1});let s=[];try{s=te=await ue()}catch(i){P(i,"addresses")}j(e,{"addresses-loading":!1,"addresses-empty":s.length===0}),t.forEach(i=>T(i,s,(r,n)=>{r.dataset.tetherAddress=n.id,c(r,d("address-bind")).concat(r.matches(d("address-bind"))?[r]:[]).forEach(a=>{let o={formatted:z(n),name:[n.firstName,n.lastName].filter(Boolean).join(" "),company:n.company||"",address1:n.address1||"",address2:n.address2||"",city:n.city||"",zip:n.zip||"",province:n.province||"",country:n.country||"",phone:n.phoneNumber||""}[y(a,"address-bind")];o!=null&&I(a,o)}),E(r,"address-show",{default:n.isDefault,"not-default":!n.isDefault})}))}var ye=["pause","resume","skip","unskip","cancel"];function be(e){let t=e.upcomingBillingCycles?.nodes?.[0],s=e.status;return{active:s==="ACTIVE",paused:s==="PAUSED",cancelled:s==="CANCELLED",expired:s==="EXPIRED",failed:s==="FAILED",skipped:!!t?.skipped,"can-pause":s==="ACTIVE","can-resume":s==="PAUSED"||s==="FAILED","can-skip":s==="ACTIVE"&&!!t&&!t.skipped,"can-unskip":s==="ACTIVE"&&!!t?.skipped,"can-cancel":s==="ACTIVE"||s==="PAUSED"||s==="FAILED"}}async function se(e){let t=c(e,d("subscriptions"));if(!t.length)return;j(e,{"subscriptions-loading":!0,"subscriptions-empty":!1});let s=[];try{s=await le()}catch(i){P(i,"subscriptions")}j(e,{"subscriptions-loading":!1,"subscriptions-empty":s.length===0}),t.forEach(i=>T(i,s,(r,n)=>{r.dataset.tetherSubscription=n.id,r.setAttribute(A("subscription-status"),x(n.status));let a=n.lines?.nodes||[],o=n.deliveryPolicy?.intervalCount?.count||1,u=x(n.deliveryPolicy?.interval),f=a.reduce((h,g)=>h+parseFloat(g.lineDiscountedPrice?.amount||0),0);c(r,d("subscription-bind")).forEach(h=>{let g=y(h,"subscription-bind"),l={status:x(n.status),next:n.nextBillingDate?O(n.nextBillingDate):"",interval:u?o===1?u:`${o} ${u}s`:"",products:a.map(v=>`${v.quantity}\xD7 ${v.title}`).join(", "),total:a.length?b({amount:String(f),currencyCode:n.currencyCode}):"",delivery:n.deliveryPrice?b(n.deliveryPrice):""}[g];l!=null&&I(h,l)}),c(r,d("subscription-lines")).forEach(h=>T(h,a,(g,l)=>{c(g,d("subscription-line")).concat(g.matches(d("subscription-line"))?[g]:[]).forEach(v=>{let _=y(v,"subscription-line");if(_==="image"){l.image&&V(v,l.image.url,l.image.altText||l.title);return}let M={title:l.title,"variant-title":l.variantTitle||"",quantity:String(l.quantity),price:b(l.currentPrice)}[_];M!=null&&I(v,M)})}));let m=be(n);E(r,"subscription-show",m),c(r,d("subscription-action")).forEach(h=>{let g=y(h,"subscription-action"),l=m[`can-${g}`];h.disabled=!l,h.classList.toggle("is-disabled",!l)})}))}async function $e(e=document){Z||(Z=!0,Ae()),await Promise.all([...c(e,d("order")).map(t=>ee(t)),...c(e,d("profile-form")).map(t=>ge(t)),B(e),se(e)])}var K=e=>Object.fromEntries([...e.elements].filter(t=>t.name&&t.type!=="submit"&&t.type!=="button"&&t.type!=="checkbox").map(t=>[t.name,t.value]));async function k(e,t,{error:s}={}){e.classList.add("is-busy"),e.setAttribute("aria-busy","true"),e.setAttribute(A("form-state"),"pending"),c(e,d("form-error")).forEach(i=>I(i,""));try{let i=await t();return e.setAttribute(A("form-state"),"saved"),i}catch(i){e.setAttribute(A("form-state"),"error");let r=i?.userErrors?.map(n=>n.message).join(" ")||i?.message||"Something went wrong";c(e,d("form-error")).forEach(n=>I(n,r.replace(/^Customer accounts: /,""))),s&&P(i,s);return}finally{e.classList.remove("is-busy"),e.removeAttribute("aria-busy")}}function Ae(){document.addEventListener("submit",e=>{let t=e.target;if(t.matches?.(d("profile-form")))e.preventDefault(),k(t,()=>de(K(t)));else if(t.matches?.(d("address-form"))){e.preventDefault();let s=t.dataset.tetherAddressId||void 0,i=!!t.elements?.isDefault?.checked;k(t,async()=>{await J(K(t),{id:s,isDefault:i}),t.reset(),delete t.dataset.tetherAddressId,await B(document)})}}),document.addEventListener("input",e=>{e.target.closest?.(d("profile-form"))&&(e.target.dataset.tetherTouched="1")}),document.addEventListener("click",e=>{let t=e.target,s=t.closest?.("[data-tether-address]"),i=n=>{let a=y(n,"confirm");return!a||window.confirm(a)},r;if((r=t.closest?.(d("address-delete")))&&s)e.preventDefault(),i(r)&&k(s,async()=>{await ce(s.dataset.tetherAddress),await B(document)});else if((r=t.closest?.(d("address-default")))&&s)e.preventDefault(),k(s,async()=>{await J(null,{id:s.dataset.tetherAddress,isDefault:!0}),await B(document)});else if((r=t.closest?.(d("address-edit")))&&s){e.preventDefault();let n=(te||[]).find(o=>o.id===s.dataset.tetherAddress),a=document.querySelector(d("address-form"));n&&a&&(a.dataset.tetherAddressId=n.id,[...a.elements].forEach(o=>{o.name&&o.name in n&&(o.value=n[o.name]??""),o.name==="isDefault"&&(o.checked=n.isDefault)}),a.scrollIntoView?.({block:"nearest"}))}else if(r=t.closest?.(d("address-new"))){let n=document.querySelector(d("address-form"));n&&(n.reset(),delete n.dataset.tetherAddressId)}else if(r=t.closest?.(d("subscription-action"))){e.preventDefault();let n=r.closest("[data-tether-subscription]"),a=y(r,"subscription-action");if(!n||!ye.includes(a)||r.disabled||!i(r))return;n.setAttribute(A("subscription-state"),"pending"),k(n,async()=>{await pe(n.dataset.tetherSubscription,a),await se(document)}).then(()=>{n.setAttribute(A("subscription-state"),n.getAttribute(A("form-state"))==="error"?"error":"done")})}else if(r=t.closest?.(d("order-return"))){e.preventDefault();let n=r.closest(he.order);if(!n?.dataset.tetherOrderId)return;let a=c(n,"[data-tether-line]").map(o=>({lineItemId:o.dataset.tetherLine,quantity:parseInt(o.querySelector(d("return-quantity"))?.value||"0",10),reasonId:o.querySelector(d("return-reason"))?.value||void 0,note:o.querySelector(d("return-note"))?.value||void 0})).filter(o=>o.quantity>0);if(!a.length||!i(r))return;k(n,async()=>{await fe(n.dataset.tetherOrderId,a),n.dataset.tetherReturned="1",await ee(n)})}})}export{ue as addresses,ce as deleteAddress,ae as order,$e as renderPages,fe as requestReturn,J as saveAddress,De as setup,pe as subscriptionAction,le as subscriptions,de as updateProfile};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b}from"./chunk-L2TRRKYV.js";import"./chunk-FIOZPPC5.js";import"./chunk-AJLPU2JC.js";import{b as s,e as T,g as m,l as x,o as g}from"./chunk-K2YEQAIH.js";import"./chunk-VC46IEJQ.js";var j=n=>n?parseFloat(n.amount):0,L=n=>String(n||"").split("/").pop();function S(n,t,e=1,o){return{item_id:t?.sku||L(t?.id)||L(n.id),item_name:n.title,item_variant:t?.title==="Default Title"?void 0:t?.title,item_brand:n.vendor||void 0,item_category:n.productType||void 0,price:j(t?.price||n.priceRange?.minVariantPrice),quantity:e,...o!=null?{index:o}:{}}}function v(n,t=n.quantity){let e=n.merchandise||{};return S({...e.product||{},title:e.product?.title},e,t)}var w=n=>Math.round(n.reduce((t,e)=>t+(e.price||0)*(e.quantity||1),0)*100)/100;function F(n,t){let e=typeof s.analytics.dataLayer=="string"?s.analytics.dataLayer:"dataLayer",o=window[e]=window[e]||[];t&&o.push({ecommerce:null}),o.push(t?{event:n,ecommerce:t}:{event:n})}var p=null;function V(n){let t=[],e=[],o=()=>window.Shopify?.customerPrivacy,a=()=>{try{let i=o();return i?.consentStatus==="loaded"&&i.currentVisitorConsent?.()?.analytics!=="no"&&!!i.analyticsProcessingAllowed?.()}catch{return!1}},c={shop:{shopId:n,channel:"headless"},consent:{mode:s.analytics.shopify?.consent||"no-banner"}},d=()=>{a()&&t.forEach(i=>{for(;i.next<e.length;){let{event:l,payload:u}=e[i.next++];(i.subs.get(l)||[]).forEach(_=>{try{_(u,i.context)}catch(r){m(r,`analytics ${i.name}`)}})}})},f={getConfig:()=>c,publish(i,l={}){e.push({event:i,payload:{shop:c.shop,url:window.location.href,...l}}),e.length>500&&(e.shift(),t.forEach(u=>{u.next=Math.max(0,u.next-1)})),d()},addDestination(i){let l=`hydrogen:${i.name}`,u={name:i.name,next:0,subs:new Map,context:{getTrackingValues:()=>{let r=a()?o()?.__internal:null;return{uniqueToken:r?.uniqueToken?.({generateFallback:!0,tag:l})??"",visitToken:r?.visitToken?.({generateFallback:!0,tag:l})??""}}}},_=(r,C)=>(u.subs.has(r)||u.subs.set(r,new Set),u.subs.get(r).add(C),()=>u.subs.get(r)?.delete(C));return Promise.resolve(i.setup?.({subscribe:_,getConfig:f.getConfig})).then(()=>{t.push(u),d()}).catch(r=>m(r,`analytics ${i.name}`)),()=>{let r=t.indexOf(u);r>=0&&t.splice(r,1)}}};return document.addEventListener("consentTrackingApiLoaded",d),document.addEventListener("visitorConsentCollected",d),f}function q(n){let t=document.createElement("script");t.src=n,t.async=!0,document.head.appendChild(t)}async function D(){if(window.Shopify?.analytics){p=window.Shopify.analytics;return}let n=await x("query TetherShopId { shop { id } }",{},{context:!1}),t=String(s.country||"US").toUpperCase(),e=window.Shopify=window.Shopify||{};Object.assign(e,{country:t,locale:(s.locale||"en").split("-")[0].toLowerCase(),shop:s.domain,routes:{root:"/",match:()=>({pageTemplateName:$()?"product":"page"}),...e.routes||{}}});let o=s.analytics.shopify?.proxy;e.customerPrivacy={...e.customerPrivacy||{},config:o?{isHeadless:!0,asyncConsent:!0,asyncVisitorState:!0,consentDomain:window.location.host}:{isHeadless:!0,storefrontAccessToken:s.token,checkoutRootDomain:s.domain}},p=V(n.shop.id),e.analytics=p,q(s.analytics.shopify?.consent==="default-banner"?"https://cdn.shopify.com/shopifycloud/privacy-banner/storefront-banner.js":"https://cdn.shopify.com/shopifycloud/consent-tracking-api/v0.2/consent-tracking-api.js"),q("https://cdn.shopify.com/storefront/analytics/shopify.js"),T("shopify analytics ready",n.shop.id)}var M=(n,t,e=1)=>({id:n.id,title:n.title,price:t.price,vendor:n.vendor||"",variantId:t.id,variantTitle:t.title,quantity:e,sku:t.sku||void 0,productType:n.productType||void 0});function E(n){let t=n.merchandise||{};return{id:n.id,quantity:n.quantity,merchandise:{id:t.id,title:t.title,price:t.price,sku:t.sku,product:{id:t.product?.id,title:t.product?.title,vendor:t.product?.vendor||"",handle:t.product?.handle}}}}function $(){let n=document.querySelector(g("product"));return n&&!n.closest(`${g("collection")},${g("products")},${g("recommendations")}`)?window.Tether?.getScope(n):null}var y=(n,t,e,o)=>{s.analytics.dataLayer&&F(n,t),p&&e&&p.publish(e,o);try{s.analytics.onEvent?.(n,t)}catch(a){m(a,"analytics onEvent")}},h=null,k=new WeakSet;function P(n){let t=n.type.slice(s.prefix.length+1),e=n.detail||{};if(t==="product-ready"){let o=e.scope;if(!o||k.has(o.root)||$()!==o)return;k.add(o.root);let a=o.variant||e.product.variants.nodes[0],c=[S(e.product,a)];y("view_item",{currency:a?.price?.currencyCode,value:w(c),items:c},"product_viewed",{products:[M(e.product,a)]})}else if(t==="list-ready"){let o=(e.products||[]).slice(0,200).map((c,d)=>S(c,c.variants?.nodes?.[0],1,d)),a={item_list_id:e.collection?.handle||"products",item_list_name:e.collection?.title||"Products"};y("view_item_list",{...a,items:o},e.collection?"collection_viewed":null,e.collection?{collection:{id:e.collection.id,handle:e.collection.handle}}:null)}else if(t==="cart-updated"){let o=e.cart,a=new Map((o?.lines?.nodes||[]).map(c=>[c.merchandise?.id,c]));if(h&&e.reason!=="load"&&e.reason!=="pending"){let c=o?.cost?.totalAmount?.currencyCode;a.forEach((d,f)=>{let i=d.quantity-(h.get(f)?.quantity||0);if(i>0){let l=[v(d,i)];y("add_to_cart",{currency:c,value:w(l),items:l},"product_added_to_cart",{cart:o,prevCart:A,currentLine:E(d),prevLine:h.get(f)?E(h.get(f)):void 0})}}),h.forEach((d,f)=>{let i=d.quantity-(a.get(f)?.quantity||0);if(i>0){let l=[v(d,i)];y("remove_from_cart",{currency:c,value:w(l),items:l})}})}h=a,A=o}else if(t==="cart-toggled"&&e.open){let o=b.lines.map(a=>v(a));y("view_cart",{currency:b.state?.cost?.totalAmount?.currencyCode,value:w(o),items:o})}else if(t==="checkout"){let o=(e.cart?.lines?.nodes||[]).map(c=>v(c)),a=(e.cart?.discountCodes||[]).filter(c=>c.applicable).map(c=>c.code).join(",")||void 0;y("begin_checkout",{currency:e.cart?.cost?.totalAmount?.currencyCode,value:w(o),coupon:a,items:o})}else t==="search"&&e.term?y("search",{search_term:e.term},"search_viewed",{searchTerm:e.term}):t==="page"&&(k=new WeakSet,p&&p.publish("page_viewed",{}))}var A=null;async function R(n){s.analytics.shopify&&await D().catch(t=>m(t,"shopify analytics")),p&&p.publish("page_viewed",{}),n.splice(0).forEach(P),n.push=t=>(P(t),0)}export{R as startAnalytics};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as c,l as g}from"./chunk-K2YEQAIH.js";var p=/^[A-Z]{2}$/,y=new Set(["PT_BR","PT_PT","ZH_CN","ZH_TW"]),d=()=>`${c.prefix}:market:${c.domain}`,h=()=>({document:typeof document<"u"?document:null,location:typeof window<"u"?window.location:null,storage:(()=>{try{return window.localStorage}catch{return null}})(),global:typeof window<"u"?window:{}});function w(t){let e=String(t||"").trim().toUpperCase();return p.test(e)&&e!=="XX"&&e!=="T1"?e:null}function C(t){let e=String(t||"").trim().replace("-","_").toUpperCase();if(!e)return null;if(y.has(e))return e;let n=e.split("_")[0];return/^[A-Z]{2,3}$/.test(n)?n:null}function b(t,e){if(!t||!e)return null;let n=String(t.cookie||"").split(";").map(r=>r.trim()).find(r=>r.startsWith(`${e}=`));return n?decodeURIComponent(n.slice(e.length+1)):null}var s=(t,e)=>{if(!t||!e)return null;let n=String(e).toLowerCase(),r=Object.keys(t).find(o=>o.toLowerCase()===n);return r?t[r]:null},T={saved(t,e){if(t.remember===!1||!e.storage)return null;try{return JSON.parse(e.storage.getItem(d())||"null")}catch{return null}},server(t,e){let n=a=>e.document?.querySelector?.(`meta[name="${a}"]`)?.getAttribute("content"),r=e.global.TETHER_COUNTRY||n("tether-country")||b(e.document,t.cookie||"tether_country"),o=e.global.TETHER_LANGUAGE||n("tether-language");return{country:r,language:o}},webflow(t,e){let n=(e.location?.pathname||"/").split("/").filter(Boolean)[0],r=s(t.locales,n);if(r)return r;let o=e.document?.documentElement?.getAttribute("lang");if(!o)return null;let a=s(t.locales,o)||s(t.locales,o.split("-")[0]);if(a)return{locale:o,...a};if(t.locales&&t.strict)return null;let l=o.split("-")[1];return{language:o,country:l&&l.length===2?l:null,locale:o}}};function L(t=c.markets,e=h()){let n=t||{};if(n.detect===!1)return{};let r=n.detect?n.detect===!0?["saved","server","webflow"]:[].concat(n.detect):["saved"];t=n;let o={sources:{}};return r.forEach(a=>{let l=T[a]?.(t,e);if(!l)return;let m={country:w(l.country),language:C(l.language),locale:l.locale||null};Object.entries(m).forEach(([i,f])=>{f&&!o[i]&&(o[i]=f,o.sources[i]=a)})}),o}function _(t){if(c.markets?.remember!==!1)try{localStorage.setItem(d(),JSON.stringify({country:t.country,language:t.language||void 0,locale:t.locale||void 0}))}catch{}}var u=null;function A(){u=null}function x(){return u||(u=g("query TetherLocalization{localization{country{isoCode name currency{isoCode symbol}}language{isoCode name}availableCountries{isoCode name currency{isoCode symbol}availableLanguages{isoCode name}}}}").then(t=>t.localization).catch(t=>{throw u=null,t})),u}export{w as a,C as b,L as c,_ as d,A as e,x as f};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{b as l}from"./chunk-K2YEQAIH.js";import{a as P}from"./chunk-VC46IEJQ.js";var i="amount currencyCode",a="url altText width height";function f(e=l){return(e.metafields||[]).map(t=>{if(typeof t=="string"){let n=t.indexOf(".");return{namespace:t.slice(0,n),key:t.slice(n+1)}}return t}).filter(t=>t.namespace&&t.key)}function $(e=l){let t=f(e);return t.length?`metafields(identifiers:[${t.map(r=>`{namespace: ${JSON.stringify(r.namespace)}, key: ${JSON.stringify(r.key)}}`).join(", ")}]){namespace key type value reference{... on MediaImage{image{${a}}}}}`:""}var A=` id name description recurringDeliveries options{name value}priceAdjustments{orderCount adjustmentValue{__typename ... on SellingPlanPercentagePriceAdjustment{adjustmentPercentage}... on SellingPlanFixedAmountPriceAdjustment{adjustmentAmount{${i}}}... on SellingPlanFixedPriceAdjustment{price{${i}}}}}`,y=` sellingPlan{id}checkoutChargeAmount{${i}}remainingBalanceChargeAmount{${i}}priceAdjustments{price{${i}}compareAtPrice{${i}}perDeliveryPrice{${i}}unitPrice{${i}}}`;function k(e=l){return` fragment TetherProduct on Product{id handle title description descriptionHtml productType vendor tags availableForSale publishedAt onlineStoreUrl requiresSellingPlan seo{title description}featuredImage{${a}}images(first:${e.imagesFirst}){nodes{${a}}}options{name optionValues{name swatch{color image{previewImage{${a}}}}}}priceRange{minVariantPrice{${i}}maxVariantPrice{${i}}}compareAtPriceRange{minVariantPrice{${i}}maxVariantPrice{${i}}}${$(e)} sellingPlanGroups(first:${e.sellingPlanGroupsFirst}){nodes{name appName options{name values}sellingPlans(first:${e.sellingPlansFirst}){nodes{${A}}}}}variants(first:${e.variantsFirst}){nodes{id title availableForSale currentlyNotInStock quantityAvailable sku barcode selectedOptions{name value}image{${a}}price{${i}}compareAtPrice{${i}}unitPrice{${i}}sellingPlanAllocations(first:${e.sellingPlansFirst}){nodes{${y}}}}}}`}function I(){return` fragment TetherCart on Cart{id checkoutUrl totalQuantity note createdAt updatedAt attributes{key value}buyerIdentity{countryCode email}discountCodes{code applicable}cost{subtotalAmount{${i}}totalAmount{${i}}checkoutChargeAmount{${i}}}lines(first:100){nodes{id quantity attributes{key value}cost{totalAmount{${i}}subtotalAmount{${i}}amountPerQuantity{${i}}compareAtAmountPerQuantity{${i}}}discountAllocations{discountedAmount{${i}}}sellingPlanAllocation{sellingPlan{id name description recurringDeliveries options{name value}}checkoutChargeAmount{${i}}priceAdjustments{price{${i}}compareAtPrice{${i}}perDeliveryPrice{${i}}}}merchandise{... on ProductVariant{id title sku availableForSale requiresShipping quantityAvailable image{${a}}price{${i}}compareAtPrice{${i}}selectedOptions{name value}product{id title handle vendor featuredImage{${a}}}}}... on ComponentizableCartLine{lineComponents{id quantity merchandise{... on ProductVariant{id title product{title handle}}}}}}}}`}function L(){return`
|
|
2
|
-
id handle title description descriptionHtml
|
|
3
|
-
image { ${a} }
|
|
4
|
-
seo { title description }`}var j={};P(j,{GID:()=>p,allPlans:()=>u,allocationFor:()=>c,findPlan:()=>C,hasPlans:()=>h,planAdjustment:()=>S,planCheckoutCharge:()=>x,planPrice:()=>m,planSavings:()=>F,plansForVariant:()=>v,toGid:()=>s});var p={product:e=>s(e,"Product"),variant:e=>s(e,"ProductVariant"),sellingPlan:e=>s(e,"SellingPlan")};function s(e,t){let n=String(e??"").trim();return n?n.startsWith("gid://")?n:/^\d+$/.test(n)?`gid://shopify/${t}/${n}`:n:null}function u(e){return(e?.sellingPlanGroups?.nodes||[]).flatMap(n=>(n.sellingPlans?.nodes||[]).map(r=>({...r,group:n})))}function h(e){return u(e).length>0}function c(e,t){return!e||!t?null:(e.sellingPlanAllocations?.nodes||[]).find(n=>n.sellingPlan?.id===t)||null}function v(e,t){return u(e).filter(n=>c(t,n.id))}function m(e,t){let r=c(e,t)?.priceAdjustments?.[0];return r?.perDeliveryPrice||r?.price||e?.price||null}function x(e,t){let n=c(e,t);return n?.checkoutChargeAmount||n?.priceAdjustments?.[0]?.price||e?.price||null}function F(e,t){let n=parseFloat(e?.price?.amount),r=parseFloat(m(e,t)?.amount);return!Number.isFinite(n)||!Number.isFinite(r)||n<=0||r>=n?{amount:null,percentage:0}:{amount:{amount:(n-r).toFixed(2),currencyCode:e.price.currencyCode},percentage:Math.round((1-r/n)*100)}}function S(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 C(e,t){if(!t)return null;let n=u(e),r=p.sellingPlan(t),d=String(t).trim().toLowerCase();return n.find(o=>o.id===r)||n.find(o=>o.name.toLowerCase()===d)||n.find(o=>(o.options||[]).some(g=>String(g.value).toLowerCase()===d))||null}export{k as a,I as b,L as c,p as d,u as e,c as f,m as g,x as h,F as i,S as j,C as k,j as l};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as w,c as v}from"./chunk-AJLPU2JC.js";import{b as x,e as K,h as P,l as p}from"./chunk-K2YEQAIH.js";var d=new Map,D=[],E=new Map,S=!1,g=0,q=t=>typeof t=="string"&&t.startsWith("gid://");function I(t){let e=String(t??"").trim();if(!e)return null;if(q(e))return e;if(/^\d+$/.test(e))return`gid://shopify/Product/${e}`;let n=e.match(/\/products\/([^/?#]+)/);return n?n[1]:e}function y(t){if(!t)return;let e=Promise.resolve(t);d.set(t.handle,e),d.set(t.id,e)}function F(t){let e=I(t);if(!e)return Promise.reject(new P("empty product key",{code:"NOT_FOUND"}));if(d.has(e))return d.get(e);let n=new Promise((c,i)=>{E.set(e,{resolve:c,reject:i}),D.push(e),S||(S=!0,setTimeout(N,0))});return d.set(e,n),n}async function N(){S=!1;let t=g,e=D.splice(0);if(!e.length)return;let n=e.filter(q),c=e.filter(s=>!q(s)),i=[],a=[],h={};n.length&&(i.push("$ids: [ID!]!"),h.ids=n,a.push("byId: nodes(ids: $ids) { ... on Product { ...TetherProduct } }")),c.forEach((s,o)=>{i.push(`$h${o}: String!`),h[`h${o}`]=s,a.push(`h${o}: product(handle: $h${o}) { ...TetherProduct }`)});let m=`query TetherProducts(${i.join(",")}){${a.join(" ")}}${w()}`;K("fetch products",e);let f=(s,o)=>{let r=E.get(s);E.delete(s),r&&o(r)};try{let s=await p(m,h),o=new Map;(s.byId||[]).forEach(r=>{r&&o.set(r.id,r)}),c.forEach((r,$)=>{s[`h${$}`]&&o.set(r,s[`h${$}`])}),e.forEach(r=>f(r,$=>{if(o.has(r)){let l=o.get(r);t===g&&(y(l),T.set(l.handle,Date.now()),T.set(l.id,Date.now())),$.resolve(l)}else{let l=d.get(r);t===g&&setTimeout(()=>{d.get(r)===l&&d.delete(r)},1e4),$.reject(new P(`Product not found: ${r}`,{code:"NOT_FOUND"}))}}))}catch(s){e.forEach(o=>f(o,r=>{t===g&&d.delete(o),r.reject(s)}))}}function M(){d.clear(),g++,u.clear(),T.clear()}var u=new Set,T=new Map,C=6e4;function b(t){(t||[]).forEach(e=>{!e?.id||!e.handle||Date.now()-(T.get(e.handle)||0)<C&&d.has(e.handle)||(y(e),u.add(e.handle),u.add(e.id))})}function _(t){let e=I(t);if(!u.has(e))return!1;let n=d.get(e);return u.delete(e),n?.then?.(c=>{u.delete(c.handle),u.delete(c.id)}),!0}function U(t){return t.forEach(e=>d.delete(I(e))),t.map(e=>F(e))}async function A({collection:t,query:e,first:n=x.collectionFirst,after:c=null,sortKey:i,reverse:a=!1,filters:h}={}){let m=w();if(t){let s=await p(`query TetherCollection($handle:String!,$first:Int!,$after:String,$sortKey:ProductCollectionSortKeys,$reverse:Boolean,$filters:[ProductFilter!]){collection(handle:$handle){${v()} products(first:$first,after:$after,sortKey:$sortKey,reverse:$reverse,filters:$filters){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}}${m}`,{handle:t,first:n,after:c,sortKey:i||void 0,reverse:a,filters:h||void 0});if(!s.collection)throw new P(`Collection not found: ${t}`,{code:"NOT_FOUND"});let{products:o,...r}=s.collection;return o.nodes.forEach(y),{collection:r,products:o.nodes,pageInfo:o.pageInfo}}let f=await p(`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}}}${m}`,{first:n,after:c,query:e||void 0,sortKey:i||void 0,reverse:a});return f.products.nodes.forEach(y),{collection:null,products:f.products.nodes,pageInfo:f.products.pageInfo}}async function B(t,e="RELATED"){let n=I(typeof t=="object"?t?.id:t),c=n?.startsWith("gid://"),a=(await p(`query TetherRecs(${c?"$id: ID!":"$handle: String!"},$intent:ProductRecommendationIntent){productRecommendations(${c?"productId: $id":"productHandle: $handle"},intent:$intent){...TetherProduct}}${w()}`,c?{id:n,intent:e}:{handle:n,intent:e})).productRecommendations||[];return a.forEach(y),a}export{I as a,y as b,F as c,M as d,b as e,_ as f,U as g,A as h,B as i};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var C={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",variantUrl:!1,maxAge:60,lowStock:5,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},n={...C};function _(t={}){return Object.keys(n).forEach(e=>delete n[e]),Object.assign(n,C,t),n.domain&&(n.domain=String(n.domain).replace(/^https?:\/\//,"").replace(/\/.*$/,"")),n.storageKey||(n.storageKey=`${n.prefix}:cart:${n.domain}`),n.apiVersion==="unstable"&&w('apiVersion "unstable" changes without notice. Pin a dated version (e.g. 2026-07).'),n}var G=()=>!!(n.domain&&n.token);function T(...t){n.debug&&console.log(`[${n.prefix}]`,...t)}function w(...t){console.warn(`[${n.prefix}]`,...t)}function B(t,e){if(w(e,t&&(t.message||t.code)?t.message||t.code:t),typeof n.onError=="function")try{n.onError(t,e)}catch{}}var d=class extends Error{constructor(e,{status:r,errors:o,userErrors:a,code:u}={}){super(e),this.name="TetherError",this.code=u||(r?`HTTP_${r}`:"ERROR"),this.status=r,this.errors=o,this.userErrors=a}};function L(t=n){return`https://${t.domain}/api/${t.apiVersion}/graphql.json`}function U(t,e=n){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 o=`@inContext(${r.join(", ")})`;return/^\s*\{/.test(t)?`query ${o} ${t.trimStart()}`:t.replace(/^(\s*(?:query|mutation)(?:\s+\w+)?\s*(?:\([^)]*\))?)/,`$1 ${o}`)}var v=t=>new Promise(e=>setTimeout(e,t));function E(t,e){return t===401||t===403?`Shopify rejected the Storefront token for ${e.domain} (${t}): use the public Storefront API token (Headless channel)${/^shpat_/.test(e.token)?", not an Admin API token (shpat_\u2026)":""}`:t===404?`Store or API version not found (404): check domain ${e.domain} and apiVersion ${e.apiVersion}`:`HTTP ${t} from ${e.domain}`}async function k(t,e,r={},{context:o=!0}={}){if(!t.domain||!t.token)throw new d("Tether is not configured: domain and token are required",{code:"NOT_CONFIGURED"});let a=o?U(e,t):e,u=t.maxAge??60;u>0&&!/^\s*mutation\b/.test(a)&&(a+=` #${Math.floor(Date.now()/(u*1e3))}`);let g=JSON.stringify({query:a,variables:r}),l=0;for(;;){let s;try{s=await(t.fetch||fetch)(L(t),{method:"POST",headers:{"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":t.token},body:g})}catch(h){if(l++<t.retries){await v(300*2**l);continue}throw new d(`Network error: ${h.message}`,{code:"NETWORK"})}if(s.status===430)throw new d("Shopify security rejection (430)",{status:430});if((s.status===429||s.status>=500)&&l++<t.retries){T("retry",s.status,l),await v(300*2**l);continue}let c;try{c=await s.json()}catch{throw new d(s.ok?`Invalid response (${s.status})`:E(s.status,t),{status:s.status})}if(c.errors?.length){if(c.errors.some(p=>/quantityAvailable/.test(p.message||""))&&/\bquantityAvailable\b/.test(g))return T("no inventory permission, retrying without quantityAvailable"),k(t,e.replace(/\bquantityAvailable\b/g,""),r,{context:o});if(c.errors.some(p=>/'warnings'/.test(p.message||""))&&/warnings \{ code message target \}/.test(e))return k(t,e.replace(/ warnings \{ code message target \}/g,""),r,{context:o});if(c.errors.some(p=>p.extensions?.code==="THROTTLED")&&l++<t.retries){await v(500*2**l);continue}let m=c.errors.map(p=>p.message).filter(Boolean).join(" | ");throw new d(s.ok?m||"Storefront API error":s.status===401||s.status===403||!m?E(s.status,t):m,{status:s.status,errors:c.errors})}if(!s.ok)throw new d(E(s.status,t),{status:s.status});return c.data}}var z=(t,e,r)=>k(n,t,e,r);function W(t,e){if(!t)throw new d(`${e}: empty response`);let r=t.userErrors||[];if(r.length)throw new d(r.map(o=>o.message).join(" | "),{userErrors:r});return t}var A=t=>`${n.prefix}-${t}`,Z=(t,e)=>e===void 0?`[${A(t)}]`:`[${A(t)}="${e}"]`,F=(t,e)=>t.getAttribute(A(e)),tt=(t,e)=>t.hasAttribute(A(e)),D=()=>`data-${n.prefix}-key`;function et(t,e){let r=n.productPath||"/product";if(!/\{(handle|id)\}/.test(r))return`${r.replace(/\/$/,"")}/${t}`;let o=e?String(e).split("/").pop():"";return r.replace(/\{handle\}/g,encodeURIComponent(t||"")).replace(/\{id\}/g,encodeURIComponent(o))}var I=(t,e)=>t?[...t.querySelectorAll(e)]:[],rt=(t,e,r)=>I(t,e).filter(o=>o.closest(r)===t);function M(t,e,r=document){r.dispatchEvent(new CustomEvent(`${n.prefix}:${t}`,{detail:e,bubbles:!0}))}function nt(t,e=n.locale){if(!t)return"";try{return new Intl.NumberFormat(e||void 0,{style:"percent",maximumFractionDigits:0}).format(t/100)}catch{return`${t}%`}}function ot(t){if(!t)return"";if(typeof n.formatMoney=="function")return n.formatMoney(t,n.locale);let e=parseFloat(t.amount);if(Number.isNaN(e))return"";try{return new Intl.NumberFormat(n.locale||void 0,{style:"currency",currency:t.currencyCode}).format(e)}catch{return`${t.currencyCode} ${e.toFixed(2)}`}}function it(t){if(!t)return"";try{return new Date(t).toLocaleDateString(n.locale||void 0)}catch{return""}}function R(t,{width:e,height:r,crop:o}={}){if(!t)return t;try{let a=new URL(t);return e&&a.searchParams.set("width",String(e)),r&&a.searchParams.set("height",String(r)),o&&a.searchParams.set("crop",o),a.toString()}catch{return t}}function V(t,e){if(!t||!e)return t;let r=o=>e.getAttribute(o)??e.getAttribute(`${n.prefix}-${o}`)??e.getAttribute(`data-${o}`);return R(t,{width:r("max-width"),height:r("max-height"),crop:r("max-width")||r("max-height")?r("crop"):null})}var j=(t,e)=>!!(t&&e)&&t.split("?")[0]===e.split("?")[0];function st(t,e,r){if(!e)return;let o=V(e,t);if(t.tagName==="IMG"&&j(t.getAttribute("src"),o)){r!=null&&!t.getAttribute("alt")&&t.setAttribute("alt",r);return}t.tagName==="IMG"?(t.removeAttribute("srcset"),t.removeAttribute("sizes"),t.setAttribute("src",o),r!=null&&t.setAttribute("alt",r),t.getAttribute("loading")||t.setAttribute("loading","lazy")):t.style.backgroundImage=`url("${o}")`}function K(t,e){let r=e==null?"":String(e);t.tagName==="INPUT"||t.tagName==="TEXTAREA"?t.value=r:t.textContent=r}var N=t=>t.tagName==="INPUT"||t.tagName==="TEXTAREA"?t.value:t.textContent;function at(t,e){let r=N(t);K(t,e);let o=N(t);if(r!==o&&t.dataset.tetherSeen&&typeof n.onValueChange=="function")try{n.onValueChange(t,r)}catch{}t.dataset.tetherSeen="1"}function ut(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(`${n.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 ct(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 $=new WeakMap,lt=t=>!!$.get(t);function O(t){if(!$.has(t)){let e=t.firstElementChild?.cloneNode(!0)??null;$.set(t,e),t.innerHTML=""}return $.get(t)}function pt(t,e,r){let o=O(t);if(!o){e.length&&w("repeater without a template child",t);return}t.innerHTML="",e.forEach((a,u)=>{let g=o.cloneNode(!0);r(g,a,u),t.appendChild(g)})}function ft(t,e,r,o,{onEnter:a,onLeave:u}={}){let g=O(t);if(!g){w("repeater without a template child",t);return}let l=D(),s=`data-${n.prefix}-leaving`,S=()=>[...t.children].filter(i=>i.hasAttribute(l)&&!i.hasAttribute(s)),c=new Map(S().map(i=>[i.getAttribute(l),i])),h=[],b=new Set;e.forEach((i,f)=>{let y=String(r(i,f)),x=c.get(y);x?c.delete(y):(x=g.cloneNode(!0),x.setAttribute(l,y),b.add(x)),o(x,i,f,b.has(x)),h.push(x)});let m=h.filter(i=>!b.has(i)),p=S().filter(i=>m.includes(i));if(!(p.length===m.length&&p.every((i,f)=>i===m[f]))){c.forEach(i=>i.remove()),h.forEach(i=>t.appendChild(i));return}h.forEach((i,f)=>{if(!b.has(i))return;let y=h[f-1];if(y&&y.parentNode===t?y.after(i):t.prepend(i),a)try{a(i)}catch{}}),c.forEach(i=>{i.setAttribute(s,""),i.removeAttribute(l),i.style.pointerEvents="none",i.inert=!0;let f=()=>i.remove();if(u)try{u(i,f)}catch{f()}else f()})}var P=null;function q(t){clearTimeout(P),P=setTimeout(()=>{typeof n.onLayoutChange=="function"?n.onLayoutChange(t):window.ScrollTrigger?.refresh&&window.ScrollTrigger.refresh(),M("layout-changed",{reason:t})},120)}function dt(t,e){let r=I(t,"img").filter(u=>!u.complete);if(!r.length)return;let o=r.length,a=()=>{--o===0&&q(`${e}:images`)};r.forEach(u=>{u.addEventListener("load",a,{once:!0}),u.addEventListener("error",a,{once:!0})})}function gt(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 ht(t,e){let r=t&&F(t,e);if(!r)return null;try{return JSON.parse(r)}catch{return w(`invalid JSON in ${A(e)}`,t),null}}function mt(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??"")})):[]}export{C as a,n as b,_ as c,G as d,T as e,w as f,B as g,d as h,L as i,U as j,k,z as l,W as m,A as n,Z as o,F as p,tt as q,et as r,I as s,rt as t,M as u,nt as v,ot as w,it as x,R as y,j as z,st as A,K as B,at as C,ut as D,ct as E,lt as F,pt as G,ft as H,q as I,dt as J,gt as K,ht as L,mt as M};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as Q}from"./chunk-FIOZPPC5.js";import{b as S,d as I,e as B}from"./chunk-AJLPU2JC.js";import{A as M,B as j,C as m,D as L,G as K,H as N,I as R,M as q,b as c,e as O,g as A,h as v,l as $,m as U,n as E,o as u,p as g,r as F,s as l,u as h,w as b}from"./chunk-K2YEQAIH.js";function G(t,e=1,n={}){let a=typeof t=="object"&&t!==null?t:{variantId:t,quantity:e,...n},s=I.variant(a.merchandiseId||a.variantId||a.id);if(!s)throw new v("add(): variantId is required");let r={merchandiseId:s,quantity:Math.max(1,parseInt(a.quantity??1,10)||1)},o=a.sellingPlanId||a.sellingPlan;o&&(r.sellingPlanId=I.sellingPlan(o));let i=q(a.attributes);return i.length&&(r.attributes=i),r}function V(t,e,n){return`mutation Tether_${t}(${e}){${t}(${n}){cart{...TetherCart}userErrors{field message}warnings{code message target}}}${S()}`}var H='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',k=null,W=t=>l(t,H).filter(e=>e.offsetParent!==null||e===document.activeElement);function x(t){l(document,u("cart-open")).forEach(e=>e.setAttribute("aria-expanded",String(t))),l(document,u("cart-drawer")).forEach(e=>{e.hasAttribute("role")||e.setAttribute("role","dialog"),!e.hasAttribute("aria-label")&&!e.hasAttribute("aria-labelledby")&&e.setAttribute("aria-label",g(e,"cart-label")||"Cart"),e.setAttribute("aria-modal",String(t)),e.classList.contains(c.cartDrawerOpenClass)||(e.setAttribute("aria-hidden","true"),c.cartFocus!==!1&&(e.inert=!0))})}var T=t=>/does not exist|not found|invalid id/i.test(t?.message||""),D={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,customerAccessToken:null,pendingQty:new Map,warnings:[],loaded:!1,_take(t,e){let n=U(t,e);return this.warnings=(n.warnings||[]).filter((a,s,r)=>r.findIndex(o=>o.message===a.message)===s).map(a=>({...a,message:typeof c.warningText=="function"&&c.warningText(a)||a.message})),this.warnings.length&&h("cart-warning",{warnings:this.warnings}),n.cart},_queue(t){let e=this._chain.then(t,t).then(n=>(this.lastError&&(this.lastError=null,this.render()),n),n=>{throw this.lastError=n,this.render(),h("cart-error",{error:n}),n});return this._chain=e.catch(()=>{}),e},_commit(t,e){this.state=t,t?.id&&this._setId(t.id);try{localStorage.setItem(`${c.storageKey}:seen`,`${Date.now()}|${t?.totalQuantity||0}`)}catch{}return this.render(),h("cart-updated",{cart:t,reason:e}),t},async init(){let t=this.id();if(!t)return this.state=null,this.loaded=!0,this.render(),h("cart-updated",{cart:null,reason:"load"}),null;if(!this.loaded)try{let e=(localStorage.getItem(`${c.storageKey}:seen`)||"").split("|")[1];e&&l(document,u("cart-count")).forEach(n=>{/^\s*0?\s*$/.test(n.textContent)&&(n.textContent=e)})}catch{}try{let e=await $(`query TetherCart($id:ID!){cart(id:$id){...TetherCart}}${S()}`,{id:t});e.cart?this.state=e.cart:(this._setId(null),this.state=null)}catch(e){A(e,"cart load failed"),this.lastError=e,T(e)&&this._setId(null),this.state=null}return this.loaded=!0,this.render(),h("cart-updated",{cart:this.state,reason:"load"}),this.state},async _create(t={}){let e=c.country||this.customerAccessToken?{...c.country?{countryCode:String(c.country).toUpperCase()}:{},...this.customerAccessToken?{customerAccessToken:this.customerAccessToken}:{}}:void 0,n=await $(V("cartCreate","$input: CartInput!","input: $input"),{input:{buyerIdentity:e,...t}});return this._take(n.cartCreate,"cartCreate")},async _mutate(t,e,n,a,s){let r=this.id();if(!r)return s?this._create(s):null;try{let o=await $(V(t,`$cartId: ID!, ${e}`,`cartId: $cartId, ${n}`),{...a,cartId:r});return this._take(o[t],t)}catch(o){if(s&&T(o))return O("cart expired, creating a new one"),this._setId(null),this._create(s);throw o}},add(t,e=1,n={}){let a=(Array.isArray(t)?t:[t]).map(s=>G(s,e,n));return this._queue(async()=>{let s=await this._mutate("cartLinesAdd","$lines: [CartLineInput!]!","lines: $lines",{lines:a},{lines:a});return this._commit(s,"add"),h("added",{cart:s,lines:a}),c.openCartOnAdd&&this.open(),s})},updateLine(t,e){let n=typeof e=="number"?{quantity:e}:{...e};if(n.quantity!==void 0&&n.quantity<=0)return this.removeLine(t);let a={id:t};return n.quantity!==void 0&&(a.quantity=n.quantity),"sellingPlanId"in n&&(a.sellingPlanId=n.sellingPlanId?I.sellingPlan(n.sellingPlanId):null),n.attributes&&(a.attributes=q(n.attributes)),(n.merchandiseId||n.variantId)&&(a.merchandiseId=I.variant(n.merchandiseId||n.variantId)),this._queue(async()=>this._commit(await this._mutate("cartLinesUpdate","$lines: [CartLineUpdateInput!]!","lines: $lines",{lines:[a]}),"update"))},changeQuantity(t,e){let n=this.lines.find(o=>o.id===t);if(!n)return Promise.resolve(this.state);let a=Math.max(0,(this.pendingQty.get(t)?.qty??n.quantity)+e),s={qty:a,done:!1};this.pendingQty.set(t,s),this.render(),h("cart-updated",{cart:this.state,reason:"pending"});let r=()=>this.pendingQty.get(t)===s;return this._queue(async()=>{if(!r())return this.state;let o=this.lines.find(d=>d.id===t);if(o&&o.quantity===a)return this.state;let i=a>0?await this._mutate("cartLinesUpdate","$lines: [CartLineUpdateInput!]!","lines: $lines",{lines:[{id:t,quantity:a}]}):await this._mutate("cartLinesRemove","$lineIds: [ID!]!","lineIds: $lineIds",{lineIds:[t]});return r()?this._commit(i,a>0?"update":"remove"):(this.state=i,i?.id&&this._setId(i.id),i)}).finally(()=>{r()&&(this.pendingQty.delete(t),this.render(),h("cart-updated",{cart:this.state,reason:"settled"}))})},quantityOf(t){return this.pendingQty.get(t.id)?.qty??t.quantity},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(a=>[a.key,a.value]));q(t).forEach(a=>e.set(a.key,a.value));let n=[...e].filter(([,a])=>a!=="").map(([a,s])=>({key:a,value:s}));return this._queue(async()=>this._commit(await this._mutate("cartAttributesUpdate","$attributes: [AttributeInput!]!","attributes: $attributes",{attributes:n},{attributes:n}),"attributes"))},setDiscountCodes(t){let e=(Array.isArray(t)?t:[t]).map(n=>String(n).trim()).filter(Boolean);return this._queue(async()=>this._commit(await this._mutate("cartDiscountCodesUpdate","$discountCodes: [String!]!","discountCodes: $discountCodes",{discountCodes:e},{discountCodes:e}),"discount"))},async applyDiscount(t){let e=(this.state?.discountCodes||[]).map(s=>s.code),n=await this.setDiscountCodes([...new Set([...e,t])]);if((n?.discountCodes||[]).find(s=>s.code.toLowerCase()===String(t).toLowerCase())?.applicable)return n;throw await this.removeDiscount(t).catch(()=>{}),new v(`Discount code not valid: ${t}`,{code:"INVALID_DISCOUNT"})},removeDiscount(t){let e=String(t).toLowerCase();return this.setDiscountCodes((this.state?.discountCodes||[]).map(n=>n.code).filter(n=>n.toLowerCase()!==e))},setBuyerIdentity(t,{create:e=!0}={}){return this._queue(async()=>{let n=await this._mutate("cartBuyerIdentityUpdate","$buyerIdentity: CartBuyerIdentityInput!","buyerIdentity: $buyerIdentity",{buyerIdentity:t},e?{buyerIdentity:t}:null).catch(a=>{if(e||!T(a))throw a;return this._setId(null),null});return this._commit(n,"buyer-identity")})},async checkout(t=c.checkoutTarget){let e=this.id();if(!e||this.state&&!this.count)return null;let n=t==="_blank"?window.open("","_blank"):null;if(n)try{n.opener=null}catch{}try{let a=await $("query TetherCheckout($id: ID!) { cart(id: $id) { checkoutUrl } }",{id:e}),s=this.beforeCheckout&&await this.beforeCheckout().catch(()=>null)||a.cart?.checkoutUrl;if(s&&this.customerAccessToken&&(s+=`${s.includes("?")?"&":"?"}logged_in=true`),!s)throw new v("No checkoutUrl (cart empty or expired)");return h("checkout",{url:s,cart:this.state}),n&&!n.closed?n.location.href=s:window.location.href=s,s}catch(a){return n&&n.close(),A(a,"checkout failed"),null}},drawers(){return l(document,u("cart-drawer"))},_open:!1,isOpen(){let t=this.drawers();return t.length?t.some(e=>e.classList.contains(c.cartDrawerOpenClass)):this._open},open(){if(this.isOpen())return;this._open=!0;let t=this.drawers().filter(e=>g(e,"cart-drawer")!=="manual");t.forEach(e=>{e.inert=!1,e.classList.add(c.cartDrawerOpenClass),e.setAttribute("aria-hidden","false")}),x(!0),c.cartFocus!==!1&&t[0]&&(k=document.activeElement,setTimeout(()=>{let e=W(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),h("cart-toggled",{open:!0})},close(){if(!this.isOpen())return;this._open=!1;let t=this.drawers(),e=t.some(n=>n.contains(document.activeElement));t.forEach(n=>{n.classList.remove(c.cartDrawerOpenClass),n.setAttribute("aria-hidden","true"),c.cartFocus!==!1&&(n.inert=!0)}),x(!1),e&&k?.isConnected&&k.focus({preventScroll:!0}),k=null,typeof c.onCartClose=="function"&&c.onCartClose(t),h("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}),n=()=>e();return["cart-updated","cart-toggled"].forEach(a=>document.addEventListener(`${c.prefix}:${a}`,n)),e(),()=>["cart-updated","cart-toggled"].forEach(a=>document.removeEventListener(`${c.prefix}:${a}`,n))},render(){let t=this.state,e=t?t.totalQuantity:0,n=r=>t?b(t.cost?.[r]):"";x(this.isOpen()),l(document,u("cart-count")).forEach(r=>m(r,e)),l(document,u("cart-subtotal")).forEach(r=>m(r,n("subtotalAmount"))),l(document,u("cart-total")).forEach(r=>m(r,n("totalAmount"))),l(document,u("cart-checkout-charge")).forEach(r=>m(r,n("checkoutChargeAmount")));let a=this.lines.some(r=>r.sellingPlanAllocation),s={"cart-empty":e===0,"cart-filled":e>0,"cart-has-subscription":a,"cart-no-subscription":!a,"cart-has-discount":(t?.discountCodes||[]).some(r=>r.applicable),"cart-error":!!this.lastError,"cart-warning":this.warnings.length>0};l(document,u("cart-warning")).forEach(r=>m(r,[...new Set(this.warnings.map(o=>o.message))].join(" "))),l(document,u("show")).forEach(r=>{let o=g(r,"show");o in s&&!r.closest(u("product"))&&L(r,s[o])}),l(document,u("checkout")).forEach(r=>{r.classList.toggle("is-disabled",!e),r.setAttribute("aria-disabled",String(!e))}),l(document,`textarea${u("cart-note")},input${u("cart-note")}`).forEach(r=>{document.activeElement!==r&&(r.value=t?.note||"")}),l(document,u("cart-discounts")).forEach(r=>{K(r,t?.discountCodes||[],(o,i)=>{o.setAttribute(E("discount-code"),i.code);let d=o.querySelector(u("discount","code"))||(o.firstElementChild?null:o);d&&j(d,i.code),o.classList.toggle("is-inapplicable",!i.applicable)})}),l(document,u("cart-lines")).forEach(r=>{N(r,this.lines,o=>o.id,(o,i)=>J(o,i),{onEnter:c.onLineEnter,onLeave:c.onLineLeave})}),t&&R("cart")}};function z(t,e){let n=t.merchandise||{},a=t.sellingPlanAllocation?.sellingPlan;switch(e){case"title":return n.product?.title;case"product-title":return n.product?.title;case"variant-title":return n.title==="Default Title"?"":n.title;case"options":return(n.selectedOptions||[]).filter(s=>s.value!=="Default Title").map(s=>`${s.name}: ${s.value}`).join(", ");case"vendor":return n.product?.vendor;case"sku":return n.sku;case"price":return b(t.cost?.amountPerQuantity||n.price);case"compare-at-price":return b(t.cost?.compareAtAmountPerQuantity||n.compareAtPrice);case"line-total":return b(t.cost?.totalAmount);case"line-subtotal":return b(t.cost?.subtotalAmount);case"quantity":return D.quantityOf(t);case"plan":return a?.name||"";case"plan-description":return a?.description||"";case"components":return(t.lineComponents||[]).map(s=>`${s.quantity} \xD7 ${s.merchandise?.product?.title||""}`).join(", ");default:if(e.startsWith("attribute:")){let s=e.slice(10);return(t.attributes||[]).find(r=>r.key===s)?.value||""}return}}function J(t,e){let n=e.merchandise||{},a=!!e.sellingPlanAllocation;t.setAttribute(E("line-id"),e.id),t.classList.toggle("is-subscription",a),l(t,u("line")).forEach(i=>{let d=g(i,"line");if(d==="image")return M(i,n.image?.url||n.product?.featuredImage?.url,n.product?.title);if(d==="url"){let y=F(n.product?.handle,n.product?.id),_=new URLSearchParams;n.id&&_.set("variant",String(n.id).split("/").pop());let w=e.sellingPlanAllocation?.sellingPlan?.id;w&&_.set("selling_plan",w.split("/").pop());let C=_.toString();return i.setAttribute("href",C?`${y}${y.includes("?")?"&":"?"}${C}`:y)}let p=z(e,d);p!==void 0&&m(i,p)});let s=D.warnings.find(i=>i.target===e.id);t.classList.toggle("is-warning",!!s);let r=D.pendingQty.has(e.id);t.classList.toggle("is-busy",r),r?t.setAttribute("aria-busy","true"):t.removeAttribute("aria-busy"),l(t,u("line","warning")).forEach(i=>m(i,s?.message||""));let o={subscription:a,"one-time":!a,"on-sale":parseFloat(e.cost?.compareAtAmountPerQuantity?.amount)>parseFloat(e.cost?.amountPerQuantity?.amount),"has-components":(e.lineComponents||[]).length>0,warning:!!s};l(t,u("line-show")).forEach(i=>{let d=g(i,"line-show");d in o&&L(i,o[d])}),l(t,`select${u("line-plan")}`).forEach(i=>{let d=n.product?.handle;d&&Q(d).then(p=>{let y=B(p),w=[...!p.requiresSellingPlan&&g(i,"line-plan")!=="subscription-only"?[{value:"",label:i.getAttribute(E("one-time-label"))||"One-time purchase"}]:[],...y.map(f=>({value:f.id,label:f.name}))],C=w.map(f=>f.value).join("|");i.dataset.tetherSig!==C&&(i.innerHTML="",w.forEach(f=>{let P=document.createElement("option");P.value=f.value,P.textContent=f.label,i.appendChild(P)}),i.dataset.tetherSig=C),i.value=e.sellingPlanAllocation?.sellingPlan?.id||"",L(i,y.length>0)}).catch(p=>A(p,"line plan options"))})}export{W as a,D as b};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{D as f,n as s,o as i,p as d,t as l}from"./chunk-K2YEQAIH.js";function w(e,r=window.location,c="product"){let t=(d(e,c)||"").trim();if(!t.toLowerCase().startsWith("url:"))return{key:t||null,fromUrl:!1,raw:t};let o=t.slice(4).trim(),n=null;if(o.toLowerCase()==="path"){let a=r.pathname.split("/").filter(Boolean);n=a.length?p(a[a.length-1]):null}else n=new URLSearchParams(r.search).get(o||"handle");return n=n&&n.trim()?n.trim():null,{key:n,fromUrl:!0,raw:t}}function p(e){try{return decodeURIComponent(e)}catch{return e}}var m=["loading","ready","error","not-found"],y=e=>e?.code==="NOT_FOUND",u=()=>["product","collection","products","recommendations"].map(e=>i(e)).join(","),b=(e,r)=>e===r||e.parentElement?.closest(u())===r;function x(e,r,c){let t=r==="not-found";e.setAttribute(s("state"),t?"error":r),r==="error"||t?e.setAttribute(s("error"),t?"not-found":c?.code||"error"):e.removeAttribute(s("error")),l(e,i("show"),u()).forEach(o=>{let n=d(o,"show");m.includes(n)&&f(o,n===r)}),(r==="error"||t)&&l(e,i("add-to-cart"),u()).forEach(o=>{o.classList.add("is-disabled"),o.setAttribute("aria-disabled","true"),"disabled"in o&&(o.disabled=!0)})}export{w as a,m as b,y as c,u as d,b as e,x as f};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var d=Object.defineProperty;var e=(c,a)=>{for(var b in a)d(c,b,{get:a[b],enumerable:!0})};export{e as a};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as E,b as K,c as z}from"./chunk-ZIUIWEON.js";import{a as g,c as w,f as p}from"./chunk-RREHGH4A.js";import{c as I,e as A,f as F,g as O,h as R,i as U}from"./chunk-FIOZPPC5.js";import{A as q,B as L,D as x,G as D,I as M,K as J,b as h,e as T,f as b,g as m,h as C,n as l,o as a,p as c,q as S,s as N,t as W,u as f}from"./chunk-K2YEQAIH.js";var P=()=>`${a("collection")},${a("products")},${a("recommendations")}`,B=class{constructor(e){this.root=e,this.products=[],this.pageInfo=null,this.collection=null,p(e,"loading"),e.addEventListener("click",n=>{let o=n.target.closest?.(a("load-more"));o&&o.closest(P())===e&&(n.preventDefault(),J(o,()=>this.load(!0)))})}$(e){return W(this.root,e,P())}options(){let e=this.root,n={first:parseInt(c(e,"limit")||"",10)||void 0,sortKey:c(e,"sort")||void 0,reverse:c(e,"reverse")==="true"};if(S(e,"collection"))n.collection=c(e,"collection");else{let o=c(e,"products")||"";n.query=o.startsWith("url:")?new URL(window.location.href).searchParams.get(o.slice(4))||"":o}return n}async load(e=!1){let n=this.loadToken=(this.loadToken||0)+1,o=()=>n!==this.loadToken;try{if(S(this.root,"recommendations")){let{key:r}=g(this.root,window.location,"recommendations"),s=this.root.closest(a("product"));if(!r&&s&&({key:r}=g(s)),!r)throw new C("No product for recommendations",{code:"NOT_FOUND"});let u=await U(r,c(this.root,"intent")||"RELATED");if(o())return;let i=parseInt(c(this.root,"limit")||"",10);this.products=i?u.slice(0,i):u}else{let r=await R({...this.options(),after:e?this.pageInfo?.endCursor:null});if(o())return;this.collection=r.collection,this.pageInfo=r.pageInfo,this.products=e?[...this.products,...r.products]:r.products}this.render(),p(this.root,"ready"),f("list-ready",{products:this.products,collection:this.collection},this.root)}catch(r){if(o())return;e||p(this.root,w(r)?"not-found":"error",r),w(r)&&S(this.root,"recommendations")||m(r,"list load failed"),f("error",{error:r,context:"list"},this.root)}}render(){let e=this.collection;this.$(a("collection-bind")).forEach(o=>{switch(c(o,"collection-bind")){case"title":return L(o,e?.title||"");case"description":o.innerHTML=e?.descriptionHtml||"";return;case"image":return q(o,e?.image?.url,e?.image?.altText||e?.title);case"count":return L(o,this.products.length);default:return}}),this.$(a("list")).forEach(o=>{D(o,this.products,(r,s)=>{r.setAttribute(l("product"),s.handle),r.removeAttribute(l("state"))}),f("list-rendered",{container:o},this.root)});let n=this.products.length===0;this.$(a("show")).forEach(o=>{let r=c(o,"show");r==="list-empty"&&x(o,n),r==="list-filled"&&x(o,!n)}),this.$(a("load-more")).forEach(o=>x(o,!!this.pageInfo?.hasNextPage)),M("list")}};var v=new WeakSet,ft=new WeakSet,k=new Set,H=new Set,j=new WeakMap;function _(){k.forEach(t=>{t.isConnected||k.delete(t)}),H.forEach(t=>{t.root.isConnected||H.delete(t)})}function pt(t,e){return[...t.matches?.(e)?[t]:[],...N(t,e)]}function G(t){if(v.has(t))return!1;let{key:e,fromUrl:n,raw:o}=g(t);if(!e)return n?(v.add(t),p(t,"not-found"),f("product-not-found",{key:null,source:o},t)):t.closest(P())||b(`[${l("product")}] without a value. Bind it to the Shopify handle field, or use "url:handle".`,t),!1;v.add(t),k.add(t);let r={};j.set(t,r);let s=()=>j.get(t)===r;E.get(t)?t.setAttribute(l("state"),"updating"):p(t,"loading");let u=I(e);return d?.add(u),u.then(i=>{if(!s())return;let y=E.get(t);y?y.update(i):new z(t,i),V(t,i),h.revalidate!==!1&&F(e)&&X(e)}).catch(i=>{if(!s())return;let y=w(i);p(t,y?"not-found":"error",i),y?(f("product-not-found",{key:e,source:o},t),n?T(`product not found: ${e}`):m(i,`product ${e}`)):(m(i,`product ${e}`),f("error",{error:i,context:"product",key:e},t))}),!0}function V(t,e){let n=c(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 ht(){_(),k.forEach(t=>{t.getAttribute(l("state"))!=="error"||t.getAttribute(l("error"))==="not-found"||(v.delete(t),G(t))})}var $=new Set;function X(t){$.size||setTimeout(Y,0),$.add(t)}function Y(){let t=[...$];$=new Set,O(t).forEach((e,n)=>e.then(o=>{k.forEach(r=>{let s=E.get(r);if(!s||!r.isConnected)return;let u=g(r).key;u!==t[n]&&u!==o.handle&&u!==o.id||JSON.stringify(s.product)!==JSON.stringify(o)&&s.update(o)})}).catch(o=>m(o,`refresh ${t[n]}`)))}var Q=new WeakSet,d=null,mt=t=>(d?.add(t),t);function Z(){if(!d)return;let t=[...d];Promise.allSettled(t).then(()=>{!d||t.some(e=>!d.has(e))||(t.length===d.size?(d=null,document.documentElement.classList.remove(`${h.prefix}-market-pending`)):Z())})}function gt(t=document){N(t.ownerDocument||t,'script[type="application/json"][data-tether-hydrate]').forEach(e=>{if(!Q.has(e)){Q.add(e);try{let n=JSON.parse(e.textContent);K(n.products);let o=(r,s)=>String(r||"").toUpperCase()===String(s||"").toUpperCase();o(n.country,h.country)&&o(n.language,h.language)?A(n.products):(T("hydration skipped: other market"),d||(d=new Set,document.documentElement.classList.add(`${h.prefix}-market-pending`)))}catch(n){b("bad data-tether-hydrate",n)}}})}export{P as a,B as b,v as c,ft as d,k as e,H as f,_ as g,pt as h,G as i,ht as j,mt as k,Z as l,gt as m};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var t={diagnose:()=>import("./diagnose-VXQBSD3A.js"),markets:()=>import("./markets-ui-F3R5T5EL.js"),search:()=>import("./search-NILMGYXG.js"),extras:()=>import("./extras-R4X34VQL.js"),account:()=>import("./account-QUBHQG3C.js"),"account-pages":()=>import("./account-pages-VWDHF6WA.js"),analytics:()=>import("./analytics-SLATWPLC.js")},r=o=>t[o](),a=void 0;export{r as a,a as b};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as rt,e as ot}from"./chunk-RREHGH4A.js";import{b as nt}from"./chunk-L2TRRKYV.js";import{d as V,e as F,f as S,g as N,h as W,i as M,j as Y,k as E}from"./chunk-AJLPU2JC.js";import{A as I,B as d,D as q,E as k,F as tt,G as A,I as D,J as et,K as it,L as st,M as at,b as T,g as G,n as g,o as l,p as c,q as P,r as J,s as B,t as K,u as x,v as z,w as $,x as X,z as Z}from"./chunk-K2YEQAIH.js";var pt=new WeakMap,lt=()=>l("product");function mt(w,i){let t=i.indexOf("."),e=i.slice(0,t),s=i.slice(t+1);return(w.metafields||[]).find(a=>a&&a.namespace===e&&a.key===s)||null}var C=new Map;function ft(w){(w||[]).forEach(i=>{i?.handle&&!C.has(i.handle)&&C.set(i.handle,(i.options||[]).map(t=>t.name))})}var ct=class{constructor(i,t){this.root=i,this.product=t,this.selected={},this.variant=null,this.quantity=Math.max(0,parseInt(c(i,"quantity")??"1",10)||(P(i,"quantity")?0:1)),this.plans=F(t),this.purchase="one-time",this.planId=null,pt.set(i,this),i.setAttribute(g("state"),"ready"),i.removeAttribute(g("error")),this.initSelection(),this.initPurchase(),this.renderProduct(),this.bind(),this.renderVariant(),et(i,"product"),D("product"),x("product-ready",{product:t,scope:this},i)}update(i){let t=this.variant?.id;this.product=i,this.plans=F(i),this.planId&&!this.plans.some(s=>s.id===this.planId)&&(this.planId=this.plans[0]?.id||null),!this.plans.length&&this.purchase==="subscription"&&(this.purchase="one-time");let e=i.variants.nodes.find(s=>s.id===t);e&&(this.selected={},e.selectedOptions.forEach(s=>{this.selected[s.name]=s.value})),this.root.setAttribute(g("state"),"ready"),this.root.removeAttribute(g("error")),this.renderProduct(),this.renderVariant(),D("product"),x("product-updated",{product:i,scope:this},this.root)}$(i){let t=K(this.root,i,lt());return this.root.matches(i)?[this.root,...t]:t}optName(i){let t=this.product?.options||[];if(!i||t.some(s=>s.name===i))return i;let e=(C.get(this.product.handle)||[]).indexOf(i);return e>=0&&t[e]?t[e].name:i}initSelection(){let i=this.product.variants.nodes,t=i.find(s=>s.availableForSale)||i[0];t&&t.selectedOptions.forEach(s=>{this.selected[s.name]=s.value});let e=new URLSearchParams(window.location.search).get("variant")||c(this.root,"variant");if(e){let s=V.variant(e),o=i.find(a=>a.id===s);o&&(this.selected={},o.selectedOptions.forEach(a=>{this.selected[a.name]=a.value}))}}initPurchase(){if(!this.plans.length)return;let i=new URLSearchParams(window.location.search),t=E(this.product,i.get("selling_plan")),e=E(this.product,c(this.root,"default-plan"));this.planId=(t||e||this.plans[0]).id;let s=t?"subscription":c(this.root,"default-purchase")||T.defaultPurchase;this.purchase=this.product.requiresSellingPlan||s==="subscription"?"subscription":"one-time"}findVariant(){return this.product.variants.nodes.find(i=>i.selectedOptions.every(t=>this.selected[t.name]===t.value))||null}isValueAvailable(i,t){return this.product.variants.nodes.some(e=>e.availableForSale&&e.selectedOptions.every(s=>s.name===i?s.value===t:this.selected[s.name]===s.value))}get plan(){return this.plans.find(i=>i.id===this.planId)||null}get subscriptionAvailable(){return!!(this.variant&&this.plans.some(i=>S(this.variant,i.id)))}get isSubscription(){return this.purchase==="subscription"&&!!S(this.variant,this.planId)}getLine(){if(!this.variant)return null;let i={merchandiseId:this.variant.id,quantity:this.quantity};this.isSubscription&&(i.sellingPlanId=this.planId);let t=this.collectAttributes();return t.length&&(i.attributes=t),i}collectAttributes(){let i=at(st(this.root,"line-attributes")),t=this.$(l("line-attribute")).map(e=>{let s=c(e,"line-attribute"),o;return e.type==="checkbox"?o=e.checked?e.value&&e.value!=="on"?e.value:"Yes":"":e.type==="radio"?o=e.checked?e.value:null:o=e.value,o==null||o===""?null:{key:s,value:String(o)}}).filter(Boolean);return[...i,...t]}select(i,t){if(this.selected[i]===t)return;let e=this.product.variants.nodes.filter(o=>o.selectedOptions.some(a=>a.name===i&&a.value===t));if(!e.length)return;let s={...this.selected,[i]:t};if(!e.some(o=>o.selectedOptions.every(a=>s[a.name]===a.value))){let o=r=>r.selectedOptions.filter(u=>u.name!==i&&this.selected[u.name]===u.value).length*2+(r.availableForSale?1:0);e.reduce((r,u)=>o(u)>o(r)?u:r).selectedOptions.forEach(r=>{s[r.name]=r.value})}this.selected=s,this.renderVariant()}selectVariant(i){let t=this.product.variants.nodes.find(e=>e.id===V.variant(i));t&&(this.selected={},t.selectedOptions.forEach(e=>{this.selected[e.name]=e.value}),this.renderVariant())}setPurchase(i){let t=i==="subscription"?"subscription":"one-time";t==="one-time"&&this.product.requiresSellingPlan||this.purchase!==t&&(this.purchase=t,this.renderVariant())}selectPlan(i){let t=E(this.product,i);t&&(this.planId=t.id,this.purchase="subscription",this.renderVariant())}setQuantity(i){let t=P(this.root,"quantity")?0:1;this.quantity=Math.max(t,parseInt(i,10)||0),this.$(l("qty")).forEach(e=>d(e,this.quantity)),this.renderVariant()}async addToCart(){if(!this.variant?.availableForSale)return null;let i=this.getLine();if(!i||i.quantity<1)return null;let t=await nt.add(i);return x("product-added",{product:this.product,variant:this.variant,line:i},this.root),t}bind(){let i=t=>t&&t.closest(lt())===this.root;this.root.addEventListener("click",t=>{let e=t.target;if(!e?.closest)return;let s=e.closest(l("option-value"));if(i(s)&&s.closest(l("option-list"))){t.preventDefault(),this.select(this.optName(c(s.closest(l("option-list")),"option-list")),c(s,"option-value"));return}let o=e.closest(l("plan-value"));if(i(o)){t.preventDefault(),this.selectPlan(c(o,"plan-value"));return}let a=e.closest(`${l("purchase")}:not(select)`);if(i(a)){a.tagName!=="INPUT"&&t.preventDefault(),this.setPurchase(c(a,"purchase"));return}let r=e.closest(l("qty-plus"));if(i(r)){t.preventDefault(),this.setQuantity(this.quantity+1);return}let u=e.closest(l("qty-minus"));if(i(u)){t.preventDefault(),this.setQuantity(this.quantity-1);return}let v=e.closest(l("add-to-cart"));i(v)&&(t.preventDefault(),this.onAddClick(v))}),this.root.addEventListener("change",t=>{let e=t.target;i(e)&&(e.matches(`select${l("option")}`)?this.select(this.optName(c(e,"option")),e.value):e.matches(`select${l("variant-select")}`)?this.selectVariant(e.value):e.matches(`select${l("plan")}`)?e.value?this.selectPlan(e.value):this.setPurchase("one-time"):e.matches(`select${l("purchase")}`)?this.setPurchase(e.value):e.matches(l("qty"))&&this.setQuantity(e.value))})}onAddClick(i){let t=i.querySelector(l("add-label"))||i,e=c(i,"adding-text"),s=o=>d(t,o);t.dataset.tetherLabel===void 0&&(t.dataset.tetherLabel=t.tagName==="INPUT"?t.value:t.textContent),it(i,async()=>{e&&s(e);try{await this.addToCart()}catch(o){G(o,"add to cart failed"),x("error",{error:o,context:"add-to-cart"},this.root)}finally{e&&s(t.dataset.tetherLabel)}}).then(()=>{this.renderVariant()})}renderProduct(){let i=this.product;C.has(i.handle)||this.$(`${l("option-list")},select${l("option")}`).map(s=>c(s,"option-list")||c(s,"option")).some(s=>i.options.some(o=>o.name===s))&&ft([i]);let t=this.product;this.$(l("bind")).forEach(e=>{let s=c(e,"bind")||"",o={title:t.title,"description-text":t.description,vendor:t.vendor,type:t.productType,handle:t.handle}[s];if(o!==void 0)return d(e,o);switch(s){case"description":e.innerHTML=t.descriptionHtml||"";return;case"published-at":return d(e,X(t.publishedAt));case"min-price":return d(e,$(t.priceRange.minVariantPrice));case"max-price":return d(e,$(t.priceRange.maxVariantPrice));case"featured-image":return I(e,t.featuredImage?.url,t.featuredImage?.altText||t.title);case"url":case"link":e.setAttribute("href",J(t.handle,t.id)),s==="url"&&!e.firstElementChild&&!e.textContent.trim()&&d(e,t.title);return;case"images":{let a=[...e.children].map(r=>r.tagName==="IMG"?r:r.querySelector("img"));if(!tt(e)&&a.length===t.images.nodes.length&&a.every((r,u)=>Z(r?.getAttribute("src"),t.images.nodes[u].url)))return}return A(e,t.images.nodes,(a,r)=>{let u=a.matches(`img,${l("bind","image")}`)?a:a.querySelector("img")||a;I(u,r.url,r.altText||t.title)});case"tags":{let a=(e.getAttribute("exclude")||"").split(",").map(r=>r.trim()).filter(Boolean);return A(e,t.tags.filter(r=>!a.includes(r)),(r,u)=>d(r,u))}default:if(/^image:\d+$/.test(s)){let a=t.images.nodes[s.slice(6)-1]||t.featuredImage;return I(e,a?.url,a?.altText||t.title)}if(s.startsWith("metafield:")){let a=mt(t,s.slice(10));return a?a.reference?.image?I(e,a.reference.image.url,a.reference.image.altText):(/^(rich_text|multi_line_text)_field$/.test(a.type)&&(e.style.whiteSpace="pre-line"),d(e,a.value)):d(e,"")}return}}),this.$(l("option-list")).forEach(e=>{let s=this.optName(c(e,"option-list")),o=t.options.find(a=>a.name===s);return!o||o.optionValues.length<=1&&P(e,"hide-single")?q(e,!1):A(e,o.optionValues,(a,r)=>{a.setAttribute(g("option-value"),r.name);let u=a.querySelector(l("bind","option-value"));u?d(u,r.name):a.firstElementChild||d(a,r.name);let v=a.querySelector(l("bind","swatch"));v&&r.swatch?.color&&(v.style.backgroundColor=r.swatch.color),v&&r.swatch?.image?.previewImage&&I(v,r.swatch.image.previewImage.url,r.name)})}),this.$(`select${l("option")}`).forEach(e=>{let s=t.options.find(o=>o.name===this.optName(c(e,"option")));if(!s)return q(e,!1);e.innerHTML="",s.optionValues.forEach(o=>e.appendChild(new Option(o.name,o.name)))}),this.$(`select${l("variant-select")}`).forEach(e=>{e.innerHTML="",t.variants.nodes.forEach(s=>e.appendChild(new Option(s.title,s.id)))}),this.$(l("plan-list")).forEach(e=>{let s=(c(e,"plan-list")||"").trim(),o=["","true","all","*"].includes(s.toLowerCase())?null:s,a=this.plans.filter(r=>!o||r.group.name===o);A(e,a,(r,u)=>{r.setAttribute(g("plan-value"),u.id),!r.firstElementChild&&!r.querySelector(l("plan-bind"))&&d(r,u.name)})}),this.$(`select${l("plan")}`).forEach(e=>{e.innerHTML="",!t.requiresSellingPlan&&c(e,"plan")!=="subscription-only"&&e.appendChild(new Option(e.getAttribute(g("one-time-label"))||"One-time purchase","")),this.plans.forEach(s=>e.appendChild(new Option(s.name,s.id)))})}renderVariant(){let i=this.product,t=this.findVariant();if(t||([t]=i.variants.nodes,t&&(this.selected={},t.selectedOptions.forEach(n=>{this.selected[n.name]=n.value}))),this.variant=t,!t)return;if(this.plans.length&&!S(t,this.planId)){let n=this.plans.find(h=>S(t,h.id));n&&(this.planId=n.id)}let e=this.isSubscription,s=t.price,o=this.planId?N(t,this.planId):null,a=e?o:s,r=e&&S(t,this.planId)?.priceAdjustments?.[0]?.compareAtPrice||t.compareAtPrice,u=r&&parseFloat(r.amount)>parseFloat(a.amount),v=u?Math.round((1-parseFloat(a.amount)/parseFloat(r.amount))*100):0,L=this.planId?M(t,this.planId):{amount:null,percentage:0},O=this.plan,ut={amount:(parseFloat(a.amount)*Math.max(1,this.quantity)).toFixed(2),currencyCode:a.currencyCode},f=$,U=n=>z(n),j={price:()=>f(a),"total-price":()=>f(ut),"one-time-price":()=>f(s),"subscription-price":()=>f(o),"subscription-savings":()=>U(L.percentage),"subscription-savings-amount":()=>f(L.amount),"checkout-charge":()=>{let n=e?W(t,this.planId):a;return n&&f({amount:(parseFloat(n.amount)*Math.max(1,this.quantity)).toFixed(2),currencyCode:n.currencyCode})},"plan-name":()=>O?.name,"plan-description":()=>O?.description,"plan-group":()=>O?.group?.name,"compare-at-price":()=>u?f(r):"","unit-price":()=>f(t.unitPrice),"discount-percentage":()=>`${v}%`,"discount-amount":()=>u?f({amount:String(parseFloat(r.amount)-parseFloat(a.amount)),currencyCode:a.currencyCode}):"","variant-title":()=>t.title,"variant-id":()=>t.id,sku:()=>t.sku,barcode:()=>t.barcode,stock:()=>t.quantityAvailable,quantity:()=>this.quantity};this.$(l("bind")).forEach(n=>{let h=c(n,"bind");h==="variant-image"?I(n,t.image?.url||i.featuredImage?.url,t.image?.altText||i.title):j[h]&&d(n,j[h]())}),this.$(l("option-selected")).forEach(n=>d(n,this.selected[this.optName(c(n,"option-selected"))]||"")),this.$(l("option-list")).forEach(n=>{let h=this.optName(c(n,"option-list"));B(n,l("option-value")).forEach(p=>{let b=c(p,"option-value");k(p,this.selected[h]===b);let m=!this.isValueAvailable(h,b);p.classList.toggle("is-unavailable",m),p.setAttribute("data-unavailable",m?"true":"false")})}),this.$(`select${l("option")}`).forEach(n=>{n.value=this.selected[this.optName(c(n,"option"))]||""}),this.$(`select${l("variant-select")}`).forEach(n=>{n.value=t.id}),this.$(l("purchase")).forEach(n=>{if(n.tagName==="SELECT"){n.value=this.purchase;return}let h=c(n,"purchase");k(n,h===this.purchase);let p=h==="subscription"?!this.subscriptionAvailable:i.requiresSellingPlan;n.classList.toggle("is-unavailable",p)}),this.$(l("plan-value")).forEach(n=>{let h=c(n,"plan-value"),p=this.plans.find(m=>m.id===h),b=!!S(t,h);k(n,e&&h===this.planId),n.classList.toggle("is-unavailable",!b),B(n,l("plan-bind")).forEach(m=>{let y=Y(p),Q=M(t,h),ht=c(m,"plan-bind"),R={name:()=>p?.name,option:()=>(p?.options||[]).map(dt=>dt.value).join(", "),description:()=>p?.description,price:()=>f(N(t,h)),savings:()=>U(Q.percentage),"savings-amount":()=>f(Q.amount),adjustment:()=>y?y.type==="percentage"?`${y.value}%`:f(y.value):""}[ht];R&&d(m,R())})}),this.$(`select${l("plan")}`).forEach(n=>{n.value=e?this.planId:""});let _=t.quantityAvailable!=null&&t.quantityAvailable>0&&t.quantityAvailable<=(T.lowStock??5),H={"in-stock":t.availableForSale,"out-of-stock":!t.availableForSale,backorder:t.availableForSale&&t.currentlyNotInStock,"on-sale":!!u,"not-on-sale":!u,"has-variants":i.variants.nodes.length>1,"single-variant":i.variants.nodes.length===1,"low-stock":_,"plenty-in-stock":t.availableForSale&&!_,"subscription-available":this.subscriptionAvailable,"subscription-unavailable":!this.subscriptionAvailable,"subscription-only":!!i.requiresSellingPlan,"one-time-available":!i.requiresSellingPlan,"subscription-selected":e,"one-time-selected":!e,"has-savings":e?L.percentage>0:!!u,loading:!1,ready:!0,error:!1,"not-found":!1};this.$(l("show")).forEach(n=>{let h=c(n,"show");h in H&&(rt.includes(h)&&!ot(n,this.root)||q(n,H[h]))}),this.root.classList.toggle("is-subscription",e),this.root.setAttribute(g("purchase-mode"),e?"subscription":"one-time"),this.$(l("add-to-cart")).forEach(n=>{let h=!t.availableForSale;n.classList.toggle("is-disabled",h),n.setAttribute("aria-disabled",String(h)),"disabled"in n&&(n.disabled=h);let p=c(n,"soldout-text"),b=c(n,"subscribe-text");if(p||b){let m=n.querySelector(l("add-label"))||n;m.dataset.tetherLabel===void 0&&(m.dataset.tetherLabel=m.tagName==="INPUT"?m.value:m.textContent);let y=m.dataset.tetherLabel;e&&b&&(y=b),h&&p&&(y=p),n.getAttribute("aria-busy")!=="true"&&d(m,y)}}),x("variant-changed",{product:i,variant:t,selected:{...this.selected},purchase:this.purchase,sellingPlanId:e?this.planId:null},this.root)}};export{pt as a,ft as b,ct as c};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import{c as D}from"./chunk-64TUD3QR.js";import{a as y,d as M}from"./chunk-RREHGH4A.js";import{c as P}from"./chunk-FIOZPPC5.js";import{e as V}from"./chunk-AJLPU2JC.js";import{F as q,b as i,d as S,i as E,l as x,n as h,o as c,p as g,s as d}from"./chunk-K2YEQAIH.js";import"./chunk-VC46IEJQ.js";var I=e=>{let n=/^(\d{4})-(01|04|07|10)$/.exec(String(e||""));return n?{y:+n[1],m:+n[2]}:null},B=(e,n)=>`${e}-${String(n).padStart(2,"0")}`;function A(e,n=1){let o=I(e);if(!o)throw new Error(`not a quarterly Shopify API version: ${e}`);let a=o.y*4+(o.m-1)/3+n;return B(Math.floor(a/4),a%4*3+1)}function T(e,n=new Date){if(e==="unstable")return{version:e,ok:!1,note:'"unstable" changes without notice: pin a dated version such as 2026-07'};let o=I(e);if(!o)return{version:e,ok:!1,note:"not a quarterly version (YYYY-01, -04, -07 or -10)"};let a=new Date(Date.UTC(o.y,o.m-1,1)),r=new Date(Date.UTC(o.y+1,o.m-1,1)),f=(r-n)/(30.44*24*3600*1e3),l=`supported until about ${r.toISOString().slice(0,7)}`;return a>n?l="not released yet (release candidate at best)":f<=0?l="no longer supported: Shopify falls back to the oldest supported version. Upgrade (see README)":f<3&&(l=`${l}: plan the upgrade to ${A(e)} or later (see README)`),{version:e,ok:a<=n&&f>0,monthsLeft:Math.round(f),next:A(e),note:l}}var C=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","subscriptions-loading","subscriptions-empty"]),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"]),U=new Set(`account account-bind account-link account-login account-logout add-label add-to-cart adding-text
|
|
2
|
-
always-enabled bind cart-checkout-charge cart-clear cart-close cart-count cart-discounts cart-drawer cart-label cart-lines
|
|
3
|
-
cart-note cart-open cart-subtotal cart-total cart-warning checkout code collection collection-bind countries country
|
|
4
|
-
country-bind country-label country-select default-plan default-purchase discount discount-code discount-form discount-input
|
|
5
|
-
discount-remove display error group group-add hide-single language limit line line-attribute line-attributes line-id
|
|
6
|
-
line-minus line-plan line-plus line-remove line-show list load-more market-pending one-time-label option option-list
|
|
7
|
-
option-selected option-value order order-bind order-line order-lines order-line-show order-show order-state order-fulfillments
|
|
8
|
-
fulfillment-bind order-return return-quantity return-reason return-note orders profile-form address-form addresses address-bind
|
|
9
|
-
address-show address-edit address-new address-delete address-default subscriptions subscription-bind subscription-lines
|
|
10
|
-
subscription-line subscription-show subscription-action subscription-status subscription-state confirm form-state form-error page-country page-language page-locale page-title plan plan-bind plan-list
|
|
11
|
-
plan-value product products purchase purchase-mode qty qty-minus qty-plus quantity recommendations reverse search
|
|
12
|
-
search-bind search-collections search-input search-limit search-min search-products search-queries search-results
|
|
13
|
-
search-state show soldout-text sort state subscribe-text variant variant-select variant-url max-width max-height crop
|
|
14
|
-
sig label hydrated busy`.split(/\s+/).filter(Boolean));function O(e,n){let o=Array.from({length:e.length+1},(a,r)=>[r,...Array(n.length).fill(0)]);for(let a=1;a<=n.length;a++)o[0][a]=a;for(let a=1;a<=e.length;a++)for(let r=1;r<=n.length;r++)o[a][r]=Math.min(o[a-1][r]+1,o[a][r-1]+1,o[a-1][r-1]+(e[a-1]===n[r-1]?0:1));return o[e.length][n.length]}function $(e,n,o=""){let a=null,r=1/0;for(let f of n){let l=O(String(e),f);l<r&&(r=l,a=f)}return a&&r<=Math.max(2,Math.floor(String(e).length/4))?` Did you mean "${o}${a}"?`:""}var L=e=>e?`${String(e).slice(0,4)}\u2026${String(e).slice(-4)} (${String(e).length} chars)`:"(missing)";function j(e){let n=e.id?`#${e.id}`:"",o=e.className&&typeof e.className=="string"?`.${e.className.trim().split(/\s+/).slice(0,2).join(".")}`:"";return`<${e.tagName.toLowerCase()}${n}${o}>`}function R(e=document){let n=[],o=(t,s,u)=>n.push({level:t,message:s,element:u?j(u):void 0,el:u}),a=t=>!!t.closest(c("product")),r=`${c("collection")},${c("products")},${c("recommendations")}`;d(e,c("product")).forEach(t=>{if(t.closest(r)&&t.closest(c("list")))return;let{key:s,fromUrl:u,raw:b}=y(t);b?u&&!s&&o("warn",`${h("product")}="${b}" but this URL has no value for it (e.g. ?handle=my-product).`,t):o("error",`${h("product")} has no value. Bind it to the Shopify handle (CMS field), or use "url:handle".`,t)}),["bind","option-list","option","variant-select","add-to-cart","purchase","plan-list","plan","qty","line-attribute"].forEach(t=>{d(e,c(t)).forEach(s=>{a(s)||t==="line-attribute"&&s.closest(c("group"))||o("warn",`${h(t)} outside any ${h("product")}: it does nothing here.`,s)})}),d(e,c("group-add")).forEach(t=>{t.closest(c("group"))||o("warn",`${h("group-add")} outside a ${h("group")}.`,t)}),["option-list","plan-list","cart-lines","list"].forEach(t=>d(e,c(t)).forEach(s=>{!s.firstElementChild&&!q(s)&&o("warn",`${h(t)} without a template child: put one example element inside it.`,s)})),d(e,r).forEach(t=>{d(t,c("list")).length||o("error",`List without a ${h("list")} child: products have nowhere to render.`,t)}),d(e,c("show")).forEach(t=>{let s=g(t,"show");C.has(s)||o("warn",`Unknown ${h("show")}="${s}".${$(s,C)}`,t)}),d(e,c("bind")).forEach(t=>{let s=g(t,"bind")||"";!s||N.has(s)||/^image:\d+$/.test(s)||s.startsWith("metafield:")||o("warn",`Unknown ${h("bind")}="${s}": it stays empty.${$(s,N)}`,t)});let l=`${i.prefix}-`,w=new Set;return d(e,"*").forEach(t=>{for(let s of t.attributes){if(!s.name.startsWith(l))continue;let u=s.name.slice(l.length);U.has(u)||w.has(u)||(w.add(u),o("warn",`Unknown attribute ${s.name}: Tether ignores it.${$(u,U,l)}`,t))}}),d(e,c("bind")).forEach(t=>{let s=g(t,"bind")||"";if(!s.startsWith("metafield:"))return;let u=s.slice(10);(i.metafields||[]).some(m=>(typeof m=="string"?m:`${m.namespace}.${m.key}`)===u)||o("error",`${h("bind")}="${s}" but "${u}" is not in config.metafields, so it stays empty.`,t)}),d(e,c("cart-open")).length&&!d(e,c("cart-drawer")).length&&o("warn",`${h("cart-open")} exists but there is no ${h("cart-drawer")} on this page.`),d(e,c("cart-drawer")).length>1&&o("warn",`More than one ${h("cart-drawer")}.`),d(e,`[${h("state")}="error"]`).forEach(t=>{t.matches(M())&&o("error",`Scope failed to load (${g(t,"error")||"error"}).`,t)}),n}async function X({root:e=document,silent:n=!1,version:o,now:a=new Date}={}){let r={version:o,config:{domain:i.domain||"(missing)",token:L(i.token),apiVersion:i.apiVersion,endpoint:i.domain?E():null,country:i.country,language:i.language,locale:i.locale,markets:i.markets||null,prefix:i.prefix,productPath:i.productPath,metafields:i.metafields,autoMount:i.autoMount,observe:i.observe,onError:typeof i.onError=="function"},apiVersion:T(i.apiVersion,a),market:{country:i.country||null,language:i.language||null,locale:i.locale||null,detected:i.markets?.detect?D(i.markets):null},reachable:!1,shop:null,latencyMs:null,products:[],sellingPlans:[],problems:[]};if(!S())r.problems.push({level:"error",message:"TETHER_CONFIG needs domain and token."});else{let f=Date.now();try{let l=await x("query TetherDiagnose { shop { name primaryDomain { url } paymentSettings { currencyCode } } }",{},{context:!1});r.reachable=!0,r.shop={name:l.shop?.name,url:l.shop?.primaryDomain?.url,currency:l.shop?.paymentSettings?.currencyCode}}catch(l){r.problems.push({level:"error",message:`Storefront API not reachable: ${l.message||l.code||"unknown error"}`})}if(r.latencyMs=Date.now()-f,r.reachable){let l=[...new Set(d(e,c("product")).map(t=>y(t).key).filter(Boolean))].slice(0,20);(await Promise.allSettled(l.map(t=>P(t)))).forEach((t,s)=>{if(t.status==="fulfilled"){let u=t.value,b=V(u);r.products.push({key:l[s],handle:u.handle,title:u.title,plans:b.length,requiresSellingPlan:u.requiresSellingPlan}),b.forEach(m=>r.sellingPlans.push({product:u.handle,group:m.group?.name,plan:m.name,id:m.id})),d(e,c("product")).filter(m=>y(m).key===l[s]&&m.querySelector(c("add-to-cart"))).forEach(m=>{let k=new Set(d(m,`${c("option-list")},select${c("option")}`).map(p=>g(p,"option-list")||g(p,"option")));if(!k.size&&d(m,`select${c("variant-select")}`).length)return;let v=(u.options||[]).map(p=>p.name);i.language||[...k].filter(p=>p&&!v.includes(p)).forEach(p=>{r.problems.push({level:"warn",message:`Product "${u.handle}" has no option "${p}" (its options: ${v.join(", ")||"none"}).${$(p,v)}`})}),(u.options||[]).filter(p=>p.optionValues.length>1&&!k.has(p.name)).forEach(p=>{r.problems.push({level:"warn",message:`Product "${u.handle}": option "${p.name}" (${p.optionValues.length} values) has no tether-option-list, so visitors can't choose it.`})})})}else r.products.push({key:l[s],error:t.reason?.message}),r.problems.push({level:"error",message:`Product "${l[s]}": ${t.reason?.message||t.reason?.code||"not loaded"}. Is it published to the Headless channel?`})})}}return(!r.apiVersion.ok||(r.apiVersion.monthsLeft??99)<3)&&r.problems.push({level:r.apiVersion.ok?"warn":"error",message:`apiVersion ${i.apiVersion}: ${r.apiVersion.note}`}),typeof document<"u"&&r.problems.push(...R(e)),n||Y(r),r}function Y(e){let n=console,o=e.problems.filter(a=>a.level==="error").length;n.group?.(`[${i.prefix}] diagnose: ${o?`${o} error(s)`:"no errors"}, ${e.problems.length-o} warning(s)`),n.log("version",e.version,"| API",e.apiVersion.version,`(${e.apiVersion.note})`),n.log("config",e.config),e.market&&n.log("market",`in use: ${[e.market.country,e.market.language].filter(Boolean).join(" / ")||"the store default"}`,e.market.detected?`(detection picks ${JSON.stringify(e.market.detected)})`:""),n.log(e.reachable?`Storefront API reachable: ${e.shop?.name} (${e.latencyMs} ms)`:"Storefront API NOT reachable"),e.products.length&&(n.table||n.log)(e.products),e.sellingPlans.length?(n.table||n.log)(e.sellingPlans):e.reachable&&n.log("No selling plans on the products of this page."),e.problems.forEach(a=>(a.level==="error"?n.error:n.warn)(a.message,a.el||"")),n.groupEnd?.()}export{T as apiVersionStatus,R as checkMarkup,X as diagnose,$ as didYouMean};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as b}from"./chunk-ZIUIWEON.js";import"./chunk-RREHGH4A.js";import{b as l}from"./chunk-L2TRRKYV.js";import"./chunk-FIOZPPC5.js";import"./chunk-AJLPU2JC.js";import{L as w,M as h,b as o,f as p,g,o as u,p as d,q as f,s as m,u as y}from"./chunk-K2YEQAIH.js";import"./chunk-VC46IEJQ.js";async function q(e){let t=e.closest(u("group"));if(!t)return null;let n=d(t,"group"),s=h(w(t,"line-attributes")),i=n?[{key:"_group",value:n},...s]:s,a=m(t,u("product")).map(r=>b.get(r)).filter(r=>r&&r.variant?.availableForSale&&r.quantity>0).map(r=>{let c=r.getLine();return c.attributes=[...c.attributes||[],...i],c});if(!a.length)return p("group-add: nothing selected"),null;try{let r=await l.add(a);return y("group-added",{group:n,lines:a},t),r}catch(r){return g(r,"group add"),null}}function A(e){if(e.key===o.storageKey||e.key===`${o.storageKey}:seen`)l.init();else if(e.key===`${o.prefix}:market:${o.domain}`&&e.newValue)try{let t=JSON.parse(e.newValue);t?.country&&window.Tether?.setCountry(t.country,{language:t.language??null,locale:t.locale,remember:!1}).catch(()=>{})}catch{}}var k=new WeakMap;function K(e,{variant:t,sellingPlanId:n}){let s=`${t.id}|${n||""}`,i=k.get(e);if(k.set(e,s),!(!i||i===s)&&!(!f(e,"variant-url")&&!(o.variantUrl&&document.querySelector(u("product"))===e)))try{let a=new URL(window.location.href);a.searchParams.set("variant",t.id.split("/").pop()),n?a.searchParams.set("selling_plan",n.split("/").pop()):a.searchParams.delete("selling_plan"),window.history.replaceState(window.history.state,"",a)}catch{}}export{q as addGroup,A as onStorage,K as writeVariantUrl};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as k,c as U,e as z,f as B,g as M,h as L,i as N}from"./chunk-VCPI7MJ2.js";import{a as C,b,c as T,d as A,e as I,f as v}from"./chunk-64TUD3QR.js";import"./chunk-ZIUIWEON.js";import"./chunk-RREHGH4A.js";import{b as d}from"./chunk-L2TRRKYV.js";import{d as E}from"./chunk-FIOZPPC5.js";import"./chunk-AJLPU2JC.js";import{b as t,g as p,h as w,n as g,o as h,p as P,u as x}from"./chunk-K2YEQAIH.js";import"./chunk-VC46IEJQ.js";function O(s=document){let u=L(s,`select${h("country-select")}`),m=L(s,h("country-bind"));return!u.length&&!m.length?Promise.resolve():v().then(l=>{let r=(t.country||l.country?.isoCode||"").toUpperCase(),c=[...l.availableCountries||[]].sort((e,o)=>e.name.localeCompare(o.name,t.locale||void 0)),i=c.find(e=>e.isoCode===r)||l.country,f=(e,o)=>e.replace(/\{name\}/g,o.name).replace(/\{code\}/g,o.isoCode).replace(/\{currency\}/g,o.currency?.isoCode||"").replace(/\{symbol\}/g,o.currency?.symbol||"");u.forEach(e=>{let o=e.getAttribute(g("country-label"))||"{name} ({currency})",a=(e.getAttribute(g("countries"))||"").toUpperCase().split(/[\s,]+/).filter(Boolean),n=a.length?a.map(y=>c.find(S=>S.isoCode===y)).filter(Boolean):c;e.innerHTML="",n.forEach(y=>e.appendChild(new Option(f(o,y),y.isoCode))),e.value=r,e.value!==r&&(e.selectedIndex=-1),e.disabled=n.length<2&&!e.hasAttribute(g("always-enabled"))}),m.forEach(e=>{let o=P(e,"country-bind")||"name",a={name:i?.name,code:i?.isoCode,currency:i?.currency?.isoCode,symbol:i?.currency?.symbol}[o];e.textContent=a||""})}).catch(l=>p(l,"country select"))}async function q(s,{language:u,locale:m,remember:l=!0}={}){let r=C(s);if(!r)throw new w(`Not a country code: ${s}`,{code:"INVALID_COUNTRY"});let c=Object.values(t.markets?.locales||{}).find(n=>C(n?.country)===r),i=m||c?.locale,f=i||t.locale,e=u!==void 0?b(u):c?c.language?b(c.language):void 0:t.language,o=r!==String(t.country||"").toUpperCase()||e!==t.language||f!==t.locale;if(t.country=r,t.language=e||void 0,t.locale=f,l&&A({country:r,language:e,locale:i}),!o)return O(),d.state;E();let a=[];return u!==void 0&&I(),d.id()&&a.push(d.setBuyerIdentity({countryCode:r},{create:!1}).catch(n=>p(n,"cart country"))),M(),B.forEach(n=>a.push(n.load())),z.forEach(n=>{n.closest(k())||(U.delete(n),N(n))}),O(),x("country-changed",{country:r,language:t.language}),await Promise.all(a),d.state}export{T as detectMarket,v as getLocalization,O as renderCountrySelects,q as setCountry};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{A as N,B as O,D as q,G as V,b as y,g as C,l as E,n as D,o as u,p,r as R,s as h,u as U,w as P}from"./chunk-K2YEQAIH.js";import"./chunk-VC46IEJQ.js";var H="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}}}",F=new WeakSet,W=0;function J(s=document){[...s.matches?.(u("search"))?[s]:[],...h(s,u("search"))].forEach(c=>{F.has(c)||(F.add(c),j(c))})}function j(s){let n=s.querySelector(u("search-input"))||s.querySelector("input"),c=s.querySelector(u("search-results"));if(!n||!c)return;let M=parseInt(p(s,"search-limit")||"6",10)||6,v=parseInt(p(s,"search-min")||"2",10)||2,k=c.id||(c.id=`${y.prefix}-search-${++W}`);n.setAttribute("role","combobox"),n.setAttribute("aria-autocomplete","list"),n.setAttribute("aria-controls",k),n.setAttribute("aria-expanded","false"),n.setAttribute("autocomplete","off"),c.hasAttribute("role")||c.setAttribute("role","listbox"),c.hidden=!0;let x=0,w=null,I="",L=new Map,b=t=>s.setAttribute(D("search-state"),t),f=t=>{s.classList.toggle("is-open",t),c.hidden=!t,n.setAttribute("aria-expanded",String(t)),t||n.removeAttribute("aria-activedescendant")},S=()=>h(c,'[role="option"]');async function Q(t){let e=++x;if(t.length<v){f(!1),b("idle");return}b("loading");try{let r=L.get(t)||(await E(H,{q:t,limit:M})).predictiveSearch;if(L.set(t,r),e!==x)return;Y(r,t)}catch(r){if(e!==x)return;b("error"),C(r,"search")}}function Y(t,e){let r=t?.products||[],o=t?.collections||[],l=(t?.queries||[]).filter(i=>i.text.toLowerCase()!==e.toLowerCase()),d=(i,a,A)=>h(c,u(i)).forEach(g=>{V(g,a,A),q(g,a.length>0)});d("search-products",r,(i,a)=>{$(i,{title:a.title,price:P(a.priceRange?.minVariantPrice),image:a.featuredImage}),T(i,R(a.handle,a.id)),i.classList.toggle("is-sold-out",!a.availableForSale)}),d("search-collections",o,(i,a)=>{$(i,{title:a.title,image:a.image}),T(i,`${(y.collectionPath||"/collection").replace(/\/$/,"")}/${a.handle}`)}),d("search-queries",l,(i,a)=>{$(i,{text:a.text});let A=i.tagName==="A"?i:i.querySelector("a"),g=s.getAttribute("action")||"/search";A&&A.setAttribute("href",`${g}${g.includes("?")?"&":"?"}${n.name||"q"}=${encodeURIComponent(a.text)}`)});let m=r.length+o.length+l.length;h(s,u("show")).forEach(i=>{let a=p(i,"show");a==="search-empty"&&q(i,m===0),a==="search-results"&&q(i,m>0)}),S().forEach((i,a)=>{i.id||(i.id=`${k}-${a}`),i.setAttribute("aria-selected","false")}),b(m?"ready":"empty"),f(!0),U("search",{term:e,products:r,collections:o,queries:l},s)}function $(t,e){h(t,u("search-bind")).forEach(r=>{let o=p(r,"search-bind");o==="image"?N(r,e.image?.url,e.image?.altText||e.title):e[o]!=null&&O(r,e[o])})}function T(t,e){let r=t.tagName==="A"?t:t.querySelector("a");r&&(r.setAttribute("href",e),r.setAttribute("role","option"))}n.addEventListener("input",()=>{let t=n.value.trim();t!==I&&(I=t,clearTimeout(w),w=setTimeout(()=>Q(t),y.searchDelay??150))}),n.addEventListener("focus",()=>{n.value.trim().length>=v&&S().length&&f(!0)}),n.addEventListener("keydown",t=>{let e=S(),r=e.findIndex(l=>l.getAttribute("aria-selected")==="true"),o=l=>{e.forEach((d,m)=>d.setAttribute("aria-selected",String(m===l))),e[l]&&(n.setAttribute("aria-activedescendant",e[l].id),e[l].scrollIntoView?.({block:"nearest"}))};t.key==="ArrowDown"&&e.length?(t.preventDefault(),f(!0),o((r+1)%e.length)):t.key==="ArrowUp"&&e.length?(t.preventDefault(),o(r<=0?e.length-1:r-1)):t.key==="Enter"&&r>=0?(t.preventDefault(),e[r].click()):t.key==="Escape"&&f(!1)}),document.addEventListener("click",t=>{s.contains(t.target)||f(!1)})}export{J as mountSearch};
|