@rebuy/rebuy 2.1.0 → 2.2.0-rc.10

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 (47) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +654 -1
  4. package/dist/index.js.map +4 -4
  5. package/dist/index.mjs +654 -1
  6. package/dist/index.mjs.map +4 -4
  7. package/dist/schema/button.d.ts +273 -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 +13 -0
  14. package/dist/schema/data-source.d.ts.map +1 -0
  15. package/dist/schema/image.d.ts +65 -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/layout.d.ts +79 -0
  20. package/dist/schema/layout.d.ts.map +1 -0
  21. package/dist/schema/offers.d.ts +67 -0
  22. package/dist/schema/offers.d.ts.map +1 -0
  23. package/dist/schema/product.d.ts +147 -0
  24. package/dist/schema/product.d.ts.map +1 -0
  25. package/dist/schema/products.d.ts +152 -0
  26. package/dist/schema/products.d.ts.map +1 -0
  27. package/dist/schema/quantity.d.ts +21 -0
  28. package/dist/schema/quantity.d.ts.map +1 -0
  29. package/dist/schema/regex.d.ts +7 -0
  30. package/dist/schema/regex.d.ts.map +1 -0
  31. package/dist/schema/reviews.d.ts +10 -0
  32. package/dist/schema/reviews.d.ts.map +1 -0
  33. package/dist/schema/root.d.ts +127 -0
  34. package/dist/schema/root.d.ts.map +1 -0
  35. package/dist/schema/shared.d.ts +78 -0
  36. package/dist/schema/shared.d.ts.map +1 -0
  37. package/dist/schema/subscription.d.ts +10 -0
  38. package/dist/schema/subscription.d.ts.map +1 -0
  39. package/dist/schema/table.d.ts +10 -0
  40. package/dist/schema/table.d.ts.map +1 -0
  41. package/dist/schema/text.d.ts +162 -0
  42. package/dist/schema/text.d.ts.map +1 -0
  43. package/dist/schema/utils.d.ts +33 -0
  44. package/dist/schema/utils.d.ts.map +1 -0
  45. package/dist/schema/variants.d.ts +17 -0
  46. package/dist/schema/variants.d.ts.map +1 -0
  47. package/package.json +7 -2
package/dist/index.js CHANGED
@@ -21,36 +21,120 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
23
  Api: () => Api,
24
+ BorderRadius: () => BorderRadius,
25
+ BorderStyle: () => BorderStyle,
26
+ BorderWidth: () => BorderWidth,
27
+ ButtonAction: () => ButtonAction,
28
+ ButtonField: () => ButtonField,
29
+ ButtonStyle: () => ButtonStyle,
30
+ CABBorder: () => CABBorder,
31
+ CABButtonContent: () => CABButtonContent,
32
+ CABButtonSection: () => CABButtonSection,
33
+ CABDataSourceSection: () => CABDataSourceSection,
34
+ CABImageSection: () => CABImageSection,
35
+ CABLayoutSection: () => CABLayoutSection,
36
+ CABOffersSection: () => CABOffersSection,
37
+ CABProductSection: () => CABProductSection,
38
+ CABProductsSection: () => CABProductsSection,
39
+ CABQuantitySection: () => CABQuantitySection,
40
+ CABReviewsSection: () => CABReviewsSection,
41
+ CABRootSection: () => CABRootSection,
42
+ CABSection: () => CABSection,
43
+ CABSubscriptionSection: () => CABSubscriptionSection,
44
+ CABTableSection: () => CABTableSection,
45
+ CABTextSection: () => CABTextSection,
46
+ CABVariantsSection: () => CABVariantsSection,
47
+ COMBINED_ENDPOINTS: () => COMBINED_ENDPOINTS,
48
+ DEFAULT_ENDPOINTS: () => DEFAULT_ENDPOINTS,
49
+ DYNAMIC_TOKEN_REGEX: () => DYNAMIC_TOKEN_REGEX,
50
+ Direction: () => Direction,
51
+ EditorMode: () => EditorMode,
24
52
  Geolocation: () => Geolocation,
53
+ HEX_COLOR_REGEX: () => HEX_COLOR_REGEX,
54
+ HTML_TAGS_REGEX: () => HTML_TAGS_REGEX,
55
+ HorizontalAlignment: () => HorizontalAlignment,
25
56
  Identity: () => Identity,
57
+ LanguageKey: () => LanguageKey,
58
+ NO_HTML: () => NO_HTML,
59
+ ObjectFit: () => ObjectFit,
60
+ QuantityInput: () => QuantityInput,
26
61
  RebuyClient: () => RebuyClient,
62
+ STATIC_ENDPOINTS: () => STATIC_ENDPOINTS,
63
+ SectionType: () => SectionType,
27
64
  Session: () => Session,
