@useinsider/guido 3.18.1-beta.74a13e4 → 3.18.1

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.
@@ -1,11 +1,11 @@
1
- var q = Object.defineProperty;
2
- var v = (o, t, e) => t in o ? q(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
- var P = (o, t, e) => v(o, typeof t != "symbol" ? t + "" : t, e);
4
- import { BLOCK_ID as U } from "../../extensions/Blocks/Items/block.js";
5
- import { productPairs as F } from "../../extensions/Blocks/Items/enums/productEnums.js";
6
- import { ItemInCartOptions as I, DefaultConfigValues as S, SETTINGS_ENUMS as p } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
7
- import { getDefaultTemplate as K } from "../../extensions/Blocks/Items/template.js";
8
- import { useTemplateStore as O } from "../../stores/template.js";
1
+ var v = Object.defineProperty;
2
+ var U = (o, t, r) => t in o ? v(o, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[t] = r;
3
+ var M = (o, t, r) => U(o, typeof t != "symbol" ? t + "" : t, r);
4
+ import { BLOCK_ID as w } from "../../extensions/Blocks/Items/block.js";
5
+ import { productPairs as K } from "../../extensions/Blocks/Items/enums/productEnums.js";
6
+ import { ItemInCartOptions as I, DefaultConfigValues as g, SETTINGS_ENUMS as p } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
7
+ import { getDefaultTemplate as F } from "../../extensions/Blocks/Items/template.js";
8
+ import { useTemplateStore as q } from "../../stores/template.js";
9
9
  const x = {
10
10
  img: {
11
11
  pairsKey: "imageSrc",
@@ -73,10 +73,10 @@ const x = {
73
73
  isArray: !1
74
74
  }
75
75
  };
76
- function $() {
76
+ function O() {
77
77
  return String(Date.now() + Math.floor(Math.random() * 1e3));
78
78
  }
79
- function R(o) {
79
+ function k(o) {
80
80
  return o ? {
81
81
  CartItems: p.ITEMS_TYPE.CART_ITEMS,
82
82
  BrowsedItems: p.ITEMS_TYPE.BROWSED_ITEMS,
@@ -86,41 +86,38 @@ function R(o) {
86
86
  PURCHASED_ITEMS: p.ITEMS_TYPE.PURCHASED_ITEMS
87
87
  }[o] || p.ITEMS_TYPE.CART_ITEMS : p.ITEMS_TYPE.CART_ITEMS;
88
88
  }
89
- function V(o) {
90
- return o.classList.contains("esd-browsed-items-block") ? p.ITEMS_TYPE.BROWSED_ITEMS : o.classList.contains("esd-purchased-items-block") ? p.ITEMS_TYPE.PURCHASED_ITEMS : p.ITEMS_TYPE.CART_ITEMS;
91
- }
92
- function M(o) {
93
- var r;
94
- const t = (l, u) => l == null ? u : l === "1" || l === "true", e = (l, u) => l || u, i = o["data-type"] || o["data-source"], a = R(i), n = I[a];
95
- let c = o["data-cart_items_select_control_value"] || ((r = n == null ? void 0 : n[0]) == null ? void 0 : r.value) || S.cartItemsSelectControlValue;
96
- if (c && !c.includes("{{") && /^\d+$/.test(c)) {
97
- const l = parseInt(c) - 1, u = I[a];
98
- u && u[l] && (c = u[l].value);
89
+ function h(o) {
90
+ var e;
91
+ const t = (l, u) => l == null ? u : l === "1" || l === "true", r = (l, u) => l || u, c = o["data-type"] || o["data-source"], a = k(c), i = I[a];
92
+ let n = o["data-cart_items_select_control_value"] || ((e = i == null ? void 0 : i[0]) == null ? void 0 : e.value) || g.cartItemsSelectControlValue;
93
+ if (n && !n.includes("{{") && /^\d+$/.test(n)) {
94
+ const l = parseInt(n) - 1, u = I[a];
95
+ u && u[l] && (n = u[l].value);
99
96
  }
100
97
  return {
101
98
  initialized: !0,
102
- blockInstanceId: e(o["data-block-instance-id"], $()),
99
+ blockInstanceId: r(o["data-block-instance-id"], O()),
103
100
  source: a,
104
101
  type: a,
105
- itemsSelectValue: c,
102
+ itemsSelectValue: n,
106
103
  orientation: o["data-card_orientation_control_value"] || p.ORIENTATION.VERTICAL,
107
104
  nameTrimming: t(o["data-product_name_control_trim"], !0),
108
105
  priceHideDiscount: t(o["data-product_price_control_nodup"], !0),
109
106
  priceFormatted: t(o["data-product_price_control_formated"], !0),
110
107
  priceSinglePrice: t(o["data-product_price_control_single_price"], !1),
111
- priceCurrencySymbol: e(
108
+ priceCurrencySymbol: r(
112
109
  o["data-product_price_control_currency_symbol"],
113
- S.productPriceCurrencySymbolControlValue
110
+ g.productPriceCurrencySymbolControlValue
114
111
  ),
115
- priceCurrencyLocation: e(
112
+ priceCurrencyLocation: r(
116
113
  o["data-product_price_currency_location"],
117
- S.productPriceCurrencyLocationControlValue
114
+ g.productPriceCurrencyLocationControlValue
118
115
  ),
119
116
  priceOrientation: o["data-product_original_price_control_orientation"] || "horizontal",
120
117
  quantityControlEnabled: t(o["data-product_quantity_control_enabled"], !0),
121
- buttonLink: e(o["data-product_button_link"], S.productButtonLinkControlValue),
122
- imageLink: e(o["data-product_image_link"], S.productImageLinkControlValue),
123
- buttonLabel: e(o["data-product_button_control_label"], "Buy"),
118
+ buttonLink: r(o["data-product_button_link"], g.productButtonLinkControlValue),
119
+ imageLink: r(o["data-product_image_link"], g.productImageLinkControlValue),
120
+ buttonLabel: r(o["data-product_button_control_label"], "Buy"),
124
121
  buttonFullWidth: t(o["data-product_button_control_atw"], !0),
125
122
  imageVisible: t(o["data-product_image_control_enabled"], !0),
126
123
  nameVisible: t(o["data-product_name_control_enabled"], !0),
@@ -130,72 +127,72 @@ function M(o) {
130
127
  buttonVisible: t(o["data-product_button_control_enabled"], !0)
131
128
  };
132
129
  }
133
- const H = {
130
+ const V = {
134
131
  ins_apr: "CART_ITEMS",
135
132
  browsed_item: "BROWSED_ITEMS",
136
133
  purchased_item: "PURCHASED_ITEMS"
137
134
  };
138
- function N(o, t) {
139
- const e = {
135
+ function $(o, t) {
136
+ const r = {
140
137
  CART_ITEMS: `{{Abandoned Cart Item (${t}) Image}}`,
141
138
  BROWSED_ITEMS: `{{Browsed Item (${t}) Image}}`,
142
139
  PURCHASED_ITEMS: `{{Purchased Item (${t}) Image}}`
143
140
  };
144
- return e[o] || e.CART_ITEMS;
141
+ return r[o] || r.CART_ITEMS;
145
142
  }
146
- function z(o, t) {
147
- const e = {
143
+ function N(o, t) {
144
+ const r = {
148
145
  CART_ITEMS: `{{Abandoned Cart Item (${t}) Url}}`,
149
146
  BROWSED_ITEMS: `{{Browsed Item (${t}) Url}}`,
150
147
  PURCHASED_ITEMS: `{{Purchased Item (${t}) Url}}`
151
148
  };
152
- return e[o] || e.CART_ITEMS;
149
+ return r[o] || r.CART_ITEMS;
153
150
  }
154
- class Y {
151
+ class H {
155
152
  constructor() {
156
- P(this, "parser");
153
+ M(this, "parser");
157
154
  this.parser = new DOMParser();
158
155
  }
159
156
  migrate(t) {
160
157
  try {
161
158
  if (!this.containsItemsBlock(t))
162
159
  return this.backfillV2ProductTdAttributes(t);
163
- let e = this.removeJinjaConditionals(t);
164
- e = this.replaceTemplateVariables(e);
165
- const i = this.parser.parseFromString(e, "text/html"), a = i.querySelectorAll(
160
+ let r = this.removeJinjaConditionals(t);
161
+ r = this.replaceTemplateVariables(r);
162
+ const c = this.parser.parseFromString(r, "text/html"), a = c.querySelectorAll(
166
163
  "td.esd-cart-items-block, td.esd-browsed-items-block, td.esd-purchased-items-block"
167
164
  );
168
- return O().$patch((c) => {
169
- c.migrations = { ...c.migrations, [U]: a.length };
170
- }), a.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), e) : (a.forEach((c) => {
171
- const r = this.extractConfiguration(c), l = K({
172
- orientation: r.orientation,
173
- itemsType: r.itemsType,
174
- itemId: r.itemId,
175
- currencySymbol: r.currencySymbol,
176
- currencyLocation: r.currencyLocation,
177
- formattedPrice: r.formattedPrice,
178
- configBlockAttributes: r.configBlockAttributes,
165
+ return q().$patch((n) => {
166
+ n.migrations = { ...n.migrations, [w]: a.length };
167
+ }), a.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), r) : (a.forEach((n) => {
168
+ const e = this.extractConfiguration(n), l = F({
169
+ orientation: e.orientation,
170
+ itemsType: e.itemsType,
171
+ itemId: e.itemId,
172
+ currencySymbol: e.currencySymbol,
173
+ currencyLocation: e.currencyLocation,
174
+ formattedPrice: e.formattedPrice,
175
+ configBlockAttributes: e.configBlockAttributes,
179
176
  migrate: !0,
180
- nameStyles: r.nameStyles,
181
- buttonStyles: r.buttonStyles,
182
- priceStyles: r.priceStyles,
183
- originalPriceStyles: r.originalPriceStyles,
184
- quantityStyles: r.quantityStyles,
185
- nodeConfig: M(r.configBlockAttributes)
186
- }), d = this.parser.parseFromString(
177
+ nameStyles: e.nameStyles,
178
+ buttonStyles: e.buttonStyles,
179
+ priceStyles: e.priceStyles,
180
+ originalPriceStyles: e.originalPriceStyles,
181
+ quantityStyles: e.quantityStyles,
182
+ nodeConfig: h(e.configBlockAttributes)
183
+ }), s = this.parser.parseFromString(
187
184
  `<table><tbody><tr>${l}</tr></tbody></table>`,
188
185
  "text/html"
189
186
  ).querySelector("td");
190
- if (d && c.parentNode) {
191
- const _ = M(r.configBlockAttributes);
192
- d.setAttribute("esd-ext-config", JSON.stringify(_)), d.setAttribute("data-type", _.type);
193
- const s = d.querySelector("esd-config-block");
194
- s && s.remove(), c.parentNode.replaceChild(d, c);
187
+ if (s && n.parentNode) {
188
+ const _ = h(e.configBlockAttributes);
189
+ s.setAttribute("esd-ext-config", JSON.stringify(_)), s.setAttribute("data-type", _.type);
190
+ const d = s.querySelector("esd-config-block");
191
+ d && d.remove(), n.parentNode.replaceChild(s, n);
195
192
  }
196
- }), i.documentElement.outerHTML);
197
- } catch (e) {
198
- return console.error("ItemsBlockMigrator failed:", e), t;
193
+ }), c.documentElement.outerHTML);
194
+ } catch (r) {
195
+ return console.error("ItemsBlockMigrator failed:", r), t;
199
196
  }
200
197
  }
201
198
  /**
@@ -205,85 +202,28 @@ class Y {
205
202
  * - UI styles from product elements (name, price, button, quantity, etc.)
206
203
  */
207
204
  extractConfiguration(t) {
208
- var D;
209
- const e = R(
210
- this.readSelfOrDescendantAttribute(t, "data-type") || V(t)
211
- ), i = this.readSelfOrDescendantAttribute(t, "data-number") || "1", a = parseInt(i) - 1, n = I[e], c = ((D = n == null ? void 0 : n[a]) == null ? void 0 : D.value) || n[0].value, r = this.extractConfigBlockAttributes(t, e, i);
212
- this.applyDomFallbacks(t, r);
213
- const l = t.querySelector('[product-attr="price"]'), u = l ?? t.querySelector('[product-attr="originalPrice"]'), d = (u == null ? void 0 : u.getAttribute("data-currency_symbol")) || r["data-product_price_control_currency_symbol"], _ = u == null ? void 0 : u.getAttribute("data-curency");
214
- let s = r["data-product_price_currency_location"] || "0";
215
- _ && (s = _ === "after" ? "1" : "0");
216
- const A = (u == null ? void 0 : u.getAttribute("data-formated")) ?? r["data-product_price_control_formated"], h = A !== "false" && A !== "0", m = r["data-card_orientation_control_value"];
217
- let g;
218
- m ? g = m === "horizontal" ? "horizontal" : "vertical" : g = t.querySelector('[colspan="2"]') !== null ? "vertical" : "horizontal";
219
- const y = t.querySelector('a[product-attr="name"]'), b = (y == null ? void 0 : y.getAttribute("style")) || void 0, E = t.querySelector('a[product-attr="button"]') ?? t.querySelector('[product-attr="button"]'), L = (E == null ? void 0 : E.getAttribute("style")) || void 0, k = (l == null ? void 0 : l.getAttribute("style")) || void 0, f = t.querySelector("p.original-price") ?? t.querySelector('[product-attr="originalPrice"]'), T = f != null && f.getAttribute("style") ? f : (f == null ? void 0 : f.closest("p")) ?? f, w = (T == null ? void 0 : T.getAttribute("style")) || void 0, C = t.querySelector('[product-attr="quantity"]'), B = (C == null ? void 0 : C.getAttribute("style")) || void 0;
205
+ var C, D, P;
206
+ const r = k(
207
+ ((C = t.querySelector("[data-type]")) == null ? void 0 : C.getAttribute("data-type")) ?? null
208
+ ), c = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", a = parseInt(c) - 1, i = I[r], n = ((P = i == null ? void 0 : i[a]) == null ? void 0 : P.value) || i[0].value, e = t.querySelector('[product-attr="price"]'), l = (e == null ? void 0 : e.getAttribute("data-currency_symbol")) || "USD", s = ((e == null ? void 0 : e.getAttribute("data-curency")) || "before") === "after" ? "1" : "0", _ = (e == null ? void 0 : e.getAttribute("data-formated")) !== "false", d = this.extractConfigBlockAttributes(t, r, c), b = d["data-card_orientation_control_value"];
209
+ let S;
210
+ b ? S = b === "horizontal" ? "horizontal" : "vertical" : S = t.querySelector('[colspan="2"]') !== null ? "vertical" : "horizontal";
211
+ const y = t.querySelector('a[product-attr="name"]'), A = (y == null ? void 0 : y.getAttribute("style")) || void 0, f = t.querySelector('a[product-attr="button"]'), m = (f == null ? void 0 : f.getAttribute("style")) || void 0, R = (e == null ? void 0 : e.getAttribute("style")) || void 0, E = t.querySelector("p.original-price"), L = (E == null ? void 0 : E.getAttribute("style")) || void 0, T = t.querySelector('[product-attr="quantity"]'), B = (T == null ? void 0 : T.getAttribute("style")) || void 0;
220
212
  return {
221
- orientation: g,
222
- itemsType: e,
223
- itemId: c,
224
- currencySymbol: d,
213
+ orientation: S,
214
+ itemsType: r,
215
+ itemId: n,
216
+ currencySymbol: l,
225
217
  currencyLocation: s,
226
- formattedPrice: h,
227
- configBlockAttributes: r,
228
- nameStyles: b,
229
- buttonStyles: L,
230
- priceStyles: k,
231
- originalPriceStyles: w,
218
+ formattedPrice: _,
219
+ configBlockAttributes: d,
220
+ nameStyles: A,
221
+ buttonStyles: m,
222
+ priceStyles: R,
223
+ originalPriceStyles: L,
232
224
  quantityStyles: B
233
225
  };
234
226
  }
235
- /**
236
- * DOM fallback for hand-edited templates whose esd-config-block was deleted. With no
237
- * toggle record left, derive each field's enabled state from whether its product-attr
238
- * element still exists and read the button label from the live caption — a deleted
239
- * element means the field is off, not an all-ON default. A present config block stays
240
- * authoritative (a missing flag there still means "default on"), so we no-op for it.
241
- */
242
- applyDomFallbacks(t, e) {
243
- var u;
244
- const i = t.querySelector("esd-config-block");
245
- if (Object.entries({
246
- image: '[product-attr="imageSrc"]',
247
- name: '[product-attr="name"]',
248
- price: '[product-attr="price"]',
249
- original_price: '[product-attr="originalPrice"], p.original-price',
250
- quantity: '[product-attr="quantity"]',
251
- button: '[product-attr="button"]'
252
- }).forEach(([d, _]) => {
253
- const s = `data-product_${d}_control_enabled`;
254
- (!i || !i.hasAttribute(s)) && (e[s] = t.querySelector(_) ? "true" : "false");
255
- }), i)
256
- return;
257
- e["data-card_orientation_control_value"] = t.querySelector('[colspan="2"]') ? "vertical" : "horizontal";
258
- const n = t.querySelector('a[product-attr="button"]') ?? t.querySelector('[product-attr="button"]'), c = (u = n == null ? void 0 : n.textContent) == null ? void 0 : u.replace(/\s+/g, " ").trim();
259
- c && (e["data-product_button_control_label"] = c), /display:\s*inline/.test((n == null ? void 0 : n.getAttribute("style")) || "") && (e["data-product_button_control_atw"] = "false");
260
- const r = t.querySelector('[product-attr="imageSrc"]'), l = r ? this.readImageDimension(r) : null;
261
- l && (e["data-product_image_control_image-height"] = l, e["data-product_image_control_image-width"] = l);
262
- }
263
- /**
264
- * Reads an attribute from the block element itself before falling back to a descendant.
265
- * Real legacy markup carries data-type/data-number on the `.ins-product-td` AND on the
266
- * esd-config-block; when an author deletes the config block only the td's copy survives.
267
- */
268
- readSelfOrDescendantAttribute(t, e) {
269
- var i;
270
- return t.getAttribute(e) || ((i = t.querySelector(`[${e}]`)) == null ? void 0 : i.getAttribute(e)) || null;
271
- }
272
- /**
273
- * Reads a pixel dimension for the product image from its DOM element — the legacy
274
- * `width` attribute first, then a px value in the inline style. An explicit `width` wins
275
- * over `max-width`, which is only an upper bound; `max-width` still covers the common
276
- * `width: 100%` case, where no pixel size can be read from `width` itself.
277
- * Returns null when no pixel size is present.
278
- */
279
- readImageDimension(t) {
280
- var n;
281
- const e = (n = t.getAttribute("width")) == null ? void 0 : n.trim();
282
- if (e && /^\d+$/.test(e))
283
- return e;
284
- const i = t.getAttribute("style") || "", a = i.match(/(?:^|;)\s*width:\s*(\d+)px/) || i.match(/max-width:\s*(\d+)px/);
285
- return a ? a[1] : null;
286
- }
287
227
  /**
288
228
  * Extracts all data-* attributes from the esd-config-block element
289
229
  * Returns a key-value mapping of all configuration attributes
@@ -291,27 +231,27 @@ class Y {
291
231
  * @param itemsType - The type of items (CART_ITEMS, BROWSED_ITEMS, PURCHASED_ITEMS)
292
232
  * @param itemNumber - The item number (1-based index)
293
233
  */
294
- extractConfigBlockAttributes(t, e, i) {
295
- const a = t.querySelector("esd-config-block"), n = {};
296
- if (a) {
297
- if (Array.from(a.attributes).forEach((r) => {
298
- r.name.startsWith("data-") && (n[r.name] = r.value);
299
- }), n["data-cart_items_select_control_value"]) {
300
- const r = n["data-cart_items_select_control_value"];
301
- if (/^\d+$/.test(r)) {
302
- const l = parseInt(r) - 1, u = I[e];
303
- u && u[l] && (n["data-cart_items_select_control_value"] = u[l].value);
304
- }
305
- }
306
- if (n["data-product_price_control_curency"]) {
307
- const r = n["data-product_price_control_curency"];
308
- let l = r;
309
- r === "before" ? l = "0" : r === "after" && (l = "1"), n["data-product_price_control_curency"] = l, n["data-product_price_currency_location"] = l;
234
+ extractConfigBlockAttributes(t, r, c) {
235
+ const a = t.querySelector("esd-config-block"), i = {};
236
+ if (!a)
237
+ return this.getDefaultConfigBlockAttributes();
238
+ if (Array.from(a.attributes).forEach((e) => {
239
+ e.name.startsWith("data-") && (i[e.name] = e.value);
240
+ }), i["data-cart_items_select_control_value"]) {
241
+ const e = i["data-cart_items_select_control_value"];
242
+ if (/^\d+$/.test(e)) {
243
+ const l = parseInt(e) - 1, u = I[r];
244
+ u && u[l] && (i["data-cart_items_select_control_value"] = u[l].value);
310
245
  }
311
- (!n["data-product_price_control_currency_symbol"] || n["data-product_price_control_currency_symbol"].trim() === "") && (n["data-product_price_control_currency_symbol"] = "USD");
312
246
  }
313
- const c = { ...this.getDefaultConfigBlockAttributes(), ...n };
314
- return c["data-type"] = e, c["data-source"] = e, c["data-product_image_link"] = N(e, i), c["data-product_button_link"] = z(e, i), c;
247
+ if (i["data-product_price_control_curency"]) {
248
+ const e = i["data-product_price_control_curency"];
249
+ let l = e;
250
+ e === "before" ? l = "0" : e === "after" && (l = "1"), i["data-product_price_control_curency"] = l, i["data-product_price_currency_location"] = l;
251
+ }
252
+ (!i["data-product_price_control_currency_symbol"] || i["data-product_price_control_currency_symbol"].trim() === "") && (i["data-product_price_control_currency_symbol"] = "USD");
253
+ const n = { ...this.getDefaultConfigBlockAttributes(), ...i };
254
+ return n["data-type"] = r, n["data-source"] = r, n["data-product_image_link"] = $(r, c), n["data-product_button_link"] = N(r, c), n;
315
255
  }
316
256
  /**
317
257
  * Returns default esd-config-block attributes based on the old template structure
@@ -385,25 +325,25 @@ class Y {
385
325
  backfillV2ProductTdAttributes(t) {
386
326
  if (!t.includes("ins-product-td") || !t.includes("esd-ext-config"))
387
327
  return t;
388
- const e = this.parser.parseFromString(t, "text/html");
389
- let i = !1;
390
- return e.querySelectorAll(".ins-product-td").forEach((a) => {
391
- a.hasAttribute("width") && (a.removeAttribute("width"), i = !0);
392
- const n = a.getAttribute("esd-ext-config");
393
- let c = null;
328
+ const r = this.parser.parseFromString(t, "text/html");
329
+ let c = !1;
330
+ return r.querySelectorAll(".ins-product-td").forEach((a) => {
331
+ a.hasAttribute("width") && (a.removeAttribute("width"), c = !0);
332
+ const i = a.getAttribute("esd-ext-config");
333
+ let n = null;
394
334
  try {
395
- c = n ? JSON.parse(n) : null;
335
+ n = i ? JSON.parse(i) : null;
396
336
  } catch {
397
337
  }
398
- if (!c || (!a.getAttribute("data-nodup") && typeof c.priceHideDiscount == "boolean" && (a.setAttribute("data-nodup", String(c.priceHideDiscount)), i = !0), a.getAttribute("data-type")))
338
+ if (!n || (!a.getAttribute("data-nodup") && typeof n.priceHideDiscount == "boolean" && (a.setAttribute("data-nodup", String(n.priceHideDiscount)), c = !0), a.getAttribute("data-type")))
399
339
  return;
400
- const r = c.type || c.source;
401
- if (!r)
340
+ const e = n.type || n.source;
341
+ if (!e)
402
342
  return;
403
- a.setAttribute("data-type", r), i = !0;
404
- const l = typeof c.itemsSelectValue == "string" ? c.itemsSelectValue.match(/\((\d+)\)/) : null;
343
+ a.setAttribute("data-type", e), c = !0;
344
+ const l = typeof n.itemsSelectValue == "string" ? n.itemsSelectValue.match(/\((\d+)\)/) : null;
405
345
  l && a.getAttribute("data-number") !== l[1] && a.setAttribute("data-number", l[1]);
406
- }), i ? e.documentElement.outerHTML : t;
346
+ }), c ? r.documentElement.outerHTML : t;
407
347
  }
408
348
  /**
409
349
  * Fast check for the presence of any items block (cart / browsed / purchased)
@@ -424,15 +364,15 @@ class Y {
424
364
  * contains display condition Jinja scripts that should NOT be removed.
425
365
  */
426
366
  removeJinjaConditionals(t) {
427
- const e = "__ESD_DISPLAY_CONDITIONS_PLACEHOLDER__", i = t.match(/esd-custom-display-conditions="[^"]*"/);
428
- let a = i ? t.replace(i[0], e) : t;
367
+ const r = "__ESD_DISPLAY_CONDITIONS_PLACEHOLDER__", c = t.match(/esd-custom-display-conditions="[^"]*"/);
368
+ let a = c ? t.replace(c[0], r) : t;
429
369
  return a = a.replace(
430
370
  /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_total_product_kind\s*(&gt;|>)\s*\d+\s*%\}/g,
431
371
  ""
432
372
  ), a = a.replace(
433
373
  /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_price_\d+\s*(!&#61;|!=)\s*\1_originalprice_\d+\s*%\}/g,
434
374
  ""
435
- ), a = a.replace(/\{%\s*endif\s*%\}/g, ""), i && (a = a.replace(e, i[0])), a = a.replace(/\n\s*\n\s*\n/g, `
375
+ ), a = a.replace(/\{%\s*endif\s*%\}/g, ""), c && (a = a.replace(r, c[0])), a = a.replace(/\n\s*\n\s*\n/g, `
436
376
 
437
377
  `), a;
438
378
  }
@@ -446,32 +386,32 @@ class Y {
446
386
  * - {{purchased_item_formattedprice_5}} → '1,490.49' (PURCHASED_ITEMS)
447
387
  */
448
388
  replaceTemplateVariables(t) {
449
- const { PAIRS_FOR_EXTENSION: e } = F;
450
- return t.replace(/{{([^}]+)}}/g, (i, a) => {
451
- const n = a.match(/^(ins_apr|browsed_item|purchased_item)_([a-z_]+)_(\d+)$/);
452
- if (!n)
453
- return i;
454
- const [, c, r, l] = n, u = H[c];
389
+ const { PAIRS_FOR_EXTENSION: r } = K;
390
+ return t.replace(/{{([^}]+)}}/g, (c, a) => {
391
+ const i = a.match(/^(ins_apr|browsed_item|purchased_item)_([a-z_]+)_(\d+)$/);
392
+ if (!i)
393
+ return c;
394
+ const [, n, e, l] = i, u = V[n];
455
395
  if (!u)
456
- return console.warn(`Unknown variable prefix: ${c}`), i;
457
- const d = x[r];
458
- if (!d)
459
- return console.warn(`Unknown variable suffix mapping for: ${r}`), i;
460
- const { pairsKey: _, defaultKey: s, isArray: A } = d, m = e[_][u];
461
- if (!m)
462
- return console.warn(`No data found for: ${_}.${u}`), i;
463
- if (A) {
464
- const y = parseInt(l) - 1, b = m[s];
465
- return Array.isArray(b) && b[y] ? b[y] : (console.warn(`Array value not found: ${_}.${u}.${s}[${y}]`), i);
396
+ return console.warn(`Unknown variable prefix: ${n}`), c;
397
+ const s = x[e];
398
+ if (!s)
399
+ return console.warn(`Unknown variable suffix mapping for: ${e}`), c;
400
+ const { pairsKey: _, defaultKey: d, isArray: b } = s, y = r[_][u];
401
+ if (!y)
402
+ return console.warn(`No data found for: ${_}.${u}`), c;
403
+ if (b) {
404
+ const f = parseInt(l) - 1, m = y[d];
405
+ return Array.isArray(m) && m[f] ? m[f] : (console.warn(`Array value not found: ${_}.${u}.${d}[${f}]`), c);
466
406
  }
467
- const g = m[s];
468
- return g !== void 0 ? String(g) : (console.warn(`Default value not found: ${_}.${u}.${s}`), i);
407
+ const A = y[d];
408
+ return A !== void 0 ? String(A) : (console.warn(`Default value not found: ${_}.${u}.${d}`), c);
469
409
  });
470
410
  }
471
411
  }
472
- function tt(o) {
473
- return new Y().migrate(o);
412
+ function Q(o) {
413
+ return new H().migrate(o);
474
414
  }
475
415
  export {
476
- tt as migrateItemsBlock
416
+ Q as migrateItemsBlock
477
417
  };
@@ -1,15 +1,14 @@
1
- import { ModificationDescription as d, UIElementType as s, UEAttr as p } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- import { CommonControl as T } from "../../../common-control.js";
3
- import { nameMaxWidthFor as h } from "../../constants/cardLayout.js";
1
+ import { ModificationDescription as l, UIElementType as s, UEAttr as d } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { CommonControl as p } from "../../../common-control.js";
4
3
  import { ItemsBlockControlId as a } from "../../enums/controlEnums.js";
5
- import { findNameTextNode as c } from "../../utils/nameNode.js";
6
- import { getItemsBlockConfig as r, setItemsBlockConfig as g } from "../../utils/nodeConfigUtils.js";
7
- const I = a.NAME_TRIMMING, n = {
4
+ import { findNameTextNode as T } from "../../utils/nameNode.js";
5
+ import { getItemsBlockConfig as r, setItemsBlockConfig as c } from "../../utils/nodeConfigUtils.js";
6
+ const g = a.NAME_TRIMMING, i = {
8
7
  TRIMMING: "trimming"
9
8
  };
10
- class E extends T {
9
+ class y extends p {
11
10
  getId() {
12
- return I;
11
+ return g;
13
12
  }
14
13
  getTemplate() {
15
14
  return `
@@ -20,39 +19,39 @@ class E extends T {
20
19
  }
21
20
  onRender() {
22
21
  const e = r(this.currentNode);
23
- this.api.updateValues({ [n.TRIMMING]: (e == null ? void 0 : e.nameTrimming) ?? !0 }), this.api.onValueChanged(n.TRIMMING, (t) => {
22
+ this.api.updateValues({ [i.TRIMMING]: (e == null ? void 0 : e.nameTrimming) ?? !0 }), this.api.onValueChanged(i.TRIMMING, (t) => {
24
23
  this._onTrimmingChange(t);
25
24
  });
26
25
  }
27
26
  onTemplateNodeUpdated(e) {
28
27
  super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
29
28
  const t = r(this.currentNode);
30
- this.api.updateValues({ [n.TRIMMING]: (t == null ? void 0 : t.nameTrimming) ?? !0 });
29
+ this.api.updateValues({ [i.TRIMMING]: (t == null ? void 0 : t.nameTrimming) ?? !0 });
31
30
  });
32
31
  }
33
32
  _onTrimmingChange(e) {
34
- g(this.currentNode, this.api, { nameTrimming: e }), this.api.updateValues({ [n.TRIMMING]: e }), this._applyTrimmingStyles(e);
33
+ c(this.currentNode, this.api, { nameTrimming: e }), this.api.updateValues({ [i.TRIMMING]: e }), this._applyTrimmingStyles(e);
35
34
  }
36
35
  _applyTrimmingStyles(e) {
37
- const t = c(this.currentNode);
36
+ const t = T(this.currentNode);
38
37
  if (!t)
39
38
  return;
40
- const i = r(this.currentNode), m = e !== void 0 ? e : (i == null ? void 0 : i.nameTrimming) ?? !0, l = h(i == null ? void 0 : i.orientation), o = this.api.getDocumentModifier().modifyHtml(t);
41
- m ? o.setStyle("white-space", "nowrap").setStyle("overflow", "hidden").setStyle("text-overflow", "ellipsis") : o.removeStyle("white-space").removeStyle("overflow").removeStyle("text-overflow"), o.setStyle("max-width", l).apply(new d(`Text Trimming ${m ? "Enabled" : "Disabled"}`));
39
+ const n = r(this.currentNode), m = e !== void 0 ? e : (n == null ? void 0 : n.nameTrimming) ?? !0, o = this.api.getDocumentModifier().modifyHtml(t);
40
+ m ? o.setStyle("white-space", "nowrap").setStyle("overflow", "hidden").setStyle("text-overflow", "ellipsis") : o.removeStyle("white-space").removeStyle("overflow").removeStyle("text-overflow"), o.setStyle("max-width", "100%").apply(new l(`Text Trimming ${m ? "Enabled" : "Disabled"}`));
42
41
  }
43
42
  _getTextTrimming() {
44
43
  return `
45
44
  <div class="display-flex align-items-center justify-content-between">
46
45
  <${s.LABEL}
47
- ${p.LABEL.text}="${this.api.translate("Text Trimming")}"
46
+ ${d.LABEL.text}="${this.api.translate("Text Trimming")}"
48
47
  >
49
48
  </${s.LABEL}>
50
- ${this._GuToggle(n.TRIMMING)}
49
+ ${this._GuToggle(i.TRIMMING)}
51
50
  </div>
52
51
  `;
53
52
  }
54
53
  }
55
54
  export {
56
- I as CONTROL_BLOCK_ID,
57
- E as NameTrimmingControl
55
+ g as CONTROL_BLOCK_ID,
56
+ y as NameTrimmingControl
58
57
  };