@useinsider/guido 3.23.0-beta.31d0f5f → 3.23.0-beta.534d03d

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 (68) hide show
  1. package/README.md +1 -0
  2. package/dist/@types/config/schemas.js +41 -39
  3. package/dist/@types/display-condition.js +25 -0
  4. package/dist/components/Guido.vue.js +8 -8
  5. package/dist/components/Guido.vue2.js +89 -83
  6. package/dist/components/organisms/display-conditions/CodeEditorField.vue.js +18 -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/DisplayConditionSelectDrawer.vue.js +34 -0
  11. package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue2.js +63 -0
  12. package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue.js +17 -0
  13. package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue2.js +22 -0
  14. package/dist/composables/useBlocksConfig.js +31 -20
  15. package/dist/composables/useDisplayConditions.js +116 -0
  16. package/dist/config/compiler/utils/itemsCompilerUtils.js +43 -42
  17. package/dist/config/compiler/utils/recommendationCompilerUtils.js +67 -64
  18. package/dist/enums/academy.js +1 -0
  19. package/dist/enums/display-condition.js +12 -0
  20. package/dist/extensions/DisplayConditions/bridge.js +25 -0
  21. package/dist/extensions/DisplayConditions/constants.js +17 -0
  22. package/dist/extensions/DisplayConditions/control.js +189 -0
  23. package/dist/extensions/DisplayConditions/display-conditions.css.js +201 -0
  24. package/dist/extensions/DisplayConditions/extension.js +28 -0
  25. package/dist/extensions/DisplayConditions/iconsRegistry.js +20 -0
  26. package/dist/extensions/DisplayConditions/library.js +28 -0
  27. package/dist/extensions/DisplayConditions/settingsPanel.js +17 -0
  28. package/dist/extensions/LinkTracking/extension.js +17 -0
  29. package/dist/extensions/LinkTracking/writer.js +35 -0
  30. package/dist/guido.css +1 -1
  31. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +93 -92
  32. package/dist/node_modules/valibot/dist/index.js +297 -261
  33. package/dist/package.json.js +1 -1
  34. package/dist/services/displayConditionApi.js +39 -0
  35. package/dist/src/@types/config/schemas.d.ts +4 -0
  36. package/dist/src/@types/display-condition.d.ts +59 -0
  37. package/dist/src/components/organisms/display-conditions/CodeEditorField.vue.d.ts +43 -0
  38. package/dist/src/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.d.ts +2 -0
  39. package/dist/src/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.d.ts +2 -0
  40. package/dist/src/components/organisms/display-conditions/DisplayConditionsHost.vue.d.ts +2 -0
  41. package/dist/src/composables/useConfig.d.ts +2 -0
  42. package/dist/src/composables/useDisplayConditions.d.ts +17 -0
  43. package/dist/src/enums/academy.d.ts +1 -0
  44. package/dist/src/enums/display-condition.d.ts +15 -0
  45. package/dist/src/extensions/DisplayConditions/bridge.d.ts +7 -0
  46. package/dist/src/extensions/DisplayConditions/constants.d.ts +14 -0
  47. package/dist/src/extensions/DisplayConditions/control.d.ts +24 -0
  48. package/dist/src/extensions/DisplayConditions/extension.d.ts +2 -0
  49. package/dist/src/extensions/DisplayConditions/iconsRegistry.d.ts +4 -0
  50. package/dist/src/extensions/DisplayConditions/library.d.ts +8 -0
  51. package/dist/src/extensions/DisplayConditions/settingsPanel.d.ts +5 -0
  52. package/dist/src/extensions/LinkTracking/extension.d.ts +2 -0
  53. package/dist/src/extensions/LinkTracking/writer.d.ts +13 -0
  54. package/dist/src/mock/api/display-conditions.d.ts +2 -0
  55. package/dist/src/services/displayConditionApi.d.ts +8 -0
  56. package/dist/src/stores/config.d.ts +166 -0
  57. package/dist/src/stores/display-condition.d.ts +84 -0
  58. package/dist/src/utils/displayCondition.d.ts +11 -0
  59. package/dist/src/utils/linkTrackingIds.d.ts +20 -5
  60. package/dist/src/utils/protectTableText.d.ts +2 -0
  61. package/dist/stores/config.js +13 -6
  62. package/dist/stores/display-condition.js +29 -0
  63. package/dist/utils/displayCondition.js +26 -0
  64. package/dist/utils/linkTrackingIds.js +80 -47
  65. package/dist/utils/pairProductVariables.js +30 -29
  66. package/dist/utils/protectTableText.js +22 -0
  67. package/dist/utils/templatePreparation.js +57 -56
  68. package/package.json +1 -1
