@occluze/tether 0.6.8 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -28
- package/dist/esm/astro.js +2 -2
- package/dist/esm/chunks/account-CXMA5RPZ.js +1 -0
- package/dist/esm/chunks/account-pages-IZO7FEOZ.js +1 -0
- package/dist/esm/chunks/analytics-PG5FPRDN.js +1 -0
- package/dist/esm/chunks/chunk-4HD4J5JC.js +1 -0
- package/dist/esm/chunks/chunk-6TFMLT4A.js +4 -0
- package/dist/esm/chunks/chunk-BBVUVPMO.js +1 -0
- package/dist/esm/chunks/chunk-E5YO6274.js +1 -0
- package/dist/esm/chunks/chunk-EW5SYO6L.js +1 -0
- package/dist/esm/chunks/chunk-HJY2JSNB.js +1 -0
- package/dist/esm/chunks/chunk-MQYB6BH4.js +1 -0
- package/dist/esm/chunks/chunk-N3V45JPS.js +1 -0
- package/dist/esm/chunks/chunk-RPMBCAGS.js +1 -0
- package/dist/esm/chunks/chunk-VFNHIGCS.js +1 -0
- package/dist/esm/chunks/chunk-WT7RGGJU.js +1 -0
- package/dist/esm/chunks/chunk-YN6LEBEN.js +1 -0
- package/dist/esm/chunks/chunk-Z6HS3H7K.js +1 -0
- package/dist/esm/chunks/diagnose-XCEBQKBO.js +14 -0
- package/dist/esm/chunks/extras-4HU3VSBQ.js +1 -0
- package/dist/esm/chunks/markets-ui-M4IQ62CT.js +1 -0
- package/dist/esm/chunks/search-A5DS2IOS.js +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/server.js +2 -2
- package/dist/presets/barba.esm.js +19 -23
- package/dist/tether.account-pages.js +332 -367
- package/dist/tether.account-pages.min.js +1 -1
- package/dist/tether.account.js +253 -492
- package/dist/tether.account.min.js +1 -1
- package/dist/tether.analytics.js +82 -89
- package/dist/tether.analytics.min.js +1 -1
- package/dist/tether.diagnose.js +52 -34
- package/dist/tether.diagnose.min.js +2 -2
- package/dist/tether.extras.js +42 -37
- package/dist/tether.extras.min.js +1 -1
- package/dist/tether.js +1361 -935
- package/dist/tether.markets.js +89 -91
- 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 +60 -69
- package/dist/tether.search.min.js +1 -1
- package/dist/types/server/src/shared/account-orders.d.ts +44 -0
- package/dist/types/server/src/shared/account-routes.d.ts +153 -0
- package/dist/types/server/src/shared/api-versions.d.ts +13 -0
- package/dist/types/server/src/shared/cart-id.d.ts +2 -0
- package/dist/types/server/src/shared/error-message.d.ts +2 -0
- package/dist/types/server/src/shared/json.d.ts +25 -0
- package/dist/types/server/src/shared/market-codes.d.ts +16 -0
- package/dist/types/src/account/addresses-view.d.ts +5 -0
- package/dist/types/src/account/answers.d.ts +40 -0
- package/dist/types/src/account/markup.d.ts +19 -0
- package/dist/types/src/account/operations.d.ts +41 -0
- package/dist/types/src/account/order-lines.d.ts +13 -0
- package/dist/types/src/account/order-list.d.ts +12 -0
- package/dist/types/src/account/order-page.d.ts +6 -0
- package/dist/types/src/account/page-answers.d.ts +182 -0
- package/dist/types/src/account/page-events.d.ts +2 -0
- package/dist/types/src/account/server-client.d.ts +60 -0
- package/dist/types/src/account/subscriptions-view.d.ts +2 -0
- package/dist/types/src/account-api.d.ts +18 -0
- package/dist/types/src/account-marks.d.ts +15 -0
- package/dist/types/src/account-pages.d.ts +8 -0
- package/dist/types/src/account.d.ts +64 -0
- package/dist/types/src/amounts.d.ts +12 -0
- package/dist/types/src/analytics-shopify.d.ts +41 -0
- package/dist/types/src/analytics.d.ts +2 -0
- package/dist/types/src/api-version.d.ts +28 -0
- package/dist/types/src/astro.d.ts +42 -0
- package/dist/types/src/cart/cart-shape.d.ts +43 -0
- package/dist/types/src/cart/checkout.d.ts +16 -0
- package/dist/types/src/cart/drawer.d.ts +18 -0
- package/dist/types/src/cart/mutations.d.ts +85 -0
- package/dist/types/src/cart/render.d.ts +17 -0
- package/dist/types/src/cart/store.d.ts +185 -0
- package/dist/types/src/cart.d.ts +106 -0
- package/dist/types/src/client.d.ts +134 -0
- package/dist/types/src/collection.d.ts +25 -0
- package/dist/types/src/config-sections.d.ts +40 -0
- package/dist/types/src/config.d.ts +190 -0
- package/dist/types/src/controls/cart-controls.d.ts +2 -0
- package/dist/types/src/controls/discount.d.ts +2 -0
- package/dist/types/src/controls/extras.d.ts +5 -0
- package/dist/types/src/controls/navigation.d.ts +12 -0
- package/dist/types/src/diagnose-markup.d.ts +19 -0
- package/dist/types/src/diagnose.d.ts +60 -0
- package/dist/types/src/dom.d.ts +75 -0
- package/dist/types/src/extras.d.ts +21 -0
- package/dist/types/src/fragments.d.ts +158 -0
- package/dist/types/src/globals.d.ts +15 -0
- package/dist/types/src/images.d.ts +20 -0
- package/dist/types/src/index.d.ts +167 -0
- package/dist/types/src/initial.d.ts +56 -0
- package/dist/types/src/lazy.d.ts +28 -0
- package/dist/types/src/loader.d.ts +84 -0
- package/dist/types/src/market-codes.d.ts +6 -0
- package/dist/types/src/markets-ui.d.ts +32 -0
- package/dist/types/src/markets.d.ts +72 -0
- package/dist/types/src/markup.d.ts +131 -0
- package/dist/types/src/mounting.d.ts +46 -0
- package/dist/types/src/page-market.d.ts +27 -0
- package/dist/types/src/presets/barba.d.ts +56 -0
- package/dist/types/src/product-events.d.ts +2 -0
- package/dist/types/src/product-render.d.ts +17 -0
- package/dist/types/src/product-shape.d.ts +90 -0
- package/dist/types/src/product-state.d.ts +110 -0
- package/dist/types/src/product.d.ts +66 -0
- package/dist/types/src/repeaters.d.ts +16 -0
- package/dist/types/src/search.d.ts +33 -0
- package/dist/types/src/selling-plans.d.ts +64 -0
- package/dist/types/src/server.d.ts +88 -0
- package/dist/types/src/shopify-values.d.ts +46 -0
- package/dist/types/src/status.d.ts +33 -0
- package/dist/types/src/storage.d.ts +12 -0
- package/dist/types/src/store-html.d.ts +39 -0
- package/dist/types/src/storefront/catalog.d.ts +38 -0
- package/dist/types/src/storefront/json-ld.d.ts +20 -0
- package/dist/types/src/variant-render.d.ts +14 -0
- package/package.json +24 -24
- package/dist/esm/chunks/account-C3NP6HFB.js +0 -1
- package/dist/esm/chunks/account-pages-WLK374FO.js +0 -1
- package/dist/esm/chunks/analytics-G3SAWMNL.js +0 -1
- package/dist/esm/chunks/chunk-27PJJZGC.js +0 -1
- package/dist/esm/chunks/chunk-2FSXS55U.js +0 -1
- package/dist/esm/chunks/chunk-FCSWQDVV.js +0 -1
- package/dist/esm/chunks/chunk-FOMSMIAM.js +0 -1
- package/dist/esm/chunks/chunk-GZJTCLLW.js +0 -1
- package/dist/esm/chunks/chunk-HEQILZVR.js +0 -1
- package/dist/esm/chunks/chunk-JOOEXYF3.js +0 -4
- package/dist/esm/chunks/chunk-MPTQYLSM.js +0 -1
- package/dist/esm/chunks/chunk-NEHZ37TU.js +0 -3
- package/dist/esm/chunks/chunk-V74KGEJF.js +0 -1
- package/dist/esm/chunks/chunk-VT4CDUJJ.js +0 -1
- package/dist/esm/chunks/chunk-YJLWX2HK.js +0 -1
- package/dist/esm/chunks/diagnose-6VVGZNTY.js +0 -14
- package/dist/esm/chunks/extras-GJVRDFM3.js +0 -1
- package/dist/esm/chunks/markets-ui-UNB4PTA7.js +0 -1
- package/dist/esm/chunks/search-OU75RNQL.js +0 -1
- package/src/account/addresses-view.js +0 -92
- package/src/account/browser-session.js +0 -359
- package/src/account/markup.js +0 -48
- package/src/account/operations.js +0 -180
- package/src/account/order-lines.js +0 -96
- package/src/account/order-list.js +0 -91
- package/src/account/order-page.js +0 -192
- package/src/account/page-events.js +0 -288
- package/src/account/server-client.js +0 -172
- package/src/account/shared.js +0 -111
- package/src/account/shopify-auth.js +0 -150
- package/src/account/subscriptions-view.js +0 -158
- package/src/account-api.js +0 -118
- package/src/account-links.js +0 -35
- package/src/account-pages.js +0 -89
- package/src/account.js +0 -342
- package/src/amounts.js +0 -36
- package/src/analytics-shopify.js +0 -241
- package/src/analytics.js +0 -352
- package/src/api-version.js +0 -85
- package/src/astro.js +0 -266
- package/src/cart/checkout.js +0 -97
- package/src/cart/drawer.js +0 -138
- package/src/cart/mutations.js +0 -234
- package/src/cart/render.js +0 -294
- package/src/cart/store.js +0 -326
- package/src/cart.js +0 -391
- package/src/client.js +0 -267
- package/src/collection.js +0 -183
- package/src/config.js +0 -349
- package/src/controls/cart-controls.js +0 -155
- package/src/controls/discount.js +0 -96
- package/src/controls/extras.js +0 -63
- package/src/controls/navigation.js +0 -83
- package/src/diagnose-markup.js +0 -333
- package/src/diagnose.js +0 -295
- package/src/dom.js +0 -287
- package/src/extras.js +0 -145
- package/src/fragments.js +0 -237
- package/src/images.js +0 -104
- package/src/index.js +0 -353
- package/src/initial.js +0 -87
- package/src/lazy-iife.js +0 -116
- package/src/lazy.js +0 -39
- package/src/loader.js +0 -337
- package/src/market-codes.js +0 -35
- package/src/markets-ui.js +0 -204
- package/src/markets.js +0 -334
- package/src/markup.js +0 -64
- package/src/mounting.js +0 -277
- package/src/page-market.js +0 -116
- package/src/parts/account-pages.js +0 -6
- package/src/parts/account.js +0 -6
- package/src/parts/analytics.js +0 -6
- package/src/parts/diagnose.js +0 -6
- package/src/parts/extras.js +0 -6
- package/src/parts/markets.js +0 -6
- package/src/parts/search.js +0 -6
- package/src/presets/barba.js +0 -190
- package/src/product-events.js +0 -130
- package/src/product-render.js +0 -257
- package/src/product-state.js +0 -318
- package/src/product.js +0 -344
- package/src/repeaters.js +0 -173
- package/src/search.js +0 -323
- package/src/selling-plans.js +0 -154
- package/src/server.js +0 -215
- package/src/shopify-values.js +0 -89
- package/src/status.js +0 -126
- package/src/store-html.js +0 -0
- package/src/storefront/catalog.js +0 -199
- package/src/storefront/json-ld.js +0 -167
- package/src/variant-render.js +0 -165
- package/types/astro.d.ts +0 -28
- package/types/barba.d.ts +0 -16
- package/types/index.d.ts +0 -577
- package/types/server.d.ts +0 -182
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTML written in the Shopify admin (product and collection descriptions), made safe to insert into the site. Store
|
|
3
|
+
* staff and apps that can edit products are not trusted to act on the storefront, where customer sessions live. Only
|
|
4
|
+
* elements and attributes that show content are kept (an allow-list, so markup nobody reviewed is never let in):
|
|
5
|
+
* text formatting, lists, tables, images, links and video embeds look as written, inline `style` included, because
|
|
6
|
+
* the Shopify editor writes its formatting there. Script, page-wide `<style>` and forms (which could post the
|
|
7
|
+
* visitor's input anywhere) are removed, and embeds run sandboxed.
|
|
8
|
+
*
|
|
9
|
+
* A description stays where it is written, so it can't be laid over the page as a fake login (a phishing form on the
|
|
10
|
+
* shop's own origin). Removed for that: `id` (it would clobber `window.<id>` and the site's own ids); `class`, which
|
|
11
|
+
* would let a description borrow the site's own overlay or modal classes; and every style that takes content out of
|
|
12
|
+
* the flow (`position`, `inset`, `z-index`), moves it from where the flow put it (transforms, motion paths, negative
|
|
13
|
+
* margins, and negative indents and spacing beyond the small values that tighten text, `NEGATIVE_LIMITS`), copies it
|
|
14
|
+
* elsewhere (reflections) or sizes it to the window (viewport and container-query units).
|
|
15
|
+
* Outlines, shadows, filters, border-image and mask-border outsets, text decoration and text stroke paint beyond their
|
|
16
|
+
* element, so they are kept only while every number they give is a pixel length of a few dozen pixels at most
|
|
17
|
+
* (`MAX_PAINT_PX`): enough to set off an image or a callout, too little to cover the page.
|
|
18
|
+
* Styles that fetch anything go too.
|
|
19
|
+
*
|
|
20
|
+
* A frame shows whatever its origin serves, sized as the description likes, so a frame from a page store staff can
|
|
21
|
+
* write would be that fake login. Frames are kept only from the video players in `EMBED_ORIGINS` and the origins the
|
|
22
|
+
* site adds (`embedOrigins`), never from the site's own origin, where a sandbox can be lifted from inside. What an
|
|
23
|
+
* allowed frame shows is up to its host: the host's player, and whatever that player lets its users add (a call to
|
|
24
|
+
* action, an email gate). An origin a site adds is trusted the same way.
|
|
25
|
+
*
|
|
26
|
+
* Not prevented: content wider than the description (a table or embed on a narrow screen, or a box given a large
|
|
27
|
+
* width in pixels) overflows beside it, as in any HTML, and a capped shadow or outline still paints just past it. Tether
|
|
28
|
+
* doesn't clip the element it fills (`contain: paint`, `overflow`), because that would cut off those wide tables and
|
|
29
|
+
* embeds, stop margins collapsing through it and make it contain floats, changing how ordinary descriptions look. A
|
|
30
|
+
* site that wants the clip sets it on that element in its own CSS.
|
|
31
|
+
*/
|
|
32
|
+
/**
|
|
33
|
+
* Store HTML as a fragment of content elements only.
|
|
34
|
+
*
|
|
35
|
+
* @param document The document the fragment is for.
|
|
36
|
+
* @param embedOrigins Origins iframes may load from besides the video players in `EMBED_ORIGINS`: the config's
|
|
37
|
+
* `embedOrigins`, already checked to be https origins.
|
|
38
|
+
*/
|
|
39
|
+
export declare function storeHtmlFragment(html: string | null | undefined, document?: Document, embedOrigins?: readonly string[]): DocumentFragment;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { StorefrontConfig } from '../client.js';
|
|
2
|
+
import type { ProductFragmentConfig, Product } from '../fragments.js';
|
|
3
|
+
import type { Collection, PageInfo, ProductPage } from '../loader.js';
|
|
4
|
+
/** What the catalog needs of a storefront's config. */
|
|
5
|
+
type CatalogConfig = StorefrontConfig & ProductFragmentConfig;
|
|
6
|
+
/** A page of a collection's products, or of a search. */
|
|
7
|
+
export interface CatalogQuery {
|
|
8
|
+
/** A collection handle; without one, a search. */
|
|
9
|
+
collection?: string;
|
|
10
|
+
/** Storefront search syntax; `null` or `''` is every product. */
|
|
11
|
+
query?: string | null;
|
|
12
|
+
/** Default the storefront's `pageSize`. */
|
|
13
|
+
first?: number;
|
|
14
|
+
/** The cursor of the page before. */
|
|
15
|
+
after?: string | null;
|
|
16
|
+
/** `ProductCollectionSortKeys` for a collection, `ProductSortKeys` for a search. */
|
|
17
|
+
sortKey?: string;
|
|
18
|
+
reverse?: boolean;
|
|
19
|
+
/** `ProductFilter` values, for a collection. */
|
|
20
|
+
filters?: unknown[];
|
|
21
|
+
}
|
|
22
|
+
type CollectionWithProducts = Collection & {
|
|
23
|
+
products: Product[];
|
|
24
|
+
pageInfo: PageInfo;
|
|
25
|
+
};
|
|
26
|
+
type RecommendationIntent = 'RELATED' | 'COMPLEMENTARY';
|
|
27
|
+
/** @param pageSize Products per page when a query doesn't say. */
|
|
28
|
+
export declare function createCatalog(conf: CatalogConfig, pageSize: number): {
|
|
29
|
+
getProduct: (raw: string | number | null | undefined) => Promise<Product | null>;
|
|
30
|
+
getProducts: (options?: CatalogQuery) => Promise<ProductPage>;
|
|
31
|
+
allProducts: (options?: Omit<CatalogQuery, "first" | "after">) => Promise<Product[]>;
|
|
32
|
+
getCollection: (handle: string, options?: Omit<CatalogQuery, "collection">) => Promise<CollectionWithProducts | null>;
|
|
33
|
+
allCollections: () => Promise<Collection[]>;
|
|
34
|
+
getRecommendations: (product: string | number | {
|
|
35
|
+
id: string;
|
|
36
|
+
} | null | undefined, intent?: RecommendationIntent) => Promise<Product[]>;
|
|
37
|
+
};
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Product } from '../fragments.js';
|
|
2
|
+
export interface JsonLdOptions {
|
|
3
|
+
/** The product page's absolute URL; default from the storefront's `siteUrl`. */
|
|
4
|
+
url?: string;
|
|
5
|
+
/** Default the product's vendor. */
|
|
6
|
+
brand?: string;
|
|
7
|
+
}
|
|
8
|
+
/** Where the product pages are. */
|
|
9
|
+
interface JsonLdSite {
|
|
10
|
+
productPath: string;
|
|
11
|
+
siteUrl: string | undefined;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Text for a `<script>` tag: `<` is escaped so product text can never close the tag, and U+2028 / U+2029 so older
|
|
15
|
+
* JavaScript parsers read it.
|
|
16
|
+
*/
|
|
17
|
+
export declare const scriptJson: (value: unknown) => string;
|
|
18
|
+
/** @returns The schema.org object, `null` without a product. */
|
|
19
|
+
export declare function jsonLdData(product: Product | null | undefined, options: JsonLdOptions, site: JsonLdSite): Record<string, unknown> | null;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ProductView } from './product-state.js';
|
|
2
|
+
import type { RenderScope } from './product-render.js';
|
|
3
|
+
/**
|
|
4
|
+
* The element of an add-to-cart button that holds its label, with the label as written kept in
|
|
5
|
+
* `data-tether-label`, so mode-dependent texts (`tether-subscribe-text`, `tether-soldout-text`) can be undone.
|
|
6
|
+
*/
|
|
7
|
+
export declare function addButtonLabel(button: HTMLElement): {
|
|
8
|
+
label: HTMLElement;
|
|
9
|
+
original: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Writes what follows the variant and purchase.
|
|
13
|
+
*/
|
|
14
|
+
export declare function writeVariant(scope: RenderScope, view: ProductView): void;
|
package/package.json
CHANGED
|
@@ -1,75 +1,72 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@occluze/tether",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Free, open-source alternative to Smootify and Storesynk (Shopyflow): Shopify products, cart and subscriptions in Webflow with HTML attributes. Optional Shopify to Webflow CMS sync.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
7
7
|
"module": "dist/esm/index.js",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"types": "./types/index.d.ts",
|
|
10
|
+
"types": "./dist/types/src/index.d.ts",
|
|
11
11
|
"default": "./dist/esm/index.js"
|
|
12
12
|
},
|
|
13
13
|
"./server": {
|
|
14
|
-
"types": "./types/server.d.ts",
|
|
14
|
+
"types": "./dist/types/src/server.d.ts",
|
|
15
15
|
"default": "./dist/esm/server.js"
|
|
16
16
|
},
|
|
17
17
|
"./astro": {
|
|
18
|
-
"types": "./types/astro.d.ts",
|
|
18
|
+
"types": "./dist/types/src/astro.d.ts",
|
|
19
19
|
"default": "./dist/esm/astro.js"
|
|
20
20
|
},
|
|
21
21
|
"./presets/barba": {
|
|
22
|
-
"types": "./types/barba.d.ts",
|
|
22
|
+
"types": "./dist/types/src/presets/barba.d.ts",
|
|
23
23
|
"default": "./dist/presets/barba.esm.js"
|
|
24
24
|
},
|
|
25
25
|
"./dist/*": "./dist/*"
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
28
|
"dist",
|
|
29
|
-
"src",
|
|
30
29
|
"LICENSE",
|
|
31
|
-
"README.md"
|
|
32
|
-
"types/index.d.ts",
|
|
33
|
-
"types/barba.d.ts",
|
|
34
|
-
"types/server.d.ts",
|
|
35
|
-
"types/astro.d.ts"
|
|
30
|
+
"README.md"
|
|
36
31
|
],
|
|
37
32
|
"scripts": {
|
|
38
|
-
"build": "node scripts/build.
|
|
39
|
-
"dev": "node scripts/build.
|
|
33
|
+
"build": "node --experimental-strip-types scripts/build.ts",
|
|
34
|
+
"dev": "node --experimental-strip-types scripts/build.ts --watch",
|
|
40
35
|
"format": "prettier --write .",
|
|
41
36
|
"format:check": "prettier --check .",
|
|
42
37
|
"lint": "eslint .",
|
|
43
|
-
"typecheck": "tsc -
|
|
38
|
+
"typecheck": "tsc -b",
|
|
44
39
|
"knip": "knip",
|
|
45
40
|
"deps": "depcruise src server/src server/bin server/scripts scripts",
|
|
46
41
|
"check": "npm run format:check && npm run lint && npm run typecheck && npm run knip && npm run deps && npm test",
|
|
47
42
|
"prepare": "lefthook install",
|
|
48
|
-
"test": "node --test test/*.test.js server/test/*.test.js && npm run test:types",
|
|
43
|
+
"test": "node --experimental-strip-types --test test/*.test.js server/test/*.test.js && npm run test:types",
|
|
49
44
|
"test:types": "tsc -p types/tsconfig.json",
|
|
50
|
-
"smoke": "node scripts/smoke.
|
|
51
|
-
"pretest": "node scripts/build.
|
|
52
|
-
"presmoke": "node scripts/build.
|
|
53
|
-
"release": "node scripts/release.
|
|
45
|
+
"smoke": "node --experimental-strip-types scripts/smoke.ts",
|
|
46
|
+
"pretest": "node --experimental-strip-types scripts/build.ts --out .test-dist",
|
|
47
|
+
"presmoke": "node --experimental-strip-types scripts/build.ts",
|
|
48
|
+
"release": "node --experimental-strip-types scripts/release.ts",
|
|
54
49
|
"e2e:build": "npm run build && cd examples/astro && (test -f .env || cp .env.example .env) && npm install --no-audit --no-fund && npm install --no-save ../.. && npx astro build",
|
|
55
50
|
"e2e": "npm run e2e:build && playwright test -c e2e/playwright.config.js"
|
|
56
51
|
},
|
|
57
52
|
"devDependencies": {
|
|
58
53
|
"@eslint/js": "10.0.1",
|
|
59
|
-
"@playwright/test": "
|
|
54
|
+
"@playwright/test": "1.64.1",
|
|
60
55
|
"@tsconfig/strictest": "2.0.8",
|
|
56
|
+
"@types/jsdom": "21.1.7",
|
|
61
57
|
"@types/node": "24.19.2",
|
|
62
58
|
"dependency-cruiser": "18.7.2",
|
|
63
|
-
"esbuild": "
|
|
59
|
+
"esbuild": "0.25.12",
|
|
64
60
|
"eslint": "10.14.0",
|
|
65
61
|
"eslint-config-prettier": "10.1.8",
|
|
66
62
|
"globals": "17.14.0",
|
|
67
|
-
"jsdom": "
|
|
63
|
+
"jsdom": "26.1.0",
|
|
68
64
|
"knip": "6.44.1",
|
|
69
65
|
"lefthook": "2.2.2",
|
|
70
66
|
"prettier": "3.9.10",
|
|
71
67
|
"typescript": "npm:@typescript/typescript6@6.0.2",
|
|
72
|
-
"typescript-eslint": "8.72.1"
|
|
68
|
+
"typescript-eslint": "8.72.1",
|
|
69
|
+
"yaml": "2.9.1"
|
|
73
70
|
},
|
|
74
71
|
"license": "MIT",
|
|
75
72
|
"author": {
|
|
@@ -110,7 +107,7 @@
|
|
|
110
107
|
"publishConfig": {
|
|
111
108
|
"access": "public"
|
|
112
109
|
},
|
|
113
|
-
"types": "types/index.d.ts",
|
|
110
|
+
"types": "dist/types/src/index.d.ts",
|
|
114
111
|
"peerDependencies": {
|
|
115
112
|
"astro": ">=4"
|
|
116
113
|
},
|
|
@@ -118,5 +115,8 @@
|
|
|
118
115
|
"astro": {
|
|
119
116
|
"optional": true
|
|
120
117
|
}
|
|
118
|
+
},
|
|
119
|
+
"engines": {
|
|
120
|
+
"node": ">=22.18"
|
|
121
121
|
}
|
|
122
122
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as oe,b as se,c as F,g as R,h as ie}from"./chunk-GZJTCLLW.js";import{a as ae}from"./chunk-VT4CDUJJ.js";import{b as f}from"./chunk-MPTQYLSM.js";import"./chunk-NEHZ37TU.js";import"./chunk-JOOEXYF3.js";import{A as te,C as re,G as ne,J as N,L as K,b as i,g as ee,i as p,l as d,s as w,t as k,v as x,x as E}from"./chunk-YJLWX2HK.js";import"./chunk-FOMSMIAM.js";var ve="amount currencyCode",ce="query TetherCustomer { customer { id firstName lastName displayName emailAddress { emailAddress } defaultAddress { formatted } } }",ue=`query TetherOrders($first:Int!){customer{orders(first:$first,sortKey:PROCESSED_AT,reverse:true){nodes{id name processedAt financialStatus fulfillmentStatus statusPageUrl totalPrice{${ve}}lineItems(first:20){nodes{title variantTitle quantity image{url altText}}}}}}}`;function G(e){return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function le(e){let t=e.replace(/-/g,"+").replace(/_/g,"/").padEnd(Math.ceil(e.length/4)*4,"=");return Uint8Array.from(atob(t),r=>r.charCodeAt(0))}function P(e=32){return G(crypto.getRandomValues(new Uint8Array(e)))}var $=()=>`${i.prefix}:account:${i.domain}`,v=()=>`${i.prefix}:account-login:${i.domain}`,De=()=>`${i.prefix}:account-hint:${i.domain}`,D=()=>i.account?.remember?"local":"session",z=e=>e==="local"?window.localStorage:window.sessionStorage;function Q(e,t){try{return JSON.parse(z(e).getItem(t)??"null")}catch{return null}}function A(e,t,r){try{r===null?z(e).removeItem(t):z(e).setItem(t,JSON.stringify(r))}catch{}}function Y(e){A("local",De(),e?1:null)}var h=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),u=e=>typeof e=="string"?e:null;async function b(e){let t;try{t=await e.json()}catch{return{}}return h(t)?t:{}}function S(e){let t=i.account?.navigate;t?t(e):window.location.assign(e)}var q=e=>e||i.account?.locale||(i.locale||"").split("-")[0]||"",j=()=>i.country?i.country.toUpperCase():"";var qe=3600,B=null;async function de(e){let t=i.account?.shopDomain||i.domain,r=await fetch(`https://${t}/.well-known/${e}`);if(!r.ok)throw new d(`Customer accounts: ${e} answered ${r.status}`,{status:r.status});let n=await r.json();return h(n)?n:{}}function I(e,t){let r=u(e[t]);if(!r)throw new d(`Customer accounts: Shopify named no ${t}`);return r}async function C(){if(B)return B;let[e,t]=await Promise.all([de("openid-configuration"),de("customer-account-api")]);return B={issuer:I(e,"issuer"),authorizationEndpoint:I(e,"authorization_endpoint"),tokenEndpoint:I(e,"token_endpoint"),endSessionEndpoint:I(e,"end_session_endpoint"),graphql:I(t,"graphql_api")},B}async function H(e){let{tokenEndpoint:t}=await C(),r=await fetch(i.account?.tokenUrl||t,{method:"POST",body:new URLSearchParams(e)}),n=await b(r),o=u(n.access_token);if(!r.ok||!o){let s=r.status===400||r.status===401;throw new d(`Customer accounts: token ${r.status} ${u(n.error)??""}`.trim(),{status:r.status,code:s?"SESSION_ENDED":"TOKEN_FAILED"})}return{access:o,refresh:u(n.refresh_token)||null,idToken:u(n.id_token)||null,expiresInSeconds:Number(n.expires_in)||qe}}function je(e){let t=e.split(".")[1];if(!t)return null;let r;try{r=JSON.parse(new TextDecoder().decode(le(t)))}catch{return null}return h(r)?r:null}function fe(e,{nonce:t,issuer:r,client:n}){let o=e?je(e):null;if(!o)return!1;let s=o.aud,a=Array.isArray(s)?s:[s],c=o.exp;return o.nonce===t&&o.iss===r&&a.includes(n)&&typeof c=="number"&&c*1e3>=Date.now()}var Be=120,Je=600*1e3,l=null,O=null,V=null;function Me(e){if(!h(e))return null;let t=e.access,r=e.expiresAt;return typeof t!="string"||typeof r!="number"?null:{access:t,expiresAt:r,refresh:u(e.refresh),idToken:u(e.idToken)}}function Ke(e){if(!h(e))return null;let{state:t,nonce:r,verifier:n,redirect:o,returnTo:s,at:a}=e;return typeof t!="string"||typeof r!="string"||typeof n!="string"||typeof o!="string"||typeof s!="string"||typeof a!="number"?null:{state:t,nonce:r,verifier:n,redirect:o,returnTo:s,at:a}}var me=()=>l??Me(Q(D(),$())),pe=()=>l?.access??null,W=()=>!!(l&&(l.refresh||l.access&&l.expiresAt>Date.now()));function X(){let e=i.account?.clientId;if(!e)throw new d("Customer accounts: set account.clientId",{code:"NOT_CONFIGURED"});return e}var Fe=async e=>G(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e)));async function ge({returnTo:e,locale:t}){let r=X(),n=await C(),o={state:P(),nonce:P(),verifier:P(),redirect:i.account?.callbackUrl||`${window.location.origin}${window.location.pathname}`,returnTo:e,at:Date.now()};A("session",v(),o);let s=new URL(n.authorizationEndpoint),a={client_id:r,scope:"openid email customer-account-api:full",response_type:"code",redirect_uri:o.redirect,state:o.state,nonce:o.nonce,code_challenge:await Fe(o.verifier),code_challenge_method:"S256"},c=q(t);c&&(a.locale=c);let m=j();m&&(a.region_country=m),Object.entries(a).forEach(([_,$e])=>{s.searchParams.set(_,$e)}),S(s.toString())}function we(e,t){l={access:e.access,expiresAt:Date.now()+Math.max(0,e.expiresInSeconds-Be)*1e3,refresh:e.refresh??t?.refresh??null,idToken:e.idToken??t?.idToken??null},A(D(),$(),l)}async function he(){let e=new URLSearchParams(window.location.search),t=Ke(Q("session",v()));if(!t||!e.has("code")&&!e.has("error")||e.get("state")!==t.state)return!1;A("session",v(),null);let r=new URL(window.location.href);["code","state","iss","error","error_description"].forEach(m=>{r.searchParams.delete(m)}),window.history.replaceState(window.history.state,"",r);let n=e.get("error");if(n!==null)return E("account-error",{error:n}),!1;if(Date.now()-t.at>Je)throw new d("Customer accounts: the login took too long, please try again");let o=X(),s=await H({grant_type:"authorization_code",client_id:o,redirect_uri:t.redirect,code:e.get("code")??"",code_verifier:t.verifier}),{issuer:a}=await C();if(!fe(s.idToken,{nonce:t.nonce,issuer:a,client:o}))throw new d("Customer accounts: the login answer did not check out (nonce/issuer/audience)");we(s,null),await ye(),E("account-login",{});let c=t.returnTo?new URL(t.returnTo,window.location.href):null;return c?.origin===window.location.origin&&c.href!==r.href&&S(c.href),!0}function Z(){l=null,O=null,A(D(),$(),null),f.setCustomer({accessToken:null})}async function Ge(e){try{let t=await H({grant_type:"refresh_token",client_id:X(),refresh_token:e.refresh??""});we(t,e),await ye()}catch(t){if(t instanceof d&&t.code==="SESSION_ENDED")Z();else throw t}}async function U(){return l=me(),l?l.access&&l.expiresAt>Date.now()?l.access:l.refresh?(V??(V=Ge(l).finally(()=>{V=null})),await V,pe()):(Z(),null):null}async function ye(){let e=pe();if(f.setCustomer({accessToken:e}),!(!f.id()||!e))try{await f.setBuyerIdentity({customerAccessToken:e},{create:!1})}catch(t){p(t,"account cart")}}async function ze(){if(f.id())try{await f.setBuyerIdentity({customerAccessToken:null},{create:!1})}catch(e){p(e,"account cart unlink"),A("local",i.storageKey,null)}}async function xe(e){let t=me()?.idToken??null;if(await ze(),Z(),E("account-logout",{}),!t)return"stayed";let r=new URL((await C()).endSessionEndpoint);return r.searchParams.set("id_token_hint",t),r.searchParams.set("post_logout_redirect_uri",e),S(r.toString()),"redirected"}async function J(e,t={}){let r=await U();if(!r)throw new d("Not logged in",{code:"NOT_LOGGED_IN"});let{graphql:n}=await C(),o=m=>fetch(n,{method:"POST",headers:{"Content-Type":"application/json",Authorization:m},body:JSON.stringify({query:e,variables:t})}),s=await o(r);s.status===401&&l?.refresh&&(l.expiresAt=0,s=await o(await U()??""));let a=await b(s),c=Array.isArray(a.errors)?a.errors:[];if(!s.ok||c.length){let m=c.map(_=>h(_)?u(_.message):null).filter(Boolean);throw new d(m.join(" | ")||`Customer accounts: ${s.status}`,{status:s.status})}return a.data}async function ke(){return O||(O=(await J(ce)).customer,O)}function Ee(){O=null}var T=null;function g(){let e=i.account?.server;return e?new URL(e,window.location.href).href.replace(/\/$/,""):""}async function L(e,{method:t="GET",body:r}={}){let n={method:t,credentials:"include"};t==="POST"&&(n.headers={"Content-Type":"application/json","X-Tether-Account":"1"}),r&&(n.body=JSON.stringify(r));let o=await fetch(`${g()}${e}`,n);if(o.status===401)return{kind:"logged-out"};let s=await b(o);if(!o.ok){let a=u(s.error)??String(o.status),c=Array.isArray(s.userErrors)?s.userErrors:void 0;throw new d(`Customer accounts: ${a}`,{status:o.status,...c&&{userErrors:c}})}return{kind:"answer",data:s}}function Qe(e){let t=h(e)?e:{},r=t.address;return{firstName:u(t.firstName),lastName:u(t.lastName),displayName:u(t.displayName),email:u(t.email),address:Array.isArray(r)?r.filter(n=>typeof n=="string"):null}}async function M(){if(!T){let e=await L("/me");T=e.kind==="answer"&&e.data.loggedIn===!0?{loggedIn:!0,customer:Qe(e.data.customer)}:{loggedIn:!1}}return Y(T.loggedIn),T}var Ae=()=>T?.loggedIn===!0;function Se(){T=null}function Te({returnTo:e,locale:t}){let r=new URL(`${g()}/login`);r.searchParams.set("returnTo",e);let n=q(t);n&&r.searchParams.set("locale",n);let o=j();o&&r.searchParams.set("country",o),S(r.toString())}async function _e(){let e=f.id();if(!(await M()).loggedIn||!e)return null;let t=await L("/cart",{method:"POST",body:{cartId:e}});if(t.kind==="logged-out")return null;let r=u(t.data.checkoutUrl);return r?`${r}${r.includes("?")?"&":"?"}logged_in=true`:null}async function be(e){let t=await L("/logout",{method:"POST",body:{returnTo:e,cartId:f.id()}});T=null,Y(!1),E("account-logout",{});let r=t.kind==="answer"?u(t.data.logoutUrl):null;return r?(S(r),"redirected"):"stayed"}var Ce=10,Ye=e=>({name:e.name,date:oe(e.processedAt),total:ne(e.totalPrice),status:e.financialStatus?.toLowerCase(),fulfillment:e.fulfillmentStatus?.toLowerCase(),items:e.lineItems.nodes.map(t=>`${t.quantity}\xD7 ${t.title}`).join(", ")});function He(e,t){let r=t.lineItems.nodes,n=se(t),o=Ye(t);x(e,w("order-bind")).forEach(s=>{let a=k(s,"order-bind")??"";if(a==="url"){n&&s.setAttribute("href",n);return}if(a==="image"){let m=r.find(_=>_.image)?.image;m&&te(s,m.url,m.altText||r[0]?.title||"");return}let c=R(o,a);c!==void 0&&N(s,c)}),x(e,w("order-lines")).forEach(s=>{ie(s,r,null)}),k(e,"order-bind")==="url"&&n&&e.setAttribute("href",n)}async function Oe(e,t){let r=x(e,w("orders")),n=r[0];if(!n)return;F(e,"show",{"orders-loading":!0,"orders-empty":!1});let o=Number.parseInt(k(n,"limit")||String(Ce),10)||Ce,s=await t(o).catch(a=>(p(a,"orders"),null));F(e,"show",{"orders-loading":!1,"orders-empty":s?.length===0}),r.forEach(a=>{re(a,s??[],He)})}var Ve=["order","addresses","subscriptions","profile-form","address-form"];function We(){return g()?Ae():W()}async function Xe({returnTo:e=window.location.href,locale:t}={}){g()?Te({returnTo:e,locale:t}):await ge({returnTo:e,locale:t})}async function Ze(e,t={}){if(g())throw new d("Customer accounts in server mode only answer customer() and orders()",{code:"NOT_ALLOWED"});return J(e,t)}async function Ne(){if(!g())return ke();let e=await M();return e.loggedIn?{...e.customer,emailAddress:{emailAddress:e.customer.email},defaultAddress:{formatted:e.customer.address}}:null}async function et({first:e=10}={}){if(g()){let r=await L(`/orders?first=${e}`);if(r.kind==="logged-out")return[];let n=r.data.orders;return Array.isArray(n)?n:[]}return(await J(ue,{first:e})).customer?.orders.nodes??[]}async function tt({returnTo:e=i.account?.logoutUrl||`${window.location.origin}/`}={}){(g()?await be(e):await xe(e))==="stayed"&&await Re(document)}async function rt(){try{return g()?(await M()).loggedIn?{kind:"logged-in"}:{kind:"logged-out"}:W()||await U()?{kind:"logged-in"}:{kind:"logged-out"}}catch(e){return{kind:"unknown",error:e}}}var Le=e=>Ve.some(t=>x(e,w(t)).length>0);function nt(e){let t=i.account;x(e,w("account-link")).forEach(r=>{let n=k(r,"account-link"),o=t?.subscriptionsUrl,s=n==="payment"&&(t?.paymentUrl||o)||n==="subscriptions"&&o;r.setAttribute("href",s||`https://${i.domain}/account`)})}async function Re(e=document){let t=await rt();t.kind==="unknown"&&p(t.error,"account");let r=t.kind==="logged-in";if(x(e,w("show")).forEach(n=>{let o=k(n,"show");o==="logged-in"&&K(n,r),o==="logged-out"&&K(n,!r)}),nt(e),t.kind==="unknown"&&Le(e)){(await y()).showUnavailable(e);return}r&&(await Pe(e),await Promise.all([Oe(e,n=>et({first:n})),Le(e)?y().then(n=>n.renderPages(e)):null]))}async function Pe(e){let t=x(e,w("account-bind"));if(!t.length)return;let r=await Ne().catch(o=>(p(o,"account"),null)),n={"first-name":r?.firstName,"last-name":r?.lastName,name:r?.displayName,email:r?.emailAddress?.emailAddress,address:r?.defaultAddress?.formatted?.join(", ")};t.forEach(o=>{let s=R(n,k(o,"account-bind")??"");s!=null&&N(o,s)})}var Ie=null;function y(){return Ie??(Ie=ae("account-pages").then(e=>(e.setup({serverBase:g,serverFetch:L,query:Ze,customer:Ne,bindCustomer:Pe,reset:()=>{Ee(),Se()}}),e))),Ie}var Qt=e=>y().then(t=>t.order(e)),Yt=e=>y().then(t=>t.updateProfile(e)),Ht=()=>y().then(e=>e.addresses()),Vt=(e,t)=>y().then(r=>r.saveAddress(e,t)),Wt=e=>y().then(t=>t.deleteAddress(e)),Xt=()=>y().then(e=>e.subscriptions()),Zt=(e,t)=>y().then(r=>r.subscriptionAction(e,t)),er=(e,t)=>y().then(r=>r.requestReturn(e,t));function ot(e){let t=e.target;t instanceof window.Element&&(t.closest(w("account-login"))?(e.preventDefault(),Xe().catch(r=>{p(r,"login")})):t.closest(w("account-logout"))&&(e.preventDefault(),tt().catch(r=>{p(r,"logout")})))}function st(){let e=new URL(window.location.href);e.searchParams.get("account")&&(e.searchParams.delete("account"),window.history.replaceState(window.history.state,"",e),E("account-login",{})),f.setCustomer({beforeCheckout:_e})}async function it(){try{await he()}catch(e){p(e,"login")}if(!f.customerAccessToken)try{let e=await U();e&&f.setCustomer({accessToken:e})}catch(e){p(e,"account")}}var Ue=!1;async function tr(e=document){Ue||(Ue=!0,document.addEventListener("click",ot),g()?st():await it(),ee("account",We()?"logged in":"logged out")),await Re(e)}export{Ht as addresses,Ne as customer,Wt as deleteAddress,U as getToken,he as handleCallback,We as isLoggedIn,Xe as login,tt as logout,tr as mountAccount,Qt as order,et as orders,Ze as query,Re as render,er as requestReturn,Vt as saveAddress,Zt as subscriptionAction,Xt as subscriptions,Yt as updateProfile};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as C,c as f,d as O,e as E,f as N,g as w,h as oe}from"./chunk-GZJTCLLW.js";import{A as re,C as x,G as g,J as h,L as ne,i as I,l as D,r as y,s as a,t as m,v as l,x as se}from"./chunk-YJLWX2HK.js";import{c as z}from"./chunk-FOMSMIAM.js";var p=class extends Error{constructor(t,{status:s=400,userErrors:r=[]}={}){super(t),this.name="InputError",this.status=s,this.userErrors=r}},A="amount currencyCode",U="id firstName lastName company address1 address2 city province zoneCode zip country countryCode phoneNumber formatted",b="userErrors { field message }",_={order:`query TetherOrder($id:ID!){order(id:$id){id name number processedAt cancelledAt financialStatus fulfillmentStatus statusPageUrl requiresShipping totalPrice{${A}}subtotal{${A}}totalShipping{${A}}totalTax{${A}}shippingAddress{${U}}billingAddress{${U}}lineItems(first:50){nodes{id name title variantTitle quantity sku image{url altText}price{${A}}totalPrice{${A}}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{${U}}}}}`,subscriptions:`query TetherSubscriptions{customer{subscriptionContracts(first:20,reverse:true){nodes{id status nextBillingDate currencyCode deliveryPrice{${A}}deliveryPolicy{interval intervalCount{count}}lines(first:20){nodes{id name title variantTitle quantity sku currentPrice{${A}}lineDiscountedPrice{${A}}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}}}}}"},L={profile:`mutation TetherProfile($input:CustomerUpdateInput!){customerUpdate(input:$input){customer{firstName lastName}${b}}}`,addressCreate:`mutation TetherAddressCreate($address:CustomerAddressInput!,$default:Boolean){customerAddressCreate(address:$address,defaultAddress:$default){customerAddress{${U}}${b}}}`,addressUpdate:`mutation TetherAddressUpdate($id:ID!,$address:CustomerAddressInput,$default:Boolean){customerAddressUpdate(addressId:$id,address:$address,defaultAddress:$default){customerAddress{${U}}${b}}}`,addressDelete:`mutation TetherAddressDelete($id:ID!){customerAddressDelete(addressId:$id){deletedAddressId ${b}}}`,returnRequest:`mutation TetherReturn($orderId:ID!,$lines:[RequestedLineItemInput!]!){orderRequestReturn(orderId:$orderId,requestedLineItems:$lines){return{id status}${b}}}`},ie={pause:{document:`mutation TetherPause($id:ID!){subscriptionContractPause(subscriptionContractId:$id){contract{id status}${b}}}`,payload:"subscriptionContractPause",input:"contract"},resume:{document:`mutation TetherResume($id:ID!){subscriptionContractActivate(subscriptionContractId:$id){contract{id status}${b}}}`,payload:"subscriptionContractActivate",input:"contract"},cancel:{document:`mutation TetherCancel($id:ID!){subscriptionContractCancel(subscriptionContractId:$id){contract{id status}${b}}}`,payload:"subscriptionContractCancel",input:"contract"},skip:{document:`mutation TetherSkip($input:SubscriptionBillingCycleInput!){subscriptionBillingCycleSkip(billingCycleInput:$input){billingCycle{cycleIndex skipped}${b}}}`,payload:"subscriptionBillingCycleSkip",input:"billingCycle"},unskip:{document:`mutation TetherUnskip($input:SubscriptionBillingCycleInput!){subscriptionBillingCycleUnskip(billingCycleInput:$input){billingCycle{cycleIndex skipped}${b}}}`,payload:"subscriptionBillingCycleUnskip",input:"billingCycle"}};function ge(e){return typeof e=="string"&&Object.hasOwn(ie,e)}function u(e,t){if(!(e===null||typeof e!="object"))return e[t]}function V(e){let t=u(e,"nodes");return Array.isArray(t)?t:[]}var we=/^\d{1,20}$/;function S(e,t){let s=typeof t=="string"||typeof t=="number"?String(t):"",r=we.test(s)?`gid://shopify/${e}/${s}`:s;if(!new RegExp(`^gid://shopify/${e}/\\d+(\\?[\\w=&.-]{1,80})?$`).test(r))throw new p(`${e} id`);return r}var Ae=/[\u0000-\u001f\u007f]/g;function B(e,t=255){if(e==null||e==="")return;if(typeof e!="string"&&typeof e!="number")throw new p("text");let s=String(e).replace(Ae,"").trim();if(s.length>t)throw new p("too long");return s}var Ie=["firstName","lastName","company","address1","address2","city","zip","zoneCode","phoneNumber"];function Ee(e,{clear:t=!1}={}){if(e===null||typeof e!="object"||Array.isArray(e))throw new p("address");let s=e,r={};for(let o of Ie){let i=B(s[o]);i!==void 0?r[o]=i:t&&o in s&&(s[o]===""||s[o]===null)&&(r[o]="")}let n=B(s.countryCode);if(n!==void 0){let o=n.toUpperCase();if(!/^[A-Z]{2}$/.test(o))throw new p("countryCode");r.countryCode=o}return r}function $(e,t){let s=u(e,t),r=u(s,"userErrors");if(Array.isArray(r)&&r.length){let n=r;throw new p(n.map(o=>o.message).join(" | "),{userErrors:n})}return s}var ae={async order(e,{id:t}){let s=await e(_.order,{id:S("Order",t)});return{order:u(s,"order")??null}},async profile(e,{firstName:t,lastName:s}){let r={};if(t!==void 0&&(r.firstName=B(t,100)??""),s!==void 0&&(r.lastName=B(s,100)??""),!Object.keys(r).length)throw new p("nothing to change");let n=$(await e(L.profile,{input:r}),"customerUpdate");return{customer:u(n,"customer")}},async addresses(e){let t=u(await e(_.addresses,{}),"customer"),s=u(u(t,"defaultAddress"),"id")??null;return{addresses:V(u(t,"addresses")).map(n=>({...n,isDefault:u(n,"id")===s}))}},async saveAddress(e,{id:t,address:s,isDefault:r}){let n=Ee(s??{},{clear:!!t}),o=r===!0;if(!t){let d=await e(L.addressCreate,{address:n,default:o});return{address:u($(d,"customerAddressCreate"),"customerAddress")}}let i=await e(L.addressUpdate,{id:S("CustomerAddress",t),address:Object.keys(n).length?n:null,default:o?!0:null});return{address:u($(i,"customerAddressUpdate"),"customerAddress")}},async deleteAddress(e,{id:t}){let s=await e(L.addressDelete,{id:S("CustomerAddress",t)});return{deleted:u($(s,"customerAddressDelete"),"deletedAddressId")}},async subscriptions(e){let t=u(u(await e(_.subscriptions,{}),"customer"),"subscriptionContracts");return{subscriptions:V(t)}},async subscription(e,{id:t,action:s}){if(!ge(s))throw new p("action");let r=S("SubscriptionContract",t),n=u(u(await e(_.contract,{id:r}),"customer"),"subscriptionContract");if(!n)throw new p("not found",{status:404});let{document:o,payload:i,input:d}=ie[s];if(d==="contract")return{contract:u($(await e(o,{id:r}),i),"contract")};let c=V(u(n,"upcomingBillingCycles")),P=s==="unskip",k=c.find(be=>!!u(be,"skipped")===P);if(!k)throw new p(P?"nothing skipped":"no upcoming delivery to skip");let he={input:{contractId:r,selector:{index:u(k,"cycleIndex")}}};return{billingCycle:u($(await e(o,he),i),"billingCycle")}},async requestReturn(e,{orderId:t,lines:s}){let r=S("Order",t);if(!Array.isArray(s)||!s.length||s.length>50)throw new p("lines");let n=s.map(i=>{let d=Number(u(i,"quantity"));if(!Number.isInteger(d)||d<1||d>1e3)throw new p("quantity");let c={lineItemId:S("LineItem",u(i,"lineItemId")),quantity:d},P=u(i,"reasonId");P&&(c.returnReasonDefinitionId=S("ReturnReasonDefinition",P));let k=B(u(i,"note"),300);return k&&(c.customerNote=k),c}),o=await e(L.returnRequest,{orderId:r,lines:n});return{return:u($(o,"orderRequestReturn"),"return")}}};var X=null;function Te(e){X=e}function v(){if(!X)throw new Error("account-pages: loaded without the account part");return X}var xe={order:e=>["GET",`/order?id=${encodeURIComponent(String(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 T(e,t={}){let{serverBase:s,serverFetch:r,query:n}=v();if(s()){let[i,d]=xe[e](t),c=await r(d,i==="POST"?{method:i,body:t}:{});if(c.kind==="logged-out")throw new D("Not logged in",{code:"NOT_LOGGED_IN",status:401});return c.data}let o=ae[e];if(!o)throw new D(`Customer accounts: no operation ${e}`);try{return await o(async(i,d)=>await n(i,d),t)}catch(i){throw i instanceof p?new D(i.message,{code:"INVALID",userErrors:i.userErrors}):i}}function M(e){v().reset(),se("account-updated",{what:e})}async function K(e){return(await T("order",{id:e})).order??null}async function Q({firstName:e,lastName:t}={}){let s=await T("profile",{firstName:e,lastName:t});return M("profile"),s.customer}async function W(){return(await T("addresses")).addresses}async function H(e,{id:t,isDefault:s}={}){let r=await T("saveAddress",{id:t,address:e,isDefault:s});return M("addresses"),r.address}async function Y(e){let t=await T("deleteAddress",{id:e});return M("addresses"),t.deleted}async function Z(){return(await T("subscriptions")).subscriptions}async function J(e,t){let s=await T("subscription",{id:e,action:t});return M("subscriptions"),s}async function ee(e,t){let s=await T("requestReturn",{orderId:e,lines:t});return M("orders"),s.return}function Ce(e){let t=m(e,"order")||"";return t.startsWith("url:")?new URL(window.location.href).searchParams.get(t.slice(4)||"id"):t}function F(e,t){e.setAttribute(y("order-state"),t),f(e,"order-show",{loading:t==="loading",ready:!1,"not-found":t==="not-found",error:t==="error"})}var Se=e=>({name:e.name,date:C(e.processedAt),total:g(e.totalPrice),subtotal:g(e.subtotal),shipping:g(e.totalShipping),tax:g(e.totalTax),status:E(e.financialStatus),fulfillment:E(e.fulfillmentStatus),"shipping-address":N(e.shippingAddress),"billing-address":N(e.billingAddress),items:e.lineItems.nodes.map(t=>`${t.quantity}\xD7 ${t.title||t.name}`).join(", "),cancelled:e.cancelledAt?C(e.cancelledAt):""});function $e(e,t){let s=t.trackingInformation[0],r={status:E(t.latestShipmentStatus||t.status),date:C(t.createdAt),eta:t.estimatedDeliveryAt?C(t.estimatedDeliveryAt):"",company:s?.company||"",number:s?.number||""};O(e,"fulfillment-bind").forEach(n=>{let o=m(n,"fulfillment-bind")??"";if(o==="url"){let d=s?.url,c=z(d);c&&d&&n.setAttribute("href",d),ne(n,c);return}let i=w(r,o);i!==void 0&&h(n,i)})}function De(e,t){let s=new Map((t.returnInformation?.returnableLineItems.nodes??[]).map(i=>[i.lineItem?.id??"",i.quantity])),r=t.fulfillments.nodes,n=Se(t);l(e,a("order-bind")).forEach(i=>{let d=m(i,"order-bind")??"";if(d==="url"){t.statusPageUrl&&z(t.statusPageUrl)&&i.setAttribute("href",t.statusPageUrl);return}let c=w(n,d);c!==void 0&&h(i,c)}),l(e,a("order-lines")).forEach(i=>{oe(i,t.lineItems.nodes,s)}),l(e,a("order-fulfillments")).forEach(i=>{x(i,r,$e)});let o=e.dataset.tetherReturned==="1";f(e,"order-show",{loading:!1,ready:!0,error:!1,"not-found":!1,cancelled:!!t.cancelledAt,shipped:r.length>0,returnable:[...s.values()].some(i=>i>0),"has-returns":!o&&t.returns.nodes.length>0,"return-requested":o}),e.setAttribute(y("order-state"),"ready")}async function j(e){let t=Ce(e);if(!t){e.setAttribute(y("order-state"),"not-found"),f(e,"order-show",{"not-found":!0});return}F(e,"loading");let s;try{s=await K(t)}catch(r){I(r,"order"),F(e,"error");return}if(!s){F(e,"not-found");return}e.dataset.tetherOrderId=s.id,De(e,s)}var de=[],ue=e=>de.find(t=>t.id===e),Oe=e=>({formatted:N(e),name:[e.firstName,e.lastName].filter(Boolean).join(" "),company:e.company||"",address1:e.address1||"",address2:e.address2||"",city:e.city||"",zip:e.zip||"",province:e.province||"",country:e.country||"",phone:e.phoneNumber||""});function ve(e,t){e.dataset.tetherAddress=t.id;let s=Oe(t);O(e,"address-bind").forEach(r=>{let n=w(s,m(r,"address-bind")??"");n!==void 0&&h(r,n)}),f(e,"address-show",{default:t.isDefault,"not-default":!t.isDefault})}async function R(e){let t=l(e,a("addresses"));if(!t.length)return;f(e,"show",{"addresses-loading":!0,"addresses-empty":!1});let s;try{s=await W()}catch(r){I(r,"addresses"),f(e,"show",{"addresses-loading":!1,"addresses-error":!0});return}de=s,f(e,"show",{"addresses-loading":!1,"addresses-empty":s.length===0,"addresses-error":!1}),t.forEach(r=>{x(r,s,ve)})}function Re(e){let t=e.upcomingBillingCycles.nodes[0],s=e.status,r=s==="ACTIVE";return{active:r,paused:s==="PAUSED",cancelled:s==="CANCELLED",expired:s==="EXPIRED",failed:s==="FAILED",skipped:!!t?.skipped,"can-pause":r,"can-resume":s==="PAUSED"||s==="FAILED","can-skip":r&&t!==void 0&&!t.skipped,"can-unskip":r&&!!t?.skipped,"can-cancel":r||s==="PAUSED"||s==="FAILED"}}function qe(e){let t=E(e.deliveryPolicy?.interval);if(!t)return"";let s=e.deliveryPolicy?.intervalCount?.count??1;return s<=1?t:`${s} ${t}s`}function Pe(e){let t=e.lines.nodes,s=t.reduce((r,n)=>r+Number.parseFloat(n.lineDiscountedPrice?.amount??"0"),0);return{status:E(e.status),next:e.nextBillingDate?C(e.nextBillingDate):"",interval:qe(e),products:t.map(r=>`${r.quantity}\xD7 ${r.title}`).join(", "),total:t.length?g({amount:String(s),currencyCode:e.currencyCode}):"",delivery:g(e.deliveryPrice)}}function ke(e,t){let s={title:t.title,"variant-title":t.variantTitle||"",quantity:String(t.quantity),price:g(t.currentPrice)};O(e,"subscription-line").forEach(r=>{let n=m(r,"subscription-line")??"";if(n==="image"){t.image&&re(r,t.image.url,t.image.altText||t.title);return}let o=w(s,n);o!==void 0&&h(r,o)})}function Ne(e,t){e.dataset.tetherSubscription=t.id,e.setAttribute(y("subscription-status"),E(t.status));let s=Pe(t);l(e,a("subscription-bind")).forEach(n=>{let o=w(s,m(n,"subscription-bind")??"");o!==void 0&&h(n,o)}),l(e,a("subscription-lines")).forEach(n=>{x(n,t.lines.nodes,ke)});let r=Re(t);f(e,"subscription-show",r),l(e,a("subscription-action")).forEach(n=>{let o=w(r,`can-${m(n,"subscription-action")??""}`)===!0;"disabled"in n&&(n.disabled=!o),n.classList.toggle("is-disabled",!o)})}async function G(e){let t=l(e,a("subscriptions"));if(!t.length)return;f(e,"show",{"subscriptions-loading":!0,"subscriptions-empty":!1});let s;try{s=await Z()}catch(r){I(r,"subscriptions"),f(e,"show",{"subscriptions-loading":!1,"subscriptions-error":!0});return}f(e,"show",{"subscriptions-loading":!1,"subscriptions-empty":s.length===0,"subscriptions-error":!1}),t.forEach(r=>{x(r,s,Ne)})}var Le=["pause","resume","skip","unskip","cancel"],Ue=e=>Le.some(t=>t===e),le=e=>e.tagName==="INPUT",fe=e=>e.tagName==="FORM";function ce(e){let t={};for(let s of e.elements){if(!le(s)&&s.tagName!=="SELECT"&&s.tagName!=="TEXTAREA")continue;let r=s;!r.name||r.type==="submit"||r.type==="button"||r.type==="checkbox"||(t[r.name]=r.value)}return t}function Be(e){let s=(e instanceof D?e.userErrors??[]:[]).map(n=>n.message).join(" ");return s||(e instanceof Error&&e.message?e.message:"Something went wrong").replace(/^Customer accounts: /,"")}async function q(e,t){if(e.getAttribute("aria-busy")==="true")return"busy";e.classList.add("is-busy"),e.setAttribute("aria-busy","true"),e.setAttribute(y("form-state"),"pending");let s=l(e,a("form-error"));s.forEach(r=>{h(r,"")});try{return await t(),e.setAttribute(y("form-state"),"saved"),"saved"}catch(r){return e.setAttribute(y("form-state"),"error"),s.forEach(n=>{h(n,Be(r))}),"error"}finally{e.classList.remove("is-busy"),e.removeAttribute("aria-busy")}}var te=e=>{let t=m(e,"confirm");return!t||window.confirm(t)},pe=e=>{e.reset(),delete e.dataset.tetherAddressId};function Me(e){let t=e.target;if(t instanceof window.HTMLFormElement){if(t.matches(a("profile-form")))e.preventDefault(),q(t,async()=>{await Q(ce(t)),await v().bindCustomer(document)});else if(t.matches(a("address-form"))){e.preventDefault();let s=t.dataset.tetherAddressId,r=t.elements.namedItem("isDefault"),n=r instanceof window.HTMLInputElement&&r.checked;q(t,async()=>{await H(ce(t),{id:s,isDefault:n}),pe(t),await R(document)})}}}function Fe(e){let t=ue(e),s=document.querySelector(a("address-form"));if(!(!t||!s||!fe(s))){s.dataset.tetherAddressId=t.id;for(let r of s.elements){if(!le(r)&&r.tagName!=="SELECT"&&r.tagName!=="TEXTAREA")continue;let n=r;if(n.name==="isDefault")n.checked=t.isDefault;else if(n.name&&Object.hasOwn(t,n.name)){let o=Object.entries(t).find(([i])=>i===n.name)?.[1];n.value=typeof o=="string"?o:""}}s.scrollIntoView({block:"nearest"})}}function _e(e,t){let s=t.closest("[data-tether-address]"),r=s instanceof window.HTMLElement?s.dataset.tetherAddress:void 0;if(t.closest(a("address-new"))){let o=document.querySelector(a("address-form"));return o&&fe(o)&&pe(o),!0}if(!(s instanceof window.HTMLElement)||!r)return!1;let n=t.closest(a("address-delete"));if(n){if(e.preventDefault(),!te(n))return!0;q(s,async()=>{await Y(r),await R(document)})}else if(t.closest(a("address-default")))e.preventDefault(),q(s,async()=>{await H(null,{id:r,isDefault:!0}),await R(document)});else if(t.closest(a("address-edit")))e.preventDefault(),Fe(r);else return!1;return!0}function He(e){let t=e.closest("[data-tether-subscription]"),s=m(e,"subscription-action"),r="disabled"in e&&e.disabled===!0||e.classList.contains("is-disabled");if(!(t instanceof window.HTMLElement)||!Ue(s)||r||!te(e))return;let n=t.dataset.tetherSubscription??"";t.setAttribute(y("subscription-state"),"pending"),q(t,async()=>{await J(n,s),await G(document)}).then(o=>{let i=o==="error"?"error":"done";l(document,"[data-tether-subscription]").filter(d=>d===t||d.dataset.tetherSubscription===n).forEach(d=>{d.setAttribute(y("subscription-state"),i)})})}function je(e){let t=e.querySelector(a("return-quantity")),s=e.querySelector(a("return-reason")),r=e.querySelector(a("return-note")),n=c=>c&&"value"in c&&typeof c.value=="string"?c.value:"",o={lineItemId:e.dataset.tetherLine??"",quantity:Number.parseInt(n(t)||"0",10)},i=n(s);i&&(o.reasonId=i);let d=n(r);return d&&(o.note=d),o}function Ge(e){let t=e.closest(a("order"));if(!(t instanceof window.HTMLElement))return;let s=t.dataset.tetherOrderId;if(!s)return;let r=l(t,"[data-tether-line]").map(je).filter(n=>n.quantity>0);!r.length||!te(e)||q(t,async()=>{await ee(s,r),t.dataset.tetherReturned="1",await j(t)})}function ze(e){let t=e.target;if(!(t instanceof window.Element)||_e(e,t))return;let s=t.closest(a("subscription-action"));if(s instanceof window.HTMLElement){e.preventDefault(),He(s);return}let r=t.closest(a("order-return"));r instanceof window.HTMLElement&&(e.preventDefault(),Ge(r))}function me(){document.addEventListener("submit",Me,!0),document.addEventListener("input",e=>{let t=e.target;t instanceof window.HTMLElement&&t.closest(a("profile-form"))&&(t.dataset.tetherTouched="1")}),document.addEventListener("click",ze)}var Ve=["firstName","lastName"];async function Xe(e){let t=await v().customer().catch(r=>(I(r,"account"),null));if(!t||e.tagName!=="FORM")return;let s=e.elements;Ve.forEach(r=>{let n=s.namedItem(r);(n instanceof window.HTMLInputElement||n instanceof window.HTMLTextAreaElement)&&!n.dataset.tetherTouched&&(n.value=t[r]??"")})}var ye=!1;async function qt(e=document){ye||(ye=!0,me()),await Promise.all([...l(e,a("order")).map(t=>j(t)),...l(e,a("profile-form")).map(t=>Xe(t)),R(e),G(e)])}function Pt(e){l(e,a("order")).forEach(t=>{F(t,"error")}),f(e,"show",{"addresses-loading":!1,"addresses-error":!0,"subscriptions-loading":!1,"subscriptions-error":!0})}export{W as addresses,Y as deleteAddress,K as order,qt as renderPages,ee as requestReturn,H as saveAddress,Te as setup,Pt as showUnavailable,J as subscriptionAction,Z as subscriptions,Q as updateProfile};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as g}from"./chunk-MPTQYLSM.js";import"./chunk-NEHZ37TU.js";import"./chunk-JOOEXYF3.js";import{b as c,g as w,i as l,p as k,s as f}from"./chunk-YJLWX2HK.js";import"./chunk-FOMSMIAM.js";var F=500,T={"default-banner":"https://cdn.shopify.com/shopifycloud/privacy-banner/storefront-banner.js",other:"https://cdn.shopify.com/shopifycloud/consent-tracking-api/v0.2/consent-tracking-api.js"},N="https://cdn.shopify.com/storefront/analytics/shopify.js";function y(){return Reflect.get(window,"Shopify")}function S(){let t=c.analytics?.shopify;return typeof t=="object"?t:{}}function x(){try{let t=y()?.customerPrivacy;return t?.consentStatus==="loaded"&&t.currentVisitorConsent?.()?.analytics!=="no"&&!!t.analyticsProcessingAllowed?.()}catch{return!1}}function V(t){let e=`hydrogen:${t}`;return{getTrackingValues:()=>{let n=x()?y()?.customerPrivacy?.__internal:void 0;return{uniqueToken:n?.uniqueToken?.({generateFallback:!0,tag:e})??"",visitToken:n?.visitToken?.({generateFallback:!0,tag:e})??""}}}}var D=t=>(e,n)=>{let o=t.subscribers.get(e)??new Set;return t.subscribers.set(e,o),o.add(n),()=>t.subscribers.get(e)?.delete(n)};function M(t){let e=[],n=[],o={shop:{shopId:t,channel:"headless"},consent:{mode:S().consent||"no-banner"}},r=()=>{if(x())for(let i of e)for(;i.next<n.length;i.next+=1){let s=n[i.next];s&&O(i,s)}},a={getConfig:()=>o,publish(i,s={}){if(n.push({event:i,payload:{shop:o.shop,url:window.location.href,...s}}),n.length>F){n.shift();for(let d of e)d.next=Math.max(0,d.next-1)}r()},addDestination(i){let s={name:i.name,next:0,subscribers:new Map,context:V(i.name)};return Promise.resolve(i.setup?.({subscribe:D(s),getConfig:a.getConfig})).then(()=>{e.push(s),r()}).catch(d=>{l(d,`analytics ${i.name}`)}),()=>{let d=e.indexOf(s);d>=0&&e.splice(d,1)}}};return document.addEventListener("consentTrackingApiLoaded",r),document.addEventListener("visitorConsentCollected",r),a}function O(t,{event:e,payload:n}){t.subscribers.get(e)?.forEach(o=>{try{o(n,t.context)}catch(r){l(r,`analytics ${t.name}`)}})}function C(t){let e=document.createElement("script");e.src=t,e.async=!0,document.head.appendChild(e)}async function E(t){let e=y();if(e?.analytics)return e.analytics;let n=await k("query TetherShopId { shop { id } }",{},{context:!1}),o=y()??{};Reflect.set(window,"Shopify",o),o.country=(c.country||"US").toUpperCase(),o.locale=(c.locale||"en").split("-")[0]?.toLowerCase()??"en",o.shop=c.domain,o.routes={root:"/",match:()=>({pageTemplateName:t()?"product":"page"}),...o.routes};let{proxy:r,consent:a}=S();o.customerPrivacy={...o.customerPrivacy,config:r?{isHeadless:!0,asyncConsent:!0,asyncVisitorState:!0,consentDomain:window.location.host}:{isHeadless:!0,storefrontAccessToken:c.token,checkoutRootDomain:c.domain}};let i=M(n.shop.id);return o.analytics=i,C(a==="default-banner"?T["default-banner"]:T.other),C(N),w("shopify analytics ready",n.shop.id),i}var U="Default Title",A=100,$=200,j=t=>t?parseFloat(t.amount):0,L=t=>(t??"").split("/").pop()??"";function v(t,e,n=1,o){let r={item_id:e?.sku||L(e?.id)||L(t.id),item_name:t.title,item_variant:e?.title===U?void 0:e?.title,item_brand:t.vendor||void 0,item_category:t.productType||void 0,price:j(e?.price??t.priceRange?.minVariantPrice),quantity:n};return o!=null&&(r.index=o),r}var m=(t,e=t.quantity)=>v(t.merchandise.product,t.merchandise,e);function p(t){let e=t.reduce((n,o)=>n+o.price*(o.quantity||1),0);return Math.round(e*A)/A}var B=(t,e,n=1)=>({id:t.id,title:t.title,price:e.price,vendor:t.vendor||"",variantId:e.id,variantTitle:e.title,quantity:n,sku:e.sku||void 0,productType:t.productType||void 0}),P=t=>({id:t.id,quantity:t.quantity,merchandise:{id:t.merchandise.id,title:t.merchandise.title,price:t.merchandise.price,sku:t.merchandise.sku,product:{id:t.merchandise.product.id,title:t.merchandise.product.title,vendor:t.merchandise.product.vendor||"",handle:t.merchandise.product.handle}}});function H(){let{dataLayer:t}=c.analytics??{},e=typeof t=="string"?t:"dataLayer",n=Reflect.get(window,e);if(Array.isArray(n))return n;let o=[];return Reflect.set(window,e,o),o}function W(t,e){let n=H();if(!e){n.push({event:t});return}n.push({ecommerce:null}),n.push({event:t,ecommerce:e})}var h=null,b=null,I=null,_=new WeakSet;function u(t,e,n,o){c.analytics?.dataLayer&&W(t,e),h&&n&&h.publish(n,o);try{c.analytics?.onEvent?.(t,e)}catch(r){l(r,"analytics onEvent")}}function q(){let t=document.querySelector(f("product"));return!t||t.closest(`${f("collection")},${f("products")},${f("recommendations")}`)?null:Reflect.get(window,"Tether").getScope(t)}function G({product:t,scope:e}){if(!e||_.has(e.root)||q()!==e)return;_.add(e.root);let n=e.variant??t.variants.nodes[0],o=[v(t,n)],r=n?[B(t,n)]:[];u("view_item",{currency:n?.price.currencyCode,value:p(o),items:o},"product_viewed",{products:r})}function X({products:t=[],collection:e}){let n=t.slice(0,$).map((r,a)=>v(r,r.variants.nodes[0],1,a)),o={item_list_id:e?.handle||"products",item_list_name:e?.title||"Products"};if(!e){u("view_item_list",{...o,items:n});return}u("view_item_list",{...o,items:n},"collection_viewed",{collection:{id:e.id,handle:e.handle}})}function Y(t,e,n){let o=t?.cost.totalAmount.currencyCode;e.forEach((r,a)=>{let i=n.get(a),s=r.quantity-(i?.quantity??0);if(s<=0)return;let d=[m(r,s)];u("add_to_cart",{currency:o,value:p(d),items:d},"product_added_to_cart",{cart:t,prevCart:I,currentLine:P(r),prevLine:i?P(i):void 0})}),n.forEach((r,a)=>{let i=r.quantity-(e.get(a)?.quantity??0);if(i<=0)return;let s=[m(r,i)];u("remove_from_cart",{currency:o,value:p(s),items:s})})}function Z({cart:t,reason:e}){let n=new Map((t?.lines.nodes??[]).map(o=>[o.merchandise.id,o]));b&&e!=="load"&&e!=="pending"&&Y(t,n,b),b=n,I=t}function z(){let t=g.lines.map(e=>m(e));u("view_cart",{currency:g.state?.cost.totalAmount.currencyCode,value:p(t),items:t})}function J({cart:t}){let e=t.lines.nodes.map(o=>m(o)),n=t.discountCodes.filter(o=>o.applicable).map(o=>o.code);u("begin_checkout",{currency:t.cost.totalAmount.currencyCode,value:p(e),coupon:n.join(",")||void 0,items:e})}function R(t){let e=t.type.slice(c.prefix.length+1),n=Reflect.get(t,"detail");switch(e){case"product-ready":G(n);break;case"list-ready":X(n);break;case"cart-updated":Z(n);break;case"cart-toggled":n.open&&z();break;case"checkout":J(n);break;case"search":{let{term:o}=n;o&&u("search",{search_term:o},"search_viewed",{searchTerm:o});break}case"page":_=new WeakSet,h?.publish("page_viewed",{});break;default:break}}async function it(t){c.analytics?.shopify&&(h=await E(()=>q()!=null).catch(e=>(l(e,"shopify analytics"),null))),h?.publish("page_viewed",{}),t.splice(0).forEach(R),t.push=(...e)=>(e.forEach(R),t.length)}export{it as startAnalytics};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as u,j as s,k as f,p as y}from"./chunk-YJLWX2HK.js";var p=["saved","server","webflow"],b="tether_country",w=()=>`${u.prefix}:market:${u.domain}`;function h(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function C(){let e=typeof window<"u";return{document:typeof document<"u"?document:null,location:e?window.location:null,storage:h(),global:e?window:{}}}function L(e){try{return JSON.parse(e)}catch(t){if(t instanceof SyntaxError)return null;throw t}}function S(e){if(typeof e!="object"||e===null)return null;let t=s(Reflect.get(e,"country"));if(!t)return null;let n=Reflect.get(e,"locale");return{country:t,language:f(Reflect.get(e,"language"))??void 0,locale:typeof n=="string"&&n?n:void 0}}function E(e=h()){let t=e?.getItem(w());return t?S(L(t)):null}function R(e,t){if(!e||!t)return null;let n=e.cookie.split(";").map(r=>r.trim()).find(r=>r.startsWith(`${t}=`));return n?decodeURIComponent(n.slice(t.length+1)):null}function g(e,t){if(!e||!t)return null;let n=t.toLowerCase(),r=Object.keys(e).find(o=>o.toLowerCase()===n);return r?e[r]??null:null}function A(e,t){let n=r=>t.document?.querySelector(`meta[name="${r}"]`)?.getAttribute("content");return{country:Reflect.get(t.global,"TETHER_COUNTRY")||n("tether-country")||R(t.document,e.cookie||b),language:Reflect.get(t.global,"TETHER_LANGUAGE")||n("tether-language")}}function O(e,t){let n=(t.location?.pathname??"/").split("/").find(i=>i!==""),r=g(e.locales,n);if(r)return r;let o=t.document?.documentElement.getAttribute("lang");if(!o)return null;let c=g(e.locales,o)??g(e.locales,o.split("-")[0]);if(c)return{locale:o,...c};if(e.locales&&e.strict)return null;let l=o.split("-")[1];return{language:o,country:l?.length===2?l:null,locale:o}}function x(e,t,n){switch(e){case"saved":return t.remember===!1?null:E(n.storage);case"server":return A(t,n);case"webflow":return O(t,n)}}var I=e=>p.some(t=>t===e);function T(e){return e?e===!0?p:[e].flat().filter(I):["saved"]}function M(e=u.markets,t=C()){let n=e??{};if(n.detect===!1)return{};let r={},o={sources:r};for(let c of T(n.detect)){let l=x(c,n,t);if(!l)continue;let i=s(l.country),d=f(l.language),m=typeof l.locale=="string"&&l.locale?l.locale:null;i&&!o.country&&(o.country=i,r.country=c),d&&!o.language&&(o.language=d,r.language=c),m&&!o.locale&&(o.locale=m,r.locale=c)}return o}function z(e,t){try{localStorage.setItem(e,t)}catch{return}}function $(e){if(u.markets?.remember===!1)return;let t={country:e.country,language:e.language||void 0,locale:e.locale||void 0};z(w(),JSON.stringify(t))}var a=null;function q(){a=null}var N="query TetherLocalization{localization{country{isoCode name currency{isoCode symbol}}language{isoCode name}availableCountries{isoCode name currency{isoCode symbol}availableLanguages{isoCode name}}}}";function H(){return a||(a=y(N).then(t=>t.localization,t=>{throw a=null,t})),a}export{E as a,M as b,$ as c,q as d,H as e};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as S,b as J,c as C,d as K,e as z,f as Z,g as tt}from"./chunk-HEQILZVR.js";import{b as $,e as et}from"./chunk-FCSWQDVV.js";import{b as Y}from"./chunk-MPTQYLSM.js";import{d as W,e as k,f as P,k as X}from"./chunk-JOOEXYF3.js";import{A as m,B as D,C as E,E as B,F as U,G as y,H as F,I as R,J as d,L as T,M as A,N as L,O as G,P as j,Q as H,R as Q,b as w,i as q,r as p,s as o,t as l,u as I,v as f,w as M,x as g,z as _}from"./chunk-YJLWX2HK.js";var dt=/^image:(\d+)$/,it="metafield:",ht=/^(rich_text|multi_line_text)_field$/,pt=["","true","all","*"],V=e=>e.tagName==="SELECT",b=(e,t)=>e.$(`select${t}`).filter(V);function ft(e,t){let i=t.images.nodes,n=[...e.children].map(s=>s.tagName==="IMG"?s:s.querySelector("img"));!D(e)&&n.length===i.length&&n.every((s,r)=>_(s?.getAttribute("src"),i[r]?.url))||E(e,i,(s,r)=>{let c=s.matches(`img,${o("bind","image")}`)?s:f(s,"img")[0]??s;m(c,r.url,r.altText||t.title)})}function mt(e,t,i){let n=i.indexOf("."),a=i.slice(0,n),s=i.slice(n+1),r=(t.metafields??[]).find(u=>u?.namespace===a&&u.key===s);if(!r){d(e,"");return}let c=r.reference?.image;if(c){m(e,c.url,c.altText);return}ht.test(r.type)&&(e.style.whiteSpace="pre-line"),d(e,r.value)}var gt=new Map(Object.entries({title:e=>e.title,"description-text":e=>e.description,vendor:e=>e.vendor,type:e=>e.productType,handle:e=>e.handle,"published-at":e=>F(e.publishedAt),"min-price":e=>y(e.priceRange.minVariantPrice),"max-price":e=>y(e.priceRange.maxVariantPrice)}));function bt(e,t){let i=(e.getAttribute("exclude")??"").split(",").map(a=>a.trim()).filter(Boolean),n=t.tags.filter(a=>!i.includes(a));E(e,n,(a,s)=>{d(a,s)})}function vt(e,t,i){let n=gt.get(t);if(n){d(e,n(i));return}switch(t){case"description":R(e,i.descriptionHtml);break;case"featured-image":m(e,i.featuredImage?.url,i.featuredImage?.altText||i.title);break;case"url":case"link":e.setAttribute("href",B(i.handle,i.id)),t==="url"&&!e.firstElementChild&&!e.textContent.trim()&&d(e,i.title);break;case"images":ft(e,i);break;case"tags":bt(e,i);break;default:xt(e,t,i)}}function xt(e,t,i){let n=dt.exec(t);if(n){let a=i.images.nodes[Number(n[1])-1]??i.featuredImage;m(e,a?.url,a?.altText||i.title)}else t.startsWith(it)&&mt(e,i,t.slice(it.length))}function It(e){let{product:t}=e;e.$(o("option-list")).forEach(i=>{let n=e.optName(l(i,"option-list")),a=t.options.find(s=>s.name===n);if(!a||a.optionValues.length<=1&&I(i,"hide-single")){T(i,!1);return}E(i,a.optionValues,(s,r)=>{s.setAttribute(p("option-value"),r.name);let c=f(s,o("bind","option-value"))[0];c?d(c,r.name):s.firstElementChild||d(s,r.name);let u=f(s,o("bind","swatch"))[0],h=r.swatch;!u||!h||(h.color&&(u.style.backgroundColor=h.color),h.image?.previewImage&&m(u,h.image.previewImage.url,r.name))})})}function Et(e){let{product:t}=e;b(e,o("option")).forEach(i=>{let n=t.options.find(a=>a.name===e.optName(l(i,"option")));if(!n){T(i,!1);return}i.replaceChildren(...n.optionValues.map(a=>new Option(a.name,a.name)))}),b(e,o("variant-select")).forEach(i=>{i.replaceChildren(...t.variants.nodes.map(n=>new Option(n.title,n.id)))}),b(e,o("plan")).forEach(i=>{let n=e.plans.map(r=>new Option(r.name,r.id)),a=!t.requiresSellingPlan&&l(i,"plan")!=="subscription-only",s=i.getAttribute(p("one-time-label"))||"One-time purchase";i.replaceChildren(...a?[new Option(s,"")]:[],...n)})}function yt(e){e.$(o("plan-list")).forEach(t=>{let i=(l(t,"plan-list")??"").trim(),n=pt.includes(i.toLowerCase())?null:i,a=e.plans.filter(s=>!n||s.group.name===n);E(t,a,(s,r)=>{s.setAttribute(p("plan-value"),r.id),!s.firstElementChild&&!s.querySelector(o("plan-bind"))&&d(s,r.name)})})}function nt(e){e.$(o("bind")).forEach(t=>{vt(t,l(t,"bind")??"",e.product)}),It(e),Et(e),yt(e)}var at={money:y,percent:U},Tt=e=>e.tagName==="INPUT";function O(e){let t=f(e,o("add-label"))[0]??e,i=t.dataset.tetherLabel??(Tt(t)?t.value:t.textContent);return t.dataset.tetherLabel=i,{label:t,original:i}}function Pt(e,t){let{product:i}=e,n=a=>t.selected[e.optName(a)]??"";e.$(o("option-selected")).forEach(a=>{d(a,n(l(a,"option-selected")))}),e.$(o("option-list")).forEach(a=>{let s=e.optName(l(a,"option-list"));f(a,o("option-value")).forEach(r=>{let c=l(r,"option-value")??"";A(r,t.selected[s]===c);let u=!J(i,t.selected,s,c);r.classList.toggle("is-unavailable",u),r.setAttribute("data-unavailable",u?"true":"false")})}),b(e,o("option")).forEach(a=>{a.value=n(l(a,"option"))}),b(e,o("variant-select")).forEach(a=>{a.value=t.variant.id})}function At(e,t){let{variant:i,purchase:n,isSubscription:a}=t;e.$(o("purchase")).forEach(s=>{if(V(s)){s.value=n.kind;return}let r=l(s,"purchase");A(s,r===n.kind);let c=r==="subscription"?!t.subscriptionAvailable:e.product.requiresSellingPlan;s.classList.toggle("is-unavailable",c)}),e.$(o("plan-value")).forEach(s=>{let r=l(s,"plan-value")??"";A(s,a&&r===n.planId),s.classList.toggle("is-unavailable",!P(i,r));let c=e.plans.find(h=>h.id===r),u=tt(i,r,c,at);f(s,o("plan-bind")).forEach(h=>{let v=u.get(l(h,"plan-bind")??"");v&&d(h,v())})}),b(e,o("plan")).forEach(s=>{s.value=a?n.planId??"":""})}function St(e,t){let i=new Map(Object.entries(t.show));$.forEach(n=>i.set(n,n==="ready")),e.$(o("show")).forEach(n=>{let a=l(n,"show")??"",s=i.get(a);s!==void 0&&($.some(r=>r===a)&&!et(n,e.root)||T(n,s))})}function Ct(e,t){let i=!t.variant.availableForSale;e.$(o("add-to-cart")).forEach(n=>{n.classList.toggle("is-disabled",i),n.setAttribute("aria-disabled",String(i)),"disabled"in n&&(n.disabled=i);let a=l(n,"soldout-text"),s=l(n,"subscribe-text");if(!a&&!s)return;let{label:r,original:c}=O(n),u=c;t.isSubscription&&s&&(u=s),i&&a&&(u=a),n.getAttribute("aria-busy")!=="true"&&d(r,u)})}function st(e,t){let{variant:i}=t,{product:n}=e,a=Z(t,at);e.$(o("bind")).forEach(s=>{let r=l(s,"bind")??"";if(r==="variant-image"){m(s,i.image?.url||n.featuredImage?.url,i.image?.altText||n.title);return}let c=a.get(r);c&&d(s,c())}),Pt(e,t),At(e,t),St(e,t),e.root.classList.toggle("is-subscription",t.isSubscription),e.root.setAttribute(p("purchase-mode"),t.isSubscription?"subscription":"one-time"),Ct(e,t)}var ot=()=>o("product"),Nt=e=>e.tagName==="INPUT"||e.tagName==="SELECT"||e.tagName==="TEXTAREA",rt=e=>e instanceof window.Element;function x(e,t,i){let n=t.closest(i);return n?.closest(ot())===e.root?n:null}function wt(e,t){let{label:i,original:n}=O(t),a=l(t,"adding-text");j(t,async()=>{a&&d(i,a);try{await e.addToCart()}catch(s){q(s,"add to cart failed"),g("error",{error:s,context:"add-to-cart"},e.root)}finally{a&&d(i,n)}}).then(()=>{e.renderVariant()})}function Lt(e,t,i){let n=x(e,i,o("option-value")),a=n?.closest(o("option-list"));if(n&&a){t.preventDefault(),e.select(e.optName(l(a,"option-list")),l(n,"option-value")??"");return}let s=x(e,i,o("plan-value"));if(s){t.preventDefault(),e.selectPlan(l(s,"plan-value"));return}let r=x(e,i,`${o("purchase")}:not(select)`);if(r){r.tagName!=="INPUT"&&t.preventDefault(),e.setPurchase(l(r,"purchase"));return}let c=x(e,i,o("qty-plus")),u=c?null:x(e,i,o("qty-minus"));if(c||u){t.preventDefault(),e.setQuantity(e.quantity+(c?1:-1));return}let h=x(e,i,o("add-to-cart"));h&&(t.preventDefault(),wt(e,h))}function kt(e,t){let i=Nt(t)?t.value:"";t.matches(`select${o("option")}`)?e.select(e.optName(l(t,"option")),i):t.matches(`select${o("variant-select")}`)?e.selectVariant(i):t.matches(`select${o("plan")}`)?i?e.selectPlan(i):e.setPurchase("one-time"):t.matches(`select${o("purchase")}`)?e.setPurchase(i):t.matches(o("qty"))&&e.setQuantity(i)}function lt(e){e.root.addEventListener("click",t=>{rt(t.target)&&Lt(e,t,t.target)}),e.root.addEventListener("change",t=>{let{target:i}=t;rt(i)&&i.closest(ot())===e.root&&kt(e,i)})}var $t=new WeakMap,Vt=()=>o("product"),N=new Map;function Ot(e){e.forEach(t=>{N.has(t.handle)||N.set(t.handle,t.options.map(i=>i.name))})}var ct=e=>e.tagName==="INPUT",qt=e=>e.tagName==="INPUT"||e.tagName==="SELECT"||e.tagName==="TEXTAREA";function Mt(e){return ct(e)&&e.type==="checkbox"?e.checked?e.value&&e.value!=="on"?e.value:"Yes":null:ct(e)&&e.type==="radio"?e.checked?e.value:null:qt(e)&&e.value||null}var ut=class{constructor(t,i){this.root=t,this.product=i,this.plans=k(i);let n=new URLSearchParams(window.location.search),a=K(i,{variant:n.get("variant")||l(t,"variant"),sellingPlan:n.get("selling_plan"),defaultPlan:l(t,"default-plan"),defaultPurchase:l(t,"default-purchase")||w.defaultPurchase});this.selected=a.selected,this.purchaseChoice=a.purchase,this.variant=null,this.quantity=I(t,"quantity")?Math.max(0,parseInt(l(t,"quantity")??"",10)||0):1,$t.set(t,this),t.setAttribute(p("state"),"ready"),t.removeAttribute(p("error")),this.renderProduct(),lt(this),this.renderVariant(),G(t,"product"),L("product"),g("product-ready",{product:i,scope:this},t)}update(t){let i=this.variant?.id;this.product=t,this.plans=k(t);let n=t.variants.nodes.find(a=>a.id===i);n&&(this.selected=S(n)),this.root.setAttribute(p("state"),"ready"),this.root.removeAttribute(p("error")),this.renderProduct(),this.renderVariant(),L("product"),g("product-updated",{product:t,scope:this},this.root)}$(t){let i=M(this.root,t,Vt());return this.root.matches(t)?[this.root,...i]:i}optName(t){if(!t)return"";let{options:i}=this.product;if(i.some(a=>a.name===t))return t;let n=(N.get(this.product.handle)??[]).indexOf(t);return i[n]?.name??t}get purchase(){return this.purchaseChoice.kind}set purchase(t){let i=t==="subscription"?"subscription":"one-time";this.purchaseChoice=C(this.product,this.variant,{kind:i,planId:this.planId})}get planId(){return this.purchaseChoice.planId}set planId(t){this.purchaseChoice=C(this.product,this.variant,{kind:this.purchase,planId:t})}get plan(){return this.plans.find(t=>t.id===this.planId)??null}get subscriptionAvailable(){return this.plans.some(t=>P(this.variant,t.id))}get isSubscription(){return this.purchase==="subscription"&&P(this.variant,this.planId)!==null}getLine(){if(!this.variant)return null;let t={merchandiseId:this.variant.id,quantity:this.quantity};this.isSubscription&&this.planId&&(t.sellingPlanId=this.planId);let i=this.collectAttributes();return i.length&&(t.attributes=i),t}collectAttributes(){let t=H(this.root,"line-attributes"),i=Q(t),n=this.$(o("line-attribute")).flatMap(a=>{let s=Mt(a);return s===null?[]:[{key:l(a,"line-attribute")??"",value:s}]});return[...i,...n]}select(t,i){if(this.selected[t]===i)return;let n=this.product.variants.nodes.filter(r=>r.selectedOptions.some(c=>c.name===t&&c.value===i)),[a]=n;if(!a)return;let s={...this.selected,[t]:i};if(!n.some(r=>r.selectedOptions.every(c=>s[c.name]===c.value))){let r=u=>u.selectedOptions.filter(v=>v.name!==t&&this.selected[v.name]===v.value).length*2+(u.availableForSale?1:0),c=n.reduce((u,h)=>r(h)>r(u)?h:u,a);Object.assign(s,S(c))}this.selected=s,this.renderVariant()}selectVariant(t){let i=this.product.variants.nodes.find(n=>n.id===W.variant(t));i&&(this.selected=S(i),this.renderVariant())}setPurchase(t){let i=t==="subscription"?"subscription":"one-time",n=C(this.product,this.variant,{kind:i,planId:this.planId});n.kind!==this.purchase&&(this.purchaseChoice=n,this.renderVariant())}selectPlan(t){let i=X(this.product,t);i&&(this.purchaseChoice={kind:"subscription",planId:i.id},this.renderVariant())}setQuantity(t){let i=I(this.root,"quantity")?0:1;this.quantity=Math.max(i,parseInt(String(t),10)||0),this.$(o("qty")).forEach(n=>{d(n,this.quantity)}),this.renderVariant()}async addToCart(){if(!this.variant?.availableForSale)return null;let t=this.getLine();if(!t||t.quantity<1)return null;let i=await Y.add(t);return g("product-added",{product:this.product,variant:this.variant,line:t},this.root),i}renderProduct(){let{product:t}=this;N.has(t.handle)||this.$(`${o("option-list")},select${o("option")}`).map(n=>l(n,"option-list")||l(n,"option")).some(n=>t.options.some(a=>a.name===n))&&Ot([t]),nt(this)}renderVariant(){let t=z(this.product,{selected:this.selected,purchase:this.purchaseChoice,quantity:this.quantity},w.lowStock);if(!t){this.variant=null;return}this.variant=t.variant,this.selected=t.selected,this.purchaseChoice=t.purchase,st(this,t),g("variant-changed",{product:this.product,variant:t.variant,selected:{...t.selected},purchase:t.purchase.kind,sellingPlanId:t.isSubscription?t.purchase.planId:null},this.root)}};export{$t as a,Ot as b,ut as c};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{L as p,r as c,s as i,t as a,w as l}from"./chunk-YJLWX2HK.js";var m="url:";function w(e){try{return decodeURIComponent(e)}catch(t){if(t instanceof URIError)return e;throw t}}function b(e,t=window.location,d="product"){let r=(a(e,d)??"").trim();if(!r.toLowerCase().startsWith(m))return{key:r||null,fromUrl:!1,raw:r};let n=r.slice(m.length).trim(),o;if(n.toLowerCase()==="path"){let s=t.pathname.split("/").filter(Boolean),f=s[s.length-1];o=f===void 0?null:w(f)}else o=new URLSearchParams(t.search).get(n||"handle");return{key:o?.trim()||null,fromUrl:!0,raw:r}}var y=["loading","ready","error","not-found"],S=e=>y.some(t=>t===e),h=e=>typeof e=="object"&&e!==null&&"code"in e?e.code:void 0,x=e=>h(e)==="NOT_FOUND",u=()=>["product","collection","products","recommendations"].map(e=>i(e)).join(","),E=(e,t)=>e===t||e.parentElement?.closest(u())===t;function U(e){let t=h(e);return typeof t=="string"&&t?t:"error"}function A(e,t,d){let r=t==="not-found",n=t==="error"||r;e.setAttribute(c("state"),r?"error":t),n?e.setAttribute(c("error"),r?"not-found":U(d)):e.removeAttribute(c("error")),l(e,i("show"),u()).forEach(o=>{let s=a(o,"show");S(s)&&p(o,s===t)}),n&&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{b as a,y as b,x as c,u as d,E as e,A as f};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var o=Object.defineProperty;var c=(t,r)=>{for(var e in r)o(t,e,{get:r[e],enumerable:!0})};var i={domain:["PUBLIC_SHOPIFY_DOMAIN","PUBLIC_SHOPIFY_STORE_DOMAIN","SHOPIFY_DOMAIN"],token:["PUBLIC_SHOPIFY_STOREFRONT_TOKEN","PUBLIC_SHOPIFY_STOREFRONT_ACCESS_TOKEN","SHOPIFY_STOREFRONT_TOKEN"]};function p(t){if(typeof t!="string")return!1;try{return new URL(t).protocol==="https:"}catch{return!1}}function s(t){return/^shp[a-z]{2}_/.test(t.trim())}function f(t,r){if(!t)return"";let e=parseFloat(t.amount);if(Number.isNaN(e))return"";try{return new Intl.NumberFormat(r||void 0,{style:"currency",currency:t.currencyCode}).format(e)}catch{return`${t.currencyCode} ${e.toFixed(2)}`}}function O(t,r,e){if(!/\{(handle|id)\}/.test(t))return`${t.replace(/\/$/,"")}/${r??String(r)}`;let n=e?e.split("/").pop()??"":"";return t.replace(/\{handle\}/g,encodeURIComponent(r??"")).replace(/\{id\}/g,encodeURIComponent(n))}function S(t){let r=String(t??"").trim();return r?r.startsWith("gid://")?r:/^\d+$/.test(r)?`gid://shopify/Product/${r}`:/\/products\/([^/?#]+)/.exec(r)?.[1]??r:null}export{c as a,i as b,p as c,s as d,f as e,O as f,S as g};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{A as h,C as x,G as d,J as I,L as T,b as u,s as a,t as c,v as s}from"./chunk-YJLWX2HK.js";import{c as g}from"./chunk-FOMSMIAM.js";function U(t,e,o){s(t,a(e)).forEach(r=>{let n=c(r,e)??"";Object.hasOwn(o,n)&&T(r,o[n]===!0)})}var w=(t,e)=>s(t,a(e)).concat(t.matches(a(e))?[t]:[]),C=t=>t?t.toLowerCase().replace(/_/g," "):"",D=t=>(t?.formatted??[]).join(", "),y=(t,e)=>Object.hasOwn(t,e)?t[e]:void 0;function j(t){try{return new Date(t).toLocaleDateString(u.locale)}catch(e){if(e instanceof RangeError)return t;throw e}}function k(t){let e=u.account?.orderUrl;if(e){let o=t.id.split("/").pop()?.split("?")[0]??"";return e.replace("{id}",encodeURIComponent(o))}return g(t.statusPageUrl)?t.statusPageUrl??null:null}var b=(t,e)=>({title:t.title||t.name,"variant-title":t.variantTitle||"",quantity:String(t.quantity),price:d(t.price),total:d(t.totalPrice),sku:t.sku||"",returnable:e===null?void 0:String(e)}),q=t=>t.tagName==="INPUT";function O(t,e,o){U(t,"order-line-show",{returnable:o>0}),s(t,a("return-quantity")).forEach(r=>{q(r)&&(r.max=String(o),r.min="0",r.value||(r.value="0"),r.disabled=o<1)}),s(t,`select${a("return-reason")}`).forEach(r=>{r.dataset.tetherFilled!==e.id&&(r.dataset.tetherFilled=e.id,(e.suggestedReturnReasonDefinitions?.nodes??[]).forEach(n=>{r.appendChild(new Option(n.name,n.id))}))})}function V(t,e,o){x(t,e,(r,n)=>{let i=n.id,f=o&&i?o.get(i)??0:null;i&&(r.dataset.tetherLine=i);let E=b(n,f);w(r,"order-line").forEach(l=>{let m=c(l,"order-line")??"";if(m==="image"){n.image&&h(l,n.image.url,n.image.altText||n.title);return}let p=y(E,m);p!==void 0&&I(l,p)}),i&&f!==null&&O(r,{...n,id:i},f)})}export{j as a,k as b,U as c,w as d,C as e,D as f,y as g,V as h};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as f,e as y,f as m,g as b,h as x,i as v,j as A,k}from"./chunk-JOOEXYF3.js";var S=100,j=100,h=n=>Math.round(parseFloat(n.amount)*S),P=(n,e)=>({amount:(n/S).toFixed(2),currencyCode:e}),C=(n,e)=>P(h(n)*e,n.currencyCode),F=n=>Object.fromEntries(n.selectedOptions.map(e=>[e.name,e.value]));function M(n,e){return n.variants.nodes.find(s=>s.selectedOptions.every(i=>e[i.name]===i.value))??null}function T(n,e,s,i){return n.variants.nodes.some(t=>t.availableForSale&&t.selectedOptions.every(a=>a.name===s?a.value===i:e[a.name]===a.value))}function I(n,e,s){let i=y(n),t=i.find(o=>o.id===s.planId)??i[0];if(!t)return{kind:"one-time",planId:null};let a=m(e,t.id)?t:i.find(o=>m(e,o.id))??t;return n.requiresSellingPlan||s.kind==="subscription"?{kind:"subscription",planId:a.id}:{kind:"one-time",planId:a.id}}function N(n,{variant:e,sellingPlan:s,defaultPlan:i,defaultPurchase:t}){let a=n.variants.nodes,o=f.variant(e),c=a.find(l=>l.id===o)??a.find(l=>l.availableForSale)??a[0]??null,r=k(n,s),p=r??k(n,i),u=r||t==="subscription"?"subscription":"one-time";return{selected:c?F(c):{},purchase:I(n,c,{kind:u,planId:p?.id??null})}}function O(n,e,s,i,t){let a=n.quantityAvailable,o=a!=null&&a>0&&a<=e,c=i.compareAtPrice!==null;return{"in-stock":n.availableForSale,"out-of-stock":!n.availableForSale,backorder:n.availableForSale&&n.currentlyNotInStock,"on-sale":c,"not-on-sale":!c,"has-variants":s>1,"single-variant":s===1,"low-stock":o,"plenty-in-stock":n.availableForSale&&!o,"subscription-available":i.subscriptionAvailable,"subscription-unavailable":!i.subscriptionAvailable,"subscription-only":t,"one-time-available":!t,"subscription-selected":i.isSubscription,"one-time-selected":!i.isSubscription,"has-savings":i.isSubscription?i.savings.percentage>0:c}}function U(n,e,s){let i=M(n,e.selected),t=i??n.variants.nodes[0];if(!t)return null;let a=I(n,t,e.purchase),{planId:o}=a,c=y(n),r=a.kind==="subscription"?m(t,o):null,p=r?b(t,o)??t.price:t.price,u=r?.priceAdjustments[0]?.compareAtPrice??t.compareAtPrice,l={isSubscription:r!==null,subscriptionAvailable:c.some(d=>m(t,d.id)),compareAtPrice:u&&parseFloat(u.amount)>parseFloat(p.amount)?u:null,savings:v(t,o)};return{...l,variant:t,selected:i?e.selected:F(t),purchase:a,plan:c.find(d=>d.id===o)??null,quantity:e.quantity,price:p,show:O(t,s,n.variants.nodes.length,l,n.requiresSellingPlan)}}function w(n,e){let{variant:s,plan:i,price:t,compareAtPrice:a,quantity:o}=n,c=n.purchase.planId,r=g=>C(g,Math.max(1,o)),d={price:()=>e.money(t),"total-price":()=>e.money(r(t)),"one-time-price":()=>e.money(s.price),"subscription-price":()=>e.money(c?b(s,c):null),"subscription-savings":()=>e.percent(n.savings.percentage),"subscription-savings-amount":()=>e.money(n.savings.amount),"checkout-charge":()=>{let g=n.isSubscription?x(s,c)??t:t;return e.money(r(g))},"plan-name":()=>i?.name,"plan-description":()=>i?.description,"plan-group":()=>i?.group.name,"compare-at-price":()=>e.money(a),"unit-price":()=>e.money(s.unitPrice),"discount-percentage":()=>a?`${Math.round((1-parseFloat(t.amount)/parseFloat(a.amount))*j)}%`:"0%","discount-amount":()=>a?e.money(P(h(a)-h(t),t.currencyCode)):"","variant-title":()=>s.title,"variant-id":()=>s.id,sku:()=>s.sku,barcode:()=>s.barcode,stock:()=>s.quantityAvailable,quantity:()=>o};return new Map(Object.entries(d))}function E(n,e,s,i){let a={name:()=>s?.name,option:()=>(s?.options??[]).map(o=>o.value).join(", "),description:()=>s?.description,price:()=>i.money(b(n,e)),savings:()=>i.percent(v(n,e).percentage),"savings-amount":()=>i.money(v(n,e).amount),adjustment:()=>{let o=A(s);return o?o.type==="percentage"?`${o.value}%`:i.money(o.value):""}};return new Map(Object.entries(a))}export{F as a,T as b,I as c,N as d,U as e,w as f,E as g};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{b as d,c as m}from"./chunk-YJLWX2HK.js";import{a as f}from"./chunk-FOMSMIAM.js";var v={};f(v,{GID:()=>p,allPlans:()=>u,allocationFor:()=>c,findPlan:()=>x,hasPlans:()=>$,planAdjustment:()=>F,planCheckoutCharge:()=>h,planPrice:()=>g,planSavings:()=>y,plansForVariant:()=>A,toGid:()=>s});function s(e,i){let t=typeof e=="string"||typeof e=="number"?String(e).trim():"";return t?t.startsWith("gid://")?t:/^\d+$/.test(t)?`gid://shopify/${i}/${t}`:t:null}var p={product:e=>s(e,"Product"),variant:e=>s(e,"ProductVariant"),sellingPlan:e=>s(e,"SellingPlan")};function u(e){return(e?.sellingPlanGroups?.nodes??[]).flatMap(t=>t.sellingPlans.nodes.map(r=>({...r,group:t})))}function $(e){return u(e).length>0}function c(e,i){return!e||!i?null:(e.sellingPlanAllocations?.nodes??[]).find(r=>r.sellingPlan.id===i)??null}function A(e,i){return u(e).filter(t=>c(i,t.id))}function g(e,i){let t=c(e,i)?.priceAdjustments[0];return t?.perDeliveryPrice??t?.price??e?.price??null}function h(e,i){let t=c(e,i);return t?.checkoutChargeAmount??t?.priceAdjustments[0]?.price??e?.price??null}function y(e,i){let t=parseFloat(e?.price.amount??""),r=parseFloat(g(e,i)?.amount??"");return!e||!Number.isFinite(t)||!Number.isFinite(r)||t<=0||r>=t?{amount:null,percentage:0}:{amount:{amount:(t-r).toFixed(2),currencyCode:e.price.currencyCode},percentage:Math.round((1-r/t)*100)}}function F(e){let i=e?.priceAdjustments[0]?.adjustmentValue;if(!i)return null;switch(i.__typename){case"SellingPlanPercentagePriceAdjustment":return{type:"percentage",value:i.adjustmentPercentage};case"SellingPlanFixedAmountPriceAdjustment":return{type:"amount",value:i.adjustmentAmount};case"SellingPlanFixedPriceAdjustment":return{type:"price",value:i.price};default:return null}}function x(e,i){if(!i)return null;let t=u(e),r=p.sellingPlan(i),o=i.trim().toLowerCase();return t.find(l=>l.id===r)??t.find(l=>l.name.toLowerCase()===o)??t.find(l=>l.options.some(P=>P.value.toLowerCase()===o))??null}var n="amount currencyCode",a="url altText width height";function C(e){let i=[];for(let r of e){let o=m(r);o&&i.push(o)}return i.length?`metafields(identifiers:[${i.map(({namespace:r,key:o})=>`{namespace: ${JSON.stringify(r)}, key: ${JSON.stringify(o)}}`).join(", ")}]){namespace key type value reference{... on MediaImage{image{${a}}}}}`:""}var j=` id name description recurringDeliveries options{name value}priceAdjustments{orderCount adjustmentValue{__typename ... on SellingPlanPercentagePriceAdjustment{adjustmentPercentage}... on SellingPlanFixedAmountPriceAdjustment{adjustmentAmount{${n}}}... on SellingPlanFixedPriceAdjustment{price{${n}}}}}`,S=` sellingPlan{id}checkoutChargeAmount{${n}}remainingBalanceChargeAmount{${n}}priceAdjustments{price{${n}}compareAtPrice{${n}}perDeliveryPrice{${n}}unitPrice{${n}}}`;function k(e=d){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{${n}}maxVariantPrice{${n}}}compareAtPriceRange{minVariantPrice{${n}}maxVariantPrice{${n}}}${C(e.metafields)} sellingPlanGroups(first:${e.sellingPlanGroupsFirst}){nodes{name appName options{name values}sellingPlans(first:${e.sellingPlansFirst}){nodes{${j}}}}}variants(first:${e.variantsFirst}){nodes{id title availableForSale currentlyNotInStock quantityAvailable sku barcode selectedOptions{name value}image{${a}}price{${n}}compareAtPrice{${n}}unitPrice{${n}}sellingPlanAllocations(first:${e.sellingPlansFirst}){nodes{${S}}}}}}`}function I(){return` fragment TetherCart on Cart{id checkoutUrl totalQuantity note createdAt updatedAt attributes{key value}buyerIdentity{countryCode email}discountCodes{code applicable}cost{subtotalAmount{${n}}totalAmount{${n}}checkoutChargeAmount{${n}}}lines(first:100){nodes{id quantity attributes{key value}cost{totalAmount{${n}}subtotalAmount{${n}}amountPerQuantity{${n}}compareAtAmountPerQuantity{${n}}}discountAllocations{discountedAmount{${n}}}sellingPlanAllocation{sellingPlan{id name description recurringDeliveries options{name value}}checkoutChargeAmount{${n}}priceAdjustments{price{${n}}compareAtPrice{${n}}perDeliveryPrice{${n}}}}merchandise{... on ProductVariant{id title sku availableForSale requiresShipping quantityAvailable image{${a}}price{${n}}compareAtPrice{${n}}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 }`}export{k as a,I as b,L as c,p as d,u as e,c as f,g,h,y as i,F as j,x as k,v as l};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as pt}from"./chunk-NEHZ37TU.js";import{b as H,d as O,e as ft}from"./chunk-JOOEXYF3.js";import{A as st,C as ct,D as ut,E as lt,G as L,J as V,K as v,L as _,N as dt,R as S,b as i,g as ot,i as C,l as w,p as Q,q as at,r as F,s as c,t as k,v as u,x as g}from"./chunk-YJLWX2HK.js";import{c as it}from"./chunk-FOMSMIAM.js";var Nt='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',Mt=60,X=!1,K=null,Wt=t=>t!==null&&"focus"in t,mt=t=>u(t,Nt).filter(e=>e.offsetParent!==null||e===document.activeElement),I=()=>u(document,c("cart-drawer")),Y=t=>t.classList.contains(i.cartDrawerOpenClass);function h(){let t=I();return t.length?t.some(Y):X}function j(t){u(document,c("cart-open")).forEach(e=>{e.setAttribute("aria-expanded",String(t))}),I().forEach(e=>{e.hasAttribute("role")||e.setAttribute("role","dialog"),!e.hasAttribute("aria-label")&&!e.hasAttribute("aria-labelledby")&&e.setAttribute("aria-label",k(e,"cart-label")||"Cart"),e.setAttribute("aria-modal",String(t)),!Y(e)&&(e.setAttribute("aria-hidden","true"),i.cartFocus&&(e.inert=!0))})}function Gt(t){let e=mt(t)[0]??t;e===t&&!t.hasAttribute("tabindex")&&(t.tabIndex=-1),e.focus({preventScroll:!0})}function B(){if(h())return;X=!0;let t=I().filter(n=>k(n,"cart-drawer")!=="manual");t.forEach(n=>{n.inert=!1,n.classList.add(i.cartDrawerOpenClass),n.setAttribute("aria-hidden","false")}),j(!0);let[e]=t;i.cartFocus&&e&&(K=Wt(document.activeElement)?document.activeElement:null,setTimeout(()=>{Gt(e)},Mt)),i.onCartOpen?.(t),g("cart-toggled",{open:!0})}function z(){if(!h())return;X=!1;let t=I(),e=t.some(n=>n.contains(document.activeElement));t.forEach(n=>{n.classList.remove(i.cartDrawerOpenClass),n.setAttribute("aria-hidden","true"),i.cartFocus&&(n.inert=!0)}),j(!1),e&&K?.isConnected&&K.focus({preventScroll:!0}),K=null,i.onCartClose?.(t),g("cart-toggled",{open:!1})}function gt(){h()?z():B()}function Rt(t){if(t.key!=="Tab"||!i.cartFocus||!h())return;let e=I().find(Y);if(!e)return;let n=mt(e),r=n[0],o=n.at(-1);if(!r||!o)return;let a=document.activeElement,s=t.shiftKey?a===r:a===o;e.contains(a)&&!s||(t.preventDefault(),(t.shiftKey?o:r).focus())}var Vt=/^(-?)(\d+)(?:\.(\d+))?$/;function ht(t,e){let n=Vt.exec(t.trim());if(!n)return null;let[,r="",o="0",a=""]=n,s=BigInt(`${o}${a.padEnd(e,"0")}`);return r==="-"?-s:s}var yt=t=>t.split(".")[1]?.length??0;function bt(t,e){if(t==null||e==null)return!1;let n=Math.max(yt(t.trim()),yt(e.trim())),r=ht(t,n),o=ht(e,n);return r===null||o===null?!1:r>o}var Ct="Default Title",J=(t,e)=>e.get(t.id)?.quantity??t.quantity,wt=t=>t.split("/").pop()??t;function Ht(t){let e=t.merchandise,n=lt(e.product.handle,e.product.id),r=new URLSearchParams;r.set("variant",wt(e.id));let o=t.sellingPlanAllocation?.sellingPlan.id;return o&&r.set("selling_plan",wt(o)),`${n}${n.includes("?")?"&":"?"}${r.toString()}`}var kt=t=>t.merchandise.product.title,vt={title:kt,"product-title":kt,"variant-title":t=>t.merchandise.title===Ct?"":t.merchandise.title,options:t=>t.merchandise.selectedOptions.filter(e=>e.value!==Ct).map(e=>`${e.name}: ${e.value}`).join(", "),vendor:t=>t.merchandise.product.vendor,sku:t=>t.merchandise.sku??"",price:t=>L(t.cost.amountPerQuantity),"compare-at-price":t=>L(t.cost.compareAtAmountPerQuantity??t.merchandise.compareAtPrice),"line-total":t=>L(t.cost.totalAmount),"line-subtotal":t=>L(t.cost.subtotalAmount),quantity:(t,e)=>J(t,e.pending),plan:t=>t.sellingPlanAllocation?.sellingPlan.name??"","plan-description":t=>t.sellingPlanAllocation?.sellingPlan.description??"",components:t=>(t.lineComponents??[]).map(e=>`${e.quantity} \xD7 ${e.merchandise.product.title}`).join(", ")},At="attribute:";function Xt(t,e,n){if(Object.hasOwn(vt,e))return vt[e]?.(t,n);if(!e.startsWith(At))return;let r=e.slice(At.length);return t.attributes.find(o=>o.key===r)?.value??""}function Yt(t,e,n){let r=ft(n),o=!n.requiresSellingPlan&&k(t,"line-plan")!=="subscription-only",a={value:"",label:t.getAttribute(F("one-time-label"))||"One-time purchase"},s=[...o?[a]:[],...r.map(d=>({value:d.id,label:d.name}))],f=s.map(d=>d.value).join("|");t.dataset.tetherSig!==f&&(t.replaceChildren(...s.map(d=>{let T=document.createElement("option");return T.value=d.value,T.textContent=d.label,T})),t.dataset.tetherSig=f),t.value=e.sellingPlanAllocation?.sellingPlan.id??"",_(t,r.length>0)}function zt(t,e,n){let r=!!e.sellingPlanAllocation;t.classList.toggle("is-subscription",r);let o=n.warnings.find(f=>f.target===e.id);t.classList.toggle("is-warning",!!o);let a=n.pending.has(e.id);t.classList.toggle("is-busy",a),a?t.setAttribute("aria-busy","true"):t.removeAttribute("aria-busy"),u(t,c("line","warning")).forEach(f=>{v(f,o?.message??"")});let s={subscription:r,"one-time":!r,"on-sale":bt(e.cost.compareAtAmountPerQuantity?.amount,e.cost.amountPerQuantity.amount),"has-components":(e.lineComponents??[]).length>0,warning:!!o};u(t,c("line-show")).forEach(f=>{let d=k(f,"line-show");d!==null&&Object.hasOwn(s,d)&&_(f,s[d])})}function Jt(t,e,n){let r=e.merchandise;t.setAttribute(F("line-id"),e.id),u(t,c("line")).forEach(o=>{let a=k(o,"line")??"";if(a==="image"){st(o,r.image?.url??r.product.featuredImage?.url,r.product.title);return}if(a==="url"){o.setAttribute("href",Ht(e));return}let s=Xt(e,a,n);s!==void 0&&v(o,s)}),zt(t,e,n),u(t,`select${c("line-plan")}`).forEach(o=>{pt(r.product.handle).then(a=>{Yt(o,e,a)}).catch(a=>{C(a,"line plan options")})})}function Zt(t,e){let n=t?.totalQuantity??0,r=(t?.lines.nodes??[]).some(a=>a.sellingPlanAllocation),o={"cart-empty":n===0,"cart-filled":n>0,"cart-has-subscription":r,"cart-no-subscription":!r,"cart-has-discount":(t?.discountCodes??[]).some(a=>a.applicable),"cart-error":e.failed,"cart-warning":e.warnings.length>0};u(document,c("show")).forEach(a=>{let s=k(a,"show");s===null||!Object.hasOwn(o,s)||a.closest(c("product"))||_(a,o[s])}),u(document,c("checkout")).forEach(a=>{a.classList.toggle("is-disabled",!n),a.setAttribute("aria-disabled",String(!n))})}function te(t){u(document,`textarea${c("cart-note")},input${c("cart-note")}`).forEach(e=>{document.activeElement!==e&&V(e,t?.note??"")}),u(document,c("cart-discounts")).forEach(e=>{ct(e,t?.discountCodes??[],(n,r)=>{n.setAttribute(F("discount-code"),r.code);let o=n.querySelector(c("discount","code"))??(n.firstElementChild?null:n);o&&V(o,r.code),n.classList.toggle("is-inapplicable",!r.applicable)})})}function It(t){let{cart:e}=t,n=r=>e?L(e.cost[r]):"";j(h()),u(document,c("cart-count")).forEach(r=>{v(r,e?.totalQuantity??0)}),u(document,c("cart-subtotal")).forEach(r=>{v(r,n("subtotalAmount"))}),u(document,c("cart-total")).forEach(r=>{v(r,n("totalAmount"))}),u(document,c("cart-checkout-charge")).forEach(r=>{v(r,n("checkoutChargeAmount"))}),Zt(e,t),u(document,c("cart-warning")).forEach(r=>{v(r,[...new Set(t.warnings.map(o=>o.message))].join(" "))}),te(e),u(document,c("cart-lines")).forEach(r=>{ut(r,e?.lines.nodes??[],o=>o.id,(o,a)=>{Jt(o,a,t)},{onEnter:i.onLineEnter,onLeave:i.onLineLeave})}),e&&dt("cart")}function xt(t){u(document,c("cart-count")).forEach(e=>{/^\s*0?\s*$/.test(e.textContent)&&(e.textContent=t)})}var m={kind:"unknown"},$=[],x=new Map,p={accessToken:null,beforeCheckout:null},N=()=>m;function l(){switch(m.kind){case"ready":case"error":return m.cart;case"unknown":case"empty":return null}}var Lt=()=>$,M=t=>t?{kind:"ready",cart:t}:{kind:"empty"},$t=()=>`${i.storageKey}:seen`;function Tt(t){try{return localStorage.getItem(t)}catch{return null}}function Z(t,e){try{e===null?localStorage.removeItem(t):localStorage.setItem(t,e)}catch{}}var E=()=>Tt(i.storageKey)||null;function q(){Z(i.storageKey,null)}function tt(t){m=M(t),t&&Z(i.storageKey,t.id)}function P(){It({cart:l(),warnings:$,pending:x,failed:m.kind==="error"})}function D(t){P(),g("cart-updated",{cart:l(),reason:t})}function y(t,e){return tt(t),Z($t(),`${Date.now()}|${t?.totalQuantity??0}`),D(e),t}function W(t){m=t.kind==="loaded"?M(t.cart):{kind:"error",error:t.error,cart:null},D("load")}function St(t){let e=l();m=t==null?M(e):{kind:"error",error:t,cart:e}}function Ot(){if(m.kind!=="unknown")return;let t=Tt($t())?.split("|")[1];t&&xt(t)}function Pt(t){$=t.filter((e,n)=>t.findIndex(r=>r.message===e.message)===n).map(e=>({...e,message:i.warningText?.(e)||e.message})),$.length&&g("cart-warning",{warnings:$})}var Et=()=>{};function ee(){let t=Promise.resolve();return e=>{let n=t.then(e);return t=n.then(Et,Et),n}}var ne=ee();function b(t){return ne(t).then(e=>(m.kind==="error"&&(m=M(m.cart),P()),e),e=>{throw m={kind:"error",error:e,cart:l()},P(),g("cart-error",{error:e}),e})}var et=t=>J(t,x),re=()=>({open:h(),count:l()?.totalQuantity??0,loaded:m.kind!=="unknown",warnings:$});function qt(t){let e=["cart-updated","cart-toggled"].map(r=>`${i.prefix}:${r}`),n=()=>{t(l(),re())};return e.forEach(r=>{document.addEventListener(r,n)}),n(),()=>{e.forEach(r=>{document.removeEventListener(r,n)})}}var oe=/does not exist|not found|invalid id/i;function G(t){return t instanceof w?t.userErrors?.some(e=>e.field?.[0]==="cartId")?!0:(t.errors??[]).some(e=>oe.test(e.message)):!1}function Ut(t,e=1,n={}){let r=typeof t=="object"&&t!==null?t:{...n,variantId:t,quantity:e},o=O.variant(r.merchandiseId||r.variantId||r.id);if(!o)throw new w("add(): variantId is required");let a=parseInt(String(r.quantity??1),10),s={merchandiseId:o,quantity:Math.max(1,a||1)},f=O.sellingPlan(r.sellingPlanId||r.sellingPlan);f&&(s.sellingPlanId=f);let d=S(r.attributes);return d.length&&(s.attributes=d),s}function ae(t,e,n){return`mutation Tether_${t}(${e}){${t}(${n}){cart{...TetherCart}userErrors{field message}warnings{code message target}}}${H()}`}async function Qt(t,e,n,r){let o=await Q(ae(t,e,n),r),a=at(o[t],t);return Pt(a.warnings??[]),a.cart}function Dt(t){let e={...i.country?{countryCode:i.country.toUpperCase()}:{},...p.accessToken?{customerAccessToken:p.accessToken}:{}},n=Object.keys(e).length?{buyerIdentity:e,...t}:t;return Qt("cartCreate","$input: CartInput!","input: $input",{input:n})}async function A({name:t,args:e,inner:n,variables:r,createInput:o}){let a=E();if(!a)return o?Dt(o):null;try{return await Qt(t,`$cartId: ID!, ${e}`,`cartId: $cartId, ${n}`,{...r,cartId:a})}catch(s){if(!G(s)||(q(),!o))throw s;return ot("cart expired, creating a new one"),Dt(o)}}async function Ft(t){return(await Q(`query TetherCart($id:ID!){cart(id:$id){...TetherCart}}${H()}`,{id:t})).cart}async function _t(t){return(await Q("query TetherCheckout($id: ID!) { cart(id: $id) { checkoutUrl } }",{id:t})).cart?.checkoutUrl??null}function Kt(t,e){let n=typeof e=="number"?{quantity:e}:e,r={id:t};n.quantity!==void 0&&(r.quantity=n.quantity),"sellingPlanId"in n&&(r.sellingPlanId=n.sellingPlanId?O.sellingPlan(n.sellingPlanId):null),n.attributes&&(r.attributes=S(n.attributes));let o=n.merchandiseId||n.variantId;return o&&(r.merchandiseId=O.variant(o)),r}var nt=t=>A({name:"cartLinesUpdate",args:"$lines: [CartLineUpdateInput!]!",inner:"lines: $lines",variables:{lines:t},createInput:null}),rt=t=>A({name:"cartLinesRemove",args:"$lineIds: [ID!]!",inner:"lineIds: $lineIds",variables:{lineIds:t},createInput:null}),jt=(t,e)=>e>0?nt([{id:t,quantity:e}]):rt([t]);var ie=t=>_t(t).then(e=>({kind:"url",url:e}),e=>({kind:"failed",error:e}));async function se(){if(!p.beforeCheckout)return null;try{return await p.beforeCheckout()}catch(t){return C(t,"account checkout"),null}}async function ce(t){let e=ie(t),n=await se();if(!n){let r=await e;if(r.kind==="failed")throw r.error;n=r.url}if(!n)throw new w("No checkoutUrl (cart empty or expired)");return p.accessToken?`${n}${n.includes("?")?"&":"?"}logged_in=true`:n}function ue(t){try{t.opener=null}catch{}}async function Bt(t=i.checkoutTarget){let e=E(),n=l();if(!e||n&&!n.totalQuantity)return null;let r=t==="_blank"?window.open("","_blank"):null;r&&ue(r);try{let o=await ce(e);if(!it(o))throw new w("The checkout URL is not https: not opened");return g("checkout",{url:o,cart:l()}),r&&!r.closed?r.location.href=o:window.location.href=o,o}catch(o){return r?.close(),C(o,"checkout failed"),null}}var R=()=>l()?.lines.nodes??[];function le(t,e){let n=R().find(f=>f.id===t);if(!n)return Promise.resolve(l());let r=Math.max(0,et(n)+e),o={quantity:r};x.set(t,o),D("pending");let a=()=>x.get(t)===o;return b(async()=>{if(!a())return l();if(R().find(T=>T.id===t)?.quantity===r)return l();let d=await jt(t,r);return a()?y(d,r>0?"update":"remove"):(tt(d),d)}).finally(()=>{a()&&(x.delete(t),D("settled"))})}function de(t){let e=(l()?.discountCodes??[]).map(r=>r.code),n=typeof t=="function"?t(e):t;return(Array.isArray(n)?n:[n]).map(r=>r.trim()).filter(Boolean)}function fe(t){let e=new Map((l()?.attributes??[]).map(n=>[n.key,n.value]));return S(t).forEach(n=>e.set(n.key,n.value)),[...e].filter(([,n])=>n!=="").map(([n,r])=>({key:n,value:r}))}async function pe(){let t=E();if(!t)return W({kind:"loaded",cart:null}),null;Ot();try{let e=await Ft(t);e||q(),W({kind:"loaded",cart:e})}catch(e){C(e,"cart load failed"),G(e)&&q(),W({kind:"failed",error:e})}return l()}var U={init:pe,id:E,get status(){return N()},get state(){return l()},get lines(){return R()},get count(){return l()?.totalQuantity??0},get loaded(){return N().kind!=="unknown"},get lastError(){let t=N();return t.kind==="error"?t.error:null},set lastError(t){St(t)},get warnings(){return Lt()},get pendingQty(){return x},get customerAccessToken(){return p.accessToken},set customerAccessToken(t){p.accessToken=t||null},get beforeCheckout(){return p.beforeCheckout},set beforeCheckout(t){p.beforeCheckout=typeof t=="function"?t:null},setCustomer(t){t.accessToken!==void 0&&(p.accessToken=t.accessToken),t.beforeCheckout!==void 0&&(p.beforeCheckout=t.beforeCheckout)},_commit:y,render:P,subscribe:qt,add(t,e=1,n={}){let r=(Array.isArray(t)?t:[t]).map(o=>Ut(o,e,n));return b(async()=>{let o=await A({name:"cartLinesAdd",args:"$lines: [CartLineInput!]!",inner:"lines: $lines",variables:{lines:r},createInput:{lines:r}});return y(o,"add"),g("added",{cart:o,lines:r}),i.openCartOnAdd&&B(),o})},updateLine(t,e){let n=typeof e=="number"?e:e.quantity;if(n!==void 0&&n<=0)return U.removeLine(t);let r=Kt(t,e);return b(async()=>y(await nt([r]),"update"))},changeQuantity:le,quantityOf:et,removeLine(t){let e=Array.isArray(t)?t:[t];return b(async()=>y(await rt(e),"remove"))},clear(){let t=R().map(e=>e.id);return t.length?U.removeLine(t):Promise.resolve(l())},setNote(t){let e={note:t??""};return b(async()=>y(await A({name:"cartNoteUpdate",args:"$note: String!",inner:"note: $note",variables:e,createInput:e}),"note"))},setAttributes(t){return b(async()=>{let e={attributes:fe(t)},n=await A({name:"cartAttributesUpdate",args:"$attributes: [AttributeInput!]!",inner:"attributes: $attributes",variables:e,createInput:e});return y(n,"attributes")})},setDiscountCodes(t){return b(async()=>{let e={discountCodes:de(t)},n=await A({name:"cartDiscountCodesUpdate",args:"$discountCodes: [String!]!",inner:"discountCodes: $discountCodes",variables:e,createInput:e});return y(n,"discount")})},async applyDiscount(t){let e=await U.setDiscountCodes(o=>[...new Set([...o,t])]),n=t.toLowerCase();if((e?.discountCodes??[]).find(o=>o.code.toLowerCase()===n)?.applicable)return e;try{await U.removeDiscount(t)}catch(o){C(o,"removing a discount code Shopify refused")}throw new w(`Discount code not valid: ${t}`,{code:"INVALID_DISCOUNT"})},removeDiscount(t){let e=t.toLowerCase();return U.setDiscountCodes(n=>n.filter(r=>r.toLowerCase()!==e))},setBuyerIdentity(t,{create:e=!0}={}){return b(async()=>{let n=await A({name:"cartBuyerIdentityUpdate",args:"$buyerIdentity: CartBuyerIdentityInput!",inner:"buyerIdentity: $buyerIdentity",variables:{buyerIdentity:t},createInput:e?{buyerIdentity:t}:null}).catch(r=>{if(e||!G(r))throw r;return null});return y(n,"buyer-identity")})},checkout:Bt,drawers:I,isOpen:h,open:B,close:z,toggle:gt};export{Rt as a,U as b};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{a as y,c as q}from"./chunk-JOOEXYF3.js";import{b as I,g as T,l as g,p as h}from"./chunk-YJLWX2HK.js";import{g as E}from"./chunk-FOMSMIAM.js";var _=1e4,N=6e4,d=new Map,w=new Map,f=new Set,m=new Map,K=[],S=!1,p=0,C=t=>t.startsWith("gid://"),P=E;function $(t){if(!t)return;let e=Promise.resolve(t);d.set(t.handle,e),d.set(t.id,e)}function b(t){let e=P(t);if(!e)return Promise.reject(new g("empty product key",{code:"NOT_FOUND"}));let o=d.get(e);if(o)return o;let r=new Promise((i,s)=>{w.set(e,{resolve:i,reject:s}),K.push(e),S||(S=!0,setTimeout(()=>void F(),0))});return d.set(e,r),r}function x(t){let e=t.filter(C),o=t.filter(u=>!C(u)),r=[],i=[],s={};return e.length&&(r.push("$ids: [ID!]!"),s.ids=e,i.push("byId: nodes(ids: $ids) { ... on Product { ...TetherProduct } }")),o.forEach((u,n)=>{r.push(`$h${n}: String!`),s[`h${n}`]=u,i.push(`h${n}: product(handle: $h${n}) { ...TetherProduct }`)}),{query:`query TetherProducts(${r.join(",")}){${i.join(" ")}}${y()}`,variables:s,handles:o}}function v(t,e){let o=w.get(t);w.delete(t),o&&e(o)}function D(t,e){if(e!==p)return;let o=d.get(t);setTimeout(()=>{d.get(t)===o&&d.delete(t)},_)}async function F(){S=!1;let t=p,e=K.splice(0);if(!e.length)return;let{query:o,variables:r,handles:i}=x(e);T("fetch products",e);let s;try{s=await h(o,r)}catch(n){e.forEach(a=>{v(a,c=>{t===p&&d.delete(a),c.reject(n)})});return}let l=new Map;for(let n of s.byId??[])n&&l.set(n.id,n);i.forEach((n,a)=>{let c=s[`h${a}`];c&&l.set(n,c)});let u=Date.now();e.forEach(n=>{v(n,a=>{let c=l.get(n);if(!c){D(n,t),a.reject(new g(`Product not found: ${n}`,{code:"NOT_FOUND"}));return}t===p&&($(c),m.set(c.handle,u),m.set(c.id,u)),a.resolve(c)})})}function L(){d.clear(),p+=1,f.clear(),m.clear()}function Q(t){for(let e of t??[])!e.id||!e.handle||Date.now()-(m.get(e.handle)??0)<N&&d.has(e.handle)||($(e),f.add(e.handle),f.add(e.id))}function W(t){let e=P(t);return!e||!f.has(e)?!1:(f.delete(e),d.get(e)?.then(o=>{f.delete(o.handle),f.delete(o.id)}),!0)}function z(t){for(let e of t){let o=P(e);o&&d.delete(o)}return t.map(e=>b(e))}var M=`query TetherCollection($handle:String!,$first:Int!,$after:String,$sortKey:ProductCollectionSortKeys,$reverse:Boolean,$filters:[ProductFilter!]){collection(handle:$handle){${q()} products(first:$first,after:$after,sortKey:$sortKey,reverse:$reverse,filters:$filters){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}}`,O="query TetherSearch($first:Int!,$after:String,$query:String,$sortKey:ProductSortKeys,$reverse:Boolean){products(first:$first,after:$after,query:$query,sortKey:$sortKey,reverse:$reverse){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}";async function B({collection:t,query:e,first:o=I.collectionFirst,after:r=null,sortKey:i,reverse:s=!1,filters:l}={}){let u=y();if(t){let a=await h(`${M}
|
|
2
|
-
${u}`,{handle:t,first:o,after:r,sortKey:i||void 0,reverse:s,filters:l??void 0});if(!a.collection)throw new g(`Collection not found: ${t}`,{code:"NOT_FOUND"});let{products:c,...R}=a.collection;return c.nodes.forEach($),{collection:R,products:c.nodes,pageInfo:c.pageInfo}}let n=await h(`${O}
|
|
3
|
-
${u}`,{first:o,after:r,query:e||void 0,sortKey:i||void 0,reverse:s});return n.products.nodes.forEach($),{collection:null,products:n.products.nodes,pageInfo:n.products.pageInfo}}async function G(t,e="RELATED"){let o=P(typeof t=="object"?t?.id:t),r=o?.startsWith("gid://")??!1,s=(await h(`query TetherRecs(${r?"$id: ID!":"$handle: String!"},$intent:ProductRecommendationIntent){productRecommendations(${r?"productId: $id":"productHandle: $handle"},intent:$intent){...TetherProduct}}${y()}`,r?{id:o,intent:e}:{handle:o,intent:e})).productRecommendations??[];return s.forEach($),s}export{P as a,$ as b,b as c,L as d,Q as e,W as f,z as g,B as h,G as i};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as S,b as Y,c as _}from"./chunk-2FSXS55U.js";import{a as m,c as g,f}from"./chunk-FCSWQDVV.js";import{c as F,e as M,f as q,g as K,h as W,i as D}from"./chunk-NEHZ37TU.js";import{A as N,C as A,I as O,J as L,L as k,N as I,P as U,b as h,g as R,h as T,i as p,l as $,r as u,s as c,t as i,u as E,v,w as C,x as l}from"./chunk-YJLWX2HK.js";var B="url:",x=()=>`${c("collection")},${c("products")},${c("recommendations")}`,V=t=>t instanceof window.Element,H=t=>parseInt(t??"",10)||void 0,X=t=>t==="COMPLEMENTARY"?"COMPLEMENTARY":"RELATED",J=class{constructor(e){this.root=e,this.products=[],this.pageInfo=null,this.collection=null,this.loadToken=0,f(e,"loading"),e.addEventListener("click",r=>{if(!V(r.target))return;let n=r.target.closest(c("load-more"));n?.closest(x())===e&&(r.preventDefault(),U(n,()=>this.load(!0)))})}$(e){return C(this.root,e,x())}options(){let{root:e}=this,r={reverse:i(e,"reverse")==="true"},n=H(i(e,"limit"));n&&(r.first=n);let o=i(e,"sort");if(o&&(r.sortKey=o),E(e,"collection"))return r.collection=i(e,"collection")??"",r;let s=i(e,"products")??"";return r.query=s.startsWith(B)?new URL(window.location.href).searchParams.get(s.slice(B.length))||"":s,r}async loadRecommendations(){let{key:e}=m(this.root,window.location,"recommendations"),r=this.root.closest(c("product"));if(!e&&r&&({key:e}=m(r)),!e)throw new $("No product for recommendations",{code:"NOT_FOUND"});return D(e,X(i(this.root,"intent")))}async load(e=!1){this.loadToken+=1;let r=this.loadToken,n=()=>r!==this.loadToken;try{if(E(this.root,"recommendations")){let o=await this.loadRecommendations();if(n())return;let s=H(i(this.root,"limit"));this.products=s?o.slice(0,s):o}else{let o=await W({...this.options(),after:e?this.pageInfo?.endCursor??null:null});if(n())return;this.collection=o.collection,this.pageInfo=o.pageInfo,this.products=e?[...this.products,...o.products]:o.products}this.render(),f(this.root,"ready"),l("list-ready",{products:this.products,collection:this.collection},this.root)}catch(o){if(n())return;e||f(this.root,g(o)?"not-found":"error",o),g(o)&&E(this.root,"recommendations")||p(o,"list load failed"),l("error",{error:o,context:"list"},this.root)}}render(){let{collection:e}=this;this.$(c("collection-bind")).forEach(n=>{switch(i(n,"collection-bind")??""){case"title":L(n,e?.title??"");break;case"description":O(n,e?.descriptionHtml);break;case"image":N(n,e?.image?.url,e?.image?.altText||e?.title);break;case"count":L(n,this.products.length);break}}),this.$(c("list")).forEach(n=>{A(n,this.products,(o,s)=>{o.setAttribute(u("product"),s.handle),o.removeAttribute(u("state"))}),l("list-rendered",{container:n},this.root)});let r=this.products.length===0;this.$(c("show")).forEach(n=>{let o=i(n,"show");o==="list-empty"&&k(n,r),o==="list-filled"&&k(n,!r)}),this.$(c("load-more")).forEach(n=>{k(n,!!this.pageInfo?.hasNextPage)}),I("list")}};var Z='script[type="application/json"][data-tether-hydrate]',P=new WeakSet,Pt=new WeakSet,y=new Set,j=new Set,z=new WeakMap;function tt(){y.forEach(t=>{t.isConnected||y.delete(t)}),j.forEach(t=>{t.root.isConnected||j.delete(t)})}function bt(t,e){return[...t.matches?.(e)?[t]:[],...v(t,e)]}function et(t,e){let r=i(t,"page-title");!r||typeof document>"u"||(document.title=r.replace(/\{title\}/g,e.title).replace(/\{vendor\}/g,e.vendor||"").replace(/\{type\}/g,e.productType||""))}function ot(t,{fromUrl:e,raw:r}){e?(P.add(t),f(t,"not-found"),l("product-not-found",{key:null,source:r},t)):t.closest(x())||T(`[${u("product")}] without a value. Bind it to the Shopify handle field, or use "url:handle".`,t)}function rt(t,e,{fromUrl:r,raw:n},o){let s=g(o);if(f(t,s?"not-found":"error",o),!s){p(o,`product ${e}`),l("error",{error:o,context:"product",key:e},t);return}l("product-not-found",{key:e,source:n},t),r?R(`product not found: ${e}`):p(o,`product ${e}`)}function nt(t){if(P.has(t))return!1;let{key:e,...r}=m(t);if(!e)return ot(t,r),!1;P.add(t),y.add(t);let n={};z.set(t,n);let o=()=>z.get(t)===n;return S.get(t)?t.setAttribute(u("state"),"updating"):f(t,"loading"),at(F(e)).then(d=>{if(!o())return;let w=S.get(t);w?w.update(d):new _(t,d),et(t,d),h.revalidate&&q(e)&&st(e)}).catch(d=>{o()&&rt(t,e,r,d)}),!0}function Rt(){tt(),y.forEach(t=>{t.getAttribute(u("state"))!=="error"||t.getAttribute(u("error"))==="not-found"||(P.delete(t),nt(t))})}var b=new Set;function st(t){b.size||setTimeout(ct,0),b.add(t)}function it(t,e){y.forEach(r=>{let n=S.get(r);if(!n||!r.isConnected)return;let o=m(r).key;o!==t&&o!==e.handle&&o!==e.id||JSON.stringify(n.product)!==JSON.stringify(e)&&n.update(e)})}function ct(){let t=[...b];b=new Set,K(t).forEach((e,r)=>{let n=t[r];e.then(o=>{it(n,o)}).catch(o=>{p(o,`refresh ${n}`)})})}var a=null,at=t=>(a?.add(t),t);function dt(){if(!a)return;let t=[...a];Promise.allSettled(t).then(()=>{if(!(!a||t.some(e=>!a?.has(e)))){if(t.length!==a.size){dt();return}a=null,document.documentElement.classList.remove(`${h.prefix}-market-pending`)}})}var ut=t=>!!(t?.id&&t.handle),Q=(t,e)=>(t??"").toUpperCase()===(e??"").toUpperCase(),G=new WeakSet;function Tt(t=document){v(t.ownerDocument??t,Z).forEach(e=>{if(G.has(e))return;G.add(e);let r;try{r=JSON.parse(e.textContent)}catch(w){T("bad data-tether-hydrate",w);return}let{country:n,language:o,products:s}=r??{},d=Array.isArray(s)?s.filter(ut):[];if(Y(d),Q(n,h.country)&&Q(o,h.language)){M(d);return}R("hydration skipped: other market"),a||(a=new Set,document.documentElement.classList.add(`${h.prefix}-market-pending`))})}export{x as a,J as b,P as c,Pt as d,y as e,j as f,tt as g,bt as h,nt as i,Rt as j,at as k,dt as l,Tt as m};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var t={diagnose:()=>import("./diagnose-6VVGZNTY.js"),markets:()=>import("./markets-ui-UNB4PTA7.js"),search:()=>import("./search-OU75RNQL.js"),extras:()=>import("./extras-GJVRDFM3.js"),account:()=>import("./account-C3NP6HFB.js"),"account-pages":()=>import("./account-pages-WLK374FO.js"),analytics:()=>import("./analytics-G3SAWMNL.js")},r=o=>t[o](),a=void 0;export{r as a,a as b};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{e as U,f as R}from"./chunk-FOMSMIAM.js";var b={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:"",cartDrawerOpenClass:"is-open",openCartOnAdd:!0,cartFocus:!0,checkoutTarget:"_self",defaultPurchase:"one-time",variantUrl:!1,maxAge:60,lowStock:5,searchDelay:150,autoMount:!0,observe:!1,astro:!0,partsUrl:null,analytics:null,account:null,warningText:null,formatMoney:null,onLayoutChange:null,onCartOpen:null,onCartClose:null,onLineEnter:null,onLineLeave:null,onValueChange:null,onError:null,debug:!1},i={...b},rt=/^[a-z][a-z0-9-]*$/,nt=/^[A-Za-z0-9_.-]+$/,ot=/^(\$app(:[A-Za-z0-9_-]+)?|[A-Za-z0-9_.-]+)$/,it=["imagesFirst","variantsFirst","sellingPlanGroupsFirst","sellingPlansFirst","collectionFirst","retries","maxAge","lowStock"],st=["warningText","formatMoney","onLayoutChange","onCartOpen","onCartClose","onLineEnter","onLineLeave","onValueChange","onError"];function g(t,e,r){return e!==void 0&&d(`invalid ${t} ${JSON.stringify(e)}: using ${JSON.stringify(r)}`),r}function at(t,e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:g(t,e,b[t])}function F(t,e,r){return r.find(n=>n===e)??g(t,e,r[0])}function ut(t){return typeof t!="string"?"":t.replace(/^https?:\/\//,"").replace(/\/.*$/,"")}function ct(t){let e,r;if(typeof t=="string"){let n=t.indexOf(".");e=n>0?t.slice(0,n):"",r=t.slice(n+1)}else typeof t=="object"&&t!==null&&(e=Reflect.get(t,"namespace"),r=Reflect.get(t,"key"));return typeof e!="string"||typeof r!="string"?null:ot.test(e)&&nt.test(r)?{namespace:e,key:r}:null}function ft(t){if(!Array.isArray(t))return g("metafields",t,[]);let e=[];for(let r of t){let n=ct(r);n?e.push(typeof r=="string"?r:n):g("metafield",r,null)}return e}function lt(t){let e=ut(t.domain),r=typeof t.prefix=="string"&&rt.test(t.prefix)?t.prefix:g("prefix",t.prefix,b.prefix),n={...b,...t,domain:e,prefix:r,storageKey:t.storageKey||`${r}:cart:${e}`,metafields:ft(t.metafields??[]),checkoutTarget:F("checkoutTarget",t.checkoutTarget,["_self","_blank"]),defaultPurchase:F("defaultPurchase",t.defaultPurchase,["one-time","subscription"])};for(let o of it)n[o]=at(o,t[o]);for(let o of st)typeof n[o]!="function"&&(n[o]=null);return n.apiVersion==="unstable"&&d('apiVersion "unstable" changes without notice. Pin a dated version (e.g. 2026-07).'),n}function zt(t={}){let e=lt(t);for(let r of Object.keys(i))r in e||Reflect.deleteProperty(i,r);return Object.assign(i,e)}var Jt=()=>!!(i.domain&&i.token);function k(...t){i.debug&&console.log(`[${i.prefix}]`,...t)}function d(...t){console.warn(`[${i.prefix}]`,...t)}function h(t,e){if(d(e,t instanceof Error&&t.message?t.message:t),!!i.onError)try{i.onError(t,e)}catch(r){d("onError threw",r)}}var pt=/^[A-Z]{2}$/,dt=new Set(["XX","T1"]),mt=new Set(["PT_BR","PT_PT","ZH_CN","ZH_TW"]),gt=/^[A-Z]{2,3}$/;function D(t){let e=(typeof t=="string"?t:"").trim().toUpperCase();return!pt.test(e)||dt.has(e)?null:e}function j(t){let e=(typeof t=="string"?t:"").trim().replace("-","_").toUpperCase();if(mt.has(e))return e;let r=e.split("_")[0]??"";return gt.test(r)?r:null}var l=class extends Error{constructor(e,{status:r,errors:n,userErrors:o,code:s}={}){super(e),this.name="TetherError",this.code=s??(r?`HTTP_${r}`:"ERROR"),this.status=r,this.errors=n,this.userErrors=o}};function ht(t=i){return`https://${t.domain}/api/${t.apiVersion}/graphql.json`}function yt(t,e=i){let r=[],n=D(e.country),o=j(e.language);if(n&&r.push(`country: ${n}`),o&&r.push(`language: ${o}`),!r.length||t.includes("@inContext"))return t;let s=`@inContext(${r.join(", ")})`;return/^\s*\{/.test(t)?`query ${s} ${t.trimStart()}`:t.replace(/^(\s*(?:query|mutation)(?:\s+\w+)?\s*(?:\([^)]*\))?)/,`$1 ${s}`)}var H=300,At=500,V=430,T="quantityAvailable",B=new Set,xt=t=>`${t.domain} ${t.apiVersion} ${t.token}`,Et=t=>new Promise(e=>setTimeout(e,t));function O(t,e){if(t===401||t===403){let r=e.token.startsWith("shpat_")?", not an Admin API token (shpat_\u2026)":"";return`Shopify rejected the Storefront token for ${e.domain} (${t}): use the public Storefront API token (Headless channel)${r}`}return t===404?`Store or API version not found (404): check domain ${e.domain} and apiVersion ${e.apiVersion}`:`HTTP ${t} from ${e.domain}`}function bt(t,e,r){let n=e.map(s=>s.message).filter(Boolean).join(" | "),o=n||"Storefront API error";return t.ok||(o=t.status===401||t.status===403||!n?O(t.status,r):n),new l(o,{status:t.status,errors:e})}async function Tt(t,e,r,n){let o;try{o=await(t.fetch??fetch)(ht(t),{method:"POST",headers:{"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":t.token},body:JSON.stringify({query:e,variables:r})})}catch(u){if(n)return{kind:"retry",backoffMs:H};throw new l(`Network error: ${u instanceof Error?u.message:String(u)}`,{code:"NETWORK"})}if(o.status===V)throw new l("Shopify security rejection (430)",{status:V});if(n&&(o.status===429||o.status>=500))return{kind:"retry",backoffMs:H};let s;try{s=await o.json()}catch{let u=o.ok?`Invalid response (${o.status})`:O(o.status,t);throw new l(u,{status:o.status})}let{data:c,errors:f=[]}=s??{};if(f.length){if(e.includes(T)&&f.some(u=>u.message.includes(T)))return{kind:"inventory-refused"};if(n&&f.some(u=>u.extensions?.code==="THROTTLED"))return{kind:"retry",backoffMs:At};throw bt(o,f,t)}if(!o.ok)throw new l(O(o.status,t),{status:o.status});return{kind:"data",data:c}}async function wt(t,e,r={},{context:n=!0}={}){if(!t.domain||!t.token)throw new l("Tether is not configured: domain and token are required",{code:"NOT_CONFIGURED"});let o=n?yt(e,t):e;t.maxAge>0&&!/^\s*mutation\b/.test(o)&&(o+=` #${Math.floor(Date.now()/(t.maxAge*1e3))}`);let s=xt(t),c=0;for(;;){let f=B.has(s)?o.replaceAll(T,""):o,u=await Tt(t,f,r,c<t.retries);switch(u.kind){case"data":return u.data;case"inventory-refused":k(`the token can't read inventory: ${T} is left out from now on`),B.add(s);break;case"retry":c+=1,k("retry",c),await Et(u.backoffMs*2**c);break}}}var Xt=(t,e,r)=>wt(i,t,e,r);function Qt(t,e){if(!t)throw new l(`${e}: empty response`);let r=t.userErrors??[];if(r.length)throw new l(r.map(n=>n.message).join(" | "),{userErrors:r});return t}var p=t=>`${i.prefix}-${t}`,St=(t,e)=>e===void 0?`[${p(t)}]`:`[${p(t)}="${e}"]`,$=(t,e)=>t.getAttribute(p(e)),Ct=(t,e)=>t.hasAttribute(p(e));function G(t,e){return t?[...t.querySelectorAll(e)]:[]}var kt=(t,e,r)=>G(t,e).filter(n=>n.closest(r)===t);function N(t,e,r=document){r.dispatchEvent(new CustomEvent(`${i.prefix}:${t}`,{detail:e,bubbles:!0}))}function K(t,{width:e,height:r,crop:n}={}){if(!t)return t;let o;try{o=new URL(t)}catch(s){if(s instanceof TypeError)return t;throw s}return e&&o.searchParams.set("width",String(e)),r&&o.searchParams.set("height",String(r)),n&&o.searchParams.set("crop",n),o.toString()}function v(t,e){return t.getAttribute(e)??t.getAttribute(p(e))??t.getAttribute(`data-${e}`)}function z(t,e){if(!t||!e)return t;let r=v(e,"max-width"),n=v(e,"max-height");return K(t,{width:r,height:n,crop:r||n?v(e,"crop"):null})}var J=(t,e)=>!!(t&&e)&&t?.split("?")[0]===e?.split("?")[0];function Ot(t){return/^\s*[a-z][a-z0-9+.-]*:/i.test(t)&&!/^\s*(https?:|data:image\/)/i.test(t)?"none":`url("${t.replace(/["\\\n\r\f]/g,n=>`\\${n.charCodeAt(0).toString(16)} `)}")`}function $t(t,e,r){if(!e)return;let n=z(e,t);if(t.tagName!=="IMG"){t.style.backgroundImage=Ot(n);return}if(J(t.getAttribute("src"),n)){r!=null&&!t.getAttribute("alt")&&t.setAttribute("alt",r);return}t.removeAttribute("srcset"),t.removeAttribute("sizes"),t.setAttribute("src",n),r!=null&&t.setAttribute("alt",r),t.getAttribute("loading")||t.setAttribute("loading","lazy")}var I=new WeakMap,Nt=t=>!!I.get(t),P=t=>t.cloneNode(!0);function q(t){let e=I.get(t);if(e!==void 0)return e;let r=t.firstElementChild,n=r?P(r):null;return I.set(t,n),t.replaceChildren(),n}function vt(t,e,r){let n=q(t);if(!n){e.length&&d("repeater without a template child",t);return}t.replaceChildren(),e.forEach((o,s)=>{let c=P(n);r(c,o,s),t.appendChild(c)})}function It(t,e){let r=()=>{t.remove()};if(!e){r();return}try{e(t,r)}catch(n){h(n,"repeater onLeave"),r()}}function Pt(t,e,r,n){e.forEach((o,s)=>{if(!r.has(o))return;let c=e[s-1];if(c?.parentNode===t?c.after(o):t.prepend(o),!!n)try{n(o)}catch(f){h(f,"repeater onEnter")}})}function Lt(t,e,r,n,{onEnter:o,onLeave:s}={}){let c=q(t);if(!c){d("repeater without a template child",t);return}let f=`data-${i.prefix}-key`,u=`data-${i.prefix}-leaving`,_=()=>[...t.children].filter(a=>a.hasAttribute(f)&&!a.hasAttribute(u)),y=new Map(_().map(a=>[a.getAttribute(f),a])),A=[],x=new Set;e.forEach((a,E)=>{let C=String(r(a,E)),m=y.get(C);m?y.delete(C):(m=P(c),m.setAttribute(f,C),x.add(m)),n(m,a,E,x.has(m)),A.push(m)});let S=A.filter(a=>!x.has(a)),M=_().filter(a=>S.includes(a));if(!(M.length===S.length&&M.every((a,E)=>a===S[E]))){y.forEach(a=>{a.remove()}),A.forEach(a=>t.appendChild(a));return}Pt(t,A,x,o),y.forEach(a=>{a.setAttribute(u,""),a.removeAttribute(f),a.style.pointerEvents="none",a.inert=!0,It(a,s)})}var _t=new Set(["SCRIPT","OBJECT","EMBED","BASE","META","LINK","NOSCRIPT","TEMPLATE","ANIMATE","SET"]),Mt=new Set(["href","src","action","formaction","xlink:href","poster","data","background"]),Ut=/^\s*(javascript|vbscript|data):/i,Rt=/^\s*data:image\/(png|gif|jpeg|webp|avif);/i,Ft=/[- ]/g;function Dt(t,e){let r=e.name.toLowerCase();if(r.startsWith("on")||r==="srcdoc")return!0;let n=e.value.replace(Ft,"");return!Mt.has(r)||!Ut.test(n)?!1:!(t.tagName==="IMG"&&r==="src"&&Rt.test(n))}function jt(t){for(let e of[...t.querySelectorAll("*")]){if(_t.has(e.tagName.toUpperCase())){e.remove();continue}for(let r of[...e.attributes])Dt(e,r)&&e.removeAttribute(r.name)}}function W(t,e=globalThis.document){let r=e.createElement("template");return r.innerHTML=t??"",jt(r.content),r.content}var Y="data-tether-seen",L="data-tether-shown",w="data-tether-prev-display",Ht=120;function pe(t,e){return R(i.productPath||"/product",t,e)}function tt(t,e){try{return t()}catch(r){if(r instanceof RangeError)return e;throw r}}function de(t,e=i.locale){return t?tt(()=>new Intl.NumberFormat(e||void 0,{style:"percent",maximumFractionDigits:0}).format(t/100),`${t}%`):""}function me(t){return t?i.formatMoney?i.formatMoney(t,i.locale):U(t,i.locale):""}function ge(t){return t?tt(()=>new Date(t).toLocaleDateString(i.locale||void 0),""):""}function he(t,e){t.replaceChildren(W(e,t.ownerDocument))}var et=t=>t.tagName==="INPUT"||t.tagName==="TEXTAREA",Z=t=>t.tagName==="INPUT";function Vt(t,e){let r=e==null?"":String(e);et(t)?t.value=r:t.textContent=r}var X=t=>et(t)?t.value:t.textContent;function ye(t,e){let r=X(t);if(Vt(t,e),r!==X(t)&&t.hasAttribute(Y)&&i.onValueChange)try{i.onValueChange(t,r)}catch(n){h(n,"onValueChange")}t.setAttribute(Y,"1")}function Bt(t){if(t.hasAttribute(L))return;t.setAttribute(L,""),t.removeAttribute("hidden");let e=t.getAttribute(w);e!==null?(t.style.display=e,t.removeAttribute(w)):t.style.display==="none"&&(t.style.display=""),typeof getComputedStyle=="function"&&getComputedStyle(t).display==="none"&&(t.style.display=t.getAttribute(p("display"))||"block")}function Ae(t,e){if(e){Bt(t);return}t.removeAttribute(L),!t.hasAttribute(w)&&t.style.display!=="none"&&t.setAttribute(w,t.style.display),t.style.display="none"}function xe(t,e){t.classList.toggle("is-selected",e),t.setAttribute("aria-pressed",e?"true":"false"),Z(t)&&(t.type==="radio"||t.type==="checkbox")&&(t.checked=e);let r=t.querySelector('input[type="radio"],input[type="checkbox"]');r&&Z(r)&&(r.checked=e)}var Q;function Gt(t){clearTimeout(Q),Q=setTimeout(()=>{let{ScrollTrigger:e}=window;i.onLayoutChange?i.onLayoutChange(t):e?.refresh?.(),N("layout-changed",{reason:t})},Ht)}function Ee(t,e){let r=[...t.querySelectorAll("img")].filter(s=>!s.complete),n=r.length,o=()=>{n-=1,n===0&&Gt(`${e}:images`)};r.forEach(s=>{s.addEventListener("load",o,{once:!0}),s.addEventListener("error",o,{once:!0})})}function be(t,e){return t.getAttribute("aria-busy")==="true"?Promise.resolve(void 0):(t.setAttribute("aria-busy","true"),Promise.resolve().then(e).finally(()=>{t.removeAttribute("aria-busy")}))}function Te(t,e){let r=t?$(t,e):null;if(!r)return null;try{return JSON.parse(r)}catch{return d(`invalid JSON in ${p(e)}`,t),null}}function we(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{b as a,i as b,ct as c,lt as d,zt as e,Jt as f,k as g,d as h,h as i,D as j,j as k,l,ht as m,yt as n,wt as o,Xt as p,Qt as q,p as r,St as s,$ as t,Ct as u,G as v,kt as w,N as x,K as y,J as z,$t as A,Nt as B,vt as C,Lt as D,pe as E,de as F,me as G,ge as H,he as I,Vt as J,ye as K,Ae as L,xe as M,Gt as N,Ee as O,be as P,Te as Q,we as R};
|