@occluze/tether 0.6.8 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -11
- package/dist/esm/astro.js +2 -2
- package/dist/esm/chunks/account-UIPWJQ3Y.js +1 -0
- package/dist/esm/chunks/account-pages-6ROA6Y4V.js +1 -0
- package/dist/esm/chunks/analytics-2V632IRV.js +1 -0
- package/dist/esm/chunks/chunk-4GCXM764.js +1 -0
- package/dist/esm/chunks/chunk-56FCLJJD.js +1 -0
- package/dist/esm/chunks/chunk-5Z5O3767.js +1 -0
- package/dist/esm/chunks/chunk-6OZJCAGZ.js +1 -0
- package/dist/esm/chunks/chunk-A5SYCVQM.js +1 -0
- package/dist/esm/chunks/chunk-BA4LQJJQ.js +1 -0
- package/dist/esm/chunks/chunk-BFTZR4OB.js +4 -0
- package/dist/esm/chunks/chunk-C5JYQCWH.js +1 -0
- package/dist/esm/chunks/chunk-E5YO6274.js +1 -0
- package/dist/esm/chunks/chunk-MPDWM2NN.js +1 -0
- package/dist/esm/chunks/chunk-T44MUL4Y.js +1 -0
- package/dist/esm/chunks/chunk-YLUULATY.js +1 -0
- package/dist/esm/chunks/diagnose-3FEKRIEK.js +14 -0
- package/dist/esm/chunks/extras-6POFBNOP.js +1 -0
- package/dist/esm/chunks/markets-ui-FD6NI2OG.js +1 -0
- package/dist/esm/chunks/search-UJ73YBQ5.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 +320 -365
- package/dist/tether.account-pages.min.js +1 -1
- package/dist/tether.account.js +242 -491
- package/dist/tether.account.min.js +1 -1
- package/dist/tether.analytics.js +66 -88
- package/dist/tether.analytics.min.js +1 -1
- package/dist/tether.diagnose.js +36 -33
- package/dist/tether.diagnose.min.js +2 -2
- package/dist/tether.extras.js +28 -36
- package/dist/tether.extras.min.js +1 -1
- package/dist/tether.js +1270 -894
- package/dist/tether.markets.js +73 -90
- 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 +44 -68
- 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/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 +79 -0
- package/dist/types/src/cart/render.d.ts +17 -0
- package/dist/types/src/cart/store.d.ts +182 -0
- package/dist/types/src/cart.d.ts +106 -0
- package/dist/types/src/client.d.ts +100 -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 +185 -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 +88 -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 -23
- package/src/account/addresses-view.ts +58 -0
- package/src/account/answers.ts +79 -0
- package/src/account/markup.ts +36 -0
- package/src/account/operations.ts +145 -0
- package/src/account/{order-lines.js → order-lines.ts} +20 -41
- package/src/account/order-list.ts +107 -0
- package/src/account/order-page.ts +137 -0
- package/src/account/page-answers.ts +317 -0
- package/src/account/{page-events.js → page-events.ts} +55 -90
- package/src/account/server-client.ts +183 -0
- package/src/account/{subscriptions-view.js → subscriptions-view.ts} +25 -68
- package/src/account-api.ts +98 -0
- package/src/account-marks.ts +35 -0
- package/src/{account-pages.js → account-pages.ts} +29 -37
- package/src/account.ts +284 -0
- package/src/amounts.ts +64 -0
- package/src/{analytics-shopify.js → analytics-shopify.ts} +112 -107
- package/src/analytics.ts +315 -0
- package/src/{api-version.js → api-version.ts} +25 -31
- package/src/{astro.js → astro.ts} +110 -104
- package/src/cart/cart-shape.ts +25 -0
- package/src/cart/checkout.ts +101 -0
- package/src/cart/{drawer.js → drawer.ts} +18 -31
- package/src/cart/mutations.ts +237 -0
- package/src/cart/{render.js → render.ts} +68 -96
- package/src/cart/store.ts +279 -0
- package/src/{cart.js → cart.ts} +82 -128
- package/src/client.ts +391 -0
- package/src/{collection.js → collection.ts} +30 -38
- package/src/config-sections.ts +284 -0
- package/src/config.ts +480 -0
- package/src/controls/{cart-controls.js → cart-controls.ts} +22 -54
- package/src/controls/{discount.js → discount.ts} +13 -34
- package/src/controls/{extras.js → extras.ts} +15 -24
- package/src/controls/{navigation.js → navigation.ts} +24 -30
- package/src/{diagnose-markup.js → diagnose-markup.ts} +37 -72
- package/src/{diagnose.js → diagnose.ts} +95 -96
- package/src/dom.ts +268 -0
- package/src/{extras.js → extras.ts} +43 -52
- package/src/fragments.ts +261 -0
- package/src/globals.d.ts +15 -0
- package/src/{images.js → images.ts} +30 -43
- package/src/index.ts +415 -0
- package/src/initial.ts +101 -0
- package/src/lazy-iife.ts +197 -0
- package/src/lazy.ts +42 -0
- package/src/{loader.js → loader.ts} +149 -123
- package/src/market-codes.ts +6 -0
- package/src/{markets-ui.js → markets-ui.ts} +91 -68
- package/src/markets.ts +246 -0
- package/src/markup.ts +127 -0
- package/src/{mounting.js → mounting.ts} +88 -101
- package/src/{page-market.js → page-market.ts} +32 -38
- package/src/part-integrity.ts +7 -0
- package/src/parts/account-pages.ts +7 -0
- package/src/parts/account.ts +7 -0
- package/src/parts/analytics.ts +7 -0
- package/src/parts/diagnose.ts +7 -0
- package/src/parts/extras.ts +7 -0
- package/src/parts/markets.ts +7 -0
- package/src/parts/search.ts +7 -0
- package/src/presets/barba.ts +194 -0
- package/src/{product-events.js → product-events.ts} +33 -48
- package/src/{product-render.js → product-render.ts} +38 -77
- package/src/product-shape.ts +49 -0
- package/src/product-state.ts +318 -0
- package/src/{product.js → product.ts} +90 -126
- package/src/{repeaters.js → repeaters.ts} +40 -52
- package/src/{search.js → search.ts} +85 -103
- package/src/selling-plans.ts +145 -0
- package/src/server.ts +211 -0
- package/src/{shopify-values.js → shopify-values.ts} +24 -22
- package/src/{status.js → status.ts} +34 -54
- package/src/storage.ts +34 -0
- package/src/store-html.ts +359 -0
- package/src/storefront/catalog.ts +196 -0
- package/src/storefront/{json-ld.js → json-ld.ts} +45 -68
- package/src/{variant-render.js → variant-render.ts} +24 -50
- 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-list.js +0 -91
- package/src/account/order-page.js +0 -192
- 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-api.js +0 -118
- package/src/account-links.js +0 -35
- package/src/account.js +0 -342
- package/src/amounts.js +0 -36
- package/src/analytics.js +0 -352
- package/src/cart/checkout.js +0 -97
- package/src/cart/mutations.js +0 -234
- package/src/cart/store.js +0 -326
- package/src/client.js +0 -267
- package/src/config.js +0 -349
- package/src/dom.js +0 -287
- package/src/fragments.js +0 -237
- 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/market-codes.js +0 -35
- package/src/markets.js +0 -334
- package/src/markup.js +0 -64
- 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-state.js +0 -318
- package/src/selling-plans.js +0 -154
- package/src/server.js +0 -215
- package/src/store-html.js +0 -0
- package/src/storefront/catalog.js +0 -199
- 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
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ An open-source, free alternative to Smootify and Storesynk (formerly Shopyflow):
|
|
|
21
21
|
- **Astro too:** build-time product pages with live prices and cart, View Transitions included ([Astro guide](docs/astro.md)).
|
|
22
22
|
- **Hand-over ready:** loading, error and not-found states, `Tether.diagnose()`, error reporting.
|
|
23
23
|
|
|
24
|
-
MIT licensed ·
|
|
24
|
+
MIT licensed · 29 KB gzipped · no dependencies · TypeScript types · [full reference](docs/reference.md) · [comparison](docs/comparison.md) · [changelog](CHANGELOG.md)
|
|
25
25
|
|
|
26
26
|
---
|
|
27
27
|
|
|
@@ -29,15 +29,15 @@ MIT licensed · 25 KB gzipped · no dependencies · TypeScript types · [full re
|
|
|
29
29
|
|
|
30
30
|
| | Pick it when | How |
|
|
31
31
|
|---|---|---|
|
|
32
|
-
| **Script tag** (jsDelivr) | a static site or Webflow, no build step, no login needed | `<script src="https://cdn.jsdelivr.net/gh/ravi-klaassens/tether@0.
|
|
32
|
+
| **Script tag** (jsDelivr) | a static site or Webflow, no build step, no login needed | `<script src="https://cdn.jsdelivr.net/gh/ravi-klaassens/tether@0.7/dist/tether.min.js" defer></script>` ([steps below](#2-add-the-script-to-webflow)) |
|
|
33
33
|
| **npm** | Astro, Vite or another bundler or framework | `npm install @occluze/tether` ([Astro guide](docs/astro.md), [other frameworks](docs/frameworks.md)) |
|
|
34
|
-
| **With the Worker** | you also want the CMS sync, rebuilds when products change, or
|
|
34
|
+
| **With the Worker** | you also want the CMS sync, rebuilds when products change, or customer accounts | either of the above, plus your own free Cloudflare Worker ([Worker](server/README.md), [accounts](docs/accounts.md)) |
|
|
35
35
|
|
|
36
|
-
The script tag pinned to one release: `…/tether@v0.
|
|
37
|
-
(search, accounts, markets, analytics) load from the same folder when a page uses them
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
The script tag pinned to one release: `…/tether@v0.7.0/dist/tether.min.js`. Its optional parts
|
|
37
|
+
(search, accounts, markets, analytics) load from the same folder when a page uses them, each checked
|
|
38
|
+
against a hash built into the core. To host them yourself, put the same release's files in one folder
|
|
39
|
+
and set `partsUrl`. Customer accounts need the Worker
|
|
40
|
+
([setup](docs/accounts.md#setup)): it keeps the customer's tokens, so the browser never holds one.
|
|
41
41
|
|
|
42
42
|
## 1. Connect Shopify (5 minutes)
|
|
43
43
|
|
|
@@ -61,11 +61,11 @@ Site settings → Custom code → **Head**:
|
|
|
61
61
|
productPath: '/product', // your Webflow product template
|
|
62
62
|
};
|
|
63
63
|
</script>
|
|
64
|
-
<script src="https://cdn.jsdelivr.net/gh/ravi-klaassens/tether@0.
|
|
64
|
+
<script src="https://cdn.jsdelivr.net/gh/ravi-klaassens/tether@0.7/dist/tether.min.js" defer></script>
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
**Versions:** `@0.
|
|
68
|
-
`@latest` always takes the newest. Hosting the file yourself? Put the optional parts next to it (`tether.markets.min.js`,
|
|
67
|
+
**Versions:** `@0.7` gets every 0.7.x fix automatically (recommended), `@v0.7.0` pins one release
|
|
68
|
+
(add its [`integrity`](docs/reference.md#config) hash to pin exactly what runs), `@latest` always takes the newest. Hosting the file yourself? Put the optional parts next to it (`tether.markets.min.js`,
|
|
69
69
|
`tether.search.min.js`, `tether.account.min.js`, `tether.account-pages.min.js`, `tether.analytics.min.js`, `tether.extras.min.js`,
|
|
70
70
|
`tether.diagnose.min.js`): each loads only when a page uses it.
|
|
71
71
|
|
package/dist/esm/astro.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`))}function
|
|
1
|
+
import{A as u,B as d,D as h,q as g}from"./chunks/chunk-E5YO6274.js";var w=["src/shop.config.js","src/shop.config.mjs","src/shop.config.ts"],O=new Set(["siteUrl","pageSize"]),y="astro/config",E=/^\s*(?:export\s+)?([\w.-]+)\s*=\s*(.*?)\s*$/,S=/^(["'])(.*?)\1/;function T(n,t=process.argv){let e=n==="dev"?"development":"production",o=t.findIndex(r=>r==="--mode"||r.startsWith("--mode="));if(o<0)return e;let i=t[o]??"";return(i.includes("=")?i.split("=")[1]:t[o+1])??e}var v=n=>n instanceof Error&&"code"in n&&n.code==="ENOENT";async function k(n){let{readFile:t}=await import("node:fs/promises");try{return await t(n,"utf8")}catch(e){if(v(e))return null;throw e}}function _(n,t){for(let e of n.split(/\r?\n/)){let o=E.exec(e);if(!o||e.trim().startsWith("#"))continue;let[,i="",s=""]=o,r=S.exec(s);t[i]=r?r[2]??"":s.replace(/\s+#.*$/,"")}}async function C(n,t){let e=await import("node:path"),o=T(n),i={};for(let s of[".env",".env.local",`.env.${o}`,`.env.${o}.local`]){let r=await k(e.join(t,s));r!==null&&_(r,i)}return{...i,...process.env}}function P(n,t,e){for(let o of["domain","token"]){if(n[o])continue;let i=d[o].find(s=>t[s]);i&&(n[o]=t[i],i.startsWith("PUBLIC_")||e.warn(`${i} is written into every page as Tether's ${o}. Name it PUBLIC_${i} to say so.`))}if(typeof n.token=="string"&&h(n.token))throw new Error("The Shopify token for Tether is a secret token (shpat_/shpss_/\u2026), which would be published in every page. Use the public Storefront API token from the Headless channel.")}async function F(n,t,e){let{existsSync:o}=await import("node:fs"),i=await import("node:path");for(let s of t){let r=i.resolve(n,s);o(r)&&e(r)}}async function I(n){try{return await import(n)}catch(t){if(t instanceof Error&&"code"in t&&t.code==="ERR_MODULE_NOT_FOUND")return null;throw t}}var A=n=>typeof n=="object"&&n!==null&&"string"in n&&typeof n.string=="function";async function N(n){if(!n.updateConfig)return;let t=await I(y),e=typeof t=="object"&&t!==null&&"envField"in t?t.envField:null;if(!A(e))return;let o=()=>e.string({context:"client",access:"public",optional:!0});try{n.updateConfig({env:{schema:{PUBLIC_SHOPIFY_DOMAIN:o(),PUBLIC_SHOPIFY_STOREFRONT_TOKEN:o()}}})}catch(i){n.logger.warn(`.env variables not declared in astro:env: ${u(i)}`)}}function R(n,t){let e=Object.keys(n).filter(o=>typeof n[o]=="function");for(let o of e)Reflect.deleteProperty(n,o);e.length&&t.warn(`${e.join(", ")}: functions can't be passed here. Set them in window.TETHER_CONFIG in your layout.`)}function L(n,t){for(let e of Object.keys(n))e in g||(Reflect.deleteProperty(n,e),O.has(e)||t.warn(`${e} is not a Tether option: left out of the page.`))}function b(n,t){n("head-inline",'window.TETHER_INTEGRATION="astro";'),n("page",["import Tether from '@occluze/tether';",`window.TETHER_CONFIG = { ...${JSON.stringify({autoMount:!1,...t})}, ...(window.TETHER_CONFIG || {}) };`,"Tether.init().then(() => Tether.mount(document));"].join(`
|
|
2
|
+
`))}function U(n={}){let{inject:t=!0,watch:e=w,...o}=n;return{name:"@occluze/tether",hooks:{"astro:config:setup":async i=>{let{injectScript:s,command:r,config:f,logger:a,addWatchFile:p}=i,{fileURLToPath:m}=await import("node:url"),l=f.root?m(f.root):process.cwd();r==="dev"&&p&&await F(l,e??[],p),await N(i);let c={...o};P(c,await C(r,l),a),R(c,a),L(c,a),(!c.domain||!c.token)&&a.warn("No Shopify store configured: set PUBLIC_SHOPIFY_DOMAIN and PUBLIC_SHOPIFY_STOREFRONT_TOKEN in .env (the public Storefront API token)."),t&&b(s,c)}}}}export{U as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{f as j,g as V,h as G,i as R,m as v,n as H}from"./chunk-5Z5O3767.js";import{a as O,c as M}from"./chunk-6OZJCAGZ.js";import{a as W}from"./chunk-C5JYQCWH.js";import{c as q,d as F,e as P}from"./chunk-A5SYCVQM.js";import"./chunk-BFTZR4OB.js";import{C as $,D as _,F as A,H as L,a as f,m as c,n as l,p as d,t as h,w as N,y as D}from"./chunk-BA4LQJJQ.js";import{A as T,C as U,d as I,g as y,r as i,x as E,z as m}from"./chunk-E5YO6274.js";var g=null;function X(){let e=i.account?.server;if(!e)throw new f("Customer accounts need the Worker: set account.server",{code:"NOT_CONFIGURED"});return new URL(e,window.location.href).href.replace(/\/$/,"")}function B(e){e?q(O(),"1"):F(O())}async function ae(e,t){try{return await fetch(e,t)}catch(r){throw new f(`Network error: ${T(r)}`,{code:"NETWORK"})}}async function ue(e){let t;try{t=await e.json()}catch{return{}}return I(t)?t:{}}async function p(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 s=await ae(`${X()}${e}`,n);if(s.status===401)return{kind:"logged-out"};let o=await ue(s);if(!s.ok){let u=y(o.error)??String(s.status),w=G(o.userErrors);throw new f(`Customer accounts: ${u}`,{status:s.status,...w.length>0&&{userErrors:w},...o.code==="INVALID"&&{code:"INVALID"}})}return{kind:"answer",data:o}}async function k(){if(!g){let e=await p("/me");g=e.kind==="answer"&&e.data.loggedIn===!0?{loggedIn:!0,customer:j(e.data.customer)}:{loggedIn:!1}}return B(g.loggedIn),g}var J=()=>g?.loggedIn===!0;function K(){g=null}function z(e){let t=i.account?.navigate;t?t(e):window.location.assign(e)}var de=e=>e||i.account?.locale||(i.locale||"").split("-")[0]||"";function Q({returnTo:e,locale:t}){let r=new URL(`${X()}/login`);r.searchParams.set("returnTo",e);let n=de(t);n&&r.searchParams.set("locale",n),i.country&&r.searchParams.set("country",i.country.toUpperCase()),z(r.toString())}async function Y(){let e=P.id();if(!(await k()).loggedIn||!e)return null;let t=await p("/cart",{method:"POST",body:{cartId:e}});return t.kind==="logged-out"?null:y(t.data.checkoutUrl)}async function Z(e){let t=await p("/logout",{method:"POST",body:{returnTo:e,cartId:P.id()}});g=null,B(!1),h("account-logout",{});let r=t.kind==="answer"?y(t.data.logoutUrl):null;return r?(z(r),"redirected"):"stayed"}var b=10,S=50,ee=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1&&e<=S;function le(e){let t=Number.parseInt(e||String(b),10)||b;return Math.min(Math.max(t,1),S)}var me=e=>e.replace(/\?.*$/,"").replace(/^.*\//,"");function ge(e){let t=i.account?.orderUrl;if(t)return t.replaceAll("{id}",encodeURIComponent(me(e.id)));let r=e.statusPageUrl;return r!==null&&U(r)?r:null}var fe=e=>({name:e.name??"",date:_(e.processedAt),total:$(e.totalPrice),status:e.financialStatus?.toLowerCase(),fulfillment:e.fulfillmentStatus?.toLowerCase(),items:e.lineItems.nodes.map(t=>`${String(t.quantity)}\xD7 ${t.title??""}`).join(", ")});function pe(e,t){let r=t.lineItems.nodes,n=ge(t),s=fe(t);d(e,c("order-bind")).forEach(o=>{let u=l(o,"order-bind")??"";if(u==="url"){n&&o.setAttribute("href",n);return}if(u==="image"){let x=r.find(ce=>ce.image)?.image;x&&N(o,x.url,x.altText||r[0]?.title||"");return}let w=v(s,u);w!==void 0&&A(o,w)}),d(e,c("order-lines")).forEach(o=>{H(o,r,null)}),l(e,"order-bind")==="url"&&n&&e.setAttribute("href",n)}async function te(e,t){let r=d(e,c("orders")),n=r[0];if(!n)return;R(e,"show",{"orders-loading":!0,"orders-empty":!1});let s=le(l(n,"limit")),o;try{o=await t(s)}catch(u){m(u,"orders"),o=null}R(e,"show",{"orders-loading":!1,"orders-empty":o?.length===0}),r.forEach(u=>{D(u,o??[],pe)})}var we=["order","addresses","subscriptions","profile-form","address-form"],he=J;function Pe({returnTo:e=window.location.href,locale:t}={}){return new Promise(r=>{Q({returnTo:e,locale:t}),r()})}async function se(){let e=await k();return e.loggedIn?e.customer:null}async function ye({first:e=b}={}){if(!ee(e))throw new f(`Customer accounts: orders() takes first from 1 to ${String(S)}`,{code:"INVALID"});let t=await p(`/orders?${new URLSearchParams({first:String(e)}).toString()}`);return t.kind==="logged-out"?[]:V(t.data.orders)}async function Ae({returnTo:e=i.account?.logoutUrl||`${window.location.origin}/`}={}){await Z(e)==="stayed"&&await C(document)}async function ve(){try{return(await k()).loggedIn?{kind:"logged-in"}:{kind:"logged-out"}}catch(e){return{kind:"unknown",error:e}}}var re=e=>we.some(t=>d(e,c(t)).length>0);function ke(e){d(e,c("account-link")).forEach(t=>{t.setAttribute("href",be(l(t,"account-link")))})}function be(e){let t=i.account,r=`https://${i.domain}/account`;return e==="payment"?t?.paymentUrl||t?.subscriptionsUrl||r:e==="subscriptions"&&t?.subscriptionsUrl||r}async function C(e=document){let t=await ve();t.kind==="unknown"&&m(t.error,"account");let r=t.kind==="logged-in";if(d(e,c("show")).forEach(n=>{let s=l(n,"show");s==="logged-in"&&L(n,r),s==="logged-out"&&L(n,!r)}),ke(e),t.kind==="unknown"&&re(e)){(await a()).showUnavailable(e);return}r&&(await ie(e),await Promise.all([te(e,n=>ye({first:n})),re(e)?a().then(n=>n.renderPages(e)):null]))}async function ie(e){let t=d(e,c("account-bind"));if(!t.length)return;let r;try{r=await se()}catch(s){m(s,"account");return}if(!r)return;let n={"first-name":r.firstName,"last-name":r.lastName,name:r.displayName,email:r.emailAddress?.emailAddress,address:r.defaultAddress?.formatted.join(", ")};t.forEach(s=>{let o=v(n,l(s,"account-bind")??"");o!=null&&A(s,o)})}var ne=null;function a(){return ne??(ne=W("account-pages").then(e=>(e.setup({serverFetch:p,customer:se,bindCustomer:ie,reset:K}),e))),ne}var Ye=e=>a().then(t=>t.order(e)),Ze=e=>a().then(t=>t.updateProfile(e)),et=()=>a().then(e=>e.addresses()),tt=(e,t)=>a().then(r=>r.saveAddress(e,t)),rt=e=>a().then(t=>t.deleteAddress(e)),nt=()=>a().then(e=>e.subscriptions()),ot=(e,t)=>a().then(r=>r.subscriptionAction(e,t)),st=(e,t)=>a().then(r=>r.requestReturn(e,t));function Se(e){let t=e.target;t instanceof window.Element&&(t.closest(c("account-login"))?(e.preventDefault(),Pe().catch(r=>{m(r,"login")})):t.closest(c("account-logout"))&&(e.preventDefault(),Ae().catch(r=>{m(r,"logout")})))}function xe(){let e=new URL(window.location.href),t=e.searchParams.get("account");if(M(t))switch(e.searchParams.delete("account"),window.history.replaceState(window.history.state,"",e),t){case"in":h("account-login",{});break;case"expired":case"error":h("account-error",{error:t});break}}var oe=!1;async function it(e=document){if(oe){await C(e);return}oe=!0,document.addEventListener("click",Se),xe(),P.setCheckoutResolver(Y),await C(e),E("account",he()?"logged in":"logged out")}export{et as addresses,se as customer,rt as deleteAddress,he as isLoggedIn,Pe as login,Ae as logout,it as mountAccount,Ye as order,ye as orders,C as render,st as requestReturn,tt as saveAddress,ot as subscriptionAction,nt as subscriptions,Ze as updateProfile};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as O,b as ie,c as oe,d as ae,e as S,i as m,j as L,k as E,l as k,m as h,n as de}from"./chunk-5Z5O3767.js";import{C as y,D as C,F as g,H as se,a as H,l as f,m as a,n as p,p as l,t as ne,w as re,y as P}from"./chunk-BA4LQJJQ.js";import{C as G,d as A,e as i,g as d,h as z,i as M,j as q,k as w,l as te,z as x}from"./chunk-E5YO6274.js";var ue={order:{name:"order",method:"GET",path:"/order",fields:{id:!0}},addresses:{name:"addresses",method:"GET",path:"/addresses",fields:{}},subscriptions:{name:"subscriptions",method:"GET",path:"/subscriptions",fields:{}},profile:{name:"profile",method:"POST",path:"/profile",fields:{firstName:!0,lastName:!0}},saveAddress:{name:"saveAddress",method:"POST",path:"/address",fields:{id:!0,address:!0,isDefault:!0}},deleteAddress:{name:"deleteAddress",method:"POST",path:"/address/delete",fields:{id:!0}},subscription:{name:"subscription",method:"POST",path:"/subscription",fields:{id:!0,action:!0}},requestReturn:{name:"requestReturn",method:"POST",path:"/return",fields:{orderId:!0,lines:!0}}},it=new Map(Object.values(ue).map(e=>[`${e.method} ${e.path}`,{...e,fields:Object.keys(e.fields)}]));function le(e,t){let n=ue[e];if(n.method==="POST")return{method:"POST",path:n.path};let r=t,s=new URLSearchParams;for(let u of Object.keys(n.fields)){let c=r[u];(typeof c=="string"||typeof c=="number")&&s.set(u,String(c))}let o=s.toString();return{method:"GET",path:o?`${n.path}?${o}`:n.path}}function me(e){let t=n=>d(i(e,n));return{id:t("id"),firstName:t("firstName"),lastName:t("lastName"),company:t("company"),address1:t("address1"),address2:t("address2"),city:t("city"),province:t("province"),zoneCode:t("zoneCode"),zip:t("zip"),country:t("country"),countryCode:t("countryCode"),phoneNumber:t("phoneNumber"),formatted:te(i(e,"formatted"))}}var ce=e=>A(e)?me(e):null,j=e=>({...me(e),id:S(i(e,"id"),"address id")}),pe=e=>q(e,t=>({...j(t),isDefault:i(t,"isDefault")===!0})),Le=e=>({...oe(e),id:S(i(e,"id"),"line item id"),name:d(i(e,"name")),sku:d(i(e,"sku")),price:O(i(e,"price")),totalPrice:O(i(e,"totalPrice")),suggestedReturnReasonDefinitions:w(i(e,"suggestedReturnReasonDefinitions"),t=>({id:S(i(t,"id"),"return reason id"),name:d(i(t,"name")),handle:d(i(t,"handle"))}))}),Ie=e=>({id:d(i(e,"id")),status:d(i(e,"status")),createdAt:d(i(e,"createdAt")),estimatedDeliveryAt:d(i(e,"estimatedDeliveryAt")),latestShipmentStatus:d(i(e,"latestShipmentStatus")),trackingInformation:q(i(e,"trackingInformation"),t=>({company:d(i(t,"company")),number:d(i(t,"number")),url:d(i(t,"url"))}))});function Re(e){let t=d(i(i(e,"lineItem"),"id"));return{quantity:M(i(e,"quantity")),lineItem:t===null?null:{id:t}}}function Ne(e){return A(e)?{returnableLineItems:w(e.returnableLineItems,Re)}:null}function fe(e){if(!A(e))return null;let t=s=>d(e[s]),n=s=>O(e[s]),r=e.requiresShipping;return{id:S(e.id,"order id"),name:t("name"),number:z(e.number),processedAt:t("processedAt"),cancelledAt:t("cancelledAt"),financialStatus:t("financialStatus"),fulfillmentStatus:t("fulfillmentStatus"),statusPageUrl:t("statusPageUrl"),requiresShipping:typeof r=="boolean"?r:null,totalPrice:n("totalPrice"),subtotal:n("subtotal"),totalShipping:n("totalShipping"),totalTax:n("totalTax"),shippingAddress:ce(e.shippingAddress),billingAddress:ce(e.billingAddress),lineItems:w(e.lineItems,Le),fulfillments:w(e.fulfillments,Ie),returnInformation:Ne(e.returnInformation),returns:w(e.returns,_)}}var ke=e=>({id:d(i(e,"id")),name:d(i(e,"name")),title:d(i(e,"title")),variantTitle:d(i(e,"variantTitle")),quantity:M(i(e,"quantity")),sku:d(i(e,"sku")),currentPrice:O(i(e,"currentPrice")),lineDiscountedPrice:O(i(e,"lineDiscountedPrice")),image:ie(i(e,"image"))}),ge=e=>({cycleIndex:z(i(e,"cycleIndex")),skipped:i(e,"skipped")===!0,billingAttemptExpectedDate:d(i(e,"billingAttemptExpectedDate"))});function De(e){if(!A(e))return null;let t=e.intervalCount;return{interval:d(e.interval),intervalCount:A(t)?{count:M(t.count)}:null}}var ve=e=>({id:S(i(e,"id"),"subscription id"),status:d(i(e,"status")),nextBillingDate:d(i(e,"nextBillingDate")),currencyCode:d(i(e,"currencyCode")),deliveryPrice:O(i(e,"deliveryPrice")),deliveryPolicy:De(i(e,"deliveryPolicy")),lines:w(i(e,"lines"),ke),upcomingBillingCycles:w(i(e,"upcomingBillingCycles"),ge)}),be=e=>q(e,ve);function ye(e){let{contract:t,billingCycle:n}=e;if(A(t))return{contract:{id:d(t.id),status:d(t.status)}};if(A(n)){let{cycleIndex:r,skipped:s}=ge(n);return{billingCycle:{cycleIndex:r,skipped:s}}}throw ae("changed subscription")}function _(e){return{id:S(i(e,"id"),"return id"),status:d(i(e,"status"))}}var he=e=>S(e,"deleted address id"),Ae=e=>({firstName:d(i(e,"firstName")),lastName:d(i(e,"lastName"))});var V=null;function Me(e){V=e}function I(){if(!V)throw new Error("account-pages: loaded without the account part");return V}async function T(e,t){let{serverFetch:n}=I(),{method:r,path:s}=le(e,t),o=await n(s,r==="POST"?{method:r,body:t}:{});if(o.kind==="logged-out")throw new H("Not logged in",{code:"NOT_LOGGED_IN",status:401});return o.data}function D(e){I().reset(),ne("account-updated",{what:e})}async function K(e){let t=await T("order",{id:e});return fe(t.order)}async function Q({firstName:e,lastName:t}={}){let n=await T("profile",{firstName:e,lastName:t});return D("profile"),Ae(n.customer)}async function W(){let e=await T("addresses",{});return pe(e.addresses)}async function F(e,{id:t,isDefault:n}={}){let r=await T("saveAddress",{id:t,address:e,isDefault:n});return D("addresses"),j(r.address)}async function X(e){let t=await T("deleteAddress",{id:e});return D("addresses"),he(t.deleted)}async function Y(){let e=await T("subscriptions",{});return be(e.subscriptions)}async function Z(e,t){let n=await T("subscription",{id:e,action:t});return D("subscriptions"),ye(n)}async function J(e,t){let n=await T("requestReturn",{orderId:e,lines:t});return D("orders"),_(n.return)}function qe(e){let t=p(e,"order")||"";return t.startsWith("url:")?new URL(window.location.href).searchParams.get(t.slice(4)||"id"):t}function v(e,t){e.setAttribute(f("order-state"),t),m(e,"order-show",{loading:t==="loading",ready:!1,"not-found":t==="not-found",error:t==="error"})}var He=e=>({name:e.name??"",date:C(e.processedAt),total:y(e.totalPrice),subtotal:y(e.subtotal),shipping:y(e.totalShipping),tax:y(e.totalTax),status:E(e.financialStatus),fulfillment:E(e.fulfillmentStatus),"shipping-address":k(e.shippingAddress),"billing-address":k(e.billingAddress),items:e.lineItems.nodes.map(t=>`${String(t.quantity)}\xD7 ${t.title||t.name||""}`).join(", "),cancelled:C(e.cancelledAt)});function Fe(e,t){let n=t.trackingInformation[0],r={status:E(t.latestShipmentStatus||t.status),date:C(t.createdAt),eta:C(t.estimatedDeliveryAt),company:n?.company||"",number:n?.number||""};L(e,"fulfillment-bind").forEach(s=>{let o=p(s,"fulfillment-bind")??"";if(o==="url"){let c=n?.url??null,b=c!==null&&G(c);b&&s.setAttribute("href",c),se(s,b);return}let u=h(r,o);u!==void 0&&g(s,u)})}function Be(e,t){let n=new Map((t.returnInformation?.returnableLineItems.nodes??[]).map(u=>[u.lineItem?.id??"",u.quantity])),r=t.fulfillments.nodes,s=He(t);l(e,a("order-bind")).forEach(u=>{let c=p(u,"order-bind")??"";if(c==="url"){let $=t.statusPageUrl;$!==null&&G($)&&u.setAttribute("href",$);return}let b=h(s,c);b!==void 0&&g(u,b)}),l(e,a("order-lines")).forEach(u=>{de(u,t.lineItems.nodes,n)}),l(e,a("order-fulfillments")).forEach(u=>{P(u,r,Fe)});let o=e.dataset.tetherReturned==="1";m(e,"order-show",{loading:!1,ready:!0,error:!1,"not-found":!1,cancelled:!!t.cancelledAt,shipped:r.length>0,returnable:[...n.values()].some(u=>u>0),"has-returns":!o&&t.returns.nodes.length>0,"return-requested":o}),e.setAttribute(f("order-state"),"ready")}async function B(e){let t=qe(e);if(!t){e.setAttribute(f("order-state"),"not-found"),m(e,"order-show",{"not-found":!0});return}v(e,"loading");let n;try{n=await K(t)}catch(r){x(r,"order"),v(e,"error");return}if(!n){v(e,"not-found");return}e.dataset.tetherOrderId=n.id,Be(e,n)}var we=[],xe=e=>we.find(t=>t.id===e),Ue=e=>({formatted:k(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 $e(e,t){e.dataset.tetherAddress=t.id;let n=Ue(t);L(e,"address-bind").forEach(r=>{let s=h(n,p(r,"address-bind")??"");s!==void 0&&g(r,s)}),m(e,"address-show",{default:t.isDefault,"not-default":!t.isDefault})}async function R(e){let t=l(e,a("addresses"));if(!t.length)return;m(e,"show",{"addresses-loading":!0,"addresses-empty":!1});let n;try{n=await W()}catch(r){x(r,"addresses"),m(e,"show",{"addresses-loading":!1,"addresses-error":!0});return}we=n,m(e,"show",{"addresses-loading":!1,"addresses-empty":n.length===0,"addresses-error":!1}),t.forEach(r=>{P(r,n,$e)})}function ze(e){let t=e.upcomingBillingCycles.nodes[0],n=e.status,r=n==="ACTIVE";return{active:r,paused:n==="PAUSED",cancelled:n==="CANCELLED",expired:n==="EXPIRED",failed:n==="FAILED",skipped:!!t?.skipped,"can-pause":r,"can-resume":n==="PAUSED"||n==="FAILED","can-skip":r&&t!==void 0&&!t.skipped,"can-unskip":r&&!!t?.skipped,"can-cancel":r||n==="PAUSED"||n==="FAILED"}}function Ge(e){let t=E(e.deliveryPolicy?.interval);if(!t)return"";let n=e.deliveryPolicy?.intervalCount?.count??1;return n<=1?t:`${String(n)} ${t}s`}function je(e){let t=e.lines.nodes,n=t.reduce((r,s)=>r+Number.parseFloat(s.lineDiscountedPrice?.amount??"0"),0);return{status:E(e.status),next:C(e.nextBillingDate),interval:Ge(e),products:t.map(r=>`${String(r.quantity)}\xD7 ${r.title??""}`).join(", "),total:y(t.length&&e.currencyCode?{amount:String(n),currencyCode:e.currencyCode}:null),delivery:y(e.deliveryPrice)}}function _e(e,t){let n={title:t.title??"","variant-title":t.variantTitle||"",quantity:String(t.quantity),price:y(t.currentPrice)};L(e,"subscription-line").forEach(r=>{let s=p(r,"subscription-line")??"";if(s==="image"){t.image&&re(r,t.image.url,t.image.altText||t.title||"");return}let o=h(n,s);o!==void 0&&g(r,o)})}function Ve(e,t){e.dataset.tetherSubscription=t.id,e.setAttribute(f("subscription-status"),E(t.status));let n=je(t);l(e,a("subscription-bind")).forEach(s=>{let o=h(n,p(s,"subscription-bind")??"");o!==void 0&&g(s,o)}),l(e,a("subscription-lines")).forEach(s=>{P(s,t.lines.nodes,_e)});let r=ze(t);m(e,"subscription-show",r),l(e,a("subscription-action")).forEach(s=>{let o=h(r,`can-${p(s,"subscription-action")??""}`)===!0;"disabled"in s&&(s.disabled=!o),s.classList.toggle("is-disabled",!o)})}async function U(e){let t=l(e,a("subscriptions"));if(!t.length)return;m(e,"show",{"subscriptions-loading":!0,"subscriptions-empty":!1});let n;try{n=await Y()}catch(r){x(r,"subscriptions"),m(e,"show",{"subscriptions-loading":!1,"subscriptions-error":!0});return}m(e,"show",{"subscriptions-loading":!1,"subscriptions-empty":n.length===0,"subscriptions-error":!1}),t.forEach(r=>{P(r,n,Ve)})}var Ke=["pause","resume","skip","unskip","cancel"],Qe=e=>Ke.some(t=>t===e),Ee=e=>e instanceof window.HTMLInputElement||e instanceof window.HTMLSelectElement||e instanceof window.HTMLTextAreaElement,Te=e=>e instanceof window.HTMLFormElement;function Se(e){let t={};for(let n of e.elements)Ee(n)&&(!n.name||n.type==="submit"||n.type==="button"||n.type==="checkbox"||(t[n.name]=n.value));return t}function We(e){let n=(e instanceof H?e.userErrors??[]:[]).map(s=>s.message).join(" ");return n||(e instanceof Error&&e.message?e.message:"Something went wrong").replace(/^Customer accounts: /,"")}async function N(e,t){if(e.getAttribute("aria-busy")==="true")return"busy";e.classList.add("is-busy"),e.setAttribute("aria-busy","true"),e.setAttribute(f("form-state"),"pending");let n=l(e,a("form-error"));n.forEach(r=>{g(r,"")});try{return await t(),e.setAttribute(f("form-state"),"saved"),"saved"}catch(r){return e.setAttribute(f("form-state"),"error"),n.forEach(s=>{g(s,We(r))}),"error"}finally{e.classList.remove("is-busy"),e.removeAttribute("aria-busy")}}var ee=e=>{let t=p(e,"confirm");return!t||window.confirm(t)},Pe=e=>{e.reset(),delete e.dataset.tetherAddressId};function Xe(e){let t=e.target;if(t instanceof window.HTMLFormElement){if(t.matches(a("profile-form")))e.preventDefault(),N(t,async()=>{await Q(Se(t)),await I().bindCustomer(document)});else if(t.matches(a("address-form"))){e.preventDefault();let n=t.dataset.tetherAddressId,r=t.elements.namedItem("isDefault"),s=r instanceof window.HTMLInputElement&&r.checked;N(t,async()=>{await F(Se(t),{id:n,isDefault:s}),Pe(t),await R(document)})}}}function Ye(e){let t=xe(e),n=document.querySelector(a("address-form"));if(!t||!n||!Te(n))return;n.dataset.tetherAddressId=t.id;let r={...t};for(let s of n.elements)if(Ee(s)){if(s.name==="isDefault")s instanceof window.HTMLInputElement&&(s.checked=t.isDefault);else if(s.name&&Object.hasOwn(r,s.name)){let o=r[s.name];s.value=typeof o=="string"?o:""}}n.scrollIntoView({block:"nearest"})}function Ze(e,t){let n=t.closest("[data-tether-address]"),r=n instanceof window.HTMLElement?n.dataset.tetherAddress:void 0;if(t.closest(a("address-new"))){let o=document.querySelector(a("address-form"));return o&&Te(o)&&Pe(o),!0}if(!(n instanceof window.HTMLElement)||!r)return!1;let s=t.closest(a("address-delete"));if(s){if(e.preventDefault(),!ee(s))return!0;N(n,async()=>{await X(r),await R(document)})}else if(t.closest(a("address-default")))e.preventDefault(),N(n,async()=>{await F(null,{id:r,isDefault:!0}),await R(document)});else if(t.closest(a("address-edit")))e.preventDefault(),Ye(r);else return!1;return!0}function Je(e){let t=e.closest("[data-tether-subscription]"),n=p(e,"subscription-action"),r="disabled"in e&&e.disabled===!0||e.classList.contains("is-disabled");if(!(t instanceof window.HTMLElement)||!Qe(n)||r||!ee(e))return;let s=t.dataset.tetherSubscription??"";t.setAttribute(f("subscription-state"),"pending"),N(t,async()=>{await Z(s,n),await U(document)}).then(o=>{let u=o==="error"?"error":"done";l(document,"[data-tether-subscription]").filter(c=>c===t||c.dataset.tetherSubscription===s).forEach(c=>{c.setAttribute(f("subscription-state"),u)})})}function et(e){let t=e.querySelector(a("return-quantity")),n=e.querySelector(a("return-reason")),r=e.querySelector(a("return-note")),s=b=>b&&"value"in b&&typeof b.value=="string"?b.value:"",o={lineItemId:e.dataset.tetherLine??"",quantity:Number.parseInt(s(t)||"0",10)},u=s(n);u&&(o.reasonId=u);let c=s(r);return c&&(o.note=c),o}function tt(e){let t=e.closest(a("order"));if(!(t instanceof window.HTMLElement))return;let n=t.dataset.tetherOrderId;if(!n)return;let r=l(t,"[data-tether-line]").map(et).filter(s=>s.quantity>0);!r.length||!ee(e)||N(t,async()=>{await J(n,r),t.dataset.tetherReturned="1",await B(t)})}function nt(e){let t=e.target;if(!(t instanceof window.Element)||Ze(e,t))return;let n=t.closest(a("subscription-action"));if(n instanceof window.HTMLElement){e.preventDefault(),Je(n);return}let r=t.closest(a("order-return"));r instanceof window.HTMLElement&&(e.preventDefault(),tt(r))}function Ce(){document.addEventListener("submit",Xe,!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",nt)}var rt=["firstName","lastName"];async function st(e){if(!(e instanceof window.HTMLFormElement))return;let t;try{t=await I().customer()}catch(r){x(r,"account");return}if(!t)return;let n=e.elements;rt.forEach(r=>{let s=n.namedItem(r);(s instanceof window.HTMLInputElement||s instanceof window.HTMLTextAreaElement)&&!s.dataset.tetherTouched&&(s.value=t[r]??"")})}var Oe=!1;async function Qt(e=document){Oe||(Oe=!0,Ce()),await Promise.all([...l(e,a("order")).map(t=>B(t)),...l(e,a("profile-form")).map(t=>st(t)),R(e),U(e)])}function Wt(e){l(e,a("order")).forEach(t=>{v(t,"error")}),m(e,"show",{"addresses-loading":!1,"addresses-error":!0,"subscriptions-loading":!1,"subscriptions-error":!0})}export{W as addresses,X as deleteAddress,K as order,Qt as renderPages,J as requestReturn,F as saveAddress,Me as setup,Wt as showUnavailable,Z as subscriptionAction,Y as subscriptions,Q as updateProfile};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as A}from"./chunk-56FCLJJD.js";import"./chunk-T44MUL4Y.js";import"./chunk-MPDWM2NN.js";import{e as h}from"./chunk-A5SYCVQM.js";import"./chunk-BFTZR4OB.js";import{d as k,h as E,m as p,r as _,s as w}from"./chunk-BA4LQJJQ.js";import{r as a,x as T,z as l}from"./chunk-E5YO6274.js";var F=500,S={"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"},O="https://cdn.shopify.com/storefront/analytics/shopify.js",x=()=>window,m=()=>x().Shopify;function L(){let t=a.analytics?.shopify;return typeof t=="object"?t:{}}function I(){try{let t=m()?.customerPrivacy;return t?.consentStatus==="loaded"&&t.currentVisitorConsent?.()?.analytics!=="no"&&!!t.analyticsProcessingAllowed?.()}catch{return!1}}function j(t){let e=`hydrogen:${t}`;return{getTrackingValues:()=>{let n=I()?m()?.customerPrivacy?.__internal:void 0;return{uniqueToken:n?.uniqueToken?.({generateFallback:!0,tag:e})??"",visitToken:n?.visitToken?.({generateFallback:!0,tag:e})??""}}}}var $=t=>(e,n)=>{let i=t.subscribers.get(e)??new Set;return t.subscribers.set(e,i),i.add(n),()=>t.subscribers.get(e)?.delete(n)};function U(t){let e=[],n=[],i={shop:{shopId:t,channel:"headless"},consent:{mode:L().consent||"no-banner"}},o=()=>{if(I())for(let r of e)for(;r.next<n.length;r.next+=1){let s=n[r.next];s&&G(r,s)}},c={getConfig:()=>i,publish(r,s={}){if(n.push({event:r,payload:{shop:i.shop,url:window.location.href,...s}}),n.length>F){n.shift();for(let d of e)d.next=Math.max(0,d.next-1)}o()},addDestination(r){let s={name:r.name,next:0,subscribers:new Map,context:j(r.name)};return Promise.resolve(r.setup?.({subscribe:$(s),getConfig:c.getConfig})).then(()=>{e.push(s),o()}).catch(d=>{l(d,`analytics ${r.name}`)}),()=>{let d=e.indexOf(s);d>=0&&e.splice(d,1)}}};return document.addEventListener("consentTrackingApiLoaded",o),document.addEventListener("visitorConsentCollected",o),c}function G(t,{event:e,payload:n}){t.subscribers.get(e)?.forEach(i=>{try{i(n,t.context)}catch(o){l(o,`analytics ${t.name}`)}})}function P(t){let e=document.createElement("script");e.src=t,e.async=!0,document.head.appendChild(e)}async function R(t){let e=m();if(e?.analytics)return e.analytics;let n=await E("query TetherShopId { shop { id } }",{},k({shop:{id:"string"}}),{context:!1}),i=m()??{};x().Shopify=i,i.country=a.country??"US";let[o="en"]=(a.locale||"en").split("-");i.locale=o.toLowerCase(),i.shop=a.domain,i.routes={root:"/",match:()=>({pageTemplateName:t()?"product":"page"}),...i.routes};let{proxy:c,consent:r}=L();i.customerPrivacy={...i.customerPrivacy,config:c?{isHeadless:!0,asyncConsent:!0,asyncVisitorState:!0,consentDomain:window.location.host}:{isHeadless:!0,storefrontAccessToken:a.token,checkoutRootDomain:a.domain}};let s=U(n.shop.id);return i.analytics=s,P(r==="default-banner"?S["default-banner"]:S.other),P(O),T("shopify analytics ready",n.shop.id),s}var W="Default Title",V=100,H=200,Y=t=>t?parseFloat(t.amount):0,N=t=>(t??"").split("/").pop()??"";function C(t,e,n=1,i){let o={item_id:e?.sku||N(e?.id)||N(t.id),item_name:t.title,item_variant:e?.title===W?void 0:e?.title,item_brand:t.vendor||void 0,item_category:t.productType||void 0,price:Y(e?.price??t.priceRange?.minVariantPrice),quantity:n};return i!=null&&(o.index=i),o}var g=(t,e=t.quantity)=>C(t.merchandise.product,t.merchandise,e);function f(t){let e=t.reduce((n,i)=>n+i.price*(i.quantity||1),0);return Math.round(e*V)/V}var X=(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}),D=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 Z(){let{dataLayer:t}=a.analytics??{},e=typeof t=="string"?t:"dataLayer",n=Reflect.get(window,e);if(Array.isArray(n))return n;let i=[];return Reflect.set(window,e,i),i}function z(t,e){let n=Z();if(!e){n.push({event:t});return}n.push({ecommerce:null}),n.push({event:t,ecommerce:e})}var y=null,v=null,q=null,b=new WeakSet;function u(t,e,n,i){a.analytics?.dataLayer&&z(t,e),y&&n&&y.publish(n,i);try{a.analytics?.onEvent?.(t,e)}catch(o){l(o,"analytics onEvent")}}function M(){let t=document.querySelector(p("product"));return!t||t.closest(`${p("collection")},${p("products")},${p("recommendations")}`)?null:A.get(t)??null}function J({product:t,scope:e}){if(b.has(e.root)||M()!==e)return;b.add(e.root);let n=e.variant??t.variants.nodes[0],i=[C(t,n)],o=n?[X(t,n)]:[];u("view_item",{currency:n?.price.currencyCode,value:f(i),items:i},"product_viewed",{products:o})}function K({products:t,collection:e}){let n=t.slice(0,H).map((o,c)=>C(o,o.variants.nodes[0],1,c)),i={item_list_id:e?.handle||"products",item_list_name:e?.title||"Products"};if(!e){u("view_item_list",{...i,items:n});return}u("view_item_list",{...i,items:n},"collection_viewed",{collection:{id:e.id,handle:e.handle}})}function Q(t,e,n){let i=t?.cost.totalAmount.currencyCode;e.forEach((o,c)=>{let r=n.get(c),s=o.quantity-(r?.quantity??0);if(s<=0)return;let d=[g(o,s)];u("add_to_cart",{currency:i,value:f(d),items:d},"product_added_to_cart",{cart:t,prevCart:q,currentLine:D(o),prevLine:r?D(r):void 0})}),n.forEach((o,c)=>{let r=o.quantity-(e.get(c)?.quantity??0);if(r<=0)return;let s=[g(o,r)];u("remove_from_cart",{currency:i,value:f(s),items:s})})}function tt({cart:t,reason:e}){let n=new Map((t?.lines.nodes??[]).map(i=>[i.merchandise.id,i]));v&&e!=="load"&&e!=="pending"&&Q(t,n,v),v=n,q=t}function et(){let t=h.lines.map(e=>g(e));u("view_cart",{currency:h.state?.cost.totalAmount.currencyCode,value:f(t),items:t})}function nt({cart:t}){if(!t)return;let e=t.lines.nodes.map(i=>g(i)),n=t.discountCodes.filter(i=>i.applicable).map(i=>i.code);u("begin_checkout",{currency:t.cost.totalAmount.currencyCode,value:f(e),coupon:n.join(",")||void 0,items:e})}var it={"product-ready":J,"list-ready":K,"cart-updated":tt,"cart-toggled":({open:t})=>{t&&et()},checkout:nt,search:({term:t})=>{t&&u("search",{search_term:t},"search_viewed",{searchTerm:t})}};function ot(t,e){it[e](t.detail)}function B(t){if(t.type==="astro:page-load"){b=new WeakSet,y?.publish("page_viewed",{});return}_.forEach(e=>{w(t,e)&&ot(t,e)})}async function ft(t){a.analytics?.shopify&&(y=await R(()=>M()!=null).catch(e=>(l(e,"shopify analytics"),null))),y?.publish("page_viewed",{}),t.splice(0).forEach(B),t.push=(...e)=>(e.forEach(B),t.length)}export{ft as startAnalytics};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as k,b as z,c as B}from"./chunk-56FCLJJD.js";import{a as g,c as y,f as l}from"./chunk-MPDWM2NN.js";import{D as _,E as J,r as D,v as U,x as W,y as Q,z as Y}from"./chunk-BFTZR4OB.js";import{E as K,F as C,H as w,K as F,M as q,a as H,l as u,m as c,n as s,o as P,p as N,q as A,t as d,w as O,y as I}from"./chunk-BA4LQJJQ.js";import{b as m,d as M,o as b,p as $,r as p,x as v,y as x,z as h}from"./chunk-E5YO6274.js";var j="url:",T=()=>`${c("collection")},${c("products")},${c("recommendations")}`,et=t=>t instanceof window.Element,G=t=>parseInt(t??"",10)||void 0,ot=t=>t==="COMPLEMENTARY"?"COMPLEMENTARY":"RELATED",V=class{constructor(e){m(this,"root");m(this,"products",[]);m(this,"pageInfo",null);m(this,"collection",null);m(this,"loadToken",0);this.root=e,l(e,"loading"),e.addEventListener("click",o=>{if(!et(o.target))return;let n=o.target.closest(c("load-more"));n?.closest(T())===e&&(o.preventDefault(),q(n,()=>this.load(!0)))})}$(e){return A(this.root,e,T())}options(){let{root:e}=this,o={reverse:s(e,"reverse")==="true"},n=G(s(e,"limit"));n&&(o.first=n);let r=s(e,"sort");if(r&&(o.sortKey=r),P(e,"collection"))return o.collection=s(e,"collection")??"",o;let i=s(e,"products")??"";return o.query=i.startsWith(j)?new URL(window.location.href).searchParams.get(i.slice(j.length))||"":i,o}async loadRecommendations(){let{key:e}=g(this.root,window.location,"recommendations"),o=this.root.closest(c("product"));if(!e&&o&&({key:e}=g(o)),!e)throw new H("No product for recommendations",{code:"NOT_FOUND"});return J(e,ot(s(this.root,"intent")))}async load(e=!1){this.loadToken+=1;let o=this.loadToken,n=()=>o!==this.loadToken;try{if(P(this.root,"recommendations")){let r=await this.loadRecommendations();if(n())return;let i=G(s(this.root,"limit"));this.products=i?r.slice(0,i):r}else{let r=await _({...this.options(),after:e?this.pageInfo?.endCursor??null:null});if(n())return;this.collection=r.collection,this.pageInfo=r.pageInfo,this.products=e?[...this.products,...r.products]:r.products}this.render(),l(this.root,"ready"),d("list-ready",{products:this.products,collection:this.collection},this.root)}catch(r){if(n())return;e||l(this.root,y(r)?"not-found":"error",r),y(r)&&P(this.root,"recommendations")||h(r,"list load failed"),d("error",{error:r,context:"list"},this.root)}}render(){let{collection:e}=this;this.$(c("collection-bind")).forEach(n=>{switch(s(n,"collection-bind")??""){case"title":C(n,e?.title??"");break;case"description":K(n,e?.descriptionHtml);break;case"image":O(n,e?.image?.url,e?.image?.altText||e?.title);break;case"count":C(n,this.products.length);break}}),this.$(c("list")).forEach(n=>{I(n,this.products,(r,i)=>{r.setAttribute(u("product"),i.handle),r.removeAttribute(u("state"))}),d("list-rendered",{container:n},this.root)});let o=this.products.length===0;this.$(c("show")).forEach(n=>{let r=s(n,"show");r==="list-empty"&&w(n,o),r==="list-filled"&&w(n,!o)}),this.$(c("load-more")).forEach(n=>{w(n,!!this.pageInfo?.hasNextPage)}),F("list")}};var rt='script[type="application/json"][data-tether-hydrate]',L=new WeakSet,Ht=new WeakSet,E=new Set,X=new Set,Z=new WeakMap;function nt(){E.forEach(t=>{t.isConnected||E.delete(t)}),X.forEach(t=>{t.root.isConnected||X.delete(t)})}function it(t,e){return[...t.matches?.(e)?[t]:[],...N(t,e)]}function st(t,e){let o=s(t,"page-title");!o||typeof document>"u"||(document.title=o.replace(/\{title\}/g,e.title).replace(/\{vendor\}/g,e.vendor||"").replace(/\{type\}/g,e.productType||""))}function ct(t,{fromUrl:e,raw:o}){e?(L.add(t),l(t,"not-found"),d("product-not-found",{key:null,source:o},t)):t.closest(T())||x(`[${u("product")}] without a value. Bind it to the Shopify handle field, or use "url:handle".`,t)}function at(t,e,{fromUrl:o,raw:n},r){let i=y(r);if(l(t,i?"not-found":"error",r),!i){h(r,`product ${e}`),d("error",{error:r,context:"product",key:e},t);return}d("product-not-found",{key:e,source:n},t),o?v(`product not found: ${e}`):h(r,`product ${e}`)}function ut(t){if(L.has(t))return!1;let{key:e,...o}=g(t);if(!e)return ct(t,o),!1;L.add(t),E.add(t);let n={};Z.set(t,n);let r=()=>Z.get(t)===n;return k.get(t)?t.setAttribute(u("state"),"updating"):l(t,"loading"),mt(U(e)).then(f=>{if(!r())return;let R=k.get(t);R?R.update(f):new B(t,f),st(t,f),p.revalidate&&Q(e)&&dt(e)}).catch(f=>{r()&&at(t,e,o,f)}),!0}function Nt(){nt(),E.forEach(t=>{t.getAttribute(u("state"))!=="error"||t.getAttribute(u("error"))==="not-found"||(L.delete(t),ut(t))})}var S=new Set;function dt(t){S.size||setTimeout(ft,0),S.add(t)}function lt(t,e){E.forEach(o=>{let n=k.get(o);if(!n||!o.isConnected)return;let r=g(o).key;r!==t&&r!==e.handle&&r!==e.id||JSON.stringify(n.product)!==JSON.stringify(e)&&n.update(e)})}function ft(){let t=[...S];S=new Set,t.forEach(e=>{Y(e).then(o=>{lt(e,o)}).catch(o=>{h(o,`refresh ${e}`)})})}var a=null,mt=t=>(a?.add(t),t);function pt(){if(!a)return;let t=[...a];Promise.allSettled(t).then(()=>{if(!(!a||t.some(e=>!a?.has(e)))){if(t.length!==a.size){pt();return}a=null,document.documentElement.classList.remove(`${p.prefix}-market-pending`)}})}function ht(t){if(!M(t))return{country:void 0,language:void 0,products:[]};let{products:e}=t,o=Array.isArray(e)?e:[];return{country:b(t.country)??void 0,language:$(t.language)??void 0,products:o.filter(D)}}var tt=new WeakSet;function At(t=document){it(t,rt).forEach(e=>{if(tt.has(e))return;tt.add(e);let o;try{o=JSON.parse(e.textContent)}catch(f){x("bad data-tether-hydrate",f);return}let{country:n,language:r,products:i}=ht(o);if(z(i),n===p.country&&r===p.language){W(i);return}v("hydration skipped: other market"),a||(a=new Set,document.documentElement.classList.add(`${p.prefix}-market-pending`))})}export{T as a,V as b,L as c,Ht as d,E as e,X as f,nt as g,it as h,ut as i,Nt as j,mt as k,pt as l,At as m};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as M,b as z,c as H,d as C,e as Z,f as tt,g as et,h as nt,i as it}from"./chunk-T44MUL4Y.js";import{b as $,e as rt}from"./chunk-MPDWM2NN.js";import{e as Y}from"./chunk-A5SYCVQM.js";import{g as J,h as N,i as S,n as K}from"./chunk-BFTZR4OB.js";import{A as D,B,C as L,D as U,E as G,F as d,H as x,I,K as V,L as j,M as Q,N as W,O as X,l as p,m as o,n as l,o as T,p as f,q as R,t as v,v as _,w as g,x as F,y}from"./chunk-BA4LQJJQ.js";import{b as h,r as A,z as w}from"./chunk-E5YO6274.js";var ft=/^image:(\d+)$/,at="metafield:",gt=/^(rich_text|multi_line_text)_field$/,vt=["","true","all","*"],q=t=>t.tagName==="SELECT",b=(t,e)=>t.$(`select${e}`).filter(q);function bt(t,e){let n=e.images.nodes,i=[...t.children].map(a=>a.tagName==="IMG"?a:a.querySelector("img"));!F(t)&&i.length===n.length&&i.every((a,s)=>_(a?.getAttribute("src"),n[s]?.url))||y(t,n,(a,s)=>{let c=a.matches(`img,${o("bind","image")}`)?a:f(a,"img")[0]??a;g(c,s.url,s.altText||e.title)})}function Et(t,e,n){let i=n.indexOf("."),r=n.slice(0,i),a=n.slice(i+1),s=(e.metafields??[]).find(u=>u?.namespace===r&&u.key===a);if(!s){d(t,"");return}let c=s.reference?.image;if(c){g(t,c.url,c.altText);return}gt.test(s.type)&&(t.style.whiteSpace="pre-line"),d(t,s.value)}var Pt=new Map(Object.entries({title:t=>t.title,"description-text":t=>t.description,vendor:t=>t.vendor,type:t=>t.productType,handle:t=>t.handle,"published-at":t=>U(t.publishedAt),"min-price":t=>L(t.priceRange.minVariantPrice),"max-price":t=>L(t.priceRange.maxVariantPrice)}));function Tt(t,e){let n=(t.getAttribute("exclude")??"").split(",").map(r=>r.trim()).filter(Boolean),i=e.tags.filter(r=>!n.includes(r));y(t,i,(r,a)=>{d(r,a)})}function yt(t,e,n){let i=Pt.get(e);if(i){d(t,i(n));return}switch(e){case"description":G(t,n.descriptionHtml);break;case"featured-image":g(t,n.featuredImage?.url,n.featuredImage?.altText||n.title);break;case"url":case"link":{let r=D(n.handle,n.id);r&&t.setAttribute("href",r),e==="url"&&!t.firstElementChild&&!t.textContent.trim()&&d(t,n.title);break}case"images":bt(t,n);break;case"tags":Tt(t,n);break;default:Lt(t,e,n)}}function Lt(t,e,n){let i=ft.exec(e);if(i){let r=n.images.nodes[Number(i[1])-1]??n.featuredImage;g(t,r?.url,r?.altText||n.title)}else e.startsWith(at)&&Et(t,n,e.slice(at.length))}function xt(t){let{product:e}=t;t.$(o("option-list")).forEach(n=>{let i=t.optName(l(n,"option-list")),r=e.options.find(a=>a.name===i);if(!r||r.optionValues.length<=1&&T(n,"hide-single")){x(n,!1);return}y(n,r.optionValues,(a,s)=>{a.setAttribute(p("option-value"),s.name);let c=f(a,o("bind","option-value"))[0];c?d(c,s.name):a.firstElementChild||d(a,s.name);let u=f(a,o("bind","swatch"))[0],{swatch:m}=s;!u||!m||(m.color&&(u.style.backgroundColor=m.color),m.image?.previewImage&&g(u,m.image.previewImage.url,s.name))})})}function It(t){let{product:e}=t;b(t,o("option")).forEach(n=>{let i=e.options.find(r=>r.name===t.optName(l(n,"option")));if(!i){x(n,!1);return}n.replaceChildren(...i.optionValues.map(r=>new Option(r.name,r.name)))}),b(t,o("variant-select")).forEach(n=>{n.replaceChildren(...e.variants.nodes.map(i=>new Option(i.title,i.id)))}),b(t,o("plan")).forEach(n=>{let i=t.plans.map(s=>new Option(s.name,s.id)),r=!e.requiresSellingPlan&&l(n,"plan")!=="subscription-only",a=n.getAttribute(p("one-time-label"))||"One-time purchase";n.replaceChildren(...r?[new Option(a,"")]:[],...i)})}function St(t){t.$(o("plan-list")).forEach(e=>{let n=(l(e,"plan-list")??"").trim(),i=vt.includes(n.toLowerCase())?null:n,r=t.plans.filter(a=>!i||a.group.name===i);y(e,r,(a,s)=>{a.setAttribute(p("plan-value"),s.id),!a.firstElementChild&&!a.querySelector(o("plan-bind"))&&d(a,s.name)})})}function st(t){t.$(o("bind")).forEach(e=>{yt(e,l(e,"bind")??"",t.product)}),xt(t),It(t),St(t)}var ot={money:L,percent:B},Mt=t=>t.tagName==="INPUT";function O(t){let e=f(t,o("add-label"))[0]??t,n=e.dataset.tetherLabel??(Mt(e)?e.value:e.textContent);return e.dataset.tetherLabel=n,{label:e,original:n}}function kt(t,e){let{product:n}=t,i=r=>e.selected[t.optName(r)]??"";t.$(o("option-selected")).forEach(r=>{d(r,i(l(r,"option-selected")))}),t.$(o("option-list")).forEach(r=>{let a=t.optName(l(r,"option-list"));f(r,o("option-value")).forEach(s=>{let c=l(s,"option-value")??"";I(s,e.selected[a]===c);let u=!z(n,e.selected,a,c);s.classList.toggle("is-unavailable",u),s.setAttribute("data-unavailable",u?"true":"false")})}),b(t,o("option")).forEach(r=>{r.value=i(l(r,"option"))}),b(t,o("variant-select")).forEach(r=>{r.value=e.variant.id})}function At(t,e){let{variant:n,purchase:i,line:r}=e;t.$(o("purchase")).forEach(a=>{if(q(a)){a.value=i.kind;return}let s=l(a,"purchase");I(a,s===i.kind);let c=s==="subscription"?!e.subscriptionAvailable:t.product.requiresSellingPlan;a.classList.toggle("is-unavailable",c)}),t.$(o("plan-value")).forEach(a=>{let s=l(a,"plan-value")??"";I(a,r.kind==="subscription"&&s===r.planId),a.classList.toggle("is-unavailable",!S(n,s));let c=t.plans.find(m=>m.id===s),u=it(n,s,c,ot);f(a,o("plan-bind")).forEach(m=>{let E=u.get(l(m,"plan-bind")??"");E&&d(m,E())})}),b(t,o("plan")).forEach(a=>{a.value=r.kind==="subscription"?r.planId:""})}function wt(t,e){let n=new Map(Object.entries(e.show));$.forEach(i=>n.set(i,i==="ready")),t.$(o("show")).forEach(i=>{let r=l(i,"show")??"",a=n.get(r);a!==void 0&&($.some(s=>s===r)&&!rt(i,t.root)||x(i,a))})}function Vt(t,e){let n=!e.variant.availableForSale;t.$(o("add-to-cart")).forEach(i=>{i.classList.toggle("is-disabled",n),i.setAttribute("aria-disabled",String(n)),"disabled"in i&&(i.disabled=n);let r=l(i,"soldout-text"),a=l(i,"subscribe-text");if(!r&&!a)return;let{label:s,original:c}=O(i),u=c;e.line.kind==="subscription"&&a&&(u=a),n&&r&&(u=r),i.getAttribute("aria-busy")!=="true"&&d(s,u)})}function lt(t,e){let{variant:n}=e,{product:i}=t,r=nt(e,ot);t.$(o("bind")).forEach(a=>{let s=l(a,"bind")??"";if(s==="variant-image"){g(a,n.image?.url||i.featuredImage?.url,n.image?.altText||i.title);return}let c=r.get(s);c&&d(a,c())}),kt(t,e),At(t,e),wt(t,e),t.root.classList.toggle("is-subscription",e.line.kind==="subscription"),t.root.setAttribute(p("purchase-mode"),e.line.kind),Vt(t,e)}var ut=()=>o("product"),Nt=t=>t.tagName==="INPUT"||t.tagName==="SELECT"||t.tagName==="TEXTAREA",ct=t=>t instanceof window.Element;function P(t,e,n){let i=e.closest(n);return i?.closest(ut())===t.root?i:null}function Ht(t,e){let{label:n,original:i}=O(e),r=l(e,"adding-text");Q(e,async()=>{r&&d(n,r);try{await t.addToCart()}catch(a){w(a,"add to cart failed"),v("error",{error:a,context:"add-to-cart"},t.root)}finally{r&&d(n,i)}}).then(()=>{t.renderVariant()}).catch(a=>{w(a,"add to cart render")})}function Ct(t,e,n){let i=P(t,n,o("option-value")),r=i?.closest(o("option-list"));if(i&&r){e.preventDefault(),t.select(t.optName(l(r,"option-list")),l(i,"option-value")??"");return}let a=P(t,n,o("plan-value"));if(a){e.preventDefault(),t.selectPlan(l(a,"plan-value"));return}let s=P(t,n,`${o("purchase")}:not(select)`);if(s){s.tagName!=="INPUT"&&e.preventDefault(),t.setPurchase(dt(l(s,"purchase")));return}let c=P(t,n,o("qty-plus")),u=c?null:P(t,n,o("qty-minus"));if(c||u){e.preventDefault(),t.setQuantity(t.quantity+(c?1:-1));return}let m=P(t,n,o("add-to-cart"));m&&(e.preventDefault(),Ht(t,m))}var dt=t=>t==="subscription"?"subscription":"one-time";function $t(t,e){let n=Nt(e)?e.value:"";e.matches(`select${o("option")}`)?t.select(t.optName(l(e,"option")),n):e.matches(`select${o("variant-select")}`)?t.selectVariant(n):e.matches(`select${o("plan")}`)?n?t.selectPlan(n):t.setPurchase("one-time"):e.matches(`select${o("purchase")}`)?t.setPurchase(dt(n)):e.matches(o("qty"))&&t.setQuantity(n)}function mt(t){t.root.addEventListener("click",e=>{ct(e.target)&&Ct(t,e,e.target)}),t.root.addEventListener("change",e=>{let{target:n}=e;ct(n)&&n.closest(ut())===t.root&&$t(t,n)})}var qt=new WeakMap,Ot=()=>o("product"),k=new Map;function Rt(t){t.forEach(e=>{k.has(e.handle)||k.set(e.handle,e.options.map(n=>n.name))})}var pt=t=>t.tagName==="INPUT",_t=t=>t.tagName==="INPUT"||t.tagName==="SELECT"||t.tagName==="TEXTAREA";function Ft(t){return pt(t)&&t.type==="checkbox"?t.checked?t.value&&t.value!=="on"?t.value:"Yes":null:pt(t)&&t.type==="radio"?t.checked?t.value:null:_t(t)&&t.value||null}var ht=class{constructor(e,n){h(this,"root");h(this,"product");h(this,"plans");h(this,"selected");h(this,"purchase");h(this,"variant");h(this,"quantity");this.root=e,this.product=n,this.plans=N(n);let i=new URLSearchParams(window.location.search),r=tt(n,{variant:i.get("variant")||l(e,"variant"),sellingPlan:i.get("selling_plan"),defaultPlan:l(e,"default-plan"),defaultPurchase:l(e,"default-purchase")||A.defaultPurchase});this.selected=r.selected,this.purchase=r.purchase,this.variant=null,this.quantity=T(e,"quantity")?Math.max(0,parseInt(l(e,"quantity")??"",10)||0):1,qt.set(e,this),e.setAttribute(p("state"),"ready"),e.removeAttribute(p("error")),this.renderProduct(),mt(this),this.renderVariant(),j(e,"product"),V("product"),v("product-ready",{product:n,scope:this},e)}update(e){let n=this.variant?.id;this.product=e,this.plans=N(e);let i=e.variants.nodes.find(r=>r.id===n);i&&(this.selected=M(i)),this.root.setAttribute(p("state"),"ready"),this.root.removeAttribute(p("error")),this.renderProduct(),this.renderVariant(),V("product"),v("product-updated",{product:e,scope:this},this.root)}$(e){let n=R(this.root,e,Ot());return this.root.matches(e)?[this.root,...n]:n}optName(e){if(!e)return"";let{options:n}=this.product;if(n.some(r=>r.name===e))return e;let i=(k.get(this.product.handle)??[]).indexOf(e);return n[i]?.name??e}get plan(){let e=H(this.purchase);return this.plans.find(n=>n.id===e)??null}get subscriptionAvailable(){return this.plans.some(e=>S(this.variant,e.id))}get isSubscription(){return C(this.purchase,this.variant).kind==="subscription"}getLine(){if(!this.variant)return null;let e={merchandiseId:this.variant.id,quantity:this.quantity},n=C(this.purchase,this.variant);n.kind==="subscription"&&(e.sellingPlanId=n.planId);let i=this.collectAttributes();return i.length&&(e.attributes=i),e}collectAttributes(){let e=X(W(this.root,"line-attributes")),n=this.$(o("line-attribute")).flatMap(i=>{let r=Ft(i);return r===null?[]:[{key:l(i,"line-attribute")??"",value:r}]});return[...e,...n]}select(e,n){if(this.selected[e]===n)return;let i=this.product.variants.nodes.filter(s=>s.selectedOptions.some(c=>c.name===e&&c.value===n)),[r]=i;if(!r)return;let a={...this.selected,[e]:n};if(!i.some(s=>s.selectedOptions.every(c=>a[c.name]===c.value))){let s=u=>u.selectedOptions.filter(E=>E.name!==e&&this.selected[E.name]===E.value).length*2+(u.availableForSale?1:0),c=i.reduce((u,m)=>s(m)>s(u)?m:u,r);Object.assign(a,M(c))}this.selected=a,this.renderVariant()}selectVariant(e){let n=this.product.variants.nodes.find(i=>i.id===J.variant(e));n&&(this.selected=M(n),this.renderVariant())}setPurchase(e){let n=Z(this.product,this.variant,e,H(this.purchase));n.kind!==this.purchase.kind&&(this.purchase=n,this.renderVariant())}selectPlan(e){let n=K(this.product,e);n&&(this.purchase={kind:"subscription",planId:n.id},this.renderVariant())}setQuantity(e){let n=T(this.root,"quantity")?0:1;this.quantity=Math.max(n,parseInt(String(e),10)||0),this.$(o("qty")).forEach(i=>{d(i,this.quantity)}),this.renderVariant()}async addToCart(){if(!this.variant?.availableForSale)return null;let e=this.getLine();if(!e||e.quantity<1)return null;let n=await Y.add(e);return v("product-added",{product:this.product,variant:this.variant,line:e},this.root),n}renderProduct(){let{product:e}=this;k.has(e.handle)||this.$(`${o("option-list")},select${o("option")}`).map(i=>l(i,"option-list")||l(i,"option")).some(i=>e.options.some(r=>r.name===i))&&Rt([e]),st(this)}renderVariant(){let e=et(this.product,{selected:this.selected,purchase:this.purchase,quantity:this.quantity},A.lowStock);if(!e){this.variant=null;return}this.variant=e.variant,this.selected=e.selected,this.purchase=e.purchase,lt(this,e),v("variant-changed",{product:this.product,variant:e.variant,selected:{...e.selected},purchase:e.purchase.kind,sellingPlanId:e.line.kind==="subscription"?e.line.planId:null},this.root)}};export{qt as a,Rt as b,ht as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as g,F as E,H as N,a as L,m as l,n as u,p as d,w as k,y as w}from"./chunk-BA4LQJJQ.js";import{d as x,e as o,f as y,g as i,i as A,j as h,k as T,l as f}from"./chunk-E5YO6274.js";function q(t){let e=i(o(t,"amount")),n=i(o(t,"currencyCode"));return e===null||n===null?null:{amount:e,currencyCode:n}}function S(t){let e=i(o(t,"url"));return e===null?null:{url:e,altText:i(o(t,"altText"))}}var U=t=>({title:i(o(t,"title")),variantTitle:i(o(t,"variantTitle")),quantity:A(o(t,"quantity")),image:S(o(t,"image"))}),H=(t,e)=>({id:e,name:i(o(t,"name")),processedAt:i(o(t,"processedAt")),financialStatus:i(o(t,"financialStatus")),fulfillmentStatus:i(o(t,"fulfillmentStatus")),statusPageUrl:i(o(t,"statusPageUrl")),totalPrice:q(o(t,"totalPrice")),lineItems:T(o(t,"lineItems"),U)});function R(t){let e=[];for(let n of y(t)){let r=i(o(n,"id"));if(r===null)return{kind:"missing-id"};e.push(H(n,r))}return{kind:"read",orders:e}}var I=t=>new L(`Customer accounts: the answer has no ${t}`);function G(t,e){let n=i(t);if(!n)throw I(e);return n}function J(t){let e=x(t)?t:{},n=i(e.id),r=i(e.email),s=e.address;return{...n===null?{}:{id:n},firstName:i(e.firstName),lastName:i(e.lastName),displayName:i(e.displayName),emailAddress:r===null?null:{emailAddress:r},defaultAddress:Array.isArray(s)?{formatted:f(s)}:null}}function K(t){let e=R(t);if(e.kind==="missing-id")throw I("order id");return e.orders}function D(t){let e=i(o(t,"message"));if(e===null)return null;let n=o(t,"field");return{message:e,field:Array.isArray(n)?f(n):null,code:i(o(t,"code"))}}var Q=t=>h(t,D).filter(e=>e!==null);function P(t,e,n){d(t,l(e)).forEach(r=>{let s=u(r,e)??"";Object.hasOwn(n,s)&&N(r,n[s]===!0)})}var b=(t,e)=>d(t,l(e)).concat(t.matches(l(e))?[t]:[]),Y=t=>t?t.toLowerCase().replace(/_/g," "):"",v=t=>(t?.formatted??[]).join(", "),M=(t,e)=>Object.hasOwn(t,e)?t[e]:void 0;var j=(t,e)=>({title:t.title||t.name||"","variant-title":t.variantTitle||"",quantity:String(t.quantity),price:g(t.price),total:g(t.totalPrice),sku:t.sku||"",returnable:e===null?void 0:String(e)}),F=t=>t.tagName==="INPUT";function V(t,e,n){P(t,"order-line-show",{returnable:n>0}),d(t,l("return-quantity")).forEach(r=>{F(r)&&(r.max=String(n),r.min="0",r.value||(r.value="0"),r.disabled=n<1)}),d(t,`select${l("return-reason")}`).forEach(r=>{r.dataset.tetherFilled!==e.id&&(r.dataset.tetherFilled=e.id,(e.suggestedReturnReasonDefinitions?.nodes??[]).forEach(s=>{r.appendChild(new Option(s.name??"",s.id))}))})}function rt(t,e,n){w(t,e,(r,s)=>{let a=s.id,c=n&&a?n.get(a)??0:null;a&&(r.dataset.tetherLine=a);let C=j(s,c);b(r,"order-line").forEach(m=>{let p=u(m,"order-line")??"";if(p==="image"){s.image&&k(m,s.image.url,s.image.altText||s.title||"");return}let O=M(C,p);O!==void 0&&E(m,O)}),a&&c!==null&&V(r,{...s,id:a},c)})}export{q as a,S as b,U as c,I as d,G as e,J as f,K as g,Q as h,P as i,b as j,Y as k,v as l,M as m,rt as n};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as e}from"./chunk-A5SYCVQM.js";import{r as o}from"./chunk-E5YO6274.js";var c=()=>`${o.prefix}:account-hint:${o.domain}`;function i(r){e(r,"sessionStorage"),e(r,"localStorage")}function m(){i(`${o.prefix}:account:${o.domain}`),i(`${o.prefix}:account-login:${o.domain}`)}var s=r=>r==="in"||r==="expired"||r==="error";export{c as a,m as b,s as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as Y,d as ht,g as q,h as Ct,p as x,v as bt}from"./chunk-BFTZR4OB.js";import{A as gt,C as I,F as G,G as v,H as N,K as yt,P as M,a as y,c as $,d as R,h as W,k as lt,l as F,m as s,n as w,p as l,t as f,w as mt,y as pt,z as ft}from"./chunk-BA4LQJJQ.js";import{C as dt,r as a,x as ct,z as S}from"./chunk-E5YO6274.js";var jt={id:"string",quantity:"number",attributes:["object"],cost:{totalAmount:x,subtotalAmount:x,amountPerQuantity:x},merchandise:{id:"string",selectedOptions:["object"],product:"object"}},X={id:"string",checkoutUrl:"string",totalQuantity:"number",attributes:["object"],discountCodes:["object"],cost:{totalAmount:x,subtotalAmount:x},lines:{nodes:[jt]}};var Ht='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',Bt=60,z=!1,K=null,Gt=t=>t!==null&&"focus"in t,St=t=>l(t,Ht).filter(n=>n.offsetParent!==null||n===document.activeElement),k=()=>l(document,s("cart-drawer")),J=t=>t.classList.contains(a.cartDrawerOpenClass);function g(){let t=k();return t.length?t.some(J):z}function V(t){l(document,s("cart-open")).forEach(n=>{n.setAttribute("aria-expanded",String(t))}),k().forEach(n=>{n.hasAttribute("role")||n.setAttribute("role","dialog"),!n.hasAttribute("aria-label")&&!n.hasAttribute("aria-labelledby")&&n.setAttribute("aria-label",w(n,"cart-label")||"Cart"),n.setAttribute("aria-modal",String(t)),!J(n)&&(n.setAttribute("aria-hidden","true"),a.cartFocus&&(n.inert=!0))})}function Yt(t){let n=St(t)[0]??t;n===t&&!t.hasAttribute("tabindex")&&(t.tabIndex=-1),n.focus({preventScroll:!0})}function _(){if(g())return;z=!0;let t=k().filter(e=>w(e,"cart-drawer")!=="manual");t.forEach(e=>{e.inert=!1,e.classList.add(a.cartDrawerOpenClass),e.setAttribute("aria-hidden","false")}),V(!0);let[n]=t;a.cartFocus&&n&&(K=Gt(document.activeElement)?document.activeElement:null,setTimeout(()=>{Yt(n)},Bt)),a.onCartOpen?.(t),f("cart-toggled",{open:!0})}function Z(){if(!g())return;z=!1;let t=k(),n=t.some(e=>e.contains(document.activeElement));t.forEach(e=>{e.classList.remove(a.cartDrawerOpenClass),e.setAttribute("aria-hidden","true"),a.cartFocus&&(e.inert=!0)}),V(!1),n&&K?.isConnected&&K.focus({preventScroll:!0}),K=null,a.onCartClose?.(t),f("cart-toggled",{open:!1})}function wt(){g()?Z():_()}function Xt(t){if(t.key!=="Tab"||!a.cartFocus||!g())return;let n=k().find(J);if(!n)return;let e=St(n),r=e[0],i=e.at(-1);if(!r||!i)return;let o=document.activeElement,u=t.shiftKey?o===r:o===i;n.contains(o)&&!u||(t.preventDefault(),(t.shiftKey?i:r).focus())}var vt="Default Title",tt=(t,n)=>n.get(t.id)?.quantity??t.quantity,At=t=>t.split("/").pop()??t;function zt(t){let n=t.merchandise,e=gt(n.product.handle,n.product.id);if(!e)return null;let r=new URLSearchParams;r.set("variant",At(n.id));let i=t.sellingPlanAllocation?.sellingPlan.id;return i&&r.set("selling_plan",At(i)),`${e}${e.includes("?")?"&":"?"}${r.toString()}`}var kt=t=>t.merchandise.product.title,Lt={title:kt,"product-title":kt,"variant-title":t=>t.merchandise.title===vt?"":t.merchandise.title,options:t=>t.merchandise.selectedOptions.filter(n=>n.value!==vt).map(n=>`${n.name}: ${n.value}`).join(", "),vendor:t=>t.merchandise.product.vendor,sku:t=>t.merchandise.sku??"",price:t=>I(t.cost.amountPerQuantity),"compare-at-price":t=>I(t.cost.compareAtAmountPerQuantity??t.merchandise.compareAtPrice),"line-total":t=>I(t.cost.totalAmount),"line-subtotal":t=>I(t.cost.subtotalAmount),quantity:(t,n)=>tt(t,n.pending),plan:t=>t.sellingPlanAllocation?.sellingPlan.name??"","plan-description":t=>t.sellingPlanAllocation?.sellingPlan.description??"",components:t=>(t.lineComponents??[]).map(n=>`${n.quantity} \xD7 ${n.merchandise.product.title}`).join(", ")},Pt="attribute:";function Jt(t,n,e){if(Object.hasOwn(Lt,n))return Lt[n]?.(t,e);if(!n.startsWith(Pt))return;let r=n.slice(Pt.length);return t.attributes.find(i=>i.key===r)?.value??""}function Zt(t,n,e){let r=Ct(e),i=!e.requiresSellingPlan&&w(t,"line-plan")!=="subscription-only",o={value:"",label:t.getAttribute(F("one-time-label"))||"One-time purchase"},u=[...i?[o]:[],...r.map(m=>({value:m.id,label:m.name}))],c=u.map(m=>m.value).join("|");t.dataset.tetherSig!==c&&(t.replaceChildren(...u.map(m=>{let b=document.createElement("option");return b.value=m.value,b.textContent=m.label,b})),t.dataset.tetherSig=c),t.value=n.sellingPlanAllocation?.sellingPlan.id??"",N(t,r.length>0)}function tn(t,n,e){let r=!!n.sellingPlanAllocation;t.classList.toggle("is-subscription",r);let i=e.warnings.find(c=>c.target===n.id);t.classList.toggle("is-warning",!!i);let o=e.pending.has(n.id);t.classList.toggle("is-busy",o),o?t.setAttribute("aria-busy","true"):t.removeAttribute("aria-busy"),l(t,s("line","warning")).forEach(c=>{v(c,i?.message??"")});let u=new Map([["subscription",r],["one-time",!r],["on-sale",ht(n.cost.compareAtAmountPerQuantity?.amount,n.cost.amountPerQuantity.amount)],["has-components",(n.lineComponents??[]).length>0],["warning",!!i]]);l(t,s("line-show")).forEach(c=>{let m=w(c,"line-show"),b=m===null?void 0:u.get(m);b!==void 0&&N(c,b)})}function nn(t,n,e){let r=n.merchandise;t.setAttribute(F("line-id"),n.id),l(t,s("line")).forEach(i=>{let o=w(i,"line")??"";if(o==="image"){mt(i,r.image?.url??r.product.featuredImage?.url,r.product.title);return}if(o==="url"){let c=zt(n);c&&i.setAttribute("href",c);return}let u=Jt(n,o,e);u!==void 0&&v(i,u)}),tn(t,n,e),l(t,`select${s("line-plan")}`).forEach(i=>{bt(r.product.handle).then(o=>{Zt(i,n,o)}).catch(o=>{S(o,"line plan options")})})}function en(t,n){let e=t?.totalQuantity??0,r=(t?.lines.nodes??[]).some(o=>o.sellingPlanAllocation),i=new Map([["cart-empty",e===0],["cart-filled",e>0],["cart-has-subscription",r],["cart-no-subscription",!r],["cart-has-discount",(t?.discountCodes??[]).some(o=>o.applicable)],["cart-error",n.failed],["cart-warning",n.warnings.length>0]]);l(document,s("show")).forEach(o=>{let u=w(o,"show"),c=u===null?void 0:i.get(u);c===void 0||o.closest(s("product"))||N(o,c)}),l(document,s("checkout")).forEach(o=>{o.classList.toggle("is-disabled",!e),o.setAttribute("aria-disabled",String(!e))})}function rn(t){l(document,`textarea${s("cart-note")},input${s("cart-note")}`).forEach(n=>{document.activeElement!==n&&G(n,t?.note??"")}),l(document,s("cart-discounts")).forEach(n=>{pt(n,t?.discountCodes??[],(e,r)=>{e.setAttribute(F("discount-code"),r.code);let i=e.querySelector(s("discount","code"))??(e.firstElementChild?null:e);i&&G(i,r.code),e.classList.toggle("is-inapplicable",!r.applicable)})})}function It(t){let{cart:n}=t,e=r=>n?I(n.cost[r]):"";V(g()),l(document,s("cart-count")).forEach(r=>{v(r,n?.totalQuantity??0)}),l(document,s("cart-subtotal")).forEach(r=>{v(r,e("subtotalAmount"))}),l(document,s("cart-total")).forEach(r=>{v(r,e("totalAmount"))}),l(document,s("cart-checkout-charge")).forEach(r=>{v(r,e("checkoutChargeAmount"))}),en(n,t),l(document,s("cart-warning")).forEach(r=>{v(r,[...new Set(t.warnings.map(i=>i.message))].join(" "))}),rn(n),l(document,s("cart-lines")).forEach(r=>{ft(r,n?.lines.nodes??[],i=>i.id,(i,o)=>{nn(i,o,t)},{onEnter:a.onLineEnter,onLeave:a.onLineLeave})}),n&&yt("cart")}function xt(t){l(document,s("cart-count")).forEach(n=>{/^\s*0?\s*$/.test(n.textContent)&&(n.textContent=String(t))})}function nt(t,n="localStorage"){try{return window[n].getItem(t)}catch{return null}}function et(t,n,e="localStorage"){try{window[e].setItem(t,n)}catch{}}function Et(t,n="localStorage"){try{window[n].removeItem(t)}catch{}}var p={kind:"unknown"},E=[],L=new Map,j=()=>p;function d(){switch(p.kind){case"ready":case"error":return p.cart;case"unknown":case"empty":return null}}var $t=()=>E,rt=t=>t?{kind:"ready",cart:t}:{kind:"empty"},Mt=()=>`${a.storageKey}:seen`,P=()=>nt(a.storageKey)||null;function T(){Et(a.storageKey)}function it(t){p=rt(t),t&&et(a.storageKey,t.id)}function U(){It({cart:d(),warnings:E,pending:L,failed:p.kind==="error"})}function O(t){U(),f("cart-updated",{cart:d(),reason:t})}function h(t,n){return it(t),et(Mt(),`${Date.now()}|${t?.totalQuantity??0}`),O(n),t}function Q(t){p=t.kind==="loaded"?rt(t.cart):{kind:"error",error:t.error,cart:null},O("load")}function on(){let t=nt(Mt())?.split("|")[1]??"",n=Number(t);return/^\d+$/.test(t)&&Number.isSafeInteger(n)?n:null}function qt(){if(p.kind!=="unknown")return;let t=on();t!==null&&xt(t)}function Ut(t){E=t.filter((n,e)=>t.findIndex(r=>r.message===n.message)===e).map(n=>({...n,message:a.warningText?.(n)||n.message})),E.length&&f("cart-warning",{warnings:E})}var Tt=()=>{};function an(){let t=Promise.resolve();return n=>{let e=t.then(n);return t=e.then(Tt,Tt),e}}var sn=an();function C(t){return sn(t).then(n=>(p.kind==="error"&&(p=rt(p.cart),U()),n),n=>{throw p={kind:"error",error:n,cart:d()},U(),f("cart-error",{error:n}),n})}var ot=t=>tt(t,L),un=()=>({open:g(),count:d()?.totalQuantity??0,loaded:p.kind!=="unknown",warnings:[...E]});function Ot(t){let n=["cart-updated","cart-toggled"].map(r=>`${a.prefix}:${r}`),e=()=>{t(d(),un())};return n.forEach(r=>{document.addEventListener(r,e)}),e(),()=>{n.forEach(r=>{document.removeEventListener(r,e)})}}var cn=/does not exist|not found|invalid id/i,ln=t=>R({[t]:$({cart:$(X)})});function H(t){return t instanceof y?t.userErrors?.some(n=>n.field?.[0]==="cartId")?!0:(t.errors??[]).some(n=>cn.test(n.message)):!1}function Dt(t,n=1,e={}){let r=typeof t=="object"&&t!==null?t:{...e,quantity:n,...t==null?{}:{variantId:t}},i=q.variant(r.merchandiseId||r.variantId||r.id);if(!i)throw new y("add(): variantId is required");let o=parseInt(String(r.quantity??1),10),u={merchandiseId:i,quantity:Math.max(1,o||1)},c=q.sellingPlan(r.sellingPlanId||r.sellingPlan);c&&(u.sellingPlanId=c);let m=M(r.attributes);return m.length&&(u.attributes=m),u}function dn(t,n,e){return r=>`mutation Tether_${t}(${n}){${t}(${e}){cart{...TetherCart}userErrors{field message}warnings{code message target}}}${Y(r)}`}async function Rt(t,n,e,r){let i=await W(dn(t,n,e),r,ln(t)),o=lt(i[t],t);return Ut(o.warnings??[]),o.cart}function Qt(t){let n=a.country?{buyerIdentity:{countryCode:a.country},...t}:t;return Rt("cartCreate","$input: CartInput!","input: $input",{input:n})}async function A({name:t,args:n,inner:e,variables:r,createInput:i}){let o=P();if(!o)return i?Qt(i):null;try{return await Rt(t,`$cartId: ID!, ${n}`,`cartId: $cartId, ${e}`,{...r,cartId:o})}catch(u){if(!H(u)||(T(),!i))throw u;return ct("cart expired, creating a new one"),Qt(i)}}async function Wt(t){return(await W(e=>`query TetherCart($id:ID!){cart(id:$id){...TetherCart}}${Y(e)}`,{id:t},R({cart:$(X)}))).cart}async function Ft(t){return(await W("query TetherCheckout($id: ID!) { cart(id: $id) { checkoutUrl } }",{id:t},R({cart:$({checkoutUrl:"string"})}))).cart?.checkoutUrl??null}function Nt(t,n){let e=typeof n=="number"?{quantity:n}:n,r={id:t};e.quantity!==void 0&&(r.quantity=e.quantity),"sellingPlanId"in e&&(r.sellingPlanId=e.sellingPlanId?q.sellingPlan(e.sellingPlanId):null),e.attributes&&(r.attributes=M(e.attributes));let i=e.merchandiseId||e.variantId;return i&&(r.merchandiseId=q.variant(i)),r}var at=t=>A({name:"cartLinesUpdate",args:"$lines: [CartLineUpdateInput!]!",inner:"lines: $lines",variables:{lines:t},createInput:null}),st=t=>A({name:"cartLinesRemove",args:"$lineIds: [ID!]!",inner:"lineIds: $lineIds",variables:{lineIds:t},createInput:null}),Kt=(t,n)=>n>0?at([{id:t,quantity:n}]):st([t]);var ut=null;function Vt(t){ut=t}var mn=t=>Ft(t).then(n=>({kind:"url",url:n}),n=>({kind:"failed",error:n}));async function pn(){if(!ut)return null;try{let t=await ut();return t&&`${t}${t.includes("?")?"&":"?"}logged_in=true`}catch(t){return S(t,"account checkout"),null}}async function fn(t){let n=mn(t),e=await pn();if(e)return e;let r=await n;if(r.kind==="failed")throw r.error;if(!r.url)throw new y("No checkoutUrl (cart empty or expired)");return r.url}function gn(t){try{t.opener=null}catch{}}async function _t(t=a.checkoutTarget){let n=P(),e=d();if(!n||e&&!e.totalQuantity)return null;let r=t==="_blank"?window.open("","_blank"):null;r&&gn(r);try{let i=await fn(n);if(!dt(i))throw new y("The checkout URL is not https: not opened");return f("checkout",{url:i,cart:d()}),r&&!r.closed?r.location.href=i:window.location.href=i,i}catch(i){return r?.close(),S(i,"checkout failed"),null}}var B=()=>d()?.lines.nodes??[];function yn(t,n){let e=B().find(c=>c.id===t);if(!e)return Promise.resolve(d());let r=Math.max(0,ot(e)+n),i={quantity:r};L.set(t,i),O("pending");let o=()=>L.get(t)===i;return C(async()=>{if(!o())return d();if(B().find(b=>b.id===t)?.quantity===r)return d();let m=await Kt(t,r);return o()?h(m,r>0?"update":"remove"):(it(m),m)}).finally(()=>{o()&&(L.delete(t),O("settled"))})}function hn(t){let n=(d()?.discountCodes??[]).map(r=>r.code),e=typeof t=="function"?t(n):t;return(Array.isArray(e)?e:[e]).map(r=>r.trim()).filter(Boolean)}function Cn(t){let n=new Map((d()?.attributes??[]).map(e=>[e.key,e.value]));return M(t).forEach(e=>n.set(e.key,e.value)),[...n].filter(([,e])=>e!=="").map(([e,r])=>({key:e,value:r}))}async function bn(){let t=P();if(!t)return Q({kind:"loaded",cart:null}),null;qt();try{let n=await Wt(t);n||T(),Q({kind:"loaded",cart:n})}catch(n){S(n,"cart load failed"),H(n)&&T(),Q({kind:"failed",error:n})}return d()}var D={init:bn,id:P,get status(){return j()},get state(){return d()},get lines(){return[...B()]},get count(){return d()?.totalQuantity??0},get loaded(){return j().kind!=="unknown"},get lastError(){let t=j();return t.kind!=="error"?null:t.error instanceof Error?t.error:new Error(String(t.error))},get warnings(){return[...$t()]},get pendingQty(){return L},setCheckoutResolver:Vt,forgetSaved(){T(),Q({kind:"loaded",cart:null})},render:U,subscribe:Ot,add(t,n=1,e={}){let r=(Array.isArray(t)?t:[t]).map(i=>Dt(i,n,e));return C(async()=>{let i=await A({name:"cartLinesAdd",args:"$lines: [CartLineInput!]!",inner:"lines: $lines",variables:{lines:r},createInput:{lines:r}});if(!i)throw new y("Shopify answered the add without a cart");return h(i,"add"),f("added",{cart:i,lines:r}),a.openCartOnAdd&&_(),i})},updateLine(t,n){let e=typeof n=="number"?n:n.quantity;if(e!==void 0&&e<=0)return D.removeLine(t);let r=Nt(t,n);return C(async()=>h(await at([r]),"update"))},changeQuantity:yn,quantityOf:ot,removeLine(t){let n=Array.isArray(t)?t:[t];return C(async()=>h(await st(n),"remove"))},clear(){let t=B().map(n=>n.id);return t.length?D.removeLine(t):Promise.resolve(d())},setNote(t){let n={note:t??""};return C(async()=>h(await A({name:"cartNoteUpdate",args:"$note: String!",inner:"note: $note",variables:n,createInput:n}),"note"))},setAttributes(t){return C(async()=>{let n={attributes:Cn(t)},e=await A({name:"cartAttributesUpdate",args:"$attributes: [AttributeInput!]!",inner:"attributes: $attributes",variables:n,createInput:n});return h(e,"attributes")})},setDiscountCodes(t){return C(async()=>{let n={discountCodes:hn(t)},e=await A({name:"cartDiscountCodesUpdate",args:"$discountCodes: [String!]!",inner:"discountCodes: $discountCodes",variables:n,createInput:n});return h(e,"discount")})},async applyDiscount(t){let n=await D.setDiscountCodes(i=>[...new Set([...i,t])]),e=t.toLowerCase();if((n?.discountCodes??[]).find(i=>i.code.toLowerCase()===e)?.applicable)return n;try{await D.removeDiscount(t)}catch(i){S(i,"removing a discount code Shopify refused")}throw new y(`Discount code not valid: ${t}`,{code:"INVALID_DISCOUNT"})},removeDiscount(t){let n=t.toLowerCase();return D.setDiscountCodes(e=>e.filter(r=>r.toLowerCase()!==n))},setBuyerIdentity(t,{create:n=!0}={}){return C(async()=>{let e=await A({name:"cartBuyerIdentityUpdate",args:"$buyerIdentity: CartBuyerIdentityInput!",inner:"buyerIdentity: $buyerIdentity",variables:{buyerIdentity:t},createInput:n?{buyerIdentity:t}:null}).catch(r=>{if(n||!H(r))throw r;return null});return h(e,"buyer-identity")})},checkout:_t,drawers:k,isOpen:g,open:_,close:Z,toggle:wt};export{Xt as a,nt as b,et as c,Et as d,D as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{A as G,E as j,F as Q,b as y,d as h,e as S,o as F,p as V,r as u,x as C,y as T,z as E}from"./chunk-E5YO6274.js";var p=class extends Error{constructor(r,{status:n,errors:i,userErrors:o,code:s}={}){super(r);y(this,"name","TetherError");y(this,"code");y(this,"status");y(this,"errors");y(this,"userErrors");this.code=s??(n?`HTTP_${n}`:"ERROR"),this.status=n,this.errors=i,this.userErrors=o}};function x(t,e){return typeof e=="function"?e(t):typeof e=="string"?e==="object"?h(t):typeof t===e:mt(e)?Array.isArray(t)&&t.every(r=>x(r,e[0])):h(t)&&Object.entries(e).every(([r,n])=>x(t[r],n))}var mt=t=>Array.isArray(t),Re=t=>e=>e===null||x(e,t),Oe=t=>e=>x(e,t);function ht(t=u){return`https://${t.domain}/api/${t.apiVersion}/graphql.json`}var yt=/"(?:\\.|[^"\\\n])*"|#[^\n]*/g,Et=/^\s*(?:query|mutation)(?:\s+\w+)?\s*(?:\([^)]*\))?/;function Y(t,{country:e,language:r}){let n=[];if(e&&n.push(`country: ${e}`),r&&n.push(`language: ${r}`),!n.length)return t;let i=`@inContext(${n.join(", ")})`,o=t.replace(yt,d=>" ".repeat(d.length)),s=o.indexOf("{");if(o.slice(0,s).includes("@inContext"))return t;if(o.trimStart().startsWith("{"))return`query ${i} ${t.slice(s)}`;let c=Et.exec(o);if(!c)return t;let l=c[0].length;return`${t.slice(0,l).trimEnd()} ${i} ${t.slice(l).trimStart()}`}function Pe(t,e=u){let r=F(e.country)??void 0,n=V(e.language)??void 0;return Y(t,{country:r,language:n})}var W=300,Tt=500,B=430,bt=1e3,I="quantityAvailable",q=new Set,wt=t=>`${t.domain} ${t.apiVersion} ${t.token}`;function At(t,e,r,n){let i=typeof e=="string"?e:e(r),o=n?Y(i,t):i;return t.maxAge<=0||/^\s*mutation\b/.test(o)?o:`${o} #${Math.floor(Date.now()/(t.maxAge*bt))}`}var St=t=>new Promise(e=>setTimeout(e,t));function R(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 xt(t){let e=S(t,"message"),r=S(S(t,"extensions"),"code"),n=typeof e=="string"?e:"";return typeof r=="string"?{message:n,extensions:{code:r}}:{message:n}}function vt(t){if(!h(t))return null;let{data:e,errors:r}=t;return r==null?{data:e}:Array.isArray(r)?{data:e,errors:r.map(xt)}:null}function N(t,e){let r=t.ok?`Invalid response (${t.status})`:R(t.status,e);return new p(r,{status:t.status})}function z(t,e,r){let n=e.map(o=>o.message).filter(Boolean).join(" | "),i=n||"Storefront API error";return t.ok||(i=t.status===401||t.status===403||!n?R(t.status,r):n),new p(i,{status:t.status,errors:e})}async function kt(t,e,r,n,i){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(f){if(i)return{kind:"retry",backoffMs:W};throw new p(`Network error: ${G(f)}`,{code:"NETWORK"})}if(o.status===B)throw new p("Shopify security rejection (430)",{status:B});if(i&&(o.status===429||o.status>=500))return{kind:"retry",backoffMs:W};let s;try{s=await o.json()}catch{throw N(o,t)}let c=vt(s);if(!c)throw N(o,t);let{data:l,errors:d=[]}=c;if(d.length){if(e.includes(I)&&d.some(f=>f.message.includes(I)))return{kind:"inventory-refused",error:z(o,d,t)};if(i&&d.some(f=>f.extensions?.code==="THROTTLED"))return{kind:"retry",backoffMs:Tt};throw z(o,d,t)}if(!o.ok)throw new p(R(o.status,t),{status:o.status});if(!n(l))throw N(o,t);return{kind:"data",data:l}}async function Lt(t,e,r,n,{context:i=!0}={}){if(!t.domain||!t.token)throw new p("Tether is not configured: domain and token are required",{code:"NOT_CONFIGURED"});let o=wt(t),s=0;for(;;){let c=At(t,e,{inventory:!q.has(o)},i),l=await kt(t,c,r,n,s<t.retries);switch(l.kind){case"data":return l.data;case"inventory-refused":if(typeof e=="string")throw l.error;C(`the token can't read inventory: ${I} is left out from now on`),q.add(o);break;case"retry":s+=1,C("retry",s),await St(l.backoffMs*2**s);break}}}function Ct(t,e,r,n){return Lt(u,t,e,r,n)}var Nt=t=>typeof t=="object"&&t!==null;function Me(t,e={},r){return Ct(t,e,Nt,r)}function _e(t,e){if(!t)throw new p(`${e}: empty response`);let r=t.userErrors??[];if(r.length)throw new p(r.map(n=>n.message).join(" | "),{userErrors:r});return t}var g=t=>`${u.prefix}-${t}`,It=(t,e)=>e===void 0?`[${g(t)}]`:`[${g(t)}="${e}"]`,O=(t,e)=>t.getAttribute(g(e)),Rt=(t,e)=>t.hasAttribute(g(e));function K(t,e){return t?[...t.querySelectorAll(e)]:[]}var Ot=(t,e,r)=>K(t,e).filter(n=>n.closest(r)===t),Pt=["product-ready","list-ready","cart-updated","cart-toggled","checkout","search"],J=new WeakMap;function X(t,e){let r=new CustomEvent(`${u.prefix}:${t}`,{detail:e,bubbles:!0});return J.set(r,t),r}function Mt(t,e){return J.get(t)===e}function P(t,e,r=document){r.dispatchEvent(X(t,e))}function tt(t,{width:e,height:r,crop:n}={}){if(!t)return t;let i;try{i=new URL(t)}catch(o){if(o instanceof TypeError)return t;throw o}return e&&i.searchParams.set("width",String(e)),r&&i.searchParams.set("height",String(r)),n&&i.searchParams.set("crop",n),i.toString()}function M(t,e){return t.getAttribute(e)??t.getAttribute(g(e))??t.getAttribute(`data-${e}`)}function et(t,e){if(!t||!e)return t;let r=M(e,"max-width"),n=M(e,"max-height");return tt(t,{width:r,height:n,crop:r||n?M(e,"crop"):null})}var Z=t=>t.replace(/\?.*$/,"");function rt(t,e){return!t||!e?!1:Z(t)===Z(e)}function _t(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 Ht(t,e,r){if(!e)return;let n=et(e,t);if(t.tagName!=="IMG"){t.style.backgroundImage=_t(n);return}if(rt(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 _=new WeakMap,Ut=t=>!!_.get(t),H=t=>t.cloneNode(!0);function nt(t){let e=_.get(t);if(e!==void 0)return e;let r=t.firstElementChild,n=r?H(r):null;return _.set(t,n),t.replaceChildren(),n}function $t(t,e,r){let n=nt(t);if(!n){e.length&&T("repeater without a template child",t);return}t.replaceChildren(),e.forEach((i,o)=>{let s=H(n);r(s,i,o),t.appendChild(s)})}function Dt(t,e){let r=()=>{t.remove()};if(!e){r();return}try{e(t,r)}catch(n){E(n,"repeater onLeave"),r()}}function Ft(t,e,r,n){e.forEach((i,o)=>{if(!r.has(i))return;let s=e[o-1];if(s?.parentNode===t?s.after(i):t.prepend(i),!!n)try{n(i)}catch(c){E(c,"repeater onEnter")}})}function Vt(t,e,r,n,{onEnter:i,onLeave:o}={}){let s=nt(t);if(!s){T("repeater without a template child",t);return}let c=`data-${u.prefix}-key`,l=`data-${u.prefix}-leaving`,d=()=>[...t.children].filter(a=>a.hasAttribute(c)&&!a.hasAttribute(l)),f=new Map(d().map(a=>[a.getAttribute(c),a])),b=[],w=new Set;e.forEach((a,A)=>{let L=String(r(a,A)),m=f.get(L);m?f.delete(L):(m=H(s),m.setAttribute(c,L),w.add(m)),n(m,a,A,w.has(m)),b.push(m)});let k=b.filter(a=>!w.has(a)),D=d().filter(a=>k.includes(a));if(!(D.length===k.length&&D.every((a,A)=>a===k[A]))){f.forEach(a=>{a.remove()}),b.forEach(a=>t.appendChild(a));return}Ft(t,b,w,i),f.forEach(a=>{a.setAttribute(l,""),a.removeAttribute(c),a.style.pointerEvents="none",a.inert=!0,Dt(a,o)})}var Gt="http://www.w3.org/1999/xhtml",jt=new Set(["h1","h2","h3","h4","h5","h6","p","span","div","br","hr","blockquote","code","pre","strong","em","b","i","u","s","small","sub","sup","ul","ol","li","dl","dt","dd","table","caption","colgroup","col","thead","tbody","tfoot","tr","th","td","a","img","picture","source","video","figure","figcaption","iframe"]),Qt=new Set(["script","style","template","noscript","textarea","select","title"]),Wt=new Set(["style","title","lang","dir","role","align","width","height"]),Bt=new Map([["a",new Set(["href","target","rel","hreflang"])],["img",new Set(["src","srcset","sizes","alt","loading","decoding"])],["source",new Set(["src","srcset","sizes","type","media"])],["video",new Set(["src","poster","controls","autoplay","muted","loop","playsinline","preload"])],["iframe",new Set(["src","allow","allowfullscreen","frameborder","loading"])],["blockquote",new Set(["cite"])],["ol",new Set(["start","type","reversed"])],["li",new Set(["value"])],["table",new Set(["border","cellpadding","cellspacing","summary"])],["col",new Set(["span"])],["colgroup",new Set(["span"])],["th",new Set(["colspan","rowspan","headers","scope","valign"])],["td",new Set(["colspan","rowspan","headers","valign"])]]),qt=new Set(["href","src","poster","cite"]),zt=/^(javascript|vbscript|data):/i,Yt=/^data:image\/(png|gif|jpeg|webp|avif);/i,Kt=new Set(["position","top","right","bottom","left","z-index","-webkit-box-reflect"]),Jt=["inset","transform","translate","rotate","scale","offset"],Xt=/\d(?:[sld]?v|cq)(?:w|h|i|b|min|max)\b/i,Zt=/^(?:outline|box-shadow|text-shadow|filter|text-decoration|text-underline-offset|text-stroke)|^(?:border-image|mask-border|mask-box-image)(?:-outset)?$/,ot=40,te=new Map([["letter-spacing",{px:4,em:.25}],["word-spacing",{px:4,em:.25}],["text-indent",{px:ot}]]),it=/(?<![\w#.-])[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?(%|[a-z]+)?/gi,ee=/(?<![\w-])(?!drop-shadow\(|blur\()[\w-]+\([^()]*\)/g,st=/(?:var|calc|min|max|clamp|env|attr)\(/i,re=/url\(|expression\(|@import/i,ne=/[\u0000- ]/g,oe="allow-scripts allow-same-origin allow-popups allow-presentation",ie=new Set(["autoplay","encrypted-media","picture-in-picture","fullscreen","clipboard-write","accelerometer","gyroscope","web-share"]),se="strict-origin-when-cross-origin",ae=["https://www.youtube.com","https://www.youtube-nocookie.com","https://player.vimeo.com","https://www.loom.com","https://fast.wistia.net"];function ue(t,e){return Wt.has(e)||e.startsWith("aria-")||(Bt.get(t)?.has(e)??!1)}function ce(t,e,r){let n=r.replace(ne,"");return zt.test(n)?t==="img"&&e==="src"&&Yt.test(n):!0}function at(t,e){try{return new URL(t,e)}catch{return null}}function le(t,e,r){let n=t.baseURI,i=at(n)?.origin??"null";return{origin:i==="null"?null:i,baseUrl:n,styleParser:e,embedOrigins:new Set([...ae,...r])}}function de(t,e){let r=at(t.trim(),e.baseUrl);return r!==null&&r.origin!==e.origin&&e.embedOrigins.has(r.origin)}function fe(t){let e=t.split(";").map(r=>r.trim().split(/\s+/)[0]?.toLowerCase()??"");return[...new Set(e.filter(r=>ie.has(r)))].join("; ")}function pe(t,e){if(Kt.has(t)||Jt.some(n=>t.startsWith(n))||Xt.test(e))return!0;let r=te.get(t);return r?st.test(e)||ge(e,r):t.startsWith("margin")&&e.includes("-")}function ge(t,e){return[...t.matchAll(it)].some(([r="",n=""])=>{let i=parseFloat(r);if(i>=0)return!1;let o=e[n.toLowerCase()];return o===void 0||-i>o})}function me(t,e){return Zt.test(t.replace(/^-webkit-/,""))?st.test(e)?!0:[...e.replace(ee,"").matchAll(it)].some(([r="",n=""])=>{let i=Math.abs(parseFloat(r));return i!==0&&(n.toLowerCase()!=="px"||i>ot)}):!1}function he(t,e){let r=e.style;r.cssText=t;let n=Array.from({length:r.length},(o,s)=>r.item(s));for(let o of n){let s=r.getPropertyValue(o);(pe(o,s)||me(o,s)||re.test(s))&&r.removeProperty(o)}let i=r.cssText;return e.removeAttribute("style"),i}function ye(t,e){let r=t.localName;for(let o of[...t.attributes]){let s=o.name.toLowerCase(),c=qt.has(s);ue(r,s)&&(!c||ce(r,s,o.value))||t.removeAttribute(o.name)}let n=t.getAttribute("style");if(n===null)return;let i=he(n,e.styleParser);i===""?t.removeAttribute("style"):t.setAttribute("style",i)}function Ee(t){if(t.localName==="iframe"){let r=fe(t.getAttribute("allow")??"");r===""?t.removeAttribute("allow"):t.setAttribute("allow",r),t.setAttribute("sandbox",oe),t.setAttribute("referrerpolicy",se);return}if(t.localName!=="a"||t.getAttribute("target")?.toLowerCase()!=="_blank")return;let e=new Set((t.getAttribute("rel")??"").split(/\s+/).filter(Boolean));e.add("noopener"),e.add("noreferrer"),t.setAttribute("rel",[...e].join(" "))}function Te(t,e){let r=t.localName,n=t.namespaceURI===Gt;if(n&&Qt.has(r)){t.remove();return}if(!n||!jt.has(r)){t.replaceWith(...t.childNodes);return}if(r==="iframe"&&!de(t.getAttribute("src")??"",e)){t.remove();return}ye(t,e),Ee(t)}function ut(t,e=globalThis.document,r=[]){let n=e.createElement("template");n.innerHTML=t??"";let i=le(e,n,r);for(let o of[...n.content.querySelectorAll("*")])Te(o,i);return n.content}var ct="data-tether-seen",$="data-tether-shown",v="data-tether-prev-display",be=120;function Ke(t,e){return Q(u.productPath||"/product",t,e)}function pt(t,e){try{return t()}catch(r){if(r instanceof RangeError)return e;throw r}}function Je(t,e=u.locale){return t?pt(()=>new Intl.NumberFormat(e||void 0,{style:"percent",maximumFractionDigits:0}).format(t/100),`${t}%`):""}function Xe(t){return t?u.formatMoney?u.formatMoney(t,u.locale):j(t,u.locale):""}function Ze(t){return t?pt(()=>new Date(t).toLocaleDateString(u.locale||void 0),""):""}function tr(t,e){t.replaceChildren(ut(e,t.ownerDocument,u.embedOrigins))}var gt=t=>t.tagName==="INPUT"||t.tagName==="TEXTAREA",lt=t=>t.tagName==="INPUT";function we(t,e){let r=e==null?"":String(e);gt(t)?t.value=r:t.textContent=r}var dt=t=>gt(t)?t.value:t.textContent;function er(t,e){let r=dt(t);if(we(t,e),r!==dt(t)&&t.hasAttribute(ct)&&u.onValueChange)try{u.onValueChange(t,r)}catch(n){E(n,"onValueChange")}t.setAttribute(ct,"1")}function Ae(t){if(t.hasAttribute($))return;t.setAttribute($,""),t.removeAttribute("hidden");let e=t.getAttribute(v);e!==null?(t.style.display=e,t.removeAttribute(v)):t.style.display==="none"&&(t.style.display=""),typeof getComputedStyle=="function"&&getComputedStyle(t).display==="none"&&(t.style.display=t.getAttribute(g("display"))||"block")}function rr(t,e){if(e){Ae(t);return}t.removeAttribute($),!t.hasAttribute(v)&&t.style.display!=="none"&&t.setAttribute(v,t.style.display),t.style.display="none"}function nr(t,e){t.classList.toggle("is-selected",e),t.setAttribute("aria-pressed",e?"true":"false"),lt(t)&&(t.type==="radio"||t.type==="checkbox")&&(t.checked=e);let r=t.querySelector('input[type="radio"],input[type="checkbox"]');r&<(r)&&(r.checked=e)}var ft,Se=t=>Reflect.get(window,t);function xe(){let t=Se("ScrollTrigger");if(typeof t!="function")return;let e=Reflect.get(t,"refresh");typeof e=="function"&&Reflect.apply(e,t,[])}function ve(t){clearTimeout(ft),ft=setTimeout(()=>{try{u.onLayoutChange?u.onLayoutChange(t):xe()}catch(e){E(e,"layout-changed")}P("layout-changed",{reason:t})},be)}function or(t,e){let r=[...t.querySelectorAll("img")].filter(o=>!o.complete),n=r.length,i=()=>{n-=1,n===0&&ve(`${e}:images`)};r.forEach(o=>{o.addEventListener("load",i,{once:!0}),o.addEventListener("error",i,{once:!0})})}function ir(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 sr(t,e){let r=t?O(t,e):null;if(!r)return null;try{return JSON.parse(r)}catch{return T(`invalid JSON in ${g(e)}`,t),null}}function U(t){return t==null?"":typeof t=="string"?t:typeof t=="number"||typeof t=="boolean"?String(t):JSON.stringify(t)}function ar(t){return Array.isArray(t)?t.filter(h).map(r=>({key:U(r.key),value:U(r.value)})):h(t)?Object.entries(t).map(([e,r])=>({key:e,value:U(r)})):[]}function ur(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{p as a,x as b,Re as c,Oe as d,ht as e,Pe as f,Lt as g,Ct as h,Nt as i,Me as j,_e as k,g as l,It as m,O as n,Rt as o,K as p,Ot as q,Pt as r,Mt as s,P as t,tt as u,rt as v,Ht as w,Ut as x,$t as y,Vt as z,Ke as A,Je as B,Xe as C,Ze as D,tr as E,we as F,er as G,rr as H,nr as I,Se as J,ve as K,or as L,ir as M,sr as N,ar as O,ur as P};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{a as b,b as h,c as y,d as v,h as $}from"./chunk-BA4LQJJQ.js";import{G as k,a as te,d as x,e as T,n as _,r as P,x as V}from"./chunk-E5YO6274.js";var de={};te(de,{GID:()=>Q,allPlans:()=>I,allocationFor:()=>M,findPlan:()=>ue,hasPlans:()=>oe,planAdjustment:()=>ce,planCheckoutCharge:()=>se,planPrice:()=>B,planSavings:()=>ae,plansForVariant:()=>le,toGid:()=>C});var re=/^(-?)(\d+)(?:\.(\d+))?$/;function G(e,n){let t=re.exec(e.trim());if(!t)return null;let[,r="",o="0",l=""]=t,u=BigInt(`${o}${l.padEnd(n,"0")}`);return r==="-"?-u:u}var L=e=>e.split(".")[1]?.length??0;function Fe(e,n){if(e==null||n==null)return!1;let t=Math.max(L(e.trim()),L(n.trim())),r=G(e,t),o=G(n,t);return r===null||o===null?!1:r>o}var q=2,U=new Map;function W(e){let n=U.get(e);if(n!==void 0)return n;let t=q;try{t=new Intl.NumberFormat("en",{style:"currency",currency:e}).resolvedOptions().maximumFractionDigits??q}catch{}return U.set(e,t),t}function N(e){return Math.round(parseFloat(e.amount)*10**W(e.currencyCode))}function K(e,n){let t=W(n);return{amount:(e/10**t).toFixed(t),currencyCode:n}}var ie=100;function C(e,n){let t=typeof e=="string"||typeof e=="number"?String(e).trim():"";return t?t.startsWith("gid://")?t:/^\d+$/.test(t)?`gid://shopify/${n}/${t}`:t:null}var Q={product:e=>C(e,"Product"),variant:e=>C(e,"ProductVariant"),sellingPlan:e=>C(e,"SellingPlan")};function I(e){return(e?.sellingPlanGroups?.nodes??[]).flatMap(t=>t.sellingPlans.nodes.map(r=>({...r,group:t})))}function oe(e){return I(e).length>0}function M(e,n){return!e||!n?null:(e.sellingPlanAllocations?.nodes??[]).find(r=>r.sellingPlan.id===n)??null}function le(e,n){return I(e).filter(t=>M(n,t.id))}function B(e,n){let t=M(e,n)?.priceAdjustments[0];return t?.perDeliveryPrice??t?.price??e?.price??null}function se(e,n){let t=M(e,n);return t?.checkoutChargeAmount??t?.priceAdjustments[0]?.price??e?.price??null}function ae(e,n){let t=B(e,n);if(!e||!t)return{amount:null,percentage:0};let r=parseFloat(e.price.amount),o=parseFloat(t.amount);if(!Number.isFinite(r)||!Number.isFinite(o)||r<=0||o>=r)return{amount:null,percentage:0};let l=N(e.price)-N(t);return{amount:K(l,e.price.currencyCode),percentage:Math.round((1-o/r)*ie)}}function ce(e){let n=e?.priceAdjustments[0]?.adjustmentValue;if(!n)return null;switch(n.__typename){case"SellingPlanPercentagePriceAdjustment":return{type:"percentage",value:n.adjustmentPercentage};case"SellingPlanFixedAmountPriceAdjustment":return{type:"amount",value:n.adjustmentAmount};case"SellingPlanFixedPriceAdjustment":return{type:"price",value:n.price};default:return null}}function ue(e,n){if(!n)return null;let t=I(e),r=Q.sellingPlan(n),o=n.trim().toLowerCase();return t.find(l=>l.id===r)??t.find(l=>l.name.toLowerCase()===o)??t.find(l=>l.options.some(u=>u.value.toLowerCase()===o))??null}var i="amount currencyCode",H={inventory:!0},Y=e=>e.inventory?"quantityAvailable":"",g="url altText width height";function pe(e){let n=[];for(let r of e){let o=_(r);o&&n.push(o)}return n.length?`metafields(identifiers:[${n.map(({namespace:r,key:o})=>`{namespace: ${JSON.stringify(r)}, key: ${JSON.stringify(o)}}`).join(", ")}]){namespace key type value reference{... on MediaImage{image{${g}}}}}`:""}var ge=` id name description recurringDeliveries options{name value}priceAdjustments{orderCount adjustmentValue{__typename ... on SellingPlanPercentagePriceAdjustment{adjustmentPercentage}... on SellingPlanFixedAmountPriceAdjustment{adjustmentAmount{${i}}}... on SellingPlanFixedPriceAdjustment{price{${i}}}}}`,me=` sellingPlan{id}checkoutChargeAmount{${i}}remainingBalanceChargeAmount{${i}}priceAdjustments{price{${i}}compareAtPrice{${i}}perDeliveryPrice{${i}}unitPrice{${i}}}`;function z(e=P,n=H){return` fragment TetherProduct on Product{id handle title description descriptionHtml productType vendor tags availableForSale publishedAt onlineStoreUrl requiresSellingPlan seo{title description}featuredImage{${g}}images(first:${e.imagesFirst}){nodes{${g}}}options{name optionValues{name swatch{color image{previewImage{${g}}}}}}priceRange{minVariantPrice{${i}}maxVariantPrice{${i}}}compareAtPriceRange{minVariantPrice{${i}}maxVariantPrice{${i}}}${pe(e.metafields)} sellingPlanGroups(first:${e.sellingPlanGroupsFirst}){nodes{name appName options{name values}sellingPlans(first:${e.sellingPlansFirst}){nodes{${ge}}}}}variants(first:${e.variantsFirst}){nodes{id title availableForSale currentlyNotInStock ${Y(n)} sku barcode selectedOptions{name value}image{${g}}price{${i}}compareAtPrice{${i}}unitPrice{${i}}sellingPlanAllocations(first:${e.sellingPlansFirst}){nodes{${me}}}}}}`}function De(e=H){return` fragment TetherCart on Cart{id checkoutUrl totalQuantity note createdAt updatedAt attributes{key value}buyerIdentity{countryCode email}discountCodes{code applicable}cost{subtotalAmount{${i}}totalAmount{${i}}checkoutChargeAmount{${i}}}lines(first:100){nodes{id quantity attributes{key value}cost{totalAmount{${i}}subtotalAmount{${i}}amountPerQuantity{${i}}compareAtAmountPerQuantity{${i}}}discountAllocations{discountedAmount{${i}}}sellingPlanAllocation{sellingPlan{id name description recurringDeliveries options{name value}}checkoutChargeAmount{${i}}priceAdjustments{price{${i}}compareAtPrice{${i}}perDeliveryPrice{${i}}}}merchandise{... on ProductVariant{id title sku availableForSale requiresShipping ${Y(e)} image{${g}}price{${i}}compareAtPrice{${i}}selectedOptions{name value}product{id title handle vendor featuredImage{${g}}}}}... on ComponentizableCartLine{lineComponents{id quantity merchandise{... on ProductVariant{id title product{title handle}}}}}}}}`}function J(){return`
|
|
2
|
+
id handle title description descriptionHtml
|
|
3
|
+
image { ${g} }
|
|
4
|
+
seo { title description }`}var D={amount:"string",currencyCode:"string"},f={id:"string",handle:"string",title:"string",options:["object"],images:{nodes:["object"]},priceRange:{minVariantPrice:D,maxVariantPrice:D},variants:{nodes:[{id:"string",price:D,selectedOptions:["object"]}]}},O={nodes:[f],pageInfo:{hasNextPage:"boolean"}},_e=e=>T(e,"id")!==""&&T(e,"handle")!==""&&h(e,f),X=e=>x(e)&&(e.id===void 0||h(e,f));var fe=1e4,Pe=6e4,c=new Map,E=new Map,m=new Set,F=new Map,ne=[],R=!1,A=0,Z=e=>e.startsWith("gid://"),j=k;function S(e){if(!e)return;let n=Promise.resolve(e);c.set(e.handle,n),c.set(e.id,n)}function he(e){let n=j(e);if(!n)return Promise.reject(new b("empty product key",{code:"NOT_FOUND"}));let t=c.get(n);if(t)return t;let r=new Promise((o,l)=>{E.set(n,{resolve:o,reject:l}),ne.push(n),R||(R=!0,setTimeout(()=>void Se(),0))});return c.set(n,r),r}var w=e=>n=>`${e}${z(P,n)}`;function ye(e){let n=e.filter(Z),t=e.filter(p=>!Z(p)),r=[],o=[],l={};return n.length&&(r.push("$ids: [ID!]!"),l.ids=n,o.push("byId: nodes(ids: $ids) { ... on Product { ...TetherProduct } }")),t.forEach((p,s)=>{r.push(`$h${s}: String!`),l[`h${s}`]=p,o.push(`h${s}: product(handle: $h${s}) { ...TetherProduct }`)}),{query:w(`query TetherProducts(${r.join(",")}){${o.join(" ")}}`),variables:l,handles:t}}function ee(e,n){let t=E.get(e);E.delete(e),t&&n(t)}function $e(e,n){if(n!==A)return;let t=c.get(e);setTimeout(()=>{c.get(e)===t&&c.delete(e)},fe)}function Ae(e){if(!x(e))return!1;let{byId:n=[],...t}=e;return h(n,[y(X)])&&Object.values(t).every(y(f))}async function Se(){R=!1;let e=A,n=ne.splice(0);if(!n.length)return;let{query:t,variables:r,handles:o}=ye(n);V("fetch products",n);let l;try{l=await $(t,r,Ae)}catch(s){n.forEach(d=>{ee(d,a=>{e===A&&c.delete(d),a.reject(s)})});return}let u=new Map;for(let s of l.byId??[])s?.id&&u.set(s.id,s);o.forEach((s,d)=>{let a=l[`h${d}`];a&&u.set(s,a)});let p=Date.now();n.forEach(s=>{ee(s,d=>{let a=u.get(s);if(!a){$e(s,e),d.reject(new b(`Product not found: ${s}`,{code:"NOT_FOUND"}));return}e===A&&(S(a),F.set(a.handle,p),F.set(a.id,p)),d.resolve(a)})})}function Ke(){c.clear(),A+=1,m.clear(),F.clear()}function Qe(e){for(let n of e??[])!n.id||!n.handle||Date.now()-(F.get(n.handle)??0)<Pe&&c.has(n.handle)||(S(n),m.add(n.handle),m.add(n.id))}function Be(e){let n=j(e);return!n||!m.has(n)?!1:(m.delete(n),c.get(n)?.then(t=>{m.delete(t.handle),m.delete(t.id)},xe),!0)}function xe(){}function He(e){let n=j(e);return n&&c.delete(n),he(e)}var be=v({collection:y({handle:"string",products:O})}),ve=v({products:O}),Ce=v({productRecommendations:y([f])}),Ie=`query TetherCollection($handle:String!,$first:Int!,$after:String,$sortKey:ProductCollectionSortKeys,$reverse:Boolean,$filters:[ProductFilter!]){collection(handle:$handle){${J()} products(first:$first,after:$after,sortKey:$sortKey,reverse:$reverse,filters:$filters){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}}`,Me="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 Ye({collection:e,query:n,first:t=P.collectionFirst,after:r=null,sortKey:o,reverse:l=!1,filters:u}={}){if(e){let s=await $(w(Ie),{handle:e,first:t,after:r,sortKey:o||void 0,reverse:l,filters:u??void 0},be);if(!s.collection)throw new b(`Collection not found: ${e}`,{code:"NOT_FOUND"});let{products:d,...a}=s.collection;return d.nodes.forEach(S),{collection:a,products:d.nodes,pageInfo:d.pageInfo}}let p=await $(w(Me),{first:t,after:r,query:n||void 0,sortKey:o||void 0,reverse:l},ve);return p.products.nodes.forEach(S),{collection:null,products:p.products.nodes,pageInfo:p.products.pageInfo}}async function ze(e,n="RELATED"){let t=j(typeof e=="object"?e?.id:e),r=t?.startsWith("gid://")??!1,l=(await $(w(`query TetherRecs(${r?"$id: ID!":"$handle: String!"},$intent:ProductRecommendationIntent){productRecommendations(${r?"productId: $id":"productHandle: $handle"},intent:$intent){...TetherProduct}}`),r?{id:t,intent:n}:{handle:t,intent:n},Ce)).productRecommendations??[];return l.forEach(S),l}export{z as a,De as b,J as c,Fe as d,N as e,K as f,Q as g,I as h,M as i,B as j,se as k,ae as l,ce as m,ue as n,de as o,D as p,f as q,_e as r,X as s,j as t,S as u,he as v,Ke as w,Qe as x,Be as y,He as z,be as A,ve as B,Ce as C,Ye as D,ze as E};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={diagnose:()=>import("./diagnose-3FEKRIEK.js"),markets:()=>import("./markets-ui-FD6NI2OG.js"),search:()=>import("./search-UJ73YBQ5.js"),extras:()=>import("./extras-6POFBNOP.js"),account:()=>import("./account-UIPWJQ3Y.js"),"account-pages":()=>import("./account-pages-6ROA6Y4V.js"),analytics:()=>import("./analytics-2V632IRV.js")},a=t=>e[t](),r=void 0;export{a,r as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var S=Object.defineProperty;var G=(n,e,t)=>e in n?S(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Fn=(n,e)=>{for(var t in e)S(n,t,{get:e[t],enumerable:!0})};var $n=(n,e,t)=>G(n,typeof e!="symbol"?e+"":e,t);var j=/^(\d{4})-(01|04|07|10)$/;function C(n){let e=j.exec(typeof n=="string"?n:"");return e?{year:Number(e[1]),month:Number(e[2])}:null}var E=n=>C(n)!==null,z=(n,e)=>`${n}-${String(e).padStart(2,"0")}`;function x(n,e=1){let t=C(n);if(!t)throw new Error(`not a quarterly Shopify API version: ${n}`);let o=t.year*4+(t.month-1)/3+e;return z(Math.floor(o/4),o%4*3+1)}function Dn(n,e=new Date){if(n==="unstable")return{version:n,ok:!1,note:'"unstable" changes without notice: pin a dated version such as 2026-07'};let t=C(n);if(!t)return{version:n,ok:!1,note:"not a quarterly version (YYYY-01, -04, -07 or -10)"};let o=new Date(Date.UTC(t.year,t.month-1,1)),r=new Date(Date.UTC(t.year,t.month-1+12,1)),i=(r.getTime()-e.getTime())/2630016e3,f=o<=e,c=`supported until about ${r.toISOString().slice(0,7)}`;return f?i<=0?c="no longer supported: Shopify falls back to the oldest supported version. Upgrade (see README)":i<3&&(c=`${c}: plan the upgrade to ${x(n)} or later (see README)`):c="not released yet (release candidate at best)",{version:n,ok:f&&i>0,monthsLeft:Math.round(i),next:x(n),note:c}}function O(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function Q(n,e){return O(n)?n[e]:void 0}function Z(n){return Array.isArray(n)?n:[]}function B(n){return typeof n=="string"&&n!==""?n:null}var W=n=>typeof n=="number"&&Number.isFinite(n)?n:null,Kn=n=>W(n)??0,R=(n,e)=>Z(n).map(t=>e(t)),Yn=(n,e)=>({nodes:R(Q(n,"nodes"),e)}),vn=n=>R(n,B).filter(e=>e!==null);var J=/^[A-Z]{2}$/,X=new Set(["XX","T1"]),q=new Set(["PT_BR","PT_PT","ZH_CN","ZH_TW"]),nn=/^[A-Z]{2,3}$/;function T(n){let e=(typeof n=="string"?n:"").trim().toUpperCase();return!J.test(e)||X.has(e)?null:e}function w(n){let e=(typeof n=="string"?n:"").trim().replace("-","_").toUpperCase();if(q.has(e))return e;let t=e.split("_")[0]??"";return nn.test(t)?t:null}var _="2026-07";var en=/^[A-Za-z0-9_.-]+$/,tn=/^(\$app(:[A-Za-z0-9_-]+)?|[A-Za-z0-9_.-]+)$/,on=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i,rn=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,sn=/^[A-Za-z_$][\w$]*$/,N="https://site.invalid",an=new Set(["localhost","127.0.0.1","[::1]"]),M=["saved","server","webflow"],un=["no-banner","default-banner","custom-banner"],y=n=>typeof n=="string"&&n!=="",ln=n=>typeof n=="function";function L(n,e){if(typeof n!="string"||!n)return"";let t=n.replace(/^https?:\/\//,"").replace(/\/.*$/,"");return gn(t)?t:(e("domain",n),"")}function U(n){if(!y(n))return!1;try{let e=new URL(n,`${N}/`);return e.origin===N?!0:e.protocol==="https:"||e.protocol==="http:"&&an.has(e.hostname)}catch{return!1}}function I(n,e){return n==null||n===""?null:typeof n=="string"&&(U(n)||cn(n))?n:(e("partsUrl",n),null)}function cn(n){if(typeof location>"u")return!1;try{return new URL(n).origin===location.origin}catch{return!1}}function fn(n){if(typeof n!="string")return null;try{let e=new URL(n);return e.protocol==="https:"&&e.href===new URL(e.origin).href?e.origin:null}catch{return null}}function F(n,e){if(!Array.isArray(n))return e("embedOrigins",n),[];let t=[],o=n;for(let r of o){let i=fn(r);i?t.push(i):e("embedOrigin",r)}return t}function dn(n){let e,t;if(typeof n=="string"){let o=n.indexOf(".");e=o>0?n.slice(0,o):"",t=n.slice(o+1)}else typeof n=="object"&&n!==null&&(e=Reflect.get(n,"namespace"),t=Reflect.get(n,"key"));return typeof e!="string"||typeof t!="string"?null:tn.test(e)&&en.test(t)?{namespace:e,key:t}:null}function $(n,e){if(!Array.isArray(n))return e("metafields",n),[];let t=[],o=n;for(let r of o){let i=dn(r);i?t.push(typeof r=="string"?r:i):e("metafield",r)}return t}var d=n=>e=>n(e)?e:void 0,gn=n=>y(n)&&on.test(n),pn=n=>y(n)&&rn.test(n),yn=n=>typeof n=="boolean"||y(n)&&sn.test(n),p=d(U),k=d(y),P=d(n=>typeof n=="boolean"),V=d(ln);function m(n,e,t,o){if(e==null)return null;if(!O(e))return o(n,e),null;let r={},i=t;for(let[f,c]of Object.entries(i)){let h=e[f];if(h===void 0)continue;let A=c(h);A===void 0?o(`${n}.${f}`,h):r[f]=A}return r}var mn={server:p,orderUrl:p,subscriptionsUrl:p,paymentUrl:p,logoutUrl:p,locale:k,navigate:V},On="customer accounts need the Worker since 0.7.0: set account.server",kn={country:k,language:k,locale:k},hn={detect:n=>{if(typeof n=="boolean")return n;let e=Array.isArray(n)?n:[n];return typeof n=="string"||Array.isArray(n)?M.filter(t=>e.includes(t)):void 0},locales:n=>{if(!O(n))return;let e={};for(let[t,o]of Object.entries(n)){let r=m(`markets.locales.${t}`,o,kn,()=>{});r&&(e[t]=r)}return e},cookie:d(pn),remember:P,strict:P},Cn={consent:n=>un.find(e=>e===n),proxy:n=>n!==void 0&&!!n},Tn={dataLayer:d(yn),shopify:n=>typeof n=="boolean"?n:m("analytics.shopify",n,Cn,()=>{})??void 0,onEvent:V};function D(n,e,t){let o=m("account",n,mn,e);if(o===null)return null;let{server:r}=o;return r===void 0?(t(On),null):{...o,server:r}}var b=(n,e)=>m("markets",n,hn,e),H=(n,e)=>m("analytics",n,Tn,e);var u={domain:"",token:"",apiVersion:_,country:void 0,language:void 0,locale:void 0,markets:null,prefix:"tether",productPath:"/product",collectionPath:"/collection",metafields:[],embedOrigins:[],imagesFirst:25,variantsFirst:100,sellingPlanGroupsFirst:10,sellingPlansFirst:25,collectionFirst:24,retries:2,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},s={...u};function v(n){let e=t=>(l(`Tether.config is read-only (${String(t)}): pass options to Tether.init() instead`),!1);return new Proxy(n,{get(t,o){let r=Reflect.get(t,o);return typeof r=="object"&&r!==null?v(r):r},set:(t,o)=>e(o),deleteProperty:(t,o)=>e(o),defineProperty:(t,o)=>e(o)})}var ee=v(s),wn=/^[a-z][a-z0-9-]*$/,bn=["revalidate","openCartOnAdd","cartFocus","variantUrl","autoMount","observe","astro","debug"],An=["token","productPath","collectionPath","cartDrawerOpenClass"],Sn=["imagesFirst","variantsFirst","sellingPlanGroupsFirst","sellingPlansFirst","collectionFirst","retries","maxAge","lowStock","searchDelay"],xn=["warningText","formatMoney","onLayoutChange","onCartOpen","onCartClose","onLineEnter","onLineLeave","onValueChange","onError"];function g(n,e,t){return e!==void 0&&l(`invalid ${n} ${JSON.stringify(e)}: using ${JSON.stringify(t)}`),t}function a(n,e){l(`invalid ${n} ${JSON.stringify(e)}: ignored`)}function En(n){for(let e of Object.keys(n))e in u||l(`unknown option ${JSON.stringify(e)}: ignored`)}function Rn(n){return typeof n=="function"?n:null}function _n(n){return Object.fromEntries(xn.map(t=>[t,Rn(n[t])]))}function Nn(n,e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:g(n,e,u[n])}function Pn(n,e){return typeof e=="boolean"?e:g(n,e,u[n])}function Mn(n,e){return typeof e=="string"?e:g(n,e,u[n])}function Ln(n){if(!(n==null||n==="")){try{if(typeof n=="string"&&Intl.getCanonicalLocales(n).length)return n}catch{}a("locale",n)}}function K(n,e,t){return t.find(o=>o===e)??g(n,e,t[0])}function Un(n){return n==="unstable"?(l('apiVersion "unstable" changes without notice. Pin a dated version (e.g. 2026-07).'),n):E(n)?n:g("apiVersion",n,u.apiVersion)}function Y(n,e,t){if(e==null||e==="")return;let o=t(e);if(o!==null)return o;a(n,e)}function In(n){En(n);let e=L(n.domain,a),t=typeof n.prefix=="string"&&wn.test(n.prefix)?n.prefix:g("prefix",n.prefix,u.prefix),o={...u,..._n(n),domain:e,apiVersion:Un(n.apiVersion),country:Y("country",n.country,T),locale:Ln(n.locale),partsUrl:I(n.partsUrl,a),language:Y("language",n.language,w),markets:b(n.markets,a),analytics:H(n.analytics,a),account:D(n.account,a,l),prefix:t,storageKey:typeof n.storageKey=="string"&&n.storageKey?n.storageKey:`${t}:cart:${e}`,metafields:$(n.metafields??[],a),embedOrigins:F(n.embedOrigins??[],a),checkoutTarget:K("checkoutTarget",n.checkoutTarget,["_self","_blank"]),defaultPurchase:K("defaultPurchase",n.defaultPurchase,["one-time","subscription"])};for(let r of Sn)o[r]=Nn(r,n[r]);for(let r of bn)o[r]=Pn(r,n[r]);for(let r of An)o[r]=Mn(r,n[r]);return o}var te=n=>b(n,a);function oe(n={}){let e=In(n);for(let t of Object.keys(s))t in e||Reflect.deleteProperty(s,t);return Object.assign(s,e)}var re=()=>!!(s.domain&&s.token);function ie(...n){s.debug&&console.log(`[${s.prefix}]`,...n)}function l(...n){console.warn(`[${s.prefix}]`,...n)}function se(n,e){if(l(e,n instanceof Error&&n.message?n.message:n),!!s.onError)try{s.onError(n,e)}catch(t){l("onError threw",t)}}function le(n){return n instanceof Error?n.message:String(n)}var fe={domain:["PUBLIC_SHOPIFY_DOMAIN","PUBLIC_SHOPIFY_STORE_DOMAIN","SHOPIFY_DOMAIN"],token:["PUBLIC_SHOPIFY_STOREFRONT_TOKEN","PUBLIC_SHOPIFY_STOREFRONT_ACCESS_TOKEN","SHOPIFY_STOREFRONT_TOKEN"]};function de(n){if(typeof n!="string")return!1;try{return new URL(n).protocol==="https:"}catch{return!1}}function ge(n){return/^shp[a-z]{2}_/.test(n.trim())}function pe(n,e){if(!n)return"";let t=parseFloat(n.amount);if(Number.isNaN(t))return"";try{return new Intl.NumberFormat(e||void 0,{style:"currency",currency:n.currencyCode}).format(t)}catch{return`${n.currencyCode} ${t.toFixed(2)}`}}function ye(n,e,t){if(!/\{(handle|id)\}/.test(n))return e?`${n.replace(/\/$/,"")}/${encodeURIComponent(e)}`:null;let o=t?t.split("/").at(-1)??"":"";return n.includes("{handle}")&&!e||n.includes("{id}")&&!o?null:n.replace(/\{handle\}/g,encodeURIComponent(e??"")).replace(/\{id\}/g,encodeURIComponent(o))}function me(n){let e=String(n??"").trim();return e?e.startsWith("gid://")?e:/^\d+$/.test(e)?`gid://shopify/Product/${e}`:/\/products\/([^/?#]+)/.exec(e)?.[1]??e:null}export{Fn as a,$n as b,Dn as c,O as d,Q as e,Z as f,B as g,W as h,Kn as i,R as j,Yn as k,vn as l,M as m,dn as n,T as o,w as p,u as q,s as r,ee as s,In as t,te as u,oe as v,re as w,ie as x,l as y,se as z,le as A,fe as B,de as C,ge as D,pe as E,ye as F,me as G};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{H as p,l as c,m as i,n as d,q as u}from"./chunk-BA4LQJJQ.js";var m="url:";function h(e){try{return decodeURIComponent(e)}catch(t){if(t instanceof URIError)return e;throw t}}function b(e,t=window.location,a="product"){let n=(d(e,a)??"").trim();if(!n.toLowerCase().startsWith(m))return{key:n||null,fromUrl:!1,raw:n};let r=n.slice(m.length).trim(),o;if(r.toLowerCase()==="path"){let s=t.pathname.split("/").filter(Boolean),f=s[s.length-1];o=f===void 0?null:h(f)}else o=new URLSearchParams(t.search).get(r||"handle");return{key:o?.trim()||null,fromUrl:!0,raw:n}}var w=["loading","ready","error","not-found"],y=e=>w.some(t=>t===e),S=e=>typeof e=="object"&&e!==null&&"code"in e?e.code:void 0,E=e=>S(e)==="NOT_FOUND",l=()=>["product","collection","products","recommendations"].map(e=>i(e)).join(","),U=(e,t)=>e===t||e.parentElement?.closest(l())===t;function g(e){let t=S(e);return typeof t=="string"&&t?t:"error"}function x(e,t,a){let n=t==="not-found",r=t==="error"||n;e.setAttribute(c("state"),n?"error":t),r?e.setAttribute(c("error"),n?"not-found":g(a)):e.removeAttribute(c("error")),u(e,i("show"),l()).forEach(o=>{let s=d(o,"show");y(s)&&p(o,s===t)}),r&&u(e,i("add-to-cart"),l()).forEach(o=>{o.classList.add("is-disabled"),o.setAttribute("aria-disabled","true"),"disabled"in o&&(o.disabled=!0)})}export{b as a,w as b,E as c,l as d,U as e,x as f};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{e as P,f,g as x,h as v,i as d,j as g,k as A,l as y,m as I,n as h}from"./chunk-BFTZR4OB.js";var M=100,V=(n,e)=>f(P(n)*e,n.currencyCode),S=n=>Object.fromEntries(n.selectedOptions.map(e=>[e.name,e.value]));function w(n,e){return n.variants.nodes.find(o=>o.selectedOptions.every(r=>e[r.name]===r.value))??null}function T(n,e,o,r){return n.variants.nodes.some(t=>t.availableForSale&&t.selectedOptions.every(i=>i.name===o?i.value===r:e[i.name]===i.value))}var k=n=>n.kind==="subscription"?n.planId:n.offeredPlanId;function F(n,e){return n.kind==="subscription"&&d(e,n.planId)?n:{kind:"one-time"}}function C(n,e,o,r){let t=v(n),i=t.find(s=>s.id===r)??t[0];if(!i)return{kind:"one-time",offeredPlanId:null};let a=d(e,i.id)?i:t.find(s=>d(e,s.id))??i;return n.requiresSellingPlan||o==="subscription"?{kind:"subscription",planId:a.id}:{kind:"one-time",offeredPlanId:a.id}}function B(n,{variant:e,sellingPlan:o,defaultPlan:r,defaultPurchase:t}){let i=n.variants.nodes,a=x.variant(e),s=i.find(l=>l.id===a)??i.find(l=>l.availableForSale)??i[0]??null,c=h(n,o),p=c??h(n,r),m=c||t==="subscription"?"subscription":"one-time";return{selected:s?S(s):{},purchase:C(n,s,m,p?.id??null)}}function j(n,e,o,r,t){let i=n.quantityAvailable,a=i!=null&&i>0&&i<=e,s=r.compareAtPrice!==null,c=r.line.kind==="subscription";return{"in-stock":n.availableForSale,"out-of-stock":!n.availableForSale,backorder:n.availableForSale&&n.currentlyNotInStock,"on-sale":s,"not-on-sale":!s,"has-variants":o>1,"single-variant":o===1,"low-stock":a,"plenty-in-stock":n.availableForSale&&!a,"subscription-available":r.subscriptionAvailable,"subscription-unavailable":!r.subscriptionAvailable,"subscription-only":t,"one-time-available":!t,"subscription-selected":c,"one-time-selected":!c,"has-savings":c?r.savings.percentage>0:s}}function R(n,e,o){let r=w(n,e.selected),t=r??n.variants.nodes[0];if(!t)return null;let i=C(n,t,e.purchase.kind,k(e.purchase)),a=k(i),s=v(n),c=F(i,t),p=c.kind==="subscription"?d(t,c.planId):null,m=p?g(t,a)??t.price:t.price,l=p?.priceAdjustments[0]?.compareAtPrice??t.compareAtPrice,b={line:c,subscriptionAvailable:s.some(u=>d(t,u.id)),compareAtPrice:l&&parseFloat(l.amount)>parseFloat(m.amount)?l:null,savings:y(t,a)};return{...b,variant:t,selected:r?e.selected:S(t),purchase:i,plan:s.find(u=>u.id===a)??null,quantity:e.quantity,price:m,show:j(t,o,n.variants.nodes.length,b,n.requiresSellingPlan)}}function G(n,e){let{variant:o,plan:r,price:t,compareAtPrice:i,quantity:a}=n,s=k(n.purchase),c=u=>V(u,Math.max(1,a)),b={price:()=>e.money(t),"total-price":()=>e.money(c(t)),"one-time-price":()=>e.money(o.price),"subscription-price":()=>e.money(s?g(o,s):null),"subscription-savings":()=>e.percent(n.savings.percentage),"subscription-savings-amount":()=>e.money(n.savings.amount),"checkout-charge":()=>{let u=n.line.kind==="subscription"?A(o,s)??t:t;return e.money(c(u))},"plan-name":()=>r?.name,"plan-description":()=>r?.description,"plan-group":()=>r?.group.name,"compare-at-price":()=>e.money(i),"unit-price":()=>e.money(o.unitPrice),"discount-percentage":()=>i?`${Math.round((1-parseFloat(t.amount)/parseFloat(i.amount))*M)}%`:"0%","discount-amount":()=>i?e.money(f(P(i)-P(t),t.currencyCode)):"","variant-title":()=>o.title,"variant-id":()=>o.id,sku:()=>o.sku,barcode:()=>o.barcode,stock:()=>o.quantityAvailable,quantity:()=>a};return new Map(Object.entries(b))}function E(n,e,o,r){let i={name:()=>o?.name,option:()=>(o?.options??[]).map(a=>a.value).join(", "),description:()=>o?.description,price:()=>r.money(g(n,e)),savings:()=>r.percent(y(n,e).percentage),"savings-amount":()=>r.money(y(n,e).amount),adjustment:()=>{let a=I(o);return a?a.type==="percentage"?`${a.value}%`:r.money(a.value):""}};return new Map(Object.entries(i))}export{S as a,T as b,k as c,F as d,C as e,B as f,R as g,G as h,E as i};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as m,c as p}from"./chunk-A5SYCVQM.js";import{m as k,o as i,p as g,r as u,u as y}from"./chunk-E5YO6274.js";var w="tether_country",C=()=>`${u.prefix}:market:${u.domain}`,M={getItem:e=>m(e)};function S(){let e=typeof window<"u";return{document:typeof document<"u"?document:null,location:e?window.location:null,storage:M,global:e?window:{}}}function b(e){try{return JSON.parse(e)}catch(n){if(n instanceof SyntaxError)return null;throw n}}function E(e){if(typeof e!="object"||e===null)return null;let n=i(Reflect.get(e,"country"));if(!n)return null;let t=Reflect.get(e,"locale");return{country:n,language:g(Reflect.get(e,"language"))??void 0,locale:typeof t=="string"&&t?t:void 0}}function L(e=M){let n=e.getItem(C());return n?E(b(n)):null}function h(e,n){if(!e||!n)return null;let t=e.cookie.split(";").map(r=>r.trim()).find(r=>r.startsWith(`${n}=`));return t?decodeURIComponent(t.slice(n.length+1)):null}function s(e,n){if(!e||!n)return null;let t=n.toLowerCase(),r=Object.keys(e).find(o=>o.toLowerCase()===t);return r?e[r]??null:null}function x(e,n){let t=a=>n.document?.querySelector(`meta[name="${a}"]`)?.getAttribute("content"),r=Reflect.get(n.global,"TETHER_COUNTRY"),o=Reflect.get(n.global,"TETHER_LANGUAGE"),l=t("tether-country")||h(n.document,e.cookie||w);return{country:r||l,language:o||t("tether-language")}}function R(e,n){let t=(n.location?.pathname??"/").split("/").find(c=>c!==""),r=s(e.locales,t);if(r)return r;let o=n.document?.documentElement.getAttribute("lang");if(!o)return null;let l=s(e.locales,o)??s(e.locales,o.split("-")[0]);if(l)return{locale:o,...l};if(e.locales&&e.strict)return null;let a=o.split("-")[1];return{language:o,country:a?.length===2?a:null,locale:o}}function N(e,n,t){switch(e){case"saved":return n.remember===!1?null:L(t.storage);case"server":return x(n,t);case"webflow":return R(n,t)}}function v(e){return e?e===!0?k:e:["saved"]}function I(e=u.markets,n=S()){let t=(e===u.markets?e:y(e))??{};if(t.detect===!1)return{};let r={},o={sources:r};for(let l of v(t.detect)){let a=N(l,t,n);if(!a)continue;let c=i(a.country),d=g(a.language),f=typeof a.locale=="string"&&a.locale?a.locale:null;c&&!o.country&&(o.country=c,r.country=l),d&&!o.language&&(o.language=d,r.language=l),f&&!o.locale&&(o.locale=f,r.locale=l)}return o}function T(e){if(u.markets?.remember===!1)return;let n={country:e.country,language:e.language||void 0,locale:e.locale||void 0};p(C(),JSON.stringify(n))}export{L as a,I as b,T as c};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import{a as h,d as A}from"./chunk-MPDWM2NN.js";import{a as M}from"./chunk-C5JYQCWH.js";import{h as E,v as D}from"./chunk-BFTZR4OB.js";import{d as P,e as $,h as v,l as p,m as l,n as m,p as d,x as S}from"./chunk-BA4LQJJQ.js";import{c as k,r as a,w}from"./chunk-E5YO6274.js";var R=new Set(["in-stock","out-of-stock","backorder","low-stock","plenty-in-stock","on-sale","not-on-sale","has-variants","single-variant","subscription-available","subscription-unavailable","subscription-only","one-time-available","subscription-selected","one-time-selected","has-savings","loading","ready","error","not-found","cart-empty","cart-filled","cart-has-subscription","cart-no-subscription","cart-has-discount","cart-error","cart-warning","list-empty","list-filled","search-empty","search-results","logged-in","logged-out","orders-empty","orders-loading","addresses-loading","addresses-empty","addresses-error","subscriptions-loading","subscriptions-empty","subscriptions-error"]),N=new Set(["title","description","description-text","vendor","type","handle","published-at","price","total-price","compare-at-price","unit-price","min-price","max-price","discount-percentage","discount-amount","variant-title","variant-id","sku","barcode","stock","quantity","featured-image","variant-image","images","tags","link","url","one-time-price","subscription-price","subscription-savings","subscription-savings-amount","checkout-charge","plan-name","plan-description","plan-group","option-value","swatch","image"]),x=new Set(`account account-bind account-link account-login account-logout add-label add-to-cart adding-text
|
|
2
|
+
always-enabled bind cart-checkout-charge cart-clear cart-close cart-count cart-discounts cart-drawer cart-label cart-lines
|
|
3
|
+
cart-note cart-open cart-subtotal cart-total cart-warning checkout code collection collection-bind countries country
|
|
4
|
+
country-bind country-label country-select default-plan default-purchase discount discount-code discount-form discount-input
|
|
5
|
+
discount-remove display error group group-add hide-single language limit line line-attribute line-attributes line-id
|
|
6
|
+
line-minus line-plan line-plus line-remove line-show list load-more market-pending one-time-label option option-list
|
|
7
|
+
option-selected option-value order order-bind order-line order-lines order-line-show order-show order-state order-fulfillments
|
|
8
|
+
fulfillment-bind order-return return-quantity return-reason return-note orders profile-form address-form addresses address-bind
|
|
9
|
+
address-show address-edit address-new address-delete address-default subscriptions subscription-bind subscription-lines
|
|
10
|
+
subscription-line subscription-show subscription-action subscription-status subscription-state confirm form-state form-error page-country page-language page-locale page-title plan plan-bind plan-list
|
|
11
|
+
plan-value product products purchase purchase-mode qty qty-minus qty-plus quantity recommendations reverse search
|
|
12
|
+
search-bind search-collections search-input search-limit search-min search-products search-queries search-results
|
|
13
|
+
search-state show soldout-text sort state subscribe-text variant variant-select variant-url max-width max-height crop
|
|
14
|
+
sig label hydrated busy`.split(/\s+/).filter(Boolean)),q=["bind","option-list","option","variant-select","add-to-cart","purchase","plan-list","plan","qty","line-attribute"],_=["option-list","plan-list","cart-lines","list"],b="metafield:",O=/^image:\d+$/,U=2;function B(e,o){let n=Array.from({length:o.length+1},(t,s)=>s);for(let t=1;t<=e.length;t++){let s=[t];for(let r=1;r<=o.length;r++){let i=(n[r-1]??0)+(e[t-1]===o[r-1]?0:1);s.push(Math.min((n[r]??0)+1,(s[r-1]??0)+1,i))}n=s}return n[o.length]??0}function f(e,o,n=""){let t=null,s=1/0;for(let i of o){let c=B(e,i);c<s&&(s=c,t=i)}let r=Math.max(2,Math.floor(e.length/4));return t!==null&&s<=r?` Did you mean "${n}${t}"?`:""}function L(e){let o=e.id?`#${e.id}`:"",n=e.className&&typeof e.className=="string"?e.className.trim().split(/\s+/):[],t=n.length?`.${n.slice(0,U).join(".")}`:"";return`<${e.tagName.toLowerCase()}${o}${t}>`}var C=()=>`${l("collection")},${l("products")},${l("recommendations")}`;function j(e,o){d(e,l("product")).forEach(n=>{if(n.closest(C())&&n.closest(l("list")))return;let{key:t,fromUrl:s,raw:r}=h(n);r?s&&!t&&o("warn",`${p("product")}="${r}" but this URL has no value for it (e.g. ?handle=my-product).`,n):o("error",`${p("product")} has no value. Bind it to the Shopify handle (CMS field), or use "url:handle".`,n)})}function H(e,o){for(let n of q)d(e,l(n)).forEach(t=>{t.closest(l("product"))||n==="line-attribute"&&t.closest(l("group"))||o("warn",`${p(n)} outside any ${p("product")}: it does nothing here.`,t)});d(e,l("group-add")).forEach(n=>{n.closest(l("group"))||o("warn",`${p("group-add")} outside a ${p("group")}.`,n)});for(let n of _)d(e,l(n)).forEach(t=>{!t.firstElementChild&&!S(t)&&o("warn",`${p(n)} without a template child: put one example element inside it.`,t)});d(e,C()).forEach(n=>{d(n,l("list")).length||o("error",`List without a ${p("list")} child: products have nowhere to render.`,n)})}function K(e,o){d(e,l("show")).forEach(n=>{let t=m(n,"show")??"";R.has(t)||o("warn",`Unknown ${p("show")}="${t}".${f(t,R)}`,n)}),d(e,l("bind")).forEach(n=>{let t=m(n,"bind")||"";!t||N.has(t)||O.test(t)||t.startsWith(b)||o("warn",`Unknown ${p("bind")}="${t}": it stays empty.${f(t,N)}`,n)})}function G(e,o){d(e,l("bind")).forEach(n=>{let t=m(n,"bind")||"";if(!t.startsWith(b))return;let s=t.slice(b.length);a.metafields.some(i=>(typeof i=="string"?i:`${i.namespace}.${i.key}`)===s)||o("error",`${p("bind")}="${t}" but "${s}" is not in config.metafields, so it stays empty.`,n)})}function W(e,o){let n=`${a.prefix}-`,t=new Set;d(e,"*").forEach(s=>{for(let{name:r}of s.attributes){if(!r.startsWith(n))continue;let i=r.slice(n.length);x.has(i)||t.has(i)||(t.add(i),o("warn",`Unknown attribute ${r}: Tether ignores it.${f(i,x,n)}`,s))}})}function Y(e,o){let n=d(e,l("cart-drawer")).length;d(e,l("cart-open")).length&&!n&&o("warn",`${p("cart-open")} exists but there is no ${p("cart-drawer")} on this page.`),n>1&&o("warn",`More than one ${p("cart-drawer")}.`),d(e,`[${p("state")}="error"]`).forEach(t=>{t.matches(A())&&o("error",`Scope failed to load (${m(t,"error")||"error"}).`,t)})}function T(e=document){let o=[],n=(t,s,r)=>{o.push(r?{level:t,message:s,element:L(r),el:r}:{level:t,message:s})};return j(e,n),H(e,n),K(e,n),W(e,n),G(e,n),Y(e,n),o}var F=20,z=3,V=4;function J(e){return e?`${e.slice(0,V)}\u2026${e.slice(-V)} (${e.length} chars)`:"(missing)"}function I(e,o){if(e instanceof Error&&e.message)return e.message;let n=typeof e=="object"&&e!==null?Reflect.get(e,"code"):void 0;return typeof n=="string"&&n?n:o}function X(){return{domain:a.domain||"(missing)",token:J(a.token),apiVersion:a.apiVersion,endpoint:a.domain?$():null,country:a.country,language:a.language,locale:a.locale,markets:a.markets,prefix:a.prefix,productPath:a.productPath,metafields:a.metafields,autoMount:a.autoMount,observe:a.observe,onError:typeof a.onError=="function"}}async function Q(){return{country:a.country||null,language:a.language||null,locale:a.locale||null,detected:a.markets?.detect?(await M("markets")).detectMarket(a.markets):null}}function Z({ok:e,monthsLeft:o,note:n}){return e&&(o===void 0||o>=z)?null:{level:e?"warn":"error",message:`apiVersion ${a.apiVersion}: ${n}`}}var ee=P({shop:{name:"string",primaryDomain:{url:"string"},paymentSettings:{currencyCode:"string"}}});async function ne(){if(!w())return{kind:"not-configured"};let e=Date.now();try{let o=await v("query TetherDiagnose { shop { name primaryDomain { url } paymentSettings { currencyCode } } }",{},ee,{context:!1});return{kind:"reachable",shop:{name:o.shop.name,url:o.shop.primaryDomain.url,currency:o.shop.paymentSettings.currencyCode},latencyMs:Date.now()-e}}catch(o){return{kind:"unreachable",error:o,latencyMs:Date.now()-e}}}function te(e,o,n){let t=[],s=n.options.map(i=>i.name),r=d(e,l("product")).filter(i=>h(i).key===o&&i.querySelector(l("add-to-cart")));for(let i of r){let c=new Set(d(i,`${l("option-list")},select${l("option")}`).map(u=>m(u,"option-list")||m(u,"option")));if(!(!c.size&&d(i,`select${l("variant-select")}`).length)){if(!a.language)for(let u of c)!u||s.includes(u)||t.push({level:"warn",message:`Product "${n.handle}" has no option "${u}" (its options: ${s.join(", ")||"none"}).${f(u,s)}`});for(let u of n.options)u.optionValues.length<=1||c.has(u.name)||t.push({level:"warn",message:`Product "${n.handle}": option "${u.name}" (${u.optionValues.length} values) has no tether-option-list, so visitors can't choose it.`})}}return t}async function oe(e,o){let n=d(e,l("product")).map(r=>h(r).key),t=[...new Set(n.filter(r=>r!==null&&r!==""))].slice(0,F);(await Promise.allSettled(t.map(r=>D(r)))).forEach((r,i)=>{let c=t[i]??"";if(r.status==="rejected"){let g=I(r.reason,"not loaded");o.products.push({key:c,error:r.reason instanceof Error?r.reason.message:void 0}),o.problems.push({level:"error",message:`Product "${c}": ${g}. Is it published to the Headless channel?`});return}let u=r.value,y=E(u);o.products.push({key:c,handle:u.handle,title:u.title,plans:y.length,requiresSellingPlan:u.requiresSellingPlan});for(let g of y)o.sellingPlans.push({product:u.handle,group:g.group.name,plan:g.name,id:g.id});o.problems.push(...te(e,c,u))})}async function ye({root:e=document,silent:o=!1,version:n="",now:t=new Date}={}){let s=await ne(),r={version:n,config:X(),apiVersion:k(a.apiVersion,t),market:await Q(),reachable:s.kind==="reachable",shop:s.kind==="reachable"?s.shop:null,latencyMs:s.kind==="not-configured"?null:s.latencyMs,products:[],sellingPlans:[],problems:[]};switch(s.kind){case"not-configured":r.problems.push({level:"error",message:"TETHER_CONFIG needs domain and token."});break;case"unreachable":r.problems.push({level:"error",message:`Storefront API not reachable: ${I(s.error,"unknown error")}`});break;case"reachable":await oe(e,r);break}let i=Z(r.apiVersion);return i&&r.problems.push(i),typeof document<"u"&&r.problems.push(...T(e)),o||re(r),r}function re(e){let o=e.problems.filter(c=>c.level==="error").length,n=e.problems.length-o;console.group(`[${a.prefix}] diagnose: ${o?`${o} error(s)`:"no errors"}, ${n} warning(s)`),console.log("version",e.version,"| API",e.apiVersion.version,`(${e.apiVersion.note})`),console.log("config",e.config);let{country:t,language:s,detected:r}=e.market,i=[t,s].filter(Boolean).join(" / ")||"the store default";console.log("market",`in use: ${i}`,r?`(detection picks ${JSON.stringify(r)})`:""),console.log(e.shop?`Storefront API reachable: ${e.shop.name} (${e.latencyMs??0} ms)`:"Storefront API NOT reachable"),e.products.length&&console.table(e.products),e.sellingPlans.length?console.table(e.sellingPlans):e.reachable&&console.log("No selling plans on the products of this page.");for(let c of e.problems)c.level==="error"?console.error(c.message,c.el??""):console.warn(c.message,c.el??"");console.groupEnd()}export{k as apiVersionStatus,T as checkMarkup,ye as diagnose,f as didYouMean};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as S}from"./chunk-56FCLJJD.js";import"./chunk-T44MUL4Y.js";import"./chunk-MPDWM2NN.js";import{e as g}from"./chunk-A5SYCVQM.js";import"./chunk-BFTZR4OB.js";import{N as w,O as k,m as s,n as d,o as m,p as y,t as h}from"./chunk-BA4LQJJQ.js";import{d as p,r as u,y as f,z as l}from"./chunk-E5YO6274.js";function v(t,e){let r=k(w(t,"line-attributes"));return e?[{key:"_group",value:e},...r]:r}async function q(t){let e=t.closest(s("group"));if(!e)return null;let r=d(e,"group"),o=v(e,r),n=y(e,s("product")).flatMap(i=>{let a=S.get(i);if(!a?.variant?.availableForSale||a.quantity<=0)return[];let c=a.getLine();return c?[{...c,attributes:[...c.attributes??[],...o]}]:[]});if(!n.length)return f("group-add: nothing selected"),null;try{let i=await g.add(n);return h("group-added",{group:r,lines:n},e),i}catch(i){return l(i,"group add"),null}}function E(t){let e;try{e=JSON.parse(t)}catch{return null}if(!p(e))return null;let{country:r,language:o,locale:n}=e;return typeof r!="string"||!r?null:{country:r,language:typeof o=="string"?o:null,locale:typeof n=="string"?n:void 0}}function A(t){if(t.key===u.storageKey||t.key===`${u.storageKey}:seen`){g.init().catch(n=>{l(n,"cart from another tab")});return}if(t.key!==`${u.prefix}:market:${u.domain}`||!t.newValue)return;let e=E(t.newValue),r=Reflect.get(window,"Tether");if(!e||!r)return;let o={language:e.language,locale:e.locale,remember:!1};r.setCountry(e.country,o).catch(n=>{l(n,"market from another tab")})}var b=new WeakMap,C=t=>t.split("/").pop()??t;function M(t){try{window.history.replaceState(window.history.state,"",t)}catch{}}function J(t,{variant:e,sellingPlanId:r}){let o=`${e.id}|${r??""}`,n=b.get(t);if(b.set(t,o),!n||n===o)return;let i=u.variantUrl&&document.querySelector(s("product"))===t;if(!m(t,"variant-url")&&!i)return;let a=new URL(window.location.href);a.searchParams.set("variant",C(e.id)),r?a.searchParams.set("selling_plan",C(r)):a.searchParams.delete("selling_plan"),M(a)}export{q as addGroup,A as onStorage,J as writeVariantUrl};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as F,c as I}from"./chunk-YLUULATY.js";import{a as E,c as P,e as k,f as T,g as A,h as p,i as x}from"./chunk-4GCXM764.js";import"./chunk-56FCLJJD.js";import"./chunk-T44MUL4Y.js";import"./chunk-MPDWM2NN.js";import{e as u}from"./chunk-A5SYCVQM.js";import{w}from"./chunk-BFTZR4OB.js";import{a as L,d as h,h as b,l as s,m as C,n as v,t as z}from"./chunk-BA4LQJJQ.js";import{o as f,p as g,r as a,z as y}from"./chunk-E5YO6274.js";var _="{name} ({currency})",j="name",d=null;function B(){d=null}var D="query TetherLocalization{localization{country{isoCode name currency{isoCode symbol}}language{isoCode name}availableCountries{isoCode name currency{isoCode symbol}availableLanguages{isoCode name}}}}",O={isoCode:"string",name:"string",currency:"object"},H=h({localization:{country:O,availableCountries:[O]}});function R(){return d??(d=b(D,{},H).then(e=>e.localization,e=>{throw d=null,e})),d}function U(e,n){switch(n){case"name":return e.name;case"code":return e.isoCode;case"currency":return e.currency.isoCode;case"symbol":return e.currency.symbol;default:return""}}var Y=(e,n)=>e.replace(/\{(name|code|currency|symbol)\}/g,(o,i)=>U(n,i));function q(e,n,o){let i=e.getAttribute(s("country-label"))||_,r=(e.getAttribute(s("countries"))||"").toUpperCase().split(/[\s,]+/).filter(Boolean),c=r.length?r.map(t=>n.find(l=>l.isoCode===t)).filter(t=>t!==void 0):n;e.replaceChildren(...c.map(t=>new Option(Y(i,t),t.isoCode))),e.value=o,e.value!==o&&(e.selectedIndex=-1),e.disabled=c.length<2&&!e.hasAttribute(s("always-enabled"))}function $(e,n,o){let i=(a.country||o.country.isoCode).toUpperCase(),r=[...o.availableCountries].sort((t,l)=>t.name.localeCompare(l.name,a.locale||void 0)),c=r.find(t=>t.isoCode===i)??o.country;e.forEach(t=>{q(t,r,i)}),n.forEach(t=>{t.textContent=U(c,v(t,"country-bind")||j)})}function S(e=document){let n=p(e,`select${C("country-select")}`),o=p(e,C("country-bind"));return!n.length&&!o.length?Promise.resolve():R().then(i=>{$(n,o,i)}).catch(i=>{y(i,"country select")})}var Q=e=>Object.values(a.markets?.locales??{}).find(n=>f(n.country)===e);function V(e,n){return e!==void 0?g(e):n?n.language?g(n.language):void 0:a.language}function Z(e){w();let n=[];return u.id()&&n.push(u.setBuyerIdentity({countryCode:e},{create:!1}).catch(o=>{y(o,"cart country")})),A(),T.forEach(o=>n.push(o.load())),k.forEach(o=>{o.closest(E())||(P.delete(o),x(o))}),n}async function re(e,{language:n,locale:o,remember:i=!0}={}){let r=f(e);if(!r)throw new L(`Not a country code: ${e}`,{code:"INVALID_COUNTRY"});let c=Q(r),t=o||c?.locale,l=t||a.locale,m=V(n,c),M=r!==a.country||m!==a.language||l!==a.locale;if(a.country=r,a.language=m||void 0,a.locale=l,i&&I({country:r,language:m,locale:t}),!M)return S(),u.state;n!==void 0&&B();let N=Z(r);return S(),z("country-changed",{country:r,language:a.language}),await Promise.all(N),u.state}export{F as detectMarket,R as getLocalization,S as renderCountrySelects,re as setCountry};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as M}from"./chunk-4GCXM764.js";import"./chunk-56FCLJJD.js";import"./chunk-T44MUL4Y.js";import"./chunk-MPDWM2NN.js";import"./chunk-A5SYCVQM.js";import"./chunk-BFTZR4OB.js";import{A as x,C,F as q,H as d,c as S,d as E,h as T,l as A,m as o,n as m,p as h,t as I,w as L,y as w}from"./chunk-BA4LQJJQ.js";import{b as a,r as u,x as b,z as y}from"./chunk-E5YO6274.js";var N=E({predictiveSearch:S({products:[{priceRange:"object"}],collections:["object"],queries:[{text:"string"}]})}),U="query TetherPredictive($q:String!,$limit:Int!){predictiveSearch(query:$q,limit:$limit,limitScope:EACH,types:[PRODUCT,COLLECTION,QUERY]){products{id handle title availableForSale featuredImage{url altText}priceRange{minVariantPrice{amount currencyCode}}}collections{handle title image{url altText}}queries{text}}}",D=6,V=2,F="/search",R=new WeakSet,v=0;function $(s,t,e){return parseInt(m(s,t)||"",10)||e}var H=s=>s.tagName==="A"?s:s.querySelector("a");function p(s,t){h(s,o("search-bind")).forEach(e=>{let i=m(e,"search-bind");i==="image"?L(e,t.image?.url,t.image?.altText||t.title):(i==="title"||i==="price"||i==="text")&&t[i]!=null&&q(e,t[i])})}function k(s,t){let e=H(s);e&&(t&&e.setAttribute("href",t),e.setAttribute("role","option"))}var f=class{constructor(t,e,i){a(this,"root");a(this,"input");a(this,"results");a(this,"limit");a(this,"minCharacters");a(this,"resultsId");a(this,"searchNumber",0);a(this,"timer");a(this,"lastTerm","");a(this,"cache",new Map);this.root=t,this.input=e,this.results=i,this.limit=$(t,"search-limit",D),this.minCharacters=$(t,"search-min",V),i.id||(v+=1,i.id=`${u.prefix}-search-${v}`),this.resultsId=i.id,this.setUpAria(),this.listen()}setUpAria(){this.input.setAttribute("role","combobox"),this.input.setAttribute("aria-autocomplete","list"),this.input.setAttribute("aria-controls",this.resultsId),this.input.setAttribute("aria-expanded","false"),this.input.setAttribute("autocomplete","off"),this.results.hasAttribute("role")||this.results.setAttribute("role","listbox"),this.results.hidden=!0}listen(){this.input.addEventListener("input",()=>{let t=this.input.value.trim();t!==this.lastTerm&&(this.lastTerm=t,clearTimeout(this.timer),this.timer=setTimeout(()=>void this.search(t),u.searchDelay))}),this.input.addEventListener("focus",()=>{this.input.value.trim().length>=this.minCharacters&&this.options().length&&this.open(!0)}),this.input.addEventListener("keydown",t=>{this.onKeydown(t)}),document.addEventListener("click",t=>{this.root.contains(t.target)||this.open(!1)})}setState(t){this.root.setAttribute(A("search-state"),t)}open(t){this.root.classList.toggle("is-open",t),this.results.hidden=!t,this.input.setAttribute("aria-expanded",String(t)),t||this.input.removeAttribute("aria-activedescendant")}options(){return h(this.results,'[role="option"]')}async fetchResults(t){let e=this.cache.get(t);if(e)return e;let i=await T(U,{q:t,limit:this.limit},N);return this.cache.set(t,i.predictiveSearch),i.predictiveSearch}async search(t){this.searchNumber+=1;let e=this.searchNumber;if(t.length<this.minCharacters){this.open(!1),this.setState("idle");return}this.setState("loading");try{let i=await this.fetchResults(t);e===this.searchNumber&&this.render(i,t)}catch(i){if(e!==this.searchNumber){b("a superseded search failed",i);return}this.setState("error"),y(i,"search")}}fillList(t,e,i){h(this.results,o(t)).forEach(l=>{w(l,e,i),d(l,e.length>0)})}queryUrl(t){let e=this.root.getAttribute("action")||F,i=e.includes("?")?"&":"?";return`${e}${i}${this.input.name||"q"}=${encodeURIComponent(t)}`}render(t,e){let i=t?.products??[],l=t?.collections??[],c=(t?.queries??[]).filter(n=>n.text.toLowerCase()!==e.toLowerCase());this.fillList("search-products",i,(n,r)=>{let P=C(r.priceRange.minVariantPrice);p(n,{title:r.title,price:P,image:r.featuredImage}),k(n,x(r.handle,r.id)),n.classList.toggle("is-sold-out",!r.availableForSale)}),this.fillList("search-collections",l,(n,r)=>{p(n,{title:r.title,image:r.image}),k(n,`${(u.collectionPath||"/collection").replace(/\/$/,"")}/${r.handle}`)}),this.fillList("search-queries",c,(n,r)=>{p(n,{text:r.text}),H(n)?.setAttribute("href",this.queryUrl(r.text))});let g=i.length+l.length+c.length;this.showCount(g),this.setState(g?"ready":"empty"),this.open(!0),I("search",{term:e,products:i,collections:l,queries:c},this.root)}showCount(t){h(this.root,o("show")).forEach(e=>{let i=m(e,"show");i==="search-empty"&&d(e,t===0),i==="search-results"&&d(e,t>0)}),this.options().forEach((e,i)=>{e.id||(e.id=`${this.resultsId}-${i}`),e.setAttribute("aria-selected","false")})}highlight(t,e){t.forEach((l,c)=>{l.setAttribute("aria-selected",String(c===e))});let i=t[e];i&&(this.input.setAttribute("aria-activedescendant",i.id),i.scrollIntoView?.({block:"nearest"}))}onKeydown(t){let e=this.options(),i=e.findIndex(l=>l.getAttribute("aria-selected")==="true");t.key==="ArrowDown"&&e.length?(t.preventDefault(),this.open(!0),this.highlight(e,(i+1)%e.length)):t.key==="ArrowUp"&&e.length?(t.preventDefault(),this.highlight(e,i<=0?e.length-1:i-1)):t.key==="Enter"&&i>=0?(t.preventDefault(),e[i]?.click()):t.key==="Escape"&&this.open(!1)}};function j(s=document){for(let t of M(s,o("search"))){if(R.has(t))continue;R.add(t);let e=t.querySelector(o("search-input"))??t.querySelector("input"),i=t.querySelector(o("search-results"));e&&i&&new f(t,e,i)}}export{j as mountSearch};
|
package/dist/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as k}from"./chunks/chunk-27PJJZGC.js";import{a as J,b as X,d as C,f as b,g as Z,h as p,i as tt,j as et,k as nt,l as rt,m as ot}from"./chunks/chunk-V74KGEJF.js";import{a as Y}from"./chunks/chunk-2FSXS55U.js";import"./chunks/chunk-HEQILZVR.js";import{a as W}from"./chunks/chunk-FCSWQDVV.js";import{a as l,b as it}from"./chunks/chunk-VT4CDUJJ.js";import{a as G,b as c}from"./chunks/chunk-MPTQYLSM.js";import{a as B,b as V,c as K,d as z,h as Q,i as j}from"./chunks/chunk-NEHZ37TU.js";import{l as F}from"./chunks/chunk-JOOEXYF3.js";import{G as U,P as m,b as r,e as D,f as L,g as E,h as O,i as a,j as N,k as _,l as v,n as H,p as R,r as d,s as i,x as g,y as q}from"./chunks/chunk-YJLWX2HK.js";import"./chunks/chunk-FOMSMIAM.js";var at={country:void 0,language:void 0,locale:void 0},x=!1;function ut(){let t=n=>document.querySelector(`meta[name="${r.prefix}-page-${n}"]`)?.getAttribute("content")||void 0,e=N(t("country"));return e?{country:e,language:_(t("language"))??void 0,locale:t("locale")}:null}async function Mt(){let t=r.markets??{};if(t.detect===!1)return null;if(!t.detect)return t.remember===!1?null:k();try{return(await l("markets")).detectMarket(t)}catch(e){return a(e,"markets"),null}}async function st(t){at={country:r.country,language:r.language,locale:r.locale};let e=ut();if(x=e!==null,e){r.country=e.country,r.language=e.language,e.locale&&(r.locale=e.locale);return}let n=await Mt();n&&(n.country&&(r.country=n.country),n.language&&(r.language=n.language),n.locale&&!t.locale&&(r.locale=n.locale),E("market",n))}var ct=(t,e)=>(t??"").toUpperCase()===(e??"").toUpperCase();function lt(){let t=ut(),e=t===null&&x;x=t!==null;let n=t??(e?k()??at:null);return!n?.country||ct(n.country,r.country)&&ct(n.language,r.language)?null:{country:n.country,language:n.language,locale:n.locale}}function y(t,e){return l("markets").then(n=>n.setCountry(t,e))}var Pt=["account-login","account-bind","account-link","orders","order","addresses","subscriptions","profile-form","address-form"],$t=()=>[...Pt.map(t=>`[${d(t)}]`),`[${d("show")}^="logged-"]`].join(",");function Dt(){let t=`${r.prefix}:account:${r.domain}`,e=`${r.prefix}:account-hint:${r.domain}`;try{return!!(sessionStorage.getItem(t)||localStorage.getItem(t)||localStorage.getItem(e))}catch{return!1}}function dt(t){!r.account?.clientId&&!r.account?.server||!(p(t,$t()).length>0||/[?&]code=/.test(window.location.search)||Dt())||l("account").then(n=>n.mountAccount(t)).catch(n=>{a(n,"account")})}function s(t){return(...e)=>l("account").then(n=>{let o=n[t];return o(...e)})}var ft={login:s("login"),logout:s("logout"),handleCallback:s("handleCallback"),getToken:s("getToken"),isLoggedIn:s("isLoggedIn"),query:s("query"),customer:s("customer"),orders:s("orders"),order:s("order"),updateProfile:s("updateProfile"),addresses:s("addresses"),saveAddress:s("saveAddress"),deleteAddress:s("deleteAddress"),subscriptions:s("subscriptions"),subscriptionAction:s("subscriptionAction"),requestReturn:s("requestReturn"),render:s("render"),mountAccount:s("mountAccount")};var mt=()=>`data-${r.prefix}-key`,gt=t=>t instanceof window.Element;function yt(t){let e=t.closest(`[${mt()}]`),n=e?.getAttribute(mt());return e&&n?{line:e,id:n}:null}function w(t,e){t.catch(n=>{a(n,e)})}function Ot(t,e){let n=yt(e);if(!n?.line.closest(i("cart-lines")))return;let{line:o,id:u}=n;if(e.closest(i("line-remove"))){t.preventDefault(),o.classList.add("is-busy"),w(c.removeLine(u),"cart line");return}let $=Nt(e);!$||!c.lines.some(It=>It.id===u)||(t.preventDefault(),w(c.changeQuantity(u,$),"cart line"))}function Nt(t){return t.closest(i("line-plus"))?1:t.closest(i("line-minus"))?-1:0}function _t(t){let{target:e}=t;if(!gt(e))return;if(e.closest(i("cart-open"))){t.preventDefault(),c.toggle();return}if(e.closest(i("cart-close"))){t.preventDefault(),c.close();return}let n=e.closest(i("cart-clear"));if(n){t.preventDefault(),m(n,()=>c.clear().catch(u=>{a(u,"cart clear")}));return}let o=e.closest(i("checkout"));if(o){t.preventDefault(),m(o,()=>c.checkout());return}Ot(t,e)}function pt(t,e,n){t.classList.add("is-busy"),t.setAttribute("aria-busy","true"),w(e,n)}function Ht(t){let{target:e}=t;if(!gt(e))return;let n=yt(e);n&&e instanceof window.HTMLInputElement&&e.matches(i("line","quantity"))?pt(n.line,c.updateLine(n.id,parseInt(e.value,10)||0),"cart line"):n&&e instanceof window.HTMLSelectElement&&e.matches(i("line-plan"))?pt(n.line,c.updateLine(n.id,{sellingPlanId:e.value||null}),"cart line plan"):Rt(e)&&e.matches(i("cart-note"))&&w(c.setNote(e.value),"cart note")}var Rt=t=>t instanceof window.HTMLInputElement||t instanceof window.HTMLTextAreaElement||t instanceof window.HTMLSelectElement;function qt(t){if(c.isOpen()){if(t.key==="Escape"){c.close();return}G(t)}}function ht(){document.addEventListener("click",_t),document.addEventListener("change",Ht),document.addEventListener("keydown",qt)}var A=t=>t instanceof window.Element;function Ut(t){let e=t.querySelector(i("discount-input"))??t.querySelector("input");return e instanceof window.HTMLInputElement?e:null}function Et(t,e,n){t.classList.toggle("is-invalid",n),n?e?.setAttribute("aria-invalid","true"):e?.removeAttribute("aria-invalid")}async function Ft(t,e,n){try{await c.applyDiscount(n),Et(t,e,!1),g("discount-applied",{code:n},t),e&&(e.value="")}catch(o){Et(t,e,!0),o instanceof v&&o.code==="INVALID_DISCOUNT"?g("discount-invalid",{code:n},t):a(o,"discount")}}function Gt(t){let{target:e}=t,n=A(e)?e.closest(i("discount-form")):null;if(!n)return;t.preventDefault();let o=Ut(n),u=o?.value.trim();u&&m(n,()=>Ft(n,o,u))}function Bt(t){let{target:e}=t;if(!A(e))return;let n=e.closest(i("discount-form"));n&&(n.classList.remove("is-invalid"),e.removeAttribute("aria-invalid"))}function Vt(t){let{target:e}=t,n=A(e)?e.closest(i("discount-remove")):null;if(!n)return;t.preventDefault();let o=n.closest(i("discount-code"))?.getAttribute(d("discount-code"));o&&c.removeDiscount(o).catch(u=>{a(u,"discount")})}function vt(){document.addEventListener("submit",Gt,!0),document.addEventListener("input",Bt),document.addEventListener("click",Vt)}var T=t=>l("extras").then(e=>e.addGroup(t)),S=t=>{a(t,"extras")};function Kt(t){let{target:e}=t,n=e instanceof window.Element?e.closest(i("group-add")):null;n&&(t.preventDefault(),m(n,()=>T(n)).catch(S))}function zt(t){!r.domain||!t.key?.startsWith(`${r.prefix}:`)||l("extras").then(e=>{e.onStorage(t)}).catch(S)}function Qt(t){let{target:e}=t;e instanceof window.Element&&(!r.variantUrl&&!e.hasAttribute(d("variant-url"))||l("extras").then(n=>{n.writeVariantUrl(e,t.detail)}).catch(S))}function bt(){document.addEventListener("click",Kt),window.addEventListener("storage",zt),document.addEventListener(`${r.prefix}:variant-changed`,Qt)}var I=null;function wt(){I=document.body}async function jt(t){await t.ready();let e=lt();if(!e){I!==document.body&&t.mount(document);return}try{await y(e.country,{language:e.language??null,locale:e.locale,remember:!1})}catch(n){a(n,"country")}t.mount(document)}function Wt(t){document.addEventListener("astro:page-load",()=>{jt(t)}),document.addEventListener("astro:before-swap",()=>{I=null,t.unmount()})}function Yt(t){let{target:e}=t;!(e instanceof window.HTMLSelectElement)||!e.matches(i("country-select"))||e.value&&y(e.value).catch(n=>{a(n,"country")})}function Jt(){et(),b.forEach(t=>{t.root.getAttribute(d("state"))==="error"&&t.load()})}function Lt(t){r.astro&&Wt(t),document.addEventListener("change",Yt),window.addEventListener("online",Jt)}var kt="0.6.8",Xt=["product-ready","list-ready","cart-updated","cart-toggled","checkout","search"],Zt=50,xt=()=>window,f=null,M=null,At=null,Ct=!1;function te(t){let e=0;return p(t,J()).forEach(n=>{if(C.has(n))return;C.add(n),e++;let o=new X(n);b.add(o),n.addEventListener(`${r.prefix}:list-rendered`,u=>{h(u.detail.container)}),nt(o.load())}),e}function ee(t){p(t,`${i("country-select")},${i("country-bind")}`).length&&l("markets").then(e=>e.renderCountrySelects(t)).catch(e=>{a(e,"markets")}),dt(t),p(t,i("search")).length&&l("search").then(e=>{e.mountSearch(t)}).catch(e=>{a(e,"search")})}function h(t=document){if(!L())return 0;t===document&&wt(),Z(),ot(t.ownerDocument??document);let e=te(t);return p(t,i("product")).forEach(n=>{tt(n)&&e++}),ee(t),rt(),c.render(),E(`mounted ${e} scope(s)`,t),e}function Tt(){c.close()}function ne(t){let e=t?.closest(i("product"));return e?Y.get(e)??null:null}function re(){Ct||(Ct=!0,ht(),vt(),bt(),Lt({ready:()=>f??Promise.resolve(null),mount:h,unmount:Tt}))}function oe(){let t=[];At=t,Xt.forEach(e=>{document.addEventListener(`${r.prefix}:${e}`,n=>t.push(n))}),document.addEventListener("astro:page-load",()=>t.push(new CustomEvent(`${r.prefix}:page`))),l("analytics").then(e=>e.startAnalytics(t)).catch(e=>{a(e,"analytics")})}async function ie(t){let e=r.country?.toUpperCase(),n=t?.buyerIdentity.countryCode;if(!t||!e||!n||n===e)return t;try{return await c.setBuyerIdentity({countryCode:e},{create:!1})}catch(o){return a(o,"cart country"),t}}function St(t={}){return f&&!Object.keys(t).length?f:(D({...xt().TETHER_CONFIG,...t}),L()?(re(),r.observe&&ce(),r.analytics&&!At&&oe(),f=st(t).then(()=>c.init()).then(ie).then(e=>(g("ready",{cart:e}),P)),f):(O("TETHER_CONFIG is missing domain or token. Tether is idle."),f=Promise.resolve(null),f))}function ce(){if(M||typeof MutationObserver>"u")return;let t,e=new Set;M=new MutationObserver(n=>{n.forEach(o=>{o.addedNodes.forEach(u=>{u instanceof window.Element&&e.add(u)})}),clearTimeout(t),t=setTimeout(()=>{e.forEach(o=>{o.isConnected&&h(o)}),e.clear()},Zt)}),M.observe(document.body,{childList:!0,subtree:!0})}var ae=t=>l("markets").then(e=>e.detectMarket(t??r.markets)),ue=()=>l("markets").then(t=>t.getLocalization()),se=t=>l("diagnose").then(e=>e.diagnose({...t,version:kt}));function le(t,e){let n=o=>{let u=o;e(u.detail,u)};return document.addEventListener(`${r.prefix}:${t}`,n),()=>{document.removeEventListener(`${r.prefix}:${t}`,n)}}var P={VERSION:kt,init:St,mount:h,unmount:Tt,get config(){return r},get ready(){return f??Promise.resolve(null)},query:R,withContext:H,cart:c,getProduct:K,getProducts:Q,getRecommendations:j,getScope:ne,addGroup:T,account:ft,primeProduct:V,normalizeProductKey:B,clearProductCache:z,formatMoney:U,imageUrl:q,plans:F,TetherError:v,resolveProductKey:W,setCountry:y,detectMarket:ae,getLocalization:ue,diagnose:se,__core:it,__parts:{},on:le},nn=P;function de(){let t=xt();if(t.Tether=P,!t.TETHER_CONFIG||t.TETHER_CONFIG.autoMount===!1||t.TETHER_INTEGRATION)return;let e=()=>{St().then(()=>h(document)).catch(n=>{a(n,"init")})};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e,{once:!0}):e()}typeof window<"u"&&typeof document<"u"&&de();export{kt as VERSION,T as addGroup,P as api,nn as default,ne as getScope,St as init,h as mount,y as setCountry,Tt as unmount};
|
|
1
|
+
import{a as x}from"./chunks/chunk-YLUULATY.js";import{a as at,b as st,d as b,f as w,g as S,h as p,i as ut,j as ct,k as lt,l as L,m as T}from"./chunks/chunk-4GCXM764.js";import{a as it}from"./chunks/chunk-56FCLJJD.js";import"./chunks/chunk-T44MUL4Y.js";import{a as ot}from"./chunks/chunk-MPDWM2NN.js";import{a as dt,b as mt,c as ft}from"./chunks/chunk-6OZJCAGZ.js";import{a as c,b as pt}from"./chunks/chunk-C5JYQCWH.js";import{a as Y,b as rt,e as s}from"./chunks/chunk-A5SYCVQM.js";import{D as et,E as nt,o as W,t as J,u as X,v as Z,w as tt}from"./chunks/chunk-BFTZR4OB.js";import{C as Q,J as P,M as f,a as k,f as B,j,l as d,m as i,r as z,s as y,t as h,u as K}from"./chunks/chunk-BA4LQJJQ.js";import{e as F,o as V,p as U,r as o,s as _,v as G,w as v,x as g,y as q,z as u}from"./chunks/chunk-E5YO6274.js";var yt={country:void 0,language:void 0,locale:void 0},M=!1;function ht(){let t=n=>document.querySelector(`meta[name="${o.prefix}-page-${n}"]`)?.getAttribute("content")||void 0,e=V(t("country"));return e?{country:e,language:U(t("language"))??void 0,locale:t("locale")}:null}async function Vt(){let t=o.markets??{};if(t.detect===!1)return null;if(!t.detect)return t.remember===!1?null:x();try{return(await c("markets")).detectMarket(t)}catch(e){return u(e,"markets"),null}}async function Et(t){yt={country:o.country,language:o.language,locale:o.locale};let e=ht();if(M=e!==null,e){o.country=e.country,o.language=e.language,e.locale&&(o.locale=e.locale);return}let n=await Vt();n&&(n.country&&(o.country=n.country),n.language&&(o.language=n.language),n.locale&&!t.locale&&(o.locale=n.locale),g("market",n))}var gt=(t,e)=>(t??"").toUpperCase()===(e??"").toUpperCase();function vt(){let t=ht(),e=t===null&&M;M=t!==null;let n=t??(e?x()??yt:null);return!n?.country||gt(n.country,o.country)&>(n.language,o.language)?null:{country:n.country,language:n.language,locale:n.locale}}function E(t,e){return c("markets").then(n=>n.setCountry(t,e))}var Ut=["account-login","account-bind","account-link","orders","order","addresses","subscriptions","profile-form","address-form"],_t=()=>[...Ut.map(t=>`[${d(t)}]`),`[${d("show")}^="logged-"]`].join(",");function Gt(){return!!rt(dt())}function kt(t){!o.account||!(p(t,_t()).length>0||ft(new URLSearchParams(window.location.search).get("account"))||Gt())||c("account").then(n=>n.mountAccount(t)).catch(n=>{u(n,"account")})}function l(t){return(...e)=>c("account").then(n=>{let r=n[t];return r(...e)})}var Pt={login:l("login"),logout:l("logout"),isLoggedIn:l("isLoggedIn"),customer:l("customer"),orders:l("orders"),order:l("order"),updateProfile:l("updateProfile"),addresses:l("addresses"),saveAddress:l("saveAddress"),deleteAddress:l("deleteAddress"),subscriptions:l("subscriptions"),subscriptionAction:l("subscriptionAction"),requestReturn:l("requestReturn"),render:l("render"),mountAccount:l("mountAccount")};var wt=()=>`data-${o.prefix}-key`,At=t=>t instanceof window.Element;function bt(t){let e=t.closest(`[${wt()}]`),n=e?.getAttribute(wt());return e&&n?{line:e,id:n}:null}function C(t,e){t.catch(n=>{u(n,e)})}function qt(t,e){let n=bt(e);if(!n?.line.closest(i("cart-lines")))return;let{line:r,id:a}=n;if(e.closest(i("line-remove"))){t.preventDefault(),r.classList.add("is-busy"),C(s.removeLine(a),"cart line");return}let $=Bt(e);!$||!s.lines.some(Ft=>Ft.id===a)||(t.preventDefault(),C(s.changeQuantity(a,$),"cart line"))}function Bt(t){return t.closest(i("line-plus"))?1:t.closest(i("line-minus"))?-1:0}function jt(t){let{target:e}=t;if(!At(e))return;if(e.closest(i("cart-open"))){t.preventDefault(),s.toggle();return}if(e.closest(i("cart-close"))){t.preventDefault(),s.close();return}let n=e.closest(i("cart-clear"));if(n){t.preventDefault(),f(n,()=>s.clear().catch(a=>{u(a,"cart clear")}));return}let r=e.closest(i("checkout"));if(r){t.preventDefault(),f(r,()=>s.checkout());return}qt(t,e)}function Ct(t,e,n){t.classList.add("is-busy"),t.setAttribute("aria-busy","true"),C(e,n)}function zt(t){let{target:e}=t;if(!At(e))return;let n=bt(e);n&&e instanceof window.HTMLInputElement&&e.matches(i("line","quantity"))?Ct(n.line,s.updateLine(n.id,parseInt(e.value,10)||0),"cart line"):n&&e instanceof window.HTMLSelectElement&&e.matches(i("line-plan"))?Ct(n.line,s.updateLine(n.id,{sellingPlanId:e.value||null}),"cart line plan"):Kt(e)&&e.matches(i("cart-note"))&&C(s.setNote(e.value),"cart note")}var Kt=t=>t instanceof window.HTMLInputElement||t instanceof window.HTMLTextAreaElement||t instanceof window.HTMLSelectElement;function Qt(t){if(s.isOpen()){if(t.key==="Escape"){s.close();return}Y(t)}}function St(){document.addEventListener("click",jt),document.addEventListener("change",zt),document.addEventListener("keydown",Qt)}var O=t=>t instanceof window.Element;function Wt(t){let e=t.querySelector(i("discount-input"))??t.querySelector("input");return e instanceof window.HTMLInputElement?e:null}function Lt(t,e,n){t.classList.toggle("is-invalid",n),n?e?.setAttribute("aria-invalid","true"):e?.removeAttribute("aria-invalid")}async function Yt(t,e,n){try{await s.applyDiscount(n),Lt(t,e,!1),h("discount-applied",{code:n},t),e&&(e.value="")}catch(r){Lt(t,e,!0),r instanceof k&&r.code==="INVALID_DISCOUNT"?h("discount-invalid",{code:n},t):u(r,"discount")}}function Jt(t){let{target:e}=t,n=O(e)?e.closest(i("discount-form")):null;if(!n)return;t.preventDefault();let r=Wt(n),a=r?.value.trim();a&&f(n,()=>Yt(n,r,a))}function Xt(t){let{target:e}=t;if(!O(e))return;let n=e.closest(i("discount-form"));n&&(n.classList.remove("is-invalid"),e.removeAttribute("aria-invalid"))}function Zt(t){let{target:e}=t,n=O(e)?e.closest(i("discount-remove")):null;if(!n)return;t.preventDefault();let r=n.closest(i("discount-code"))?.getAttribute(d("discount-code"));r&&s.removeDiscount(r).catch(a=>{u(a,"discount")})}function Tt(){document.addEventListener("submit",Jt,!0),document.addEventListener("input",Xt),document.addEventListener("click",Zt)}var I=t=>c("extras").then(e=>e.addGroup(t)),N=t=>{u(t,"extras")};function te(t){let{target:e}=t,n=e instanceof window.Element?e.closest(i("group-add")):null;n&&(t.preventDefault(),f(n,()=>I(n)).catch(N))}function ee(t){!o.domain||!t.key?.startsWith(`${o.prefix}:`)||c("extras").then(e=>{e.onStorage(t)}).catch(N)}function ne(t){if(!y(t,"variant-changed"))return;let{target:e}=t;e instanceof window.Element&&(!o.variantUrl&&!e.hasAttribute(d("variant-url"))||c("extras").then(n=>{n.writeVariantUrl(e,t.detail)}).catch(N))}function xt(){document.addEventListener("click",te),window.addEventListener("storage",ee),document.addEventListener(`${o.prefix}:variant-changed`,ne)}var D=null;function Mt(){D=document.body}async function re(t){await t.ready();let e=vt();if(!e){D!==document.body&&t.mount(document);return}try{await E(e.country,{language:e.language??null,locale:e.locale,remember:!1})}catch(n){u(n,"country")}t.mount(document)}function oe(t){document.addEventListener("astro:page-load",()=>{re(t).catch(e=>{u(e,"page mount")})}),document.addEventListener("astro:before-swap",()=>{D=null,t.unmount()})}function ie(t){let{target:e}=t;!(e instanceof window.HTMLSelectElement)||!e.matches(i("country-select"))||e.value&&E(e.value).catch(n=>{u(n,"country")})}function ae(){ct(),w.forEach(t=>{t.root.getAttribute(d("state"))==="error"&&t.load()})}function Ot(t){o.astro&&oe(t),document.addEventListener("change",ie),window.addEventListener("online",ae)}var Nt="0.7.0",se=50;function ue(){let t=P("TETHER_CONFIG");return typeof t=="object"&&t!==null?Object.fromEntries(Object.entries(t)):{}}var m=null,R=null,Dt=null,It=!1;function ce(t){let e=0;return p(t,at()).forEach(n=>{if(b.has(n))return;b.add(n),e++;let r=new st(n);w.add(r),n.addEventListener(`${o.prefix}:list-rendered`,a=>{y(a,"list-rendered")&&A(a.detail.container)}),lt(r.load())}),e}function le(t){p(t,`${i("country-select")},${i("country-bind")}`).length&&c("markets").then(e=>e.renderCountrySelects(t)).catch(e=>{u(e,"markets")}),kt(t),p(t,i("search")).length&&c("search").then(e=>{e.mountSearch(t)}).catch(e=>{u(e,"search")})}function Rt(t){let e=ce(t);return p(t,i("product")).forEach(n=>{ut(n)&&e++}),le(t),e}function A(t=document){if(!v())return 0;t===document&&Mt(),S(),T(t.ownerDocument??document);let e=Rt(t);return L(),s.render(),g(`mounted ${e} scope(s)`,t),e}function de(t){let e=t.filter(r=>r.isConnected&&!t.some(a=>a!==r&&a.contains(r)));if(!e.length||!v())return;S(),e.forEach(r=>{T(r)});let n=e.reduce((r,a)=>r+Rt(a),0);L(),s.render(),g(`mounted ${n} scope(s) in ${e.length} added element(s)`)}function Ht(){s.close()}function me(t){let e=t?.closest(i("product"));return e?it.get(e)??null:null}function fe(){It||(It=!0,St(),Tt(),xt(),Ot({ready:()=>m??Promise.resolve(null),mount:A,unmount:Ht}))}function pe(){let t=[];Dt=t,z.forEach(e=>{document.addEventListener(`${o.prefix}:${e}`,n=>t.push(n))}),document.addEventListener("astro:page-load",e=>t.push(e)),c("analytics").then(e=>e.startAnalytics(t)).catch(e=>{u(e,"analytics")})}async function ge(t){let e=o.country,n=t?.buyerIdentity.countryCode;if(!t||!e||!n||n===e)return t;try{return await s.setBuyerIdentity({countryCode:e},{create:!1})}catch(r){return u(r,"cart country"),t}}function $t(t={}){return m&&!Object.keys(t).length?m:(G({...ue(),...t}),v()?(mt(),fe(),o.observe&&ye(),o.analytics&&!Dt&&pe(),m=Et(t).then(()=>s.init()).then(ge).then(e=>(h("ready",{cart:e}),H)),m):(q("TETHER_CONFIG is missing domain or token. Tether is idle."),m=Promise.resolve(null),m))}function ye(){if(R||typeof MutationObserver>"u")return;let t,e=new Set;R=new MutationObserver(n=>{n.forEach(r=>{r.addedNodes.forEach(a=>{a instanceof window.Element&&e.add(a)})}),clearTimeout(t),t=setTimeout(()=>{let r=[...e];e.clear(),de(r)},se)}),R.observe(document.body,{childList:!0,subtree:!0})}var he=t=>c("markets").then(e=>e.detectMarket(t??o.markets)),Ee=()=>c("markets").then(t=>t.getLocalization()),ve=t=>c("diagnose").then(e=>e.diagnose({...t,version:Nt}));function ke(t,e){let n=`${o.prefix}:${t}`,r=a=>{y(a,t)&&e(a.detail,a)};return document.addEventListener(n,r),()=>{document.removeEventListener(n,r)}}var Pe={VERSION:Nt,init:$t,mount:A,unmount:Ht,get config(){return _},get ready(){return m??Promise.resolve(null)},query:j,withContext:B,cart:s,getProduct:Z,getProducts:et,getRecommendations:nt,getScope:me,addGroup:I,account:Pt,primeProduct:X,normalizeProductKey:J,clearProductCache:tt,formatMoney:Q,imageUrl:K,plans:W,TetherError:k,resolveProductKey:ot,setCountry:E,detectMarket:he,getLocalization:Ee,diagnose:ve,on:ke},we={__core:pt,__parts:{}},H=Object.assign(Pe,we),vn=H;function Ce(){Reflect.set(window,"Tether",H);let t=P("TETHER_CONFIG");if(!t||F(t,"autoMount")===!1||P("TETHER_INTEGRATION"))return;let e=()=>{$t().then(()=>A(document)).catch(n=>{u(n,"init")})};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e,{once:!0}):e()}typeof window<"u"&&typeof document<"u"&&Ce();export{Nt as VERSION,I as addGroup,H as api,vn as default,me as getScope,$t as init,A as mount,E as setCountry,Ht as unmount};
|