@@ -0,0 +1,84 @@
1
+ import type { AppliedDisplayCondition, SavedDisplayCondition } from '@@/Types/display-condition';
2
+ export type DisplayConditionView = 'none' | 'create' | 'select';
3
+ export type DisplayConditionListStatus = 'idle' | 'loading' | 'loaded' | 'error';
4
+ interface DisplayConditionState {
5
+ view: DisplayConditionView;
6
+ editing: AppliedDisplayCondition | null;
7
+ list: SavedDisplayCondition[];
8
+ listStatus: DisplayConditionListStatus;
9
+ listRequest: number;
10
+ pendingDelete: SavedDisplayCondition | null;
11
+ }
12
+ export declare const useDisplayConditionStore: import("pinia").StoreDefinition<"guidoDisplayCondition", DisplayConditionState, {
13
+ isCreateOpen: (state: {
14
+ view: DisplayConditionView;
15
+ editing: {
16
+ id: number;
17
+ name: string;
18
+ description: string;
19
+ beforeScript: string;
20
+ afterScript: string;
21
+ extraData?: string | undefined;
22
+ } | null;
23
+ list: {
24
+ id: number;
25
+ name: string;
26
+ description: string;
27
+ syntax: "liquid" | "pongo";
28
+ method: "codeOnly" | "logicBuilder";
29
+ codeBefore: string;
30
+ codeAfter: string;
31
+ createdAt?: string | undefined;
32
+ }[];
33
+ listStatus: DisplayConditionListStatus;
34
+ listRequest: number;
35
+ pendingDelete: {
36
+ id: number;
37
+ name: string;
38
+ description: string;
39
+ syntax: "liquid" | "pongo";
40
+ method: "codeOnly" | "logicBuilder";
41
+ codeBefore: string;
42
+ codeAfter: string;
43
+ createdAt?: string | undefined;
44
+ } | null;
45
+ } & import("pinia").PiniaCustomStateProperties<DisplayConditionState>) => boolean;
46
+ isSelectOpen: (state: {
47
+ view: DisplayConditionView;
48
+ editing: {
49
+ id: number;
50
+ name: string;
51
+ description: string;
52
+ beforeScript: string;
53
+ afterScript: string;
54
+ extraData?: string | undefined;
55
+ } | null;
56
+ list: {
57
+ id: number;
58
+ name: string;
59
+ description: string;
60
+ syntax: "liquid" | "pongo";
61
+ method: "codeOnly" | "logicBuilder";
62
+ codeBefore: string;
63
+ codeAfter: string;
64
+ createdAt?: string | undefined;
65
+ }[];
66
+ listStatus: DisplayConditionListStatus;
67
+ listRequest: number;
68
+ pendingDelete: {
69
+ id: number;
70
+ name: string;
71
+ description: string;
72
+ syntax: "liquid" | "pongo";
73
+ method: "codeOnly" | "logicBuilder";
74
+ codeBefore: string;
75
+ codeAfter: string;
76
+ createdAt?: string | undefined;
77
+ } | null;
78
+ } & import("pinia").PiniaCustomStateProperties<DisplayConditionState>) => boolean;
79
+ }, {
80
+ openCreate(editing?: AppliedDisplayCondition | null): void;
81
+ openSelect(): void;
82
+ close(): void;
83
+ }>;
84
+ export {};
@@ -0,0 +1,11 @@
1
+ import type { AppliedDisplayCondition } 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) => CodeField[];
11
+ export {};
@@ -10,6 +10,13 @@ export interface TrackingIdResult {
10
10
  changed: boolean;
11
11
  nextSeq: number;
12
12
  }
