@useinsider/guido 2.1.0-beta.6df87d7 → 2.1.0-beta.73f314b

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 (38) hide show
  1. package/README.md +36 -0
  2. package/dist/@types/config/schemas.js +70 -65
  3. package/dist/components/Guido.vue.js +1 -1
  4. package/dist/components/Guido.vue2.js +69 -58
  5. package/dist/components/organisms/extensions/recommendation/FilterItem.vue.js +11 -13
  6. package/dist/components/organisms/extensions/recommendation/FilterItem.vue2.js +55 -24
  7. package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue.js +3 -3
  8. package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue2.js +34 -21
  9. package/dist/components/organisms/extensions/recommendation/Filters.vue.js +11 -11
  10. package/dist/components/organisms/extensions/recommendation/Filters.vue2.js +44 -34
  11. package/dist/composables/useBlocksConfig.js +26 -16
  12. package/dist/composables/useHtmlValidator.js +107 -119
  13. package/dist/config/compiler/utils/recommendationCompilerUtils.js +27 -22
  14. package/dist/config/migrator/itemsBlockMigrator.js +101 -97
  15. package/dist/enums/defaults.js +8 -4
  16. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +117 -66
  17. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +95 -61
  18. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +25 -30
  19. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +20 -25
  20. package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +8 -8
  21. package/dist/extensions/Blocks/Recommendation/validation/filterSchema.js +29 -0
  22. package/dist/extensions/ModulesTabIcons/extension.js +17 -0
  23. package/dist/guido.css +1 -1
  24. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +204 -136
  25. package/dist/services/stripoApi.js +20 -17
  26. package/dist/src/@types/config/schemas.d.ts +8 -0
  27. package/dist/src/components/organisms/extensions/recommendation/FilterItem.vue.d.ts +1 -0
  28. package/dist/src/components/organisms/extensions/recommendation/Filters.vue.d.ts +15 -1
  29. package/dist/src/composables/useConfig.d.ts +4 -0
  30. package/dist/src/enums/defaults.d.ts +4 -0
  31. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +17 -0
  32. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +18 -2
  33. package/dist/src/extensions/Blocks/Recommendation/validation/filterSchema.d.ts +15 -0
  34. package/dist/src/extensions/ModulesTabIcons/extension.d.ts +2 -0
  35. package/dist/src/stores/config.d.ts +36 -0
  36. package/dist/static/templates/empty/index.html.js +74 -0
  37. package/dist/static/templates/empty/style.css.js +779 -0
  38. package/package.json +1 -1
@@ -1,8 +1,8 @@
1
1
  var B = Object.defineProperty;
