@juo/blocks 1.16.0 → 2.0.0-alpha.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 (103) hide show
  1. package/dist/{ExtensionRoot-C3lVJEBl.js → ExtensionRoot-DRpD5EcC.js} +24 -6
  2. package/dist/block-BjJztStr.js +993 -0
  3. package/dist/{block-dVP4Rqgz.js → block-DnhzyZ1H.js} +29 -3
  4. package/dist/block.d.ts +56 -0
  5. package/dist/block.d.ts.map +1 -1
  6. package/dist/{bridge-xiKEzCGR.js → bridge-Mz0CqG6E.js} +39 -30
  7. package/dist/core.js +336 -222
  8. package/dist/css-runtime-B7tZrBIp.js +749 -0
  9. package/dist/devtools/hook.d.ts +0 -5
  10. package/dist/devtools/hook.d.ts.map +1 -1
  11. package/dist/devtools/index.d.ts +0 -1
  12. package/dist/devtools/index.d.ts.map +1 -1
  13. package/dist/devtools/protocol.d.ts +15 -1
  14. package/dist/devtools/protocol.d.ts.map +1 -1
  15. package/dist/devtools.js +42 -9
  16. package/dist/editor/bridge.d.ts +7 -0
  17. package/dist/editor/bridge.d.ts.map +1 -1
  18. package/dist/editor/components.d.ts.map +1 -1
  19. package/dist/editor/main.d.ts +2 -1
  20. package/dist/editor/main.d.ts.map +1 -1
  21. package/dist/editor/messages.d.ts +13 -2
  22. package/dist/editor/messages.d.ts.map +1 -1
  23. package/dist/editor/overlays.d.ts +14 -0
  24. package/dist/editor/overlays.d.ts.map +1 -0
  25. package/dist/editor/overlays.test.d.ts +2 -0
  26. package/dist/editor/overlays.test.d.ts.map +1 -0
  27. package/dist/editor.js +52 -33
  28. package/dist/{gridstack-adapter-CDWbSpbt.js → gridstack-adapter-BGKGC-eO.js} +2 -2
  29. package/dist/main.d.ts +3 -1
  30. package/dist/main.d.ts.map +1 -1
  31. package/dist/{morph-n4LMxOYo.js → morph-CT5hc5Qp.js} +1 -1
  32. package/dist/overlay-wrapper.d.ts +69 -0
  33. package/dist/overlay-wrapper.d.ts.map +1 -0
  34. package/dist/overlay-wrapper.test.d.ts +2 -0
  35. package/dist/overlay-wrapper.test.d.ts.map +1 -0
  36. package/dist/overlays/OverlayService.d.ts +34 -0
  37. package/dist/overlays/OverlayService.d.ts.map +1 -0
  38. package/dist/overlays/OverlayService.test.d.ts +2 -0
  39. package/dist/overlays/OverlayService.test.d.ts.map +1 -0
  40. package/dist/preact/block.d.ts.map +1 -1
  41. package/dist/preact/context.d.ts.map +1 -1
  42. package/dist/preact/context.test.d.ts +2 -0
  43. package/dist/preact/context.test.d.ts.map +1 -0
  44. package/dist/preact/signals.d.ts +19 -0
  45. package/dist/preact/signals.d.ts.map +1 -1
  46. package/dist/preact/useContextSubscription.test.d.ts +2 -0
  47. package/dist/preact/useContextSubscription.test.d.ts.map +1 -0
  48. package/dist/preact.js +33 -7
  49. package/dist/{project-gridstack-CM783oKI.js → project-gridstack-PxN_DIfP.js} +1 -1
  50. package/dist/react/block.d.ts.map +1 -1
  51. package/dist/react/context.d.ts.map +1 -1
  52. package/dist/react/context.test.d.ts +2 -0
  53. package/dist/react/context.test.d.ts.map +1 -0
  54. package/dist/react/signals.d.ts +19 -0
  55. package/dist/react/signals.d.ts.map +1 -1
  56. package/dist/react/useContextSubscription.test.d.ts +2 -0
  57. package/dist/react/useContextSubscription.test.d.ts.map +1 -0
  58. package/dist/react.js +40 -8
  59. package/dist/services/index.d.ts +1 -1
  60. package/dist/services/index.d.ts.map +1 -1
  61. package/dist/services/order/adapter.d.ts +7 -6
  62. package/dist/services/order/adapter.d.ts.map +1 -1
  63. package/dist/services/order/index.d.ts +2 -3
  64. package/dist/services/order/index.d.ts.map +1 -1
  65. package/dist/services/order/orderService.d.ts +2 -3
  66. package/dist/services/order/orderService.d.ts.map +1 -1
  67. package/dist/services/order/orderService.test.d.ts +2 -0
  68. package/dist/services/order/orderService.test.d.ts.map +1 -0
  69. package/dist/services/order/types.d.ts +53 -14
  70. package/dist/services/order/types.d.ts.map +1 -1
  71. package/dist/shared/context.d.ts +10 -3
  72. package/dist/shared/context.d.ts.map +1 -1
  73. package/dist/shared/touchSignals.d.ts +17 -0
  74. package/dist/shared/touchSignals.d.ts.map +1 -0
  75. package/dist/shared/touchSignals.test.d.ts +2 -0
  76. package/dist/shared/touchSignals.test.d.ts.map +1 -0
  77. package/dist/theme-state.d.ts +2 -1
  78. package/dist/theme-state.d.ts.map +1 -1
  79. package/dist/theme-state.params.test.d.ts +2 -0
  80. package/dist/theme-state.params.test.d.ts.map +1 -0
  81. package/dist/theme-state.translations.test.d.ts +2 -0
  82. package/dist/theme-state.translations.test.d.ts.map +1 -0
  83. package/dist/vue/block.d.ts.map +1 -1
  84. package/dist/vue.js +16 -13
  85. package/dist/web-components/ExtensionRoot.d.ts +1 -0
  86. package/dist/web-components/ExtensionRoot.d.ts.map +1 -1
  87. package/dist/web-components-editor.js +6 -5
  88. package/dist/web-components-runtime.js +3 -2
  89. package/package.json +1 -1
  90. package/dist/css-runtime-ClH0MEYr.js +0 -1570
  91. package/dist/devtools/instrumentation.d.ts +0 -47
  92. package/dist/devtools/instrumentation.d.ts.map +0 -1
  93. package/dist/index-JSv6UH_o.js +0 -169
  94. package/dist/services/orders/adapter.d.ts +0 -10
  95. package/dist/services/orders/adapter.d.ts.map +0 -1
  96. package/dist/services/orders/index.d.ts +0 -4
  97. package/dist/services/orders/index.d.ts.map +0 -1
  98. package/dist/services/orders/ordersService.d.ts +0 -6
  99. package/dist/services/orders/ordersService.d.ts.map +0 -1
  100. package/dist/services/orders/ordersService.test.d.ts +0 -2
  101. package/dist/services/orders/ordersService.test.d.ts.map +0 -1
  102. package/dist/services/orders/types.d.ts +0 -60
  103. package/dist/services/orders/types.d.ts.map +0 -1
package/dist/core.js CHANGED
@@ -1,11 +1,13 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { f as createContext, g as d, h as w, j as registerBlock, E, u, k as getDefinedBlocks, l as createBlockInstance, m as defineBlock, s as subscribeContext, G as GRID_V1_ENGINE_ID, n as clampRect, p as applyFillExpansion, q as compactItems, t as findFreeRect, D as DEFAULT_GRID } from "./css-runtime-ClH0MEYr.js";
5
- import { B, v, x, y, z, L, P, S, c, T, A, d as d2, b, F, H, I, J, K, N, O, Q, R, U, V, W, X, Y, Z, i, _, a, $, a0, o, a1, a2, a3, e, a4, r, a5, a6, a7, w as w2 } from "./css-runtime-ClH0MEYr.js";
4
+ import { e as createContext, f as d, m as w, n as defineBlock, h as createBlockInstance, j as getDefinedBlocks, p as registerBlock, E, u, s as subscribeContext } from "./block-BjJztStr.js";
5
+ import { B, q, t, S, v, _, x, c, y, g, z, A, D, F, G, i, H, b, I, o, J, k, K, l, L, w as w2 } from "./block-BjJztStr.js";
6
+ import { G as GRID_V1_ENGINE_ID, d as clampRect, e as applyFillExpansion, f as compactItems, g as findFreeRect, D as DEFAULT_GRID } from "./css-runtime-B7tZrBIp.js";
7
+ import { h, i as i2, L as L2, P, a, T, b as b2, j, k as k2, l as l2, m, n, o as o2, p, q as q2, s, t as t2, u as u2, v as v2, c as c2, w as w3, r } from "./css-runtime-B7tZrBIp.js";
6
8
  import { reportBlockWarning, reportBlockError } from "./observability.js";
