@useinsider/guido 2.1.0-beta.f869a80 → 2.1.0-beta.f9ab899

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.
Files changed (75) hide show
  1. package/dist/@types/config/schemas.js +1 -1
  2. package/dist/components/organisms/base/Toaster.vue.js +4 -4
  3. package/dist/components/organisms/base/Toaster.vue2.js +12 -9
  4. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.js +5 -5
  5. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue2.js +2 -2
  6. package/dist/components/organisms/extensions/recommendation/FilterItem.vue.js +13 -11
  7. package/dist/components/organisms/extensions/recommendation/FilterItem.vue2.js +23 -54
  8. package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue.js +5 -7
  9. package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue2.js +21 -34
  10. package/dist/components/organisms/extensions/recommendation/Filters.vue.js +11 -11
  11. package/dist/components/organisms/extensions/recommendation/Filters.vue2.js +36 -48
  12. package/dist/components/organisms/extensions/recommendation/LogicAdapter.vue2.js +9 -11
  13. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +1 -1
  14. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +19 -19
  15. package/dist/composables/useRecommendation.js +9 -9
  16. package/dist/composables/useStripo.js +25 -23
  17. package/dist/composables/useVersionHistoryApi.js +1 -1
  18. package/dist/config/i18n/en/index.js +11 -0
  19. package/dist/config/i18n/en/labels.json.js +7 -0
  20. package/dist/config/i18n/en/toasters.json.js +56 -0
  21. package/dist/config/i18n/en/tooltips.json.js +82 -0
  22. package/dist/config/i18n/index.js +7 -0
  23. package/dist/config/migrator/itemsBlockMigrator.js +65 -64
  24. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +36 -33
  25. package/dist/extensions/Blocks/Recommendation/constants/layout.js +16 -14
  26. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +13 -12
  27. package/dist/extensions/Blocks/Recommendation/controls/button/index.js +9 -9
  28. package/dist/extensions/Blocks/Recommendation/controls/image/index.js +1 -1
  29. package/dist/extensions/Blocks/Recommendation/controls/layout/index.js +37 -27
  30. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +16 -16
  31. package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +30 -32
  32. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +177 -125
  33. package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +9 -9
  34. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +46 -38
  35. package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +16 -16
  36. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +269 -215
  37. package/dist/extensions/Blocks/Recommendation/controls/name/index.js +10 -10
  38. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +5 -5
  39. package/dist/extensions/Blocks/Recommendation/controls/oldPrice/index.js +14 -14
  40. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.js +9 -9
  41. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.js +3 -3
  42. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.js +1 -1
  43. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/index.js +9 -9
  44. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.js +3 -3
  45. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.js +3 -3
  46. package/dist/extensions/Blocks/Recommendation/controls/price/index.js +3 -3
  47. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +225 -102
  48. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +123 -128
  49. package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +8 -8
  50. package/dist/extensions/Blocks/Unsubscribe/block.js +29 -29
  51. package/dist/extensions/Blocks/Unsubscribe/control.js +12 -9
  52. package/dist/extensions/Blocks/Unsubscribe/elements/preview.js +13 -11
  53. package/dist/extensions/Blocks/Unsubscribe/styles.css.js +31 -1
  54. package/dist/guido.css +1 -1
  55. package/dist/src/components/organisms/extensions/recommendation/FilterItem.vue.d.ts +0 -1
  56. package/dist/src/components/organisms/extensions/recommendation/Filters.vue.d.ts +1 -17
  57. package/dist/src/config/i18n/en/index.d.ts +1 -0
  58. package/dist/src/config/i18n/index.d.ts +16 -0
  59. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +6 -0
  60. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +3 -3
  61. package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +6 -2
  62. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +6 -1
  63. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +33 -15
  64. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +24 -14
  65. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +49 -17
  66. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +3 -18
  67. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +8 -0
  68. package/dist/src/extensions/Blocks/Unsubscribe/control.d.ts +1 -0
  69. package/dist/static/styles/components/notification.css.js +18 -0
  70. package/dist/static/styles/components/tools.css.js +6 -2
  71. package/dist/static/styles/variables.css.js +2 -0
  72. package/dist/stores/unsubscribe.js +37 -34
  73. package/package.json +1 -1
  74. package/dist/extensions/Blocks/Recommendation/validation/filterSchema.js +0 -29
  75. package/dist/src/extensions/Blocks/Recommendation/validation/filterSchema.d.ts +0 -15
