@useinsider/guido 3.25.0 → 3.26.0-beta.17e2434

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 (85) hide show
  1. package/README.md +11 -0
  2. package/dist/@types/config/schemas.js +106 -100
  3. package/dist/@types/display-condition.js +25 -0
  4. package/dist/components/Guido.vue.js +7 -7
  5. package/dist/components/Guido.vue2.js +113 -104
  6. package/dist/components/organisms/display-conditions/CodeEditorField.vue.js +17 -0
  7. package/dist/components/organisms/display-conditions/CodeEditorField.vue2.js +41 -0
  8. package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.js +30 -0
  9. package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue2.js +81 -0
  10. package/dist/components/organisms/display-conditions/DisplayConditionListState.vue.js +17 -0
  11. package/dist/components/organisms/display-conditions/DisplayConditionListState.vue2.js +45 -0
  12. package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.js +36 -0
  13. package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue2.js +63 -0
  14. package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue.js +17 -0
  15. package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue2.js +22 -0
  16. package/dist/components/organisms/unsubscribe/LegacyUnsubscribeConvertedModal.vue.js +17 -0
  17. package/dist/components/organisms/unsubscribe/LegacyUnsubscribeConvertedModal.vue2.js +30 -0
  18. package/dist/composables/useBlocksConfig.js +29 -20
  19. package/dist/composables/useDisplayConditions.js +116 -0
  20. package/dist/composables/useModuleRepair.js +33 -24
  21. package/dist/composables/useSave.js +57 -52
  22. package/dist/composables/useSaveValidation.js +118 -110
  23. package/dist/composables/useTranslations.js +2 -1
  24. package/dist/composables/validators/useUnsubscribeBlockValidator.js +48 -33
  25. package/dist/config/compiler/utils/itemsCompilerUtils.js +43 -42
  26. package/dist/config/compiler/utils/recommendationCompilerUtils.js +67 -64
  27. package/dist/config/migrator/index.js +8 -7
  28. package/dist/config/migrator/legacyUnsubscribeTextMigrator.js +16 -0
  29. package/dist/enums/academy.js +3 -1
  30. package/dist/enums/display-condition.js +12 -0
  31. package/dist/enums/save-validation.js +1 -1
  32. package/dist/extensions/DisplayConditions/bridge.js +25 -0
  33. package/dist/extensions/DisplayConditions/constants.js +26 -0
  34. package/dist/extensions/DisplayConditions/control.js +215 -0
  35. package/dist/extensions/DisplayConditions/display-conditions.css.js +226 -0
  36. package/dist/extensions/DisplayConditions/extension.js +28 -0
  37. package/dist/extensions/DisplayConditions/iconsRegistry.js +20 -0
  38. package/dist/extensions/DisplayConditions/library.js +30 -0
  39. package/dist/extensions/DisplayConditions/settingsPanel.js +17 -0
  40. package/dist/guido.css +1 -1
  41. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +93 -92
  42. package/dist/node_modules/valibot/dist/index.js +297 -261
  43. package/dist/package.json.js +2 -2
  44. package/dist/services/displayConditionApi.js +39 -0
  45. package/dist/src/@types/config/schemas.d.ts +12 -0
  46. package/dist/src/@types/display-condition.d.ts +61 -0
  47. package/dist/src/components/organisms/display-conditions/CodeEditorField.vue.d.ts +43 -0
  48. package/dist/src/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.d.ts +2 -0
  49. package/dist/src/components/organisms/display-conditions/DisplayConditionListState.vue.d.ts +18 -0
  50. package/dist/src/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.d.ts +2 -0
  51. package/dist/src/components/organisms/display-conditions/DisplayConditionsHost.vue.d.ts +2 -0
  52. package/dist/src/components/organisms/unsubscribe/LegacyUnsubscribeConvertedModal.vue.d.ts +2 -0
  53. package/dist/src/composables/useConfig.d.ts +6 -0
  54. package/dist/src/composables/useDisplayConditions.d.ts +18 -0
  55. package/dist/src/composables/useModuleRepair.d.ts +2 -11
  56. package/dist/src/composables/useSaveValidation.d.ts +1 -1
  57. package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +4 -0
  58. package/dist/src/config/migrator/legacyUnsubscribeTextMigrator.d.ts +1 -0
  59. package/dist/src/enums/academy.d.ts +2 -0
  60. package/dist/src/enums/display-condition.d.ts +15 -0
  61. package/dist/src/enums/save-validation.d.ts +2 -1
  62. package/dist/src/extensions/DisplayConditions/bridge.d.ts +7 -0
  63. package/dist/src/extensions/DisplayConditions/constants.d.ts +23 -0
  64. package/dist/src/extensions/DisplayConditions/control.d.ts +25 -0
  65. package/dist/src/extensions/DisplayConditions/extension.d.ts +2 -0
  66. package/dist/src/extensions/DisplayConditions/iconsRegistry.d.ts +4 -0
  67. package/dist/src/extensions/DisplayConditions/library.d.ts +8 -0
  68. package/dist/src/extensions/DisplayConditions/settingsPanel.d.ts +5 -0
  69. package/dist/src/mock/api/display-conditions.d.ts +2 -0
  70. package/dist/src/services/displayConditionApi.d.ts +8 -0
  71. package/dist/src/stores/config.d.ts +210 -0
  72. package/dist/src/stores/display-condition.d.ts +86 -0
  73. package/dist/src/stores/editor.d.ts +27 -0
  74. package/dist/src/utils/displayCondition.d.ts +11 -0
  75. package/dist/src/utils/legacyUnsubscribeConversion.d.ts +10 -0
  76. package/dist/src/utils/protectTableText.d.ts +2 -0
  77. package/dist/static/styles/variables.css.js +1 -0
  78. package/dist/stores/config.js +13 -6
  79. package/dist/stores/display-condition.js +29 -0
  80. package/dist/stores/editor.js +1 -0
  81. package/dist/utils/displayCondition.js +29 -0
  82. package/dist/utils/legacyUnsubscribeConversion.js +49 -0
  83. package/dist/utils/pairProductVariables.js +29 -28
  84. package/dist/utils/protectTableText.js +22 -0
  85. package/package.json +1 -1
