@occluze/tether 0.6.8 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (215) hide show
  1. package/README.md +28 -28
  2. package/dist/esm/astro.js +2 -2
  3. package/dist/esm/chunks/account-CXMA5RPZ.js +1 -0
  4. package/dist/esm/chunks/account-pages-IZO7FEOZ.js +1 -0
  5. package/dist/esm/chunks/analytics-PG5FPRDN.js +1 -0
  6. package/dist/esm/chunks/chunk-4HD4J5JC.js +1 -0
  7. package/dist/esm/chunks/chunk-6TFMLT4A.js +4 -0
  8. package/dist/esm/chunks/chunk-BBVUVPMO.js +1 -0
  9. package/dist/esm/chunks/chunk-E5YO6274.js +1 -0
  10. package/dist/esm/chunks/chunk-EW5SYO6L.js +1 -0
  11. package/dist/esm/chunks/chunk-HJY2JSNB.js +1 -0
  12. package/dist/esm/chunks/chunk-MQYB6BH4.js +1 -0
  13. package/dist/esm/chunks/chunk-N3V45JPS.js +1 -0
  14. package/dist/esm/chunks/chunk-RPMBCAGS.js +1 -0
  15. package/dist/esm/chunks/chunk-VFNHIGCS.js +1 -0
  16. package/dist/esm/chunks/chunk-WT7RGGJU.js +1 -0
  17. package/dist/esm/chunks/chunk-YN6LEBEN.js +1 -0
  18. package/dist/esm/chunks/chunk-Z6HS3H7K.js +1 -0
  19. package/dist/esm/chunks/diagnose-XCEBQKBO.js +14 -0
  20. package/dist/esm/chunks/extras-4HU3VSBQ.js +1 -0
  21. package/dist/esm/chunks/markets-ui-M4IQ62CT.js +1 -0
  22. package/dist/esm/chunks/search-A5DS2IOS.js +1 -0
  23. package/dist/esm/index.js +1 -1
  24. package/dist/esm/server.js +2 -2
  25. package/dist/presets/barba.esm.js +19 -23
  26. package/dist/tether.account-pages.js +332 -367
  27. package/dist/tether.account-pages.min.js +1 -1
  28. package/dist/tether.account.js +253 -492
  29. package/dist/tether.account.min.js +1 -1
  30. package/dist/tether.analytics.js +82 -89
  31. package/dist/tether.analytics.min.js +1 -1
  32. package/dist/tether.diagnose.js +52 -34
  33. package/dist/tether.diagnose.min.js +2 -2
  34. package/dist/tether.extras.js +42 -37
  35. package/dist/tether.extras.min.js +1 -1
  36. package/dist/tether.js +1361 -935
  37. package/dist/tether.markets.js +89 -91
  38. package/dist/tether.markets.min.js +1 -1
  39. package/dist/tether.min.js +0 -0
  40. package/dist/tether.min.js.map +4 -4
  41. package/dist/tether.search.js +60 -69
  42. package/dist/tether.search.min.js +1 -1
  43. package/dist/types/server/src/shared/account-orders.d.ts +44 -0
  44. package/dist/types/server/src/shared/account-routes.d.ts +153 -0
  45. package/dist/types/server/src/shared/api-versions.d.ts +13 -0
  46. package/dist/types/server/src/shared/cart-id.d.ts +2 -0
  47. package/dist/types/server/src/shared/error-message.d.ts +2 -0
  48. package/dist/types/server/src/shared/json.d.ts +25 -0
  49. package/dist/types/server/src/shared/market-codes.d.ts +16 -0
  50. package/dist/types/src/account/addresses-view.d.ts +5 -0
  51. package/dist/types/src/account/answers.d.ts +40 -0
  52. package/dist/types/src/account/markup.d.ts +19 -0
  53. package/dist/types/src/account/operations.d.ts +41 -0
  54. package/dist/types/src/account/order-lines.d.ts +13 -0
  55. package/dist/types/src/account/order-list.d.ts +12 -0
  56. package/dist/types/src/account/order-page.d.ts +6 -0
  57. package/dist/types/src/account/page-answers.d.ts +182 -0
  58. package/dist/types/src/account/page-events.d.ts +2 -0
  59. package/dist/types/src/account/server-client.d.ts +60 -0
  60. package/dist/types/src/account/subscriptions-view.d.ts +2 -0
  61. package/dist/types/src/account-api.d.ts +18 -0
  62. package/dist/types/src/account-marks.d.ts +15 -0
  63. package/dist/types/src/account-pages.d.ts +8 -0
  64. package/dist/types/src/account.d.ts +64 -0
  65. package/dist/types/src/amounts.d.ts +12 -0
  66. package/dist/types/src/analytics-shopify.d.ts +41 -0
  67. package/dist/types/src/analytics.d.ts +2 -0
  68. package/dist/types/src/api-version.d.ts +28 -0
  69. package/dist/types/src/astro.d.ts +42 -0
  70. package/dist/types/src/cart/cart-shape.d.ts +43 -0
  71. package/dist/types/src/cart/checkout.d.ts +16 -0
  72. package/dist/types/src/cart/drawer.d.ts +18 -0
  73. package/dist/types/src/cart/mutations.d.ts +85 -0
  74. package/dist/types/src/cart/render.d.ts +17 -0
  75. package/dist/types/src/cart/store.d.ts +185 -0
  76. package/dist/types/src/cart.d.ts +106 -0
  77. package/dist/types/src/client.d.ts +134 -0
  78. package/dist/types/src/collection.d.ts +25 -0
  79. package/dist/types/src/config-sections.d.ts +40 -0
  80. package/dist/types/src/config.d.ts +190 -0
  81. package/dist/types/src/controls/cart-controls.d.ts +2 -0
  82. package/dist/types/src/controls/discount.d.ts +2 -0
  83. package/dist/types/src/controls/extras.d.ts +5 -0
  84. package/dist/types/src/controls/navigation.d.ts +12 -0
  85. package/dist/types/src/diagnose-markup.d.ts +19 -0
  86. package/dist/types/src/diagnose.d.ts +60 -0
  87. package/dist/types/src/dom.d.ts +75 -0
  88. package/dist/types/src/extras.d.ts +21 -0
  89. package/dist/types/src/fragments.d.ts +158 -0
  90. package/dist/types/src/globals.d.ts +15 -0
  91. package/dist/types/src/images.d.ts +20 -0
  92. package/dist/types/src/index.d.ts +167 -0
  93. package/dist/types/src/initial.d.ts +56 -0
  94. package/dist/types/src/lazy.d.ts +28 -0
  95. package/dist/types/src/loader.d.ts +84 -0
  96. package/dist/types/src/market-codes.d.ts +6 -0
  97. package/dist/types/src/markets-ui.d.ts +32 -0
  98. package/dist/types/src/markets.d.ts +72 -0
  99. package/dist/types/src/markup.d.ts +131 -0
  100. package/dist/types/src/mounting.d.ts +46 -0
  101. package/dist/types/src/page-market.d.ts +27 -0
  102. package/dist/types/src/presets/barba.d.ts +56 -0
  103. package/dist/types/src/product-events.d.ts +2 -0
  104. package/dist/types/src/product-render.d.ts +17 -0
  105. package/dist/types/src/product-shape.d.ts +90 -0
  106. package/dist/types/src/product-state.d.ts +110 -0
  107. package/dist/types/src/product.d.ts +66 -0
  108. package/dist/types/src/repeaters.d.ts +16 -0
  109. package/dist/types/src/search.d.ts +33 -0
  110. package/dist/types/src/selling-plans.d.ts +64 -0
  111. package/dist/types/src/server.d.ts +88 -0
  112. package/dist/types/src/shopify-values.d.ts +46 -0
  113. package/dist/types/src/status.d.ts +33 -0
  114. package/dist/types/src/storage.d.ts +12 -0
  115. package/dist/types/src/store-html.d.ts +39 -0
  116. package/dist/types/src/storefront/catalog.d.ts +38 -0
  117. package/dist/types/src/storefront/json-ld.d.ts +20 -0
  118. package/dist/types/src/variant-render.d.ts +14 -0
  119. package/package.json +24 -24
  120. package/dist/esm/chunks/account-C3NP6HFB.js +0 -1
  121. package/dist/esm/chunks/account-pages-WLK374FO.js +0 -1
  122. package/dist/esm/chunks/analytics-G3SAWMNL.js +0 -1
  123. package/dist/esm/chunks/chunk-27PJJZGC.js +0 -1
  124. package/dist/esm/chunks/chunk-2FSXS55U.js +0 -1
  125. package/dist/esm/chunks/chunk-FCSWQDVV.js +0 -1
  126. package/dist/esm/chunks/chunk-FOMSMIAM.js +0 -1
  127. package/dist/esm/chunks/chunk-GZJTCLLW.js +0 -1
  128. package/dist/esm/chunks/chunk-HEQILZVR.js +0 -1
  129. package/dist/esm/chunks/chunk-JOOEXYF3.js +0 -4
  130. package/dist/esm/chunks/chunk-MPTQYLSM.js +0 -1
  131. package/dist/esm/chunks/chunk-NEHZ37TU.js +0 -3
  132. package/dist/esm/chunks/chunk-V74KGEJF.js +0 -1
  133. package/dist/esm/chunks/chunk-VT4CDUJJ.js +0 -1
  134. package/dist/esm/chunks/chunk-YJLWX2HK.js +0 -1
  135. package/dist/esm/chunks/diagnose-6VVGZNTY.js +0 -14
  136. package/dist/esm/chunks/extras-GJVRDFM3.js +0 -1
  137. package/dist/esm/chunks/markets-ui-UNB4PTA7.js +0 -1
  138. package/dist/esm/chunks/search-OU75RNQL.js +0 -1
  139. package/src/account/addresses-view.js +0 -92
  140. package/src/account/browser-session.js +0 -359
  141. package/src/account/markup.js +0 -48
  142. package/src/account/operations.js +0 -180
  143. package/src/account/order-lines.js +0 -96
  144. package/src/account/order-list.js +0 -91
  145. package/src/account/order-page.js +0 -192
  146. package/src/account/page-events.js +0 -288
  147. package/src/account/server-client.js +0 -172
  148. package/src/account/shared.js +0 -111
  149. package/src/account/shopify-auth.js +0 -150
  150. package/src/account/subscriptions-view.js +0 -158
  151. package/src/account-api.js +0 -118
  152. package/src/account-links.js +0 -35
  153. package/src/account-pages.js +0 -89
  154. package/src/account.js +0 -342
  155. package/src/amounts.js +0 -36
  156. package/src/analytics-shopify.js +0 -241
  157. package/src/analytics.js +0 -352
  158. package/src/api-version.js +0 -85
  159. package/src/astro.js +0 -266
  160. package/src/cart/checkout.js +0 -97
  161. package/src/cart/drawer.js +0 -138
  162. package/src/cart/mutations.js +0 -234
  163. package/src/cart/render.js +0 -294
  164. package/src/cart/store.js +0 -326
  165. package/src/cart.js +0 -391
  166. package/src/client.js +0 -267
  167. package/src/collection.js +0 -183
  168. package/src/config.js +0 -349
  169. package/src/controls/cart-controls.js +0 -155
  170. package/src/controls/discount.js +0 -96
  171. package/src/controls/extras.js +0 -63
  172. package/src/controls/navigation.js +0 -83
  173. package/src/diagnose-markup.js +0 -333
  174. package/src/diagnose.js +0 -295
  175. package/src/dom.js +0 -287
  176. package/src/extras.js +0 -145
  177. package/src/fragments.js +0 -237
  178. package/src/images.js +0 -104
  179. package/src/index.js +0 -353
  180. package/src/initial.js +0 -87
  181. package/src/lazy-iife.js +0 -116
  182. package/src/lazy.js +0 -39
  183. package/src/loader.js +0 -337
  184. package/src/market-codes.js +0 -35
  185. package/src/markets-ui.js +0 -204
  186. package/src/markets.js +0 -334
  187. package/src/markup.js +0 -64
  188. package/src/mounting.js +0 -277
  189. package/src/page-market.js +0 -116
  190. package/src/parts/account-pages.js +0 -6
  191. package/src/parts/account.js +0 -6
  192. package/src/parts/analytics.js +0 -6
  193. package/src/parts/diagnose.js +0 -6
  194. package/src/parts/extras.js +0 -6
  195. package/src/parts/markets.js +0 -6
  196. package/src/parts/search.js +0 -6
  197. package/src/presets/barba.js +0 -190
  198. package/src/product-events.js +0 -130
  199. package/src/product-render.js +0 -257
  200. package/src/product-state.js +0 -318
  201. package/src/product.js +0 -344
  202. package/src/repeaters.js +0 -173
  203. package/src/search.js +0 -323
  204. package/src/selling-plans.js +0 -154
  205. package/src/server.js +0 -215
  206. package/src/shopify-values.js +0 -89
  207. package/src/status.js +0 -126
  208. package/src/store-html.js +0 -0
  209. package/src/storefront/catalog.js +0 -199
  210. package/src/storefront/json-ld.js +0 -167
  211. package/src/variant-render.js +0 -165
  212. package/types/astro.d.ts +0 -28
  213. package/types/barba.d.ts +0 -16
  214. package/types/index.d.ts +0 -577
  215. package/types/server.d.ts +0 -182
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  (() => {
3
2
  var __defProp = Object.defineProperty;
4
3
  var __export = (target, all) => {
@@ -6,7 +5,7 @@
6
5
  __defProp(target, name, { get: all[name], enumerable: true });
7
6
  };
8
7
 
9
- // src/markets-ui.js
8
+ // src/markets-ui.ts
10
9
  var markets_ui_exports = {};
11
10
  __export(markets_ui_exports, {
12
11
  detectMarket: () => detectMarket,
@@ -15,65 +14,69 @@
15
14
  setCountry: () => setCountry
16
15
  });
17
16
 
18
- // tether-core:config.js
19
- var m = window.Tether.__core["config.js"];
20
- var { DEFAULTS, cfg, configure, isConfigured, log, reportError, resolveConfig, toMetafieldIdentifier, warn } = m;
17
+ // tether-core:config.ts
18
+ var m = window.Tether.__core["config.ts"];
19
+ var [cfg, isConfigured, log, MARKET_SOURCES, parseMarkets, reportError, warn] = m;
21
20
 
22
- // tether-core:client.js
23
- var m2 = window.Tether.__core["client.js"];
24
- var { TetherError, endpoint, gql, request, unwrap, withContext } = m2;
21
+ // tether-core:client.ts
22
+ var m2 = window.Tether.__core["client.ts"];
23
+ var [endpoint, gql, orNull, shaped, TetherError] = m2;
25
24
 
26
- // tether-core:cart.js
27
- var m3 = window.Tether.__core["cart.js"];
28
- var { Cart, trapFocus } = m3;
25
+ // tether-core:cart.ts
26
+ var m3 = window.Tether.__core["cart.ts"];
27
+ var [Cart] = m3;
29
28
 
30
- // tether-core:collection.js
31
- var m4 = window.Tether.__core["collection.js"];
32
- var { ListScope, listSelector } = m4;
29
+ // tether-core:collection.ts
30
+ var m4 = window.Tether.__core["collection.ts"];
31
+ var [listSelector] = m4;
33
32
 
34
- // tether-core:loader.js
35
- var m5 = window.Tether.__core["loader.js"];
36
- var { clearProductCache, getProduct, getProducts, getRecommendations, hydrateProducts, normalizeProductKey, primeProduct, refreshProducts, takeStale } = m5;
33
+ // tether-core:loader.ts
34
+ var m5 = window.Tether.__core["loader.ts"];
35
+ var [clearProductCache, getProduct] = m5;
37
36
 
38
- // tether-core:dom.js
39
- var m6 = window.Tether.__core["dom.js"];
40
- var { attr, busy, cdnUrl, emit, formatDate, formatMoney, formatPercent, get, has, hasTemplate, imageUrl, notifyLayoutChanged, parseJSONAttr, productUrl, qsa, repeat, repeatKeyed, sameImage, scoped, sel, setImage, setSelected, setStoreHtml, setText, setTextTracked, show, toAttributes, watchImages } = m6;
37
+ // tether-core:dom.ts
38
+ var m6 = window.Tether.__core["dom.ts"];
39
+ var [ANALYTICS_EVENTS, attr, attributesFromJson, emit, formatDate, formatMoney, get, has, hasTemplate, isOwnEvent, parseJSONAttr, productUrl, qsa, repeat, sel, setImage, setText, show] = m6;
41
40
 
42
- // tether-core:mounting.js
43
- var m7 = window.Tether.__core["mounting.js"];
44
- var { hydrateFromPage, liveLists, liveProducts, mountProduct, mountedLists, mountedProducts, pruneLive, retryFailed, settleMarket, trackMarket, within } = m7;
41
+ // tether-core:mounting.ts
42
+ var m7 = window.Tether.__core["mounting.ts"];
43
+ var [liveLists, liveProducts, mountedProducts, mountProduct, pruneLive, within] = m7;
45
44
 
46
- // tether-core:market-codes.js
47
- var m8 = window.Tether.__core["market-codes.js"];
48
- var { toCountry, toLanguage } = m8;
45
+ // tether-core:market-codes.ts
46
+ var m8 = window.Tether.__core["market-codes.ts"];
47
+ var [toCountry, toLanguage] = m8;
49
48
 
50
- // src/markets.js
51
- var ALL_SOURCES = ["saved", "server", "webflow"];
52
- var DEFAULT_COOKIE = "tether_country";
53
- var storageKey = () => `${cfg.prefix}:market:${cfg.domain}`;
54
- function localStorageIfAllowed() {
55
- if (typeof window === "undefined") return null;
49
+ // src/storage.ts
50
+ function getStored(key, area = "localStorage") {
56
51
  try {
57
- return window.localStorage;
52
+ return window[area].getItem(key);
58
53
  } catch {
59
54
  return null;
60
55
  }
61
56
  }
57
+ function setStored(key, value, area = "localStorage") {
58
+ try {
59
+ window[area].setItem(key, value);
60
+ } catch {
61
+ }
62
+ }
63
+
64
+ // src/markets.ts
65
+ var DEFAULT_COOKIE = "tether_country";
66
+ var storageKey = () => `${cfg.prefix}:market:${cfg.domain}`;
67
+ var pageStorage = { getItem: (key) => getStored(key) };
62
68
  function pageEnv() {
63
69
  const hasWindow = typeof window !== "undefined";
64
70
  return {
65
71
  document: typeof document !== "undefined" ? document : null,
66
72
  location: hasWindow ? window.location : null,
67
- storage: localStorageIfAllowed(),
73
+ storage: pageStorage,
68
74
  global: hasWindow ? window : {}
69
75
  };
70
76
  }
71
77
  function parseJsonOrNull(text) {
72
78
  try {
73
- return (
74
- /** @type {unknown} */
75
- JSON.parse(text)
76
- );
79
+ return JSON.parse(text);
77
80
  } catch (error) {
78
81
  if (error instanceof SyntaxError) return null;
79
82
  throw error;
@@ -83,18 +86,15 @@
83
86
  if (typeof value !== "object" || value === null) return null;
84
87
  const country = toCountry(Reflect.get(value, "country"));
85
88
  if (!country) return null;
86
- const locale = (
87
- /** @type {unknown} */
88
- Reflect.get(value, "locale")
89
- );
89
+ const locale = Reflect.get(value, "locale");
90
90
  return {
91
91
  country,
92
92
  language: toLanguage(Reflect.get(value, "language")) ?? void 0,
93
93
  locale: typeof locale === "string" && locale ? locale : void 0
94
94
  };
95
95
  }
96
- function readSavedMarket(storage = localStorageIfAllowed()) {
97
- const text = storage?.getItem(storageKey());
96
+ function readSavedMarket(storage = pageStorage) {
97
+ const text = storage.getItem(storageKey());
98
98
  return text ? toMarket(parseJsonOrNull(text)) : null;
99
99
  }
100
100
  function readCookie(doc, name) {
@@ -110,9 +110,12 @@
110
110
  }
111
111
  function readServerHint(markets, env) {
112
112
  const meta = (name) => env.document?.querySelector(`meta[name="${name}"]`)?.getAttribute("content");
113
+ const globalCountry = Reflect.get(env.global, "TETHER_COUNTRY");
114
+ const globalLanguage = Reflect.get(env.global, "TETHER_LANGUAGE");
115
+ const pageCountry = meta("tether-country") || readCookie(env.document, markets.cookie || DEFAULT_COOKIE);
113
116
  return {
114
- country: Reflect.get(env.global, "TETHER_COUNTRY") || meta("tether-country") || readCookie(env.document, markets.cookie || DEFAULT_COOKIE),
115
- language: Reflect.get(env.global, "TETHER_LANGUAGE") || meta("tether-language")
117
+ country: globalCountry || pageCountry,
118
+ language: globalLanguage || meta("tether-language")
116
119
  };
117
120
  }
118
121
  function readWebflowLocale(markets, env) {
@@ -137,17 +140,12 @@
137
140
  return readWebflowLocale(markets, env);
138
141
  }
139
142
  }
140
- var isMarketSource = (name) => ALL_SOURCES.some((source) => source === name);
141
143
  function sourcesFor(detect) {
142
144
  if (!detect) return ["saved"];
143
- if (detect === true) return ALL_SOURCES;
144
- return (
145
- /** @type {unknown[]} */
146
- [detect].flat().filter(isMarketSource)
147
- );
145
+ return detect === true ? MARKET_SOURCES : detect;
148
146
  }
149
147
  function detectMarket(markets = cfg.markets, env = pageEnv()) {
150
- const config = markets ?? {};
148
+ const config = (markets === cfg.markets ? markets : parseMarkets(markets)) ?? {};
151
149
  if (config.detect === false) return {};
152
150
  const sources = {};
153
151
  const found = { sources };
@@ -172,40 +170,34 @@
172
170
  }
173
171
  return found;
174
172
  }
175
- function storeIfAllowed(key, value) {
176
- try {
177
- localStorage.setItem(key, value);
178
- } catch {
179
- return;
180
- }
181
- }
182
173
  function rememberMarket(market) {
183
174
  if (cfg.markets?.remember === false) return;
184
175
  const saved = { country: market.country, language: market.language || void 0, locale: market.locale || void 0 };
185
- storeIfAllowed(storageKey(), JSON.stringify(saved));
176
+ setStored(storageKey(), JSON.stringify(saved));
186
177
  }
178
+
179
+ // src/markets-ui.ts
180
+ var DEFAULT_LABEL = "{name} ({currency})";
181
+ var DEFAULT_BIND = "name";
187
182
  var localizationPromise = null;
188
183
  function clearLocalization() {
189
184
  localizationPromise = null;
190
185
  }
191
186
  var LOCALIZATION_QUERY = `query TetherLocalization{localization{country{isoCode name currency{isoCode symbol}}language{isoCode name}availableCountries{isoCode name currency{isoCode symbol}availableLanguages{isoCode name}}}}`;
187
+ var COUNTRY = { isoCode: "string", name: "string", currency: "object" };
188
+ var isLocalizationAnswer = shaped({
189
+ localization: { country: COUNTRY, availableCountries: [COUNTRY] }
190
+ });
192
191
  function getLocalization() {
193
- if (!localizationPromise) {
194
- const loading = gql(LOCALIZATION_QUERY);
195
- localizationPromise = loading.then(
196
- (data) => data.localization,
197
- (error) => {
198
- localizationPromise = null;
199
- throw error;
200
- }
201
- );
202
- }
192
+ localizationPromise ?? (localizationPromise = gql(LOCALIZATION_QUERY, {}, isLocalizationAnswer).then(
193
+ (data) => data.localization,
194
+ (error) => {
195
+ localizationPromise = null;
196
+ throw error;
197
+ }
198
+ ));
203
199
  return localizationPromise;
204
200
  }
205
-
206
- // src/markets-ui.js
207
- var DEFAULT_LABEL = "{name} ({currency})";
208
- var DEFAULT_BIND = "name";
209
201
  function countryField(country, field) {
210
202
  switch (field) {
211
203
  case "name":
@@ -220,10 +212,7 @@
220
212
  return "";
221
213
  }
222
214
  }
223
- var fillLabel = (template, country) => template.replace(
224
- /\{(name|code|currency|symbol)\}/g,
225
- (_match, field) => countryField(country, field)
226
- );
215
+ var fillLabel = (template, country) => template.replace(/\{(name|code|currency|symbol)\}/g, (_match, field) => countryField(country, field));
227
216
  function fillCountrySelect(select, countries, current) {
228
217
  const template = select.getAttribute(attr("country-label")) || DEFAULT_LABEL;
229
218
  const only = (select.getAttribute(attr("countries")) || "").toUpperCase().split(/[\s,]+/).filter(Boolean);
@@ -247,10 +236,7 @@
247
236
  });
248
237
  }
249
238
  function renderCountrySelects(root = document) {
250
- const selects = (
251
- /** @type {HTMLSelectElement[]} */
252
- within(root, `select${sel("country-select")}`)
253
- );
239
+ const selects = within(root, `select${sel("country-select")}`);
254
240
  const binds = within(root, sel("country-bind"));
255
241
  if (!selects.length && !binds.length) return Promise.resolve();
256
242
  return getLocalization().then((localization) => {
@@ -291,7 +277,7 @@
291
277
  const ownLocale = locale || entry?.locale;
292
278
  const nextLocale = ownLocale || cfg.locale;
293
279
  const nextLanguage = languageFor(language, entry);
294
- const changed = country !== cfg.country?.toUpperCase() || nextLanguage !== cfg.language || nextLocale !== cfg.locale;
280
+ const changed = country !== cfg.country || nextLanguage !== cfg.language || nextLocale !== cfg.locale;
295
281
  cfg.country = country;
296
282
  cfg.language = nextLanguage || void 0;
297
283
  cfg.locale = nextLocale;
@@ -308,11 +294,23 @@
308
294
  return Cart.state;
309
295
  }
310
296
 
311
- // src/parts/markets.js
312
- var { Tether } = (
313
- /** @type {Window & { Tether?: { __parts: Record<string, unknown> } }} */
314
- window
315
- );
316
- if (!Tether) throw new Error("tether.markets.js runs after the Tether script, which loads it");
317
- Tether.__parts["markets"] = markets_ui_exports;
297
+ // server/src/shared/json.ts
298
+ function isRecord(value) {
299
+ return value !== null && typeof value === "object" && !Array.isArray(value);
300
+ }
301
+
302
+ // src/part-registry.ts
303
+ function isTetherInternals(value) {
304
+ return isRecord(value) && isRecord(value["__core"]) && isRecord(value["__parts"]);
305
+ }
306
+ function registerPart(name, part) {
307
+ const tether = Reflect.get(window, "Tether");
308
+ if (!isTetherInternals(tether)) {
309
+ throw new Error(`tether.${name}.js runs after the Tether script, which loads it, and needs its window.Tether`);
310
+ }
311
+ tether.__parts[name] = part;
312
+ }
313
+
314
+ // src/parts/markets.ts
315
+ registerPart("markets", markets_ui_exports);
318
316
  })();
@@ -1 +1 @@
1
- "use strict";(()=>{var B=Object.defineProperty;var H=(e,t)=>{for(var o in t)B(e,o,{get:t[o],enumerable:!0})};var T={};H(T,{detectMarket:()=>F,getLocalization:()=>y,renderCountrySelects:()=>L,setCountry:()=>be});var J=window.Tether.__core["config.js"],{DEFAULTS:Te,cfg:a,configure:_e,isConfigured:xe,log:Ee,reportError:h,resolveConfig:Se,toMetafieldIdentifier:Ae,warn:Pe}=J;var K=window.Tether.__core["client.js"],{TetherError:_,endpoint:ke,gql:x,request:Ue,unwrap:ve,withContext:je}=K;var W=window.Tether.__core["cart.js"],{Cart:f,trapFocus:Re}=W;var Y=window.Tether.__core["collection.js"],{ListScope:Fe,listSelector:E}=Y;var G=window.Tether.__core["loader.js"],{clearProductCache:S,getProduct:ze,getProducts:De,getRecommendations:qe,hydrateProducts:$e,normalizeProductKey:Be,primeProduct:He,refreshProducts:Je,takeStale:Ke}=G;var Q=window.Tether.__core["dom.js"],{attr:p,busy:Ye,cdnUrl:Ge,emit:A,formatDate:Qe,formatMoney:Ve,formatPercent:Ze,get:P,has:Xe,hasTemplate:et,imageUrl:tt,notifyLayoutChanged:ot,parseJSONAttr:nt,productUrl:rt,qsa:ct,repeat:at,repeatKeyed:lt,sameImage:it,scoped:ut,sel:w,setImage:st,setSelected:dt,setStoreHtml:ft,setText:gt,setTextTracked:mt,show:pt,toAttributes:yt,watchImages:ht}=Q;var V=window.Tether.__core["mounting.js"],{hydrateFromPage:Ct,liveLists:I,liveProducts:k,mountProduct:U,mountedLists:bt,mountedProducts:v,pruneLive:j,retryFailed:Lt,settleMarket:Tt,trackMarket:_t,within:C}=V;var Z=window.Tether.__core["market-codes.js"],{toCountry:s,toLanguage:d}=Z;var O=["saved","server","webflow"],X="tether_country",R=()=>`${a.prefix}:market:${a.domain}`;function M(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function ee(){let e=typeof window<"u";return{document:typeof document<"u"?document:null,location:e?window.location:null,storage:M(),global:e?window:{}}}function te(e){try{return JSON.parse(e)}catch(t){if(t instanceof SyntaxError)return null;throw t}}function oe(e){if(typeof e!="object"||e===null)return null;let t=s(Reflect.get(e,"country"));if(!t)return null;let o=Reflect.get(e,"locale");return{country:t,language:d(Reflect.get(e,"language"))??void 0,locale:typeof o=="string"&&o?o:void 0}}function ne(e=M()){let t=e?.getItem(R());return t?oe(te(t)):null}function re(e,t){if(!e||!t)return null;let o=e.cookie.split(";").map(r=>r.trim()).find(r=>r.startsWith(`${t}=`));return o?decodeURIComponent(o.slice(t.length+1)):null}function b(e,t){if(!e||!t)return null;let o=t.toLowerCase(),r=Object.keys(e).find(n=>n.toLowerCase()===o);return r?e[r]??null:null}function ce(e,t){let o=r=>t.document?.querySelector(`meta[name="${r}"]`)?.getAttribute("content");return{country:Reflect.get(t.global,"TETHER_COUNTRY")||o("tether-country")||re(t.document,e.cookie||X),language:Reflect.get(t.global,"TETHER_LANGUAGE")||o("tether-language")}}function ae(e,t){let o=(t.location?.pathname??"/").split("/").find(i=>i!==""),r=b(e.locales,o);if(r)return r;let n=t.document?.documentElement.getAttribute("lang");if(!n)return null;let l=b(e.locales,n)??b(e.locales,n.split("-")[0]);if(l)return{locale:n,...l};if(e.locales&&e.strict)return null;let c=n.split("-")[1];return{language:n,country:c?.length===2?c:null,locale:n}}function le(e,t,o){switch(e){case"saved":return t.remember===!1?null:ne(o.storage);case"server":return ce(t,o);case"webflow":return ae(t,o)}}var ie=e=>O.some(t=>t===e);function ue(e){return e?e===!0?O:[e].flat().filter(ie):["saved"]}function F(e=a.markets,t=ee()){let o=e??{};if(o.detect===!1)return{};let r={},n={sources:r};for(let l of ue(o.detect)){let c=le(l,o,t);if(!c)continue;let i=s(c.country),u=d(c.language),m=typeof c.locale=="string"&&c.locale?c.locale:null;i&&!n.country&&(n.country=i,r.country=l),u&&!n.language&&(n.language=u,r.language=l),m&&!n.locale&&(n.locale=m,r.locale=l)}return n}function se(e,t){try{localStorage.setItem(e,t)}catch{return}}function N(e){if(a.markets?.remember===!1)return;let t={country:e.country,language:e.language||void 0,locale:e.locale||void 0};se(R(),JSON.stringify(t))}var g=null;function z(){g=null}var de="query TetherLocalization{localization{country{isoCode name currency{isoCode symbol}}language{isoCode name}availableCountries{isoCode name currency{isoCode symbol}availableLanguages{isoCode name}}}}";function y(){return g||(g=x(de).then(t=>t.localization,t=>{throw g=null,t})),g}var fe="{name} ({currency})",ge="name";function D(e,t){switch(t){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 me=(e,t)=>e.replace(/\{(name|code|currency|symbol)\}/g,(o,r)=>D(t,r));function pe(e,t,o){let r=e.getAttribute(p("country-label"))||fe,n=(e.getAttribute(p("countries"))||"").toUpperCase().split(/[\s,]+/).filter(Boolean),l=n.length?n.map(c=>t.find(i=>i.isoCode===c)).filter(c=>c!==void 0):t;e.replaceChildren(...l.map(c=>new Option(me(r,c),c.isoCode))),e.value=o,e.value!==o&&(e.selectedIndex=-1),e.disabled=l.length<2&&!e.hasAttribute(p("always-enabled"))}function ye(e,t,o){let r=(a.country||o.country.isoCode).toUpperCase(),n=[...o.availableCountries].sort((c,i)=>c.name.localeCompare(i.name,a.locale||void 0)),l=n.find(c=>c.isoCode===r)??o.country;e.forEach(c=>{pe(c,n,r)}),t.forEach(c=>{c.textContent=D(l,P(c,"country-bind")||ge)})}function L(e=document){let t=C(e,`select${w("country-select")}`),o=C(e,w("country-bind"));return!t.length&&!o.length?Promise.resolve():y().then(r=>{ye(t,o,r)}).catch(r=>{h(r,"country select")})}var he=e=>Object.values(a.markets?.locales??{}).find(t=>s(t.country)===e);function we(e,t){return e!==void 0?d(e):t?t.language?d(t.language):void 0:a.language}function Ce(e){S();let t=[];return f.id()&&t.push(f.setBuyerIdentity({countryCode:e},{create:!1}).catch(o=>{h(o,"cart country")})),j(),I.forEach(o=>t.push(o.load())),k.forEach(o=>{o.closest(E())||(v.delete(o),U(o))}),t}async function be(e,{language:t,locale:o,remember:r=!0}={}){let n=s(e);if(!n)throw new _(`Not a country code: ${e}`,{code:"INVALID_COUNTRY"});let l=he(n),c=o||l?.locale,i=c||a.locale,u=we(t,l),m=n!==a.country?.toUpperCase()||u!==a.language||i!==a.locale;if(a.country=n,a.language=u||void 0,a.locale=i,r&&N({country:n,language:u,locale:c}),!m)return L(),f.state;t!==void 0&&z();let $=Ce(n);return L(),A("country-changed",{country:n,language:a.language}),await Promise.all($),f.state}var{Tether:q}=window;if(!q)throw new Error("tether.markets.js runs after the Tether script, which loads it");q.__parts.markets=T;})();
1
+ (()=>{var W=Object.defineProperty;var G=(e,t)=>{for(var n in t)W(e,n,{get:t[n],enumerable:!0})};var b={};G(b,{detectMarket:()=>j,getLocalization:()=>J,renderCountrySelects:()=>L,setCountry:()=>xe});var V=window.Tether.__core["config.ts"],[c,_e,Pe,M,S,C,Ae]=V;var Z=window.Tether.__core["client.ts"],[ve,x,Oe,T,E]=Z;var Q=window.Tether.__core["cart.ts"],[g]=Q;var X=window.Tether.__core["collection.ts"],[_]=X;var ee=window.Tether.__core["loader.ts"],[P,Ue]=ee;var te=window.Tether.__core["dom.ts"],[De,m,Fe,A,je,$e,N,qe,Je,Ye,Be,Ke,We,Ge,w,Ve,Ze,Qe]=te;var ne=window.Tether.__core["mounting.ts"],[v,O,I,z,R,k]=ne;var oe=window.Tether.__core["market-codes.ts"],[s,d]=oe;function U(e,t="localStorage"){try{return window[t].getItem(e)}catch{return null}}function H(e,t,n="localStorage"){try{window[n].setItem(e,t)}catch{}}var re="tether_country",D=()=>`${c.prefix}:market:${c.domain}`,F={getItem:e=>U(e)};function ae(){let e=typeof window<"u";return{document:typeof document<"u"?document:null,location:e?window.location:null,storage:F,global:e?window:{}}}function ce(e){try{return JSON.parse(e)}catch(t){if(t instanceof SyntaxError)return null;throw t}}function ie(e){if(typeof e!="object"||e===null)return null;let t=s(Reflect.get(e,"country"));if(!t)return null;let n=Reflect.get(e,"locale");return{country:t,language:d(Reflect.get(e,"language"))??void 0,locale:typeof n=="string"&&n?n:void 0}}function ue(e=F){let t=e.getItem(D());return t?ie(ce(t)):null}function le(e,t){if(!e||!t)return null;let n=e.cookie.split(";").map(a=>a.trim()).find(a=>a.startsWith(`${t}=`));return n?decodeURIComponent(n.slice(t.length+1)):null}function h(e,t){if(!e||!t)return null;let n=t.toLowerCase(),a=Object.keys(e).find(o=>o.toLowerCase()===n);return a?e[a]??null:null}function se(e,t){let n=r=>t.document?.querySelector(`meta[name="${r}"]`)?.getAttribute("content"),a=Reflect.get(t.global,"TETHER_COUNTRY"),o=Reflect.get(t.global,"TETHER_LANGUAGE"),i=n("tether-country")||le(t.document,e.cookie||re);return{country:a||i,language:o||n("tether-language")}}function de(e,t){let n=(t.location?.pathname??"/").split("/").find(u=>u!==""),a=h(e.locales,n);if(a)return a;let o=t.document?.documentElement.getAttribute("lang");if(!o)return null;let i=h(e.locales,o)??h(e.locales,o.split("-")[0]);if(i)return{locale:o,...i};if(e.locales&&e.strict)return null;let r=o.split("-")[1];return{language:o,country:r?.length===2?r:null,locale:o}}function ge(e,t,n){switch(e){case"saved":return t.remember===!1?null:ue(n.storage);case"server":return se(t,n);case"webflow":return de(t,n)}}function fe(e){return e?e===!0?M:e:["saved"]}function j(e=c.markets,t=ae()){let n=(e===c.markets?e:S(e))??{};if(n.detect===!1)return{};let a={},o={sources:a};for(let i of fe(n.detect)){let r=ge(i,n,t);if(!r)continue;let u=s(r.country),l=d(r.language),f=typeof r.locale=="string"&&r.locale?r.locale:null;u&&!o.country&&(o.country=u,a.country=i),l&&!o.language&&(o.language=l,a.language=i),f&&!o.locale&&(o.locale=f,a.locale=i)}return o}function $(e){if(c.markets?.remember===!1)return;let t={country:e.country,language:e.language||void 0,locale:e.locale||void 0};H(D(),JSON.stringify(t))}var me="{name} ({currency})",pe="name",p=null;function ye(){p=null}var Ce="query TetherLocalization{localization{country{isoCode name currency{isoCode symbol}}language{isoCode name}availableCountries{isoCode name currency{isoCode symbol}availableLanguages{isoCode name}}}}",q={isoCode:"string",name:"string",currency:"object"},we=T({localization:{country:q,availableCountries:[q]}});function J(){return p??(p=x(Ce,{},we).then(e=>e.localization,e=>{throw p=null,e})),p}function Y(e,t){switch(t){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 ke=(e,t)=>e.replace(/\{(name|code|currency|symbol)\}/g,(n,a)=>Y(t,a));function he(e,t,n){let a=e.getAttribute(m("country-label"))||me,o=(e.getAttribute(m("countries"))||"").toUpperCase().split(/[\s,]+/).filter(Boolean),i=o.length?o.map(r=>t.find(u=>u.isoCode===r)).filter(r=>r!==void 0):t;e.replaceChildren(...i.map(r=>new Option(ke(a,r),r.isoCode))),e.value=n,e.value!==n&&(e.selectedIndex=-1),e.disabled=i.length<2&&!e.hasAttribute(m("always-enabled"))}function Le(e,t,n){let a=(c.country||n.country.isoCode).toUpperCase(),o=[...n.availableCountries].sort((r,u)=>r.name.localeCompare(u.name,c.locale||void 0)),i=o.find(r=>r.isoCode===a)??n.country;e.forEach(r=>{he(r,o,a)}),t.forEach(r=>{r.textContent=Y(i,N(r,"country-bind")||pe)})}function L(e=document){let t=k(e,`select${w("country-select")}`),n=k(e,w("country-bind"));return!t.length&&!n.length?Promise.resolve():J().then(a=>{Le(t,n,a)}).catch(a=>{C(a,"country select")})}var be=e=>Object.values(c.markets?.locales??{}).find(t=>s(t.country)===e);function Me(e,t){return e!==void 0?d(e):t?t.language?d(t.language):void 0:c.language}function Se(e){P();let t=[];return g.id()&&t.push(g.setBuyerIdentity({countryCode:e},{create:!1}).catch(n=>{C(n,"cart country")})),R(),v.forEach(n=>t.push(n.load())),O.forEach(n=>{n.closest(_())||(I.delete(n),z(n))}),t}async function xe(e,{language:t,locale:n,remember:a=!0}={}){let o=s(e);if(!o)throw new E(`Not a country code: ${e}`,{code:"INVALID_COUNTRY"});let i=be(o),r=n||i?.locale,u=r||c.locale,l=Me(t,i),f=o!==c.country||l!==c.language||u!==c.locale;if(c.country=o,c.language=l||void 0,c.locale=u,a&&$({country:o,language:l,locale:r}),!f)return L(),g.state;t!==void 0&&ye();let K=Se(o);return L(),A("country-changed",{country:o,language:c.language}),await Promise.all(K),g.state}function y(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Te(e){return y(e)&&y(e.__core)&&y(e.__parts)}function B(e,t){let n=Reflect.get(window,"Tether");if(!Te(n))throw new Error(`tether.${e}.js runs after the Tether script, which loads it, and needs its window.Tether`);n.__parts[e]=t}B("markets",b);})();
Binary file