@useinsider/guido 3.19.0-beta.cac604e → 3.19.0-beta.cd75ff0
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 +1 -0
- package/dist/@types/config/schemas.js +39 -37
- package/dist/components/Guido.vue.js +4 -4
- package/dist/components/Guido.vue2.js +83 -75
- package/dist/components/organisms/AutoSaveController.vue2.js +10 -8
- package/dist/components/organisms/base/AuthErrorModal.vue.js +18 -0
- package/dist/components/organisms/base/AuthErrorModal.vue2.js +42 -0
- package/dist/components/organisms/header/EditorActions.vue.js +5 -5
- package/dist/components/organisms/header/EditorActions.vue2.js +83 -46
- package/dist/components/organisms/header/LeftSlot.vue.js +5 -5
- package/dist/components/organisms/header/LeftSlot.vue2.js +16 -12
- package/dist/components/organisms/validation/ValidationErrorDrawer.vue.js +20 -0
- package/dist/components/organisms/validation/ValidationErrorDrawer.vue2.js +50 -0
- package/dist/components/wrappers/WpDrawer.vue.js +9 -7
- package/dist/components/wrappers/WpDrawer.vue2.js +1 -1
- package/dist/components/wrappers/WpModal.vue.js +1 -1
- package/dist/components/wrappers/WpModal.vue2.js +4 -3
- package/dist/composables/useAuthError.js +52 -0
- package/dist/composables/useAutoSave.js +44 -42
- package/dist/composables/useHtmlCompiler.js +37 -26
- package/dist/composables/useHtmlValidator.js +2 -0
- package/dist/composables/useHttp.js +64 -54
- package/dist/composables/useLegacyStrategyConversion.js +23 -19
- package/dist/composables/useSave.js +92 -45
- package/dist/composables/useSaveValidation.js +284 -0
- package/dist/composables/useSaveValidationRollout.js +20 -0
- package/dist/composables/useStripo.js +24 -20
- package/dist/composables/useToaster.js +17 -15
- package/dist/composables/validators/useCouponBlockValidator.js +24 -21
- package/dist/composables/validators/useLiquidValidator.js +15 -15
- package/dist/composables/validators/useUnsubscribeBlockValidator.js +34 -27
- package/dist/config/migrator/index.js +14 -13
- package/dist/config/migrator/recommendationPartnerMigrator.js +50 -0
- package/dist/enums/extensions/recommendationBlock.js +30 -29
- package/dist/enums/save-validation.js +4 -0
- package/dist/extensions/Blocks/Recommendation/block.js +54 -88
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +32 -51
- package/dist/extensions/Blocks/Recommendation/utils/partnerScope.js +11 -12
- package/dist/guido.css +1 -1
- package/dist/services/settingsApi.js +11 -0
- package/dist/src/@types/config/schemas.d.ts +4 -0
- package/dist/src/@types/save-validation.d.ts +19 -0
- package/dist/src/components/Guido.vue.d.ts +17 -1
- package/dist/src/components/organisms/base/AuthErrorModal.vue.d.ts +2 -0
- package/dist/src/components/organisms/header/EditorActions.vue.d.ts +17 -1
- package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +17 -1
- package/dist/src/components/organisms/header/RightSlot.vue.d.ts +17 -1
- package/dist/src/components/organisms/validation/ValidationErrorDrawer.vue.d.ts +2 -0
- package/dist/src/components/wrappers/WpDrawer.vue.d.ts +4 -3
- package/dist/src/components/wrappers/WpModal.vue.d.ts +5 -1
- package/dist/src/composables/useAuthError.d.ts +12 -0
- package/dist/src/composables/useAutoSave.d.ts +4 -1
- package/dist/src/composables/useConfig.d.ts +2 -0
- package/dist/src/composables/useHtmlValidator.d.ts +21 -0
- package/dist/src/composables/useHttp.d.ts +2 -0
- package/dist/src/composables/useSave.d.ts +6 -1
- package/dist/src/composables/useSaveValidation.d.ts +6 -0
- package/dist/src/composables/useSaveValidationRollout.d.ts +4 -0
- package/dist/src/composables/validators/useCouponBlockValidator.d.ts +3 -0
- package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +10 -0
- package/dist/src/config/migrator/index.d.ts +2 -1
- package/dist/src/config/migrator/recommendationPartnerMigrator.d.ts +19 -0
- package/dist/src/enums/extensions/recommendationBlock.d.ts +1 -1
- package/dist/src/enums/save-validation.d.ts +27 -0
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +0 -6
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/utils/partnerScope.d.ts +13 -7
- package/dist/src/services/settingsApi.d.ts +6 -0
- package/dist/src/stores/config.d.ts +32 -0
- package/dist/src/stores/save-validation.d.ts +22 -0
- package/dist/src/stores/setup-settings.d.ts +4 -0
- package/dist/src/utils/templatePreparation.d.ts +30 -0
- package/dist/stores/config.js +84 -67
- package/dist/stores/save-validation.js +30 -0
- package/dist/stores/setup-settings.js +10 -0
- package/dist/utils/templatePreparation.js +39 -36
- package/package.json +1 -1
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { migrateCheckbox as
|
|
2
|
-
import { migrateCouponBlock as
|
|
3
|
-
import { migrateItemsBlock as
|
|
4
|
-
import { migrateProductNameLink as
|
|
5
|
-
import { migrateRadioButton as
|
|
6
|
-
import { migrateRecommendation as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { migrateCheckbox as i } from "./checkboxMigrator.js";
|
|
2
|
+
import { migrateCouponBlock as e } from "./couponBlockMigrator.js";
|
|
3
|
+
import { migrateItemsBlock as a } from "./itemsBlockMigrator.js";
|
|
4
|
+
import { migrateProductNameLink as n } from "./productNameLinkMigrator.js";
|
|
5
|
+
import { migrateRadioButton as c } from "./radioButtonMigrator.js";
|
|
6
|
+
import { migrateRecommendation as g } from "./recommendationMigrator.js";
|
|
7
|
+
import { migrateRecommendationPartnerScope as f } from "./recommendationPartnerMigrator.js";
|
|
8
|
+
import { migrateRecommendationTitle as p } from "./recommendationTitleMigrator.js";
|
|
9
|
+
import { migrateSocialIcons as d } from "./socialIconMigrator.js";
|
|
10
|
+
import { migrateUnsubscribe as l } from "./unsubscribeMigrator.js";
|
|
11
|
+
const h = async (r, t = {}, o) => {
|
|
12
|
+
let m = r;
|
|
13
|
+
return m = i(m), m = c(m), m = await l(m), m = e(m), m = g(m, t), o && (m = f(m, o)), m = p(m), m = a(m), m = n(m), m = d(m), m;
|
|
13
14
|
};
|
|
14
15
|
export {
|
|
15
|
-
|
|
16
|
+
h as migrate
|
|
16
17
|
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { RECOMMENDATION_ID_ATTR as f, SELECTOR_ATTRIBUTE_ROW as _, ATTR_DATA_ATTRIBUTE_TYPE as a, ATTR_CUSTOM_PREFIX as g, ATTR_DATA_CARD_COMPOSITION as O, ATTR_DATA_CUSTOM_ATTRIBUTES as R } from "../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
2
|
+
import { carriesForeignPartnerConfig as m, canJudgeUnstampedBlock as E, withoutCustomAttributes as d } from "../../extensions/Blocks/Recommendation/utils/partnerScope.js";
|
|
3
|
+
const S = ".recommendation-block-v2[esd-ext-config]", c = "esd-ext-config";
|
|
4
|
+
function C(t) {
|
|
5
|
+
const e = t.getAttribute(c);
|
|
6
|
+
if (!e)
|
|
7
|
+
return null;
|
|
8
|
+
try {
|
|
9
|
+
const r = JSON.parse(e);
|
|
10
|
+
return r && typeof r == "object" && !Array.isArray(r) ? r : null;
|
|
11
|
+
} catch {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function I(t, e, r) {
|
|
16
|
+
const o = d(e.composition ?? []);
|
|
17
|
+
t.querySelectorAll(_).forEach((i) => {
|
|
18
|
+
var s;
|
|
19
|
+
(s = i.getAttribute(a)) != null && s.startsWith(g) && i.remove();
|
|
20
|
+
}), t.setAttribute(O, o.join(",")), t.setAttribute(R, "[]"), t.setAttribute(c, JSON.stringify({
|
|
21
|
+
...e,
|
|
22
|
+
strategyId: "",
|
|
23
|
+
strategy: "",
|
|
24
|
+
filters: [],
|
|
25
|
+
productIds: [],
|
|
26
|
+
composition: o,
|
|
27
|
+
partnerName: r
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
function p(t, { partnerName: e, campaignUrls: r, rrsEnabled: o }) {
|
|
31
|
+
if (!e)
|
|
32
|
+
return t;
|
|
33
|
+
const i = new DOMParser().parseFromString(t, "text/html"), s = Array.from(i.querySelectorAll(S));
|
|
34
|
+
if (s.length === 0)
|
|
35
|
+
return t;
|
|
36
|
+
let T = 0;
|
|
37
|
+
return s.forEach((u) => {
|
|
38
|
+
const n = C(u), A = Number(u.getAttribute(f));
|
|
39
|
+
if (!(!n || !Number.isFinite(A))) {
|
|
40
|
+
if (m({ config: n, blockId: A, partnerName: e, campaignUrls: r, rrsEnabled: o })) {
|
|
41
|
+
I(u, n, e), T += 1;
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
n.partnerName || !E({ config: n, campaignUrls: r, rrsEnabled: o }) || (u.setAttribute(c, JSON.stringify({ ...n, partnerName: e })), T += 1);
|
|
45
|
+
}
|
|
46
|
+
}), T > 0 ? i.documentElement.outerHTML : t;
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
p as migrateRecommendationPartnerScope
|
|
50
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useTranslations as s } from "../../composables/useTranslations.js";
|
|
2
|
-
const
|
|
2
|
+
const t = {
|
|
3
3
|
RECOMMENDATION_API_URL: "https://recommendationv2.api.useinsider.com",
|
|
4
4
|
// Relative path → same-origin as the embedding inone dashboard.
|
|
5
5
|
PRODUCT_ATTRIBUTES_PATH: "/product-attributes/get-attributes",
|
|
@@ -9,17 +9,17 @@ const a = {
|
|
|
9
9
|
MIGRATE_STRATEGIES_PATH: "/newsletter/recommendations/migrate-strategies",
|
|
10
10
|
// The template route narrows the recommendations resource before the action: the id
|
|
11
11
|
// travels in the body, not the path.
|
|
12
|
-
TEMPLATE_MIGRATE_STRATEGIES_PATH: "/newsletter/recommendations/template/migrate-strategies"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
},
|
|
17
|
-
const { RECOMMENDATION_STRATEGIES_PANEL_PATH: n } =
|
|
18
|
-
return `${n}/${e}/edit
|
|
19
|
-
}, m = {
|
|
20
|
-
campaign: a.MIGRATE_STRATEGIES_PATH,
|
|
21
|
-
template: a.TEMPLATE_MIGRATE_STRATEGIES_PATH
|
|
12
|
+
TEMPLATE_MIGRATE_STRATEGIES_PATH: "/newsletter/recommendations/template/migrate-strategies"
|
|
13
|
+
}, d = () => {
|
|
14
|
+
const { RECOMMENDATION_STRATEGIES_PANEL_PATH: e } = t;
|
|
15
|
+
return `${e}/create`;
|
|
16
|
+
}, m = (e) => {
|
|
17
|
+
const { RECOMMENDATION_STRATEGIES_PANEL_PATH: n } = t;
|
|
18
|
+
return `${n}/${e}/edit`;
|
|
22
19
|
}, T = {
|
|
20
|
+
campaign: t.MIGRATE_STRATEGIES_PATH,
|
|
21
|
+
template: t.TEMPLATE_MIGRATE_STRATEGIES_PATH
|
|
22
|
+
}, p = {
|
|
23
23
|
CLIENT_ID: "clientId"
|
|
24
24
|
}, E = () => {
|
|
25
25
|
const e = s();
|
|
@@ -85,21 +85,21 @@ const a = {
|
|
|
85
85
|
path: "top-sellers"
|
|
86
86
|
}
|
|
87
87
|
];
|
|
88
|
-
},
|
|
88
|
+
}, A = ["discount", "omnibus_price", "omnibus_discount", "price", "original_price"], v = [
|
|
89
89
|
{ text: "before the amount", value: "0" },
|
|
90
90
|
{ text: "after the amount", value: "1" }
|
|
91
|
-
],
|
|
91
|
+
], _ = [
|
|
92
92
|
{ text: "dot(.)", value: "." },
|
|
93
93
|
{ text: "comma(,)", value: "," },
|
|
94
94
|
{ text: "space( )", value: " " }
|
|
95
|
-
],
|
|
95
|
+
], h = [
|
|
96
96
|
{ text: "0", value: "0" },
|
|
97
97
|
{ text: "1", value: "1" },
|
|
98
98
|
{ text: "2", value: "2" },
|
|
99
99
|
{ text: "3", value: "3" },
|
|
100
100
|
{ text: "4", value: "4" },
|
|
101
101
|
{ text: "5", value: "5" }
|
|
102
|
-
], r = "||",
|
|
102
|
+
], r = "||", a = [
|
|
103
103
|
{ text: "is exactly", value: "=" },
|
|
104
104
|
{ text: "contains", value: "~" },
|
|
105
105
|
{ text: "does not contain", value: "!~" },
|
|
@@ -121,9 +121,9 @@ const a = {
|
|
|
121
121
|
], c = [
|
|
122
122
|
{ text: "true", value: "==" },
|
|
123
123
|
{ text: "false", value: "!=" }
|
|
124
|
-
],
|
|
124
|
+
], x = (e) => {
|
|
125
125
|
if (!e)
|
|
126
|
-
return
|
|
126
|
+
return a;
|
|
127
127
|
switch (e) {
|
|
128
128
|
case "Boolean":
|
|
129
129
|
return c;
|
|
@@ -132,28 +132,29 @@ const a = {
|
|
|
132
132
|
case "Number":
|
|
133
133
|
return i;
|
|
134
134
|
case "String":
|
|
135
|
-
return
|
|
135
|
+
return a;
|
|
136
136
|
case "Strings":
|
|
137
137
|
return o;
|
|
138
138
|
default:
|
|
139
|
-
return
|
|
139
|
+
return a;
|
|
140
140
|
}
|
|
141
141
|
};
|
|
142
142
|
export {
|
|
143
|
-
|
|
143
|
+
T as MIGRATION_PATHS,
|
|
144
144
|
r as OP_ANY_OF,
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
145
|
+
A as PriceAttributes,
|
|
146
|
+
p as QUERY_PARAMS,
|
|
147
|
+
t as URLS,
|
|
148
|
+
h as currencyDecimalCounts,
|
|
149
|
+
v as currencyLocationMaps,
|
|
150
|
+
_ as currencyOperators,
|
|
151
|
+
x as getOperatorOptions,
|
|
152
152
|
E as getRecommendationFeedSourceMaps,
|
|
153
153
|
o as operatorOptionsForArrayOfStrings,
|
|
154
154
|
c as operatorOptionsForBooleans,
|
|
155
155
|
u as operatorOptionsForDates,
|
|
156
156
|
i as operatorOptionsForNumbers,
|
|
157
|
-
|
|
158
|
-
d as
|
|
157
|
+
a as operatorOptionsForStrings,
|
|
158
|
+
d as strategyCreatePath,
|
|
159
|
+
m as strategyEditPath
|
|
159
160
|
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var n = /* @__PURE__ */ ((s) => (s.CouponTagModified = "coupon-tag-modified", s.DuplicateUnsubBlock = "duplicate-unsub-block", s.UnsubBlockMissingTemplate = "unsub-block-missing-template", s.LiquidSyntax = "liquid-syntax", s.InvalidLinks = "invalid-links", s.LinkCheckInProgress = "link-check-in-progress", s.CustomFieldScript = "custom-field-script", s.EmptyHtml = "empty-html", s.MismatchedBraces = "mismatched-braces", s.InvalidDynamicTag = "invalid-dynamic-tag", s.InvalidCustomField = "invalid-custom-field", s.ConditionsSyntax = "conditions-syntax", s.WrongEqualityOperator = "wrong-equality-operator", s.MissingIfEndif = "missing-if-endif", s.ConditionTagSpacing = "condition-tag-spacing", s.BracesInsideIfTag = "braces-inside-if-tag", s.RecommendationRequiredFields = "recommendation-required-fields", s.RecommendationFilters = "recommendation-filters", s.InvalidImageType = "invalid-image-type", s.CheckboxUnsubGroup = "checkbox-unsub-group", s.RadioButtonUnsubGroup = "radio-button-unsub-group", s))(n || {});
|
|
2
|
+
export {
|
|
3
|
+
n as SaveValidationRule
|
|
4
|
+
};
|
|
@@ -1,41 +1,39 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { useConfig as
|
|
5
|
-
import { BlockId as
|
|
6
|
-
import { getMigrationBannerHtml as
|
|
7
|
-
import { Block as
|
|
8
|
-
import { CURRENT_CONFIG_VERSION as
|
|
9
|
-
import { RECOMMENDATION_ID_ATTR as
|
|
10
|
-
import { regenerateMobileProductRows as
|
|
11
|
-
import { ensureMobileCssRulesExist as
|
|
1
|
+
var y = Object.defineProperty;
|
|
2
|
+
var A = (l, c, t) => c in l ? y(l, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[c] = t;
|
|
3
|
+
var h = (l, c, t) => A(l, typeof c != "symbol" ? c + "" : c, t);
|
|
4
|
+
import { useConfig as d } from "../../../composables/useConfig.js";
|
|
5
|
+
import { BlockId as D } from "../../../enums/block.js";
|
|
6
|
+
import { getMigrationBannerHtml as C } from "../../../utils/migrationBannerHtml.js";
|
|
7
|
+
import { Block as E, BlockCompositionType as S, ModificationDescription as p } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
8
|
+
import { CURRENT_CONFIG_VERSION as N, PRE_RRS_CONFIG_VERSION as O } from "./constants/defaultConfig.js";
|
|
9
|
+
import { RECOMMENDATION_ID_ATTR as m } from "./constants/selectors.js";
|
|
10
|
+
import { regenerateMobileProductRows as M } from "./controls/main/utils.js";
|
|
11
|
+
import { ensureMobileCssRulesExist as I, setMobileLayoutOptOut as R, hasMobileLayoutOptOut as w } from "./controls/mobileLayout/cssRules.js";
|
|
12
12
|
import { RecommendationConfigService as s } from "./services/configService.js";
|
|
13
|
-
import { useRecommendationExtensionStore as
|
|
14
|
-
import { getDefaultTemplate as
|
|
15
|
-
import { useRecommendationBlockWarning as
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
let E = !1;
|
|
20
|
-
class at extends O {
|
|
13
|
+
import { useRecommendationExtensionStore as g } from "./store/recommendation.js";
|
|
14
|
+
import { getDefaultTemplate as T } from "./templates/grid/template.js";
|
|
15
|
+
import { useRecommendationBlockWarning as v } from "./useRecommendationBlockWarning.js";
|
|
16
|
+
const k = D.Recommendation, u = "recommendation-block-v2", B = "hide-price";
|
|
17
|
+
let b = !1;
|
|
18
|
+
class j extends E {
|
|
21
19
|
constructor() {
|
|
22
20
|
super();
|
|
23
21
|
/**
|
|
24
22
|
* Stores the ID generated in getTemplate() so onCreated() can reuse it.
|
|
25
23
|
* This avoids generating a new (different) ID in onCreated().
|
|
26
24
|
*/
|
|
27
|
-
|
|
25
|
+
h(this, "_pendingBlockId", null);
|
|
28
26
|
/** Ids already reset under their new name, so the deferred pass skips their stale snapshot. */
|
|
29
|
-
|
|
27
|
+
h(this, "_resetSourceIds", /* @__PURE__ */ new Set());
|
|
30
28
|
}
|
|
31
29
|
getId() {
|
|
32
|
-
return
|
|
30
|
+
return k;
|
|
33
31
|
}
|
|
34
32
|
getIcon() {
|
|
35
33
|
return "recommendation-icon";
|
|
36
34
|
}
|
|
37
35
|
getBlockCompositionType() {
|
|
38
|
-
return
|
|
36
|
+
return S.CONTAINER;
|
|
39
37
|
}
|
|
40
38
|
getName() {
|
|
41
39
|
return this.api.translate("Recommendation Block");
|
|
@@ -46,8 +44,8 @@ class at extends O {
|
|
|
46
44
|
);
|
|
47
45
|
}
|
|
48
46
|
getSettingsPanelTitleHtml() {
|
|
49
|
-
return
|
|
50
|
-
|
|
47
|
+
return C(
|
|
48
|
+
k,
|
|
51
49
|
this.api.translate("Recommendation Block"),
|
|
52
50
|
this.api.translate("This block is switched from the Old Version to the New Version. We recommend you check the Recommendation block and test your message to ensure it works properly.")
|
|
53
51
|
);
|
|
@@ -70,7 +68,7 @@ class at extends O {
|
|
|
70
68
|
*/
|
|
71
69
|
getTemplate() {
|
|
72
70
|
const t = this._generateNextId();
|
|
73
|
-
return this._pendingBlockId = t,
|
|
71
|
+
return this._pendingBlockId = t, T(t);
|
|
74
72
|
}
|
|
75
73
|
/**
|
|
76
74
|
* Called when a new block is dropped into the template
|
|
@@ -93,28 +91,28 @@ class at extends O {
|
|
|
93
91
|
}
|
|
94
92
|
const i = this._pendingBlockId ?? this._generateNextId();
|
|
95
93
|
this._pendingBlockId = null, this._assignRecommendationId(t, i);
|
|
96
|
-
const n =
|
|
94
|
+
const n = d().isFeatureEnabled("reusableRecommendationStrategy"), o = n && !s.hasConfig(t), { config: r, wasFreshDrop: a } = s.initializeConfig(
|
|
97
95
|
this.api,
|
|
98
96
|
t,
|
|
99
97
|
{
|
|
100
98
|
recommendationId: i,
|
|
101
|
-
configVersion: n ?
|
|
102
|
-
...o ? { partnerName:
|
|
99
|
+
configVersion: n ? N : O,
|
|
100
|
+
...o ? { partnerName: d().partnerName.value } : {},
|
|
103
101
|
// An RRS block picks a strategy, not an algorithm, and its algorithm control is
|
|
104
102
|
// hidden. Keeping the `mostPopular` default would bake a most-popular feed URL
|
|
105
103
|
// at save for a block the user never configured.
|
|
106
104
|
...o ? { strategy: "" } : {}
|
|
107
105
|
}
|
|
108
|
-
),
|
|
109
|
-
if (
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
|
|
106
|
+
), f = g();
|
|
107
|
+
if (f.setCurrentBlock(i), this._stampHidePrice(t, r.priceHideIfSameAsDiscounted), a) {
|
|
108
|
+
I(this.api);
|
|
109
|
+
const _ = this._getBlockElement(t);
|
|
110
|
+
_ && (R(this.api, _, !0), M({
|
|
113
111
|
currentNode: t,
|
|
114
112
|
documentModifier: this.api.getDocumentModifier()
|
|
115
113
|
}));
|
|
116
114
|
}
|
|
117
|
-
|
|
115
|
+
f.patchCurrentBlockConfig({ language: r.language }, { triggerRefetch: !1 }), this._warnIfMultipleBlocks();
|
|
118
116
|
}
|
|
119
117
|
/**
|
|
120
118
|
* Called when the document changes or template is loaded
|
|
@@ -134,13 +132,13 @@ class at extends O {
|
|
|
134
132
|
"Assign recommendation ID to legacy block"
|
|
135
133
|
);
|
|
136
134
|
}
|
|
137
|
-
this._healLingeringDuplicate(t), s.needsMigration(t) && this._migrateFromLegacy(t), this._healHidePriceAttr(t)
|
|
135
|
+
this._healLingeringDuplicate(t), s.needsMigration(t) && this._migrateFromLegacy(t), this._healHidePriceAttr(t);
|
|
138
136
|
try {
|
|
139
|
-
|
|
137
|
+
b || (I(this.api), b = !0);
|
|
140
138
|
const e = s.getConfig(t), i = this._getBlockElement(t);
|
|
141
139
|
if (i) {
|
|
142
140
|
const n = !e.mobileLayoutEnabled;
|
|
143
|
-
|
|
141
|
+
w(i) !== n && R(this.api, i, n);
|
|
144
142
|
}
|
|
145
143
|
} catch {
|
|
146
144
|
}
|
|
@@ -154,7 +152,7 @@ class at extends O {
|
|
|
154
152
|
*/
|
|
155
153
|
onDelete(t) {
|
|
156
154
|
const e = this._getRecommendationId(t);
|
|
157
|
-
e &&
|
|
155
|
+
e && g().removeBlockState(e);
|
|
158
156
|
}
|
|
159
157
|
/**
|
|
160
158
|
* Warns (dark advisory toaster) when the design holds more than one live
|
|
@@ -170,7 +168,7 @@ class at extends O {
|
|
|
170
168
|
*/
|
|
171
169
|
_warnIfMultipleBlocks() {
|
|
172
170
|
try {
|
|
173
|
-
|
|
171
|
+
v().warnIfMultipleBlocks(this.api.getDocumentRootHtmlNode());
|
|
174
172
|
} catch {
|
|
175
173
|
}
|
|
176
174
|
}
|
|
@@ -182,9 +180,9 @@ class at extends O {
|
|
|
182
180
|
let t = 0;
|
|
183
181
|
try {
|
|
184
182
|
const e = this.api.getDocumentRoot();
|
|
185
|
-
e && "querySelectorAll" in e && e.querySelectorAll(`.${
|
|
183
|
+
e && "querySelectorAll" in e && e.querySelectorAll(`.${u}`).forEach((n) => {
|
|
186
184
|
if ("getAttribute" in n) {
|
|
187
|
-
const o = n.getAttribute(
|
|
185
|
+
const o = n.getAttribute(m), r = o ? parseInt(o) : 0;
|
|
188
186
|
r > t && (t = r);
|
|
189
187
|
}
|
|
190
188
|
});
|
|
@@ -200,9 +198,9 @@ class at extends O {
|
|
|
200
198
|
* the renamed one depending on where the module was dropped (SD-149916).
|
|
201
199
|
*/
|
|
202
200
|
_scheduleArrivalReset(t) {
|
|
203
|
-
|
|
201
|
+
d().isFeatureEnabled("reusableRecommendationStrategy") && setTimeout(() => {
|
|
204
202
|
const e = this._getRecommendationId(t);
|
|
205
|
-
e !== null && e > 0 && !this._resetSourceIds.delete(e) &&
|
|
203
|
+
e !== null && e > 0 && !this._resetSourceIds.delete(e) && g().resetArrivedBlock(e);
|
|
206
204
|
}, 0);
|
|
207
205
|
}
|
|
208
206
|
/**
|
|
@@ -225,7 +223,7 @@ class at extends O {
|
|
|
225
223
|
if (!i || !("querySelectorAll" in i))
|
|
226
224
|
return;
|
|
227
225
|
const n = i.querySelectorAll(
|
|
228
|
-
`.${
|
|
226
|
+
`.${u}[${m}="${e}"]`
|
|
229
227
|
);
|
|
230
228
|
if (n.length <= 1)
|
|
231
229
|
return;
|
|
@@ -250,7 +248,7 @@ class at extends O {
|
|
|
250
248
|
const e = this.api.getDocumentRoot();
|
|
251
249
|
if (e && "querySelectorAll" in e)
|
|
252
250
|
return e.querySelectorAll(
|
|
253
|
-
`.${
|
|
251
|
+
`.${u}[${m}="${t}"]`
|
|
254
252
|
).length > 1;
|
|
255
253
|
} catch {
|
|
256
254
|
}
|
|
@@ -258,8 +256,8 @@ class at extends O {
|
|
|
258
256
|
}
|
|
259
257
|
/** Assigns a fresh id to a duplicated block and syncs DOM, node config and store. */
|
|
260
258
|
_handleDuplicate(t, e) {
|
|
261
|
-
const i = this._reassignDuplicateId(t, e), n =
|
|
262
|
-
n.cloneBlockState(e, i), n.setCurrentBlock(i),
|
|
259
|
+
const i = this._reassignDuplicateId(t, e), n = g();
|
|
260
|
+
n.cloneBlockState(e, i), n.setCurrentBlock(i), d().isFeatureEnabled("reusableRecommendationStrategy") && (this._resetSourceIds.add(e), n.resetArrivedBlock(i)), this._warnIfMultipleBlocks();
|
|
263
261
|
}
|
|
264
262
|
/**
|
|
265
263
|
* Core id-reassignment for a duplicated block: rewrites the DOM
|
|
@@ -292,7 +290,7 @@ class at extends O {
|
|
|
292
290
|
if (!("getAttribute" in t))
|
|
293
291
|
return;
|
|
294
292
|
const n = `ins-recommendation-v3-block-${e}`, o = `ins-recommendation-v3-block-${i}`, r = this.api.getDocumentModifier();
|
|
295
|
-
r.modifyHtml(t).removeClass(n).setClass(o), r.apply(new
|
|
293
|
+
r.modifyHtml(t).removeClass(n).setClass(o), r.apply(new p(
|
|
296
294
|
`Reassign recommendation instance class ${n} -> ${o}`
|
|
297
295
|
));
|
|
298
296
|
}
|
|
@@ -307,7 +305,7 @@ class at extends O {
|
|
|
307
305
|
if (!i)
|
|
308
306
|
return;
|
|
309
307
|
const n = this.api.getDocumentModifier();
|
|
310
|
-
n.modifyHtml(i).setAttribute(
|
|
308
|
+
n.modifyHtml(i).setAttribute(m, e.toString()), n.apply(new p(`Assign recommendation ID ${e}`));
|
|
311
309
|
}
|
|
312
310
|
/**
|
|
313
311
|
* Stamps the `hide-price` attribute (read by email-service at send time) on
|
|
@@ -315,7 +313,7 @@ class at extends O {
|
|
|
315
313
|
*/
|
|
316
314
|
_stampHidePrice(t, e) {
|
|
317
315
|
const i = this._getBlockElement(t);
|
|
318
|
-
i && this.api.getDocumentModifier().modifyHtml(i).setAttribute(B, String(e)).apply(new
|
|
316
|
+
i && this.api.getDocumentModifier().modifyHtml(i).setAttribute(B, String(e)).apply(new p("Stamp hide-price"));
|
|
319
317
|
}
|
|
320
318
|
/**
|
|
321
319
|
* Stamps `hide-price` from config only when the block lacks the attribute —
|
|
@@ -328,38 +326,6 @@ class at extends O {
|
|
|
328
326
|
const { priceHideIfSameAsDiscounted: i } = s.getConfig(t);
|
|
329
327
|
this._stampHidePrice(t, i);
|
|
330
328
|
}
|
|
331
|
-
/**
|
|
332
|
-
* Empties a block copied in from another account: its strategy and attribute types
|
|
333
|
-
* are account-scoped and would not resolve here (SD-151945). Layout, locale and
|
|
334
|
-
* currency stay. The write stamps the current account, so the next pass is a no-op.
|
|
335
|
-
*/
|
|
336
|
-
_resetForeignPartnerConfig(t) {
|
|
337
|
-
var I, R;
|
|
338
|
-
const e = this._getRecommendationId(t), i = this._getBlockElement(t);
|
|
339
|
-
if (e === null || !i || !s.hasConfig(t))
|
|
340
|
-
return;
|
|
341
|
-
const { partnerName: n, template: o } = g(), r = s.getConfig(t);
|
|
342
|
-
if (!W({
|
|
343
|
-
config: r,
|
|
344
|
-
blockId: e,
|
|
345
|
-
partnerName: n.value,
|
|
346
|
-
campaignUrls: (I = o.value) == null ? void 0 : I.recommendationCampaignUrls,
|
|
347
|
-
loadedIds: K(((R = o.value) == null ? void 0 : R.html) ?? "")
|
|
348
|
-
}))
|
|
349
|
-
return;
|
|
350
|
-
const u = z(r.composition), l = this.api.getDocumentModifier();
|
|
351
|
-
i.querySelectorAll(F).forEach((k) => {
|
|
352
|
-
var A;
|
|
353
|
-
(A = V(k)) != null && A.startsWith(H) && l.modifyHtml(k).delete();
|
|
354
|
-
}), l.modifyHtml(i).setAttribute(P, u.join(",")).setAttribute(x, "[]"), s.stageConfig(l, t, {
|
|
355
|
-
strategyId: "",
|
|
356
|
-
strategy: "",
|
|
357
|
-
filters: [],
|
|
358
|
-
productIds: [],
|
|
359
|
-
composition: u,
|
|
360
|
-
partnerName: n.value
|
|
361
|
-
}), l.apply(new h("Reset recommendation block copied from another account")), p().resetPartnerScopedConfig(e);
|
|
362
|
-
}
|
|
363
329
|
/**
|
|
364
330
|
* Gets the recommendation-id from a block node
|
|
365
331
|
*/
|
|
@@ -367,7 +333,7 @@ class at extends O {
|
|
|
367
333
|
const e = this._getBlockElement(t);
|
|
368
334
|
if (!e || !("getAttribute" in e))
|
|
369
335
|
return null;
|
|
370
|
-
const i = e.getAttribute(
|
|
336
|
+
const i = e.getAttribute(m);
|
|
371
337
|
if (!i)
|
|
372
338
|
return null;
|
|
373
339
|
const n = parseInt(i);
|
|
@@ -379,10 +345,10 @@ class at extends O {
|
|
|
379
345
|
_getBlockElement(t) {
|
|
380
346
|
if ("getAttribute" in t) {
|
|
381
347
|
const e = t.getAttribute("class");
|
|
382
|
-
if (e && e.includes(
|
|
348
|
+
if (e && e.includes(u))
|
|
383
349
|
return t;
|
|
384
350
|
}
|
|
385
|
-
return "querySelector" in t ? t.querySelector(`.${
|
|
351
|
+
return "querySelector" in t ? t.querySelector(`.${u}`) ?? null : null;
|
|
386
352
|
}
|
|
387
353
|
/**
|
|
388
354
|
* Migrate configuration from legacy format
|
|
@@ -392,6 +358,6 @@ class at extends O {
|
|
|
392
358
|
}
|
|
393
359
|
}
|
|
394
360
|
export {
|
|
395
|
-
|
|
396
|
-
|
|
361
|
+
k as BLOCK_ID,
|
|
362
|
+
j as RecommendationBlock
|
|
397
363
|
};
|