webim-adapter 0.14.0 → 0.16.0

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.
@@ -1150,19 +1150,218 @@ function qe({ slides: e = [], linked: t, ...n }) {
1150
1150
  }
1151
1151
  }) : null;
1152
1152
  }
1153
- var Je = {
1153
+ function Je({ images: e = [], columns: t = 3, gap: n = 8, showNames: r = !1, lightbox: i = !0, style: o, nodeRef: s, inert: c }) {
1154
+ let p = Array.isArray(e) ? e.filter((e) => e && typeof e == "object" && e.src) : [], m = Math.max(0, Number(n) || 0), h = c ? (e) => e.preventDefault() : void 0, [g, _] = l(null), v = i && !c && g !== null && p[g];
1155
+ a(() => {
1156
+ if (!v) return;
1157
+ let e = (e) => {
1158
+ e.key === "Escape" && _(null), e.key === "ArrowRight" && _((e) => (e + 1) % p.length), e.key === "ArrowLeft" && _((e) => (e - 1 + p.length) % p.length);
1159
+ };
1160
+ return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
1161
+ }, [v, p.length]);
1162
+ let y = (e) => {
1163
+ if (typeof e.name == "string" && e.name.trim()) return e.name;
1164
+ if (typeof e.alt == "string" && e.alt.trim()) return e.alt;
1165
+ try {
1166
+ let t = String(e.src).split("?")[0].split("/").pop();
1167
+ return decodeURIComponent(t ?? "");
1168
+ } catch {
1169
+ return "";
1170
+ }
1171
+ };
1172
+ return /* @__PURE__ */ f("div", {
1173
+ ref: s,
1174
+ style: {
1175
+ columnCount: Math.min(Math.max(Number(t) || 3, 1), 8),
1176
+ columnGap: m,
1177
+ width: "100%",
1178
+ ...C(o)
1179
+ },
1180
+ children: [
1181
+ p.map((e, t) => {
1182
+ let n = /* @__PURE__ */ f("span", {
1183
+ style: {
1184
+ position: "relative",
1185
+ display: "block",
1186
+ borderRadius: "inherit",
1187
+ overflow: "hidden"
1188
+ },
1189
+ children: [/* @__PURE__ */ d("img", {
1190
+ src: e.src,
1191
+ alt: e.alt ?? "",
1192
+ style: {
1193
+ width: "100%",
1194
+ display: "block",
1195
+ borderRadius: "inherit"
1196
+ }
1197
+ }), r && y(e) && /* @__PURE__ */ d("span", {
1198
+ style: {
1199
+ position: "absolute",
1200
+ insetInline: 0,
1201
+ bottom: 0,
1202
+ padding: "14px 10px 8px",
1203
+ background: "linear-gradient(transparent, rgba(0, 0, 0, 0.65))",
1204
+ color: "#fff",
1205
+ fontSize: 12,
1206
+ lineHeight: 1.3,
1207
+ whiteSpace: "nowrap",
1208
+ overflow: "hidden",
1209
+ textOverflow: "ellipsis"
1210
+ },
1211
+ children: y(e)
1212
+ })]
1213
+ }), a = e.href ? /* @__PURE__ */ d("a", {
1214
+ href: e.href,
1215
+ onClick: h,
1216
+ target: e.target || void 0,
1217
+ rel: e.target === "_blank" ? "noopener noreferrer" : void 0,
1218
+ style: {
1219
+ display: "block",
1220
+ borderRadius: "inherit"
1221
+ },
1222
+ children: n
1223
+ }) : i && !c ? /* @__PURE__ */ d("span", {
1224
+ role: "button",
1225
+ tabIndex: 0,
1226
+ onClick: () => _(t),
1227
+ onKeyDown: (e) => (e.key === "Enter" || e.key === " ") && _(t),
1228
+ style: {
1229
+ display: "block",
1230
+ borderRadius: "inherit",
1231
+ cursor: "zoom-in"
1232
+ },
1233
+ children: n
1234
+ }) : n;
1235
+ return /* @__PURE__ */ d("div", {
1236
+ style: {
1237
+ breakInside: "avoid",
1238
+ marginBottom: m,
1239
+ borderRadius: "inherit",
1240
+ overflow: "hidden"
1241
+ },
1242
+ children: a
1243
+ }, t);
1244
+ }),
1245
+ !p.length && /* @__PURE__ */ d("div", {
1246
+ style: {
1247
+ padding: "24px 12px",
1248
+ fontSize: 13,
1249
+ opacity: .55,
1250
+ textAlign: "center",
1251
+ columnSpan: "all"
1252
+ },
1253
+ children: "Pick images in Settings to fill the gallery"
1254
+ }),
1255
+ v && /* @__PURE__ */ f("div", {
1256
+ role: "dialog",
1257
+ "aria-modal": "true",
1258
+ onClick: () => _(null),
1259
+ style: {
1260
+ position: "fixed",
1261
+ inset: 0,
1262
+ zIndex: 1400,
1263
+ background: "rgba(0, 0, 0, 0.86)",
1264
+ display: "flex",
1265
+ flexDirection: "column",
1266
+ alignItems: "center",
1267
+ justifyContent: "center",
1268
+ padding: 24
1269
+ },
1270
+ children: [
1271
+ /* @__PURE__ */ d("img", {
1272
+ src: p[g].src,
1273
+ alt: p[g].alt ?? "",
1274
+ onClick: (e) => e.stopPropagation(),
1275
+ style: {
1276
+ maxWidth: "92vw",
1277
+ maxHeight: "84vh",
1278
+ borderRadius: 8,
1279
+ boxShadow: "0 12px 48px rgba(0,0,0,0.5)"
1280
+ }
1281
+ }),
1282
+ y(p[g]) && /* @__PURE__ */ d("div", {
1283
+ style: {
1284
+ color: "#fff",
1285
+ fontSize: 14,
1286
+ marginTop: 12,
1287
+ opacity: .85
1288
+ },
1289
+ children: y(p[g])
1290
+ }),
1291
+ /* @__PURE__ */ d("button", {
1292
+ type: "button",
1293
+ "aria-label": "Close",
1294
+ onClick: () => _(null),
1295
+ style: {
1296
+ position: "absolute",
1297
+ top: 16,
1298
+ right: 20,
1299
+ background: "transparent",
1300
+ border: 0,
1301
+ color: "#fff",
1302
+ fontSize: 28,
1303
+ lineHeight: 1,
1304
+ cursor: "pointer"
1305
+ },
1306
+ children: "×"
1307
+ }),
1308
+ p.length > 1 && /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("button", {
1309
+ type: "button",
1310
+ "aria-label": "Previous",
1311
+ onClick: (e) => {
1312
+ e.stopPropagation(), _((e) => (e - 1 + p.length) % p.length);
1313
+ },
1314
+ style: {
1315
+ position: "absolute",
1316
+ left: 16,
1317
+ top: "50%",
1318
+ transform: "translateY(-50%)",
1319
+ background: "transparent",
1320
+ border: 0,
1321
+ color: "#fff",
1322
+ fontSize: 36,
1323
+ cursor: "pointer",
1324
+ padding: 12
1325
+ },
1326
+ children: "‹"
1327
+ }), /* @__PURE__ */ d("button", {
1328
+ type: "button",
1329
+ "aria-label": "Next",
1330
+ onClick: (e) => {
1331
+ e.stopPropagation(), _((e) => (e + 1) % p.length);
1332
+ },
1333
+ style: {
1334
+ position: "absolute",
1335
+ right: 16,
1336
+ top: "50%",
1337
+ transform: "translateY(-50%)",
1338
+ background: "transparent",
1339
+ border: 0,
1340
+ color: "#fff",
1341
+ fontSize: 36,
1342
+ cursor: "pointer",
1343
+ padding: 12
1344
+ },
1345
+ children: "›"
1346
+ })] })
1347
+ ]
1348
+ })
1349
+ ]
1350
+ });
1351
+ }
1352
+ var Ye = {
1154
1353
  color: "inherit",
1155
1354
  textDecoration: "none",
1156
1355
  fontSize: 14,
1157
1356
  opacity: .85
1158
- }, Ye = {
1357
+ }, Xe = {
1159
1358
  background: "var(--page-bg, #ffffff)",
1160
1359
  color: "var(--page-text, #111827)",
1161
1360
  border: "1px solid rgba(148, 163, 184, 0.25)",
1162
1361
  boxShadow: "0 16px 40px rgba(15, 23, 42, 0.16)",
1163
1362
  zIndex: 60
1164
1363
  };