13
+ export interface TrackingIdPlan {
14
+ /** Anchor index in document order → id to write. Anchors keeping their id are absent. */
15
+ assignments: Map<number, number>;
16
+ nextSeq: number;
17
+ seqChanged: boolean;
18
+ changed: boolean;
19
+ }
13
20
  /**
14
21
  * Reads the persisted id high-water mark: <body> attr, then <html> attr,
15
22
  * then the leading comment fallback. Returns 0 when absent.
@@ -21,10 +28,18 @@ export declare function readTrackSeq(html: string): number;
21
28
  */
22
29
  export declare function readTrackFloor(html: string, persistedCounter?: number): number;
23
30
  /**
24
- * Ensures every <a> opening tag carries a unique positive-integer id and the
25
- * document records the id high-water mark. Ids are minted above
26
- * max(persisted seq, max id in document, floor) so deleted ids are never
27
- * reused — even after a version restore or paste-over (floor = session floor).
28
- * Idempotent: a document already normalized returns changed=false.
31
+ * Mints ids above max(persisted seq, max id seen, floor) so a deleted id is never reused;
32
+ * invalid or duplicate values are reassigned, the first duplicate in document order keeps its id.
29
33
  */
34
+ export declare function planTrackingIds(rawIds: (string | null)[], persistedSeq: number, floor?: number): TrackingIdPlan;
35
+ export interface DocumentTrackingIdPlan {
36
+ /** data-ins-track-id per anchor in document order; '' when absent. */
37
+ anchorIds: string[];
38
+ plan: TrackingIdPlan;
39
+ }
40
+ /** Plans the ids for an HTML document without rewriting it. */
41
+ export declare function planDocumentTrackingIds(html: string, floor?: number): DocumentTrackingIdPlan;
42
+ /** Writes a plan into the HTML string: anchor ids by document order, then the seq host. */
43
+ export declare function renderTrackingIdPlan(html: string, { plan }: DocumentTrackingIdPlan): string;
44
+ /** Gives every <a> a unique positive-integer id and records the high-water mark; idempotent. */
30
45
  export declare function assignTrackingIds(html: string, floor?: number): TrackingIdResult;