7
- import { a as createEditorBridge, D as createSelectBlockMessage } from "./bridge-xiKEzCGR.js";
8
- import { p } from "./project-gridstack-CM783oKI.js";
9
+ import { a as createEditorBridge, E as createSelectBlockMessage } from "./bridge-Mz0CqG6E.js";
10
+ import { p as p2 } from "./project-gridstack-PxN_DIfP.js";
9
11
  import { clearLayoutModeAdapter, getLayoutModeAdapter, registerLayoutModeAdapter } from "./layout-mode-adapter-BBd4JRQd.js";
10
12
  function createState() {
11
13
  const discountCode = d(null);
@@ -75,6 +77,111 @@ function createState() {
75
77
  };
76
78
  }
77
79
  const StateContext = createContext("state");
80
+ const OVERLAY_WRAPPER_SCHEMA = {
81
+ type: "object",
82
+ properties: {
83
+ props: {
84
+ type: "object",
85
+ properties: {
86
+ layout: {
87
+ type: "string",
88
+ enum: ["modal", "sidebar"]
89
+ },
90
+ canAbort: {
91
+ type: "boolean"
92
+ }
93
+ },
94
+ required: ["layout"],
95
+ additionalProperties: false
96
+ },
97
+ slots: {
98
+ type: "object",
99
+ properties: {
100
+ content: {}
101
+ },
102
+ additionalProperties: false
103
+ }
104
+ },
105
+ required: ["props", "slots"],
106
+ additionalProperties: false
107
+ };
108
+ function defineOverlayWrapper(opts) {
109
+ const layout = opts.layout ?? "sidebar";
110
+ const canAbort = opts.canAbort ?? true;
111
+ return defineBlock(opts.name, {
112
+ displayName: opts.title,
113
+ group: "internal",
114
+ schema: OVERLAY_WRAPPER_SCHEMA,
115
+ initialValue: () => ({
116
+ props: { layout, canAbort },
117
+ slots: {
118
+ content: [createBlockInstance(opts.content)]
119
+ }
120
+ }),
121
+ renderer: () => null
122
+ });
123
+ }
124
+ const OVERLAY_PREFIX$1 = "overlay:";
125
+ function callInitialValue(block) {
126
+ if (typeof block.initialValue !== "function") return block.initialValue;
127
+ try {
128
+ return block.initialValue();
129
+ } catch (error) {
130
+ console.warn(
131
+ `[overlays] initialValue() threw for "${block.name}"; its content block will not be hidden from the palette.`,
132
+ error
133
+ );
134
+ return void 0;
135
+ }
136
+ }
137
+ function buildOverlayRegistry(blocks) {
138
+ var _a, _b;
139
+ const registry = {};
140
+ for (const block of blocks) {
141
+ if (!block.name.startsWith(OVERLAY_PREFIX$1)) continue;
142
+ const id = block.name.slice(OVERLAY_PREFIX$1.length);
143
+ const initial = callInitialValue(block);
144
+ const first = (_b = (_a = initial == null ? void 0 : initial.slots) == null ? void 0 : _a.content) == null ? void 0 : _b[0];
145
+ const contentBlock = typeof (first == null ? void 0 : first.type) === "string" ? first.type : "";
146
+ registry[id] = {
147
+ block: block.name,
148
+ title: block.displayName ?? id,
149
+ contentBlock
150
+ };
151
+ }
152
+ return registry;
153
+ }
154
+ const OVERLAY_PREFIX = "overlay:";
155
+ const OverlayServiceContext = createContext("services/overlay");
156
+ function createOverlayService(themeState, options = {}) {
157
+ const getBlocks = options.getBlocks ?? getDefinedBlocks;
158
+ const current = w(() => {
159
+ const root = themeState.overlay.blocks.value[0];
160
+ const type = root == null ? void 0 : root.type;
161
+ if (typeof type !== "string" || !type.startsWith(OVERLAY_PREFIX)) {
162
+ return null;
163
+ }
164
+ const props = root.props ?? {};
165
+ return {
166
+ name: type,
167
+ // Defaults mirror defineOverlayWrapper's seeding in overlay-wrapper.ts — keep in sync.
168
+ layout: props.layout ?? "sidebar",
169
+ canAbort: Boolean(props.canAbort ?? true)
170
+ };
171
+ });
172
+ return {
173
+ getEditableOverlays() {
174
+ return buildOverlayRegistry(getBlocks());
175
+ },
176
+ open(name, params) {
177
+ void themeState.resolve("overlay", name, params);
178
+ },
179
+ close() {
180
+ themeState.overlay.blocks.value = [];
181
+ },
182
+ current
183
+ };
184
+ }
78
185
  function isLocalhostOrigin(origin) {
79
186
  try {
80
187
  const url = new URL(origin);
@@ -190,8 +297,8 @@ function createApiCustomerAdapter(fetcher) {
190
297
  _tag: "Success",
191
298
  data: { id: data.id, name, email: data.email }
192
299
  };
193
- } catch (e2) {
194
- return { _tag: "Failure", error: e2 };
300
+ } catch (e) {
301
+ return { _tag: "Failure", error: e };
195
302
  }
196
303
  }
197
304
  };
@@ -209,7 +316,7 @@ const PARAMS = {
209
316
  function uuid() {
210
317
  return ("10000000-1000-4000-8000" + -1e11).replace(
211
318
  /[018]/g,
212
- (c2) => (c2 ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c2 / 4).toString(16)
319
+ (c3) => (c3 ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c3 / 4).toString(16)
213
320
  );
214
321
  }
215
322
  function createMockLoginAdapter(opts = {}) {
@@ -280,8 +387,8 @@ function createApiLoginAdapter(fetcher, opts) {
280
387
  lang
281
388
  );
282
389
  return { _tag: "Success", data: void 0 };
283
- } catch (e2) {
284
- return { _tag: "Failure", error: e2 };
390
+ } catch (e) {
391
+ return { _tag: "Failure", error: e };
285
392
  }
286
393
  },
287
394
  async authenticate(params) {
@@ -315,8 +422,8 @@ function createApiLoginAdapter(fetcher, opts) {
315
422
  throw new Error(`Unexpected response: ${res.statusText}`);
316
423
  }
317
424
  return { _tag: "Success", data: await res.json() };
318
- } catch (e2) {
319
- return { _tag: "Failure", error: e2 };
425
+ } catch (e) {
426
+ return { _tag: "Failure", error: e };
320
427
  }
321
428
  },