1165
- function Xe({ brand: e, logo: n, brandHref: r, brandTarget: i, links: o = [], style: s, nodeRef: c, menu: p = "auto", breakpoint: m = 768 }) {
1364
+ function Ze({ brand: e, logo: n, brandHref: r, brandTarget: i, links: o = [], style: s, nodeRef: c, menu: p = "auto", breakpoint: m = 768 }) {
1166
1365
  let [h, g] = l(null), [_, v] = l(!1), [y, b] = l(!1), [x, S] = l(null);
1167
1366
  a(() => {
1168
1367
  if (!h) return;
@@ -1172,7 +1371,7 @@ function Xe({ brand: e, logo: n, brandHref: r, brandTarget: i, links: o = [], st
1172
1371
  let w = p === "hamburger" || p === "auto" && _, T = (e, t) => /* @__PURE__ */ f("a", {
1173
1372
  href: e.href || "#",
1174
1373
  style: {
1175
- ...Je,
1374
+ ...Ye,
1176
1375
  display: "block",
1177
1376
  ...t
1178
1377
  },
@@ -1260,7 +1459,7 @@ function Xe({ brand: e, logo: n, brandHref: r, brandTarget: i, links: o = [], st
1260
1459
  let t = e.children ?? [];
1261
1460
  if (!t.length) return /* @__PURE__ */ d("a", {
1262
1461
  href: e.href || "#",
1263
- style: Je,
1462
+ style: Ye,
1264
1463
  children: e.label
1265
1464
  }, e.key);
1266
1465
  let n = e.type === "mega";
@@ -1274,7 +1473,7 @@ function Xe({ brand: e, logo: n, brandHref: r, brandTarget: i, links: o = [], st
1274
1473
  children: [/* @__PURE__ */ f("a", {
1275
1474
  href: e.href || "#",
1276
1475
  style: {
1277
- ...Je,
1476
+ ...Ye,
1278
1477
  cursor: "pointer"
1279
1478
  },
1280
1479
  children: [
@@ -1290,7 +1489,7 @@ function Xe({ brand: e, logo: n, brandHref: r, brandTarget: i, links: o = [], st
1290
1489
  ]
1291
1490
  }), x === e.key && (n ? /* @__PURE__ */ d("div", {
1292
1491
  style: {
1293
- ...Ye,
1492
+ ...Xe,
1294
1493
  position: "absolute",
1295
1494
  left: 0,
1296
1495
  right: 0,
@@ -1306,7 +1505,7 @@ function Xe({ brand: e, logo: n, brandHref: r, brandTarget: i, links: o = [], st
1306
1505
  }))
1307
1506
  }) : /* @__PURE__ */ d("div", {
1308
1507
  style: {
1309
- ...Ye,
1508
+ ...Xe,
1310
1509
  position: "absolute",
1311
1510
  top: "100%",
1312
1511
  left: 0,
@@ -1335,7 +1534,7 @@ function Xe({ brand: e, logo: n, brandHref: r, brandTarget: i, links: o = [], st
1335
1534
  children: o.map((e) => /* @__PURE__ */ f(t, { children: [/* @__PURE__ */ d("a", {
1336
1535
  href: e.href || "#",
1337
1536
  style: {
1338
- ...Je,
1537
+ ...Ye,
1339
1538
  padding: "10px 4px",
1340
1539
  fontWeight: (e.children ?? []).length ? 600 : 400,
1341
1540
  opacity: 1
@@ -1346,7 +1545,7 @@ function Xe({ brand: e, logo: n, brandHref: r, brandTarget: i, links: o = [], st
1346
1545
  ]
1347
1546
  });
1348
1547
  }
1349
- function Ze({ tabs: e = [], linked: t, style: n, nodeRef: r }) {
1548
+ function Qe({ tabs: e = [], linked: t, style: n, nodeRef: r }) {
1350
1549
  let [i, a] = l(0), o = e.length ? Math.min(i, e.length - 1) : 0;
1351
1550
  return e.length ? /* @__PURE__ */ f("div", {
1352
1551
  ref: r,
@@ -1386,7 +1585,7 @@ function Ze({ tabs: e = [], linked: t, style: n, nodeRef: r }) {
1386
1585
  }, e.key))]
1387
1586
  }) : null;
1388
1587
  }
1389
- function Qe({ items: e = [], linked: t, multiple: n = !1, style: r, nodeRef: i }) {
1588
+ function $e({ items: e = [], linked: t, multiple: n = !1, style: r, nodeRef: i }) {
1390
1589
  let [a, o] = l(() => new Set(e.length ? [e[0].key] : []));
1391
1590
  if (!e.length) return null;
1392
1591
  let s = (e) => o((t) => {
@@ -1443,7 +1642,7 @@ function Qe({ items: e = [], linked: t, multiple: n = !1, style: r, nodeRef: i }
1443
1642
  })
1444
1643
  });
1445
1644
  }
1446
- var $e = {
1645
+ var et = {
1447
1646
  display: "flex",
1448
1647
  flexDirection: "column",
1449
1648
  gap: "12px"
@@ -1461,7 +1660,7 @@ var $e = {
1461
1660
  boxSizing: "border-box",
1462
1661
  backgroundColor: "#ffffff",
1463
1662
  color: "#111827"
1464
- }, et = {
1663
+ }, tt = {
1465
1664
  display: "flex",
1466
1665
  alignItems: "center",
1467
1666
  gap: "8px",
@@ -1472,7 +1671,7 @@ var $e = {
1472
1671
  tabIndex: -1,
1473
1672
  onMouseDown: (e) => e.preventDefault()
1474
1673
  } : {};
1475
- function tt(e, t) {
1674
+ function nt(e, t) {
1476
1675
  if (!e) return !0;
1477
1676
  let n = t[e.field], r = n == null || n === "" ? "" : String(n), i = e.value ?? "";
1478
1677
  switch (e.op) {
@@ -1486,11 +1685,11 @@ function tt(e, t) {
1486
1685
  default: return !1;
1487
1686
  }
1488
1687
  }
1489
- var nt = {
1688
+ var rt = {
1490
1689
  display: "flex",
1491
1690
  flexDirection: "column",
1492
1691
  gap: 6
1493
- }, rt = {
1692
+ }, it = {
1494
1693
  font: "inherit",
1495
1694
  fontSize: 15,
1496
1695
  padding: "10px 12px",
@@ -1501,13 +1700,13 @@ var nt = {
1501
1700
  width: "100%",
1502
1701
  boxSizing: "border-box"
1503
1702
  };
1504
- function it(e, t) {
1703
+ function at(e, t) {
1505
1704
  let n = Array.isArray(e?.options) ? e.options : [];
1506
1705
  if (!e?.parentField) return n;
1507
1706
  let r = t?.[e.parentField];
1508
1707
  return r ? n.filter((e) => typeof e == "string" ? !1 : !e.parent || e.parent === r) : [];
1509
1708
  }
1510
- function at({ field: e, value: t, onChange: n, inert: r, values: i }) {
1709
+ function ot({ field: e, value: t, onChange: n, inert: r, values: i }) {
1511
1710
  let a = /* @__PURE__ */ f("span", {
1512
1711
  style: {
1513
1712
  ...Y,
@@ -1519,7 +1718,7 @@ function at({ field: e, value: t, onChange: n, inert: r, values: i }) {
1519
1718
  required: e.required || void 0,
1520
1719
  placeholder: e.placeholder || void 0,
1521
1720
  disabled: r || void 0,
1522
- style: rt,
1721
+ style: it,
1523
1722
  value: t ?? "",
1524
1723
  onChange: (t) => n(e.name, t.target.value)
1525
1724
  };
@@ -1560,14 +1759,14 @@ function at({ field: e, value: t, onChange: n, inert: r, values: i }) {
1560
1759
  display: "block"
1561
1760
  }
1562
1761
  }) : null : /* @__PURE__ */ f("label", {
1563
- style: nt,
1762
+ style: rt,
1564
1763
  children: [
1565
1764
  a,
1566
1765
  e.type === "textarea" || e.multiline ? /* @__PURE__ */ d("textarea", {
1567
1766
  ...o,
1568
1767
  rows: 4,
1569
1768
  style: {
1570
- ...rt,
1769
+ ...it,
1571
1770
  resize: "vertical"
1572
1771
  }
1573
1772
  }) : e.type === "select" ? /* @__PURE__ */ f("select", {
@@ -1576,7 +1775,7 @@ function at({ field: e, value: t, onChange: n, inert: r, values: i }) {
1576
1775
  children: [/* @__PURE__ */ d("option", {
1577
1776
  value: "",
1578
1777
  children: e.placeholder || "—"
1579
- }), it(e, i).map((e, t) => /* @__PURE__ */ d("option", {
1778
+ }), at(e, i).map((e, t) => /* @__PURE__ */ d("option", {
1580
1779
  value: typeof e == "string" ? e : e.value,
1581
1780
  children: typeof e == "string" ? e : e.label ?? e.value
1582
1781
  }, t))]
@@ -1623,7 +1822,7 @@ function at({ field: e, value: t, onChange: n, inert: r, values: i }) {
1623
1822
  ]
1624
1823
  });
1625
1824
  }
1626
- function ot({ style: e, action: t, method: n, name: r, enctype: o, formSlug: s, auto: c, submitLabel: p, nodeRef: m, inert: h, children: g, linked: _, show: v }) {
1825
+ function st({ style: e, action: t, method: n, name: r, enctype: o, formSlug: s, auto: c, submitLabel: p, nodeRef: m, inert: h, children: g, linked: _, show: v }) {
1627
1826
  let { tenant: y, apiUrl: b } = i(H), [x, S] = l("form"), [w, T] = l(null), [E, D] = l({}), [O, k] = l(0), A = h ? v || "form" : x;
1628
1827
  a(() => {
1629
1828
  if (!c || !s) return;
@@ -1645,9 +1844,9 @@ function ot({ style: e, action: t, method: n, name: r, enctype: o, formSlug: s,
1645
1844
  section: e,
1646
1845
  fields: []
1647
1846
  }) : j[j.length - 1].fields.push(e);
1648
- let M = j.filter((e) => e.section || e.fields.length), N = M.filter((e) => !e.section || tt(e.section.condition, E)).map((e) => ({
1847
+ let M = j.filter((e) => e.section || e.fields.length), N = M.filter((e) => !e.section || nt(e.section.condition, E)).map((e) => ({
1649
1848
  ...e,
1650
- fields: e.fields.filter((e) => tt(e.condition, E))
1849
+ fields: e.fields.filter((e) => nt(e.condition, E))
1651
1850
  })), P = M.length > 1, F = Math.min(O, Math.max(0, N.length - 1)), I = P ? N[F]?.fields ?? [] : N.flatMap((e) => e.fields), L = I.filter((e) => {
1652
1851
  let t = E[e.name];
1653
1852
  return e.required && (t == null || t === "" || t === !1);
@@ -1705,11 +1904,11 @@ function ot({ style: e, action: t, method: n, name: r, enctype: o, formSlug: s,
1705
1904
  }
1706
1905
  },
1707
1906
  style: {
1708
- ...$e,
1907
+ ...et,
1709
1908
  display: A === "success" ? "none" : "flex"
1710
1909
  },
1711
1910
  children: c && s ? /* @__PURE__ */ f(u, { children: [
1712
- P && /* @__PURE__ */ d(xt, {
1911
+ P && /* @__PURE__ */ d(St, {
1713
1912
  steps: N.map((e) => ({ label: e.section?.label ?? "Start" })),
1714
1913
  active: F + 1,
1715
1914
  style: { marginBottom: 8 }
@@ -1722,7 +1921,7 @@ function ot({ style: e, action: t, method: n, name: r, enctype: o, formSlug: s,
1722
1921
  },
1723
1922
  children: N[F].section.help
1724
1923
  }),
1725
- I.map((e) => /* @__PURE__ */ d(at, {
1924
+ I.map((e) => /* @__PURE__ */ d(ot, {
1726
1925
  field: e,
1727
1926
  value: E[e.name],
1728
1927
  values: E,
@@ -1795,19 +1994,19 @@ function ot({ style: e, action: t, method: n, name: r, enctype: o, formSlug: s,
1795
1994
  ]
1796
1995
  });
1797
1996
  }
1798
- var st = null, ct = () => st || (st = new Promise((e) => {
1997
+ var ct = null, lt = () => ct || (ct = new Promise((e) => {
1799
1998
  if (typeof window > "u") return;
1800
1999
  if (window.grecaptcha?.render) return e(window.grecaptcha);
1801
2000
  window.__webimRecaptchaReady = () => e(window.grecaptcha);
1802
2001
  let t = document.createElement("script");
1803
2002
  t.src = "https://www.google.com/recaptcha/api.js?onload=__webimRecaptchaReady&render=explicit", t.async = !0, document.head.appendChild(t);
1804
- }), st);
1805
- function lt({ siteKey: e, theme: t, size: n, style: r, nodeRef: o, inert: s }) {
2003
+ }), ct);
2004
+ function ut({ siteKey: e, theme: t, size: n, style: r, nodeRef: o, inert: s }) {
1806
2005
  let l = i(H), u = l?.settings && typeof l.settings == "object" ? l.settings["google.recaptchaKey"] : "", p = typeof e == "string" && e.trim() || (typeof u == "string" ? u.trim() : ""), m = c(null), h = c(!1);
1807
2006
  if (a(() => {
1808
2007
  if (s || !p || h.current || !m.current) return;
1809
2008
  let e = !0;
1810
- return ct().then((r) => {
2009
+ return lt().then((r) => {
1811
2010
  if (!(!e || h.current || !m.current || !r?.render)) {
1812
2011
  h.current = !0;
1813
2012
  try {
@@ -1885,7 +2084,7 @@ function lt({ siteKey: e, theme: t, size: n, style: r, nodeRef: o, inert: s }) {
1885
2084
  children: /* @__PURE__ */ d("div", { ref: m })
1886
2085
  }) : null;
1887
2086
  }
1888
- function ut({ text: e, parts: t, style: n, nodeRef: r, linked: i }) {
2087
+ function dt({ text: e, parts: t, style: n, nodeRef: r, linked: i }) {
1889
2088
  return /* @__PURE__ */ d("label", {
1890
2089
  ref: r,
1891
2090
  style: {
@@ -1895,7 +2094,7 @@ function ut({ text: e, parts: t, style: n, nodeRef: r, linked: i }) {
1895
2094
  children: J(t, e, i)
1896
2095
  });
1897
2096
  }
1898
- function dt({ type: e = "text", name: t, placeholder: n, required: r, style: i, nodeRef: a, inert: o }) {
2097
+ function ft({ type: e = "text", name: t, placeholder: n, required: r, style: i, nodeRef: a, inert: o }) {
1899
2098
  return /* @__PURE__ */ d("input", {
1900
2099
  ref: a,
1901
2100
  type: e,
@@ -1909,7 +2108,7 @@ function dt({ type: e = "text", name: t, placeholder: n, required: r, style: i,
1909
2108
  ...Z(o)
1910
2109
  });
1911
2110
  }
1912
- function ft({ name: e, placeholder: t, rows: n = 4, required: r, style: i, nodeRef: a, inert: o }) {
2111
+ function pt({ name: e, placeholder: t, rows: n = 4, required: r, style: i, nodeRef: a, inert: o }) {
1913
2112
  return /* @__PURE__ */ d("textarea", {
1914
2113
  ref: a,
1915
2114
  name: e || void 0,
@@ -1924,11 +2123,11 @@ function ft({ name: e, placeholder: t, rows: n = 4, required: r, style: i, nodeR
1924
2123
  ...Z(o)
1925
2124
  });
1926
2125
  }
1927
- function pt({ kind: e = "checkbox", label: t, name: n, value: r, required: i, style: a, nodeRef: o, inert: s }) {
2126
+ function mt({ kind: e = "checkbox", label: t, name: n, value: r, required: i, style: a, nodeRef: o, inert: s }) {
1928
2127
  return /* @__PURE__ */ f("label", {
1929
2128
  ref: o,
1930
2129
  style: {
1931
- ...et,
2130
+ ...tt,
1932
2131
  ...C(a)
1933
2132
  },
1934
2133
  children: [/* @__PURE__ */ d("input", {
@@ -1945,7 +2144,7 @@ function pt({ kind: e = "checkbox", label: t, name: n, value: r, required: i, st
1945
2144
  }), t]
1946
2145
  });
1947
2146
  }
1948
- function mt({ name: e, placeholder: t, options: n = [], required: r, style: i, nodeRef: a, inert: o }) {
2147
+ function ht({ name: e, placeholder: t, options: n = [], required: r, style: i, nodeRef: a, inert: o }) {
1949
2148
  return /* @__PURE__ */ f("select", {
1950
2149
  ref: a,
1951
2150
  name: e || void 0,
@@ -1968,7 +2167,7 @@ function mt({ name: e, placeholder: t, options: n = [], required: r, style: i, n
1968
2167
  }, t))]
1969
2168
  });
1970
2169
  }
1971
- function ht({ name: e, accept: t, required: n, text: r = "Choose a file…", style: i, nodeRef: a, inert: o }) {
2170
+ function gt({ name: e, accept: t, required: n, text: r = "Choose a file…", style: i, nodeRef: a, inert: o }) {
1972
2171
  let [s, c] = l(null);
1973
2172
  return /* @__PURE__ */ f("label", {
1974
2173
  ref: a,
@@ -2000,7 +2199,7 @@ function ht({ name: e, accept: t, required: n, text: r = "Choose a file…", sty
2000
2199
  ]
2001
2200
  });
2002
2201
  }
2003
- function gt({ text: e = "Submit", style: t, nodeRef: n, inert: r }) {
2202
+ function _t({ text: e = "Submit", style: t, nodeRef: n, inert: r }) {
2004
2203
  return /* @__PURE__ */ d("button", {
2005
2204
  ref: n,
2006
2205
  type: r ? "button" : "submit",
@@ -2020,7 +2219,7 @@ function gt({ text: e = "Submit", style: t, nodeRef: n, inert: r }) {
2020
2219
  children: e
2021
2220
  });
2022
2221
  }
2023
- function _t({ cols: e = 2, rows: t = 1, style: n, nodeRef: r, linked: i }) {
2222
+ function vt({ cols: e = 2, rows: t = 1, style: n, nodeRef: r, linked: i }) {
2024
2223
  let a = Math.max(1, (Number(e) || 1) * (Number(t) || 1));
2025
2224
  return /* @__PURE__ */ d("div", {
2026
2225
  ref: r,
@@ -2037,7 +2236,7 @@ function _t({ cols: e = 2, rows: t = 1, style: n, nodeRef: r, linked: i }) {
2037
2236
  }, t))
2038
2237
  });
2039
2238
  }
2040
- function vt({ collection: e, limit: t = 6, layout: n = "grid", columns: r = 3, imageField: o, titleField: s = "name", textField: c, custom: u, templateId: p, paged: m, style: h, nodeRef: g }) {
2239
+ function yt({ collection: e, limit: t = 6, layout: n = "grid", columns: r = 3, imageField: o, titleField: s = "name", textField: c, custom: u, templateId: p, paged: m, style: h, nodeRef: g }) {
2041
2240
  let { tenant: _, apiUrl: v, locale: y } = i(H), b = i(ae), x = i(U), S = x?.[e], w = m ? W(x) : 1, [T, E] = l(null);
2042
2241
  if (a(() => {
2043
2242
  if (!e || S) return;
@@ -2146,7 +2345,7 @@ function vt({ collection: e, limit: t = 6, layout: n = "grid", columns: r = 3, i
2146
2345
  })
2147
2346
  });
2148
2347
  }
2149
- function yt({ items: e = [], separator: t = "/", style: n, nodeRef: r }) {
2348
+ function bt({ items: e = [], separator: t = "/", style: n, nodeRef: r }) {
2150
2349
  return e.length ? /* @__PURE__ */ d("nav", {
2151
2350
  ref: r,
2152
2351
  "aria-label": "Breadcrumb",
@@ -2196,7 +2395,7 @@ function yt({ items: e = [], separator: t = "/", style: n, nodeRef: r }) {
2196
2395
  })
2197
2396
  }) : null;
2198
2397
  }
2199
- function bt({ pages: e = 5, current: t = 1, prevNext: n = !0, href: r = "#", source: o, pageSize: s = 6, align: c, hideEmpty: u, inert: p, style: m, nodeRef: h }) {
2398
+ function xt({ pages: e = 5, current: t = 1, prevNext: n = !0, href: r = "#", source: o, pageSize: s = 6, align: c, hideEmpty: u, inert: p, style: m, nodeRef: h }) {
2200
2399
  let { tenant: g, apiUrl: _ } = i(H), v = i(U), [y, b] = l(null), x = o ? Number(v?.[`${o}:total`]) : NaN;
2201
2400
  a(() => {
2202
2401
  if (!o || Number.isFinite(x)) return;
@@ -2281,7 +2480,7 @@ function bt({ pages: e = 5, current: t = 1, prevNext: n = !0, href: r = "#", sou
2281
2480
  ]
2282
2481
  });
2283
2482
  }
2284
- function xt({ steps: e = [], active: n = 1, vertical: r = !1, style: i, nodeRef: a }) {
2483
+ function St({ steps: e = [], active: n = 1, vertical: r = !1, style: i, nodeRef: a }) {
2285
2484
  if (!e.length) return null;
2286
2485
  let o = Math.min(Math.max(Number(n) || 1, 1), e.length), s = (e) => ({
2287
2486
  width: 32,
@@ -2359,7 +2558,7 @@ function xt({ steps: e = [], active: n = 1, vertical: r = !1, style: i, nodeRef:
2359
2558
  })
2360
2559
  });
2361
2560
  }
2362
- var St = {
2561
+ var Ct = {
2363
2562
  small: {
2364
2563
  w: 132,
2365
2564
  h: 46,
@@ -2381,10 +2580,10 @@ var St = {
2381
2580
  title: 12.5,
2382
2581
  avatar: 46
2383
2582
  }
2384
- }, Ct = (e) => St[e] ?? St.medium;
2385
- St.medium.w, St.medium.h;
2386
- function wt(e, { size: t = "medium", horizontal: n = !1 } = {}) {
2387
- let r = Ct(t), i = n ? r.h : r.w, a = n ? 16 : 20, o = (n ? r.w : r.h) + (n ? 56 : 48), s = Array.isArray(e) ? e.filter((e) => e && e.id) : [], c = new Set(s.map((e) => e.id)), l = /* @__PURE__ */ new Map(), u = [];
2583
+ }, wt = (e) => Ct[e] ?? Ct.medium;
2584
+ Ct.medium.w, Ct.medium.h;
2585
+ function Tt(e, { size: t = "medium", horizontal: n = !1 } = {}) {
2586
+ let r = wt(t), i = n ? r.h : r.w, a = n ? 16 : 20, o = (n ? r.w : r.h) + (n ? 56 : 48), s = Array.isArray(e) ? e.filter((e) => e && e.id) : [], c = new Set(s.map((e) => e.id)), l = /* @__PURE__ */ new Map(), u = [];
2388
2587
  for (let e of s) e.parent && c.has(e.parent) && e.parent !== e.id ? (l.has(e.parent) || l.set(e.parent, []), l.get(e.parent).push(e)) : u.push(e);
2389
2588
  let d = /* @__PURE__ */ new Map(), f = (e, t) => {
2390
2589
  if (t.has(e.id)) return 0;
@@ -2436,18 +2635,18 @@ function wt(e, { size: t = "medium", horizontal: n = !1 } = {}) {
2436
2635
  horizontal: n
2437
2636
  };
2438
2637
  }
2439
- var Tt = (e, t) => {
2638
+ var Et = (e, t) => {
2440
2639
  let n = String(e ?? "");
2441
2640
  return n.length > t ? `${n.slice(0, t - 1)}…` : n;
2442
- }, Et = (e) => {
2641
+ }, Dt = (e) => {
2443
2642
  let t = /^#([0-9a-f]{6}|[0-9a-f]{3})$/i.exec(String(e ?? "").trim());
2444
2643
  if (!t) return "#ffffff";
2445
2644
  let n = t[1];
2446
2645
  n.length === 3 && (n = [...n].map((e) => e + e).join(""));
2447
2646
  let r = parseInt(n, 16);
2448
2647
  return .299 * (r >> 16 & 255) + .587 * (r >> 8 & 255) + .114 * (r & 255) > 150 ? "#111827" : "#ffffff";
2449
- }, Dt = (e) => !!(e?.cv?.trim?.() || e?.photo);
2450
- function Ot(e, t = {}) {
2648
+ }, Ot = (e) => !!(e?.cv?.trim?.() || e?.photo);
2649
+ function kt(e, t = {}) {
2451
2650
  let n = Array.isArray(e) ? e.filter((e) => e && typeof e == "object" && e.id) : [], r = (e) => Array.isArray(e) ? e[0] : e, i = (e) => e == null ? "" : K(e);
2452
2651
  return n.map((e) => {
2453
2652
  let n = e.data ?? {}, a = r(n[t.parentField]), o = a && typeof a == "object" ? a.id ?? null : a || null;
@@ -2462,11 +2661,11 @@ function Ot(e, t = {}) {
2462
2661
  };
2463
2662
  });
2464
2663
  }
2465
- var kt = {
2664
+ var At = {
2466
2665
  size: 36,
2467
2666
  pad: 10
2468
2667
  };
2469
- function At({ node: e, onClose: t }) {
2668
+ function jt({ node: e, onClose: t }) {
2470
2669
  return a(() => {
2471
2670
  let e = (e) => e.key === "Escape" && t();
2472
2671
  return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
@@ -2584,7 +2783,7 @@ function At({ node: e, onClose: t }) {
2584
2783
  })
2585
2784
  });
2586
2785
  }
2587
- function jt({ nodes: e = [], source: t, nameField: n, titleField: r, photoField: s, parentField: c, cvField: p, hrefField: m, size: h = "medium", horizontal: g = !1, style: _, nodeRef: v, interactive: y = !0 }) {
2786
+ function Mt({ nodes: e = [], source: t, nameField: n, titleField: r, photoField: s, parentField: c, cvField: p, hrefField: m, size: h = "medium", horizontal: g = !1, style: _, nodeRef: v, interactive: y = !0 }) {
2588
2787
  let b = o(), [x, S] = l(null), { tenant: w, apiUrl: T } = i(H), E = i(U)?.[t], [D, O] = l(null);
2589
2788
  a(() => {
2590
2789
  if (!t || E) return;
@@ -2601,14 +2800,14 @@ function jt({ nodes: e = [], source: t, nameField: n, titleField: r, photoField:
2601
2800
  T,
2602
2801
  E
2603
2802
  ]);
2604
- let k = t ? Ot(E ?? D ?? [], {
2803
+ let k = t ? kt(E ?? D ?? [], {
2605
2804
  nameField: n,
2606
2805
  titleField: r,
2607
2806
  photoField: s,
2608
2807
  parentField: c,
2609
2808
  cvField: p,
2610
2809
  hrefField: m
2611
- }) : e, A = Ct(h), { boxes: j, links: M, width: N, height: P } = wt(k, {
2810
+ }) : e, A = wt(h), { boxes: j, links: M, width: N, height: P } = Tt(k, {
2612
2811
  size: h,
2613
2812
  horizontal: g
2614
2813
  });
@@ -2654,7 +2853,7 @@ function jt({ nodes: e = [], source: t, nameField: n, titleField: r, photoField:
2654
2853
  stroke: "rgba(148, 163, 184, 0.7)",
2655
2854
  strokeWidth: "1.5"
2656
2855
  }, t)), j.map(({ node: e, x: t, y: n }) => {
2657
- let r = F.has(e.id), i = !!e.color2, a = !!e.color || r || i, o = e.color || (r ? "var(--page-accent, #4f46e5)" : "var(--page-bg, #ffffff)"), s = e.color ? Et(e.color) : r ? "var(--page-accent-text, #ffffff)" : "var(--page-text, #111827)", c = i ? Et(e.color2) : s, l = y && (Dt(e) || e.href), p = () => Dt(e) ? S(e) : window.open(e.href, "_blank", "noreferrer"), m = e.photo ? t + kt.pad + A.avatar + 8 : t + A.w / 2, h = e.photo ? "start" : "middle", g = e.photo ? Math.floor((A.w - A.avatar - 26) / 7) : Math.floor(A.w / 7.6), _ = A.h / 2, v = [e.name, e.title].map((e) => String(e ?? "").trim()).filter(Boolean);
2856
+ let r = F.has(e.id), i = !!e.color2, a = !!e.color || r || i, o = e.color || (r ? "var(--page-accent, #4f46e5)" : "var(--page-bg, #ffffff)"), s = e.color ? Dt(e.color) : r ? "var(--page-accent-text, #ffffff)" : "var(--page-text, #111827)", c = i ? Dt(e.color2) : s, l = y && (Ot(e) || e.href), p = () => Ot(e) ? S(e) : window.open(e.href, "_blank", "noreferrer"), m = e.photo ? t + At.pad + A.avatar + 8 : t + A.w / 2, h = e.photo ? "start" : "middle", g = e.photo ? Math.floor((A.w - A.avatar - 26) / 7) : Math.floor(A.w / 7.6), _ = A.h / 2, v = [e.name, e.title].map((e) => String(e ?? "").trim()).filter(Boolean);
2658
2857
  return /* @__PURE__ */ f("g", {
2659
2858
  onClick: l ? p : void 0,
2660
2859
  style: l ? { cursor: "pointer" } : void 0,
@@ -2718,13 +2917,13 @@ function jt({ nodes: e = [], source: t, nameField: n, titleField: r, photoField:
2718
2917
  e.photo && /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("clipPath", {
2719
2918
  id: `${b}-${e.id}`,
2720
2919
  children: /* @__PURE__ */ d("circle", {
2721
- cx: t + kt.pad + A.avatar / 2,
2920
+ cx: t + At.pad + A.avatar / 2,
2722
2921
  cy: n + A.h / 2,
2723
2922
  r: A.avatar / 2
2724
2923
  })
2725
2924
  }), /* @__PURE__ */ d("image", {
2726
2925
  href: e.photo,
2727
- x: t + kt.pad,
2926
+ x: t + At.pad,
2728
2927
  y: n + (A.h - A.avatar) / 2,
2729
2928
  width: A.avatar,
2730
2929
  height: A.avatar,
@@ -2738,7 +2937,7 @@ function jt({ nodes: e = [], source: t, nameField: n, titleField: r, photoField:
2738
2937
  fontSize: A.title,
2739
2938
  fontWeight: "600",
2740
2939
  fill: s,
2741
- children: Tt(e.title, g + 4)
2940
+ children: Et(e.title, g + 4)
2742
2941
  }), e.name && /* @__PURE__ */ d("text", {
2743
2942
  x: m,
2744
2943
  y: n + _ + _ / 2 + A.name * .35,
@@ -2746,7 +2945,7 @@ function jt({ nodes: e = [], source: t, nameField: n, titleField: r, photoField:
2746
2945
  fontSize: A.name,
2747
2946
  fontWeight: "600",
2748
2947
  fill: c,
2749
- children: Tt(e.name, g)
2948
+ children: Et(e.name, g)
2750
2949
  })] }) : /* @__PURE__ */ f(u, { children: [v[0] && /* @__PURE__ */ d("text", {
2751
2950
  x: m,
2752
2951
  y: n + (v[1] ? A.h * .43 : A.h * .57),
@@ -2754,7 +2953,7 @@ function jt({ nodes: e = [], source: t, nameField: n, titleField: r, photoField:
2754
2953
  fontSize: A.name,
2755
2954
  fontWeight: "600",
2756
2955
  fill: s,
2757
- children: Tt(v[0], g)
2956
+ children: Et(v[0], g)
2758
2957
  }), v[1] && /* @__PURE__ */ d("text", {
2759
2958
  x: m,
2760
2959
  y: n + A.h * .73,
@@ -2762,18 +2961,18 @@ function jt({ nodes: e = [], source: t, nameField: n, titleField: r, photoField:
2762
2961
  fontSize: A.title,
2763
2962
  opacity: "0.7",
2764
2963
  fill: s,
2765
- children: Tt(v[1], g + 4)
2964
+ children: Et(v[1], g + 4)
2766
2965
  })] })
2767
2966
  ]
2768
2967
  }, e.id);
2769
2968
  })]
2770
- }), x && /* @__PURE__ */ d(At, {
2969
+ }), x && /* @__PURE__ */ d(jt, {
2771
2970
  node: x,
2772
2971
  onClose: () => S(null)
2773
2972
  })]
2774
2973
  });
2775
2974
  }
2776
- function Mt({ columns: e = [], rows: t = [], source: n, limit: r = 10, striped: o = !0, bordered: s = !1, compact: c = !1, paged: u, emptyText: p, style: m, nodeRef: h }) {
2975
+ function Nt({ columns: e = [], rows: t = [], source: n, limit: r = 10, striped: o = !0, bordered: s = !1, compact: c = !1, paged: u, emptyText: p, style: m, nodeRef: h }) {
2777
2976
  let { tenant: g, apiUrl: _ } = i(H), v = i(U), y = v?.[n], b = u ? W(v) : 1, [x, S] = l(null);
2778
2977
  if (a(() => {
2779
2978
  if (!n || y) return;
@@ -2839,7 +3038,7 @@ function Mt({ columns: e = [], rows: t = [], source: n, limit: r = 10, striped:
2839
3038
  })
2840
3039
  });
2841
3040
  }
2842
- var Nt = {
3041
+ var Pt = {
2843
3042
  PageRoot: he,
2844
3043
  Section: ge,
2845
3044
  Container: _e,
@@ -2851,16 +3050,17 @@ var Nt = {
2851
3050
  Divider: Be,
2852
3051
  SliderBlock: Ke,
2853
3052
  CanvasSlider: qe,
2854
- TabsBlock: Ze,
2855
- QuickStack: _t,
2856
- CollectionList: vt,
2857
- BreadcrumbsBlock: yt,
2858
- PaginationBlock: bt,
2859
- StepperBlock: xt,
2860
- OrgChartBlock: jt,
2861
- TableBlock: Mt,
2862
- AccordionBlock: Qe,
2863
- NavbarBlock: Xe,
3053
+ TabsBlock: Qe,
3054
+ QuickStack: vt,
3055
+ CollectionList: yt,
3056
+ BreadcrumbsBlock: bt,
3057
+ PaginationBlock: xt,
3058
+ StepperBlock: St,
3059
+ OrgChartBlock: Mt,
3060
+ TableBlock: Nt,
3061
+ MasonryBlock: Je,
3062
+ AccordionBlock: $e,
3063
+ NavbarBlock: Ze,
2864
3064
  ListBlock: Oe,
2865
3065
  TextSpan: xe,
2866
3066
  QuoteBlock: De,
@@ -2871,42 +3071,42 @@ var Nt = {
2871
3071
  YouTubeBlock: Ie,
2872
3072
  IframeBlock: Le,
2873
3073
  EmbedBlock: Re,
2874
- FormBlock: ot,
2875
- FormLabel: ut,
2876
- FormInput: dt,
2877
- FormTextarea: ft,
2878
- FormCheckbox: (e) => /* @__PURE__ */ d(pt, {
3074
+ FormBlock: st,
3075
+ FormLabel: dt,
3076
+ FormInput: ft,
3077
+ FormTextarea: pt,
3078
+ FormCheckbox: (e) => /* @__PURE__ */ d(mt, {
2879
3079
  kind: "checkbox",
2880
3080
  ...e
2881
3081
  }),
2882
- FormRadio: (e) => /* @__PURE__ */ d(pt, {
3082
+ FormRadio: (e) => /* @__PURE__ */ d(mt, {
2883
3083
  kind: "radio",
2884
3084
  ...e
2885
3085
  }),
2886
- FormSelect: mt,
2887
- FormFile: ht,
2888
- FormRecaptcha: lt,
2889
- FormSubmit: gt
2890
- }, Pt = {
3086
+ FormSelect: ht,
3087
+ FormFile: gt,
3088
+ FormRecaptcha: ut,
3089
+ FormSubmit: _t
3090
+ }, Ft = {
2891
3091
  id: "auth",
2892
3092
  label: "Accounts",
2893
3093
  category: "Apps",
2894
3094
  keys: ["SiteLoginForm", "SiteAccountMenu"],
2895
3095
  ssr: "shell",
2896
3096
  settings: ["apps.auth.redirect"]
2897
- }, Ft = n({
3097
+ }, It = n({
2898
3098
  user: null,
2899
3099
  status: "idle",
2900
3100
  ensure: () => {},
2901
3101
  refresh: () => {},
2902
3102
  signOut: () => {}
2903
- }), It = () => {
2904
- let e = i(Ft);
3103
+ }), Lt = () => {
3104
+ let e = i(It);
2905
3105
  return a(() => {
2906
3106
  e.ensure();
2907
3107
  }, [e]), e;
2908
3108
  };
2909
- function Lt({ children: e, initialUser: t, disabled: n, apiUrl: a, tenant: o }) {
3109
+ function Rt({ children: e, initialUser: t, disabled: n, apiUrl: a, tenant: o }) {
2910
3110
  let u = i(H), f = a || u?.apiUrl || "/api", p = o || u?.tenant || "", [m, h] = l(t ?? null), [g, _] = l(t ? "user" : n ? "guest" : "idle"), v = c(!1), y = r((e, t) => fetch(`${f}${e}`, {
2911
3111
  ...t,
2912
3112
  credentials: "include",
@@ -2939,18 +3139,18 @@ function Lt({ children: e, initialUser: t, disabled: n, apiUrl: a, tenant: o })
2939
3139
  b,
2940
3140
  x
2941
3141
  ]);
2942
- return /* @__PURE__ */ d(Ft.Provider, {
3142
+ return /* @__PURE__ */ d(It.Provider, {
2943
3143
  value: C,
2944
3144
  children: e
2945
3145
  });
2946
3146
  }
2947
- function Rt({ when: e, children: t }) {
2948
- let { status: n } = It();
3147
+ function zt({ when: e, children: t }) {
3148
+ let { status: n } = Lt();
2949
3149
  return !e || e === "always" ? t : n === "idle" || n === "loading" ? null : e === "user" == (n === "user") ? t : null;
2950
3150
  }
2951
3151
  //#endregion
2952
3152
  //#region ../ui/src/components/builder/apps/auth/views.jsx
2953
- function zt({ mode: e = "login", redirect: t, emailLabel: n = "Email", passwordLabel: r = "Password", nameLabel: a = "Name", submitLabel: o, style: s, nodeRef: c, inert: u, linked: p, show: m }) {
3153
+ function Bt({ mode: e = "login", redirect: t, emailLabel: n = "Email", passwordLabel: r = "Password", nameLabel: a = "Name", submitLabel: o, style: s, nodeRef: c, inert: u, linked: p, show: m }) {
2954
3154
  let { tenant: h, apiUrl: g, settings: _ } = i(H), [v, y] = l("form"), [b, x] = l(""), [S, w] = l(!1), T = e === "register", E = u ? m || "form" : v, D = (e) => typeof e == "string" && e.startsWith("/") && !e.startsWith("//") ? e : "", O = async (e) => {
2955
3155
  if (e.preventDefault(), u) return;
2956
3156
  let n = new FormData(e.currentTarget);
@@ -3074,8 +3274,8 @@ function zt({ mode: e = "login", redirect: t, emailLabel: n = "Email", passwordL
3074
3274
  ]
3075
3275
  });
3076
3276
  }
3077
- function Bt({ greeting: e = "Hi", signOutLabel: t = "Sign out", showEmail: n = !1, style: r, nodeRef: i, inert: a, linked: o, show: s }) {
3078
- let { user: c, status: l, signOut: u } = It(), p = a ? s || "user" : l, m = a ? {
3277
+ function Vt({ greeting: e = "Hi", signOutLabel: t = "Sign out", showEmail: n = !1, style: r, nodeRef: i, inert: a, linked: o, show: s }) {
3278
+ let { user: c, status: l, signOut: u } = Lt(), p = a ? s || "user" : l, m = a ? {
3079
3279
  name: "Ada Lovelace",
3080
3280
  email: "ada@example.com"
3081
3281
  } : c;
@@ -3140,16 +3340,99 @@ function Bt({ greeting: e = "Hi", signOutLabel: t = "Sign out", showEmail: n = !
3140
3340
  }
3141
3341
  //#endregion
3142
3342
  //#region ../ui/src/components/builder/apps/index.js
3143
- var Vt = [Pt], Ht = {
3144
- SiteLoginForm: zt,
3145
- SiteAccountMenu: Bt
3343
+ var Ht = [Ft], Ut = {
3344
+ SiteLoginForm: Bt,
3345
+ SiteAccountMenu: Vt
3146
3346
  };
3147
- new Set(Vt.filter((e) => e.ssr === "shell").flatMap((e) => e.keys));
3347
+ new Set(Ht.filter((e) => e.ssr === "shell").flatMap((e) => e.keys));
3348
+ //#endregion
3349
+ //#region ../ui/src/components/builder/plugins/runtime.js
3350
+ var Wt = /* @__PURE__ */ new Map();
3351
+ function Gt(e) {
3352
+ if (Wt.has(e)) return Wt.get(e);
3353
+ let t = URL.createObjectURL(new Blob([e], { type: "text/javascript" })), n = import(
3354
+ /* @vite-ignore */
3355
+ /* webpackIgnore: true */
3356
+ t
3357
+ ).finally(() => URL.revokeObjectURL(t));
3358
+ return Wt.set(e, n), n;
3359
+ }
3360
+ function Kt(e) {
3361
+ let t = e && typeof e == "object" ? e.builder_plugins : null, n = t && typeof t == "object" ? t.plugins : null;
3362
+ return n && typeof n == "object" ? n : {};
3363
+ }
3364
+ //#endregion
3365
+ //#region ../ui/src/components/builder/plugins/view.jsx
3366
+ async function qt(e, t) {
3367
+ let n = await Gt(e);
3368
+ return (Array.isArray(n?.default?.blocks) ? n.default.blocks : []).find((e) => e?.id === t && typeof e.mount == "function") ?? null;
3369
+ }
3370
+ var Jt = {
3371
+ padding: "10px 12px",
3372
+ border: "1px dashed rgba(148, 163, 184, 0.5)",
3373
+ borderRadius: 8,
3374
+ fontSize: 12,
3375
+ opacity: .6
3376
+ };
3377
+ function Yt({ pluginId: e, blockId: t, props: n, style: r, nodeRef: o }) {
3378
+ let s = i(H), l = Kt(s?.settings)[e], u = c(null), p = c(null), m = {
3379
+ tenant: s?.tenant ?? "",
3380
+ apiUrl: s?.apiUrl ?? "/api",
3381
+ locale: s?.locale ?? "",
3382
+ settings: s?.settings ?? null
3383
+ }, h = c(m);
3384
+ h.current = m;
3385
+ let g = JSON.stringify(n ?? {});
3386
+ return a(() => {
3387
+ let e = u.current;
3388
+ if (!l?.code || !e) return;
3389
+ let n = !0;
3390
+ return qt(l.code, t).then((e) => {
3391
+ if (!(!n || !e || !u.current)) {
3392
+ p.current = e;
3393
+ try {
3394
+ e.mount(u.current, JSON.parse(g), h.current);
3395
+ } catch {
3396
+ p.current = null;
3397
+ }
3398
+ }
3399
+ }).catch(() => {}), () => {
3400
+ n = !1;
3401
+ let t = p.current;
3402
+ p.current = null;
3403
+ try {
3404
+ t?.unmount?.(e);
3405
+ } catch {}
3406
+ e && (e.innerHTML = "");
3407
+ };
3408
+ }, [l?.code, t]), a(() => {
3409
+ let e = p.current, t = u.current;
3410
+ if (!(!e || !t)) try {
3411
+ e.update ? e.update(t, JSON.parse(g), h.current) : (e.unmount?.(t), t.innerHTML = "", e.mount(t, JSON.parse(g), h.current));
3412
+ } catch {}
3413
+ }, [g]), l ? /* @__PURE__ */ d("div", {
3414
+ ref: o,
3415
+ style: C(r),
3416
+ children: /* @__PURE__ */ d("div", { ref: u })
3417
+ }) : /* @__PURE__ */ f("div", {
3418
+ ref: o,
3419
+ style: {
3420
+ ...Jt,
3421
+ ...C(r)
3422
+ },
3423
+ children: [
3424
+ "Plugin “",
3425
+ e,
3426
+ "” is not installed"
3427
+ ]
3428
+ });
3429
+ }
3148
3430
  //#endregion
3149
3431
  //#region ../ui/src/components/builder/render.jsx
3150
- var Ut = {
3151
- ...Nt,
3152
- ...Ht
3432
+ var Xt = {
3433
+ ...Pt,
3434
+ ...Ut,
3435
+ PluginBlock: Yt
3153
3436
  };
3154
3437
  function Q(e, n, r, i = /* @__PURE__ */ new Set(), a = void 0) {
3155
3438
  let o = n[e];
@@ -3161,7 +3444,7 @@ function Q(e, n, r, i = /* @__PURE__ */ new Set(), a = void 0) {
3161
3444
  let c = new Set(i).add(n);
3162
3445
  return /* @__PURE__ */ d(t, { children: Q(s.template.rootId, s.template.nodes, r, c, a) }, e);
3163
3446
  }
3164
- let l = Ut[s];
3447
+ let l = Xt[s];
3165
3448
  if (!l) return null;
3166
3449
  let u = (o.nodes ?? []).map((e) => Q(e, n, r, i, a)).filter(Boolean), f = Object.entries(o.linkedNodes ?? {}), p = f.length ? Object.fromEntries(f.map(([e, t]) => [e, Q(t, n, r, i)])) : void 0, m = /* @__PURE__ */ d(l, {
3167
3450
  ...c,
@@ -3172,15 +3455,15 @@ function Q(e, n, r, i = /* @__PURE__ */ new Set(), a = void 0) {
3172
3455
  },
3173
3456
  children: u.length ? u : void 0
3174
3457
  }, e);
3175
- return c.when && c.when !== "always" ? /* @__PURE__ */ d(Rt, {
3458
+ return c.when && c.when !== "always" ? /* @__PURE__ */ d(zt, {
3176
3459
  when: c.when,
3177
3460
  children: m
3178
3461
  }, e) : m;
3179
3462
  }
3180
3463
  //#endregion
3181
3464
  //#region ../ui/src/components/builder/PageRenderer.jsx
3182
- var Wt = (e) => Object.entries(e).map(([e, t]) => `${e}: ${t};`).join(" ");
3183
- function Gt({ blocks: e, theme: t, components: n, mode: r = "auto", style: i, custom: o, tenant: c, apiUrl: l, datasets: u, locale: p, direction: m, settings: g, siteUser: v }) {
3465
+ var Zt = (e) => Object.entries(e).map(([e, t]) => `${e}: ${t};`).join(" ");
3466
+ function Qt({ blocks: e, theme: t, components: n, mode: r = "auto", style: i, custom: o, tenant: c, apiUrl: l, datasets: u, locale: p, direction: m, settings: g, siteUser: v }) {
3184
3467
  let b = o?.js?.trim();
3185
3468
  if (a(() => {
3186
3469
  if (!b) return;
@@ -3206,7 +3489,7 @@ function Gt({ blocks: e, theme: t, components: n, mode: r = "auto", style: i, cu
3206
3489
  locale: p || "",
3207
3490
  settings: g ?? null
3208
3491
  },
3209
- children: /* @__PURE__ */ d(Lt, {
3492
+ children: /* @__PURE__ */ d(Rt, {
3210
3493
  initialUser: v,
3211
3494
  children: /* @__PURE__ */ d(U.Provider, {
3212
3495
  value: u ?? null,
@@ -3241,7 +3524,7 @@ function Gt({ blocks: e, theme: t, components: n, mode: r = "auto", style: i, cu
3241
3524
  locale: p || "",
3242
3525
  settings: g ?? null
3243
3526
  },
3244
- children: /* @__PURE__ */ d(Lt, {
3527
+ children: /* @__PURE__ */ d(Rt, {
3245
3528
  initialUser: v,
3246
3529
  children: /* @__PURE__ */ d(U.Provider, {
3247
3530
  value: u ?? null,
@@ -3256,8 +3539,8 @@ function Gt({ blocks: e, theme: t, components: n, mode: r = "auto", style: i, cu
3256
3539
  ...i
3257
3540
  },
3258
3541
  children: [
3259
- /* @__PURE__ */ d("style", { children: `.webim-page { ${Wt(V(A.light))} }
3260
- @media (prefers-color-scheme: dark) { .webim-page { ${Wt(V(A.dark))} } }` }),
3542
+ /* @__PURE__ */ d("style", { children: `.webim-page { ${Zt(V(A.light))} }
3543
+ @media (prefers-color-scheme: dark) { .webim-page { ${Zt(V(A.dark))} } }` }),
3261
3544
  k,
3262
3545
  /* @__PURE__ */ d("style", { children: S }),
3263
3546
  E && /* @__PURE__ */ d("style", { children: E }),
@@ -3273,8 +3556,8 @@ function Gt({ blocks: e, theme: t, components: n, mode: r = "auto", style: i, cu
3273
3556
  }
3274
3557
  //#endregion
3275
3558
  //#region src/WebimContent.jsx
3276
- function Kt({ bundle: e, mode: t = "auto", style: n }) {
3277
- return e?.blocks?.ROOT ? /* @__PURE__ */ d(Gt, {
3559
+ function $t({ bundle: e, mode: t = "auto", style: n }) {
3560
+ return e?.blocks?.ROOT ? /* @__PURE__ */ d(Qt, {
3278
3561
  blocks: e.blocks,
3279
3562
  theme: e.theme,
3280
3563
  components: e.components,
@@ -3291,7 +3574,7 @@ function Kt({ bundle: e, mode: t = "auto", style: n }) {
3291
3574
  }
3292
3575
  //#endregion
3293
3576
  //#region src/bundle.js
3294
- function qt({ page: e, settings: t, tenant: n, apiUrl: r, locale: i }) {
3577
+ function en({ page: e, settings: t, tenant: n, apiUrl: r, locale: i }) {
3295
3578
  let a = {
3296
3579
  ...t?.global ?? {},
3297
3580
  ...t?.tenant ?? {}
@@ -3315,18 +3598,18 @@ function qt({ page: e, settings: t, tenant: n, apiUrl: r, locale: i }) {
3315
3598
  }
3316
3599
  //#endregion
3317
3600
  //#region src/fetchPage.js
3318
- var Jt = async (e) => {
3601
+ var tn = async (e) => {
3319
3602
  let t = await e.json().catch(() => null);
3320
3603
  if (!e.ok || t?.success === !1) throw Error(t?.error?.message || `Request failed (${e.status})`);
3321
3604
  return t?.payload ?? t;
3322
3605
  };
3323
- async function Yt({ apiUrl: e, tenant: t, slug: n, locale: r, preview: i, token: a, page: o, fetch: s }) {
3606
+ async function nn({ apiUrl: e, tenant: t, slug: n, locale: r, preview: i, token: a, page: o, fetch: s }) {
3324
3607
  if (!e) throw Error("fetchPage: apiUrl is required");
3325
3608
  if (!n) throw Error("fetchPage: slug is required");
3326
3609
  let c = s ?? fetch, l = e.replace(/\/$/, ""), u = {
3327
3610
  ...t ? { "x-tenant": t } : {},
3328
3611
  ...a ? { authorization: `Bearer ${a}` } : {}
3329
- }, [d, f] = await Promise.all([c(`${l}/render/${encodeURIComponent(n)}${i ? `?preview=${encodeURIComponent(i)}` : ""}`, { headers: u }).then(Jt), c(`${l}/settings/public`, { headers: u }).then(Jt)]), p = qt({
3612
+ }, [d, f] = await Promise.all([c(`${l}/render/${encodeURIComponent(n)}${i ? `?preview=${encodeURIComponent(i)}` : ""}`, { headers: u }).then(tn), c(`${l}/settings/public`, { headers: u }).then(tn)]), p = en({
3330
3613
  page: d,
3331
3614
  settings: f,
3332
3615
  tenant: t,
@@ -3334,7 +3617,7 @@ async function Yt({ apiUrl: e, tenant: t, slug: n, locale: r, preview: i, token:
3334
3617
  locale: r
3335
3618
  }), m = [...new Set(Object.values(p.blocks ?? {}).map((e) => e?.type?.resolvedName === "CollectionList" ? e.props?.collection : e?.type?.resolvedName === "TableBlock" || e?.type?.resolvedName === "OrgChartBlock" ? e.props?.source : null).filter(Boolean))];
3336
3619
  if (m.length) {
3337
- let e = (e) => e.startsWith("api:") ? `${l}/data/${encodeURIComponent(e.slice(4))}` : `${l}/dynamic/${encodeURIComponent(e)}?all=1${r ? `&locale=${encodeURIComponent(r)}` : ""}`, t = await Promise.all(m.map((t) => c(e(t), { headers: u }).then(Jt).then((e) => {
3620
+ let e = (e) => e.startsWith("api:") ? `${l}/data/${encodeURIComponent(e.slice(4))}` : `${l}/dynamic/${encodeURIComponent(e)}?all=1${r ? `&locale=${encodeURIComponent(r)}` : ""}`, t = await Promise.all(m.map((t) => c(e(t), { headers: u }).then(tn).then((e) => {
3338
3621
  let n = Array.isArray(e) ? e : Array.isArray(e?.data) ? e.data : [], r = Number(e?.total?.filtered ?? e?.total?.all ?? n.length);
3339
3622
  return [[t, n], [`${t}:total`, Number.isFinite(r) ? r : n.length]];
3340
3623
  }).catch(() => [[t, []]])));
@@ -3354,14 +3637,14 @@ var $ = (e) => String(e ?? "").replace(/[&<>"]/g, (e) => ({
3354
3637
  ">": "&gt;",
3355
3638
  "\"": "&quot;"
3356
3639
  })[e]);
3357
- function Xt(t, { mode: n = "auto", style: r } = {}) {
3358
- return e(/* @__PURE__ */ d(Kt, {
3640
+ function rn(t, { mode: n = "auto", style: r } = {}) {
3641
+ return e(/* @__PURE__ */ d($t, {
3359
3642
  bundle: t,
3360
3643
  mode: n,
3361
3644
  style: r
3362
3645
  }));
3363
3646
  }
3364
- function Zt(e, { mode: t = "auto", lang: n } = {}) {
3647
+ function an(e, { mode: t = "auto", lang: n } = {}) {
3365
3648
  let r = e.seo ?? {}, i = n || e.locale || "en", a = h(e.direction, i), o = r.title || e.title || e.slug || "Page", s = e.custom?.js?.trim(), c = [
3366
3649
  "<meta charset=\"utf-8\"/>",
3367
3650
  "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"/>",
@@ -3378,10 +3661,10 @@ function Zt(e, { mode: t = "auto", lang: n } = {}) {
3378
3661
  ${c}
3379
3662
  </head>
3380
3663
  <body>
3381
- ${Xt(e, { mode: t })}
3664
+ ${rn(e, { mode: t })}
3382
3665
  ${s ? `<script>${s.replaceAll("<\/script", "<\\/script")}<\/script>` : ""}
3383
3666
  </body>
3384
3667
  </html>`;
3385
3668
  }
3386
3669
  //#endregion
3387
- export { qt as assembleBundle, Yt as fetchPage, Xt as renderBundleHtml, Zt as renderPageDocument };
3670
+ export { en as assembleBundle, nn as fetchPage, rn as renderBundleHtml, an as renderPageDocument };