65
+ Spacing: () => Spacing,
66
+ TextAlignment: () => TextAlignment,
67
+ TextColorName: () => TextColorName,
68
+ TextSizeName: () => TextSizeName,
69
+ TiptapDocument: () => TiptapDocument,
70
+ TiptapParagraph: () => TiptapParagraph,
71
+ TiptapText: () => TiptapText,
72
+ VariantSelector: () => VariantSelector,
73
+ VerticalAlignment: () => VerticalAlignment,
74
+ WidgetType: () => WidgetType,
28
75
  amountToCents: () => amountToCents,
76
+ borderRadii: () => borderRadii,
77
+ borderStyles: () => borderStyles,
78
+ borderWidths: () => borderWidths,
79
+ buttonActions: () => buttonActions,
80
+ buttonFields: () => buttonFields,
81
+ buttonStyles: () => buttonStyles,
82
+ checkForHTML: () => checkForHTML,
29
83
  convertProductToStorefrontFormat: () => convertProductToStorefrontFormat,
30
84
  convertToNodes: () => convertToNodes,
31
85
  convertVariantToStorefrontFormat: () => convertVariantToStorefrontFormat,
32
86
  dataToString: () => dataToString,
33
87
  destroy: () => destroy,
88
+ directions: () => directions,
89
+ editorModes: () => editorModes,
34
90
  enabled: () => enabled,
35
91
  find: () => find,
36
92
  firstAvailableVariant: () => firstAvailableVariant,
37
93
  get: () => get,
38
94
  getAll: () => getAll,
39
95
  getIdFromGraphUrl: () => getIdFromGraphUrl,
96
+ hasHTMLInDoc: () => hasHTMLInDoc,
97
+ horizontalAlignments: () => horizontalAlignments,
40
98
  isBase64Encoded: () => isBase64Encoded,
99
+ isButtonType: () => isButtonType,
100
+ isDataSourceType: () => isDataSourceType,
101
+ isHTML: () => isHTML,
102
+ isImageType: () => isImageType,
103
+ isLayoutType: () => isLayoutType,
104
+ isOffersType: () => isOffersType,
105
+ isProductType: () => isProductType,
106
+ isProductsType: () => isProductsType,
107
+ isQuantityType: () => isQuantityType,
108
+ isReviewsType: () => isReviewsType,
109
+ isSubscriptionType: () => isSubscriptionType,
110
+ isTableType: () => isTableType,
111
+ isTextType: () => isTextType,
112
+ isVariantsType: () => isVariantsType,
113
+ languageKeys: () => languageKeys,
114
+ objectFits: () => objectFits,
41
115
  productImageObject: () => productImageObject,
116
+ quantityInputs: () => quantityInputs,
42
117
  queryStringToObject: () => queryStringToObject,
118
+ sectionTypes: () => sectionTypes,
43
119
  selectedVariantOptions: () => selectedVariantOptions,
44
120
  serialize: () => serialize,
45
121
  sessionId: () => sessionId,
46
122
  set: () => set,
123
+ spacings: () => spacings,
47
124
  stringToData: () => stringToData,
48
125
  stripHtml: () => stripHtml,
126
+ targetAreas: () => targetAreas,
127
+ textAlignments: () => textAlignments,
128
+ textColorNames: () => textColorNames,
129
+ textSizeNames: () => textSizeNames,
49
130
  utmObjectFromString: () => utmObjectFromString,
50
131
  uuid: () => uuid,
51
132
  variantAvailable: () => variantAvailable,
52
133
  variantMinMaxPriceObject: () => variantMinMaxPriceObject,
53
- variantPriceObject: () => variantPriceObject
134
+ variantPriceObject: () => variantPriceObject,
135
+ variantSelectors: () => variantSelectors,
136
+ verticalAlignments: () => verticalAlignments,
137
+ widgetTypes: () => widgetTypes
54
138
  });
55
139
  module.exports = __toCommonJS(index_exports);
56
140
 
@@ -788,4 +872,573 @@ var RebuyClient = class {
788
872
  return null;
789
873
  }
790
874
  };
