@adoptai/genui-components 0.1.45 → 0.1.55

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 (61) hide show
  1. package/dist/builders/BlockForm.d.ts +31 -0
  2. package/dist/builders/BlockForm.d.ts.map +1 -0
  3. package/dist/builders/BuilderForm.d.ts +10 -2
  4. package/dist/builders/BuilderForm.d.ts.map +1 -1
  5. package/dist/builders/BuilderRecap.d.ts.map +1 -1
  6. package/dist/builders/ContextSlot.d.ts +6 -0
  7. package/dist/builders/ContextSlot.d.ts.map +1 -1
  8. package/dist/builders/FieldRenderer.d.ts +5 -2
  9. package/dist/builders/FieldRenderer.d.ts.map +1 -1
  10. package/dist/builders/StepperBuilder.d.ts +4 -2
  11. package/dist/builders/StepperBuilder.d.ts.map +1 -1
  12. package/dist/builders/fields.d.ts +22 -1
  13. package/dist/builders/fields.d.ts.map +1 -1
  14. package/dist/builders/hooks.d.ts +17 -0
  15. package/dist/builders/hooks.d.ts.map +1 -1
  16. package/dist/builders/index.d.ts +5 -5
  17. package/dist/builders/index.d.ts.map +1 -1
  18. package/dist/builders/resolver.d.ts +4 -1
  19. package/dist/builders/resolver.d.ts.map +1 -1
  20. package/dist/builders/schemas.d.ts +196 -1
  21. package/dist/builders/schemas.d.ts.map +1 -1
  22. package/dist/composites/journal-entry/resolver.cjs +2 -2
  23. package/dist/composites/journal-entry/resolver.cjs.map +1 -1
  24. package/dist/composites/journal-entry/resolver.js +2 -2
  25. package/dist/composites/journal-entry/resolver.js.map +1 -1
  26. package/dist/composites/waterfall-chart/resolver.cjs +21 -7
  27. package/dist/composites/waterfall-chart/resolver.cjs.map +1 -1
  28. package/dist/composites/waterfall-chart/resolver.d.ts.map +1 -1
  29. package/dist/composites/waterfall-chart/resolver.js +21 -7
  30. package/dist/composites/waterfall-chart/resolver.js.map +1 -1
  31. package/dist/composites/workflow-stepper/resolver.cjs +2 -0
  32. package/dist/composites/workflow-stepper/resolver.cjs.map +1 -1
  33. package/dist/composites/workflow-stepper/resolver.d.ts.map +1 -1
  34. package/dist/composites/workflow-stepper/resolver.js +2 -0
  35. package/dist/composites/workflow-stepper/resolver.js.map +1 -1
  36. package/dist/index.cjs +1415 -783
  37. package/dist/index.cjs.map +1 -1
  38. package/dist/index.js +1415 -783
  39. package/dist/index.js.map +1 -1
  40. package/dist/renderer.cjs +28 -12
  41. package/dist/renderer.cjs.map +1 -1
  42. package/dist/renderer.js +28 -12
  43. package/dist/renderer.js.map +1 -1
  44. package/dist/resolver.cjs +28 -12
  45. package/dist/resolver.cjs.map +1 -1
  46. package/dist/resolver.js +28 -12
  47. package/dist/resolver.js.map +1 -1
  48. package/dist/schemas/index.cjs +3 -3
  49. package/dist/schemas/index.cjs.map +1 -1
  50. package/dist/schemas/index.d.ts +1 -0
  51. package/dist/schemas/index.d.ts.map +1 -1
  52. package/dist/schemas/index.js +3 -3
  53. package/dist/schemas/index.js.map +1 -1
  54. package/dist/schemas/workflow-stepper.d.ts +1 -0
  55. package/dist/schemas/workflow-stepper.d.ts.map +1 -1
  56. package/dist/tool-definitions.json +4 -3
  57. package/package.json +2 -2
  58. package/dist/builders/EscalationCard.d.ts +0 -17
  59. package/dist/builders/EscalationCard.d.ts.map +0 -1
  60. package/dist/builders/FormBuilder.d.ts +0 -19
  61. package/dist/builders/FormBuilder.d.ts.map +0 -1
package/dist/index.js CHANGED
@@ -226,7 +226,7 @@ function alignFromSeparator(cell) {
226
226
  return "left";
227
227
  }
