@chaibuilder/sdk 3.1.26 → 3.1.28

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 (35) hide show
  1. package/dist/{IconPicker-CluS-5Mv.js → IconPicker-6JSublJp.js} +1 -1
  2. package/dist/{IconPicker-BWE43eMO.cjs → IconPicker-DpQQDK_Q.cjs} +1 -1
  3. package/dist/{apply-binding-COFSiTeM.js → apply-binding-BwPhgnhk.js} +326 -198
  4. package/dist/apply-binding-Dblf6wMG.cjs +1 -0
  5. package/dist/{code-display-BOOy3Lpy.js → code-display-DuH-UOhl.js} +1 -1
  6. package/dist/{code-display-B1O2gN5f.cjs → code-display-Dw1tAwiJ.cjs} +1 -1
  7. package/dist/code-editor-DosOD_MJ.cjs +1 -0
  8. package/dist/{code-editor-TDs5CPAW.js → code-editor-W1Kvc_mp.js} +6 -5
  9. package/dist/common-functions-B3a4xKt_.cjs +1 -0
  10. package/dist/common-functions-D2lMFR6K.js +13 -0
  11. package/dist/core.cjs +1 -1
  12. package/dist/core.d.ts +13 -2
  13. package/dist/core.js +3 -3
  14. package/dist/{css-import-modal-sHoiyimv.js → css-import-modal-CFB2YjDT.js} +1 -1
  15. package/dist/{css-import-modal-CrlmcFy4.cjs → css-import-modal-bGWZSlqv.cjs} +1 -1
  16. package/dist/{index-DFvi9z_N.js → index-hrVqQhCa.js} +2853 -2530
  17. package/dist/index-tOL3lzGY.cjs +154 -0
  18. package/dist/render.cjs +2 -2
  19. package/dist/render.d.ts +9 -0
  20. package/dist/render.js +69 -66
  21. package/dist/{rte-widget-modal-DX07GFaV.cjs → rte-widget-modal-BFwz3uU8.cjs} +1 -1
  22. package/dist/{rte-widget-modal-3KfJEwf3.js → rte-widget-modal-DioHGWr7.js} +2 -2
  23. package/dist/{tooltip-CzZ7Fvt7.cjs → tooltip-Ba1-8jmj.cjs} +1 -1
  24. package/dist/{tooltip-Bz2MxMHf.js → tooltip-DUosa-uC.js} +83 -83
  25. package/dist/ui.cjs +1 -1
  26. package/dist/ui.d.ts +14 -14
  27. package/dist/ui.js +1 -1
  28. package/dist/web-blocks.cjs +1 -1
  29. package/dist/web-blocks.js +1 -1
  30. package/package.json +3 -2
  31. package/dist/apply-binding-Dvnd_Vhq.cjs +0 -1
  32. package/dist/code-editor-B7JGUrWa.cjs +0 -1
  33. package/dist/common-functions-BGzDsf1z.js +0 -14
  34. package/dist/common-functions-BZmyleS1.cjs +0 -1
  35. package/dist/index-C4b6LcwL.cjs +0 -154
@@ -1,10 +1,10 @@
1
- import { g as ot, c as R } from "./common-functions-BGzDsf1z.js";
2
- import { isEmpty as f, flatten as ct, flatMapDeep as lt, get as d, set as E, startsWith as _, find as m, startCase as pt, forEach as $, camelCase as ut, includes as v, has as A, filter as G, some as dt, unset as H, map as tt, compact as ht, trim as gt, capitalize as mt, memoize as et, cloneDeep as M, keys as P, isString as B, isArray as C, last as yt } from "lodash-es";
3
- import { parse as bt, stringify as N } from "himalaya";
4
- import { getRegisteredChaiBlock as ft } from "@chaibuilder/runtime";
5
- import { twMerge as xt } from "tailwind-merge";
6
- const x = "#styles:", jt = "__ADD_BLOCK_INTERNAL_ROOT", qt = "@", _t = "#", st = (e) => {
7
- if (e = e.replace(x, ""), !e) return { baseClasses: "", classes: "" };
1
+ import { g as rt, c as H } from "./common-functions-D2lMFR6K.js";
2
+ import { isEmpty as x, flatten as ct, flatMapDeep as pt, get as d, set as E, startsWith as k, find as m, startCase as ut, forEach as S, camelCase as dt, includes as w, has as A, filter as Q, some as ht, unset as P, map as et, compact as yt, trim as mt, capitalize as gt, memoize as bt, cloneDeep as M, keys as R, isString as $, isArray as I, each as xt, last as ft } from "lodash-es";
3
+ import { parse as _t, stringify as D } from "himalaya";
4
+ import { getRegisteredChaiBlock as kt } from "@chaibuilder/runtime";
5
+ import { twMerge as vt } from "tailwind-merge";
6
+ const f = "#styles:", jt = "__ADD_BLOCK_INTERNAL_ROOT", qt = "@", wt = "#", st = (e) => {
7
+ if (e = e.replace(f, ""), !e) return { baseClasses: "", classes: "" };
8
8
  const a = e.split(/,(?![^\[]*\])/);
9
9
  if (a.length === 1)
10
10
  return { baseClasses: "", classes: a[0].trim() };
@@ -41,19 +41,19 @@ import.meta.vitest && describe("getSplitChaiClasses", () => {
41
41
  }
42
42
  };
43
43
  for (let a in e) {
44
- const t = st(`${x}${a}`);
44
+ const t = st(`${f}${a}`);
45
45
  expect(t).toEqual(e[a]);
46
46
  }
47
47
  });
48
48
  });