2
- var U = (r, t, e) => t in r ? B(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
- var M = (r, t, e) => U(r, typeof t != "symbol" ? t + "" : t, e);
2
+ var U = (e, t, r) => t in e ? B(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var M = (e, t, r) => U(e, typeof t != "symbol" ? t + "" : t, r);
4
4
  import { productPairs as v } from "../../extensions/Blocks/Items/enums/productEnums.js";
5
- import { ItemInCartOptions as E, DefaultConfigValues as g, SETTINGS_ENUMS as d } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
5
+ import { ItemInCartOptions as E, DefaultConfigValues as g, SETTINGS_ENUMS as u } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
6
6
  import { getDefaultTemplate as K } from "../../extensions/Blocks/Items/template.js";
7
7
  const w = {
8
8
  img: {
@@ -74,76 +74,76 @@ const w = {
74
74
  function F() {
75
75
  return String(Date.now() + Math.floor(Math.random() * 1e3));
76
76
  }
77
- function q(r) {
78
- return r ? {
79
- CartItems: d.ITEMS_TYPE.CART_ITEMS,
80
- BrowsedItems: d.ITEMS_TYPE.BROWSED_ITEMS,
81
- PurchasedItems: d.ITEMS_TYPE.PURCHASED_ITEMS,
82
- CART_ITEMS: d.ITEMS_TYPE.CART_ITEMS,
83
- BROWSED_ITEMS: d.ITEMS_TYPE.BROWSED_ITEMS,
84
- PURCHASED_ITEMS: d.ITEMS_TYPE.PURCHASED_ITEMS
85
- }[r] || d.ITEMS_TYPE.CART_ITEMS : d.ITEMS_TYPE.CART_ITEMS;
77
+ function q(e) {
78
+ return e ? {
79
+ CartItems: u.ITEMS_TYPE.CART_ITEMS,
80
+ BrowsedItems: u.ITEMS_TYPE.BROWSED_ITEMS,
81
+ PurchasedItems: u.ITEMS_TYPE.PURCHASED_ITEMS,
82
+ CART_ITEMS: u.ITEMS_TYPE.CART_ITEMS,
83
+ BROWSED_ITEMS: u.ITEMS_TYPE.BROWSED_ITEMS,
84
+ PURCHASED_ITEMS: u.ITEMS_TYPE.PURCHASED_ITEMS
85
+ }[e] || u.ITEMS_TYPE.CART_ITEMS : u.ITEMS_TYPE.CART_ITEMS;
86
86
  }
87
- function R(r) {
88
- const t = (a, o) => a == null ? o : a === "1" || a === "true", e = (a, o) => a || o, i = r["data-type"] || r["data-source"], l = q(i);
89
- let n = r["data-cart_items_select_control_value"] || g.cartItemsSelectControlValue;
87
+ function R(e) {
88
+ const t = (a, o) => a == null ? o : a === "1" || a === "true", r = (a, o) => a || o, c = e["data-type"] || e["data-source"], i = q(c);
89
+ let n = e["data-cart_items_select_control_value"] || g.cartItemsSelectControlValue;
90
90
  if (n && !n.includes("{{") && /^\d+$/.test(n)) {
91
- const a = parseInt(n) - 1, o = E[l];
91
+ const a = parseInt(n) - 1, o = E[i];
92
92
  o && o[a] && (n = o[a].value);
93
93
  }
94
94
  return {
95
95
  initialized: !0,
96
- blockInstanceId: e(r["data-block-instance-id"], F()),
97
- source: l,
98
- type: l,
96
+ blockInstanceId: r(e["data-block-instance-id"], F()),
97
+ source: i,
98
+ type: i,
99
99
  itemsSelectValue: n,
100
- orientation: r["data-card_orientation_control_value"] || d.ORIENTATION.VERTICAL,
101
- nameTrimming: t(r["data-product_name_control_trim"], !0),
102
- priceHideDiscount: t(r["data-product_price_control_nodup"], !0),
103
- priceFormatted: t(r["data-product_price_control_formated"], !0),
104
- priceSinglePrice: t(r["data-product_price_control_single_price"], !1),
105
- priceCurrencySymbol: e(
106
- r["data-product_price_control_currency_symbol"],
100
+ orientation: e["data-card_orientation_control_value"] || u.ORIENTATION.VERTICAL,
101
+ nameTrimming: t(e["data-product_name_control_trim"], !0),
102
+ priceHideDiscount: t(e["data-product_price_control_nodup"], !0),
103
+ priceFormatted: t(e["data-product_price_control_formated"], !0),
104
+ priceSinglePrice: t(e["data-product_price_control_single_price"], !1),
105
+ priceCurrencySymbol: r(
106
+ e["data-product_price_control_currency_symbol"],
107
107
  g.productPriceCurrencySymbolControlValue
108
108
  ),
109
- priceCurrencyLocation: e(
110
- r["data-product_price_currency_location"],
109
+ priceCurrencyLocation: r(
110
+ e["data-product_price_currency_location"],
111
111
  g.productPriceCurrencyLocationControlValue
112
112
  ),
113
- priceOrientation: r["data-product_original_price_control_orientation"] || "horizontal",
114
- quantityControlEnabled: t(r["data-product_quantity_control_enabled"], !0),
115
- buttonLink: e(r["data-product_button_link"], g.productButtonLinkControlValue),
116
- imageLink: e(r["data-product_image_link"], g.productImageLinkControlValue),
117
- buttonLabel: e(r["data-product_button_control_label"], "Buy"),
118
- buttonFullWidth: t(r["data-product_button_control_atw"], !0),
119
- imageVisible: t(r["data-product_image_control_enabled"], !0),
120
- nameVisible: t(r["data-product_name_control_enabled"], !0),
121
- quantityVisible: t(r["data-product_quantity_control_enabled"], !0),
122
- priceVisible: t(r["data-product_price_control_enabled"], !0),
123
- originalPriceVisible: t(r["data-product_original_price_control_enabled"], !0),
124
- buttonVisible: t(r["data-product_button_control_enabled"], !0)
113
+ priceOrientation: e["data-product_original_price_control_orientation"] || "horizontal",
114
+ quantityControlEnabled: t(e["data-product_quantity_control_enabled"], !0),
115
+ buttonLink: r(e["data-product_button_link"], g.productButtonLinkControlValue),
116
+ imageLink: r(e["data-product_image_link"], g.productImageLinkControlValue),
117
+ buttonLabel: r(e["data-product_button_control_label"], "Buy"),
118
+ buttonFullWidth: t(e["data-product_button_control_atw"], !0),
119
+ imageVisible: t(e["data-product_image_control_enabled"], !0),
120
+ nameVisible: t(e["data-product_name_control_enabled"], !0),
121
+ quantityVisible: t(e["data-product_quantity_control_enabled"], !0),
122
+ priceVisible: t(e["data-product_price_control_enabled"], !0),
123
+ originalPriceVisible: t(e["data-product_original_price_control_enabled"], !0),
124
+ buttonVisible: t(e["data-product_button_control_enabled"], !0)
125
125
  };
126
126
  }
127
- const $ = {
127
+ const O = {
128
128
  ins_apr: "CART_ITEMS",
129
129
  browsed_item: "BROWSED_ITEMS",
130
130
  purchased_item: "PURCHASED_ITEMS"
131
131
  };
132
- function x(r, t) {
133
- const e = {
132
+ function $(e, t) {
133
+ const r = {
134
134
  CART_ITEMS: `{{Abandoned Cart Item (${t}) Image}}`,
135
135
  BROWSED_ITEMS: `{{Browsed Item (${t}) Image}}`,
136
136
  PURCHASED_ITEMS: `{{Purchased Item (${t}) Image}}`
137
137
  };
138
- return e[r] || e.CART_ITEMS;
138
+ return r[e] || r.CART_ITEMS;
139
139
  }
140
- function O(r, t) {
141
- const e = {
140
+ function x(e, t) {
141
+ const r = {
142
142
  CART_ITEMS: `{{Abandoned Cart Item (${t}) Url}}`,
143
143
  BROWSED_ITEMS: `{{Browsed Item (${t}) Url}}`,
144
144
  PURCHASED_ITEMS: `{{Purchased Item (${t}) Url}}`
145
145
  };
146
- return e[r] || e.CART_ITEMS;
146
+ return r[e] || r.CART_ITEMS;
147
147
  }
148
148
  class V {
149
149
  constructor() {
@@ -152,12 +152,12 @@ class V {
152
152
  }
153
153
  migrate(t) {
154
154
  try {
155
- let e = this.removeJinjaConditionals(t);
156
- e = this.replaceTemplateVariables(e);
157
- const i = this.parser.parseFromString(e, "text/html"), l = i.querySelectorAll(
155
+ let r = this.removeJinjaConditionals(t);
156
+ r = this.replaceTemplateVariables(r);
157
+ const c = this.parser.parseFromString(r, "text/html"), i = c.querySelectorAll(
158
158
  "td.esd-cart-items-block, td.esd-browsed-items-block, td.esd-purchased-items-block"
159
159
  );
160
- return l.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), e) : (l.forEach((n) => {
160
+ return i.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), r) : (i.forEach((n) => {
161
161
  const a = this.extractConfiguration(n), o = K({
162
162
  orientation: a.orientation,
163
163
  itemsType: a.itemsType,
@@ -173,19 +173,19 @@ class V {
173
173
  originalPriceStyles: a.originalPriceStyles,
174
174
  quantityStyles: a.quantityStyles,
175
175
  nodeConfig: R(a.configBlockAttributes)
176
- }), c = this.parser.parseFromString(
176
+ }), l = this.parser.parseFromString(
177
177
  `<table><tbody><tr>${o}</tr></tbody></table>`,
178
178
  "text/html"
179
179
  ).querySelector("td");
180
- if (c && n.parentNode) {
180
+ if (l && n.parentNode) {
181
181
  const f = R(a.configBlockAttributes);
182
- c.setAttribute("esd-ext-config", JSON.stringify(f));
183
- const u = c.querySelector("esd-config-block");
184
- u && u.remove(), n.parentNode.replaceChild(c, n);
182
+ l.setAttribute("esd-ext-config", JSON.stringify(f));
183
+ const d = l.querySelector("esd-config-block");
184
+ d && d.remove(), n.parentNode.replaceChild(l, n);
185
185
  }
186
- }), i.documentElement.outerHTML);
187
- } catch (e) {
188
- return console.error("ItemsBlockMigrator failed:", e), t;
186
+ }), c.documentElement.outerHTML);
187
+ } catch (r) {
188
+ return console.error("ItemsBlockMigrator failed:", r), t;
189
189
  }
190
190
  }
191
191
  /**
@@ -196,22 +196,22 @@ class V {
196
196
  */
197
197
  extractConfiguration(t) {
198
198
  var C, D, P;
199
- const e = ((C = t.querySelector("[data-type]")) == null ? void 0 : C.getAttribute("data-type")) || "CART_ITEMS", i = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", l = parseInt(i) - 1, n = E[e], a = ((P = n == null ? void 0 : n[l]) == null ? void 0 : P.value) || n[0].value, o = t.querySelector('[product-attr="price"]'), _ = (o == null ? void 0 : o.getAttribute("data-currency_symbol")) || "USD", f = ((o == null ? void 0 : o.getAttribute("data-curency")) || "before") === "after" ? "1" : "0", u = (o == null ? void 0 : o.getAttribute("data-formated")) !== "false", s = this.extractConfigBlockAttributes(t, e, i), b = s["data-card_orientation_control_value"];
200
- let S;
201
- b ? S = b === "horizontal" ? "horizontal" : "vertical" : S = t.querySelector('[colspan="2"]') !== null ? "vertical" : "horizontal";
202
- const p = t.querySelector('a[product-attr="name"]'), T = (p == null ? void 0 : p.getAttribute("style")) || void 0, y = t.querySelector('a[product-attr="button"]'), m = (y == null ? void 0 : y.getAttribute("style")) || void 0, k = (o == null ? void 0 : o.getAttribute("style")) || void 0, I = t.querySelector("p.original-price"), h = (I == null ? void 0 : I.getAttribute("style")) || void 0, A = t.querySelector('[product-attr="quantity"]'), L = (A == null ? void 0 : A.getAttribute("style")) || void 0;
199
+ const r = ((C = t.querySelector("[data-type]")) == null ? void 0 : C.getAttribute("data-type")) || "CART_ITEMS", c = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", i = parseInt(c) - 1, n = E[r], a = ((P = n == null ? void 0 : n[i]) == null ? void 0 : P.value) || n[0].value, o = t.querySelector('[product-attr="price"]'), _ = (o == null ? void 0 : o.getAttribute("data-currency_symbol")) || "USD", f = ((o == null ? void 0 : o.getAttribute("data-curency")) || "before") === "after" ? "1" : "0", d = (o == null ? void 0 : o.getAttribute("data-formated")) !== "false", s = this.extractConfigBlockAttributes(t, r, c), S = s["data-card_orientation_control_value"];
200
+ let b;
201
+ S ? b = S === "horizontal" ? "horizontal" : "vertical" : b = t.querySelector('[colspan="2"]') !== null ? "vertical" : "horizontal";
202
+ const p = t.querySelector('a[product-attr="name"]'), I = (p == null ? void 0 : p.getAttribute("style")) || void 0, y = t.querySelector('a[product-attr="button"]'), m = (y == null ? void 0 : y.getAttribute("style")) || void 0, h = (o == null ? void 0 : o.getAttribute("style")) || void 0, T = t.querySelector("p.original-price"), k = (T == null ? void 0 : T.getAttribute("style")) || void 0, A = t.querySelector('[product-attr="quantity"]'), L = (A == null ? void 0 : A.getAttribute("style")) || void 0;
203
203
  return {
204
- orientation: S,
205
- itemsType: e,
204
+ orientation: b,
205
+ itemsType: r,
206
206
  itemId: a,
207
207
  currencySymbol: _,
208
208
  currencyLocation: f,
209
- formattedPrice: u,
209
+ formattedPrice: d,
210
210
  configBlockAttributes: s,
211
- nameStyles: T,
211
+ nameStyles: I,
212
212
  buttonStyles: m,
213
- priceStyles: k,
214
- originalPriceStyles: h,
213
+ priceStyles: h,
214
+ originalPriceStyles: k,
215
215
  quantityStyles: L
216
216
  };
217
217
  }
@@ -222,17 +222,17 @@ class V {
222
222
  * @param itemsType - The type of items (CART_ITEMS, BROWSED_ITEMS, PURCHASED_ITEMS)
223
223
  * @param itemNumber - The item number (1-based index)
224
224
  */
225
- extractConfigBlockAttributes(t, e, i) {
226
- const l = t.querySelector("esd-config-block"), n = {};
227
- if (!l)
225
+ extractConfigBlockAttributes(t, r, c) {
226
+ const i = t.querySelector("esd-config-block"), n = {};
227
+ if (!i)
228
228
  return this.getDefaultConfigBlockAttributes();
229
- if (Array.from(l.attributes).forEach((o) => {
229
+ if (Array.from(i.attributes).forEach((o) => {
230
230
  o.name.startsWith("data-") && (n[o.name] = o.value);
231
231
  }), n["data-cart_items_select_control_value"]) {
232
232
  const o = n["data-cart_items_select_control_value"];
233
233
  if (/^\d+$/.test(o)) {
234
- const _ = parseInt(o) - 1, c = E[e];
235
- c && c[_] && (n["data-cart_items_select_control_value"] = c[_].value);
234
+ const _ = parseInt(o) - 1, l = E[r];
235
+ l && l[_] && (n["data-cart_items_select_control_value"] = l[_].value);
236
236
  }
237
237
  }
238
238
  if (n["data-product_price_control_curency"]) {
@@ -242,7 +242,7 @@ class V {
242
242
  }
243
243
  (!n["data-product_price_control_currency_symbol"] || n["data-product_price_control_currency_symbol"].trim() === "") && (n["data-product_price_control_currency_symbol"] = "USD");
244
244
  const a = { ...this.getDefaultConfigBlockAttributes(), ...n };
245
- return a["data-type"] = e, a["data-source"] = e, a["data-product_image_link"] = x(e, i), a["data-product_button_link"] = O(e, i), a;
245
+ return a["data-type"] = r, a["data-source"] = r, a["data-product_image_link"] = $(r, c), a["data-product_button_link"] = x(r, c), a;
246
246
  }
247
247
  /**
248
248
  * Returns default esd-config-block attributes based on the old template structure
@@ -297,18 +297,22 @@ class V {
297
297
  * - Cart Items: ins_apr_total_product_kind, ins_apr_price_N, ins_apr_originalprice_N
298
298
  * - Browsed Items: browsed_item_total_product_kind, browsed_item_price_N, browsed_item_originalprice_N
299
299
  * - Purchased Items: purchased_item_total_product_kind, purchased_item_price_N, purchased_item_originalprice_N
300
+ *
301
+ * IMPORTANT: Preserves the esd-custom-display-conditions attribute on <body> which
302
+ * contains display condition Jinja scripts that should NOT be removed.
300
303
  */
301
304
  removeJinjaConditionals(t) {
302
- let e = t.replace(
305
+ const r = "__ESD_DISPLAY_CONDITIONS_PLACEHOLDER__", c = t.match(/esd-custom-display-conditions="[^"]*"/);
306
+ let i = c ? t.replace(c[0], r) : t;
307
+ return i = i.replace(
303
308
  /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_total_product_kind\s*(&gt;|>)\s*\d+\s*%\}/g,
304
309
  ""
305
- );
306
- return e = e.replace(
310
+ ), i = i.replace(
307
311
  /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_price_\d+\s*(!&#61;|!=)\s*\1_originalprice_\d+\s*%\}/g,
308
312
  ""
309
- ), e = e.replace(/\{%\s*endif\s*%\}/g, ""), e = e.replace(/\n\s*\n\s*\n/g, `
313
+ ), i = i.replace(/\{%\s*endif\s*%\}/g, ""), c && (i = i.replace(r, c[0])), i = i.replace(/\n\s*\n\s*\n/g, `
310
314
 
311
- `), e;
315
+ `), i;
312
316
  }
313
317
  /**
314
318
  * Replaces template variables with default values from productPairs
@@ -320,31 +324,31 @@ class V {
320
324
  * - {{purchased_item_formattedprice_5}} → '1,490.49' (PURCHASED_ITEMS)
321
325
  */
322
326
  replaceTemplateVariables(t) {
323
- const { PAIRS_FOR_EXTENSION: e } = v;
324
- return t.replace(/{{([^}]+)}}/g, (i, l) => {
325
- const n = l.match(/^(ins_apr|browsed_item|purchased_item)_([a-z_]+)_(\d+)$/);
327
+ const { PAIRS_FOR_EXTENSION: r } = v;
328
+ return t.replace(/{{([^}]+)}}/g, (c, i) => {
329
+ const n = i.match(/^(ins_apr|browsed_item|purchased_item)_([a-z_]+)_(\d+)$/);
326
330
  if (!n)
327
- return i;
328
- const [, a, o, _] = n, c = $[a];
329
- if (!c)
330
- return console.warn(`Unknown variable prefix: ${a}`), i;
331
+ return c;
332
+ const [, a, o, _] = n, l = O[a];
333
+ if (!l)
334
+ return console.warn(`Unknown variable prefix: ${a}`), c;
331
335
  const f = w[o];
332
336
  if (!f)
333
- return console.warn(`Unknown variable suffix mapping for: ${o}`), i;
334
- const { pairsKey: u, defaultKey: s, isArray: b } = f, p = e[u][c];
337
+ return console.warn(`Unknown variable suffix mapping for: ${o}`), c;
338
+ const { pairsKey: d, defaultKey: s, isArray: S } = f, p = r[d][l];
335
339
  if (!p)
336
- return console.warn(`No data found for: ${u}.${c}`), i;
337
- if (b) {
340
+ return console.warn(`No data found for: ${d}.${l}`), c;
341
+ if (S) {
338
342
  const y = parseInt(_) - 1, m = p[s];
339
- return Array.isArray(m) && m[y] ? m[y] : (console.warn(`Array value not found: ${u}.${c}.${s}[${y}]`), i);
343
+ return Array.isArray(m) && m[y] ? m[y] : (console.warn(`Array value not found: ${d}.${l}.${s}[${y}]`), c);
340
344
  }
341
- const T = p[s];
342
- return T !== void 0 ? String(T) : (console.warn(`Default value not found: ${u}.${c}.${s}`), i);
345
+ const I = p[s];
346
+ return I !== void 0 ? String(I) : (console.warn(`Default value not found: ${d}.${l}.${s}`), c);
343
347
  });
344
348
  }
345
349
  }
346
- function G(r) {
347
- return new V().migrate(r);
350
+ function G(e) {
351
+ return new V().migrate(e);
348
352
  }
349
353
  export {
350
354
  G as migrateItemsBlock
@@ -1,8 +1,12 @@
1
- const t = {
1
+ const e = {
2
2
  transactional: 2
3
- }, o = 2, T = 13;
3
+ }, o = 2, t = 13, s = {
4
+ SAVED_MODULES: "savedModules",
5
+ DEFAULT_MODULES: "defaultModules"
6
+ };
4
7
  export {
5
8
  o as EditorType,
6
- T as MAX_DEFAULT_TEMPLATE_ID,
7
- t as TemplateTypes
9
+ t as MAX_DEFAULT_TEMPLATE_ID,
10
+ s as ModuleFolderDefaults,
11
+ e as TemplateTypes
8
12
  };
@@ -1,25 +1,26 @@
1
- var d = Object.defineProperty;
2
- var m = (c, s, t) => s in c ? d(c, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[s] = t;
3
- var n = (c, s, t) => m(c, typeof s != "symbol" ? s + "" : s, t);
4
- import { CommonControl as h } from "../../../common-control.js";
1
+ var m = Object.defineProperty;
2
+ var h = (c, s, t) => s in c ? m(c, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[s] = t;
3
+ var n = (c, s, t) => h(c, typeof s != "symbol" ? s + "" : s, t);
4
+ import { CommonControl as f } from "../../../common-control.js";
5
+ import { RecommendationConfigService as l } from "../../services/configService.js";
5
6
  import { useRecommendationExtensionStore as C } from "../../store/recommendation.js";
6
- import { AlgorithmControl as f } from "./algorithm.js";
7
- import { ALGORITHM_CONTROL_ID as M } from "./algorithm.js";
8
- import { CurrencyControl as p } from "./currency.js";
9
- import { CURRENCY_CONTROL_ID as W } from "./currency.js";
10
- import { FiltersControl as g } from "./filters.js";
11
- import { FILTERS_CONTROL_ID as H } from "./filters.js";
12
- import { LocaleControl as R } from "./locale.js";
13
- import { LOCALE_CONTROL_ID as j } from "./locale.js";
14
- import { ProductLayoutControl as _ } from "./productLayout.js";
15
- import { PRODUCT_LAYOUT_CONTROL_ID as K } from "./productLayout.js";
16
- import { ShuffleControl as N } from "./shuffle.js";
17
- import { SHUFFLE_CONTROL_ID as J } from "./shuffle.js";
18
- import { regenerateProductRowsWithStyles as b, getBlockElement as P, updateProductContentInPlace as y } from "./utils.js";
19
- import { formatProductPrice as X, getCardComposition as Z, getCurrentLayout as tt, reapplySpacing as et, regenerateMobileProductRows as ot, regenerateProductRows as rt, setCurrencyAttributes as nt, updatePricesInPlace as it, updateSingleProductContent as st } from "./utils.js";
20
- import { useDebounceFn as a } from "../../../../../node_modules/@vueuse/shared/index.js";
21
- const I = "recommendation-id", T = "ui-elements-recommendation-block";
22
- class B extends h {
7
+ import { AlgorithmControl as p } from "./algorithm.js";
8
+ import { ALGORITHM_CONTROL_ID as W } from "./algorithm.js";
9
+ import { CurrencyControl as g } from "./currency.js";
10
+ import { CURRENCY_CONTROL_ID as H } from "./currency.js";
11
+ import { FiltersControl as R } from "./filters.js";
12
+ import { FILTERS_CONTROL_ID as j } from "./filters.js";
13
+ import { LocaleControl as N } from "./locale.js";
14
+ import { LOCALE_CONTROL_ID as K } from "./locale.js";
15
+ import { ProductLayoutControl as y } from "./productLayout.js";
16
+ import { PRODUCT_LAYOUT_CONTROL_ID as J } from "./productLayout.js";
17
+ import { ShuffleControl as _ } from "./shuffle.js";
18
+ import { SHUFFLE_CONTROL_ID as X } from "./shuffle.js";
19
+ import { regenerateProductRowsWithStyles as b, getBlockElement as I, updateProductContentInPlace as P } from "./utils.js";
20
+ import { formatProductPrice as tt, getCardComposition as et, getCurrentLayout as ot, reapplySpacing as rt, regenerateMobileProductRows as it, regenerateProductRows as nt, setCurrencyAttributes as st, updatePricesInPlace as ct, updateSingleProductContent as at } from "./utils.js";
21
+ import { useDebounceFn as u } from "../../../../../node_modules/@vueuse/shared/index.js";
22
+ const T = "recommendation-id", S = "ui-elements-recommendation-block";
23
+ class z extends f {
23
24
  constructor() {
24
25
  super(...arguments);
25
26
  n(this, "store", C());
@@ -35,19 +36,19 @@ class B extends h {
35
36
  /**
36
37
  * Debounced product fetch to prevent rapid API calls during config changes
37
38
  */
38
- n(this, "_debouncedFetchProducts", a(() => {
39
+ n(this, "_debouncedFetchProducts", u(() => {
39
40
  this.store.fetchRecommendationProducts();
40
41
  }, 500));
41
42
  /**
42
43
  * Debounced regeneration when products arrive from API
43
44
  * Tries in-place update first to preserve styles, falls back to full regeneration
44
45
  */
45
- n(this, "_debouncedRegenerateWithProducts", a(() => {
46
+ n(this, "_debouncedRegenerateWithProducts", u(() => {
46
47
  const t = this.store.recommendationProducts;
47
48
  if (!this.currentNode || !this.api)
48
49
  return;
49
50
  const e = this.api.getDocumentModifier();
50
- y({
51
+ P({
51
52
  currentNode: this.currentNode,
52
53
  documentModifier: e,
53
54
  products: t
@@ -55,10 +56,10 @@ class B extends h {
55
56
  }, 100));
56
57
  }
57
58
  getId() {
58
- return T;
59
+ return S;
59
60
  }
60
61
  getTemplate() {
61
- return this.algorithmControl = new f(), this.localeControl = new R(), this.currencyControl = new p(), this.productLayoutControl = new _(), this.filtersControl = new g(), this.shuffleControl = new N(), `
62
+ return this.algorithmControl = new p(), this.localeControl = new N(), this.currencyControl = new g(), this.productLayoutControl = new y(), this.filtersControl = new R(), this.shuffleControl = new _(), `
62
63
  <div class="recommendation-controls-container">
63
64
  ${this.algorithmControl.getTemplate()}
64
65
  ${this.localeControl.getTemplate()}
@@ -94,19 +95,19 @@ class B extends h {
94
95
  });
95
96
  }
96
97
  onTemplateNodeUpdated(t) {
97
- var i;
98
+ var r;
98
99
  super.onTemplateNodeUpdated(t);
99
100
  const e = this._getRecommendationIdFromNode(t);
100
- e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), e !== null && !((i = this.store.blockStates[e]) != null && i.isInitialized) && this._fetchBlockData(e), [
101
+ e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), this._syncNodeConfigToStore(), e !== null && !((r = this.store.blockStates[e]) != null && r.isInitialized) && this._fetchBlockData(e), [
101
102
  this.algorithmControl,
102
103
  this.localeControl,
103
104
  this.currencyControl,
104
105
  this.productLayoutControl,
105
106
  this.filtersControl,
106
107
  this.shuffleControl
107
- ].forEach((r) => {
108
- var l;
109
- r != null && r.api && (r.currentNode = t, (l = r.onTemplateNodeUpdated) == null || l.call(r, t));
108
+ ].forEach((i) => {
109
+ var a;
110
+ i != null && i.api && (i.currentNode = t, (a = i.onTemplateNodeUpdated) == null || a.call(i, t));
110
111
  });
111
112
  }
112
113
  onDestroy() {
@@ -139,6 +140,41 @@ class B extends h {
139
140
  e && (e.api = this.api, e.currentNode = this.currentNode, (o = e.onRender) == null || o.call(e));
140
141
  });
141
142
  }
143
+ /**
144
+ * Syncs persisted node config into the Pinia store's block state.
145
+ *
146
+ * setCurrentBlock() creates a default entry (USD, en_US, mostPopular).
147
+ * For saved templates, the real config lives in the node (e.g., TRY, tr_TR).
148
+ * This method reads it and patches the store so fetchRecommendationProducts()
149
+ * uses the correct values.
150
+ *
151
+ * Uses triggerRefetch: false because the fetch hasn't happened yet —
152
+ * values are being prepared for the upcoming initial fetch.
153
+ */
154
+ _syncNodeConfigToStore() {
155
+ var r;
156
+ const t = l.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((r = this.store.blockStates[e]) == null ? void 0 : r.isInitialized);
157
+ this.store.patchCurrentBlockConfig({
158
+ strategy: t.strategy,
159
+ language: t.language,
160
+ size: t.size,
161
+ productIds: t.productIds,
162
+ // Only sync filters from node config during initial load.
163
+ // After initialization, the Pinia store is the source of truth
164
+ // for filters (edited via the filter drawer).
165
+ ...o ? {} : { filters: t.filters },
166
+ shuffleProducts: t.shuffleProducts,
167
+ currencySettings: {
168
+ name: t.currency.code,
169
+ value: t.currency.code,
170
+ symbol: t.currency.symbol,
171
+ alignment: t.currency.alignment === "before" ? "0" : "1",
172
+ decimalCount: t.currency.decimalCount.toString(),
173
+ decimalSeparator: t.currency.decimalSeparator,
174
+ thousandSeparator: t.currency.thousandSeparator
175
+ }
176
+ }, { triggerRefetch: !1 });
177
+ }
142
178
  /**
143
179
  * Fetches initial data for a block (filters, algorithms, products).
144
180
  * Shared by onRender() and onTemplateNodeUpdated() to avoid duplication.
@@ -149,26 +185,26 @@ class B extends h {
149
185
  this.store.fetchRecommendationFilters(),
150
186
  this.store.fetchRecommendationCreateData(),
151
187
  this.store.fetchRecommendationProducts()
152
- ])).forEach((o, i) => {
188
+ ])).forEach((o, r) => {
153
189
  o.status === "rejected" && console.warn(`Recommendation block: ${[
154
190
  "fetchRecommendationFilters",
155
191
  "fetchRecommendationCreateData",
156
192
  "fetchRecommendationProducts"
157
- ][i]} failed`, o.reason);
193
+ ][r]} failed`, o.reason);
158
194
  });
159
195
  }
160
196
  /**
161
197
  * Reads the recommendation-id attribute from the block element within the node
162
198
  */
163
199
  _getRecommendationIdFromNode(t) {
164
- const e = P(t);
200
+ const e = I(t);
165
201
  if (!e || !("getAttribute" in e))
166
202
  return null;
167
- const o = e.getAttribute(I);
203
+ const o = e.getAttribute(T);
168
204
  if (!o)
169
205
  return null;
170
- const i = parseInt(o);
171
- return Number.isNaN(i) ? null : i;
206
+ const r = parseInt(o);
207
+ return Number.isNaN(r) ? null : r;
172
208
  }
173
209
  /**
174
210
  * Listen to store changes that require product refresh or regeneration.
@@ -181,38 +217,53 @@ class B extends h {
181
217
  const { store: t } = this;
182
218
  let e = t.recommendationProducts, o = t.$state.configVersion;
183
219
  this.storeUnsubscription = t.$subscribe(() => {
184
- const i = t.$state.configVersion;
185
- i !== o && (o = i, this._debouncedFetchProducts());
186
- const r = t.recommendationProducts, l = r !== e, u = Array.isArray(r) && r.length > 0;
187
- l && u && (e = r, this._debouncedRegenerateWithProducts());
220
+ const r = t.$state.configVersion;
221
+ r !== o && (o = r, this._persistFiltersToNodeConfig(), this._debouncedFetchProducts());
222
+ const i = t.recommendationProducts, a = i !== e, d = Array.isArray(i) && i.length > 0;
223
+ a && d && (e = i, this._debouncedRegenerateWithProducts());
188
224
  });
189
225
  }
226
+ /**
227
+ * Persists the current filter state from Pinia store to the Stripo node config.
228
+ * This ensures filters survive template save/reload cycles.
229
+ */
230
+ _persistFiltersToNodeConfig() {
231
+ if (!this.currentNode || !this.api)
232
+ return;
233
+ const { filters: t } = this.store.recommendationConfigs;
234
+ l.updateConfig(
235
+ this.api,
236
+ this.currentNode,
237
+ { filters: t },
238
+ "Update recommendation filters"
239
+ );
240
+ }
190
241
  }
191
242
  export {
192
- M as ALGORITHM_CONTROL_ID,
193
- f as AlgorithmControl,
194
- T as CONTROL_BLOCK_ID,
195
- W as CURRENCY_CONTROL_ID,
196
- p as CurrencyControl,
197
- H as FILTERS_CONTROL_ID,
198
- g as FiltersControl,
199
- j as LOCALE_CONTROL_ID,
200
- R as LocaleControl,
201
- K as PRODUCT_LAYOUT_CONTROL_ID,
202
- _ as ProductLayoutControl,
203
- B as RecommendationBlockControl,
204
- J as SHUFFLE_CONTROL_ID,
205
- N as ShuffleControl,
206
- X as formatProductPrice,
207
- P as getBlockElement,
208
- Z as getCardComposition,
209
- tt as getCurrentLayout,
210
- et as reapplySpacing,
211
- ot as regenerateMobileProductRows,
212
- rt as regenerateProductRows,
243
+ W as ALGORITHM_CONTROL_ID,
244
+ p as AlgorithmControl,
245
+ S as CONTROL_BLOCK_ID,
246
+ H as CURRENCY_CONTROL_ID,
247
+ g as CurrencyControl,
248
+ j as FILTERS_CONTROL_ID,
249
+ R as FiltersControl,
250
+ K as LOCALE_CONTROL_ID,
251
+ N as LocaleControl,
252
+ J as PRODUCT_LAYOUT_CONTROL_ID,
253
+ y as ProductLayoutControl,
254
+ z as RecommendationBlockControl,
255
+ X as SHUFFLE_CONTROL_ID,
256
+ _ as ShuffleControl,
257
+ tt as formatProductPrice,
258
+ I as getBlockElement,
259
+ et as getCardComposition,
260
+ ot as getCurrentLayout,
261
+ rt as reapplySpacing,
262
+ it as regenerateMobileProductRows,
263
+ nt as regenerateProductRows,
213
264
  b as regenerateProductRowsWithStyles,
214
- nt as setCurrencyAttributes,
215
- it as updatePricesInPlace,
216
- y as updateProductContentInPlace,
217
- st as updateSingleProductContent
265
+ st as setCurrencyAttributes,
266
+ ct as updatePricesInPlace,
267
+ P as updateProductContentInPlace,
268
+ at as updateSingleProductContent
218
269
  };