@delopay/sdk 0.164.0 → 0.165.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -42,6 +42,7 @@ import {
42
42
  DEFAULT_BADGES_DARK,
43
43
  DEFAULT_BRANDING,
44
44
  DEFAULT_BRANDING_DARK,
45
+ DEFAULT_NOTICES,
45
46
  Delopay,
46
47
  DelopayAuthenticationError,
47
48
  DelopayError,
@@ -63,6 +64,12 @@ import {
63
64
  NATIVE_PANE_CATEGORY_KEYS,
64
65
  NATIVE_PANE_ICON_KEYS,
65
66
  NOMUPAY_FORM_STYLES,
67
+ NOTICES_PER_SECTION,
68
+ NOTICE_ICONS,
69
+ NOTICE_ICON_FALLBACK,
70
+ NOTICE_ICON_PATHS,
71
+ NOTICE_LABEL_MAX_LENGTH,
72
+ NOTICE_SECTIONS,
66
73
  OperationLimits,
67
74
  PANES_MAX,
68
75
  PANE_CATEGORY_KEYS,
@@ -120,6 +127,7 @@ import {
120
127
  cloneBranding,
121
128
  cloneCustomField,
122
129
  cloneNativePane,
130
+ cloneNotice,
123
131
  clonePane,
124
132
  compareSections,
125
133
  contrastRatio,
@@ -135,11 +143,13 @@ import {
135
143
  decodeMethodSectionLabels,
136
144
  decodeMethodSectionOrder,
137
145
  decodeNativePanes,
146
+ decodeNotices,
138
147
  decodePanes,
139
148
  defaultBranding,
140
149
  defaultCustomFieldVisibility,
141
150
  defaultMethodSectionOrder,
142
151
  defaultNativePane,
152
+ defaultNotices,
143
153
  defaultOperatorForSource,
144
154
  defaultPane,
145
155
  emptyPaneCatalog,
@@ -149,6 +159,7 @@ import {
149
159
  encodeMethodSectionLabels,
150
160
  encodeMethodSectionOrder,
151
161
  encodeNativePanes,
162
+ encodeNotices,
152
163
  encodePanes,
153
164
  evaluateCustomFieldCondition,
154
165
  evaluateCustomFieldVisibility,
@@ -159,13 +170,17 @@ import {
159
170
  inputPadValue,
160
171
  isCheckboxChecked,
161
172
  isDarkSurface,
173
+ isDefaultBadgeSet,
162
174
  isHexColor,
175
+ isNoticeIcon,
163
176
  isSubscriptionDisputeWebhook,
164
177
  isSubscriptionLifecycleWebhook,
165
178
  knownSectionLabelKey,
166
179
  leaf,
167
180
  logoDimensions,
168
181
  nativePaneMethodInfo,
182
+ noticeText,
183
+ noticesIn,
169
184
  offerablePaneMethods,
170
185
  paneCatalogFor,
171
186
  paneDisplayDefaults,
@@ -174,6 +189,7 @@ import {
174
189
  paneViewVisibility,
175
190
  parseCustomFieldsLoose,
176
191
  parseImportedBranding,
192
+ parseNoticesLoose,
177
193
  programToTree,
178
194
  radiusValue,
179
195
  readableInkOn,
@@ -181,12 +197,14 @@ import {
181
197
  resolveAirwallexLabelStyle,
182
198
  resolveApplePayButtonStyle,
183
199
  resolveGooglePayButtonColor,
200
+ resolveNoticesAndBadges,
184
201
  resolveStripeTheme,
185
202
  ruleMatchToTree,
186
203
  sanitizeCustomCss,
187
204
  sectionLabel,
188
205
  sectionOrderOf,
189
206
  shadowFor,
207
+ shownNotices,
190
208
  stripeSpacingValues,
191
209
  surchargeFigurePlan,
192
210
  surchargeShowsLabel,
@@ -197,7 +215,7 @@ import {
197
215
  validatePanes,
198
216
  verticalGapValue,
199
217
  visibleCustomFields
200
- } from "./chunk-GCJDY4KX.js";
218
+ } from "./chunk-CP5M5WR6.js";
201
219
  export {
202
220
  AIRWALLEX_AUTOFILL_TREATMENTS,
203
221
  AIRWALLEX_CARD_LAYOUTS,
@@ -242,6 +260,7 @@ export {
242
260
  DEFAULT_BADGES_DARK,
243
261
  DEFAULT_BRANDING,
244
262
  DEFAULT_BRANDING_DARK,
263
+ DEFAULT_NOTICES,
245
264
  Delopay,
246
265
  DelopayAuthenticationError,
247
266
  DelopayError,
@@ -263,6 +282,12 @@ export {
263
282
  NATIVE_PANE_CATEGORY_KEYS,
264
283
  NATIVE_PANE_ICON_KEYS,
265
284
  NOMUPAY_FORM_STYLES,
285
+ NOTICES_PER_SECTION,
286
+ NOTICE_ICONS,
287
+ NOTICE_ICON_FALLBACK,
288
+ NOTICE_ICON_PATHS,
289
+ NOTICE_LABEL_MAX_LENGTH,
290
+ NOTICE_SECTIONS,
266
291
  OperationLimits,
267
292
  PANES_MAX,
268
293
  PANE_CATEGORY_KEYS,
@@ -320,6 +345,7 @@ export {
320
345
  cloneBranding,
321
346
  cloneCustomField,
322
347
  cloneNativePane,
348
+ cloneNotice,
323
349
  clonePane,
324
350
  compareSections,
325
351
  contrastRatio,
@@ -335,11 +361,13 @@ export {
335
361
  decodeMethodSectionLabels,
336
362
  decodeMethodSectionOrder,
337
363
  decodeNativePanes,
364
+ decodeNotices,
338
365
  decodePanes,
339
366
  defaultBranding,
340
367
  defaultCustomFieldVisibility,
341
368
  defaultMethodSectionOrder,
342
369
  defaultNativePane,
370
+ defaultNotices,
343
371
  defaultOperatorForSource,
344
372
  defaultPane,
345
373
  emptyPaneCatalog,
@@ -349,6 +377,7 @@ export {
349
377
  encodeMethodSectionLabels,
350
378
  encodeMethodSectionOrder,
351
379
  encodeNativePanes,
380
+ encodeNotices,
352
381
  encodePanes,
353
382
  evaluateCustomFieldCondition,
354
383
  evaluateCustomFieldVisibility,
@@ -359,13 +388,17 @@ export {
359
388
  inputPadValue,
360
389
  isCheckboxChecked,
361
390
  isDarkSurface,
391
+ isDefaultBadgeSet,
362
392
  isHexColor,
393
+ isNoticeIcon,
363
394
  isSubscriptionDisputeWebhook,
364
395
  isSubscriptionLifecycleWebhook,
365
396
  knownSectionLabelKey,
366
397
  leaf,
367
398
  logoDimensions,
368
399
  nativePaneMethodInfo,
400
+ noticeText,
401
+ noticesIn,
369
402
  offerablePaneMethods,
370
403
  paneCatalogFor,
371
404
  paneDisplayDefaults,
@@ -374,6 +407,7 @@ export {
374
407
  paneViewVisibility,
375
408
  parseCustomFieldsLoose,
376
409
  parseImportedBranding,
410
+ parseNoticesLoose,
377
411
  programToTree,
378
412
  radiusValue,
379
413
  readableInkOn,
@@ -381,12 +415,14 @@ export {
381
415
  resolveAirwallexLabelStyle,
382
416
  resolveApplePayButtonStyle,
383
417
  resolveGooglePayButtonColor,
418
+ resolveNoticesAndBadges,
384
419
  resolveStripeTheme,
385
420
  ruleMatchToTree,
386
421
  sanitizeCustomCss,
387
422
  sectionLabel,
388
423
  sectionOrderOf,
389
424
  shadowFor,
425
+ shownNotices,
390
426
  stripeSpacingValues,
391
427
  surchargeFigurePlan,
392
428
  surchargeShowsLabel,
package/dist/internal.cjs CHANGED
@@ -71,6 +71,7 @@ __export(internal_exports, {
71
71
  DEFAULT_BADGES_DARK: () => DEFAULT_BADGES_DARK,
72
72
  DEFAULT_BRANDING: () => DEFAULT_BRANDING,
73
73
  DEFAULT_BRANDING_DARK: () => DEFAULT_BRANDING_DARK,
74
+ DEFAULT_NOTICES: () => DEFAULT_NOTICES,
74
75
  Delopay: () => Delopay,
75
76
  DelopayAuthenticationError: () => DelopayAuthenticationError,
76
77
  DelopayError: () => DelopayError,
@@ -95,6 +96,12 @@ __export(internal_exports, {
95
96
  NATIVE_PANE_CATEGORY_KEYS: () => NATIVE_PANE_CATEGORY_KEYS,
96
97
  NATIVE_PANE_ICON_KEYS: () => NATIVE_PANE_ICON_KEYS,
97
98
  NOMUPAY_FORM_STYLES: () => NOMUPAY_FORM_STYLES,
99
+ NOTICES_PER_SECTION: () => NOTICES_PER_SECTION,
100
+ NOTICE_ICONS: () => NOTICE_ICONS,
101
+ NOTICE_ICON_FALLBACK: () => NOTICE_ICON_FALLBACK,
102
+ NOTICE_ICON_PATHS: () => NOTICE_ICON_PATHS,
103
+ NOTICE_LABEL_MAX_LENGTH: () => NOTICE_LABEL_MAX_LENGTH,
104
+ NOTICE_SECTIONS: () => NOTICE_SECTIONS,
98
105
  OperationLimits: () => OperationLimits,
99
106
  PANES_MAX: () => PANES_MAX,
100
107
  PANE_CATEGORY_KEYS: () => PANE_CATEGORY_KEYS,
@@ -154,6 +161,7 @@ __export(internal_exports, {
154
161
  cloneBranding: () => cloneBranding,
155
162
  cloneCustomField: () => cloneCustomField,
156
163
  cloneNativePane: () => cloneNativePane,
164
+ cloneNotice: () => cloneNotice,
157
165
  clonePane: () => clonePane,
158
166
  compareSections: () => compareSections,
159
167
  contrastRatio: () => contrastRatio,
@@ -169,11 +177,13 @@ __export(internal_exports, {
169
177
  decodeMethodSectionLabels: () => decodeMethodSectionLabels,
170
178
  decodeMethodSectionOrder: () => decodeMethodSectionOrder,
171
179
  decodeNativePanes: () => decodeNativePanes,
180
+ decodeNotices: () => decodeNotices,
172
181
  decodePanes: () => decodePanes,
173
182
  defaultBranding: () => defaultBranding,
174
183
  defaultCustomFieldVisibility: () => defaultCustomFieldVisibility,
175
184
  defaultMethodSectionOrder: () => defaultMethodSectionOrder,
176
185
  defaultNativePane: () => defaultNativePane,
186
+ defaultNotices: () => defaultNotices,
177
187
  defaultOperatorForSource: () => defaultOperatorForSource,
178
188
  defaultPane: () => defaultPane,
179
189
  emptyPaneCatalog: () => emptyPaneCatalog,
@@ -183,6 +193,7 @@ __export(internal_exports, {
183
193
  encodeMethodSectionLabels: () => encodeMethodSectionLabels,
184
194
  encodeMethodSectionOrder: () => encodeMethodSectionOrder,
185
195
  encodeNativePanes: () => encodeNativePanes,
196
+ encodeNotices: () => encodeNotices,
186
197
  encodePanes: () => encodePanes,
187
198
  evaluateCustomFieldCondition: () => evaluateCustomFieldCondition,
188
199
  evaluateCustomFieldVisibility: () => evaluateCustomFieldVisibility,
@@ -193,13 +204,17 @@ __export(internal_exports, {
193
204
  inputPadValue: () => inputPadValue,
194
205
  isCheckboxChecked: () => isCheckboxChecked,
195
206
  isDarkSurface: () => isDarkSurface,
207
+ isDefaultBadgeSet: () => isDefaultBadgeSet,
196
208
  isHexColor: () => isHexColor,
209
+ isNoticeIcon: () => isNoticeIcon,
197
210
  isSubscriptionDisputeWebhook: () => isSubscriptionDisputeWebhook,
198
211
  isSubscriptionLifecycleWebhook: () => isSubscriptionLifecycleWebhook,
199
212
  knownSectionLabelKey: () => knownSectionLabelKey,
200
213
  leaf: () => leaf,
201
214
  logoDimensions: () => logoDimensions,
202
215
  nativePaneMethodInfo: () => nativePaneMethodInfo,
216
+ noticeText: () => noticeText,
217
+ noticesIn: () => noticesIn,
203
218
  offerablePaneMethods: () => offerablePaneMethods,
204
219
  paneCatalogFor: () => paneCatalogFor,
205
220
  paneDisplayDefaults: () => paneDisplayDefaults,
@@ -208,6 +223,7 @@ __export(internal_exports, {
208
223
  paneViewVisibility: () => paneViewVisibility,
209
224
  parseCustomFieldsLoose: () => parseCustomFieldsLoose,
210
225
  parseImportedBranding: () => parseImportedBranding,
226
+ parseNoticesLoose: () => parseNoticesLoose,
211
227
  programToTree: () => programToTree,
212
228
  radiusValue: () => radiusValue,
213
229
  readableInkOn: () => readableInkOn,
@@ -215,12 +231,14 @@ __export(internal_exports, {
215
231
  resolveAirwallexLabelStyle: () => resolveAirwallexLabelStyle,
216
232
  resolveApplePayButtonStyle: () => resolveApplePayButtonStyle,
217
233
  resolveGooglePayButtonColor: () => resolveGooglePayButtonColor,
234
+ resolveNoticesAndBadges: () => resolveNoticesAndBadges,
218
235
  resolveStripeTheme: () => resolveStripeTheme,
219
236
  ruleMatchToTree: () => ruleMatchToTree,
220
237
  sanitizeCustomCss: () => sanitizeCustomCss,
221
238
  sectionLabel: () => sectionLabel,
222
239
  sectionOrderOf: () => sectionOrderOf,
223
240
  shadowFor: () => shadowFor,
241
+ shownNotices: () => shownNotices,
224
242
  stripeSpacingValues: () => stripeSpacingValues,
225
243
  surchargeFigurePlan: () => surchargeFigurePlan,
226
244
  surchargeShowsLabel: () => surchargeShowsLabel,
@@ -6732,6 +6750,66 @@ function surchargeWordFor(branding, isDiscount, locale) {
6732
6750
  locale
6733
6751
  );
6734
6752
  }
6753
+ var NOTICE_SECTIONS = ["summary", "payment"];
6754
+ var NOTICES_PER_SECTION = 3;
6755
+ var NOTICE_LABEL_MAX_LENGTH = 80;
6756
+ var NOTICE_ICONS = [
6757
+ "lock",
6758
+ "shield",
6759
+ "check",
6760
+ "truck",
6761
+ "package",
6762
+ "refresh",
6763
+ "star",
6764
+ "support",
6765
+ "globe",
6766
+ "tag",
6767
+ "heart",
6768
+ "leaf",
6769
+ "clock",
6770
+ "bank"
6771
+ ];
6772
+ var NOTICE_ICON_FALLBACK = "check";
6773
+ var NOTICE_ICON_PATHS = {
6774
+ lock: [
6775
+ "M6 10h12a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2z",
6776
+ "M8 10V7a4 4 0 0 1 8 0v3"
6777
+ ],
6778
+ shield: ["M12 3l7 3v6c0 4.2-2.9 7.6-7 9-4.1-1.4-7-4.8-7-9V6z", "M9 12l2.5 2.5 4-4.5"],
6779
+ check: ["M21 12a9 9 0 1 1-18 0a9 9 0 1 1 18 0z", "M8 12.5l3 3 5-6"],
6780
+ truck: [
6781
+ "M3 7.5h10v9H3z",
6782
+ "M13 11h4l3 3v2.5h-7z",
6783
+ "M8.8 18a1.8 1.8 0 1 1-3.6 0a1.8 1.8 0 1 1 3.6 0z",
6784
+ "M18.8 18a1.8 1.8 0 1 1-3.6 0a1.8 1.8 0 1 1 3.6 0z"
6785
+ ],
6786
+ package: [
6787
+ "M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",
6788
+ "M12 22V12",
6789
+ "M3.29 7L12 12l8.71-5"
6790
+ ],
6791
+ refresh: ["M20 12a8 8 0 1 1-2.5-5.8", "M20 4v5h-5"],
6792
+ star: ["m12 3.6 2.6 5.3 5.9.9-4.3 4.1 1 5.8-5.2-2.7-5.2 2.7 1-5.8-4.3-4.1 5.9-.9z"],
6793
+ support: [
6794
+ "M5 13v-1a7 7 0 0 1 14 0v1",
6795
+ "M3.5 14.5a1.8 1.8 0 0 1 1.8-1.8H7v5H5.3a1.8 1.8 0 0 1-1.8-1.8z",
6796
+ "M20.5 14.5a1.8 1.8 0 0 0-1.8-1.8H17v5h1.7a1.8 1.8 0 0 0 1.8-1.8z",
6797
+ "M19 17.7v.8a2.5 2.5 0 0 1-2.5 2.5H13"
6798
+ ],
6799
+ globe: [
6800
+ "M21 12a9 9 0 1 1-18 0a9 9 0 1 1 18 0z",
6801
+ "M3 12h18",
6802
+ "M12 3a14 14 0 0 1 0 18a14 14 0 0 1 0-18z"
6803
+ ],
6804
+ tag: ["M11 3H4v7l10 10 7-7z", "M9.1 7a1.3 1.3 0 1 1-2.6 0a1.3 1.3 0 1 1 2.6 0z"],
6805
+ heart: ["M12 20s-7-4.4-7-9.3A3.9 3.9 0 0 1 12 8a3.9 3.9 0 0 1 7 2.7c0 4.9-7 9.3-7 9.3z"],
6806
+ leaf: ["M20 4c0 9-5.4 13-9.5 13A4.5 4.5 0 0 1 6 12.5C6 7 12 4 20 4z", "M4 20c2-4.5 5-7.5 9-9.5"],
6807
+ clock: ["M21 12a9 9 0 1 1-18 0a9 9 0 1 1 18 0z", "M12 7v5l3 2"],
6808
+ bank: ["M3 9.5 12 4l9 5.5", "M5 10v8M9.5 10v8M14.5 10v8M19 10v8", "M3 20h18"]
6809
+ };
6810
+ function isNoticeIcon(value) {
6811
+ return typeof value === "string" && NOTICE_ICONS.includes(value);
6812
+ }
6735
6813
  var FONT_STACKS = {
6736
6814
  inter: "'Inter Variable', 'Inter', system-ui, -apple-system, sans-serif",
6737
6815
  system: "system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif",
@@ -6901,6 +6979,96 @@ var DEFAULT_BADGES_DARK = [
6901
6979
  borderColor: "#1e40af"
6902
6980
  }
6903
6981
  ];
6982
+ var DEFAULT_NOTICES = [
6983
+ {
6984
+ id: "secure",
6985
+ section: "summary",
6986
+ icon: "shield",
6987
+ label: "Secure payment",
6988
+ labelTranslations: {
6989
+ de: "Sichere Zahlung",
6990
+ fr: "Paiement s\xE9curis\xE9",
6991
+ es: "Pago seguro",
6992
+ it: "Pagamento sicuro",
6993
+ nl: "Veilig betalen",
6994
+ zh: "\u5B89\u5168\u652F\u4ED8",
6995
+ "zh-Hant": "\u5B89\u5168\u4ED8\u6B3E",
6996
+ hi: "\u0938\u0941\u0930\u0915\u094D\u0937\u093F\u0924 \u092D\u0941\u0917\u0924\u093E\u0928",
6997
+ ar: "\u062F\u0641\u0639 \u0622\u0645\u0646"
6998
+ }
6999
+ },
7000
+ {
7001
+ id: "ssl",
7002
+ section: "summary",
7003
+ icon: "lock",
7004
+ label: "Encrypted \xB7 256-bit SSL",
7005
+ labelTranslations: {
7006
+ de: "Verschl\xFCsselt \xB7 256-Bit-SSL",
7007
+ fr: "Chiffr\xE9 \xB7 SSL 256 bits",
7008
+ es: "Cifrado \xB7 SSL de 256 bits",
7009
+ it: "Crittografato \xB7 SSL a 256 bit",
7010
+ nl: "Versleuteld \xB7 256-bit SSL",
7011
+ zh: "\u52A0\u5BC6 \xB7 256 \u4F4D SSL",
7012
+ "zh-Hant": "\u52A0\u5BC6 \xB7 256 \u4F4D\u5143 SSL",
7013
+ hi: "\u090F\u0928\u094D\u0915\u094D\u0930\u093F\u092A\u094D\u091F\u0947\u0921 \xB7 256-\u092C\u093F\u091F SSL",
7014
+ ar: "\u0645\u0634\u0641\u0651\u0631 \xB7 SSL \u0628\u0637\u0648\u0644 256 \u0628\u062A"
7015
+ }
7016
+ }
7017
+ ];
7018
+ function defaultNotices() {
7019
+ return DEFAULT_NOTICES.map(cloneNotice);
7020
+ }
7021
+ function cloneNotice(notice) {
7022
+ return { ...notice, labelTranslations: { ...notice.labelTranslations } };
7023
+ }
7024
+ function hexChannels(hex) {
7025
+ const raw = /^#([0-9a-f]{6})$/i.exec(hex.trim())?.[1];
7026
+ if (!raw) return null;
7027
+ return [
7028
+ parseInt(raw.slice(0, 2), 16),
7029
+ parseInt(raw.slice(2, 4), 16),
7030
+ parseInt(raw.slice(4, 6), 16)
7031
+ ];
7032
+ }
7033
+ function isThemeTintedBadgeColouring(textColor, fill, border) {
7034
+ const primary = hexChannels(textColor);
7035
+ const bg = hexChannels(fill);
7036
+ const line = hexChannels(border);
7037
+ if (!primary || !bg || !line) return false;
7038
+ const mixed = (surface, to, share) => Math.round(surface + (to - surface) * share);
7039
+ return primary.every((p, i) => {
7040
+ for (let surface = 0; surface <= 255; surface += 1) {
7041
+ if (mixed(surface, p, 0.08) === bg[i] && mixed(surface, p, 0.3) === line[i]) return true;
7042
+ }
7043
+ return false;
7044
+ });
7045
+ }
7046
+ function isDefaultBadgeSet(badges) {
7047
+ if (badges.length !== DEFAULT_BADGES.length) return false;
7048
+ const sameContent = badges.every(
7049
+ (badge, i) => badge.id === DEFAULT_BADGES[i]?.id && badge.label === DEFAULT_BADGES[i]?.label
7050
+ );
7051
+ if (!sameContent) return false;
7052
+ const colouring = (set) => set.map((b) => [b.textColor, b.backgroundColor, b.borderColor ?? ""].join("|").toLowerCase()).join("/");
7053
+ const mine = colouring(badges);
7054
+ if (mine === colouring(DEFAULT_BADGES) || mine === colouring(DEFAULT_BADGES_DARK)) return true;
7055
+ const [first] = badges;
7056
+ const border = first?.borderColor;
7057
+ if (!first || !border) return false;
7058
+ const same = (a, b) => (a ?? "").toLowerCase() === b.toLowerCase();
7059
+ return badges.every(
7060
+ (b) => same(b.textColor, first.textColor) && same(b.backgroundColor, first.backgroundColor) && same(b.borderColor, border)
7061
+ ) && isThemeTintedBadgeColouring(first.textColor, first.backgroundColor, border);
7062
+ }
7063
+ function resolveNoticesAndBadges(savedBadges, savedNotices) {
7064
+ if (savedNotices !== null) {
7065
+ return { trustBadges: savedBadges ?? [], notices: savedNotices };
7066
+ }
7067
+ if (savedBadges === null || isDefaultBadgeSet(savedBadges)) {
7068
+ return { trustBadges: [], notices: defaultNotices() };
7069
+ }
7070
+ return { trustBadges: savedBadges, notices: [] };
7071
+ }
6904
7072
  var METHOD_SECTION_ORDER_KEY = "methodSectionOrder";
6905
7073
  var METHOD_SECTION_LABELS_KEY = "methodSectionLabels";
6906
7074
  var MIN_SECTION_ORDER = 1;
@@ -7187,7 +7355,11 @@ var DEFAULT_BRANDING_BASE = {
7187
7355
  var DEFAULT_BRANDING = {
7188
7356
  ...DEFAULT_BRANDING_BASE,
7189
7357
  ...LIGHT_PALETTE,
7190
- trustBadges: DEFAULT_BADGES.map((b) => ({ ...b })),
7358
+ // No badges by default since todos#218 — notices took their place.
7359
+ // `DEFAULT_BADGES` stays exported because `isDefaultBadgeSet` still has to
7360
+ // recognise the pair on shops saved before.
7361
+ trustBadges: [],
7362
+ notices: defaultNotices(),
7191
7363
  customFields: [],
7192
7364
  methodSectionOrder: defaultMethodSectionOrder(),
7193
7365
  methodSectionLabels: {}
@@ -7210,7 +7382,8 @@ var DEFAULT_BRANDING_DARK = {
7210
7382
  // end of the ramp — 10.69 and 9.29 against the dark surface, also pinned.
7211
7383
  surchargeColor: "#fbbf24",
7212
7384
  discountColor: "#34d399",
7213
- trustBadges: DEFAULT_BADGES_DARK.map((b) => ({ ...b })),
7385
+ trustBadges: [],
7386
+ notices: defaultNotices(),
7214
7387
  customFields: [],
7215
7388
  methodSectionOrder: defaultMethodSectionOrder(),
7216
7389
  methodSectionLabels: {}
@@ -7222,6 +7395,7 @@ function cloneBranding(b) {
7222
7395
  return {
7223
7396
  ...b,
7224
7397
  trustBadges: b.trustBadges.map((badge) => ({ ...badge })),
7398
+ notices: b.notices.map(cloneNotice),
7225
7399
  customFields: b.customFields.map(cloneCustomField),
7226
7400
  methodSectionOrder: { ...b.methodSectionOrder },
7227
7401
  methodSectionLabels: Object.fromEntries(
@@ -7331,6 +7505,80 @@ function encodeBadges(badges) {
7331
7505
  }))
7332
7506
  );
7333
7507
  }
7508
+ var NOTICE_ID_MAX_LENGTH = 40;
7509
+ function capNoticeText(value) {
7510
+ return Array.from(value).slice(0, NOTICE_LABEL_MAX_LENGTH).join("");
7511
+ }
7512
+ function normalizeNotices(list) {
7513
+ const seen = /* @__PURE__ */ new Set();
7514
+ const perSection = /* @__PURE__ */ new Map();
7515
+ const out = [];
7516
+ list.forEach((raw, index) => {
7517
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return;
7518
+ const src = raw;
7519
+ const label = typeof src["label"] === "string" ? capNoticeText(src["label"]) : "";
7520
+ const labelTranslations = {};
7521
+ for (const [locale, text] of Object.entries(parseTranslations(src["labelTranslations"]))) {
7522
+ labelTranslations[locale] = capNoticeText(text);
7523
+ }
7524
+ if (label.trim().length === 0 && Object.keys(labelTranslations).length === 0) return;
7525
+ const section = pickEnum(src["section"], NOTICE_SECTIONS, "summary");
7526
+ const used = perSection.get(section) ?? 0;
7527
+ if (used >= NOTICES_PER_SECTION) return;
7528
+ perSection.set(section, used + 1);
7529
+ let id = typeof src["id"] === "string" ? src["id"].replace(/[^A-Za-z0-9_-]/g, "").slice(0, NOTICE_ID_MAX_LENGTH) : "";
7530
+ if (!id || seen.has(id)) id = `notice-${index + 1}`;
7531
+ while (seen.has(id)) id = `${id}x`;
7532
+ seen.add(id);
7533
+ out.push({
7534
+ id,
7535
+ section,
7536
+ icon: isNoticeIcon(src["icon"]) ? src["icon"] : NOTICE_ICON_FALLBACK,
7537
+ label,
7538
+ labelTranslations
7539
+ });
7540
+ });
7541
+ return out;
7542
+ }
7543
+ function decodeNotices(raw) {
7544
+ if (raw === void 0) return null;
7545
+ let parsed;
7546
+ try {
7547
+ parsed = JSON.parse(raw);
7548
+ } catch {
7549
+ return null;
7550
+ }
7551
+ return Array.isArray(parsed) ? normalizeNotices(parsed) : null;
7552
+ }
7553
+ function parseNoticesLoose(raw) {
7554
+ if (typeof raw === "string") return decodeNotices(raw);
7555
+ return Array.isArray(raw) ? normalizeNotices(raw) : null;
7556
+ }
7557
+ function encodeNotices(notices) {
7558
+ return JSON.stringify(
7559
+ notices.map((n) => {
7560
+ const translations = Object.entries(n.labelTranslations).filter(
7561
+ ([, text]) => text.trim().length > 0
7562
+ );
7563
+ return {
7564
+ id: n.id,
7565
+ section: n.section,
7566
+ icon: n.icon,
7567
+ label: n.label,
7568
+ ...translations.length > 0 ? { labelTranslations: Object.fromEntries(translations) } : {}
7569
+ };
7570
+ })
7571
+ );
7572
+ }
7573
+ function noticeText(notice, locale) {
7574
+ return translationFor(notice.labelTranslations, locale) ?? notice.label;
7575
+ }
7576
+ function noticesIn(notices, section) {
7577
+ return notices.filter((n) => n.section === section).slice(0, NOTICES_PER_SECTION);
7578
+ }
7579
+ function shownNotices(notices, section, locale) {
7580
+ return noticesIn(notices, section).map((notice) => ({ notice, text: noticeText(notice, locale).trim() })).filter((entry) => entry.text.length > 0);
7581
+ }
7334
7582
  var CUSTOM_FIELDS_MAX = 20;
7335
7583
  var CUSTOM_FIELD_KEY_PATTERN = /^[A-Za-z][A-Za-z0-9_-]{0,39}$/;
7336
7584
  var ALL_CUSTOM_FIELD_TYPES = [
@@ -7674,7 +7922,10 @@ function customFieldOptionLabel(option, locale) {
7674
7922
  function decodeBranding(source) {
7675
7923
  if (!source) return cloneBranding(DEFAULT_BRANDING);
7676
7924
  const extras = source.sdk_ui_rules?.[BRANDING_GROUP_KEY] ?? {};
7677
- const decodedBadges = decodeBadges(extras["trustBadges"]);
7925
+ const trustRow = resolveNoticesAndBadges(
7926
+ decodeBadges(extras["trustBadges"]),
7927
+ decodeNotices(extras["notices"])
7928
+ );
7678
7929
  const decodedCustomFields = decodeCustomFields(extras["customFields"]);
7679
7930
  const displayName = s(source.merchant_name) || s(source.seller_name);
7680
7931
  const logoUrl = s(source.merchant_logo) || s(source.logo);
@@ -7853,7 +8104,8 @@ function decodeBranding(source) {
7853
8104
  totalLabel: s(extras["totalLabel"]) || DEFAULT_BRANDING.totalLabel,
7854
8105
  showCurrencyCode: parseBool(extras["showCurrencyCode"], DEFAULT_BRANDING.showCurrencyCode),
7855
8106
  showOrderItems: parseBool(extras["showOrderItems"], DEFAULT_BRANDING.showOrderItems),
7856
- trustBadges: decodedBadges ?? DEFAULT_BRANDING.trustBadges.map((b) => ({ ...b })),
8107
+ trustBadges: trustRow.trustBadges,
8108
+ notices: trustRow.notices,
7857
8109
  customFields: decodedCustomFields ?? [],
7858
8110
  methodSectionOrder: decodeMethodSectionOrder(extras[METHOD_SECTION_ORDER_KEY]),
7859
8111
  methodSectionLabels: decodeMethodSectionLabels(extras[METHOD_SECTION_LABELS_KEY]),
@@ -8137,9 +8389,14 @@ function encodeBranding(branding, base) {
8137
8389
  nomupayApplePayButtonType: branding.nomupayApplePayButtonType,
8138
8390
  nomupayGooglePayButtonColor: branding.nomupayGooglePayButtonColor,
8139
8391
  nomupayGooglePayButtonType: branding.nomupayGooglePayButtonType,
8140
- trustBadges: encodeBadges(branding.trustBadges),
8392
+ // Always written, `[]` included — its presence is what stops a later
8393
+ // decode from migrating the shop again (`resolveNoticesAndBadges`).
8394
+ notices: encodeNotices(branding.notices),
8141
8395
  [METHOD_SECTION_ORDER_KEY]: encodeMethodSectionOrder(branding.methodSectionOrder)
8142
8396
  };
8397
+ if (branding.trustBadges.length > 0) {
8398
+ extras["trustBadges"] = encodeBadges(branding.trustBadges);
8399
+ }
8143
8400
  const sectionLabels = encodeMethodSectionLabels(branding.methodSectionLabels);
8144
8401
  if (sectionLabels) extras[METHOD_SECTION_LABELS_KEY] = sectionLabels;
8145
8402
  if (branding.customFields.length > 0) {
@@ -8205,7 +8462,10 @@ function parseImportedBranding(raw) {
8205
8462
  const dflt = DEFAULT_BRANDING;
8206
8463
  const sStr = (v, fallback) => typeof v === "string" ? v : fallback;
8207
8464
  const sHex = (v, fallback) => typeof v === "string" && isHexColor(v) ? v : fallback;
8208
- const trustBadges = parseTrustBadgesLoose(root["trustBadges"]) ?? dflt.trustBadges.map((b) => ({ ...b }));
8465
+ const { trustBadges, notices } = resolveNoticesAndBadges(
8466
+ parseTrustBadgesLoose(root["trustBadges"]),
8467
+ parseNoticesLoose(root["notices"])
8468
+ );
8209
8469
  const customFields = parseCustomFieldsLoose(root["customFields"]) ?? [];
8210
8470
  const labelStyle = (() => {
8211
8471
  const v = root["labelStyle"];
@@ -8348,6 +8608,7 @@ function parseImportedBranding(raw) {
8348
8608
  showCurrencyCode: parseBool(root["showCurrencyCode"], dflt.showCurrencyCode),
8349
8609
  showOrderItems: parseBool(root["showOrderItems"], dflt.showOrderItems),
8350
8610
  trustBadges,
8611
+ notices,
8351
8612
  customFields,
8352
8613
  // An export writes the decoded maps; a hand-written file may carry the
8353
8614
  // JSON strings the bag uses. Both are accepted, and neither is required.
@@ -10956,6 +11217,7 @@ var DelopayInternal = class extends Delopay {
10956
11217
  DEFAULT_BADGES_DARK,
10957
11218
  DEFAULT_BRANDING,
10958
11219
  DEFAULT_BRANDING_DARK,
11220
+ DEFAULT_NOTICES,
10959
11221
  Delopay,
10960
11222
  DelopayAuthenticationError,
10961
11223
  DelopayError,
@@ -10980,6 +11242,12 @@ var DelopayInternal = class extends Delopay {
10980
11242
  NATIVE_PANE_CATEGORY_KEYS,
10981
11243
  NATIVE_PANE_ICON_KEYS,
10982
11244
  NOMUPAY_FORM_STYLES,
11245
+ NOTICES_PER_SECTION,
11246
+ NOTICE_ICONS,
11247
+ NOTICE_ICON_FALLBACK,
11248
+ NOTICE_ICON_PATHS,
11249
+ NOTICE_LABEL_MAX_LENGTH,
11250
+ NOTICE_SECTIONS,
10983
11251
  OperationLimits,
10984
11252
  PANES_MAX,
10985
11253
  PANE_CATEGORY_KEYS,
@@ -11039,6 +11307,7 @@ var DelopayInternal = class extends Delopay {
11039
11307
  cloneBranding,
11040
11308
  cloneCustomField,
11041
11309
  cloneNativePane,
11310
+ cloneNotice,
11042
11311
  clonePane,
11043
11312
  compareSections,
11044
11313
  contrastRatio,
@@ -11054,11 +11323,13 @@ var DelopayInternal = class extends Delopay {
11054
11323
  decodeMethodSectionLabels,
11055
11324
  decodeMethodSectionOrder,
11056
11325
  decodeNativePanes,
11326
+ decodeNotices,
11057
11327
  decodePanes,
11058
11328
  defaultBranding,
11059
11329
  defaultCustomFieldVisibility,
11060
11330
  defaultMethodSectionOrder,
11061
11331
  defaultNativePane,
11332
+ defaultNotices,
11062
11333
  defaultOperatorForSource,
11063
11334
  defaultPane,
11064
11335
  emptyPaneCatalog,
@@ -11068,6 +11339,7 @@ var DelopayInternal = class extends Delopay {
11068
11339
  encodeMethodSectionLabels,
11069
11340
  encodeMethodSectionOrder,
11070
11341
  encodeNativePanes,
11342
+ encodeNotices,
11071
11343
  encodePanes,
11072
11344
  evaluateCustomFieldCondition,
11073
11345
  evaluateCustomFieldVisibility,
@@ -11078,13 +11350,17 @@ var DelopayInternal = class extends Delopay {
11078
11350
  inputPadValue,
11079
11351
  isCheckboxChecked,
11080
11352
  isDarkSurface,
11353
+ isDefaultBadgeSet,
11081
11354
  isHexColor,
11355
+ isNoticeIcon,
11082
11356
  isSubscriptionDisputeWebhook,
11083
11357
  isSubscriptionLifecycleWebhook,
11084
11358
  knownSectionLabelKey,
11085
11359
  leaf,
11086
11360
  logoDimensions,
11087
11361
  nativePaneMethodInfo,
11362
+ noticeText,
11363
+ noticesIn,
11088
11364
  offerablePaneMethods,
11089
11365
  paneCatalogFor,
11090
11366
  paneDisplayDefaults,
@@ -11093,6 +11369,7 @@ var DelopayInternal = class extends Delopay {
11093
11369
  paneViewVisibility,
11094
11370
  parseCustomFieldsLoose,
11095
11371
  parseImportedBranding,
11372
+ parseNoticesLoose,
11096
11373
  programToTree,
11097
11374
  radiusValue,
11098
11375
  readableInkOn,
@@ -11100,12 +11377,14 @@ var DelopayInternal = class extends Delopay {
11100
11377
  resolveAirwallexLabelStyle,
11101
11378
  resolveApplePayButtonStyle,
11102
11379
  resolveGooglePayButtonColor,
11380
+ resolveNoticesAndBadges,
11103
11381
  resolveStripeTheme,
11104
11382
  ruleMatchToTree,
11105
11383
  sanitizeCustomCss,
11106
11384
  sectionLabel,
11107
11385
  sectionOrderOf,
11108
11386
  shadowFor,
11387
+ shownNotices,
11109
11388
  stripeSpacingValues,
11110
11389
  surchargeFigurePlan,
11111
11390
  surchargeShowsLabel,