@useinsider/guido 3.24.1-beta.32ff492 → 3.25.0-beta.aa06f6b

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 (73) hide show
  1. package/README.md +10 -0
  2. package/dist/@types/config/schemas.js +22 -18
  3. package/dist/components/Guido.vue.js +4 -4
  4. package/dist/components/Guido.vue2.js +98 -92
  5. package/dist/components/organisms/unsubscribe/LegacyUnsubscribeConvertedModal.vue.js +17 -0
  6. package/dist/components/organisms/unsubscribe/LegacyUnsubscribeConvertedModal.vue2.js +30 -0
  7. package/dist/composables/useActionsApi.js +2 -2
  8. package/dist/composables/useEditorTrackingIds.js +49 -0
  9. package/dist/composables/useHtmlCompiler.js +2 -0
  10. package/dist/composables/useModuleRepair.js +34 -23
  11. package/dist/config/compiler/htmlCompilerRules.js +14 -6
  12. package/dist/config/migrator/index.js +17 -15
  13. package/dist/config/migrator/itemsPriceFormatMigrator.js +20 -0
  14. package/dist/config/migrator/legacyUnsubscribeTextMigrator.js +16 -0
  15. package/dist/enums/academy.js +2 -1
  16. package/dist/extensions/Blocks/Items/block.js +115 -77
  17. package/dist/extensions/Blocks/Items/constants/currency.js +59 -14
  18. package/dist/extensions/Blocks/Items/controls/blockBackground/index.js +11 -0
  19. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +34 -23
  20. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +62 -51
  21. package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +18 -17
  22. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +42 -31
  23. package/dist/extensions/Blocks/Items/controls/priceFormat.js +135 -0
  24. package/dist/extensions/Blocks/Items/controls/settingsControl.js +141 -120
  25. package/dist/extensions/Blocks/Items/enums/controlEnums.js +2 -2
  26. package/dist/extensions/Blocks/Items/extension.js +15 -13
  27. package/dist/extensions/Blocks/Items/items.css.js +19 -0
  28. package/dist/extensions/Blocks/Items/settingsPanel.js +35 -25
  29. package/dist/extensions/Blocks/Items/template.js +250 -212
  30. package/dist/extensions/Blocks/Items/utils/priceFormatOps.js +185 -0
  31. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +10 -8
  32. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +28 -24
  33. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +23 -22
  34. package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +1 -0
  35. package/dist/extensions/Blocks/controlFactories.js +104 -104
  36. package/dist/guido.css +1 -1
  37. package/dist/package.json.js +2 -2
  38. package/dist/services/templateLibraryApi.js +39 -36
  39. package/dist/src/@types/config/schemas.d.ts +8 -0
  40. package/dist/src/components/organisms/unsubscribe/LegacyUnsubscribeConvertedModal.vue.d.ts +2 -0
  41. package/dist/src/composables/useConfig.d.ts +4 -0
  42. package/dist/src/composables/useEditorTrackingIds.d.ts +7 -0
  43. package/dist/src/composables/useModuleRepair.d.ts +2 -11
  44. package/dist/src/config/migrator/index.d.ts +4 -1
  45. package/dist/src/config/migrator/itemsPriceFormatMigrator.d.ts +1 -0
  46. package/dist/src/config/migrator/legacyUnsubscribeTextMigrator.d.ts +1 -0
  47. package/dist/src/enums/academy.d.ts +1 -0
  48. package/dist/src/extensions/Blocks/Items/block.d.ts +6 -9
  49. package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +32 -0
  50. package/dist/src/extensions/Blocks/Items/controls/blockBackground/index.d.ts +15 -0
  51. package/dist/src/extensions/Blocks/Items/controls/priceFormat.d.ts +24 -0
  52. package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +1 -0
  53. package/dist/src/extensions/Blocks/Items/enums/controlEnums.d.ts +2 -0
  54. package/dist/src/extensions/Blocks/Items/template.d.ts +4 -1
  55. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +3 -0
  56. package/dist/src/extensions/Blocks/Items/utils/priceFormatOps.d.ts +66 -0
  57. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +2 -0
  58. package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +12 -0
  59. package/dist/src/extensions/Blocks/controlFactories.d.ts +1 -1
  60. package/dist/src/stores/config.d.ts +40 -0
  61. package/dist/src/stores/editor.d.ts +27 -0
  62. package/dist/src/utils/itemsCurrencyRepair.d.ts +5 -1
  63. package/dist/src/utils/legacyUnsubscribeConversion.d.ts +10 -0
  64. package/dist/src/utils/linkTrackingIds.d.ts +19 -0
  65. package/dist/src/utils/trimHrefWhitespace.d.ts +5 -0
  66. package/dist/stores/editor.js +1 -0
  67. package/dist/utils/itemsCurrencyRepair.js +29 -24
  68. package/dist/utils/legacyUnsubscribeConversion.js +49 -0
  69. package/dist/utils/linkTrackingIds.js +82 -48
  70. package/dist/utils/pairProductVariables.js +119 -99
  71. package/dist/utils/templatePreparation.js +30 -33
  72. package/dist/utils/trimHrefWhitespace.js +10 -0
  73. 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;
