@useinsider/guido 3.24.0-beta.0abeefe → 3.24.0-beta.172ae7a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -2
- package/dist/@types/config/schemas.js +37 -37
- package/dist/components/Guido.vue.js +2 -2
- package/dist/components/Guido.vue2.js +80 -82
- package/dist/components/organisms/unsubscribe/LegacyUnsubscribeConvertedModal.vue.js +17 -0
- package/dist/components/organisms/unsubscribe/LegacyUnsubscribeConvertedModal.vue2.js +30 -0
- package/dist/composables/useActionsApi.js +2 -2
- package/dist/composables/useBlocksConfig.js +20 -31
- package/dist/composables/useEditorTrackingIds.js +49 -0
- package/dist/composables/useHtmlCompiler.js +2 -0
- package/dist/composables/useModuleRepair.js +32 -23
- package/dist/composables/useStripo.js +70 -70
- package/dist/composables/useTranslations.js +1 -2
- package/dist/config/compiler/htmlCompilerRules.js +14 -6
- package/dist/config/compiler/utils/itemsCompilerUtils.js +42 -43
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +64 -67
- package/dist/config/migrator/index.js +10 -9
- package/dist/config/migrator/legacyUnsubscribeTextMigrator.js +16 -0
- package/dist/enums/academy.js +2 -2
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +10 -8
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +28 -24
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +23 -22
- package/dist/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +92 -93
- package/dist/node_modules/valibot/dist/index.js +261 -297
- package/dist/package.json.js +6 -6
- package/dist/services/templateLibraryApi.js +39 -36
- package/dist/src/@types/config/schemas.d.ts +4 -4
- package/dist/src/composables/useConfig.d.ts +2 -2
- package/dist/src/composables/useEditorTrackingIds.d.ts +7 -0
- package/dist/src/composables/useModuleRepair.d.ts +2 -11
- package/dist/src/composables/useStripo.d.ts +1 -1
- package/dist/src/config/migrator/legacyUnsubscribeTextMigrator.d.ts +1 -0
- package/dist/src/enums/academy.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +2 -0
- package/dist/src/stores/config.d.ts +20 -167
- package/dist/src/stores/editor.d.ts +27 -0
- package/dist/src/utils/legacyUnsubscribeConversion.d.ts +10 -0
- package/dist/src/utils/linkTrackingIds.d.ts +24 -22
- package/dist/src/utils/trimHrefWhitespace.d.ts +5 -0
- package/dist/stores/config.js +6 -13
- package/dist/stores/editor.js +1 -0
- package/dist/utils/legacyUnsubscribeConversion.js +49 -0
- package/dist/utils/linkTrackingIds.js +72 -72
- package/dist/utils/pairProductVariables.js +29 -30
- package/dist/utils/templatePreparation.js +59 -72
- package/dist/utils/trimHrefWhitespace.js +10 -0
- package/package.json +1 -1
- package/dist/@types/display-condition.js +0 -25
- package/dist/components/organisms/display-conditions/CodeEditorField.vue.js +0 -17
- package/dist/components/organisms/display-conditions/CodeEditorField.vue2.js +0 -41
- package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.js +0 -30
- package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue2.js +0 -81
- package/dist/components/organisms/display-conditions/DisplayConditionListState.vue.js +0 -17
- package/dist/components/organisms/display-conditions/DisplayConditionListState.vue2.js +0 -45
- package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.js +0 -36
- package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue2.js +0 -63
- package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue.js +0 -17
- package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue2.js +0 -22
- package/dist/composables/useDisplayConditions.js +0 -117
- package/dist/enums/display-condition.js +0 -12
- package/dist/extensions/DisplayConditions/bridge.js +0 -25
- package/dist/extensions/DisplayConditions/constants.js +0 -26
- package/dist/extensions/DisplayConditions/control.js +0 -215
- package/dist/extensions/DisplayConditions/display-conditions.css.js +0 -226
- package/dist/extensions/DisplayConditions/extension.js +0 -28
- package/dist/extensions/DisplayConditions/iconsRegistry.js +0 -20
- package/dist/extensions/DisplayConditions/library.js +0 -30
- package/dist/extensions/DisplayConditions/settingsPanel.js +0 -17
- package/dist/extensions/LinkTracking/extension.js +0 -17
- package/dist/extensions/LinkTracking/writer.js +0 -41
- package/dist/services/displayConditionApi.js +0 -39
- package/dist/src/@types/display-condition.d.ts +0 -60
- package/dist/src/components/organisms/display-conditions/CodeEditorField.vue.d.ts +0 -43
- package/dist/src/components/organisms/display-conditions/DisplayConditionListState.vue.d.ts +0 -18
- package/dist/src/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.d.ts +0 -2
- package/dist/src/components/organisms/display-conditions/DisplayConditionsHost.vue.d.ts +0 -2
- package/dist/src/composables/useDisplayConditions.d.ts +0 -18
- package/dist/src/enums/display-condition.d.ts +0 -15
- package/dist/src/extensions/DisplayConditions/bridge.d.ts +0 -7
- package/dist/src/extensions/DisplayConditions/constants.d.ts +0 -23
- package/dist/src/extensions/DisplayConditions/control.d.ts +0 -25
- package/dist/src/extensions/DisplayConditions/extension.d.ts +0 -2
- package/dist/src/extensions/DisplayConditions/iconsRegistry.d.ts +0 -4
- package/dist/src/extensions/DisplayConditions/library.d.ts +0 -8
- package/dist/src/extensions/DisplayConditions/settingsPanel.d.ts +0 -5
- package/dist/src/extensions/LinkTracking/extension.d.ts +0 -2
- package/dist/src/extensions/LinkTracking/writer.d.ts +0 -13
- package/dist/src/mock/api/display-conditions.d.ts +0 -2
- package/dist/src/services/displayConditionApi.d.ts +0 -8
- package/dist/src/stores/display-condition.d.ts +0 -84
- package/dist/src/utils/displayCondition.d.ts +0 -11
- package/dist/src/utils/protectTableText.d.ts +0 -2
- package/dist/stores/display-condition.js +0 -29
- package/dist/utils/displayCondition.js +0 -26
- package/dist/utils/protectTableText.js +0 -22
- /package/dist/src/components/organisms/{display-conditions/DisplayConditionCreateDrawer.vue.d.ts → unsubscribe/LegacyUnsubscribeConvertedModal.vue.d.ts} +0 -0
|
@@ -10,13 +10,6 @@ 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
|
-
}
|
|
20
13
|
/**
|
|
21
14
|
* Reads the persisted id high-water mark: <body> attr, then <html> attr,
|
|
22
15
|
* then the leading comment fallback. Returns 0 when absent.
|
|
@@ -27,21 +20,30 @@ export declare function readTrackSeq(html: string): number;
|
|
|
27
20
|
* Scans the document because a rewrite can strip the seq host but keep the ids.
|
|
28
21
|
*/
|
|
29
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
|
+
}
|
|
30
31
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
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;
|
|
42
|
+
/**
|
|
43
|
+
* Ensures every <a> opening tag carries a unique positive-integer id and the
|
|
44
|
+
* document records the id high-water mark. Ids are minted above
|
|
45
|
+
* max(persisted seq, max id in document, floor) so deleted ids are never
|
|
46
|
+
* reused — even after a version restore or paste-over (floor = session floor).
|
|
47
|
+
* Idempotent: a document already normalized returns changed=false.
|
|
33
48
|
*/
|
|
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
|
-
/** Per anchor: inside an HTML comment (e.g. Stripo's `<!--[if mso]>` button copy), absent from the node tree. */
|
|
39
|
-
inComment: boolean[];
|
|
40
|
-
plan: TrackingIdPlan;
|
|
41
|
-
}
|
|
42
|
-
/** Plans the ids for an HTML document without rewriting it. */
|
|
43
|
-
export declare function planDocumentTrackingIds(html: string, floor?: number): DocumentTrackingIdPlan;
|
|
44
|
-
/** Writes a plan into the HTML string: anchor ids by document order, then the seq host. */
|
|
45
|
-
export declare function renderTrackingIdPlan(html: string, { plan }: DocumentTrackingIdPlan): string;
|
|
46
|
-
/** Gives every <a> a unique positive-integer id and records the high-water mark; idempotent. */
|
|
47
49
|
export declare function assignTrackingIds(html: string, floor?: number): TrackingIdResult;
|
package/dist/stores/config.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { MessageType as
|
|
1
|
+
import { MessageType as r } from "../@types/config/schemas.js";
|
|
2
2
|
import "../@types/config/defaults.js";
|
|
3
|
-
import { parseConfig as
|
|
4
|
-
import { defineStore as
|
|
5
|
-
const g =
|
|
3
|
+
import { parseConfig as a } from "../@types/config/validator.js";
|
|
4
|
+
import { defineStore as o } from "pinia";
|
|
5
|
+
const g = o("guido-config", {
|
|
6
6
|
state: () => ({
|
|
7
7
|
initialized: !1,
|
|
8
8
|
config: null
|
|
@@ -132,7 +132,7 @@ const g = l("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 ===
|
|
135
|
+
return this.messageType === r.TRANSACTIONAL;
|
|
136
136
|
},
|
|
137
137
|
/**
|
|
138
138
|
* Soft-save policy: may the editor persist a template with validation errors?
|
|
@@ -158,13 +158,6 @@ const g = l("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
|
-
},
|
|
168
161
|
/**
|
|
169
162
|
* Check if a specific feature is enabled.
|
|
170
163
|
* Returns false before init (config null) so header controls don't
|
|
@@ -181,7 +174,7 @@ const g = l("guido-config", {
|
|
|
181
174
|
* Initialize the config store with validated configuration
|
|
182
175
|
*/
|
|
183
176
|
init(i) {
|
|
184
|
-
const e =
|
|
177
|
+
const e = a(i);
|
|
185
178
|
this.config = e, this.initialized = !0;
|
|
186
179
|
},
|
|
187
180
|
/**
|
package/dist/stores/editor.js
CHANGED
|
@@ -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,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,90 +1,90 @@
|
|
|
1
|
-
const
|
|
2
|
-
function
|
|
3
|
-
const
|
|
4
|
-
return
|
|
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
5
|
}
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
-
|
|
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 };
|
|
10
|
+
});
|
|
9
11
|
}
|
|
10
|
-
function
|
|
11
|
-
var
|
|
12
|
-
const
|
|
13
|
-
var
|
|
14
|
-
const
|
|
15
|
-
return
|
|
16
|
-
}, n =
|
|
17
|
-
return
|
|
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);
|
|
18
20
|
}
|
|
19
|
-
function
|
|
21
|
+
function h(e, c = 0) {
|
|
20
22
|
let n = 0;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
I.test(o) && (n = Math.max(n, Number(o)));
|
|
23
|
+
T(e).forEach(({ rawValue: r }) => {
|
|
24
|
+
$.test(r) && (n = Math.max(n, Number(r)));
|
|
24
25
|
});
|
|
25
|
-
const
|
|
26
|
-
return Math.max(
|
|
26
|
+
const t = Number.isSafeInteger(c) && c > 0 ? c : 0;
|
|
27
|
+
return Math.max(b(e), n, t);
|
|
27
28
|
}
|
|
28
|
-
function
|
|
29
|
-
const n = `${E}="${
|
|
30
|
-
if (
|
|
31
|
-
const [
|
|
32
|
-
return e.slice(0,
|
|
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);
|
|
33
34
|
}
|
|
34
|
-
const
|
|
35
|
-
return
|
|
35
|
+
const r = `<!--${p}:${c}-->`;
|
|
36
|
+
return x.test(e) ? e.replace(x, r) : `${r}${e}`;
|
|
36
37
|
}
|
|
37
|
-
function
|
|
38
|
-
const
|
|
39
|
-
return
|
|
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}`);
|
|
40
41
|
}
|
|
41
|
-
function
|
|
42
|
-
const
|
|
43
|
-
let
|
|
44
|
-
const
|
|
45
|
-
if (
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
o.forEach((u, T) => {
|
|
54
|
-
u === null && (r += 1, i.set(T, r));
|
|
55
|
-
});
|
|
56
|
-
const x = r > 0 && t !== r;
|
|
57
|
-
return { assignments: i, nextSeq: r, seqChanged: x, changed: i.size > 0 || x };
|
|
42
|
+
function C(e, c, n = 0) {
|
|
43
|
+
const t = /* @__PURE__ */ new Set();
|
|
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) };
|
|
58
54
|
}
|
|
59
|
-
function
|
|
60
|
-
return
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
64
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const n = b(e), c = n.map((a) => a.rawValue), s = [...e.matchAll(C)].map((a) => [a.index, a.index + a[0].length]), o = n.map(({ index: a }) => s.some(([r, i]) => a > r && a < i));
|
|
68
|
-
return { anchorIds: c, inComment: o, plan: w(c, N(e), t) };
|
|
65
|
+
function P(e) {
|
|
66
|
+
return T(e).map((c) => c.rawValue);
|
|
69
67
|
}
|
|
70
|
-
function
|
|
71
|
-
|
|
72
|
-
return b(e).forEach((s, o) => {
|
|
73
|
-
const a = t.assignments.get(o);
|
|
74
|
-
n += e.slice(c, s.index), n += a === void 0 ? s.tag : q(s.tag, s.attrMatch, a), c = s.index + s.tag.length;
|
|
75
|
-
}), n += e.slice(c), t.seqChanged ? M(n, t.nextSeq) : n;
|
|
68
|
+
function K(e, c) {
|
|
69
|
+
return N(e, T(e), c);
|
|
76
70
|
}
|
|
77
|
-
function O(e,
|
|
78
|
-
const n =
|
|
79
|
-
|
|
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 };
|
|
80
79
|
}
|
|
81
80
|
export {
|
|
82
|
-
|
|
81
|
+
l as TRACK_ID_ATTRIBUTE,
|
|
83
82
|
E as TRACK_SEQ_ATTRIBUTE,
|
|
84
83
|
O as assignTrackingIds,
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
84
|
+
D as parseTrackSeq,
|
|
85
|
+
C as planTrackingIds,
|
|
86
|
+
P as readAnchorTrackIds,
|
|
87
|
+
h as readTrackFloor,
|
|
88
|
+
b as readTrackSeq,
|
|
89
|
+
K as writeAnchorTrackIds
|
|
90
90
|
};
|
|
@@ -2,35 +2,34 @@ 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 {
|
|
6
|
-
import { unwrapProductNameLinks as j } from "./unwrapProductNameLink.js";
|
|
5
|
+
import { unwrapProductNameLinks as X } from "./unwrapProductNameLink.js";
|
|
7
6
|
const q = {
|
|
8
7
|
CART_ITEMS: "ins_apr",
|
|
9
8
|
BROWSED_ITEMS: "browsed_item",
|
|
10
9
|
PURCHASED_ITEMS: "purchased_item"
|
|
11
10
|
}, W = ($) => $.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->");
|
|
12
|
-
function
|
|
11
|
+
function v($, C, A) {
|
|
13
12
|
let d = C;
|
|
14
13
|
for (; d > 0 && /\s/.test($[d - 1]); )
|
|
15
14
|
d -= 1;
|
|
16
15
|
return A.some((E) => $.endsWith(E, d));
|
|
17
16
|
}
|
|
18
|
-
const
|
|
19
|
-
function
|
|
17
|
+
const j = /(\s)href=(["'])(?:[^"']*#!|#)?\2/gi;
|
|
18
|
+
function Q($, C) {
|
|
20
19
|
var d;
|
|
21
20
|
const A = $.ownerDocument.createTreeWalker($, NodeFilter.SHOW_COMMENT);
|
|
22
21
|
for (let E = A.nextNode(); E; E = A.nextNode())
|
|
23
|
-
(d = E.nodeValue) != null && d.includes("[if mso]") && (E.nodeValue = E.nodeValue.replace(
|
|
22
|
+
(d = E.nodeValue) != null && d.includes("[if mso]") && (E.nodeValue = E.nodeValue.replace(j, (k, P) => `${P}href="${C}"`));
|
|
24
23
|
}
|
|
25
|
-
function
|
|
26
|
-
const C = W(
|
|
27
|
-
|
|
24
|
+
function et($) {
|
|
25
|
+
const C = W($), A = new DOMParser().parseFromString(C, "text/html");
|
|
26
|
+
X(A);
|
|
28
27
|
const d = M.PAIRS_FOR_EXTENSION;
|
|
29
28
|
Object.entries(d).forEach(([o, p]) => {
|
|
30
29
|
A.querySelectorAll(".ins-product-td").forEach((r) => {
|
|
31
30
|
const _ = r.getAttribute("data-number") || "1", y = r.getAttribute("data-type") || "CART_ITEMS";
|
|
32
31
|
r.querySelectorAll(`[product-attr="${o}"]`).forEach((t) => {
|
|
33
|
-
var
|
|
32
|
+
var S, I, O, x;
|
|
34
33
|
const m = t.getAttribute("data-type") || y, n = t.getAttribute("data-number") || _, f = p[m];
|
|
35
34
|
if (f)
|
|
36
35
|
switch (o) {
|
|
@@ -46,12 +45,12 @@ function ot($) {
|
|
|
46
45
|
return a.includes(g) || a.includes(u) || H === u;
|
|
47
46
|
}) && (e.src = `{{${c}_${n}}}`);
|
|
48
47
|
}
|
|
49
|
-
const i = (I = (
|
|
48
|
+
const i = (I = (S = d.name) == null ? void 0 : S[m]) == null ? void 0 : I.ATTR;
|
|
50
49
|
if (i && e.setAttribute("alt", `{{${i}_${n}}}`), s) {
|
|
51
|
-
const a = (
|
|
50
|
+
const a = (O = d.itemLink) == null ? void 0 : O[m];
|
|
52
51
|
if (a) {
|
|
53
|
-
const
|
|
54
|
-
(u === "#" || u === "" || u.endsWith("#!") || u.endsWith(g) || u === `${window.location.href}${g}` || !u || u === window.location.href) && (s.href = `{{${
|
|
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}}}`);
|
|
55
54
|
}
|
|
56
55
|
}
|
|
57
56
|
break;
|
|
@@ -61,25 +60,25 @@ function ot($) {
|
|
|
61
60
|
t.textContent && (t.innerHTML = L(t, `{{${s}_${n}}}`));
|
|
62
61
|
const i = t.closest("a") || (t.tagName === "A" ? t : null);
|
|
63
62
|
if (i && c) {
|
|
64
|
-
const a = i.href,
|
|
65
|
-
(a ===
|
|
63
|
+
const a = i.href, b = `${window.location.href}${l}`;
|
|
64
|
+
(a === b || a.endsWith(l)) && (i.href = `{{${c}_${n}}}`);
|
|
66
65
|
}
|
|
67
66
|
break;
|
|
68
67
|
}
|
|
69
68
|
case "price":
|
|
70
69
|
case "originalPrice": {
|
|
71
70
|
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";
|
|
72
|
-
let
|
|
73
|
-
i ?
|
|
71
|
+
let b;
|
|
72
|
+
i ? b = c ? e.SINGLE_PRICE_FORMATTED : e.SINGLE_PRICE : b = c ? e.PRICE_FORMATTED : e.PRICE;
|
|
74
73
|
const g = e.CURRENCY;
|
|
75
|
-
let u = `{{${
|
|
74
|
+
let u = `{{${b}_${n}}}`;
|
|
76
75
|
const H = (t.getAttribute(U.SYMBOL) || "").trim(), G = Y(H);
|
|
77
76
|
let F = "";
|
|
78
77
|
G ? F = H : g && (F = `{{${g}_${n}}}`), F && (u = a === "after" ? `${u} ${F}` : `${F} ${u}`), t.innerHTML = L(t, u);
|
|
79
78
|
break;
|
|
80
79
|
}
|
|
81
80
|
case "quantity": {
|
|
82
|
-
const e = f, s = e.ATTR, l = [e.DEFAULT, ...e.LEGACY_DEFAULTS], c = (
|
|
81
|
+
const e = f, s = e.ATTR, l = [e.DEFAULT, ...e.LEGACY_DEFAULTS], c = (x = t.textContent) == null ? void 0 : x.trim();
|
|
83
82
|
c && l.includes(c) && (t.innerHTML = L(t, `{{${s}_${n}}}`));
|
|
84
83
|
break;
|
|
85
84
|
}
|
|
@@ -89,7 +88,7 @@ function ot($) {
|
|
|
89
88
|
const i = c.href || "", a = `${window.location.href}${l}`;
|
|
90
89
|
(i === "" || i === "#" || i === a || i.endsWith(l) || i.endsWith("#!") || i === window.location.href) && (c.href = `{{${s}_${n}}}`);
|
|
91
90
|
}
|
|
92
|
-
|
|
91
|
+
Q(t, `{{${s}_${n}}}`);
|
|
93
92
|
break;
|
|
94
93
|
}
|
|
95
94
|
case "itemLink": {
|
|
@@ -130,30 +129,30 @@ function ot($) {
|
|
|
130
129
|
h = h.replace(o, B(n));
|
|
131
130
|
}
|
|
132
131
|
});
|
|
133
|
-
const V = A.querySelectorAll('[product-attr="originalPrice"][data-type]'), w = /* @__PURE__ */ new Map(),
|
|
132
|
+
const V = A.querySelectorAll('[product-attr="originalPrice"][data-type]'), w = /* @__PURE__ */ new Map(), D = /* @__PURE__ */ new Set();
|
|
134
133
|
return V.forEach((o) => {
|
|
135
134
|
var t;
|
|
136
135
|
const p = o.getAttribute("data-number"), T = o.getAttribute("data-type");
|
|
137
136
|
if (!p || !q[T])
|
|
138
137
|
return;
|
|
139
138
|
const r = o.closest(".product-original-price-class");
|
|
140
|
-
if (!r ||
|
|
139
|
+
if (!r || D.has(r))
|
|
141
140
|
return;
|
|
142
|
-
|
|
141
|
+
D.add(r);
|
|
143
142
|
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: [] };
|
|
144
143
|
R.wrap.push(y !== "false"), w.set(_, R);
|
|
145
144
|
}), w.forEach(({ number: o, type: p, wrap: T }, r) => {
|
|
146
145
|
if (r.includes("{% if") || !T.some(Boolean))
|
|
147
146
|
return;
|
|
148
147
|
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)];
|
|
149
|
-
let m = "", n = 0, f = 0,
|
|
150
|
-
for (;
|
|
151
|
-
const I = T[f] === !0 && !
|
|
152
|
-
m += h.slice(n,
|
|
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);
|
|
153
152
|
}
|
|
154
153
|
h = m + h.slice(n);
|
|
155
|
-
}),
|
|
154
|
+
}), h.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
156
155
|
}
|
|
157
156
|
export {
|
|
158
|
-
|
|
157
|
+
et as pairProductVariables
|
|
159
158
|
};
|