@useinsider/guido 3.18.1-beta.e489d08 → 3.18.1-beta.e609a33
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/Guido.vue.js +3 -3
- package/dist/components/Guido.vue2.js +30 -30
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +11 -13
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +53 -65
- package/dist/components/organisms/onboarding/OnboardingWrapper.vue2.js +18 -20
- package/dist/components/organisms/save-as-template/SaveAsTemplateDrawer.vue2.js +34 -34
- package/dist/composables/useCustomInterfaceAppearance.js +41 -46
- package/dist/composables/useHtmlValidator.js +79 -84
- package/dist/composables/useHttp.js +24 -22
- package/dist/composables/useRecommendation.js +18 -21
- package/dist/composables/useStripo.js +7 -7
- package/dist/enums/extensions/recommendationBlock.js +31 -38
- package/dist/extensions/Blocks/Recommendation/block.js +39 -43
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +57 -62
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +52 -80
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +73 -150
- package/dist/extensions/Blocks/Recommendation/validation/requiredFields.js +12 -21
- package/dist/guido.css +1 -1
- package/dist/services/templateLibraryApi.js +39 -37
- package/dist/src/enums/extensions/recommendationBlock.d.ts +0 -2
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +0 -2
- package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +0 -9
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +0 -61
- package/dist/src/extensions/Blocks/Recommendation/validation/requiredFields.d.ts +0 -4
- package/dist/src/stores/onboarding.d.ts +0 -377
- package/dist/static/styles/components/recommendation-strategy.css.js +4 -51
- package/dist/stores/onboarding.js +36 -41
- package/dist/utils/templatePreparation.js +50 -50
- package/package.json +1 -1
- package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.js +0 -21
- package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue2.js +0 -47
- package/dist/src/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.d.ts +0 -2
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
import { useTranslations as
|
|
2
|
-
const
|
|
1
|
+
import { useTranslations as r } from "../../composables/useTranslations.js";
|
|
2
|
+
const l = {
|
|
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",
|
|
6
6
|
RECOMMENDATION_STRATEGIES_PATH: "/api/recommendation-strategies",
|
|
7
|
-
RECOMMENDATION_STRATEGIES_PANEL_PATH: "/discovery/recommendation-strategies"
|
|
8
|
-
|
|
9
|
-
// without this flag can never be Email-suitable and would never reach the editor's list.
|
|
10
|
-
RECOMMENDATION_STRATEGY_CREATE_PATH: "/discovery/recommendation-strategies/create?isEmail=true"
|
|
11
|
-
}, d = (e) => {
|
|
12
|
-
const { RECOMMENDATION_STRATEGIES_PANEL_PATH: r } = o;
|
|
13
|
-
return `${r}/${e}/edit`;
|
|
14
|
-
}, m = {
|
|
7
|
+
RECOMMENDATION_STRATEGIES_PANEL_PATH: "/discovery/recommendation-strategies"
|
|
8
|
+
}, c = {
|
|
15
9
|
CLIENT_ID: "clientId"
|
|
16
|
-
},
|
|
17
|
-
const e =
|
|
10
|
+
}, d = () => {
|
|
11
|
+
const e = r();
|
|
18
12
|
return [
|
|
19
13
|
{
|
|
20
14
|
id: 11,
|
|
@@ -77,14 +71,14 @@ const o = {
|
|
|
77
71
|
path: "top-sellers"
|
|
78
72
|
}
|
|
79
73
|
];
|
|
80
|
-
},
|
|
74
|
+
}, m = ["discount", "omnibus_price", "omnibus_discount", "price", "original_price"], p = [
|
|
81
75
|
{ text: "before the amount", value: "0" },
|
|
82
76
|
{ text: "after the amount", value: "1" }
|
|
83
|
-
],
|
|
77
|
+
], v = [
|
|
84
78
|
{ text: "dot(.)", value: "." },
|
|
85
79
|
{ text: "comma(,)", value: "," },
|
|
86
80
|
{ text: "space( )", value: " " }
|
|
87
|
-
],
|
|
81
|
+
], h = [
|
|
88
82
|
{ text: "0", value: "0" },
|
|
89
83
|
{ text: "1", value: "1" },
|
|
90
84
|
{ text: "2", value: "2" },
|
|
@@ -96,55 +90,54 @@ const o = {
|
|
|
96
90
|
{ text: "contains", value: "~" },
|
|
97
91
|
{ text: "does not contain", value: "!~" },
|
|
98
92
|
{ text: "any of", value: a }
|
|
99
|
-
],
|
|
93
|
+
], n = [
|
|
100
94
|
{ text: "is exactly", value: "=" },
|
|
101
95
|
{ text: "is not exactly", value: "!==" },
|
|
102
96
|
{ text: "contains", value: "~" },
|
|
103
97
|
{ text: "does not contain", value: "!~" },
|
|
104
98
|
{ text: "any of", value: a }
|
|
105
|
-
],
|
|
99
|
+
], o = [
|
|
106
100
|
{ text: "is equal to", value: "=" },
|
|
107
101
|
{ text: "is greater than", value: ">" },
|
|
108
102
|
{ text: "is less than", value: "<" }
|
|
109
|
-
],
|
|
103
|
+
], s = [
|
|
110
104
|
{ text: "is equal to", value: "=" },
|
|
111
105
|
{ text: "after", value: ">" },
|
|
112
106
|
{ text: "before", value: "<" }
|
|
113
|
-
],
|
|
107
|
+
], i = [
|
|
114
108
|
{ text: "true", value: "==" },
|
|
115
109
|
{ text: "false", value: "!=" }
|
|
116
|
-
],
|
|
110
|
+
], x = (e) => {
|
|
117
111
|
if (!e)
|
|
118
112
|
return t;
|
|
119
113
|
switch (e) {
|
|
120
114
|
case "Boolean":
|
|
121
|
-
return
|
|
115
|
+
return i;
|
|
122
116
|
case "Date":
|
|
123
|
-
return
|
|
117
|
+
return s;
|
|
124
118
|
case "Number":
|
|
125
|
-
return
|
|
119
|
+
return o;
|
|
126
120
|
case "String":
|
|
127
121
|
return t;
|
|
128
122
|
case "Strings":
|
|
129
|
-
return
|
|
123
|
+
return n;
|
|
130
124
|
default:
|
|
131
125
|
return t;
|
|
132
126
|
}
|
|
133
127
|
};
|
|
134
128
|
export {
|
|
135
129
|
a as OP_ANY_OF,
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
t as operatorOptionsForStrings
|
|
149
|
-
d as strategyEditPath
|
|
130
|
+
m as PriceAttributes,
|
|
131
|
+
c as QUERY_PARAMS,
|
|
132
|
+
l as URLS,
|
|
133
|
+
h as currencyDecimalCounts,
|
|
134
|
+
p as currencyLocationMaps,
|
|
135
|
+
v as currencyOperators,
|
|
136
|
+
x as getOperatorOptions,
|
|
137
|
+
d as getRecommendationFeedSourceMaps,
|
|
138
|
+
n as operatorOptionsForArrayOfStrings,
|
|
139
|
+
i as operatorOptionsForBooleans,
|
|
140
|
+
s as operatorOptionsForDates,
|
|
141
|
+
o as operatorOptionsForNumbers,
|
|
142
|
+
t as operatorOptionsForStrings
|
|
150
143
|
};
|
|
@@ -1,37 +1,37 @@
|
|
|
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
|
|
1
|
+
var R = Object.defineProperty;
|
|
2
|
+
var B = (a, c, t) => c in a ? R(a, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[c] = t;
|
|
3
|
+
var p = (a, c, t) => B(a, typeof c != "symbol" ? c + "" : c, t);
|
|
4
|
+
import { useConfig as D } from "../../../composables/useConfig.js";
|
|
5
|
+
import { BlockId as y } from "../../../enums/block.js";
|
|
6
|
+
import { getMigrationBannerHtml as C } from "../../../utils/migrationBannerHtml.js";
|
|
7
|
+
import { Block as b, BlockCompositionType as A, ModificationDescription as g } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
8
|
+
import { CURRENT_CONFIG_VERSION as E, PRE_RRS_CONFIG_VERSION as S } from "./constants/defaultConfig.js";
|
|
9
9
|
import { RECOMMENDATION_ID_ATTR as m } from "./constants/selectors.js";
|
|
10
|
-
import { regenerateMobileProductRows as
|
|
11
|
-
import { ensureMobileCssRulesExist as
|
|
10
|
+
import { regenerateMobileProductRows as N } from "./controls/main/utils.js";
|
|
11
|
+
import { ensureMobileCssRulesExist as h, setMobileLayoutOptOut as f, hasMobileLayoutOptOut as O } from "./controls/mobileLayout/cssRules.js";
|
|
12
12
|
import { RecommendationConfigService as s } from "./services/configService.js";
|
|
13
13
|
import { useRecommendationExtensionStore as d } from "./store/recommendation.js";
|
|
14
|
-
import { getDefaultTemplate as
|
|
15
|
-
import { useRecommendationBlockWarning as
|
|
16
|
-
const
|
|
17
|
-
let
|
|
18
|
-
class
|
|
14
|
+
import { getDefaultTemplate as M } from "./templates/grid/template.js";
|
|
15
|
+
import { useRecommendationBlockWarning as w } from "./useRecommendationBlockWarning.js";
|
|
16
|
+
const _ = y.Recommendation, u = "recommendation-block-v2", I = "hide-price";
|
|
17
|
+
let k = !1;
|
|
18
|
+
class W extends b {
|
|
19
19
|
constructor() {
|
|
20
20
|
super();
|
|
21
21
|
/**
|
|
22
22
|
* Stores the ID generated in getTemplate() so onCreated() can reuse it.
|
|
23
23
|
* This avoids generating a new (different) ID in onCreated().
|
|
24
24
|
*/
|
|
25
|
-
|
|
25
|
+
p(this, "_pendingBlockId", null);
|
|
26
26
|
}
|
|
27
27
|
getId() {
|
|
28
|
-
return
|
|
28
|
+
return _;
|
|
29
29
|
}
|
|
30
30
|
getIcon() {
|
|
31
31
|
return "recommendation-icon";
|
|
32
32
|
}
|
|
33
33
|
getBlockCompositionType() {
|
|
34
|
-
return
|
|
34
|
+
return A.CONTAINER;
|
|
35
35
|
}
|
|
36
36
|
getName() {
|
|
37
37
|
return this.api.translate("Recommendation Block");
|
|
@@ -42,8 +42,8 @@ class j extends E {
|
|
|
42
42
|
);
|
|
43
43
|
}
|
|
44
44
|
getSettingsPanelTitleHtml() {
|
|
45
|
-
return
|
|
46
|
-
|
|
45
|
+
return C(
|
|
46
|
+
_,
|
|
47
47
|
this.api.translate("Recommendation Block"),
|
|
48
48
|
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.")
|
|
49
49
|
);
|
|
@@ -66,7 +66,7 @@ class j extends E {
|
|
|
66
66
|
*/
|
|
67
67
|
getTemplate() {
|
|
68
68
|
const t = this._generateNextId();
|
|
69
|
-
return this._pendingBlockId = t,
|
|
69
|
+
return this._pendingBlockId = t, M(t);
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
72
|
* Called when a new block is dropped into the template
|
|
@@ -89,27 +89,23 @@ class j extends E {
|
|
|
89
89
|
}
|
|
90
90
|
const i = this._pendingBlockId ?? this._generateNextId();
|
|
91
91
|
this._pendingBlockId = null, this._assignRecommendationId(t, i);
|
|
92
|
-
const
|
|
92
|
+
const { config: n, wasFreshDrop: o } = s.initializeConfig(
|
|
93
93
|
this.api,
|
|
94
94
|
t,
|
|
95
95
|
{
|
|
96
96
|
recommendationId: i,
|
|
97
|
-
configVersion:
|
|
98
|
-
// An RRS block picks a strategy, not an algorithm, and its algorithm control is
|
|
99
|
-
// hidden. Keeping the `mostPopular` default would bake a most-popular feed URL
|
|
100
|
-
// at save for a block the user never configured.
|
|
101
|
-
...o ? { strategy: "" } : {}
|
|
97
|
+
configVersion: D().isFeatureEnabled("reusableRecommendationStrategy") ? E : S
|
|
102
98
|
}
|
|
103
|
-
),
|
|
104
|
-
if (
|
|
105
|
-
|
|
106
|
-
const
|
|
107
|
-
|
|
99
|
+
), r = d();
|
|
100
|
+
if (r.setCurrentBlock(i), this._stampHidePrice(t, n.priceHideIfSameAsDiscounted), o) {
|
|
101
|
+
h(this.api);
|
|
102
|
+
const l = this._getBlockElement(t);
|
|
103
|
+
l && (f(this.api, l, !0), N({
|
|
108
104
|
currentNode: t,
|
|
109
105
|
documentModifier: this.api.getDocumentModifier()
|
|
110
106
|
}));
|
|
111
107
|
}
|
|
112
|
-
|
|
108
|
+
r.patchCurrentBlockConfig({ language: n.language }, { triggerRefetch: !1 }), this._warnIfMultipleBlocks();
|
|
113
109
|
}
|
|
114
110
|
/**
|
|
115
111
|
* Called when the document changes or template is loaded
|
|
@@ -131,11 +127,11 @@ class j extends E {
|
|
|
131
127
|
}
|
|
132
128
|
this._healLingeringDuplicate(t), s.needsMigration(t) && this._migrateFromLegacy(t), this._healHidePriceAttr(t);
|
|
133
129
|
try {
|
|
134
|
-
|
|
130
|
+
k || (h(this.api), k = !0);
|
|
135
131
|
const e = s.getConfig(t), i = this._getBlockElement(t);
|
|
136
132
|
if (i) {
|
|
137
133
|
const n = !e.mobileLayoutEnabled;
|
|
138
|
-
|
|
134
|
+
O(i) !== n && f(this.api, i, n);
|
|
139
135
|
}
|
|
140
136
|
} catch {
|
|
141
137
|
}
|
|
@@ -165,7 +161,7 @@ class j extends E {
|
|
|
165
161
|
*/
|
|
166
162
|
_warnIfMultipleBlocks() {
|
|
167
163
|
try {
|
|
168
|
-
|
|
164
|
+
w().warnIfMultipleBlocks(this.api.getDocumentRootHtmlNode());
|
|
169
165
|
} catch {
|
|
170
166
|
}
|
|
171
167
|
}
|
|
@@ -215,9 +211,9 @@ class j extends E {
|
|
|
215
211
|
if (!o)
|
|
216
212
|
return;
|
|
217
213
|
let r = -1;
|
|
218
|
-
for (let
|
|
219
|
-
if (n[
|
|
220
|
-
r =
|
|
214
|
+
for (let l = 0; l < n.length; l++)
|
|
215
|
+
if (n[l] === o) {
|
|
216
|
+
r = l;
|
|
221
217
|
break;
|
|
222
218
|
}
|
|
223
219
|
if (r <= 0)
|
|
@@ -297,7 +293,7 @@ class j extends E {
|
|
|
297
293
|
*/
|
|
298
294
|
_stampHidePrice(t, e) {
|
|
299
295
|
const i = this._getBlockElement(t);
|
|
300
|
-
i && this.api.getDocumentModifier().modifyHtml(i).setAttribute(
|
|
296
|
+
i && this.api.getDocumentModifier().modifyHtml(i).setAttribute(I, String(e)).apply(new g("Stamp hide-price"));
|
|
301
297
|
}
|
|
302
298
|
/**
|
|
303
299
|
* Stamps `hide-price` from config only when the block lacks the attribute —
|
|
@@ -305,7 +301,7 @@ class j extends E {
|
|
|
305
301
|
*/
|
|
306
302
|
_healHidePriceAttr(t) {
|
|
307
303
|
const e = this._getBlockElement(t);
|
|
308
|
-
if (!e || !("getAttribute" in e) || e.getAttribute(
|
|
304
|
+
if (!e || !("getAttribute" in e) || e.getAttribute(I) !== null)
|
|
309
305
|
return;
|
|
310
306
|
const { priceHideIfSameAsDiscounted: i } = s.getConfig(t);
|
|
311
307
|
this._stampHidePrice(t, i);
|
|
@@ -342,6 +338,6 @@ class j extends E {
|
|
|
342
338
|
}
|
|
343
339
|
}
|
|
344
340
|
export {
|
|
345
|
-
|
|
346
|
-
|
|
341
|
+
_ as BLOCK_ID,
|
|
342
|
+
W as RecommendationBlock
|
|
347
343
|
};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
var m = Object.defineProperty;
|
|
2
|
-
var C = (
|
|
3
|
-
var
|
|
2
|
+
var C = (h, l, t) => l in h ? m(h, l, { enumerable: !0, configurable: !0, writable: !0, value: t }) : h[l] = t;
|
|
3
|
+
var n = (h, l, t) => C(h, typeof l != "symbol" ? l + "" : l, t);
|
|
4
4
|
import { useConfig as p } from "../../../../../composables/useConfig.js";
|
|
5
5
|
import { ModificationDescription as y } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
6
6
|
import { CommonControl as N } from "../../../common-control.js";
|
|
7
7
|
import { CURRENT_CONFIG_VERSION as _, DEFAULT_NODE_CONFIG as a } from "../../constants/defaultConfig.js";
|
|
8
8
|
import { RECOMMENDATION_ID_ATTR as I } from "../../constants/selectors.js";
|
|
9
|
-
import { RecommendationConfigService as
|
|
9
|
+
import { RecommendationConfigService as c } from "../../services/configService.js";
|
|
10
10
|
import { useRecommendationExtensionStore as R } from "../../store/recommendation.js";
|
|
11
11
|
import { registerNodeConfigWriter as b } from "../../utils/nodeConfigWriter.js";
|
|
12
12
|
import { AlgorithmControl as T } from "./algorithm.js";
|
|
13
13
|
import { ALGORITHM_CONTROL_ID as ut } from "./algorithm.js";
|
|
14
14
|
import { CurrencyControl as P } from "./currency.js";
|
|
15
|
-
import { CURRENCY_CONTROL_ID as
|
|
15
|
+
import { CURRENCY_CONTROL_ID as ht } from "./currency.js";
|
|
16
16
|
import { FiltersControl as S } from "./filters.js";
|
|
17
|
-
import { FILTERS_CONTROL_ID as
|
|
17
|
+
import { FILTERS_CONTROL_ID as gt } from "./filters.js";
|
|
18
18
|
import { LayoutOrientationControl as O } from "./layoutOrientation.js";
|
|
19
19
|
import { LAYOUT_ORIENTATION_CONTROL_ID as Ct } from "./layoutOrientation.js";
|
|
20
20
|
import { LocaleControl as L } from "./locale.js";
|
|
@@ -31,36 +31,36 @@ import { StrategyControl as w } from "./strategy.js";
|
|
|
31
31
|
import { STRATEGY_CONTROL_ID as Lt } from "./strategy.js";
|
|
32
32
|
import { setCurrencyAttributes as A, getBlockElement as v, isPartnerManagedBlock as x, updateProductContentInPlace as B, regenerateProductRowsWithStyles as U } from "./utils.js";
|
|
33
33
|
import { adjustProductsToSize as kt, formatProductPrice as Dt, getCardComposition as Ft, getCurrentLayout as wt, getMainContainerTbody as At, regenerateMobileProductRows as vt, updatePricesInPlace as xt, updateSingleProductContent as Bt } from "./utils.js";
|
|
34
|
-
import { useDebounceFn as
|
|
35
|
-
const
|
|
34
|
+
import { useDebounceFn as f } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
35
|
+
const $ = "ui-elements-recommendation-block";
|
|
36
36
|
class at extends N {
|
|
37
37
|
constructor() {
|
|
38
38
|
super(...arguments);
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
n(this, "store", R());
|
|
40
|
+
n(this, "storeUnsubscription", () => {
|
|
41
41
|
});
|
|
42
42
|
// blockId -> fingerprint of the node config as it looked at the last sync.
|
|
43
|
-
|
|
43
|
+
n(this, "syncedConfigs", /* @__PURE__ */ new Map());
|
|
44
44
|
// A config change waiting to reach the node config. Deferred so it can ride the
|
|
45
45
|
// re-render's single apply() — one user action must cost one undo press.
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
n(this, "pendingNodeConfigWrite", null);
|
|
47
|
+
n(this, "pendingConfigFlushTimer", null);
|
|
48
48
|
// Sub-control instances for lifecycle management
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
49
|
+
n(this, "algorithmControl", null);
|
|
50
|
+
n(this, "localeControl", null);
|
|
51
|
+
n(this, "currencyControl", null);
|
|
52
|
+
n(this, "productCountControl", null);
|
|
53
|
+
n(this, "productLayoutControl", null);
|
|
54
|
+
n(this, "filtersControl", null);
|
|
55
|
+
n(this, "shuffleControl", null);
|
|
56
|
+
n(this, "pricePlacementControl", null);
|
|
57
|
+
n(this, "layoutOrientationControl", null);
|
|
58
|
+
n(this, "strategyControl", null);
|
|
59
|
+
n(this, "rrsEnabled", !1);
|
|
60
60
|
/**
|
|
61
61
|
* Debounced product fetch to prevent rapid API calls during config changes
|
|
62
62
|
*/
|
|
63
|
-
|
|
63
|
+
n(this, "_debouncedFetchProducts", f(async () => {
|
|
64
64
|
try {
|
|
65
65
|
await this.store.fetchRecommendationProducts();
|
|
66
66
|
} finally {
|
|
@@ -78,7 +78,7 @@ class at extends N {
|
|
|
78
78
|
* count. The store pads products to the configured size, so in-place only
|
|
79
79
|
* fails when the size actually changed.
|
|
80
80
|
*/
|
|
81
|
-
|
|
81
|
+
n(this, "_debouncedRegenerateWithProducts", f(() => {
|
|
82
82
|
const t = this.store.recommendationProducts;
|
|
83
83
|
if (!this.currentNode || !this.api)
|
|
84
84
|
return;
|
|
@@ -99,7 +99,7 @@ class at extends N {
|
|
|
99
99
|
}, 100));
|
|
100
100
|
}
|
|
101
101
|
getId() {
|
|
102
|
-
return
|
|
102
|
+
return $;
|
|
103
103
|
}
|
|
104
104
|
get _subControls() {
|
|
105
105
|
return [
|
|
@@ -142,14 +142,14 @@ class at extends N {
|
|
|
142
142
|
const e = (i = this.getContainer()) == null ? void 0 : i.querySelector(".recommendation-controls-container");
|
|
143
143
|
if (!e)
|
|
144
144
|
return;
|
|
145
|
-
const o = this._getRecommendationIdFromNode(t) === null ? null :
|
|
146
|
-
e.classList.toggle("strategy-block",
|
|
145
|
+
const o = this._getRecommendationIdFromNode(t) === null ? null : c.getConfig(t), r = this.rrsEnabled && !!o && (!!(o != null && o.strategyId) || ((o == null ? void 0 : o.configVersion) ?? 0) >= _);
|
|
146
|
+
e.classList.toggle("strategy-block", r);
|
|
147
147
|
}
|
|
148
148
|
async onRender() {
|
|
149
149
|
var o;
|
|
150
150
|
b(this.api);
|
|
151
151
|
const t = this._getRecommendationIdFromNode(this.currentNode), e = t ?? this.store.currentRecommendationId;
|
|
152
|
-
if (e !== null && this.store.setCurrentBlock(e), t !== null && this._syncNodeConfigIfChanged(t), this._listenStateUpdates(), this._showControlsForBlock(this.currentNode),
|
|
152
|
+
if (e !== null && this.store.setCurrentBlock(e), t !== null && this._syncNodeConfigIfChanged(t), this._listenStateUpdates(), this._showControlsForBlock(this.currentNode), e !== null && ((o = this.store.blockStates[e]) != null && o.isInitialized)) {
|
|
153
153
|
this._initializeSubControls();
|
|
154
154
|
return;
|
|
155
155
|
}
|
|
@@ -161,9 +161,9 @@ class at extends N {
|
|
|
161
161
|
const e = this._getRecommendationIdFromNode(t);
|
|
162
162
|
e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), e !== null && this._syncNodeConfigIfChanged(e), this._showControlsForBlock(t), e !== null && !((o = this.store.blockStates[e]) != null && o.isInitialized) && this._fetchBlockData(e).then(() => {
|
|
163
163
|
this._initializeSubControls();
|
|
164
|
-
}), this._subControls.forEach((
|
|
164
|
+
}), this._subControls.forEach((r) => {
|
|
165
165
|
var i;
|
|
166
|
-
|
|
166
|
+
r != null && r.api && (r.currentNode = t, (i = r.onTemplateNodeUpdated) == null || i.call(r, t));
|
|
167
167
|
});
|
|
168
168
|
}
|
|
169
169
|
onDestroy() {
|
|
@@ -203,23 +203,18 @@ class at extends N {
|
|
|
203
203
|
*/
|
|
204
204
|
_syncNodeConfigIfChanged(t) {
|
|
205
205
|
this.pendingNodeConfigWrite && this.pendingNodeConfigWrite.blockId !== t && this._flushPendingNodeConfig();
|
|
206
|
-
const e = JSON.stringify(
|
|
206
|
+
const e = JSON.stringify(c.getConfig(this.currentNode)), o = this.syncedConfigs.get(t);
|
|
207
207
|
this.syncedConfigs.set(t, e), o !== e && (this.pendingNodeConfigWrite || this._syncNodeConfigToStore());
|
|
208
208
|
}
|
|
209
|
-
/** Whether the deferred write would move the node's strategyId — see the caller (SD-149916). */
|
|
210
|
-
_isPendingStrategyIdChange() {
|
|
211
|
-
const t = this.pendingNodeConfigWrite;
|
|
212
|
-
return t ? l.getConfig(this.currentNode).strategyId !== t.updates.strategyId : !1;
|
|
213
|
-
}
|
|
214
209
|
_capturePendingNodeConfigWrite() {
|
|
215
210
|
const t = this.store.currentRecommendationId;
|
|
216
211
|
if (!this.currentNode || !this.api || t === null)
|
|
217
212
|
return;
|
|
218
|
-
const { filters: e, strategyId: o, size:
|
|
213
|
+
const { filters: e, strategyId: o, size: r } = this.store.recommendationConfigs;
|
|
219
214
|
this.pendingNodeConfigWrite = {
|
|
220
215
|
blockId: t,
|
|
221
216
|
node: this.currentNode,
|
|
222
|
-
updates: { filters: e, strategyId: o, size:
|
|
217
|
+
updates: { filters: e, strategyId: o, size: r }
|
|
223
218
|
};
|
|
224
219
|
}
|
|
225
220
|
/**
|
|
@@ -234,7 +229,7 @@ class at extends N {
|
|
|
234
229
|
*/
|
|
235
230
|
_stagePendingNodeConfig(t) {
|
|
236
231
|
const e = this.pendingNodeConfigWrite;
|
|
237
|
-
return !e || !this.currentNode ? !1 : (
|
|
232
|
+
return !e || !this.currentNode ? !1 : (c.stageConfig(t, this.currentNode, e.updates), !0);
|
|
238
233
|
}
|
|
239
234
|
/**
|
|
240
235
|
* Arms the guaranteed fallback write, once the product fetch has settled. The
|
|
@@ -258,12 +253,12 @@ class at extends N {
|
|
|
258
253
|
const t = this.pendingNodeConfigWrite;
|
|
259
254
|
if (this.pendingNodeConfigWrite = null, this._clearConfigFlush(), !t || !this.api)
|
|
260
255
|
return;
|
|
261
|
-
const e = t.blockId === this.store.currentRecommendationId && this.currentNode ? this.currentNode : t.node, o =
|
|
262
|
-
JSON.stringify(o.filters) === JSON.stringify(t.updates.filters) && o.strategyId === t.updates.strategyId && o.size === t.updates.size ||
|
|
256
|
+
const e = t.blockId === this.store.currentRecommendationId && this.currentNode ? this.currentNode : t.node, o = c.getConfig(e);
|
|
257
|
+
JSON.stringify(o.filters) === JSON.stringify(t.updates.filters) && o.strategyId === t.updates.strategyId && o.size === t.updates.size || c.updateConfig(this.api, e, t.updates, "Update recommendation filters");
|
|
263
258
|
}
|
|
264
259
|
_syncNodeConfigToStore() {
|
|
265
|
-
var
|
|
266
|
-
const t =
|
|
260
|
+
var r;
|
|
261
|
+
const t = c.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((r = this.store.blockStates[e]) == null ? void 0 : r.isInitialized);
|
|
267
262
|
this.store.patchCurrentBlockConfig({
|
|
268
263
|
strategy: t.strategy,
|
|
269
264
|
strategyId: t.strategyId,
|
|
@@ -305,8 +300,8 @@ class at extends N {
|
|
|
305
300
|
t !== null && this.store.markBlockInitialized(t), (await Promise.allSettled([
|
|
306
301
|
this.store.fetchRecommendationCreateData(),
|
|
307
302
|
this.store.fetchRecommendationFilters()
|
|
308
|
-
])).forEach((o,
|
|
309
|
-
o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][
|
|
303
|
+
])).forEach((o, r) => {
|
|
304
|
+
o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][r]} failed`, o.reason);
|
|
310
305
|
}), this._applySmartDefaults();
|
|
311
306
|
try {
|
|
312
307
|
await this.store.fetchRecommendationProducts();
|
|
@@ -327,8 +322,8 @@ class at extends N {
|
|
|
327
322
|
_applySmartDefaults() {
|
|
328
323
|
if (!this.currentNode || !this.api)
|
|
329
324
|
return;
|
|
330
|
-
const t =
|
|
331
|
-
let o = null,
|
|
325
|
+
const t = c.getConfig(this.currentNode), e = {};
|
|
326
|
+
let o = null, r = null, i = null;
|
|
332
327
|
if (t.currency.code === a.currency.code) {
|
|
333
328
|
const { currencyList: s } = this.store;
|
|
334
329
|
s.length > 0 && (s.some(
|
|
@@ -343,7 +338,7 @@ class at extends N {
|
|
|
343
338
|
const s = this.store.getActivePredictiveAlgorithms;
|
|
344
339
|
s.length > 0 && (s.some(
|
|
345
340
|
(d) => d.value === a.strategy
|
|
346
|
-
) || (
|
|
341
|
+
) || (r = s[0].value, e.strategy = r));
|
|
347
342
|
}
|
|
348
343
|
if (t.language === a.language) {
|
|
349
344
|
const s = this.store.getLanguages;
|
|
@@ -351,7 +346,7 @@ class at extends N {
|
|
|
351
346
|
(d) => d.value === a.language
|
|
352
347
|
) || (i = s[0].value, e.language = i));
|
|
353
348
|
}
|
|
354
|
-
!o && !
|
|
349
|
+
!o && !r && !i || (c.updateConfig(
|
|
355
350
|
this.api,
|
|
356
351
|
this.currentNode,
|
|
357
352
|
e,
|
|
@@ -372,7 +367,7 @@ class at extends N {
|
|
|
372
367
|
thousandSeparator: a.currency.thousandSeparator
|
|
373
368
|
}
|
|
374
369
|
} : {},
|
|
375
|
-
...
|
|
370
|
+
...r ? { strategy: r } : {},
|
|
376
371
|
...i ? { language: i } : {}
|
|
377
372
|
}, { triggerRefetch: !1 }));
|
|
378
373
|
}
|
|
@@ -386,8 +381,8 @@ class at extends N {
|
|
|
386
381
|
const o = e.getAttribute(I);
|
|
387
382
|
if (!o)
|
|
388
383
|
return null;
|
|
389
|
-
const
|
|
390
|
-
return Number.isNaN(
|
|
384
|
+
const r = parseInt(o);
|
|
385
|
+
return Number.isNaN(r) ? null : r;
|
|
391
386
|
}
|
|
392
387
|
/**
|
|
393
388
|
* Listen to store changes that require product refresh or regeneration.
|
|
@@ -404,27 +399,27 @@ class at extends N {
|
|
|
404
399
|
*/
|
|
405
400
|
_listenStateUpdates() {
|
|
406
401
|
const { store: t } = this;
|
|
407
|
-
let e = t.recommendationProducts, o = t.$state.configVersion,
|
|
402
|
+
let e = t.recommendationProducts, o = t.$state.configVersion, r = t.currentRecommendationId;
|
|
408
403
|
this.storeUnsubscription = t.$subscribe(() => {
|
|
409
404
|
const i = t.currentRecommendationId;
|
|
410
|
-
if (i !==
|
|
411
|
-
|
|
405
|
+
if (i !== r) {
|
|
406
|
+
r = i, e = t.recommendationProducts, o = t.$state.configVersion;
|
|
412
407
|
return;
|
|
413
408
|
}
|
|
414
409
|
const s = t.$state.configVersion;
|
|
415
|
-
s !== o && (o = s, this._capturePendingNodeConfigWrite(), this.
|
|
416
|
-
const u = t.recommendationProducts, d = u !== e,
|
|
417
|
-
d &&
|
|
410
|
+
s !== o && (o = s, this._capturePendingNodeConfigWrite(), this._debouncedFetchProducts());
|
|
411
|
+
const u = t.recommendationProducts, d = u !== e, g = Array.isArray(u) && u.length > 0;
|
|
412
|
+
d && g && (e = u, this._debouncedRegenerateWithProducts());
|
|
418
413
|
});
|
|
419
414
|
}
|
|
420
415
|
}
|
|
421
416
|
export {
|
|
422
417
|
ut as ALGORITHM_CONTROL_ID,
|
|
423
418
|
T as AlgorithmControl,
|
|
424
|
-
|
|
425
|
-
|
|
419
|
+
$ as CONTROL_BLOCK_ID,
|
|
420
|
+
ht as CURRENCY_CONTROL_ID,
|
|
426
421
|
P as CurrencyControl,
|
|
427
|
-
|
|
422
|
+
gt as FILTERS_CONTROL_ID,
|
|
428
423
|
S as FiltersControl,
|
|
429
424
|
Ct as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
430
425
|
yt as LOCALE_CONTROL_ID,
|