@useinsider/guido 3.18.2-beta.fc246a7 → 3.18.2-beta.ff43aaa
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/organisms/save-as-template/SaveAsTemplateDrawer.vue2.js +34 -34
- package/dist/composables/useHttp.js +24 -22
- package/dist/config/migrator/itemsBlockMigrator.js +167 -257
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +17 -18
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +105 -114
- package/dist/extensions/Blocks/Items/enums/productEnums.js +9 -14
- package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +9 -11
- package/dist/extensions/Blocks/Items/template.js +204 -219
- package/dist/services/templateLibraryApi.js +17 -14
- package/dist/src/extensions/Blocks/Items/enums/productEnums.d.ts +0 -3
- package/dist/src/extensions/Blocks/Items/template.d.ts +0 -19
- package/dist/src/utils/genericUtil.d.ts +6 -0
- package/dist/src/utils/liquidDynamicContent.d.ts +20 -0
- package/dist/utils/genericUtil.js +63 -54
- package/dist/utils/liquidDynamicContent.js +15 -0
- package/dist/utils/pairProductVariables.js +71 -71
- package/dist/utils/templatePreparation.js +37 -36
- package/package.json +1 -1
- package/dist/extensions/Blocks/Items/constants/cardLayout.js +0 -20
- package/dist/src/extensions/Blocks/Items/constants/cardLayout.d.ts +0 -44
|
@@ -4,13 +4,14 @@ import { useToaster as C } from "../composables/useToaster.js";
|
|
|
4
4
|
import { useTranslations as h } from "../composables/useTranslations.js";
|
|
5
5
|
import { useLiquidValidator as S } from "../composables/validators/useLiquidValidator.js";
|
|
6
6
|
import { EditorType as v } from "../enums/defaults.js";
|
|
7
|
-
import { ToasterTypeOptions as
|
|
8
|
-
import { useRecommendationExtensionStore as
|
|
9
|
-
import { useSaveAsTemplateStore as
|
|
7
|
+
import { ToasterTypeOptions as x } from "../enums/toaster.js";
|
|
8
|
+
import { useRecommendationExtensionStore as E } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
9
|
+
import { useSaveAsTemplateStore as N } from "../stores/save-as-template.js";
|
|
10
10
|
import { base64EncodeWithSpecialChars as r } from "../utils/base64.js";
|
|
11
|
+
import { isPlainObject as P } from "../utils/genericUtil.js";
|
|
11
12
|
import { useTemplatePreparation as A } from "../utils/templatePreparation.js";
|
|
12
|
-
const
|
|
13
|
-
const { get: n, post: m } = b(), { handleError: o, showToaster: l } = C(), { config: c, isFeatureEnabled: p } = w(), { validateLiquidSyntax:
|
|
13
|
+
const B = () => {
|
|
14
|
+
const { get: n, post: m } = b(), { handleError: o, showToaster: l } = C(), { config: c, isFeatureEnabled: p } = w(), { validateLiquidSyntax: f } = S(), u = h();
|
|
14
15
|
return {
|
|
15
16
|
getCategories: async () => {
|
|
16
17
|
try {
|
|
@@ -40,10 +41,10 @@ const j = () => {
|
|
|
40
41
|
createTemplate: async () => {
|
|
41
42
|
var e, t, d, y;
|
|
42
43
|
try {
|
|
43
|
-
const { prepareTemplateDetails: i } = A(), s =
|
|
44
|
-
if (p("liquidSyntax") && !await
|
|
44
|
+
const { prepareTemplateDetails: i } = A(), s = N(), a = await i();
|
|
45
|
+
if (p("liquidSyntax") && !await f(a.compiledHtml))
|
|
45
46
|
return !1;
|
|
46
|
-
const
|
|
47
|
+
const T = {
|
|
47
48
|
name: s.getTemplateName,
|
|
48
49
|
categories: s.getSelectedCategoryIds,
|
|
49
50
|
productId: ((t = (e = c.value) == null ? void 0 : e.partner) == null ? void 0 : t.productType) || 0,
|
|
@@ -54,7 +55,7 @@ const j = () => {
|
|
|
54
55
|
unsubscriptionPreferencePageStatus: !1,
|
|
55
56
|
unsubscriptionPreferencePages: [],
|
|
56
57
|
recommendationCampaignUrls: r(
|
|
57
|
-
|
|
58
|
+
E().recommendationCampaignUrls
|
|
58
59
|
),
|
|
59
60
|
recommendationConfigs: r({}),
|
|
60
61
|
isGuido: !0,
|
|
@@ -66,16 +67,18 @@ const j = () => {
|
|
|
66
67
|
css: a.css,
|
|
67
68
|
dynamicContentList: a.dynamicContentList
|
|
68
69
|
})
|
|
69
|
-
}, { data:
|
|
70
|
+
}, { data: g } = await m(
|
|
70
71
|
"/newsletter/template-library/create-template",
|
|
71
|
-
|
|
72
|
+
T
|
|
72
73
|
);
|
|
73
|
-
|
|
74
|
+
if (!P(g))
|
|
75
|
+
throw new Error("Unexpected create-template response");
|
|
76
|
+
return g.type === "alert" ? (l({
|
|
74
77
|
message: u(
|
|
75
78
|
"newsletter.template-library-save-alert",
|
|
76
79
|
{ templateName: s.getTemplateName }
|
|
77
80
|
),
|
|
78
|
-
type:
|
|
81
|
+
type: x.Error
|
|
79
82
|
}), !1) : (l({
|
|
80
83
|
message: u(
|
|
81
84
|
"newsletter.template-library-save-success",
|
|
@@ -90,5 +93,5 @@ const j = () => {
|
|
|
90
93
|
};
|
|
91
94
|
};
|
|
92
95
|
export {
|
|
93
|
-
|
|
96
|
+
B as useTemplateLibraryApi
|
|
94
97
|
};
|
|
@@ -39,17 +39,14 @@ export declare const productPairs: {
|
|
|
39
39
|
CART_ITEMS: {
|
|
40
40
|
ATTR: string;
|
|
41
41
|
DEFAULT: string;
|
|
42
|
-
LEGACY_DEFAULTS: readonly string[];
|
|
43
42
|
};
|
|
44
43
|
BROWSED_ITEMS: {
|
|
45
44
|
ATTR: string;
|
|
46
45
|
DEFAULT: string;
|
|
47
|
-
LEGACY_DEFAULTS: readonly string[];
|
|
48
46
|
};
|
|
49
47
|
PURCHASED_ITEMS: {
|
|
50
48
|
ATTR: string;
|
|
51
49
|
DEFAULT: string;
|
|
52
|
-
LEGACY_DEFAULTS: readonly string[];
|
|
53
50
|
};
|
|
54
51
|
};
|
|
55
52
|
price: {
|
|
@@ -37,25 +37,6 @@ type TemplateParameters = {
|
|
|
37
37
|
/** Price orientation within the card ('vertical' = stacked, 'horizontal' = side-by-side) */
|
|
38
38
|
priceOrientation?: PriceOrientationType;
|
|
39
39
|
};
|
|
40
|
-
/**
|
|
41
|
-
* Applies price orientation styles to the generated HTML template.
|
|
42
|
-
*
|
|
43
|
-
* For Vertical Layout:
|
|
44
|
-
* - vertical price orientation: both cells 100% (stacked)
|
|
45
|
-
* - horizontal price orientation with both visible: both cells 50% (side-by-side)
|
|
46
|
-
* - horizontal price orientation with one hidden: visible cell 100%
|
|
47
|
-
*
|
|
48
|
-
* For Horizontal Layout:
|
|
49
|
-
* - horizontal price orientation: .horizontal-price visible, .vertical-price hidden
|
|
50
|
-
* - vertical price orientation: .horizontal-price hidden, .vertical-price visible
|
|
51
|
-
* @param html - The HTML template string with placeholders replaced
|
|
52
|
-
* @param layoutOrientation - The card layout orientation ('vertical' or 'horizontal')
|
|
53
|
-
* @param priceOrientation - The price orientation within the card ('vertical' or 'horizontal')
|
|
54
|
-
* @param isPriceVisible - Whether the price element is visible
|
|
55
|
-
* @param isOriginalPriceVisible - Whether the original price element is visible
|
|
56
|
-
* @returns HTML string with price orientation styles applied
|
|
57
|
-
*/
|
|
58
|
-
export declare const applyPriceOrientationStyles: (html: string, layoutOrientation: OrientationType, priceOrientation: PriceOrientationType, isPriceVisible?: boolean, isOriginalPriceVisible?: boolean) => string;
|
|
59
40
|
/**
|
|
60
41
|
* Generates the default template for the Items Block.
|
|
61
42
|
* @param params - Template parameters including orientation, items type, item ID, and formatting options
|
|
@@ -30,3 +30,9 @@ export declare const replaceString: (string?: string, values?: Record<string, st
|
|
|
30
30
|
* a string nor a number becomes ''.
|
|
31
31
|
*/
|
|
32
32
|
export declare const asText: (value: unknown) => string;
|
|
33
|
+
/**
|
|
34
|
+
* Narrows an unknown API value to a plain JSON object. Arrays and exotic
|
|
35
|
+
* objects (Blob, Date, FormData) are rejected, so a response body that useHttp
|
|
36
|
+
* parsed as text or blob can never be read as a JSON payload.
|
|
37
|
+
*/
|
|
38
|
+
export declare const isPlainObject: <T>(value: T) => value is T & Record<string, unknown>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { BaseDynamicContent } from '@@/Types/generic';
|
|
2
|
+
export type DynamicContentFormat = NonNullable<BaseDynamicContent['format']>;
|
|
3
|
+
/** Format key the dynamic-content picker sends for a custom date/time format. */
|
|
4
|
+
export declare const TIME_FORMAT_KEY = "time-format";
|
|
5
|
+
/** Wraps a Liquid filter argument in whichever quote style the value itself does not use. */
|
|
6
|
+
export declare const quoteArgument: (value: string) => string | null;
|
|
7
|
+
/**
|
|
8
|
+
* `{ key: 'time-format', value: '%Y-%m-%d' }` -> `date: "%Y-%m-%d"`.
|
|
9
|
+
*
|
|
10
|
+
* Only a custom date/time strftime pattern has a Liquid equivalent. Anything else returns null so
|
|
11
|
+
* the caller emits a plain tag rather than one that silently lost — or literally printed — its
|
|
12
|
+
* format.
|
|
13
|
+
* @example formatToLiquidFilter({ key: 'time-format', value: '%b %-d, %Y' }) -> date: "%b %-d, %Y"
|
|
14
|
+
*/
|
|
15
|
+
export declare const formatToLiquidFilter: (format: DynamicContentFormat) => string | null;
|
|
16
|
+
/**
|
|
17
|
+
* Inverse of `formatToLiquidFilter` — reads the picker format back out of one filter segment, so a
|
|
18
|
+
* reopened tag restores its selection in the host's format dropdown.
|
|
19
|
+
*/
|
|
20
|
+
export declare const liquidFilterToFormat: (segment: string) => DynamicContentFormat | null;
|
|
@@ -1,69 +1,78 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { formatToLiquidFilter as b, quoteArgument as y, liquidFilterToFormat as h } from "./liquidDynamicContent.js";
|
|
2
|
+
const g = (t) => {
|
|
3
|
+
if (!t.includes("="))
|
|
4
|
+
return null;
|
|
5
|
+
const [r, e] = t.split("=");
|
|
6
|
+
return { key: r.trim(), value: e.trim() };
|
|
7
|
+
}, c = "default:", f = (t) => {
|
|
8
|
+
if (!t.startsWith(c))
|
|
9
|
+
return t;
|
|
10
|
+
const r = t.slice(c.length).trim(), e = (l) => r.length >= 2 && r.startsWith(l) && r.endsWith(l);
|
|
11
|
+
return e('"') || e("'") ? r.slice(1, -1) : r;
|
|
12
|
+
}, k = (t) => {
|
|
13
|
+
const e = t.value.match(/\{\{([^}]+)\}\}/)[1].split("|").map((a) => a.trim()), [l] = e, s = {
|
|
3
14
|
text: t.label,
|
|
4
|
-
value:
|
|
15
|
+
value: l || ""
|
|
5
16
|
};
|
|
6
|
-
if (
|
|
7
|
-
const [,
|
|
8
|
-
if (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
n ? r.format = n : e || (r.fallback = l), e && (r.fallback = e);
|
|
17
|
+
if (e.length >= 2) {
|
|
18
|
+
const [, a, n] = e;
|
|
19
|
+
if (a.startsWith(c))
|
|
20
|
+
s.fallback = f(a);
|
|
21
|
+
else {
|
|
22
|
+
const o = h(a) ?? g(a);
|
|
23
|
+
o ? s.format = o : n || (s.fallback = a), n && (s.fallback = f(n));
|
|
14
24
|
}
|
|
15
25
|
}
|
|
16
|
-
return
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
};
|
|
23
|
-
if (c) {
|
|
24
|
-
if (!a.fallback)
|
|
25
|
-
return {
|
|
26
|
-
label: a.text,
|
|
27
|
-
value: `{{ ${a.value} }}`
|
|
28
|
-
};
|
|
29
|
-
const r = !Number.isNaN(Number(a.fallback)) && a.fallback.trim() !== "" ? a.fallback : `"${a.fallback}"`;
|
|
30
|
-
return {
|
|
31
|
-
label: `${a.text} | ${a.fallback}`,
|
|
32
|
-
value: `{{ ${a.value} | default: ${r} }}`
|
|
33
|
-
};
|
|
34
|
-
}
|
|
26
|
+
return s;
|
|
27
|
+
}, p = (t) => {
|
|
28
|
+
const e = !Number.isNaN(Number(t)) && t.trim() !== "" ? t : y(t);
|
|
29
|
+
return e === null ? null : `${c} ${e}`;
|
|
30
|
+
}, v = (t) => {
|
|
31
|
+
const r = t.format ? b(t.format) : null, e = t.fallback ? p(t.fallback) : null, l = [t.value, r, e].filter(Boolean);
|
|
35
32
|
return {
|
|
36
|
-
label:
|
|
37
|
-
value:
|
|
33
|
+
label: [t.text, r, e && t.fallback].filter(Boolean).join(" | "),
|
|
34
|
+
value: `{{ ${l.join(" | ")} }}`
|
|
38
35
|
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
36
|
+
}, i = (t, r = !1) => t.map((e) => r ? v(e) : e.format ? {
|
|
37
|
+
label: `${e.text} | ${e.format.key}=${e.format.value}`,
|
|
38
|
+
value: `{{${e.value}|${e.format.key}=${e.format.value}}}`
|
|
39
|
+
} : {
|
|
40
|
+
label: e.fallback ? `${e.text} | ${e.fallback}` : e.text,
|
|
41
|
+
value: e.fallback ? `{{${e.value}|${e.fallback}}}` : `{{${e.value}}}`
|
|
42
|
+
}), $ = (t) => {
|
|
43
|
+
const r = [], e = /* @__PURE__ */ new Set(), l = (a) => {
|
|
44
|
+
Array.isArray(a) && a.forEach((n) => {
|
|
45
|
+
const o = [...n.children ?? [], ...n.select_items ?? []];
|
|
46
|
+
if (o.length > 0) {
|
|
47
|
+
l(o);
|
|
45
48
|
return;
|
|
46
49
|
}
|
|
47
|
-
const u =
|
|
48
|
-
u &&
|
|
50
|
+
const u = n.text || n.tag_text;
|
|
51
|
+
u && n.value && !e.has(n.value) && (e.add(n.value), r.push({ text: u, value: n.value }));
|
|
49
52
|
});
|
|
50
|
-
}, [
|
|
51
|
-
return s
|
|
52
|
-
},
|
|
53
|
-
const
|
|
53
|
+
}, [s] = Object.values(t ?? {});
|
|
54
|
+
return l(s), r;
|
|
55
|
+
}, d = (t, r, e = !1) => {
|
|
56
|
+
const l = new Set(t.map((a) => a.value)), s = r.filter((a) => l.has(a.value) ? !1 : (l.add(a.value), !0));
|
|
54
57
|
return [
|
|
55
|
-
...
|
|
56
|
-
...
|
|
58
|
+
...i(t, e),
|
|
59
|
+
...i(s, e)
|
|
57
60
|
];
|
|
58
|
-
},
|
|
61
|
+
}, F = () => {
|
|
59
62
|
var t;
|
|
60
63
|
return ((t = document.head.querySelector('meta[name="csrf-token"]')) == null ? void 0 : t.getAttribute("content")) ?? "";
|
|
61
|
-
},
|
|
64
|
+
}, T = (t) => typeof t == "string" ? t : typeof t == "number" ? String(t) : "", x = (t) => {
|
|
65
|
+
if (t === null || typeof t != "object" || Array.isArray(t))
|
|
66
|
+
return !1;
|
|
67
|
+
const r = Object.getPrototypeOf(t);
|
|
68
|
+
return r === Object.prototype || r === null;
|
|
69
|
+
};
|
|
62
70
|
export {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
71
|
+
T as asText,
|
|
72
|
+
d as buildMergeTagEntries,
|
|
73
|
+
i as dynamicContentToMergeTags,
|
|
74
|
+
$ as flattenDynamicContentList,
|
|
75
|
+
F as getCsrfToken,
|
|
76
|
+
x as isPlainObject,
|
|
77
|
+
k as mergeTagToDynamicContent
|
|
69
78
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const E = "time-format", r = "date", u = new RegExp(`^${r}\\s*:\\s*(?:"([^"]*)"|'([^']*)')$`), s = /%[-_0^#]?\d*[a-zA-Z%]/, c = new RegExp(s, "g"), l = /\b(?:Y{2,4}|M{2,4}|D{1,4}|d{3,4}|H{2}|h{2}|m{2}|s{2}|S{1,3}|A|a)\b/, T = (t) => t.includes('"') ? t.includes("'") ? null : `'${t}'` : `"${t}"`, i = (t) => s.test(t) && !l.test(t.replace(c, "")), R = (t) => {
|
|
2
|
+
if (t.key !== E || !i(t.value ?? ""))
|
|
3
|
+
return null;
|
|
4
|
+
const n = T(t.value);
|
|
5
|
+
return n === null ? null : `${r}: ${n}`;
|
|
6
|
+
}, _ = (t) => {
|
|
7
|
+
const [, n, o] = t.match(u) ?? [], e = n ?? o;
|
|
8
|
+
return e ? { key: E, value: e } : null;
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
E as TIME_FORMAT_KEY,
|
|
12
|
+
R as formatToLiquidFilter,
|
|
13
|
+
_ as liquidFilterToFormat,
|
|
14
|
+
T as quoteArgument
|
|
15
|
+
};
|
|
@@ -1,100 +1,100 @@
|
|
|
1
|
-
import { ITEMS_CURRENCY_ATTR as
|
|
2
|
-
import { productPairs as
|
|
1
|
+
import { ITEMS_CURRENCY_ATTR as D, isCustomCurrencySymbol as G } from "../extensions/Blocks/Items/constants/currency.js";
|
|
2
|
+
import { productPairs as L } from "../extensions/Blocks/Items/enums/productEnums.js";
|
|
3
3
|
import { escapeReplacement as X } from "../extensions/Blocks/Items/utils/nodeConfigUtils.js";
|
|
4
|
-
import { preserveTextStyles as
|
|
5
|
-
import { unwrapProductNameLinks as
|
|
6
|
-
const
|
|
4
|
+
import { preserveTextStyles as F } from "./preserveTextStyles.js";
|
|
5
|
+
import { unwrapProductNameLinks as Y } from "./unwrapProductNameLink.js";
|
|
6
|
+
const x = {
|
|
7
7
|
CART_ITEMS: "ins_apr",
|
|
8
8
|
BROWSED_ITEMS: "browsed_item",
|
|
9
9
|
PURCHASED_ITEMS: "purchased_item"
|
|
10
|
-
},
|
|
11
|
-
function
|
|
10
|
+
}, O = (S) => S.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->");
|
|
11
|
+
function v(S, y, b) {
|
|
12
12
|
let h = y;
|
|
13
13
|
for (; h > 0 && /\s/.test(S[h - 1]); )
|
|
14
14
|
h -= 1;
|
|
15
15
|
return b.some((I) => S.endsWith(I, h));
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
const y =
|
|
19
|
-
|
|
20
|
-
const h =
|
|
17
|
+
function K(S) {
|
|
18
|
+
const y = O(S), b = new DOMParser().parseFromString(y, "text/html");
|
|
19
|
+
Y(b);
|
|
20
|
+
const h = L.PAIRS_FOR_EXTENSION;
|
|
21
21
|
Object.entries(h).forEach(([n, d]) => {
|
|
22
22
|
b.querySelectorAll(".ins-product-td").forEach((r) => {
|
|
23
23
|
const E = r.getAttribute("data-number") || "1", m = r.getAttribute("data-type") || "CART_ITEMS";
|
|
24
24
|
r.querySelectorAll(`[product-attr="${n}"]`).forEach((t) => {
|
|
25
|
-
var $,
|
|
26
|
-
const g = t.getAttribute("data-type") || m, o = t.getAttribute("data-number") || E,
|
|
27
|
-
if (
|
|
25
|
+
var $, H, N;
|
|
26
|
+
const g = t.getAttribute("data-type") || m, o = t.getAttribute("data-number") || E, u = d[g];
|
|
27
|
+
if (u)
|
|
28
28
|
switch (n) {
|
|
29
29
|
case "imageSrc": {
|
|
30
|
-
let e = null,
|
|
31
|
-
if (t.tagName === "IMG" ? (e = t,
|
|
30
|
+
let e = null, s = null;
|
|
31
|
+
if (t.tagName === "IMG" ? (e = t, s = e.closest("a")) : (e = t.querySelector("img"), s = t.querySelector("a") || t.closest("a")), !e)
|
|
32
32
|
break;
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
return
|
|
39
|
-
}) && (e.src = `{{${
|
|
33
|
+
const a = u.DEFAULT, l = u.ATTR;
|
|
34
|
+
if (a && e.src) {
|
|
35
|
+
const i = e.src;
|
|
36
|
+
a.some((_) => {
|
|
37
|
+
const f = _.split("/").pop() || "", P = i.split("/").pop() || "";
|
|
38
|
+
return i.includes(_) || i.includes(f) || P === f;
|
|
39
|
+
}) && (e.src = `{{${l}_${o}}}`);
|
|
40
40
|
}
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
45
|
-
const
|
|
46
|
-
(
|
|
41
|
+
const c = (H = ($ = h.name) == null ? void 0 : $[g]) == null ? void 0 : H.ATTR;
|
|
42
|
+
if (c && e.setAttribute("alt", `{{${c}_${o}}}`), s) {
|
|
43
|
+
const i = (N = h.itemLink) == null ? void 0 : N[g];
|
|
44
|
+
if (i) {
|
|
45
|
+
const R = i.HREF, _ = i.DEFAULT_HREF || "#!", f = s.href;
|
|
46
|
+
(f === "#" || f === "" || f.endsWith("#!") || f.endsWith(_) || f === `${window.location.href}${_}` || !f || f === window.location.href) && (s.href = `{{${R}_${o}}}`);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
break;
|
|
50
50
|
}
|
|
51
51
|
case "name": {
|
|
52
|
-
const e =
|
|
53
|
-
t.textContent && (t.innerHTML =
|
|
54
|
-
const
|
|
55
|
-
if (
|
|
56
|
-
const
|
|
57
|
-
(
|
|
52
|
+
const e = u, s = e.ATTR, a = e.DEFAULT_HREF || "#!", l = e.HREF;
|
|
53
|
+
t.textContent && (t.innerHTML = F(t, `{{${s}_${o}}}`));
|
|
54
|
+
const c = t.closest("a") || (t.tagName === "A" ? t : null);
|
|
55
|
+
if (c && l) {
|
|
56
|
+
const i = c.href, R = `${window.location.href}${a}`;
|
|
57
|
+
(i === R || i.endsWith(a)) && (c.href = `{{${l}_${o}}}`);
|
|
58
58
|
}
|
|
59
59
|
break;
|
|
60
60
|
}
|
|
61
61
|
case "price":
|
|
62
62
|
case "originalPrice": {
|
|
63
|
-
const e =
|
|
64
|
-
let
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
let
|
|
68
|
-
const
|
|
63
|
+
const e = u, s = t.getAttribute("data-formated"), a = t.getAttribute("data-single_price"), l = s === "true", c = a === "true", i = t.getAttribute(D.POSITION) || "before";
|
|
64
|
+
let R;
|
|
65
|
+
c ? R = l ? e.SINGLE_PRICE_FORMATTED : e.SINGLE_PRICE : R = l ? e.PRICE_FORMATTED : e.PRICE;
|
|
66
|
+
const _ = e.CURRENCY;
|
|
67
|
+
let f = `{{${R}_${o}}}`;
|
|
68
|
+
const P = (t.getAttribute(D.SYMBOL) || "").trim(), V = G(P);
|
|
69
69
|
let C = "";
|
|
70
|
-
|
|
70
|
+
V ? C = P : _ && (C = `{{${_}_${o}}}`), C && (f = i === "after" ? `${f} ${C}` : `${C} ${f}`), t.innerHTML = F(t, f);
|
|
71
71
|
break;
|
|
72
72
|
}
|
|
73
73
|
case "quantity": {
|
|
74
|
-
const e =
|
|
75
|
-
|
|
74
|
+
const e = u, s = e.ATTR, a = e.DEFAULT;
|
|
75
|
+
t.textContent && t.textContent.trim() === a && (t.innerHTML = F(t, `{{${s}_${o}}}`));
|
|
76
76
|
break;
|
|
77
77
|
}
|
|
78
78
|
case "button": {
|
|
79
|
-
const e =
|
|
80
|
-
if (
|
|
81
|
-
const
|
|
82
|
-
(
|
|
79
|
+
const e = u, s = e.HREF, a = e.DEFAULT_HREF || "#!", l = t.tagName === "A" ? t : t.querySelector("a");
|
|
80
|
+
if (l) {
|
|
81
|
+
const c = l.href || "", i = `${window.location.href}${a}`;
|
|
82
|
+
(c === "" || c === "#" || c === i || c.endsWith(a) || c.endsWith("#!") || c === window.location.href) && (l.href = `{{${s}_${o}}}`);
|
|
83
83
|
}
|
|
84
84
|
break;
|
|
85
85
|
}
|
|
86
86
|
case "itemLink": {
|
|
87
|
-
const e =
|
|
88
|
-
if (
|
|
89
|
-
const
|
|
90
|
-
(
|
|
87
|
+
const e = u, s = e.HREF, a = e.DEFAULT_HREF || "#!", l = t;
|
|
88
|
+
if (l.href) {
|
|
89
|
+
const c = l.href, i = `${window.location.href}${a}`;
|
|
90
|
+
(c === i || c.endsWith(a)) && (l.href = `{{${s}_${o}}}`);
|
|
91
91
|
}
|
|
92
92
|
break;
|
|
93
93
|
}
|
|
94
94
|
default: {
|
|
95
|
-
if ("ATTR" in
|
|
96
|
-
const e =
|
|
97
|
-
t.textContent && (t.innerHTML =
|
|
95
|
+
if ("ATTR" in u) {
|
|
96
|
+
const e = u.ATTR;
|
|
97
|
+
t.textContent && (t.innerHTML = F(t, `{{${e}_${o}}}`));
|
|
98
98
|
}
|
|
99
99
|
break;
|
|
100
100
|
}
|
|
@@ -102,9 +102,9 @@ function Z(S) {
|
|
|
102
102
|
});
|
|
103
103
|
});
|
|
104
104
|
});
|
|
105
|
-
const I = y.match(/<!DOCTYPE[^>]*>/i),
|
|
106
|
-
` : "",
|
|
107
|
-
|
|
105
|
+
const I = y.match(/<!DOCTYPE[^>]*>/i), q = I ? `${I[0]}
|
|
106
|
+
` : "", U = b.querySelectorAll(".ins-product-td"), M = [];
|
|
107
|
+
U.forEach((n) => {
|
|
108
108
|
const d = n.getAttribute("data-type") || "CART_ITEMS", p = n.getAttribute("data-number") || "1", r = n.outerHTML;
|
|
109
109
|
M.push({
|
|
110
110
|
element: n,
|
|
@@ -113,38 +113,38 @@ function Z(S) {
|
|
|
113
113
|
number: p
|
|
114
114
|
});
|
|
115
115
|
});
|
|
116
|
-
let A =
|
|
116
|
+
let A = q + b.documentElement.outerHTML;
|
|
117
117
|
M.reverse().forEach(({ outerHtml: n, type: d, number: p }) => {
|
|
118
|
-
const r =
|
|
118
|
+
const r = x[d], E = r ? `${r}_total_product_kind` : "";
|
|
119
119
|
if (E) {
|
|
120
120
|
const T = parseInt(p) - 1, o = `${`{% if ${E} > ${T} %}`}${n}{% endif %}`;
|
|
121
121
|
A = A.replace(n, X(o));
|
|
122
122
|
}
|
|
123
123
|
});
|
|
124
|
-
const
|
|
125
|
-
return
|
|
124
|
+
const W = b.querySelectorAll('[product-attr="originalPrice"][data-type]'), w = /* @__PURE__ */ new Map(), k = /* @__PURE__ */ new Set();
|
|
125
|
+
return W.forEach((n) => {
|
|
126
126
|
var t;
|
|
127
127
|
const d = n.getAttribute("data-number"), p = n.getAttribute("data-type");
|
|
128
|
-
if (!d || !
|
|
128
|
+
if (!d || !x[p])
|
|
129
129
|
return;
|
|
130
130
|
const r = n.closest(".product-original-price-class");
|
|
131
131
|
if (!r || k.has(r))
|
|
132
132
|
return;
|
|
133
133
|
k.add(r);
|
|
134
|
-
const E = r.outerHTML, m = (t = n.closest(".ins-product-td")) == null ? void 0 : t.getAttribute("data-nodup"), T =
|
|
135
|
-
T.wrap.push(m !== "false"),
|
|
136
|
-
}),
|
|
134
|
+
const E = r.outerHTML, m = (t = n.closest(".ins-product-td")) == null ? void 0 : t.getAttribute("data-nodup"), T = w.get(E) ?? { number: d, type: p, wrap: [] };
|
|
135
|
+
T.wrap.push(m !== "false"), w.set(E, T);
|
|
136
|
+
}), w.forEach(({ number: n, type: d, wrap: p }, r) => {
|
|
137
137
|
if (r.includes("{% if") || !p.some(Boolean))
|
|
138
138
|
return;
|
|
139
|
-
const E =
|
|
140
|
-
let g = "", o = 0,
|
|
139
|
+
const E = L.PAIRS_FOR_EXTENSION.price[d].PRICE, m = L.PAIRS_FOR_EXTENSION.originalPrice[d].PRICE, T = `{% if ${E}_${n} != ${m}_${n} %}`, t = [T, O(T)];
|
|
140
|
+
let g = "", o = 0, u = 0, $ = A.indexOf(r);
|
|
141
141
|
for (; $ !== -1; ) {
|
|
142
|
-
const
|
|
143
|
-
g += A.slice(o, $) + (
|
|
142
|
+
const H = p[u] === !0 && !v(A, $, t);
|
|
143
|
+
g += A.slice(o, $) + (H ? `${T}${r}{% endif %}` : r), o = $ + r.length, u += 1, $ = A.indexOf(r, o);
|
|
144
144
|
}
|
|
145
145
|
A = g + A.slice(o);
|
|
146
146
|
}), A.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
147
147
|
}
|
|
148
148
|
export {
|
|
149
|
-
|
|
149
|
+
K as pairProductVariables
|
|
150
150
|
};
|