@declarion/react 0.57.0 → 0.59.2

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 (166) hide show
  1. package/README.md +0 -2
  2. package/dist-lib/AgentChatPanel.impl-DBH1Ff4G.js +1200 -0
  3. package/dist-lib/DetailAuditStrip-9eJM2Fml.js +288 -0
  4. package/dist-lib/{DraggableChildrenTable-BV5sb8Uo.js → DraggableChildrenTable-4RZC351U.js} +87 -86
  5. package/dist-lib/Grid-CQabaBLx.js +405 -0
  6. package/dist-lib/{LayoutRenderer-C9AH9cXf.js → LayoutRenderer-DGKWZKpW.js} +1000 -1114
  7. package/dist-lib/{ListCardsBody-DXcDg536.js → ListCardsBody-DfGmyNIu.js} +84 -84
  8. package/dist-lib/MarkdownRenderer-BDbzDv_y.js +87 -0
  9. package/dist-lib/{RefreshControl-CNtN8zSl.js → RefreshControl-Bhoib0ZA.js} +126 -155
  10. package/dist-lib/SmartDetailPage.impl-DFjz29Ff.js +1565 -0
  11. package/dist-lib/SmartListPage.impl-BrZLE_Gb.js +3046 -0
  12. package/dist-lib/{SmartRecordListPage.impl-Bkl9aZJ8.js → SmartRecordListPage.impl-C1FJLr80.js} +281 -280
  13. package/dist-lib/SortHeaderMenu-Cijxk4cX.js +107 -0
  14. package/dist-lib/action-dispatch-DY0c8U81.js +1967 -0
  15. package/dist-lib/api/client.d.ts +5 -0
  16. package/dist-lib/api/data.d.ts +2 -4
  17. package/dist-lib/api/entities.d.ts +8 -15
  18. package/dist-lib/api/events.d.ts +3 -3
  19. package/dist-lib/cardProjection-Bkl2SSYz.js +499 -0
  20. package/dist-lib/components/actions/ResponsiveActionBar.d.ts +17 -16
  21. package/dist-lib/components/agents/AgentChatPanel.d.ts +3 -13
  22. package/dist-lib/components/agents/AgentChatPanel.impl.d.ts +14 -0
  23. package/dist-lib/components/agents/AgentPicker.d.ts +1 -2
  24. package/dist-lib/components/chrome/PageShell.d.ts +7 -0
  25. package/dist-lib/components/chrome/RecordHeader.d.ts +1 -2
  26. package/dist-lib/components/chrome/headerActionZone.d.ts +27 -0
  27. package/dist-lib/components/detail-layout/DetailAuditStrip.d.ts +1 -2
  28. package/dist-lib/components/detail-layout/DetailHighlights.d.ts +1 -2
  29. package/dist-lib/components/detail-layout/blockMeta.d.ts +2 -1
  30. package/dist-lib/components/fields/BoolField.d.ts +1 -1
  31. package/dist-lib/components/fields/EnumField.d.ts +1 -1
  32. package/dist-lib/components/fields/IntArrayField.d.ts +1 -1
  33. package/dist-lib/components/fields/MultilangArrayField.d.ts +2 -0
  34. package/dist-lib/components/fields/MultilangField.d.ts +1 -1
  35. package/dist-lib/components/fields/MultilangTextField.d.ts +1 -1
  36. package/dist-lib/components/fields/NumberField.d.ts +1 -1
  37. package/dist-lib/components/fields/PasswordField.d.ts +1 -1
  38. package/dist-lib/components/fields/RefCombobox.d.ts +1 -1
  39. package/dist-lib/components/fields/SecretField.d.ts +1 -1
  40. package/dist-lib/components/fields/StringArrayField.d.ts +1 -1
  41. package/dist-lib/components/fields/TimestampField.d.ts +1 -1
  42. package/dist-lib/components/fields/cells/registry.d.ts +2 -1
  43. package/dist-lib/components/fields/index.d.ts +2 -1
  44. package/dist-lib/components/fields/langMap.d.ts +2 -0
  45. package/dist-lib/components/fields/secretValue.d.ts +2 -0
  46. package/dist-lib/components/file-widgets/UnknownFileWidget.d.ts +3 -0
  47. package/dist-lib/components/file-widgets/UploadFailureText.d.ts +4 -0
  48. package/dist-lib/components/file-widgets/helpers.d.ts +1 -1
  49. package/dist-lib/components/file-widgets/host.d.ts +4 -3
  50. package/dist-lib/components/file-widgets/types.d.ts +1 -0
  51. package/dist-lib/components/file-widgets/upload.d.ts +18 -3
  52. package/dist-lib/components/filters/filter-op-label.d.ts +3 -0
  53. package/dist-lib/components/layout/ImpersonationBanner.d.ts +1 -1
  54. package/dist-lib/components/layout/ImpersonationFrame.d.ts +1 -1
  55. package/dist-lib/components/layout/Layout.d.ts +2 -1
  56. package/dist-lib/components/layout/Sidebar.d.ts +2 -1
  57. package/dist-lib/components/layout/TenantChip.d.ts +1 -1
  58. package/dist-lib/components/list/ViewSwitcher.d.ts +4 -2
  59. package/dist-lib/components/pages/DocumentsMenu.d.ts +1 -2
  60. package/dist-lib/components/pages/ExportMenu.d.ts +3 -5
  61. package/dist-lib/components/pages/RecordDocumentsPanel.d.ts +1 -2
  62. package/dist-lib/components/pages/auth/AuthShell.d.ts +4 -31
  63. package/dist-lib/components/pages/exportRequest.d.ts +4 -6
  64. package/dist-lib/components/pages/list/DeleteViewDialog.d.ts +8 -0
  65. package/dist-lib/components/pages/list/ListCardRow.d.ts +1 -2
  66. package/dist-lib/components/pages/list/ListCardsBody.d.ts +0 -1
  67. package/dist-lib/components/pages/list/ListFloatbar.d.ts +2 -2
  68. package/dist-lib/components/pages/list/ListHeader.d.ts +2 -2
  69. package/dist-lib/components/pages/list/ListNoRows.d.ts +4 -5
  70. package/dist-lib/components/pages/list/ListToolbar.d.ts +3 -2
  71. package/dist-lib/components/pages/list/ListUrlBanner.d.ts +10 -0
  72. package/dist-lib/components/pages/list/RowActionsCell.d.ts +2 -4
  73. package/dist-lib/components/pages/list/RowContextMenu.d.ts +1 -2
  74. package/dist-lib/components/pages/list/columns.d.ts +2 -1
  75. package/dist-lib/components/pages/list/filter-meta.d.ts +2 -1
  76. package/dist-lib/components/pages/list/useActiveView.d.ts +38 -0
  77. package/dist-lib/components/pages/list/useListColumnLayout.d.ts +6 -5
  78. package/dist-lib/components/pages/list/useListQuery.d.ts +4 -4
  79. package/dist-lib/components/pages/list/useListSort.d.ts +5 -4
  80. package/dist-lib/components/pages/list/useListViews.d.ts +18 -8
  81. package/dist-lib/components/pages/list/useRowMenu.d.ts +2 -3
  82. package/dist-lib/components/pages/profile/Profile.d.ts +3 -0
  83. package/dist-lib/components/params/ParamsBlock.d.ts +1 -13
  84. package/dist-lib/components/params/param-editors.d.ts +3 -11
  85. package/dist-lib/components/primitives/ClassifiedFieldLocked.d.ts +1 -2
  86. package/dist-lib/components/shared/DynamicIcon.d.ts +2 -2
  87. package/dist-lib/components/shared/LoadingSkeleton.d.ts +1 -0
  88. package/dist-lib/components/shared/LucideIcon.d.ts +1 -1
  89. package/dist-lib/components/shared/useOwnRefresh.d.ts +1 -1
  90. package/dist-lib/declarion-react.css +1 -1
  91. package/dist-lib/embed/theme.d.ts +1 -1
  92. package/dist-lib/embed/useEmbedNavigate.d.ts +1 -1
  93. package/dist-lib/failure-v-uGSpbX.js +158 -0
  94. package/dist-lib/{field-classification-D6xQYn-h.js → field-classification-C28XE-_P.js} +514 -307
  95. package/dist-lib/format-count-DA4wmmWR.js +1771 -0
  96. package/dist-lib/hooks/useEntityData.d.ts +1 -1
  97. package/dist-lib/hooks/useFilters.d.ts +7 -5
  98. package/dist-lib/hooks/useLanguage.d.ts +4 -0
  99. package/dist-lib/hooks/useParams.d.ts +4 -51
  100. package/dist-lib/hooks/useRegisterScreenTab.d.ts +1 -1
  101. package/dist-lib/hooks/useSSE.d.ts +3 -3
  102. package/dist-lib/hooks/useTabTitle.d.ts +2 -0
  103. package/dist-lib/hooks/useText.d.ts +3 -3
  104. package/dist-lib/hooks/useVersionWatcher.d.ts +1 -1
  105. package/dist-lib/hooks/useViews.d.ts +20 -0
  106. package/dist-lib/index.d.ts +8 -7
  107. package/dist-lib/index.js +2716 -5803
  108. package/dist-lib/lib/action-dispatch.d.ts +2 -1
  109. package/dist-lib/lib/actions.d.ts +30 -42
  110. package/dist-lib/lib/anchor.d.ts +3 -4
  111. package/dist-lib/lib/decimal-text.d.ts +1 -0
  112. package/dist-lib/lib/document-templates.d.ts +1 -2
  113. package/dist-lib/lib/download.d.ts +2 -1
  114. package/dist-lib/lib/evidence-verdict.d.ts +2 -1
  115. package/dist-lib/lib/failure.d.ts +2 -0
  116. package/dist-lib/lib/field-classification.d.ts +3 -3
  117. package/dist-lib/lib/filters.d.ts +18 -2
  118. package/dist-lib/lib/format-count.d.ts +8 -7
  119. package/dist-lib/lib/language.d.ts +19 -0
  120. package/dist-lib/lib/mass-edit.d.ts +2 -1
  121. package/dist-lib/lib/realtime-query-keys.d.ts +1 -1
  122. package/dist-lib/lib/realtime-reconcile.d.ts +3 -4
  123. package/dist-lib/lib/screen-back.d.ts +4 -6
  124. package/dist-lib/lib/sort.d.ts +9 -9
  125. package/dist-lib/lib/timestamp.d.ts +5 -7
  126. package/dist-lib/lib/ui-actions.d.ts +2 -1
  127. package/dist-lib/peekDraftStore-D-cTbiIr.js +199 -0
  128. package/dist-lib/registry-Cb3W-czW.js +1950 -0
  129. package/dist-lib/safe-url-oSJw5pzO.js +34 -0
  130. package/dist-lib/stores/icon-registry.d.ts +2 -2
  131. package/dist-lib/stores/list-layout.d.ts +3 -4
  132. package/dist-lib/stores/realtime.d.ts +1 -1
  133. package/dist-lib/stores/tabs.d.ts +3 -2
  134. package/dist-lib/testing.d.ts +6 -0
  135. package/dist-lib/testing.js +98 -76
  136. package/dist-lib/types/api.d.ts +7 -8
  137. package/dist-lib/types/fieldType.d.ts +1 -1
  138. package/dist-lib/types/files.d.ts +4 -4
  139. package/dist-lib/types/schema.d.ts +44 -50
  140. package/dist-lib/useAgentConversation-D97IqE-J.js +623 -0
  141. package/dist-lib/{useCurrentScreen-CzwzQpoW.js → useCurrentScreen-BL5NZFCw.js} +2777 -3768
  142. package/dist-lib/useListQuery-BG1GyKtJ.js +103 -0
  143. package/dist-lib/useProperties-4Lg3odrt.js +83 -0
  144. package/dist-lib/{useTabSearchMirror-C39U85cg.js → useTabSearchMirror-ZVLlINBX.js} +49 -51
  145. package/dist-lib/useText-BFDCTUSo.js +952 -0
  146. package/dist-lib/{value-Bo8C8WMU.js → value-By1-WJ8J.js} +74 -76
  147. package/dist-lib/vite/fingerprint-plugin.d.ts +2 -3
  148. package/package.json +9 -9
  149. package/dist-lib/Grid-DWgUPuZ3.js +0 -404
  150. package/dist-lib/MarkdownRenderer-CcSFc2N3.js +0 -85
  151. package/dist-lib/RecordIdBadge-CGxPR-8q.js +0 -24
  152. package/dist-lib/SmartDetailPage.impl-lskCd-WG.js +0 -1846
  153. package/dist-lib/SmartListPage.impl-CrGbdzyK.js +0 -2854
  154. package/dist-lib/SortHeaderMenu-SYSAaqQJ.js +0 -106
  155. package/dist-lib/action-dispatch-CR4ajBtT.js +0 -1985
  156. package/dist-lib/cardProjection-CW5RIMko.js +0 -699
  157. package/dist-lib/components/pages/home/HomeStub.d.ts +0 -6
  158. package/dist-lib/components/pages/jobs/Jobs.d.ts +0 -1
  159. package/dist-lib/components/pages/pipeline/Pipeline.d.ts +0 -1
  160. package/dist-lib/format-count-Dobmi-Ji.js +0 -1551
  161. package/dist-lib/hooks/useUserLocale.d.ts +0 -1
  162. package/dist-lib/lib/messages.d.ts +0 -12
  163. package/dist-lib/peekDraftStore-5wQ7lq_V.js +0 -194
  164. package/dist-lib/registry-CjgUaF7C.js +0 -1768
  165. package/dist-lib/useListQuery-D7Hr5WM1.js +0 -96
  166. package/dist-lib/useProperties-CqtCzFCr.js +0 -81