322
429
  getAuthorizeUrl({ connection, state, shop }) {
@@ -575,7 +682,7 @@ function createLoginService(init) {
575
682
  return service;
576
683
  }
577
684
  const LoginServiceContext = createContext("services/login");
578
- function createMockOrdersAdapter() {
685
+ function createMockOrderAdapter() {
579
686
  const mockOrders = [
580
687
  {
581
688
  id: "10001",
@@ -659,7 +766,7 @@ function mapOrder(order) {
659
766
  customAttributes: order.customAttributes
660
767
  };
661
768
  }
662
- function createApiOrdersAdapter(fetcher) {
769
+ function createApiOrderAdapter(fetcher) {
663
770
  return {
664
771
  async getOrders(params) {
665
772
  const query = new URLSearchParams();
@@ -685,7 +792,7 @@ function createApiOrdersAdapter(fetcher) {
685
792
  }
686
793
  };
687
794
  }
688
- function createOrdersService(adapter) {
795
+ function createOrderService(adapter) {
689
796
  return {
690
797
  async getOrders(params) {
691
798
  try {
@@ -697,7 +804,7 @@ function createOrdersService(adapter) {
697
804
  }
698
805
  };
699
806
  }
700
- const OrdersServiceContext = createContext("services/orders");
807
+ const OrderServiceContext = createContext("services/order");
701
808
  function createMockProductAdapter() {
702
809
  const products = [
703
810
  {
@@ -888,9 +995,9 @@ function createMockProductAdapter() {
888
995
  await new Promise((resolve) => setTimeout(resolve, 100));
889
996
  return products.filter((product) => ids.includes(product.id)).map(toAvailableProduct);
890
997
  },
891
- async getAvailableProducts({ q }) {
998
+ async getAvailableProducts({ q: q3 }) {
892
999
  await new Promise((resolve) => setTimeout(resolve, 100));
893
- const queryLower = q == null ? void 0 : q.toLowerCase();
1000
+ const queryLower = q3 == null ? void 0 : q3.toLowerCase();
894
1001
  return products.filter(
895
1002
  (product) => !queryLower || product.title.toLowerCase().includes(queryLower) || product.variants.some(
896
1003
  (variant) => variant.title.toLowerCase().includes(queryLower)
@@ -964,7 +1071,7 @@ function mapProduct(product, currencyCode) {
964
1071
  featuredImage: product.image == null ? null : { url: product.image.url, altText: product.image.altText ?? void 0 },
965
1072
  hasOnlyDefaultVariant: product.variants.length <= 1,
966
1073
  variants: {
967
- items: product.variants.map((v2) => mapVariant(v2, currencyCode)),
1074
+ items: product.variants.map((v3) => mapVariant(v3, currencyCode)),
968
1075
  pageInfo: {
969
1076
  hasNextPage: false,
970
1077
  hasPrevPage: false,
@@ -1019,7 +1126,7 @@ function createApiProductAdapter(fetcher, opts = { currencyCode: "USD" }) {
1019
1126
  }
1020
1127
  const body = await fetchProducts(params);
1021
1128
  return {
1022
- items: body.data.map((p2) => mapProduct(p2, currencyCode)),
1129
+ items: body.data.map((p3) => mapProduct(p3, currencyCode)),
1023
1130
  pageInfo: {
1024
1131
  hasNextPage: body.hasNextPage,
1025
1132
  hasPrevPage: body.hasPrevPage,
@@ -1045,10 +1152,10 @@ function createApiProductAdapter(fetcher, opts = { currencyCode: "USD" }) {
1045
1152
  const res = await fetcher(`/customer/products/by-ids?${params.toString()}`);
1046
1153
  if (!res.ok) return [];
1047
1154
  const data = await res.json();
1048
- return (data ?? []).map((p2) => ({
1049
- id: p2.id,
1050
- title: p2.title ?? "",
1051
- featuredImage: p2.featuredImage ? { url: p2.featuredImage.url, altText: p2.featuredImage.altText } : null,
1155
+ return (data ?? []).map((p3) => ({
1156
+ id: p3.id,
1157
+ title: p3.title ?? "",
1158
+ featuredImage: p3.featuredImage ? { url: p3.featuredImage.url, altText: p3.featuredImage.altText } : null,
1052
1159
  hasOnlyDefaultVariant: true,
1053
1160
  collections: []
1054
1161
  }));
@@ -1060,30 +1167,30 @@ function createApiProductAdapter(fetcher, opts = { currencyCode: "USD" }) {
1060
1167
  const res = await fetcher(`/customer/products/variants?${params.toString()}`);
1061
1168
  if (!res.ok) return [];
1062
1169
  const data = await res.json();
1063
- return (data ?? []).map((p2) => {
1170
+ return (data ?? []).map((p3) => {
1064
1171
  var _a;
1065
1172
  return {
1066
- id: p2.id,
1067
- title: p2.title,
1068
- description: p2.description ?? "",
1069
- featuredImage: p2.featuredImage,
1070
- hasOnlyDefaultVariant: p2.hasOnlyDefaultVariant ?? (((_a = p2.variants) == null ? void 0 : _a.length) ?? 0) <= 1,
1071
- variants: (p2.variants ?? []).map((v2) => ({
1072
- id: v2.id,
1073
- availableForSale: v2.availableForSale,
1074
- title: v2.title,
1075
- currentPrice: v2.currentPrice,
1076
- basePrice: v2.basePrice,
1077
- image: v2.image,
1078
- recurring: v2.recurring
1173
+ id: p3.id,
1174
+ title: p3.title,
1175
+ description: p3.description ?? "",
1176
+ featuredImage: p3.featuredImage,
1177
+ hasOnlyDefaultVariant: p3.hasOnlyDefaultVariant ?? (((_a = p3.variants) == null ? void 0 : _a.length) ?? 0) <= 1,
1178
+ variants: (p3.variants ?? []).map((v3) => ({
1179
+ id: v3.id,
1180
+ availableForSale: v3.availableForSale,
1181
+ title: v3.title,
1182
+ currentPrice: v3.currentPrice,
1183
+ basePrice: v3.basePrice,
1184
+ image: v3.image,
1185
+ recurring: v3.recurring
1079
1186
  }))
1080
1187
  };
1081
1188
  });
1082
1189
  },
1083
- async getAvailableProducts({ subscriptionId, lineId, q, mode, action, pagination }) {
1190
+ async getAvailableProducts({ subscriptionId, lineId, q: q3, mode, action, pagination }) {
1084
1191
  const params = new URLSearchParams();
1085
1192
  params.set("action", action);
1086
- if (q) params.set("q", q);
1193
+ if (q3) params.set("q", q3);
1087
1194
  if (mode) params.set("mode", mode);
1088
1195
  if (pagination && "after" in pagination) params.set("after", pagination.after);
1089
1196
  if (pagination && "before" in pagination) params.set("before", pagination.before);
@@ -1092,22 +1199,22 @@ function createApiProductAdapter(fetcher, opts = { currencyCode: "USD" }) {
1092
1199
  );
1093
1200
  if (!res.ok) return [];
1094
1201
  const data = await res.json();
1095
- return (data ?? []).map((p2) => {
1202
+ return (data ?? []).map((p3) => {
1096
1203
  var _a;
1097
1204
  return {
1098
- id: p2.id,
1099
- title: p2.title,
1100
- description: p2.description ?? "",
1101
- featuredImage: p2.featuredImage,
1102
- hasOnlyDefaultVariant: p2.hasOnlyDefaultVariant ?? (((_a = p2.variants) == null ? void 0 : _a.length) ?? 0) <= 1,
1103
- variants: (p2.variants ?? []).map((v2) => ({
1104
- id: v2.id,
1105
- availableForSale: v2.availableForSale,
1106
- title: v2.title,
1107
- currentPrice: v2.currentPrice,
1108
- basePrice: v2.basePrice,
1109
- image: v2.image,
1110
- recurring: v2.recurring
1205
+ id: p3.id,
1206
+ title: p3.title,
1207
+ description: p3.description ?? "",
1208
+ featuredImage: p3.featuredImage,
1209
+ hasOnlyDefaultVariant: p3.hasOnlyDefaultVariant ?? (((_a = p3.variants) == null ? void 0 : _a.length) ?? 0) <= 1,
1210
+ variants: (p3.variants ?? []).map((v3) => ({
1211
+ id: v3.id,
1212
+ availableForSale: v3.availableForSale,
1213
+ title: v3.title,
1214
+ currentPrice: v3.currentPrice,
1215
+ basePrice: v3.basePrice,
1216
+ image: v3.image,
1217
+ recurring: v3.recurring
1111
1218
  }))
1112
1219
  };
1113
1220
  });
@@ -1152,7 +1259,7 @@ function routeNameTableFromPages(pages) {
1152
1259
  function createRouterService(options) {
1153
1260
  const { pages, pushImplementation } = options;
1154
1261
  const routeNameToPagePath = routeNameTableFromPages(pages);
1155
- const pathSet = new Set(pages.map((p2) => p2.path));
1262
+ const pathSet = new Set(pages.map((p3) => p3.path));
1156
1263
  const navigationSubscribers = [];
1157
1264
  function notifySubscribers(logicalPath) {
1158
1265
  for (const cb of navigationSubscribers) cb({ path: logicalPath });
@@ -1420,7 +1527,7 @@ function createMockSubscriptionAdapter(options = {}) {
1420
1527
  data: subscription ? {
1421
1528
  ...subscription,
1422
1529
  items: subscription.items.map((item) => ({ ...item })),
1423
- discounts: subscription.discounts.map((d3) => ({ ...d3 }))
1530
+ discounts: subscription.discounts.map((d2) => ({ ...d2 }))
1424
1531
  } : null
1425
1532
  };
1426
1533
  },
@@ -1468,7 +1575,7 @@ function createMockSubscriptionAdapter(options = {}) {
1468
1575
  }
1469
1576
  const currencyCode = ((_a = subscription.items[0]) == null ? void 0 : _a.price.currencyCode) ?? "USD";
1470
1577
  const product = await ((_b = options.productAdapter) == null ? void 0 : _b.getByVariantId(item.variantId)) ?? await ((_c = options.productAdapter) == null ? void 0 : _c.getById(item.variantId)) ?? null;
1471
- const variant = (product == null ? void 0 : product.variants.items.find((v2) => v2.id === item.variantId)) ?? (product == null ? void 0 : product.variants.items[0]);
1578
+ const variant = (product == null ? void 0 : product.variants.items.find((v3) => v3.id === item.variantId)) ?? (product == null ? void 0 : product.variants.items[0]);
1472
1579
  const linePrice = ((_e = (_d = variant == null ? void 0 : variant.purchaseOptions) == null ? void 0 : _d[0]) == null ? void 0 : _e.price) ?? (variant == null ? void 0 : variant.price);
1473
1580
  subscription.items.push({
1474
1581
  id: `item_${Date.now()}_${subscription.items.length}`,
@@ -1493,7 +1600,7 @@ function createMockSubscriptionAdapter(options = {}) {
1493
1600
  if (!subscription) {
1494
1601
  return { _tag: "Failure", error: "Subscription not found" };
1495
1602
  }
1496
- subscription.items = subscription.items.filter((i2) => i2.id !== itemId);
1603
+ subscription.items = subscription.items.filter((i3) => i3.id !== itemId);
1497
1604
  subscription.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
1498
1605
  return { _tag: "Success", data: void 0 };
1499
1606
  },
@@ -1503,7 +1610,7 @@ function createMockSubscriptionAdapter(options = {}) {
1503
1610
  if (!subscription) {
1504
1611
  return { _tag: "Failure", error: "Subscription not found" };
1505
1612
  }
1506
- const item = subscription.items.find((i2) => i2.id === lineId);
1613
+ const item = subscription.items.find((i3) => i3.id === lineId);
1507
1614
  if (!item) {
1508
1615
  return { _tag: "Failure", error: "Line item not found" };
1509
1616
  }
@@ -1519,7 +1626,7 @@ function createMockSubscriptionAdapter(options = {}) {
1519
1626
  if (!subscription) {
1520
1627
  return { _tag: "Failure", error: "Subscription not found" };
1521
1628
  }
1522
- const item = subscription.items.find((i2) => i2.id === lineId);
1629
+ const item = subscription.items.find((i3) => i3.id === lineId);
1523
1630
  if (!item) {
1524
1631
  return { _tag: "Failure", error: "Line item not found" };
1525
1632
  }
@@ -1709,7 +1816,7 @@ function createMockSubscriptionAdapter(options = {}) {
1709
1816
  data: {
1710
1817
  ...subscription,
1711
1818
  items: subscription.items.map((item) => ({ ...item })),
1712
- discounts: subscription.discounts.map((d3) => ({ ...d3 }))
1819
+ discounts: subscription.discounts.map((d2) => ({ ...d2 }))
1713
1820
  }
1714
1821
  };
1715
1822
  },
@@ -1781,14 +1888,14 @@ function mapSubscription(raw) {
1781
1888
  ),
1782
1889
  discounts: (raw.discounts ?? []).map(
1783
1890
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1784
- (d3) => {
1891
+ (d2) => {
1785
1892
  var _a2, _b2, _c;
1786
1893
  return {
1787
- id: d3.id,
1788
- type: ((_a2 = d3.value) == null ? void 0 : _a2.type) === "fixed-amount" || d3.type === "fixed_amount" ? "fixed_amount" : "percentage",
1789
- value: ((_b2 = d3.value) == null ? void 0 : _b2.amount) ?? ((_c = d3.value) == null ? void 0 : _c.percentage) ?? d3.value ?? 0,
1790
- code: d3.title ?? d3.code ?? "",
1791
- description: d3.description ?? ""
1894
+ id: d2.id,
1895
+ type: ((_a2 = d2.value) == null ? void 0 : _a2.type) === "fixed-amount" || d2.type === "fixed_amount" ? "fixed_amount" : "percentage",
1896
+ value: ((_b2 = d2.value) == null ? void 0 : _b2.amount) ?? ((_c = d2.value) == null ? void 0 : _c.percentage) ?? d2.value ?? 0,
1897
+ code: d2.title ?? d2.code ?? "",
1898
+ description: d2.description ?? ""
1792
1899
  };
1793
1900
  }
1794
1901
  ),
@@ -1822,8 +1929,8 @@ function createApiSubscriptionAdapter(fetcher) {
1822
1929
  try {
1823
1930
  const params = new URLSearchParams();
1824
1931
  if ((_a = options == null ? void 0 : options.filters) == null ? void 0 : _a.length) {
1825
- const groups = options.filters.filter((f) => Object.keys(f).length > 0).map((f) => Object.entries(f).filter(([, v2]) => Boolean(v2))).filter((entries) => entries.length > 0).map(
1826
- (entries) => "(" + entries.map(([k, v2]) => `${k}:'${v2}'`).join(" AND ") + ")"
1932
+ const groups = options.filters.filter((f) => Object.keys(f).length > 0).map((f) => Object.entries(f).filter(([, v3]) => Boolean(v3))).filter((entries) => entries.length > 0).map(
1933
+ (entries) => "(" + entries.map(([k3, v3]) => `${k3}:'${v3}'`).join(" AND ") + ")"
1827
1934
  );
1828
1935
  if (groups.length) params.set("query", groups.join(" OR "));
1829
1936
  }
@@ -1853,8 +1960,8 @@ function createApiSubscriptionAdapter(fetcher) {
1853
1960
  }
1854
1961
  }
1855
1962
  };
1856
- } catch (e2) {
1857
- return { _tag: "Failure", error: e2 };
1963
+ } catch (e) {
1964
+ return { _tag: "Failure", error: e };
1858
1965
  }
1859
1966
  },
1860
1967
  async getById(id) {
@@ -1866,8 +1973,8 @@ function createApiSubscriptionAdapter(fetcher) {
1866
1973
  const body = await res.json();
1867
1974
  const raw = body.data[0];
1868
1975
  return { _tag: "Success", data: raw ? mapSubscription(raw) : null };
1869
- } catch (e2) {
1870
- return { _tag: "Failure", error: e2 };
1976
+ } catch (e) {
1977
+ return { _tag: "Failure", error: e };
1871
1978
  }
1872
1979
  },
1873
1980
  async addItem({ subscriptionId, item }) {
@@ -1882,8 +1989,8 @@ function createApiSubscriptionAdapter(fetcher) {
1882
1989
  );
1883
1990
  if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
1884
1991
  return { _tag: "Success", data: void 0 };
1885
- } catch (e2) {
1886
- return { _tag: "Failure", error: e2 };
1992
+ } catch (e) {
1993
+ return { _tag: "Failure", error: e };
1887
1994
  }
1888
1995
  },
1889
1996
  async removeItem({ subscriptionId, itemId }) {
@@ -1894,8 +2001,8 @@ function createApiSubscriptionAdapter(fetcher) {
1894
2001
  );
1895
2002
  if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
1896
2003
  return { _tag: "Success", data: void 0 };
1897
- } catch (e2) {
1898
- return { _tag: "Failure", error: e2 };
2004
+ } catch (e) {
2005
+ return { _tag: "Failure", error: e };
1899
2006
  }
1900
2007
  },
1901
2008
  async updateItem({ subscriptionId, lineId, update }) {
@@ -1916,8 +2023,8 @@ function createApiSubscriptionAdapter(fetcher) {
1916
2023
  );
1917
2024
  if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
1918
2025
  return { _tag: "Success", data: void 0 };
1919
- } catch (e2) {
1920
- return { _tag: "Failure", error: e2 };
2026
+ } catch (e) {
2027
+ return { _tag: "Failure", error: e };
1921
2028
  }
1922
2029
  },
1923
2030
  async updateItemAttributes({ subscriptionId, lineId, customAttributes }) {
@@ -1932,8 +2039,8 @@ function createApiSubscriptionAdapter(fetcher) {
1932
2039
  );
1933
2040
  if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
1934
2041
  return { _tag: "Success", data: void 0 };
1935
- } catch (e2) {
1936
- return { _tag: "Failure", error: e2 };
2042
+ } catch (e) {
2043
+ return { _tag: "Failure", error: e };
1937
2044
  }
1938
2045
  },
1939
2046
  async updateAttributes({ subscriptionId, customAttributes }) {
@@ -1948,8 +2055,8 @@ function createApiSubscriptionAdapter(fetcher) {
1948
2055
  );
1949
2056
  if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
1950
2057
  return { _tag: "Success", data: void 0 };
1951
- } catch (e2) {
1952
- return { _tag: "Failure", error: e2 };
2058
+ } catch (e) {
2059
+ return { _tag: "Failure", error: e };
1953
2060
  }
1954
2061
  },
1955
2062
  async skipLineItem({ subscriptionId, lineId, nextBillingDate }) {
@@ -1964,8 +2071,8 @@ function createApiSubscriptionAdapter(fetcher) {
1964
2071
  );
1965
2072
  if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
1966
2073
  return { _tag: "Success", data: void 0 };
1967
- } catch (e2) {
1968
- return { _tag: "Failure", error: e2 };
2074
+ } catch (e) {
2075
+ return { _tag: "Failure", error: e };
1969
2076
  }
1970
2077
  },
1971
2078
  async updateBoxItems({ subscriptionId, parentId, items, shippingMethodHandle }) {
@@ -1980,8 +2087,8 @@ function createApiSubscriptionAdapter(fetcher) {
1980
2087
  );
1981
2088
  if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
1982
2089
  return { _tag: "Success", data: void 0 };
1983
- } catch (e2) {
1984
- return { _tag: "Failure", error: e2 };
2090
+ } catch (e) {
2091
+ return { _tag: "Failure", error: e };
1985
2092
  }
1986
2093
  },
1987
2094
  async addDiscount({ subscriptionId, code }) {
@@ -2007,10 +2114,10 @@ function createApiSubscriptionAdapter(fetcher) {
2007
2114
  return { _tag: "Failure", error: { kind: "UNKNOWN", message: `HTTP ${res.status}` } };
2008
2115
  }
2009
2116
  return { _tag: "Success", data: void 0 };
2010
- } catch (e2) {
2117
+ } catch (e) {
2011
2118
  return {
2012
2119
  _tag: "Failure",
2013
- error: { kind: "NETWORK", message: e2 instanceof Error ? e2.message : void 0 }
2120
+ error: { kind: "NETWORK", message: e instanceof Error ? e.message : void 0 }
2014
2121
  };
2015
2122
  }
2016
2123
  },
@@ -2032,10 +2139,10 @@ function createApiSubscriptionAdapter(fetcher) {
2032
2139
  return { _tag: "Failure", error: { kind: "UNKNOWN", message: `HTTP ${res.status}` } };
2033
2140
  }
2034
2141
  return { _tag: "Success", data: void 0 };
2035
- } catch (e2) {
2142
+ } catch (e) {
2036
2143
  return {
2037
2144
  _tag: "Failure",
2038
- error: { kind: "NETWORK", message: e2 instanceof Error ? e2.message : void 0 }
2145
+ error: { kind: "NETWORK", message: e instanceof Error ? e.message : void 0 }
2039
2146
  };
2040
2147
  }
2041
2148
  },
@@ -2053,8 +2160,8 @@ function createApiSubscriptionAdapter(fetcher) {
2053
2160
  if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
2054
2161
  const data = await res.json();
2055
2162
  return { _tag: "Success", data: mapSubscription(data) };
2056
- } catch (e2) {
2057
- return { _tag: "Failure", error: e2 };
2163
+ } catch (e) {
2164
+ return { _tag: "Failure", error: e };
2058
2165
  }
2059
2166
  },
2060
2167
  // PATCH /customer/v1/subscriptions/{id} with the full customer-visible set.
@@ -2071,8 +2178,8 @@ function createApiSubscriptionAdapter(fetcher) {
2071
2178
  if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
2072
2179
  const data = await res.json();
2073
2180
  return { _tag: "Success", data: mapSubscription(data) };
2074
- } catch (e2) {
2075
- return { _tag: "Failure", error: e2 };
2181
+ } catch (e) {
2182
+ return { _tag: "Failure", error: e };
2076
2183
  }
2077
2184
  },
2078
2185
  async resume({ subscriptionId }) {
@@ -2084,8 +2191,8 @@ function createApiSubscriptionAdapter(fetcher) {
2084
2191
  if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
2085
2192
  const data = await res.json();
2086
2193
  return { _tag: "Success", data: mapSubscription(data) };
2087
- } catch (e2) {
2088
- return { _tag: "Failure", error: e2 };
2194
+ } catch (e) {
2195
+ return { _tag: "Failure", error: e };
2089
2196
  }
2090
2197
  },
2091
2198
  async pause({ subscriptionId }) {
@@ -2097,8 +2204,8 @@ function createApiSubscriptionAdapter(fetcher) {
2097
2204
  if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
2098
2205
  const data = await res.json();
2099
2206
  return { _tag: "Success", data: mapSubscription(data) };
2100
- } catch (e2) {
2101
- return { _tag: "Failure", error: e2 };
2207
+ } catch (e) {
2208
+ return { _tag: "Failure", error: e };
2102
2209
  }
2103
2210
  },
2104
2211
  async reactivate({ subscriptionId }) {
@@ -2110,8 +2217,8 @@ function createApiSubscriptionAdapter(fetcher) {
2110
2217
  if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
2111
2218
  const data = await res.json();
2112
2219
  return { _tag: "Success", data: mapSubscription(data) };
2113
- } catch (e2) {
2114
- return { _tag: "Failure", error: e2 };
2220
+ } catch (e) {
2221
+ return { _tag: "Failure", error: e };
2115
2222
  }
2116
2223
  },
2117
2224
  async cancel({ subscriptionId, reason }) {
@@ -2127,8 +2234,8 @@ function createApiSubscriptionAdapter(fetcher) {
2127
2234
  if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
2128
2235
  const data = await res.json();
2129
2236
  return { _tag: "Success", data: mapSubscription(data) };
2130
- } catch (e2) {
2131
- return { _tag: "Failure", error: e2 };
2237
+ } catch (e) {
2238
+ return { _tag: "Failure", error: e };
2132
2239
  }
2133
2240
  },
2134
2241
  // Legacy endpoint — no /customer/v1/subscriptions/{id}/plans exists yet.
@@ -2140,8 +2247,8 @@ function createApiSubscriptionAdapter(fetcher) {
2140
2247
  if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
2141
2248
  const data = await res.json();
2142
2249
  return { _tag: "Success", data };
2143
- } catch (e2) {
2144
- return { _tag: "Failure", error: e2 };
2250
+ } catch (e) {
2251
+ return { _tag: "Failure", error: e };
2145
2252
  }
2146
2253
  },
2147
2254
  // Legacy endpoint — no /customer/v1 equivalent exists yet.
@@ -2153,8 +2260,8 @@ function createApiSubscriptionAdapter(fetcher) {
2153
2260
  if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
2154
2261
  const data = await res.json();
2155
2262
  return { _tag: "Success", data: (data == null ? void 0 : data.id) ?? null };
2156
- } catch (e2) {
2157
- return { _tag: "Failure", error: e2 };
2263
+ } catch (e) {
2264
+ return { _tag: "Failure", error: e };
2158
2265
  }
2159
2266
  },
2160
2267
  // Legacy endpoint — no /customer/v1/subscriptions/{id}/upsells exists yet.
@@ -2165,24 +2272,24 @@ function createApiSubscriptionAdapter(fetcher) {
2165
2272
  );
2166
2273
  if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
2167
2274
  const data = await res.json();
2168
- const products = data.map((p2) => {
2275
+ const products = data.map((p3) => {
2169
2276
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
2170
2277
  return {
2171
- id: p2.id,
2172
- variantId: ((_b = (_a = p2.variants) == null ? void 0 : _a[0]) == null ? void 0 : _b.id) ?? "",
2173
- title: p2.title ?? "",
2174
- imageUrl: ((_c = p2.featuredImage) == null ? void 0 : _c.url) ?? void 0,
2278
+ id: p3.id,
2279
+ variantId: ((_b = (_a = p3.variants) == null ? void 0 : _a[0]) == null ? void 0 : _b.id) ?? "",
2280
+ title: p3.title ?? "",
2281
+ imageUrl: ((_c = p3.featuredImage) == null ? void 0 : _c.url) ?? void 0,
2175
2282
  price: {
2176
- amount: String(((_f = (_e = (_d = p2.variants) == null ? void 0 : _d[0]) == null ? void 0 : _e.currentPrice) == null ? void 0 : _f.amount) ?? 0),
2177
- currencyCode: ((_i = (_h = (_g = p2.variants) == null ? void 0 : _g[0]) == null ? void 0 : _h.currentPrice) == null ? void 0 : _i.currencyCode) ?? ""
2283
+ amount: String(((_f = (_e = (_d = p3.variants) == null ? void 0 : _d[0]) == null ? void 0 : _e.currentPrice) == null ? void 0 : _f.amount) ?? 0),
2284
+ currencyCode: ((_i = (_h = (_g = p3.variants) == null ? void 0 : _g[0]) == null ? void 0 : _h.currentPrice) == null ? void 0 : _i.currencyCode) ?? ""
2178
2285
  },
2179
2286
  // recurring comes from the upsell rule on variants[0]; present in PreparedProductSchema
2180
- recurring: (_k = (_j = p2.variants) == null ? void 0 : _j[0]) == null ? void 0 : _k.recurring
2287
+ recurring: (_k = (_j = p3.variants) == null ? void 0 : _j[0]) == null ? void 0 : _k.recurring
2181
2288
  };
2182
2289
  });
2183
2290
  return { _tag: "Success", data: products };
2184
- } catch (e2) {
2185
- return { _tag: "Failure", error: e2 };
2291
+ } catch (e) {
2292
+ return { _tag: "Failure", error: e };
2186
2293
  }
2187
2294
  },
2188
2295
  // Legacy endpoint — no /customer/v1/subscriptions/{id}/upsells POST exists yet.
@@ -2202,8 +2309,8 @@ function createApiSubscriptionAdapter(fetcher) {
2202
2309
  );
2203
2310
  if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
2204
2311
  return { _tag: "Success", data: void 0 };
2205
- } catch (e2) {
2206
- return { _tag: "Failure", error: e2 };
2312
+ } catch (e) {
2313
+ return { _tag: "Failure", error: e };
2207
2314
  }
2208
2315
  },
2209
2316
  // Legacy endpoint — no /customer/v1 equivalent exists yet.
@@ -2219,8 +2326,8 @@ function createApiSubscriptionAdapter(fetcher) {
2219
2326
  _tag: "Success",
2220
2327
  data: { id: data.id, createdAt: data.createdAt }
2221
2328
  };
2222
- } catch (e2) {
2223
- return { _tag: "Failure", error: e2 };
2329
+ } catch (e) {
2330
+ return { _tag: "Failure", error: e };
2224
2331
  }
2225
2332
  },
2226
2333
  // Legacy endpoints, split by stage (see SubscriptionService.renewNow docs):
@@ -2240,8 +2347,8 @@ function createApiSubscriptionAdapter(fetcher) {
2240
2347
  result: (body == null ? void 0 : body.result) ?? "success"
2241
2348
  }
2242
2349
  };
2243
- } catch (e2) {
2244
- return { _tag: "Failure", error: e2 };
2350
+ } catch (e) {
2351
+ return { _tag: "Failure", error: e };
2245
2352
  }
2246
2353
  },
2247
2354
  // Legacy endpoint — POST /plan returns 204; re-fetch to return the updated subscription.
@@ -2263,8 +2370,8 @@ function createApiSubscriptionAdapter(fetcher) {
2263
2370
  _tag: "Failure",
2264
2371
  error: "Subscription not found after frequency change"
2265
2372
  };
2266
- } catch (e2) {
2267
- return { _tag: "Failure", error: e2 };
2373
+ } catch (e) {
2374
+ return { _tag: "Failure", error: e };
2268
2375
  }
2269
2376
  }
2270
2377
  };
@@ -2325,13 +2432,13 @@ function mapScheduleOrder(order) {
2325
2432
  };
2326
2433
  }),
2327
2434
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2328
- discounts: (order.discounts ?? []).map((d3) => {
2435
+ discounts: (order.discounts ?? []).map((d2) => {
2329
2436
  var _a, _b, _c;
2330
2437
  return {
2331
- id: d3.id,
2332
- title: d3.title ?? void 0,
2333
- type: ((_a = d3.value) == null ? void 0 : _a.type) === "fixed-amount" ? "fixed_amount" : "percentage",
2334
- value: ((_b = d3.value) == null ? void 0 : _b.amount) ?? ((_c = d3.value) == null ? void 0 : _c.percentage) ?? 0
2438
+ id: d2.id,
2439
+ title: d2.title ?? void 0,
2440
+ type: ((_a = d2.value) == null ? void 0 : _a.type) === "fixed-amount" ? "fixed_amount" : "percentage",
2441
+ value: ((_b = d2.value) == null ? void 0 : _b.amount) ?? ((_c = d2.value) == null ? void 0 : _c.percentage) ?? 0
2335
2442
  };
2336
2443
  })
2337
2444
  };
@@ -2370,26 +2477,26 @@ function buildSkipItemMatcher(params) {
2370
2477
  const DELIVERY_PRICE = 5;
2371
2478
  const DELIVERY_OFFSET_DAYS = 2;
2372
2479
  function toPrice(amount) {
2373
- const n = Number.parseFloat(amount ?? "0");
2374
- return Number.isFinite(n) ? n : 0;
2480
+ const n2 = Number.parseFloat(amount ?? "0");
2481
+ return Number.isFinite(n2) ? n2 : 0;
2375
2482
  }
2376
2483
  function addInterval(date, interval, units) {
2377
- const d3 = new Date(date);
2484
+ const d2 = new Date(date);
2378
2485
  switch (interval) {
2379
2486
  case "DAY":
2380
- d3.setDate(d3.getDate() + units);
2487
+ d2.setDate(d2.getDate() + units);
2381
2488
  break;
2382
2489
  case "WEEK":
2383
- d3.setDate(d3.getDate() + units * 7);
2490
+ d2.setDate(d2.getDate() + units * 7);
2384
2491
  break;
2385
2492
  case "YEAR":
2386
- d3.setFullYear(d3.getFullYear() + units);
2493
+ d2.setFullYear(d2.getFullYear() + units);
2387
2494
  break;
2388
2495
  default:
2389
- d3.setMonth(d3.getMonth() + units);
2496
+ d2.setMonth(d2.getMonth() + units);
2390
2497
  break;
2391
2498
  }
2392
- return d3;
2499
+ return d2;
2393
2500
  }
2394
2501
  function mapItem(sub, item, cycle) {
2395
2502
  var _a, _b;
@@ -2447,11 +2554,11 @@ function projectUpcomingOrders(sub, count) {
2447
2554
  deliveryDate: deliveryDate.toISOString(),
2448
2555
  status: "scheduled",
2449
2556
  items,
2450
- discounts: sub.discounts.map((d3) => ({
2451
- id: d3.id,
2452
- title: d3.code,
2453
- type: d3.type,
2454
- value: d3.value
2557
+ discounts: sub.discounts.map((d2) => ({
2558
+ id: d2.id,
2559
+ title: d2.code,
2560
+ type: d2.type,
2561
+ value: d2.value
2455
2562
  }))
2456
2563
  });
2457
2564
  }
@@ -2479,7 +2586,7 @@ function applyAdjustments(orders, stored) {
2479
2586
  );
2480
2587
  const subtotal = items.reduce((sum, it) => sum + it.totalPrice, 0);
2481
2588
  next = { ...next, items, subtotal };
2482
- if (items.length > 0 && items.every((i2) => i2.skipped)) {
2589
+ if (items.length > 0 && items.every((i3) => i3.skipped)) {
2483
2590
  next = { ...next, skipped: true, status: "skipped", deliveryPrice: 0 };
2484
2591
  }
2485
2592
  }
@@ -2514,11 +2621,11 @@ function createMockSchedulesAdapter(subscriptions = createMockSubscriptionAdapte
2514
2621
  const iso = toIsoOrNull(opts.date);
2515
2622
  const target = iso == null ? void 0 : iso.split("T")[0];
2516
2623
  const match = target ? orders.find(
2517
- (o2) => o2.deliveryDate.split("T")[0] === target || o2.date.split("T")[0] === target
2624
+ (o3) => o3.deliveryDate.split("T")[0] === target || o3.date.split("T")[0] === target
2518
2625
  ) : void 0;
2519
2626
  return match ? match.cycleIndex : null;
2520
2627
  }
2521
- const firstScheduled = orders.find((o2) => o2.status === "scheduled");
2628
+ const firstScheduled = orders.find((o3) => o3.status === "scheduled");
2522
2629
  return (firstScheduled == null ? void 0 : firstScheduled.cycleIndex) ?? null;
2523
2630
  }
2524
2631
  async function recordAdjustment(subscriptionId, opts, buildAction, matcherOverride) {
@@ -2551,25 +2658,25 @@ function createMockSchedulesAdapter(subscriptions = createMockSubscriptionAdapte
2551
2658
  const subs = await subscriptionsToProject(subscriptionId);
2552
2659
  const skipCount = new Set(
2553
2660
  stored.filter(
2554
- (s) => s.adjustment.action.type === "SKIP_ORDER" || s.adjustment.action.type === "SKIP_ITEM"
2555
- ).map((s) => `${s.subscriptionId}:${s.cycle}`)
2661
+ (s2) => s2.adjustment.action.type === "SKIP_ORDER" || s2.adjustment.action.type === "SKIP_ITEM"
2662
+ ).map((s2) => `${s2.subscriptionId}:${s2.cycle}`)
2556
2663
  ).size;
2557
2664
  const depth = excludeSkipped ? count + skipCount : count;
2558
2665
  const orders = subs.flatMap(
2559
2666
  (sub) => applyAdjustments(projectUpcomingOrders(sub, depth), stored)
2560
- ).filter((o2) => excludeSkipped ? !o2.skipped : true).map(
2561
- (o2) => (
2667
+ ).filter((o3) => excludeSkipped ? !o3.skipped : true).map(
2668
+ (o3) => (
2562
2669
  // Mirror backend removeSkippedItems: the billable view also strips
2563
2670
  // skipped lines from surviving (partially-skipped) orders. No
2564
2671
  // recompute needed — skipped lines already carry totalPrice 0 (R4).
2565
- excludeSkipped && o2.items.some((i2) => i2.skipped) ? { ...o2, items: o2.items.filter((i2) => !i2.skipped) } : o2
2672
+ excludeSkipped && o3.items.some((i3) => i3.skipped) ? { ...o3, items: o3.items.filter((i3) => !i3.skipped) } : o3
2566
2673
  )
2567
- ).sort((a8, b2) => a8.date.localeCompare(b2.date));
2674
+ ).sort((a2, b3) => a2.date.localeCompare(b3.date));
2568
2675
  return { _tag: "Success", data: orders.slice(0, count) };
2569
2676
  },
2570
2677
  async getAdjustments() {
2571
2678
  await new Promise((r2) => setTimeout(r2, 200));
2572
- return { _tag: "Success", data: stored.map((s) => s.adjustment) };
2679
+ return { _tag: "Success", data: stored.map((s2) => s2.adjustment) };
2573
2680
  },
2574
2681
  async skipOrder({ subscriptionId, cycle, date }) {
2575
2682
  await new Promise((r2) => setTimeout(r2, 300));
@@ -2642,7 +2749,7 @@ function createMockSchedulesAdapter(subscriptions = createMockSubscriptionAdapte
2642
2749
  },
2643
2750
  async removeAdjustment({ adjustmentId }) {
2644
2751
  await new Promise((r2) => setTimeout(r2, 200));
2645
- stored = stored.filter((s) => s.adjustment.id !== adjustmentId);
2752
+ stored = stored.filter((s2) => s2.adjustment.id !== adjustmentId);
2646
2753
  return { _tag: "Success", data: void 0 };
2647
2754
  }
2648
2755
  };
@@ -2657,8 +2764,8 @@ function createApiSchedulesAdapter(fetcher) {
2657
2764
  });
2658
2765
  if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
2659
2766
  return { _tag: "Success", data: void 0 };
2660
- } catch (e2) {
2661
- return { _tag: "Failure", error: e2 };
2767
+ } catch (e) {
2768
+ return { _tag: "Failure", error: e };
2662
2769
  }
2663
2770
  }
2664
2771
  return {
@@ -2671,8 +2778,8 @@ function createApiSchedulesAdapter(fetcher) {
2671
2778
  if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
2672
2779
  const data = await res.json();
2673
2780
  return { _tag: "Success", data: (data.orders ?? []).map(mapScheduleOrder) };
2674
- } catch (e2) {
2675
- return { _tag: "Failure", error: e2 };
2781
+ } catch (e) {
2782
+ return { _tag: "Failure", error: e };
2676
2783
  }
2677
2784
  },
2678
2785
  async getAdjustments() {
@@ -2688,10 +2795,10 @@ function createApiSchedulesAdapter(fetcher) {
2688
2795
  if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
2689
2796
  const body = await res.json();
2690
2797
  all.push(
2691
- ...body.data.map((a8) => ({
2692
- id: a8.id,
2693
- matcher: a8.matcher,
2694
- action: a8.action
2798
+ ...body.data.map((a2) => ({
2799
+ id: a2.id,
2800
+ matcher: a2.matcher,
2801
+ action: a2.action
2695
2802
  }))
2696
2803
  );
2697
2804
  if (!body.hasNextPage) return { _tag: "Success", data: all };
@@ -2707,8 +2814,8 @@ function createApiSchedulesAdapter(fetcher) {
2707
2814
  _tag: "Failure",
2708
2815
  error: "Adjustments pagination exceeded 50 pages"
2709
2816
  };
2710
- } catch (e2) {
2711
- return { _tag: "Failure", error: e2 };
2817
+ } catch (e) {
2818
+ return { _tag: "Failure", error: e };
2712
2819
  }
2713
2820
  },
2714
2821
  async skipOrder({ cycle, date }) {
@@ -2784,16 +2891,16 @@ function createApiSchedulesAdapter(fetcher) {
2784
2891
  );
2785
2892
  if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
2786
2893
  return { _tag: "Success", data: void 0 };
2787
- } catch (e2) {
2788
- return { _tag: "Failure", error: e2 };
2894
+ } catch (e) {
2895
+ return { _tag: "Failure", error: e };
2789
2896
  }
2790
2897
  }
2791
2898
  };
2792
2899
  }
2793
2900
  const SchedulesServiceContext = createContext("services/schedules");
2794
- function isSameCalendarDay(a8, b2) {
2795
- const da = new Date(a8);
2796
- const db = new Date(b2);
2901
+ function isSameCalendarDay(a2, b3) {
2902
+ const da = new Date(a2);
2903
+ const db = new Date(b3);
2797
2904
  if (Number.isNaN(da.getTime()) || Number.isNaN(db.getTime())) return false;
2798
2905
  return da.toISOString().slice(0, 10) === db.toISOString().slice(0, 10);
2799
2906
  }
@@ -2873,26 +2980,26 @@ function createSchedulesService(adapter, opts) {
2873
2980
  const adjustments = await adapter.getAdjustments();
2874
2981
  if (adjustments._tag === "Failure") return adjustments;
2875
2982
  const covering = adjustments.data.filter(
2876
- (a8) => a8.action.type === "SKIP_ITEM" && a8.action.input.lineIds.includes(lineId) && matcherAffects(a8.matcher, { cycle, date })
2983
+ (a2) => a2.action.type === "SKIP_ITEM" && a2.action.input.lineIds.includes(lineId) && matcherAffects(a2.matcher, { cycle, date })
2877
2984
  );
2878
2985
  if (covering.length === 0) {
2879
2986
  return { _tag: "Failure", error: "No skip found for this item" };
2880
2987
  }
2881
- if (covering.some((a8) => a8.action.input.lineIds.length > 1)) {
2988
+ if (covering.some((a2) => a2.action.input.lineIds.length > 1)) {
2882
2989
  return {
2883
2990
  _tag: "Failure",
2884
2991
  error: "This item was skipped together with other items and can't be unskipped individually"
2885
2992
  };
2886
2993
  }
2887
- if (covering.some((a8) => !matcherExactlyTargets(a8.matcher, { cycle, date }))) {
2994
+ if (covering.some((a2) => !matcherExactlyTargets(a2.matcher, { cycle, date }))) {
2888
2995
  return {
2889
2996
  _tag: "Failure",
2890
2997
  error: "This skip also affects another order and can't be removed from here"
2891
2998
  };
2892
2999
  }
2893
3000
  let deleted = 0;
2894
- for (const a8 of covering) {
2895
- const result = await adapter.removeAdjustment({ adjustmentId: a8.id });
3001
+ for (const a2 of covering) {
3002
+ const result = await adapter.removeAdjustment({ adjustmentId: a2.id });
2896
3003
  if (result._tag === "Failure") {
2897
3004
  if (deleted > 0) await notifyChanged(subscriptionId);
2898
3005
  return result;
@@ -3127,7 +3234,7 @@ function createSubscriptionService(adapter) {
3127
3234
  function getDefaultBlockForAction(actionType, actionConfig, blockId) {
3128
3235
  const blockName = `action:${actionType}`;
3129
3236
  const definedBlocks = getDefinedBlocks();
3130
- const exists = definedBlocks.some((b2) => b2.name === blockName);
3237
+ const exists = definedBlocks.some((b3) => b3.name === blockName);
3131
3238
  if (!exists) {
3132
3239
  throw new Error(
3133
3240
  `No default block registered for action type "${actionType}". Expected a block named "${blockName}" to be registered in blocks-extensions.`
@@ -3137,7 +3244,7 @@ function getDefaultBlockForAction(actionType, actionConfig, blockId) {
3137
3244
  }
3138
3245
  function hasDefaultBlockForAction(actionType) {
3139
3246
  const blockName = `action:${actionType}`;
3140
- return getDefinedBlocks().some((b2) => b2.name === blockName);
3247
+ return getDefinedBlocks().some((b3) => b3.name === blockName);
3141
3248
  }
3142
3249
  const WorkflowServiceContext = createContext("services/workflow");
3143
3250
  const RUN_SCOPED_RESET = {
@@ -3275,7 +3382,7 @@ function createWorkflowService(deps) {
3275
3382
  outcome: null
3276
3383
  });
3277
3384
  if (editor.isEditorMode) {
3278
- const displayStepId = isInitialResponse && previewStepId && ((_e = data.interactiveSteps) == null ? void 0 : _e.some((s) => s.stepId === previewStepId)) ? previewStepId : currentStepId;
3385
+ const displayStepId = isInitialResponse && previewStepId && ((_e = data.interactiveSteps) == null ? void 0 : _e.some((s2) => s2.stepId === previewStepId)) ? previewStepId : currentStepId;
3279
3386
  const overlayBlocks = deps.themeState.overlay.blocks.value;
3280
3387
  const rootBlock = overlayBlocks[0];
3281
3388
  const stepSlot = displayStepId ? (_f = rootBlock == null ? void 0 : rootBlock.slots) == null ? void 0 : _f[displayStepId] : null;
@@ -3370,7 +3477,7 @@ function createWorkflowService(deps) {
3370
3477
  const presets = {};
3371
3478
  const baseLabelFor = (step) => {
3372
3479
  var _a;
3373
- return ((_a = getDefinedBlocks().find((b2) => b2.name === `action:${step.actionType}`)) == null ? void 0 : _a.displayName) ?? step.stepId;
3480
+ return ((_a = getDefinedBlocks().find((b3) => b3.name === `action:${step.actionType}`)) == null ? void 0 : _a.displayName) ?? step.stepId;
3374
3481
  };
3375
3482
  const totalCounts = /* @__PURE__ */ new Map();
3376
3483
  for (const step of allSteps) {
@@ -3965,9 +4072,9 @@ const gridV1Engine = {
3965
4072
  case "resize": {
3966
4073
  const current = layout.items[cmd.blockId];
3967
4074
  if (current) {
3968
- const w3 = Math.max(1, Math.min(cmd.size.w, ctx2.cols - current.c));
3969
- const h = Math.max(1, cmd.size.h);
3970
- layout.items[cmd.blockId] = { ...current, w: w3, h };
4075
+ const w4 = Math.max(1, Math.min(cmd.size.w, ctx2.cols - current.c));
4076
+ const h2 = Math.max(1, cmd.size.h);
4077
+ layout.items[cmd.blockId] = { ...current, w: w4, h: h2 };
3971
4078
  }
3972
4079
  break;
3973
4080
  }
@@ -4034,7 +4141,7 @@ function insertRectRelative(doc, args) {
4034
4141
  if (!layout) continue;
4035
4142
  const target = layout.items[args.targetId];
4036
4143
  if (!target) continue;
4037
- const cols = ((_a = doc.breakpoints.find((b2) => b2.id === breakpointId)) == null ? void 0 : _a.cols) ?? ((_b = layout.grid) == null ? void 0 : _b.cols) ?? DEFAULT_GRID.cols;
4144
+ const cols = ((_a = doc.breakpoints.find((b3) => b3.id === breakpointId)) == null ? void 0 : _a.cols) ?? ((_b = layout.grid) == null ? void 0 : _b.cols) ?? DEFAULT_GRID.cols;
4038
4145
  const insertRow = args.position === "before" ? target.r : target.r + target.h;
4039
4146
  for (const [id, rect] of Object.entries(layout.items)) {
4040
4147
  if (id === args.blockId) continue;
@@ -4085,18 +4192,19 @@ export {
4085
4192
  AuthenticationError,
4086
4193
  AuthenticationErrorReason,
4087
4194
  B as BlockWrapperEvent,
4088
- v as ContextProvideEvent,
4089
- x as ContextRequestEvent,
4195
+ q as ContextProvideEvent,
4196
+ t as ContextRequestEvent,
4090
4197
  CustomerServiceContext,
4091
- y as DEFAULT_BREAKPOINTS,
4092
- z as DEFAULT_GLOBAL_STYLES,
4198
+ h as DEFAULT_BREAKPOINTS,
4199
+ i2 as DEFAULT_GLOBAL_STYLES,
4093
4200
  DEFAULT_GRID,
4094
4201
  DEFAULT_NEW_BLOCK_HEIGHT,
4095
4202
  DISCOUNT_REJECTION_REASONS,
4096
4203
  GRID_V1_ENGINE_ID,
4097
- L as LAYOUT_SCOPE_ATTR,
4204
+ L2 as LAYOUT_SCOPE_ATTR,
4098
4205
  LoginServiceContext,
4099
- OrdersServiceContext,
4206
+ OrderServiceContext,
4207
+ OverlayServiceContext,
4100
4208
  P as PAGE_ROOT_SLOT,
4101
4209
  ProductServiceContext,
4102
4210
  RouterServiceContext,
@@ -4107,99 +4215,105 @@ export {
4107
4215
  u as Signal,
4108
4216
  StateContext,
4109
4217
  SubscriptionServiceContext,
4110
- c as ThemeStateContext,
4218
+ a as ThemeStateContext,
4111
4219
  T as TranslationContext,
4112
4220
  WorkflowServiceContext,
4113
- A as attachEmptyTracking,
4114
- d2 as backfillInstanceDefaults,
4115
- b as buildGridLayout,
4116
- F as buildLayoutCss,
4221
+ v as __recordDevtoolsInstance,
4222
+ _ as __recordDevtoolsPropSetter,
4223
+ x as attachEmptyTracking,
4224
+ c as backfillInstanceDefaults,
4225
+ b2 as buildGridLayout,
4226
+ j as buildLayoutCss,
4117
4227
  canvasMode,
4118
4228
  clampRect,
4119
- H as classifyRowDividers,
4229
+ k2 as classifyRowDividers,
4120
4230
  clearAllSurfaceContexts,
4121
4231
  clearLayoutModeAdapter,
4122
4232
  compactItems,
4123
- I as compactLayoutDocument,
4233
+ l2 as compactLayoutDocument,
4124
4234
  w as computed,
4125
4235
  createApiCustomerAdapter,
4126
4236
  createApiLoginAdapter,
4127
- createApiOrdersAdapter,
4237
+ createApiOrderAdapter,
4128
4238
  createApiProductAdapter,
4129
4239
  createApiSchedulesAdapter,
4130
4240
  createApiSubscriptionAdapter,
4131
4241
  createBlockInstance,
4132
- J as createBlockInstanceFromJSON,
4133
- K as createBlockInstanceFromObject,
4134
- N as createCeRenderer,
4242
+ y as createBlockInstanceFromJSON,
4243
+ g as createBlockInstanceFromObject,
4244
+ z as createCeRenderer,
4135
4245
  createContext,
4136
4246
  createCustomerService,
4137
- O as createDefaultLayoutDocument,
4247
+ m as createDefaultLayoutDocument,
4138
4248
  createLoginService,
4139
4249
  createMockCustomerAdapter,
4140
4250
  createMockLoginAdapter,
4141
- createMockOrdersAdapter,
4251
+ createMockOrderAdapter,
4142
4252
  createMockProductAdapter,
4143
4253
  createMockRouterService,
4144
4254
  createMockSchedulesAdapter,
4145
4255
  createMockSubscriptionAdapter,
4146
4256
  createMockWorkflowApiAdapter,
4147
- createOrdersService,
4257
+ createOrderService,
4258
+ createOverlayService,
4148
4259
  createProductService,
4149
4260
  createRouterService,
4150
4261
  createSchedulesService,
4151
- Q as createSelectedBlock,
4262
+ A as createSelectedBlock,
4152
4263
  createSettingsService,
4153
4264
  createShopService,
4154
4265
  createState,
4155
4266
  createSubscriptionService,
4156
- R as createThemeState,
4157
- U as createTranslationService,
4267
+ n as createThemeState,
4268
+ o2 as createTranslationService,
4158
4269
  createWorkflowApiAdapter,
4159
4270
  createWorkflowService,
4160
4271
  defineBlock,
4161
- V as defineBlockRuntime,
4162
- W as deriveLayout,
4272
+ D as defineBlockRuntime,
4273
+ defineOverlayWrapper,
4274
+ p as deriveLayout,
4163
4275
  E as effect,
4164
4276
  emitLayoutCommand,
4165
4277
  emitLayoutSetRects,
4166
- X as expandFillLayoutDocument,
4278
+ q2 as expandFillLayoutDocument,
4167
4279
  findFreeRect,
4168
4280
  getActiveSurfaceContext,
4169
4281
  getDefaultBlockForAction,
4170
4282
  getDefinedBlocks,
4283
+ F as getDevtoolsBlockState,
4171
4284
  getLayoutModeAdapter,
4172
4285
  gridV1Engine,
4173
4286
  hasDefaultBlockForAction,
4174
- Y as hasRenderedContent,
4175
- Z as indexOverrides,
4287
+ G as hasRenderedContent,
4288
+ s as indexOverrides,
4176
4289
  i as injectContext,
4177
4290
  insertRectRelative,
4178
- _ as isEditorPreview,
4179
- a as isStubDefinition,
4180
- $ as layoutScopeSelector,
4181
- a0 as layoutSystemEnabled,
4291
+ H as isEditorPreview,
4292
+ b as isStubDefinition,
4293
+ t2 as layoutScopeSelector,
4294
+ I as layoutSystemEnabled,
4182
4295
  loadBlockRegistry,
4183
4296
  loginService,
4184
4297
  o as onRegisterBlock,
4185
- a1 as projectToCss,
4186
- p as projectToGridStack,
4187
- a2 as provideContext,
4188
- a3 as readingOrder,
4189
- e as reconcileLayout,
4190
- a4 as rectsOverlap,
4298
+ u2 as projectToCss,
4299
+ p2 as projectToGridStack,
4300
+ J as provideContext,
4301
+ v2 as readingOrder,
4302
+ c2 as reconcileLayout,
4303
+ w3 as rectsOverlap,
4191
4304
  registerBlock,
4192
4305
  registerLayoutModeAdapter,
4193
4306
  resetBreakpoint,
4194
4307
  r as resolveLayout,
4195
- a5 as serializeBlocks,
4308
+ k as serializeBlocks,
4196
4309
  setActiveSurfaceContext,
4310
+ K as setDevtoolsBlockProp,
4197
4311
  setLayoutCommandDispatcher,
4198
4312
  setLayoutCommandEmitter,
4199
- a6 as setLayoutSystemEnabled,
4313
+ l as setLayoutSystemEnabled,
4200
4314
  d as signal,
4201
4315
  subscribeContext,
4202
- a7 as untracked,
4316
+ L as untracked,
4203
4317
  waitForDevBlocksUrl,
4204
4318
  w2 as withWrapper
4205
4319
  };