@@ -1,3 +1,7 @@
1
+ export interface ItemsCurrencyRepairOptions {
2
+ /** Convert legacy-model blocks to the root price-format contract (itemsPriceFormatting). */
3
+ convertToPriceFormat?: boolean;
4
+ }
1
5
  /**
2
6
  * Heals stale price currency attributes on every v2 Items block inside a dropped
3
7
  * saved module, driving `data-curency` / `data-currency_symbol` from each block's
@@ -14,4 +18,4 @@
14
18
  * recommendationMigrator wraps). If the wrap fails to capture the blocks (non-`<td>`
15
19
  * root foster-parented out), it bails to the original string.
16
20
  */
17
- export declare function repairItemsCurrencyAttributes(html: string): string;
21
+ export declare function repairItemsCurrencyAttributes(html: string, { convertToPriceFormat }?: ItemsCurrencyRepairOptions): string;
@@ -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;
@@ -20,6 +20,25 @@ export declare function readTrackSeq(html: string): number;
20
20
  * Scans the document because a rewrite can strip the seq host but keep the ids.
21
21
  */
22
22
  export declare function readTrackFloor(html: string, persistedCounter?: number): number;
23
+ export interface TrackingIdPlan {
24
+ /** Final id per anchor, in the order the raw values were given. */
25
+ ids: number[];
26
+ reassigned: boolean[];
27
+ nextSeq: number;
28
+ seqChanged: boolean;
29
+ changed: boolean;
30
+ }
31
+ /**
32
+ * The id rule shared by the string transform and the editor-model writer: `rawIds` are the
33
+ * anchors' current `data-ins-track-id` values in document order ('' when absent).
34
+ */
35
+ export declare function planTrackingIds(rawIds: readonly string[], persistedSeq: number, floor?: number): TrackingIdPlan;
36
+ /** Reads a `data-ins-track-seq` attribute value the way readTrackSeq reads it from HTML. */
37
+ export declare function parseTrackSeq(value: string | null): number;
38
+ /** The `data-ins-track-id` value of every `<a>` opening tag in `html`, in order ('' when absent). */
39
+ export declare function readAnchorTrackIds(html: string): string[];
40
+ /** Writes `ids[i]` onto the i-th `<a>` opening tag of `html`; `null` or a missing entry leaves it untouched. */
41
+ export declare function writeAnchorTrackIds(html: string, ids: readonly (number | null)[]): string;
23
42
  /**
24
43
  * Ensures every <a> opening tag carries a unique positive-integer id and the
25
44
  * document records the id high-water mark. Ids are minted above
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Browsers ignore whitespace around an href, but the send-time link rewrite does not:
3
+ * a trailing space ends up inside the path and a leading one skips the tracking params.
4
+ */
5
+ export declare function trimHrefWhitespace(html: string): string;
@@ -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
@@ -1,39 +1,44 @@
1
- import { currencyAttrTargets as u, ITEMS_CURRENCY_ATTR as c } from "../extensions/Blocks/Items/constants/currency.js";
2
- import { ItemsBlockId as l } from "../extensions/Blocks/Items/enums/controlEnums.js";
3
- const s = "items-block-v2";
4
- function f(e) {
5
- const i = e.getAttribute("esd-ext-config");
6
- if (!i)
1
+ import { isNewPriceFormatRoot as a, currencyAttrTargets as f, ITEMS_CURRENCY_ATTR as c } from "../extensions/Blocks/Items/constants/currency.js";
2
+ import { ItemsBlockId as p } from "../extensions/Blocks/Items/enums/controlEnums.js";
3
+ import { snapshotPriceFormatFromElement as m, planPriceFormatOps as y, applyPriceFormatOpsToElement as d } from "../extensions/Blocks/Items/utils/priceFormatOps.js";
4
+ const u = "items-block-v2";
5
+ function S(e, i) {
6
+ if (i || a(e)) {
7
+ const t = m(e), l = y(t, { convertLegacy: i });
8
+ return d(e, l);
9
+ }
10
+ const n = e.getAttribute("esd-ext-config");
11
+ if (!n)
7
12
  return !1;
8
- let t, r;
13
+ let r, o;
9
14
  try {
10
- ({ position: t, symbol: r } = u(JSON.parse(i)));
15
+ ({ position: r, symbol: o } = f(JSON.parse(n)));
11
16
  } catch {
12
17
  return !1;
13
18
  }
14
- let o = !1;
15
- return e.querySelectorAll(`.${l.PRICE} p`).forEach((n) => {
16
- t !== void 0 && n.getAttribute(c.POSITION) !== t && (n.setAttribute(c.POSITION, t), o = !0), r !== void 0 && n.getAttribute(c.SYMBOL) !== r && (n.setAttribute(c.SYMBOL, r), o = !0);
17
- }), o;
19
+ let s = !1;
20
+ return e.querySelectorAll(`.${p.PRICE} p`).forEach((t) => {
21
+ r !== void 0 && t.getAttribute(c.POSITION) !== r && (t.setAttribute(c.POSITION, r), s = !0), o !== void 0 && t.getAttribute(c.SYMBOL) !== o && (t.setAttribute(c.SYMBOL, o), s = !0);
22
+ }), s;
18
23
  }
19
- function S(e) {
20
- if (typeof e != "string" || !e.includes(s))
24
+ function I(e, { convertToPriceFormat: i = !1 } = {}) {
25
+ if (typeof e != "string" || !e.includes(u))
21
26
  return e;
22
27
  try {
23
- const t = new DOMParser().parseFromString(
28
+ const r = new DOMParser().parseFromString(
24
29
  `<table><tbody><tr>${e}</tr></tbody></table>`,
25
30
  "text/html"
26
- ).querySelector("tr"), r = t.querySelectorAll(`.${s}`);
27
- if (r.length === 0)
31
+ ).querySelector("tr"), o = r.querySelectorAll(`.${u}`);
32
+ if (o.length === 0)
28
33
  return e;
29
- let o = !1;
30
- return r.forEach((n) => {
31
- f(n) && (o = !0);
32
- }), o ? t.innerHTML : e;
33
- } catch (i) {
34
- return console.error("Failed to repair items currency on module add:", i), e;
34
+ let s = !1;
35
+ return o.forEach((t) => {
36
+ S(t, i) && (s = !0);
37
+ }), s ? r.innerHTML : e;
38
+ } catch (n) {
39
+ return console.error("Failed to repair items currency on module add:", n), e;
35
40
  }
36
41
  }
37
42
  export {
38
- S as repairItemsCurrencyAttributes
43
+ I as repairItemsCurrencyAttributes
39
44
  };
@@ -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
+ };
@@ -1,56 +1,90 @@
1
- const g = "data-ins-track-id", $ = "data-ins-track-seq", E = `(?:[^>"']|"[^"]*"|'[^']*')*`, f = new RegExp(`<a\\b${E}>`, "gi"), b = new RegExp(`<body\\b${E}>`, "i"), N = new RegExp(`<html\\b${E}>`, "i"), I = new RegExp(`\\b${g}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i"), S = new RegExp(`\\b${$}\\s*=\\s*(?:"(\\d+)"|'(\\d+)'|(\\d+))`, "i"), p = "ins-track-seq", _ = new RegExp(`<!--\\s*${p}:(\\d+)\\s*-->`, "i"), w = /^[1-9][0-9]{0,14}$/, k = 999999999999999;
2
- function m(e) {
3
- const n = Number(e);
4
- return Number.isSafeInteger(n) && n > 0 ? n : 0;
5
- }
6
- function M(e) {
7
- var a;
8
- const n = (s) => {
9
- var r;
10
- const o = (r = s.exec(e)) == null ? void 0 : r[0];
11
- return o ? S.exec(o) : null;
12
- }, t = n(b) ?? n(N), c = (t == null ? void 0 : t[1]) ?? (t == null ? void 0 : t[2]) ?? (t == null ? void 0 : t[3]) ?? ((a = _.exec(e)) == null ? void 0 : a[1]) ?? "";
13
- return m(c);
14
- }
15
- function P(e, n = 0) {
16
- let t = 0;
17
- [...e.matchAll(f)].forEach(([a]) => {
18
- const s = I.exec(a), o = s ? s[1] ?? s[2] ?? s[3] ?? "" : "";
19
- w.test(o) && (t = Math.max(t, Number(o)));
1
+ const l = "data-ins-track-id", E = "data-ins-track-seq", A = `(?:[^>"']|"[^"]*"|'[^']*')*`, k = new RegExp(`<a\\b${A}>`, "gi"), R = new RegExp(`<body\\b${A}>`, "i"), _ = new RegExp(`<html\\b${A}>`, "i"), m = new RegExp(`\\b${l}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i"), f = new RegExp(`\\b${E}\\s*=\\s*(?:"(\\d+)"|'(\\d+)'|(\\d+))`, "i"), p = "ins-track-seq", x = new RegExp(`<!--\\s*${p}:(\\d+)\\s*-->`, "i"), $ = /^[1-9][0-9]{0,14}$/, q = 999999999999999;
2
+ function I(e) {
3
+ const c = Number(e);
4
+ return Number.isSafeInteger(c) && c > 0 ? c : 0;
5
+ }
6
+ function T(e) {
7
+ return [...e.matchAll(k)].map((c) => {
8
+ const [n] = c, t = m.exec(n), r = t ? t[1] ?? t[2] ?? t[3] ?? "" : "";
9
+ return { index: c.index, tag: n, attrMatch: t, rawValue: r };
20
10
  });
21
- const c = Number.isSafeInteger(n) && n > 0 ? n : 0;
22
- return Math.max(M(e), t, c);
23
- }
24
- function q(e, n) {
25
- const t = `${$}="${n}"`, c = b.exec(e) ?? N.exec(e);
26
- if (c) {
27
- const [s] = c, o = S.exec(s), r = o ? s.replace(o[0], t) : s.replace(/\/?>$/, (T) => ` ${t}${T}`);
28
- return e.slice(0, c.index) + r + e.slice(c.index + s.length);
11
+ }
12
+ function b(e) {
13
+ var r;
14
+ const c = (s) => {
15
+ var a;
16
+ const o = (a = s.exec(e)) == null ? void 0 : a[0];
17
+ return o ? f.exec(o) : null;
18
+ }, n = c(R) ?? c(_), t = (n == null ? void 0 : n[1]) ?? (n == null ? void 0 : n[2]) ?? (n == null ? void 0 : n[3]) ?? ((r = x.exec(e)) == null ? void 0 : r[1]) ?? "";
19
+ return I(t);
20
+ }
21
+ function h(e, c = 0) {
22
+ let n = 0;
23
+ T(e).forEach(({ rawValue: r }) => {
24
+ $.test(r) && (n = Math.max(n, Number(r)));
25
+ });
26
+ const t = Number.isSafeInteger(c) && c > 0 ? c : 0;
27
+ return Math.max(b(e), n, t);
28
+ }
29
+ function w(e, c) {
30
+ const n = `${E}="${c}"`, t = R.exec(e) ?? _.exec(e);
31
+ if (t) {
32
+ const [s] = t, o = f.exec(s), a = o ? s.replace(o[0], n) : s.replace(/\/?>$/, (u) => ` ${n}${u}`);
33
+ return e.slice(0, t.index) + a + e.slice(t.index + s.length);
29
34
  }
30
- const a = `<!--${p}:${n}-->`;
31
- return _.test(e) ? e.replace(_, a) : `${a}${e}`;
35
+ const r = `<!--${p}:${c}-->`;
36
+ return x.test(e) ? e.replace(x, r) : `${r}${e}`;
32
37
  }
33
- function D(e, n, t) {
34
- const c = `${g}="${t}"`;
35
- return n ? e.replace(n[0], c) : e.replace(/^<a\b/i, (a) => `${a} ${c}`);
38
+ function M(e, c, n) {
39
+ const t = `${l}="${n}"`;
40
+ return c ? e.replace(c[0], t) : e.replace(/^<a\b/i, (r) => `${r} ${t}`);
36
41
  }
37
- function C(e, n = 0) {
42
+ function C(e, c, n = 0) {
38
43
  const t = /* @__PURE__ */ new Set();
39
- let c = 0;
40
- const a = [...e.matchAll(f)].map((i) => {
41
- const [l] = i, u = I.exec(l), R = u ? u[1] ?? u[2] ?? u[3] ?? "" : "";
42
- let x = null;
43
- return w.test(R) && !t.has(Number(R)) && (x = Number(R), t.add(x), c = Math.max(c, x)), { index: i.index, tag: l, attrMatch: u, id: x };
44
- }), s = M(e), o = Number.isSafeInteger(n) && n > 0 && n < k ? n : 0;
45
- let r = Math.max(s, c, o), T = "", d = 0, A = !1;
46
- return a.forEach((i) => {
47
- T += e.slice(d, i.index), i.id === null ? (r += 1, T += D(i.tag, i.attrMatch, r), A = !0) : T += i.tag, d = i.index + i.tag.length;
48
- }), T += e.slice(d), r > 0 && s !== r && (T = q(T, r), A = !0), { html: T, changed: A, nextSeq: r };
44
+ let r = 0;
45
+ const s = e.map((i) => {
46
+ if (!$.test(i) || t.has(Number(i)))
47
+ return null;
48
+ const d = Number(i);
49
+ return t.add(d), r = Math.max(r, d), d;
50
+ }), o = Number.isSafeInteger(n) && n > 0 && n < q ? n : 0;
51
+ let a = Math.max(c, r, o);
52
+ const u = s.map((i) => i === null), S = s.map((i) => i !== null ? i : (a += 1, a)), g = a > 0 && c !== a;
53
+ return { ids: S, reassigned: u, nextSeq: a, seqChanged: g, changed: g || u.includes(!0) };
54
+ }
55
+ function D(e) {
56
+ return e !== null && /^\d+$/.test(e) ? I(e) : 0;
57
+ }
58
+ function N(e, c, n) {
59
+ let t = "", r = 0;
60
+ return c.forEach((s, o) => {
61
+ const a = n[o] ?? null;
62
+ t += e.slice(r, s.index), t += a === null ? s.tag : M(s.tag, s.attrMatch, a), r = s.index + s.tag.length;
63
+ }), t + e.slice(r);
64
+ }
65
+ function P(e) {
66
+ return T(e).map((c) => c.rawValue);
67
+ }
68
+ function K(e, c) {
69
+ return N(e, T(e), c);
70
+ }
71
+ function O(e, c = 0) {
72
+ const n = T(e), t = C(n.map((s) => s.rawValue), b(e), c);
73
+ let r = N(
74
+ e,
75
+ n,
76
+ t.ids.map((s, o) => t.reassigned[o] ? s : null)
77
+ );
78
+ return t.seqChanged && (r = w(r, t.nextSeq)), { html: r, changed: t.changed, nextSeq: t.nextSeq };
49
79
  }
50
80
  export {
51
- g as TRACK_ID_ATTRIBUTE,
52
- $ as TRACK_SEQ_ATTRIBUTE,
53
- C as assignTrackingIds,
54
- P as readTrackFloor,
55
- M as readTrackSeq
81
+ l as TRACK_ID_ATTRIBUTE,
82
+ E as TRACK_SEQ_ATTRIBUTE,
83
+ O as assignTrackingIds,
84
+ D as parseTrackSeq,
85
+ C as planTrackingIds,
86
+ P as readAnchorTrackIds,
87
+ h as readTrackFloor,
88
+ b as readTrackSeq,
89
+ K as writeAnchorTrackIds
56
90
  };