@useinsider/guido 3.19.0-beta.d04f200 → 3.19.0-beta.e110e88
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/@types/config/schemas.js +91 -104
- package/dist/components/Guido.vue.js +8 -8
- package/dist/components/Guido.vue2.js +74 -79
- package/dist/components/wrappers/WpModal.vue.js +1 -1
- package/dist/components/wrappers/WpModal.vue2.js +3 -4
- package/dist/composables/useHttp.js +54 -64
- package/dist/composables/useLegacyStrategyConversion.js +19 -23
- package/dist/composables/useStripo.js +20 -24
- package/dist/composables/useToaster.js +15 -17
- package/dist/composables/validators/useLiquidValidator.js +15 -15
- package/dist/config/migrator/index.js +13 -14
- package/dist/enums/extensions/recommendationBlock.js +29 -30
- package/dist/extensions/Blocks/Recommendation/block.js +22 -21
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +107 -97
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +49 -72
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +209 -203
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +91 -67
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +26 -21
- package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +55 -16
- package/dist/guido.css +1 -1
- package/dist/src/@types/config/schemas.d.ts +0 -16
- package/dist/src/components/wrappers/WpModal.vue.d.ts +1 -5
- package/dist/src/composables/useConfig.d.ts +0 -2
- package/dist/src/composables/useHttp.d.ts +0 -2
- package/dist/src/config/migrator/index.d.ts +1 -2
- package/dist/src/enums/extensions/recommendationBlock.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +13 -2
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +0 -6
- package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +3 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/strategyCommit.d.ts +7 -0
- package/dist/src/stores/config.d.ts +0 -20
- package/dist/static/styles/components/recommendation-strategy.css.js +0 -9
- package/package.json +1 -1
- package/dist/components/organisms/base/AuthErrorModal.vue.js +0 -18
- package/dist/components/organisms/base/AuthErrorModal.vue2.js +0 -42
- package/dist/composables/useAuthError.js +0 -52
- package/dist/config/migrator/recommendationPartnerMigrator.js +0 -50
- package/dist/extensions/Blocks/Recommendation/utils/partnerScope.js +0 -25
- package/dist/src/components/organisms/base/AuthErrorModal.vue.d.ts +0 -2
- package/dist/src/composables/useAuthError.d.ts +0 -12
- package/dist/src/config/migrator/recommendationPartnerMigrator.d.ts +0 -19
- package/dist/src/extensions/Blocks/Recommendation/utils/partnerScope.d.ts +0 -33
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var i = (g,
|
|
4
|
-
import { useConfig as
|
|
1
|
+
var m = Object.defineProperty;
|
|
2
|
+
var C = (g, c, t) => c in g ? m(g, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : g[c] = t;
|
|
3
|
+
var i = (g, c, t) => C(g, typeof c != "symbol" ? c + "" : c, t);
|
|
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 { RRS_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 l } 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
|
-
import { AlgorithmControl as
|
|
13
|
-
import { ALGORITHM_CONTROL_ID as
|
|
14
|
-
import { CurrencyControl as
|
|
12
|
+
import { AlgorithmControl as P } from "./algorithm.js";
|
|
13
|
+
import { ALGORITHM_CONTROL_ID as dt } from "./algorithm.js";
|
|
14
|
+
import { CurrencyControl as T } from "./currency.js";
|
|
15
15
|
import { CURRENCY_CONTROL_ID as gt } from "./currency.js";
|
|
16
16
|
import { FiltersControl as S } from "./filters.js";
|
|
17
17
|
import { FILTERS_CONTROL_ID as ft } 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
|
-
import { LocaleControl as
|
|
20
|
+
import { LocaleControl as k } from "./locale.js";
|
|
21
21
|
import { LOCALE_CONTROL_ID as yt } from "./locale.js";
|
|
22
|
-
import { PricePlacementControl as
|
|
22
|
+
import { PricePlacementControl as L } from "./pricePlacement.js";
|
|
23
23
|
import { PRICE_PLACEMENT_CONTROL_ID as _t } from "./pricePlacement.js";
|
|
24
24
|
import { ProductCountControl as E } from "./productCount.js";
|
|
25
25
|
import { PRODUCT_COUNT_CONTROL_ID as Rt } from "./productCount.js";
|
|
26
26
|
import { ProductLayoutControl as F } from "./productLayout.js";
|
|
27
|
-
import { PRODUCT_LAYOUT_CONTROL_ID as
|
|
27
|
+
import { PRODUCT_LAYOUT_CONTROL_ID as Pt } from "./productLayout.js";
|
|
28
28
|
import { ShuffleControl as D } from "./shuffle.js";
|
|
29
29
|
import { SHUFFLE_CONTROL_ID as St } from "./shuffle.js";
|
|
30
|
-
import { StrategyControl as
|
|
31
|
-
import { STRATEGY_CONTROL_ID as
|
|
32
|
-
import { setCurrencyAttributes as
|
|
33
|
-
import { adjustProductsToSize as Et, formatProductPrice as Ft, getCardComposition as Dt, getCurrentLayout as
|
|
34
|
-
import { useDebounceFn as
|
|
30
|
+
import { StrategyControl as B } from "./strategy.js";
|
|
31
|
+
import { STRATEGY_CONTROL_ID as kt } from "./strategy.js";
|
|
32
|
+
import { setCurrencyAttributes as w, getBlockElement as A, isPartnerManagedBlock as v, updateProductContentInPlace as x, regenerateProductRowsWithStyles as U } from "./utils.js";
|
|
33
|
+
import { adjustProductsToSize as Et, formatProductPrice as Ft, getCardComposition as Dt, getCurrentLayout as Bt, getMainContainerTbody as wt, regenerateMobileProductRows as At, updatePricesInPlace as vt, updateSingleProductContent as xt } from "./utils.js";
|
|
34
|
+
import { useDebounceFn as h } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
35
35
|
const W = "ui-elements-recommendation-block";
|
|
36
36
|
class at extends N {
|
|
37
37
|
constructor() {
|
|
@@ -58,7 +58,7 @@ class at extends N {
|
|
|
58
58
|
/**
|
|
59
59
|
* Debounced product fetch to prevent rapid API calls during config changes
|
|
60
60
|
*/
|
|
61
|
-
i(this, "_debouncedFetchProducts",
|
|
61
|
+
i(this, "_debouncedFetchProducts", h(async () => {
|
|
62
62
|
try {
|
|
63
63
|
await this.store.fetchRecommendationProducts();
|
|
64
64
|
} finally {
|
|
@@ -76,24 +76,22 @@ class at extends N {
|
|
|
76
76
|
* count. The store pads products to the configured size, so in-place only
|
|
77
77
|
* fails when the size actually changed.
|
|
78
78
|
*/
|
|
79
|
-
i(this, "_debouncedRegenerateWithProducts",
|
|
80
|
-
const t = this.store.recommendationProducts;
|
|
79
|
+
i(this, "_debouncedRegenerateWithProducts", h(() => {
|
|
81
80
|
if (!this.currentNode || !this.api)
|
|
82
81
|
return;
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
85
|
-
|
|
82
|
+
const t = this._getRecommendationIdFromNode(this.currentNode), e = this.store.currentRecommendationId;
|
|
83
|
+
if (t === null || e === null || t === e || !this.store.blockStates[t]) {
|
|
84
|
+
this._regenerateWithProducts();
|
|
86
85
|
return;
|
|
87
86
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
});
|
|
87
|
+
if (this.store.blockStates[t].recommendationProducts.length) {
|
|
88
|
+
this.store.setCurrentBlock(t);
|
|
89
|
+
try {
|
|
90
|
+
this._regenerateWithProducts();
|
|
91
|
+
} finally {
|
|
92
|
+
this.store.setCurrentBlock(e);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
97
95
|
}, 100));
|
|
98
96
|
}
|
|
99
97
|
getId() {
|
|
@@ -115,10 +113,10 @@ class at extends N {
|
|
|
115
113
|
}
|
|
116
114
|
getTemplate() {
|
|
117
115
|
var t;
|
|
118
|
-
return this.rrsEnabled =
|
|
116
|
+
return this.rrsEnabled = p().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((e) => {
|
|
119
117
|
var o;
|
|
120
118
|
return (o = e == null ? void 0 : e.onDestroy) == null ? void 0 : o.call(e);
|
|
121
|
-
}), this.algorithmControl = new
|
|
119
|
+
}), this.algorithmControl = new P(), this.localeControl = new k(), this.currencyControl = new T(), this.productCountControl = new E(), this.productLayoutControl = new F(), this.filtersControl = new S(), this.shuffleControl = new D(), this.pricePlacementControl = new L(), this.layoutOrientationControl = new O(), this.strategyControl = this.rrsEnabled ? new B() : null, this._subControls.forEach((e) => {
|
|
122
120
|
e && (e.api = this.api);
|
|
123
121
|
}), `
|
|
124
122
|
<div class="recommendation-controls-container">
|
|
@@ -136,12 +134,12 @@ class at extends N {
|
|
|
136
134
|
`;
|
|
137
135
|
}
|
|
138
136
|
_showControlsForBlock(t) {
|
|
139
|
-
var
|
|
140
|
-
const e = (
|
|
137
|
+
var n;
|
|
138
|
+
const e = (n = this.getContainer()) == null ? void 0 : n.querySelector(".recommendation-controls-container");
|
|
141
139
|
if (!e)
|
|
142
140
|
return;
|
|
143
|
-
const o = this._getRecommendationIdFromNode(t) === null ? null :
|
|
144
|
-
e.classList.toggle("strategy-block",
|
|
141
|
+
const o = this._getRecommendationIdFromNode(t) === null ? null : l.getConfig(t), r = this.rrsEnabled && !!o && (!!(o != null && o.strategyId) || ((o == null ? void 0 : o.configVersion) ?? 0) >= _), s = this.rrsEnabled && !!o && !r;
|
|
142
|
+
e.classList.toggle("strategy-block", r), e.classList.toggle("legacy-strategy-block", s);
|
|
145
143
|
}
|
|
146
144
|
async onRender() {
|
|
147
145
|
var o;
|
|
@@ -159,9 +157,9 @@ class at extends N {
|
|
|
159
157
|
const e = this._getRecommendationIdFromNode(t);
|
|
160
158
|
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(() => {
|
|
161
159
|
this._initializeSubControls();
|
|
162
|
-
}), this._subControls.forEach((
|
|
160
|
+
}), this._subControls.forEach((r) => {
|
|
163
161
|
var s;
|
|
164
|
-
|
|
162
|
+
r != null && r.api && (r.currentNode = t, (s = r.onTemplateNodeUpdated) == null || s.call(r, t));
|
|
165
163
|
});
|
|
166
164
|
}
|
|
167
165
|
onDestroy() {
|
|
@@ -209,30 +207,23 @@ class at extends N {
|
|
|
209
207
|
const e = this.store.blockStates[t];
|
|
210
208
|
if (!e)
|
|
211
209
|
return;
|
|
212
|
-
const o = JSON.stringify(
|
|
213
|
-
e.syncedConfigFingerprint = o,
|
|
210
|
+
const o = JSON.stringify(l.getConfig(this.currentNode)), r = e.syncedConfigFingerprint;
|
|
211
|
+
e.syncedConfigFingerprint = o, r !== o && (this.pendingNodeConfigWrite || this._syncNodeConfigToStore());
|
|
214
212
|
}
|
|
215
213
|
/** Whether the deferred write would move the node's strategyId — see the caller (SD-149916). */
|
|
216
214
|
_isPendingStrategyIdChange() {
|
|
217
215
|
const t = this.pendingNodeConfigWrite;
|
|
218
|
-
return t ?
|
|
216
|
+
return t ? l.getConfig(this.currentNode).strategyId !== t.updates.strategyId : !1;
|
|
219
217
|
}
|
|
220
218
|
_capturePendingNodeConfigWrite() {
|
|
221
219
|
const t = this.store.currentRecommendationId;
|
|
222
220
|
if (!this.currentNode || !this.api || t === null)
|
|
223
221
|
return;
|
|
224
|
-
const { filters: e, strategy: o, strategyId:
|
|
222
|
+
const { filters: e, strategy: o, strategyId: r, size: s, nodeConfigVersion: n } = this.store.recommendationConfigs;
|
|
225
223
|
this.pendingNodeConfigWrite = {
|
|
226
224
|
blockId: t,
|
|
227
225
|
node: this.currentNode,
|
|
228
|
-
updates: {
|
|
229
|
-
filters: e,
|
|
230
|
-
strategy: o,
|
|
231
|
-
strategyId: n,
|
|
232
|
-
size: s,
|
|
233
|
-
configVersion: r,
|
|
234
|
-
...l.value ? { partnerName: l.value } : {}
|
|
235
|
-
}
|
|
226
|
+
updates: { filters: e, strategy: o, strategyId: r, size: s, configVersion: n }
|
|
236
227
|
};
|
|
237
228
|
}
|
|
238
229
|
/**
|
|
@@ -247,7 +238,7 @@ class at extends N {
|
|
|
247
238
|
*/
|
|
248
239
|
_stagePendingNodeConfig(t) {
|
|
249
240
|
const e = this.pendingNodeConfigWrite;
|
|
250
|
-
return !e || !this.currentNode ? !1 : (
|
|
241
|
+
return !e || !this.currentNode ? !1 : (l.stageConfig(t, this.currentNode, e.updates), !0);
|
|
251
242
|
}
|
|
252
243
|
/**
|
|
253
244
|
* Arms the guaranteed fallback write, once the product fetch has settled. The
|
|
@@ -271,12 +262,12 @@ class at extends N {
|
|
|
271
262
|
const t = this.pendingNodeConfigWrite;
|
|
272
263
|
if (this.pendingNodeConfigWrite = null, this._clearConfigFlush(), !t || !this.api)
|
|
273
264
|
return;
|
|
274
|
-
const e = t.blockId === this.store.currentRecommendationId && this.currentNode ? this.currentNode : t.node, o =
|
|
275
|
-
JSON.stringify(o.filters) === JSON.stringify(t.updates.filters) && o.strategy === t.updates.strategy && o.strategyId === t.updates.strategyId && o.size === t.updates.size ||
|
|
265
|
+
const e = t.blockId === this.store.currentRecommendationId && this.currentNode ? this.currentNode : t.node, o = l.getConfig(e);
|
|
266
|
+
JSON.stringify(o.filters) === JSON.stringify(t.updates.filters) && o.strategy === t.updates.strategy && o.strategyId === t.updates.strategyId && o.size === t.updates.size || l.updateConfig(this.api, e, t.updates, "Update recommendation filters");
|
|
276
267
|
}
|
|
277
268
|
_syncNodeConfigToStore() {
|
|
278
|
-
var
|
|
279
|
-
const t =
|
|
269
|
+
var r;
|
|
270
|
+
const t = l.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((r = this.store.blockStates[e]) == null ? void 0 : r.isInitialized);
|
|
280
271
|
this.store.patchCurrentBlockConfig({
|
|
281
272
|
strategy: t.strategy,
|
|
282
273
|
strategyId: t.strategyId,
|
|
@@ -319,8 +310,8 @@ class at extends N {
|
|
|
319
310
|
t !== null && this.store.markBlockInitialized(t), (await Promise.allSettled([
|
|
320
311
|
this.store.fetchRecommendationCreateData(),
|
|
321
312
|
this.store.fetchRecommendationFilters()
|
|
322
|
-
])).forEach((o,
|
|
323
|
-
o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][
|
|
313
|
+
])).forEach((o, r) => {
|
|
314
|
+
o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][r]} failed`, o.reason);
|
|
324
315
|
}), this._applySmartDefaults();
|
|
325
316
|
try {
|
|
326
317
|
await this.store.fetchRecommendationProducts();
|
|
@@ -341,36 +332,36 @@ class at extends N {
|
|
|
341
332
|
_applySmartDefaults() {
|
|
342
333
|
if (!this.currentNode || !this.api)
|
|
343
334
|
return;
|
|
344
|
-
const t =
|
|
345
|
-
let o = null,
|
|
335
|
+
const t = l.getConfig(this.currentNode), e = {};
|
|
336
|
+
let o = null, r = null, s = null;
|
|
346
337
|
if (t.currency.code === a.currency.code) {
|
|
347
|
-
const { currencyList:
|
|
348
|
-
|
|
349
|
-
(
|
|
350
|
-
) || (o =
|
|
338
|
+
const { currencyList: n } = this.store;
|
|
339
|
+
n.length > 0 && (n.some(
|
|
340
|
+
(u) => u.value === `price.${a.currency.code}`
|
|
341
|
+
) || (o = n[0].value.replace("price.", ""), e.currency = {
|
|
351
342
|
...a.currency,
|
|
352
343
|
code: o,
|
|
353
344
|
symbol: o
|
|
354
345
|
}));
|
|
355
346
|
}
|
|
356
347
|
if (t.strategy === a.strategy) {
|
|
357
|
-
const
|
|
358
|
-
|
|
359
|
-
(
|
|
360
|
-
) || (
|
|
348
|
+
const n = this.store.getActivePredictiveAlgorithms;
|
|
349
|
+
n.length > 0 && (n.some(
|
|
350
|
+
(u) => u.value === a.strategy
|
|
351
|
+
) || (r = n[0].value, e.strategy = r));
|
|
361
352
|
}
|
|
362
353
|
if (t.language === a.language) {
|
|
363
|
-
const
|
|
364
|
-
|
|
365
|
-
(
|
|
366
|
-
) || (s =
|
|
354
|
+
const n = this.store.getLanguages;
|
|
355
|
+
n.length > 0 && (n.some(
|
|
356
|
+
(u) => u.value === a.language
|
|
357
|
+
) || (s = n[0].value, e.language = s));
|
|
367
358
|
}
|
|
368
|
-
!o && !
|
|
359
|
+
!o && !r && !s || (l.updateConfig(
|
|
369
360
|
this.api,
|
|
370
361
|
this.currentNode,
|
|
371
362
|
e,
|
|
372
363
|
"Applied smart defaults"
|
|
373
|
-
), o && e.currency &&
|
|
364
|
+
), o && e.currency && w({
|
|
374
365
|
currentNode: this.currentNode,
|
|
375
366
|
documentModifier: this.api.getDocumentModifier(),
|
|
376
367
|
currency: e.currency
|
|
@@ -386,7 +377,7 @@ class at extends N {
|
|
|
386
377
|
thousandSeparator: a.currency.thousandSeparator
|
|
387
378
|
}
|
|
388
379
|
} : {},
|
|
389
|
-
...
|
|
380
|
+
...r ? { strategy: r } : {},
|
|
390
381
|
...s ? { language: s } : {}
|
|
391
382
|
}, { triggerRefetch: !1 }));
|
|
392
383
|
}
|
|
@@ -400,8 +391,27 @@ class at extends N {
|
|
|
400
391
|
const o = e.getAttribute(I);
|
|
401
392
|
if (!o)
|
|
402
393
|
return null;
|
|
403
|
-
const
|
|
404
|
-
return Number.isNaN(
|
|
394
|
+
const r = parseInt(o);
|
|
395
|
+
return Number.isNaN(r) ? null : r;
|
|
396
|
+
}
|
|
397
|
+
/** Draws the current block's products into this panel's node. */
|
|
398
|
+
_regenerateWithProducts() {
|
|
399
|
+
if (!this.currentNode || !this.api)
|
|
400
|
+
return;
|
|
401
|
+
const t = this.store.recommendationProducts, e = this.api.getDocumentModifier(), o = this._stagePendingNodeConfig(e);
|
|
402
|
+
if (v(this.currentNode)) {
|
|
403
|
+
o && (e.apply(new y("Update recommendation configuration")), this.pendingNodeConfigWrite = null, this._clearConfigFlush());
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
x({
|
|
407
|
+
currentNode: this.currentNode,
|
|
408
|
+
documentModifier: e,
|
|
409
|
+
products: t
|
|
410
|
+
}) || U({
|
|
411
|
+
currentNode: this.currentNode,
|
|
412
|
+
documentModifier: e,
|
|
413
|
+
products: t
|
|
414
|
+
});
|
|
405
415
|
}
|
|
406
416
|
/**
|
|
407
417
|
* Listen to store changes that require product refresh or regeneration.
|
|
@@ -418,54 +428,54 @@ class at extends N {
|
|
|
418
428
|
*/
|
|
419
429
|
_listenStateUpdates() {
|
|
420
430
|
const { store: t } = this;
|
|
421
|
-
let e = t.recommendationProducts, o = t.$state.configVersion,
|
|
431
|
+
let e = t.recommendationProducts, o = t.$state.configVersion, r = t.currentRecommendationId;
|
|
422
432
|
this.storeUnsubscription = t.$subscribe(() => {
|
|
423
433
|
const s = t.currentRecommendationId;
|
|
424
|
-
if (s !==
|
|
425
|
-
|
|
434
|
+
if (s !== r) {
|
|
435
|
+
r = s, e = t.recommendationProducts, o = t.$state.configVersion;
|
|
426
436
|
return;
|
|
427
437
|
}
|
|
428
|
-
const
|
|
429
|
-
|
|
430
|
-
const
|
|
431
|
-
|
|
438
|
+
const n = t.$state.configVersion;
|
|
439
|
+
n !== o && (o = n, this._capturePendingNodeConfigWrite(), this._isPendingStrategyIdChange() && this._flushPendingNodeConfig(), this._debouncedFetchProducts());
|
|
440
|
+
const d = t.recommendationProducts, u = d !== e, f = Array.isArray(d) && d.length > 0;
|
|
441
|
+
u && f && (e = d, this._debouncedRegenerateWithProducts());
|
|
432
442
|
});
|
|
433
443
|
}
|
|
434
444
|
}
|
|
435
445
|
export {
|
|
436
|
-
|
|
437
|
-
|
|
446
|
+
dt as ALGORITHM_CONTROL_ID,
|
|
447
|
+
P as AlgorithmControl,
|
|
438
448
|
W as CONTROL_BLOCK_ID,
|
|
439
449
|
gt as CURRENCY_CONTROL_ID,
|
|
440
|
-
|
|
450
|
+
T as CurrencyControl,
|
|
441
451
|
ft as FILTERS_CONTROL_ID,
|
|
442
452
|
S as FiltersControl,
|
|
443
453
|
Ct as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
444
454
|
yt as LOCALE_CONTROL_ID,
|
|
445
455
|
O as LayoutOrientationControl,
|
|
446
|
-
|
|
456
|
+
k as LocaleControl,
|
|
447
457
|
_t as PRICE_PLACEMENT_CONTROL_ID,
|
|
448
458
|
Rt as PRODUCT_COUNT_CONTROL_ID,
|
|
449
|
-
|
|
450
|
-
|
|
459
|
+
Pt as PRODUCT_LAYOUT_CONTROL_ID,
|
|
460
|
+
L as PricePlacementControl,
|
|
451
461
|
E as ProductCountControl,
|
|
452
462
|
F as ProductLayoutControl,
|
|
453
463
|
at as RecommendationBlockControl,
|
|
454
464
|
St as SHUFFLE_CONTROL_ID,
|
|
455
|
-
|
|
465
|
+
kt as STRATEGY_CONTROL_ID,
|
|
456
466
|
D as ShuffleControl,
|
|
457
|
-
|
|
467
|
+
B as StrategyControl,
|
|
458
468
|
Et as adjustProductsToSize,
|
|
459
469
|
Ft as formatProductPrice,
|
|
460
470
|
A as getBlockElement,
|
|
461
471
|
Dt as getCardComposition,
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
472
|
+
Bt as getCurrentLayout,
|
|
473
|
+
wt as getMainContainerTbody,
|
|
474
|
+
v as isPartnerManagedBlock,
|
|
465
475
|
At as regenerateMobileProductRows,
|
|
466
476
|
U as regenerateProductRowsWithStyles,
|
|
467
|
-
|
|
468
|
-
|
|
477
|
+
w as setCurrencyAttributes,
|
|
478
|
+
vt as updatePricesInPlace,
|
|
469
479
|
x as updateProductContentInPlace,
|
|
470
480
|
xt as updateSingleProductContent
|
|
471
481
|
};
|
|
@@ -1,35 +1,33 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var i = (
|
|
4
|
-
import { useLegacyStrategyConversion as
|
|
5
|
-
import { ACADEMY_LINKS as
|
|
6
|
-
import { useOnboardingStore as
|
|
7
|
-
import { CommonControl as
|
|
8
|
-
import { RRS_CONFIG_VERSION as
|
|
9
|
-
import { RecommendationConfigService as
|
|
10
|
-
import { useRecommendationExtensionStore as
|
|
11
|
-
const
|
|
12
|
-
class
|
|
1
|
+
var C = Object.defineProperty;
|
|
2
|
+
var $ = (c, n, t) => n in c ? C(c, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[n] = t;
|
|
3
|
+
var i = (c, n, t) => $(c, typeof n != "symbol" ? n + "" : n, t);
|
|
4
|
+
import { useLegacyStrategyConversion as k } from "../../../../../composables/useLegacyStrategyConversion.js";
|
|
5
|
+
import { ACADEMY_LINKS as L } from "../../../../../enums/academy.js";
|
|
6
|
+
import { useOnboardingStore as w } from "../../../../../stores/onboarding.js";
|
|
7
|
+
import { CommonControl as A } from "../../../common-control.js";
|
|
8
|
+
import { RRS_CONFIG_VERSION as N } from "../../constants/defaultConfig.js";
|
|
9
|
+
import { RecommendationConfigService as b } from "../../services/configService.js";
|
|
10
|
+
import { useRecommendationExtensionStore as R } from "../../store/recommendation.js";
|
|
11
|
+
const E = "recommendation-strategy-control";
|
|
12
|
+
class M extends A {
|
|
13
13
|
constructor() {
|
|
14
14
|
super(...arguments);
|
|
15
|
-
i(this, "store",
|
|
16
|
-
i(this, "onboardingStore",
|
|
17
|
-
i(this, "legacyConversion",
|
|
15
|
+
i(this, "store", R());
|
|
16
|
+
i(this, "onboardingStore", w());
|
|
17
|
+
i(this, "legacyConversion", k());
|
|
18
18
|
i(this, "storeUnsubscription", () => {
|
|
19
19
|
});
|
|
20
20
|
i(this, "listeners", []);
|
|
21
21
|
i(this, "lastPaintedState", null);
|
|
22
22
|
}
|
|
23
23
|
getId() {
|
|
24
|
-
return
|
|
24
|
+
return E;
|
|
25
25
|
}
|
|
26
26
|
getTemplate() {
|
|
27
27
|
const t = this.api.translate(
|
|
28
28
|
"You can assign a recommendation strategy by selecting an existing one or creating a new one to show specific content."
|
|
29
|
-
), e = this.api.translate("For more information, you can"),
|
|
29
|
+
), e = this.api.translate("For more information, you can"), s = this.api.translate("visit Academy"), o = this.api.translate("Legacy Strategy"), a = this.api.translate(
|
|
30
30
|
"Note that this is an older version of the Recommendation Strategy. We recommend you update it to the new Recommendation Strategy for an improved experience."
|
|
31
|
-
), g = this.api.translate(
|
|
32
|
-
"The recommendation strategy used in the recommendation block is no longer available. You can assign a different strategy to it."
|
|
33
31
|
);
|
|
34
32
|
return `
|
|
35
33
|
<div class="strategy-control-container">
|
|
@@ -54,9 +52,9 @@ class P extends R {
|
|
|
54
52
|
${t}
|
|
55
53
|
${e}
|
|
56
54
|
<a
|
|
57
|
-
href="${
|
|
55
|
+
href="${L.EMAIL_RECOMMENDATION_BLOCK}"
|
|
58
56
|
target="_blank"
|
|
59
|
-
rel="noopener noreferrer">${
|
|
57
|
+
rel="noopener noreferrer">${s}</a>.
|
|
60
58
|
</p>
|
|
61
59
|
</div>
|
|
62
60
|
<div data-strategy-empty-state style="display: none;">
|
|
@@ -73,37 +71,16 @@ class P extends R {
|
|
|
73
71
|
id: "guido__btn-create-strategy",
|
|
74
72
|
className: "strategy-control-cta primary"
|
|
75
73
|
})
|
|
76
|
-
], "strategy-control-cta-row")}
|
|
77
|
-
</div>
|
|
78
|
-
<div data-strategy-unavailable-state style="display: none;">
|
|
79
|
-
<div class="strategy-control-notice-row">
|
|
80
|
-
<div class="strategy-control-notice strategy-control-notice--error" role="alert">
|
|
81
|
-
<p class="strategy-control-notice-text">${g}</p>
|
|
82
|
-
</div>
|
|
83
|
-
</div>
|
|
84
|
-
${this._GuTwoColumns([
|
|
85
|
-
this._GuButton({
|
|
86
|
-
name: "assignUnavailableStrategy",
|
|
87
|
-
label: this.api.translate("Assign Strategy"),
|
|
88
|
-
id: "guido__btn-assign-unavailable-strategy",
|
|
89
|
-
className: "strategy-control-cta on"
|
|
90
|
-
}),
|
|
91
|
-
this._GuButton({
|
|
92
|
-
name: "createUnavailableStrategy",
|
|
93
|
-
label: this.api.translate("Create New Strategy"),
|
|
94
|
-
id: "guido__btn-create-unavailable-strategy",
|
|
95
|
-
className: "strategy-control-cta primary"
|
|
96
|
-
})
|
|
97
74
|
], "strategy-control-cta-row")}
|
|
98
75
|
</div>
|
|
99
76
|
<div data-strategy-legacy-state style="display: none;">
|
|
100
77
|
<div class="strategy-control-notice-row">
|
|
101
78
|
<div class="strategy-control-notice">
|
|
102
|
-
<p class="strategy-control-notice-text">${
|
|
79
|
+
<p class="strategy-control-notice-text">${a}</p>
|
|
103
80
|
</div>
|
|
104
81
|
</div>
|
|
105
82
|
<div class="strategy-control-name-band">
|
|
106
|
-
<span class="strategy-control-name">${
|
|
83
|
+
<span class="strategy-control-name">${o}</span>
|
|
107
84
|
${this._strategyAction({
|
|
108
85
|
id: "guido__btn-update-legacy-strategy",
|
|
109
86
|
label: this.api.translate("Update"),
|
|
@@ -146,12 +123,12 @@ class P extends R {
|
|
|
146
123
|
</div>
|
|
147
124
|
`;
|
|
148
125
|
}
|
|
149
|
-
_strategyAction({ id: t, label: e, modifier:
|
|
126
|
+
_strategyAction({ id: t, label: e, modifier: s }) {
|
|
150
127
|
return `
|
|
151
128
|
<button
|
|
152
129
|
id="${t}"
|
|
153
130
|
type="button"
|
|
154
|
-
class="strategy-control-action strategy-control-action--${
|
|
131
|
+
class="strategy-control-action strategy-control-action--${s}">
|
|
155
132
|
<span>${e}</span>
|
|
156
133
|
</button>
|
|
157
134
|
`;
|
|
@@ -159,8 +136,8 @@ class P extends R {
|
|
|
159
136
|
onRender() {
|
|
160
137
|
this._teardown(), this.store.strategyPanelOpen = !0, this._setupButtonListeners(), this._renderState(), this.storeUnsubscription = this.store.$subscribe(() => {
|
|
161
138
|
this._renderState();
|
|
162
|
-
}), this.store.recommendationConfigs.strategyId && !this.store.
|
|
163
|
-
})
|
|
139
|
+
}), this.store.recommendationConfigs.strategyId && !this.store.strategiesFetched && this.store.fetchStrategies().catch(() => {
|
|
140
|
+
});
|
|
164
141
|
}
|
|
165
142
|
/**
|
|
166
143
|
* Whether the document itself says this block has no strategy.
|
|
@@ -170,10 +147,10 @@ class P extends R {
|
|
|
170
147
|
* strategyId) for an assigned block.
|
|
171
148
|
*/
|
|
172
149
|
_isNodeUnassigned() {
|
|
173
|
-
if (!
|
|
150
|
+
if (!b.hasConfig(this.currentNode))
|
|
174
151
|
return !1;
|
|
175
|
-
const t =
|
|
176
|
-
return !t.strategyId && (t.configVersion ?? 0) >=
|
|
152
|
+
const t = b.getConfig(this.currentNode);
|
|
153
|
+
return !t.strategyId && (t.configVersion ?? 0) >= N;
|
|
177
154
|
}
|
|
178
155
|
onDestroy() {
|
|
179
156
|
this._teardown();
|
|
@@ -186,37 +163,37 @@ class P extends R {
|
|
|
186
163
|
const t = this.getContainer();
|
|
187
164
|
if (!t)
|
|
188
165
|
return;
|
|
189
|
-
const e = (
|
|
190
|
-
const
|
|
191
|
-
|
|
166
|
+
const e = (s, o) => {
|
|
167
|
+
const a = t.querySelector(s);
|
|
168
|
+
a && (a.addEventListener("click", o), this.listeners.push({ element: a, handler: o }));
|
|
192
169
|
};
|
|
193
|
-
e("#guido__btn-assign-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-create-strategy", () => this.store.openStrategyCreation()), e("#guido__btn-
|
|
170
|
+
e("#guido__btn-assign-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-create-strategy", () => this.store.openStrategyCreation()), e("#guido__btn-change-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-change-legacy-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-remove-strategy", () => this.store.openRemoveStrategyModal()), e("#guido__btn-remove-legacy-strategy", () => this.store.openRemoveStrategyModal()), e("#guido__btn-update-legacy-strategy", () => {
|
|
194
171
|
this.legacyConversion.convertLegacyStrategy();
|
|
195
172
|
});
|
|
196
173
|
}
|
|
197
174
|
_renderState() {
|
|
198
|
-
var
|
|
199
|
-
const { strategyId: t } = this.store.recommendationConfigs, e = t ? ((
|
|
200
|
-
if (
|
|
175
|
+
var _;
|
|
176
|
+
const { strategyId: t } = this.store.recommendationConfigs, e = t ? ((_ = this.store.assignedStrategy) == null ? void 0 : _.name) ?? "" : "", s = !!t && !e && (this.store.strategiesLoading || !this.store.strategiesSettled), o = this.store.legacyConversionLoading, a = this.store.isLegacyStrategyBlock, h = `${t}\0${e}\0${s}\0${o}\0${a}`;
|
|
177
|
+
if (h === this.lastPaintedState)
|
|
201
178
|
return;
|
|
202
|
-
const
|
|
203
|
-
if (!
|
|
179
|
+
const r = this.getContainer();
|
|
180
|
+
if (!r)
|
|
204
181
|
return;
|
|
205
|
-
const
|
|
206
|
-
if (!
|
|
182
|
+
const d = r.querySelector("[data-strategy-empty-state]"), y = r.querySelector("[data-strategy-assigned-state]"), g = r.querySelector("[data-strategy-legacy-state]"), p = r.querySelector("[data-strategy-loading-state]"), u = r.querySelector("[data-strategy-content]"), m = r.querySelector("[data-strategy-name]"), v = r.querySelector("[data-strategy-name-skeleton]");
|
|
183
|
+
if (!d || !y || !g)
|
|
207
184
|
return;
|
|
208
|
-
|
|
209
|
-
const
|
|
210
|
-
[
|
|
211
|
-
|
|
212
|
-
}),
|
|
213
|
-
|
|
214
|
-
}),
|
|
185
|
+
p && (p.style.display = "none"), u && (u.style.display = "");
|
|
186
|
+
const f = t ? y : a ? g : d;
|
|
187
|
+
[d, y, g].forEach((l) => {
|
|
188
|
+
l.style.display = l === f ? "" : "none";
|
|
189
|
+
}), g.querySelectorAll("button").forEach((l) => {
|
|
190
|
+
l.disabled = o;
|
|
191
|
+
}), g.classList.toggle("is-converting", o), !t && this._isNodeUnassigned() && this.onboardingStore.startOnboarding("recommendationStrategyOnboarding");
|
|
215
192
|
const S = this.store.currentRecommendationId;
|
|
216
|
-
|
|
193
|
+
a && S !== null && this.store.blockStates[S] && this.onboardingStore.startOnboarding("recommendationLegacyStrategyOnboarding"), m && (m.style.display = s ? "none" : "", t && !s && (m.textContent = e || `#${t}`)), v && (v.style.display = s ? "block" : "none"), this.lastPaintedState = h;
|
|
217
194
|
}
|
|
218
195
|
}
|
|
219
196
|
export {
|
|
220
|
-
|
|
221
|
-
|
|
197
|
+
E as STRATEGY_CONTROL_ID,
|
|
198
|
+
M as StrategyControl
|
|
222
199
|
};
|