@@ -1,15 +1,16 @@
1
- import { RecommendationFeedSourceMaps as f, getOperatorOptions as g, PriceAttributes as S } from "../../../../enums/extensions/recommendationBlock.js";
2
- import { useRecommendationApi as b } from "../../../../services/recommendationApi.js";
3
- import { useConfigStore as I } from "../../../../stores/config.js";
4
- import { defineStore as R } from "pinia";
5
- import { DEFAULT_CARDS_IN_ROW as k } from "../constants/layout.js";
6
- import { getDefaultProducts as C } from "../templates/utils.js";
7
- import { generateCompleteFilterQuery as h } from "../utils/filterUtil.js";
8
- import { isFilterValid as G } from "../validation/filterSchema.js";
9
- const u = b();
10
- function p() {
1
+ import { RecommendationFeedSourceMaps as S, PriceAttributes as R } from "../../../../enums/extensions/recommendationBlock.js";
2
+ import { useRecommendationApi as k } from "../../../../services/recommendationApi.js";
3
+ import { useConfigStore as y } from "../../../../stores/config.js";
4
+ import { defineStore as C } from "pinia";
5
+ import { DEFAULT_CARDS_IN_ROW as G } from "../constants/layout.js";
6
+ import { EXCLUDED_ALGORITHM_IDS as P } from "../constants/defaultConfig.js";
7
+ import { getDefaultProducts as p } from "../templates/utils.js";
8
+ import { generateCompleteFilterQuery as b } from "../utils/filterUtil.js";
9
+ const h = k();
10
+ let a = null, l = null, u = null;
11
+ function I() {
11
12
  return {
12
- cardsInRow: k,
13
+ cardsInRow: G,
13
14
  currencySettings: {
14
15
  name: "USD",
15
16
  value: "USD",
@@ -33,18 +34,17 @@ function p() {
33
34
  size: "6"
34
35
  };
35
36
  }
36
- function y() {
37
+ function v() {
37
38
  return {
38
- recommendationConfigs: p(),
39
+ recommendationConfigs: I(),
39
40
  recommendationProducts: [],
40
41
  filterStatus: !1,
41
42
  filterSelectionDrawerStatus: !1,
42
43
  filterGroup: 1,
43
- isInitialized: !1,
44
- filterSnapshot: null
44
+ isInitialized: !1
45
45
  };
46
46
  }
47
- const F = () => ({
47
+ const D = () => ({
48
48
  recommendationCampaignUrls: {},
49
49
  activePredictiveAlgorithms: [],
50
50
  languages: {},
@@ -53,8 +53,8 @@ const F = () => ({
53
53
  blockStates: {},
54
54
  currentRecommendationId: null,
55
55
  configVersion: 0
56
- }), V = R("guidoRecommendationExtension", {
57
- state: () => F(),
56
+ }), _ = C("guidoRecommendationExtension", {
57
+ state: () => D(),
58
58
  getters: {
59
59
  // ====================================================================
60
60
  // Proxy Getters — Backward Compatible Access to Current Block State
@@ -64,7 +64,7 @@ const F = () => ({
64
64
  * This allows all existing code that reads `store.recommendationConfigs` to work unchanged.
65
65
  */
66
66
  recommendationConfigs(t) {
67
- return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : p();
67
+ return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : I();
68
68
  },
69
69
  /**
70
70
  * Proxy getter: delegates to blockStates[currentRecommendationId].recommendationProducts
@@ -96,22 +96,14 @@ const F = () => ({
96
96
  hasFilters() {
97
97
  return !!this.recommendationConfigs.filters.length;
98
98
  },
99
- hasValidFilters() {
100
- const { filters: t } = this.recommendationConfigs;
101
- return t.length ? t.every((r) => r.isValid) : !1;
102
- },
103
99
  getFilterGroupCount() {
104
100
  const { filters: t } = this.recommendationConfigs;
105
- return t.length ? new Set(t.map((r) => r.filterGroup)).size : 0;
106
- },
107
- getUniqueFilterGroups() {
108
- const { filters: t } = this.recommendationConfigs;
109
- return [...new Set(t.map((r) => r.filterGroup))].sort((r, e) => r - e);
101
+ return t.length && t[t.length - 1].filterGroup || 0;
110
102
  },
111
103
  getActivePredictiveAlgorithms: (t) => {
112
104
  const r = [];
113
- return t.activePredictiveAlgorithms.forEach((e) => {
114
- r.push(...f.filter((n) => n.id === e));
105
+ return t.activePredictiveAlgorithms.filter((e) => !P.includes(e)).forEach((e) => {
106
+ r.push(...S.filter((n) => n.id === e));
115
107
  }), r.map((e) => ({
116
108
  text: e.name,
117
109
  value: e.key
@@ -127,7 +119,7 @@ const F = () => ({
127
119
  })),
128
120
  getFilterList() {
129
121
  return Object.values(this.filterList).map((t) => {
130
- const r = t.type === "defaultAttribute", e = S.includes(t.attributeName);
122
+ const r = t.type === "defaultAttribute", e = R.includes(t.attributeName);
131
123
  let n = r ? t.attributeName : `product_attributes.${t.attributeName}`;
132
124
  return n = e ? `${n}.${this.recommendationConfigs.currencySettings.value}` : n, {
133
125
  text: t.displayName,
@@ -151,7 +143,7 @@ const F = () => ({
151
143
  setCurrentBlock(t) {
152
144
  this.blockStates[t] || (this.blockStates = {
153
145
  ...this.blockStates,
154
- [t]: y()
146
+ [t]: v()
155
147
  }), this.currentRecommendationId = t;
156
148
  },
157
149
  /**
@@ -191,94 +183,95 @@ const F = () => ({
191
183
  const { triggerRefetch: n = !0 } = r;
192
184
  n && this.configVersion++;
193
185
  },
194
- /**
195
- * Creates a filter with the first available attribute and operator pre-selected.
196
- */
197
- createDefaultFilter(t, r) {
198
- const [e] = this.getFilterList, [n] = g(e == null ? void 0 : e.type);
199
- return {
200
- type: "standardFilter",
201
- attribute: (e == null ? void 0 : e.value) ?? "",
202
- operator: (n == null ? void 0 : n.value) ?? "",
203
- innerGroupOperator: "*",
204
- outerGroupOperator: "*",
205
- filterNumber: r,
206
- filterGroup: t,
207
- isValid: !1,
208
- value: ""
209
- };
210
- },
211
186
  /**
212
187
  * Opens the filter selection drawer for the current block.
213
- * Saves a snapshot of current filters for cancel/revert.
214
- * If no filters exist, initializes with a default filter
188
+ * If no filters exist, initializes with a default empty filter
215
189
  * so the user has a starting point for input.
216
190
  */
217
191
  openFilterDrawer() {
218
192
  if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
219
193
  return;
220
194
  const t = this.blockStates[this.currentRecommendationId];
221
- t.filterSnapshot = JSON.parse(
222
- JSON.stringify(t.recommendationConfigs.filters)
223
- ), t.recommendationConfigs.filters.length || (t.recommendationConfigs.filters = [this.createDefaultFilter(1, 1)]), t.filterSelectionDrawerStatus = !0;
195
+ t.recommendationConfigs.filters.length || (t.recommendationConfigs.filters = [{
196
+ type: "standardFilter",
197
+ attribute: "",
198
+ operatorReplace: "",
199
+ operator: "",
200
+ innerGroupOperator: "*",
201
+ outerGroupOperator: "*",
202
+ filterNumber: 1,
203
+ filterGroup: 1,
204
+ isValid: !1,
205
+ value: ""
206
+ }]), t.filterSelectionDrawerStatus = !0;
224
207
  },
225
208
  /**
226
- * Closes the filter selection drawer for the current block.
227
- * Called after successful apply — discards the snapshot.
209
+ * Closes the filter selection drawer for the current block
228
210
  */
229
211
  closeFilterDrawer() {
230
- if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
231
- return;
232
- const t = this.blockStates[this.currentRecommendationId];
233
- t.filterSnapshot = null, t.filterSelectionDrawerStatus = !1;
234
- },
235
- /**
236
- * Cancels the filter selection drawer and reverts filters
237
- * to the snapshot taken when the drawer was opened.
238
- */
239
- cancelFilterDrawer() {
240
- if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
241
- return;
242
- const t = this.blockStates[this.currentRecommendationId];
243
- t.filterSnapshot !== null && (t.recommendationConfigs.filters = t.filterSnapshot, t.filterSnapshot = null), t.filterSelectionDrawerStatus = !1;
212
+ this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId] || (this.blockStates[this.currentRecommendationId].filterSelectionDrawerStatus = !1);
244
213
  },
245
214
  // ====================================================================
246
215
  // Shared Data Fetching (fetched once, used by all blocks)
247
216
  // ====================================================================
248
217
  async fetchRecommendationCreateData() {
249
- if (this.activePredictiveAlgorithms.length)
250
- return;
251
- const {
252
- activePredictiveAlgorithms: t,
253
- languages: r,
254
- currencies: e
255
- } = await u.fetchRecommendationCreateData();
256
- if (this.activePredictiveAlgorithms = t, this.languages = r, this.currentRecommendationId !== null && this.blockStates[this.currentRecommendationId]) {
257
- const n = this.blockStates[this.currentRecommendationId];
258
- n.filterStatus = !!n.recommendationConfigs.filters.length;
218
+ if (!this.activePredictiveAlgorithms.length) {
219
+ if (a) {
220
+ await a;
221
+ return;
222
+ }
223
+ a = (async () => {
224
+ const {
225
+ activePredictiveAlgorithms: t,
226
+ languages: r,
227
+ currencies: e
228
+ } = await h.fetchRecommendationCreateData();
229
+ if (this.activePredictiveAlgorithms = t, this.languages = r, this.currentRecommendationId !== null && this.blockStates[this.currentRecommendationId]) {
230
+ const n = this.blockStates[this.currentRecommendationId];
231
+ n.filterStatus = !!n.recommendationConfigs.filters.length;
232
+ }
233
+ this.currencyList = e;
234
+ })();
235
+ try {
236
+ await a;
237
+ } finally {
238
+ a = null;
239
+ }
259
240
  }
260
- this.currencyList = e;
261
241
  },
262
242
  async fetchRecommendationFilters() {
263
- const t = await u.fetchRecommendationFilters();
264
- this.filterList = t;
243
+ if (!Object.keys(this.filterList).length) {
244
+ if (l) {
245
+ await l;
246
+ return;
247
+ }
248
+ l = (async () => {
249
+ const t = await h.fetchRecommendationFilters();
250
+ this.filterList = t;
251
+ })();
252
+ try {
253
+ await l;
254
+ } finally {
255
+ l = null;
256
+ }
257
+ }
265
258
  },
266
259
  // ====================================================================
267
260
  // Per-Block Filter Actions
268
261
  // ====================================================================
269
262
  addFilterGroup(t) {
270
- this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId] || this.blockStates[this.currentRecommendationId].recommendationConfigs.filters.push(
271
- this.createDefaultFilter(t, 1)
272
- );
273
- },
274
- deleteFilterGroup(t) {
275
- if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
276
- return;
277
- const r = this.blockStates[this.currentRecommendationId], e = r.recommendationConfigs.filters.filter((i) => i.filterGroup !== t), n = [...new Set(e.map((i) => i.filterGroup))].sort((i, o) => i - o), c = new Map(n.map((i, o) => [i, o + 1]));
278
- r.recommendationConfigs.filters = e.map((i) => ({
279
- ...i,
280
- filterGroup: c.get(i.filterGroup) ?? i.filterGroup
281
- }));
263
+ this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId] || this.blockStates[this.currentRecommendationId].recommendationConfigs.filters.push({
264
+ type: "standardFilter",
265
+ attribute: "",
266
+ operatorReplace: "",
267
+ operator: "",
268
+ innerGroupOperator: "",
269
+ outerGroupOperator: "",
270
+ value: "",
271
+ filterNumber: 1,
272
+ isValid: !0,
273
+ filterGroup: t
274
+ });
282
275
  },
283
276
  updateFilter(t) {
284
277
  if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
@@ -286,10 +279,7 @@ const F = () => ({
286
279
  const r = this.blockStates[this.currentRecommendationId], e = r.recommendationConfigs.filters.findIndex((n) => n.filterNumber === t.filterNumber && n.filterGroup === t.filterGroup);
287
280
  if (e !== -1) {
288
281
  const n = [...r.recommendationConfigs.filters];
289
- n[e] = {
290
- ...t,
291
- isValid: G(t)
292
- }, r.recommendationConfigs.filters = n;
282
+ n[e] = t, t.value.length && t.operator && t.attribute && t.innerGroupOperator && t.outerGroupOperator ? n[e].isValid = !0 : n[e].isValid = !1, r.recommendationConfigs.filters = n;
293
283
  }
294
284
  },
295
285
  deleteFilter(t) {
@@ -297,45 +287,47 @@ const F = () => ({
297
287
  return;
298
288
  const r = this.blockStates[this.currentRecommendationId], e = [...r.recommendationConfigs.filters].findIndex((n) => n.filterNumber === t.filterNumber && n.filterGroup === t.filterGroup);
299
289
  if (e !== -1) {
300
- let n = [...r.recommendationConfigs.filters];
301
- if (n.splice(e, 1), n.some((i) => i.filterGroup === t.filterGroup)) {
302
- let i = 1;
303
- n = n.map((o) => o.filterGroup === t.filterGroup ? { ...o, filterNumber: i++ } : o);
304
- } else {
305
- const i = [...new Set(n.map((s) => s.filterGroup))].sort((s, a) => s - a), o = new Map(i.map((s, a) => [s, a + 1]));
306
- n = n.map((s) => ({
307
- ...s,
308
- filterGroup: o.get(s.filterGroup) ?? s.filterGroup
309
- }));
310
- }
311
- r.recommendationConfigs.filters = n;
290
+ const n = [...r.recommendationConfigs.filters];
291
+ n.splice(e, 1), r.recommendationConfigs.filters = n;
312
292
  }
313
293
  },
314
294
  addFilter(t) {
315
295
  if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
316
296
  return;
317
- const r = this.blockStates[this.currentRecommendationId], e = [...r.recommendationConfigs.filters], c = e.filter(
297
+ const r = this.blockStates[this.currentRecommendationId], e = [...r.recommendationConfigs.filters], s = e.filter(
318
298
  (o) => o.filterGroup === t.filterGroup
319
- ).length + 1, i = e.findLastIndex((o) => o.filterGroup === t.filterGroup);
320
- i !== -1 ? e.splice(i + 1, 0, {
299
+ ).length + 1, m = e.findLastIndex((o) => o.filterGroup === t.filterGroup);
300
+ m !== -1 ? e.splice(m + 1, 0, {
321
301
  ...t,
322
- filterNumber: c
302
+ filterNumber: s
323
303
  }) : e.push({
324
304
  ...t,
325
- filterNumber: c
305
+ filterNumber: s
326
306
  }), r.recommendationConfigs.filters = e;
327
307
  },
328
308
  generateFilterQuery() {
329
- return h(this.recommendationConfigs.filters);
309
+ return b(this.recommendationConfigs.filters);
330
310
  },
331
311
  // ====================================================================
332
312
  // Per-Block Product Fetching
333
313
  // ====================================================================
334
314
  async fetchRecommendationProducts() {
335
- var d;
336
- if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
337
- return;
338
- const t = this.currentRecommendationId, r = this.blockStates[t], { recommendationConfigs: e } = r, n = e.filters.filter((m) => m.isValid), c = h(n), i = ((d = f.find((m) => m.key === e.strategy)) == null ? void 0 : d.path) || "", o = I(), s = {
315
+ if (!(this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])) {
316
+ if (u) {
317
+ await u;
318
+ return;
319
+ }
320
+ u = this._doFetchProducts();
321
+ try {
322
+ await u;
323
+ } finally {
324
+ u = null;
325
+ }
326
+ }
327
+ },
328
+ async _doFetchProducts() {
329
+ var g;
330
+ const t = this.currentRecommendationId, r = this.blockStates[t], { recommendationConfigs: e } = r, n = e.filters.filter((i) => i.isValid), s = b(n), m = ((g = S.find((i) => i.key === e.strategy)) == null ? void 0 : g.path) || "", o = y(), c = {
339
331
  locale: e.language,
340
332
  currency: e.currencySettings.value,
341
333
  partnerName: o.partnerName,
@@ -343,18 +335,21 @@ const F = () => ({
343
335
  details: !0,
344
336
  campaignId: o.variationId
345
337
  };
346
- e.strategy === "manualMerchandising" ? s.productId = e.productIds.join(",") : e.strategy === "similarViewed" && (s.productId = "{itemId}"), c && (s.filter = c), e.shuffleProducts && (s.shuffle = !0);
347
- const a = parseInt(e.size) || 6;
348
- let l;
338
+ e.strategy === "manualMerchandising" ? c.productId = e.productIds.join(",") : e.strategy === "similarViewed" && (c.productId = "{itemId}"), e.strategy === "userBased" && (c.userId = "{user_id}"), s && (c.filter = s), e.shuffleProducts && (c.shuffle = !0);
339
+ const f = parseInt(e.size) || 6;
340
+ let d;
349
341
  try {
350
- l = await u.fetchRecommendationProducts(i, s);
342
+ d = await h.fetchRecommendationProducts(m, c);
351
343
  } catch {
352
- l = [];
344
+ d = [];
345
+ }
346
+ if (this.blockStates[t]) {
347
+ const i = d.length > 0 ? d : p(f);
348
+ this.blockStates[t].recommendationProducts = i.length < f ? [...i, ...p(f - i.length)] : i;
353
349
  }
354
- this.blockStates[t] && (this.blockStates[t].recommendationProducts = l.length > 0 ? l : C(a));
355
350
  }
356
351
  }
357
352
  });
358
353
  export {
359
- V as useRecommendationExtensionStore
354
+ _ as useRecommendationExtensionStore
360
355
  };
@@ -1,22 +1,22 @@
1
1
  function l(t) {
2
2
  if (t.length === 0)
3
3
  return "";
4
- const o = t.sort((r, e) => r.filterNumber - e.filterNumber), n = o.map((r) => `[${r.attribute}][${r.operator}][${r.value}]`), [p, ...i] = n;
5
- let u = p;
6
- for (let r = 0; r < i.length; r++) {
7
- const e = o[r].innerGroupOperator;
8
- u += `${e}${i[r]}`;
4
+ const o = t.sort((r, e) => r.filterNumber - e.filterNumber), n = o.map((r) => `[${r.attribute}][${r.operatorReplace}][${r.value}]`), [i, ...p] = n;
5
+ let u = i;
6
+ for (let r = 0; r < p.length; r++) {
7
+ const e = o[r + 1].innerGroupOperator;
8
+ u += `${e}${p[r]}`;
9
9
  }
10
10
  return `(${u})`;
11
11
  }
12
12
  function f(t) {
13
13
  if (!t || t.length === 0)
14
14
  return "";
15
- const o = t.reduce((r, e) => (r[e.filterGroup] || (r[e.filterGroup] = []), r[e.filterGroup].push(e), r), {}), n = Object.keys(o).map(Number).sort((r, e) => r - e), p = n.map((r) => {
15
+ const o = t.reduce((r, e) => (r[e.filterGroup] || (r[e.filterGroup] = []), r[e.filterGroup].push(e), r), {}), n = Object.keys(o).map(Number).sort((r, e) => r - e), i = n.map((r) => {
16
16
  const e = o[r];
17
17
  return l(e);
18
- }), [i, ...u] = p;
19
- let s = i;
18
+ }), [p, ...u] = i;
19
+ let s = p;
20
20
  for (let r = 0; r < u.length; r++) {
21
21
  const e = n[r + 1], c = o[e][0].outerGroupOperator;
22
22
  s += `${c}${u[r]}`;
@@ -1,17 +1,17 @@
1
1
  var d = Object.defineProperty;
2
- var _ = (n, i, e) => i in n ? d(n, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[i] = e;
3
- var u = (n, i, e) => _(n, typeof i != "symbol" ? i + "" : i, e);
2
+ var h = (n, i, e) => i in n ? d(n, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[i] = e;
3
+ var u = (n, i, e) => h(n, typeof i != "symbol" ? i + "" : i, e);
4
4
  import { PAGE_TYPES as E } from "../../../enums/unsubscribe.js";
5
5
  import { useUnsubscribeStore as c } from "../../../stores/unsubscribe.js";
6
- import { Block as h, BlockCompositionType as S, ModificationDescription as b } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
6
+ import { Block as _, BlockCompositionType as S, ModificationDescription as b } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
7
7
  import { getDefaultTemplate as L } from "./template.js";
8
8
  import { UNSUBSCRIBE_EVENTS as a, DATA_ATTRIBUTES as o } from "./utils/constants.js";
9
9
  import { parsePageList as p } from "./utils/utils.js";
10
- const g = "unsubscribe-block", v = 'a[data-unsubscribe-link="true"]', f = ".unsubscribe-block-v2", B = "{{ins-unsubscribe-link}}", T = {
10
+ const v = "unsubscribe-block", g = 'a[data-unsubscribe-link="true"]', f = ".unsubscribe-block-v2", T = "{{ins-unsubscribe-link}}", B = {
11
11
  [E.GLOBAL_UNSUBSCRIBE]: "{{ins-global-unsubscribe-link}}",
12
12
  [E.SUBSCRIPTION_PREFERENCE_CENTER]: "{{ins-preferences-unsubscribe-link}}"
13
13
  };
14
- class R extends h {
14
+ class R extends _ {
15
15
  constructor() {
16
16
  super();
17
17
  u(this, "selectEventListener", null);
@@ -19,7 +19,7 @@ class R extends h {
19
19
  u(this, "currentNode");
20
20
  }
21
21
  getId() {
22
- return g;
22
+ return v;
23
23
  }
24
24
  getIcon() {
25
25
  return "unsubscribe-icon";
@@ -47,8 +47,8 @@ class R extends h {
47
47
  }
48
48
  _setupSelectEventListener() {
49
49
  this._removeSelectEventListener(), this.selectEventListener = (e) => {
50
- const s = e, { collectionType: t, selectedPages: r } = s.detail;
51
- this._updateBlock(t, r.join(","));
50
+ const r = e, { collectionType: s, selectedPages: t } = r.detail;
51
+ this._updateBlock(s, t.join(","));
52
52
  }, document.addEventListener(a.SELECT, this.selectEventListener);
53
53
  }
54
54
  _removeSelectEventListener() {
@@ -74,17 +74,17 @@ class R extends h {
74
74
  _removeEventListeners() {
75
75
  this._removeSelectEventListener(), this._removeCancelEventListener();
76
76
  }
77
- _updateBlock(e, s) {
77
+ _updateBlock(e, r) {
78
78
  if (!this.currentNode || !("querySelector" in this.currentNode))
79
79
  return;
80
- const t = this.currentNode.querySelector(v);
81
- if (!t)
80
+ const s = this.currentNode.querySelector(g);
81
+ if (!s)
82
82
  return;
83
- const r = this._getMergeTag(e);
84
- this.api.getDocumentModifier().modifyHtml(t).setAttribute("href", r).apply(new b(`Updated unsubscribe link to ${r}`)), this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(o.PAGE_TYPE, e.toString()).setAttribute(o.PAGE_LIST, s).apply(new b("Updated unsubscribe block metadata"));
83
+ const t = this._getMergeTag(e);
84
+ this.api.getDocumentModifier().modifyHtml(s).setAttribute("href", t).apply(new b(`Updated unsubscribe link to ${t}`)), this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(o.PAGE_TYPE, e.toString()).setAttribute(o.PAGE_LIST, r).apply(new b("Updated unsubscribe block metadata"));
85
85
  }
86
86
  _getMergeTag(e) {
87
- return T[e] ?? B;
87
+ return B[e] ?? T;
88
88
  }
89
89
  _openDrawer() {
90
90
  if (!(this.currentNode && this.currentNode.getAttribute("data-unsubscribe-page-type")))
@@ -97,24 +97,24 @@ class R extends h {
97
97
  }
98
98
  _checkExistingBlocks() {
99
99
  const e = c();
100
- e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(f).forEach((t) => {
101
- if ("getAttribute" in t) {
102
- const r = t.getAttribute(o.PAGE_TYPE);
103
- if (r) {
104
- const l = Number(r);
100
+ e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(f).forEach((s) => {
101
+ if ("getAttribute" in s) {
102
+ const t = s.getAttribute(o.PAGE_TYPE);
103
+ if (t) {
104
+ const l = Number(t);
105
105
  l === E.GLOBAL_UNSUBSCRIBE ? e.isGlobalUnsubscribeDisabled = !0 : l === E.SUBSCRIPTION_PREFERENCE_CENTER && (e.isSubscriptionPreferencesCenterDisabled = !0);
106
106
  }
107
107
  }
108
108
  });
109
109
  }
110
- _loadBlockState(e) {
110
+ async _loadBlockState(e) {
111
111
  if (!("getAttribute" in e))
112
112
  return;
113
- const s = e.getAttribute(o.PAGE_TYPE), t = e.getAttribute(o.PAGE_LIST);
114
- if (!s || !t)
113
+ const r = e.getAttribute(o.PAGE_TYPE), s = e.getAttribute(o.PAGE_LIST);
114
+ if (!r || !s)
115
115
  return;
116
- const r = c(), l = Number(s), m = p(t);
117
- r.setCollectionWithoutAutoSelection(l), r.loadSelectedTemplates(m);
116
+ const t = c(), l = Number(r), m = p(s);
117
+ await t.fetchTemplates(), t.setCollectionWithoutAutoSelection(l), t.loadSelectedTemplates(m);
118
118
  }
119
119
  _resetStoreState() {
120
120
  c().$reset();
@@ -122,14 +122,14 @@ class R extends h {
122
122
  _removeBlockTemplatesFromStore(e) {
123
123
  if (!("getAttribute" in e))
124
124
  return;
125
- const s = e.getAttribute(o.PAGE_LIST);
126
- if (!s)
125
+ const r = e.getAttribute(o.PAGE_LIST);
126
+ if (!r)
127
127
  return;
128
- const t = c(), r = p(s);
129
- t.removeUnsubscribePages(r);
128
+ const s = c(), t = p(r);
129
+ s.removeUnsubscribePages(t);
130
130
  }
131
131
  }
132
132
  export {
133
- g as UNSUBSCRIBE_BLOCK_ID,
133
+ v as UNSUBSCRIBE_BLOCK_ID,
134
134
  R as UnsubscribeBlock
135
135
  };
@@ -1,18 +1,18 @@
1
- var h = Object.defineProperty;
2
- var d = (a, s, e) => s in a ? h(a, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[s] = e;
3
- var u = (a, s, e) => d(a, typeof s != "symbol" ? s + "" : s, e);
1
+ var d = Object.defineProperty;
2
+ var h = (a, s, e) => s in a ? d(a, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[s] = e;
3
+ var u = (a, s, e) => h(a, typeof s != "symbol" ? s + "" : s, e);
4
4
  import { useUnsubscribeStore as l } from "../../../stores/unsubscribe.js";
5
5
  import { Control as T, UEAttr as i, UIElementType as n } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
6
6
  import { DATA_ATTRIBUTES as p } from "./utils/constants.js";
7
7
  import { parsePageList as _ } from "./utils/utils.js";
8
- const g = "ui-elements-unsubscribe", r = {
8
+ const v = "ui-elements-unsubscribe", r = {
9
9
  SELECT_BUTTON: "selectTemplateButton",
10
10
  PREV_BUTTON: "prevButton",
11
11
  NEXT_BUTTON: "nextButton",
12
12
  COUNTER_TEXT: "counterText",
13
13
  PREVIEW_IMAGE: "previewImage"
14
14
  };
15
- class N extends T {
15
+ class B extends T {
16
16
  constructor() {
17
17
  super(...arguments);
18
18
  u(this, "currentPreviewIndex", 0);
@@ -22,7 +22,7 @@ class N extends T {
22
22
  u(this, "lastParsedAttribute");
23
23
  }
24
24
  getId() {
25
- return g;
25
+ return v;
26
26
  }
27
27
  getTemplate() {
28
28
  return `
@@ -35,7 +35,7 @@ class N extends T {
35
35
  onTemplateNodeUpdated(e) {
36
36
  if (this.currentNode = e, "getAttribute" in this.currentNode) {
37
37
  const t = this.currentNode.getAttribute(p.PAGE_LIST);
38
- t && (t !== this.lastParsedAttribute && (this.currentPages = _(t), this.lastParsedAttribute = t, this.currentPreviewIndex = 0), this._updatePreview(), this._updateCounter());
38
+ t && (t !== this.lastParsedAttribute && (this.currentPages = _(t), this.lastParsedAttribute = t, this.currentPreviewIndex = 0), this._updateCounter(), this._loadAndUpdatePreview());
39
39
  }
40
40
  }
41
41
  onRender() {
@@ -73,6 +73,9 @@ class N extends T {
73
73
  _onNextClick() {
74
74
  this.currentPreviewIndex < this.totalTemplates - 1 && (this.currentPreviewIndex++, this._updatePreview(), this._updateCounter());
75
75
  }
76
+ async _loadAndUpdatePreview() {
77
+ await l().fetchTemplates(), this._updatePreview(), this._updateCounter();
78
+ }
76
79
  _updatePreview() {
77
80
  var e;
78
81
  if ((e = this.currentPages) != null && e.length)
@@ -162,6 +165,6 @@ class N extends T {
162
165
  }
163
166
  }
164
167
  export {
165
- g as UNSUBSCRIBE_CONTROL_ID,
166
- N as UnsubscribeControl
168
+ v as UNSUBSCRIBE_CONTROL_ID,
169
+ B as UnsubscribeControl
167
170
  };
@@ -1,12 +1,12 @@
1
- var r = Object.defineProperty;
2
- var n = (i, t, e) => t in i ? r(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
3
- var s = (i, t, e) => n(i, typeof t != "symbol" ? t + "" : t, e);
4
- import { UIElement as m } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- const E = "unsubscribe-preview", l = "img", c = "Unsubscribe page preview";
6
- class o extends m {
1
+ var n = Object.defineProperty;
2
+ var m = (s, i, e) => i in s ? n(s, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[i] = e;
3
+ var r = (s, i, e) => m(s, typeof i != "symbol" ? i + "" : i, e);
4
+ import { UIElement as l } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ const E = "unsubscribe-preview", c = "img", a = "Unsubscribe page preview", g = "is-loaded";
6
+ class d extends l {
7
7
  constructor() {
8
8
  super(...arguments);
9
- s(this, "imgElement");
9
+ r(this, "imgElement");
10
10
  }
11
11
  getId() {
12
12
  return E;
@@ -14,19 +14,21 @@ class o extends m {
14
14
  getTemplate() {
15
15
  return `
16
16
  <div class="unsubscribe-preview-image-container">
17
+ <div class="unsubscribe-preview-loader"></div>
17
18
  <img
18
19
  src=""
19
- alt="${c}"
20
+ alt="${a}"
20
21
  class="unsubscribe-preview-image"
21
22
  />
22
23
  </div>
23
24
  `;
24
25
  }
25
26
  onRender(e) {
26
- this.imgElement = e.querySelector(l);
27
+ this.imgElement = e.querySelector(c);
27
28
  }
28
29
  setValue(e) {
29
- this.imgElement && (this.imgElement.src = e);
30
+ var t;
31
+ this.imgElement && (this.imgElement.src = e, (t = this.imgElement.parentElement) == null || t.classList.add(g));
30
32
  }
31
33
  getValue() {
32
34
  var e;
@@ -38,5 +40,5 @@ class o extends m {
38
40
  }
39
41
  export {
40
42
  E as PREVIEW_UI_ELEMENT_ID,
41
- o as PreviewUIElement
43
+ d as PreviewUIElement
42
44
  };