@declarion/react 0.36.3 → 0.36.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import { s as e, t } from "./DynamicIcon-BWO6QtNF.js";
2
- import { En as n, F as r, Hn as i, I as a, Ln as o, Qt as s, Un as c, V as l, Wn as u, an as d, cn as f, f as p, h as m, in as h, jn as g, kt as _, ln as v, m as y, mn as b, nt as x, p as S, pn as C, pt as w, rn as T, rt as E, sn as D, tt as O, un as k, vn as A } from "./ActionRunner-BrXXs8ga.js";
3
- import { E as j, J as M, K as ee, St as N, T as P, Y as F, d as I, et as L, k as R, o as z, pt as B, q as V, r as te, t as ne, tt as re, u as ie, xt as ae } from "./registry-D_zbJrLC.js";
2
+ import { Gn as n, Kn as r, L as i, Nn as a, On as o, R as s, U as c, Wn as l, _ as u, an as d, at as f, bn as p, dn as m, en as h, fn as g, g as _, gn as v, h as y, hn as b, ht as x, it as S, jt as C, ln as w, m as T, on as E, rt as D, sn as O, un as k, zn as A } from "./useCurrentScreen-Bgp6_vne.js";
3
+ import { E as j, J as M, K as ee, St as N, T as P, Y as F, d as I, et as L, k as R, o as z, pt as B, q as V, r as te, t as ne, tt as re, u as ie, xt as ae } from "./registry-KMbQkTF6.js";
4
4
  import { n as oe, r as se, t as ce } from "./dataTableStyles-vwD1mVOP.js";
5
5
  import { Suspense as le, createContext as ue, lazy as H, useCallback as U, useContext as de, useEffect as W, useId as fe, useLayoutEffect as pe, useMemo as G, useRef as K, useState as q } from "react";
6
6
  import { useInfiniteQuery as me, useMutation as he, useQueryClient as ge } from "@tanstack/react-query";