228
228
  function MarkdownBlock({ content }) {
229
- var _a;
229
+ var _a2;
230
230
  const lines = content.split("\n");
231
231
  const elements = [];
232
232
  let key = 0;
@@ -246,7 +246,7 @@ function MarkdownBlock({ content }) {
246
246
  3: { size: "12px", weight: 600, serif: false, mt: "12px" },
247
247
  4: { size: "11px", weight: 600, serif: false, mt: "10px" }
248
248
  };
249
- const s = (_a = cfg[level]) != null ? _a : cfg[3];
249
+ const s = (_a2 = cfg[level]) != null ? _a2 : cfg[3];
250
250
  elements.push(
251
251
  /* @__PURE__ */ jsx(
252
252
  "div",
@@ -367,8 +367,8 @@ function MarkdownBlock({ content }) {
367
367
  i++;
368
368
  }
369
369
  const colAlign = (idx) => {
370
- var _a2;
371
- return (_a2 = aligns[idx]) != null ? _a2 : "left";
370
+ var _a3;
371
+ return (_a3 = aligns[idx]) != null ? _a3 : "left";
372
372
  };
373
373
  elements.push(
374
374
  /* @__PURE__ */ jsx("div", { style: { margin: "6px 0 10px 0", overflowX: "auto" }, children: /* @__PURE__ */ jsxs(
@@ -401,7 +401,7 @@ function MarkdownBlock({ content }) {
401
401
  idx
402
402
  )) }) }),
403
403
  /* @__PURE__ */ jsx("tbody", { children: rows.map((cells, rIdx) => /* @__PURE__ */ jsx("tr", { children: headers.map((_, cIdx) => {
404
- var _a2;
404
+ var _a3;
405
405
  return /* @__PURE__ */ jsx(
406
406
  "td",
407
407
  {
@@ -412,7 +412,7 @@ function MarkdownBlock({ content }) {
412
412
  color: "var(--foreground)",
413
413
  verticalAlign: "top"
414
414
  },
415
- children: renderInline((_a2 = cells[cIdx]) != null ? _a2 : "")
415
+ children: renderInline((_a3 = cells[cIdx]) != null ? _a3 : "")
416
416
  },
417
417
  cIdx
418
418
  );
@@ -487,7 +487,7 @@ function splitEdge(line) {
487
487
  return null;
488
488
  }
489
489
  function parseMermaidFlow(source) {
490
- var _a, _b, _c;
490
+ var _a2, _b, _c;
491
491
  const lines = source.split("\n").map((l) => l.trim()).filter((l) => l && !l.startsWith("%%"));
492
492
  if (!lines.length) return null;
493
493
  const header = lines[0].toLowerCase();
@@ -499,7 +499,7 @@ function parseMermaidFlow(source) {
499
499
  rl: "RL",
500
500
  bt: "BT"
501
501
  };
502
- const dirToken = (_b = (_a = header.split(/\s+/)[1]) == null ? void 0 : _a.toLowerCase()) != null ? _b : "td";
502
+ const dirToken = (_b = (_a2 = header.split(/\s+/)[1]) == null ? void 0 : _a2.toLowerCase()) != null ? _b : "td";
503
503
  const direction = (_c = directionMap[dirToken]) != null ? _c : "TB";
504
504
  const nodeMap = /* @__PURE__ */ new Map();
505
505
  const edges = [];
@@ -742,51 +742,51 @@ function DoneBadge() {
742
742
  return /* @__PURE__ */ jsx("span", { className: "gx-done-badge", "aria-hidden": "true", children: /* @__PURE__ */ jsx("svg", { width: "9", height: "9", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "4", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "M20 6 9 17l-5-5" }) }) });
743
743
  }
744
744
  function RectNode({ data }) {
745
- var _a;
745
+ var _a2;
746
746
  const s = data.status;
747
747
  return /* @__PURE__ */ jsxs("div", { className: nodeClass(s), style: __spreadProps(__spreadValues({}, nodeBase), { borderRadius: "6px" }), children: [
748
748
  /* @__PURE__ */ jsx(Handles, { dir: data.direction }),
749
749
  s === "done" && /* @__PURE__ */ jsx(DoneBadge, {}),
750
- String((_a = data.label) != null ? _a : "")
750
+ String((_a2 = data.label) != null ? _a2 : "")
751
751
  ] });
752
752
  }
753
753
  function RoundedNode({ data }) {
754
- var _a;
754
+ var _a2;
755
755
  const s = data.status;
756
756
  return /* @__PURE__ */ jsxs("div", { className: nodeClass(s), style: __spreadProps(__spreadValues({}, nodeBase), { borderRadius: "999px" }), children: [
757
757
  /* @__PURE__ */ jsx(Handles, { dir: data.direction }),
758
758
  s === "done" && /* @__PURE__ */ jsx(DoneBadge, {}),
759
- String((_a = data.label) != null ? _a : "")
759
+ String((_a2 = data.label) != null ? _a2 : "")
760
760
  ] });
761
761
  }
762
762
  function CircleNode({ data }) {
763
- var _a;
763
+ var _a2;
764
764
  const s = data.status;
765
765
  return /* @__PURE__ */ jsxs("div", { className: nodeClass(s), style: __spreadProps(__spreadValues({}, nodeBase), { borderRadius: "50%", padding: "6px" }), children: [
766
766
  /* @__PURE__ */ jsx(Handles, { dir: data.direction }),
767
767
  s === "done" && /* @__PURE__ */ jsx(DoneBadge, {}),
768
- String((_a = data.label) != null ? _a : "")
768
+ String((_a2 = data.label) != null ? _a2 : "")
769
769
  ] });
770
770
  }
771
771
  function DiamondNode({ data }) {
772
- var _a;
772
+ var _a2;
773
773
  const s = data.status;
774
774
  return /* @__PURE__ */ jsxs("div", { className: nodeClass(s), style: { position: "relative", width: "100%", height: "100%", display: "flex", alignItems: "center", justifyContent: "center", border: "none", background: "transparent" }, children: [
775
775
  /* @__PURE__ */ jsx(Handles, { dir: data.direction }),
776
776
  s === "done" && /* @__PURE__ */ jsx(DoneBadge, {}),
777
777
  /* @__PURE__ */ jsx("svg", { style: { position: "absolute", inset: 0, width: "100%", height: "100%", overflow: "visible" }, viewBox: "0 0 1 1", preserveAspectRatio: "none", children: /* @__PURE__ */ jsx("polygon", { className: "gx-flow-poly", points: "0.5,0.03 0.97,0.5 0.5,0.97 0.03,0.5", fill: "var(--gx-bg)", stroke: "var(--gx-outline)", strokeWidth: "1.5", vectorEffect: "non-scaling-stroke" }) }),
778
- /* @__PURE__ */ jsx("span", { style: { position: "relative", zIndex: 1, fontFamily: "var(--gx-font)", fontSize: "11px", fontWeight: 500, color: "var(--gx-text)", textAlign: "center", lineHeight: 1.25, userSelect: "none", padding: "0 22px", maxWidth: "100%" }, children: String((_a = data.label) != null ? _a : "") })
778
+ /* @__PURE__ */ jsx("span", { style: { position: "relative", zIndex: 1, fontFamily: "var(--gx-font)", fontSize: "11px", fontWeight: 500, color: "var(--gx-text)", textAlign: "center", lineHeight: 1.25, userSelect: "none", padding: "0 22px", maxWidth: "100%" }, children: String((_a2 = data.label) != null ? _a2 : "") })
779
779
  ] });
780
780
  }
781
781
  function CylinderNode({ data }) {
782
- var _a;
782
+ var _a2;
783
783
  const a = 5;
784
784
  const s = data.status;
785
785
  return /* @__PURE__ */ jsxs("div", { className: nodeClass(s), style: { position: "relative", width: "100%", height: "100%", border: "none", background: "transparent" }, children: [
786
786
  /* @__PURE__ */ jsx(Handles, { dir: data.direction }),
787
787
  s === "done" && /* @__PURE__ */ jsx(DoneBadge, {}),
788
788
  /* @__PURE__ */ jsx("div", { style: { position: "absolute", top: 0, left: 0, right: 0, height: a * 2, border: "1.5px solid var(--gx-outline)", borderRadius: "50%", background: "var(--gx-bg)", zIndex: 1 } }),
789
- /* @__PURE__ */ jsx("div", { style: { position: "absolute", inset: `${a}px 0`, border: "1.5px solid var(--gx-outline)", borderTop: "none", borderBottom: "none", background: "var(--gx-bg)", display: "flex", alignItems: "center", justifyContent: "center", fontFamily: "var(--gx-font)", fontSize: "12px", fontWeight: 500, color: "var(--gx-text)" }, children: String((_a = data.label) != null ? _a : "") }),
789
+ /* @__PURE__ */ jsx("div", { style: { position: "absolute", inset: `${a}px 0`, border: "1.5px solid var(--gx-outline)", borderTop: "none", borderBottom: "none", background: "var(--gx-bg)", display: "flex", alignItems: "center", justifyContent: "center", fontFamily: "var(--gx-font)", fontSize: "12px", fontWeight: 500, color: "var(--gx-text)" }, children: String((_a2 = data.label) != null ? _a2 : "") }),
790
790
  /* @__PURE__ */ jsx("div", { style: { position: "absolute", bottom: 0, left: 0, right: 0, height: a * 2, border: "1.5px solid var(--gx-outline)", borderRadius: "50%", background: "var(--gx-bg)", zIndex: 1 } })
791
791
  ] });
792
792
  }
@@ -924,31 +924,31 @@ function FullscreenModal({ nodes, edges, title, onClose }) {
924
924
  function usePrefersReducedMotion() {
925
925
  const [reduced, setReduced] = useState(false);
926
926
  useEffect(() => {
927
- var _a;
927
+ var _a2;
928
928
  if (typeof matchMedia === "undefined") return;
929
929
  const mq = matchMedia("(prefers-reduced-motion: reduce)");
930
930
  setReduced(mq.matches);
931
931
  const h = () => setReduced(mq.matches);
932
- (_a = mq.addEventListener) == null ? void 0 : _a.call(mq, "change", h);
932
+ (_a2 = mq.addEventListener) == null ? void 0 : _a2.call(mq, "change", h);
933
933
  return () => {
934
- var _a2;
935
- return (_a2 = mq.removeEventListener) == null ? void 0 : _a2.call(mq, "change", h);
934
+ var _a3;
935
+ return (_a3 = mq.removeEventListener) == null ? void 0 : _a3.call(mq, "change", h);
936
936
  };
937
937
  }, []);
938
938
  return reduced;
939
939
  }
940
940
  function topoOrder(nodeIds, edges) {
941
- var _a, _b, _c, _d;
941
+ var _a2, _b, _c, _d;
942
942
  const indeg = new Map(nodeIds.map((id) => [id, 0]));
943
943
  const adj = new Map(nodeIds.map((id) => [id, []]));
944
944
  for (const e of edges) {
945
945
  if (!indeg.has(e.target) || !adj.has(e.source)) continue;
946
- indeg.set(e.target, ((_a = indeg.get(e.target)) != null ? _a : 0) + 1);
946
+ indeg.set(e.target, ((_a2 = indeg.get(e.target)) != null ? _a2 : 0) + 1);
947
947
  adj.get(e.source).push(e.target);
948
948
  }
949
949
  const queue = nodeIds.filter((id) => {
950
- var _a2;
951
- return ((_a2 = indeg.get(id)) != null ? _a2 : 0) === 0;
950
+ var _a3;
951
+ return ((_a3 = indeg.get(id)) != null ? _a3 : 0) === 0;
952
952
  });
953
953
  const seen = /* @__PURE__ */ new Set();
954
954
  const order = [];
@@ -1001,11 +1001,11 @@ function useAutoplay(order, enabled) {
1001
1001
  }, [order, step]);
1002
1002
  }
1003
1003
  function resolveStates(nodes, nodeStates) {
1004
- var _a, _b;
1004
+ var _a2, _b;
1005
1005
  if (!nodeStates) return {};
1006
1006
  const m = {};
1007
1007
  for (const n of nodes) {
1008
- const label = (_a = n.data) == null ? void 0 : _a.label;
1008
+ const label = (_a2 = n.data) == null ? void 0 : _a2.label;
1009
1009
  const st = (_b = nodeStates[n.id]) != null ? _b : label ? nodeStates[label] : void 0;
1010
1010
  if (st) m[n.id] = st;
1011
1011
  }
@@ -1021,8 +1021,8 @@ function Inner({ diagram, title, autoplay, nodeStates }) {
1021
1021
  const layout = useMemo(() => parsed ? computeLayout(parsed) : null, [parsed]);
1022
1022
  const themedEdges = useMemo(
1023
1023
  () => {
1024
- var _a;
1025
- return ((_a = layout == null ? void 0 : layout.edges) != null ? _a : []).map((e) => __spreadProps(__spreadValues({}, e), {
1024
+ var _a2;
1025
+ return ((_a2 = layout == null ? void 0 : layout.edges) != null ? _a2 : []).map((e) => __spreadProps(__spreadValues({}, e), {
1026
1026
  style: __spreadProps(__spreadValues({}, e.style), { stroke: tokens.ACCENT, strokeWidth: 1.75 }),
1027
1027
  labelStyle: { fill: tokens.MUTED, fontSize: 10, fontFamily: "var(--font-sans, Figtree, system-ui, sans-serif)" },
1028
1028
  labelBgStyle: { fill: "#ffffff", fillOpacity: 0.92 },
@@ -1033,21 +1033,21 @@ function Inner({ diagram, title, autoplay, nodeStates }) {
1033
1033
  );
1034
1034
  const order = useMemo(
1035
1035
  () => {
1036
- var _a, _b;
1037
- return topoOrder(((_a = layout == null ? void 0 : layout.nodes) != null ? _a : []).map((n) => n.id), (_b = layout == null ? void 0 : layout.edges) != null ? _b : []);
1036
+ var _a2, _b;
1037
+ return topoOrder(((_a2 = layout == null ? void 0 : layout.nodes) != null ? _a2 : []).map((n) => n.id), (_b = layout == null ? void 0 : layout.edges) != null ? _b : []);
1038
1038
  },
1039
1039
  [layout]
1040
1040
  );
1041
1041
  const autoStatus = useAutoplay(order, !!autoplay);
1042
1042
  const staticStatus = useMemo(() => {
1043
- var _a;
1044
- return resolveStates((_a = layout == null ? void 0 : layout.nodes) != null ? _a : [], nodeStates);
1043
+ var _a2;
1044
+ return resolveStates((_a2 = layout == null ? void 0 : layout.nodes) != null ? _a2 : [], nodeStates);
1045
1045
  }, [layout, nodeStates]);
1046
1046
  const statusMap = autoplay ? autoStatus : staticStatus;
1047
1047
  const displayNodes = useMemo(
1048
1048
  () => {
1049
- var _a;
1050
- return ((_a = layout == null ? void 0 : layout.nodes) != null ? _a : []).map((n) => __spreadProps(__spreadValues({}, n), { data: __spreadProps(__spreadValues({}, n.data), { status: statusMap[n.id] }) }));
1049
+ var _a2;
1050
+ return ((_a2 = layout == null ? void 0 : layout.nodes) != null ? _a2 : []).map((n) => __spreadProps(__spreadValues({}, n), { data: __spreadProps(__spreadValues({}, n.data), { status: statusMap[n.id] }) }));
1051
1051
  },
1052
1052
  [layout, statusMap]
1053
1053
  );
@@ -1263,8 +1263,8 @@ function PdfViewer({ url, base64, onLoadSuccess }) {
1263
1263
  useEffect(() => {
1264
1264
  if (numPages <= 1) return;
1265
1265
  const handler = (e) => {
1266
- var _a;
1267
- const tag = (_a = e.target) == null ? void 0 : _a.tagName;
1266
+ var _a2;
1267
+ const tag = (_a2 = e.target) == null ? void 0 : _a2.tagName;
1268
1268
  if (tag === "INPUT" || tag === "TEXTAREA") return;
1269
1269
  if (e.key === "ArrowLeft" || e.key === "ArrowUp") {
1270
1270
  e.preventDefault();
@@ -1423,8 +1423,8 @@ function ExcelViewer({ url, base64, onLoadSuccess }) {
1423
1423
  useEffect(() => {
1424
1424
  if (sheetNames.length <= 1) return;
1425
1425
  const handler = (e) => {
1426
- var _a;
1427
- const tag = (_a = e.target) == null ? void 0 : _a.tagName;
1426
+ var _a2;
1427
+ const tag = (_a2 = e.target) == null ? void 0 : _a2.tagName;
1428
1428
  if (tag === "INPUT" || tag === "TEXTAREA") return;
1429
1429
  if (e.key === "ArrowLeft") {
1430
1430
  e.preventDefault();
@@ -1478,8 +1478,8 @@ function ExcelViewer({ url, base64, onLoadSuccess }) {
1478
1478
  name
1479
1479
  )) }),
1480
1480
  /* @__PURE__ */ jsx("div", { style: { overflow: "auto", maxHeight: "500px" }, children: /* @__PURE__ */ jsx("table", { style: { width: "100%", borderCollapse: "collapse", fontSize: "12px" }, children: /* @__PURE__ */ jsx("tbody", { children: data.map((row, ri) => /* @__PURE__ */ jsx("tr", { children: row.map((cell, ci) => {
1481
- var _a, _b;
1482
- const isHeader = ri === 0 || ri === 2 && ((_a = data[0]) == null ? void 0 : _a[0]) && !((_b = data[1]) == null ? void 0 : _b[0]);
1481
+ var _a2, _b;
1482
+ const isHeader = ri === 0 || ri === 2 && ((_a2 = data[0]) == null ? void 0 : _a2[0]) && !((_b = data[1]) == null ? void 0 : _b[0]);
1483
1483
  const Tag = isHeader ? "th" : "td";
1484
1484
  return /* @__PURE__ */ jsx(
1485
1485
  Tag,
@@ -1626,8 +1626,8 @@ function CsvViewer({ url, base64, delimiter, maxRows }) {
1626
1626
  i
1627
1627
  )) }) }),
1628
1628
  /* @__PURE__ */ jsx("tbody", { children: shown.map((row, ri) => /* @__PURE__ */ jsx("tr", { children: header.map((_, ci) => {
1629
- var _a;
1630
- const cell = (_a = row[ci]) != null ? _a : "";
1629
+ var _a2;
1630
+ const cell = (_a2 = row[ci]) != null ? _a2 : "";
1631
1631
  return /* @__PURE__ */ jsx(
1632
1632
  "td",
1633
1633
  {
@@ -1934,12 +1934,12 @@ var statusCardSchema = z.object({
1934
1934
  z.object({
1935
1935
  label: z.string(),
1936
1936
  variant: z.string().transform((v) => {
1937
- var _a;
1938
- return (_a = variantMap[v]) != null ? _a : "bordered";
1937
+ var _a2;
1938
+ return (_a2 = variantMap[v]) != null ? _a2 : "bordered";
1939
1939
  }).default("bordered"),
1940
1940
  color: z.string().transform((v) => {
1941
- var _a;
1942
- return (_a = colorMap[v]) != null ? _a : "default";
1941
+ var _a2;
1942
+ return (_a2 = colorMap[v]) != null ? _a2 : "default";
1943
1943
  }).default("default")
1944
1944
  })
1945
1945
  ).max(3).optional()
@@ -2231,9 +2231,9 @@ var groupedTableSchema = z.object({
2231
2231
  key: z.string(),
2232
2232
  label: z.string(),
2233
2233
  align: z.string().transform((v) => {
2234
- var _a;
2234
+ var _a2;
2235
2235
  const map = { left: "start", right: "end", start: "start", center: "center", end: "end" };
2236
- return (_a = map[v]) != null ? _a : "start";
2236
+ return (_a2 = map[v]) != null ? _a2 : "start";
2237
2237
  }).default("start")
2238
2238
  })).min(1).max(10),
2239
2239
  groups: z.array(groupSchema).min(1).max(20)
@@ -4725,8 +4725,8 @@ var comboChartSchema = z.object({
4725
4725
  lines: z.array(seriesRef).max(4).optional(),
4726
4726
  data: z.array(z.record(z.string(), z.union([z.string(), z.number()]))).min(2).max(500)
4727
4727
  }).refine((v) => {
4728
- var _a, _b, _c, _d;
4729
- return ((_b = (_a = v.bars) == null ? void 0 : _a.length) != null ? _b : 0) + ((_d = (_c = v.lines) == null ? void 0 : _c.length) != null ? _d : 0) >= 1;
4728
+ var _a2, _b, _c, _d;
4729
+ return ((_b = (_a2 = v.bars) == null ? void 0 : _a2.length) != null ? _b : 0) + ((_d = (_c = v.lines) == null ? void 0 : _c.length) != null ? _d : 0) >= 1;
4730
4730
  }, {
4731
4731
  message: "combo-chart needs at least one bar or line series"
4732
4732
  });
@@ -5227,7 +5227,7 @@ var workflowStepperSchema = z.object({
5227
5227
  n: z.number().int().positive().optional(),
5228
5228
  title: z.string(),
5229
5229
  sub: z.string().optional(),
5230
- status: z.enum(["done", "active", "review", "pending", "failed"]),
5230
+ status: z.enum(["done", "active", "review", "pending", "blocked", "failed"]),
5231
5231
  assignees: z.array(
5232
5232
  z.object({
5233
5233
  name: z.string(),
@@ -5242,7 +5242,7 @@ var workflowStepperSchema = z.object({
5242
5242
  });
5243
5243
  var workflowStepperTool = {
5244
5244
  name: "render_workflow_stepper",
5245
- description: "Render a recurring-process workflow stepper \u2014 a horizontal strip of sequential step cards (e.g. a monthly close pipeline) with per-step status (done/active/review/pending/failed) and human + agent assignee avatars. Use for org processes with named steps and owners, NOT for generic progress bars or project phase summaries.",
5245
+ description: "Render a recurring-process workflow stepper \u2014 a horizontal strip of sequential step cards (e.g. a monthly close pipeline) with per-step status (done/active/review/pending/blocked/failed) and human + agent assignee avatars. Use for org processes with named steps and owners, NOT for generic progress bars or project phase summaries.",
5246
5246
  input_schema: {
5247
5247
  type: "object",
5248
5248
  properties: {
@@ -5263,7 +5263,7 @@ var workflowStepperTool = {
5263
5263
  n: { type: "number", description: "Step number; defaults to index + 1" },
5264
5264
  title: { type: "string" },
5265
5265
  sub: { type: "string", description: "Short status caption, e.g. '7 accounts \xB7 2 exceptions'" },
5266
- status: { type: "string", enum: ["done", "active", "review", "pending", "failed"] },
5266
+ status: { type: "string", enum: ["done", "active", "review", "pending", "blocked", "failed"] },
5267
5267
  assignees: {
5268
5268
  type: "array",
5269
5269
  maxItems: 6,
@@ -5303,12 +5303,12 @@ function buildRenderUITool(selectedSchemas) {
5303
5303
 
5304
5304
  // src/schemas/coercePayload.ts
5305
5305
  function coercePayload(data) {
5306
- var _a, _b, _c;
5306
+ var _a2, _b, _c;
5307
5307
  if (!data || typeof data !== "object" || Array.isArray(data)) return data;
5308
5308
  const obj = data;
5309
5309
  const type = obj.type;
5310
5310
  if (typeof type !== "string" || !(type in schemaRegistry)) return data;
5311
- const props = (_c = (_b = (_a = schemaRegistry[type]) == null ? void 0 : _a.tool) == null ? void 0 : _b.input_schema) == null ? void 0 : _c.properties;
5311
+ const props = (_c = (_b = (_a2 = schemaRegistry[type]) == null ? void 0 : _a2.tool) == null ? void 0 : _b.input_schema) == null ? void 0 : _c.properties;
5312
5312
  if (!props || typeof props !== "object") return data;
5313
5313
  let out = null;
5314
5314
  for (const [key, propSchema] of Object.entries(props)) {
@@ -5469,8 +5469,8 @@ function ComponentActions({ children, onDownloadCSV, columnConfig, filename = "c
5469
5469
  useEffect(() => {
5470
5470
  if (!open) return;
5471
5471
  const handler = (e) => {
5472
- var _a, _b;
5473
- if ((_a = menuRef.current) == null ? void 0 : _a.contains(e.target)) return;
5472
+ var _a2, _b;
5473
+ if ((_a2 = menuRef.current) == null ? void 0 : _a2.contains(e.target)) return;
5474
5474
  if ((_b = btnRef.current) == null ? void 0 : _b.contains(e.target)) return;
5475
5475
  close();
5476
5476
  };
@@ -5669,9 +5669,9 @@ var td = (align, last) => ({
5669
5669
  whiteSpace: align === "end" || align === "center" ? "nowrap" : "normal"
5670
5670
  });
5671
5671
  function DataTableResolver(p) {
5672
- var _a, _b, _c;
5672
+ var _a2, _b, _c;
5673
5673
  const { BORDER: BORDER4, MUTED: MUTED2, PAPER: PAPER2 } = useTheme();
5674
- const columns = (_a = p.columns) != null ? _a : [];
5674
+ const columns = (_a2 = p.columns) != null ? _a2 : [];
5675
5675
  const rows = (_b = p.rows) != null ? _b : [];
5676
5676
  const { visibleColumns, hidden, toggle, showAll, hideAll, allColumns } = useColumnVisibility(columns);
5677
5677
  return /* @__PURE__ */ jsx(
@@ -5679,8 +5679,8 @@ function DataTableResolver(p) {
5679
5679
  {
5680
5680
  filename: (_c = p.title) != null ? _c : "data-table",
5681
5681
  onDownloadCSV: () => {
5682
- var _a2;
5683
- return downloadCSV(visibleColumns, rows, (_a2 = p.title) != null ? _a2 : "data-table");
5682
+ var _a3;
5683
+ return downloadCSV(visibleColumns, rows, (_a3 = p.title) != null ? _a3 : "data-table");
5684
5684
  },
5685
5685
  columnConfig: { columns: allColumns, hidden, onToggle: toggle, onShowAll: showAll, onHideAll: hideAll },
5686
5686
  children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "10px" }, children: [
@@ -5688,8 +5688,8 @@ function DataTableResolver(p) {
5688
5688
  /* @__PURE__ */ jsx("div", { style: { overflowX: "auto", borderRadius: "0.75rem", border: `1px solid ${BORDER4}`, boxShadow: "0 1px 2px rgba(0,0,0,0.03), 0 4px 12px rgba(0,0,0,0.05)" }, children: /* @__PURE__ */ jsxs("table", { style: { width: "100%", borderCollapse: "collapse" }, children: [
5689
5689
  /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: visibleColumns.map((col) => /* @__PURE__ */ jsx("th", { style: th(col.align), children: col.label }, col.key)) }) }),
5690
5690
  /* @__PURE__ */ jsx("tbody", { children: rows.map((row, ri) => /* @__PURE__ */ jsx("tr", { style: { background: ri % 2 === 0 ? "white" : "#fafafa" }, children: visibleColumns.map((col) => {
5691
- var _a2;
5692
- return /* @__PURE__ */ jsx("td", { style: td(col.align, ri === rows.length - 1), children: String((_a2 = row[col.key]) != null ? _a2 : "\u2014") }, col.key);
5691
+ var _a3;
5692
+ return /* @__PURE__ */ jsx("td", { style: td(col.align, ri === rows.length - 1), children: String((_a3 = row[col.key]) != null ? _a3 : "\u2014") }, col.key);
5693
5693
  }) }, ri)) })
5694
5694
  ] }) })
5695
5695
  ] })
@@ -5740,9 +5740,9 @@ var S = {
5740
5740
  label: { fontSize: "12px", color: MUTED, flexShrink: 0 }
5741
5741
  };
5742
5742
  function StatusCardResolver(p) {
5743
- var _a, _b, _c, _d, _e;
5743
+ var _a2, _b, _c, _d, _e;
5744
5744
  const { ACCENT: ACCENT2, MUTED: MUTED2 } = useTheme();
5745
- const status = (_a = p.status) != null ? _a : "default";
5745
+ const status = (_a2 = p.status) != null ? _a2 : "default";
5746
5746
  return /* @__PURE__ */ jsx(ComponentActions, { filename: (_b = p.title) != null ? _b : "status-card", children: /* @__PURE__ */ jsxs("div", { style: S.card, children: [
5747
5747
  /* @__PURE__ */ jsxs("div", { style: S.header, children: [
5748
5748
  /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "8px", flexWrap: "wrap" }, children: [
@@ -5765,8 +5765,8 @@ function StatusCardResolver(p) {
5765
5765
  p.subtitle && /* @__PURE__ */ jsx("p", { style: S.subtitle, children: /* @__PURE__ */ jsx(Markdown, { inline: true, content: p.subtitle }) })
5766
5766
  ] }),
5767
5767
  /* @__PURE__ */ jsx("div", { style: S.content, children: /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column" }, children: ((_c = p.fields) != null ? _c : []).map((field, i) => {
5768
- var _a2;
5769
- return /* @__PURE__ */ jsxs("div", { style: __spreadValues(__spreadValues({}, S.fieldRow), i === ((_a2 = p.fields) != null ? _a2 : []).length - 1 ? { borderBottom: "none" } : {}), children: [
5768
+ var _a3;
5769
+ return /* @__PURE__ */ jsxs("div", { style: __spreadValues(__spreadValues({}, S.fieldRow), i === ((_a3 = p.fields) != null ? _a3 : []).length - 1 ? { borderBottom: "none" } : {}), children: [
5770
5770
  /* @__PURE__ */ jsx("span", { style: S.label, children: field.label }),
5771
5771
  /* @__PURE__ */ jsx("span", { style: {
5772
5772
  fontSize: "13px",
@@ -5819,8 +5819,8 @@ var statusStyles = {
5819
5819
  default: { border: "#dedede", bg: "#f6f6f6", icon: "\u2139" }
5820
5820
  };
5821
5821
  function AlertResolver(p) {
5822
- var _a, _b;
5823
- const status = toAlertStatus((_a = p.color) != null ? _a : "default");
5822
+ var _a2, _b;
5823
+ const status = toAlertStatus((_a2 = p.color) != null ? _a2 : "default");
5824
5824
  const s = statusStyles[status];
5825
5825
  return /* @__PURE__ */ jsx(ComponentActions, { filename: (_b = p.title) != null ? _b : "alert", children: /* @__PURE__ */ jsx("div", { style: { width: "100%" }, children: /* @__PURE__ */ jsxs(
5826
5826
  "div",
@@ -5937,9 +5937,9 @@ var cardStyle = {
5937
5937
  overflow: "hidden"
5938
5938
  };
5939
5939
  function StatGridResolver(p) {
5940
- var _a;
5940
+ var _a2;
5941
5941
  const { MUTED: MUTED2 } = useTheme();
5942
- return /* @__PURE__ */ jsx(ComponentActions, { filename: "stat-grid", children: /* @__PURE__ */ jsx("div", { style: { width: "100%", display: "grid", gap: "10px", gridTemplateColumns: "repeat(auto-fill, minmax(min(140px, 100%), 1fr))" }, children: ((_a = p.stats) != null ? _a : []).map((stat, i) => /* @__PURE__ */ jsx("div", { style: cardStyle, children: /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "4px", padding: "4px 0", minWidth: 0 }, children: [
5942
+ return /* @__PURE__ */ jsx(ComponentActions, { filename: "stat-grid", children: /* @__PURE__ */ jsx("div", { style: { width: "100%", display: "grid", gap: "10px", gridTemplateColumns: "repeat(auto-fill, minmax(min(140px, 100%), 1fr))" }, children: ((_a2 = p.stats) != null ? _a2 : []).map((stat, i) => /* @__PURE__ */ jsx("div", { style: cardStyle, children: /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "4px", padding: "4px 0", minWidth: 0 }, children: [
5943
5943
  /* @__PURE__ */ jsx("p", { style: __spreadValues({ fontSize: "11.5px", color: MUTED2, letterSpacing: "0.02em", textTransform: "uppercase", margin: 0 }, TRUNCATE), children: stat.label }),
5944
5944
  /* @__PURE__ */ jsx(
5945
5945
  FitText,
@@ -5958,7 +5958,7 @@ function StatGridResolver(p) {
5958
5958
  init_Markdown();
5959
5959
  init_ThemeContext();
5960
5960
  function TabsPanelResolver(p) {
5961
- var _a;
5961
+ var _a2;
5962
5962
  const { BORDER: BORDER4, MUTED: MUTED2, PAPER: PAPER2, ACCENT: ACCENT2 } = useTheme();
5963
5963
  const [activeIdx, setActiveIdx] = useState(0);
5964
5964
  const activeTab = p.tabs[activeIdx];
@@ -5977,8 +5977,8 @@ function TabsPanelResolver(p) {
5977
5977
  borderRight: `1px solid ${BORDER4}`,
5978
5978
  borderBottom: `1px solid ${BORDER4}`
5979
5979
  },
5980
- children: ((_a = p.tabs) != null ? _a : []).map((tab, i) => {
5981
- var _a2;
5980
+ children: ((_a2 = p.tabs) != null ? _a2 : []).map((tab, i) => {
5981
+ var _a3;
5982
5982
  const isActive = i === activeIdx;
5983
5983
  return /* @__PURE__ */ jsxs(
5984
5984
  "button",
@@ -5999,7 +5999,7 @@ function TabsPanelResolver(p) {
5999
5999
  color: isActive ? "var(--foreground)" : MUTED2,
6000
6000
  position: "relative",
6001
6001
  transition: "all 0.15s ease",
6002
- borderRadius: i === 0 ? "8px 0 0 0" : i === ((_a2 = p.tabs) != null ? _a2 : []).length - 1 ? "0 8px 0 0" : "0"
6002
+ borderRadius: i === 0 ? "8px 0 0 0" : i === ((_a3 = p.tabs) != null ? _a3 : []).length - 1 ? "0 8px 0 0" : "0"
6003
6003
  },
6004
6004
  children: [
6005
6005
  isActive && /* @__PURE__ */ jsx(
@@ -6073,16 +6073,16 @@ var thStyle = {
6073
6073
  whiteSpace: "nowrap"
6074
6074
  };
6075
6075
  function SparklineTableResolver(p) {
6076
- var _a, _b, _c;
6076
+ var _a2, _b, _c;
6077
6077
  const { BORDER: BORDER4, MUTED: MUTED2, PAPER: PAPER2 } = useTheme();
6078
- const { visibleColumns, hidden, toggle, showAll, hideAll, allColumns } = useColumnVisibility((_a = p.columns) != null ? _a : []);
6078
+ const { visibleColumns, hidden, toggle, showAll, hideAll, allColumns } = useColumnVisibility((_a2 = p.columns) != null ? _a2 : []);
6079
6079
  return /* @__PURE__ */ jsx(
6080
6080
  ComponentActions,
6081
6081
  {
6082
6082
  filename: (_b = p.title) != null ? _b : "sparkline-table",
6083
6083
  onDownloadCSV: () => {
6084
- var _a2;
6085
- return downloadCSV(visibleColumns, p.rows, (_a2 = p.title) != null ? _a2 : "sparkline-table");
6084
+ var _a3;
6085
+ return downloadCSV(visibleColumns, p.rows, (_a3 = p.title) != null ? _a3 : "sparkline-table");
6086
6086
  },
6087
6087
  columnConfig: { columns: allColumns, hidden, onToggle: toggle, onShowAll: showAll, onHideAll: hideAll },
6088
6088
  children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "10px" }, children: [
@@ -6093,10 +6093,10 @@ function SparklineTableResolver(p) {
6093
6093
  /* @__PURE__ */ jsx("th", { style: __spreadProps(__spreadValues({}, thStyle), { textAlign: "center" }), children: p.sparklineLabel })
6094
6094
  ] }) }),
6095
6095
  /* @__PURE__ */ jsx("tbody", { children: ((_c = p.rows) != null ? _c : []).map((row, ri) => {
6096
- var _a2;
6097
- return /* @__PURE__ */ jsxs("tr", { style: { background: ri % 2 === 0 ? "white" : "#fafafa", borderBottom: ri < ((_a2 = p.rows) != null ? _a2 : []).length - 1 ? "1px solid #f2f2f2" : "none" }, children: [
6096
+ var _a3;
6097
+ return /* @__PURE__ */ jsxs("tr", { style: { background: ri % 2 === 0 ? "white" : "#fafafa", borderBottom: ri < ((_a3 = p.rows) != null ? _a3 : []).length - 1 ? "1px solid #f2f2f2" : "none" }, children: [
6098
6098
  visibleColumns.map((col) => {
6099
- var _a3;
6099
+ var _a4;
6100
6100
  return /* @__PURE__ */ jsx("td", { style: {
6101
6101
  padding: "8px 10px",
6102
6102
  fontSize: "13px",
@@ -6104,7 +6104,7 @@ function SparklineTableResolver(p) {
6104
6104
  fontVariantNumeric: "tabular-nums",
6105
6105
  whiteSpace: col.align === "end" || col.align === "center" ? "nowrap" : "normal",
6106
6106
  textAlign: col.align === "end" ? "right" : col.align === "center" ? "center" : "left"
6107
- }, children: String((_a3 = row[col.key]) != null ? _a3 : "\u2014") }, col.key);
6107
+ }, children: String((_a4 = row[col.key]) != null ? _a4 : "\u2014") }, col.key);
6108
6108
  }),
6109
6109
  /* @__PURE__ */ jsx("td", { style: { padding: "6px 12px", textAlign: "center", verticalAlign: "middle" }, children: /* @__PURE__ */ jsx(SparklinePath, { points: row.sparkline }) })
6110
6110
  ] }, ri);
@@ -6143,17 +6143,17 @@ var th2 = {
6143
6143
  background: PAPER
6144
6144
  };
6145
6145
  function HeatmapTableResolver(p) {
6146
- var _a, _b, _c, _d, _e;
6146
+ var _a2, _b, _c, _d, _e;
6147
6147
  const { BORDER: BORDER4, MUTED: MUTED2, PAPER: PAPER2 } = useTheme();
6148
- const colDefs = ((_a = p.columns) != null ? _a : []).map((c) => ({ key: c.key, label: c.label }));
6148
+ const colDefs = ((_a2 = p.columns) != null ? _a2 : []).map((c) => ({ key: c.key, label: c.label }));
6149
6149
  const { visibleColumns, hidden, toggle, showAll, hideAll, allColumns } = useColumnVisibility(colDefs);
6150
6150
  const visibleKeys = new Set(visibleColumns.map((c) => c.key));
6151
6151
  const csvRows = ((_b = p.rows) != null ? _b : []).map((row) => {
6152
- var _a2;
6152
+ var _a3;
6153
6153
  const obj = { Asset: row.rowLabel };
6154
- ((_a2 = row.cells) != null ? _a2 : []).forEach((cell, ci) => {
6155
- var _a3;
6156
- if (ci < ((_a3 = p.columns) != null ? _a3 : []).length) obj[p.columns[ci].key] = cell.value;
6154
+ ((_a3 = row.cells) != null ? _a3 : []).forEach((cell, ci) => {
6155
+ var _a4;
6156
+ if (ci < ((_a4 = p.columns) != null ? _a4 : []).length) obj[p.columns[ci].key] = cell.value;
6157
6157
  });
6158
6158
  return obj;
6159
6159
  });
@@ -6162,8 +6162,8 @@ function HeatmapTableResolver(p) {
6162
6162
  {
6163
6163
  filename: (_c = p.title) != null ? _c : "heatmap-table",
6164
6164
  onDownloadCSV: () => {
6165
- var _a2;
6166
- return downloadCSV([{ key: "Asset", label: "Asset" }, ...visibleColumns], csvRows, (_a2 = p.title) != null ? _a2 : "heatmap-table");
6165
+ var _a3;
6166
+ return downloadCSV([{ key: "Asset", label: "Asset" }, ...visibleColumns], csvRows, (_a3 = p.title) != null ? _a3 : "heatmap-table");
6167
6167
  },
6168
6168
  columnConfig: { columns: allColumns, hidden, onToggle: toggle, onShowAll: showAll, onHideAll: hideAll },
6169
6169
  children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "10px" }, children: [
@@ -6174,12 +6174,12 @@ function HeatmapTableResolver(p) {
6174
6174
  ((_d = p.columns) != null ? _d : []).map((col) => visibleKeys.has(col.key) ? /* @__PURE__ */ jsx("th", { style: th2, children: col.label }, col.key) : null)
6175
6175
  ] }) }),
6176
6176
  /* @__PURE__ */ jsx("tbody", { children: ((_e = p.rows) != null ? _e : []).map((row, ri) => {
6177
- var _a2, _b2;
6178
- return /* @__PURE__ */ jsxs("tr", { style: { borderBottom: ri < ((_a2 = p.rows) != null ? _a2 : []).length - 1 ? "1px solid #e5e5e5" : "none" }, children: [
6177
+ var _a3, _b2;
6178
+ return /* @__PURE__ */ jsxs("tr", { style: { borderBottom: ri < ((_a3 = p.rows) != null ? _a3 : []).length - 1 ? "1px solid #e5e5e5" : "none" }, children: [
6179
6179
  /* @__PURE__ */ jsx("td", { style: { padding: "8px 10px", fontWeight: 500, color: "var(--foreground)", fontSize: "12.5px", background: "white" }, children: row.rowLabel }),
6180
6180
  ((_b2 = row.cells) != null ? _b2 : []).map((cell, ci) => {
6181
- var _a3;
6182
- return ci < ((_a3 = p.columns) != null ? _a3 : []).length && visibleKeys.has(p.columns[ci].key) ? /* @__PURE__ */ jsx(
6181
+ var _a4;
6182
+ return ci < ((_a4 = p.columns) != null ? _a4 : []).length && visibleKeys.has(p.columns[ci].key) ? /* @__PURE__ */ jsx(
6183
6183
  "td",
6184
6184
  {
6185
6185
  style: {
@@ -6224,9 +6224,9 @@ var thStyle2 = {
6224
6224
  whiteSpace: "nowrap"
6225
6225
  };
6226
6226
  function ScreenerTableResolver(p) {
6227
- var _a, _b, _c, _d, _e, _f;
6227
+ var _a2, _b, _c, _d, _e, _f;
6228
6228
  const { ACCENT: ACCENT2, BORDER: BORDER4, MUTED: MUTED2, PAPER: PAPER2 } = useTheme();
6229
- const [activeFilters, setActiveFilters] = useState(new Set((_a = p.activeFilters) != null ? _a : []));
6229
+ const [activeFilters, setActiveFilters] = useState(new Set((_a2 = p.activeFilters) != null ? _a2 : []));
6230
6230
  const { visibleColumns, hidden, toggle, showAll, hideAll, allColumns } = useColumnVisibility((_b = p.columns) != null ? _b : []);
6231
6231
  const toggleFilter = (f) => setActiveFilters((prev) => {
6232
6232
  const next = new Set(prev);
@@ -6238,8 +6238,8 @@ function ScreenerTableResolver(p) {
6238
6238
  {
6239
6239
  filename: (_c = p.title) != null ? _c : "screener-table",
6240
6240
  onDownloadCSV: () => {
6241
- var _a2;
6242
- return downloadCSV(visibleColumns, p.rows, (_a2 = p.title) != null ? _a2 : "screener-table");
6241
+ var _a3;
6242
+ return downloadCSV(visibleColumns, p.rows, (_a3 = p.title) != null ? _a3 : "screener-table");
6243
6243
  },
6244
6244
  columnConfig: { columns: allColumns, hidden, onToggle: toggle, onShowAll: showAll, onHideAll: hideAll },
6245
6245
  children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "10px" }, children: [
@@ -6263,9 +6263,9 @@ function ScreenerTableResolver(p) {
6263
6263
  /* @__PURE__ */ jsx("div", { style: { overflowX: "auto", borderRadius: "0.75rem", border: `1px solid ${BORDER4}`, boxShadow: "0 1px 2px rgba(0,0,0,0.03), 0 4px 12px rgba(0,0,0,0.05)" }, children: /* @__PURE__ */ jsxs("table", { style: { width: "100%", borderCollapse: "collapse", minWidth: "420px" }, children: [
6264
6264
  /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: visibleColumns.map((col) => /* @__PURE__ */ jsx("th", { style: __spreadProps(__spreadValues({}, thStyle2), { textAlign: col.align === "end" ? "right" : col.align === "center" ? "center" : "left" }), children: col.label }, col.key)) }) }),
6265
6265
  /* @__PURE__ */ jsx("tbody", { children: ((_f = p.rows) != null ? _f : []).map((row, ri) => {
6266
- var _a2;
6267
- return /* @__PURE__ */ jsx("tr", { style: { background: ri % 2 === 0 ? "white" : "#fafafa", borderBottom: ri < ((_a2 = p.rows) != null ? _a2 : []).length - 1 ? "1px solid #f2f2f2" : "none" }, children: visibleColumns.map((col) => {
6268
- var _a3;
6266
+ var _a3;
6267
+ return /* @__PURE__ */ jsx("tr", { style: { background: ri % 2 === 0 ? "white" : "#fafafa", borderBottom: ri < ((_a3 = p.rows) != null ? _a3 : []).length - 1 ? "1px solid #f2f2f2" : "none" }, children: visibleColumns.map((col) => {
6268
+ var _a4;
6269
6269
  const raw = row[col.key];
6270
6270
  return /* @__PURE__ */ jsx("td", { style: {
6271
6271
  padding: "8px 10px",
@@ -6274,7 +6274,7 @@ function ScreenerTableResolver(p) {
6274
6274
  fontVariantNumeric: "tabular-nums",
6275
6275
  whiteSpace: col.align === "end" || col.align === "center" || col.meterKey ? "nowrap" : "normal",
6276
6276
  textAlign: col.align === "end" ? "right" : col.align === "center" ? "center" : "left"
6277
- }, children: col.meterKey && typeof raw === "number" ? /* @__PURE__ */ jsx(MeterBar, { value: raw, max: (_a3 = col.meterMax) != null ? _a3 : 100 }) : String(raw != null ? raw : "\u2014") }, col.key);
6277
+ }, children: col.meterKey && typeof raw === "number" ? /* @__PURE__ */ jsx(MeterBar, { value: raw, max: (_a4 = col.meterMax) != null ? _a4 : 100 }) : String(raw != null ? raw : "\u2014") }, col.key);
6278
6278
  }) }, ri);
6279
6279
  }) })
6280
6280
  ] }) })
@@ -6295,7 +6295,7 @@ var th3 = {
6295
6295
  background: PAPER
6296
6296
  };
6297
6297
  function GroupRows({ group, columns, depth }) {
6298
- var _a, _b;
6298
+ var _a2, _b;
6299
6299
  const [open, setOpen] = useState(true);
6300
6300
  const indent = depth * 14;
6301
6301
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -6314,9 +6314,9 @@ function GroupRows({ group, columns, depth }) {
6314
6314
  }
6315
6315
  ),
6316
6316
  open && /* @__PURE__ */ jsxs(Fragment, { children: [
6317
- (_a = group.subGroups) == null ? void 0 : _a.map((sub, si) => /* @__PURE__ */ jsx(GroupRows, { group: __spreadProps(__spreadValues({}, sub), { subGroups: void 0 }), columns, depth: depth + 1 }, si)),
6317
+ (_a2 = group.subGroups) == null ? void 0 : _a2.map((sub, si) => /* @__PURE__ */ jsx(GroupRows, { group: __spreadProps(__spreadValues({}, sub), { subGroups: void 0 }), columns, depth: depth + 1 }, si)),
6318
6318
  ((_b = group.rows) != null ? _b : []).map((row, ri) => /* @__PURE__ */ jsx("tr", { style: { borderBottom: "1px solid #f2f2f2" }, children: columns.map((col, ci) => {
6319
- var _a2;
6319
+ var _a3;
6320
6320
  return /* @__PURE__ */ jsx(
6321
6321
  "td",
6322
6322
  {
@@ -6328,7 +6328,7 @@ function GroupRows({ group, columns, depth }) {
6328
6328
  fontVariantNumeric: "tabular-nums",
6329
6329
  textAlign: col.align === "end" ? "right" : col.align === "center" ? "center" : "left"
6330
6330
  },
6331
- children: String((_a2 = row[col.key]) != null ? _a2 : "\u2014")
6331
+ children: String((_a3 = row[col.key]) != null ? _a3 : "\u2014")
6332
6332
  },
6333
6333
  col.key
6334
6334
  );
@@ -6337,14 +6337,14 @@ function GroupRows({ group, columns, depth }) {
6337
6337
  ] });
6338
6338
  }
6339
6339
  function GroupedTableResolver(p) {
6340
- var _a, _b, _c, _d;
6340
+ var _a2, _b, _c, _d;
6341
6341
  const { BORDER: BORDER4, MUTED: MUTED2, PAPER: PAPER2 } = useTheme();
6342
- const { visibleColumns, hidden, toggle, showAll, hideAll, allColumns } = useColumnVisibility((_a = p.columns) != null ? _a : []);
6342
+ const { visibleColumns, hidden, toggle, showAll, hideAll, allColumns } = useColumnVisibility((_a2 = p.columns) != null ? _a2 : []);
6343
6343
  const flatRows = [];
6344
6344
  const flatten = (groups) => {
6345
- var _a2;
6345
+ var _a3;
6346
6346
  for (const g of groups) {
6347
- for (const row of (_a2 = g.rows) != null ? _a2 : []) flatRows.push(row);
6347
+ for (const row of (_a3 = g.rows) != null ? _a3 : []) flatRows.push(row);
6348
6348
  if (g.subGroups) flatten(g.subGroups);
6349
6349
  }
6350
6350
  };
@@ -6354,8 +6354,8 @@ function GroupedTableResolver(p) {
6354
6354
  {
6355
6355
  filename: (_c = p.title) != null ? _c : "grouped-table",
6356
6356
  onDownloadCSV: () => {
6357
- var _a2;
6358
- return downloadCSV(visibleColumns, flatRows, (_a2 = p.title) != null ? _a2 : "grouped-table");
6357
+ var _a3;
6358
+ return downloadCSV(visibleColumns, flatRows, (_a3 = p.title) != null ? _a3 : "grouped-table");
6359
6359
  },
6360
6360
  columnConfig: { columns: allColumns, hidden, onToggle: toggle, onShowAll: showAll, onHideAll: hideAll },
6361
6361
  children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "10px" }, children: [
@@ -6399,16 +6399,16 @@ var dotColor = {
6399
6399
  neutral: "#888888"
6400
6400
  };
6401
6401
  function NewsFeedResolver(p) {
6402
- var _a, _b;
6402
+ var _a2, _b;
6403
6403
  const { ACCENT: ACCENT2, MUTED: MUTED2 } = useTheme();
6404
6404
  const [filter, setFilter] = useState(null);
6405
6405
  const sentiments = ["positive", "neutral", "negative"].filter(
6406
6406
  (s) => {
6407
- var _a2;
6408
- return ((_a2 = p.items) != null ? _a2 : []).some((i) => i.sentiment === s);
6407
+ var _a3;
6408
+ return ((_a3 = p.items) != null ? _a3 : []).some((i) => i.sentiment === s);
6409
6409
  }
6410
6410
  );
6411
- const visible = filter ? ((_a = p.items) != null ? _a : []).filter((i) => i.sentiment === filter) : p.items;
6411
+ const visible = filter ? ((_a2 = p.items) != null ? _a2 : []).filter((i) => i.sentiment === filter) : p.items;
6412
6412
  return /* @__PURE__ */ jsx(ComponentActions, { filename: (_b = p.title) != null ? _b : "news-feed", children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "10px" }, children: [
6413
6413
  p.title && /* @__PURE__ */ jsx("p", { style: { fontFamily: "var(--font-serif)", fontSize: "15px", fontWeight: 600, color: "var(--foreground)", letterSpacing: "-0.005em" }, children: p.title }),
6414
6414
  sentiments.length > 1 && /* @__PURE__ */ jsx("div", { style: { display: "flex", flexWrap: "wrap", gap: "6px" }, children: sentiments.map((s) => /* @__PURE__ */ jsx("button", { onClick: () => setFilter(filter === s ? null : s), style: sentimentStyle(s, filter === s), children: s }, s)) }),
@@ -6469,9 +6469,9 @@ var tooltipStyle = {
6469
6469
  color: "var(--foreground)"
6470
6470
  };
6471
6471
  function AreaChartResolver(p) {
6472
- var _a, _b, _c, _d;
6472
+ var _a2, _b, _c, _d;
6473
6473
  const { BORDER: BORDER4, MUTED: MUTED2, ACCENT: ACCENT2 } = useTheme();
6474
- const series = (_a = p.series) != null ? _a : [];
6474
+ const series = (_a2 = p.series) != null ? _a2 : [];
6475
6475
  const data = (_b = p.data) != null ? _b : [];
6476
6476
  const xKey = (_c = p.xKey) != null ? _c : "x";
6477
6477
  const { isVisible, toggle } = useSeriesToggle(series.map((s) => s.dataKey));
@@ -6560,12 +6560,12 @@ var tooltipStyle2 = {
6560
6560
  };
6561
6561
  var tdStyle = { padding: "5px 10px 5px 0", fontSize: "12.5px", verticalAlign: "middle" };
6562
6562
  function AllocationDonutResolver(p) {
6563
- var _a, _b;
6563
+ var _a2, _b;
6564
6564
  const { BORDER: BORDER4, MUTED: MUTED2, CHART_PALETTE: CHART_PALETTE2 } = useTheme();
6565
- const slices = (_a = p.slices) != null ? _a : [];
6565
+ const slices = (_a2 = p.slices) != null ? _a2 : [];
6566
6566
  const allData = slices.map((s, i) => {
6567
- var _a2;
6568
- return __spreadProps(__spreadValues({}, s), { fill: (_a2 = s.color) != null ? _a2 : PALETTE[i % PALETTE.length] });
6567
+ var _a3;
6568
+ return __spreadProps(__spreadValues({}, s), { fill: (_a3 = s.color) != null ? _a3 : PALETTE[i % PALETTE.length] });
6569
6569
  });
6570
6570
  const { isVisible, toggle } = useSeriesToggle(allData.map((s) => s.label));
6571
6571
  const data = allData.filter((s) => isVisible(s.label));
@@ -6650,6 +6650,14 @@ init_ThemeContext();
6650
6650
  var TERRACOTTA = ACCENT;
6651
6651
  var POS = "#15803d";
6652
6652
  var NEG = "#dc2626";
6653
+ var _CURRENCY = /* @__PURE__ */ new Set(["$", "\u20AC", "\xA3", "\xA5", "\u20B9"]);
6654
+ function _abbrev(n) {
6655
+ const a = Math.abs(n);
6656
+ if (a >= 1e9) return `${(a / 1e9).toFixed(1).replace(/\.0$/, "")}B`;
6657
+ if (a >= 1e6) return `${(a / 1e6).toFixed(1).replace(/\.0$/, "")}M`;
6658
+ if (a >= 1e3) return `${(a / 1e3).toFixed(1).replace(/\.0$/, "")}K`;
6659
+ return `${a}`;
6660
+ }
6653
6661
  var tooltipStyle3 = {
6654
6662
  fontSize: "12px",
6655
6663
  borderRadius: "8px",
@@ -6659,11 +6667,20 @@ var tooltipStyle3 = {
6659
6667
  color: "var(--foreground)"
6660
6668
  };
6661
6669
  function WaterfallChartResolver(p) {
6662
- var _a, _b, _c;
6670
+ var _a2, _b, _c;
6663
6671
  const { ACCENT: ACCENT2, BORDER: BORDER4, MUTED: MUTED2 } = useTheme();
6664
6672
  const { isVisible, toggle } = useSeriesToggle(["Positive", "Negative", "Total"]);
6665
- const unit = (_a = p.unit) != null ? _a : "";
6673
+ const unit = (_a2 = p.unit) != null ? _a2 : "";
6666
6674
  const bars = (_b = p.bars) != null ? _b : [];
6675
+ const fmtVal = (v, withSign = false) => {
6676
+ const sign = v < 0 ? "-" : withSign && v > 0 ? "+" : "";
6677
+ const body = _CURRENCY.has(unit) ? `${unit}${_abbrev(v)}` : `${_abbrev(v)}${unit}`;
6678
+ return `${sign}${body}`;
6679
+ };
6680
+ const yAxisWidth = Math.min(
6681
+ 72,
6682
+ Math.max(40, ...bars.map((b) => fmtVal(b.value).length * 7 + 8))
6683
+ );
6667
6684
  let running = 0;
6668
6685
  const chartData = bars.map((bar) => {
6669
6686
  const base = bar.isTotal ? 0 : running;
@@ -6673,7 +6690,7 @@ function WaterfallChartResolver(p) {
6673
6690
  }).filter((d) => isVisible(d.category));
6674
6691
  return /* @__PURE__ */ jsx(ComponentActions, { filename: (_c = p.title) != null ? _c : "waterfall-chart", children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "12px" }, children: [
6675
6692
  p.title && /* @__PURE__ */ jsx("p", { style: { fontFamily: "var(--font-serif)", fontSize: "15px", fontWeight: 600, color: "var(--foreground)", letterSpacing: "-0.005em" }, children: p.title }),
6676
- /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: 200, children: /* @__PURE__ */ jsxs(BarChart, { data: chartData, margin: { top: 4, right: 8, left: 0, bottom: 0 }, children: [
6693
+ /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: 200, children: /* @__PURE__ */ jsxs(BarChart, { data: chartData, margin: { top: 4, right: 8, left: 4, bottom: 0 }, children: [
6677
6694
  /* @__PURE__ */ jsx(
6678
6695
  XAxis,
6679
6696
  {
@@ -6689,17 +6706,14 @@ function WaterfallChartResolver(p) {
6689
6706
  tick: { fontSize: 11, fill: MUTED2 },
6690
6707
  axisLine: false,
6691
6708
  tickLine: false,
6692
- width: 42,
6693
- tickFormatter: (v) => `${v}${unit}`
6709
+ width: yAxisWidth,
6710
+ tickFormatter: (v) => fmtVal(Number(v))
6694
6711
  }
6695
6712
  ),
6696
6713
  /* @__PURE__ */ jsx(
6697
6714
  Tooltip,
6698
6715
  {
6699
- formatter: (value) => {
6700
- const v = Number(value);
6701
- return [`${v > 0 ? "+" : ""}${v}${unit}`, ""];
6702
- },
6716
+ formatter: (value) => [fmtVal(Number(value), true), ""],
6703
6717
  contentStyle: tooltipStyle3,
6704
6718
  cursor: { fill: "#f2f2f2" }
6705
6719
  }
@@ -6939,9 +6953,9 @@ function FlowCanvasRenderer({
6939
6953
  ] });
6940
6954
  }
6941
6955
  function FlowCanvasResolver(p) {
6942
- var _a;
6956
+ var _a2;
6943
6957
  const { ACCENT: ACCENT2, BORDER: BORDER4 } = useTheme();
6944
- return /* @__PURE__ */ jsx(ComponentActions, { filename: (_a = p.title) != null ? _a : "flow-canvas", children: /* @__PURE__ */ jsx(
6958
+ return /* @__PURE__ */ jsx(ComponentActions, { filename: (_a2 = p.title) != null ? _a2 : "flow-canvas", children: /* @__PURE__ */ jsx(
6945
6959
  FlowCanvasRenderer,
6946
6960
  {
6947
6961
  diagram: p.diagram,
@@ -6964,13 +6978,13 @@ var categoryLabels = {
6964
6978
  other: "Other"
6965
6979
  };
6966
6980
  function TrialBalanceResolver(p) {
6967
- var _a, _b, _c, _d;
6981
+ var _a2, _b, _c, _d;
6968
6982
  const { BORDER: BORDER4, MUTED: MUTED2, PAPER: PAPER2 } = useTheme();
6969
6983
  let totalDebit = 0;
6970
6984
  let totalCredit = 0;
6971
- ((_a = p.groups) != null ? _a : []).forEach((g) => {
6972
- var _a2;
6973
- return ((_a2 = g.accounts) != null ? _a2 : []).forEach((a) => {
6985
+ ((_a2 = p.groups) != null ? _a2 : []).forEach((g) => {
6986
+ var _a3;
6987
+ return ((_a3 = g.accounts) != null ? _a3 : []).forEach((a) => {
6974
6988
  totalDebit += a.debit;
6975
6989
  totalCredit += a.credit;
6976
6990
  });
@@ -6978,12 +6992,12 @@ function TrialBalanceResolver(p) {
6978
6992
  const balanced = Math.abs(totalDebit - totalCredit) < 5e-3;
6979
6993
  const csvCols = [{ key: "category", label: "Category" }, { key: "code", label: "Code" }, { key: "name", label: "Account" }, { key: "debit", label: "Debit" }, { key: "credit", label: "Credit" }];
6980
6994
  const csvRows = ((_b = p.groups) != null ? _b : []).flatMap((g) => {
6981
- var _a2;
6982
- return ((_a2 = g.accounts) != null ? _a2 : []).map((a) => ({ category: g.category, code: a.code, name: a.name, debit: a.debit, credit: a.credit }));
6995
+ var _a3;
6996
+ return ((_a3 = g.accounts) != null ? _a3 : []).map((a) => ({ category: g.category, code: a.code, name: a.name, debit: a.debit, credit: a.credit }));
6983
6997
  });
6984
6998
  return /* @__PURE__ */ jsx(ComponentActions, { filename: (_c = p.title) != null ? _c : "trial-balance", onDownloadCSV: () => {
6985
- var _a2;
6986
- return downloadCSV(csvCols, csvRows, (_a2 = p.title) != null ? _a2 : "trial-balance");
6999
+ var _a3;
7000
+ return downloadCSV(csvCols, csvRows, (_a3 = p.title) != null ? _a3 : "trial-balance");
6987
7001
  }, children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "10px" }, children: [
6988
7002
  /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "10px" }, children: [
6989
7003
  p.title && /* @__PURE__ */ jsx("p", { style: { fontFamily: "var(--font-serif)", fontSize: "15px", fontWeight: 600, color: "var(--foreground)", letterSpacing: "-0.005em" }, children: p.title }),
@@ -7016,9 +7030,9 @@ function TrialBalanceResolver(p) {
7016
7030
  }, children: h }, h)) }) }),
7017
7031
  /* @__PURE__ */ jsxs("tbody", { children: [
7018
7032
  ((_d = p.groups) != null ? _d : []).map((group) => {
7019
- var _a2, _b2, _c2;
7033
+ var _a3, _b2, _c2;
7020
7034
  let gDebit = 0, gCredit = 0;
7021
- ((_a2 = group.accounts) != null ? _a2 : []).forEach((a) => {
7035
+ ((_a3 = group.accounts) != null ? _a3 : []).forEach((a) => {
7022
7036
  gDebit += a.debit;
7023
7037
  gCredit += a.credit;
7024
7038
  });
@@ -7067,25 +7081,25 @@ var statusColors = {
7067
7081
  };
7068
7082
  var fmt2 = (v, currency) => new Intl.NumberFormat("en-US", { style: "currency", currency: currency || "USD", minimumFractionDigits: 2 }).format(v);
7069
7083
  function JournalEntryResolver(p) {
7070
- var _a, _b, _c;
7084
+ var _a2, _b, _c;
7071
7085
  const { BORDER: BORDER4, MUTED: MUTED2, PAPER: PAPER2, ACCENT: ACCENT2 } = useTheme();
7072
7086
  const csvCols = [{ key: "entryId", label: "Entry ID" }, { key: "date", label: "Date" }, { key: "status", label: "Status" }, { key: "account", label: "Account" }, { key: "description", label: "Description" }, { key: "debit", label: "Debit" }, { key: "credit", label: "Credit" }];
7073
- const csvRows = ((_a = p.entries) != null ? _a : []).flatMap((e) => {
7074
- var _a2;
7075
- return ((_a2 = e.lines) != null ? _a2 : []).map((l) => {
7076
- var _a3;
7077
- return { entryId: e.entryId, date: e.date, status: e.status, account: l.account, description: (_a3 = l.description) != null ? _a3 : "", debit: l.debit, credit: l.credit };
7087
+ const csvRows = ((_a2 = p.entries) != null ? _a2 : []).flatMap((e) => {
7088
+ var _a3;
7089
+ return ((_a3 = e.lines) != null ? _a3 : []).map((l) => {
7090
+ var _a4;
7091
+ return { entryId: e.entryId, date: e.date, status: e.status, account: l.account, description: (_a4 = l.description) != null ? _a4 : "", debit: l.debit, credit: l.credit };
7078
7092
  });
7079
7093
  });
7080
7094
  return /* @__PURE__ */ jsx(ComponentActions, { filename: (_b = p.title) != null ? _b : "journal-entry", onDownloadCSV: () => {
7081
- var _a2;
7082
- return downloadCSV(csvCols, csvRows, (_a2 = p.title) != null ? _a2 : "journal-entry");
7095
+ var _a3;
7096
+ return downloadCSV(csvCols, csvRows, (_a3 = p.title) != null ? _a3 : "journal-entry");
7083
7097
  }, children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "14px" }, children: [
7084
7098
  p.title && /* @__PURE__ */ jsx("p", { style: { fontFamily: "var(--font-serif)", fontSize: "15px", fontWeight: 600, color: "var(--foreground)", letterSpacing: "-0.005em" }, children: p.title }),
7085
7099
  ((_c = p.entries) != null ? _c : []).map((entry) => {
7086
- var _a2, _b2;
7100
+ var _a3, _b2, _c2;
7087
7101
  let totalDebit = 0, totalCredit = 0;
7088
- ((_a2 = entry.lines) != null ? _a2 : []).forEach((l) => {
7102
+ ((_a3 = entry.lines) != null ? _a3 : []).forEach((l) => {
7089
7103
  totalDebit += l.debit;
7090
7104
  totalCredit += l.credit;
7091
7105
  });
@@ -7109,11 +7123,11 @@ function JournalEntryResolver(p) {
7109
7123
  letterSpacing: "0.02em"
7110
7124
  }, children: h }, h)) }) }),
7111
7125
  /* @__PURE__ */ jsxs("tbody", { children: [
7112
- entry.lines.map((line, li) => {
7113
- var _a3;
7126
+ ((_c2 = entry.lines) != null ? _c2 : []).map((line, li) => {
7127
+ var _a4;
7114
7128
  return /* @__PURE__ */ jsxs("tr", { style: { background: li % 2 === 0 ? "white" : "#fafafa" }, children: [
7115
7129
  /* @__PURE__ */ jsx("td", { style: { padding: "6px 12px", fontSize: "13px" }, children: line.account }),
7116
- /* @__PURE__ */ jsx("td", { style: { padding: "6px 12px", fontSize: "12px", color: MUTED2 }, children: (_a3 = line.description) != null ? _a3 : "\u2014" }),
7130
+ /* @__PURE__ */ jsx("td", { style: { padding: "6px 12px", fontSize: "12px", color: MUTED2 }, children: (_a4 = line.description) != null ? _a4 : "\u2014" }),
7117
7131
  /* @__PURE__ */ jsx("td", { style: { padding: "6px 12px", fontSize: "13px", textAlign: "right", fontVariantNumeric: "tabular-nums" }, children: line.debit > 0 ? fmt2(line.debit, p.currency) : "\u2014" }),
7118
7132
  /* @__PURE__ */ jsx("td", { style: { padding: "6px 12px", fontSize: "13px", textAlign: "right", fontVariantNumeric: "tabular-nums" }, children: line.credit > 0 ? fmt2(line.credit, p.currency) : "\u2014" })
7119
7133
  ] }, li);
@@ -7144,17 +7158,17 @@ function agingHeat(index, total) {
7144
7158
  return `rgba(220, 38, 38, ${alpha})`;
7145
7159
  }
7146
7160
  function AgingReportResolver(p) {
7147
- var _a, _b, _c, _d;
7161
+ var _a2, _b, _c, _d;
7148
7162
  const { BORDER: BORDER4, MUTED: MUTED2, PAPER: PAPER2, ACCENT: ACCENT2 } = useTheme();
7149
- const buckets = (_a = p.buckets) != null ? _a : [];
7163
+ const buckets = (_a2 = p.buckets) != null ? _a2 : [];
7150
7164
  const entities = (_b = p.entities) != null ? _b : [];
7151
7165
  const currency = (_c = p.currency) != null ? _c : "USD";
7152
7166
  const bucketCount = buckets.length;
7153
7167
  const totals = new Array(bucketCount).fill(0);
7154
7168
  let grandTotal = 0;
7155
7169
  entities.forEach((e) => {
7156
- var _a2, _b2;
7157
- ((_a2 = e.amounts) != null ? _a2 : []).forEach((a, i) => {
7170
+ var _a3, _b2;
7171
+ ((_a3 = e.amounts) != null ? _a3 : []).forEach((a, i) => {
7158
7172
  if (i < bucketCount) totals[i] += a;
7159
7173
  });
7160
7174
  grandTotal += (_b2 = e.total) != null ? _b2 : 0;
@@ -7168,8 +7182,8 @@ function AgingReportResolver(p) {
7168
7182
  return row;
7169
7183
  });
7170
7184
  return /* @__PURE__ */ jsx(ComponentActions, { filename: (_d = p.title) != null ? _d : "aging-report", onDownloadCSV: () => {
7171
- var _a2;
7172
- return downloadCSV(csvCols, csvRows, (_a2 = p.title) != null ? _a2 : "aging-report");
7185
+ var _a3;
7186
+ return downloadCSV(csvCols, csvRows, (_a3 = p.title) != null ? _a3 : "aging-report");
7173
7187
  }, children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "10px" }, children: [
7174
7188
  /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "10px" }, children: [
7175
7189
  p.title && /* @__PURE__ */ jsx("p", { style: { fontFamily: "var(--font-serif)", fontSize: "15px", fontWeight: 600, color: "var(--foreground)", letterSpacing: "-0.005em" }, children: p.title }),
@@ -7187,12 +7201,12 @@ function AgingReportResolver(p) {
7187
7201
  ] }) }),
7188
7202
  /* @__PURE__ */ jsxs("tbody", { children: [
7189
7203
  entities.map((entity, ri) => {
7190
- var _a2;
7204
+ var _a3;
7191
7205
  return /* @__PURE__ */ jsxs("tr", { style: { background: ri % 2 === 0 ? "white" : "#fafafa" }, children: [
7192
7206
  /* @__PURE__ */ jsx("td", { style: { padding: "6px 12px", fontSize: "13px", borderBottom: `1px solid #f2f2f2`, maxWidth: "200px", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: entity.name }),
7193
7207
  buckets.map((_, bi) => {
7194
- var _a3, _b2;
7195
- const val = bi < ((_a3 = entity.amounts) != null ? _a3 : []).length ? ((_b2 = entity.amounts) != null ? _b2 : [])[bi] : 0;
7208
+ var _a4, _b2;
7209
+ const val = bi < ((_a4 = entity.amounts) != null ? _a4 : []).length ? ((_b2 = entity.amounts) != null ? _b2 : [])[bi] : 0;
7196
7210
  const isLast = bi === bucketCount - 1;
7197
7211
  return /* @__PURE__ */ jsx("td", { style: {
7198
7212
  padding: "6px 12px",
@@ -7205,7 +7219,7 @@ function AgingReportResolver(p) {
7205
7219
  fontWeight: isLast && val > 0 ? 600 : void 0
7206
7220
  }, children: val !== 0 ? fmt3(val, currency) : "\u2014" }, bi);
7207
7221
  }),
7208
- /* @__PURE__ */ jsx("td", { style: { padding: "6px 12px", fontSize: "13px", textAlign: "right", fontVariantNumeric: "tabular-nums", fontWeight: 600, borderBottom: `1px solid #f2f2f2` }, children: fmt3((_a2 = entity.total) != null ? _a2 : 0, currency) })
7222
+ /* @__PURE__ */ jsx("td", { style: { padding: "6px 12px", fontSize: "13px", textAlign: "right", fontVariantNumeric: "tabular-nums", fontWeight: 600, borderBottom: `1px solid #f2f2f2` }, children: fmt3((_a3 = entity.total) != null ? _a3 : 0, currency) })
7209
7223
  ] }, ri);
7210
7224
  }),
7211
7225
  /* @__PURE__ */ jsxs("tr", { style: { background: PAPER2 }, children: [
@@ -7223,14 +7237,14 @@ init_ThemeContext();
7223
7237
  var fmt4 = (v, currency) => new Intl.NumberFormat("en-US", { style: "currency", currency: currency || "USD", minimumFractionDigits: 2 }).format(v);
7224
7238
  var pctFmt = (v) => isFinite(v) ? `${v > 0 ? "+" : ""}${v.toFixed(1)}%` : "N/A";
7225
7239
  function VarianceAnalysisResolver(p) {
7226
- var _a, _b, _c, _d;
7240
+ var _a2, _b, _c, _d;
7227
7241
  const { BORDER: BORDER4, MUTED: MUTED2, PAPER: PAPER2 } = useTheme();
7228
- const maxAbsVar = Math.max(...((_a = p.rows) != null ? _a : []).filter((r) => !r.isSubtotal).map((r) => Math.abs(r.actual - r.budget)), 1);
7242
+ const maxAbsVar = Math.max(...((_a2 = p.rows) != null ? _a2 : []).filter((r) => !r.isSubtotal).map((r) => Math.abs(r.actual - r.budget)), 1);
7229
7243
  const csvCols = [{ key: "lineItem", label: "Line Item" }, { key: "budget", label: "Budget" }, { key: "actual", label: "Actual" }, { key: "variance", label: "Variance $" }, { key: "variancePct", label: "Variance %" }];
7230
7244
  const csvRows = ((_b = p.rows) != null ? _b : []).map((r) => ({ lineItem: r.lineItem, budget: r.budget, actual: r.actual, variance: r.actual - r.budget, variancePct: r.budget !== 0 ? ((r.actual - r.budget) / Math.abs(r.budget) * 100).toFixed(1) + "%" : "N/A" }));
7231
7245
  return /* @__PURE__ */ jsx(ComponentActions, { filename: (_c = p.title) != null ? _c : "variance-analysis", onDownloadCSV: () => {
7232
- var _a2;
7233
- return downloadCSV(csvCols, csvRows, (_a2 = p.title) != null ? _a2 : "variance-analysis");
7246
+ var _a3;
7247
+ return downloadCSV(csvCols, csvRows, (_a3 = p.title) != null ? _a3 : "variance-analysis");
7234
7248
  }, children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "10px" }, children: [
7235
7249
  /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "10px" }, children: [
7236
7250
  p.title && /* @__PURE__ */ jsx("p", { style: { fontFamily: "var(--font-serif)", fontSize: "15px", fontWeight: 600, color: "var(--foreground)", letterSpacing: "-0.005em" }, children: p.title }),
@@ -7251,7 +7265,7 @@ function VarianceAnalysisResolver(p) {
7251
7265
  width: i === 5 ? "60px" : void 0
7252
7266
  }, children: h }, h || i)) }) }),
7253
7267
  /* @__PURE__ */ jsx("tbody", { children: ((_d = p.rows) != null ? _d : []).map((row, ri) => {
7254
- var _a2;
7268
+ var _a3;
7255
7269
  const variance = row.actual - row.budget;
7256
7270
  const pct = row.budget !== 0 ? variance / Math.abs(row.budget) * 100 : NaN;
7257
7271
  const favorable = p.favorableDirection === "higher" ? variance >= 0 : variance <= 0;
@@ -7262,7 +7276,7 @@ function VarianceAnalysisResolver(p) {
7262
7276
  fontWeight: row.isSubtotal ? 700 : void 0,
7263
7277
  borderTop: row.isSubtotal ? `1px solid ${BORDER4}` : void 0
7264
7278
  }, children: [
7265
- /* @__PURE__ */ jsx("td", { style: { padding: "6px 10px", paddingLeft: `${12 + ((_a2 = row.indent) != null ? _a2 : 0) * 16}px`, fontSize: "13px", borderBottom: `1px solid #f2f2f2` }, children: row.lineItem }),
7279
+ /* @__PURE__ */ jsx("td", { style: { padding: "6px 10px", paddingLeft: `${12 + ((_a3 = row.indent) != null ? _a3 : 0) * 16}px`, fontSize: "13px", borderBottom: `1px solid #f2f2f2` }, children: row.lineItem }),
7266
7280
  /* @__PURE__ */ jsx("td", { style: { padding: "6px 10px", fontSize: "13px", textAlign: "right", fontVariantNumeric: "tabular-nums", borderBottom: `1px solid #f2f2f2` }, children: fmt4(row.budget, p.currency) }),
7267
7281
  /* @__PURE__ */ jsx("td", { style: { padding: "6px 10px", fontSize: "13px", textAlign: "right", fontVariantNumeric: "tabular-nums", borderBottom: `1px solid #f2f2f2` }, children: fmt4(row.actual, p.currency) }),
7268
7282
  /* @__PURE__ */ jsxs("td", { style: { padding: "6px 10px", fontSize: "13px", textAlign: "right", fontVariantNumeric: "tabular-nums", borderBottom: `1px solid #f2f2f2`, color }, children: [
@@ -7296,16 +7310,16 @@ function abbreviate(v) {
7296
7310
  }
7297
7311
  var fmt5 = (v, currency) => new Intl.NumberFormat("en-US", { style: "currency", currency: currency || "USD", minimumFractionDigits: 2 }).format(v);
7298
7312
  function StackedBreakdownResolver(p) {
7299
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
7313
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
7300
7314
  const { BORDER: BORDER4, MUTED: MUTED2, PAPER: PAPER2, CHART_PALETTE: CHART_PALETTE2 } = useTheme();
7301
- const { isVisible, toggle } = useSeriesToggle(((_a = p.categories) != null ? _a : []).map((c) => c.name));
7315
+ const { isVisible, toggle } = useSeriesToggle(((_a2 = p.categories) != null ? _a2 : []).map((c) => c.name));
7302
7316
  const chartData = ((_b = p.periods) != null ? _b : []).map((period, pi) => {
7303
- var _a2;
7317
+ var _a3;
7304
7318
  const row = { period };
7305
7319
  let total = 0;
7306
- ((_a2 = p.categories) != null ? _a2 : []).forEach((cat) => {
7307
- var _a3, _b2;
7308
- const v = pi < ((_a3 = cat.values) != null ? _a3 : []).length ? ((_b2 = cat.values) != null ? _b2 : [])[pi] : 0;
7320
+ ((_a3 = p.categories) != null ? _a3 : []).forEach((cat) => {
7321
+ var _a4, _b2;
7322
+ const v = pi < ((_a4 = cat.values) != null ? _a4 : []).length ? ((_b2 = cat.values) != null ? _b2 : [])[pi] : 0;
7309
7323
  row[cat.name] = v;
7310
7324
  total += v;
7311
7325
  });
@@ -7319,8 +7333,8 @@ function StackedBreakdownResolver(p) {
7319
7333
  {
7320
7334
  filename: (_e = p.title) != null ? _e : "stacked-breakdown",
7321
7335
  onDownloadCSV: () => {
7322
- var _a2;
7323
- return downloadCSV(csvCols, chartData, (_a2 = p.title) != null ? _a2 : "stacked-breakdown");
7336
+ var _a3;
7337
+ return downloadCSV(csvCols, chartData, (_a3 = p.title) != null ? _a3 : "stacked-breakdown");
7324
7338
  },
7325
7339
  children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "12px" }, children: [
7326
7340
  p.title && /* @__PURE__ */ jsx("p", { style: { fontFamily: "var(--font-serif)", fontSize: "15px", fontWeight: 600, color: "var(--foreground)", letterSpacing: "-0.005em" }, children: p.title }),
@@ -7329,13 +7343,13 @@ function StackedBreakdownResolver(p) {
7329
7343
  /* @__PURE__ */ jsx(YAxis, { tick: { fontSize: 11, fill: MUTED2 }, axisLine: false, tickLine: false, width: 52, tickFormatter: abbreviate }),
7330
7344
  /* @__PURE__ */ jsx(Tooltip, { contentStyle: tooltipStyle4, formatter: (value) => [fmt5(value, p.currency), ""], cursor: { fill: "#f2f2f2" } }),
7331
7345
  ((_f = p.categories) != null ? _f : []).map((cat, ci) => {
7332
- var _a2, _b2;
7346
+ var _a3, _b2;
7333
7347
  return /* @__PURE__ */ jsx(
7334
7348
  Bar,
7335
7349
  {
7336
7350
  dataKey: cat.name,
7337
7351
  stackId: "tax",
7338
- fill: (_a2 = cat.color) != null ? _a2 : PALETTE2[ci % PALETTE2.length],
7352
+ fill: (_a3 = cat.color) != null ? _a3 : PALETTE2[ci % PALETTE2.length],
7339
7353
  radius: ci === ((_b2 = p.categories) != null ? _b2 : []).length - 1 ? [3, 3, 0, 0] : void 0,
7340
7354
  hide: !isVisible(cat.name)
7341
7355
  },
@@ -7344,7 +7358,7 @@ function StackedBreakdownResolver(p) {
7344
7358
  })
7345
7359
  ] }) }),
7346
7360
  /* @__PURE__ */ jsx("div", { style: { display: "flex", flexWrap: "wrap", gap: "14px" }, children: ((_g = p.categories) != null ? _g : []).map((cat, ci) => {
7347
- var _a2;
7361
+ var _a3;
7348
7362
  return /* @__PURE__ */ jsxs(
7349
7363
  "div",
7350
7364
  {
@@ -7368,7 +7382,7 @@ function StackedBreakdownResolver(p) {
7368
7382
  height: "10px",
7369
7383
  borderRadius: "2px",
7370
7384
  flexShrink: 0,
7371
- background: (_a2 = cat.color) != null ? _a2 : PALETTE2[ci % PALETTE2.length],
7385
+ background: (_a3 = cat.color) != null ? _a3 : PALETTE2[ci % PALETTE2.length],
7372
7386
  display: "inline-block",
7373
7387
  opacity: isVisible(cat.name) ? 1 : 0.3,
7374
7388
  transition: "opacity 0.15s"
@@ -7386,15 +7400,15 @@ function StackedBreakdownResolver(p) {
7386
7400
  ] }) }),
7387
7401
  /* @__PURE__ */ jsxs("tbody", { children: [
7388
7402
  ((_i = p.categories) != null ? _i : []).map((cat, ci) => {
7389
- var _a2, _b2;
7403
+ var _a3, _b2;
7390
7404
  return /* @__PURE__ */ jsxs("tr", { style: { background: ci % 2 === 0 ? "white" : "#fafafa" }, children: [
7391
7405
  /* @__PURE__ */ jsxs("td", { style: { padding: "6px 12px", fontSize: "13px", borderBottom: `1px solid #f2f2f2` }, children: [
7392
- /* @__PURE__ */ jsx("span", { style: { display: "inline-block", width: "8px", height: "8px", borderRadius: "2px", background: (_a2 = cat.color) != null ? _a2 : PALETTE2[ci % PALETTE2.length], marginRight: "6px" } }),
7406
+ /* @__PURE__ */ jsx("span", { style: { display: "inline-block", width: "8px", height: "8px", borderRadius: "2px", background: (_a3 = cat.color) != null ? _a3 : PALETTE2[ci % PALETTE2.length], marginRight: "6px" } }),
7393
7407
  cat.name
7394
7408
  ] }),
7395
7409
  ((_b2 = p.periods) != null ? _b2 : []).map((_, pi) => {
7396
- var _a3, _b3;
7397
- const v = pi < ((_a3 = cat.values) != null ? _a3 : []).length ? ((_b3 = cat.values) != null ? _b3 : [])[pi] : 0;
7410
+ var _a4, _b3;
7411
+ const v = pi < ((_a4 = cat.values) != null ? _a4 : []).length ? ((_b3 = cat.values) != null ? _b3 : [])[pi] : 0;
7398
7412
  return /* @__PURE__ */ jsx("td", { style: { padding: "6px 12px", fontSize: "13px", textAlign: "right", fontVariantNumeric: "tabular-nums", whiteSpace: "nowrap", borderBottom: `1px solid #f2f2f2`, color: v < 0 ? "#dc2626" : void 0 }, children: v < 0 ? `(${fmt5(Math.abs(v), p.currency)})` : fmt5(v, p.currency) }, pi);
7399
7413
  })
7400
7414
  ] }, cat.name);
@@ -7429,9 +7443,9 @@ var tooltipStyle5 = {
7429
7443
  color: "var(--foreground)"
7430
7444
  };
7431
7445
  function ComparativeBarChartResolver(p) {
7432
- var _a, _b, _c, _d;
7446
+ var _a2, _b, _c, _d;
7433
7447
  const { BORDER: BORDER4, MUTED: MUTED2, CHART_PALETTE: CHART_PALETTE2 } = useTheme();
7434
- const series = (_a = p.series) != null ? _a : [];
7448
+ const series = (_a2 = p.series) != null ? _a2 : [];
7435
7449
  const data = (_b = p.data) != null ? _b : [];
7436
7450
  const xKey = (_c = p.xKey) != null ? _c : "x";
7437
7451
  const horizontal = p.orientation === "horizontal";
@@ -7459,13 +7473,13 @@ function ComparativeBarChartResolver(p) {
7459
7473
  ),
7460
7474
  /* @__PURE__ */ jsx(Tooltip, { contentStyle: tooltipStyle5, cursor: { fill: "#f2f2f2" } }),
7461
7475
  series.map((s, si) => {
7462
- var _a2;
7476
+ var _a3;
7463
7477
  return /* @__PURE__ */ jsx(
7464
7478
  Bar,
7465
7479
  {
7466
7480
  dataKey: s.dataKey,
7467
7481
  name: s.name,
7468
- fill: (_a2 = s.color) != null ? _a2 : PALETTE3[si % PALETTE3.length],
7482
+ fill: (_a3 = s.color) != null ? _a3 : PALETTE3[si % PALETTE3.length],
7469
7483
  stackId: stacked ? "stack" : void 0,
7470
7484
  radius: horizontal ? void 0 : [3, 3, 0, 0],
7471
7485
  hide: !isVisible(s.dataKey),
@@ -7476,7 +7490,7 @@ function ComparativeBarChartResolver(p) {
7476
7490
  })
7477
7491
  ] }) }),
7478
7492
  series.length > 1 && /* @__PURE__ */ jsx("div", { style: { display: "flex", flexWrap: "wrap", gap: "14px" }, children: series.map((s, si) => {
7479
- var _a2;
7493
+ var _a3;
7480
7494
  return /* @__PURE__ */ jsxs(
7481
7495
  "div",
7482
7496
  {
@@ -7497,7 +7511,7 @@ function ComparativeBarChartResolver(p) {
7497
7511
  width: "10px",
7498
7512
  height: "10px",
7499
7513
  borderRadius: "2px",
7500
- background: (_a2 = s.color) != null ? _a2 : PALETTE3[si % PALETTE3.length],
7514
+ background: (_a3 = s.color) != null ? _a3 : PALETTE3[si % PALETTE3.length],
7501
7515
  display: "inline-block",
7502
7516
  opacity: isVisible(s.dataKey) ? 1 : 0.3,
7503
7517
  transition: "opacity 0.15s"
@@ -7528,8 +7542,8 @@ var priorityConfig = {
7528
7542
  low: { color: MUTED, bg: "#f2f2f2" }
7529
7543
  };
7530
7544
  function ItemRow({ item }) {
7531
- var _a, _b;
7532
- const sc = (_a = statusConfig[item.status]) != null ? _a : statusConfig["not-started"];
7545
+ var _a2, _b;
7546
+ const sc = (_a2 = statusConfig[item.status]) != null ? _a2 : statusConfig["not-started"];
7533
7547
  const pc = (_b = priorityConfig[item.priority]) != null ? _b : priorityConfig.medium;
7534
7548
  return /* @__PURE__ */ jsxs("div", { style: {
7535
7549
  display: "flex",
@@ -7598,24 +7612,24 @@ function Section({ section }) {
7598
7612
  ] });
7599
7613
  }
7600
7614
  function ComplianceChecklistResolver(p) {
7601
- var _a, _b, _c, _d;
7615
+ var _a2, _b, _c, _d;
7602
7616
  const { BORDER: BORDER4, MUTED: MUTED2, ACCENT: ACCENT2 } = useTheme();
7603
- const allItems = ((_a = p.sections) != null ? _a : []).flatMap((s) => s.items);
7617
+ const allItems = ((_a2 = p.sections) != null ? _a2 : []).flatMap((s) => s.items);
7604
7618
  const total = allItems.length;
7605
7619
  const completed = allItems.filter((i) => i.status === "completed").length;
7606
7620
  const overdue = allItems.filter((i) => i.status === "overdue").length;
7607
7621
  const pct = total > 0 ? Math.round(completed / total * 100) : 0;
7608
7622
  const csvCols = [{ key: "section", label: "Section" }, { key: "id", label: "ID" }, { key: "description", label: "Description" }, { key: "status", label: "Status" }, { key: "priority", label: "Priority" }, { key: "assignee", label: "Assignee" }, { key: "dueDate", label: "Due Date" }];
7609
7623
  const csvRows = ((_b = p.sections) != null ? _b : []).flatMap((s) => {
7610
- var _a2;
7611
- return ((_a2 = s.items) != null ? _a2 : []).map((i) => {
7612
- var _a3, _b2;
7613
- return { section: s.sectionTitle, id: i.id, description: i.description, status: i.status, priority: i.priority, assignee: (_a3 = i.assignee) != null ? _a3 : "", dueDate: (_b2 = i.dueDate) != null ? _b2 : "" };
7624
+ var _a3;
7625
+ return ((_a3 = s.items) != null ? _a3 : []).map((i) => {
7626
+ var _a4, _b2;
7627
+ return { section: s.sectionTitle, id: i.id, description: i.description, status: i.status, priority: i.priority, assignee: (_a4 = i.assignee) != null ? _a4 : "", dueDate: (_b2 = i.dueDate) != null ? _b2 : "" };
7614
7628
  });
7615
7629
  });
7616
7630
  return /* @__PURE__ */ jsx(ComponentActions, { filename: (_c = p.title) != null ? _c : "compliance-checklist", onDownloadCSV: () => {
7617
- var _a2;
7618
- return downloadCSV(csvCols, csvRows, (_a2 = p.title) != null ? _a2 : "compliance-checklist");
7631
+ var _a3;
7632
+ return downloadCSV(csvCols, csvRows, (_a3 = p.title) != null ? _a3 : "compliance-checklist");
7619
7633
  }, children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "10px" }, children: [
7620
7634
  p.title && /* @__PURE__ */ jsx("p", { style: { fontFamily: "var(--font-serif)", fontSize: "15px", fontWeight: 600, color: "var(--foreground)", letterSpacing: "-0.005em" }, children: p.title }),
7621
7635
  /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "10px" }, children: [
@@ -7677,9 +7691,9 @@ function DiffCell({ diff, currency }) {
7677
7691
  );
7678
7692
  }
7679
7693
  function ReconciliationViewResolver(p) {
7680
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
7694
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
7681
7695
  const { BORDER: BORDER4, MUTED: MUTED2, PAPER: PAPER2, ACCENT: ACCENT2 } = useTheme();
7682
- const sourceA = (_a = p.sourceA) != null ? _a : { label: "Source A" };
7696
+ const sourceA = (_a2 = p.sourceA) != null ? _a2 : { label: "Source A" };
7683
7697
  const sourceB = (_b = p.sourceB) != null ? _b : { label: "Source B" };
7684
7698
  const [activeTab, setActiveTab] = useState("matched");
7685
7699
  const balanceA = (_d = (_c = p.summary) == null ? void 0 : _c.balanceA) != null ? _d : 0;
@@ -7696,7 +7710,7 @@ function ReconciliationViewResolver(p) {
7696
7710
  ];
7697
7711
  const csvRows = [
7698
7712
  ...((_i = p.matched) != null ? _i : []).map((m) => {
7699
- var _a2;
7713
+ var _a3;
7700
7714
  return {
7701
7715
  type: "Matched",
7702
7716
  date: m.date,
@@ -7704,11 +7718,11 @@ function ReconciliationViewResolver(p) {
7704
7718
  amountA: m.amountA,
7705
7719
  amountB: m.amountB,
7706
7720
  diff: m.amountA - m.amountB,
7707
- reference: (_a2 = m.reference) != null ? _a2 : ""
7721
+ reference: (_a3 = m.reference) != null ? _a3 : ""
7708
7722
  };
7709
7723
  }),
7710
7724
  ...((_j = p.unmatchedA) != null ? _j : []).map((u) => {
7711
- var _a2;
7725
+ var _a3;
7712
7726
  return {
7713
7727
  type: `Unmatched ${sourceA.label}`,
7714
7728
  date: u.date,
@@ -7716,11 +7730,11 @@ function ReconciliationViewResolver(p) {
7716
7730
  amountA: u.amount,
7717
7731
  amountB: "",
7718
7732
  diff: "",
7719
- reference: (_a2 = u.reference) != null ? _a2 : ""
7733
+ reference: (_a3 = u.reference) != null ? _a3 : ""
7720
7734
  };
7721
7735
  }),
7722
7736
  ...((_k = p.unmatchedB) != null ? _k : []).map((u) => {
7723
- var _a2;
7737
+ var _a3;
7724
7738
  return {
7725
7739
  type: `Unmatched ${sourceB.label}`,
7726
7740
  date: u.date,
@@ -7728,7 +7742,7 @@ function ReconciliationViewResolver(p) {
7728
7742
  amountA: "",
7729
7743
  amountB: u.amount,
7730
7744
  diff: "",
7731
- reference: (_a2 = u.reference) != null ? _a2 : ""
7745
+ reference: (_a3 = u.reference) != null ? _a3 : ""
7732
7746
  };
7733
7747
  })
7734
7748
  ];
@@ -7744,8 +7758,8 @@ function ReconciliationViewResolver(p) {
7744
7758
  {
7745
7759
  filename: (_s = p.title) != null ? _s : "reconciliation-view",
7746
7760
  onDownloadCSV: () => {
7747
- var _a2;
7748
- return downloadCSV(csvCols, csvRows, (_a2 = p.title) != null ? _a2 : "reconciliation-view");
7761
+ var _a3;
7762
+ return downloadCSV(csvCols, csvRows, (_a3 = p.title) != null ? _a3 : "reconciliation-view");
7749
7763
  },
7750
7764
  children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "0" }, children: [
7751
7765
  p.title && /* @__PURE__ */ jsx(
@@ -7916,7 +7930,7 @@ function ReconciliationViewResolver(p) {
7916
7930
  borderBottom: `1px solid ${BORDER4}`
7917
7931
  },
7918
7932
  children: tabs.map((tab, i) => {
7919
- var _a2;
7933
+ var _a3;
7920
7934
  const isActive = activeTab === tab.key;
7921
7935
  return /* @__PURE__ */ jsxs(
7922
7936
  "button",
@@ -7953,7 +7967,7 @@ function ReconciliationViewResolver(p) {
7953
7967
  left: "16px",
7954
7968
  right: "16px",
7955
7969
  height: "2px",
7956
- background: (_a2 = tab.accent) != null ? _a2 : ACCENT2,
7970
+ background: (_a3 = tab.accent) != null ? _a3 : ACCENT2,
7957
7971
  borderRadius: "2px 2px 0 0"
7958
7972
  }
7959
7973
  }
@@ -8019,7 +8033,7 @@ function ReconciliationViewResolver(p) {
8019
8033
  )
8020
8034
  ) }) }),
8021
8035
  /* @__PURE__ */ jsx("tbody", { children: ((_u = p.matched) != null ? _u : []).map((m, ri) => {
8022
- var _a2;
8036
+ var _a3;
8023
8037
  const diff = m.amountA - m.amountB;
8024
8038
  const isZero = Math.abs(diff) < 5e-3;
8025
8039
  return /* @__PURE__ */ jsxs(
@@ -8114,7 +8128,7 @@ function ReconciliationViewResolver(p) {
8114
8128
  borderBottom: `1px solid ${INNER_BORDER}`,
8115
8129
  letterSpacing: "0.02em"
8116
8130
  },
8117
- children: (_a2 = m.reference) != null ? _a2 : "\u2014"
8131
+ children: (_a3 = m.reference) != null ? _a3 : "\u2014"
8118
8132
  }
8119
8133
  )
8120
8134
  ]
@@ -8124,8 +8138,8 @@ function ReconciliationViewResolver(p) {
8124
8138
  }) })
8125
8139
  ] })),
8126
8140
  (activeTab === "unmatchedA" || activeTab === "unmatchedB") && (() => {
8127
- var _a2, _b2;
8128
- const items = activeTab === "unmatchedA" ? (_a2 = p.unmatchedA) != null ? _a2 : [] : (_b2 = p.unmatchedB) != null ? _b2 : [];
8141
+ var _a3, _b2;
8142
+ const items = activeTab === "unmatchedA" ? (_a3 = p.unmatchedA) != null ? _a3 : [] : (_b2 = p.unmatchedB) != null ? _b2 : [];
8129
8143
  const sourceLabel = activeTab === "unmatchedA" ? sourceA.label : sourceB.label;
8130
8144
  if (items.length === 0)
8131
8145
  return /* @__PURE__ */ jsx(
@@ -8157,7 +8171,7 @@ function ReconciliationViewResolver(p) {
8157
8171
  )
8158
8172
  ) }) }),
8159
8173
  /* @__PURE__ */ jsx("tbody", { children: items.map((item, ri) => {
8160
- var _a3;
8174
+ var _a4;
8161
8175
  return /* @__PURE__ */ jsxs(
8162
8176
  "tr",
8163
8177
  {
@@ -8249,7 +8263,7 @@ function ReconciliationViewResolver(p) {
8249
8263
  borderBottom: `1px solid ${INNER_BORDER}`,
8250
8264
  letterSpacing: "0.02em"
8251
8265
  },
8252
- children: (_a3 = item.reference) != null ? _a3 : "\u2014"
8266
+ children: (_a4 = item.reference) != null ? _a4 : "\u2014"
8253
8267
  }
8254
8268
  )
8255
8269
  ]
@@ -8323,9 +8337,9 @@ function ChangesView({ changes }) {
8323
8337
  ] }, i)) });
8324
8338
  }
8325
8339
  function EventCard({ event }) {
8326
- var _a;
8340
+ var _a2;
8327
8341
  const [showChanges, setShowChanges] = useState(false);
8328
- const ac = (_a = actionConfig[event.action]) != null ? _a : actionConfig.commented;
8342
+ const ac = (_a2 = actionConfig[event.action]) != null ? _a2 : actionConfig.commented;
8329
8343
  const hasChanges = event.changes && event.changes.length > 0;
8330
8344
  return /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: "12px", position: "relative" }, children: [
8331
8345
  /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", flexShrink: 0 }, children: [
@@ -8369,9 +8383,9 @@ function EventCard({ event }) {
8369
8383
  ] });
8370
8384
  }
8371
8385
  function AuditTrailResolver(p) {
8372
- var _a, _b;
8386
+ var _a2, _b;
8373
8387
  const { BORDER: BORDER4, MUTED: MUTED2, ACCENT: ACCENT2 } = useTheme();
8374
- const sorted = [...(_a = p.events) != null ? _a : []].sort((a, b) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime());
8388
+ const sorted = [...(_a2 = p.events) != null ? _a2 : []].sort((a, b) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime());
8375
8389
  return /* @__PURE__ */ jsx(ComponentActions, { filename: (_b = p.title) != null ? _b : "audit-trail", children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "10px" }, children: [
8376
8390
  /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "10px" }, children: [
8377
8391
  p.title && /* @__PURE__ */ jsx("p", { style: { fontFamily: "var(--font-serif)", fontSize: "15px", fontWeight: 600, color: "var(--foreground)", letterSpacing: "-0.005em" }, children: p.title }),
@@ -8391,12 +8405,12 @@ function useFullscreen(ref) {
8391
8405
  return () => document.removeEventListener("fullscreenchange", handler);
8392
8406
  }, []);
8393
8407
  const enter = useCallback(() => {
8394
- var _a, _b;
8395
- (_b = (_a = ref.current) == null ? void 0 : _a.requestFullscreen) == null ? void 0 : _b.call(_a);
8408
+ var _a2, _b;
8409
+ (_b = (_a2 = ref.current) == null ? void 0 : _a2.requestFullscreen) == null ? void 0 : _b.call(_a2);
8396
8410
  }, [ref]);
8397
8411
  const exit = useCallback(() => {
8398
- var _a;
8399
- if (document.fullscreenElement) (_a = document.exitFullscreen) == null ? void 0 : _a.call(document);
8412
+ var _a2;
8413
+ if (document.fullscreenElement) (_a2 = document.exitFullscreen) == null ? void 0 : _a2.call(document);
8400
8414
  }, []);
8401
8415
  const toggle = useCallback(() => {
8402
8416
  if (isFullscreen) exit();
@@ -8421,8 +8435,8 @@ var highlightColors = {
8421
8435
  blue: { bg: "rgba(29,78,216,0.12)", border: "#1d4ed8" }
8422
8436
  };
8423
8437
  function sanitizeFilename(name) {
8424
- var _a;
8425
- return (_a = name.replace(/\.\.\//g, "").replace(/\.\.\\/g, "").split(/[/\\]/).pop()) != null ? _a : name;
8438
+ var _a2;
8439
+ return (_a2 = name.replace(/\.\.\//g, "").replace(/\.\.\\/g, "").split(/[/\\]/).pop()) != null ? _a2 : name;
8426
8440
  }
8427
8441
  function IconButton({ title, onClick, href, download, children }) {
8428
8442
  const style = {
@@ -8459,12 +8473,12 @@ function DownloadIcon() {
8459
8473
  ] });
8460
8474
  }
8461
8475
  function DocumentPreviewResolver(p) {
8462
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
8476
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
8463
8477
  const { BORDER: BORDER4, MUTED: MUTED2, PAPER: PAPER2, ACCENT: ACCENT2 } = useTheme();
8464
8478
  const [currentPage, setCurrentPage] = useState(0);
8465
8479
  const containerRef = useRef(null);
8466
8480
  const { isFullscreen, toggle } = useFullscreen(containerRef);
8467
- const hasRealFile = !!(((_a = p.source) == null ? void 0 : _a.url) || ((_b = p.source) == null ? void 0 : _b.base64));
8481
+ const hasRealFile = !!(((_a2 = p.source) == null ? void 0 : _a2.url) || ((_b = p.source) == null ? void 0 : _b.base64));
8468
8482
  const isPdf = p.documentType === "pdf";
8469
8483
  const isExcel = p.documentType === "excel";
8470
8484
  const totalPages = ((_c = p.pages) != null ? _c : []).length;
@@ -8527,7 +8541,7 @@ function DocumentPreviewResolver(p) {
8527
8541
  href: (_k = (_j = p.source) == null ? void 0 : _j.url) != null ? _k : void 0,
8528
8542
  download: sanitizeFilename((_m = (_l = p.source) == null ? void 0 : _l.filename) != null ? _m : "file"),
8529
8543
  onClick: !((_n = p.source) == null ? void 0 : _n.url) && ((_o = p.source) == null ? void 0 : _o.base64) ? () => {
8530
- var _a2, _b2;
8544
+ var _a3, _b2;
8531
8545
  const mime = isPdf ? "application/pdf" : "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
8532
8546
  const binary = atob(p.source.base64);
8533
8547
  const bytes = new Uint8Array(binary.length);
@@ -8535,7 +8549,7 @@ function DocumentPreviewResolver(p) {
8535
8549
  const blob = new Blob([bytes], { type: mime });
8536
8550
  const a = document.createElement("a");
8537
8551
  a.href = URL.createObjectURL(blob);
8538
- a.download = sanitizeFilename((_b2 = (_a2 = p.source) == null ? void 0 : _a2.filename) != null ? _b2 : "file");
8552
+ a.download = sanitizeFilename((_b2 = (_a3 = p.source) == null ? void 0 : _a3.filename) != null ? _b2 : "file");
8539
8553
  a.click();
8540
8554
  URL.revokeObjectURL(a.href);
8541
8555
  } : void 0,
@@ -8590,8 +8604,8 @@ function DocumentPreviewResolver(p) {
8590
8604
  (_u = page == null ? void 0 : page.label) != null ? _u : "this page"
8591
8605
  ] }),
8592
8606
  pageHighlights.length > 0 && /* @__PURE__ */ jsx("div", { style: { padding: "0 20px 20px", display: "flex", flexDirection: "column", gap: "6px" }, children: pageHighlights.map((h, i) => {
8593
- var _a2;
8594
- const hc = (_a2 = highlightColors[h.color]) != null ? _a2 : highlightColors.yellow;
8607
+ var _a3;
8608
+ const hc = (_a3 = highlightColors[h.color]) != null ? _a3 : highlightColors.yellow;
8595
8609
  return /* @__PURE__ */ jsxs("div", { style: { padding: "6px 10px", borderRadius: "4px", background: hc.bg, borderLeft: `3px solid ${hc.border}`, fontSize: "12px" }, children: [
8596
8610
  /* @__PURE__ */ jsx("span", { style: { fontWeight: 600 }, children: h.text }),
8597
8611
  h.note && /* @__PURE__ */ jsxs("span", { style: { color: MUTED2, marginLeft: "8px" }, children: [
@@ -8647,10 +8661,10 @@ function ConfidenceBar({ confidence, height = 6 }) {
8647
8661
  );
8648
8662
  }
8649
8663
  function StepCard({ step, isLast }) {
8650
- var _a;
8664
+ var _a2;
8651
8665
  const [expanded, setExpanded] = useState(false);
8652
8666
  const cfg = stepTypeConfig[step.stepType];
8653
- const detail = (_a = step.detail) != null ? _a : "";
8667
+ const detail = (_a2 = step.detail) != null ? _a2 : "";
8654
8668
  const isLong = detail.length > 100;
8655
8669
  const displayDetail = isLong && !expanded ? detail.slice(0, 100) + "..." : detail;
8656
8670
  const metaEntries = step.metadata ? Object.entries(step.metadata) : [];
@@ -8781,9 +8795,9 @@ function statusColor(status) {
8781
8795
  }
8782
8796
  }
8783
8797
  function ProvenanceChainResolver(p) {
8784
- var _a, _b, _c, _d;
8798
+ var _a2, _b, _c, _d;
8785
8799
  const { BORDER: BORDER4, MUTED: MUTED2, ACCENT: ACCENT2 } = useTheme();
8786
- const steps = (_a = p.steps) != null ? _a : [];
8800
+ const steps = (_a2 = p.steps) != null ? _a2 : [];
8787
8801
  const stepsWithConf = steps.filter((s) => s.confidence != null && s.confidence > 0);
8788
8802
  const derivedConfidence = stepsWithConf.length > 0 ? stepsWithConf.reduce((sum, s) => sum + s.confidence, 0) / stepsWithConf.length : 0;
8789
8803
  const raw = (_b = p.conclusion) != null ? _b : { status: "not-qualified", value: "", confidence: 0 };
@@ -8934,8 +8948,8 @@ function highlightSnippet(snippet, highlights) {
8934
8948
  });
8935
8949
  }
8936
8950
  function ResultCard({ result, isLast }) {
8937
- var _a;
8938
- const badge = result.sourceType ? (_a = badgeColors[result.sourceType]) != null ? _a : badgeColors.other : null;
8951
+ var _a2;
8952
+ const badge = result.sourceType ? (_a2 = badgeColors[result.sourceType]) != null ? _a2 : badgeColors.other : null;
8939
8953
  const pct = Math.round(result.relevance * 100);
8940
8954
  const titleEl = /* @__PURE__ */ jsx("span", { style: { fontSize: "13px", fontWeight: 700, color: "var(--foreground)" }, children: result.title });
8941
8955
  return /* @__PURE__ */ jsxs(
@@ -9026,9 +9040,9 @@ function ResultCard({ result, isLast }) {
9026
9040
  );
9027
9041
  }
9028
9042
  function SearchResultsResolver(p) {
9029
- var _a, _b, _c, _d, _e, _f;
9043
+ var _a2, _b, _c, _d, _e, _f;
9030
9044
  const { BORDER: BORDER4, MUTED: MUTED2, ACCENT: ACCENT2 } = useTheme();
9031
- return /* @__PURE__ */ jsx(ComponentActions, { filename: (_a = p.title) != null ? _a : "search-results", children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "10px" }, children: [
9045
+ return /* @__PURE__ */ jsx(ComponentActions, { filename: (_a2 = p.title) != null ? _a2 : "search-results", children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "10px" }, children: [
9032
9046
  /* @__PURE__ */ jsx(
9033
9047
  "p",
9034
9048
  {
@@ -9064,8 +9078,8 @@ function SearchResultsResolver(p) {
9064
9078
  background: "white"
9065
9079
  },
9066
9080
  children: ((_f = p.results) != null ? _f : []).map((result, i) => {
9067
- var _a2;
9068
- return /* @__PURE__ */ jsx(ResultCard, { result, isLast: i === ((_a2 = p.results) != null ? _a2 : []).length - 1 }, i);
9081
+ var _a3;
9082
+ return /* @__PURE__ */ jsx(ResultCard, { result, isLast: i === ((_a3 = p.results) != null ? _a3 : []).length - 1 }, i);
9069
9083
  })
9070
9084
  }
9071
9085
  )
@@ -9082,8 +9096,8 @@ var resultConfig = {
9082
9096
  na: { color: MUTED, bg: "#f2f2f2", label: "N/A" }
9083
9097
  };
9084
9098
  function ResultBadge({ result, size = "normal" }) {
9085
- var _a;
9086
- const cfg = (_a = resultConfig[result]) != null ? _a : resultConfig.na;
9099
+ var _a2;
9100
+ const cfg = (_a2 = resultConfig[result]) != null ? _a2 : resultConfig.na;
9087
9101
  const isNormal = size === "normal";
9088
9102
  return /* @__PURE__ */ jsx(
9089
9103
  "span",
@@ -9215,9 +9229,9 @@ function PartSection({ part, defaultOpen }) {
9215
9229
  ] });
9216
9230
  }
9217
9231
  function LegalTestResultResolver(p) {
9218
- var _a, _b;
9232
+ var _a2, _b;
9219
9233
  const { BORDER: BORDER4, MUTED: MUTED2, ACCENT: ACCENT2, PAPER: PAPER2 } = useTheme();
9220
- return /* @__PURE__ */ jsx(ComponentActions, { filename: (_a = p.title) != null ? _a : "legal-test-result", children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "10px" }, children: [
9234
+ return /* @__PURE__ */ jsx(ComponentActions, { filename: (_a2 = p.title) != null ? _a2 : "legal-test-result", children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "10px" }, children: [
9221
9235
  /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "10px", flexWrap: "wrap" }, children: [
9222
9236
  p.title && /* @__PURE__ */ jsx(
9223
9237
  "span",
@@ -9277,9 +9291,9 @@ function lineColor(left, right) {
9277
9291
  return "#d6d3d1";
9278
9292
  }
9279
9293
  function EngagementPipelineResolver(p) {
9280
- var _a, _b, _c, _d, _e;
9294
+ var _a2, _b, _c, _d, _e;
9281
9295
  const { BORDER: BORDER4, MUTED: MUTED2, ACCENT: ACCENT2 } = useTheme();
9282
- const phases = (_a = p.phases) != null ? _a : [];
9296
+ const phases = (_a2 = p.phases) != null ? _a2 : [];
9283
9297
  const defaultActive = phases.findIndex(
9284
9298
  (ph) => ph.status === "in-progress" || ph.status === "blocked"
9285
9299
  );
@@ -9363,8 +9377,8 @@ function EngagementPipelineResolver(p) {
9363
9377
  overflow: "auto"
9364
9378
  },
9365
9379
  children: ((_d = p.phases) != null ? _d : []).map((phase, i) => {
9366
- var _a2;
9367
- const color = (_a2 = statusColor2[phase.status]) != null ? _a2 : "#d6d3d1";
9380
+ var _a3;
9381
+ const color = (_a3 = statusColor2[phase.status]) != null ? _a3 : "#d6d3d1";
9368
9382
  const isCurrent = i === activeIdx;
9369
9383
  const size = isCurrent ? 28 : 20;
9370
9384
  return /* @__PURE__ */ jsxs(React41.Fragment, { children: [
@@ -9672,10 +9686,10 @@ function Avatar({ name, avatar, hovered }) {
9672
9686
  );
9673
9687
  }
9674
9688
  function EntityCardGridResolver(p) {
9675
- var _a, _b;
9689
+ var _a2, _b;
9676
9690
  const { BORDER: BORDER4, MUTED: MUTED2, ACCENT: ACCENT2 } = useTheme();
9677
9691
  const [hoveredId, setHoveredId] = useState(null);
9678
- return /* @__PURE__ */ jsx(ComponentActions, { filename: (_a = p.title) != null ? _a : "entity-card-grid", children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "10px" }, children: [
9692
+ return /* @__PURE__ */ jsx(ComponentActions, { filename: (_a2 = p.title) != null ? _a2 : "entity-card-grid", children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "10px" }, children: [
9679
9693
  p.title && /* @__PURE__ */ jsx(
9680
9694
  "p",
9681
9695
  {
@@ -9755,8 +9769,8 @@ function EntityCardGridResolver(p) {
9755
9769
  ] })
9756
9770
  ] }),
9757
9771
  item.badges && item.badges.length > 0 && /* @__PURE__ */ jsx("div", { style: { display: "flex", flexWrap: "wrap", gap: "4px" }, children: item.badges.map((badge, i) => {
9758
- var _a2, _b2;
9759
- const c = (_b2 = BADGE_COLORS[(_a2 = badge.color) != null ? _a2 : "gray"]) != null ? _b2 : BADGE_COLORS.gray;
9772
+ var _a3, _b2;
9773
+ const c = (_b2 = BADGE_COLORS[(_a3 = badge.color) != null ? _a3 : "gray"]) != null ? _b2 : BADGE_COLORS.gray;
9760
9774
  return /* @__PURE__ */ jsx(
9761
9775
  "span",
9762
9776
  {
@@ -9868,8 +9882,8 @@ function formatTime(ts) {
9868
9882
  }
9869
9883
  }
9870
9884
  function StepRow({ step }) {
9871
- var _a, _b, _c;
9872
- const color = (_a = stepStatusColors[step.status]) != null ? _a : MUTED;
9885
+ var _a2, _b, _c;
9886
+ const color = (_a2 = stepStatusColors[step.status]) != null ? _a2 : MUTED;
9873
9887
  return /* @__PURE__ */ jsxs(
9874
9888
  "div",
9875
9889
  {
@@ -9928,10 +9942,10 @@ function StepRow({ step }) {
9928
9942
  );
9929
9943
  }
9930
9944
  function JobTrackerResolver(p) {
9931
- var _a, _b, _c, _d, _e, _f, _g;
9945
+ var _a2, _b, _c, _d, _e, _f, _g;
9932
9946
  const { BORDER: BORDER4, MUTED: MUTED2, ACCENT: ACCENT2, PAPER: PAPER2 } = useTheme();
9933
9947
  const [stepsOpen, setStepsOpen] = useState(true);
9934
- const barColor = (_a = statusColors2[p.status]) != null ? _a : MUTED2;
9948
+ const barColor = (_a2 = statusColors2[p.status]) != null ? _a2 : MUTED2;
9935
9949
  const badge = (_b = statusBadgeConfig[p.status]) != null ? _b : statusBadgeConfig.queued;
9936
9950
  const progress = (_c = p.progress) != null ? _c : p.status === "completed" ? 100 : 0;
9937
9951
  return /* @__PURE__ */ jsxs(ComponentActions, { filename: (_d = p.title) != null ? _d : "job-tracker", children: [
@@ -10199,8 +10213,8 @@ var sourceTypeColors = {
10199
10213
  workpaper: { bg: "#fff7ed", color: "#f59e0b" }
10200
10214
  };
10201
10215
  function getSourceTypeBadgeStyle(sourceType) {
10202
- var _a;
10203
- const entry = (_a = sourceTypeColors[sourceType]) != null ? _a : { bg: "#f2f2f2", color: MUTED };
10216
+ var _a2;
10217
+ const entry = (_a2 = sourceTypeColors[sourceType]) != null ? _a2 : { bg: "#f2f2f2", color: MUTED };
10204
10218
  return {
10205
10219
  display: "inline-block",
10206
10220
  fontSize: "9px",
@@ -10422,7 +10436,7 @@ function CitationMarker({
10422
10436
  );
10423
10437
  }
10424
10438
  function CitedAnswerResolver(p) {
10425
- var _a, _b, _c, _d, _e;
10439
+ var _a2, _b, _c, _d, _e;
10426
10440
  const { BORDER: BORDER4, MUTED: MUTED2, ACCENT: ACCENT2, SECONDARY: SECONDARY2 } = useTheme();
10427
10441
  const [expandedIds, setExpandedIds] = useState(/* @__PURE__ */ new Set());
10428
10442
  const toggleCitation = (id) => {
@@ -10437,7 +10451,7 @@ function CitedAnswerResolver(p) {
10437
10451
  });
10438
10452
  };
10439
10453
  const parts = parseAnswer(p.answer, p.citations);
10440
- return /* @__PURE__ */ jsx(ComponentActions, { filename: (_a = p.title) != null ? _a : "cited-answer", children: /* @__PURE__ */ jsxs(
10454
+ return /* @__PURE__ */ jsx(ComponentActions, { filename: (_a2 = p.title) != null ? _a2 : "cited-answer", children: /* @__PURE__ */ jsxs(
10441
10455
  "div",
10442
10456
  {
10443
10457
  style: {
@@ -10555,8 +10569,8 @@ var CURRENCY_SYMBOLS = {
10555
10569
  BRL: "R$"
10556
10570
  };
10557
10571
  function getCurrencySymbol(currency) {
10558
- var _a;
10559
- return (_a = CURRENCY_SYMBOLS[currency.toUpperCase()]) != null ? _a : currency + " ";
10572
+ var _a2;
10573
+ return (_a2 = CURRENCY_SYMBOLS[currency.toUpperCase()]) != null ? _a2 : currency + " ";
10560
10574
  }
10561
10575
  function formatAmount(amount, currency) {
10562
10576
  const sym = getCurrencySymbol(currency);
@@ -10725,9 +10739,9 @@ function formatSummaryAmount(amount, currency) {
10725
10739
  return `${sym}${formatted}`;
10726
10740
  }
10727
10741
  function TransactionFeedResolver(p) {
10728
- var _a, _b, _c, _d, _e;
10742
+ var _a2, _b, _c, _d, _e;
10729
10743
  const { BORDER: BORDER4, MUTED: MUTED2 } = useTheme();
10730
- const currency = (_a = p.currency) != null ? _a : "USD";
10744
+ const currency = (_a2 = p.currency) != null ? _a2 : "USD";
10731
10745
  const [hoveredIndex, setHoveredIndex] = useState(null);
10732
10746
  const hasBalance = ((_b = p.transactions) != null ? _b : []).some((tx) => tx.balance != null);
10733
10747
  const totalInflows = p.transactions.filter((tx) => tx.amount > 0 && tx.status !== "reversed").reduce((sum, tx) => sum + tx.amount, 0);
@@ -10742,11 +10756,11 @@ function TransactionFeedResolver(p) {
10742
10756
  { key: "balance", label: "Balance" }
10743
10757
  ];
10744
10758
  const csvRows = ((_c = p.transactions) != null ? _c : []).map((tx) => {
10745
- var _a2, _b2, _c2;
10759
+ var _a3, _b2, _c2;
10746
10760
  return {
10747
10761
  date: tx.date,
10748
10762
  description: tx.description,
10749
- counterparty: (_a2 = tx.counterparty) != null ? _a2 : "",
10763
+ counterparty: (_a3 = tx.counterparty) != null ? _a3 : "",
10750
10764
  category: (_b2 = tx.category) != null ? _b2 : "",
10751
10765
  amount: tx.amount,
10752
10766
  balance: (_c2 = tx.balance) != null ? _c2 : ""
@@ -10764,8 +10778,8 @@ function TransactionFeedResolver(p) {
10764
10778
  {
10765
10779
  filename: (_d = p.title) != null ? _d : "transaction-feed",
10766
10780
  onDownloadCSV: () => {
10767
- var _a2;
10768
- return downloadCSV(csvCols, csvRows, (_a2 = p.title) != null ? _a2 : "transaction-feed");
10781
+ var _a3;
10782
+ return downloadCSV(csvCols, csvRows, (_a3 = p.title) != null ? _a3 : "transaction-feed");
10769
10783
  },
10770
10784
  children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "10px" }, children: [
10771
10785
  p.title && /* @__PURE__ */ jsx(
@@ -10803,7 +10817,7 @@ function TransactionFeedResolver(p) {
10803
10817
  }
10804
10818
  ),
10805
10819
  /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column" }, children: ((_e = p.transactions) != null ? _e : []).map((tx, i) => {
10806
- var _a2;
10820
+ var _a3;
10807
10821
  return /* @__PURE__ */ jsx(
10808
10822
  TransactionRow,
10809
10823
  {
@@ -10813,7 +10827,7 @@ function TransactionFeedResolver(p) {
10813
10827
  onMouseEnter: () => setHoveredIndex(i),
10814
10828
  onMouseLeave: () => setHoveredIndex(null)
10815
10829
  },
10816
- (_a2 = tx.id) != null ? _a2 : i
10830
+ (_a3 = tx.id) != null ? _a3 : i
10817
10831
  );
10818
10832
  }) }),
10819
10833
  /* @__PURE__ */ jsxs(
@@ -10870,10 +10884,10 @@ var docTypeConfig = {
10870
10884
  csv: { label: "CSV", color: "#7c3aed", bg: "#f5f3ff" }
10871
10885
  };
10872
10886
  function getDocConfig(docType) {
10873
- var _a;
10887
+ var _a2;
10874
10888
  if (!docType) return { label: "FILE", color: MUTED, bg: "#f2f2f2" };
10875
10889
  const key = docType.toLowerCase().replace(/^\./, "");
10876
- return (_a = docTypeConfig[key]) != null ? _a : { label: key.toUpperCase().slice(0, 4), color: MUTED, bg: "#f2f2f2" };
10890
+ return (_a2 = docTypeConfig[key]) != null ? _a2 : { label: key.toUpperCase().slice(0, 4), color: MUTED, bg: "#f2f2f2" };
10877
10891
  }
10878
10892
  function formatDate2(dateStr) {
10879
10893
  if (!dateStr) return "";
@@ -10884,7 +10898,7 @@ function formatDate2(dateStr) {
10884
10898
  }
10885
10899
  }
10886
10900
  function FileRow({ item }) {
10887
- var _a;
10901
+ var _a2;
10888
10902
  const [hovered, setHovered] = useState(false);
10889
10903
  const cfg = getDocConfig(item.docType);
10890
10904
  return /* @__PURE__ */ jsxs(
@@ -10955,7 +10969,7 @@ function FileRow({ item }) {
10955
10969
  ] }),
10956
10970
  item.author && /* @__PURE__ */ jsx("span", { style: { fontSize: "11px", color: MUTED, flexShrink: 0, maxWidth: "100px", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: item.author }),
10957
10971
  item.size && /* @__PURE__ */ jsx("span", { style: { fontSize: "11px", color: MUTED, flexShrink: 0, minWidth: "50px", textAlign: "right" }, children: item.size }),
10958
- (item.modifiedAt || item.createdAt) && /* @__PURE__ */ jsx("span", { style: { fontSize: "11px", color: MUTED, flexShrink: 0, minWidth: "80px", textAlign: "right" }, children: formatDate2((_a = item.modifiedAt) != null ? _a : item.createdAt) })
10972
+ (item.modifiedAt || item.createdAt) && /* @__PURE__ */ jsx("span", { style: { fontSize: "11px", color: MUTED, flexShrink: 0, minWidth: "80px", textAlign: "right" }, children: formatDate2((_a2 = item.modifiedAt) != null ? _a2 : item.createdAt) })
10959
10973
  ]
10960
10974
  }
10961
10975
  );
@@ -11001,15 +11015,15 @@ function GroupSection({ groupName, items }) {
11001
11015
  }
11002
11016
  ),
11003
11017
  open && items.map((item, i) => {
11004
- var _a;
11005
- return /* @__PURE__ */ jsx(FileRow, { item }, (_a = item.id) != null ? _a : i);
11018
+ var _a2;
11019
+ return /* @__PURE__ */ jsx(FileRow, { item }, (_a2 = item.id) != null ? _a2 : i);
11006
11020
  })
11007
11021
  ] });
11008
11022
  }
11009
11023
  function FileBrowserResolver(p) {
11010
- var _a, _b, _c, _d;
11024
+ var _a2, _b, _c, _d;
11011
11025
  const { BORDER: BORDER4, MUTED: MUTED2, ACCENT: ACCENT2, PAPER: PAPER2 } = useTheme();
11012
- const items = (_a = p.items) != null ? _a : [];
11026
+ const items = (_a2 = p.items) != null ? _a2 : [];
11013
11027
  const hasGroups = items.some((item) => item.group);
11014
11028
  const groups = /* @__PURE__ */ new Map();
11015
11029
  if (hasGroups) {
@@ -11062,8 +11076,8 @@ function FileBrowserResolver(p) {
11062
11076
  fontSize: "13px",
11063
11077
  color: MUTED2
11064
11078
  }, children: "No files" }) : hasGroups ? Array.from(groups.entries()).map(([groupName, items2]) => /* @__PURE__ */ jsx(GroupSection, { groupName, items: items2 }, groupName)) : items.map((item, i) => {
11065
- var _a2;
11066
- return /* @__PURE__ */ jsx(FileRow, { item }, (_a2 = item.id) != null ? _a2 : i);
11079
+ var _a3;
11080
+ return /* @__PURE__ */ jsx(FileRow, { item }, (_a3 = item.id) != null ? _a3 : i);
11067
11081
  })
11068
11082
  ] })
11069
11083
  ] }) });
@@ -11107,7 +11121,7 @@ var PREVIEW_EXTS = {
11107
11121
  docx: "docx"
11108
11122
  };
11109
11123
  function extOf(fileType, filename) {
11110
- var _a;
11124
+ var _a2;
11111
11125
  if (fileType && fileType.includes("/")) {
11112
11126
  const mime = fileType.toLowerCase();
11113
11127
  if (mime.includes("pdf")) return "pdf";
@@ -11120,11 +11134,11 @@ function extOf(fileType, filename) {
11120
11134
  const t = fileType.toLowerCase().replace(/[^a-z0-9]/g, "");
11121
11135
  if (t) return t;
11122
11136
  }
11123
- return ((_a = (filename || "").split(".").pop()) == null ? void 0 : _a.toLowerCase().replace(/[^a-z0-9]/g, "")) || "";
11137
+ return ((_a2 = (filename || "").split(".").pop()) == null ? void 0 : _a2.toLowerCase().replace(/[^a-z0-9]/g, "")) || "";
11124
11138
  }
11125
11139
  function previewKindFor(fileType, filename) {
11126
- var _a;
11127
- return (_a = PREVIEW_EXTS[extOf(fileType, filename)]) != null ? _a : null;
11140
+ var _a2;
11141
+ return (_a2 = PREVIEW_EXTS[extOf(fileType, filename)]) != null ? _a2 : null;
11128
11142
  }
11129
11143
  function isPreviewable(fileType, filename) {
11130
11144
  return previewKindFor(fileType, filename) !== null;
@@ -11702,8 +11716,8 @@ function Chevron({ open }) {
11702
11716
  );
11703
11717
  }
11704
11718
  function DownloadCardResolver(p) {
11705
- var _a, _b;
11706
- const files = (_a = p.files) != null ? _a : [];
11719
+ var _a2, _b;
11720
+ const files = (_a2 = p.files) != null ? _a2 : [];
11707
11721
  return /* @__PURE__ */ jsx(ComponentActions, { filename: (_b = p.title) != null ? _b : "download-card", children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "10px" }, children: [
11708
11722
  p.title && /* @__PURE__ */ jsx(
11709
11723
  "p",
@@ -11875,10 +11889,10 @@ function ServiceCard({ item, isHovered, onHover, onLeave: onLeave2 }) {
11875
11889
  );
11876
11890
  }
11877
11891
  function OpsDashboardResolver(p) {
11878
- var _a, _b, _c;
11892
+ var _a2, _b, _c;
11879
11893
  const { BORDER: BORDER4, MUTED: MUTED2 } = useTheme();
11880
11894
  const [hoveredId, setHoveredId] = useState(null);
11881
- const hasRunning = ((_a = p.items) != null ? _a : []).some((item) => item.state === "running");
11895
+ const hasRunning = ((_a2 = p.items) != null ? _a2 : []).some((item) => item.state === "running");
11882
11896
  return /* @__PURE__ */ jsxs(ComponentActions, { filename: (_b = p.title) != null ? _b : "ops-dashboard", children: [
11883
11897
  hasRunning && /* @__PURE__ */ jsx("style", { children: PULSE_KEYFRAMES }),
11884
11898
  /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "10px" }, children: [
@@ -11962,8 +11976,8 @@ function CopyButton({ value, rowHovered }) {
11962
11976
  );
11963
11977
  }
11964
11978
  function ValueCell({ item }) {
11965
- var _a, _b;
11966
- const t = (_a = item.type) != null ? _a : "text";
11979
+ var _a2, _b;
11980
+ const t = (_a2 = item.type) != null ? _a2 : "text";
11967
11981
  switch (t) {
11968
11982
  case "url":
11969
11983
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -12070,9 +12084,9 @@ function ItemsList({ items, isLastGroup, indexOffset }) {
12070
12084
  )) });
12071
12085
  }
12072
12086
  function KeyValueListResolver(p) {
12073
- var _a, _b, _c;
12087
+ var _a2, _b, _c;
12074
12088
  const { BORDER: BORDER4, MUTED: MUTED2, PAPER: PAPER2, SECONDARY: SECONDARY2 } = useTheme();
12075
- const groups = (_a = p.groups) != null ? _a : [];
12089
+ const groups = (_a2 = p.groups) != null ? _a2 : [];
12076
12090
  const items = (_b = p.items) != null ? _b : [];
12077
12091
  const hasGroups = groups.length > 0;
12078
12092
  const hasItems = items.length > 0;
@@ -12101,12 +12115,12 @@ function KeyValueListResolver(p) {
12101
12115
  },
12102
12116
  children: [
12103
12117
  hasGroups && groups.map((group, gi) => {
12104
- var _a2;
12105
- const groupItems = (_a2 = group.items) != null ? _a2 : [];
12118
+ var _a3;
12119
+ const groupItems = (_a3 = group.items) != null ? _a3 : [];
12106
12120
  const isLastGroup = gi === groups.length - 1 && !hasItems;
12107
12121
  const prevItemCount = groups.slice(0, gi).reduce((sum, g) => {
12108
- var _a3;
12109
- return sum + ((_a3 = g.items) != null ? _a3 : []).length;
12122
+ var _a4;
12123
+ return sum + ((_a4 = g.items) != null ? _a4 : []).length;
12110
12124
  }, 0);
12111
12125
  return /* @__PURE__ */ jsxs(React41.Fragment, { children: [
12112
12126
  /* @__PURE__ */ jsxs(
@@ -12141,8 +12155,8 @@ function KeyValueListResolver(p) {
12141
12155
  ] }, gi);
12142
12156
  }),
12143
12157
  hasItems && /* @__PURE__ */ jsx(ItemsList, { items, isLastGroup: true, indexOffset: hasGroups ? groups.reduce((sum, g) => {
12144
- var _a2;
12145
- return sum + ((_a2 = g.items) != null ? _a2 : []).length;
12158
+ var _a3;
12159
+ return sum + ((_a3 = g.items) != null ? _a3 : []).length;
12146
12160
  }, 0) : 0 })
12147
12161
  ]
12148
12162
  }
@@ -12160,24 +12174,24 @@ var categoryLabels2 = {
12160
12174
  function computeSectionTotal(section) {
12161
12175
  if (section.total) return section.total;
12162
12176
  const currentPeriod = section.subsections.reduce((sum, sub) => {
12163
- var _a, _b, _c;
12164
- return sum + ((_c = (_a = sub.subtotal) == null ? void 0 : _a.currentPeriod) != null ? _c : ((_b = sub.items) != null ? _b : []).reduce((s, i) => s + i.currentPeriod, 0));
12177
+ var _a2, _b, _c;
12178
+ return sum + ((_c = (_a2 = sub.subtotal) == null ? void 0 : _a2.currentPeriod) != null ? _c : ((_b = sub.items) != null ? _b : []).reduce((s, i) => s + i.currentPeriod, 0));
12165
12179
  }, 0);
12166
12180
  const priorPeriod = section.subsections.reduce((sum, sub) => {
12167
- var _a, _b, _c;
12168
- return sum + ((_c = (_a = sub.subtotal) == null ? void 0 : _a.priorPeriod) != null ? _c : ((_b = sub.items) != null ? _b : []).reduce((s, i) => {
12169
- var _a2;
12170
- return s + ((_a2 = i.priorPeriod) != null ? _a2 : 0);
12181
+ var _a2, _b, _c;
12182
+ return sum + ((_c = (_a2 = sub.subtotal) == null ? void 0 : _a2.priorPeriod) != null ? _c : ((_b = sub.items) != null ? _b : []).reduce((s, i) => {
12183
+ var _a3;
12184
+ return s + ((_a3 = i.priorPeriod) != null ? _a3 : 0);
12171
12185
  }, 0));
12172
12186
  }, 0);
12173
12187
  return { currentPeriod, priorPeriod: priorPeriod || void 0 };
12174
12188
  }
12175
12189
  function BalanceSheetResolver(p) {
12176
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
12190
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
12177
12191
  const { BORDER: BORDER4, MUTED: MUTED2, PAPER: PAPER2 } = useTheme();
12178
12192
  const hasPrior = !!p.priorPeriodLabel;
12179
12193
  const colSpan = hasPrior ? 3 : 2;
12180
- const sectionTotals = new Map(((_a = p.sections) != null ? _a : []).map((s) => [s.category, computeSectionTotal(s)]));
12194
+ const sectionTotals = new Map(((_a2 = p.sections) != null ? _a2 : []).map((s) => [s.category, computeSectionTotal(s)]));
12181
12195
  const assetsTotal = (_c = (_b = sectionTotals.get("assets")) == null ? void 0 : _b.currentPeriod) != null ? _c : 0;
12182
12196
  let leTotal;
12183
12197
  if (p.totalLiabilitiesAndEquity) {
@@ -12196,22 +12210,22 @@ function BalanceSheetResolver(p) {
12196
12210
  const csvRows = ((_j = p.sections) != null ? _j : []).flatMap(
12197
12211
  (section) => section.subsections.flatMap(
12198
12212
  (sub) => {
12199
- var _a2;
12200
- return ((_a2 = sub.items) != null ? _a2 : []).map((item) => {
12201
- var _a3;
12213
+ var _a3;
12214
+ return ((_a3 = sub.items) != null ? _a3 : []).map((item) => {
12215
+ var _a4;
12202
12216
  return __spreadValues({
12203
12217
  category: section.category,
12204
12218
  subsection: sub.label,
12205
12219
  name: item.name,
12206
12220
  currentPeriod: item.currentPeriod
12207
- }, hasPrior ? { priorPeriod: (_a3 = item.priorPeriod) != null ? _a3 : "" } : {});
12221
+ }, hasPrior ? { priorPeriod: (_a4 = item.priorPeriod) != null ? _a4 : "" } : {});
12208
12222
  });
12209
12223
  }
12210
12224
  )
12211
12225
  );
12212
12226
  return /* @__PURE__ */ jsx(ComponentActions, { filename: (_k = p.title) != null ? _k : "balance-sheet", onDownloadCSV: () => {
12213
- var _a2;
12214
- return downloadCSV(csvCols, csvRows, (_a2 = p.title) != null ? _a2 : "balance-sheet");
12227
+ var _a3;
12228
+ return downloadCSV(csvCols, csvRows, (_a3 = p.title) != null ? _a3 : "balance-sheet");
12215
12229
  }, children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "10px" }, children: [
12216
12230
  p.metadata && /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", gap: "2px", position: "relative" }, children: [
12217
12231
  p.metadata.status && /* @__PURE__ */ jsx("span", { style: {
@@ -12285,7 +12299,7 @@ function BalanceSheetResolver(p) {
12285
12299
  ] }) }),
12286
12300
  /* @__PURE__ */ jsxs("tbody", { children: [
12287
12301
  ((_p = p.sections) != null ? _p : []).map((section) => {
12288
- var _a2;
12302
+ var _a3;
12289
12303
  return /* @__PURE__ */ jsxs(React41.Fragment, { children: [
12290
12304
  /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan, style: {
12291
12305
  padding: "8px 12px",
@@ -12296,9 +12310,9 @@ function BalanceSheetResolver(p) {
12296
12310
  borderBottom: `1px solid ${BORDER4}`,
12297
12311
  textTransform: "uppercase",
12298
12312
  letterSpacing: "0.04em"
12299
- }, children: (_a2 = categoryLabels2[section.category]) != null ? _a2 : section.category }) }),
12313
+ }, children: (_a3 = categoryLabels2[section.category]) != null ? _a3 : section.category }) }),
12300
12314
  section.subsections.map((sub, si) => {
12301
- var _a3;
12315
+ var _a4;
12302
12316
  return /* @__PURE__ */ jsxs(React41.Fragment, { children: [
12303
12317
  /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan, style: {
12304
12318
  padding: "6px 10px 6px 24px",
@@ -12307,7 +12321,7 @@ function BalanceSheetResolver(p) {
12307
12321
  color: "var(--foreground)",
12308
12322
  borderBottom: `1px solid #f2f2f2`
12309
12323
  }, children: sub.label }) }),
12310
- ((_a3 = sub.items) != null ? _a3 : []).map((item, ii) => /* @__PURE__ */ jsxs("tr", { style: { background: "white" }, children: [
12324
+ ((_a4 = sub.items) != null ? _a4 : []).map((item, ii) => /* @__PURE__ */ jsxs("tr", { style: { background: "white" }, children: [
12311
12325
  /* @__PURE__ */ jsx("td", { style: { padding: "6px 10px 6px 40px", fontSize: "13px", color: "var(--foreground)", borderBottom: `1px solid #f2f2f2` }, children: item.name }),
12312
12326
  /* @__PURE__ */ jsx("td", { style: { padding: "6px 10px", fontSize: "13px", fontVariantNumeric: "tabular-nums", textAlign: "right", borderBottom: `1px solid #f2f2f2` }, children: item.currentPeriod !== 0 ? fmt7(item.currentPeriod, p.currency) : "\u2014" }),
12313
12327
  hasPrior && /* @__PURE__ */ jsx("td", { style: { padding: "6px 10px", fontSize: "13px", fontVariantNumeric: "tabular-nums", textAlign: "right", borderBottom: `1px solid #f2f2f2` }, children: item.priorPeriod != null && item.priorPeriod !== 0 ? fmt7(item.priorPeriod, p.currency) : "\u2014" })
@@ -12323,12 +12337,12 @@ function BalanceSheetResolver(p) {
12323
12337
  ] }, si);
12324
12338
  }),
12325
12339
  (() => {
12326
- var _a3;
12340
+ var _a4;
12327
12341
  const total = sectionTotals.get(section.category);
12328
12342
  return /* @__PURE__ */ jsxs("tr", { style: { background: PAPER2 }, children: [
12329
12343
  /* @__PURE__ */ jsxs("td", { style: { padding: "8px 10px", fontSize: "12px", fontWeight: 600, borderTop: `1px solid ${BORDER4}`, borderBottom: `1px solid ${BORDER4}` }, children: [
12330
12344
  "Total ",
12331
- (_a3 = categoryLabels2[section.category]) != null ? _a3 : section.category
12345
+ (_a4 = categoryLabels2[section.category]) != null ? _a4 : section.category
12332
12346
  ] }),
12333
12347
  /* @__PURE__ */ jsx("td", { style: { padding: "8px 10px", fontSize: "12px", fontWeight: 600, textAlign: "right", fontVariantNumeric: "tabular-nums", borderTop: `1px solid ${BORDER4}`, borderBottom: `1px solid ${BORDER4}` }, children: fmt7(total.currentPeriod, p.currency) }),
12334
12348
  hasPrior && /* @__PURE__ */ jsx("td", { style: { padding: "8px 10px", fontSize: "12px", fontWeight: 600, textAlign: "right", fontVariantNumeric: "tabular-nums", borderTop: `1px solid ${BORDER4}`, borderBottom: `1px solid ${BORDER4}` }, children: total.priorPeriod != null ? fmt7(total.priorPeriod, p.currency) : "\u2014" })
@@ -12358,23 +12372,23 @@ var pctFmt2 = (amount, revenue) => {
12358
12372
  return `${(amount / revenue * 100).toFixed(1)}%`;
12359
12373
  };
12360
12374
  function IncomeStatementResolver(p) {
12361
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
12375
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
12362
12376
  const { BORDER: BORDER4, MUTED: MUTED2, PAPER: PAPER2 } = useTheme();
12363
- const currency = (_a = p.currency) != null ? _a : "USD";
12377
+ const currency = (_a2 = p.currency) != null ? _a2 : "USD";
12364
12378
  const periods = (_b = p.periods) != null ? _b : [];
12365
12379
  const sections = (_c = p.sections) != null ? _c : [];
12366
12380
  const calculatedTotals = (_d = p.calculatedTotals) != null ? _d : {};
12367
12381
  const showPct = (_e = p.showPercentOfRevenue) != null ? _e : false;
12368
12382
  const isTotalRow = (li) => {
12369
- var _a2;
12370
- return li.isSubtotal === true || /^\s*(total|subtotal)\b/i.test((_a2 = li.name) != null ? _a2 : "");
12383
+ var _a3;
12384
+ return li.isSubtotal === true || /^\s*(total|subtotal)\b/i.test((_a3 = li.name) != null ? _a3 : "");
12371
12385
  };
12372
12386
  const revenueTotals = periods.map(
12373
12387
  (_, pi) => {
12374
- var _a2, _b2, _c2;
12375
- return (_c2 = ((_b2 = (_a2 = sections[0]) == null ? void 0 : _a2.lineItems) != null ? _b2 : []).filter((li) => !isTotalRow(li)).reduce((sum, li) => {
12376
- var _a3, _b3;
12377
- return sum + ((_b3 = ((_a3 = li.amounts) != null ? _a3 : [])[pi]) != null ? _b3 : 0);
12388
+ var _a3, _b2, _c2;
12389
+ return (_c2 = ((_b2 = (_a3 = sections[0]) == null ? void 0 : _a3.lineItems) != null ? _b2 : []).filter((li) => !isTotalRow(li)).reduce((sum, li) => {
12390
+ var _a4, _b3;
12391
+ return sum + ((_b3 = ((_a4 = li.amounts) != null ? _a4 : [])[pi]) != null ? _b3 : 0);
12378
12392
  }, 0)) != null ? _c2 : 0;
12379
12393
  }
12380
12394
  );
@@ -12388,8 +12402,8 @@ function IncomeStatementResolver(p) {
12388
12402
  for (const li of (_f = section.lineItems) != null ? _f : []) {
12389
12403
  const row = { section: section.label, name: li.name };
12390
12404
  periods.forEach((period, pi) => {
12391
- var _a2, _b2;
12392
- row[period] = (_b2 = ((_a2 = li.amounts) != null ? _a2 : [])[pi]) != null ? _b2 : 0;
12405
+ var _a3, _b2;
12406
+ row[period] = (_b2 = ((_a3 = li.amounts) != null ? _a3 : [])[pi]) != null ? _b2 : 0;
12393
12407
  });
12394
12408
  csvRows.push(row);
12395
12409
  }
@@ -12398,13 +12412,13 @@ function IncomeStatementResolver(p) {
12398
12412
  const operatingIncome = calculatedTotals.operatingIncome;
12399
12413
  const rawNetIncome = calculatedTotals.netIncome;
12400
12414
  const netIncome = rawNetIncome && rawNetIncome.length > 0 ? rawNetIncome : periods.map((_, pi) => {
12401
- var _a2;
12415
+ var _a3;
12402
12416
  let total = 0;
12403
12417
  for (const section of sections) {
12404
- const sectionSum = ((_a2 = section.lineItems) != null ? _a2 : []).reduce(
12418
+ const sectionSum = ((_a3 = section.lineItems) != null ? _a3 : []).reduce(
12405
12419
  (s, li) => {
12406
- var _a3, _b2;
12407
- return s + ((_b2 = ((_a3 = li.amounts) != null ? _a3 : [])[pi]) != null ? _b2 : 0);
12420
+ var _a4, _b2;
12421
+ return s + ((_b2 = ((_a4 = li.amounts) != null ? _a4 : [])[pi]) != null ? _b2 : 0);
12408
12422
  },
12409
12423
  0
12410
12424
  );
@@ -12415,31 +12429,31 @@ function IncomeStatementResolver(p) {
12415
12429
  if (grossProfit) {
12416
12430
  const row = { section: "", name: "GROSS PROFIT" };
12417
12431
  periods.forEach((period, pi) => {
12418
- var _a2;
12419
- row[period] = (_a2 = grossProfit[pi]) != null ? _a2 : 0;
12432
+ var _a3;
12433
+ row[period] = (_a3 = grossProfit[pi]) != null ? _a3 : 0;
12420
12434
  });
12421
12435
  csvRows.push(row);
12422
12436
  }
12423
12437
  if (operatingIncome) {
12424
12438
  const row = { section: "", name: "OPERATING INCOME" };
12425
12439
  periods.forEach((period, pi) => {
12426
- var _a2;
12427
- row[period] = (_a2 = operatingIncome[pi]) != null ? _a2 : 0;
12440
+ var _a3;
12441
+ row[period] = (_a3 = operatingIncome[pi]) != null ? _a3 : 0;
12428
12442
  });
12429
12443
  csvRows.push(row);
12430
12444
  }
12431
12445
  {
12432
12446
  const row = { section: "", name: "NET INCOME" };
12433
12447
  periods.forEach((period, pi) => {
12434
- var _a2;
12435
- row[period] = (_a2 = netIncome[pi]) != null ? _a2 : 0;
12448
+ var _a3;
12449
+ row[period] = (_a3 = netIncome[pi]) != null ? _a3 : 0;
12436
12450
  });
12437
12451
  csvRows.push(row);
12438
12452
  }
12439
12453
  const colCount = showPct ? 1 + periods.length * 2 : 1 + periods.length;
12440
12454
  return /* @__PURE__ */ jsx(ComponentActions, { filename: (_g = p.title) != null ? _g : "income-statement", onDownloadCSV: () => {
12441
- var _a2;
12442
- return downloadCSV(csvCols, csvRows, (_a2 = p.title) != null ? _a2 : "income-statement");
12455
+ var _a3;
12456
+ return downloadCSV(csvCols, csvRows, (_a3 = p.title) != null ? _a3 : "income-statement");
12443
12457
  }, children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "10px" }, children: [
12444
12458
  p.metadata && /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", gap: "2px", position: "relative" }, children: [
12445
12459
  p.metadata.status && /* @__PURE__ */ jsx("span", { style: {
@@ -12504,7 +12518,7 @@ function IncomeStatementResolver(p) {
12504
12518
  ] }) }),
12505
12519
  /* @__PURE__ */ jsxs("tbody", { children: [
12506
12520
  sections.map((section, si) => {
12507
- var _a2;
12521
+ var _a3;
12508
12522
  const isSubtotal = section.sectionType === "subtotal";
12509
12523
  return /* @__PURE__ */ jsxs(React41.Fragment, { children: [
12510
12524
  /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan: colCount, style: {
@@ -12517,9 +12531,9 @@ function IncomeStatementResolver(p) {
12517
12531
  textTransform: "uppercase",
12518
12532
  letterSpacing: "0.04em"
12519
12533
  }, children: section.label }) }),
12520
- ((_a2 = section.lineItems) != null ? _a2 : []).map((li, li_i) => {
12521
- var _a3, _b2;
12522
- const indent = (_a3 = li.indent) != null ? _a3 : 0;
12534
+ ((_a3 = section.lineItems) != null ? _a3 : []).map((li, li_i) => {
12535
+ var _a4, _b2;
12536
+ const indent = (_a4 = li.indent) != null ? _a4 : 0;
12523
12537
  const amounts = (_b2 = li.amounts) != null ? _b2 : [];
12524
12538
  return /* @__PURE__ */ jsxs("tr", { style: {
12525
12539
  background: isSubtotal ? PAPER2 : "white",
@@ -12534,8 +12548,8 @@ function IncomeStatementResolver(p) {
12534
12548
  borderBottom: `1px solid #f2f2f2`
12535
12549
  }, children: li.name }),
12536
12550
  periods.map((_, pi) => {
12537
- var _a4;
12538
- const val = (_a4 = amounts[pi]) != null ? _a4 : 0;
12551
+ var _a5;
12552
+ const val = (_a5 = amounts[pi]) != null ? _a5 : 0;
12539
12553
  const isNeg = val < 0;
12540
12554
  return /* @__PURE__ */ jsxs(React41.Fragment, { children: [
12541
12555
  /* @__PURE__ */ jsx("td", { style: {
@@ -12569,8 +12583,8 @@ function IncomeStatementResolver(p) {
12569
12583
  borderBottom: `1px solid ${BORDER4}`
12570
12584
  }, children: "GROSS PROFIT" }),
12571
12585
  periods.map((_, pi) => {
12572
- var _a2;
12573
- const val = (_a2 = grossProfit[pi]) != null ? _a2 : 0;
12586
+ var _a3;
12587
+ const val = (_a3 = grossProfit[pi]) != null ? _a3 : 0;
12574
12588
  const isNeg = val < 0;
12575
12589
  return /* @__PURE__ */ jsxs(React41.Fragment, { children: [
12576
12590
  /* @__PURE__ */ jsx("td", { style: {
@@ -12604,8 +12618,8 @@ function IncomeStatementResolver(p) {
12604
12618
  borderBottom: `1px solid ${BORDER4}`
12605
12619
  }, children: "OPERATING INCOME" }),
12606
12620
  periods.map((_, pi) => {
12607
- var _a2;
12608
- const val = (_a2 = operatingIncome[pi]) != null ? _a2 : 0;
12621
+ var _a3;
12622
+ const val = (_a3 = operatingIncome[pi]) != null ? _a3 : 0;
12609
12623
  const isNeg = val < 0;
12610
12624
  return /* @__PURE__ */ jsxs(React41.Fragment, { children: [
12611
12625
  /* @__PURE__ */ jsx("td", { style: {
@@ -12638,8 +12652,8 @@ function IncomeStatementResolver(p) {
12638
12652
  borderTop: `2px solid ${BORDER4}`
12639
12653
  }, children: "NET INCOME" }),
12640
12654
  periods.map((_, pi) => {
12641
- var _a2;
12642
- const val = (_a2 = netIncome[pi]) != null ? _a2 : 0;
12655
+ var _a3;
12656
+ const val = (_a3 = netIncome[pi]) != null ? _a3 : 0;
12643
12657
  const isNeg = val < 0;
12644
12658
  return /* @__PURE__ */ jsxs(React41.Fragment, { children: [
12645
12659
  /* @__PURE__ */ jsx("td", { style: {
@@ -12684,17 +12698,17 @@ var fmt9 = (v, currency) => {
12684
12698
  return v < 0 ? `(${formatted})` : formatted;
12685
12699
  };
12686
12700
  function deriveNetCash(a) {
12687
- var _a;
12701
+ var _a2;
12688
12702
  if (a.netCash != null && a.netCash !== 0) return a.netCash;
12689
- return ((_a = a.lineItems) != null ? _a : []).filter((li) => !li.isSubtotal).reduce((sum, li) => sum + li.amount, 0);
12703
+ return ((_a2 = a.lineItems) != null ? _a2 : []).filter((li) => !li.isSubtotal).reduce((sum, li) => sum + li.amount, 0);
12690
12704
  }
12691
12705
  function CashFlowStatementResolver(p) {
12692
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
12706
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
12693
12707
  const { BORDER: BORDER4, MUTED: MUTED2, PAPER: PAPER2 } = useTheme();
12694
- const activities = ((_a = p.activities) != null ? _a : []).map((a) => {
12695
- var _a2;
12708
+ const activities = ((_a2 = p.activities) != null ? _a2 : []).map((a) => {
12709
+ var _a3;
12696
12710
  return __spreadProps(__spreadValues({}, a), {
12697
- lineItems: (_a2 = a.lineItems) != null ? _a2 : [],
12711
+ lineItems: (_a3 = a.lineItems) != null ? _a3 : [],
12698
12712
  netCash: deriveNetCash(a)
12699
12713
  });
12700
12714
  });
@@ -12713,19 +12727,19 @@ function CashFlowStatementResolver(p) {
12713
12727
  ...hasPrior ? [{ key: "priorAmount", label: priorLabel }] : []
12714
12728
  ];
12715
12729
  const csvRows = activities.flatMap((a) => {
12716
- var _a2, _b2, _c2, _d2;
12730
+ var _a3, _b2, _c2, _d2;
12717
12731
  return [
12718
12732
  ...a.lineItems.map((li) => {
12719
- var _a3, _b3;
12733
+ var _a4, _b3;
12720
12734
  return {
12721
- activity: (_a3 = activityLabels[a.activityType]) != null ? _a3 : a.activityType,
12735
+ activity: (_a4 = activityLabels[a.activityType]) != null ? _a4 : a.activityType,
12722
12736
  name: li.name,
12723
12737
  amount: li.amount,
12724
12738
  priorAmount: (_b3 = li.priorAmount) != null ? _b3 : ""
12725
12739
  };
12726
12740
  }),
12727
12741
  {
12728
- activity: (_a2 = activityLabels[a.activityType]) != null ? _a2 : a.activityType,
12742
+ activity: (_a3 = activityLabels[a.activityType]) != null ? _a3 : a.activityType,
12729
12743
  name: `Net Cash from ${(_c2 = (_b2 = activityLabels[a.activityType]) == null ? void 0 : _b2.replace("Cash Flows from ", "")) != null ? _c2 : a.activityType}`,
12730
12744
  amount: a.netCash,
12731
12745
  priorAmount: (_d2 = a.priorNetCash) != null ? _d2 : ""
@@ -12738,8 +12752,8 @@ function CashFlowStatementResolver(p) {
12738
12752
  {
12739
12753
  filename: (_e = p.title) != null ? _e : "cash-flow-statement",
12740
12754
  onDownloadCSV: () => {
12741
- var _a2;
12742
- return downloadCSV(csvCols, csvRows, (_a2 = p.title) != null ? _a2 : "cash-flow-statement");
12755
+ var _a3;
12756
+ return downloadCSV(csvCols, csvRows, (_a3 = p.title) != null ? _a3 : "cash-flow-statement");
12743
12757
  },
12744
12758
  children: /* @__PURE__ */ jsxs(
12745
12759
  "div",
@@ -12860,7 +12874,7 @@ function CashFlowStatementResolver(p) {
12860
12874
  ] }) }),
12861
12875
  /* @__PURE__ */ jsxs("tbody", { children: [
12862
12876
  activities.map((activity, ai) => {
12863
- var _a2, _b2, _c2;
12877
+ var _a3, _b2, _c2;
12864
12878
  return /* @__PURE__ */ jsxs(React41.Fragment, { children: [
12865
12879
  ai > 0 && /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx(
12866
12880
  "td",
@@ -12883,12 +12897,12 @@ function CashFlowStatementResolver(p) {
12883
12897
  textTransform: "uppercase",
12884
12898
  letterSpacing: "0.04em"
12885
12899
  },
12886
- children: (_a2 = activityLabels[activity.activityType]) != null ? _a2 : activity.activityType
12900
+ children: (_a3 = activityLabels[activity.activityType]) != null ? _a3 : activity.activityType
12887
12901
  }
12888
12902
  ) }),
12889
12903
  activity.lineItems.map((li, li_i) => {
12890
- var _a3, _b3;
12891
- const indent = (_a3 = li.indent) != null ? _a3 : 0;
12904
+ var _a4, _b3;
12905
+ const indent = (_a4 = li.indent) != null ? _a4 : 0;
12892
12906
  const isSub = (_b3 = li.isSubtotal) != null ? _b3 : false;
12893
12907
  return /* @__PURE__ */ jsxs(
12894
12908
  "tr",
@@ -13157,7 +13171,7 @@ var formatDate4 = (iso) => {
13157
13171
  };
13158
13172
  var accountTypeBadge = ACCOUNT_TYPE_COLORS;
13159
13173
  function GeneralLedgerResolver(p) {
13160
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
13174
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
13161
13175
  const { BORDER: BORDER4, MUTED: MUTED2, PAPER: PAPER2 } = useTheme();
13162
13176
  const csvCols = [
13163
13177
  { key: "date", label: "Date" },
@@ -13167,11 +13181,11 @@ function GeneralLedgerResolver(p) {
13167
13181
  { key: "credit", label: "Credit" },
13168
13182
  { key: "runningBalance", label: "Balance" }
13169
13183
  ];
13170
- const csvRows = ((_a = p.transactions) != null ? _a : []).map((t) => {
13171
- var _a2;
13184
+ const csvRows = ((_a2 = p.transactions) != null ? _a2 : []).map((t) => {
13185
+ var _a3;
13172
13186
  return {
13173
13187
  date: t.date,
13174
- reference: (_a2 = t.reference) != null ? _a2 : "",
13188
+ reference: (_a3 = t.reference) != null ? _a3 : "",
13175
13189
  description: t.description,
13176
13190
  debit: t.debit,
13177
13191
  credit: t.credit,
@@ -13184,8 +13198,8 @@ function GeneralLedgerResolver(p) {
13184
13198
  {
13185
13199
  filename: (_d = p.title) != null ? _d : "general-ledger",
13186
13200
  onDownloadCSV: () => {
13187
- var _a2;
13188
- return downloadCSV(csvCols, csvRows, (_a2 = p.title) != null ? _a2 : "general-ledger");
13201
+ var _a3;
13202
+ return downloadCSV(csvCols, csvRows, (_a3 = p.title) != null ? _a3 : "general-ledger");
13189
13203
  },
13190
13204
  children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "10px" }, children: [
13191
13205
  p.title && /* @__PURE__ */ jsx(
@@ -13443,14 +13457,14 @@ var fmt11 = (v, currency) => {
13443
13457
  return v < 0 ? `(${s})` : s;
13444
13458
  };
13445
13459
  function ChartOfAccountsResolver(p) {
13446
- var _a, _b, _c, _d, _e, _f, _g;
13460
+ var _a2, _b, _c, _d, _e, _f, _g;
13447
13461
  const { BORDER: BORDER4, MUTED: MUTED2, PAPER: PAPER2 } = useTheme();
13448
- const hasSubType = ((_a = p.accounts) != null ? _a : []).some((a) => a.subType);
13462
+ const hasSubType = ((_a2 = p.accounts) != null ? _a2 : []).some((a) => a.subType);
13449
13463
  const showBalances = (_b = p.showBalances) != null ? _b : false;
13450
13464
  const currency = (_c = p.currency) != null ? _c : "USD";
13451
13465
  const activeCount = ((_d = p.accounts) != null ? _d : []).filter((a) => {
13452
- var _a2;
13453
- return !a.isHeader && ((_a2 = a.status) != null ? _a2 : "active") === "active";
13466
+ var _a3;
13467
+ return !a.isHeader && ((_a3 = a.status) != null ? _a3 : "active") === "active";
13454
13468
  }).length;
13455
13469
  const inactiveCount = ((_e = p.accounts) != null ? _e : []).filter((a) => !a.isHeader && a.status === "inactive").length;
13456
13470
  const csvCols = [
@@ -13462,12 +13476,12 @@ function ChartOfAccountsResolver(p) {
13462
13476
  ...showBalances ? [{ key: "balance", label: "Balance" }] : []
13463
13477
  ];
13464
13478
  const csvRows = p.accounts.filter((a) => !a.isHeader).map((a) => {
13465
- var _a2, _b2, _c2;
13479
+ var _a3, _b2, _c2;
13466
13480
  return {
13467
13481
  code: a.code,
13468
13482
  name: a.name,
13469
13483
  accountType: a.accountType,
13470
- subType: (_a2 = a.subType) != null ? _a2 : "",
13484
+ subType: (_a3 = a.subType) != null ? _a3 : "",
13471
13485
  status: ((_b2 = a.status) != null ? _b2 : "active").charAt(0).toUpperCase() + ((_c2 = a.status) != null ? _c2 : "active").slice(1),
13472
13486
  balance: a.balance != null ? a.balance : ""
13473
13487
  };
@@ -13477,8 +13491,8 @@ function ChartOfAccountsResolver(p) {
13477
13491
  {
13478
13492
  filename: (_f = p.title) != null ? _f : "chart-of-accounts",
13479
13493
  onDownloadCSV: () => {
13480
- var _a2;
13481
- return downloadCSV(csvCols, csvRows, (_a2 = p.title) != null ? _a2 : "chart-of-accounts");
13494
+ var _a3;
13495
+ return downloadCSV(csvCols, csvRows, (_a3 = p.title) != null ? _a3 : "chart-of-accounts");
13482
13496
  },
13483
13497
  children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "10px" }, children: [
13484
13498
  p.title && /* @__PURE__ */ jsx(
@@ -13610,9 +13624,9 @@ function ChartOfAccountsResolver(p) {
13610
13624
  )
13611
13625
  ] }) }),
13612
13626
  /* @__PURE__ */ jsx("tbody", { children: ((_g = p.accounts) != null ? _g : []).map((account, ri) => {
13613
- var _a2, _b2, _c2;
13627
+ var _a3, _b2, _c2;
13614
13628
  const isInactive = account.status === "inactive";
13615
- const indent = (_a2 = account.indent) != null ? _a2 : 0;
13629
+ const indent = (_a3 = account.indent) != null ? _a3 : 0;
13616
13630
  if (account.isHeader) {
13617
13631
  const colSpan = 3 + (hasSubType ? 1 : 0) + 1 + (showBalances ? 1 : 0);
13618
13632
  return /* @__PURE__ */ jsx("tr", { style: { background: PAPER2 }, children: /* @__PURE__ */ jsx(
@@ -13801,9 +13815,9 @@ var formatDate5 = (d) => {
13801
13815
  }
13802
13816
  };
13803
13817
  function InvoiceDetailResolver(p) {
13804
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
13818
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
13805
13819
  const { BORDER: BORDER4, MUTED: MUTED2, PAPER: PAPER2 } = useTheme();
13806
- const statusStyle = (_a = STATUS_COLORS2[p.status]) != null ? _a : STATUS_COLORS2.void;
13820
+ const statusStyle = (_a2 = STATUS_COLORS2[p.status]) != null ? _a2 : STATUS_COLORS2.void;
13807
13821
  const isOverdue = p.status === "overdue";
13808
13822
  return /* @__PURE__ */ jsx(ComponentActions, { filename: `invoice-${p.invoiceNumber}`, children: /* @__PURE__ */ jsxs(
13809
13823
  "div",
@@ -14282,7 +14296,7 @@ function InvoiceDetailResolver(p) {
14282
14296
  h
14283
14297
  )) }) }),
14284
14298
  /* @__PURE__ */ jsx("tbody", { children: ((_q = p.payments) != null ? _q : []).map((pmt, i) => {
14285
- var _a2;
14299
+ var _a3;
14286
14300
  return /* @__PURE__ */ jsxs("tr", { children: [
14287
14301
  /* @__PURE__ */ jsx(
14288
14302
  "td",
@@ -14330,7 +14344,7 @@ function InvoiceDetailResolver(p) {
14330
14344
  color: MUTED2,
14331
14345
  borderBottom: `1px solid #f2f2f2`
14332
14346
  },
14333
- children: (_a2 = pmt.reference) != null ? _a2 : "\u2014"
14347
+ children: (_a3 = pmt.reference) != null ? _a3 : "\u2014"
14334
14348
  }
14335
14349
  )
14336
14350
  ] }, i);
@@ -14418,14 +14432,14 @@ var tdStyle2 = (align = "left", last = false) => ({
14418
14432
  whiteSpace: "nowrap"
14419
14433
  });
14420
14434
  function AmortizationTableResolver(p) {
14421
- var _a, _b, _c, _d, _e, _f, _g;
14435
+ var _a2, _b, _c, _d, _e, _f, _g;
14422
14436
  const { BORDER: BORDER4, MUTED: MUTED2, PAPER: PAPER2 } = useTheme();
14423
- const currency = (_a = p.currency) != null ? _a : "USD";
14437
+ const currency = (_a2 = p.currency) != null ? _a2 : "USD";
14424
14438
  const payments = (_b = p.payments) != null ? _b : [];
14425
14439
  const hasDate = payments.some((r) => r.paymentDate);
14426
14440
  const hasExtra = payments.some((r) => {
14427
- var _a2;
14428
- return ((_a2 = r.extra) != null ? _a2 : 0) > 0;
14441
+ var _a3;
14442
+ return ((_a3 = r.extra) != null ? _a3 : 0) > 0;
14429
14443
  });
14430
14444
  const derivedMonthly = payments.length > 0 ? payments[0].payment : 0;
14431
14445
  const derivedTotalInterest = payments.reduce((s, r) => s + r.interest, 0);
@@ -14446,10 +14460,10 @@ function AmortizationTableResolver(p) {
14446
14460
  { key: "balance", label: "Balance" }
14447
14461
  ];
14448
14462
  const csvRows = payments.map((r) => {
14449
- var _a2, _b2;
14463
+ var _a3, _b2;
14450
14464
  return {
14451
14465
  period: r.period,
14452
- paymentDate: (_a2 = r.paymentDate) != null ? _a2 : "",
14466
+ paymentDate: (_a3 = r.paymentDate) != null ? _a3 : "",
14453
14467
  payment: r.payment,
14454
14468
  principal: r.principal,
14455
14469
  interest: r.interest,
@@ -14462,8 +14476,8 @@ function AmortizationTableResolver(p) {
14462
14476
  {
14463
14477
  filename: (_g = p.title) != null ? _g : "amortization-table",
14464
14478
  onDownloadCSV: () => {
14465
- var _a2;
14466
- return downloadCSV(csvCols, csvRows, (_a2 = p.title) != null ? _a2 : "amortization-table");
14479
+ var _a3;
14480
+ return downloadCSV(csvCols, csvRows, (_a3 = p.title) != null ? _a3 : "amortization-table");
14467
14481
  },
14468
14482
  children: /* @__PURE__ */ jsxs(
14469
14483
  "div",
@@ -14705,7 +14719,7 @@ function AmortizationTableResolver(p) {
14705
14719
  /* @__PURE__ */ jsx("th", { style: thStyle3("right"), children: "Balance" })
14706
14720
  ] }) }),
14707
14721
  /* @__PURE__ */ jsx("tbody", { children: payments.map((row, ri) => {
14708
- var _a2, _b2, _c2, _d2;
14722
+ var _a3, _b2, _c2, _d2;
14709
14723
  const isLast = ri === payments.length - 1;
14710
14724
  const principalPct = row.payment > 0 ? Math.min(row.principal / row.payment * 100, 100) : 0;
14711
14725
  const balanceIsZero = originalAmount > 0 && row.balance < originalAmount * 0.01;
@@ -14755,7 +14769,7 @@ function AmortizationTableResolver(p) {
14755
14769
  }
14756
14770
  )
14757
14771
  ] }),
14758
- hasDate && /* @__PURE__ */ jsx("td", { style: tdStyle2("left", isLast), children: (_a2 = row.paymentDate) != null ? _a2 : "\u2014" }),
14772
+ hasDate && /* @__PURE__ */ jsx("td", { style: tdStyle2("left", isLast), children: (_a3 = row.paymentDate) != null ? _a3 : "\u2014" }),
14759
14773
  /* @__PURE__ */ jsx("td", { style: tdStyle2("right", isLast), children: fmt13(row.payment, currency) }),
14760
14774
  /* @__PURE__ */ jsx(
14761
14775
  "td",
@@ -14834,9 +14848,9 @@ var TH_STYLE = {
14834
14848
  };
14835
14849
  var TH_RIGHT = __spreadProps(__spreadValues({}, TH_STYLE), { textAlign: "right" });
14836
14850
  function DepreciationScheduleResolver(p) {
14837
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
14851
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
14838
14852
  const { BORDER: BORDER4, MUTED: MUTED2, PAPER: PAPER2 } = useTheme();
14839
- const currency = (_a = p.currency) != null ? _a : "USD";
14853
+ const currency = (_a2 = p.currency) != null ? _a2 : "USD";
14840
14854
  const fmt18 = (v) => {
14841
14855
  if (v === 0) return "\u2014";
14842
14856
  return new Intl.NumberFormat("en-US", {
@@ -14879,11 +14893,11 @@ function DepreciationScheduleResolver(p) {
14879
14893
  { key: "bookValue", label: "Book Value" }
14880
14894
  ];
14881
14895
  const csvRows = ((_g = p.assets) != null ? _g : []).map((a) => {
14882
- var _a2, _b2, _c2, _d2;
14896
+ var _a3, _b2, _c2, _d2;
14883
14897
  return {
14884
14898
  id: a.id,
14885
14899
  name: a.name,
14886
- category: (_a2 = a.category) != null ? _a2 : "",
14900
+ category: (_a3 = a.category) != null ? _a3 : "",
14887
14901
  acquiredDate: a.acquiredDate,
14888
14902
  cost: a.cost,
14889
14903
  usefulLife: (_b2 = a.usefulLife) != null ? _b2 : "",
@@ -14898,8 +14912,8 @@ function DepreciationScheduleResolver(p) {
14898
14912
  {
14899
14913
  filename: (_h = p.title) != null ? _h : "depreciation-schedule",
14900
14914
  onDownloadCSV: () => {
14901
- var _a2;
14902
- return downloadCSV(csvCols, csvRows, (_a2 = p.title) != null ? _a2 : "depreciation-schedule");
14915
+ var _a3;
14916
+ return downloadCSV(csvCols, csvRows, (_a3 = p.title) != null ? _a3 : "depreciation-schedule");
14903
14917
  },
14904
14918
  children: /* @__PURE__ */ jsxs(
14905
14919
  "div",
@@ -14979,7 +14993,7 @@ function DepreciationScheduleResolver(p) {
14979
14993
  ] }) }),
14980
14994
  /* @__PURE__ */ jsxs("tbody", { children: [
14981
14995
  ((_i = p.assets) != null ? _i : []).map((asset, ri) => {
14982
- var _a2, _b2, _c2;
14996
+ var _a3, _b2, _c2;
14983
14997
  const catColor = asset.category && CATEGORY_COLORS[asset.category] || DEFAULT_CATEGORY_COLOR;
14984
14998
  const bvRatio = asset.cost > 0 ? asset.bookValue / asset.cost : 0;
14985
14999
  const barColor = bvRatio > 0.5 ? "#15803d" : bvRatio > 0.2 ? "#f59e0b" : "#dc2626";
@@ -15063,7 +15077,7 @@ function DepreciationScheduleResolver(p) {
15063
15077
  borderBottom: "1px solid #f2f2f2",
15064
15078
  whiteSpace: "nowrap"
15065
15079
  },
15066
- children: (_a2 = asset.usefulLife) != null ? _a2 : "\u2014"
15080
+ children: (_a3 = asset.usefulLife) != null ? _a3 : "\u2014"
15067
15081
  }
15068
15082
  ),
15069
15083
  /* @__PURE__ */ jsx(
@@ -15272,12 +15286,12 @@ var PRIORITY_STYLES = {
15272
15286
  low: { color: "#777777", bg: "#f2f2f2", label: "LOW" }
15273
15287
  };
15274
15288
  function EscalationCardResolver(p) {
15275
- var _a, _b, _c, _d;
15289
+ var _a2, _b, _c, _d;
15276
15290
  const { BORDER: BORDER4, MUTED: MUTED2, ACCENT: ACCENT2, ACCENT_SOFT: ACCENT_SOFT2 } = useTheme();
15277
15291
  const [cardHovered, setCardHovered] = useState(false);
15278
15292
  const [btnHovered, setBtnHovered] = useState(false);
15279
15293
  const priorityStyle = p.priority ? PRIORITY_STYLES[p.priority] : null;
15280
- const railColor = (_a = priorityStyle == null ? void 0 : priorityStyle.color) != null ? _a : ACCENT2;
15294
+ const railColor = (_a2 = priorityStyle == null ? void 0 : priorityStyle.color) != null ? _a2 : ACCENT2;
15281
15295
  const iconBg = (_b = priorityStyle == null ? void 0 : priorityStyle.bg) != null ? _b : "#fff2ec";
15282
15296
  return /* @__PURE__ */ jsx(ComponentActions, { filename: (_c = p.title) != null ? _c : "escalation", children: /* @__PURE__ */ jsx("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "10px" }, children: /* @__PURE__ */ jsxs(
15283
15297
  "div",
@@ -15409,9 +15423,9 @@ function fmt14(v, unit) {
15409
15423
  return /^[$€£¥]/.test(unit) ? `${unit}${n}` : `${n}${unit === "%" ? "%" : ` ${unit}`}`;
15410
15424
  }
15411
15425
  function LineChartResolver(p) {
15412
- var _a, _b, _c, _d;
15426
+ var _a2, _b, _c, _d;
15413
15427
  const { BORDER: BORDER4, MUTED: MUTED2, ACCENT: ACCENT2 } = useTheme();
15414
- const series = (_a = p.series) != null ? _a : [];
15428
+ const series = (_a2 = p.series) != null ? _a2 : [];
15415
15429
  const data = (_b = p.data) != null ? _b : [];
15416
15430
  const xKey = (_c = p.xKey) != null ? _c : "x";
15417
15431
  const { isVisible, toggle } = useSeriesToggle(series.map((s) => s.dataKey));
@@ -15439,14 +15453,14 @@ function LineChartResolver(p) {
15439
15453
  }
15440
15454
  ),
15441
15455
  series.map((s, i) => {
15442
- var _a2;
15456
+ var _a3;
15443
15457
  return /* @__PURE__ */ jsx(
15444
15458
  Line,
15445
15459
  {
15446
15460
  type: p.smooth ? "monotone" : "linear",
15447
15461
  dataKey: s.dataKey,
15448
15462
  name: s.name,
15449
- stroke: (_a2 = s.color) != null ? _a2 : CHART_PALETTE[i % CHART_PALETTE.length],
15463
+ stroke: (_a3 = s.color) != null ? _a3 : CHART_PALETTE[i % CHART_PALETTE.length],
15450
15464
  strokeWidth: 2,
15451
15465
  dot: false,
15452
15466
  activeDot: { r: 4, strokeWidth: 2, stroke: "white" },
@@ -15458,7 +15472,7 @@ function LineChartResolver(p) {
15458
15472
  })
15459
15473
  ] }) }),
15460
15474
  series.length > 1 && /* @__PURE__ */ jsx("div", { style: { display: "flex", flexWrap: "wrap", gap: "14px" }, children: series.map((s, i) => {
15461
- var _a2;
15475
+ var _a3;
15462
15476
  return /* @__PURE__ */ jsxs(
15463
15477
  "div",
15464
15478
  {
@@ -15479,7 +15493,7 @@ function LineChartResolver(p) {
15479
15493
  width: "16px",
15480
15494
  height: "2px",
15481
15495
  borderRadius: "9999px",
15482
- background: (_a2 = s.color) != null ? _a2 : CHART_PALETTE[i % CHART_PALETTE.length],
15496
+ background: (_a3 = s.color) != null ? _a3 : CHART_PALETTE[i % CHART_PALETTE.length],
15483
15497
  display: "inline-block",
15484
15498
  opacity: isVisible(s.dataKey) ? 1 : 0.3,
15485
15499
  transition: "opacity 0.15s"
@@ -15508,15 +15522,15 @@ function fmt15(v, unit) {
15508
15522
  return /^[$€£¥]/.test(unit) ? `${unit}${n}` : `${n}${unit === "%" ? "%" : ` ${unit}`}`;
15509
15523
  }
15510
15524
  function ComboChartResolver(p) {
15511
- var _a, _b, _c, _d, _e;
15525
+ var _a2, _b, _c, _d, _e;
15512
15526
  const { BORDER: BORDER4, MUTED: MUTED2 } = useTheme();
15513
- const bars = (_a = p.bars) != null ? _a : [];
15527
+ const bars = (_a2 = p.bars) != null ? _a2 : [];
15514
15528
  const lines = (_b = p.lines) != null ? _b : [];
15515
15529
  const data = (_c = p.data) != null ? _c : [];
15516
15530
  const xKey = (_d = p.xKey) != null ? _d : "x";
15517
15531
  const hasRight = bars.some((b) => b.axis === "right") || lines.some((l) => {
15518
- var _a2;
15519
- return ((_a2 = l.axis) != null ? _a2 : "right") === "right";
15532
+ var _a3;
15533
+ return ((_a3 = l.axis) != null ? _a3 : "right") === "right";
15520
15534
  });
15521
15535
  const all = [
15522
15536
  ...bars.map((b) => __spreadProps(__spreadValues({}, b), { kind: "bar" })),
@@ -15524,9 +15538,9 @@ function ComboChartResolver(p) {
15524
15538
  ];
15525
15539
  const { isVisible, toggle } = useSeriesToggle(all.map((s) => s.dataKey));
15526
15540
  const colorOf = (dataKey, fallbackIdx) => {
15527
- var _a2;
15541
+ var _a3;
15528
15542
  const s = all.find((x) => x.dataKey === dataKey);
15529
- return (_a2 = s == null ? void 0 : s.color) != null ? _a2 : CHART_PALETTE[fallbackIdx % CHART_PALETTE.length];
15543
+ return (_a3 = s == null ? void 0 : s.color) != null ? _a3 : CHART_PALETTE[fallbackIdx % CHART_PALETTE.length];
15530
15544
  };
15531
15545
  return /* @__PURE__ */ jsx(ComponentActions, { filename: (_e = p.title) != null ? _e : "combo-chart", children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "12px" }, children: [
15532
15546
  p.title && /* @__PURE__ */ jsx("p", { style: { fontFamily: "var(--font-serif)", fontSize: "15px", fontWeight: 600, color: "var(--foreground)", letterSpacing: "-0.005em" }, children: p.title }),
@@ -15558,11 +15572,11 @@ function ComboChartResolver(p) {
15558
15572
  ),
15559
15573
  /* @__PURE__ */ jsx(Tooltip, { contentStyle: tooltipStyle7, cursor: { fill: "rgba(0,0,0,0.03)" } }),
15560
15574
  bars.map((b, i) => {
15561
- var _a2;
15575
+ var _a3;
15562
15576
  return /* @__PURE__ */ jsx(
15563
15577
  Bar,
15564
15578
  {
15565
- yAxisId: (_a2 = b.axis) != null ? _a2 : "left",
15579
+ yAxisId: (_a3 = b.axis) != null ? _a3 : "left",
15566
15580
  dataKey: b.dataKey,
15567
15581
  name: b.name,
15568
15582
  fill: colorOf(b.dataKey, i),
@@ -15575,11 +15589,11 @@ function ComboChartResolver(p) {
15575
15589
  );
15576
15590
  }),
15577
15591
  lines.map((l, i) => {
15578
- var _a2;
15592
+ var _a3;
15579
15593
  return /* @__PURE__ */ jsx(
15580
15594
  Line,
15581
15595
  {
15582
- yAxisId: (_a2 = l.axis) != null ? _a2 : "right",
15596
+ yAxisId: (_a3 = l.axis) != null ? _a3 : "right",
15583
15597
  type: "monotone",
15584
15598
  dataKey: l.dataKey,
15585
15599
  name: l.name,
@@ -15639,9 +15653,9 @@ function fmt16(v, unit) {
15639
15653
  return /^[$€£¥]/.test(unit) ? `${unit}${n}` : `${n}${unit === "%" ? "%" : ` ${unit}`}`;
15640
15654
  }
15641
15655
  function GaugeChartResolver(p) {
15642
- var _a, _b;
15656
+ var _a2, _b;
15643
15657
  const { MUTED: MUTED2, ACCENT: ACCENT2, PAPER: PAPER2 } = useTheme();
15644
- const items = (_a = p.items) != null ? _a : [];
15658
+ const items = (_a2 = p.items) != null ? _a2 : [];
15645
15659
  return /* @__PURE__ */ jsx(ComponentActions, { filename: (_b = p.title) != null ? _b : "gauge-chart", children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "12px" }, children: [
15646
15660
  p.title && /* @__PURE__ */ jsx("p", { style: { fontFamily: "var(--font-serif)", fontSize: "15px", fontWeight: 600, color: "var(--foreground)", letterSpacing: "-0.005em" }, children: p.title }),
15647
15661
  /* @__PURE__ */ jsx("div", { style: { display: "flex", flexWrap: "wrap", gap: "8px", justifyContent: items.length === 1 ? "center" : "space-around" }, children: items.map((it, i) => {
@@ -15720,24 +15734,24 @@ function makeCellContent(total, currency) {
15720
15734
  };
15721
15735
  }
15722
15736
  function TreemapChartResolver(p) {
15723
- var _a, _b;
15737
+ var _a2, _b;
15724
15738
  useTheme();
15725
- const nodes = (_a = p.nodes) != null ? _a : [];
15739
+ const nodes = (_a2 = p.nodes) != null ? _a2 : [];
15726
15740
  const total = nodes.reduce((s, n) => s + (n.value || 0), 0);
15727
15741
  const data = nodes.map((n, i) => {
15728
- var _a2;
15742
+ var _a3;
15729
15743
  return {
15730
15744
  name: n.name,
15731
15745
  value: n.value,
15732
- fill: (_a2 = n.color) != null ? _a2 : CHART_PALETTE[i % CHART_PALETTE.length]
15746
+ fill: (_a3 = n.color) != null ? _a3 : CHART_PALETTE[i % CHART_PALETTE.length]
15733
15747
  };
15734
15748
  });
15735
15749
  const csv = () => {
15736
- var _a2;
15750
+ var _a3;
15737
15751
  return downloadCSV(
15738
15752
  [{ key: "name", label: "Name" }, { key: "value", label: "Value" }],
15739
15753
  nodes.map((n) => ({ name: n.name, value: n.value })),
15740
- (_a2 = p.title) != null ? _a2 : "treemap-chart"
15754
+ (_a3 = p.title) != null ? _a3 : "treemap-chart"
15741
15755
  );
15742
15756
  };
15743
15757
  return /* @__PURE__ */ jsx(ComponentActions, { filename: (_b = p.title) != null ? _b : "treemap-chart", onDownloadCSV: csv, children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "12px" }, children: [
@@ -15772,9 +15786,9 @@ var tooltipStyle9 = {
15772
15786
  color: "var(--foreground)"
15773
15787
  };
15774
15788
  function RadarChartResolver(p) {
15775
- var _a, _b, _c;
15789
+ var _a2, _b, _c;
15776
15790
  const { BORDER: BORDER4, MUTED: MUTED2 } = useTheme();
15777
- const series = (_a = p.series) != null ? _a : [];
15791
+ const series = (_a2 = p.series) != null ? _a2 : [];
15778
15792
  const data = (_b = p.data) != null ? _b : [];
15779
15793
  const { isVisible, toggle } = useSeriesToggle(series.map((s) => s.dataKey));
15780
15794
  return /* @__PURE__ */ jsx(ComponentActions, { filename: (_c = p.title) != null ? _c : "radar-chart", children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "12px" }, children: [
@@ -15785,8 +15799,8 @@ function RadarChartResolver(p) {
15785
15799
  /* @__PURE__ */ jsx(PolarRadiusAxis, { tick: { fontSize: 10, fill: MUTED2 }, axisLine: false }),
15786
15800
  /* @__PURE__ */ jsx(Tooltip, { contentStyle: tooltipStyle9, formatter: (value) => p.unit ? `${Number(value)}${p.unit}` : `${Number(value)}` }),
15787
15801
  series.map((s, i) => {
15788
- var _a2;
15789
- const c = (_a2 = s.color) != null ? _a2 : CHART_PALETTE[i % CHART_PALETTE.length];
15802
+ var _a3;
15803
+ const c = (_a3 = s.color) != null ? _a3 : CHART_PALETTE[i % CHART_PALETTE.length];
15790
15804
  return /* @__PURE__ */ jsx(
15791
15805
  Radar,
15792
15806
  {
@@ -15804,8 +15818,8 @@ function RadarChartResolver(p) {
15804
15818
  })
15805
15819
  ] }) }),
15806
15820
  series.length > 1 && /* @__PURE__ */ jsx("div", { style: { display: "flex", flexWrap: "wrap", gap: "14px", justifyContent: "center" }, children: series.map((s, i) => {
15807
- var _a2;
15808
- const c = (_a2 = s.color) != null ? _a2 : CHART_PALETTE[i % CHART_PALETTE.length];
15821
+ var _a3;
15822
+ const c = (_a3 = s.color) != null ? _a3 : CHART_PALETTE[i % CHART_PALETTE.length];
15809
15823
  return /* @__PURE__ */ jsxs(
15810
15824
  "div",
15811
15825
  {
@@ -15854,24 +15868,24 @@ function money2(v, currency) {
15854
15868
  return currency ? `${currency}${n}` : n;
15855
15869
  }
15856
15870
  function FunnelChartResolver(p) {
15857
- var _a, _b, _c, _d;
15871
+ var _a2, _b, _c, _d;
15858
15872
  const { MUTED: MUTED2 } = useTheme();
15859
- const stages = (_a = p.stages) != null ? _a : [];
15873
+ const stages = (_a2 = p.stages) != null ? _a2 : [];
15860
15874
  const data = stages.map((s, i) => {
15861
- var _a2;
15875
+ var _a3;
15862
15876
  return {
15863
15877
  name: s.label,
15864
15878
  value: s.value,
15865
- fill: (_a2 = s.color) != null ? _a2 : CHART_PALETTE[i % CHART_PALETTE.length]
15879
+ fill: (_a3 = s.color) != null ? _a3 : CHART_PALETTE[i % CHART_PALETTE.length]
15866
15880
  };
15867
15881
  });
15868
15882
  const first = (_c = (_b = stages[0]) == null ? void 0 : _b.value) != null ? _c : 0;
15869
15883
  const csv = () => {
15870
- var _a2;
15884
+ var _a3;
15871
15885
  return downloadCSV(
15872
15886
  [{ key: "label", label: "Stage" }, { key: "value", label: "Value" }],
15873
15887
  stages.map((s) => ({ label: s.label, value: s.value })),
15874
- (_a2 = p.title) != null ? _a2 : "funnel-chart"
15888
+ (_a3 = p.title) != null ? _a3 : "funnel-chart"
15875
15889
  );
15876
15890
  };
15877
15891
  return /* @__PURE__ */ jsx(ComponentActions, { filename: (_d = p.title) != null ? _d : "funnel-chart", onDownloadCSV: csv, children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "12px" }, children: [
@@ -15884,13 +15898,13 @@ function FunnelChartResolver(p) {
15884
15898
  ] })
15885
15899
  ] }) }),
15886
15900
  /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column", gap: "4px" }, children: stages.map((s, i) => {
15887
- var _a2;
15901
+ var _a3;
15888
15902
  const prior = i === 0 ? null : stages[i - 1].value;
15889
15903
  const stepPct = prior && prior > 0 ? Math.round(s.value / prior * 100) : null;
15890
15904
  const ofTop = first > 0 ? Math.round(s.value / first * 100) : null;
15891
15905
  return /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", fontSize: "12px" }, children: [
15892
15906
  /* @__PURE__ */ jsxs("span", { style: { display: "flex", alignItems: "center", gap: "8px", color: "var(--foreground)" }, children: [
15893
- /* @__PURE__ */ jsx("span", { style: { width: "10px", height: "10px", borderRadius: "3px", background: (_a2 = s.color) != null ? _a2 : CHART_PALETTE[i % CHART_PALETTE.length] } }),
15907
+ /* @__PURE__ */ jsx("span", { style: { width: "10px", height: "10px", borderRadius: "3px", background: (_a3 = s.color) != null ? _a3 : CHART_PALETTE[i % CHART_PALETTE.length] } }),
15894
15908
  s.label
15895
15909
  ] }),
15896
15910
  /* @__PURE__ */ jsxs("span", { style: { color: MUTED2, fontVariantNumeric: "tabular-nums" }, children: [
@@ -15913,22 +15927,22 @@ function fmt17(v, unit) {
15913
15927
  return /^[$€£¥]/.test(unit) ? `${unit}${n}` : `${n}${unit === "%" ? "%" : ` ${unit}`}`;
15914
15928
  }
15915
15929
  function BulletChartResolver(p) {
15916
- var _a, _b;
15930
+ var _a2, _b;
15917
15931
  const { MUTED: MUTED2, PAPER: PAPER2 } = useTheme();
15918
- const items = (_a = p.items) != null ? _a : [];
15932
+ const items = (_a2 = p.items) != null ? _a2 : [];
15919
15933
  const csv = () => {
15920
- var _a2;
15934
+ var _a3;
15921
15935
  return downloadCSV(
15922
15936
  [{ key: "label", label: "KPI" }, { key: "value", label: "Actual" }, { key: "target", label: "Target" }],
15923
15937
  items.map((it) => ({ label: it.label, value: it.value, target: it.target })),
15924
- (_a2 = p.title) != null ? _a2 : "bullet-chart"
15938
+ (_a3 = p.title) != null ? _a3 : "bullet-chart"
15925
15939
  );
15926
15940
  };
15927
15941
  return /* @__PURE__ */ jsx(ComponentActions, { filename: (_b = p.title) != null ? _b : "bullet-chart", onDownloadCSV: csv, children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "12px" }, children: [
15928
15942
  p.title && /* @__PURE__ */ jsx("p", { style: { fontFamily: "var(--font-serif)", fontSize: "15px", fontWeight: 600, color: "var(--foreground)", letterSpacing: "-0.005em" }, children: p.title }),
15929
15943
  /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column", gap: "12px" }, children: items.map((it, i) => {
15930
- var _a2;
15931
- const max = (_a2 = it.max) != null ? _a2 : Math.max(it.value, it.target) * 1.25 || 1;
15944
+ var _a3;
15945
+ const max = (_a3 = it.max) != null ? _a3 : Math.max(it.value, it.target) * 1.25 || 1;
15932
15946
  const valPct = Math.max(0, Math.min(100, it.value / max * 100));
15933
15947
  const tgtPct = Math.max(0, Math.min(100, it.target / max * 100));
15934
15948
  const ratio = it.target > 0 ? it.value / it.target : 1;
@@ -15958,20 +15972,20 @@ function axisFmt(v, unit) {
15958
15972
  return /^[$€£¥]/.test(unit) ? `${unit}${n}` : `${n}${unit === "%" ? "%" : ` ${unit}`}`;
15959
15973
  }
15960
15974
  function ScatterChartResolver(p) {
15961
- var _a, _b;
15975
+ var _a2, _b;
15962
15976
  const { BORDER: BORDER4, MUTED: MUTED2 } = useTheme();
15963
- const series = (_a = p.series) != null ? _a : [];
15977
+ const series = (_a2 = p.series) != null ? _a2 : [];
15964
15978
  const hasZ = series.some((s) => s.points.some((pt) => pt.z != null));
15965
15979
  const { isVisible, toggle } = useSeriesToggle(series.map((s) => s.name));
15966
15980
  const tooltipContent = (props) => {
15967
- var _a2, _b2;
15981
+ var _a3, _b2;
15968
15982
  const { active, payload } = props;
15969
15983
  if (!active || !payload || !payload.length) return null;
15970
15984
  const d = payload[0].payload;
15971
15985
  return /* @__PURE__ */ jsxs("div", { style: { fontSize: "12px", borderRadius: "8px", border: `1px solid ${BORDER4}`, background: "white", boxShadow: "0 4px 12px rgba(0,0,0,0.08)", color: "var(--foreground)", padding: "8px 10px" }, children: [
15972
15986
  d.label && /* @__PURE__ */ jsx("div", { style: { fontWeight: 600, marginBottom: "2px" }, children: d.label }),
15973
15987
  /* @__PURE__ */ jsxs("div", { style: { color: MUTED2 }, children: [
15974
- (_a2 = p.xLabel) != null ? _a2 : "x",
15988
+ (_a3 = p.xLabel) != null ? _a3 : "x",
15975
15989
  ": ",
15976
15990
  axisFmt(d.x, p.xUnit)
15977
15991
  ] }),
@@ -16019,13 +16033,13 @@ function ScatterChartResolver(p) {
16019
16033
  hasZ && /* @__PURE__ */ jsx(ZAxis, { type: "number", dataKey: "z", range: [60, 420] }),
16020
16034
  /* @__PURE__ */ jsx(Tooltip, { content: tooltipContent, cursor: { strokeDasharray: "3 3" } }),
16021
16035
  series.map((s, i) => {
16022
- var _a2;
16036
+ var _a3;
16023
16037
  return /* @__PURE__ */ jsx(
16024
16038
  Scatter,
16025
16039
  {
16026
16040
  name: s.name,
16027
16041
  data: s.points,
16028
- fill: (_a2 = s.color) != null ? _a2 : CHART_PALETTE[i % CHART_PALETTE.length],
16042
+ fill: (_a3 = s.color) != null ? _a3 : CHART_PALETTE[i % CHART_PALETTE.length],
16029
16043
  fillOpacity: 0.7,
16030
16044
  hide: !isVisible(s.name),
16031
16045
  isAnimationActive: false
@@ -16035,8 +16049,8 @@ function ScatterChartResolver(p) {
16035
16049
  })
16036
16050
  ] }) }),
16037
16051
  series.length > 1 && /* @__PURE__ */ jsx("div", { style: { display: "flex", flexWrap: "wrap", gap: "14px" }, children: series.map((s, i) => {
16038
- var _a2;
16039
- const c = (_a2 = s.color) != null ? _a2 : CHART_PALETTE[i % CHART_PALETTE.length];
16052
+ var _a3;
16053
+ const c = (_a3 = s.color) != null ? _a3 : CHART_PALETTE[i % CHART_PALETTE.length];
16040
16054
  return /* @__PURE__ */ jsxs(
16041
16055
  "div",
16042
16056
  {
@@ -16120,7 +16134,7 @@ function brandIconUrl(name) {
16120
16134
  }
16121
16135
  var CONNECTED_GREEN = "#15803d";
16122
16136
  function ConnectIntegrationResolver(p) {
16123
- var _a;
16137
+ var _a2;
16124
16138
  const { BORDER: BORDER4, MUTED: MUTED2, ACCENT: ACCENT2, ACCENT_SOFT: ACCENT_SOFT2 } = useTheme();
16125
16139
  const [cardHovered, setCardHovered] = useState(false);
16126
16140
  const [btnHovered, setBtnHovered] = useState(false);
@@ -16130,7 +16144,7 @@ function ConnectIntegrationResolver(p) {
16130
16144
  const iconSrc = p.iconUrl || brandIconUrl(name);
16131
16145
  const showImg = Boolean(iconSrc) && !imgFailed;
16132
16146
  const connected = p.status === "connected";
16133
- const label = (_a = p.ctaLabel) != null ? _a : connected ? "Open" : "Connect";
16147
+ const label = (_a2 = p.ctaLabel) != null ? _a2 : connected ? "Open" : "Connect";
16134
16148
  return /* @__PURE__ */ jsx(ComponentActions, { filename: name, children: /* @__PURE__ */ jsx("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "10px" }, children: /* @__PURE__ */ jsxs(
16135
16149
  "div",
16136
16150
  {
@@ -16283,14 +16297,14 @@ init_ThemeContext();
16283
16297
  var CONNECTED_GREEN2 = "#15803d";
16284
16298
  var CONNECTED_BG = "#eaf6ee";
16285
16299
  function IntegrationsListResolver(p) {
16286
- var _a, _b;
16300
+ var _a2, _b;
16287
16301
  const { BORDER: BORDER4, MUTED: MUTED2, PAPER: PAPER2, ACCENT: ACCENT2, ACCENT_SOFT: ACCENT_SOFT2 } = useTheme();
16288
16302
  const integrations = Array.isArray(p.integrations) ? p.integrations : [];
16289
16303
  const [rowHover, setRowHover] = useState(null);
16290
16304
  const [btnHover, setBtnHover] = useState(null);
16291
16305
  const [failed, setFailed] = useState({});
16292
16306
  const connectedCount = integrations.filter((i) => i.status === "connected").length;
16293
- return /* @__PURE__ */ jsx(ComponentActions, { filename: (_a = p.title) != null ? _a : "integrations", children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "11px" }, children: [
16307
+ return /* @__PURE__ */ jsx(ComponentActions, { filename: (_a2 = p.title) != null ? _a2 : "integrations", children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "11px" }, children: [
16294
16308
  /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "2px" }, children: [
16295
16309
  /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "baseline", justifyContent: "space-between", gap: "12px" }, children: [
16296
16310
  /* @__PURE__ */ jsx(
@@ -16564,11 +16578,11 @@ function layoutGraph(steps, startX = 0, startY = 0, keyPrefix = "") {
16564
16578
  let prevId = null;
16565
16579
  let totalW = NODE_W;
16566
16580
  steps.forEach((step, idx) => {
16567
- var _a, _b, _c, _d;
16581
+ var _a2, _b, _c, _d;
16568
16582
  const op = step.operation;
16569
16583
  const isBranch = op === "BRANCH" || op === "CONDITION";
16570
16584
  const isFanOut = op === "FAN_OUT";
16571
- const baseId = `${keyPrefix}${(_a = step.id) != null ? _a : `s${idx}`}`;
16585
+ const baseId = `${keyPrefix}${(_a2 = step.id) != null ? _a2 : `s${idx}`}`;
16572
16586
  if (isFanOut && ((_b = step.subSteps) == null ? void 0 : _b.length)) {
16573
16587
  const foNodeId = baseId;
16574
16588
  const res = layoutGraph(step.subSteps, 0, 0, `${baseId}/`);
@@ -16610,10 +16624,10 @@ function layoutGraph(steps, startX = 0, startY = 0, keyPrefix = "") {
16610
16624
  if (prevId) edges.push({ from: prevId, to: bNodeId });
16611
16625
  y += BRANCH_NODE_H + GAP_Y;
16612
16626
  const branchResults = step.branches.map((br, bi) => {
16613
- var _a2;
16627
+ var _a3;
16614
16628
  return __spreadValues({
16615
16629
  branch: __spreadProps(__spreadValues({}, br), { color: BRANCH_COLORS[bi % BRANCH_COLORS.length], _gid: `${bNodeId}-b${bi}` })
16616
- }, layoutGraph((_a2 = br.steps) != null ? _a2 : [], 0, 0, `${bNodeId}/b${bi}/`));
16630
+ }, layoutGraph((_a3 = br.steps) != null ? _a3 : [], 0, 0, `${bNodeId}/b${bi}/`));
16617
16631
  });
16618
16632
  let bTotalW = branchResults.reduce((sum, r) => sum + r.totalW + GAP_X, 0) - GAP_X;
16619
16633
  if (!Number.isFinite(bTotalW) || bTotalW <= 0) bTotalW = NODE_W;
@@ -16769,10 +16783,10 @@ var ellipsis = {
16769
16783
  display: "block"
16770
16784
  };
16771
16785
  function PipelinePreviewResolver(p) {
16772
- var _a, _b, _c, _d, _e, _f, _g;
16786
+ var _a2, _b, _c, _d, _e, _f, _g;
16773
16787
  const { MUTED: MUTED2, PAPER: PAPER2, BORDER: BORDER4, ACCENT: ACCENT2, ACCENT_SOFT: ACCENT_SOFT2 } = useTheme();
16774
16788
  const [btnHovered, setBtnHovered] = useState(false);
16775
- const stateCfg = STATE_CONFIG[(_a = p.state) != null ? _a : "draft"];
16789
+ const stateCfg = STATE_CONFIG[(_a2 = p.state) != null ? _a2 : "draft"];
16776
16790
  const destinations = (_b = p.destinations) != null ? _b : [];
16777
16791
  const steps = (_c = p.steps) != null ? _c : [];
16778
16792
  const workstreams = (_d = p.workstreams) != null ? _d : [];
@@ -17177,6 +17191,7 @@ var STATUS_COLORS3 = {
17177
17191
  // filled from theme ACCENT at render time
17178
17192
  review: "#f59e0b",
17179
17193
  pending: "#9ca3af",
17194
+ blocked: "#b45309",
17180
17195
  failed: "#dc2626"
17181
17196
  };
17182
17197
  var STATUS_LABELS = {
@@ -17184,6 +17199,7 @@ var STATUS_LABELS = {
17184
17199
  active: "In progress",
17185
17200
  review: "In review",
17186
17201
  pending: "Pending",
17202
+ blocked: "Blocked",
17187
17203
  failed: "Failed"
17188
17204
  };
17189
17205
  var HUMAN_PALETTE = ["#2563eb", "#0f766e", "#7c3aed", "#b45309", "#be185d", "#4d7c0f"];
@@ -17193,10 +17209,10 @@ function hashColor(name) {
17193
17209
  return HUMAN_PALETTE[Math.abs(h) % HUMAN_PALETTE.length];
17194
17210
  }
17195
17211
  function initialsOf(a) {
17196
- var _a, _b, _c, _d;
17212
+ var _a2, _b, _c, _d;
17197
17213
  if (a.initials) return a.initials.slice(0, 2).toUpperCase();
17198
17214
  const parts = a.name.trim().split(/\s+/);
17199
- return (((_b = (_a = parts[0]) == null ? void 0 : _a[0]) != null ? _b : "") + ((_d = (_c = parts[1]) == null ? void 0 : _c[0]) != null ? _d : "")).toUpperCase() || "?";
17215
+ return (((_b = (_a2 = parts[0]) == null ? void 0 : _a2[0]) != null ? _b : "") + ((_d = (_c = parts[1]) == null ? void 0 : _c[0]) != null ? _d : "")).toUpperCase() || "?";
17200
17216
  }
17201
17217
  function SparkMark({ size, color }) {
17202
17218
  return /* @__PURE__ */ jsx("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx(
@@ -17264,8 +17280,8 @@ function AvatarStack({ assignees, accent }) {
17264
17280
  ] });
17265
17281
  }
17266
17282
  function IndexDot({ step, index, accent }) {
17267
- var _a;
17268
- const n = (_a = step.n) != null ? _a : index + 1;
17283
+ var _a2;
17284
+ const n = (_a2 = step.n) != null ? _a2 : index + 1;
17269
17285
  const base = {
17270
17286
  width: 18,
17271
17287
  height: 18,
@@ -17301,8 +17317,8 @@ function useContainerWidth(ref) {
17301
17317
  const el = ref.current;
17302
17318
  if (!el || typeof ResizeObserver === "undefined") return;
17303
17319
  const ro = new ResizeObserver((entries) => {
17304
- var _a;
17305
- const cr = (_a = entries[0]) == null ? void 0 : _a.contentRect;
17320
+ var _a2;
17321
+ const cr = (_a2 = entries[0]) == null ? void 0 : _a2.contentRect;
17306
17322
  if (cr) setW(cr.width);
17307
17323
  });
17308
17324
  ro.observe(el);
@@ -17391,9 +17407,9 @@ function WorkflowStepperRenderer({
17391
17407
  loadingSteps = 6,
17392
17408
  showProgress = true
17393
17409
  }) {
17394
- var _a, _b, _c, _d, _e, _f;
17410
+ var _a2, _b, _c, _d, _e, _f;
17395
17411
  const { BORDER: BORDER4, MUTED: MUTED2, ACCENT: ACCENT2 } = useTheme();
17396
- const steps = (_a = data.steps) != null ? _a : [];
17412
+ const steps = (_a2 = data.steps) != null ? _a2 : [];
17397
17413
  const activeStepId = (_d = (_c = data.active_step) != null ? _c : (_b = steps.find((s) => s.status === "active")) == null ? void 0 : _b.id) != null ? _d : null;
17398
17414
  const interactive = typeof onSelectStep === "function";
17399
17415
  const statusColor3 = (s) => s === "active" ? ACCENT2 : STATUS_COLORS3[s];
@@ -17621,13 +17637,13 @@ function WorkflowStepperRenderer({
17621
17637
  .wfs-scroller:hover::-webkit-scrollbar-thumb{background:#aab2c2;background-clip:padding-box}
17622
17638
  ` }),
17623
17639
  steps.map((step, i) => {
17624
- var _a2;
17640
+ var _a3;
17625
17641
  const isSelected = selectedStep === step.id;
17626
17642
  const isActive = step.status === "active";
17627
17643
  const reached = step.status !== "pending";
17628
17644
  const clickable = interactive && reached;
17629
17645
  const color = statusColor3(step.status);
17630
- const humans = ((_a2 = step.assignees) != null ? _a2 : []).filter((a) => a.kind === "human");
17646
+ const humans = ((_a3 = step.assignees) != null ? _a3 : []).filter((a) => a.kind === "human");
17631
17647
  const roleCaption = humans.map((h) => h.role).filter(Boolean).slice(0, 2).join(" \xB7 ");
17632
17648
  return /* @__PURE__ */ jsxs(React41.Fragment, { children: [
17633
17649
  i > 0 && /* @__PURE__ */ jsx(
@@ -17824,9 +17840,9 @@ function WorkflowStepperRenderer({
17824
17840
  ] });
17825
17841
  }
17826
17842
  function WorkflowStepperResolver(p) {
17827
- var _a;
17843
+ var _a2;
17828
17844
  const { selectedStepId, onStepSelect } = useGenUIInteraction();
17829
- return /* @__PURE__ */ jsx(ComponentActions, { filename: (_a = p.title) != null ? _a : "workflow-stepper", children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: 10 }, children: [
17845
+ return /* @__PURE__ */ jsx(ComponentActions, { filename: (_a2 = p.title) != null ? _a2 : "workflow-stepper", children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: 10 }, children: [
17830
17846
  /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8, flexWrap: "wrap" }, children: [
17831
17847
  /* @__PURE__ */ jsx(
17832
17848
  "p",
@@ -18061,12 +18077,57 @@ var BUILDER_FIELD_TYPES = [
18061
18077
  "multi_select",
18062
18078
  "date",
18063
18079
  "checkbox",
18064
- "file_upload"
18080
+ "file_upload",
18081
+ // Server-backed search-as-you-type combobox. Unlike `select` (static
18082
+ // `options`), it queries an allowlisted `source` via host-injected callbacks
18083
+ // (onEntitySearch/onEntityCreate) and can create a new record inline.
18084
+ "entity_picker",
18085
+ // Assign a set of files to role categories (grouped cards + inline Move).
18086
+ // Self-contained: candidate files + AI suggestions ride the `file_map` config
18087
+ // in the payload (no host callback). Submitted value = {category_id:[path]}.
18088
+ "file_map"
18065
18089
  ];
18066
18090
  var builderFieldOptionSchema = z.object({
18067
18091
  value: z.string(),
18068
18092
  label: z.string()
18069
18093
  });
18094
+ z.object({
18095
+ value: z.string(),
18096
+ label: z.string(),
18097
+ description: z.string().optional().nullable(),
18098
+ meta: z.string().optional().nullable()
18099
+ });
18100
+ var entityCreateFieldSchema = z.object({
18101
+ name: z.string(),
18102
+ label: z.string(),
18103
+ field_type: z.enum(["text", "textarea", "number", "date", "checkbox", "select"]).optional().default("text"),
18104
+ required: z.boolean().optional().default(false),
18105
+ placeholder: z.string().optional().default(""),
18106
+ options: z.array(builderFieldOptionSchema).optional().nullable()
18107
+ });
18108
+ var fileMapCategorySchema = z.object({
18109
+ id: z.string(),
18110
+ label: z.string(),
18111
+ hint: z.string().optional().nullable()
18112
+ });
18113
+ var fileMapFileSchema = z.object({
18114
+ path: z.string(),
18115
+ name: z.string().optional().nullable(),
18116
+ type: z.string().optional().nullable(),
18117
+ // ext, e.g. "csv"
18118
+ size: z.string().optional().nullable()
18119
+ // pre-formatted, e.g. "600 B"
18120
+ });
18121
+ var fileMapConfigSchema = z.object({
18122
+ categories: z.array(fileMapCategorySchema).min(1),
18123
+ files: z.array(fileMapFileSchema),
18124
+ /** AI seed: {category_id: [file_path]}. */
18125
+ suggestions: z.record(z.string(), z.array(z.string())).optional().nullable(),
18126
+ /** {file_path: HIGH|MEDIUM|LOW} for the suggested rows. */
18127
+ confidence: z.record(z.string(), z.enum(["HIGH", "MEDIUM", "LOW"])).optional().nullable(),
18128
+ /** Allow files to stay unassigned (default true). */
18129
+ allow_unassigned: z.boolean().optional().default(true)
18130
+ });
18070
18131
  var builderFieldValidationSchema = z.object({
18071
18132
  min: z.number().optional(),
18072
18133
  max: z.number().optional(),
@@ -18083,7 +18144,17 @@ var builderFieldSchema = z.object({
18083
18144
  description: z.string().optional().default(""),
18084
18145
  options: z.array(builderFieldOptionSchema).optional().nullable(),
18085
18146
  default_value: z.any().optional().nullable(),
18086
- validation: builderFieldValidationSchema.nullable()
18147
+ validation: builderFieldValidationSchema.nullable(),
18148
+ // --- entity_picker config (ignored by other field types) ---
18149
+ /** Allowlisted entity source the host knows how to search/create, e.g.
18150
+ * "workstreams". NOT a raw URL — the host maps it to a real endpoint. */
18151
+ source: z.string().optional().nullable(),
18152
+ /** Show the inline "Create new …" affordance (host still enforces perms). */
18153
+ allow_create: z.boolean().optional().default(false),
18154
+ /** Fields for the inline create sub-form (defaults to a single `name`). */
18155
+ create_fields: z.array(entityCreateFieldSchema).optional().nullable(),
18156
+ // --- file_map config (ignored by other field types) ---
18157
+ file_map: fileMapConfigSchema.optional().nullable()
18087
18158
  });
18088
18159
  var builderBlockSchema = z.object({
18089
18160
  id: z.string(),
@@ -18114,7 +18185,7 @@ function validateBuilderPayload(data) {
18114
18185
  };
18115
18186
  }
18116
18187
 
18117
- // src/builders/FormBuilder.tsx
18188
+ // src/builders/BlockForm.tsx
18118
18189
  init_ThemeContext();
18119
18190
 
18120
18191
  // src/builders/FieldRenderer.tsx
@@ -18169,7 +18240,7 @@ function TextAreaField({ field, value, onChange, disabled, error }) {
18169
18240
  );
18170
18241
  }
18171
18242
  function NumberField({ field, value, onChange, disabled, error }) {
18172
- var _a, _b;
18243
+ var _a2, _b;
18173
18244
  const base = useInputBase();
18174
18245
  return /* @__PURE__ */ jsx(
18175
18246
  "input",
@@ -18182,7 +18253,7 @@ function NumberField({ field, value, onChange, disabled, error }) {
18182
18253
  },
18183
18254
  placeholder: field.placeholder || "",
18184
18255
  disabled,
18185
- min: (_a = field.validation) == null ? void 0 : _a.min,
18256
+ min: (_a2 = field.validation) == null ? void 0 : _a2.min,
18186
18257
  max: (_b = field.validation) == null ? void 0 : _b.max,
18187
18258
  style: error ? __spreadValues(__spreadValues({}, base), INPUT_ERROR) : base
18188
18259
  }
@@ -18328,9 +18399,9 @@ function FileUploadField({ field, value, onChange, disabled, onFileUpload, error
18328
18399
  const [entries, setEntries] = useState(() => {
18329
18400
  const arr = Array.isArray(value) ? value : value && typeof value === "object" ? [value] : [];
18330
18401
  return arr.map((item) => {
18331
- var _a, _b;
18402
+ var _a2, _b;
18332
18403
  const r = item;
18333
- return { key: keyRef.current += 1, name: (_b = (_a = r.filename) != null ? _a : r.name) != null ? _b : "file", size: r.size, status: "done", result: r };
18404
+ return { key: keyRef.current += 1, name: (_b = (_a2 = r.filename) != null ? _a2 : r.name) != null ? _b : "file", size: r.size, status: "done", result: r };
18334
18405
  });
18335
18406
  });
18336
18407
  const entriesRef = React41.useRef(entries);
@@ -18364,19 +18435,19 @@ function FileUploadField({ field, value, onChange, disabled, onFileUpload, error
18364
18435
  });
18365
18436
  };
18366
18437
  const handleInput = (e) => {
18367
- var _a;
18368
- addFiles(Array.from((_a = e.target.files) != null ? _a : []));
18438
+ var _a2;
18439
+ addFiles(Array.from((_a2 = e.target.files) != null ? _a2 : []));
18369
18440
  if (inputRef.current) inputRef.current.value = "";
18370
18441
  };
18371
18442
  const handleDrop = (e) => {
18372
- var _a;
18443
+ var _a2;
18373
18444
  e.preventDefault();
18374
18445
  setDragOver(false);
18375
- addFiles(Array.from((_a = e.dataTransfer.files) != null ? _a : []));
18446
+ addFiles(Array.from((_a2 = e.dataTransfer.files) != null ? _a2 : []));
18376
18447
  };
18377
18448
  const openPicker = () => {
18378
- var _a;
18379
- if (interactive) (_a = inputRef.current) == null ? void 0 : _a.click();
18449
+ var _a2;
18450
+ if (interactive) (_a2 = inputRef.current) == null ? void 0 : _a2.click();
18380
18451
  };
18381
18452
  const removeEntry = (key) => commit(entriesRef.current.filter((e) => e.key !== key));
18382
18453
  const borderColor = dragOver ? ACCENT2 : error ? "#dc2626" : BORDER4;
@@ -18453,107 +18524,614 @@ function FileUploadField({ field, value, onChange, disabled, onFileUpload, error
18453
18524
  })
18454
18525
  ] });
18455
18526
  }
18456
- var FIELD_REGISTRY = {
18457
- text: TextField,
18458
- textarea: TextAreaField,
18459
- number: NumberField,
18460
- select: SelectField,
18461
- multi_select: MultiSelectField,
18462
- date: DateField,
18463
- checkbox: CheckboxField,
18464
- file_upload: FileUploadField
18465
- };
18466
- function FieldRenderer({ field, value, onChange, disabled, error, onFileUpload, dense }) {
18467
- const { MUTED: MUTED2 } = useTheme();
18468
- const FieldComp = FIELD_REGISTRY[field.field_type] || FIELD_REGISTRY.text;
18469
- return /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "3px" }, children: [
18470
- field.field_type !== "checkbox" && /* @__PURE__ */ jsxs("label", { style: { fontSize: "12px", fontWeight: 600, color: "var(--foreground)", letterSpacing: "0.01em" }, children: [
18471
- field.label,
18472
- field.required && /* @__PURE__ */ jsx("span", { style: { color: "#dc2626", marginLeft: "2px" }, children: "*" })
18473
- ] }),
18474
- field.description && !dense && /* @__PURE__ */ jsx("div", { style: { fontSize: "11px", color: MUTED2, lineHeight: 1.4 }, children: field.description }),
18475
- /* @__PURE__ */ jsx(FieldComp, { field, value, onChange, disabled, error, dense, onFileUpload: field.field_type === "file_upload" ? onFileUpload : void 0 }),
18476
- error && /* @__PURE__ */ jsx("div", { style: { fontSize: "11px", color: "#dc2626", fontWeight: 500, marginTop: "1px" }, children: error })
18527
+ function highlightMatch(label, q, accent) {
18528
+ const query = q.trim();
18529
+ if (!query) return label;
18530
+ const i = label.toLowerCase().indexOf(query.toLowerCase());
18531
+ if (i < 0) return label;
18532
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
18533
+ label.slice(0, i),
18534
+ /* @__PURE__ */ jsx("span", { style: { fontWeight: 700, color: accent }, children: label.slice(i, i + query.length) }),
18535
+ label.slice(i + query.length)
18477
18536
  ] });
18478
18537
  }
18479
- var SlotErrorBoundary = class extends React41.Component {
18480
- constructor(props) {
18481
- super(props);
18482
- this.state = { hasError: false };
18483
- }
18484
- static getDerivedStateFromError() {
18485
- return { hasError: true };
18486
- }
18487
- render() {
18488
- if (this.state.hasError) return null;
18489
- return this.props.children;
18490
- }
18491
- };
18492
- function ContextSlot({ payload }) {
18493
- if (!payload || typeof payload.type !== "string") return null;
18494
- return /* @__PURE__ */ jsx("div", { style: S2.slot, children: /* @__PURE__ */ jsx(SlotErrorBoundary, { children: resolveUI(payload) }) });
18495
- }
18496
- var S2 = {
18497
- slot: {
18498
- marginBottom: "8px",
18499
- borderRadius: "0.5rem",
18500
- overflow: "hidden"
18501
- }
18502
- };
18503
-
18504
- // src/builders/BuilderRecap.tsx
18505
- init_ThemeContext();
18506
- function BuilderRecap({ builder, state }) {
18507
- const t = useTheme();
18508
- const blocks = builder.blocks || [];
18509
- const display = (field, value) => {
18510
- if (value == null || value === "") return "";
18511
- const opt = (v) => {
18512
- var _a, _b, _c;
18513
- return (_c = (_b = (_a = field.options) == null ? void 0 : _a.find((o) => o.value === v)) == null ? void 0 : _b.label) != null ? _c : String(v);
18538
+ function EntityPickerField({ field, value, onChange, disabled, error, onEntitySearch, onEntityCreate }) {
18539
+ const { BORDER: BORDER4, MUTED: MUTED2, ACCENT: ACCENT2, PAPER: PAPER2 } = useTheme();
18540
+ const base = useInputBase();
18541
+ const source = field.source || "";
18542
+ const [open, setOpen] = useState(false);
18543
+ const [query, setQuery] = useState("");
18544
+ const [results, setResults] = useState([]);
18545
+ const [loading, setLoading] = useState(false);
18546
+ const [err, setErr] = useState(null);
18547
+ const [hi, setHi] = useState(0);
18548
+ const [selectedLabel, setSelectedLabel] = useState(null);
18549
+ const [creating, setCreating] = useState(false);
18550
+ const [createVals, setCreateVals] = useState({});
18551
+ const [createBusy, setCreateBusy] = useState(false);
18552
+ const boxRef = useRef(null);
18553
+ const seq = useRef(0);
18554
+ const allowCreate = !!field.allow_create && !!onEntityCreate;
18555
+ const createFields = useMemo(
18556
+ () => field.create_fields && field.create_fields.length ? field.create_fields : [{ name: "name", label: "Name", field_type: "text", required: true, placeholder: "" }],
18557
+ [field.create_fields]
18558
+ );
18559
+ const runSearch = useCallback(
18560
+ (q) => {
18561
+ if (!onEntitySearch || !source) return;
18562
+ const my = ++seq.current;
18563
+ setLoading(true);
18564
+ setErr(null);
18565
+ onEntitySearch(source, q).then((rows) => {
18566
+ if (my === seq.current) {
18567
+ setResults(rows || []);
18568
+ setHi(0);
18569
+ }
18570
+ }).catch(() => {
18571
+ if (my === seq.current) {
18572
+ setErr("Search failed \u2014 try again");
18573
+ setResults([]);
18574
+ }
18575
+ }).finally(() => {
18576
+ if (my === seq.current) setLoading(false);
18577
+ });
18578
+ },
18579
+ [onEntitySearch, source]
18580
+ );
18581
+ useEffect(() => {
18582
+ if (!open || creating) return;
18583
+ const id = setTimeout(() => runSearch(query), 200);
18584
+ return () => clearTimeout(id);
18585
+ }, [open, creating, query, runSearch]);
18586
+ useEffect(() => {
18587
+ if (!open) return;
18588
+ const onDoc = (e) => {
18589
+ if (boxRef.current && !boxRef.current.contains(e.target)) {
18590
+ setOpen(false);
18591
+ setCreating(false);
18592
+ }
18514
18593
  };
18515
- if (field.field_type === "multi_select" && Array.isArray(value)) return value.map(opt).join(", ");
18516
- if (field.field_type === "select") return opt(value);
18517
- if (field.field_type === "checkbox") return value ? "Yes" : "No";
18518
- if (field.field_type === "file_upload") {
18519
- const files = Array.isArray(value) ? value : [value];
18520
- return files.map((x) => x && typeof x === "object" ? x.filename || x.name || "file" : String(x)).join(", ");
18521
- }
18522
- return String(value);
18594
+ document.addEventListener("mousedown", onDoc);
18595
+ return () => document.removeEventListener("mousedown", onDoc);
18596
+ }, [open]);
18597
+ const openMenu = () => {
18598
+ if (disabled) return;
18599
+ setOpen(true);
18523
18600
  };
18524
- const decisionField = (b) => (b.fields || []).find((f) => f.field_type === "select") || (b.fields || [])[0];
18525
- const rows = useMemo(
18526
- () => blocks.map((b) => {
18527
- const df = decisionField(b);
18528
- const decision = df ? display(df, state.getValue(b.id, df.name)) : "";
18529
- const extras = (b.fields || []).filter((f) => f !== df).map((f) => ({ label: f.label, value: display(f, state.getValue(b.id, f.name)) })).filter((x) => x.value);
18530
- return { id: b.id, title: b.title, decision, extras };
18531
- }),
18532
- // eslint-disable-next-line react-hooks/exhaustive-deps
18533
- [blocks, state.values]
18534
- );
18535
- const counts = useMemo(() => {
18536
- const m = /* @__PURE__ */ new Map();
18537
- for (const r of rows) {
18538
- const k = r.decision || "\u2014";
18539
- m.set(k, (m.get(k) || 0) + 1);
18601
+ const select = useCallback((opt) => {
18602
+ onChange({ value: opt.value, label: opt.label });
18603
+ setSelectedLabel(opt.label);
18604
+ setQuery("");
18605
+ setOpen(false);
18606
+ setCreating(false);
18607
+ }, [onChange]);
18608
+ const nameField = createFields.find((f) => {
18609
+ var _a2;
18610
+ return ((_a2 = f.field_type) != null ? _a2 : "text") === "text";
18611
+ }) || createFields[0];
18612
+ const otherRequired = createFields.filter((f) => f !== nameField && f.required);
18613
+ const showCreateRow = allowCreate && !creating && query.trim().length > 0;
18614
+ const totalRows = results.length + (showCreateRow ? 1 : 0);
18615
+ const beginCreate = useCallback(() => {
18616
+ const init = {};
18617
+ if (nameField && query.trim()) init[nameField.name] = query.trim();
18618
+ setCreateVals(init);
18619
+ setErr(null);
18620
+ setCreating(true);
18621
+ }, [nameField, query]);
18622
+ const submitCreate = useCallback((vals) => {
18623
+ if (!onEntityCreate || !source) return;
18624
+ const payload = vals || createVals;
18625
+ for (const f of createFields) {
18626
+ if (f.required && (payload[f.name] == null || payload[f.name] === "")) {
18627
+ setErr(`${f.label} is required`);
18628
+ return;
18629
+ }
18540
18630
  }
18541
- return Array.from(m.entries());
18542
- }, [rows]);
18543
- const pill = (label) => {
18544
- const l = label.toLowerCase();
18545
- let fg = t.MUTED, bg = "#f2f2f2";
18546
- if (/accept|approve|confirm|keep|yes/.test(l)) {
18547
- fg = "#15803d";
18548
- bg = "#dcfce7";
18549
- } else if (/exclud|reject|remove|delete|deny|no\b/.test(l)) {
18550
- fg = "#dc2626";
18551
- bg = "#fef2f2";
18552
- } else if (/reclass|change|edit|modif|review|other/.test(l)) {
18553
- fg = t.SECONDARY;
18554
- bg = "#e8f0fe";
18631
+ setCreateBusy(true);
18632
+ setErr(null);
18633
+ onEntityCreate(source, payload).then((opt) => select(opt)).catch(() => setErr("Couldn't create \u2014 you may not have permission")).finally(() => setCreateBusy(false));
18634
+ }, [onEntityCreate, source, createFields, createVals, select]);
18635
+ const handleCreateRow = useCallback(() => {
18636
+ const q = query.trim();
18637
+ if (!q || !nameField) return;
18638
+ if (otherRequired.length === 0) {
18639
+ submitCreate({ [nameField.name]: q });
18640
+ } else {
18641
+ beginCreate();
18642
+ }
18643
+ }, [query, nameField, otherRequired, submitCreate, beginCreate]);
18644
+ const onKeyDown = (e) => {
18645
+ if (creating) return;
18646
+ if (!open) {
18647
+ if (e.key === "ArrowDown" || e.key === "Enter") {
18648
+ openMenu();
18649
+ e.preventDefault();
18650
+ }
18651
+ return;
18652
+ }
18653
+ if (e.key === "ArrowDown") {
18654
+ setHi((h) => Math.min(h + 1, Math.max(totalRows - 1, 0)));
18655
+ e.preventDefault();
18656
+ } else if (e.key === "ArrowUp") {
18657
+ setHi((h) => Math.max(h - 1, 0));
18658
+ e.preventDefault();
18659
+ } else if (e.key === "Enter") {
18660
+ e.preventDefault();
18661
+ if (hi < results.length) select(results[hi]);
18662
+ else if (showCreateRow) handleCreateRow();
18663
+ } else if (e.key === "Escape") {
18664
+ setOpen(false);
18555
18665
  }
18556
- return { fg, bg };
18666
+ };
18667
+ const selectedObj = value && typeof value === "object" ? value : null;
18668
+ const displayValue = selectedObj ? selectedObj.label || selectedObj.value : value ? selectedLabel != null ? selectedLabel : String(value) : "";
18669
+ const inputStyle = error ? __spreadValues(__spreadValues({}, base), INPUT_ERROR) : base;
18670
+ const rowStyle = (active) => ({
18671
+ display: "flex",
18672
+ flexDirection: "column",
18673
+ gap: "1px",
18674
+ padding: "8px 11px",
18675
+ cursor: "pointer",
18676
+ boxSizing: "border-box",
18677
+ background: active ? `${ACCENT2}0d` : "white",
18678
+ borderLeft: `2px solid ${active ? ACCENT2 : "transparent"}`
18679
+ });
18680
+ return /* @__PURE__ */ jsxs("div", { ref: boxRef, style: { position: "relative" }, children: [
18681
+ /* @__PURE__ */ jsx(
18682
+ "input",
18683
+ {
18684
+ type: "text",
18685
+ role: "combobox",
18686
+ "aria-expanded": open,
18687
+ "aria-autocomplete": "list",
18688
+ value: open ? query : displayValue,
18689
+ placeholder: field.placeholder || "Search\u2026",
18690
+ disabled,
18691
+ onFocus: openMenu,
18692
+ onChange: (e) => {
18693
+ setQuery(e.target.value);
18694
+ if (!open) setOpen(true);
18695
+ },
18696
+ onKeyDown,
18697
+ style: inputStyle
18698
+ }
18699
+ ),
18700
+ open && /* @__PURE__ */ jsx(
18701
+ "div",
18702
+ {
18703
+ role: "listbox",
18704
+ style: {
18705
+ position: "absolute",
18706
+ zIndex: 30,
18707
+ top: "calc(100% + 4px)",
18708
+ left: 0,
18709
+ right: 0,
18710
+ background: "white",
18711
+ border: `1px solid ${BORDER4}`,
18712
+ borderRadius: "0.625rem",
18713
+ boxShadow: "0 4px 16px rgba(0,0,0,0.10)",
18714
+ overflow: "hidden",
18715
+ maxHeight: "280px",
18716
+ overflowY: "auto"
18717
+ },
18718
+ children: creating ? /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "9px", padding: "12px" }, children: [
18719
+ /* @__PURE__ */ jsx("div", { style: { fontSize: "12px", fontWeight: 600, color: "var(--foreground)" }, children: "Create new" }),
18720
+ createFields.map((f) => {
18721
+ var _a2, _b, _c, _d, _e;
18722
+ return /* @__PURE__ */ jsxs("label", { style: { display: "flex", flexDirection: "column", gap: "3px" }, children: [
18723
+ /* @__PURE__ */ jsxs("span", { style: { fontSize: "11.5px", fontWeight: 600, color: "var(--foreground)" }, children: [
18724
+ f.label,
18725
+ f.required && /* @__PURE__ */ jsx("span", { style: { color: "#dc2626", marginLeft: "2px" }, children: "*" })
18726
+ ] }),
18727
+ ((_a2 = f.field_type) != null ? _a2 : "text") === "textarea" ? /* @__PURE__ */ jsx(
18728
+ "textarea",
18729
+ {
18730
+ value: (_b = createVals[f.name]) != null ? _b : "",
18731
+ placeholder: f.placeholder || "",
18732
+ onChange: (e) => setCreateVals((p) => __spreadProps(__spreadValues({}, p), { [f.name]: e.target.value })),
18733
+ rows: 3,
18734
+ style: __spreadProps(__spreadValues({}, base), { resize: "vertical" })
18735
+ }
18736
+ ) : /* @__PURE__ */ jsx(
18737
+ "input",
18738
+ {
18739
+ type: ((_c = f.field_type) != null ? _c : "text") === "number" ? "number" : ((_d = f.field_type) != null ? _d : "text") === "date" ? "date" : "text",
18740
+ value: (_e = createVals[f.name]) != null ? _e : "",
18741
+ placeholder: f.placeholder || "",
18742
+ onChange: (e) => setCreateVals((p) => __spreadProps(__spreadValues({}, p), { [f.name]: e.target.value })),
18743
+ style: base
18744
+ }
18745
+ )
18746
+ ] }, f.name);
18747
+ }),
18748
+ err && /* @__PURE__ */ jsx("div", { style: { fontSize: "11px", color: "#dc2626", fontWeight: 500 }, children: err }),
18749
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: "8px", justifyContent: "flex-end" }, children: [
18750
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: () => {
18751
+ setCreating(false);
18752
+ setErr(null);
18753
+ }, style: { font: "inherit", fontSize: "12px", fontWeight: 600, color: MUTED2, background: "transparent", border: `1px solid ${BORDER4}`, borderRadius: "9999px", padding: "5px 13px", cursor: "pointer" }, children: "Cancel" }),
18754
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: () => submitCreate(), disabled: createBusy, style: { font: "inherit", fontSize: "12px", fontWeight: 600, color: "white", background: ACCENT2, border: "none", borderRadius: "9999px", padding: "5px 15px", cursor: "pointer", opacity: createBusy ? 0.6 : 1 }, children: createBusy ? "Creating\u2026" : "Create" })
18755
+ ] })
18756
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
18757
+ loading && /* @__PURE__ */ jsxs("div", { style: { padding: "10px 11px", fontSize: "12px", color: MUTED2, display: "flex", alignItems: "center", gap: "8px" }, children: [
18758
+ /* @__PURE__ */ jsx("span", { style: { width: "13px", height: "13px", borderRadius: "50%", border: `2px solid ${ACCENT2}33`, borderTopColor: ACCENT2, animation: "genuiSpin 0.7s linear infinite" }, "aria-hidden": "true" }),
18759
+ "Searching\u2026"
18760
+ ] }),
18761
+ !loading && err && /* @__PURE__ */ jsx("div", { style: { padding: "10px 11px", fontSize: "12px", color: "#dc2626" }, children: err }),
18762
+ !loading && !err && results.length === 0 && !showCreateRow && /* @__PURE__ */ jsxs("div", { style: { padding: "10px 11px", fontSize: "12px", color: MUTED2 }, children: [
18763
+ "No matches",
18764
+ query ? ` for \u201C${query}\u201D` : "",
18765
+ "."
18766
+ ] }),
18767
+ !loading && results.map((opt, idx) => /* @__PURE__ */ jsxs(
18768
+ "div",
18769
+ {
18770
+ role: "option",
18771
+ "aria-selected": hi === idx,
18772
+ onMouseEnter: () => setHi(idx),
18773
+ onMouseDown: (e) => {
18774
+ e.preventDefault();
18775
+ select(opt);
18776
+ },
18777
+ style: rowStyle(hi === idx),
18778
+ children: [
18779
+ /* @__PURE__ */ jsx("span", { style: { fontSize: "13px", color: "var(--foreground)" }, children: highlightMatch(opt.label, query, ACCENT2) }),
18780
+ (opt.description || opt.meta) && /* @__PURE__ */ jsx("span", { style: { fontSize: "11px", color: MUTED2, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: [opt.description, opt.meta].filter(Boolean).join(" \xB7 ") })
18781
+ ]
18782
+ },
18783
+ opt.value
18784
+ )),
18785
+ showCreateRow && /* @__PURE__ */ jsxs(
18786
+ "div",
18787
+ {
18788
+ role: "option",
18789
+ "aria-selected": hi === results.length,
18790
+ onMouseEnter: () => setHi(results.length),
18791
+ onMouseDown: (e) => {
18792
+ e.preventDefault();
18793
+ handleCreateRow();
18794
+ },
18795
+ style: __spreadProps(__spreadValues({}, rowStyle(hi === results.length)), { borderTop: results.length ? `1px solid ${BORDER4}` : "none", flexDirection: "row", alignItems: "center", gap: "7px", background: hi === results.length ? `${ACCENT2}0d` : PAPER2, opacity: createBusy ? 0.6 : 1, cursor: createBusy ? "default" : "pointer" }),
18796
+ children: [
18797
+ /* @__PURE__ */ jsx("span", { style: { fontSize: "15px", lineHeight: 1, color: ACCENT2, fontWeight: 700 }, children: "\uFF0B" }),
18798
+ /* @__PURE__ */ jsx("span", { style: { fontSize: "12.5px", fontWeight: 600, color: ACCENT2 }, children: createBusy ? `Creating \u201C${query.trim()}\u201D\u2026` : `Create \u201C${query.trim()}\u201D as a new ${source.replace(/s$/, "")}` })
18799
+ ]
18800
+ }
18801
+ )
18802
+ ] })
18803
+ }
18804
+ )
18805
+ ] });
18806
+ }
18807
+ var _FILEMAP_UNASSIGNED = "unassigned";
18808
+ var _CONF_COLOR = { HIGH: "#15803d", MEDIUM: "#92400e", LOW: "#777777" };
18809
+ function _fileExt(path, type) {
18810
+ if (type) return String(type).toLowerCase();
18811
+ const base = (path || "").split("/").pop() || "";
18812
+ return base.includes(".") ? (base.split(".").pop() || "").toLowerCase() : "";
18813
+ }
18814
+ function FileMapField({ field, value, onChange, disabled }) {
18815
+ const { BORDER: BORDER4, MUTED: MUTED2, ACCENT: ACCENT2, PAPER: PAPER2 } = useTheme();
18816
+ const cfg = field.file_map || null;
18817
+ const categories = useMemo(() => (cfg == null ? void 0 : cfg.categories) || [], [cfg]);
18818
+ const fileList = useMemo(() => (cfg == null ? void 0 : cfg.files) || [], [cfg]);
18819
+ const suggestions = (cfg == null ? void 0 : cfg.suggestions) || {};
18820
+ const confidence = (cfg == null ? void 0 : cfg.confidence) || {};
18821
+ const initial = useMemo(() => {
18822
+ const a = {};
18823
+ if (value && typeof value === "object" && !Array.isArray(value)) {
18824
+ for (const [grp, paths] of Object.entries(value))
18825
+ for (const p of paths || []) a[p] = grp;
18826
+ } else {
18827
+ for (const [cid, paths] of Object.entries(suggestions))
18828
+ for (const p of paths || []) a[p] = cid;
18829
+ }
18830
+ for (const f of fileList) if (!(f.path in a)) a[f.path] = _FILEMAP_UNASSIGNED;
18831
+ return a;
18832
+ }, []);
18833
+ const [assignment, setAssignment] = useState(initial);
18834
+ const [collapsed, setCollapsed] = useState({});
18835
+ const [menuFor, setMenuFor] = useState(null);
18836
+ const boardRef = useRef(null);
18837
+ const fileByPath = useMemo(
18838
+ () => Object.fromEntries(fileList.map((f) => [f.path, f])),
18839
+ [fileList]
18840
+ );
18841
+ const groupFrom = useCallback((a) => {
18842
+ const g = { [_FILEMAP_UNASSIGNED]: [] };
18843
+ for (const c of categories) g[c.id] = [];
18844
+ for (const f of fileList) {
18845
+ const grp = a[f.path] || _FILEMAP_UNASSIGNED;
18846
+ if (!g[grp]) g[grp] = [];
18847
+ g[grp].push(f.path);
18848
+ }
18849
+ return g;
18850
+ }, [categories, fileList]);
18851
+ const grouped = useMemo(() => groupFrom(assignment), [assignment, groupFrom]);
18852
+ const emit = useCallback((g) => onChange(g), [onChange]);
18853
+ const emittedRef = useRef(false);
18854
+ useEffect(() => {
18855
+ if (!emittedRef.current) {
18856
+ emittedRef.current = true;
18857
+ emit(grouped);
18858
+ }
18859
+ }, [grouped, emit]);
18860
+ useEffect(() => {
18861
+ if (!menuFor) return;
18862
+ const onDoc = (e) => {
18863
+ if (boardRef.current && !boardRef.current.contains(e.target)) setMenuFor(null);
18864
+ };
18865
+ document.addEventListener("mousedown", onDoc);
18866
+ return () => document.removeEventListener("mousedown", onDoc);
18867
+ }, [menuFor]);
18868
+ const move = useCallback((path, grp) => {
18869
+ setMenuFor(null);
18870
+ setAssignment((prev) => {
18871
+ const next = __spreadProps(__spreadValues({}, prev), { [path]: grp });
18872
+ emit(groupFrom(next));
18873
+ return next;
18874
+ });
18875
+ }, [emit, groupFrom]);
18876
+ const labelOf = (gid) => {
18877
+ var _a2;
18878
+ return gid === _FILEMAP_UNASSIGNED ? "Unassigned" : ((_a2 = categories.find((c) => c.id === gid)) == null ? void 0 : _a2.label) || gid;
18879
+ };
18880
+ const hintOf = (gid) => {
18881
+ var _a2;
18882
+ return gid === _FILEMAP_UNASSIGNED ? null : ((_a2 = categories.find((c) => c.id === gid)) == null ? void 0 : _a2.hint) || null;
18883
+ };
18884
+ const orderedGroups = [_FILEMAP_UNASSIGNED, ...categories.map((c) => c.id)];
18885
+ if (!cfg || categories.length === 0) {
18886
+ return /* @__PURE__ */ jsx("div", { style: { fontSize: "12px", color: MUTED2 }, children: "No file-map configuration." });
18887
+ }
18888
+ const total = fileList.length;
18889
+ const assigned = fileList.filter((f) => (assignment[f.path] || _FILEMAP_UNASSIGNED) !== _FILEMAP_UNASSIGNED).length;
18890
+ const pct = total ? Math.round(assigned / total * 100) : 0;
18891
+ const cards = () => orderedGroups.map((gid) => {
18892
+ const paths = grouped[gid] || [];
18893
+ if (gid === _FILEMAP_UNASSIGNED && paths.length === 0) return null;
18894
+ const isCollapsed = !!collapsed[gid];
18895
+ const hint = hintOf(gid);
18896
+ return /* @__PURE__ */ jsxs("div", { style: { border: `1px solid ${BORDER4}`, borderRadius: "0.75rem", overflow: "visible", background: "white" }, children: [
18897
+ /* @__PURE__ */ jsxs(
18898
+ "button",
18899
+ {
18900
+ type: "button",
18901
+ onClick: () => setCollapsed((c) => __spreadProps(__spreadValues({}, c), { [gid]: !c[gid] })),
18902
+ style: { width: "100%", display: "flex", alignItems: "center", gap: "8px", padding: "8px 11px", background: PAPER2, border: "none", borderBottom: isCollapsed ? "none" : `1px solid ${BORDER4}`, borderTopLeftRadius: "0.75rem", borderTopRightRadius: "0.75rem", cursor: "pointer", textAlign: "left", minWidth: 0 },
18903
+ children: [
18904
+ /* @__PURE__ */ jsx("span", { style: { transition: "transform 0.15s", transform: isCollapsed ? "rotate(-90deg)" : "none", color: MUTED2, fontSize: "10px", flexShrink: 0 }, children: "\u25BE" }),
18905
+ /* @__PURE__ */ jsx("span", { style: { fontSize: "12px", fontWeight: 600, color: gid === _FILEMAP_UNASSIGNED ? MUTED2 : "var(--foreground)", flexShrink: 0 }, children: labelOf(gid) }),
18906
+ /* @__PURE__ */ jsxs("span", { style: { fontSize: "11px", color: MUTED2, fontVariantNumeric: "tabular-nums", flexShrink: 0 }, children: [
18907
+ "(",
18908
+ paths.length,
18909
+ ")"
18910
+ ] }),
18911
+ hint && !isCollapsed && /* @__PURE__ */ jsxs("span", { style: { fontSize: "11px", color: MUTED2, marginLeft: "2px", minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: [
18912
+ "\xB7 ",
18913
+ hint
18914
+ ] })
18915
+ ]
18916
+ }
18917
+ ),
18918
+ !isCollapsed && /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column" }, children: paths.length === 0 ? /* @__PURE__ */ jsx("div", { style: { padding: "9px 12px", fontSize: "11px", color: MUTED2, fontStyle: "italic" }, children: "No files \u2014 use Move on a file to assign it here." }) : paths.map((p) => {
18919
+ const f = fileByPath[p] || { name: p };
18920
+ const ext = _fileExt(p, f.type);
18921
+ const conf = confidence[p];
18922
+ const open = menuFor === p;
18923
+ return /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "9px", padding: "8px 11px", borderTop: `1px solid ${BORDER4}`, animation: "agFmFade 0.15s ease", minWidth: 0 }, children: [
18924
+ ext && /* @__PURE__ */ jsx("span", { style: { fontSize: "9px", fontWeight: 700, letterSpacing: "0.04em", color: MUTED2, background: PAPER2, border: `1px solid ${BORDER4}`, borderRadius: "0.3rem", padding: "2px 5px", textTransform: "uppercase", flexShrink: 0 }, children: ext }),
18925
+ /* @__PURE__ */ jsx("span", { style: { fontSize: "12.5px", color: "var(--foreground)", flex: 1, minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: f.name || p }),
18926
+ f.size && /* @__PURE__ */ jsx("span", { style: { fontSize: "11px", color: MUTED2, flexShrink: 0 }, children: f.size }),
18927
+ conf && /* @__PURE__ */ jsx("span", { title: `${conf} confidence`, "aria-label": `${conf} confidence`, style: { width: "8px", height: "8px", borderRadius: "50%", background: _CONF_COLOR[conf] || MUTED2, flexShrink: 0 } }),
18928
+ !disabled && /* @__PURE__ */ jsxs("div", { style: { position: "relative", flexShrink: 0 }, children: [
18929
+ /* @__PURE__ */ jsxs(
18930
+ "button",
18931
+ {
18932
+ type: "button",
18933
+ onMouseDown: (e) => {
18934
+ e.preventDefault();
18935
+ setMenuFor(open ? null : p);
18936
+ },
18937
+ style: { font: "inherit", fontSize: "11px", fontWeight: 600, color: ACCENT2, background: "transparent", border: `1px solid ${BORDER4}`, borderRadius: "9999px", padding: "3px 9px", cursor: "pointer" },
18938
+ children: [
18939
+ gid === _FILEMAP_UNASSIGNED ? "Assign" : "Move",
18940
+ " \u25BE"
18941
+ ]
18942
+ }
18943
+ ),
18944
+ open && /* @__PURE__ */ jsx("div", { role: "listbox", style: { position: "absolute", right: 0, top: "calc(100% + 4px)", zIndex: 30, minWidth: "180px", maxWidth: "min(240px, 80vw)", maxHeight: "240px", overflowY: "auto", background: "white", border: `1px solid ${BORDER4}`, borderRadius: "0.5rem", boxShadow: "0 4px 16px rgba(0,0,0,0.10)" }, children: orderedGroups.filter((t) => t !== gid).map((t) => /* @__PURE__ */ jsx(
18945
+ "button",
18946
+ {
18947
+ type: "button",
18948
+ onMouseDown: (e) => {
18949
+ e.preventDefault();
18950
+ move(p, t);
18951
+ },
18952
+ style: { display: "block", width: "100%", textAlign: "left", font: "inherit", fontSize: "12px", color: t === _FILEMAP_UNASSIGNED ? MUTED2 : "var(--foreground)", background: "white", border: "none", borderBottom: `1px solid ${BORDER4}`, padding: "7px 11px", cursor: "pointer" },
18953
+ children: labelOf(t)
18954
+ },
18955
+ t
18956
+ )) })
18957
+ ] })
18958
+ ] }, p);
18959
+ }) })
18960
+ ] }, gid);
18961
+ });
18962
+ const progressBar = /* @__PURE__ */ jsx("div", { style: { flex: 1, height: "4px", borderRadius: "9999px", background: PAPER2, overflow: "hidden", border: `1px solid ${BORDER4}`, minWidth: 0 }, children: /* @__PURE__ */ jsx("div", { style: { width: `${pct}%`, height: "100%", background: ACCENT2, borderRadius: "9999px", transition: "width 0.25s" } }) });
18963
+ const countLabel = /* @__PURE__ */ jsxs("span", { style: { fontSize: "11px", fontWeight: 600, color: MUTED2, textTransform: "uppercase", letterSpacing: "0.04em", whiteSpace: "nowrap", fontVariantNumeric: "tabular-nums" }, children: [
18964
+ assigned,
18965
+ " of ",
18966
+ total,
18967
+ " mapped"
18968
+ ] });
18969
+ return /* @__PURE__ */ jsxs("div", { ref: boardRef, style: { width: "100%", maxWidth: "100%", boxSizing: "border-box", display: "flex", flexDirection: "column", gap: "8px" }, children: [
18970
+ /* @__PURE__ */ jsx("style", { children: "@keyframes agFmFade{from{opacity:0;transform:translateY(2px)}to{opacity:1;transform:none}}" }),
18971
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "12px" }, children: [
18972
+ countLabel,
18973
+ progressBar
18974
+ ] }),
18975
+ cards()
18976
+ ] });
18977
+ }
18978
+ var FIELD_REGISTRY = {
18979
+ text: TextField,
18980
+ textarea: TextAreaField,
18981
+ number: NumberField,
18982
+ select: SelectField,
18983
+ multi_select: MultiSelectField,
18984
+ date: DateField,
18985
+ checkbox: CheckboxField,
18986
+ file_upload: FileUploadField,
18987
+ entity_picker: EntityPickerField,
18988
+ file_map: FileMapField
18989
+ };
18990
+ function FieldRenderer({ field, value, onChange, disabled, error, onFileUpload, onEntitySearch, onEntityCreate, dense }) {
18991
+ const { MUTED: MUTED2 } = useTheme();
18992
+ const FieldComp = FIELD_REGISTRY[field.field_type] || FIELD_REGISTRY.text;
18993
+ const isEntity = field.field_type === "entity_picker";
18994
+ return /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "3px" }, children: [
18995
+ field.field_type !== "checkbox" && /* @__PURE__ */ jsxs("label", { style: { fontSize: "12px", fontWeight: 600, color: "var(--foreground)", letterSpacing: "0.01em" }, children: [
18996
+ field.label,
18997
+ field.required && /* @__PURE__ */ jsx("span", { style: { color: "#dc2626", marginLeft: "2px" }, children: "*" })
18998
+ ] }),
18999
+ field.description && !dense && /* @__PURE__ */ jsx("div", { style: { fontSize: "11px", color: MUTED2, lineHeight: 1.4 }, children: field.description }),
19000
+ /* @__PURE__ */ jsx(
19001
+ FieldComp,
19002
+ {
19003
+ field,
19004
+ value,
19005
+ onChange,
19006
+ disabled,
19007
+ error,
19008
+ dense,
19009
+ onFileUpload: field.field_type === "file_upload" ? onFileUpload : void 0,
19010
+ onEntitySearch: isEntity ? onEntitySearch : void 0,
19011
+ onEntityCreate: isEntity ? onEntityCreate : void 0
19012
+ }
19013
+ ),
19014
+ error && /* @__PURE__ */ jsx("div", { style: { fontSize: "11px", color: "#dc2626", fontWeight: 500, marginTop: "1px" }, children: error })
19015
+ ] });
19016
+ }
19017
+ init_ThemeContext();
19018
+ var SlotErrorBoundary = class extends React41.Component {
19019
+ constructor(props) {
19020
+ super(props);
19021
+ this.state = { hasError: false };
19022
+ }
19023
+ static getDerivedStateFromError() {
19024
+ return { hasError: true };
19025
+ }
19026
+ render() {
19027
+ if (this.state.hasError) return this.props.fallback;
19028
+ return this.props.children;
19029
+ }
19030
+ };
19031
+ function ContextRender({ payload }) {
19032
+ return resolveUI(payload);
19033
+ }
19034
+ var _a;
19035
+ var _isDev = typeof process !== "undefined" && ((_a = process.env) == null ? void 0 : _a.NODE_ENV) !== "production";
19036
+ function ContextSlot({ payload }) {
19037
+ const { MUTED: MUTED2, BORDER: BORDER4, PAPER: PAPER2 } = useTheme();
19038
+ if (!payload || typeof payload.type !== "string") return null;
19039
+ const note = (msg) => /* @__PURE__ */ jsx("div", { style: __spreadProps(__spreadValues({}, S2.slot), { border: `1px solid ${BORDER4}`, background: PAPER2, padding: "8px 11px", fontSize: "12px", color: MUTED2 }), children: msg });
19040
+ const result = validatePayload(payload.type, payload);
19041
+ const safePayload = result.success ? result.data : payload;
19042
+ if (!result.success && _isDev) {
19043
+ console.warn(`[ContextSlot] invalid embedded "${payload.type}" payload:`, result.error);
19044
+ }
19045
+ const fallback = note(
19046
+ _isDev ? `Couldn't render embedded ${payload.type}: ${result.success ? "render error" : result.error}` : `Couldn't render embedded ${payload.type}.`
19047
+ );
19048
+ if (!result.success) return fallback;
19049
+ return /* @__PURE__ */ jsx("div", { style: S2.slot, children: /* @__PURE__ */ jsx(SlotErrorBoundary, { fallback, children: /* @__PURE__ */ jsx(ContextRender, { payload: safePayload }) }) });
19050
+ }
19051
+ var S2 = {
19052
+ slot: {
19053
+ marginBottom: "8px",
19054
+ borderRadius: "0.5rem",
19055
+ overflow: "hidden"
19056
+ }
19057
+ };
19058
+
19059
+ // src/builders/BuilderRecap.tsx
19060
+ init_ThemeContext();
19061
+ function BuilderRecap({ builder, state }) {
19062
+ const t = useTheme();
19063
+ const blocks = builder.blocks || [];
19064
+ const display = (field, value) => {
19065
+ if (value == null || value === "") return "";
19066
+ const opt = (v) => {
19067
+ var _a2, _b, _c;
19068
+ return (_c = (_b = (_a2 = field.options) == null ? void 0 : _a2.find((o) => o.value === v)) == null ? void 0 : _b.label) != null ? _c : String(v);
19069
+ };
19070
+ if (field.field_type === "multi_select" && Array.isArray(value)) return value.map(opt).join(", ");
19071
+ if (field.field_type === "select") return opt(value);
19072
+ if (field.field_type === "checkbox") return value ? "Yes" : "No";
19073
+ if (field.field_type === "entity_picker") {
19074
+ if (value && typeof value === "object") {
19075
+ const o = value;
19076
+ return o.label || o.value || "";
19077
+ }
19078
+ return String(value);
19079
+ }
19080
+ if (field.field_type === "file_upload") {
19081
+ const files = Array.isArray(value) ? value : [value];
19082
+ return files.map((x) => x && typeof x === "object" ? x.filename || x.name || "file" : String(x)).join(", ");
19083
+ }
19084
+ if (field.field_type === "file_map") {
19085
+ if (value && typeof value === "object" && !Array.isArray(value)) {
19086
+ let files = 0, roles = 0, unassigned = 0;
19087
+ for (const [g, paths] of Object.entries(value)) {
19088
+ const n = Array.isArray(paths) ? paths.length : 0;
19089
+ if (g === "unassigned") unassigned += n;
19090
+ else {
19091
+ files += n;
19092
+ if (n > 0) roles += 1;
19093
+ }
19094
+ }
19095
+ const tot = files + unassigned;
19096
+ return `${tot} file${tot !== 1 ? "s" : ""} \xB7 ${roles} role${roles !== 1 ? "s" : ""}${unassigned ? ` (${unassigned} unassigned)` : ""}`;
19097
+ }
19098
+ return String(value);
19099
+ }
19100
+ return String(value);
19101
+ };
19102
+ const decisionField = (b) => (b.fields || []).find((f) => f.field_type === "select") || (b.fields || [])[0];
19103
+ const rows = useMemo(
19104
+ () => blocks.map((b) => {
19105
+ const df = decisionField(b);
19106
+ const decision = df ? display(df, state.getValue(b.id, df.name)) : "";
19107
+ const extras = (b.fields || []).filter((f) => f !== df).map((f) => ({ label: f.label, value: display(f, state.getValue(b.id, f.name)) })).filter((x) => x.value);
19108
+ return { id: b.id, title: b.title, decision, extras };
19109
+ }),
19110
+ // eslint-disable-next-line react-hooks/exhaustive-deps
19111
+ [blocks, state.values]
19112
+ );
19113
+ const counts = useMemo(() => {
19114
+ const m = /* @__PURE__ */ new Map();
19115
+ for (const r of rows) {
19116
+ const k = r.decision || "\u2014";
19117
+ m.set(k, (m.get(k) || 0) + 1);
19118
+ }
19119
+ return Array.from(m.entries());
19120
+ }, [rows]);
19121
+ const pill = (label) => {
19122
+ const l = label.toLowerCase();
19123
+ let fg = t.MUTED, bg = "#f2f2f2";
19124
+ if (/accept|approve|confirm|keep|yes/.test(l)) {
19125
+ fg = "#15803d";
19126
+ bg = "#dcfce7";
19127
+ } else if (/exclud|reject|remove|delete|deny|no\b/.test(l)) {
19128
+ fg = "#dc2626";
19129
+ bg = "#fef2f2";
19130
+ } else if (/reclass|change|edit|modif|review|other/.test(l)) {
19131
+ fg = t.SECONDARY;
19132
+ bg = "#e8f0fe";
19133
+ }
19134
+ return { fg, bg };
18557
19135
  };
18558
19136
  const total = rows.length;
18559
19137
  return /* @__PURE__ */ jsxs("div", { style: S3(t).card, children: [
@@ -18655,21 +19233,173 @@ function S3(t) {
18655
19233
  }
18656
19234
  };
18657
19235
  }
18658
- function FormBuilder({ builder, state, onSubmit, onCancel, disabled, onFileUpload, dense, hideActions }) {
18659
- var _a;
19236
+ function fieldKey(blockId, name) {
19237
+ return `${blockId}\0${name}`;
19238
+ }
19239
+ function isRequiredMissing(fieldType, v) {
19240
+ if (fieldType === "checkbox") return v !== true;
19241
+ if (fieldType === "file_map") {
19242
+ if (!v || typeof v !== "object" || Array.isArray(v)) return true;
19243
+ return !Object.entries(v).some(
19244
+ ([g, paths]) => g !== "unassigned" && Array.isArray(paths) && paths.length > 0
19245
+ );
19246
+ }
19247
+ return v == null || v === "" || Array.isArray(v) && v.length === 0;
19248
+ }
19249
+ function useBuilderState(blocks) {
19250
+ const isMultiBlock = blocks.length > 1;
19251
+ const [values, setValues] = useState(() => {
19252
+ const init = {};
19253
+ for (const block of blocks) {
19254
+ for (const field of block.fields || []) {
19255
+ if (field.default_value != null) init[fieldKey(block.id, field.name)] = field.default_value;
19256
+ }
19257
+ }
19258
+ return init;
19259
+ });
19260
+ const [errors, setErrors] = useState({});
19261
+ const [currentBlock, setCurrentBlock] = useState(0);
19262
+ const getValue = useCallback(
19263
+ (blockId, name) => values[fieldKey(blockId, name)],
19264
+ [values]
19265
+ );
19266
+ const getError = useCallback(
19267
+ (blockId, name) => errors[fieldKey(blockId, name)],
19268
+ [errors]
19269
+ );
19270
+ const setFieldValue = useCallback((blockId, name, value) => {
19271
+ const k = fieldKey(blockId, name);
19272
+ setValues((prev) => __spreadProps(__spreadValues({}, prev), { [k]: value }));
19273
+ setErrors((prev) => {
19274
+ if (!prev[k]) return prev;
19275
+ const next = __spreadValues({}, prev);
19276
+ delete next[k];
19277
+ return next;
19278
+ });
19279
+ }, []);
19280
+ const validateBlock = useCallback(
19281
+ (blockIdx) => {
19282
+ const block = blocks[blockIdx];
19283
+ if (!block) return true;
19284
+ const newErrors = {};
19285
+ for (const field of block.fields || []) {
19286
+ const k = fieldKey(block.id, field.name);
19287
+ const v = values[k];
19288
+ if (field.required) {
19289
+ if (isRequiredMissing(field.field_type, v)) {
19290
+ newErrors[k] = "Required";
19291
+ continue;
19292
+ }
19293
+ }
19294
+ if (v == null || v === "") continue;
19295
+ const val = field.validation;
19296
+ if (!val) continue;
19297
+ if (val.min_length && typeof v === "string" && v.length < val.min_length) {
19298
+ newErrors[k] = `Min ${val.min_length} characters`;
19299
+ } else if (val.max_length && typeof v === "string" && v.length > val.max_length) {
19300
+ newErrors[k] = `Max ${val.max_length} characters`;
19301
+ } else if (val.min != null && typeof v === "number" && v < val.min) {
19302
+ newErrors[k] = `Min ${val.min}`;
19303
+ } else if (val.max != null && typeof v === "number" && v > val.max) {
19304
+ newErrors[k] = `Max ${val.max}`;
19305
+ } else if (val.pattern && typeof v === "string" && !new RegExp(val.pattern).test(v)) {
19306
+ newErrors[k] = "Invalid format";
19307
+ }
19308
+ }
19309
+ setErrors((prev) => __spreadValues(__spreadValues({}, prev), newErrors));
19310
+ return Object.keys(newErrors).length === 0;
19311
+ },
19312
+ [blocks, values]
19313
+ );
19314
+ const validateAllDetailed = useCallback(() => {
19315
+ let firstBlockIndex = -1;
19316
+ let firstKey = null;
19317
+ let firstBlockId = null;
19318
+ let firstName = null;
19319
+ const failingKeys = [];
19320
+ const allErrors = {};
19321
+ for (let i = 0; i < blocks.length; i++) {
19322
+ const block = blocks[i];
19323
+ for (const field of block.fields || []) {
19324
+ const k = fieldKey(block.id, field.name);
19325
+ const v = values[k];
19326
+ if (field.required && isRequiredMissing(field.field_type, v)) {
19327
+ allErrors[k] = "Required";
19328
+ failingKeys.push(k);
19329
+ if (firstBlockIndex < 0) {
19330
+ firstBlockIndex = i;
19331
+ firstKey = k;
19332
+ firstBlockId = block.id;
19333
+ firstName = field.name;
19334
+ }
19335
+ }
19336
+ }
19337
+ }
19338
+ setErrors(allErrors);
19339
+ if (firstBlockIndex >= 0) setCurrentBlock(firstBlockIndex);
19340
+ return { firstKey, firstBlockId, firstName, firstBlockIndex, failingKeys };
19341
+ }, [blocks, values]);
19342
+ const validateAll = useCallback(
19343
+ () => validateAllDetailed().failingKeys.length === 0,
19344
+ [validateAllDetailed]
19345
+ );
19346
+ return {
19347
+ values,
19348
+ errors,
19349
+ getValue,
19350
+ getError,
19351
+ setFieldValue,
19352
+ validateBlock,
19353
+ validateAll,
19354
+ validateAllDetailed,
19355
+ currentBlock,
19356
+ setCurrentBlock,
19357
+ isMultiBlock
19358
+ };
19359
+ }
19360
+ function BlockForm({
19361
+ builder,
19362
+ state,
19363
+ onSubmit,
19364
+ onCancel,
19365
+ disabled,
19366
+ onFileUpload,
19367
+ onEntitySearch,
19368
+ onEntityCreate,
19369
+ hideActions,
19370
+ dense,
19371
+ variant = "form"
19372
+ }) {
19373
+ var _a2;
18660
19374
  const t = useTheme();
18661
19375
  const S4 = useMemo(() => makeStyles(t), [t]);
18662
19376
  const block = builder.blocks[0];
19377
+ const isEscalation = variant === "escalation";
19378
+ const errorCount = ((block == null ? void 0 : block.fields) || []).reduce(
19379
+ (n, f) => state.getError(block.id, f.name) ? n + 1 : n,
19380
+ 0
19381
+ );
18663
19382
  if (!block) return null;
18664
19383
  if (disabled) return /* @__PURE__ */ jsx(BuilderRecap, { builder, state });
18665
- const containerStyle = dense ? { display: "flex", flexDirection: "column", gap: "12px" } : S4.card;
19384
+ const containerStyle = dense ? { display: "flex", flexDirection: "column", gap: isEscalation ? "10px" : "12px" } : isEscalation ? S4.escalationCard : S4.formCard;
18666
19385
  return /* @__PURE__ */ jsxs("div", { style: containerStyle, children: [
18667
- dense ? builder.description && /* @__PURE__ */ jsx("p", { style: { fontSize: "12px", color: t.MUTED, lineHeight: 1.45, margin: 0 }, children: builder.description }) : /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "2px" }, children: [
19386
+ !isEscalation && !dense ? /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "2px" }, children: [
18668
19387
  /* @__PURE__ */ jsx("p", { style: S4.title, children: builder.title }),
18669
19388
  builder.description && /* @__PURE__ */ jsx("p", { style: { fontSize: "12px", color: t.MUTED, lineHeight: 1.45, margin: 0 }, children: builder.description })
18670
- ] }),
18671
- ((_a = block.context) == null ? void 0 : _a.type) && /* @__PURE__ */ jsx(ContextSlot, { payload: block.context }),
18672
- /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column", gap: dense ? "8px" : "12px" }, children: (block.fields || []).map((field) => /* @__PURE__ */ jsx(
19389
+ ] }) : builder.description && /* @__PURE__ */ jsx(
19390
+ "p",
19391
+ {
19392
+ style: {
19393
+ fontSize: isEscalation && !dense ? "13px" : "12px",
19394
+ color: isEscalation && !dense ? "var(--foreground)" : t.MUTED,
19395
+ lineHeight: 1.45,
19396
+ margin: 0
19397
+ },
19398
+ children: builder.description
19399
+ }
19400
+ ),
19401
+ ((_a2 = block.context) == null ? void 0 : _a2.type) && /* @__PURE__ */ jsx(ContextSlot, { payload: block.context }),
19402
+ /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column", gap: dense ? "8px" : isEscalation ? "10px" : "12px" }, children: (block.fields || []).map((field) => /* @__PURE__ */ jsx("div", { "data-field-key": fieldKey(block.id, field.name), children: /* @__PURE__ */ jsx(
18673
19403
  FieldRenderer,
18674
19404
  {
18675
19405
  field,
@@ -18678,20 +19408,45 @@ function FormBuilder({ builder, state, onSubmit, onCancel, disabled, onFileUploa
18678
19408
  disabled,
18679
19409
  error: state.getError(block.id, field.name),
18680
19410
  dense,
18681
- onFileUpload
18682
- },
18683
- `${block.id}:${field.name}`
18684
- )) }),
18685
- hideActions ? null : /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "8px", paddingTop: "4px" }, children: [
18686
- /* @__PURE__ */ jsx("div", { style: { flex: 1 } }),
18687
- onCancel && /* @__PURE__ */ jsx("button", { type: "button", onClick: onCancel, style: S4.cancelBtn, children: builder.cancel_label || "Cancel" }),
18688
- /* @__PURE__ */ jsx("button", { type: "button", onClick: onSubmit, style: S4.submitBtn, children: builder.submit_label || "Submit" })
19411
+ onFileUpload,
19412
+ onEntitySearch,
19413
+ onEntityCreate
19414
+ }
19415
+ ) }, `${block.id}:${field.name}`)) }),
19416
+ hideActions ? null : /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "6px", paddingTop: isEscalation ? "2px" : "4px" }, children: [
19417
+ errorCount > 0 ? /* @__PURE__ */ jsxs("div", { style: { fontSize: "11px", fontWeight: 600, color: "#dc2626" }, children: [
19418
+ errorCount,
19419
+ " required field",
19420
+ errorCount === 1 ? "" : "s",
19421
+ " need",
19422
+ errorCount === 1 ? "s" : "",
19423
+ " attention"
19424
+ ] }) : null,
19425
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
19426
+ /* @__PURE__ */ jsx("div", { style: { flex: 1 } }),
19427
+ onCancel ? /* @__PURE__ */ jsx("button", { type: "button", onClick: onCancel, style: S4.cancelBtn, children: builder.cancel_label || "Cancel" }) : null,
19428
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: onSubmit, style: isEscalation ? S4.continueBtn : S4.submitBtn, children: builder.submit_label || (isEscalation ? "Continue" : "Submit") })
19429
+ ] })
18689
19430
  ] })
18690
19431
  ] });
18691
19432
  }
18692
19433
  function makeStyles(t) {
18693
19434
  return {
18694
- card: {
19435
+ // Escalation: accent left-rail card (attention).
19436
+ escalationCard: {
19437
+ display: "flex",
19438
+ flexDirection: "column",
19439
+ gap: "10px",
19440
+ padding: "12px 14px",
19441
+ borderRadius: "0.75rem",
19442
+ borderTop: `1px solid ${t.BORDER}`,
19443
+ borderRight: `1px solid ${t.BORDER}`,
19444
+ borderBottom: `1px solid ${t.BORDER}`,
19445
+ borderLeft: `2px solid ${t.ACCENT}`,
19446
+ background: "white"
19447
+ },
19448
+ // Form: standard bordered card with a soft shadow.
19449
+ formCard: {
18695
19450
  display: "flex",
18696
19451
  flexDirection: "column",
18697
19452
  gap: "14px",
@@ -18701,11 +19456,6 @@ function makeStyles(t) {
18701
19456
  background: "white",
18702
19457
  boxShadow: "0 1px 2px rgba(0,0,0,0.03), 0 4px 12px rgba(0,0,0,0.04)"
18703
19458
  },
18704
- inert: {
18705
- opacity: 0.55,
18706
- pointerEvents: "none",
18707
- userSelect: "none"
18708
- },
18709
19459
  title: {
18710
19460
  fontFamily: "var(--font-serif)",
18711
19461
  fontSize: "15px",
@@ -18714,6 +19464,23 @@ function makeStyles(t) {
18714
19464
  letterSpacing: "-0.01em",
18715
19465
  margin: 0
18716
19466
  },
19467
+ // Escalation CTA: outlined accent pill.
19468
+ continueBtn: {
19469
+ font: "inherit",
19470
+ fontSize: "12px",
19471
+ fontWeight: 600,
19472
+ color: t.ACCENT,
19473
+ background: "transparent",
19474
+ borderTop: `1px solid ${t.ACCENT}`,
19475
+ borderRight: `1px solid ${t.ACCENT}`,
19476
+ borderBottom: `1px solid ${t.ACCENT}`,
19477
+ borderLeft: `1px solid ${t.ACCENT}`,
19478
+ borderRadius: "9999px",
19479
+ padding: "6px 14px",
19480
+ cursor: "pointer",
19481
+ transition: "all 0.15s"
19482
+ },
19483
+ // Form CTA: filled accent pill.
18717
19484
  submitBtn: {
18718
19485
  font: "inherit",
18719
19486
  fontSize: "12px",
@@ -18743,8 +19510,8 @@ function makeStyles(t) {
18743
19510
 
18744
19511
  // src/builders/StepperBuilder.tsx
18745
19512
  init_ThemeContext();
18746
- function StepperBuilder({ builder, state, onSubmit, onCancel, disabled, onFileUpload, dense }) {
18747
- var _a;
19513
+ function StepperBuilder({ builder, state, onSubmit, onCancel, disabled, onFileUpload, onEntitySearch, onEntityCreate, dense }) {
19514
+ var _a2;
18748
19515
  const t = useTheme();
18749
19516
  const S4 = useMemo(() => makeStyles2(t), [t]);
18750
19517
  const { blocks } = builder;
@@ -18783,7 +19550,7 @@ function StepperBuilder({ builder, state, onSubmit, onCancel, disabled, onFileUp
18783
19550
  ] }),
18784
19551
  /* @__PURE__ */ jsx("div", { style: dense ? __spreadProps(__spreadValues({}, S4.body), { padding: "12px 0" }) : S4.body, children: block && /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "12px", animation: "agStepFade 0.22s ease" }, children: [
18785
19552
  block.description && /* @__PURE__ */ jsx("div", { style: S4.blockDesc, children: block.description }),
18786
- ((_a = block.context) == null ? void 0 : _a.type) && /* @__PURE__ */ jsx(ContextSlot, { payload: block.context }),
19553
+ ((_a2 = block.context) == null ? void 0 : _a2.type) && /* @__PURE__ */ jsx(ContextSlot, { payload: block.context }),
18787
19554
  /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column", gap: "12px" }, children: (block.fields || []).map((field) => /* @__PURE__ */ jsx(
18788
19555
  FieldRenderer,
18789
19556
  {
@@ -18793,7 +19560,9 @@ function StepperBuilder({ builder, state, onSubmit, onCancel, disabled, onFileUp
18793
19560
  disabled,
18794
19561
  error: state.getError(block.id, field.name),
18795
19562
  dense,
18796
- onFileUpload
19563
+ onFileUpload,
19564
+ onEntitySearch,
19565
+ onEntityCreate
18797
19566
  },
18798
19567
  `${block.id}:${field.name}`
18799
19568
  )) })
@@ -18919,168 +19688,19 @@ function makeStyles2(t) {
18919
19688
  }
18920
19689
  };
18921
19690
  }
18922
-
18923
- // src/builders/EscalationCard.tsx
18924
- init_ThemeContext();
18925
- function EscalationCard({ builder, state, onSubmit, disabled, onFileUpload, hideActions, dense }) {
18926
- var _a;
18927
- const t = useTheme();
18928
- const S4 = useMemo(() => makeStyles3(t), [t]);
18929
- const block = builder.blocks[0];
18930
- if (!block) return null;
18931
- if (disabled) return /* @__PURE__ */ jsx(BuilderRecap, { builder, state });
18932
- const containerStyle = dense ? { display: "flex", flexDirection: "column", gap: "10px" } : S4.card;
18933
- return /* @__PURE__ */ jsxs("div", { style: containerStyle, children: [
18934
- builder.description && /* @__PURE__ */ jsx("p", { style: { fontSize: dense ? "12px" : "13px", color: dense ? t.MUTED : "var(--foreground)", lineHeight: 1.45, margin: 0 }, children: builder.description }),
18935
- ((_a = block.context) == null ? void 0 : _a.type) && /* @__PURE__ */ jsx(ContextSlot, { payload: block.context }),
18936
- /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column", gap: dense ? "8px" : "10px" }, children: (block.fields || []).map((field) => /* @__PURE__ */ jsx(FieldRenderer, { field, value: state.getValue(block.id, field.name), onChange: (v) => state.setFieldValue(block.id, field.name, v), disabled, error: state.getError(block.id, field.name), onFileUpload, dense }, `${block.id}:${field.name}`)) }),
18937
- disabled ? /* @__PURE__ */ jsx("div", { style: { fontSize: "11px", fontWeight: 600, color: t.MUTED, textAlign: "center", padding: "2px 0" }, children: "Submitted" }) : hideActions ? null : /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "8px", paddingTop: "2px" }, children: [
18938
- /* @__PURE__ */ jsx("div", { style: { flex: 1 } }),
18939
- /* @__PURE__ */ jsx("button", { type: "button", onClick: onSubmit, style: S4.continueBtn, children: builder.submit_label || "Continue" })
18940
- ] })
18941
- ] });
18942
- }
18943
- function makeStyles3(t) {
18944
- return {
18945
- card: {
18946
- display: "flex",
18947
- flexDirection: "column",
18948
- gap: "10px",
18949
- padding: "12px 14px",
18950
- borderRadius: "0.75rem",
18951
- borderTop: `1px solid ${t.BORDER}`,
18952
- borderRight: `1px solid ${t.BORDER}`,
18953
- borderBottom: `1px solid ${t.BORDER}`,
18954
- borderLeft: `2px solid ${t.ACCENT}`,
18955
- background: "white"
18956
- },
18957
- inert: { opacity: 0.55, pointerEvents: "none", userSelect: "none" },
18958
- continueBtn: {
18959
- font: "inherit",
18960
- fontSize: "12px",
18961
- fontWeight: 600,
18962
- color: t.ACCENT,
18963
- background: "transparent",
18964
- borderTop: `1px solid ${t.ACCENT}`,
18965
- borderRight: `1px solid ${t.ACCENT}`,
18966
- borderBottom: `1px solid ${t.ACCENT}`,
18967
- borderLeft: `1px solid ${t.ACCENT}`,
18968
- borderRadius: "9999px",
18969
- padding: "6px 14px",
18970
- cursor: "pointer",
18971
- transition: "all 0.15s"
18972
- }
18973
- };
18974
- }
18975
- function fieldKey(blockId, name) {
18976
- return `${blockId}\0${name}`;
18977
- }
18978
- function useBuilderState(blocks) {
18979
- const isMultiBlock = blocks.length > 1;
18980
- const [values, setValues] = useState(() => {
18981
- const init = {};
18982
- for (const block of blocks) {
18983
- for (const field of block.fields || []) {
18984
- if (field.default_value != null) init[fieldKey(block.id, field.name)] = field.default_value;
18985
- }
18986
- }
18987
- return init;
18988
- });
18989
- const [errors, setErrors] = useState({});
18990
- const [currentBlock, setCurrentBlock] = useState(0);
18991
- const getValue = useCallback(
18992
- (blockId, name) => values[fieldKey(blockId, name)],
18993
- [values]
18994
- );
18995
- const getError = useCallback(
18996
- (blockId, name) => errors[fieldKey(blockId, name)],
18997
- [errors]
18998
- );
18999
- const setFieldValue = useCallback((blockId, name, value) => {
19000
- const k = fieldKey(blockId, name);
19001
- setValues((prev) => __spreadProps(__spreadValues({}, prev), { [k]: value }));
19002
- setErrors((prev) => {
19003
- if (!prev[k]) return prev;
19004
- const next = __spreadValues({}, prev);
19005
- delete next[k];
19006
- return next;
19007
- });
19008
- }, []);
19009
- const validateBlock = useCallback(
19010
- (blockIdx) => {
19011
- const block = blocks[blockIdx];
19012
- if (!block) return true;
19013
- const newErrors = {};
19014
- for (const field of block.fields || []) {
19015
- const k = fieldKey(block.id, field.name);
19016
- const v = values[k];
19017
- if (field.required) {
19018
- if (v == null || v === "" || Array.isArray(v) && v.length === 0) {
19019
- newErrors[k] = "Required";
19020
- continue;
19021
- }
19022
- }
19023
- if (v == null || v === "") continue;
19024
- const val = field.validation;
19025
- if (!val) continue;
19026
- if (val.min_length && typeof v === "string" && v.length < val.min_length) {
19027
- newErrors[k] = `Min ${val.min_length} characters`;
19028
- } else if (val.max_length && typeof v === "string" && v.length > val.max_length) {
19029
- newErrors[k] = `Max ${val.max_length} characters`;
19030
- } else if (val.min != null && typeof v === "number" && v < val.min) {
19031
- newErrors[k] = `Min ${val.min}`;
19032
- } else if (val.max != null && typeof v === "number" && v > val.max) {
19033
- newErrors[k] = `Max ${val.max}`;
19034
- } else if (val.pattern && typeof v === "string" && !new RegExp(val.pattern).test(v)) {
19035
- newErrors[k] = "Invalid format";
19036
- }
19037
- }
19038
- setErrors((prev) => __spreadValues(__spreadValues({}, prev), newErrors));
19039
- return Object.keys(newErrors).length === 0;
19040
- },
19041
- [blocks, values]
19042
- );
19043
- const validateAll = useCallback(() => {
19044
- let firstFailing = -1;
19045
- const allErrors = {};
19046
- for (let i = 0; i < blocks.length; i++) {
19047
- const block = blocks[i];
19048
- for (const field of block.fields || []) {
19049
- const k = fieldKey(block.id, field.name);
19050
- const v = values[k];
19051
- if (field.required && (v == null || v === "" || Array.isArray(v) && v.length === 0)) {
19052
- allErrors[k] = "Required";
19053
- if (firstFailing < 0) firstFailing = i;
19054
- }
19055
- }
19056
- }
19057
- setErrors(allErrors);
19058
- if (firstFailing >= 0) setCurrentBlock(firstFailing);
19059
- return Object.keys(allErrors).length === 0;
19060
- }, [blocks, values]);
19061
- return {
19062
- values,
19063
- errors,
19064
- getValue,
19065
- getError,
19066
- setFieldValue,
19067
- validateBlock,
19068
- validateAll,
19069
- currentBlock,
19070
- setCurrentBlock,
19071
- isMultiBlock
19072
- };
19073
- }
19074
19691
  function BuilderFormResolver({
19075
19692
  builder,
19076
19693
  onSubmit,
19077
19694
  onCancel,
19078
19695
  disabled,
19079
19696
  onFileUpload,
19697
+ onEntitySearch,
19698
+ onEntityCreate,
19080
19699
  onChange,
19081
19700
  submitRef,
19082
19701
  hideActions,
19083
- dense
19702
+ dense,
19703
+ onValidationError
19084
19704
  }) {
19085
19705
  const state = useBuilderState(builder.blocks);
19086
19706
  const kind = builder.builder_kind || "form";
@@ -19098,9 +19718,13 @@ function BuilderFormResolver({
19098
19718
  }, [builder, kind, state.getValue]);
19099
19719
  const handleSubmit = useCallback(() => {
19100
19720
  if (disabled) return;
19101
- if (!state.validateAll()) return;
19721
+ const failure = state.validateAllDetailed();
19722
+ if (failure.failingKeys.length > 0) {
19723
+ onValidationError == null ? void 0 : onValidationError(failure);
19724
+ return;
19725
+ }
19102
19726
  onSubmit(buildSubmission());
19103
- }, [disabled, state.validateAll, onSubmit, buildSubmission]);
19727
+ }, [disabled, state.validateAllDetailed, onSubmit, buildSubmission, onValidationError]);
19104
19728
  useEffect(() => {
19105
19729
  if (!onChange) return;
19106
19730
  onChange(buildSubmission());
@@ -19123,32 +19747,40 @@ function BuilderFormResolver({
19123
19747
  onCancel,
19124
19748
  disabled,
19125
19749
  onFileUpload,
19750
+ onEntitySearch,
19751
+ onEntityCreate,
19126
19752
  dense
19127
19753
  }
19128
19754
  );
19129
19755
  case "escalation":
19130
19756
  return /* @__PURE__ */ jsx(
19131
- EscalationCard,
19757
+ BlockForm,
19132
19758
  {
19759
+ variant: "escalation",
19133
19760
  builder,
19134
19761
  state,
19135
19762
  onSubmit: handleSubmit,
19136
19763
  disabled,
19137
19764
  onFileUpload,
19765
+ onEntitySearch,
19766
+ onEntityCreate,
19138
19767
  hideActions,
19139
19768
  dense
19140
19769
  }
19141
19770
  );
19142
19771
  default:
19143
19772
  return /* @__PURE__ */ jsx(
19144
- FormBuilder,
19773
+ BlockForm,
19145
19774
  {
19775
+ variant: "form",
19146
19776
  builder,
19147
19777
  state,
19148
19778
  onSubmit: handleSubmit,
19149
19779
  onCancel,
19150
19780
  disabled,
19151
19781
  onFileUpload,
19782
+ onEntitySearch,
19783
+ onEntityCreate,
19152
19784
  dense,
19153
19785
  hideActions
19154
19786
  }