@@ -12,6 +12,7 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
12
12
  hasChanges: boolean;
13
13
  changeSeq: number;
14
14
  isStripoInitialized: boolean;
15
+ isLegacyUnsubscribeModalRequested: boolean;
15
16
  templateId: string;
16
17
  syncModulesEnabled: boolean;
17
18
  trackIdSessionFloor: number;
@@ -29,6 +30,7 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
29
30
  hasChanges: boolean;
30
31
  changeSeq: number;
31
32
  isStripoInitialized: boolean;
33
+ isLegacyUnsubscribeModalRequested: boolean;
32
34
  templateId: string;
33
35
  syncModulesEnabled: boolean;
34
36
  trackIdSessionFloor: number;
@@ -45,6 +47,7 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
45
47
  hasChanges: boolean;
46
48
  changeSeq: number;
47
49
  isStripoInitialized: boolean;
50
+ isLegacyUnsubscribeModalRequested: boolean;
48
51
  templateId: string;
49
52
  syncModulesEnabled: boolean;
50
53
  trackIdSessionFloor: number;
@@ -62,6 +65,7 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
62
65
  hasChanges: boolean;
63
66
  changeSeq: number;
64
67
  isStripoInitialized: boolean;
68
+ isLegacyUnsubscribeModalRequested: boolean;
65
69
  templateId: string;
66
70
  syncModulesEnabled: boolean;
67
71
  trackIdSessionFloor: number;
@@ -78,6 +82,7 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
78
82
  hasChanges: boolean;
79
83
  changeSeq: number;
80
84
  isStripoInitialized: boolean;
85
+ isLegacyUnsubscribeModalRequested: boolean;
81
86
  templateId: string;
82
87
  syncModulesEnabled: boolean;
83
88
  trackIdSessionFloor: number;
@@ -95,6 +100,7 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
95
100
  hasChanges: boolean;
96
101
  changeSeq: number;
97
102
  isStripoInitialized: boolean;
103
+ isLegacyUnsubscribeModalRequested: boolean;
98
104
  templateId: string;
99
105
  syncModulesEnabled: boolean;
100
106
  trackIdSessionFloor: number;
@@ -111,6 +117,7 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
111
117
  hasChanges: boolean;
112
118
  changeSeq: number;
113
119
  isStripoInitialized: boolean;
120
+ isLegacyUnsubscribeModalRequested: boolean;
114
121
  templateId: string;
115
122
  syncModulesEnabled: boolean;
116
123
  trackIdSessionFloor: number;
@@ -128,6 +135,7 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
128
135
  hasChanges: boolean;
129
136
  changeSeq: number;
130
137
  isStripoInitialized: boolean;
138
+ isLegacyUnsubscribeModalRequested: boolean;
131
139
  templateId: string;
132
140
  syncModulesEnabled: boolean;
133
141
  trackIdSessionFloor: number;
@@ -144,6 +152,7 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
144
152
  hasChanges: boolean;
145
153
  changeSeq: number;
146
154
  isStripoInitialized: boolean;
155
+ isLegacyUnsubscribeModalRequested: boolean;
147
156
  templateId: string;
148
157
  syncModulesEnabled: boolean;
149
158
  trackIdSessionFloor: number;
@@ -161,6 +170,7 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
161
170
  hasChanges: boolean;
162
171
  changeSeq: number;
163
172
  isStripoInitialized: boolean;
173
+ isLegacyUnsubscribeModalRequested: boolean;
164
174
  templateId: string;
165
175
  syncModulesEnabled: boolean;
166
176
  trackIdSessionFloor: number;
@@ -177,6 +187,7 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
177
187
  hasChanges: boolean;
178
188
  changeSeq: number;
179
189
  isStripoInitialized: boolean;
190
+ isLegacyUnsubscribeModalRequested: boolean;
180
191
  templateId: string;
181
192
  syncModulesEnabled: boolean;
182
193
  trackIdSessionFloor: number;
