@rebuy/rebuy 2.1.0 → 2.2.0-rc.2

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 (51) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +628 -1
  4. package/dist/index.js.map +4 -4
  5. package/dist/index.mjs +628 -1
  6. package/dist/index.mjs.map +4 -4
  7. package/dist/schema/button.d.ts +271 -0
  8. package/dist/schema/button.d.ts.map +1 -0
  9. package/dist/schema/common.d.ts +369 -0
  10. package/dist/schema/common.d.ts.map +1 -0
  11. package/dist/schema/constants.d.ts +165 -0
  12. package/dist/schema/constants.d.ts.map +1 -0
  13. package/dist/schema/data-source.d.ts +11 -0
  14. package/dist/schema/data-source.d.ts.map +1 -0
  15. package/dist/schema/image.d.ts +63 -0
  16. package/dist/schema/image.d.ts.map +1 -0
  17. package/dist/schema/index.d.ts +20 -0
  18. package/dist/schema/index.d.ts.map +1 -0
  19. package/dist/schema/index.js +652 -0
  20. package/dist/schema/index.js.map +7 -0
  21. package/dist/schema/index.mjs +629 -0
  22. package/dist/schema/index.mjs.map +7 -0
  23. package/dist/schema/layout.d.ts +78 -0
  24. package/dist/schema/layout.d.ts.map +1 -0
  25. package/dist/schema/offers.d.ts +67 -0
  26. package/dist/schema/offers.d.ts.map +1 -0
  27. package/dist/schema/product.d.ts +147 -0
  28. package/dist/schema/product.d.ts.map +1 -0
  29. package/dist/schema/products.d.ts +150 -0
  30. package/dist/schema/products.d.ts.map +1 -0
  31. package/dist/schema/quantity.d.ts +19 -0
  32. package/dist/schema/quantity.d.ts.map +1 -0
  33. package/dist/schema/regex.d.ts +7 -0
  34. package/dist/schema/regex.d.ts.map +1 -0
  35. package/dist/schema/reviews.d.ts +8 -0
  36. package/dist/schema/reviews.d.ts.map +1 -0
  37. package/dist/schema/root.d.ts +127 -0
  38. package/dist/schema/root.d.ts.map +1 -0
  39. package/dist/schema/shared.d.ts +38 -0
  40. package/dist/schema/shared.d.ts.map +1 -0
  41. package/dist/schema/subscription.d.ts +8 -0
  42. package/dist/schema/subscription.d.ts.map +1 -0
  43. package/dist/schema/table.d.ts +8 -0
  44. package/dist/schema/table.d.ts.map +1 -0
  45. package/dist/schema/text.d.ts +160 -0
  46. package/dist/schema/text.d.ts.map +1 -0
  47. package/dist/schema/utils.d.ts +8 -0
  48. package/dist/schema/utils.d.ts.map +1 -0
  49. package/dist/schema/variants.d.ts +15 -0
  50. package/dist/schema/variants.d.ts.map +1 -0
  51. package/package.json +12 -1