@@ -0,0 +1,2 @@
1
+ export declare function protectTableText(html: string): string;
2
+ export declare const restoreTableText: (html: string) => string;
@@ -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
+ };
@@ -0,0 +1,26 @@
1
+ import { DisplayConditionSourceType as n } from "../enums/display-condition.js";
2
+ const T = (e) => {
3
+ if (!e)
4
+ return null;
5
+ try {
6
+ return JSON.parse(e.extraData ?? "{}").source === n.INLINE ? n.INLINE : n.SAVED;
7
+ } catch {
8
+ return n.SAVED;
9
+ }
10
+ }, m = (e) => !e || !(e.name || e.beforeScript || e.afterScript) ? null : { ...e, description: e.description ?? "" };
11
+ let c = 0;
12
+ const I = () => (c = Math.max(Date.now(), c + 1), c), f = /{%-?\s*(\w+)[\s\S]*?-?%}/g, p = /{%[\s\S]*?%}|{{[\s\S]*?}}/g, S = /{%-?\s*(comment|raw)\s*-?%}[\s\S]*?{%-?\s*end\1\s*-?%}/g, i = /* @__PURE__ */ new Set(["if", "unless", "for", "case", "capture", "tablerow", "comment"]), u = /* @__PURE__ */ new Set(["else", "elsif", "elif", "when"]), A = (e) => /{%|%}|{{|}}/.test(e.replace(p, "")), N = (e, a) => {
13
+ const t = /* @__PURE__ */ new Set(), r = [];
14
+ return [["codeBefore", e], ["codeAfter", a]].forEach(([o, d]) => {
15
+ const l = d.replace(S, "");
16
+ A(l) && t.add(o), Array.from(l.matchAll(f), (s) => s[1]).forEach((s) => {
17
+ i.has(s) ? r.push(s) : s.startsWith("end") && i.has(s.slice(3)) ? r.pop() !== s.slice(3) && t.add(o) : u.has(s) && !r.length && t.add(o);
18
+ });
19
+ }), r.length && t.add("codeAfter"), [...t];
20
+ };
21
+ export {
22
+ N as findInvalidCodeFields,
23
+ I as nextConditionId,
24
+ T as parseSource,
25
+ m as toAppliedCondition
26
+ };
@@ -1,56 +1,89 @@
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]) ?? "";
1
+ const A = "data-ins-track-id", E = "data-ins-track-seq", g = `(?:[^>"']|"[^"]*"|'[^']*')*`, R = new RegExp(`<a\\b${g}>`, "gi"), _ = new RegExp(`<body\\b${g}>`, "i"), f = new RegExp(`<html\\b${g}>`, "i"), S = new RegExp(`\\b${A}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i"), l = new RegExp(`\\b${E}\\s*=\\s*(?:"(\\d+)"|'(\\d+)'|(\\d+))`, "i"), I = "ins-track-seq", d = new RegExp(`<!--\\s*${I}:(\\d+)\\s*-->`, "i"), $ = /^[1-9][0-9]{0,14}$/, k = 999999999999999;
2
+ function p(t) {
3
+ const e = S.exec(t), n = e ? e[1] ?? e[2] ?? e[3] ?? "" : "";
4
+ return { attrMatch: e, rawValue: n };
5
+ }
6
+ function m(t) {
7
+ const e = Number(t);
8
+ return Number.isSafeInteger(e) && e > 0 ? e : 0;
9
+ }
10
+ function b(t) {
11
+ var s;
12
+ const e = (a) => {
13
+ var o;
14
+ const r = (o = a.exec(t)) == null ? void 0 : o[0];
15
+ return r ? l.exec(r) : null;
16
+ }, n = e(_) ?? e(f), c = (n == null ? void 0 : n[1]) ?? (n == null ? void 0 : n[2]) ?? (n == null ? void 0 : n[3]) ?? ((s = d.exec(t)) == null ? void 0 : s[1]) ?? "";
13
17
  return m(c);
14
18
  }
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)));
19
+ function D(t, e = 0) {
20
+ let n = 0;
21
+ [...t.matchAll(R)].forEach(([s]) => {
22
+ const { rawValue: a } = p(s);
23
+ $.test(a) && (n = Math.max(n, Number(a)));
20
24
  });
21
- const c = Number.isSafeInteger(n) && n > 0 ? n : 0;
22
- return Math.max(M(e), t, c);
25
+ const c = Number.isSafeInteger(e) && e > 0 ? e : 0;
26
+ return Math.max(b(t), n, c);
23
27
  }
24
- function q(e, n) {
25
- const t = `${$}="${n}"`, c = b.exec(e) ?? N.exec(e);
28
+ function q(t, e) {
29
+ const n = `${E}="${e}"`, c = _.exec(t) ?? f.exec(t);
26
30
  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);
31
+ const [a] = c, r = l.exec(a), o = r ? a.replace(r[0], n) : a.replace(/\/?>$/, (u) => ` ${n}${u}`);
32
+ return t.slice(0, c.index) + o + t.slice(c.index + a.length);
29
33
  }
30
- const a = `<!--${p}:${n}-->`;
31
- return _.test(e) ? e.replace(_, a) : `${a}${e}`;
32
- }
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}`);
36
- }
37
- function C(e, n = 0) {
38
- 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 };
34
+ const s = `<!--${I}:${e}-->`;
35
+ return d.test(t) ? t.replace(d, s) : `${s}${t}`;
36
+ }
37
+ function w(t, e, n) {
38
+ const c = `${A}="${n}"`;
39
+ return e ? t.replace(e[0], c) : t.replace(/^<a\b/i, (s) => `${s} ${c}`);
40
+ }
41
+ function M(t, e, n = 0) {
42
+ const c = /* @__PURE__ */ new Set();
43
+ let s = 0;
44
+ const a = t.map((i) => {
45
+ if (i !== null && $.test(i) && !c.has(Number(i))) {
46
+ const T = Number(i);
47
+ return c.add(T), s = Math.max(s, T), T;
48
+ }
49
+ return null;
50
+ }), r = Number.isSafeInteger(n) && n > 0 && n < k ? n : 0;
51
+ let o = Math.max(e, s, r);
52
+ const u = /* @__PURE__ */ new Map();
53
+ a.forEach((i, T) => {
54
+ i === null && (o += 1, u.set(T, o));
55
+ });
56
+ const x = o > 0 && e !== o;
57
+ return { assignments: u, nextSeq: o, seqChanged: x, changed: u.size > 0 || x };
58
+ }
59
+ function N(t) {
60
+ return [...t.matchAll(R)].map((e) => {
61
+ const [n] = e;
62
+ return { index: e.index, tag: n, ...p(n) };
63
+ });
64
+ }
65
+ function P(t, e = 0) {
66
+ const n = N(t).map((c) => c.rawValue);
67
+ return { anchorIds: n, plan: M(n, b(t), e) };
68
+ }
69
+ function C(t, { plan: e }) {
70
+ let n = "", c = 0;
71
+ return N(t).forEach((s, a) => {
72
+ const r = e.assignments.get(a);
73
+ n += t.slice(c, s.index), n += r === void 0 ? s.tag : w(s.tag, s.attrMatch, r), c = s.index + s.tag.length;
74
+ }), n += t.slice(c), e.seqChanged ? q(n, e.nextSeq) : n;
75
+ }
76
+ function K(t, e = 0) {
77
+ const n = P(t, e), { changed: c, nextSeq: s } = n.plan;
78
+ return { html: c ? C(t, n) : t, changed: c, nextSeq: s };
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
+ A as TRACK_ID_ATTRIBUTE,
82
+ E as TRACK_SEQ_ATTRIBUTE,
83
+ K as assignTrackingIds,
84
+ P as planDocumentTrackingIds,
85
+ M as planTrackingIds,
86
+ D as readTrackFloor,
87
+ b as readTrackSeq,
88
+ C as renderTrackingIdPlan
56
89
  };