@@ -194,6 +205,7 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
194
205
  hasChanges: boolean;
195
206
  changeSeq: number;
196
207
  isStripoInitialized: boolean;
208
+ isLegacyUnsubscribeModalRequested: boolean;
197
209
  templateId: string;
198
210
  syncModulesEnabled: boolean;
199
211
  trackIdSessionFloor: number;
@@ -210,6 +222,7 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
210
222
  hasChanges: boolean;
211
223
  changeSeq: number;
212
224
  isStripoInitialized: boolean;
225
+ isLegacyUnsubscribeModalRequested: boolean;
213
226
  templateId: string;
214
227
  syncModulesEnabled: boolean;
215
228
  trackIdSessionFloor: number;
@@ -227,6 +240,7 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
227
240
  hasChanges: boolean;
228
241
  changeSeq: number;
229
242
  isStripoInitialized: boolean;
243
+ isLegacyUnsubscribeModalRequested: boolean;
230
244
  templateId: string;
231
245
  syncModulesEnabled: boolean;
232
246
  trackIdSessionFloor: number;
@@ -243,6 +257,7 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
243
257
  hasChanges: boolean;
244
258
  changeSeq: number;
245
259
  isStripoInitialized: boolean;
260
+ isLegacyUnsubscribeModalRequested: boolean;
246
261
  templateId: string;
247
262
  syncModulesEnabled: boolean;
248
263
  trackIdSessionFloor: number;
@@ -260,6 +275,7 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
260
275
  hasChanges: boolean;
261
276
  changeSeq: number;
262
277
  isStripoInitialized: boolean;
278
+ isLegacyUnsubscribeModalRequested: boolean;
263
279
  templateId: string;
264
280
  syncModulesEnabled: boolean;
265
281
  trackIdSessionFloor: number;
@@ -276,6 +292,7 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
276
292
  hasChanges: boolean;
277
293
  changeSeq: number;
278
294
  isStripoInitialized: boolean;
295
+ isLegacyUnsubscribeModalRequested: boolean;
279
296
  templateId: string;
280
297
  syncModulesEnabled: boolean;
281
298
  trackIdSessionFloor: number;
@@ -293,6 +310,7 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
293
310
  hasChanges: boolean;
294
311
  changeSeq: number;
295
312
  isStripoInitialized: boolean;
313
+ isLegacyUnsubscribeModalRequested: boolean;
296
314
  templateId: string;
297
315
  syncModulesEnabled: boolean;
298
316
  trackIdSessionFloor: number;
@@ -309,6 +327,7 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
309
327
  hasChanges: boolean;
310
328
  changeSeq: number;
311
329
  isStripoInitialized: boolean;
330
+ isLegacyUnsubscribeModalRequested: boolean;
312
331
  templateId: string;
313
332
  syncModulesEnabled: boolean;
314
333
  trackIdSessionFloor: number;
@@ -326,6 +345,7 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
326
345
  hasChanges: boolean;
327
346
  changeSeq: number;
328
347
  isStripoInitialized: boolean;
348
+ isLegacyUnsubscribeModalRequested: boolean;
329
349
  templateId: string;
330
350
  syncModulesEnabled: boolean;
331
351
  trackIdSessionFloor: number;
@@ -342,6 +362,7 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
342
362
  hasChanges: boolean;
343
363
  changeSeq: number;
344
364
  isStripoInitialized: boolean;
365
+ isLegacyUnsubscribeModalRequested: boolean;
345
366
  templateId: string;
346
367
  syncModulesEnabled: boolean;
347
368
  trackIdSessionFloor: number;
@@ -359,6 +380,7 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
359
380
  hasChanges: boolean;
360
381
  changeSeq: number;
361
382
  isStripoInitialized: boolean;
383
+ isLegacyUnsubscribeModalRequested: boolean;
362
384
  templateId: string;
363
385
  syncModulesEnabled: boolean;
364
386
  trackIdSessionFloor: number;
@@ -375,6 +397,7 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
375
397
  hasChanges: boolean;
376
398
  changeSeq: number;
377
399
  isStripoInitialized: boolean;
400
+ isLegacyUnsubscribeModalRequested: boolean;
378
401
  templateId: string;
379
402
  syncModulesEnabled: boolean;
380
403
  trackIdSessionFloor: number;
@@ -392,6 +415,7 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
392
415
  hasChanges: boolean;
393
416
  changeSeq: number;
394
417
  isStripoInitialized: boolean;
418
+ isLegacyUnsubscribeModalRequested: boolean;
395
419
  templateId: string;
396
420
  syncModulesEnabled: boolean;
397
421
  trackIdSessionFloor: number;
@@ -408,6 +432,7 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
408
432
  hasChanges: boolean;
409
433
  changeSeq: number;
410
434
  isStripoInitialized: boolean;
435
+ isLegacyUnsubscribeModalRequested: boolean;
411
436
  templateId: string;
412
437
  syncModulesEnabled: boolean;
413
438
  trackIdSessionFloor: number;
@@ -425,6 +450,7 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
425
450
  hasChanges: boolean;