875
+
876
+ // src/schema/button.ts
877
+ var import_uuid12 = require("uuid");
878
+ var import_v416 = require("zod/v4");
879
+
880
+ // src/schema/common.ts
881
+ var import_v4 = require("zod/v4");
882
+ var borderRadii = ["none", "small", "base", "large", "fullyRounded"];
883
+ var borderRadius = import_v4.z.enum(borderRadii);
884
+ var BorderRadius = borderRadius.enum;
885
+ var borderStyles = ["none", "base", "dotted", "dashed"];
886
+ var borderStyle = import_v4.z.enum(borderStyles);
887
+ var BorderStyle = borderStyle.enum;
888
+ var borderWidths = ["base", "medium", "thick"];
889
+ var borderWidth = import_v4.z.enum(borderWidths);
890
+ var BorderWidth = borderWidth.enum;
891
+ var buttonActions = [
892
+ "addToOrder",
893
+ "declineAllOffers",
894
+ "declineOffer",
895
+ "goToRebuyApp",
896
+ "goToRebuyVault",
897
+ "goToURL",
898
+ "removeFromCart",
899
+ "showVariants",
900
+ "switchToSubscription"
901
+ ];
902
+ var buttonAction = import_v4.z.enum(buttonActions);
903
+ var ButtonAction = buttonAction.enum;
904
+ var buttonFields = [
905
+ "addedToCart",
906
+ "addingToCart",
907
+ "addToCart",
908
+ "buttonLabel",
909
+ "declineAllOffers",
910
+ "declineOffer",
911
+ "destinationUrl",
912
+ "payNow",
913
+ "removeFromCart",
914
+ "showVariant",
915
+ "showVariants",
916
+ "soldOut",
917
+ "switchToOneTimeAction",
918
+ "switchToOneTimePurchase",
919
+ "switchToSubscriptionAction",
920
+ "switchToSubscriptionNoDiscount",
921
+ "switchToSubscriptionWithDiscount"
922
+ ];
923
+ var buttonField = import_v4.z.enum(buttonFields);
924
+ var ButtonField = buttonField.enum;
925
+ var buttonStyles = ["primary", "secondary", "plain", "custom"];
926
+ var buttonStyle = import_v4.z.enum(buttonStyles);
927
+ var ButtonStyle = buttonStyle.enum;
928
+ var directions = ["columns", "rows"];
929
+ var direction = import_v4.z.enum(directions);
930
+ var Direction = direction.enum;
931
+ var editorModes = [
932
+ "checkoutExtension",
933
+ "postPurchaseOffer",
934
+ "thankYouPage",
935
+ "orderStatusPage",
936
+ "ordersIndexPage",
937
+ "customerProfilePage"
938
+ ];
939
+ var editorMode = import_v4.z.enum(editorModes);
940
+ var EditorMode = editorMode.enum;
941
+ var horizontalAlignments = ["start", "center", "end"];
942
+ var horizontalAlignment = import_v4.z.enum(horizontalAlignments);
943
+ var HorizontalAlignment = horizontalAlignment.enum;
944
+ var languageKeys = [
945
+ "ar",
946
+ "cs",
947
+ "da",
948
+ "de",
949
+ "en",
950
+ "es",
951
+ "fi",
952
+ "fr",
953
+ "ga",
954
+ "he",
955
+ "hi",
956
+ "id",
957
+ "it",
958
+ "ja",
959
+ "ko",
960
+ "nl",
961
+ "no",
962
+ "pl",
963
+ "pt",
964
+ "ru",
965
+ "sv",
966
+ "th",
967
+ "tr",
968
+ "uk",
969
+ "vi",
970
+ "zh"
971
+ ];
972
+ var languageKey = import_v4.z.enum(languageKeys);
973
+ var LanguageKey = languageKey.enum;
974
+ var objectFits = ["cover", "contain"];
975
+ var objectFit = import_v4.z.enum(objectFits);
976
+ var ObjectFit = objectFit.enum;
977
+ var quantityInputs = ["select", "number"];
978
+ var quantityInput = import_v4.z.enum(quantityInputs);
979
+ var QuantityInput = quantityInput.enum;
980
+ var sectionTypes = [
981
+ "button",
982
+ "dataSource",
983
+ "image",
984
+ "layout",
985
+ "offers",
986
+ "product",
987
+ "products",
988
+ "quantity",
989
+ "reviews",
990
+ "subscription",
991
+ "table",
992
+ "text",
993
+ "variants"
994
+ ];
995
+ var sectionType = import_v4.z.enum(sectionTypes);
996
+ var SectionType = sectionType.enum;
997
+ var spacings = ["none", "extraTight", "tight", "base", "loose", "extraLoose"];
998
+ var spacing = import_v4.z.enum(spacings);
999
+ var Spacing = spacing.enum;
1000
+ var textAlignments = ["start", "center", "end"];
1001
+ var textAlignment = import_v4.z.enum(textAlignments);
1002
+ var TextAlignment = textAlignment.enum;
1003
+ var textColorNames = ["base", "subdued", "accent", "decorative", "success", "warning", "critical"];
1004
+ var textColorName = import_v4.z.enum(textColorNames);
1005
+ var TextColorName = textColorName.enum;
1006
+ var textSizeNames = ["extraSmall", "small", "base", "medium", "large", "extraLarge"];
1007
+ var textSizeName = import_v4.z.enum(textSizeNames);
1008
+ var TextSizeName = textSizeName.enum;
1009
+ var variantSelectors = ["menu", "button", "radio", "color", "image"];
1010
+ var variantSelector = import_v4.z.enum(variantSelectors);
1011
+ var VariantSelector = variantSelector.enum;
1012
+ var verticalAlignments = ["top", "middle", "bottom"];
1013
+ var verticalAlignment = import_v4.z.enum(verticalAlignments);
1014
+ var VerticalAlignment = verticalAlignment.enum;
1015
+
1016
+ // src/schema/image.ts
1017
+ var import_uuid11 = require("uuid");
1018
+ var import_v415 = require("zod/v4");
1019
+
1020
+ // src/schema/regex.ts
1021
+ var DYNAMIC_TOKEN_REGEX = /^\{\{\s*[A-Za-z]+\s*\}\}$/;
1022
+ var HEX_COLOR_REGEX = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
1023
+ var HTML_TAGS_REGEX = /<[^>]*>/gi;
1024
+
1025
+ // src/schema/shared.ts
1026
+ var import_v414 = require("zod/v4");
1027
+
1028
+ // src/schema/data-source.ts
1029
+ var import_uuid = require("uuid");
1030
+ var import_v43 = require("zod/v4");
1031
+
1032
+ // src/schema/constants.ts
1033
+ var import_lodash_es = require("lodash-es");
1034
+ var import_v42 = require("zod/v4");
1035
+ var DEFAULT_ENDPOINTS = [
1036
+ { label: "Recommended (AI)", value: "/products/recommended" },
1037
+ { label: "Top Sellers", value: "/products/top_sellers" },
1038
+ { label: "Buy It Again", value: "/products/purchased" },
1039
+ { label: "Recently Viewed", value: "/products/viewed" },
1040
+ { label: "Products Search", value: "/products/search" },
1041
+ { label: "Collection Products", value: "/products/collections" },
1042
+ { label: "Similar Products (AI)", value: "/products/similar_products" }
1043
+ ];
1044
+ var STATIC_ENDPOINTS = [
1045
+ { label: "Recommended (AI)", value: "/products/recommended" },
1046
+ { label: "Top Sellers", value: "/products/top_sellers" },
1047
+ { label: "Trending Products", value: "/products/trending_products" },
1048
+ { label: "Buy It Again", value: "/products/purchased" },
1049
+ { label: "Collection Products", value: "/products/collections" },
1050
+ { label: "Recently Viewed", value: "/products/viewed" },
1051
+ { label: "Static Products", value: "/products/static" },
1052
+ { label: "Products Search", value: "/products/search" },
1053
+ { label: "Similar Products (AI)", value: "/products/similar_products" }
1054
+ ];
1055
+ var COMBINED_ENDPOINTS = (0, import_lodash_es.uniqBy)([...DEFAULT_ENDPOINTS, ...STATIC_ENDPOINTS], "value");
1056
+ var targetAreas = {
1057
+ [EditorMode.checkoutExtension]: [
1058
+ { icon: "splitscreen_top", label: "Header Area", width: "984px" },
1059
+ { icon: "splitscreen_left", label: "Main Column", width: "503px" },
1060
+ { icon: "splitscreen_right", label: "Summary Column", width: "404px" }
1061
+ ],
1062
+ [EditorMode.postPurchaseOffer]: null,
1063
+ [EditorMode.thankYouPage]: [
1064
+ { icon: "splitscreen_top", label: "Header Area", width: "984px" },
1065
+ { icon: "splitscreen_left", label: "Main Column", width: "503px" },
1066
+ { icon: "splitscreen_right", label: "Summary Column", width: "404px" }
1067
+ ],
1068
+ [EditorMode.orderStatusPage]: [
1069
+ // { fill: true, flip: 'vertical', icon: 'bottom_navigation', label: 'Announcement Bar' },
1070
+ { icon: "splitscreen_top", label: "Header Area", width: "1124px" },
1071
+ { fill: true, icon: "view_column_2", label: "Main Area", width: "646px" },
1072
+ { icon: "splitscreen_bottom", label: "Footer Area", width: "1124px" }
1073
+ ],
1074
+ [EditorMode.ordersIndexPage]: [
1075
+ // { fill: true, flip: 'vertical', icon: 'bottom_navigation', label: 'Announcement Bar' },
1076
+ { icon: "splitscreen_top", label: "Main Area", width: "1124px" }
1077
+ ],
1078
+ [EditorMode.customerProfilePage]: [
1079
+ // { fill: true, flip: 'vertical', icon: 'bottom_navigation', label: 'Announcement Bar' },
1080
+ { icon: "splitscreen_top", label: "Main Area", width: "1124px" }
1081
+ ]
1082
+ };
1083
+ var widgetTypes = [
1084
+ "bundle_builder",
1085
+ "cart",
1086
+ "cart_subscription",
1087
+ "dynamic_bundle",
1088
+ "gift_with_purchase",
1089
+ "pre_purchase",
1090
+ "product",
1091
+ "product_addon",
1092
+ "product_upsell",
1093
+ "recharge_checkout",
1094
+ "recharge_customer_portal",
1095
+ "recharge_post_purchase",
1096
+ "shopify_checkout",
1097
+ "shopify_checkout_extension",
1098
+ "shopify_post_purchase",
1099
+ "shopify_post_purchase_extension",
1100
+ "switch_to_subscription",
1101
+ "ui_extension_ad",
1102
+ "ui_extension_button",
1103
+ "ui_extension_content_block",
1104
+ "ui_extension_line_item_editor",
1105
+ "ui_extension_progress_bar"
1106
+ ];
1107
+ var widgetType = import_v42.z.enum(widgetTypes);
1108
+ var WidgetType = widgetType.enum;
1109
+
1110
+ // src/schema/data-source.ts
1111
+ var CABDataSourceSection = import_v43.z.object({
1112
+ dataSourceId: import_v43.z.number().nullable().default(null),
1113
+ dataSourcePath: import_v43.z.string().default(DEFAULT_ENDPOINTS[0].value),
1114
+ limit: import_v43.z.number().default(1),
1115
+ name: import_v43.z.string().default(DEFAULT_ENDPOINTS[0].label),
1116
+ sectionId: import_v43.z.uuidv7().default(() => (0, import_uuid.v7)()),
1117
+ sectionType: import_v43.z.literal(SectionType.dataSource).default(SectionType.dataSource)
1118
+ });
1119
+
1120
+ // src/schema/layout.ts
1121
+ var import_uuid2 = require("uuid");
1122
+ var import_v44 = require("zod/v4");
1123
+ var CABLayoutSection = import_v44.z.object({
1124
+ alignment: import_v44.z.object({
1125
+ horizontal: import_v44.z.enum(horizontalAlignments).default(HorizontalAlignment.start),
1126
+ vertical: import_v44.z.enum(verticalAlignments).default(VerticalAlignment.top)
1127
+ }).default({
1128
+ horizontal: HorizontalAlignment.start,
1129
+ vertical: VerticalAlignment.top
1130
+ }),
1131
+ border: import_v44.z.lazy(() => CABBorder),
1132
+ direction: import_v44.z.enum(directions).default(Direction.rows),
1133
+ name: import_v44.z.string().optional(),
1134
+ padding: import_v44.z.enum(spacings).default(Spacing.none),
1135
+ sectionId: import_v44.z.uuidv7().default(() => (0, import_uuid2.v7)()),
1136
+ sections: import_v44.z.array(import_v44.z.lazy(() => CABSection)).default(() => []),
1137
+ sectionType: import_v44.z.literal(SectionType.layout).default(SectionType.layout),
1138
+ spacing: import_v44.z.enum(spacings).default(Spacing.base),
1139
+ width: import_v44.z.number().default(100)
1140
+ });
1141
+
1142
+ // src/schema/offers.ts
1143
+ var import_v48 = require("zod/v4");
1144
+
1145
+ // src/schema/products.ts
1146
+ var import_uuid5 = require("uuid");
1147
+ var import_v47 = require("zod/v4");
1148
+
1149
+ // src/schema/product.ts
1150
+ var import_uuid4 = require("uuid");
1151
+ var import_v46 = require("zod/v4");
1152
+
1153
+ // src/schema/text.ts
1154
+ var import_lodash_es3 = require("lodash-es");
1155
+ var import_uuid3 = require("uuid");
1156
+ var import_v45 = require("zod/v4");
1157
+
1158
+ // src/schema/utils.ts
1159
+ var import_lodash_es2 = require("lodash-es");
1160
+ var isHTML = (html = "") => {
1161
+ if (typeof window !== "undefined") {
1162
+ const parser = new DOMParser();
1163
+ const doc = parser.parseFromString(html, "text/html");
1164
+ const hasHTML = (nodeList) => Array.from(nodeList).some((node) => node.nodeType === 1);
1165
+ return hasHTML(doc.body.childNodes) || hasHTML(doc.head.childNodes);
1166
+ }
1167
+ return HTML_TAGS_REGEX.test(html);
1168
+ };
1169
+ var hasHTMLInDoc = (doc) => doc.content.some(({ content = [] }) => content.some(({ text }) => isHTML(text)));
1170
+ var checkForHTML = (input) => !((0, import_lodash_es2.isString)(input) && isHTML(input) || (0, import_lodash_es2.isPlainObject)(input) && hasHTMLInDoc(input));
1171
+ var NO_HTML = { message: "HTML is not supported" };
1172
+ var isButtonType = (section) => (0, import_lodash_es2.get)(section, "sectionType") === SectionType.button;
1173
+ var isDataSourceType = (section) => (0, import_lodash_es2.get)(section, "sectionType") === SectionType.dataSource;
1174
+ var isImageType = (section) => (0, import_lodash_es2.get)(section, "sectionType") === SectionType.image;
1175
+ var isLayoutType = (section) => (0, import_lodash_es2.get)(section, "sectionType") === SectionType.layout;
1176
+ var isOffersType = (section) => (0, import_lodash_es2.get)(section, "sectionType") === SectionType.offers;
1177
+ var isProductType = (section) => (0, import_lodash_es2.get)(section, "sectionType") === SectionType.product;
1178
+ var isProductsType = (section) => (0, import_lodash_es2.get)(section, "sectionType") === SectionType.products;
1179
+ var isQuantityType = (section) => (0, import_lodash_es2.get)(section, "sectionType") === SectionType.quantity;
1180
+ var isReviewsType = (section) => (0, import_lodash_es2.get)(section, "sectionType") === SectionType.reviews;
1181
+ var isSubscriptionType = (section) => (0, import_lodash_es2.get)(section, "sectionType") === SectionType.subscription;
1182
+ var isTableType = (section) => (0, import_lodash_es2.get)(section, "sectionType") === SectionType.table;
1183
+ var isTextType = (section) => (0, import_lodash_es2.get)(section, "sectionType") === SectionType.text;
1184
+ var isVariantsType = (section) => (0, import_lodash_es2.get)(section, "sectionType") === SectionType.variants;
1185
+
1186
+ // src/schema/text.ts
1187
+ var enumOrOmit = (...vals) => import_v45.z.string().transform((val) => vals.includes(val) ? val : void 0).optional();
1188
+ var TiptapText = import_v45.z.object({
1189
+ marks: import_v45.z.array(
1190
+ import_v45.z.discriminatedUnion("type", [
1191
+ import_v45.z.object({ type: import_v45.z.literal("bold") }),
1192
+ import_v45.z.object({ type: import_v45.z.literal("italic") }),
1193
+ import_v45.z.object({
1194
+ attrs: import_v45.z.object({
1195
+ class: import_v45.z.string().nullable(),
1196
+ href: import_v45.z.union([import_v45.z.url(), import_v45.z.string().regex(DYNAMIC_TOKEN_REGEX)]),
1197
+ rel: import_v45.z.string().default("noopener noreferrer nofollow"),
1198
+ target: import_v45.z.string().default("_blank")
1199
+ }),
1200
+ type: import_v45.z.literal("link")
1201
+ }),
1202
+ import_v45.z.object({ type: import_v45.z.literal("strike") }),
1203
+ import_v45.z.object({
1204
+ attrs: import_v45.z.object({
1205
+ color: enumOrOmit(...textColorNames).default(TextColorName.base),
1206
+ fontSize: enumOrOmit(...textSizeNames).default(TextSizeName.base)
1207
+ }),
1208
+ type: import_v45.z.literal("textStyle")
1209
+ })
1210
+ ])
1211
+ ).optional(),
1212
+ text: import_v45.z.string().default(""),
1213
+ type: import_v45.z.literal("text").default("text")
1214
+ });
1215
+ var TiptapParagraph = import_v45.z.object({
1216
+ attrs: import_v45.z.object({
1217
+ textAlign: enumOrOmit(...textAlignments)
1218
+ }).default({ textAlign: TextAlignment.start }),
1219
+ content: import_v45.z.array(TiptapText).default([]),
1220
+ type: import_v45.z.literal("paragraph").default("paragraph")
1221
+ });
1222
+ var TiptapDocument = import_v45.z.object({
1223
+ attrs: import_v45.z.object({
1224
+ blockSpacing: enumOrOmit(...spacings)
1225
+ }).default({ blockSpacing: Spacing.base }),
1226
+ content: import_v45.z.array(TiptapParagraph).default([TiptapParagraph.parse({})]),
1227
+ type: import_v45.z.literal("doc").default("doc")
1228
+ });
1229
+ var CABTextSection = import_v45.z.object({
1230
+ buttonField: import_v45.z.enum(buttonFields).optional(),
1231
+ content: import_v45.z.record(import_v45.z.string(), import_v45.z.union([import_v45.z.string(), TiptapDocument]).refine(checkForHTML, NO_HTML).optional()).default({ en: TiptapDocument.parse({}) }).optional(),
1232
+ name: import_v45.z.string().optional(),
1233
+ sectionId: import_v45.z.uuidv7().default(() => (0, import_uuid3.v7)()),
1234
+ sectionType: import_v45.z.literal(SectionType.text).default(SectionType.text)
1235
+ }).superRefine(({ buttonField: buttonField2, content }, ctx) => {
1236
+ if (buttonField2 === ButtonField.destinationUrl && content) {
1237
+ (0, import_lodash_es3.forEach)(content, (value, lang) => {
1238
+ if (value && (0, import_lodash_es3.isString)(value)) {
1239
+ if (DYNAMIC_TOKEN_REGEX.test(value)) return;
1240
+ try {
1241
+ new URL(value);
1242
+ } catch {
1243
+ ctx.addIssue({
1244
+ code: "custom",
1245
+ message: "Invalid URL",
1246
+ path: ["content", lang]
1247
+ });
1248
+ }
1249
+ }
1250
+ });
1251
+ }
1252
+ });
1253
+
1254
+ // src/schema/product.ts
1255
+ var CABProductSection = import_v46.z.object({
1256
+ name: import_v46.z.string().optional(),
1257
+ options: import_v46.z.array(
1258
+ import_v46.z.object({
1259
+ /** `name` represents `Color`, `Size`, etc. */
1260
+ name: import_v46.z.string(),
1261
+ optionId: import_v46.z.number(),
1262
+ selector: import_v46.z.enum(variantSelectors).default(VariantSelector.menu),
1263
+ values: import_v46.z.array(
1264
+ import_v46.z.object({
1265
+ color: import_v46.z.string().optional(),
1266
+ image: import_v46.z.lazy(() => CABImageSection).optional(),
1267
+ /** `name` represents `Red`, `Blue`, etc. */
1268
+ name: import_v46.z.string(),
1269
+ text: import_v46.z.lazy(() => CABTextSection).optional()
1270
+ })
1271
+ )
1272
+ })
1273
+ ).default(() => []),
1274
+ productId: import_v46.z.number().nullable().default(null),
1275
+ sectionId: import_v46.z.uuidv7().default(() => (0, import_uuid4.v7)()),
1276
+ sectionType: import_v46.z.literal(SectionType.product).default(SectionType.product)
1277
+ });
1278
+
1279
+ // src/schema/products.ts
1280
+ var CABProductsSection = import_v47.z.object({
1281
+ name: import_v47.z.string().optional(),
1282
+ sectionId: import_v47.z.uuidv7().default(() => (0, import_uuid5.v7)()),
1283
+ sections: import_v47.z.array(import_v47.z.lazy(() => CABProductSection)).default(() => []),
1284
+ sectionType: import_v47.z.literal(SectionType.products).default(SectionType.products)
1285
+ });
1286
+
1287
+ // src/schema/offers.ts
1288
+ var CABOffersSection = CABLayoutSection.omit({ sections: true, sectionType: true }).extend(
1289
+ import_v48.z.object({
1290
+ sections: import_v48.z.array(import_v48.z.lazy(() => CABSection)).default(() => [CABDataSourceSection.parse({}), CABProductsSection.parse({})]),
1291
+ sectionType: import_v48.z.literal(SectionType.offers).default(SectionType.offers)
1292
+ }).shape
1293
+ );
1294
+
1295
+ // src/schema/quantity.ts
1296
+ var import_uuid6 = require("uuid");
1297
+ var import_v49 = require("zod/v4");
1298
+ var CABQuantitySection = import_v49.z.object({
1299
+ errorMessages: import_v49.z.record(
1300
+ import_v49.z.string(),
1301
+ import_v49.z.object({
1302
+ max: import_v49.z.string().optional(),
1303
+ min: import_v49.z.string().optional(),
1304
+ neg: import_v49.z.string().optional()
1305
+ })
1306
+ ).default({
1307
+ en: {
1308
+ max: "Maximum quantity allowed is {{max}}",
1309
+ min: "Minimum quantity required is {{min}}",
1310
+ neg: "Quantity cannot be negative"
1311
+ }
1312
+ }),
1313
+ inputType: import_v49.z.enum(quantityInputs).default(QuantityInput.select),
1314
+ max: import_v49.z.number().min(1).max(100).default(10),
1315
+ min: import_v49.z.number().min(1).default(1),
1316
+ name: import_v49.z.string().optional(),
1317
+ sectionId: import_v49.z.uuidv7().default(() => (0, import_uuid6.v7)()),
1318
+ sectionType: import_v49.z.literal(SectionType.quantity).default(SectionType.quantity)
1319
+ });
1320
+
1321
+ // src/schema/reviews.ts
1322
+ var import_uuid7 = require("uuid");
1323
+ var import_v410 = require("zod/v4");
1324
+ var CABReviewsSection = import_v410.z.object({
1325
+ name: import_v410.z.string().optional(),
1326
+ sectionId: import_v410.z.uuidv7().default(() => (0, import_uuid7.v7)()),
1327
+ sectionType: import_v410.z.literal(SectionType.reviews).default(SectionType.reviews)
1328
+ });
1329
+
1330
+ // src/schema/subscription.ts
1331
+ var import_uuid8 = require("uuid");
1332
+ var import_v411 = require("zod/v4");
1333
+ var CABSubscriptionSection = import_v411.z.object({
1334
+ name: import_v411.z.string().optional(),
1335
+ sectionId: import_v411.z.uuidv7().default(() => (0, import_uuid8.v7)()),
1336
+ sectionType: import_v411.z.literal(SectionType.subscription).default(SectionType.subscription)
1337
+ });
1338
+
1339
+ // src/schema/table.ts
1340
+ var import_uuid9 = require("uuid");
1341
+ var import_v412 = require("zod/v4");
1342
+ var CABTableSection = import_v412.z.object({
1343
+ name: import_v412.z.string().optional(),
1344
+ sectionId: import_v412.z.uuidv7().default(() => (0, import_uuid9.v7)()),
1345
+ sectionType: import_v412.z.literal(SectionType.table).default(SectionType.table)
1346
+ });
1347
+
1348
+ // src/schema/variants.ts
1349
+ var import_lodash_es4 = require("lodash-es");
1350
+ var import_uuid10 = require("uuid");
1351
+ var import_v413 = require("zod/v4");
1352
+ var CABVariantsSection = import_v413.z.object({
1353
+ name: import_v413.z.string().optional(),
1354
+ sectionId: import_v413.z.uuidv7().default(() => (0, import_uuid10.v7)()),
1355
+ sectionType: import_v413.z.literal(SectionType.variants).default(SectionType.variants),
1356
+ selector: import_v413.z.enum((0, import_lodash_es4.slice)(variantSelectors, 0, 3)).default(VariantSelector.menu)
1357
+ });
1358
+
1359
+ // src/schema/shared.ts
1360
+ var CABBorder = import_v414.z.object({
1361
+ radius: import_v414.z.enum(borderRadii).default(BorderRadius.base),
1362
+ style: import_v414.z.enum(borderStyles).default(BorderStyle.none),
1363
+ width: import_v414.z.enum(borderWidths).default(BorderWidth.base)
1364
+ }).default({
1365
+ radius: BorderRadius.base,
1366
+ style: BorderStyle.none,
1367
+ width: BorderWidth.base
1368
+ });
1369
+ var CABSection = import_v414.z.lazy(
1370
+ () => import_v414.z.discriminatedUnion("sectionType", [
1371
+ CABButtonSection,
1372
+ CABDataSourceSection,
1373
+ CABImageSection,
1374
+ CABLayoutSection,
1375
+ CABOffersSection,
1376
+ CABProductSection,
1377
+ CABProductsSection,
1378
+ CABQuantitySection,
1379
+ CABReviewsSection,
1380
+ CABSubscriptionSection,
1381
+ CABTableSection,
1382
+ CABTextSection,
1383
+ CABVariantsSection
1384
+ ])
1385
+ );
1386
+
1387
+ // src/schema/image.ts
1388
+ var CABImageSection = import_v415.z.object({
1389
+ altText: import_v415.z.string().refine(checkForHTML, NO_HTML).default(""),
1390
+ aspectRatio: import_v415.z.literal(1).nullable().default(null),
1391
+ border: import_v415.z.lazy(() => CABBorder),
1392
+ buttonField: import_v415.z.enum(buttonFields).optional(),
1393
+ category: import_v415.z.enum(["gallery", "icons", "payment-methods", "secure-checkout"]).nullable().default(null),
1394
+ name: import_v415.z.string().optional(),
1395
+ naturalHeight: import_v415.z.number().default(0),
1396
+ naturalWidth: import_v415.z.number().default(0),
1397
+ objectFit: import_v415.z.enum(objectFits).default(ObjectFit.cover),
1398
+ sectionId: import_v415.z.uuidv7().default(() => (0, import_uuid11.v7)()),
1399
+ sectionType: import_v415.z.literal(SectionType.image).default(SectionType.image),
1400
+ source: import_v415.z.union([import_v415.z.url(), import_v415.z.literal(""), import_v415.z.string().regex(DYNAMIC_TOKEN_REGEX)]).default(""),
1401
+ width: import_v415.z.number().default(100)
1402
+ });
1403
+
1404
+ // src/schema/button.ts
1405
+ var CABButtonContent = import_v416.z.lazy(() => import_v416.z.discriminatedUnion("sectionType", [CABImageSection, CABTextSection]));
1406
+ var CABButtonSection = import_v416.z.object({
1407
+ action: import_v416.z.union([import_v416.z.literal(""), import_v416.z.enum(buttonActions)]).default(""),
1408
+ buttonStyle: import_v416.z.enum(buttonStyles).default(ButtonStyle.primary),
1409
+ custom: import_v416.z.object({
1410
+ color: import_v416.z.string().regex(HEX_COLOR_REGEX).default("#005bd3"),
1411
+ height: import_v416.z.number().default(52),
1412
+ width: import_v416.z.number().default(300)
1413
+ }).default({
1414
+ color: "#005bd3",
1415
+ height: 52,
1416
+ width: 300
1417
+ }),
1418
+ name: import_v416.z.string().optional(),
1419
+ sectionId: import_v416.z.uuidv7().default(() => (0, import_uuid12.v7)()),
1420
+ sections: import_v416.z.array(CABButtonContent).default(() => []),
1421
+ sectionType: import_v416.z.literal(SectionType.button).default(SectionType.button)
1422
+ });
1423
+
1424
+ // src/schema/root.ts
1425
+ var import_v417 = require("zod/v4");
1426
+ var TargetArea = import_v417.z.object({
1427
+ fill: import_v417.z.boolean().optional(),
1428
+ flip: import_v417.z.enum(["both", "horizontal", "vertical"]).optional(),
1429
+ icon: import_v417.z.string(),
1430
+ label: import_v417.z.string(),
1431
+ width: import_v417.z.string()
1432
+ }).default(targetAreas[EditorMode.checkoutExtension][1]);
1433
+ var CABRootSection = CABLayoutSection.extend(
1434
+ import_v417.z.object({
1435
+ editorMode: import_v417.z.enum(editorModes).default(EditorMode.checkoutExtension),
1436
+ previewMode: import_v417.z.boolean().default(false),
1437
+ storeId: import_v417.z.number().nullable().default(null),
1438
+ targetArea: TargetArea.nullable(),
1439
+ type: import_v417.z.enum(widgetTypes).default(WidgetType.ui_extension_content_block),
1440
+ version: import_v417.z.literal(2).default(2),
1441
+ widgetId: import_v417.z.number().nullable().default(null)
1442
+ }).shape
1443
+ );
791
1444
  //# sourceMappingURL=index.js.map