@@ -2,34 +2,35 @@ import { ITEMS_CURRENCY_ATTR as U, isCustomCurrencySymbol as Y } from "../extens
2
2
  import { productPairs as M } from "../extensions/Blocks/Items/enums/productEnums.js";
3
3
  import { escapeReplacement as B } from "../extensions/Blocks/Items/utils/nodeConfigUtils.js";
4
4
  import { preserveTextStyles as L } from "./preserveTextStyles.js";
5
- import { unwrapProductNameLinks as X } from "./unwrapProductNameLink.js";
5
+ import { protectTableText as X, restoreTableText as v } from "./protectTableText.js";
6
+ import { unwrapProductNameLinks as j } 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 = ($) => $.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->");
11
- function v($, C, A) {
12
+ function Q($, C, A) {
12
13
  let d = C;
13
14
  for (; d > 0 && /\s/.test($[d - 1]); )
14
15
  d -= 1;
15
16
  return A.some((E) => $.endsWith(E, d));
16
17
  }
17
- const j = /(\s)href=(["'])(?:[^"']*#!|#)?\2/gi;
18
- function Q($, C) {
18
+ const z = /(\s)href=(["'])(?:[^"']*#!|#)?\2/gi;
19
+ function J($, C) {
19
20
  var d;
20
21
  const A = $.ownerDocument.createTreeWalker($, NodeFilter.SHOW_COMMENT);
21
22
  for (let E = A.nextNode(); E; E = A.nextNode())
22
- (d = E.nodeValue) != null && d.includes("[if mso]") && (E.nodeValue = E.nodeValue.replace(j, (k, P) => `${P}href="${C}"`));
23
+ (d = E.nodeValue) != null && d.includes("[if mso]") && (E.nodeValue = E.nodeValue.replace(z, (k, P) => `${P}href="${C}"`));
23
24
  }
24
- function et($) {
25
- const C = W($), A = new DOMParser().parseFromString(C, "text/html");
26
- X(A);
25
+ function ot($) {
26
+ const C = W(X($)), A = new DOMParser().parseFromString(C, "text/html");
27
+ j(A);
27
28
  const d = M.PAIRS_FOR_EXTENSION;
28
29
  Object.entries(d).forEach(([o, p]) => {
29
30
  A.querySelectorAll(".ins-product-td").forEach((r) => {
30
31
  const _ = r.getAttribute("data-number") || "1", y = r.getAttribute("data-type") || "CART_ITEMS";
31
32
  r.querySelectorAll(`[product-attr="${o}"]`).forEach((t) => {
32
- var S, I, O, x;
33
+ var b, I, D, O;
33
34
  const m = t.getAttribute("data-type") || y, n = t.getAttribute("data-number") || _, f = p[m];
34
35
  if (f)
35
36
  switch (o) {
@@ -45,12 +46,12 @@ function et($) {
45
46
  return a.includes(g) || a.includes(u) || H === u;
46
47
  }) && (e.src = `{{${c}_${n}}}`);
47
48
  }
48
- const i = (I = (S = d.name) == null ? void 0 : S[m]) == null ? void 0 : I.ATTR;
49
+ const i = (I = (b = d.name) == null ? void 0 : b[m]) == null ? void 0 : I.ATTR;
49
50
  if (i && e.setAttribute("alt", `{{${i}_${n}}}`), s) {
50
- const a = (O = d.itemLink) == null ? void 0 : O[m];
51
+ const a = (D = d.itemLink) == null ? void 0 : D[m];
51
52
  if (a) {
52
- const b = a.HREF, g = a.DEFAULT_HREF || "#!", u = s.href;
53
- (u === "#" || u === "" || u.endsWith("#!") || u.endsWith(g) || u === `${window.location.href}${g}` || !u || u === window.location.href) && (s.href = `{{${b}_${n}}}`);
53
+ const S = a.HREF, g = a.DEFAULT_HREF || "#!", u = s.href;
54
+ (u === "#" || u === "" || u.endsWith("#!") || u.endsWith(g) || u === `${window.location.href}${g}` || !u || u === window.location.href) && (s.href = `{{${S}_${n}}}`);
54
55
  }
55
56
  }
56
57
  break;
@@ -60,25 +61,25 @@ function et($) {
60
61
  t.textContent && (t.innerHTML = L(t, `{{${s}_${n}}}`));
61
62
  const i = t.closest("a") || (t.tagName === "A" ? t : null);
62
63
  if (i && c) {
63
- const a = i.href, b = `${window.location.href}${l}`;
64
- (a === b || a.endsWith(l)) && (i.href = `{{${c}_${n}}}`);
64
+ const a = i.href, S = `${window.location.href}${l}`;
65
+ (a === S || a.endsWith(l)) && (i.href = `{{${c}_${n}}}`);
65
66
  }
66
67
  break;
67
68
  }
68
69
  case "price":
69
70
  case "originalPrice": {
70
71
  const e = f, s = t.getAttribute("data-formated"), l = t.getAttribute("data-single_price"), c = s === "true", i = l === "true", a = t.getAttribute(U.POSITION) || "before";
71
- let b;
72
- i ? b = c ? e.SINGLE_PRICE_FORMATTED : e.SINGLE_PRICE : b = c ? e.PRICE_FORMATTED : e.PRICE;
72
+ let S;
73
+ i ? S = c ? e.SINGLE_PRICE_FORMATTED : e.SINGLE_PRICE : S = c ? e.PRICE_FORMATTED : e.PRICE;
73
74
  const g = e.CURRENCY;
74
- let u = `{{${b}_${n}}}`;
75
+ let u = `{{${S}_${n}}}`;
75
76
  const H = (t.getAttribute(U.SYMBOL) || "").trim(), G = Y(H);
76
77
  let F = "";
77
78
  G ? F = H : g && (F = `{{${g}_${n}}}`), F && (u = a === "after" ? `${u} ${F}` : `${F} ${u}`), t.innerHTML = L(t, u);
78
79
  break;
79
80
  }
80
81
  case "quantity": {
81
- const e = f, s = e.ATTR, l = [e.DEFAULT, ...e.LEGACY_DEFAULTS], c = (x = t.textContent) == null ? void 0 : x.trim();
82
+ const e = f, s = e.ATTR, l = [e.DEFAULT, ...e.LEGACY_DEFAULTS], c = (O = t.textContent) == null ? void 0 : O.trim();
82
83
  c && l.includes(c) && (t.innerHTML = L(t, `{{${s}_${n}}}`));
83
84
  break;
84
85
  }
@@ -88,7 +89,7 @@ function et($) {
88
89
  const i = c.href || "", a = `${window.location.href}${l}`;
89
90
  (i === "" || i === "#" || i === a || i.endsWith(l) || i.endsWith("#!") || i === window.location.href) && (c.href = `{{${s}_${n}}}`);
90
91
  }
91
- Q(t, `{{${s}_${n}}}`);
92
+ J(t, `{{${s}_${n}}}`);
92
93
  break;
93
94
  }
94
95
  case "itemLink": {
@@ -129,30 +130,30 @@ function et($) {
129
130
  h = h.replace(o, B(n));
130
131
  }
131
132
  });
132
- const V = A.querySelectorAll('[product-attr="originalPrice"][data-type]'), w = /* @__PURE__ */ new Map(), D = /* @__PURE__ */ new Set();
133
+ const V = A.querySelectorAll('[product-attr="originalPrice"][data-type]'), w = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Set();
133
134
  return V.forEach((o) => {
134
135
  var t;
135
136
  const p = o.getAttribute("data-number"), T = o.getAttribute("data-type");
136
137
  if (!p || !q[T])
137
138
  return;
138
139
  const r = o.closest(".product-original-price-class");
139
- if (!r || D.has(r))
140
+ if (!r || x.has(r))
140
141
  return;
141
- D.add(r);
142
+ x.add(r);
142
143
  const _ = r.outerHTML, y = (t = o.closest(".ins-product-td")) == null ? void 0 : t.getAttribute("data-nodup"), R = w.get(_) ?? { number: p, type: T, wrap: [] };
143
144
  R.wrap.push(y !== "false"), w.set(_, R);
144
145
  }), w.forEach(({ number: o, type: p, wrap: T }, r) => {
145
146
  if (r.includes("{% if") || !T.some(Boolean))
146
147
  return;
147
148
  const _ = M.PAIRS_FOR_EXTENSION.price[p].PRICE, y = M.PAIRS_FOR_EXTENSION.originalPrice[p].PRICE, R = `{% if ${_}_${o} != ${y}_${o} %}`, t = [R, W(R)];
148
- let m = "", n = 0, f = 0, S = h.indexOf(r);
149
- for (; S !== -1; ) {
150
- const I = T[f] === !0 && !v(h, S, t);
151
- m += h.slice(n, S) + (I ? `${R}${r}{% endif %}` : r), n = S + r.length, f += 1, S = h.indexOf(r, n);
149
+ let m = "", n = 0, f = 0, b = h.indexOf(r);
150
+ for (; b !== -1; ) {
151
+ const I = T[f] === !0 && !Q(h, b, t);
152
+ m += h.slice(n, b) + (I ? `${R}${r}{% endif %}` : r), n = b + r.length, f += 1, b = h.indexOf(r, n);
152
153
  }
153
154
  h = m + h.slice(n);
154
- }), h.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
155
+ }), v(h.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}"));
155
156
  }
156
157
  export {
157
- et as pairProductVariables
158
+ ot as pairProductVariables
158
159
  };
@@ -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
+ };