426
451
  changeSeq: number;
427
452
  isStripoInitialized: boolean;
453
+ isLegacyUnsubscribeModalRequested: boolean;
428
454
  templateId: string;
429
455
  syncModulesEnabled: boolean;
430
456
  trackIdSessionFloor: number;
@@ -441,6 +467,7 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
441
467
  hasChanges: boolean;
442
468
  changeSeq: number;
443
469
  isStripoInitialized: boolean;
470
+ isLegacyUnsubscribeModalRequested: boolean;
444
471
  templateId: string;
445
472
  syncModulesEnabled: boolean;
446
473
  trackIdSessionFloor: number;
@@ -0,0 +1,11 @@
1
+ import type { AppliedDisplayCondition, DisplayConditionSyntax } from '@@/Types/display-condition';
2
+ import { DisplayConditionSourceType } from '@@/Enums/display-condition';
3
+ export declare const parseSource: (condition: AppliedDisplayCondition | null | undefined) => DisplayConditionSourceType | null;
4
+ type ConditionLike = Omit<AppliedDisplayCondition, 'description'> & {
5
+ description?: string | null;
6
+ };
7
+ export declare const toAppliedCondition: (condition: ConditionLike | null | undefined) => AppliedDisplayCondition | null;
8
+ export declare const nextConditionId: () => number;
9
+ export type CodeField = 'codeBefore' | 'codeAfter';
10
+ export declare const findInvalidCodeFields: (codeBefore: string, codeAfter: string, syntax?: DisplayConditionSyntax) => CodeField[];
11
+ export {};
@@ -0,0 +1,10 @@
1
+ export declare const LEGACY_UNSUBSCRIBE_SELECTOR = "td.unsubscribe-block";
2
+ export declare const LEGACY_UNSUBSCRIBE_LINK_SELECTORS: readonly ["a.unsubscribe-link", "a[href*=\"unsubscribe\"]"];
3
+ export interface LegacyUnsubscribeConversionResult {
4
+ html: string;
5
+ converted: boolean;
6
+ }
7
+ export declare const hasLegacyUnsubscribeClass: (html: string) => boolean;
8
+ export declare const convertLinklessLegacyUnsubscribeBlocks: (root: ParentNode) => number;
9
+ export declare const convertLegacyUnsubscribeInModuleHtml: (html: string) => LegacyUnsubscribeConversionResult;
10
+ export declare const convertLegacyUnsubscribeInDocumentHtml: (html: string) => LegacyUnsubscribeConversionResult;
@@ -0,0 +1,2 @@
1
+ export declare function protectTableText(html: string): string;
2
+ export declare const restoreTableText: (html: string) => string;
@@ -12,6 +12,7 @@ const o = `:host {
12
12
  --guido-color-gray-100: #F5F5F5;
13
13
  --guido-color-gray-1: #F0F0F0;
14
14
  --guido-color-gray-0: #F9F9F9;
15
+ --guido-color-neutral-900: #0A0F19;
15
16
  --guido-color-neutral-800: #222938;
16
17
  --guido-color-neutral-700: #2C3546;
17
18
  --guido-color-neutral-500: #5D6980;
@@ -1,8 +1,8 @@
1
- import { MessageType as r } from "../@types/config/schemas.js";
1
+ import { MessageType as a } from "../@types/config/schemas.js";
2
2
  import "../@types/config/defaults.js";
3
- import { parseConfig as a } from "../@types/config/validator.js";
4
- import { defineStore as o } from "pinia";
5
- const g = o("guido-config", {
3
+ import { parseConfig as o } from "../@types/config/validator.js";
4
+ import { defineStore as l } from "pinia";
5
+ const g = l("guido-config", {
6
6
  state: () => ({
7
7
  initialized: !1,
8
8
  config: null
@@ -132,7 +132,7 @@ const g = o("guido-config", {
132
132
  * consumers stay safe in setup where a raw config read snapshots null (SD-147945).
133
133
  */
134
134
  isTransactional() {
135
- return this.messageType === r.TRANSACTIONAL;
135
+ return this.messageType === a.TRANSACTIONAL;
136
136
  },
137
137
  /**
138
138
  * Soft-save policy: may the editor persist a template with validation errors?
@@ -158,6 +158,13 @@ const g = o("guido-config", {
158
158
  var e, t;
159
159
  return ((t = (e = i.config) == null ? void 0 : e.ui) == null ? void 0 : t.showHeader) ?? !0;
160
160
  },
161
+ /**
162
+ * Check if the Insider display-condition UI replaces Stripo's
163
+ */
164
+ externalDisplayConditions: (i) => {
165
+ var e, t, n, r;
166
+ return (((t = (e = i.config) == null ? void 0 : e.ui) == null ? void 0 : t.externalDisplayConditions) ?? !1) && (((r = (n = i.config) == null ? void 0 : n.features) == null ? void 0 : r.displayConditions) ?? !0);
167
+ },
161
168
  /**
162
169
  * Check if a specific feature is enabled.
163
170
  * Returns false before init (config null) so header controls don't
@@ -174,7 +181,7 @@ const g = o("guido-config", {
174
181
  * Initialize the config store with validated configuration
175
182
  */
176
183
  init(i) {
177
- const e = a(i);
184
+ const e = o(i);
178
185
  this.config = e, this.initialized = !0;
179
186
  },
180
187
  /**
@@ -0,0 +1,29 @@
1
+ import { defineStore as t } from "pinia";
2
+ const n = t("guidoDisplayCondition", {
3
+ state: () => ({
4
+ view: "none",
5
+ editing: null,
6
+ list: [],
7
+ listStatus: "idle",
8
+ listRequest: 0,
9
+ pendingDelete: null
10
+ }),
11
+ getters: {
12
+ isCreateOpen: (e) => e.view === "create",
13
+ isSelectOpen: (e) => e.view === "select"
14
+ },
15
+ actions: {
16
+ openCreate(e = null) {
17
+ this.editing = e, this.view = "create";
18
+ },
19
+ openSelect() {
20
+ this.editing = null, this.view = "select";
21
+ },
22
+ close() {
23
+ this.view = "none", this.pendingDelete = null;
24
+ }
25
+ }
26
+ });
27
+ export {
28
+ n as useDisplayConditionStore
29
+ };
@@ -16,6 +16,7 @@ const o = e("guidoEditor", {
16
16
  // that need every change (the outbound state bridge) watch this instead.
17
17
  changeSeq: 0,
18
18
  isStripoInitialized: !1,
19
+ isLegacyUnsubscribeModalRequested: !1,
19
20
  templateId: "",
20
21
  syncModulesEnabled: !1,
21
22
  // In-session id high-water mark; floors tracking-id minting so ids
@@ -0,0 +1,29 @@
1
+ import { DisplayConditionSourceType as n } from "../enums/display-condition.js";
2
+ const p = "PREDEFINED", I = (e) => {
3
+ if (!e)
4
+ return null;
5
+ if (e.type === p)
6
+ return n.SAVED;
7
+ try {
8
+ const t = JSON.parse(e.extraData || "{}");
9
+ return (t == null ? void 0 : t.source) === n.SAVED ? n.SAVED : n.INLINE;
10
+ } catch {
11
+ return n.INLINE;
12
+ }
13
+ }, m = (e) => !e || !(e.name || e.beforeScript || e.afterScript) ? null : { ...e, description: e.description ?? "" };
14
+ let l = 0;
15
+ const _ = () => (l = Math.max(Date.now(), l + 1), l), E = /{%-?\s*(\w+)[\s\S]*?-?%}/g, S = /{%[\s\S]*?%}|{{[\s\S]*?}}/g, u = /{%-?\s*(comment|raw)\s*-?%}[\s\S]*?{%-?\s*end\1\s*-?%}/g, A = /{#[\s\S]*?#}/g, f = /* @__PURE__ */ new Set(["if", "unless", "for", "case", "capture", "tablerow", "comment"]), T = /* @__PURE__ */ new Set(["else", "elsif", "elif", "when"]), h = (e) => /{%|{{/.test(e.replace(S, "")), C = (e, t, d = "liquid") => {
16
+ const r = /* @__PURE__ */ new Set(), o = [];
17
+ return [["codeBefore", e], ["codeAfter", t]].forEach(([c, a]) => {
18
+ const i = (d === "pongo" ? a.replace(A, "") : a).replace(u, "");
19
+ h(i) && r.add(c), Array.from(i.matchAll(E), (s) => s[1]).forEach((s) => {
20
+ f.has(s) ? o.push(s) : s.startsWith("end") && f.has(s.slice(3)) ? o.pop() !== s.slice(3) && r.add(c) : T.has(s) && !o.length && r.add(c);
21
+ });
22
+ }), o.length && r.add("codeAfter"), [...r];
23
+ };
24
+ export {
25
+ C as findInvalidCodeFields,
26
+ _ as nextConditionId,
27
+ I as parseSource,
28
+ m as toAppliedCondition
29
+ };
@@ -0,0 +1,49 @@
1
+ import { protectLiquid as a, restoreLiquid as u } from "./liquidProtection.js";
2
+ const b = "td.unsubscribe-block", l = ["a.unsubscribe-link", 'a[href*="unsubscribe"]'], d = "esd-block-text", m = [
3
+ "unsubscribe-block",
4
+ "esd-extension",
5
+ "esd-extension-block",
6
+ "esd-unsubscribe-block",
7
+ "esd-block-unsubscribe"
8
+ ], L = "esd-extension-block-id", S = "data-unsubscribe-", E = "address,article,aside,blockquote,center,details,dialog,dir,div,dd,dl,dt,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,li,listing,main,menu,nav,ol,p,plaintext,pre,search,section,summary,table,ul,xmp", f = new RegExp(`class\\s*=\\s*(?:["'][^"']*)?(?<![\\w-])unsubscribe-block(?![\\w-])`, "i"), p = (e) => typeof e == "string" && f.test(e), y = (e) => l.some((t) => e.querySelector(t) !== null), g = (e) => {
9
+ e.classList.remove(...m), e.classList.add(d), e.removeAttribute(L), Array.from(e.attributes).filter(({ name: t }) => t.startsWith(S)).forEach(({ name: t }) => e.removeAttribute(t)), e.querySelector(E) || (e.innerHTML = `<p path="1">${e.innerHTML}</p>`);
10
+ }, h = (e) => {
11
+ const t = Array.from(e.querySelectorAll(b)).filter((r) => !y(r));
12
+ return t.forEach(g), t.length;
13
+ }, v = (e) => {
14
+ const t = e.trimStart(), r = new DOMParser();
15
+ return /^<t[dh][\s>]/i.test(t) ? r.parseFromString(`<table><tbody><tr>${e}</tr></tbody></table>`, "text/html").querySelector("tr") : /^<tr[\s>]/i.test(t) ? r.parseFromString(`<table><tbody>${e}</tbody></table>`, "text/html").querySelector("tbody") : /^<table[\s>]/i.test(t) ? r.parseFromString(e, "text/html").body : (console.debug("[LegacyUnsubscribeConversion] Skipped module with a non-table root"), null);
16
+ }, c = (e) => {
17
+ const t = e.search(/<html[\s>]/i), r = [...e.matchAll(/<\/html\s*>/gi)].at(-1), s = (r == null ? void 0 : r.index) === void 0 ? -1 : r.index + r[0].length;
18
+ return t < 0 || s <= t ? { head: "", root: e, tail: "" } : { head: e.slice(0, t), root: e.slice(t, s), tail: e.slice(s) };
19
+ }, i = (e, t, r, s) => {
20
+ if (!p(e))
21
+ return { html: e, converted: !1 };
22
+ try {
23
+ const o = a(e), n = t(o);
24
+ return !n || h(n) === 0 ? { html: e, converted: !1 } : { html: u(r(n, o)), converted: !0 };
25
+ } catch (o) {
26
+ return console.error(`Failed to convert legacy unsubscribe blocks in ${s}:`, o), { html: e, converted: !1 };
27
+ }
28
+ }, C = (e) => i(
29
+ e,
30
+ v,
31
+ (t) => t.innerHTML,
32
+ "module"
33
+ ), _ = (e) => i(
34
+ e,
35
+ (t) => new DOMParser().parseFromString(c(t).root, "text/html"),
36
+ (t, r) => {
37
+ const { head: s, tail: o } = c(r);
38
+ return `${s}${t.documentElement.outerHTML}${o}`;
39
+ },
40
+ "document"
41
+ );
42
+ export {
43
+ l as LEGACY_UNSUBSCRIBE_LINK_SELECTORS,
44
+ b as LEGACY_UNSUBSCRIBE_SELECTOR,
45
+ _ as convertLegacyUnsubscribeInDocumentHtml,
46
+ C as convertLegacyUnsubscribeInModuleHtml,
47
+ h as convertLinklessLegacyUnsubscribeBlocks,
48
+ p as hasLegacyUnsubscribeClass
49
+ };
@@ -2,26 +2,27 @@ import { isNewPriceFormatRoot as G, ITEMS_PRICE_FORMAT_ATTR as N, currencyPositi
2
2
  import { productPairs as k } from "../extensions/Blocks/Items/enums/productEnums.js";
3
3
  import { escapeReplacement as v } from "../extensions/Blocks/Items/utils/nodeConfigUtils.js";
4
4
  import { preserveTextStyles as w } from "./preserveTextStyles.js";
5
- import { unwrapProductNameLinks as X } from "./unwrapProductNameLink.js";
5
+ import { protectTableText as X, restoreTableText as j } from "./protectTableText.js";
6
+ import { unwrapProductNameLinks as Q } from "./unwrapProductNameLink.js";
6
7
  const q = {
7
8
  CART_ITEMS: "ins_apr",
8
9
  BROWSED_ITEMS: "browsed_item",
9
10
  PURCHASED_ITEMS: "purchased_item"
10
11
  }, W = (r) => r.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->");
11
- function j(r, h, p) {
12
+ function z(r, h, p) {
12
13
  let u = h;
13
14
  for (; u > 0 && /\s/.test(r[u - 1]); )
14
15
  u -= 1;
15
16
  return p.some((A) => r.endsWith(A, u));
16
17
  }
17
- const Q = /(\s)href=(["'])(?:[^"']*#!|#)?\2/gi;
18
- function z(r, h) {
18
+ const J = /(\s)href=(["'])(?:[^"']*#!|#)?\2/gi;
19
+ function K(r, h) {
19
20
  var u;
20
21
  const p = r.ownerDocument.createTreeWalker(r, NodeFilter.SHOW_COMMENT);
21
22
  for (let A = p.nextNode(); A; A = p.nextNode())
22
- (u = A.nodeValue) != null && u.includes("[if mso]") && (A.nodeValue = A.nodeValue.replace(Q, (L, P) => `${P}href="${h}"`));
23
+ (u = A.nodeValue) != null && u.includes("[if mso]") && (A.nodeValue = A.nodeValue.replace(J, (L, P) => `${P}href="${h}"`));
23
24
  }
24
- function J(r) {
25
+ function Z(r) {
25
26
  return {
26
27
  isFormatted: r.getAttribute("data-formated") === "true",
27
28
  isSinglePrice: r.getAttribute("data-single_price") === "true",
@@ -29,7 +30,7 @@ function J(r) {
29
30
  configuredSymbol: (r.getAttribute(U.SYMBOL) || "").trim()
30
31
  };
31
32
  }
32
- function K(r) {
33
+ function tt(r) {
33
34
  return {
34
35
  isFormatted: !1,
35
36
  isSinglePrice: r.getAttribute(N.SINGLE_PRICE) === "true",
@@ -39,7 +40,7 @@ function K(r) {
39
40
  configuredSymbol: (r.getAttribute(N.SYMBOL) || "").trim()
40
41
  };
41
42
  }
42
- function Z(r, h, p) {
43
+ function et(r, h, p) {
43
44
  const { isFormatted: u, isSinglePrice: A, currencyPosition: L, configuredSymbol: P } = p;
44
45
  let y;
45
46
  A ? y = u ? r.SINGLE_PRICE_FORMATTED : r.SINGLE_PRICE : y = u ? r.PRICE_FORMATTED : r.PRICE;
@@ -47,15 +48,15 @@ function Z(r, h, p) {
47
48
  let F = `{{${y}_${h}}}`, R = "";
48
49
  return B(P) ? R = P : E && (R = `{{${E}_${h}}}`), R && (F = L === "after" ? `${F} ${R}` : `${R} ${F}`), F;
49
50
  }
50
- function ct(r) {
51
- const h = W(r), p = new DOMParser().parseFromString(h, "text/html");
52
- X(p);
51
+ function at(r) {
52
+ const h = W(X(r)), p = new DOMParser().parseFromString(h, "text/html");
53
+ Q(p);
53
54
  const u = k.PAIRS_FOR_EXTENSION;
54
55
  Object.entries(u).forEach(([o, T]) => {
55
56
  p.querySelectorAll(".ins-product-td").forEach((n) => {
56
57
  const S = n.getAttribute("data-number") || "1", I = n.getAttribute("data-type") || "CART_ITEMS";
57
58
  n.querySelectorAll(`[product-attr="${o}"]`).forEach((t) => {
58
- var b, M, D, x;
59
+ var g, M, x, D;
59
60
  const m = t.getAttribute("data-type") || I, c = t.getAttribute("data-number") || S, f = T[m];
60
61
  if (f)
61
62
  switch (o) {
@@ -71,9 +72,9 @@ function ct(r) {
71
72
  return l.includes(C) || l.includes($) || V === $;
72
73
  }) && (e.src = `{{${a}_${c}}}`);
73
74
  }
74
- const s = (M = (b = u.name) == null ? void 0 : b[m]) == null ? void 0 : M.ATTR;
75
+ const s = (M = (g = u.name) == null ? void 0 : g[m]) == null ? void 0 : M.ATTR;
75
76
  if (s && e.setAttribute("alt", `{{${s}_${c}}}`), i) {
76
- const l = (D = u.itemLink) == null ? void 0 : D[m];
77
+ const l = (x = u.itemLink) == null ? void 0 : x[m];
77
78
  if (l) {
78
79
  const H = l.HREF, C = l.DEFAULT_HREF || "#!", $ = i.href;
79
80
  ($ === "#" || $ === "" || $.endsWith("#!") || $.endsWith(C) || $ === `${window.location.href}${C}` || !$ || $ === window.location.href) && (i.href = `{{${H}_${c}}}`);
@@ -93,12 +94,12 @@ function ct(r) {
93
94
  }
94
95
  case "price":
95
96
  case "originalPrice": {
96
- const e = f, i = G(n) ? K(n) : J(t);
97
- t.innerHTML = w(t, Z(e, c, i));
97
+ const e = f, i = G(n) ? tt(n) : Z(t);
98
+ t.innerHTML = w(t, et(e, c, i));
98
99
  break;
99
100
  }
100
101
  case "quantity": {
101
- const e = f, i = e.ATTR, d = [e.DEFAULT, ...e.LEGACY_DEFAULTS], a = (x = t.textContent) == null ? void 0 : x.trim();
102
+ const e = f, i = e.ATTR, d = [e.DEFAULT, ...e.LEGACY_DEFAULTS], a = (D = t.textContent) == null ? void 0 : D.trim();
102
103
  a && d.includes(a) && (t.innerHTML = w(t, `{{${i}_${c}}}`));
103
104
  break;
104
105
  }
@@ -108,7 +109,7 @@ function ct(r) {
108
109
  const s = a.href || "", l = `${window.location.href}${d}`;
109
110
  (s === "" || s === "#" || s === l || s.endsWith(d) || s.endsWith("#!") || s === window.location.href) && (a.href = `{{${i}_${c}}}`);
110
111
  }
111
- z(t, `{{${i}_${c}}}`);
112
+ K(t, `{{${i}_${c}}}`);
112
113
  break;
113
114
  }
114
115
  case "itemLink": {
@@ -145,7 +146,7 @@ function ct(r) {
145
146
  y.reverse().forEach(({ outerHtml: o, type: T, number: _ }) => {
146
147
  const n = q[T], S = n ? `${n}_total_product_kind` : "";
147
148
  if (S) {
148
- const g = parseInt(_) - 1, c = `${`{% if ${S} > ${g} %}`}${o}{% endif %}`;
149
+ const b = parseInt(_) - 1, c = `${`{% if ${S} > ${b} %}`}${o}{% endif %}`;
149
150
  E = E.replace(o, v(c));
150
151
  }
151
152
  });
@@ -159,20 +160,20 @@ function ct(r) {
159
160
  if (!n || O.has(n))
160
161
  return;
161
162
  O.add(n);
162
- const S = n.outerHTML, I = (t = o.closest(".ins-product-td")) == null ? void 0 : t.getAttribute("data-nodup"), g = R.get(S) ?? { number: T, type: _, wrap: [] };
163
- g.wrap.push(I !== "false"), R.set(S, g);
163
+ const S = n.outerHTML, I = (t = o.closest(".ins-product-td")) == null ? void 0 : t.getAttribute("data-nodup"), b = R.get(S) ?? { number: T, type: _, wrap: [] };
164
+ b.wrap.push(I !== "false"), R.set(S, b);
164
165
  }), R.forEach(({ number: o, type: T, wrap: _ }, n) => {
165
166
  if (n.includes("{% if") || !_.some(Boolean))
166
167
  return;
167
- const S = k.PAIRS_FOR_EXTENSION.price[T].PRICE, I = k.PAIRS_FOR_EXTENSION.originalPrice[T].PRICE, g = `{% if ${S}_${o} != ${I}_${o} %}`, t = [g, W(g)];
168
- let m = "", c = 0, f = 0, b = E.indexOf(n);
169
- for (; b !== -1; ) {
170
- const M = _[f] === !0 && !j(E, b, t);
171
- m += E.slice(c, b) + (M ? `${g}${n}{% endif %}` : n), c = b + n.length, f += 1, b = E.indexOf(n, c);
168
+ const S = k.PAIRS_FOR_EXTENSION.price[T].PRICE, I = k.PAIRS_FOR_EXTENSION.originalPrice[T].PRICE, b = `{% if ${S}_${o} != ${I}_${o} %}`, t = [b, W(b)];
169
+ let m = "", c = 0, f = 0, g = E.indexOf(n);
170
+ for (; g !== -1; ) {
171
+ const M = _[f] === !0 && !z(E, g, t);
172
+ m += E.slice(c, g) + (M ? `${b}${n}{% endif %}` : n), c = g + n.length, f += 1, g = E.indexOf(n, c);
172
173
  }
173
174
  E = m + E.slice(c);
174
- }), E.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
175
+ }), j(E.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}"));
175
176
  }
176
177
  export {
177
- ct as pairProductVariables
178
+ at as pairProductVariables
178
179
  };
@@ -0,0 +1,22 @@
1
+ const n = "guido-table-text:", i = new RegExp(`<!--${n}([A-Za-z0-9+/=]*)-->`, "g"), T = /<!--[\s\S]*?-->|\{%[\s\S]*?%\}|<[a-zA-Z/!?](?:[^>"']|"[^"]*"|'[^']*')*>|[^<{]+|[<{]/g, o = /* @__PURE__ */ new Set(["table", "tbody", "thead", "tfoot", "tr", "colgroup"]), r = /* @__PURE__ */ new Set(["col"]), f = /* @__PURE__ */ new Set([...o, ...r, "td", "th", "caption"]), p = (s) => btoa(unescape(encodeURIComponent(s))), u = (s) => decodeURIComponent(escape(atob(s))), d = (s) => {
2
+ const e = /^<(\/?)([a-zA-Z][\w-]*)/.exec(s);
3
+ return { name: e ? e[2].toLowerCase() : "", closing: e ? e[1] === "/" : !1 };
4
+ };
5
+ function E(s) {
6
+ const e = [];
7
+ let a = !1;
8
+ return s.replace(T, (t) => {
9
+ if (t.startsWith("<!--") || t.startsWith("{%"))
10
+ return t;
11
+ if (t.length > 1 && t.startsWith("<")) {
12
+ const { name: c, closing: l } = d(t);
13
+ return a = f.has(c), !a || r.has(c) || (l ? e.includes(c) && e.splice(e.lastIndexOf(c)) : e.push(c)), t;
14
+ }
15
+ return a && o.has(e[e.length - 1] ?? "") && t.trim() ? `<!--${n}${p(t)}-->` : t;
16
+ });
17
+ }
18
+ const g = (s) => s.replace(i, (e, a) => u(a));
19
+ export {
20
+ E as protectTableText,
21
+ g as restoreTableText
22
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.25.0",
3
+ "version": "3.26.0-beta.17e2434",
4
4
  "description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
5
5
  "main": "./dist/guido.umd.cjs",
6
6
  "module": "./dist/library.js",