49
- const kt = (e) => {
49
+ const Bt = (e) => {
50
50
  const a = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, t = /(?:https?:\/\/)?(?:www\.)?(player)?.vimeo\.com/;
51
51
  return a.test(e) || t.test(e);
52
- }, vt = (e) => {
53
- if (f(e)) return e;
54
- const a = /<video[^>]+src=['"]([^'">]+)['"]/, t = /<iframe[^>]+src=['"]([^'">]+)['"]/, s = e.match(a), n = e.match(t), r = s ? s[1] : n ? n[1] : null, o = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, l = /(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;
55
- return r && (o.test(r) || l.test(r)) ? r : e;
56
- }, at = ["chai-name", "data-chai-name"], wt = {
52
+ }, Tt = (e) => {
53
+ if (x(e)) return e;
54
+ const a = /<video[^>]+src=['"]([^'">]+)['"]/, t = /<iframe[^>]+src=['"]([^'">]+)['"]/, s = e.match(a), n = e.match(t), o = s ? s[1] : n ? n[1] : null, l = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, i = /(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;
55
+ return o && (l.test(o) || i.test(o)) ? o : e;
56
+ }, nt = ["chai-name", "data-chai-name"], Et = {
57
57
  img: { alt: "alt", width: "width", height: "height", src: "image" },
58
58
  video: {
59
59
  src: "url",
@@ -89,58 +89,58 @@ const kt = (e) => {
89
89
  form: {
90
90
  action: "action"
91
91
  }
92
- }, Tt = (e, a) => e.children.length === 1 && v(
92
+ }, $t = (e, a) => e.children.length === 1 && w(
93
93
  ["Heading", "Paragraph", "Span", "ListItem", "Button", "Label", "TableCell", "Link", "RichText"],
94
94
  a._type
95
- ), j = (e) => e.map((a) => a.type === "text" ? d(a, "content", "") : f(a.children) ? "" : j(a.children)).join(""), S = (e) => e === null ? "" : e, nt = (e) => {
96
- const a = ht(tt(e.split(/\s+/), gt)), t = m(a, (l) => /^w-/.test(l)), s = m(a, (l) => /^h-/.test(l));
95
+ ), j = (e) => e.map((a) => a.type === "text" ? d(a, "content", "") : x(a.children) ? "" : j(a.children)).join(""), W = (e) => e === null ? "" : e, at = (e) => {
96
+ const a = yt(et(e.split(/\s+/), mt)), t = m(a, (i) => /^w-/.test(i)), s = m(a, (i) => /^h-/.test(i));
97
97
  if (!s || !t) return { height: "", width: "" };
98
- const n = (l) => {
99
- if (!l) return;
100
- const g = l.match(/^[wh]-(?:\[(.*?)\]|(.+))$/);
101
- if (!g) return;
102
- if (g[1]) return g[1];
103
- const i = g[2];
104
- return /^\d+(\.\d+)?$/.test(i) ? `${Number(i) * 4}px` : i === "auto" || v(i, "%") ? i : "16px";
105
- }, r = n(t), o = n(s);
98
+ const n = (i) => {
99
+ if (!i) return;
100
+ const h = i.match(/^[wh]-(?:\[(.*?)\]|(.+))$/);
101
+ if (!h) return;
102
+ if (h[1]) return h[1];
103
+ const r = h[2];
104
+ return /^\d+(\.\d+)?$/.test(r) ? `${Number(r) * 4}px` : r === "auto" || w(r, "%") ? r : "16px";
105
+ }, o = n(t), l = n(s);
106
106
  return {
107
- width: v(r, "px") ? r : "16px",
108
- height: v(o, "px") ? o : "16px"
107
+ width: w(o, "px") ? o : "16px",
108
+ height: w(l, "px") ? l : "16px"
109
109
  };
110
- }, Q = (e) => {
110
+ }, tt = (e) => {
111
111
  if (e.tagName === "svg") return {};
112
- const a = {}, t = wt[e.tagName] || {}, s = e.attributes;
113
- return $(s, ({ key: n, value: r }) => {
114
- if (!v(at, n))
115
- if (n === "bid" && (a._bid = S(r)), t[n]) {
116
- if (e.tagName === "img" && n === "src" && !r.startsWith("http")) {
117
- const o = m(e.attributes, { key: "width" }), l = m(e.attributes, { key: "height" });
118
- o && l ? r = `https://picsum.photos/${o == null ? void 0 : o.value}x${l == null ? void 0 : l.value}` : r = "https://picsum.photos/150x150";
112
+ const a = {}, t = Et[e.tagName] || {}, s = e.attributes;
113
+ return S(s, ({ key: n, value: o }) => {
114
+ if (!w(nt, n))
115
+ if (n === "bid" && (a._bid = W(o)), t[n]) {
116
+ if (e.tagName === "img" && n === "src" && !o.startsWith("http")) {
117
+ const l = m(e.attributes, { key: "width" }), i = m(e.attributes, { key: "height" });
118
+ l && i ? o = `https://picsum.photos/${l == null ? void 0 : l.value}x${i == null ? void 0 : i.value}` : o = "https://picsum.photos/150x150";
119
119
  }
120
- E(a, t[n], S(r));
121
- } else v(["style", "class", "srcset", "bid"], n) || (A(a, "styles_attrs") || (a.styles_attrs = {}), _(n, "@") && (n = n.replace("@", "x-on:")), a.styles_attrs[`${n}`] = S(r));
120
+ E(a, t[n], W(o));
121
+ } else w(["style", "class", "srcset", "bid"], n) || (A(a, "styles_attrs") || (a.styles_attrs = {}), k(n, "@") && (n = n.replace("@", "x-on:")), a.styles_attrs[`${n}`] = W(o));
122
122
  }), delete a.class, a;
123
- }, Et = (e, a = "styles") => {
124
- if (!e.attributes) return { [a]: `${x},` };
123
+ }, St = (e, a = "styles") => {
124
+ if (!e.attributes) return { [a]: `${f},` };
125
125
  const t = m(e.attributes, { key: "class" });
126
126
  if (t) {
127
127
  const s = t.value;
128
- return { [a]: `${x},${s}` };
128
+ return { [a]: `${f},${s}` };
129
129
  }
130
- return { [a]: `${x},` };
131
- }, $t = (e) => {
132
- const a = d(e, "attributes", []), t = a.find((i) => i.key === "data-chai-richtext" || i.key === "chai-richtext"), s = a.find((i) => i.key === "data-chai-lightbox" || i.key === "chai-lightbox"), n = a.find((i) => i.key === "data-chai-dropdown" || i.key === "chai-dropdown"), r = a.find(
133
- (i) => i.key === "data-chai-dropdown-button" || i.key === "chai-dropdown-button"
134
- ), o = a.find(
135
- (i) => i.key === "data-chai-dropdown-content" || i.key === "chai-dropdown-content"
136
- ), l = a.find((i) => i.key === "class"), g = l && l.value.split(/\s+/).includes("rte");
130
+ return { [a]: `${f},` };
131
+ }, Nt = (e) => {
132
+ const a = d(e, "attributes", []), t = a.find((r) => r.key === "data-chai-richtext" || r.key === "chai-richtext"), s = a.find((r) => r.key === "data-chai-lightbox" || r.key === "chai-lightbox"), n = a.find((r) => r.key === "data-chai-dropdown" || r.key === "chai-dropdown"), o = a.find(
133
+ (r) => r.key === "data-chai-dropdown-button" || r.key === "chai-dropdown-button"
134
+ ), l = a.find(
135
+ (r) => r.key === "data-chai-dropdown-content" || r.key === "chai-dropdown-content"
136
+ ), i = a.find((r) => r.key === "class"), h = i && i.value.split(/\s+/).includes("rte");
137
137
  if (n)
138
138
  return { _type: "Dropdown" };
139
- if (r)
140
- return { _type: "DropdownButton" };
141
139
  if (o)
140
+ return { _type: "DropdownButton" };
141
+ if (l)
142
142
  return { _type: "DropdownContent" };
143
- if (t || g)
143
+ if (t || h)
144
144
  return { _type: "Paragraph" };
145
145
  if (s)
146
146
  return { _type: "LightBoxLink" };
@@ -222,58 +222,58 @@ const kt = (e) => {
222
222
  case "tfoot":
223
223
  return { _type: "TableFooter" };
224
224
  default: {
225
- const i = d(e, "children", []).length > 0 ? "Box" : "EmptyBox";
225
+ const r = d(e, "children", []).length > 0 ? "Box" : "EmptyBox";
226
226
  return {
227
- _type: i,
227
+ _type: r,
228
228
  tag: e.tagName,
229
- _name: i == "EmptyBox" || e.tagName === "div" ? i : mt(e.tagName)
229
+ _name: r == "EmptyBox" || e.tagName === "div" ? r : gt(e.tagName)
230
230
  };
231
231
  }
232
232
  }
233
- }, q = (e, a = null) => lt(e, (t) => {
234
- var J, O, z, V, W, F, U, Y, K, X;
233
+ }, q = (e, a = null) => pt(e, (t) => {
234
+ var O, V, J, z, F, U, Y, K, X, Z;
235
235
  if (t.type === "comment") return [];
236
- let s = { _id: ot() };
236
+ let s = { _id: rt() };
237
237
  if (a && (s._parent = a.block._id), t.type === "text")
238
- return f(d(t, "content", "")) ? [] : a && Tt(a.node, a.block) ? (E(a, "block.content", d(t, "content", "")), []) : { ...s, _type: "Text", content: d(t, "content", "") };
239
- if (_(t.tagName, "chai-")) {
240
- const c = t.attributes, p = m(c, { key: "chai-type" }), u = (p == null ? void 0 : p.value) || pt(t.tagName.replace("chai-", "")).replace(/\s+/g, "");
241
- s._type = u, $(c, ({ key: y, value: Z }) => {
242
- if (y === "about-this-component" || y === "chai-type" || y === "can-move" || y === "can-delete") return;
243
- if (y === "id") {
244
- s._id = Z;
238
+ return x(d(t, "content", "")) ? [] : a && $t(a.node, a.block) ? (E(a, "block.content", d(t, "content", "")), []) : { ...s, _type: "Text", content: d(t, "content", "") };
239
+ if (k(t.tagName, "chai-")) {
240
+ const c = t.attributes, p = m(c, { key: "chai-type" }), u = (p == null ? void 0 : p.value) || ut(t.tagName.replace("chai-", "")).replace(/\s+/g, "");
241
+ s._type = u, S(c, ({ key: g, value: G }) => {
242
+ if (g === "about-this-component" || g === "chai-type" || g === "can-move" || g === "can-delete") return;
243
+ if (g === "id") {
244
+ s._id = G;
245
245
  return;
246
246
  }
247
- const rt = _(y, "_") ? y : ut(y);
248
- let I = S(Z);
249
- typeof I == "string" && _(I, "#styles:") && (I = I.replace("#styles:", "#styles:,")), s[rt] = I;
247
+ const lt = k(g, "_") ? g : dt(g);
248
+ let N = W(G);
249
+ typeof N == "string" && k(N, "#styles:") && (N = N.replace("#styles:", "#styles:,")), s[lt] = N;
250
250
  });
251
- const h = q(t.children, { block: s, node: t });
252
- return [s, ...h];
251
+ const y = q(t.children, { block: s, node: t });
252
+ return [s, ...y];
253
253
  }
254
- const n = d(t, "attributes", []), r = n.find(
254
+ const n = d(t, "attributes", []), o = n.find(
255
255
  (c) => c.key === "data-chai-richtext" || c.key === "chai-richtext"
256
- ), o = n.find((c) => c.key === "class"), l = o && o.value.split(/\s+/).includes("rte"), g = n.find(
256
+ ), l = n.find((c) => c.key === "class"), i = l && l.value.split(/\s+/).includes("rte"), h = n.find(
257
257
  (c) => c.key === "data-chai-lightbox" || c.key === "chai-lightbox"
258
- ), i = n.find(
258
+ ), r = n.find(
259
259
  (c) => c.key === "data-chai-dropdown" || c.key === "chai-dropdown"
260
- ), w = n.find(
260
+ ), B = n.find(
261
261
  (c) => c.key === "data-chai-dropdown-button" || c.key === "chai-dropdown-button"
262
- ), D = n.find(
262
+ ), C = n.find(
263
263
  (c) => c.key === "data-chai-dropdown-content" || c.key === "chai-dropdown-content"
264
264
  );
265
265
  if (s = {
266
266
  ...s,
267
- ...$t(t),
268
- ...Q(t),
269
- ...Et(t)
267
+ ...Nt(t),
268
+ ...tt(t),
269
+ ...St(t)
270
270
  }, t.attributes) {
271
- const c = t.attributes.find((p) => v(at, p.key));
271
+ const c = t.attributes.find((p) => w(nt, p.key));
272
272
  c && (s._name = c.value);
273
273
  }
274
- if (r || l)
275
- return s.content = N(t.children), A(s, "styles_attrs.data-chai-richtext") && delete s.styles_attrs["data-chai-richtext"], A(s, "styles_attrs.chai-richtext") && delete s.styles_attrs["chai-richtext"], [s];
276
- if (g) {
274
+ if (o || i)
275
+ return s.content = D(t.children), A(s, "styles_attrs.data-chai-richtext") && delete s.styles_attrs["data-chai-richtext"], A(s, "styles_attrs.chai-richtext") && delete s.styles_attrs["chai-richtext"], [s];
276
+ if (h) {
277
277
  const c = [
278
278
  "data-chai-lightbox",
279
279
  "chai-lightbox",
@@ -286,30 +286,30 @@ const kt = (e) => {
286
286
  ];
287
287
  s = {
288
288
  ...s,
289
- href: ((J = n.find((p) => p.key === "href")) == null ? void 0 : J.value) || "",
290
- hrefType: ((O = n.find((p) => p.key === "data-vbtype")) == null ? void 0 : O.value) || "video",
291
- autoplay: ((z = n.find((p) => p.key === "data-autoplay")) == null ? void 0 : z.value) === "true" ? "true" : "false",
292
- maxWidth: ((W = (V = n.find((p) => p.key === "data-maxwidth")) == null ? void 0 : V.value) == null ? void 0 : W.replace("px", "")) || "",
293
- backdropColor: ((F = n.find((p) => p.key === "data-overlay")) == null ? void 0 : F.value) || "",
294
- galleryName: ((U = n.find((p) => p.key === "data-gall")) == null ? void 0 : U.value) || ""
295
- }, $(c, (p) => {
289
+ href: ((O = n.find((p) => p.key === "href")) == null ? void 0 : O.value) || "",
290
+ hrefType: ((V = n.find((p) => p.key === "data-vbtype")) == null ? void 0 : V.value) || "video",
291
+ autoplay: ((J = n.find((p) => p.key === "data-autoplay")) == null ? void 0 : J.value) === "true" ? "true" : "false",
292
+ maxWidth: ((F = (z = n.find((p) => p.key === "data-maxwidth")) == null ? void 0 : z.value) == null ? void 0 : F.replace("px", "")) || "",
293
+ backdropColor: ((U = n.find((p) => p.key === "data-overlay")) == null ? void 0 : U.value) || "",
294
+ galleryName: ((Y = n.find((p) => p.key === "data-gall")) == null ? void 0 : Y.value) || ""
295
+ }, S(c, (p) => {
296
296
  A(s, `styles_attrs.${p}`) && delete s.styles_attrs[p];
297
297
  });
298
298
  }
299
- if (i && (delete s.styles_attrs, s.showDropdown = !1), D && delete s.styles_attrs, w) {
299
+ if (r && (delete s.styles_attrs, s.showDropdown = !1), C && delete s.styles_attrs, B) {
300
300
  delete s.styles_attrs;
301
- const c = G(t.children || [], (u) => (u == null ? void 0 : u.tagName) !== "span");
301
+ const c = Q(t.children || [], (u) => (u == null ? void 0 : u.tagName) !== "span");
302
302
  s.content = j(c);
303
303
  const p = m(
304
304
  t.children || [],
305
- (u) => (u == null ? void 0 : u.tagName) === "span" && dt(u.children || [], (h) => (h == null ? void 0 : h.tagName) === "svg")
305
+ (u) => (u == null ? void 0 : u.tagName) === "span" && ht(u.children || [], (y) => (y == null ? void 0 : y.tagName) === "svg")
306
306
  );
307
307
  if (p) {
308
- const u = m(p.children || [], (h) => (h == null ? void 0 : h.tagName) === "svg");
308
+ const u = m(p.children || [], (y) => (y == null ? void 0 : y.tagName) === "svg");
309
309
  if (u) {
310
- s.icon = N([u]);
311
- const { height: h, width: y } = Bt(u, "16px", "16px");
312
- s.iconHeight = h, s.iconWidth = y;
310
+ s.icon = D([u]);
311
+ const { height: y, width: g } = It(u, "16px", "16px");
312
+ s.iconHeight = y, s.iconWidth = g;
313
313
  }
314
314
  }
315
315
  return [s];
@@ -318,122 +318,249 @@ const kt = (e) => {
318
318
  const c = s.inputType || "text";
319
319
  c === "checkbox" ? E(s, "_type", "Checkbox") : c === "radio" && E(s, "_type", "Radio");
320
320
  } else if (t.tagName === "video" || t.tagName === "iframe") {
321
- const c = N([t]);
322
- return kt(c) && (E(s, "_type", "Video"), E(s, "url", vt(c)), E(s, "styles", `${x},`), E(s, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), s.content = c, [s];
321
+ const c = D([t]);
322
+ return Bt(c) && (E(s, "_type", "Video"), E(s, "url", Tt(c)), E(s, "styles", `${f},`), E(s, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), s.content = c, [s];
323
323
  } else if (t.tagName === "svg") {
324
- const c = d(m(t.attributes, { key: "class" }), "value", ""), { height: p, width: u } = nt(c);
324
+ const c = d(m(t.attributes, { key: "class" }), "value", ""), { height: p, width: u } = at(c);
325
325
  if (p && u)
326
- s.styles = `${x}, ${R(`w-${u} h-${p}`, c)}`.trim(), s.height = p == null ? void 0 : p.replace("px", ""), s.width = u == null ? void 0 : u.replace("px", "");
326
+ s.styles = `${f}, ${H(`w-${u} h-${p}`, c)}`.trim(), s.height = p == null ? void 0 : p.replace("px", ""), s.width = u == null ? void 0 : u.replace("px", "");
327
327
  else {
328
- const h = (Y = m(t.attributes, { key: "height" })) == null ? void 0 : Y.value, y = (K = m(t.attributes, { key: "width" })) == null ? void 0 : K.value;
329
- h && y ? (s.styles = `${x}, ${R(`w-[${y}px] h-[${h}px]`, c)}`.trim(), s.height = h, s.width = y) : s.styles = `${x}, ${R("w-full h-full", c)}`.trim();
328
+ const y = (K = m(t.attributes, { key: "height" })) == null ? void 0 : K.value, g = (X = m(t.attributes, { key: "width" })) == null ? void 0 : X.value;
329
+ y && g ? (s.styles = `${f}, ${H(`w-[${g}px] h-[${y}px]`, c)}`.trim(), s.height = y, s.width = g) : s.styles = `${f}, ${H("w-full h-full", c)}`.trim();
330
330
  }
331
- return t.attributes = G(t.attributes, (h) => !v(["style", "width", "height", "class"], h.key)), s.icon = N([t]), [s];
332
- } else if (t.tagName == "option" && a && ((X = a.block) == null ? void 0 : X._type) === "Select")
331
+ return t.attributes = Q(t.attributes, (y) => !w(["style", "width", "height", "class"], y.key)), s.icon = D([t]), [s];
332
+ } else if (t.tagName == "option" && a && ((Z = a.block) == null ? void 0 : Z._type) === "Select")
333
333
  return a.block.options.push({
334
334
  label: j(t.children),
335
- ...Q(t)
335
+ ...tt(t)
336
336
  }), [];
337
337
  const T = q(t.children, { block: s, node: t });
338
338
  return [s, ...T];
339
- }), Bt = (e, a, t) => {
340
- var g, i;
341
- const s = d(e, "attributes", []), { height: n, width: r } = nt(
339
+ }), It = (e, a, t) => {
340
+ var h, r;
341
+ const s = d(e, "attributes", []), { height: n, width: o } = at(
342
342
  d(m(s, { key: "class" }), "value", "")
343
343
  );
344
- if (n && r)
344
+ if (n && o)
345
345
  return {
346
346
  height: `[${n}px]`,
347
- width: `[${r}px]`
347
+ width: `[${o}px]`
348
348
  };
349
- const o = (g = m(s, { key: "height" })) == null ? void 0 : g.value, l = (i = m(s, { key: "width" })) == null ? void 0 : i.value;
349
+ const l = (h = m(s, { key: "height" })) == null ? void 0 : h.value, i = (r = m(s, { key: "width" })) == null ? void 0 : r.value;
350
350
  return {
351
- height: o ? `[${o}px]` : t,
352
- width: l ? `[${l}px]` : a
351
+ height: l ? `[${l}px]` : t,
352
+ width: i ? `[${i}px]` : a
353
353
  };
354
- }, It = (e) => {
355
- e = e.replace(/(\w+)=\\?"(.*?)\\?"/g, (s, n, r) => {
356
- let o = r.replace(/\\"/g, '"');
357
- return o = o.replace(/{([^}]+)}/g, (l) => l.replace(/"/g, '\\"')), `${n}="${o.replace(/\\"/g, '"')}"`;
354
+ }, Ct = (e) => {
355
+ e = e.replace(/(\w+)=\\?"(.*?)\\?"/g, (s, n, o) => {
356
+ let l = o.replace(/\\"/g, '"');
357
+ return l = l.replace(/{([^}]+)}/g, (i) => i.replace(/"/g, '\\"')), `${n}="${l.replace(/\\"/g, '"')}"`;
358
358
  }), e = e.replace(/\\n/g, "").replace(/\\\\/g, "").replace(/\\([/<>])/g, "$1").replace(/\\./g, "").replace(/[\n\r\t\f\v]/g, ""), e = e.replace(/\$name="[^"]*"/g, "");
359
359
  const a = e.match(/<body[^>]*>[\s\S]*?<\/body>/);
360
360
  return (a && a.length > 0 ? a[0].replace(/<body/, "<div").replace(/<\/body>/, "</div>") : e).replace(/\s+/g, " ").replaceAll("> <", "><").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "").trim();
361
- }, Ct = (e, a) => m(e, { _id: a }), Mt = (e, a) => f(a) ? e.map((t) => (H(t, "_bid"), t)) : tt(e, (t) => {
362
- const s = f(t._bid) ? void 0 : Ct(a, t._bid);
361
+ }, Dt = (e, a) => m(e, { _id: a }), Mt = (e, a) => x(a) ? e.map((t) => (P(t, "_bid"), t)) : et(e, (t) => {
362
+ const s = x(t._bid) ? void 0 : Dt(a, t._bid);
363
363
  if (s) {
364
364
  s._type === "Icon" && d(t, "icon", "").match(/chai-default-svg/) && delete t.icon;
365
365
  const n = { ...s, ...t };
366
- return H(n, "_bid"), n;
366
+ return P(n, "_bid"), n;
367
367
  }
368
- return H(t, "_bid"), t;
369
- }), Pt = (e) => {
370
- const a = bt(It(e));
371
- return f(e) ? [] : ct(q(a));
368
+ return P(t, "_bid"), t;
369
+ }), Ot = (e) => {
370
+ const a = _t(Ct(e));
371
+ return x(e) ? [] : ct(q(a));
372
372
  };
373
- function Jt(e, a, t) {
373
+ function Vt(e, a, t) {
374
374
  const s = d(t, "i18nProps", []);
375
- if (f(a) || f(s)) return e;
375
+ if (x(a) || x(s)) return e;
376
376
  const n = M(e);
377
- return $(P(n), (r) => {
378
- if (v(s, r) && !f(a)) {
379
- const o = d(n, r), l = d(n, `${r}-${a}`, "");
380
- B(o) ? n[r] = B(l) && !f(l.trim()) && l.trimStart() || o : n[r] = f(l) ? o : l;
377
+ return S(R(n), (o) => {
378
+ if (w(s, o) && !x(a)) {
379
+ const l = d(n, o), i = d(n, `${o}-${a}`, "");
380
+ $(l) ? n[o] = $(i) && !x(i.trim()) && i.trimStart() || l : n[o] = x(i) ? l : i;
381
381
  }
382
382
  }), n;
383
383
  }
384
- const Dt = et((e) => {
385
- const { baseClasses: a, classes: t } = st(e);
386
- return xt(a, t);
387
- });
388
- function Nt(e, a) {
384
+ const ot = (e, a) => {
385
+ const { baseClasses: t, classes: s } = st(e), o = s.split(" ").filter((i) => i.startsWith("dt-")).map((i) => {
386
+ var h;
387
+ return (h = a[i.replace("dt-", "")]) == null ? void 0 : h.value;
388
+ }), l = s.split(" ").filter((i) => !i.startsWith("dt-")).join(" ");
389
+ return vt.apply(null, [t, ...o, l]);
390
+ };
391
+ function Lt(e, a) {
389
392
  return d(e, `${a}_attrs`, {});
390
393
  }
391
- function Ot(e, a = !0) {
392
- const t = {};
393
- return Object.keys(e).forEach((s) => {
394
- if (B(e[s]) && e[s].startsWith(x)) {
395
- const n = Dt(e[s]), r = Nt(e, s);
396
- t[s] = {
397
- ...!f(n) && { className: n },
398
- ...r,
394
+ function Jt(e, a = !0, t = {}) {
395
+ const s = {};
396
+ return Object.keys(e).forEach((n) => {
397
+ if ($(e[n]) && e[n].startsWith(f)) {
398
+ const o = ot(e[n], t), l = Lt(e, n);
399
+ s[n] = {
400
+ ...!x(o) && { className: o },
401
+ ...l,
399
402
  ...a ? {
400
- "data-style-prop": s,
403
+ "data-style-prop": n,
401
404
  "data-block-parent": e._id,
402
- "data-style-id": `${s}-${e._id}`
405
+ "data-style-id": `${n}-${e._id}`
403
406
  } : {}
404
407
  };
405
408
  }
406
- }), t;
409
+ }), s;
407
410
  }
408
- const zt = et((e) => {
409
- const a = ft(e), t = d(a, "schema.properties", {});
411
+ const zt = bt((e) => {
412
+ const a = kt(e), t = d(a, "schema.properties", {});
410
413
  return Object.fromEntries(Object.entries(t).filter(([, s]) => d(s, "runtime", !1)));
411
- }), Vt = (e, a) => {
412
- if (!C(e)) return e;
414
+ }), Ft = (e, a) => {
415
+ if (!I(e)) return e;
413
416
  let t = e, s;
414
417
  return typeof a.limit == "number" && a.limit > 0 && (s = a.limit), s !== void 0 && (t = t.slice(0, s)), t;
415
- }, Wt = (e, a) => {
418
+ }, Ut = (e, a) => {
416
419
  const t = M(e);
417
- return $(P(t), (s) => {
418
- if (B(t[s]) && !_(s, "_")) {
420
+ return S(R(t), (s) => {
421
+ if ($(t[s]) && !k(s, "_")) {
419
422
  let n = t[s];
420
423
  s === "repeaterItems" && (t.repeaterItemsBinding = n);
421
- const r = /\{\{(.*?)\}\}/g, o = n.match(r);
422
- o && o.forEach((l) => {
423
- let g = l.slice(2, -2);
424
- const i = d(a, g, l);
425
- n = C(i) ? i : n.replace(l, i);
424
+ const o = /\{\{(.*?)\}\}/g, l = n.match(o);
425
+ l && l.forEach((i) => {
426
+ let h = i.slice(2, -2);
427
+ const r = d(a, h, i);
428
+ n = I(r) ? r : n.replace(i, r);
426
429
  }), t[s] = n;
427
430
  }
428
431
  }), t;
429
- }, k = (e) => {
430
- const a = yt(e);
432
+ }, _ = (e, a) => e.map((t) => {
433
+ const s = R(t).filter((n) => $(t[n]) && t[n].startsWith(f));
434
+ return xt(s, (n) => {
435
+ t[n] = `${f},${ot(t[n], a)}`;
436
+ }), t;
437
+ });
438
+ import.meta.vitest && describe("applyDesignTokens", () => {
439
+ const e = {
440
+ token1: { name: "primary-color", value: "bg-blue-500" },
441
+ token2: { name: "text-size", value: "text-lg" },
442
+ token3: { name: "spacing", value: "p-4" }
443
+ }, a = [
444
+ {
445
+ _id: "block1",
446
+ _type: "div",
447
+ styles: "#styles:,dt-token1bg-white text-sm",
448
+ className: "#styles:,dt-token2 dt-token3",
449
+ otherProp: "not-a-style",
450
+ _name: "Test Block"
451
+ },
452
+ {
453
+ _id: "block2",
454
+ _type: "button",
455
+ styles: "#styles:bg-red-500",
456
+ nonStringProp: 123,
457
+ _name: "Button Block"
458
+ },
459
+ {
460
+ _id: "block3",
461
+ _type: "span",
462
+ noStyles: "regular-string",
463
+ _name: "No Styles Block"
464
+ }
465
+ ];
466
+ it("should process blocks and replace style properties with generated class names", () => {
467
+ const t = _(a, e);
468
+ expect(t).toHaveLength(3), expect(t[0].styles).toBe("#styles:,text-sm"), expect(t[0].className).toBe("#styles:,text-lg p-4"), expect(t[0].otherProp).toBe("not-a-style"), expect(t[0]._id).toBe("block1"), expect(t[0]._type).toBe("div");
469
+ }), it("should handle blocks with no style properties", () => {
470
+ const t = _(a, e);
471
+ expect(t[2].noStyles).toBe("regular-string"), expect(t[2]._id).toBe("block3");
472
+ }), it("should handle empty blocks array", () => {
473
+ const t = _([], e);
474
+ expect(t).toEqual([]);
475
+ }), it("should handle empty design tokens", () => {
476
+ const t = _(a, {});
477
+ expect(t[0].styles).toBe("#styles:,text-sm");
478
+ }), it("should handle blocks with only style prefix", () => {
479
+ const s = _([
480
+ {
481
+ _id: "block1",
482
+ _type: "div",
483
+ styles: "#styles:",
484
+ _name: "Prefix Only"
485
+ }
486
+ ], e);
487
+ expect(s[0].styles).toBe("#styles:,");
488
+ }), it("should handle blocks with multiple style properties", () => {
489
+ const s = _([
490
+ {
491
+ _id: "block1",
492
+ _type: "div",
493
+ styles: "#styles:bg-white dt-token1",
494
+ hoverStyles: "#styles:bg-gray-100 dt-token2",
495
+ focusStyles: "#styles:outline-none dt-token3",
496
+ _name: "Multi Style"
497
+ }
498
+ ], e);
499
+ expect(s[0].styles).toBe("#styles:,bg-white"), expect(s[0].hoverStyles).toBe("#styles:,text-lg bg-gray-100"), expect(s[0].focusStyles).toBe("#styles:,p-4 outline-none");
500
+ }), it("should not modify non-string properties that start with #styles:", () => {
501
+ const s = _([
502
+ {
503
+ _id: "block1",
504
+ _type: "div",
505
+ styles: "#styles:bg-white",
506
+ objectStyles: { startsWith: "#styles:" },
507
+ arrayStyles: ["#styles:bg-red-500"],
508
+ _name: "Non String Styles"
509
+ }
510
+ ], e);
511
+ expect(s[0].styles).toBe("#styles:,bg-white"), expect(s[0].objectStyles).toEqual({ startsWith: "#styles:" }), expect(s[0].arrayStyles).toEqual(["#styles:bg-red-500"]);
512
+ }), it("should handle undefined and null values", () => {
513
+ const s = _([
514
+ {
515
+ _id: "block1",
516
+ _type: "div",
517
+ styles: "#styles:bg-white",
518
+ nullStyles: null,
519
+ undefinedStyles: void 0,
520
+ _name: " Null Undefined"
521
+ }
522
+ ], e);
523
+ expect(s[0].styles).toBe("#styles:,bg-white"), expect(s[0].nullStyles).toBeNull(), expect(s[0].undefinedStyles).toBeUndefined();
524
+ }), it("should preserve block structure and non-style properties", () => {
525
+ _(a, e).forEach((s, n) => {
526
+ expect(s._id).toBe(a[n]._id), expect(s._type).toBe(a[n]._type), expect(s._name).toBe(a[n]._name);
527
+ });
528
+ }), it("should handle complex design token values", () => {
529
+ const n = _([
530
+ {
531
+ _id: "block1",
532
+ _type: "div",
533
+ styles: "#styles:bg-white dt-complex1",
534
+ _name: "Complex Tokens"
535
+ }
536
+ ], {
537
+ complex1: { name: "complex-token", value: "hover:bg-blue-600 focus:outline-none transition-colors" },
538
+ complex2: { name: "spacing-token", value: "px-6 py-3 m-2" }
539
+ });
540
+ expect(n[0].styles).toBe("#styles:,hover:bg-blue-600 focus:outline-none transition-colors bg-white");
541
+ }), it("should handle tokens with empty values", () => {
542
+ const n = _([
543
+ {
544
+ _id: "block1",
545
+ _type: "div",
546
+ styles: "#styles:bg-white dt-empty1 dt-valid1",
547
+ _name: "Empty Value Tokens"
548
+ }
549
+ ], {
550
+ empty1: { name: "empty-token", value: "" },
551
+ valid1: { name: "valid-token", value: "bg-green-500" }
552
+ });
553
+ expect(n[0].styles).toBe("#styles:,bg-white");
554
+ });
555
+ });
556
+ const v = (e) => {
557
+ const a = ft(e);
431
558
  return e.map((t) => {
432
559
  const s = Object.keys(t);
433
560
  for (let n = 0; n < s.length; n++)
434
- if (B(t[s[n]]) && _(s[n], "content")) {
435
- const r = t === a ? "" : " ";
436
- t[s[n]] = `${t[s[n]].trim()}${r}`;
561
+ if ($(t[s[n]]) && k(s[n], "content")) {
562
+ const o = t === a ? "" : " ";
563
+ t[s[n]] = `${t[s[n]].trim()}${o}`;
437
564
  }
438
565
  return t;
439
566
  });
@@ -442,50 +569,50 @@ if (import.meta.vitest) {
442
569
  const { describe: e, it: a, expect: t } = import.meta.vitest;
443
570
  e("adjustSpacingInContentBlocks", () => {
444
571
  a("should add space after content fields except for the last block", () => {
445
- const n = k([
572
+ const n = v([
446
573
  { _id: "1", _type: "Text", content: "First" },
447
574
  { _id: "2", _type: "Text", content: "Second" },
448
575
  { _id: "3", _type: "Text", content: "Third" }
449
576
  ]);
450
577
  t(n[0].content).toBe("First "), t(n[1].content).toBe("Second "), t(n[2].content).toBe("Third");
451
578
  }), a("should trim whitespace from content before adding space", () => {
452
- const n = k([
579
+ const n = v([
453
580
  { _id: "1", _type: "Text", content: " First " },
454
581
  { _id: "2", _type: "Text", content: " Second " }
455
582
  ]);
456
583
  t(n[0].content).toBe("First "), t(n[1].content).toBe("Second");
457
584
  }), a("should handle multiple content fields in a single block", () => {
458
- const n = k([
585
+ const n = v([
459
586
  { _id: "1", _type: "Text", content: "Main", contentAlt: "Alt" },
460
587
  { _id: "2", _type: "Text", content: "Last", contentSecondary: "Secondary" }
461
588
  ]);
462
589
  t(n[0].content).toBe("Main "), t(n[0].contentAlt).toBe("Alt "), t(n[1].content).toBe("Last"), t(n[1].contentSecondary).toBe("Secondary");
463
590
  }), a("should only process fields that start with 'content'", () => {
464
- const n = k([
591
+ const n = v([
465
592
  { _id: "1", _type: "Text", content: "Text", title: "Title", text: "Text" },
466
593
  { _id: "2", _type: "Text", content: "Last" }
467
594
  ]);
468
595
  t(n[0].content).toBe("Text "), t(n[0].title).toBe("Title"), t(n[0].text).toBe("Text"), t(n[1].content).toBe("Last");
469
596
  }), a("should handle empty array", () => {
470
- const n = k([]);
597
+ const n = v([]);
471
598
  t(n).toEqual([]);
472
599
  }), a("should handle single block", () => {
473
- const n = k([{ _id: "1", _type: "Text", content: "Only" }]);
600
+ const n = v([{ _id: "1", _type: "Text", content: "Only" }]);
474
601
  t(n[0].content).toBe("Only");
475
602
  }), a("should handle blocks without content fields", () => {
476
- const n = k([
603
+ const n = v([
477
604
  { _id: "1", _type: "Container", title: "Title" },
478
605
  { _id: "2", _type: "Container", name: "Name" }
479
606
  ]);
480
607
  t(n[0].title).toBe("Title"), t(n[1].name).toBe("Name");
481
608
  }), a("should handle blocks with non-string content fields", () => {
482
- const n = k([
609
+ const n = v([
483
610
  { _id: "1", _type: "Text", content: "Text", contentNum: 123 },
484
611
  { _id: "2", _type: "Text", content: "Last", contentBool: !0 }
485
612
  ]);
486
613
  t(n[0].content).toBe("Text "), t(n[0].contentNum).toBe(123), t(n[1].content).toBe("Last"), t(n[1].contentBool).toBe(!0);
487
614
  }), a("should handle empty string content", () => {
488
- const n = k([
615
+ const n = v([
489
616
  { _id: "1", _type: "Text", content: "" },
490
617
  { _id: "2", _type: "Text", content: "Last" }
491
618
  ]);
@@ -494,32 +621,32 @@ if (import.meta.vitest) {
494
621
  });
495
622
  }
496
623
  const b = (e, a, { index: t, key: s }, n) => {
497
- if (B(e)) {
498
- let r = e;
499
- const o = /\{\{(.*?)\}\}/g, l = e.match(o);
500
- if (l) {
501
- const g = n === "image" || n === "mobileImage";
502
- l.forEach((i) => {
503
- let w = i.slice(2, -2).trim(), D = s.slice(2, -2).trim();
504
- t !== -1 && _(w, "$index.") ? w = `${D}.${t}.${w.slice(7)}` : t !== -1 && _(w, "$index") && (w = `${D}.${t}`);
505
- const T = d(a, w);
506
- T === void 0 ? r = r.replace(i, "") : g && !C(T) ? r = T : r = C(T) ? T : r.replace(i, T);
624
+ if ($(e)) {
625
+ let o = e;
626
+ const l = /\{\{(.*?)\}\}/g, i = e.match(l);
627
+ if (i) {
628
+ const h = n === "image" || n === "mobileImage";
629
+ i.forEach((r) => {
630
+ let B = r.slice(2, -2).trim(), C = s.slice(2, -2).trim();
631
+ t !== -1 && k(B, "$index.") ? B = `${C}.${t}.${B.slice(7)}` : t !== -1 && k(B, "$index") && (B = `${C}.${t}`);
632
+ const T = d(a, B);
633
+ T === void 0 ? o = o.replace(r, "") : h && !I(T) ? o = T : o = I(T) ? T : o.replace(r, T);
507
634
  });
508
635
  }
509
- return r;
636
+ return o;
510
637
  }
511
- if (C(e))
512
- return e.map((r) => b(r, a, { index: t, key: s }, n));
638
+ if (I(e))
639
+ return e.map((o) => b(o, a, { index: t, key: s }, n));
513
640
  if (e && typeof e == "object") {
514
- const r = {};
515
- return $(P(e), (o) => {
516
- !_(o, "_") && o !== "$repeaterItemsKey" ? r[o] = b(e[o], a, { index: t, key: s }, o) : r[o] = e[o];
517
- }), r;
641
+ const o = {};
642
+ return S(R(e), (l) => {
643
+ !k(l, "_") && l !== "$repeaterItemsKey" ? o[l] = b(e[l], a, { index: t, key: s }, l) : o[l] = e[l];
644
+ }), o;
518
645
  }
519
646
  return e;
520
647
  }, L = (e, a, { index: t, key: s }) => {
521
648
  let n = M(e);
522
- return n.repeaterItems && (n.$repeaterItemsKey = n.repeaterItems, _(n.repeaterItems, `{{${_t}`) && (n.$repeaterItemsKey = n.repeaterItems = `${n.repeaterItems.replace("}}", `/${n._id}}}`)}`), !f(n.repeaterItems) && n.pagination && (n.repeaterTotalItems = `${n.repeaterItems.replace("}}", `/${n._id}/totalItems}}`)}`)), b(n, a, { index: t, key: s });
649
+ return n.repeaterItems && (n.$repeaterItemsKey = n.repeaterItems, k(n.repeaterItems, `{{${wt}`) && (n.$repeaterItemsKey = n.repeaterItems = `${n.repeaterItems.replace("}}", `/${n._id}}}`)}`), !x(n.repeaterItems) && n.pagination && (n.repeaterTotalItems = `${n.repeaterItems.replace("}}", `/${n._id}/totalItems}}`)}`)), b(n, a, { index: t, key: s });
523
650
  };
524
651
  import.meta.vitest && (describe("applyBindingToValue", () => {
525
652
  it("should handle string values with bindings", () => {
@@ -693,18 +820,19 @@ import.meta.vitest && (describe("applyBindingToValue", () => {
693
820
  });
694
821
  }));
695
822
  export {
696
- _t as C,
823
+ wt as C,
697
824
  qt as R,
698
- x as S,
825
+ f as S,
699
826
  L as a,
700
- Jt as b,
827
+ Vt as b,
701
828
  zt as c,
702
- Vt as d,
703
- k as e,
704
- Wt as f,
705
- Ot as g,
706
- Pt as h,
707
- st as i,
708
- jt as j,
829
+ Ft as d,
830
+ v as e,
831
+ Ut as f,
832
+ Jt as g,
833
+ Ot as h,
834
+ _ as i,
835
+ st as j,
836
+ jt as k,
709
837
  Mt as m
710
838
  };