@@ -0,0 +1,1967 @@
1
+ import { s as e, t } from "./DynamicIcon-DW5krHuX.js";
2
+ import { $ as n, L as r, Ln as i, Pn as a, R as o, Rn as s, U as c, _n as l, dt as u, ft as d, gt as f, ht as p, lt as m, mt as h, nn as g, pt as _, rn as v, rt as y, st as b, tt as x, ut as S, vn as C, yt as w } from "./useCurrentScreen-BL5NZFCw.js";
3
+ import { i as T, r as E, t as D, u as O } from "./useText-BFDCTUSo.js";
4
+ import { a as k, c as A, d as j, f as M, i as ee, l as te, m as N, n as P, o as F, p as I, r as L, s as R, t as z, u as ne } from "./value-By1-WJ8J.js";
5
+ import { Fragment as re, Suspense as B, lazy as V, useCallback as H, useEffect as U, useLayoutEffect as W, useMemo as ie, useRef as G, useState as K } from "react";
6
+ import { Fragment as q, jsx as J, jsxs as Y } from "react/jsx-runtime";
7
+ //#region src/components/file-widgets/registry.ts
8
+ var X = /* @__PURE__ */ new Map();
9
+ function Z(e, t) {
10
+ X.set(e, t);
11
+ }
12
+ function ae(e) {
13
+ return X.get(e);
14
+ }
15
+ function oe(e) {
16
+ return X.has(e);
17
+ }
18
+ //#endregion
19
+ //#region src/components/file-widgets/cropper.ts
20
+ var se = ({ file: e }) => Promise.resolve({
21
+ blob: e,
22
+ filename: e.name
23
+ }), ce = se;
24
+ function le(e) {
25
+ ce = e ?? se;
26
+ }
27
+ function Q() {
28
+ return ce;
29
+ }
30
+ //#endregion
31
+ //#region src/components/file-widgets/ImageWidget.tsx
32
+ function ue(e, t) {
33
+ return A(e, t);
34
+ }
35
+ function de(e) {
36
+ let t = e.trim().split(/\s+/).filter(Boolean);
37
+ return t.length === 1 ? t[0].slice(0, 2).toUpperCase() : (t[0][0] + t[1][0]).toUpperCase();
38
+ }
39
+ function fe(e) {
40
+ let { field: t, fieldName: n, value: r, onChange: i, mode: a, alt: o, recordTitle: s, disabled: c, visual: l, uploadFieldCode: u, uploadSlotCode: f } = e, g = P(r), [v, y] = K("idle"), [x, C] = K(null), [w, O] = K(null), [k, A] = K(null), [F, L] = K(!1), z = G(null), ne = G(!1), re = G(null), { register: B, unregister: V, isDraft: W } = b(), q = D(), X = D("errors");
41
+ U(() => () => {
42
+ z.current && z.current.abort();
43
+ }, []);
44
+ let Z = T(), ae = E(), oe = ie(() => M(g, o, n, Z, ae), [
45
+ o,
46
+ n,
47
+ g,
48
+ Z,
49
+ ae
50
+ ]), se = t.display?.initials ? s?.trim() : void 0, ce = (t.accepts ?? ["image/*"]).join(","), le = H(async (r) => {
51
+ let a = p(r, t.accepts, t.max_size_bytes);
52
+ if (a) {
53
+ O(d(q, X, a)), y("error");
54
+ return;
55
+ }
56
+ let o = r;
57
+ if (t.display?.crop_on_upload) try {
58
+ let { blob: e, filename: n } = await Q()({
59
+ file: r,
60
+ aspectRatio: ge(t.display.aspect_ratio)
61
+ });
62
+ o = new File([e], n, { type: e.type || r.type });
63
+ } catch {
64
+ O({
65
+ code: "file.crop_failed",
66
+ message: X("file.crop_failed", "The image could not be cropped.")
67
+ }), y("error");
68
+ return;
69
+ }
70
+ O(null), ne.current = !1, y("uploading"), C({
71
+ loaded: 0,
72
+ total: o.size,
73
+ pct: 0
74
+ });
75
+ let s = new AbortController();
76
+ z.current = s;
77
+ try {
78
+ let r = await h({
79
+ file: o,
80
+ entityCode: e.entityCode,
81
+ fieldCode: u ?? n,
82
+ slotCode: f,
83
+ signal: s.signal,
84
+ onProgress: C
85
+ });
86
+ if (ne.current) {
87
+ S(r.id).catch(() => {}), V(r.id);
88
+ return;
89
+ }
90
+ g && W(g.id) && (S(g.id).catch(() => {}), V(g.id)), B(r.id, () => S(r.id)), A(r.id), y("idle"), C(null);
91
+ let a = {
92
+ id: r.id,
93
+ filename: r.filename,
94
+ content_type: r.content_type,
95
+ size_bytes: r.size_bytes,
96
+ sha256: r.sha256,
97
+ width: r.width,
98
+ height: r.height,
99
+ url: r.url,
100
+ metadata: r.metadata
101
+ };
102
+ i?.(t.mode === "array" ? [a] : a);
103
+ } catch (e) {
104
+ if (e instanceof m && e.code === "ABORTED") return;
105
+ O(_(q, X, e)), y("error"), C(null);
106
+ }
107
+ }, [
108
+ X,
109
+ q,
110
+ t.accepts,
111
+ t.max_size_bytes,
112
+ t.display?.crop_on_upload,
113
+ t.display?.aspect_ratio,
114
+ t.mode,
115
+ n,
116
+ i,
117
+ e.entityCode,
118
+ B,
119
+ W,
120
+ g,
121
+ V,
122
+ u,
123
+ f
124
+ ]), de = H(() => {
125
+ v === "uploading" && z.current && (ne.current = !0, z.current.abort(), z.current = null, y("idle"), C(null)), k && (S(k).catch(() => {}), V(k), A(null));
126
+ }, [
127
+ v,
128
+ k,
129
+ V
130
+ ]), fe = H(() => {
131
+ g && W(g.id) && (S(g.id).catch(() => {}), V(g.id), A(null)), i?.(t.mode === "array" ? [] : null);
132
+ }, [
133
+ g,
134
+ t.mode,
135
+ W,
136
+ i,
137
+ V
138
+ ]), ye = H(() => {
139
+ O(null), y("idle"), re.current?.click();
140
+ }, []), be = H(() => {
141
+ c || re.current?.click();
142
+ }, [c]), xe = H((e) => {
143
+ c || (e.key === "Enter" || e.key === " ") && (e.preventDefault(), be());
144
+ }, [c, be]), Se = H((e) => {
145
+ c || (e.preventDefault(), e.dataTransfer.dropEffect = "copy");
146
+ }, [c]), Ce = H((e) => {
147
+ if (c) return;
148
+ e.preventDefault();
149
+ let t = e.dataTransfer.files?.[0];
150
+ t && le(t);
151
+ }, [c, le]), we = H((e) => {
152
+ let t = e.target.files?.[0];
153
+ e.target.value = "", t && le(t);
154
+ }, [le]), Te = l.aspectRatio ?? he(l.shape, t.display?.aspect_ratio), Ee = j(g), De = {
155
+ aspectRatio: Te,
156
+ width: l.width ?? (l.shape === "wide" ? "100%" : "120px")
157
+ }, Oe = !!g, ke = ue(g, t.display?.listable_thumbnail), Ae = te(g, t.display?.listable_thumbnail), je = ee(g?.id, Ae, ke), Me = a === "display", Ne = H((e) => {
158
+ e.stopPropagation(), L((e) => !e);
159
+ }, []), Pe = H((e) => {
160
+ if (!g || !F) return;
161
+ let n = e.currentTarget.getBoundingClientRect(), r = n.width > 0 ? (e.clientX - n.left) / n.width : .5, a = n.height > 0 ? (e.clientY - n.top) / n.height : .5, o = I(g, {
162
+ x: Math.max(0, Math.min(1, r)),
163
+ y: Math.max(0, Math.min(1, a))
164
+ });
165
+ i?.(t.mode === "array" ? [o] : o), L(!1);
166
+ }, [
167
+ t.mode,
168
+ g,
169
+ F,
170
+ i
171
+ ]);
172
+ return Me ? /* @__PURE__ */ J("div", {
173
+ className: pe(l.shape, !1),
174
+ style: De,
175
+ "aria-label": oe,
176
+ children: Oe && je ? /* @__PURE__ */ J("img", {
177
+ src: je,
178
+ alt: oe,
179
+ className: me(l.shape),
180
+ style: { objectPosition: R(Ee) },
181
+ loading: "lazy"
182
+ }) : /* @__PURE__ */ J(_e, {
183
+ shape: l.shape,
184
+ initialsTitle: se
185
+ })
186
+ }) : /* @__PURE__ */ Y("div", {
187
+ className: pe(l.shape, !c),
188
+ style: De,
189
+ tabIndex: c ? -1 : 0,
190
+ role: "button",
191
+ "aria-label": oe,
192
+ "aria-disabled": c || void 0,
193
+ "aria-busy": v === "uploading" || void 0,
194
+ "aria-invalid": v === "error" || void 0,
195
+ onClick: v === "idle" && !Oe ? be : void 0,
196
+ onMouseDown: F ? Pe : void 0,
197
+ onKeyDown: xe,
198
+ onDragOver: Se,
199
+ onDrop: Ce,
200
+ "data-testid": F ? "focal-point-target" : `file-widget-${n}`,
201
+ children: [
202
+ /* @__PURE__ */ J("input", {
203
+ ref: re,
204
+ type: "file",
205
+ accept: ce,
206
+ onChange: we,
207
+ style: { display: "none" },
208
+ "data-testid": `file-input-${n}`
209
+ }),
210
+ Oe && je ? /* @__PURE__ */ J("img", {
211
+ src: je,
212
+ alt: oe,
213
+ className: me(l.shape),
214
+ style: { objectPosition: R(Ee) },
215
+ loading: "lazy"
216
+ }) : v === "uploading" ? null : /* @__PURE__ */ J(_e, {
217
+ shape: l.shape,
218
+ initialsTitle: se
219
+ }),
220
+ v === "uploading" && /* @__PURE__ */ J(ve, {
221
+ pct: x?.pct ?? 0,
222
+ label: q("file.upload.progress", "Uploading {pct}%", { pct: Math.round(x?.pct ?? 0) })
223
+ }),
224
+ k && /* @__PURE__ */ J("span", {
225
+ className: "absolute right-1 top-1 h-2 w-2 rounded-full bg-warning",
226
+ "aria-hidden": "true",
227
+ "data-testid": "draft-indicator"
228
+ }),
229
+ Oe && v === "idle" && !c && /* @__PURE__ */ Y("div", {
230
+ className: "absolute inset-0 flex items-center justify-center gap-2 bg-black/40 opacity-0 transition-opacity hover:opacity-100 focus-within:opacity-100",
231
+ children: [
232
+ t.display?.focal_point && /* @__PURE__ */ J("button", {
233
+ type: "button",
234
+ className: "rounded-sm border border-border bg-card px-2 py-1 text-xs text-foreground hover:bg-surface-2",
235
+ onClick: Ne,
236
+ "data-testid": "focal-point-toggle",
237
+ children: F ? q("file.image.focus_cancel", "Cancel focus") : q("file.image.focus_set", "Set focus")
238
+ }),
239
+ /* @__PURE__ */ J("button", {
240
+ type: "button",
241
+ className: "rounded-sm border border-border bg-card px-2 py-1 text-xs text-foreground hover:bg-surface-2",
242
+ onClick: (e) => {
243
+ e.stopPropagation(), be();
244
+ },
245
+ children: q("file.image.change", "Change")
246
+ }),
247
+ /* @__PURE__ */ J("button", {
248
+ type: "button",
249
+ className: "rounded-sm border border-border bg-card px-2 py-1 text-xs text-destructive hover:bg-surface-2",
250
+ onClick: (e) => {
251
+ e.stopPropagation(), fe();
252
+ },
253
+ children: q("file.remove", "Remove")
254
+ })
255
+ ]
256
+ }),
257
+ Ee && Oe && /* @__PURE__ */ J("span", {
258
+ className: "absolute h-3 w-3 -translate-x-1/2 -translate-y-1/2 rounded-full border border-white bg-black/70",
259
+ style: {
260
+ left: `${Ee.x * 100}%`,
261
+ top: `${Ee.y * 100}%`
262
+ },
263
+ "data-testid": "focal-point-marker"
264
+ }),
265
+ v === "uploading" && /* @__PURE__ */ J("button", {
266
+ type: "button",
267
+ className: "absolute bottom-1 right-1 rounded-sm border border-border bg-card px-2 py-0.5 text-xs",
268
+ onClick: (e) => {
269
+ e.stopPropagation(), de();
270
+ },
271
+ "data-testid": "cancel-upload",
272
+ children: q("file.upload.cancel", "Cancel")
273
+ }),
274
+ v === "error" && w && /* @__PURE__ */ Y("div", {
275
+ className: "absolute inset-x-0 bottom-0 flex items-center justify-between gap-2 bg-destructive-soft px-2 py-1 text-xs text-destructive",
276
+ role: "alert",
277
+ children: [/* @__PURE__ */ J("span", {
278
+ className: "truncate",
279
+ title: w.message,
280
+ children: /* @__PURE__ */ J(N, { failure: w })
281
+ }), /* @__PURE__ */ J("button", {
282
+ type: "button",
283
+ className: "underline",
284
+ onClick: (e) => {
285
+ e.stopPropagation(), ye();
286
+ },
287
+ "data-testid": "retry-upload",
288
+ children: q("file.upload.retry", "Retry")
289
+ })]
290
+ })
291
+ ]
292
+ });
293
+ }
294
+ function pe(e, t) {
295
+ return [
296
+ "relative overflow-hidden border border-border bg-surface-2",
297
+ e === "circle" ? "rounded-full" : "rounded-md",
298
+ t ? "cursor-pointer focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent" : ""
299
+ ].filter(Boolean).join(" ");
300
+ }
301
+ function me(e) {
302
+ return "h-full w-full object-cover";
303
+ }
304
+ function he(e, t) {
305
+ return t ? t.replace(":", " / ") : e === "wide" ? "16 / 9" : "1 / 1";
306
+ }
307
+ function ge(e) {
308
+ if (!e) return;
309
+ let t = e.replace(/\s/g, "").match(/^(\d+(?:\.\d+)?)[:/](\d+(?:\.\d+)?)$/);
310
+ if (!t) return;
311
+ let n = Number(t[1]), r = Number(t[2]);
312
+ if (n && r) return n / r;
313
+ }
314
+ function _e({ shape: e, initialsTitle: t }) {
315
+ let n = D();
316
+ return t ? /* @__PURE__ */ J("div", {
317
+ className: "flex h-full w-full items-center justify-center bg-surface-3 text-text-3",
318
+ children: /* @__PURE__ */ J("span", {
319
+ className: e === "circle" ? "text-lg font-medium" : "text-base font-medium",
320
+ children: de(t)
321
+ })
322
+ }) : /* @__PURE__ */ J("div", {
323
+ className: "flex h-full w-full items-center justify-center bg-surface-3 text-text-4",
324
+ children: /* @__PURE__ */ J("span", {
325
+ className: "text-xs",
326
+ children: e === "wide" ? n("file.image.drop", "Drop image here") : "+"
327
+ })
328
+ });
329
+ }
330
+ function ve({ pct: e, label: t }) {
331
+ let n = 2 * Math.PI * 18, r = n - Math.max(0, Math.min(100, e)) / 100 * n;
332
+ return /* @__PURE__ */ Y("div", {
333
+ className: "absolute inset-0 flex items-center justify-center bg-black/30",
334
+ "data-testid": "upload-progress",
335
+ "aria-label": t,
336
+ role: "progressbar",
337
+ "aria-valuenow": Math.round(e),
338
+ "aria-valuemin": 0,
339
+ "aria-valuemax": 100,
340
+ children: [/* @__PURE__ */ Y("svg", {
341
+ width: "48",
342
+ height: "48",
343
+ viewBox: "0 0 48 48",
344
+ children: [/* @__PURE__ */ J("circle", {
345
+ cx: "24",
346
+ cy: "24",
347
+ r: 18,
348
+ stroke: "currentColor",
349
+ strokeOpacity: "0.25",
350
+ strokeWidth: "4",
351
+ fill: "none",
352
+ className: "text-foreground"
353
+ }), /* @__PURE__ */ J("circle", {
354
+ cx: "24",
355
+ cy: "24",
356
+ r: 18,
357
+ stroke: "currentColor",
358
+ strokeWidth: "4",
359
+ fill: "none",
360
+ strokeDasharray: n,
361
+ strokeDashoffset: r,
362
+ strokeLinecap: "round",
363
+ className: "text-accent",
364
+ transform: "rotate(-90 24 24)"
365
+ })]
366
+ }), /* @__PURE__ */ Y("span", {
367
+ className: "absolute text-xs text-foreground",
368
+ children: [Math.round(e), "%"]
369
+ })]
370
+ });
371
+ }
372
+ //#endregion
373
+ //#region src/components/file-widgets/SquareImage.tsx
374
+ function ye(e) {
375
+ return /* @__PURE__ */ J(fe, {
376
+ ...e,
377
+ visual: { shape: "square" }
378
+ });
379
+ }
380
+ //#endregion
381
+ //#region src/components/file-widgets/CircleImage.tsx
382
+ function be(e) {
383
+ return /* @__PURE__ */ J(fe, {
384
+ ...e,
385
+ visual: { shape: "circle" }
386
+ });
387
+ }
388
+ //#endregion
389
+ //#region src/components/file-widgets/WideBanner.tsx
390
+ function xe(e) {
391
+ return /* @__PURE__ */ J(fe, {
392
+ ...e,
393
+ visual: { shape: "wide" }
394
+ });
395
+ }
396
+ //#endregion
397
+ //#region src/components/file-widgets/GridLazy.tsx
398
+ var Se = V(() => import("./Grid-CQabaBLx.js").then((e) => ({ default: e.Grid })));
399
+ function Ce() {
400
+ return /* @__PURE__ */ J("div", { className: "h-24 w-full rounded-md bg-muted animate-pulse" });
401
+ }
402
+ function we(e) {
403
+ return /* @__PURE__ */ J(B, {
404
+ fallback: /* @__PURE__ */ J(Ce, {}),
405
+ children: /* @__PURE__ */ J(Se, { ...e })
406
+ });
407
+ }
408
+ //#endregion
409
+ //#region src/components/file-widgets/DocumentCard.tsx
410
+ function Te({ contentType: e }) {
411
+ let t = D(), n = e ? e.includes("pdf") ? "PDF" : e.includes("word") ? "DOC" : e.includes("sheet") || e.includes("excel") ? "XLS" : e.startsWith("image/") ? "IMG" : e.split("/")[1]?.slice(0, 4).toUpperCase() ?? t("file.document.type_other", "FILE") : t("file.document.type_other", "FILE");
412
+ return /* @__PURE__ */ J("div", {
413
+ className: "flex h-16 w-16 flex-none items-center justify-center rounded-md border border-border bg-surface-3 text-xs font-medium text-muted-foreground",
414
+ children: n
415
+ });
416
+ }
417
+ function Ee(e) {
418
+ let { field: t, fieldName: n, value: r, onChange: i, mode: a, disabled: o, uploadFieldCode: s, uploadSlotCode: c } = e, l = P(r), [f, g] = K("idle"), [v, y] = K(null), [x, C] = K(null), [w, T] = K(!1), [E, A] = K(l?.filename ?? ""), j = G(null), M = G(!1), ee = G(null), { register: te, unregister: I, isDraft: R } = b(), z = D(), re = D("errors"), { open: B } = L();
419
+ U(() => () => {
420
+ j.current && j.current.abort();
421
+ }, []), U(() => {
422
+ A(l?.filename ?? "");
423
+ }, [l?.filename]);
424
+ let V = (t.accepts ?? []).join(","), W = H(async (r) => {
425
+ let a = p(r, t.accepts, t.max_size_bytes);
426
+ if (a) {
427
+ C(d(z, re, a)), g("error");
428
+ return;
429
+ }
430
+ C(null), M.current = !1, g("uploading"), y({
431
+ loaded: 0,
432
+ total: r.size,
433
+ pct: 0
434
+ });
435
+ let o = new AbortController();
436
+ j.current = o;
437
+ try {
438
+ let a = await h({
439
+ file: r,
440
+ entityCode: e.entityCode,
441
+ fieldCode: s ?? n,
442
+ slotCode: c,
443
+ signal: o.signal,
444
+ onProgress: y
445
+ });
446
+ if (M.current) {
447
+ S(a.id).catch(() => {}), I(a.id);
448
+ return;
449
+ }
450
+ l && R(l.id) && (S(l.id).catch(() => {}), I(l.id)), te(a.id, () => S(a.id)), g("idle"), y(null);
451
+ let u = {
452
+ id: a.id,
453
+ filename: a.filename,
454
+ content_type: a.content_type,
455
+ size_bytes: a.size_bytes,
456
+ sha256: a.sha256,
457
+ width: a.width,
458
+ height: a.height,
459
+ url: a.url,
460
+ metadata: a.metadata
461
+ };
462
+ i?.(t.mode === "array" ? [u] : u);
463
+ } catch (e) {
464
+ if (e instanceof m && e.code === "ABORTED") return;
465
+ C(_(z, re, e)), g("error"), y(null);
466
+ }
467
+ }, [
468
+ re,
469
+ z,
470
+ t.accepts,
471
+ t.max_size_bytes,
472
+ t.mode,
473
+ n,
474
+ l,
475
+ R,
476
+ i,
477
+ e.entityCode,
478
+ te,
479
+ I,
480
+ s,
481
+ c
482
+ ]), ie = H(() => {
483
+ o || ee.current?.click();
484
+ }, [o]), X = H((e) => {
485
+ let t = e.target.files?.[0];
486
+ e.target.value = "", t && W(t);
487
+ }, [W]), Z = H(() => {
488
+ l && R(l.id) && (S(l.id).catch(() => {}), I(l.id)), i?.(t.mode === "array" ? [] : null);
489
+ }, [
490
+ l,
491
+ t.mode,
492
+ R,
493
+ i,
494
+ I
495
+ ]), ae = H(() => {
496
+ f === "uploading" && j.current && (M.current = !0, j.current.abort(), j.current = null, g("idle"), y(null));
497
+ }, [f]), oe = H(() => {
498
+ l && B(l.id, "download", F(l));
499
+ }, [l, B]), se = l ? k(l) : !1, ce = H(() => {
500
+ l && k(l) && B(l.id, "preview", ne(l));
501
+ }, [l, B]), le = H(() => {
502
+ if (!l) {
503
+ T(!1);
504
+ return;
505
+ }
506
+ let e = E.trim();
507
+ if (T(!1), !e || e === l.filename) {
508
+ A(l.filename);
509
+ return;
510
+ }
511
+ let n = {
512
+ ...l,
513
+ filename: e
514
+ };
515
+ i?.(t.mode === "array" ? [n] : n);
516
+ }, [
517
+ E,
518
+ l,
519
+ i,
520
+ t.mode
521
+ ]), Q = a === "display";
522
+ return !l && f !== "uploading" ? /* @__PURE__ */ Y("div", {
523
+ "data-testid": `file-widget-${n}`,
524
+ className: "flex items-center gap-3 rounded-md border border-dashed border-border bg-surface p-3",
525
+ children: [
526
+ /* @__PURE__ */ J(Te, {}),
527
+ /* @__PURE__ */ Y("div", {
528
+ className: "flex flex-col gap-1",
529
+ children: [/* @__PURE__ */ J("span", {
530
+ className: "text-sm text-foreground",
531
+ children: z(t.display?.placeholder) || z("file.document.empty", "No document attached")
532
+ }), !Q && /* @__PURE__ */ J("button", {
533
+ type: "button",
534
+ className: "self-start rounded-sm border border-border bg-card px-2 py-1 text-xs text-foreground hover:bg-surface-2",
535
+ onClick: ie,
536
+ disabled: o,
537
+ "data-testid": "upload",
538
+ children: z("file.document.upload", "Upload")
539
+ })]
540
+ }),
541
+ !Q && /* @__PURE__ */ J("input", {
542
+ ref: ee,
543
+ type: "file",
544
+ accept: V || void 0,
545
+ onChange: X,
546
+ style: { display: "none" },
547
+ "data-testid": `file-input-${n}`
548
+ }),
549
+ f === "error" && x && /* @__PURE__ */ J("div", {
550
+ className: "ml-auto text-xs text-destructive",
551
+ role: "alert",
552
+ children: /* @__PURE__ */ J(N, { failure: x })
553
+ })
554
+ ]
555
+ }) : /* @__PURE__ */ Y("div", {
556
+ "data-testid": `file-widget-${n}`,
557
+ className: "flex items-center gap-3 rounded-md border border-border bg-surface p-3",
558
+ "aria-busy": f === "uploading" || void 0,
559
+ "aria-invalid": f === "error" || void 0,
560
+ children: [
561
+ /* @__PURE__ */ J(Te, { contentType: l?.content_type }),
562
+ /* @__PURE__ */ Y("div", {
563
+ className: "flex min-w-0 flex-1 flex-col gap-1",
564
+ children: [
565
+ w && l ? /* @__PURE__ */ J("input", {
566
+ type: "text",
567
+ className: "rounded-sm border border-border bg-card px-1 py-0.5 text-sm text-foreground",
568
+ value: E,
569
+ autoFocus: !0,
570
+ onChange: (e) => A(e.target.value),
571
+ onBlur: le,
572
+ onKeyDown: (e) => {
573
+ e.key === "Enter" ? le() : e.key === "Escape" && (T(!1), A(l.filename));
574
+ },
575
+ "data-testid": "filename-input"
576
+ }) : /* @__PURE__ */ J("button", {
577
+ type: "button",
578
+ className: "truncate text-left text-sm font-medium text-foreground hover:underline",
579
+ onClick: () => !Q && l && T(!0),
580
+ disabled: Q || o || !l,
581
+ title: l?.filename,
582
+ "data-testid": "filename",
583
+ children: l?.filename ?? z("file.document.uploading", "Uploading…")
584
+ }),
585
+ /* @__PURE__ */ Y("div", {
586
+ className: "flex flex-wrap gap-2 text-xs text-muted-foreground",
587
+ children: [
588
+ l && /* @__PURE__ */ J("span", { children: u(l.size_bytes) }),
589
+ l?.page_count != null && /* @__PURE__ */ J("span", { children: O(z, "file.document.pages", l.page_count, {
590
+ one: "{count} page",
591
+ other: "{count} pages"
592
+ }) }),
593
+ l?.uploaded_at && /* @__PURE__ */ J("span", { children: De(l.uploaded_at) }),
594
+ l?.uploaded_by && /* @__PURE__ */ J("span", { children: z("file.document.uploaded_by", "by {user}", { user: l.uploaded_by }) }),
595
+ l?.version?.number != null && /* @__PURE__ */ J("span", {
596
+ "data-testid": "version-badge",
597
+ children: z("file.document.version", "v{number}", { number: l.version.number })
598
+ })
599
+ ]
600
+ }),
601
+ f === "uploading" && /* @__PURE__ */ J("div", {
602
+ className: "text-xs text-muted-foreground",
603
+ role: "progressbar",
604
+ "aria-valuenow": v?.pct ?? 0,
605
+ "aria-valuemin": 0,
606
+ "aria-valuemax": 100,
607
+ "data-testid": "upload-progress",
608
+ children: z("file.upload.progress", "Uploading {pct}%", { pct: v?.pct ?? 0 })
609
+ }),
610
+ f === "error" && x && /* @__PURE__ */ J("div", {
611
+ className: "text-xs text-destructive",
612
+ role: "alert",
613
+ children: /* @__PURE__ */ J(N, { failure: x })
614
+ })
615
+ ]
616
+ }),
617
+ /* @__PURE__ */ Y("div", {
618
+ className: "flex flex-none items-center gap-1",
619
+ children: [l && f !== "uploading" && /* @__PURE__ */ Y(q, { children: [
620
+ /* @__PURE__ */ J("button", {
621
+ type: "button",
622
+ className: "rounded-sm border border-border bg-card px-2 py-1 text-xs text-foreground hover:bg-surface-2",
623
+ onClick: oe,
624
+ "data-testid": "download",
625
+ children: z("file.download", "Download")
626
+ }),
627
+ /* @__PURE__ */ J("button", {
628
+ type: "button",
629
+ className: "rounded-sm border border-border bg-card px-2 py-1 text-xs text-foreground hover:bg-surface-2 disabled:cursor-not-allowed disabled:opacity-50",
630
+ onClick: ce,
631
+ disabled: !se,
632
+ title: se ? void 0 : z("file.document.preview_images_only", "Preview is available only for images and PDFs"),
633
+ "data-testid": "preview",
634
+ children: z("file.document.preview", "Preview")
635
+ }),
636
+ !Q && /* @__PURE__ */ Y(q, { children: [/* @__PURE__ */ J("button", {
637
+ type: "button",
638
+ className: "rounded-sm border border-border bg-card px-2 py-1 text-xs text-foreground hover:bg-surface-2",
639
+ onClick: ie,
640
+ disabled: o,
641
+ "data-testid": "replace",
642
+ children: z("file.document.replace", "Replace")
643
+ }), /* @__PURE__ */ J("button", {
644
+ type: "button",
645
+ className: "rounded-sm border border-border bg-card px-2 py-1 text-xs text-destructive hover:bg-surface-2",
646
+ onClick: Z,
647
+ disabled: o,
648
+ "data-testid": "remove",
649
+ children: z("file.remove", "Remove")
650
+ })] })
651
+ ] }), f === "uploading" && /* @__PURE__ */ J("button", {
652
+ type: "button",
653
+ className: "rounded-sm border border-border bg-card px-2 py-1 text-xs",
654
+ onClick: ae,
655
+ "data-testid": "cancel-upload",
656
+ children: z("file.upload.cancel", "Cancel")
657
+ })]
658
+ }),
659
+ !Q && /* @__PURE__ */ J("input", {
660
+ ref: ee,
661
+ type: "file",
662
+ accept: V || void 0,
663
+ onChange: X,
664
+ style: { display: "none" },
665
+ "data-testid": `file-input-${n}`
666
+ })
667
+ ]
668
+ });
669
+ }
670
+ function De(e) {
671
+ let t = new Date(e);
672
+ return isNaN(t.getTime()) ? e : t.toISOString().slice(0, 10);
673
+ }
674
+ //#endregion
675
+ //#region src/components/file-widgets/FileList.tsx
676
+ function Oe(e) {
677
+ return e ? (e.split("/")[1] ?? e).toUpperCase().slice(0, 6) : "";
678
+ }
679
+ function ke(e) {
680
+ let { field: t, fieldName: n, value: r, onChange: i, mode: a, disabled: o } = e, s = z(r), [c, l] = K([]), { register: f, unregister: g, isDraft: v } = b(), y = D(), x = D("errors"), C = G(s);
681
+ C.current = s;
682
+ let w = G(null), T = G(/* @__PURE__ */ new Set()), E = G([]);
683
+ E.current = c;
684
+ let { open: O } = L();
685
+ U(() => () => {
686
+ E.current.forEach((e) => e.abort());
687
+ }, []);
688
+ let k = (t.accepts ?? []).join(","), A = a === "display", j = H(async (r) => {
689
+ let a = p(r, t.accepts, t.max_size_bytes), o = `row-${Math.random().toString(36).slice(2)}-${Date.now()}`, s = new AbortController();
690
+ if (a) {
691
+ l((e) => [...e, {
692
+ localId: o,
693
+ filename: r.name,
694
+ progress: null,
695
+ error: d(y, x, a),
696
+ abort: () => {}
697
+ }]);
698
+ return;
699
+ }
700
+ l((e) => [...e, {
701
+ localId: o,
702
+ filename: r.name,
703
+ progress: {
704
+ loaded: 0,
705
+ total: r.size,
706
+ pct: 0
707
+ },
708
+ error: null,
709
+ abort: () => s.abort()
710
+ }]);
711
+ try {
712
+ let t = await h({
713
+ file: r,
714
+ entityCode: e.entityCode,
715
+ fieldCode: n,
716
+ signal: s.signal,
717
+ onProgress: (e) => l((t) => t.map((t) => t.localId === o ? {
718
+ ...t,
719
+ progress: e
720
+ } : t))
721
+ });
722
+ if (T.current.delete(o)) {
723
+ S(t.id).catch(() => {}), g(t.id);
724
+ return;
725
+ }
726
+ f(t.id, () => S(t.id));
727
+ let a = {
728
+ id: t.id,
729
+ filename: t.filename,
730
+ content_type: t.content_type,
731
+ size_bytes: t.size_bytes,
732
+ sha256: t.sha256,
733
+ width: t.width,
734
+ height: t.height,
735
+ url: t.url,
736
+ metadata: t.metadata
737
+ }, c = [...C.current, a];
738
+ C.current = c, i?.(c), l((e) => e.filter((e) => e.localId !== o));
739
+ } catch (e) {
740
+ if (e instanceof m && e.code === "ABORTED") {
741
+ l((e) => e.filter((e) => e.localId !== o));
742
+ return;
743
+ }
744
+ let t = _(y, x, e);
745
+ l((e) => e.map((e) => e.localId === o ? {
746
+ ...e,
747
+ error: t,
748
+ progress: null,
749
+ abort: () => {}
750
+ } : e));
751
+ }
752
+ }, [
753
+ x,
754
+ y,
755
+ t.accepts,
756
+ t.max_size_bytes,
757
+ n,
758
+ i,
759
+ e.entityCode,
760
+ f,
761
+ g
762
+ ]), M = H((e) => {
763
+ Array.from(e).forEach((e) => void j(e));
764
+ }, [j]), ee = H(() => {
765
+ o || w.current?.click();
766
+ }, [o]), te = H((e) => {
767
+ let t = e.target.files;
768
+ e.target.value = "", t && t.length > 0 && M(t);
769
+ }, [M]), P = H((e) => {
770
+ v(e) && (S(e).catch(() => {}), g(e)), i?.(s.filter((t) => t.id !== e));
771
+ }, [
772
+ v,
773
+ s,
774
+ i,
775
+ g
776
+ ]), I = H((e) => {
777
+ O(e.id, "download", F(e));
778
+ }, [O]);
779
+ return /* @__PURE__ */ Y("div", {
780
+ "data-testid": `file-widget-${n}`,
781
+ className: "flex flex-col gap-2",
782
+ children: [/* @__PURE__ */ Y("ul", {
783
+ className: "flex flex-col divide-y divide-divider rounded-md border border-border bg-surface",
784
+ children: [
785
+ s.length === 0 && c.length === 0 && /* @__PURE__ */ J("li", {
786
+ className: "px-3 py-4 text-center text-sm text-muted-foreground",
787
+ children: y(t.display?.placeholder) || y("file.list.empty", "No files")
788
+ }),
789
+ s.map((e) => /* @__PURE__ */ Y("li", {
790
+ className: "flex items-center gap-3 px-3 py-2",
791
+ "data-testid": `row-${e.id}`,
792
+ children: [
793
+ /* @__PURE__ */ J("span", {
794
+ className: "flex-none rounded-sm border border-border bg-surface-3 px-1.5 py-0.5 text-[10px] text-muted-foreground",
795
+ children: Oe(e.content_type)
796
+ }),
797
+ /* @__PURE__ */ J("button", {
798
+ type: "button",
799
+ onClick: () => I(e),
800
+ className: "min-w-0 flex-1 truncate text-left text-sm text-foreground hover:underline",
801
+ title: e.filename,
802
+ children: e.filename
803
+ }),
804
+ /* @__PURE__ */ J("span", {
805
+ className: "flex-none text-xs text-muted-foreground",
806
+ children: u(e.size_bytes)
807
+ }),
808
+ /* @__PURE__ */ J("button", {
809
+ type: "button",
810
+ className: "flex-none rounded-sm border border-border bg-card px-2 py-0.5 text-xs text-foreground hover:bg-surface-2",
811
+ onClick: () => I(e),
812
+ "data-testid": `download-${e.id}`,
813
+ children: y("file.download", "Download")
814
+ }),
815
+ !A && /* @__PURE__ */ J("button", {
816
+ type: "button",
817
+ className: "flex-none rounded-sm border border-border bg-card px-2 py-0.5 text-xs text-destructive hover:bg-surface-2",
818
+ onClick: () => P(e.id),
819
+ disabled: o,
820
+ "data-testid": `remove-${e.id}`,
821
+ children: y("file.remove", "Remove")
822
+ })
823
+ ]
824
+ }, e.id)),
825
+ c.map((e) => /* @__PURE__ */ Y("li", {
826
+ className: "flex items-center gap-3 px-3 py-2",
827
+ "data-testid": `pending-row-${e.localId}`,
828
+ "aria-busy": !e.error,
829
+ "aria-invalid": !!e.error || void 0,
830
+ children: [
831
+ /* @__PURE__ */ J("span", {
832
+ className: "flex-none truncate text-sm text-foreground",
833
+ title: e.filename,
834
+ children: e.filename
835
+ }),
836
+ /* @__PURE__ */ J("span", { className: "flex-1" }),
837
+ e.error ? /* @__PURE__ */ J("span", {
838
+ role: "alert",
839
+ className: "text-xs text-destructive",
840
+ children: /* @__PURE__ */ J(N, { failure: e.error })
841
+ }) : /* @__PURE__ */ Y("span", {
842
+ className: "text-xs text-muted-foreground",
843
+ role: "progressbar",
844
+ "aria-valuenow": e.progress?.pct ?? 0,
845
+ "aria-valuemin": 0,
846
+ "aria-valuemax": 100,
847
+ children: [e.progress?.pct ?? 0, "%"]
848
+ }),
849
+ /* @__PURE__ */ J("button", {
850
+ type: "button",
851
+ className: "flex-none rounded-sm border border-border bg-card px-2 py-0.5 text-xs",
852
+ onClick: () => {
853
+ e.abort(), T.current.add(e.localId), l((t) => t.filter((t) => t.localId !== e.localId));
854
+ },
855
+ children: e.error ? y("file.upload.dismiss", "Dismiss") : y("file.upload.cancel", "Cancel")
856
+ })
857
+ ]
858
+ }, e.localId))
859
+ ]
860
+ }), !A && /* @__PURE__ */ Y(q, { children: [/* @__PURE__ */ J("button", {
861
+ type: "button",
862
+ className: "self-start rounded-sm border border-border bg-card px-2 py-1 text-xs text-foreground hover:bg-surface-2",
863
+ onClick: ee,
864
+ disabled: o,
865
+ "data-testid": "add-files",
866
+ children: y("file.list.add", "Add files")
867
+ }), /* @__PURE__ */ J("input", {
868
+ ref: w,
869
+ type: "file",
870
+ accept: k || void 0,
871
+ multiple: !0,
872
+ onChange: te,
873
+ style: { display: "none" },
874
+ "data-testid": `file-input-${n}`
875
+ })] })]
876
+ });
877
+ }
878
+ //#endregion
879
+ //#region src/components/file-widgets/UnknownFileWidget.tsx
880
+ function Ae({ widgetCode: e }) {
881
+ let t = D(), n = D("errors");
882
+ return e ? /* @__PURE__ */ Y("span", {
883
+ className: "text-sm text-muted-foreground",
884
+ children: [
885
+ n("file.unknown_widget", "This file field names a widget this deployment does not have."),
886
+ " ",
887
+ /* @__PURE__ */ J("span", {
888
+ className: "opacity-80",
889
+ children: t("file.widget_code", "Widget: {widget}", { widget: e })
890
+ })
891
+ ]
892
+ }) : /* @__PURE__ */ J("span", {
893
+ className: "text-sm text-muted-foreground",
894
+ children: n("file.missing_widget", "This file field does not name a widget to show it.")
895
+ });
896
+ }
897
+ //#endregion
898
+ //#region src/components/file-widgets/LabeledSlots.tsx
899
+ function je(e) {
900
+ return !e || Array.isArray(e) || typeof e != "object" ? {} : e;
901
+ }
902
+ function Me(e, t) {
903
+ return t?.content_type?.startsWith("image/") ? !0 : (e.accepts ?? []).some((e) => e === "image/*" || e.startsWith("image/"));
904
+ }
905
+ function Ne(e, t, n, r) {
906
+ return {
907
+ ...e,
908
+ name: `${e.name}.${t}`,
909
+ mode: "single",
910
+ accepts: n.accepts ?? e.accepts,
911
+ max_size_bytes: n.max_size_bytes ?? e.max_size_bytes,
912
+ slots: void 0,
913
+ display: {
914
+ ...e.display ?? { widget: "document_card" },
915
+ widget: Me(n, r) ? "square_image" : "document_card",
916
+ aspect_ratio: n.aspect_ratio ?? e.display?.aspect_ratio
917
+ }
918
+ };
919
+ }
920
+ function Pe(e) {
921
+ let { field: t, fieldName: n, entityCode: r, value: i, recordTitle: a, onChange: o, mode: s, disabled: c } = e, l = Object.entries(t.slots ?? {}), u = je(i), d = D();
922
+ return l.length === 0 ? /* @__PURE__ */ J("span", {
923
+ className: "text-sm text-muted-foreground",
924
+ children: d("file.slots.empty", "No slots configured")
925
+ }) : /* @__PURE__ */ J("div", {
926
+ className: "grid gap-3",
927
+ children: l.map(([e, i]) => {
928
+ let l = u[e] ?? null, f = Ne(t, e, i, l), p = f.display?.widget ?? "document_card", m = ae(p);
929
+ return m ? /* @__PURE__ */ Y("div", {
930
+ className: "grid gap-1.5",
931
+ children: [/* @__PURE__ */ J("div", {
932
+ className: "text-xs font-semibold text-text-2",
933
+ children: d(i.name)
934
+ }), /* @__PURE__ */ J(m, {
935
+ field: f,
936
+ fieldName: e,
937
+ entityCode: r,
938
+ value: l,
939
+ recordTitle: a,
940
+ mode: s,
941
+ disabled: c,
942
+ uploadFieldCode: n,
943
+ uploadSlotCode: e,
944
+ onChange: (t) => {
945
+ o && o({
946
+ ...u,
947
+ [e]: t ?? null
948
+ });
949
+ }
950
+ })]
951
+ }, e) : /* @__PURE__ */ Y("div", {
952
+ className: "grid gap-1.5",
953
+ children: [/* @__PURE__ */ J("div", {
954
+ className: "text-xs font-semibold text-text-2",
955
+ children: d(i.name)
956
+ }), /* @__PURE__ */ J(Ae, { widgetCode: p })]
957
+ }, e);
958
+ })
959
+ });
960
+ }
961
+ //#endregion
962
+ //#region src/components/file-widgets/builtins.ts
963
+ var Fe = !1;
964
+ function Ie() {
965
+ Fe ||= (Z("square_image", ye), Z("circle_image", be), Z("wide_banner", xe), Z("grid", we), Z("document_card", Ee), Z("file_list", ke), Z("labeled_slots", Pe), !0);
966
+ }
967
+ //#endregion
968
+ //#region src/components/file-widgets/host.tsx
969
+ Ie();
970
+ function Le(e, t) {
971
+ return e.files?.get(t);
972
+ }
973
+ function Re(e, t) {
974
+ return Object.prototype.hasOwnProperty.call(e, t) ? e[t] ?? null : e.$files?.[t] ?? null;
975
+ }
976
+ function ze(e, t, n) {
977
+ if (Le(e, n)) return Re(t, n);
978
+ let r = e.fields.get(n);
979
+ return r?.type === "rich_text" && r.files?.mode === "rich_text_inline" ? f(t[n], Re(t, n)) : t[n];
980
+ }
981
+ function Be(e, t, n) {
982
+ let r = e.fields.get(t);
983
+ return r?.type === "rich_text" && r.files?.mode === "rich_text_inline" ? w(n) : n;
984
+ }
985
+ function Ve(e, t, n, r) {
986
+ let i = Le(t, n);
987
+ if (i) return i.name || n;
988
+ let a = t.fields.get(n);
989
+ return a ? l(e, a, n, r) : n;
990
+ }
991
+ function He(e) {
992
+ let { entity: t, entityCode: n, fieldName: r, record: i, mode: a, onChange: o, refs: s, disabled: c, surface: l, entities: u, screens: d, t: f, fieldId: p, labelId: m, structure: h, detailScreen: g } = e, _ = Le(t, r);
993
+ if (_) {
994
+ let e = _.display?.widget ?? "", s = ae(e);
995
+ return s ? /* @__PURE__ */ J(s, {
996
+ field: _,
997
+ fieldName: r,
998
+ entityCode: n,
999
+ value: Re(i, r),
1000
+ recordTitle: C(f, i, t),
1001
+ mode: a,
1002
+ onChange: o,
1003
+ disabled: c,
1004
+ fieldId: p
1005
+ }) : /* @__PURE__ */ J(Ae, { widgetCode: e });
1006
+ }
1007
+ let v = t.fields.get(r), b = h && a === "display" && v ? {
1008
+ ...v,
1009
+ structure: h
1010
+ } : v;
1011
+ return b ? y({
1012
+ field: b,
1013
+ entityCode: n,
1014
+ fieldName: r,
1015
+ value: ze(t, i, r),
1016
+ mode: a,
1017
+ onChange: o,
1018
+ record: i,
1019
+ refs: s,
1020
+ surface: l,
1021
+ entity: n && u ? u[n] : void 0,
1022
+ entities: u,
1023
+ screens: d,
1024
+ t: f,
1025
+ fieldId: p,
1026
+ labelId: m,
1027
+ detailScreen: g
1028
+ }) : null;
1029
+ }
1030
+ //#endregion
1031
+ //#region src/components/actions/ResponsiveActionBar.tsx
1032
+ function Ue(e, t) {
1033
+ return e.replace(/\$\{([^}]+)\}/g, (e, n) => Object.prototype.hasOwnProperty.call(t, n) ? t[n] : e);
1034
+ }
1035
+ function We(e) {
1036
+ return e.widget ? "widget" : e.href ? "href" : e.handler ? "handler" : e.association ? "association" : e.ui_steps && e.ui_steps.length > 0 ? "ui_steps" : "unknown";
1037
+ }
1038
+ function Ge(e, t, n, r, i) {
1039
+ let a = We(t), o = x(n, r?.entity), s = r?.entityCode ?? "";
1040
+ if (e === "__peek") return i?.({
1041
+ code: e,
1042
+ entity: s,
1043
+ mode: "peek",
1044
+ rowId: o
1045
+ }), r?.openPeek?.(n), !0;
1046
+ if (i?.({
1047
+ code: e,
1048
+ entity: s,
1049
+ mode: a,
1050
+ rowId: o
1051
+ }), a === "widget") return console.warn(`[ResponsiveActionBar] widget "${t.widget}" requested for action "${e}" but the SDK has no widget registry yet; falling back to onRun.`), !1;
1052
+ if (a === "href" && r) {
1053
+ let e = Ue(t.href ?? "", {
1054
+ entity: s,
1055
+ id: encodeURIComponent(o)
1056
+ }), n = e.indexOf("?");
1057
+ return n === -1 ? r.tabNavigate(e) : r.tabNavigate(e.slice(0, n), { search: e.slice(n + 1) }), !0;
1058
+ }
1059
+ return a === "handler" || a === "association" || a === "ui_steps" || a === "unknown" && console.warn(`[ResponsiveActionBar] no dispatch mode set on action "${e}" (none of handler/association/widget/href/ui_steps).`), !1;
1060
+ }
1061
+ function Ke(e) {
1062
+ let t = 0;
1063
+ for (let n of e) n.kind === "action" ? t++ : t += Ke(n.items);
1064
+ return t;
1065
+ }
1066
+ function qe(e, t, n) {
1067
+ let r = [], i = [];
1068
+ for (let a of e) a.kind === "action" && Ye(a.code, t, n)?.destructive ? i.push(a) : r.push(a);
1069
+ return {
1070
+ normal: r,
1071
+ destructive: i
1072
+ };
1073
+ }
1074
+ function Je(e, t, n) {
1075
+ let r = [], i = [], a = [];
1076
+ for (let o of e) {
1077
+ if (o.kind !== "action") {
1078
+ i.push(o);
1079
+ continue;
1080
+ }
1081
+ let e = Ye(o.code, t, n), s = e?.destructive === !0, c = e?.display?.primary === !0;
1082
+ if (s && c) {
1083
+ console.warn(`[ResponsiveActionBar] action "${o.code}" declares both primary and destructive; treating as destructive.`), a.push(o);
1084
+ continue;
1085
+ }
1086
+ if (s) {
1087
+ a.push(o);
1088
+ continue;
1089
+ }
1090
+ if (c) {
1091
+ r.push(o);
1092
+ continue;
1093
+ }
1094
+ i.push(o);
1095
+ }
1096
+ return {
1097
+ primary: r,
1098
+ regular: i,
1099
+ destructive: a
1100
+ };
1101
+ }
1102
+ function Ye(e, t, n) {
1103
+ if (t && e in t) return t[e];
1104
+ if (n && e in n) return n[e];
1105
+ }
1106
+ function Xe(e, t, n, r) {
1107
+ return e(Ye(t, n, r)?.display?.name) || t;
1108
+ }
1109
+ function Ze(e, t, n) {
1110
+ return Ye(e, t, n)?.display?.icon || void 0;
1111
+ }
1112
+ function Qe(e) {
1113
+ return `action-tooltip-${e}`;
1114
+ }
1115
+ function $e({ leaf: e, entityActions: n, globalActions: r, onRun: i, loading: a, onLoadingChange: o, measureRef: l, style: u, row: d, widgetContext: f, onActionClick: p, iconOnly: m = !1 }) {
1116
+ let h = D(), _ = Ye(e.code, n, r), v = Xe(h, e.code, n, r), y = Ze(e.code, n, r), b = _?.destructive ?? !1, x = !b && _?.display?.primary === !0, S = !e.enabled, C = S ? Qe(e.code) : void 0, w = H(async () => {
1117
+ if (!(!_ || S || a)) {
1118
+ o(!0);
1119
+ try {
1120
+ Ge(e.code, _, d, f, p) || await Promise.resolve(i(e.code, _));
1121
+ } finally {
1122
+ o(!1);
1123
+ }
1124
+ }
1125
+ }, [
1126
+ _,
1127
+ S,
1128
+ a,
1129
+ i,
1130
+ e.code,
1131
+ o,
1132
+ d,
1133
+ f,
1134
+ p
1135
+ ]), T = a ? /* @__PURE__ */ J(g, { size: 12 }) : y ? /* @__PURE__ */ J(t, {
1136
+ name: y,
1137
+ size: 12
1138
+ }) : null;
1139
+ return /* @__PURE__ */ Y(q, { children: [C && e.reason && /* @__PURE__ */ J("span", {
1140
+ id: C,
1141
+ role: "tooltip",
1142
+ style: {
1143
+ position: "absolute",
1144
+ width: 1,
1145
+ height: 1,
1146
+ overflow: "hidden",
1147
+ clip: "rect(0,0,0,0)"
1148
+ },
1149
+ children: e.reason
1150
+ }), /* @__PURE__ */ J(s, {
1151
+ ref: l,
1152
+ kind: x ? "primary" : "default",
1153
+ danger: b,
1154
+ icon: T,
1155
+ disabled: S || a,
1156
+ "aria-disabled": S ? "true" : void 0,
1157
+ "aria-describedby": C,
1158
+ "aria-label": m ? v : void 0,
1159
+ title: c(h, _, v, S, e.reason, m),
1160
+ onClick: w,
1161
+ style: u,
1162
+ children: m ? null : v
1163
+ })] });
1164
+ }
1165
+ function et({ group: n, entityActions: r, globalActions: i, onRun: o, loading: c, onLoadingChange: l, measureRef: u, style: d, row: f, widgetContext: p, onActionClick: m }) {
1166
+ let h = D(), _ = G(null), [v, y] = K(!1), b = n.name ? h(n.name) : h("action.menu.title", "Actions"), x = H((e) => {
1167
+ _.current = e, u?.(e);
1168
+ }, [u]), S = H((e, t) => (y(!1), o(e, t)), [o]);
1169
+ return /* @__PURE__ */ Y(q, { children: [/* @__PURE__ */ J(s, {
1170
+ ref: x,
1171
+ kind: "default",
1172
+ icon: c == null ? n.icon ? /* @__PURE__ */ J(t, {
1173
+ name: n.icon,
1174
+ size: 12
1175
+ }) : void 0 : /* @__PURE__ */ J(g, { size: 12 }),
1176
+ iconRight: /* @__PURE__ */ J(e.down, { size: 10 }),
1177
+ "aria-haspopup": "menu",
1178
+ "aria-expanded": v ? "true" : "false",
1179
+ title: b,
1180
+ onClick: () => y((e) => !e),
1181
+ style: d,
1182
+ children: b
1183
+ }), /* @__PURE__ */ J(a, {
1184
+ open: v,
1185
+ anchor: _.current,
1186
+ onClose: () => y(!1),
1187
+ align: "start",
1188
+ width: 200,
1189
+ children: /* @__PURE__ */ J("div", {
1190
+ role: "menu",
1191
+ "aria-label": b,
1192
+ children: n.items.map((e) => e.kind === "action" ? /* @__PURE__ */ J(tt, {
1193
+ leaf: e,
1194
+ entityActions: r,
1195
+ globalActions: i,
1196
+ onRun: S,
1197
+ loading: c === e.code,
1198
+ onLoadingChange: (t) => l(t ? e.code : null),
1199
+ row: f,
1200
+ widgetContext: p,
1201
+ onActionClick: m
1202
+ }, e.code) : /* @__PURE__ */ J(nt, {
1203
+ group: e,
1204
+ entityActions: r,
1205
+ globalActions: i,
1206
+ onRun: S,
1207
+ loading: c,
1208
+ onLoadingChange: l,
1209
+ row: f,
1210
+ widgetContext: p,
1211
+ onActionClick: m
1212
+ }, e.items[0]?.kind === "action" ? e.items[0].code : e.icon ?? "group"))
1213
+ })
1214
+ })] });
1215
+ }
1216
+ function tt({ leaf: e, entityActions: n, globalActions: r, onRun: i, loading: a, onLoadingChange: o, row: s, widgetContext: l, onActionClick: u }) {
1217
+ let d = D(), f = Ye(e.code, n, r), p = Xe(d, e.code, n, r), m = Ze(e.code, n, r), h = f?.destructive ?? !1, _ = !e.enabled, v = _ ? Qe(e.code) : void 0, y = a ? /* @__PURE__ */ J(g, { size: 12 }) : m ? /* @__PURE__ */ J(t, {
1218
+ name: m,
1219
+ size: 12
1220
+ }) : null;
1221
+ return /* @__PURE__ */ Y(q, { children: [v && e.reason && /* @__PURE__ */ J("span", {
1222
+ id: v,
1223
+ role: "tooltip",
1224
+ style: {
1225
+ position: "absolute",
1226
+ width: 1,
1227
+ height: 1,
1228
+ overflow: "hidden",
1229
+ clip: "rect(0,0,0,0)"
1230
+ },
1231
+ children: e.reason
1232
+ }), /* @__PURE__ */ Y("div", {
1233
+ role: "menuitem",
1234
+ "aria-disabled": _ ? "true" : void 0,
1235
+ "aria-describedby": v,
1236
+ title: c(d, f, p, _, e.reason),
1237
+ onClick: async () => {
1238
+ if (!(!f || _ || a)) {
1239
+ o(!0);
1240
+ try {
1241
+ Ge(e.code, f, s, l, u) || await Promise.resolve(i(e.code, f));
1242
+ } finally {
1243
+ o(!1);
1244
+ }
1245
+ }
1246
+ },
1247
+ style: {
1248
+ display: "flex",
1249
+ alignItems: "center",
1250
+ gap: 8,
1251
+ padding: "6px 10px",
1252
+ borderRadius: 5,
1253
+ fontSize: 12.5,
1254
+ color: h ? "var(--danger)" : _ ? "var(--text-3)" : "var(--text-2)",
1255
+ cursor: _ ? "not-allowed" : "pointer",
1256
+ opacity: _ ? .6 : 1
1257
+ },
1258
+ onMouseEnter: (e) => {
1259
+ _ || (e.currentTarget.style.background = "var(--surface-3)");
1260
+ },
1261
+ onMouseLeave: (e) => {
1262
+ e.currentTarget.style.background = "transparent";
1263
+ },
1264
+ children: [y && /* @__PURE__ */ J("span", {
1265
+ style: {
1266
+ color: h ? "var(--danger)" : "var(--text-3)",
1267
+ display: "flex"
1268
+ },
1269
+ children: y
1270
+ }), /* @__PURE__ */ J("span", {
1271
+ style: { flex: 1 },
1272
+ children: p
1273
+ })]
1274
+ })] });
1275
+ }
1276
+ function nt({ group: e, entityActions: t, globalActions: n, onRun: r, loading: i, onLoadingChange: a, row: o, widgetContext: s, onActionClick: c }) {
1277
+ let l = D(), u = e.name ? l(e.name) : void 0;
1278
+ return /* @__PURE__ */ Y(q, { children: [u && /* @__PURE__ */ J("div", {
1279
+ style: {
1280
+ padding: "4px 10px 2px",
1281
+ fontSize: 10.5,
1282
+ fontWeight: 600,
1283
+ color: "var(--text-3)",
1284
+ textTransform: "uppercase",
1285
+ letterSpacing: "0.05em"
1286
+ },
1287
+ children: u
1288
+ }), e.items.map((e) => e.kind === "action" ? /* @__PURE__ */ J(tt, {
1289
+ leaf: e,
1290
+ entityActions: t,
1291
+ globalActions: n,
1292
+ onRun: r,
1293
+ loading: i === e.code,
1294
+ onLoadingChange: (t) => a(t ? e.code : null),
1295
+ row: o,
1296
+ widgetContext: s,
1297
+ onActionClick: c
1298
+ }, e.code) : /* @__PURE__ */ J(nt, {
1299
+ group: e,
1300
+ entityActions: t,
1301
+ globalActions: n,
1302
+ onRun: r,
1303
+ loading: i,
1304
+ onLoadingChange: a,
1305
+ row: o,
1306
+ widgetContext: s,
1307
+ onActionClick: c
1308
+ }, e.icon ?? "nested"))] });
1309
+ }
1310
+ function rt({ layout: t, entityActions: n, globalActions: r, onRun: o, row: s, widgetContext: c, onActionClick: l }) {
1311
+ let u = D(), d = G(null), [f, p] = K(!1), [m, h] = K(null), _ = H((e, t) => (p(!1), o(e, t)), [o]);
1312
+ return Ke(t) === 0 ? null : /* @__PURE__ */ Y("div", {
1313
+ "data-open": f ? "true" : void 0,
1314
+ style: {
1315
+ display: "inline-flex",
1316
+ alignItems: "center"
1317
+ },
1318
+ children: [/* @__PURE__ */ J(i, {
1319
+ ref: d,
1320
+ icon: J(m == null ? e.more : g, { size: 14 }),
1321
+ title: u("action.menu.title", "Actions"),
1322
+ size: 28,
1323
+ onClick: () => p((e) => !e)
1324
+ }), /* @__PURE__ */ J(a, {
1325
+ open: f,
1326
+ anchor: d.current,
1327
+ onClose: () => p(!1),
1328
+ align: "end",
1329
+ width: 220,
1330
+ children: /* @__PURE__ */ J(at, {
1331
+ layout: t,
1332
+ entityActions: n,
1333
+ globalActions: r,
1334
+ onRun: _,
1335
+ loading: m,
1336
+ onLoadingChange: h,
1337
+ row: s,
1338
+ widgetContext: c,
1339
+ onActionClick: l
1340
+ })
1341
+ })]
1342
+ });
1343
+ }
1344
+ function it(e) {
1345
+ let t = 0;
1346
+ for (let r of e) if (r.kind === "action" && n(r.code)) t++;
1347
+ else break;
1348
+ return t;
1349
+ }
1350
+ function at({ layout: e, entityActions: t, globalActions: n, onRun: r, loading: i, onLoadingChange: a, row: o, widgetContext: s, onActionClick: c, ariaLabel: l }) {
1351
+ let u = D(), { normal: d, destructive: f } = qe(e, t, n), p = it(d), m = d.slice(0, p), h = d.slice(p), g = f.length > 0, _ = h.length > 0, y = (e) => /* @__PURE__ */ J(tt, {
1352
+ leaf: e,
1353
+ entityActions: t,
1354
+ globalActions: n,
1355
+ onRun: r,
1356
+ loading: i === e.code,
1357
+ onLoadingChange: (t) => a(t ? e.code : null),
1358
+ row: o,
1359
+ widgetContext: s,
1360
+ onActionClick: c
1361
+ }, e.code);
1362
+ return /* @__PURE__ */ Y("div", {
1363
+ role: "menu",
1364
+ "aria-label": l ?? u("action.menu.row_actions", "Row actions"),
1365
+ children: [
1366
+ m.map((e) => e.kind === "action" ? y(e) : null),
1367
+ m.length > 0 && _ && /* @__PURE__ */ J(v, { divider: !0 }),
1368
+ h.map((e) => e.kind === "action" ? y(e) : /* @__PURE__ */ J(nt, {
1369
+ group: e,
1370
+ entityActions: t,
1371
+ globalActions: n,
1372
+ onRun: r,
1373
+ loading: i,
1374
+ onLoadingChange: a,
1375
+ row: o,
1376
+ widgetContext: s,
1377
+ onActionClick: c
1378
+ }, e.icon ?? "group")),
1379
+ g && /* @__PURE__ */ J(v, { divider: !0 }),
1380
+ f.map((e) => y(e))
1381
+ ]
1382
+ });
1383
+ }
1384
+ var ot = "__overflow_trigger__", st = 90, ct = 4, lt = 8;
1385
+ function ut(e) {
1386
+ return `icon:${$(e)}`;
1387
+ }
1388
+ function dt() {
1389
+ return lt;
1390
+ }
1391
+ function ft(e, t, n) {
1392
+ return [
1393
+ ...e,
1394
+ ...t,
1395
+ ...n
1396
+ ];
1397
+ }
1398
+ var pt = () => {}, mt = () => Promise.resolve();
1399
+ function ht(e) {
1400
+ return (t) => {
1401
+ t && (t.setAttribute("data-node-key", e), t.setAttribute("tabindex", "-1"));
1402
+ };
1403
+ }
1404
+ function gt(e, t) {
1405
+ if (e.size !== t.size) return !1;
1406
+ for (let [n, r] of t) if (e.get(n) !== r) return !1;
1407
+ return !0;
1408
+ }
1409
+ function _t(e, t) {
1410
+ return t.get($(e)) ?? 0;
1411
+ }
1412
+ function vt(e, t) {
1413
+ return t.get(ut(e));
1414
+ }
1415
+ function yt(e, t, n, r, i, a, o, s, c) {
1416
+ let { primary: l, regular: u, destructive: d } = Je(e, i, a), f = ct, p = r.get(ot) ?? st, m = t - n, h = ft(l, u, d), g = /* @__PURE__ */ new Set(), _ = /* @__PURE__ */ new Set();
1417
+ if (o) for (let e of h) o(e) && g.add($(e));
1418
+ else {
1419
+ let e = (e, t) => t ? vt(e, r) ?? _t(e, r) : _t(e, r), t = (e) => s ? e.filter((e) => !s.has($(e))).length * dt() : 0, n = (e, t) => c ? e.slice(0, t).filter((e) => c.has($(e))).length * dt() : 0, i = (r, i) => {
1420
+ let a = r.length < h.length ? p + f : 0, o = r.length > 1 ? (r.length - 1) * f : 0;
1421
+ return r.reduce((t, n, r) => t + e(n, r >= i), 0) + o + a + t(r) + n(r, i) <= m;
1422
+ }, a = 0, o = !1;
1423
+ for (let e = h.length; e >= 1 && a === 0; e--) i(h.slice(0, e), 1) ? a = e : i(h.slice(0, e), 0) && (a = e, o = !0);
1424
+ let l = o ? 0 : Math.min(1, a), u = h.slice(0, a);
1425
+ for (; l < a && i(u, l + 1);) l++;
1426
+ u.forEach((e, t) => {
1427
+ let n = $(e);
1428
+ g.add(n), t >= l && _.add(n);
1429
+ });
1430
+ }
1431
+ let v = (e) => g.has($(e)), y = [
1432
+ ...l,
1433
+ ...u,
1434
+ ...d
1435
+ ].filter((e) => !v(e));
1436
+ return {
1437
+ primaryInline: l.filter(v),
1438
+ inline: u.filter(v),
1439
+ overflow: y,
1440
+ destructiveInline: d.filter(v),
1441
+ iconOnly: _
1442
+ };
1443
+ }
1444
+ function $(e) {
1445
+ return e.kind === "action" ? `action:${e.code}` : `group:${JSON.stringify(e.name ?? {})}`;
1446
+ }
1447
+ function bt(e) {
1448
+ let t = e.parentElement;
1449
+ for (; t && getComputedStyle(t).display === "contents";) t = t.parentElement;
1450
+ if (!t) return !1;
1451
+ let n = getComputedStyle(t);
1452
+ return !(parseFloat(n.flexGrow) > 0 || n.display === "block" || n.display === "flow-root" || n.width !== "auto" || n.maxWidth !== "none");
1453
+ }
1454
+ function xt({ layout: t, entityActions: n, globalActions: r, onRun: i, reservedRightWidth: o = 0, measurementOverride: c, ariaLabel: l, align: u = "trailing", constrain: d = !0, row: f, widgetContext: p, onActionClick: m }) {
1455
+ let h = D(), g = G(null), _ = G(null), [y, b] = K(0), [x, S] = K(/* @__PURE__ */ new Map()), [C, w] = K(!1), [T, E] = K(null), [O, k] = K(() => typeof document < "u" && document.documentElement.dir === "rtl");
1456
+ U(() => {
1457
+ if (typeof MutationObserver > "u") return;
1458
+ let e = new MutationObserver((e) => {
1459
+ for (let t of e) t.attributeName === "dir" && k(document.documentElement.dir === "rtl"), t.attributeName === "lang" && w(!1);
1460
+ });
1461
+ return e.observe(document.documentElement, {
1462
+ attributes: !0,
1463
+ attributeFilter: ["dir", "lang"]
1464
+ }), () => e.disconnect();
1465
+ }, []);
1466
+ let A = G(null), [j, M] = K(!1), ee = H((e, t) => (M(!1), i(e, t)), [i]), te = Ke(t), N = !!c, P = H(() => {
1467
+ if (N || !_.current) return;
1468
+ let e = Array.from(_.current.children), t = /* @__PURE__ */ new Map();
1469
+ e.forEach((e) => {
1470
+ let n = e.dataset.nodeKey;
1471
+ n && t.set(n, e.getBoundingClientRect().width || e.offsetWidth);
1472
+ }), S((e) => gt(e, t) ? e : t), w(!0);
1473
+ }, [N]), F = ie(() => JSON.stringify(t.map((e) => $(e))), [t]);
1474
+ U(() => {
1475
+ if (N) return;
1476
+ let e = _.current;
1477
+ if (!e || typeof ResizeObserver > "u") return;
1478
+ let t = new ResizeObserver(() => P());
1479
+ t.observe(e);
1480
+ for (let n of Array.from(e.children)) t.observe(n);
1481
+ return () => t.disconnect();
1482
+ }, [
1483
+ P,
1484
+ N,
1485
+ F
1486
+ ]), W(() => {
1487
+ if (N) {
1488
+ w(!0);
1489
+ return;
1490
+ }
1491
+ w(!1);
1492
+ let e = requestAnimationFrame(() => {
1493
+ P();
1494
+ });
1495
+ return () => cancelAnimationFrame(e);
1496
+ }, [
1497
+ F,
1498
+ P,
1499
+ N
1500
+ ]), U(() => {
1501
+ if (N || C) return;
1502
+ let e = setTimeout(() => {
1503
+ P(), w(!0);
1504
+ }, 16);
1505
+ return () => clearTimeout(e);
1506
+ }, [
1507
+ C,
1508
+ P,
1509
+ N
1510
+ ]), U(() => {
1511
+ if (N || !d || !C || y === 0) return;
1512
+ let e = g.current;
1513
+ if (!e || !bt(e)) return;
1514
+ let t = [...e.children].filter((e) => e.getAttribute("aria-hidden") !== "true"), n = t.length > 1 ? (t.length - 1) * 4 : 0, r = t.reduce((e, t) => e + t.getBoundingClientRect().width, 0) + n;
1515
+ r > 0 && Math.abs(y - r) < 1 && console.error(`[declarion] ResponsiveActionBar is measuring itself: its container is ${Math.round(y)}px, exactly the width of what it just rendered. The slot holding this bar is sized by its own content, so it cannot tell the bar how much room there is. Give that slot \`flex: 1 1 auto; min-width: 0\` (and justify its content to the edge the buttons sit on), or pass \`constrain={false}\` if it genuinely has no row to take space from.`);
1516
+ }, [
1517
+ N,
1518
+ d,
1519
+ C,
1520
+ y,
1521
+ x
1522
+ ]), U(() => {
1523
+ if (N) return;
1524
+ let e = g.current;
1525
+ if (!e) return;
1526
+ if (typeof ResizeObserver > "u") {
1527
+ b(e.getBoundingClientRect().width);
1528
+ return;
1529
+ }
1530
+ let t = new ResizeObserver((e) => {
1531
+ let t = e[0];
1532
+ t && b(t.contentRect.width);
1533
+ });
1534
+ return t.observe(e), b(e.getBoundingClientRect().width), () => t.disconnect();
1535
+ }, [N]);
1536
+ let I = G(void 0), L = G(void 0);
1537
+ U(() => {
1538
+ I.current = void 0, L.current = void 0;
1539
+ }, [F]);
1540
+ let R = ie(() => N || !d ? yt(t, 2 ** 53 - 1, o, x, n, r, c) : C ? y === 0 ? yt(t, 2 ** 53 - 1, o, x, n, r, c) : yt(t, y, o, x, n, r, c, I.current, L.current) : {
1541
+ primaryInline: [],
1542
+ inline: [],
1543
+ overflow: [],
1544
+ destructiveInline: [],
1545
+ iconOnly: /* @__PURE__ */ new Set()
1546
+ }, [
1547
+ N,
1548
+ d,
1549
+ C,
1550
+ y,
1551
+ t,
1552
+ o,
1553
+ x,
1554
+ n,
1555
+ r,
1556
+ c
1557
+ ]);
1558
+ if (U(() => {
1559
+ (C || N) && (I.current = new Set([
1560
+ ...R.primaryInline,
1561
+ ...R.inline,
1562
+ ...R.destructiveInline
1563
+ ].map($)), L.current = new Set(R.iconOnly));
1564
+ }, [
1565
+ R,
1566
+ C,
1567
+ N
1568
+ ]), te === 0) return null;
1569
+ let z = R.overflow.length > 0, { normal: ne, destructive: B } = qe(R.overflow, n, r);
1570
+ return /* @__PURE__ */ Y("div", {
1571
+ ref: g,
1572
+ role: "toolbar",
1573
+ "aria-label": l ?? h("action.menu.title", "Actions"),
1574
+ style: {
1575
+ display: "flex",
1576
+ flexDirection: O ? "row-reverse" : "row",
1577
+ alignItems: "center",
1578
+ gap: ct,
1579
+ flexWrap: "wrap",
1580
+ visibility: C || N ? "visible" : "hidden",
1581
+ position: "relative",
1582
+ flex: d ? "1 1 auto" : "0 1 auto",
1583
+ justifyContent: u === "trailing" ? "flex-end" : "flex-start",
1584
+ minWidth: 0,
1585
+ boxSizing: "border-box"
1586
+ },
1587
+ children: [
1588
+ /* @__PURE__ */ Y("div", {
1589
+ ref: _,
1590
+ "aria-hidden": "true",
1591
+ inert: !0,
1592
+ style: {
1593
+ position: "absolute",
1594
+ visibility: "hidden",
1595
+ pointerEvents: "none",
1596
+ display: "flex",
1597
+ gap: 4,
1598
+ top: 0,
1599
+ left: 0,
1600
+ width: "max-content",
1601
+ flexWrap: "nowrap"
1602
+ },
1603
+ children: [/* @__PURE__ */ J(s, {
1604
+ "data-node-key": ot,
1605
+ iconRight: /* @__PURE__ */ J(e.down, { size: 10 }),
1606
+ tabIndex: -1,
1607
+ children: h("action.menu.title", "Actions")
1608
+ }, ot), t.map((e) => {
1609
+ let t = $(e);
1610
+ return e.kind === "action" ? /* @__PURE__ */ Y(re, { children: [/* @__PURE__ */ J($e, {
1611
+ leaf: e,
1612
+ entityActions: n,
1613
+ globalActions: r,
1614
+ onRun: mt,
1615
+ loading: !1,
1616
+ onLoadingChange: pt,
1617
+ row: f,
1618
+ widgetContext: p,
1619
+ measureRef: ht(t)
1620
+ }), Ze(e.code, n, r) && /* @__PURE__ */ J($e, {
1621
+ leaf: e,
1622
+ entityActions: n,
1623
+ globalActions: r,
1624
+ onRun: mt,
1625
+ loading: !1,
1626
+ onLoadingChange: pt,
1627
+ row: f,
1628
+ widgetContext: p,
1629
+ iconOnly: !0,
1630
+ measureRef: ht(ut(e))
1631
+ })] }, t) : /* @__PURE__ */ J(et, {
1632
+ group: e,
1633
+ entityActions: n,
1634
+ globalActions: r,
1635
+ onRun: mt,
1636
+ loading: null,
1637
+ onLoadingChange: pt,
1638
+ row: f,
1639
+ widgetContext: p,
1640
+ onActionClick: m,
1641
+ measureRef: ht(t)
1642
+ }, t);
1643
+ })]
1644
+ }),
1645
+ R.primaryInline.map((e) => /* @__PURE__ */ J($e, {
1646
+ leaf: e,
1647
+ entityActions: n,
1648
+ globalActions: r,
1649
+ onRun: i,
1650
+ loading: T === e.code,
1651
+ onLoadingChange: (t) => E(t ? e.code : null),
1652
+ row: f,
1653
+ widgetContext: p,
1654
+ onActionClick: m,
1655
+ iconOnly: R.iconOnly.has($(e))
1656
+ }, $(e))),
1657
+ R.inline.map((e) => {
1658
+ let t = $(e);
1659
+ return e.kind === "action" ? /* @__PURE__ */ J($e, {
1660
+ leaf: e,
1661
+ entityActions: n,
1662
+ globalActions: r,
1663
+ onRun: i,
1664
+ loading: T === e.code,
1665
+ onLoadingChange: (t) => E(t ? e.code : null),
1666
+ row: f,
1667
+ widgetContext: p,
1668
+ onActionClick: m,
1669
+ iconOnly: R.iconOnly.has(t)
1670
+ }, t) : /* @__PURE__ */ J(et, {
1671
+ group: e,
1672
+ entityActions: n,
1673
+ globalActions: r,
1674
+ onRun: i,
1675
+ loading: T,
1676
+ onLoadingChange: E,
1677
+ row: f,
1678
+ widgetContext: p,
1679
+ onActionClick: m
1680
+ }, t);
1681
+ }),
1682
+ z && /* @__PURE__ */ Y(q, { children: [/* @__PURE__ */ J(s, {
1683
+ ref: A,
1684
+ kind: "default",
1685
+ iconRight: /* @__PURE__ */ J(e.down, { size: 10 }),
1686
+ "aria-haspopup": "menu",
1687
+ "aria-expanded": j ? "true" : "false",
1688
+ onClick: () => M((e) => !e),
1689
+ children: h("action.menu.title", "Actions")
1690
+ }), /* @__PURE__ */ J(a, {
1691
+ open: j,
1692
+ anchor: A.current,
1693
+ onClose: () => M(!1),
1694
+ align: O ? "start" : "end",
1695
+ width: 220,
1696
+ children: /* @__PURE__ */ J("div", {
1697
+ role: "menu",
1698
+ "aria-label": h("action.menu.more", "More actions"),
1699
+ children: [
1700
+ ...ne,
1701
+ ...B.length > 0 ? [null] : [],
1702
+ ...B
1703
+ ].map((e, t) => e === null ? /* @__PURE__ */ J(v, { divider: !0 }, "destructive-divider") : e.kind === "action" ? /* @__PURE__ */ J(tt, {
1704
+ leaf: e,
1705
+ entityActions: n,
1706
+ globalActions: r,
1707
+ onRun: ee,
1708
+ loading: T === e.code,
1709
+ onLoadingChange: (t) => E(t ? e.code : null),
1710
+ row: f,
1711
+ widgetContext: p,
1712
+ onActionClick: m
1713
+ }, e.code) : /* @__PURE__ */ J(nt, {
1714
+ group: e,
1715
+ entityActions: n,
1716
+ globalActions: r,
1717
+ onRun: ee,
1718
+ loading: T,
1719
+ onLoadingChange: E,
1720
+ row: f,
1721
+ widgetContext: p,
1722
+ onActionClick: m
1723
+ }, `${$(e)}-${t}`))
1724
+ })
1725
+ })] }),
1726
+ R.destructiveInline.map((e) => /* @__PURE__ */ J($e, {
1727
+ leaf: e,
1728
+ entityActions: n,
1729
+ globalActions: r,
1730
+ onRun: i,
1731
+ loading: T === e.code,
1732
+ onLoadingChange: (t) => E(t ? e.code : null),
1733
+ row: f,
1734
+ widgetContext: p,
1735
+ onActionClick: m,
1736
+ iconOnly: R.iconOnly.has($(e))
1737
+ }, $(e)))
1738
+ ]
1739
+ });
1740
+ }
1741
+ function St({ layout: e, rowSelection: t = [], ...n }) {
1742
+ let r = t.length > 0;
1743
+ return /* @__PURE__ */ Y("div", {
1744
+ style: {
1745
+ position: "relative",
1746
+ display: "flex",
1747
+ flex: "1 1 auto",
1748
+ minWidth: 0
1749
+ },
1750
+ children: [/* @__PURE__ */ J("div", {
1751
+ "aria-hidden": r ? "true" : void 0,
1752
+ style: {
1753
+ display: r ? "none" : "flex",
1754
+ flex: "1 1 auto",
1755
+ minWidth: 0
1756
+ },
1757
+ children: /* @__PURE__ */ J(xt, {
1758
+ layout: e,
1759
+ rowSelection: [],
1760
+ ...n
1761
+ })
1762
+ }), /* @__PURE__ */ J("div", {
1763
+ "aria-hidden": r ? void 0 : "true",
1764
+ style: {
1765
+ display: r ? "flex" : "none",
1766
+ flex: "1 1 auto",
1767
+ minWidth: 0
1768
+ },
1769
+ children: /* @__PURE__ */ J(xt, {
1770
+ layout: e,
1771
+ rowSelection: t,
1772
+ ...n
1773
+ })
1774
+ })]
1775
+ });
1776
+ }
1777
+ function Ct({ layout: e, row: t, rowSelection: n, onRun: r, reservedRightWidth: i = 0, kind: a = "toolbar", align: o = "trailing", constrain: s = !0, measurementOverride: c, entityActions: l, globalActions: u, ariaLabel: d, widgetContext: f, onActionClick: p }) {
1778
+ let m = Ke(e);
1779
+ return a === "row" ? /* @__PURE__ */ J(rt, {
1780
+ layout: e,
1781
+ entityActions: l,
1782
+ globalActions: u,
1783
+ onRun: r,
1784
+ row: t,
1785
+ widgetContext: f,
1786
+ onActionClick: p
1787
+ }) : m === 0 ? null : J(a === "toolbar" ? St : xt, {
1788
+ layout: e,
1789
+ row: t,
1790
+ rowSelection: n,
1791
+ onRun: r,
1792
+ reservedRightWidth: i,
1793
+ measurementOverride: c,
1794
+ entityActions: l,
1795
+ globalActions: u,
1796
+ ariaLabel: d,
1797
+ align: o,
1798
+ constrain: s,
1799
+ widgetContext: f,
1800
+ onActionClick: p
1801
+ });
1802
+ }
1803
+ //#endregion
1804
+ //#region src/lib/filter-evaluator.ts
1805
+ var wt = /* @__PURE__ */ new Set([
1806
+ "string",
1807
+ "text",
1808
+ "rich_text",
1809
+ "email",
1810
+ "url",
1811
+ "phone"
1812
+ ]), Tt = /* @__PURE__ */ new Set([
1813
+ "int",
1814
+ "float",
1815
+ "decimal"
1816
+ ]), Et = /* @__PURE__ */ new Set([
1817
+ "date",
1818
+ "timestamp",
1819
+ "time"
1820
+ ]), Dt = /^(?:eq|not_eq|contains|starts_with|is_empty|is_not_empty)$/, Ot = /^(?:eq|not_eq|in|not_in|is_empty|is_not_empty)$/, kt = /^(?:eq|not_eq|gt|gte|lt|lte|between|is_empty|is_not_empty)$/, At = {
1821
+ string: Dt,
1822
+ text: Dt,
1823
+ rich_text: Dt,
1824
+ email: Dt,
1825
+ url: Dt,
1826
+ phone: Dt,
1827
+ enum: Ot,
1828
+ int: kt,
1829
+ float: kt,
1830
+ decimal: kt,
1831
+ date: kt,
1832
+ timestamp: kt,
1833
+ time: kt,
1834
+ bool: /^(?:eq|is_empty)$/,
1835
+ ref: /^(?:eq|not_eq|is_empty|is_not_empty)$/,
1836
+ uuid: /^(?:eq|not_eq|is_empty|is_not_empty)$/
1837
+ };
1838
+ function jt(e, t, n) {
1839
+ return e.every((e) => Mt(e, t, n));
1840
+ }
1841
+ function Mt(e, t, n) {
1842
+ if (e.and) return e.and.every((e) => Mt(e, t, n));
1843
+ if (e.or) return e.or.some((e) => Mt(e, t, n));
1844
+ if (!e.field || !e.op) return !1;
1845
+ let r = t[e.field];
1846
+ return !r || !At[r.type]?.test(e.op) ? !1 : Nt(e, r.type, n[e.field]);
1847
+ }
1848
+ function Nt(e, t, n) {
1849
+ let r = Pt(n);
1850
+ if (e.op === "is_empty") return r;
1851
+ if (e.op === "is_not_empty") return !r;
1852
+ if (r) return !1;
1853
+ let i = e.value;
1854
+ switch (e.op) {
1855
+ case "eq": return Ft(t, n, i);
1856
+ case "not_eq": return !Ft(t, n, i) && It(t, n, i);
1857
+ case "in": return Array.isArray(i) && i.some((e) => Ft(t, n, e));
1858
+ case "not_in": return Array.isArray(i) && i.every((e) => It(t, n, e) && !Ft(t, n, e));
1859
+ case "contains": return typeof n == "string" && typeof i == "string" && n.toLowerCase().includes(i.toLowerCase());
1860
+ case "starts_with": return typeof n == "string" && typeof i == "string" && n.toLowerCase().startsWith(i.toLowerCase());
1861
+ case "gt": return Lt(t, n, i, (e, t) => e > t);
1862
+ case "gte": return Lt(t, n, i, (e, t) => e >= t);
1863
+ case "lt": return Lt(t, n, i, (e, t) => e < t);
1864
+ case "lte": return Lt(t, n, i, (e, t) => e <= t);
1865
+ case "between": {
1866
+ if (!Array.isArray(i) || i.length !== 2) return !1;
1867
+ let e = Rt(t, n, i[0]), r = Rt(t, n, i[1]);
1868
+ return e === void 0 || r === void 0 ? !1 : e >= 0 && r <= 0;
1869
+ }
1870
+ default: return !1;
1871
+ }
1872
+ }
1873
+ function Pt(e) {
1874
+ return e == null || e === "" || Array.isArray(e) && e.length === 0;
1875
+ }
1876
+ function Ft(e, t, n) {
1877
+ return It(e, t, n) ? Et.has(e) ? Rt(e, t, n) === 0 : t === n : !1;
1878
+ }
1879
+ function It(e, t, n) {
1880
+ return Rt(e, t, n) !== void 0;
1881
+ }
1882
+ function Lt(e, t, n, r) {
1883
+ let i = Rt(e, t, n);
1884
+ return i !== void 0 && r(i, 0);
1885
+ }
1886
+ function Rt(e, t, n) {
1887
+ if (Tt.has(e)) return typeof t != "number" || typeof n != "number" || !Number.isFinite(t) || !Number.isFinite(n) ? void 0 : t === n ? 0 : t < n ? -1 : 1;
1888
+ if (Et.has(e)) return typeof t != "string" || typeof n != "string" || !zt(e, t) || !zt(e, n) ? void 0 : t === n ? 0 : t < n ? -1 : 1;
1889
+ if (wt.has(e) || e === "enum" || e === "ref" || e === "uuid") return typeof t != "string" || typeof n != "string" ? void 0 : t === n ? 0 : t < n ? -1 : 1;
1890
+ if (e === "bool") return typeof t != "boolean" || typeof n != "boolean" ? void 0 : t === n ? 0 : t ? 1 : -1;
1891
+ }
1892
+ function zt(e, t) {
1893
+ switch (e) {
1894
+ case "date": return /^\d{4}-\d{2}-\d{2}$/.test(t);
1895
+ case "time": return /^\d{2}:\d{2}:\d{2}(?:\.\d+)?$/.test(t);
1896
+ case "timestamp": return /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/.test(t);
1897
+ default: return !1;
1898
+ }
1899
+ }
1900
+ //#endregion
1901
+ //#region src/lib/variants.ts
1902
+ function Bt(e, t) {
1903
+ let n = e.variants;
1904
+ if (!n || n.length === 0) return;
1905
+ let r = {};
1906
+ for (let [t, n] of e.fields) r[t] = n;
1907
+ for (let [e, i] of n) if (e !== "default" && i.when && jt(i.when, r, t)) return e;
1908
+ return n.has("default") ? "default" : void 0;
1909
+ }
1910
+ function Vt(e, t) {
1911
+ let n = e?.variants;
1912
+ if (!n || !n.items().some((e) => e.actions !== void 0)) return;
1913
+ let r = Bt(e, t), i = n.get("default"), a = (r ? n.get(r)?.actions : void 0) ?? i?.actions ?? [];
1914
+ return new Set(a);
1915
+ }
1916
+ function Ht(e, t) {
1917
+ if (t.length === 0) return;
1918
+ let n = t.map((t) => Vt(e, t));
1919
+ if (n.every((e) => e === void 0)) return;
1920
+ let r = n[0] ?? /* @__PURE__ */ new Set(), i = new Set(r);
1921
+ for (let e of n.slice(1)) {
1922
+ if (!e) {
1923
+ i.clear();
1924
+ break;
1925
+ }
1926
+ for (let t of i) e.has(t) || i.delete(t);
1927
+ }
1928
+ return i;
1929
+ }
1930
+ function Ut(e, t, n) {
1931
+ if (!t.variants || t.variants.length === 0) return;
1932
+ if (e.variants) {
1933
+ let r = Bt(e, n) ?? "default";
1934
+ return t.variants.has(r) ? r : "default";
1935
+ }
1936
+ let r = {};
1937
+ for (let [t, n] of e.fields) r[t] = n;
1938
+ for (let [e, i] of t.variants) if (e !== "default" && i.when && jt(i.when, r, n)) return e;
1939
+ return "default";
1940
+ }
1941
+ var Wt = [
1942
+ "items",
1943
+ "sidebar",
1944
+ "sidebar_width",
1945
+ "highlights",
1946
+ "audit",
1947
+ "actions",
1948
+ "row_actions",
1949
+ "action_layout",
1950
+ "card",
1951
+ "quick_peek"
1952
+ ];
1953
+ function Gt(e, t, n) {
1954
+ if (!e || !t?.variants) return t;
1955
+ let r = Ut(e, t, n), i = r ? t.variants.get(r) : void 0;
1956
+ if (!i) return t;
1957
+ let a = { ...t };
1958
+ for (let e of Wt) i[e] !== void 0 && (a[e] = i[e]);
1959
+ return a;
1960
+ }
1961
+ //#endregion
1962
+ //#region src/lib/action-dispatch.ts
1963
+ function Kt(e, t, n, i, a) {
1964
+ return o(n) ? (r(e, n.ui_steps, i), null) : n.entity ? `${n.entity}.${t}` : a ? `${a}.${t}` : t;
1965
+ }
1966
+ //#endregion
1967
+ export { Z as C, oe as S, be as _, Ut as a, le as b, Ct as c, Re as d, ze as f, xe as g, Be as h, Bt as i, at as l, Ve as m, Ht as n, Vt as o, He as p, Gt as r, jt as s, Kt as t, Le as u, ye as v, ae as x, Q as y };