@@ -123,13 +123,13 @@ function Ce(e) {
123
123
  function Z(e, t) {
124
124
  let n = Ce(e);
125
125
  if (n) {
126
- if (e.label) return f(e.label);
126
+ if (e.label) return k(e.label);
127
127
  let r = t.entity.children?.find((e) => e.entity === n);
128
- if (r?.display?.name) return f(r.display.name);
128
+ if (r?.display?.name) return k(r.display.name);
129
129
  let i = t.schema.entities[n];
130
- return i && (f(i.display.name_plural) || f(i.display.name)) || n;
130
+ return i && (k(i.display.name_plural) || k(i.display.name)) || n;
131
131
  }
132
- return e.section ? f(e.section.name) : "Tab";
132
+ return e.section ? k(e.section.name) : "Tab";
133
133
  }
134
134
  function we(e, t) {
135
135
  if (e.icon) return e.icon;
@@ -144,9 +144,9 @@ function we(e, t) {
144
144
  //#endregion
145
145
  //#region src/components/detail-layout/LayoutTabs.tsx
146
146
  function Te({ config: e, ctx: n }) {
147
- let { items: r } = e, [i, a] = q(0), s = o(), c = n.detailTabsPresentation ?? (s.isPhone ? "sections" : "scroll");
147
+ let { items: r } = e, [i, a] = q(0), o = A(), s = n.detailTabsPresentation ?? (o.isPhone ? "sections" : "scroll");
148
148
  if (r.length === 0) return null;
149
- if (c === "sections") {
149
+ if (s === "sections") {
150
150
  let e = r.map((e, t) => `detail-tab-section-${t}`);
151
151
  return /* @__PURE__ */ X("div", {
152
152
  style: {
@@ -338,16 +338,16 @@ function Ee({ config: e, ctx: n }) {
338
338
  }, d = s ? /* @__PURE__ */ Y(t, {
339
339
  name: s,
340
340
  size: 14
341
- }) : void 0, p = c ? {
342
- text: f(c.text),
341
+ }) : void 0, f = c ? {
342
+ text: k(c.text),
343
343
  tone: c.tone,
344
344
  dot: c.dot
345
345
  } : void 0;
346
346
  return /* @__PURE__ */ Y(N, {
347
- title: f(r),
347
+ title: k(r),
348
348
  defaultOpen: !a,
349
349
  icon: d,
350
- badge: p,
350
+ badge: f,
351
351
  emphasis: l,
352
352
  headingLevel: n.withinCard ? 3 : 2,
353
353
  children: /* @__PURE__ */ Y(Kt, {
@@ -383,7 +383,7 @@ function Q(e, t, n) {
383
383
  return e ?? t ?? n;
384
384
  }
385
385
  function Oe(e) {
386
- return T(e, "update") ? "inline_edit" : "readonly";
386
+ return d(e, "update") ? "inline_edit" : "readonly";
387
387
  }
388
388
  function ke(e) {
389
389
  return e.display.name_plural && Object.keys(e.display.name_plural).length > 0 ? e.display.name_plural : e.display.name;
@@ -459,7 +459,7 @@ function Le(e, ...t) {
459
459
  }
460
460
  }
461
461
  function Re(e) {
462
- let t = D(e);
462
+ let t = w(e);
463
463
  return t.length > 0 ? t[0] : void 0;
464
464
  }
465
465
  function ze(e, t) {
@@ -473,7 +473,7 @@ function Be(e, t, n, r) {
473
473
  ...e
474
474
  };
475
475
  if (Array.isArray(n)) {
476
- let e = Array.isArray(r) ? r.map(String) : k(String(r), n.length);
476
+ let e = Array.isArray(r) ? r.map(String) : g(String(r), n.length);
477
477
  if (!e || e.length !== n.length) throw Error("invalid composite parent id");
478
478
  for (let t = 0; t < n.length; t++) i[n[t]] = e[t];
479
479
  } else i[n] = Array.isArray(r) ? r[0] : r;
@@ -488,18 +488,18 @@ function Ve(e, t) {
488
488
  }
489
489
  //#endregion
490
490
  //#region src/components/detail-layout/useQuickAdd.ts
491
- function He(e, t, n, i) {
491
+ function He(e, t, n, r) {
492
492
  let [a, o] = q(() => {
493
- let t = e.quick_add, n = i.entities[e.entity], a = {};
494
- if (t?.fields) for (let e of t.fields) t.defaults?.[e] == null ? n?.fields.get(e)?.type === "timestamp" && (a[e] = r()) : a[e] = t.defaults[e];
493
+ let t = e.quick_add, n = r.entities[e.entity], a = {};
494
+ if (t?.fields) for (let e of t.fields) t.defaults?.[e] == null ? n?.fields.get(e)?.type === "timestamp" && (a[e] = i()) : a[e] = t.defaults[e];
495
495
  return a;
496
496
  }), s = ge(), { mutate: c, isPending: l, error: u, reset: d } = he({
497
- mutationFn: (t) => O(e.entity, t),
497
+ mutationFn: (t) => D(e.entity, t),
498
498
  onMutate: async (r) => {
499
499
  let i = [
500
500
  M,
501
501
  t,
502
- Array.isArray(n) ? v(n.map(String)) : n,
502
+ Array.isArray(n) ? m(n.map(String)) : n,
503
503
  e.entity
504
504
  ];
505
505
  await s.cancelQueries({ queryKey: i });
@@ -527,12 +527,12 @@ function He(e, t, n, i) {
527
527
  if (n?.snapshots) for (let [e, t] of n.snapshots) s.setQueryData(e, t);
528
528
  },
529
529
  onSuccess: () => {
530
- let t = e.quick_add, n = i.entities[e.entity], a = {};
531
- if (t?.fields) for (let e of t.fields) t?.defaults?.[e] == null ? n?.fields.get(e)?.type === "timestamp" ? a[e] = r() : a[e] = "" : a[e] = t.defaults[e];
530
+ let t = e.quick_add, n = r.entities[e.entity], a = {};
531
+ if (t?.fields) for (let e of t.fields) t?.defaults?.[e] == null ? n?.fields.get(e)?.type === "timestamp" ? a[e] = i() : a[e] = "" : a[e] = t.defaults[e];
532
532
  o(a);
533
533
  },
534
534
  onSettled: () => {
535
- let r = Array.isArray(n) ? v(n.map(String)) : n;
535
+ let r = Array.isArray(n) ? m(n.map(String)) : n;
536
536
  s.invalidateQueries({ queryKey: [
537
537
  M,
538
538
  t,
@@ -540,13 +540,13 @@ function He(e, t, n, i) {
540
540
  e.entity
541
541
  ] });
542
542
  }
543
- }), f = e.quick_add, p = i.entities[e.entity], m = Ve(a, f?.fields.filter((e) => p?.fields.get(e)?.required) ?? []);
544
- function h(t) {
543
+ }), f = e.quick_add, p = r.entities[e.entity], h = Ve(a, f?.fields.filter((e) => p?.fields.get(e)?.required) ?? []);
544
+ function g(t) {
545
545
  if (t.preventDefault(), !f) return;
546
546
  let r = Be(a, f.defaults, e.foreign_key, n);
547
547
  c(r);
548
548
  }
549
- function g(e, t) {
549
+ function _(e, t) {
550
550
  u && d(), o((n) => ({
551
551
  ...n,
552
552
  [e]: t
@@ -558,20 +558,20 @@ function He(e, t, n, i) {
558
558
  childEntity: p,
559
559
  isPending: l,
560
560
  error: u,
561
- isReady: m,
562
- handleSubmit: h,
563
- handleFieldChange: g
561
+ isReady: h,
562
+ handleSubmit: g,
563
+ handleFieldChange: _
564
564
  };
565
565
  }
566
566
  //#endregion
567
567
  //#region src/components/detail-layout/QuickAddForm.tsx
568
- function Ue({ config: t, parentEntity: n, parentId: r, schema: i }) {
569
- let { values: a, quickAdd: s, childEntity: c, isPending: l, error: f, isReady: p, handleSubmit: m, handleFieldChange: h } = He(t, n, r, i), g = S(), _ = o(), v = fe();
568
+ function Ue({ config: t, parentEntity: n, parentId: i, schema: a }) {
569
+ let { values: o, quickAdd: s, childEntity: c, isPending: l, error: u, isReady: d, handleSubmit: f, handleFieldChange: p } = He(t, n, i, a), m = y(), h = A(), g = fe();
570
570
  return !s || s.fields.length === 0 || !c ? null : /* @__PURE__ */ X("form", {
571
- onSubmit: m,
571
+ onSubmit: f,
572
572
  style: {
573
573
  display: "flex",
574
- flexDirection: _.isPhone ? "column" : "row",
574
+ flexDirection: h.isPhone ? "column" : "row",
575
575
  alignItems: "flex-end",
576
576
  gap: 8,
577
577
  padding: "8px 0",
@@ -581,15 +581,15 @@ function Ue({ config: t, parentEntity: n, parentId: r, schema: i }) {
581
581
  s.fields.map((e) => {
582
582
  let n = c.fields.get(e);
583
583
  if (!n) return null;
584
- let r = `${v}-quick-add-${t.entity}-${e}`, o = `${r}-label`;
584
+ let r = `${g}-quick-add-${t.entity}-${e}`, i = `${r}-label`;
585
585
  return /* @__PURE__ */ X("div", {
586
586
  style: {
587
587
  flex: 1,
588
588
  minWidth: 0,
589
- width: _.isPhone ? "100%" : void 0
589
+ width: h.isPhone ? "100%" : void 0
590
590
  },
591
591
  children: [/* @__PURE__ */ Y("label", {
592
- id: o,
592
+ id: i,
593
593
  htmlFor: r,
594
594
  style: {
595
595
  fontSize: 11,
@@ -598,71 +598,71 @@ function Ue({ config: t, parentEntity: n, parentId: r, schema: i }) {
598
598
  display: "block",
599
599
  fontWeight: 500
600
600
  },
601
- children: d(n, e, i.entities)
602
- }), y({
601
+ children: O(n, e, a.entities)
602
+ }), _({
603
603
  field: n,
604
604
  fieldName: e,
605
- value: a[e] ?? "",
605
+ value: o[e] ?? "",
606
606
  mode: "edit",
607
- onChange: (t) => h(e, t),
608
- record: a,
607
+ onChange: (t) => p(e, t),
608
+ record: o,
609
609
  fieldId: r,
610
- labelId: o,
611
- locale: g
610
+ labelId: i,
611
+ locale: m
612
612
  })]
613
613
  }, e);
614
614
  }),
615
- /* @__PURE__ */ Y(u, {
615
+ /* @__PURE__ */ Y(r, {
616
616
  type: "submit",
617
617
  kind: "primary",
618
- size: _.isPhone ? "md" : "sm",
618
+ size: h.isPhone ? "md" : "sm",
619
619
  icon: /* @__PURE__ */ Y(e.plus, { size: 12 }),
620
- disabled: l || !p,
621
- style: _.isPhone ? { alignSelf: "flex-end" } : void 0,
620
+ disabled: l || !d,
621
+ style: h.isPhone ? { alignSelf: "flex-end" } : void 0,
622
622
  children: "Add"
623
623
  }),
624
- f != null && /* @__PURE__ */ Y("span", {
624
+ u != null && /* @__PURE__ */ Y("span", {
625
625
  style: {
626
626
  fontSize: 11,
627
627
  color: "var(--danger)",
628
628
  alignSelf: "flex-end",
629
629
  marginBottom: 4
630
630
  },
631
- children: f.message
631
+ children: u.message
632
632
  })
633
633
  ]
634
634
  });
635
635
  }
636
636
  //#endregion
637
637
  //#region src/components/detail-layout/ChildrenTable.tsx
638
- function We({ config: t, parentEntity: n, parentId: r, schema: a }) {
639
- let o = a.entities[t.entity], s = S(), l = V((e) => e.degradedEntities), { data: u, isLoading: f, isError: p, isFetching: h, refetch: _ } = F(n, r, t.entity, t.foreign_key, t.sort, t.limit), v = u?.data ?? [], y = u?.$refs, x = K(y);
640
- x.current = y;
641
- let C = t.columns, w = t.interaction === "navigate", T = C[0], E = w && o ? b(void 0, o, a.screens) : null, D = o ? Re(o) : void 0, O = G(() => {
638
+ function We({ config: t, parentEntity: r, parentId: i, schema: o }) {
639
+ let s = o.entities[t.entity], c = y(), d = V((e) => e.degradedEntities), { data: f, isLoading: m, isError: h, isFetching: g, refetch: _ } = F(r, i, t.entity, t.foreign_key, t.sort, t.limit), b = f?.data ?? [], x = f?.$refs, S = K(x);
640
+ S.current = x;
641
+ let C = t.columns, w = t.interaction === "navigate", T = C[0], E = w && s ? v(void 0, s, o.screens) : null, D = s ? Re(s) : void 0, k = G(() => {
642
642
  let e = /* @__PURE__ */ new Map();
643
- if (!o) return e;
643
+ if (!s) return e;
644
644
  for (let t of C) {
645
- let n = o.fields.get(t);
646
- n && e.set(t, m({
645
+ let n = s.fields.get(t);
646
+ n && e.set(t, u({
647
647
  field: n,
648
648
  fieldName: t,
649
649
  surface: "list",
650
- entity: o,
651
- entities: a.entities,
652
- screens: a.screens,
653
- refs: () => x.current,
654
- locale: s
650
+ entity: s,
651
+ entities: o.entities,
652
+ screens: o.screens,
653
+ refs: () => S.current,
654
+ locale: c
655
655
  }));
656
656
  }
657
657
  return e;
658
658
  }, [
659
- o,
659
+ s,
660
660
  C,
661
- a.entities,
662
- a.screens,
663
- s
661
+ o.entities,
662
+ o.screens,
663
+ c
664
664
  ]);
665
- if (!o) return /* @__PURE__ */ Y("div", {
665
+ if (!s) return /* @__PURE__ */ Y("div", {
666
666
  style: {
667
667
  fontSize: 12.5,
668
668
  color: "var(--text-3)",
@@ -670,11 +670,11 @@ function We({ config: t, parentEntity: n, parentId: r, schema: a }) {
670
670
  },
671
671
  children: "Entity not found."
672
672
  });
673
- let k = /* @__PURE__ */ Y(Ue, {
673
+ let A = /* @__PURE__ */ Y(Ue, {
674
674
  config: t,
675
- parentEntity: n,
676
- parentId: r,
677
- schema: a
675
+ parentEntity: r,
676
+ parentId: i,
677
+ schema: o
678
678
  }), j = /* @__PURE__ */ X("div", {
679
679
  style: {
680
680
  display: "flex",
@@ -683,31 +683,31 @@ function We({ config: t, parentEntity: n, parentId: r, schema: a }) {
683
683
  padding: "4px 0",
684
684
  justifyContent: "flex-end"
685
685
  },
686
- children: [ee(o.realtime, l, t.entity) && /* @__PURE__ */ Y("span", {
686
+ children: [ee(s.realtime, d, t.entity) && /* @__PURE__ */ Y("span", {
687
687
  "data-testid": "children-live-indicator",
688
688
  title: "This table updates automatically in realtime.",
689
- children: /* @__PURE__ */ Y(i, {
689
+ children: /* @__PURE__ */ Y(l, {
690
690
  tone: "emerald",
691
691
  size: "xs",
692
692
  dot: !0,
693
693
  children: "Live"
694
694
  })
695
- }), /* @__PURE__ */ Y(c, {
696
- icon: h ? /* @__PURE__ */ Y("span", {
695
+ }), /* @__PURE__ */ Y(n, {
696
+ icon: g ? /* @__PURE__ */ Y("span", {
697
697
  "data-testid": "children-refresh-spinner",
698
698
  style: { display: "inline-flex" },
699
- children: /* @__PURE__ */ Y(g, { size: 13 })
699
+ children: /* @__PURE__ */ Y(a, { size: 13 })
700
700
  }) : /* @__PURE__ */ Y(e.refresh, { size: 13 }),
701
701
  title: "Refresh",
702
702
  size: 24,
703
- disabled: h,
703
+ disabled: g,
704
704
  onClick: () => {
705
705
  _();
706
706
  }
707
707
  })]
708
708
  });
709
- return p ? /* @__PURE__ */ X("div", { children: [
710
- k,
709
+ return h ? /* @__PURE__ */ X("div", { children: [
710
+ A,
711
711
  j,
712
712
  /* @__PURE__ */ Y("div", {
713
713
  style: {
@@ -717,8 +717,8 @@ function We({ config: t, parentEntity: n, parentId: r, schema: a }) {
717
717
  },
718
718
  children: "Failed to load. Try again."
719
719
  })
720
- ] }) : f ? /* @__PURE__ */ X("div", { children: [
721
- k,
720
+ ] }) : m ? /* @__PURE__ */ X("div", { children: [
721
+ A,
722
722
  j,
723
723
  /* @__PURE__ */ Y("div", {
724
724
  style: {
@@ -737,8 +737,8 @@ function We({ config: t, parentEntity: n, parentId: r, schema: a }) {
737
737
  borderRadius: 4
738
738
  } }, e))
739
739
  })
740
- ] }) : v.length === 0 ? /* @__PURE__ */ X("div", { children: [
741
- k,
740
+ ] }) : b.length === 0 ? /* @__PURE__ */ X("div", { children: [
741
+ A,
742
742
  j,
743
743
  /* @__PURE__ */ Y("div", {
744
744
  style: {
@@ -749,22 +749,22 @@ function We({ config: t, parentEntity: n, parentId: r, schema: a }) {
749
749
  children: "No records yet."
750
750
  })
751
751
  ] }) : /* @__PURE__ */ X("div", { children: [
752
- k,
752
+ A,
753
753
  j,
754
754
  /* @__PURE__ */ Y("div", {
755
755
  style: { overflowX: "auto" },
756
756
  children: /* @__PURE__ */ X("table", {
757
757
  style: se,
758
758
  children: [/* @__PURE__ */ Y("thead", { children: /* @__PURE__ */ Y("tr", { children: C.map((e) => {
759
- let t = o.fields.get(e);
759
+ let t = s.fields.get(e);
760
760
  return /* @__PURE__ */ Y("th", {
761
761
  style: oe,
762
- children: t ? d(t, e, a.entities) : e
762
+ children: t ? O(t, e, o.entities) : e
763
763
  }, e);
764
- }) }) }), /* @__PURE__ */ Y("tbody", { children: v.map((e, t) => {
765
- let n = D ? A(e[D]) : "", r = w && E && n ? E.replace(/:\w+/, n) : void 0;
764
+ }) }) }), /* @__PURE__ */ Y("tbody", { children: b.map((e, t) => {
765
+ let n = D ? p(e[D]) : "", r = w && E && n ? E.replace(/:\w+/, n) : void 0;
766
766
  return /* @__PURE__ */ Y("tr", { children: C.map((t) => {
767
- let n = t === T, i = O.get(t), a = i ? i(e[t], e) : A(e[t]);
767
+ let n = t === T, i = k.get(t), a = i ? i(e[t], e) : p(e[t]);
768
768
  return /* @__PURE__ */ Y("td", {
769
769
  title: typeof a == "string" ? a : void 0,
770
770
  style: ce,
@@ -780,7 +780,7 @@ function We({ config: t, parentEntity: n, parentId: r, schema: a }) {
780
780
  children: a
781
781
  }) : a
782
782
  }, t);
783
- }) }, A(e.id ?? t));
783
+ }) }, p(e.id ?? t));
784
784
  }) })]
785
785
  })
786
786
  })
@@ -789,7 +789,7 @@ function We({ config: t, parentEntity: n, parentId: r, schema: a }) {
789
789
  //#endregion
790
790
  //#region src/components/detail-layout/ChildrenList.tsx
791
791
  function Ge({ config: e, parentEntity: t, parentId: n, schema: r }) {
792
- let i = r.entities[e.entity], a = S(), { data: o, isLoading: c, isError: l } = F(t, n, e.entity, e.foreign_key, e.sort, e.limit), u = o?.data ?? [], d = o?.$refs, f = e.columns;
792
+ let i = r.entities[e.entity], a = y(), { data: o, isLoading: s, isError: c } = F(t, n, e.entity, e.foreign_key, e.sort, e.limit), l = o?.data ?? [], u = o?.$refs, d = e.columns;
793
793
  if (!i) return /* @__PURE__ */ Y("div", {
794
794
  style: {
795
795
  fontSize: 12.5,
@@ -798,13 +798,13 @@ function Ge({ config: e, parentEntity: t, parentId: n, schema: r }) {
798
798
  },
799
799
  children: "Entity not found."
800
800
  });
801
- let p = /* @__PURE__ */ Y(Ue, {
801
+ let f = /* @__PURE__ */ Y(Ue, {
802
802
  config: e,
803
803
  parentEntity: t,
804
804
  parentId: n,
805
805
  schema: r
806
806
  });
807
- if (l) return /* @__PURE__ */ X("div", { children: [p, /* @__PURE__ */ Y("div", {
807
+ if (c) return /* @__PURE__ */ X("div", { children: [f, /* @__PURE__ */ Y("div", {
808
808
  style: {
809
809
  fontSize: 12.5,
810
810
  color: "var(--danger)",
@@ -812,7 +812,7 @@ function Ge({ config: e, parentEntity: t, parentId: n, schema: r }) {
812
812
  },
813
813
  children: "Failed to load. Try again."
814
814
  })] });
815
- if (c) return /* @__PURE__ */ X("div", { children: [p, /* @__PURE__ */ X("div", {
815
+ if (s) return /* @__PURE__ */ X("div", { children: [f, /* @__PURE__ */ X("div", {
816
816
  style: {
817
817
  display: "flex",
818
818
  flexDirection: "column",
@@ -838,7 +838,7 @@ function Ge({ config: e, parentEntity: t, parentId: n, schema: r }) {
838
838
  } })
839
839
  ]
840
840
  })] });
841
- if (u.length === 0) return /* @__PURE__ */ X("div", { children: [p, /* @__PURE__ */ Y("div", {
841
+ if (l.length === 0) return /* @__PURE__ */ X("div", { children: [f, /* @__PURE__ */ Y("div", {
842
842
  style: {
843
843
  fontSize: 12.5,
844
844
  color: "var(--text-3)",
@@ -846,13 +846,13 @@ function Ge({ config: e, parentEntity: t, parentId: n, schema: r }) {
846
846
  },
847
847
  children: "No records yet."
848
848
  })] });
849
- let m = f.length > 0 ? i.display.display_field ?? f[0] : i.display.display_field;
850
- return /* @__PURE__ */ X("div", { children: [p, /* @__PURE__ */ Y("div", {
849
+ let m = d.length > 0 ? i.display.display_field ?? d[0] : i.display.display_field;
850
+ return /* @__PURE__ */ X("div", { children: [f, /* @__PURE__ */ Y("div", {
851
851
  style: {
852
852
  display: "flex",
853
853
  flexDirection: "column"
854
854
  },
855
- children: u.map((e, t) => /* @__PURE__ */ Y("div", {
855
+ children: l.map((e, t) => /* @__PURE__ */ Y("div", {
856
856
  style: {
857
857
  display: "flex",
858
858
  alignItems: "center",
@@ -872,17 +872,17 @@ function Ge({ config: e, parentEntity: t, parentId: n, schema: r }) {
872
872
  textOverflow: "ellipsis",
873
873
  whiteSpace: "nowrap"
874
874
  },
875
- children: (typeof e.$display == "string" ? e[s] : "") || (m && i.fields.get(m) ? y({
875
+ children: (typeof e.$display == "string" ? e[h] : "") || (m && i.fields.get(m) ? _({
876
876
  field: i.fields.get(m),
877
877
  fieldName: m,
878
878
  value: e[m],
879
879
  mode: "display",
880
880
  record: e,
881
- refs: d,
881
+ refs: u,
882
882
  locale: a
883
- }) : m && e[m] != null ? A(e[m]) : null)
884
- }), f.length > 1 && (() => {
885
- let t = f.slice(1, 3).filter((t) => e[t] != null);
883
+ }) : m && e[m] != null ? p(e[m]) : null)
884
+ }), d.length > 1 && (() => {
885
+ let t = d.slice(1, 3).filter((t) => e[t] != null);
886
886
  return t.length === 0 ? null : /* @__PURE__ */ Y("div", {
887
887
  style: {
888
888
  fontSize: 11.5,
@@ -891,26 +891,26 @@ function Ge({ config: e, parentEntity: t, parentId: n, schema: r }) {
891
891
  textOverflow: "ellipsis",
892
892
  whiteSpace: "nowrap"
893
893
  },
894
- children: t.map((t, n) => /* @__PURE__ */ X("span", { children: [n > 0 && " · ", i.fields.get(t) ? y({
894
+ children: t.map((t, n) => /* @__PURE__ */ X("span", { children: [n > 0 && " · ", i.fields.get(t) ? _({
895
895
  field: i.fields.get(t),
896
896
  fieldName: t,
897
897
  value: e[t],
898
898
  mode: "display",
899
899
  record: e,
900
- refs: d,
900
+ refs: u,
901
901
  locale: a
902
902
  }) : String(e[t])] }, t))
903
903
  });
904
904
  })()]
905
905
  })
906
- }, A(e.id ?? t)))
906
+ }, p(e.id ?? t)))
907
907
  })] });
908
908
  }
909
909
  //#endregion
910
910
  //#region src/components/detail-layout/ChildrenCards.tsx
911
911
  function Ke({ config: e, parentEntity: t, parentId: n, schema: r }) {
912
- let a = r.entities[e.entity], o = S(), { data: s, isLoading: c, isError: l } = F(t, n, e.entity, e.foreign_key, e.sort, e.limit), u = s?.data ?? [], d = s?.$refs, f = e.columns, p = e.cards, m = p?.header_field ?? f[0], h = p?.badge_field, g = p?.columns_count ?? 3;
913
- if (!a) return /* @__PURE__ */ Y("div", {
912
+ let i = r.entities[e.entity], a = y(), { data: o, isLoading: s, isError: c } = F(t, n, e.entity, e.foreign_key, e.sort, e.limit), u = o?.data ?? [], d = o?.$refs, f = e.columns, m = e.cards, h = m?.header_field ?? f[0], g = m?.badge_field, v = m?.columns_count ?? 3;
913
+ if (!i) return /* @__PURE__ */ Y("div", {
914
914
  style: {
915
915
  fontSize: 12.5,
916
916
  color: "var(--text-3)",
@@ -918,17 +918,17 @@ function Ke({ config: e, parentEntity: t, parentId: n, schema: r }) {
918
918
  },
919
919
  children: "Entity not found."
920
920
  });
921
- let _ = {
921
+ let b = {
922
922
  display: "grid",
923
- gridTemplateColumns: `repeat(auto-fill, minmax(${g >= 4 ? 180 : 240}px, 1fr))`,
923
+ gridTemplateColumns: `repeat(auto-fill, minmax(${v >= 4 ? 180 : 240}px, 1fr))`,
924
924
  gap: 12
925
- }, v = /* @__PURE__ */ Y(Ue, {
925
+ }, x = /* @__PURE__ */ Y(Ue, {
926
926
  config: e,
927
927
  parentEntity: t,
928
928
  parentId: n,
929
929
  schema: r
930
930
  });
931
- if (l) return /* @__PURE__ */ X("div", { children: [v, /* @__PURE__ */ Y("div", {
931
+ if (c) return /* @__PURE__ */ X("div", { children: [x, /* @__PURE__ */ Y("div", {
932
932
  style: {
933
933
  fontSize: 12.5,
934
934
  color: "var(--danger)",
@@ -936,8 +936,8 @@ function Ke({ config: e, parentEntity: t, parentId: n, schema: r }) {
936
936
  },
937
937
  children: "Failed to load. Try again."
938
938
  })] });
939
- if (c) return /* @__PURE__ */ X("div", { children: [v, /* @__PURE__ */ Y("div", {
940
- style: _,
939
+ if (s) return /* @__PURE__ */ X("div", { children: [x, /* @__PURE__ */ Y("div", {
940
+ style: b,
941
941
  children: [
942
942
  0,
943
943
  1,
@@ -948,7 +948,7 @@ function Ke({ config: e, parentEntity: t, parentId: n, schema: r }) {
948
948
  borderRadius: 10
949
949
  } }, e))
950
950
  })] });
951
- if (u.length === 0) return /* @__PURE__ */ X("div", { children: [v, /* @__PURE__ */ Y("div", {
951
+ if (u.length === 0) return /* @__PURE__ */ X("div", { children: [x, /* @__PURE__ */ Y("div", {
952
952
  style: {
953
953
  fontSize: 12.5,
954
954
  color: "var(--text-3)",
@@ -956,9 +956,9 @@ function Ke({ config: e, parentEntity: t, parentId: n, schema: r }) {
956
956
  },
957
957
  children: "No records yet."
958
958
  })] });
959
- let b = f.filter((e) => e !== m && e !== h);
960
- return /* @__PURE__ */ X("div", { children: [v, /* @__PURE__ */ Y("div", {
961
- style: _,
959
+ let S = f.filter((e) => e !== h && e !== g);
960
+ return /* @__PURE__ */ X("div", { children: [x, /* @__PURE__ */ Y("div", {
961
+ style: b,
962
962
  children: u.map((t, n) => /* @__PURE__ */ X("div", {
963
963
  style: {
964
964
  background: "var(--surface)",
@@ -973,7 +973,7 @@ function Ke({ config: e, parentEntity: t, parentId: n, schema: r }) {
973
973
  alignItems: "center",
974
974
  justifyContent: "space-between",
975
975
  gap: 8,
976
- borderBottom: b.length > 0 ? "1px solid var(--divider)" : "none"
976
+ borderBottom: S.length > 0 ? "1px solid var(--divider)" : "none"
977
977
  },
978
978
  children: [/* @__PURE__ */ Y("div", {
979
979
  style: {
@@ -983,38 +983,38 @@ function Ke({ config: e, parentEntity: t, parentId: n, schema: r }) {
983
983
  textOverflow: "ellipsis",
984
984
  whiteSpace: "nowrap"
985
985
  },
986
- children: m && a.fields.get(m) ? y({
987
- field: a.fields.get(m),
988
- fieldName: m,
989
- value: t[m],
986
+ children: h && i.fields.get(h) ? _({
987
+ field: i.fields.get(h),
988
+ fieldName: h,
989
+ value: t[h],
990
990
  mode: "display",
991
991
  record: t,
992
992
  refs: d,
993
- locale: o
993
+ locale: a
994
994
  }) : `Record ${n + 1}`
995
- }), h && t[h] != null && /* @__PURE__ */ Y(i, {
995
+ }), g && t[g] != null && /* @__PURE__ */ Y(l, {
996
996
  tone: "slate",
997
997
  size: "xs",
998
- children: a.fields.get(h) ? y({
999
- field: a.fields.get(h),
1000
- fieldName: h,
1001
- value: t[h],
998
+ children: i.fields.get(g) ? _({
999
+ field: i.fields.get(g),
1000
+ fieldName: g,
1001
+ value: t[g],
1002
1002
  mode: "display",
1003
1003
  record: t,
1004
1004
  refs: d,
1005
- locale: o
1006
- }) : A(t[h])
1005
+ locale: a
1006
+ }) : p(t[g])
1007
1007
  })]
1008
- }), b.length > 0 && /* @__PURE__ */ Y("div", {
1008
+ }), S.length > 0 && /* @__PURE__ */ Y("div", {
1009
1009
  style: {
1010
1010
  padding: "10px 14px",
1011
1011
  display: "flex",
1012
1012
  flexDirection: "column",
1013
1013
  gap: 4
1014
1014
  },
1015
- children: b.slice(0, 4).map((n) => {
1016
- let i = a.fields.get(n);
1017
- return i ? /* @__PURE__ */ X("div", {
1015
+ children: S.slice(0, 4).map((n) => {
1016
+ let o = i.fields.get(n);
1017
+ return o ? /* @__PURE__ */ X("div", {
1018
1018
  style: {
1019
1019
  display: "flex",
1020
1020
  alignItems: "baseline",
@@ -1033,27 +1033,27 @@ function Ke({ config: e, parentEntity: t, parentId: n, schema: r }) {
1033
1033
  textOverflow: "ellipsis",
1034
1034
  whiteSpace: "nowrap"
1035
1035
  },
1036
- children: y({
1037
- field: i,
1036
+ children: _({
1037
+ field: o,
1038
1038
  fieldName: n,
1039
1039
  value: t[n],
1040
1040
  mode: "display",
1041
1041
  record: t,
1042
1042
  refs: d,
1043
- locale: o
1043
+ locale: a
1044
1044
  })
1045
1045
  })]
1046
1046
  }, n) : null;
1047
1047
  })
1048
1048
  })]
1049
- }, A(t.id ?? n)))
1049
+ }, p(t.id ?? n)))
1050
1050
  })] });
1051
1051
  }
1052
1052
  //#endregion
1053
1053
  //#region src/hooks/useTimelineData.ts
1054
1054
  var qe = 50;
1055
1055
  function Je(e, t, n, r, i, a) {
1056
- let o = Array.isArray(r) ? r : [r], s = Array.isArray(r) ? k(t, o.length) : [t], c = a ?? qe, l = me({
1056
+ let o = Array.isArray(r) ? r : [r], s = Array.isArray(r) ? g(t, o.length) : [t], c = a ?? qe, l = me({
1057
1057
  queryKey: [
1058
1058
  M,
1059
1059
  e,
@@ -1071,7 +1071,7 @@ function Je(e, t, n, r, i, a) {
1071
1071
  op: "eq",
1072
1072
  value: s[t]
1073
1073
  }));
1074
- return t.set("filters", JSON.stringify(r)), t.set("preview", "true"), i ? t.set("sort", `${i}:desc`) : typeof console < "u" && console.warn(`[useTimelineData] no time_field for ${n}; fetch order falls back to API default`), t.set("limit", String(c)), e && t.set("after", e), _(`/api/data/${n}?${t.toString()}`);
1074
+ return t.set("filters", JSON.stringify(r)), t.set("preview", "true"), i ? t.set("sort", `${i}:desc`) : typeof console < "u" && console.warn(`[useTimelineData] no time_field for ${n}; fetch order falls back to API default`), t.set("limit", String(c)), e && t.set("after", e), C(`/api/data/${n}?${t.toString()}`);
1075
1075
  },
1076
1076
  getNextPageParam: (e) => e.meta?.has_more ? e.meta.cursor : void 0,
1077
1077
  initialPageParam: void 0,
@@ -1090,74 +1090,74 @@ function Je(e, t, n, r, i, a) {
1090
1090
  //#endregion
1091
1091
  //#region src/components/detail-layout/TimelineComposer.tsx
1092
1092
  var Ye = "quick_entry", Xe = 100, Ze = 240, Qe = 800, $e = 80;
1093
- function et({ config: t, parentEntity: n, parentId: r, schema: i }) {
1094
- let { values: a, quickAdd: o, childEntity: s, isPending: c, error: l, isReady: d, handleSubmit: f, handleFieldChange: m } = He(t, n, r, i), h = S(), [g, _] = q(Ze), v = K(null), b = K(null), [x, C] = q(Qe);
1093
+ function et({ config: t, parentEntity: n, parentId: i, schema: a }) {
1094
+ let { values: o, quickAdd: s, childEntity: c, isPending: l, error: u, isReady: d, handleSubmit: f, handleFieldChange: p } = He(t, n, i, a), m = y(), [h, g] = q(Ze), v = K(null), b = K(null), [x, S] = q(Qe);
1095
1095
  W(() => {
1096
1096
  let e = b.current?.parentElement;
1097
1097
  if (!e) return;
1098
1098
  let t = () => {
1099
1099
  let t = Math.max(Xe, e.clientHeight - $e);
1100
- C(Math.min(Qe, t));
1100
+ S(Math.min(Qe, t));
1101
1101
  };
1102
1102
  t();
1103
1103
  let n = new ResizeObserver(t);
1104
1104
  return n.observe(e), () => n.disconnect();
1105
1105
  }, []), W(() => {
1106
- _((e) => Math.min(e, x));
1106
+ g((e) => Math.min(e, x));
1107
1107
  }, [x]);
1108
- let w = K(a);
1109
- w.current = a;
1110
- let T = K(m);
1111
- T.current = m;
1108
+ let C = K(o);
1109
+ C.current = o;
1110
+ let w = K(p);
1111
+ w.current = p;
1112
1112
  let E = K({}), D = G(() => ({
1113
- getField: (e) => w.current[e],
1113
+ getField: (e) => C.current[e],
1114
1114
  setField: (e, t) => {
1115
- T.current(e, t);
1115
+ w.current(e, t);
1116
1116
  },
1117
1117
  focusField: (e) => {
1118
1118
  let t = E.current[e];
1119
1119
  t && (t.querySelector("textarea, input, select, [contenteditable]") ?? t).focus();
1120
1120
  }
1121
1121
  }), []);
1122
- W(() => p(Ye, D), [D]);
1122
+ W(() => T(Ye, D), [D]);
1123
1123
  let O = U((e) => {
1124
1124
  e.preventDefault(), v.current = {
1125
1125
  startY: e.clientY,
1126
- startHeight: g
1126
+ startHeight: h
1127
1127
  };
1128
1128
  let t = (e) => {
1129
1129
  if (!v.current) return;
1130
1130
  let t = v.current.startY - e.clientY, n = Math.min(x, Math.max(Xe, v.current.startHeight + t));
1131
- _(n);
1131
+ g(n);
1132
1132
  }, n = () => {
1133
1133
  v.current = null, document.removeEventListener("mousemove", t), document.removeEventListener("mouseup", n);
1134
1134
  };
1135
1135
  document.addEventListener("mousemove", t), document.addEventListener("mouseup", n);
1136
- }, [g, x]);
1137
- if (!o || o.fields.length === 0 || !s) return null;
1138
- let k = o.fields.find((e) => {
1139
- let t = s.fields.get(e);
1136
+ }, [h, x]);
1137
+ if (!s || s.fields.length === 0 || !c) return null;
1138
+ let k = s.fields.find((e) => {
1139
+ let t = c.fields.get(e);
1140
1140
  return t && (t.type === "text" || t.type === "string");
1141
1141
  }), A = [], j = [];
1142
- for (let e of o.fields) {
1142
+ for (let e of s.fields) {
1143
1143
  if (e === k) continue;
1144
- let t = s.fields.get(e);
1144
+ let t = c.fields.get(e);
1145
1145
  t && (t.type === "enum" ? A.push(e) : j.push(e));
1146
1146
  }
1147
1147
  let M = (e) => {
1148
- let t = s.fields.get(e);
1148
+ let t = c.fields.get(e);
1149
1149
  return t ? /* @__PURE__ */ Y("div", {
1150
1150
  ref: (t) => {
1151
1151
  E.current[e] = t;
1152
1152
  },
1153
- children: y({
1153
+ children: _({
1154
1154
  field: t,
1155
1155
  fieldName: e,
1156
- value: a[e] ?? "",
1156
+ value: o[e] ?? "",
1157
1157
  mode: "edit",
1158
- onChange: (t) => m(e, t),
1159
- record: a,
1160
- locale: h
1158
+ onChange: (t) => p(e, t),
1159
+ record: o,
1160
+ locale: m
1161
1161
  })
1162
1162
  }, e) : null;
1163
1163
  };
@@ -1169,7 +1169,7 @@ function et({ config: t, parentEntity: n, parentId: r, schema: i }) {
1169
1169
  background: "var(--surface)",
1170
1170
  display: "flex",
1171
1171
  flexDirection: "column",
1172
- height: `${g}px`
1172
+ height: `${h}px`
1173
1173
  },
1174
1174
  children: [/* @__PURE__ */ Y("div", {
1175
1175
  onMouseDown: O,
@@ -1212,7 +1212,7 @@ function et({ config: t, parentEntity: n, parentId: r, schema: i }) {
1212
1212
  },
1213
1213
  children: A.map(M)
1214
1214
  }),
1215
- k && s.fields.get(k) && /* @__PURE__ */ Y("div", {
1215
+ k && c.fields.get(k) && /* @__PURE__ */ Y("div", {
1216
1216
  style: {
1217
1217
  flex: 1,
1218
1218
  minHeight: 0,
@@ -1221,15 +1221,15 @@ function et({ config: t, parentEntity: n, parentId: r, schema: i }) {
1221
1221
  ref: (e) => {
1222
1222
  E.current[k] = e;
1223
1223
  },
1224
- children: y({
1225
- field: s.fields.get(k),
1224
+ children: _({
1225
+ field: c.fields.get(k),
1226
1226
  fieldName: k,
1227
- value: a[k] ?? "",
1227
+ value: o[k] ?? "",
1228
1228
  mode: "edit",
1229
- onChange: (e) => m(k, e),
1230
- record: a,
1229
+ onChange: (e) => p(k, e),
1230
+ record: o,
1231
1231
  fill: !0,
1232
- locale: h
1232
+ locale: m
1233
1233
  })
1234
1234
  }),
1235
1235
  /* @__PURE__ */ X("div", {
@@ -1263,23 +1263,23 @@ function et({ config: t, parentEntity: n, parentId: r, schema: i }) {
1263
1263
  }),
1264
1264
  " to add"
1265
1265
  ]
1266
- }), /* @__PURE__ */ Y(u, {
1266
+ }), /* @__PURE__ */ Y(r, {
1267
1267
  type: "submit",
1268
1268
  kind: "primary",
1269
1269
  icon: /* @__PURE__ */ Y(e.plus, { size: 13 }),
1270
- disabled: c || !d,
1270
+ disabled: l || !d,
1271
1271
  children: "Add"
1272
1272
  })]
1273
1273
  })]
1274
1274
  }),
1275
- l != null && /* @__PURE__ */ Y("p", {
1275
+ u != null && /* @__PURE__ */ Y("p", {
1276
1276
  style: {
1277
1277
  fontSize: 11,
1278
1278
  color: "var(--danger)",
1279
1279
  margin: 0,
1280
1280
  flexShrink: 0
1281
1281
  },
1282
- children: l.message
1282
+ children: u.message
1283
1283
  })
1284
1284
  ]
1285
1285
  })]
@@ -1291,63 +1291,63 @@ var tt = 80, nt = 200;
1291
1291
  function rt(e, t) {
1292
1292
  if (it(t)) {
1293
1293
  let e = t.id;
1294
- return e == null ? "" : A(e);
1294
+ return e == null ? "" : p(e);
1295
1295
  }
1296
- return E(h(e, t));
1296
+ return f(E(e, t));
1297
1297
  }
1298
1298
  function it(e) {
1299
1299
  return e.__optimistic === !0;
1300
1300
  }
1301
- function at({ config: e, parentEntity: t, parentId: n, schema: r }) {
1302
- let i = r.entities[e.entity], { rows: a, refs: o, fetchNextPage: s, hasOlder: c, isFetchingOlder: l, isLoading: d, isError: p } = Je(t, n, e.entity, e.foreign_key, e.timeline?.time_field, e.limit), m = e.timeline, h = m?.scroll ?? !1, _ = (e.sort ?? "").endsWith(":asc"), v = G(() => _ ? [...a].reverse() : a, [a, _]), y = m?.auto_scroll ?? "none", b = K(null), x = K(null), S = K(!1), C = K(0), w = K(null), T = K(null), E = K(!0), D = K(null);
1301
+ function at({ config: e, parentEntity: t, parentId: n, schema: i }) {
1302
+ let o = i.entities[e.entity], { rows: s, refs: c, fetchNextPage: l, hasOlder: u, isFetchingOlder: d, isLoading: f, isError: p } = Je(t, n, e.entity, e.foreign_key, e.timeline?.time_field, e.limit), m = e.timeline, h = m?.scroll ?? !1, g = (e.sort ?? "").endsWith(":asc"), _ = G(() => g ? [...s].reverse() : s, [s, g]), v = m?.auto_scroll ?? "none", y = K(null), b = K(null), x = K(!1), S = K(0), C = K(null), w = K(null), T = K(!0), E = K(null);
1303
1303
  W(() => {
1304
- S.current = !1, C.current = 0, w.current = null, T.current = null, E.current = !0, D.current = null;
1304
+ x.current = !1, S.current = 0, C.current = null, w.current = null, T.current = !0, E.current = null;
1305
1305
  }, [n]), pe(() => {
1306
- !l || !b.current || (D.current = {
1307
- scrollHeight: b.current.scrollHeight,
1308
- scrollTop: b.current.scrollTop
1306
+ !d || !y.current || (E.current = {
1307
+ scrollHeight: y.current.scrollHeight,
1308
+ scrollTop: y.current.scrollTop
1309
1309
  });
1310
- }, [l]), pe(() => {
1311
- let e = b.current;
1312
- if (!e || v.length === 0 || !i) {
1313
- C.current = v.length;
1310
+ }, [d]), pe(() => {
1311
+ let e = y.current;
1312
+ if (!e || _.length === 0 || !o) {
1313
+ S.current = _.length;
1314
1314
  return;
1315
1315
  }
1316
- let t = rt(i, v[0]), n = rt(i, v[v.length - 1]), r = !S.current, a = v.length > C.current && C.current > 0, o = a && (_ && t !== w.current && n === T.current || !_ && n !== T.current && t === w.current), s = a && !o;
1317
- if (r) _ && y === "bottom" && (e.scrollTop = e.scrollHeight), S.current = !0;
1318
- else if (o && D.current) {
1319
- let t = D.current;
1320
- _ && (e.scrollTop = t.scrollTop + (e.scrollHeight - t.scrollHeight)), D.current = null;
1321
- } else s && _ && E.current && (e.scrollTop = e.scrollHeight);
1322
- C.current = v.length, w.current = t, T.current = n;
1316
+ let t = rt(o, _[0]), n = rt(o, _[_.length - 1]), r = !x.current, i = _.length > S.current && S.current > 0, a = i && (g && t !== C.current && n === w.current || !g && n !== w.current && t === C.current), s = i && !a;
1317
+ if (r) g && v === "bottom" && (e.scrollTop = e.scrollHeight), x.current = !0;
1318
+ else if (a && E.current) {
1319
+ let t = E.current;
1320
+ g && (e.scrollTop = t.scrollTop + (e.scrollHeight - t.scrollHeight)), E.current = null;
1321
+ } else s && g && T.current && (e.scrollTop = e.scrollHeight);
1322
+ S.current = _.length, C.current = t, w.current = n;
1323
1323
  }, [
1324
- v,
1325
- y,
1326
1324
  _,
1327
- i
1325
+ v,
1326
+ g,
1327
+ o
1328
1328
  ]);
1329
- let O = U(() => {
1330
- let e = b.current;
1331
- e && (E.current = e.scrollHeight - e.scrollTop - e.clientHeight < tt);
1329
+ let D = U(() => {
1330
+ let e = y.current;
1331
+ e && (T.current = e.scrollHeight - e.scrollTop - e.clientHeight < tt);
1332
1332
  }, []);
1333
1333
  W(() => {
1334
- let e = x.current;
1334
+ let e = b.current;
1335
1335
  if (!e || typeof IntersectionObserver > "u") return;
1336
1336
  let t = new IntersectionObserver((e) => {
1337
- for (let t of e) t.isIntersecting && c && !l && s();
1337
+ for (let t of e) t.isIntersecting && u && !d && l();
1338
1338
  }, {
1339
- root: b.current ?? null,
1339
+ root: y.current ?? null,
1340
1340
  rootMargin: `${nt}px 0px 0px 0px`,
1341
1341
  threshold: 0
1342
1342
  });
1343
1343
  return t.observe(e), () => t.disconnect();
1344
1344
  }, [
1345
- c,
1346
- l,
1347
- s
1345
+ u,
1346
+ d,
1347
+ l
1348
1348
  ]);
1349
- let [k, A] = q(null);
1350
- if (!i) return /* @__PURE__ */ Y("div", {
1349
+ let [O, A] = q(null);
1350
+ if (!o) return /* @__PURE__ */ Y("div", {
1351
1351
  style: {
1352
1352
  fontSize: 12.5,
1353
1353
  color: "var(--text-3)",
@@ -1355,21 +1355,21 @@ function at({ config: e, parentEntity: t, parentId: n, schema: r }) {
1355
1355
  },
1356
1356
  children: "Entity not found."
1357
1357
  });
1358
- let j = e.quick_add?.fields ?? [m?.content_field].filter(Boolean), M = f(i.display?.name_plural) || f(i.display?.name) || e.entity, ee = c ? /* @__PURE__ */ Y("div", {
1358
+ let j = e.quick_add?.fields ?? [m?.content_field].filter(Boolean), M = k(o.display?.name_plural) || k(o.display?.name) || e.entity, ee = u ? /* @__PURE__ */ Y("div", {
1359
1359
  style: {
1360
1360
  display: "flex",
1361
1361
  justifyContent: "center",
1362
1362
  padding: "6px 0"
1363
1363
  },
1364
- children: /* @__PURE__ */ Y(u, {
1364
+ children: /* @__PURE__ */ Y(r, {
1365
1365
  size: "xs",
1366
- onClick: () => s(),
1367
- disabled: l,
1368
- icon: l ? /* @__PURE__ */ Y(g, { size: 11 }) : void 0,
1369
- children: l ? "Loading…" : "Load older"
1366
+ onClick: () => l(),
1367
+ disabled: d,
1368
+ icon: d ? /* @__PURE__ */ Y(a, { size: 11 }) : void 0,
1369
+ children: d ? "Loading…" : "Load older"
1370
1370
  })
1371
1371
  }) : null, N = /* @__PURE__ */ Y("div", {
1372
- ref: x,
1372
+ ref: b,
1373
1373
  "aria-hidden": "true",
1374
1374
  style: { height: 1 }
1375
1375
  }), P;
@@ -1381,7 +1381,7 @@ function at({ config: e, parentEntity: t, parentId: n, schema: r }) {
1381
1381
  },
1382
1382
  children: "Failed to load."
1383
1383
  });
1384
- else if (d) P = /* @__PURE__ */ X("div", {
1384
+ else if (f) P = /* @__PURE__ */ X("div", {
1385
1385
  style: {
1386
1386
  display: "flex",
1387
1387
  flexDirection: "column",
@@ -1398,7 +1398,7 @@ function at({ config: e, parentEntity: t, parentId: n, schema: r }) {
1398
1398
  borderRadius: 8
1399
1399
  } })]
1400
1400
  });
1401
- else if (v.length === 0) P = /* @__PURE__ */ X(J, { children: [N, /* @__PURE__ */ Y("div", {
1401
+ else if (_.length === 0) P = /* @__PURE__ */ X(J, { children: [N, /* @__PURE__ */ Y("div", {
1402
1402
  style: {
1403
1403
  fontSize: 12.5,
1404
1404
  color: "var(--text-3)",
@@ -1407,42 +1407,42 @@ function at({ config: e, parentEntity: t, parentId: n, schema: r }) {
1407
1407
  children: "No activity yet."
1408
1408
  })] });
1409
1409
  else {
1410
- let a = (a, s) => {
1411
- let c = rt(i, a) || String(s);
1410
+ let r = (r, a) => {
1411
+ let s = rt(o, r) || String(a);
1412
1412
  return /* @__PURE__ */ Y(ot, {
1413
- row: a,
1414
- rowId: c,
1415
- childEntity: i,
1413
+ row: r,
1414
+ rowId: s,
1415
+ childEntity: o,
1416
1416
  entityCode: e.entity,
1417
1417
  parentEntity: t,
1418
1418
  parentId: n,
1419
1419
  timeline: m,
1420
1420
  editableFields: j,
1421
- refs: o,
1422
- isEditing: k === c,
1423
- onStartEdit: () => A(c),
1421
+ refs: c,
1422
+ isEditing: O === s,
1423
+ onStartEdit: () => A(s),
1424
1424
  onCancelEdit: () => A(null),
1425
1425
  onSaved: () => A(null),
1426
- schema: r,
1427
- optimistic: it(a)
1428
- }, c);
1429
- }, s = m?.time_field, c;
1430
- if (s) {
1426
+ schema: i,
1427
+ optimistic: it(r)
1428
+ }, s);
1429
+ }, a = m?.time_field, s;
1430
+ if (a) {
1431
1431
  let e = [];
1432
- v.forEach((t, n) => {
1433
- let r = t[s], i = st(r), a = e[e.length - 1];
1434
- !a || a.key !== i ? e.push({
1432
+ _.forEach((t, n) => {
1433
+ let r = t[a], i = st(r), o = e[e.length - 1];
1434
+ !o || o.key !== i ? e.push({
1435
1435
  key: i,
1436
1436
  label: ct(r),
1437
1437
  rows: [{
1438
1438
  row: t,
1439
1439
  idx: n
1440
1440
  }]
1441
- }) : a.rows.push({
1441
+ }) : o.rows.push({
1442
1442
  row: t,
1443
1443
  idx: n
1444
1444
  });
1445
- }), c = e.map((e) => /* @__PURE__ */ X("div", {
1445
+ }), s = e.map((e) => /* @__PURE__ */ X("div", {
1446
1446
  style: {
1447
1447
  display: "flex",
1448
1448
  flexDirection: "column",
@@ -1451,13 +1451,13 @@ function at({ config: e, parentEntity: t, parentId: n, schema: r }) {
1451
1451
  children: [/* @__PURE__ */ Y(lt, {
1452
1452
  label: e.label,
1453
1453
  count: e.rows.length
1454
- }), e.rows.map(({ row: e, idx: t }) => a(e, t))]
1454
+ }), e.rows.map(({ row: e, idx: t }) => r(e, t))]
1455
1455
  }, `day-${e.key}`));
1456
- } else c = v.map((e, t) => a(e, t));
1456
+ } else s = _.map((e, t) => r(e, t));
1457
1457
  P = /* @__PURE__ */ X(J, { children: [
1458
1458
  N,
1459
1459
  ee,
1460
- c
1460
+ s
1461
1461
  ] });
1462
1462
  }
1463
1463
  return h ? /* @__PURE__ */ X("div", {
@@ -1486,8 +1486,8 @@ function at({ config: e, parentEntity: t, parentId: n, schema: r }) {
1486
1486
  })
1487
1487
  }),
1488
1488
  /* @__PURE__ */ Y("div", {
1489
- ref: b,
1490
- onScroll: O,
1489
+ ref: y,
1490
+ onScroll: D,
1491
1491
  style: {
1492
1492
  flex: 1,
1493
1493
  overflowY: "auto",
@@ -1502,7 +1502,7 @@ function at({ config: e, parentEntity: t, parentId: n, schema: r }) {
1502
1502
  config: e,
1503
1503
  parentEntity: t,
1504
1504
  parentId: n,
1505
- schema: r
1505
+ schema: i
1506
1506
  })
1507
1507
  ]
1508
1508
  }) : /* @__PURE__ */ X("div", { children: [/* @__PURE__ */ Y("div", {
@@ -1516,48 +1516,48 @@ function at({ config: e, parentEntity: t, parentId: n, schema: r }) {
1516
1516
  config: e,
1517
1517
  parentEntity: t,
1518
1518
  parentId: n,
1519
- schema: r
1519
+ schema: i
1520
1520
  })] });
1521
1521
  }
1522
- function ot({ row: t, rowId: n, childEntity: r, entityCode: a, parentEntity: o, parentId: s, timeline: f, editableFields: p, refs: m, isEditing: h, onStartEdit: _, onCancelEdit: v, onSaved: b, schema: C, optimistic: T = !1 }) {
1523
- let E = ge(), D = S(), [O, k] = q({}), A = U(() => {
1524
- E.invalidateQueries({ queryKey: [
1522
+ function ot({ row: t, rowId: i, childEntity: o, entityCode: s, parentEntity: u, parentId: d, timeline: f, editableFields: p, refs: m, isEditing: h, onStartEdit: g, onCancelEdit: v, onSaved: b, schema: C, optimistic: w = !1 }) {
1523
+ let T = ge(), E = y(), [D, k] = q({}), A = U(() => {
1524
+ T.invalidateQueries({ queryKey: [
1525
1525
  M,
1526
- o,
1527
- s,
1528
- a
1526
+ u,
1527
+ d,
1528
+ s
1529
1529
  ] });
1530
1530
  }, [
1531
- E,
1532
- o,
1533
- s,
1534
- a
1531
+ T,
1532
+ u,
1533
+ d,
1534
+ s
1535
1535
  ]), j = he({
1536
1536
  mutationFn: (e) => {
1537
- let r = t.$row_version;
1538
- return w(a, n, typeof r == "string" && r !== "" ? {
1537
+ let n = t.$row_version;
1538
+ return x(s, i, typeof n == "string" && n !== "" ? {
1539
1539
  ...e,
1540
- $row_version: r
1540
+ $row_version: n
1541
1541
  } : e);
1542
1542
  },
1543
1543
  onSuccess: () => {
1544
- A(), l.success("Updated"), b();
1544
+ A(), c.success("Updated"), b();
1545
1545
  },
1546
- onError: (e) => l.error(e.message)
1546
+ onError: (e) => c.error(e.message)
1547
1547
  }), ee = he({
1548
- mutationFn: () => x(a, n),
1548
+ mutationFn: () => S(s, i),
1549
1549
  onSuccess: () => {
1550
- A(), l.success("Deleted");
1550
+ A(), c.success("Deleted");
1551
1551
  },
1552
- onError: (e) => l.error(e.message)
1552
+ onError: (e) => c.error(e.message)
1553
1553
  }), N = U(() => {
1554
1554
  let e = {};
1555
1555
  for (let n of p) e[n] = t[n] ?? "";
1556
- k(e), _();
1556
+ k(e), g();
1557
1557
  }, [
1558
1558
  t,
1559
1559
  p,
1560
- _
1560
+ g
1561
1561
  ]), P = U((e, t) => {
1562
1562
  k((n) => ({
1563
1563
  ...n,
@@ -1575,7 +1575,7 @@ function ot({ row: t, rowId: n, childEntity: r, entityCode: a, parentEntity: o,
1575
1575
  gap: 8
1576
1576
  },
1577
1577
  children: [p.map((e) => {
1578
- let t = r.fields.get(e);
1578
+ let t = o.fields.get(e);
1579
1579
  return t ? /* @__PURE__ */ X("div", { children: [/* @__PURE__ */ Y("label", {
1580
1580
  style: {
1581
1581
  fontSize: 11,
@@ -1583,15 +1583,15 @@ function ot({ row: t, rowId: n, childEntity: r, entityCode: a, parentEntity: o,
1583
1583
  marginBottom: 4,
1584
1584
  display: "block"
1585
1585
  },
1586
- children: d(t, e, C.entities)
1587
- }), y({
1586
+ children: O(t, e, C.entities)
1587
+ }), _({
1588
1588
  field: t,
1589
1589
  fieldName: e,
1590
- value: O[e] ?? "",
1590
+ value: D[e] ?? "",
1591
1591
  mode: "edit",
1592
1592
  onChange: (t) => P(e, t),
1593
- record: O,
1594
- locale: D
1593
+ record: D,
1594
+ locale: E
1595
1595
  })] }, e) : null;
1596
1596
  }), /* @__PURE__ */ X("div", {
1597
1597
  style: {
@@ -1600,14 +1600,14 @@ function ot({ row: t, rowId: n, childEntity: r, entityCode: a, parentEntity: o,
1600
1600
  gap: 6,
1601
1601
  paddingTop: 4
1602
1602
  },
1603
- children: [/* @__PURE__ */ Y(u, {
1603
+ children: [/* @__PURE__ */ Y(r, {
1604
1604
  kind: "primary",
1605
1605
  size: "xs",
1606
- icon: j.isPending ? /* @__PURE__ */ Y(g, { size: 12 }) : /* @__PURE__ */ Y(e.check, { size: 12 }),
1607
- onClick: () => j.mutate(O),
1606
+ icon: j.isPending ? /* @__PURE__ */ Y(a, { size: 12 }) : /* @__PURE__ */ Y(e.check, { size: 12 }),
1607
+ onClick: () => j.mutate(D),
1608
1608
  disabled: j.isPending,
1609
1609
  children: j.isPending ? "Saving…" : "Save"
1610
- }), /* @__PURE__ */ Y(u, {
1610
+ }), /* @__PURE__ */ Y(r, {
1611
1611
  size: "xs",
1612
1612
  icon: /* @__PURE__ */ Y(e.x, { size: 12 }),
1613
1613
  onClick: () => {
@@ -1619,14 +1619,14 @@ function ot({ row: t, rowId: n, childEntity: r, entityCode: a, parentEntity: o,
1619
1619
  })]
1620
1620
  }) : /* @__PURE__ */ X("div", {
1621
1621
  className: "group",
1622
- "data-optimistic": T || void 0,
1622
+ "data-optimistic": w || void 0,
1623
1623
  style: {
1624
1624
  borderRadius: 10,
1625
1625
  border: "1px solid var(--border)",
1626
1626
  background: "var(--surface)",
1627
1627
  padding: 12,
1628
1628
  transition: "border-color .12s",
1629
- opacity: T ? .6 : 1
1629
+ opacity: w ? .6 : 1
1630
1630
  },
1631
1631
  onMouseEnter: (e) => e.currentTarget.style.borderColor = "var(--border-strong)",
1632
1632
  onMouseLeave: (e) => e.currentTarget.style.borderColor = "var(--border)",
@@ -1641,74 +1641,74 @@ function ot({ row: t, rowId: n, childEntity: r, entityCode: a, parentEntity: o,
1641
1641
  color: "var(--text-3)"
1642
1642
  },
1643
1643
  children: [
1644
- F && t[F] != null && r.fields.get(F) && /* @__PURE__ */ Y("span", {
1644
+ F && t[F] != null && o.fields.get(F) && /* @__PURE__ */ Y("span", {
1645
1645
  style: { fontWeight: 500 },
1646
- children: y({
1647
- field: r.fields.get(F),
1646
+ children: _({
1647
+ field: o.fields.get(F),
1648
1648
  fieldName: F,
1649
1649
  value: t[F],
1650
1650
  mode: "display",
1651
1651
  record: t,
1652
1652
  refs: m,
1653
- locale: D
1653
+ locale: E
1654
1654
  })
1655
1655
  }),
1656
- I && t[I] != null && r.fields.get(I) && /* @__PURE__ */ Y(i, {
1656
+ I && t[I] != null && o.fields.get(I) && /* @__PURE__ */ Y(l, {
1657
1657
  tone: "slate",
1658
1658
  size: "xs",
1659
- children: y({
1660
- field: r.fields.get(I),
1659
+ children: _({
1660
+ field: o.fields.get(I),
1661
1661
  fieldName: I,
1662
1662
  value: t[I],
1663
1663
  mode: "display",
1664
1664
  record: t,
1665
1665
  refs: m,
1666
- locale: D
1666
+ locale: E
1667
1667
  })
1668
1668
  }),
1669
- B && t[B] != null && r.fields.get(B) && /* @__PURE__ */ Y(ut, {
1669
+ B && t[B] != null && o.fields.get(B) && /* @__PURE__ */ Y(ut, {
1670
1670
  value: t[B],
1671
- field: r.fields.get(B)
1671
+ field: o.fields.get(B)
1672
1672
  }),
1673
- V && t[V] != null && r.fields.get(V) && /* @__PURE__ */ Y(i, {
1673
+ V && t[V] != null && o.fields.get(V) && /* @__PURE__ */ Y(l, {
1674
1674
  tone: "slate",
1675
1675
  size: "xs",
1676
- children: y({
1677
- field: r.fields.get(V),
1676
+ children: _({
1677
+ field: o.fields.get(V),
1678
1678
  fieldName: V,
1679
1679
  value: t[V],
1680
1680
  mode: "display",
1681
1681
  record: t,
1682
1682
  refs: m,
1683
- locale: D
1683
+ locale: E
1684
1684
  })
1685
1685
  }),
1686
- z && t[z] != null && r.fields.get(z) && /* @__PURE__ */ X("span", { children: [
1686
+ z && t[z] != null && o.fields.get(z) && /* @__PURE__ */ X("span", { children: [
1687
1687
  "by",
1688
1688
  " ",
1689
- y({
1690
- field: r.fields.get(z),
1689
+ _({
1690
+ field: o.fields.get(z),
1691
1691
  fieldName: z,
1692
1692
  value: t[z],
1693
1693
  mode: "display",
1694
1694
  record: t,
1695
1695
  refs: m,
1696
- locale: D
1696
+ locale: E
1697
1697
  })
1698
1698
  ] }),
1699
- !T && /* @__PURE__ */ X("div", {
1699
+ !w && /* @__PURE__ */ X("div", {
1700
1700
  style: {
1701
1701
  marginLeft: "auto",
1702
1702
  display: "flex",
1703
1703
  alignItems: "center",
1704
1704
  gap: 2
1705
1705
  },
1706
- children: [/* @__PURE__ */ Y(c, {
1706
+ children: [/* @__PURE__ */ Y(n, {
1707
1707
  size: 22,
1708
1708
  icon: /* @__PURE__ */ Y(e.edit, { size: 11 }),
1709
1709
  onClick: N,
1710
1710
  title: "Edit"
1711
- }), /* @__PURE__ */ Y(c, {
1711
+ }), /* @__PURE__ */ Y(n, {
1712
1712
  size: 22,
1713
1713
  icon: /* @__PURE__ */ Y(e.trash, { size: 11 }),
1714
1714
  onClick: () => ee.mutate(),
@@ -1717,36 +1717,36 @@ function ot({ row: t, rowId: n, childEntity: r, entityCode: a, parentEntity: o,
1717
1717
  })
1718
1718
  ]
1719
1719
  }),
1720
- L && t[L] != null && r.fields.get(L) && /* @__PURE__ */ Y("div", {
1720
+ L && t[L] != null && o.fields.get(L) && /* @__PURE__ */ Y("div", {
1721
1721
  style: {
1722
1722
  fontSize: 12.5,
1723
1723
  fontWeight: 500,
1724
1724
  marginTop: 6
1725
1725
  },
1726
- children: y({
1727
- field: r.fields.get(L),
1726
+ children: _({
1727
+ field: o.fields.get(L),
1728
1728
  fieldName: L,
1729
1729
  value: t[L],
1730
1730
  mode: "display",
1731
1731
  record: t,
1732
1732
  refs: m,
1733
- locale: D
1733
+ locale: E
1734
1734
  })
1735
1735
  }),
1736
- R && t[R] != null && R !== L && r.fields.get(R) && /* @__PURE__ */ Y("div", {
1736
+ R && t[R] != null && R !== L && o.fields.get(R) && /* @__PURE__ */ Y("div", {
1737
1737
  style: {
1738
1738
  fontSize: 12.5,
1739
1739
  fontWeight: 400,
1740
1740
  marginTop: 6
1741
1741
  },
1742
- children: y({
1743
- field: r.fields.get(R),
1742
+ children: _({
1743
+ field: o.fields.get(R),
1744
1744
  fieldName: R,
1745
1745
  value: t[R],
1746
1746
  mode: "display",
1747
1747
  record: t,
1748
1748
  refs: m,
1749
- locale: D
1749
+ locale: E
1750
1750
  })
1751
1751
  })
1752
1752
  ]
@@ -1754,12 +1754,12 @@ function ot({ row: t, rowId: n, childEntity: r, entityCode: a, parentEntity: o,
1754
1754
  }
1755
1755
  function st(e) {
1756
1756
  if (e == null) return "";
1757
- let t = new Date(A(e));
1757
+ let t = new Date(p(e));
1758
1758
  return Number.isNaN(t.getTime()) ? "" : `${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`;
1759
1759
  }
1760
1760
  function ct(e) {
1761
1761
  if (e == null) return "—";
1762
- let t = new Date(A(e));
1762
+ let t = new Date(p(e));
1763
1763
  if (Number.isNaN(t.getTime())) return "—";
1764
1764
  let n = /* @__PURE__ */ new Date(), r = /* @__PURE__ */ new Date();
1765
1765
  r.setDate(n.getDate() - 1);
@@ -1835,68 +1835,68 @@ function dt(e, t) {
1835
1835
  }
1836
1836
  //#endregion
1837
1837
  //#region src/components/detail-layout/EditableChildrenTable.tsx
1838
- function ft({ config: t, childEntity: n, schema: r, rows: i, onChange: a, validationErrors: s, refs: l, forceTablePresentation: f = !1 }) {
1839
- let p = S(), m = o(), h = K(null), g = t.columns, _ = t.position_field, v = new Set(Array.isArray(t.foreign_key) ? t.foreign_key : [t.foreign_key]), b = g.filter((e) => {
1838
+ function ft({ config: t, childEntity: i, schema: a, rows: o, onChange: s, validationErrors: c, refs: l, forceTablePresentation: u = !1 }) {
1839
+ let d = y(), f = A(), m = K(null), h = t.columns, g = t.position_field, v = new Set(Array.isArray(t.foreign_key) ? t.foreign_key : [t.foreign_key]), b = h.filter((e) => {
1840
1840
  if (v.has(e) || t.position_field && e === t.position_field) return !1;
1841
- let r = n.fields.get(e);
1842
- return !(!r || r.auto || r.primary || r.source);
1843
- }), x = new Set(g.filter((e) => {
1841
+ let n = i.fields.get(e);
1842
+ return !(!n || n.auto || n.primary || n.source);
1843
+ }), x = new Set(h.filter((e) => {
1844
1844
  if (t.position_field && e === t.position_field) return !0;
1845
- let r = n.fields.get(e);
1846
- return r && (r.auto || r.primary || r.source);
1847
- })), C = U((e, t, n) => {
1848
- a(i.map((r) => r._key === e ? {
1845
+ let n = i.fields.get(e);
1846
+ return n && (n.auto || n.primary || n.source);
1847
+ })), S = U((e, t, n) => {
1848
+ s(o.map((r) => r._key === e ? {
1849
1849
  ...r,
1850
1850
  [t]: n,
1851
1851
  _dirty: !0
1852
1852
  } : r));
1853
- }, [i, a]), w = U(() => {
1853
+ }, [o, s]), C = U(() => {
1854
1854
  let e = {
1855
1855
  _key: crypto.randomUUID(),
1856
1856
  _dirty: !0
1857
1857
  };
1858
- _ && (e[_] = i.filter((e) => !e._deleted).reduce((e, t) => {
1859
- let n = typeof t[_] == "number" ? t[_] : -1;
1858
+ g && (e[g] = o.filter((e) => !e._deleted).reduce((e, t) => {
1859
+ let n = typeof t[g] == "number" ? t[g] : -1;
1860
1860
  return Math.max(e, n);
1861
1861
  }, -1) + 1);
1862
- let r = t.quick_add?.defaults ?? {};
1862
+ let n = t.quick_add?.defaults ?? {};
1863
1863
  for (let t of b) {
1864
- let i = n.fields.get(t);
1865
- i && (r[t] === void 0 ? i.default === void 0 ? i.type === "bool" && (e[t] = !1) : e[t] = i.default : e[t] = r[t]);
1864
+ let r = i.fields.get(t);
1865
+ r && (n[t] === void 0 ? r.default === void 0 ? r.type === "bool" && (e[t] = !1) : e[t] = r.default : e[t] = n[t]);
1866
1866
  }
1867
- a([...i, e]);
1867
+ s([...o, e]);
1868
1868
  }, [
1869
- i,
1870
- a,
1869
+ o,
1870
+ s,
1871
1871
  b,
1872
- n,
1872
+ i,
1873
1873
  t.quick_add?.defaults,
1874
- _
1875
- ]), T = U((e) => {
1876
- a(i.map((t) => t._key === e ? {
1874
+ g
1875
+ ]), w = U((e) => {
1876
+ s(o.map((t) => t._key === e ? {
1877
1877
  ...t,
1878
1878
  _deleted: !0
1879
1879
  } : t));
1880
- }, [i, a]), E = U((e) => {
1881
- a(i.map((t) => t._key === e ? {
1880
+ }, [o, s]), T = U((e) => {
1881
+ s(o.map((t) => t._key === e ? {
1882
1882
  ...t,
1883
1883
  _deleted: !1
1884
1884
  } : t));
1885
- }, [i, a]), D = U((e, t) => {
1886
- if (!_) return;
1887
- let n = i.filter((e) => !e._deleted), r = i.filter((e) => e._deleted), o = n.findIndex((t) => t._key === e), s = o + t;
1888
- if (o < 0 || s < 0 || s >= n.length) return;
1889
- let c = [...n], [l] = c.splice(o, 1);
1890
- c.splice(s, 0, l), a([...c.map((e, t) => ({
1885
+ }, [o, s]), E = U((e, t) => {
1886
+ if (!g) return;
1887
+ let n = o.filter((e) => !e._deleted), r = o.filter((e) => e._deleted), i = n.findIndex((t) => t._key === e), a = i + t;
1888
+ if (i < 0 || a < 0 || a >= n.length) return;
1889
+ let c = [...n], [l] = c.splice(i, 1);
1890
+ c.splice(a, 0, l), s([...c.map((e, t) => ({
1891
1891
  ...e,
1892
- [_]: t,
1893
- _dirty: e[_] === t ? e._dirty : !0
1892
+ [g]: t,
1893
+ _dirty: e[g] === t ? e._dirty : !0
1894
1894
  })), ...r]);
1895
1895
  }, [
1896
- i,
1897
- a,
1898
- _
1899
- ]), O = U((e) => {
1896
+ o,
1897
+ s,
1898
+ g
1899
+ ]), D = U((e) => {
1900
1900
  let t = e.target, n = t.closest("td");
1901
1901
  if (!n) return;
1902
1902
  let r = n.closest("tr");
@@ -1920,7 +1920,7 @@ function ft({ config: t, childEntity: n, schema: r, rows: i, onChange: a, valida
1920
1920
  if (o < t.length - 1) {
1921
1921
  let e = t[o + 1].cells[a]?.querySelector("input, select, textarea, [tabindex]");
1922
1922
  e && e.focus();
1923
- } else w(), requestAnimationFrame(() => {
1923
+ } else C(), requestAnimationFrame(() => {
1924
1924
  let e = i.querySelectorAll("tr"), t = e[e.length - 1];
1925
1925
  if (t) {
1926
1926
  let e = t.querySelector("input, select, textarea, [tabindex]");
@@ -1928,21 +1928,21 @@ function ft({ config: t, childEntity: n, schema: r, rows: i, onChange: a, valida
1928
1928
  }
1929
1929
  });
1930
1930
  } else e.key === "Escape" && t.blur?.();
1931
- }, [w]), k = oe;
1932
- return m.isPhone && !f ? /* @__PURE__ */ X("div", { children: [/* @__PURE__ */ Y("div", {
1931
+ }, [C]), k = oe;
1932
+ return f.isPhone && !u ? /* @__PURE__ */ X("div", { children: [/* @__PURE__ */ Y("div", {
1933
1933
  style: {
1934
1934
  display: "flex",
1935
1935
  flexDirection: "column",
1936
1936
  gap: 10
1937
1937
  },
1938
- children: i.map((t, a) => {
1939
- let o = !!t._deleted, u = s?.[t._key], f = _ ? i.filter((e) => !e._deleted) : [], m = _ ? f.findIndex((e) => e._key === t._key) : -1;
1938
+ children: o.map((t, r) => {
1939
+ let s = !!t._deleted, u = c?.[t._key], f = g ? o.filter((e) => !e._deleted) : [], m = g ? f.findIndex((e) => e._key === t._key) : -1;
1940
1940
  return /* @__PURE__ */ X("div", {
1941
1941
  style: {
1942
1942
  border: "1px solid var(--border)",
1943
1943
  borderRadius: 8,
1944
1944
  background: "var(--surface)",
1945
- opacity: o ? .58 : 1,
1945
+ opacity: s ? .58 : 1,
1946
1946
  overflow: "hidden"
1947
1947
  },
1948
1948
  children: [/* @__PURE__ */ X("div", {
@@ -1961,34 +1961,34 @@ function ft({ config: t, childEntity: n, schema: r, rows: i, onChange: a, valida
1961
1961
  fontWeight: 600,
1962
1962
  color: "var(--text-2)"
1963
1963
  },
1964
- children: ["Row ", a + 1]
1964
+ children: ["Row ", r + 1]
1965
1965
  }), /* @__PURE__ */ X("div", {
1966
1966
  style: {
1967
1967
  display: "flex",
1968
1968
  alignItems: "center",
1969
1969
  gap: 4
1970
1970
  },
1971
- children: [_ && !o && /* @__PURE__ */ X(J, { children: [/* @__PURE__ */ Y(c, {
1971
+ children: [g && !s && /* @__PURE__ */ X(J, { children: [/* @__PURE__ */ Y(n, {
1972
1972
  size: 32,
1973
1973
  icon: /* @__PURE__ */ Y(e.up, { size: 14 }),
1974
- onClick: () => D(t._key, -1),
1974
+ onClick: () => E(t._key, -1),
1975
1975
  disabled: m <= 0,
1976
1976
  title: "Move row up"
1977
- }), /* @__PURE__ */ Y(c, {
1977
+ }), /* @__PURE__ */ Y(n, {
1978
1978
  size: 32,
1979
1979
  icon: /* @__PURE__ */ Y(e.down, { size: 14 }),
1980
- onClick: () => D(t._key, 1),
1980
+ onClick: () => E(t._key, 1),
1981
1981
  disabled: m === -1 || m >= f.length - 1,
1982
1982
  title: "Move row down"
1983
- })] }), o ? /* @__PURE__ */ Y(c, {
1983
+ })] }), s ? /* @__PURE__ */ Y(n, {
1984
1984
  size: 32,
1985
1985
  icon: /* @__PURE__ */ Y(e.refresh, { size: 14 }),
1986
- onClick: () => E(t._key),
1986
+ onClick: () => T(t._key),
1987
1987
  title: "Undo delete"
1988
- }) : /* @__PURE__ */ Y(c, {
1988
+ }) : /* @__PURE__ */ Y(n, {
1989
1989
  size: 32,
1990
1990
  icon: /* @__PURE__ */ Y(e.trash, { size: 14 }),
1991
- onClick: () => T(t._key),
1991
+ onClick: () => w(t._key),
1992
1992
  title: "Delete row"
1993
1993
  })]
1994
1994
  })]
@@ -1999,26 +1999,26 @@ function ft({ config: t, childEntity: n, schema: r, rows: i, onChange: a, valida
1999
1999
  flexDirection: "column",
2000
2000
  gap: 12
2001
2001
  },
2002
- children: g.map((e) => {
2003
- let i = n.fields.get(e), a = u?.includes(e), s = x.has(e), c = i ? d(i, e, r.entities) : e, f = `child-${t._key}-${e}`, m = `${f}-label`, h = {
2004
- outline: a ? "1px solid var(--danger)" : "none",
2002
+ children: h.map((e) => {
2003
+ let n = i.fields.get(e), r = u?.includes(e), o = x.has(e), c = n ? O(n, e, a.entities) : e, f = `child-${t._key}-${e}`, m = `${f}-label`, h = {
2004
+ outline: r ? "1px solid var(--danger)" : "none",
2005
2005
  outlineOffset: 3,
2006
- borderRadius: a ? 5 : 0
2006
+ borderRadius: r ? 5 : 0
2007
2007
  }, g = {
2008
2008
  fontSize: 11.5,
2009
2009
  fontWeight: 600,
2010
2010
  color: "var(--text-3)"
2011
- }, _ = !o && !s && !!i;
2011
+ }, v = !s && !o && !!n;
2012
2012
  return /* @__PURE__ */ X("div", {
2013
2013
  style: {
2014
2014
  display: "flex",
2015
2015
  flexDirection: "column",
2016
2016
  gap: 5,
2017
2017
  minWidth: 0,
2018
- textDecoration: o ? "line-through" : "none"
2018
+ textDecoration: s ? "line-through" : "none"
2019
2019
  },
2020
- title: a ? `${e} is required` : void 0,
2021
- children: [_ ? /* @__PURE__ */ Y("label", {
2020
+ title: r ? `${e} is required` : void 0,
2021
+ children: [v ? /* @__PURE__ */ Y("label", {
2022
2022
  id: m,
2023
2023
  htmlFor: f,
2024
2024
  style: g,
@@ -2029,8 +2029,8 @@ function ft({ config: t, childEntity: n, schema: r, rows: i, onChange: a, valida
2029
2029
  children: c
2030
2030
  }), /* @__PURE__ */ Y("div", {
2031
2031
  style: h,
2032
- children: o || s ? i ? y({
2033
- field: i,
2032
+ children: s || o ? n ? _({
2033
+ field: n,
2034
2034
  fieldName: e,
2035
2035
  value: t[e],
2036
2036
  mode: "display",
@@ -2038,20 +2038,20 @@ function ft({ config: t, childEntity: n, schema: r, rows: i, onChange: a, valida
2038
2038
  refs: l,
2039
2039
  fieldId: f,
2040
2040
  labelId: m,
2041
- locale: p
2042
- }) : A(t[e]) : i ? y({
2043
- field: i,
2041
+ locale: d
2042
+ }) : p(t[e]) : n ? _({
2043
+ field: n,
2044
2044
  fieldName: e,
2045
2045
  value: t[e],
2046
2046
  mode: "edit",
2047
- onChange: (n) => C(t._key, e, n),
2047
+ onChange: (n) => S(t._key, e, n),
2048
2048
  record: t,
2049
2049
  refs: l,
2050
2050
  compact: !0,
2051
2051
  fieldId: f,
2052
2052
  labelId: m,
2053
- locale: p
2054
- }) : A(t[e])
2053
+ locale: d
2054
+ }) : p(t[e])
2055
2055
  })]
2056
2056
  }, e);
2057
2057
  })
@@ -2060,34 +2060,34 @@ function ft({ config: t, childEntity: n, schema: r, rows: i, onChange: a, valida
2060
2060
  })
2061
2061
  }), /* @__PURE__ */ Y("div", {
2062
2062
  style: { marginTop: 10 },
2063
- children: /* @__PURE__ */ Y(u, {
2063
+ children: /* @__PURE__ */ Y(r, {
2064
2064
  kind: "ghost",
2065
2065
  size: "sm",
2066
2066
  icon: /* @__PURE__ */ Y(e.plus, { size: 14 }),
2067
- onClick: w,
2067
+ onClick: C,
2068
2068
  children: "Add row"
2069
2069
  })
2070
2070
  })] }) : /* @__PURE__ */ X("div", { children: [/* @__PURE__ */ Y("div", {
2071
2071
  style: { overflowX: "auto" },
2072
2072
  children: /* @__PURE__ */ X("table", {
2073
- ref: h,
2073
+ ref: m,
2074
2074
  style: se,
2075
- onKeyDown: O,
2076
- children: [/* @__PURE__ */ Y("thead", { children: /* @__PURE__ */ X("tr", { children: [g.map((e) => {
2077
- let t = n.fields.get(e);
2075
+ onKeyDown: D,
2076
+ children: [/* @__PURE__ */ Y("thead", { children: /* @__PURE__ */ X("tr", { children: [h.map((e) => {
2077
+ let t = i.fields.get(e);
2078
2078
  return /* @__PURE__ */ Y("th", {
2079
2079
  style: k,
2080
- children: t ? d(t, e, r.entities) : e
2080
+ children: t ? O(t, e, a.entities) : e
2081
2081
  }, e);
2082
2082
  }), /* @__PURE__ */ Y("th", { style: {
2083
2083
  ...k,
2084
2084
  width: 40
2085
- } })] }) }), /* @__PURE__ */ Y("tbody", { children: i.map((t) => {
2086
- let r = !!t._deleted, i = s?.[t._key];
2085
+ } })] }) }), /* @__PURE__ */ Y("tbody", { children: o.map((t) => {
2086
+ let r = !!t._deleted, a = c?.[t._key];
2087
2087
  return /* @__PURE__ */ X("tr", {
2088
2088
  style: { opacity: r ? .5 : 1 },
2089
- children: [g.map((e) => {
2090
- let a = n.fields.get(e), o = i?.includes(e), s = x.has(e);
2089
+ children: [h.map((e) => {
2090
+ let n = i.fields.get(e), o = a?.includes(e), s = x.has(e);
2091
2091
  return r || s ? /* @__PURE__ */ Y("td", {
2092
2092
  style: {
2093
2093
  padding: "6px 12px",
@@ -2096,15 +2096,15 @@ function ft({ config: t, childEntity: n, schema: r, rows: i, onChange: a, valida
2096
2096
  textDecoration: r ? "line-through" : "none",
2097
2097
  color: "var(--text-2)"
2098
2098
  },
2099
- children: a ? y({
2100
- field: a,
2099
+ children: n ? _({
2100
+ field: n,
2101
2101
  fieldName: e,
2102
2102
  value: t[e],
2103
2103
  mode: "display",
2104
2104
  record: t,
2105
2105
  refs: l,
2106
- locale: p
2107
- }) : A(t[e])
2106
+ locale: d
2107
+ }) : p(t[e])
2108
2108
  }, e) : /* @__PURE__ */ Y("td", {
2109
2109
  style: {
2110
2110
  padding: "4px 4px",
@@ -2115,17 +2115,17 @@ function ft({ config: t, childEntity: n, schema: r, rows: i, onChange: a, valida
2115
2115
  borderRadius: o ? 4 : 0
2116
2116
  },
2117
2117
  title: o ? `${e} is required` : void 0,
2118
- children: a ? y({
2119
- field: a,
2118
+ children: n ? _({
2119
+ field: n,
2120
2120
  fieldName: e,
2121
2121
  value: t[e],
2122
2122
  mode: "edit",
2123
- onChange: (n) => C(t._key, e, n),
2123
+ onChange: (n) => S(t._key, e, n),
2124
2124
  record: t,
2125
2125
  refs: l,
2126
2126
  compact: !0,
2127
- locale: p
2128
- }) : A(t[e])
2127
+ locale: d
2128
+ }) : p(t[e])
2129
2129
  }, e);
2130
2130
  }), /* @__PURE__ */ Y("td", {
2131
2131
  style: {
@@ -2133,15 +2133,15 @@ function ft({ config: t, childEntity: n, schema: r, rows: i, onChange: a, valida
2133
2133
  borderBottom: "1px solid var(--divider)",
2134
2134
  verticalAlign: "middle"
2135
2135
  },
2136
- children: r ? /* @__PURE__ */ Y(c, {
2136
+ children: r ? /* @__PURE__ */ Y(n, {
2137
2137
  size: 24,
2138
2138
  icon: /* @__PURE__ */ Y(e.refresh, { size: 12 }),
2139
- onClick: () => E(t._key),
2139
+ onClick: () => T(t._key),
2140
2140
  title: "Undo delete"
2141
- }) : /* @__PURE__ */ Y(c, {
2141
+ }) : /* @__PURE__ */ Y(n, {
2142
2142
  size: 24,
2143
2143
  icon: /* @__PURE__ */ Y(e.trash, { size: 12 }),
2144
- onClick: () => T(t._key),
2144
+ onClick: () => w(t._key),
2145
2145
  title: "Delete row"
2146
2146
  })
2147
2147
  })]
@@ -2150,48 +2150,48 @@ function ft({ config: t, childEntity: n, schema: r, rows: i, onChange: a, valida
2150
2150
  })
2151
2151
  }), /* @__PURE__ */ Y("div", {
2152
2152
  style: { marginTop: 8 },
2153
- children: /* @__PURE__ */ Y(u, {
2153
+ children: /* @__PURE__ */ Y(r, {
2154
2154
  kind: "ghost",
2155
2155
  size: "xs",
2156
2156
  icon: /* @__PURE__ */ Y(e.plus, { size: 12 }),
2157
- onClick: w,
2157
+ onClick: C,
2158
2158
  children: "Add row"
2159
2159
  })
2160
2160
  })] });
2161
2161
  }
2162
2162
  //#endregion
2163
2163
  //#region src/components/detail-layout/ChildrenBlock.tsx
2164
- var pt = H(() => import("./DraggableChildrenTable-ChUh120M.js").then((e) => ({ default: e.DraggableChildrenTable })));
2164
+ var pt = H(() => import("./DraggableChildrenTable-BfErdVdt.js").then((e) => ({ default: e.DraggableChildrenTable })));
2165
2165
  function mt({ node: e, ctx: n }) {
2166
- let r = o(), i = e.children;
2166
+ let r = A(), i = e.children;
2167
2167
  if (!i) return null;
2168
2168
  let a = r.isPhone && n.relatedRecordsPresentation === "table";
2169
2169
  if (n.isNew && n.mode !== "edit") return null;
2170
- let s = ze(n.entity, i);
2171
- if (!s) return /* @__PURE__ */ X("div", {
2170
+ let o = ze(n.entity, i);
2171
+ if (!o) return /* @__PURE__ */ X("div", {
2172
2172
  className: "text-sm text-muted-foreground py-2",
2173
2173
  children: ["Unknown child relation: ", i]
2174
2174
  });
2175
- let c = n.schema.entities[s.entity];
2176
- if (!c) return /* @__PURE__ */ X("div", {
2175
+ let s = n.schema.entities[o.entity];
2176
+ if (!s) return /* @__PURE__ */ X("div", {
2177
2177
  className: "text-sm text-muted-foreground py-2",
2178
- children: ["Entity not found: ", s.entity]
2178
+ children: ["Entity not found: ", o.entity]
2179
2179
  });
2180
- let l = De(s, c, e), u = Z(e, n), d = we(e, n), f = (e) => l.mode === "timeline" || n.withinCard ? e : /* @__PURE__ */ Y(N, {
2181
- title: u,
2182
- icon: d ? /* @__PURE__ */ Y(t, {
2183
- name: d,
2180
+ let c = De(o, s, e), l = Z(e, n), u = we(e, n), f = (e) => c.mode === "timeline" || n.withinCard ? e : /* @__PURE__ */ Y(N, {
2181
+ title: l,
2182
+ icon: u ? /* @__PURE__ */ Y(t, {
2183
+ name: u,
2184
2184
  size: 14
2185
2185
  }) : void 0,
2186
2186
  children: e
2187
2187
  });
2188
- if (n.mode === "edit" && l.editable && l.interaction !== "navigate" && l.interaction !== "readonly" && T(c, "update") && l.mode === "table" && n.pendingChildren !== void 0 && n.onChildrenChange) {
2189
- let e = n.pendingChildren[i] ?? [], t = n.childValidationErrors?.[i], o = l.position_field ? r.isPhone && !a ? ft : pt : ft;
2188
+ if (n.mode === "edit" && c.editable && c.interaction !== "navigate" && c.interaction !== "readonly" && d(s, "update") && c.mode === "table" && n.pendingChildren !== void 0 && n.onChildrenChange) {
2189
+ let e = n.pendingChildren[i] ?? [], t = n.childValidationErrors?.[i], o = c.position_field ? r.isPhone && !a ? ft : pt : ft;
2190
2190
  return f(/* @__PURE__ */ Y(le, {
2191
2191
  fallback: /* @__PURE__ */ Y(P, {}),
2192
2192
  children: /* @__PURE__ */ Y(o, {
2193
- config: l,
2194
- childEntity: c,
2193
+ config: c,
2194
+ childEntity: s,
2195
2195
  schema: n.schema,
2196
2196
  rows: e,
2197
2197
  onChange: (e) => n.onChildrenChange(i, e),
@@ -2203,12 +2203,12 @@ function mt({ node: e, ctx: n }) {
2203
2203
  }
2204
2204
  if (n.isNew) return null;
2205
2205
  let p = {
2206
- config: l,
2206
+ config: c,
2207
2207
  parentEntity: n.entityCode,
2208
2208
  parentId: n.recordId,
2209
2209
  schema: n.schema
2210
2210
  };
2211
- switch (l.mode) {
2211
+ switch (c.mode) {
2212
2212
  case "list": return f(/* @__PURE__ */ Y(Ge, { ...p }));
2213
2213
  case "cards": return f(/* @__PURE__ */ Y(Ke, { ...p }));
2214
2214
  case "timeline": return f(/* @__PURE__ */ Y(at, { ...p }));
@@ -2249,8 +2249,8 @@ function xt({ columns: e = 2, children: t }) {
2249
2249
  })
2250
2250
  });
2251
2251
  }
2252
- function St({ label: t, children: n, span: r = !1, required: i, error: o, hint: s, actions: c, copyValue: l, mode: u = "display", htmlFor: d, labelId: f, labelTitle: p, "data-testid": m }) {
2253
- let h = de(bt), g = r || h.columns === 1, _ = !!o;
2252
+ function St({ label: t, children: n, span: r = !1, required: i, error: a, hint: o, actions: c, copyValue: l, mode: u = "display", htmlFor: d, labelId: f, labelTitle: p, "data-testid": m }) {
2253
+ let h = de(bt), g = r || h.columns === 1, _ = !!a;
2254
2254
  return /* @__PURE__ */ X("div", {
2255
2255
  className: "detail-row",
2256
2256
  "data-error": _ || void 0,
@@ -2333,13 +2333,13 @@ function St({ label: t, children: n, span: r = !1, required: i, error: o, hint:
2333
2333
  flexShrink: 0,
2334
2334
  marginTop: -2
2335
2335
  },
2336
- children: [l && /* @__PURE__ */ Y(a, {
2336
+ children: [l && /* @__PURE__ */ Y(s, {
2337
2337
  value: l,
2338
2338
  size: "sm",
2339
2339
  title: "Copy value"
2340
2340
  }), c]
2341
2341
  })]
2342
- }), (_ || s != null) && /* @__PURE__ */ X("div", {
2342
+ }), (_ || o != null) && /* @__PURE__ */ X("div", {
2343
2343
  style: {
2344
2344
  fontSize: 11.5,
2345
2345
  lineHeight: 1.4,
@@ -2348,7 +2348,7 @@ function St({ label: t, children: n, span: r = !1, required: i, error: o, hint:
2348
2348
  alignItems: "center",
2349
2349
  gap: 4
2350
2350
  },
2351
- children: [_ && /* @__PURE__ */ Y(e.warning, { size: 11 }), /* @__PURE__ */ Y("span", { children: _ ? o : s })]
2351
+ children: [_ && /* @__PURE__ */ Y(e.warning, { size: 11 }), /* @__PURE__ */ Y("span", { children: _ ? a : o })]
2352
2352
  })]
2353
2353
  })]
2354
2354
  });
@@ -2356,11 +2356,11 @@ function St({ label: t, children: n, span: r = !1, required: i, error: o, hint:
2356
2356
  //#endregion
2357
2357
  //#region src/components/detail-layout/FieldsBlock.tsx
2358
2358
  function Ct({ fields: e, ctx: t }) {
2359
- let { entity: n, entityCode: r, record: i, mode: a, onFieldChange: o, schema: s } = t, c = S(), l = t.columns ?? 2, u = l === 1 && e.length === 1;
2359
+ let { entity: n, entityCode: r, record: i, mode: a, onFieldChange: o, schema: s } = t, c = y(), l = t.columns ?? 2, u = l === 1 && e.length === 1;
2360
2360
  return /* @__PURE__ */ Y(xt, {
2361
2361
  columns: l,
2362
2362
  children: e.map((e) => {
2363
- let l = e.name, d = `${r ?? "field"}-${l}`, p = `${d}-label`, m = n.fields.get(l), h = !!(m?.auto || m?.readonly || m?.source), g = I(n, l), _ = g?.read === "denied", v = g?.write === "denied", y = a === "display" ? _ : v || _, b = h || a === "edit" && v ? "display" : a, x = y ? /* @__PURE__ */ Y(ae, {
2363
+ let l = e.name, d = `${r ?? "field"}-${l}`, f = `${d}-label`, m = n.fields.get(l), h = !!(m?.auto || m?.readonly || m?.source), g = I(n, l), _ = g?.read === "denied", v = g?.write === "denied", y = a === "display" ? _ : v || _, b = h || a === "edit" && v ? "display" : a, x = y ? /* @__PURE__ */ Y(ae, {
2364
2364
  tier: g.classification,
2365
2365
  tierDef: ie(s, n, l),
2366
2366
  requiredPermission: g?.required_permission,
@@ -2378,7 +2378,7 @@ function Ct({ fields: e, ctx: t }) {
2378
2378
  screens: s?.screens,
2379
2379
  locale: c,
2380
2380
  fieldId: d,
2381
- labelId: p
2381
+ labelId: f
2382
2382
  });
2383
2383
  if (!x) return null;
2384
2384
  let S = a === "display" && e.actions && e.actions.length > 0 ? /* @__PURE__ */ Y(J, { children: e.actions.map((e, t) => /* @__PURE__ */ Y(R, {
@@ -2388,7 +2388,7 @@ function Ct({ fields: e, ctx: t }) {
2388
2388
  row: i,
2389
2389
  variant: "ghost",
2390
2390
  size: "icon"
2391
- }, t)) }) : void 0, C = !!m && yt.has(m.type), w = i?.[l], T = b === "display" && (m?.copyable || m?.type === "uuid") && w != null && w !== "" ? A(w) : void 0, E = f(m?.display?.description);
2391
+ }, t)) }) : void 0, C = !!m && yt.has(m.type), w = i?.[l], T = b === "display" && (m?.copyable || m?.type === "uuid") && w != null && w !== "" ? p(w) : void 0, E = k(m?.display?.description);
2392
2392
  return u ? /* @__PURE__ */ X("div", {
2393
2393
  style: { gridColumn: "1 / -1" },
2394
2394
  children: [x, b === "edit" && E && /* @__PURE__ */ Y("div", {
@@ -2403,7 +2403,7 @@ function Ct({ fields: e, ctx: t }) {
2403
2403
  }, l) : /* @__PURE__ */ Y(St, {
2404
2404
  label: re(n, l, s.entities),
2405
2405
  htmlFor: b === "edit" ? d : void 0,
2406
- labelId: p,
2406
+ labelId: f,
2407
2407
  labelTitle: E || void 0,
2408
2408
  required: m?.required ?? !1,
2409
2409
  mode: b,
@@ -2435,7 +2435,7 @@ function Et({ node: e, ctx: t }) {
2435
2435
  return u.length === 0 ? null : /* @__PURE__ */ Y(xt, {
2436
2436
  columns: 2,
2437
2437
  children: u.map(([e, a]) => {
2438
- let c = r?.find((t) => t.property_code === e), l = C(a), u = a.readonly || !i ? "display" : o;
2438
+ let c = r?.find((t) => t.property_code === e), l = b(a), u = a.readonly || !i ? "display" : o;
2439
2439
  return /* @__PURE__ */ Y(Dt, {
2440
2440
  propCode: e,
2441
2441
  prop: a,
@@ -2451,7 +2451,7 @@ function Et({ node: e, ctx: t }) {
2451
2451
  });
2452
2452
  }
2453
2453
  function Dt({ propCode: e, prop: t, field: n, value: r, mode: i, onSetProperty: a, refs: o, entity: s, schema: c }) {
2454
- let l = S(), u = K(null);
2454
+ let l = y(), u = K(null);
2455
2455
  W(() => () => {
2456
2456
  u.current && clearTimeout(u.current);
2457
2457
  }, []);
@@ -2461,23 +2461,23 @@ function Dt({ propCode: e, prop: t, field: n, value: r, mode: i, onSetProperty:
2461
2461
  e,
2462
2462
  t.type,
2463
2463
  a
2464
- ]), p = I(s, e), m = p?.read === "denied", h = p?.write === "denied", g = i === "display" ? m : h || m, _ = i === "edit" && h ? "display" : i;
2464
+ ]), f = I(s, e), p = f?.read === "denied", m = f?.write === "denied", h = i === "display" ? p : m || p, g = i === "edit" && m ? "display" : i;
2465
2465
  return /* @__PURE__ */ Y(St, {
2466
- label: f(t.display?.name ?? t.name),
2467
- mode: _,
2466
+ label: k(t.display?.name ?? t.name),
2467
+ mode: g,
2468
2468
  span: yt.has(t.type),
2469
- children: g ? /* @__PURE__ */ Y(ae, {
2470
- tier: p.classification,
2469
+ children: h ? /* @__PURE__ */ Y(ae, {
2470
+ tier: f.classification,
2471
2471
  tierDef: ie(c, s, e),
2472
- requiredPermission: p?.required_permission,
2472
+ requiredPermission: f?.required_permission,
2473
2473
  locale: l,
2474
- variant: _ === "edit" ? "input" : "value"
2475
- }) : y({
2474
+ variant: g === "edit" ? "input" : "value"
2475
+ }) : _({
2476
2476
  field: n,
2477
2477
  fieldName: e,
2478
2478
  value: r,
2479
- mode: _,
2480
- onChange: _ === "edit" ? d : void 0,
2479
+ mode: g,
2480
+ onChange: g === "edit" ? d : void 0,
2481
2481
  refs: o,
2482
2482
  locale: l
2483
2483
  })
@@ -2552,7 +2552,7 @@ function Ot({ stages: t, current: n, selectable: r, onSelect: i, compact: a = !1
2552
2552
  }
2553
2553
  //#endregion
2554
2554
  //#region src/components/shared/StatusGroupsDisplay.tsx
2555
- function kt({ statusGroups: e, objectStatuses: t, onSetStatus: r, isPending: a, mode: o = "edit" }) {
2555
+ function kt({ statusGroups: e, objectStatuses: t, onSetStatus: n, isPending: r, mode: i = "edit" }) {
2556
2556
  return /* @__PURE__ */ Y("div", {
2557
2557
  style: {
2558
2558
  display: "flex",
@@ -2560,10 +2560,10 @@ function kt({ statusGroups: e, objectStatuses: t, onSetStatus: r, isPending: a,
2560
2560
  alignItems: "center",
2561
2561
  gap: 16
2562
2562
  },
2563
- children: Object.entries(e).map(([e, s]) => {
2564
- let c = t?.find((t) => t.group_code === e)?.status_code, l = c ? s.statuses.find((e) => e.code === c) : void 0;
2565
- if (s.display_mode === "stepper") {
2566
- let t = o === "edit", n = t ? s.transitions && c ? /* @__PURE__ */ new Set([c, ...s.transitions[c] ?? []]) : new Set(s.statuses.map((e) => e.code)) : void 0;
2563
+ children: Object.entries(e).map(([e, a]) => {
2564
+ let s = t?.find((t) => t.group_code === e)?.status_code, c = s ? a.statuses.find((e) => e.code === s) : void 0;
2565
+ if (a.display_mode === "stepper") {
2566
+ let t = i === "edit", o = t ? a.transitions && s ? /* @__PURE__ */ new Set([s, ...a.transitions[s] ?? []]) : new Set(a.statuses.map((e) => e.code)) : void 0;
2567
2567
  return /* @__PURE__ */ X("div", {
2568
2568
  style: {
2569
2569
  display: "flex",
@@ -2577,27 +2577,27 @@ function kt({ statusGroups: e, objectStatuses: t, onSetStatus: r, isPending: a,
2577
2577
  color: "var(--text-3)",
2578
2578
  flexShrink: 0
2579
2579
  },
2580
- children: [f(s.name), ":"]
2580
+ children: [k(a.name), ":"]
2581
2581
  }), /* @__PURE__ */ Y("div", {
2582
2582
  style: {
2583
2583
  minWidth: 240,
2584
- opacity: a ? .6 : 1,
2585
- pointerEvents: a ? "none" : "auto"
2584
+ opacity: r ? .6 : 1,
2585
+ pointerEvents: r ? "none" : "auto"
2586
2586
  },
2587
2587
  children: /* @__PURE__ */ Y(Ot, {
2588
- stages: s.statuses.map((e) => ({
2588
+ stages: a.statuses.map((e) => ({
2589
2589
  code: e.code,
2590
- label: f(e.name)
2590
+ label: k(e.name)
2591
2591
  })),
2592
- current: c,
2593
- selectable: n,
2594
- onSelect: t ? (t) => r(e, t) : void 0,
2592
+ current: s,
2593
+ selectable: o,
2594
+ onSelect: t ? (t) => n(e, t) : void 0,
2595
2595
  compact: !0
2596
2596
  })
2597
2597
  })]
2598
2598
  }, e);
2599
2599
  }
2600
- if (o === "display") return /* @__PURE__ */ X("div", {
2600
+ if (i === "display") return /* @__PURE__ */ X("div", {
2601
2601
  style: {
2602
2602
  display: "flex",
2603
2603
  alignItems: "center",
@@ -2608,11 +2608,11 @@ function kt({ statusGroups: e, objectStatuses: t, onSetStatus: r, isPending: a,
2608
2608
  fontSize: 12,
2609
2609
  color: "var(--text-3)"
2610
2610
  },
2611
- children: [f(s.name), ":"]
2612
- }), l ? /* @__PURE__ */ Y(i, {
2613
- tone: l.color ?? "slate",
2611
+ children: [k(a.name), ":"]
2612
+ }), c ? /* @__PURE__ */ Y(l, {
2613
+ tone: c.color ?? "slate",
2614
2614
  size: "xs",
2615
- children: f(l.name)
2615
+ children: k(c.name)
2616
2616
  }) : /* @__PURE__ */ Y("span", {
2617
2617
  style: {
2618
2618
  fontSize: 12.5,
@@ -2621,7 +2621,7 @@ function kt({ statusGroups: e, objectStatuses: t, onSetStatus: r, isPending: a,
2621
2621
  children: "—"
2622
2622
  })]
2623
2623
  }, e);
2624
- let u = (s.transitions && c ? s.statuses.filter((e) => e.code === c || (s.transitions[c]?.includes(e.code) ?? !1)) : s.statuses).map((e) => ({
2624
+ let u = (a.transitions && s ? a.statuses.filter((e) => e.code === s || (a.transitions[s]?.includes(e.code) ?? !1)) : a.statuses).map((e) => ({
2625
2625
  value: e.code,
2626
2626
  label: /* @__PURE__ */ X("span", {
2627
2627
  style: {
@@ -2635,7 +2635,7 @@ function kt({ statusGroups: e, objectStatuses: t, onSetStatus: r, isPending: a,
2635
2635
  borderRadius: 999,
2636
2636
  background: `var(--pill-${e.color}, ${e.color})`,
2637
2637
  display: "inline-block"
2638
- } }), f(e.name)]
2638
+ } }), k(e.name)]
2639
2639
  })
2640
2640
  }));
2641
2641
  return /* @__PURE__ */ X("div", {
@@ -2649,17 +2649,17 @@ function kt({ statusGroups: e, objectStatuses: t, onSetStatus: r, isPending: a,
2649
2649
  fontSize: 12,
2650
2650
  color: "var(--text-3)"
2651
2651
  },
2652
- children: [f(s.name), ":"]
2652
+ children: [k(a.name), ":"]
2653
2653
  }), /* @__PURE__ */ Y("div", {
2654
2654
  style: {
2655
2655
  minWidth: 180,
2656
- opacity: a ? .6 : 1,
2657
- pointerEvents: a ? "none" : "auto"
2656
+ opacity: r ? .6 : 1,
2657
+ pointerEvents: r ? "none" : "auto"
2658
2658
  },
2659
- children: /* @__PURE__ */ Y(n, {
2660
- value: c ?? "",
2659
+ children: /* @__PURE__ */ Y(o, {
2660
+ value: s ?? "",
2661
2661
  options: u,
2662
- onChange: (t) => r(e, t),
2662
+ onChange: (t) => n(e, t),
2663
2663
  placeholder: "Select…"
2664
2664
  })
2665
2665
  })]