@@ -0,0 +1,629 @@
1
+ // src/schema/button.ts
2
+ import { v7 as uuidv712 } from "uuid";
3
+ import { z as z16 } from "zod";
4
+
5
+ // src/schema/common.ts
6
+ import { z } from "zod";
7
+ var borderRadii = ["none", "small", "base", "large", "fullyRounded"];
8
+ var borderRadius = z.enum(borderRadii);
9
+ var BorderRadius = borderRadius.enum;
10
+ var borderStyles = ["none", "base", "dotted", "dashed"];
11
+ var borderStyle = z.enum(borderStyles);
12
+ var BorderStyle = borderStyle.enum;
13
+ var borderWidths = ["base", "medium", "thick"];
14
+ var borderWidth = z.enum(borderWidths);
15
+ var BorderWidth = borderWidth.enum;
16
+ var buttonActions = [
17
+ "addToOrder",
18
+ "declineAllOffers",
19
+ "declineOffer",
20
+ "goToRebuyApp",
21
+ "goToRebuyVault",
22
+ "goToURL",
23
+ "removeFromCart",
24
+ "showVariants",
25
+ "switchToSubscription"
26
+ ];
27
+ var buttonAction = z.enum(buttonActions);
28
+ var ButtonAction = buttonAction.enum;
29
+ var buttonFields = [
30
+ "addedToCart",
31
+ "addingToCart",
32
+ "addToCart",
33
+ "buttonLabel",
34
+ "declineAllOffers",
35
+ "declineOffer",
36
+ "destinationUrl",
37
+ "payNow",
38
+ "removeFromCart",
39
+ "showVariant",
40
+ "showVariants",
41
+ "soldOut",
42
+ "switchToOneTimeAction",
43
+ "switchToOneTimePurchase",
44
+ "switchToSubscriptionAction",
45
+ "switchToSubscriptionNoDiscount",
46
+ "switchToSubscriptionWithDiscount"
47
+ ];
48
+ var buttonField = z.enum(buttonFields);
49
+ var ButtonField = buttonField.enum;
50
+ var buttonStyles = ["primary", "secondary", "plain", "custom"];
51
+ var buttonStyle = z.enum(buttonStyles);
52
+ var ButtonStyle = buttonStyle.enum;
53
+ var directions = ["columns", "rows"];
54
+ var direction = z.enum(directions);
55
+ var Direction = direction.enum;
56
+ var editorModes = [
57
+ "checkoutExtension",
58
+ "postPurchaseOffer",
59
+ "thankYouPage",
60
+ "orderStatusPage",
61
+ "ordersIndexPage",
62
+ "customerProfilePage"
63
+ ];
64
+ var editorMode = z.enum(editorModes);
65
+ var EditorMode = editorMode.enum;
66
+ var horizontalAlignments = ["start", "center", "end"];
67
+ var horizontalAlignment = z.enum(horizontalAlignments);
68
+ var HorizontalAlignment = horizontalAlignment.enum;
69
+ var languageKeys = [
70
+ "ar",
71
+ "cs",
72
+ "da",
73
+ "de",
74
+ "en",
75
+ "es",
76
+ "fi",
77
+ "fr",
78
+ "ga",
79
+ "he",
80
+ "hi",
81
+ "id",
82
+ "it",
83
+ "ja",
84
+ "ko",
85
+ "nl",
86
+ "no",
87
+ "pl",
88
+ "pt",
89
+ "ru",
90
+ "sv",
91
+ "th",
92
+ "tr",
93
+ "uk",
94
+ "vi",
95
+ "zh"
96
+ ];
97
+ var languageKey = z.enum(languageKeys);
98
+ var LanguageKey = languageKey.enum;
99
+ var objectFits = ["cover", "contain"];
100
+ var objectFit = z.enum(objectFits);
101
+ var ObjectFit = objectFit.enum;
102
+ var quantityInputs = ["select", "number"];
103
+ var quantityInput = z.enum(quantityInputs);
104
+ var QuantityInput = quantityInput.enum;
105
+ var sectionTypes = [
106
+ "button",
107
+ "dataSource",
108
+ "image",
109
+ "layout",
110
+ "offers",
111
+ "product",
112
+ "products",
113
+ "quantity",
114
+ "reviews",
115
+ "subscription",
116
+ "table",
117
+ "text",
118
+ "variants"
119
+ ];
120
+ var sectionType = z.enum(sectionTypes);
121
+ var SectionType = sectionType.enum;
122
+ var spacings = ["none", "extraTight", "tight", "base", "loose", "extraLoose"];
123
+ var spacing = z.enum(spacings);
124
+ var Spacing = spacing.enum;
125
+ var textAlignments = ["start", "center", "end"];
126
+ var textAlignment = z.enum(textAlignments);
127
+ var TextAlignment = textAlignment.enum;
128
+ var textColorNames = ["base", "subdued", "accent", "decorative", "success", "warning", "critical"];
129
+ var textColorName = z.enum(textColorNames);
130
+ var TextColorName = textColorName.enum;
131
+ var textSizeNames = ["extraSmall", "small", "base", "medium", "large", "extraLarge"];
132
+ var textSizeName = z.enum(textSizeNames);
133
+ var TextSizeName = textSizeName.enum;
134
+ var variantSelectors = ["menu", "button", "radio", "color", "image"];
135
+ var variantSelector = z.enum(variantSelectors);
136
+ var VariantSelector = variantSelector.enum;
137
+ var verticalAlignments = ["top", "middle", "bottom"];
138
+ var verticalAlignment = z.enum(verticalAlignments);
139
+ var VerticalAlignment = verticalAlignment.enum;
140
+
141
+ // src/schema/image.ts
142
+ import { v7 as uuidv711 } from "uuid";
143
+ import { z as z15 } from "zod";
144
+
145
+ // src/schema/regex.ts
146
+ var DYNAMIC_TOKEN_REGEX = /^\{\{\s*[A-Za-z]+\s*\}\}$/;
147
+ var HEX_COLOR_REGEX = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
148
+ var HTML_TAGS_REGEX = /<[^>]*>/gi;
149
+
150
+ // src/schema/shared.ts
151
+ import { z as z14 } from "zod";
152
+
153
+ // src/schema/data-source.ts
154
+ import { v7 as uuidv7 } from "uuid";
155
+ import { z as z3 } from "zod";
156
+
157
+ // src/schema/constants.ts
158
+ import { uniqBy } from "lodash-es";
159
+ import { z as z2 } from "zod";
160
+ var DEFAULT_ENDPOINTS = [
161
+ { label: "Recommended (AI)", value: "/products/recommended" },
162
+ { label: "Top Sellers", value: "/products/top_sellers" },
163
+ { label: "Buy It Again", value: "/products/purchased" },
164
+ { label: "Recently Viewed", value: "/products/viewed" },
165
+ { label: "Products Search", value: "/products/search" },
166
+ { label: "Collection Products", value: "/products/collections" },
167
+ { label: "Similar Products (AI)", value: "/products/similar_products" }
168
+ ];
169
+ var STATIC_ENDPOINTS = [
170
+ { label: "Recommended (AI)", value: "/products/recommended" },
171
+ { label: "Top Sellers", value: "/products/top_sellers" },
172
+ { label: "Trending Products", value: "/products/trending_products" },
173
+ { label: "Buy It Again", value: "/products/purchased" },
174
+ { label: "Collection Products", value: "/products/collections" },
175
+ { label: "Recently Viewed", value: "/products/viewed" },
176
+ { label: "Static Products", value: "/products/static" },
177
+ { label: "Products Search", value: "/products/search" },
178
+ { label: "Similar Products (AI)", value: "/products/similar_products" }
179
+ ];
180
+ var COMBINED_ENDPOINTS = uniqBy([...DEFAULT_ENDPOINTS, ...STATIC_ENDPOINTS], "value");
181
+ var targetAreas = {
182
+ [EditorMode.checkoutExtension]: [
183
+ { icon: "splitscreen_top", label: "Header Area", width: "984px" },
184
+ { icon: "splitscreen_left", label: "Main Column", width: "503px" },
185
+ { icon: "splitscreen_right", label: "Summary Column", width: "404px" }
186
+ ],
187
+ [EditorMode.postPurchaseOffer]: null,
188
+ [EditorMode.thankYouPage]: [
189
+ { icon: "splitscreen_top", label: "Header Area", width: "984px" },
190
+ { icon: "splitscreen_left", label: "Main Column", width: "503px" },
191
+ { icon: "splitscreen_right", label: "Summary Column", width: "404px" }
192
+ ],
193
+ [EditorMode.orderStatusPage]: [
194
+ // { fill: true, flip: 'vertical', icon: 'bottom_navigation', label: 'Announcement Bar' },
195
+ { icon: "splitscreen_top", label: "Header Area", width: "1124px" },
196
+ { fill: true, icon: "view_column_2", label: "Main Area", width: "646px" },
197
+ { icon: "splitscreen_bottom", label: "Footer Area", width: "1124px" }
198
+ ],
199
+ [EditorMode.ordersIndexPage]: [
200
+ // { fill: true, flip: 'vertical', icon: 'bottom_navigation', label: 'Announcement Bar' },
201
+ { icon: "splitscreen_top", label: "Main Area", width: "1124px" }
202
+ ],
203
+ [EditorMode.customerProfilePage]: [
204
+ // { fill: true, flip: 'vertical', icon: 'bottom_navigation', label: 'Announcement Bar' },
205
+ { icon: "splitscreen_top", label: "Main Area", width: "1124px" }
206
+ ]
207
+ };
208
+ var widgetTypes = [
209
+ "bundle_builder",
210
+ "cart",
211
+ "cart_subscription",
212
+ "dynamic_bundle",
213
+ "gift_with_purchase",
214
+ "pre_purchase",
215
+ "product",
216
+ "product_addon",
217
+ "product_upsell",
218
+ "recharge_checkout",
219
+ "recharge_customer_portal",
220
+ "recharge_post_purchase",
221
+ "shopify_checkout",
222
+ "shopify_checkout_extension",
223
+ "shopify_post_purchase",
224
+ "shopify_post_purchase_extension",
225
+ "switch_to_subscription",
226
+ "ui_extension_ad",
227
+ "ui_extension_button",
228
+ "ui_extension_content_block",
229
+ "ui_extension_line_item_editor",
230
+ "ui_extension_progress_bar"
231
+ ];
232
+ var widgetType = z2.enum(widgetTypes);
233
+ var WidgetType = widgetType.enum;
234
+
235
+ // src/schema/data-source.ts
236
+ var CABDataSourceSection = z3.strictObject({
237
+ dataSourceId: z3.number().nullable().default(null),
238
+ dataSourcePath: z3.string().default(DEFAULT_ENDPOINTS[0].value),
239
+ limit: z3.number().default(1),
240
+ name: z3.string().default(DEFAULT_ENDPOINTS[0].label),
241
+ sectionId: z3.uuidv7().default(() => uuidv7()),
242
+ sectionType: z3.literal(SectionType.dataSource).default(SectionType.dataSource)
243
+ });
244
+
245
+ // src/schema/layout.ts
246
+ import { v7 as uuidv72 } from "uuid";
247
+ import { z as z4 } from "zod";
248
+ var CABLayoutSection = z4.strictObject({
249
+ alignment: z4.strictObject({
250
+ horizontal: z4.enum(horizontalAlignments).default(HorizontalAlignment.start),
251
+ vertical: z4.enum(verticalAlignments).default(VerticalAlignment.top)
252
+ }).default({
253
+ horizontal: HorizontalAlignment.start,
254
+ vertical: VerticalAlignment.top
255
+ }),
256
+ border: CABBorder,
257
+ direction: z4.enum(directions).default(Direction.rows),
258
+ name: z4.string().optional(),
259
+ padding: z4.enum(spacings).default(Spacing.none),
260
+ sectionId: z4.uuidv7().default(() => uuidv72()),
261
+ sections: z4.array(z4.lazy(() => CABSection)).default(() => []),
262
+ sectionType: z4.literal(SectionType.layout).default(SectionType.layout),
263
+ spacing: z4.enum(spacings).default(Spacing.base),
264
+ width: z4.number().default(100)
265
+ });
266
+
267
+ // src/schema/offers.ts
268
+ import { z as z8 } from "zod";
269
+
270
+ // src/schema/products.ts
271
+ import { v7 as uuidv75 } from "uuid";
272
+ import { z as z7 } from "zod";
273
+
274
+ // src/schema/product.ts
275
+ import { v7 as uuidv74 } from "uuid";
276
+ import { z as z6 } from "zod";
277
+
278
+ // src/schema/text.ts
279
+ import { forEach, isString as isString2 } from "lodash-es";
280
+ import { v7 as uuidv73 } from "uuid";
281
+ import { z as z5 } from "zod";
282
+
283
+ // src/schema/utils.ts
284
+ import { isPlainObject, isString } from "lodash-es";
285
+ var isHTML = (html = "") => {
286
+ if (typeof window !== "undefined") {
287
+ const parser = new DOMParser();
288
+ const doc = parser.parseFromString(html, "text/html");
289
+ const hasHTML = (nodeList) => Array.from(nodeList).some((node) => node.nodeType === 1);
290
+ return hasHTML(doc.body.childNodes) || hasHTML(doc.head.childNodes);
291
+ }
292
+ return HTML_TAGS_REGEX.test(html);
293
+ };
294
+ var hasHTMLInDoc = (doc) => doc.content.some(({ content = [] }) => content.some(({ text }) => isHTML(text)));
295
+ var checkForHTML = (input) => !(isString(input) && isHTML(input) || isPlainObject(input) && hasHTMLInDoc(input));
296
+ var NO_HTML = { message: "HTML is not supported" };
297
+
298
+ // src/schema/text.ts
299
+ var enumOrOmit = (...vals) => z5.string().transform((val) => vals.includes(val) ? val : void 0).optional();
300
+ var TiptapText = z5.strictObject({
301
+ marks: z5.array(
302
+ z5.discriminatedUnion("type", [
303
+ z5.strictObject({ type: z5.literal("bold") }),
304
+ z5.strictObject({ type: z5.literal("italic") }),
305
+ z5.strictObject({
306
+ attrs: z5.strictObject({
307
+ class: z5.string().nullable(),
308
+ href: z5.union([z5.url(), z5.string().regex(DYNAMIC_TOKEN_REGEX)]),
309
+ rel: z5.string().default("noopener noreferrer nofollow"),
310
+ target: z5.string().default("_blank")
311
+ }),
312
+ type: z5.literal("link")
313
+ }),
314
+ z5.strictObject({ type: z5.literal("strike") }),
315
+ z5.strictObject({
316
+ attrs: z5.strictObject({
317
+ color: enumOrOmit(...textColorNames).default(TextColorName.base),
318
+ fontSize: enumOrOmit(...textSizeNames).default(TextSizeName.base)
319
+ }),
320
+ type: z5.literal("textStyle")
321
+ })
322
+ ])
323
+ ).optional(),
324
+ text: z5.string().default(""),
325
+ type: z5.literal("text").default("text")
326
+ });
327
+ var TiptapParagraph = z5.strictObject({
328
+ attrs: z5.strictObject({
329
+ textAlign: enumOrOmit(...textAlignments)
330
+ }).default({ textAlign: TextAlignment.start }),
331
+ content: z5.array(TiptapText).default([]),
332
+ type: z5.literal("paragraph").default("paragraph")
333
+ });
334
+ var TiptapDocument = z5.strictObject({
335
+ attrs: z5.strictObject({
336
+ blockSpacing: enumOrOmit(...spacings)
337
+ }).default({ blockSpacing: Spacing.base }),
338
+ content: z5.array(TiptapParagraph).default([TiptapParagraph.parse({})]),
339
+ type: z5.literal("doc").default("doc")
340
+ });
341
+ var CABTextSection = z5.strictObject({
342
+ buttonField: z5.enum(buttonFields).optional(),
343
+ content: z5.record(z5.string(), z5.union([z5.string(), TiptapDocument]).refine(checkForHTML, NO_HTML).optional()).default({ en: TiptapDocument.parse({}) }).optional(),
344
+ name: z5.string().optional(),
345
+ sectionId: z5.uuidv7().default(() => uuidv73()),
346
+ sectionType: z5.literal(SectionType.text).default(SectionType.text)
347
+ }).superRefine(({ buttonField: buttonField2, content }, ctx) => {
348
+ if (buttonField2 === ButtonField.destinationUrl && content) {
349
+ forEach(content, (value, lang) => {
350
+ if (value && isString2(value)) {
351
+ if (DYNAMIC_TOKEN_REGEX.test(value)) return;
352
+ try {
353
+ new URL(value);
354
+ } catch {
355
+ ctx.addIssue({
356
+ code: "custom",
357
+ message: "Invalid URL",
358
+ path: ["content", lang]
359
+ });
360
+ }
361
+ }
362
+ });
363
+ }
364
+ });
365
+
366
+ // src/schema/product.ts
367
+ var CABProductSection = z6.strictObject({
368
+ name: z6.string().optional(),
369
+ options: z6.array(
370
+ z6.strictObject({
371
+ /** `name` represents `Color`, `Size`, etc. */
372
+ name: z6.string(),
373
+ optionId: z6.number(),
374
+ selector: z6.enum(variantSelectors).default(VariantSelector.menu),
375
+ values: z6.array(
376
+ z6.strictObject({
377
+ color: z6.string().optional(),
378
+ image: CABImageSection.optional(),
379
+ /** `name` represents `Red`, `Blue`, etc. */
380
+ name: z6.string(),
381
+ text: CABTextSection.optional()
382
+ })
383
+ )
384
+ })
385
+ ).default(() => []),
386
+ productId: z6.number().nullable().default(null),
387
+ sectionId: z6.uuidv7().default(() => uuidv74()),
388
+ sectionType: z6.literal(SectionType.product).default(SectionType.product)
389
+ });
390
+
391
+ // src/schema/products.ts
392
+ var CABProductsSection = z7.strictObject({
393
+ name: z7.string().optional(),
394
+ sectionId: z7.uuidv7().default(() => uuidv75()),
395
+ sections: z7.array(CABProductSection).default(() => []),
396
+ sectionType: z7.literal(SectionType.products).default(SectionType.products)
397
+ });
398
+
399
+ // src/schema/offers.ts
400
+ var CABOffersSection = CABLayoutSection.omit({ sections: true, sectionType: true }).extend(
401
+ z8.strictObject({
402
+ sections: z8.array(z8.lazy(() => CABSection)).default(() => [CABDataSourceSection.parse({}), CABProductsSection.parse({})]),
403
+ sectionType: z8.literal(SectionType.offers).default(SectionType.offers)
404
+ }).shape
405
+ );
406
+
407
+ // src/schema/quantity.ts
408
+ import { v7 as uuidv76 } from "uuid";
409
+ import { z as z9 } from "zod";
410
+ var CABQuantitySection = z9.strictObject({
411
+ errorMessages: z9.record(
412
+ z9.string(),
413
+ z9.strictObject({
414
+ max: z9.string().optional(),
415
+ min: z9.string().optional(),
416
+ neg: z9.string().optional()
417
+ })
418
+ ).default({
419
+ en: {
420
+ max: "Maximum quantity allowed is {{max}}",
421
+ min: "Minimum quantity required is {{min}}",
422
+ neg: "Quantity cannot be negative"
423
+ }
424
+ }),
425
+ inputType: z9.enum(quantityInputs).default(QuantityInput.select),
426
+ max: z9.number().min(1).max(100).default(10),
427
+ min: z9.number().min(1).default(1),
428
+ name: z9.string().optional(),
429
+ sectionId: z9.uuidv7().default(() => uuidv76()),
430
+ sectionType: z9.literal(SectionType.quantity).default(SectionType.quantity)
431
+ });
432
+
433
+ // src/schema/reviews.ts
434
+ import { v7 as uuidv77 } from "uuid";
435
+ import { z as z10 } from "zod";
436
+ var CABReviewsSection = z10.strictObject({
437
+ name: z10.string().optional(),
438
+ sectionId: z10.uuidv7().default(() => uuidv77()),
439
+ sectionType: z10.literal(SectionType.reviews).default(SectionType.reviews)
440
+ });
441
+
442
+ // src/schema/subscription.ts
443
+ import { v7 as uuidv78 } from "uuid";
444
+ import { z as z11 } from "zod";
445
+ var CABSubscriptionSection = z11.strictObject({
446
+ name: z11.string().optional(),
447
+ sectionId: z11.uuidv7().default(() => uuidv78()),
448
+ sectionType: z11.literal(SectionType.subscription).default(SectionType.subscription)
449
+ });
450
+
451
+ // src/schema/table.ts
452
+ import { v7 as uuidv79 } from "uuid";
453
+ import { z as z12 } from "zod";
454
+ var CABTableSection = z12.strictObject({
455
+ name: z12.string().optional(),
456
+ sectionId: z12.uuidv7().default(() => uuidv79()),
457
+ sectionType: z12.literal(SectionType.table).default(SectionType.table)
458
+ });
459
+
460
+ // src/schema/variants.ts
461
+ import { slice } from "lodash-es";
462
+ import { v7 as uuidv710 } from "uuid";
463
+ import { z as z13 } from "zod";
464
+ var CABVariantsSection = z13.strictObject({
465
+ name: z13.string().optional(),
466
+ sectionId: z13.uuidv7().default(() => uuidv710()),
467
+ sectionType: z13.literal(SectionType.variants).default(SectionType.variants),
468
+ selector: z13.enum(slice(variantSelectors, 0, 3)).default(VariantSelector.menu)
469
+ });
470
+
471
+ // src/schema/shared.ts
472
+ var CABBorder = z14.strictObject({
473
+ radius: z14.enum(borderRadii).default(BorderRadius.base),
474
+ style: z14.enum(borderStyles).default(BorderStyle.none),
475
+ width: z14.enum(borderWidths).default(BorderWidth.base)
476
+ }).default({
477
+ radius: BorderRadius.base,
478
+ style: BorderStyle.none,
479
+ width: BorderWidth.base
480
+ });
481
+ var CABSection = z14.lazy(
482
+ () => z14.discriminatedUnion("sectionType", [
483
+ CABButtonSection,
484
+ CABDataSourceSection,
485
+ CABImageSection,
486
+ CABLayoutSection,
487
+ CABOffersSection,
488
+ CABProductSection,
489
+ CABProductsSection,
490
+ CABQuantitySection,
491
+ CABReviewsSection,
492
+ CABSubscriptionSection,
493
+ CABTableSection,
494
+ CABTextSection,
495
+ CABVariantsSection
496
+ ])
497
+ );
498
+
499
+ // src/schema/image.ts
500
+ var CABImageSection = z15.strictObject({
501
+ altText: z15.string().refine(checkForHTML, NO_HTML).default(""),
502
+ aspectRatio: z15.literal(1).nullable().default(null),
503
+ border: CABBorder,
504
+ buttonField: z15.enum(buttonFields).optional(),
505
+ category: z15.enum(["gallery", "icons", "payment-methods", "secure-checkout"]).nullable().default(null),
506
+ name: z15.string().optional(),
507
+ naturalHeight: z15.number().default(0),
508
+ naturalWidth: z15.number().default(0),
509
+ objectFit: z15.enum(objectFits).default(ObjectFit.cover),
510
+ sectionId: z15.uuidv7().default(() => uuidv711()),
511
+ sectionType: z15.literal(SectionType.image).default(SectionType.image),
512
+ source: z15.union([z15.url(), z15.literal(""), z15.string().regex(DYNAMIC_TOKEN_REGEX)]).default(""),
513
+ width: z15.number().default(100)
514
+ });
515
+
516
+ // src/schema/button.ts
517
+ var CABButtonContent = z16.discriminatedUnion("sectionType", [CABImageSection, CABTextSection]);
518
+ var CABButtonSection = z16.strictObject({
519
+ action: z16.union([z16.literal(""), z16.enum(buttonActions)]).default(""),
520
+ buttonStyle: z16.enum(buttonStyles).default(ButtonStyle.primary),
521
+ custom: z16.strictObject({
522
+ color: z16.string().regex(HEX_COLOR_REGEX).default("#005bd3"),
523
+ height: z16.number().default(52),
524
+ width: z16.number().default(300)
525
+ }).default({
526
+ color: "#005bd3",
527
+ height: 52,
528
+ width: 300
529
+ }),
530
+ name: z16.string().optional(),
531
+ sectionId: z16.uuidv7().default(() => uuidv712()),
532
+ sections: z16.array(CABButtonContent).default(() => []),
533
+ sectionType: z16.literal(SectionType.button).default(SectionType.button)
534
+ });
535
+
536
+ // src/schema/root.ts
537
+ import { z as z17 } from "zod";
538
+ var TargetArea = z17.strictObject({
539
+ fill: z17.boolean().optional(),
540
+ flip: z17.enum(["both", "horizontal", "vertical"]).optional(),
541
+ icon: z17.string(),
542
+ label: z17.string(),
543
+ width: z17.string()
544
+ }).default(targetAreas[EditorMode.checkoutExtension][1]);
545
+ var CABRootSection = CABLayoutSection.extend(
546
+ z17.strictObject({
547
+ editorMode: z17.enum(editorModes).default(EditorMode.checkoutExtension),
548
+ previewMode: z17.boolean().default(false),
549
+ storeId: z17.number().nullable().default(null),
550
+ targetArea: TargetArea.nullable(),
551
+ type: z17.enum(widgetTypes).default(WidgetType.ui_extension_content_block),
552
+ version: z17.literal(2).default(2),
553
+ widgetId: z17.number().nullable().default(null)
554
+ }).shape
555
+ );
556
+ export {
557
+ BorderRadius,
558
+ BorderStyle,
559
+ BorderWidth,
560
+ ButtonAction,
561
+ ButtonField,
562
+ ButtonStyle,
563
+ CABBorder,
564
+ CABButtonContent,
565
+ CABButtonSection,
566
+ CABDataSourceSection,
567
+ CABImageSection,
568
+ CABLayoutSection,
569
+ CABOffersSection,
570
+ CABProductSection,
571
+ CABProductsSection,
572
+ CABQuantitySection,
573
+ CABReviewsSection,
574
+ CABRootSection,
575
+ CABSection,
576
+ CABSubscriptionSection,
577
+ CABTableSection,
578
+ CABTextSection,
579
+ CABVariantsSection,
580
+ COMBINED_ENDPOINTS,
581
+ DEFAULT_ENDPOINTS,
582
+ DYNAMIC_TOKEN_REGEX,
583
+ Direction,
584
+ EditorMode,
585
+ HEX_COLOR_REGEX,
586
+ HTML_TAGS_REGEX,
587
+ HorizontalAlignment,
588
+ LanguageKey,
589
+ NO_HTML,
590
+ ObjectFit,
591
+ QuantityInput,
592
+ STATIC_ENDPOINTS,
593
+ SectionType,
594
+ Spacing,
595
+ TextAlignment,
596
+ TextColorName,
597
+ TextSizeName,
598
+ TiptapDocument,
599
+ TiptapParagraph,
600
+ TiptapText,
601
+ VariantSelector,
602
+ VerticalAlignment,
603
+ WidgetType,
604
+ borderRadii,
605
+ borderStyles,
606
+ borderWidths,
607
+ buttonActions,
608
+ buttonFields,
609
+ buttonStyles,
610
+ checkForHTML,
611
+ directions,
612
+ editorModes,
613
+ hasHTMLInDoc,
614
+ horizontalAlignments,
615
+ isHTML,
616
+ languageKeys,
617
+ objectFits,
618
+ quantityInputs,
619
+ sectionTypes,
620
+ spacings,
621
+ targetAreas,
622
+ textAlignments,
623
+ textColorNames,
624
+ textSizeNames,
625
+ variantSelectors,
626
+ verticalAlignments,
627
+ widgetTypes
628
+ };
629
+ //# sourceMappingURL=index.mjs.map