@object-ui/layout 17.6.0 → 17.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,179 +1,142 @@
1
- import { ComponentRegistry as e } from "@object-ui/core";
2
- import t, { useEffect as n, useMemo as r, useState as i } from "react";
3
- import { Badge as a, Button as o, Collapsible as s, CollapsibleContent as c, CollapsibleTrigger as l, Input as u, LazyIcon as d, Separator as f, Sidebar as p, SidebarContent as m, SidebarFooter as h, SidebarGroup as g, SidebarGroupContent as _, SidebarGroupLabel as v, SidebarHeader as y, SidebarInput as b, SidebarInset as x, SidebarMenu as S, SidebarMenuAction as C, SidebarMenuButton as w, SidebarMenuItem as T, SidebarMenuSub as E, SidebarMenuSubButton as D, SidebarMenuSubItem as O, SidebarProvider as k, cn as A, getLazyIcon as j, useIsMobile as M } from "@object-ui/components";
4
- import { ArrowLeft as N, ChevronRight as P, FileText as ee, GripVertical as te, Layers as F, Pin as ne, PinOff as re, Search as ie, Star as I } from "lucide-react";
5
- import { SchemaRenderer as L, useRecordContext as R } from "@object-ui/react";
6
- import { Fragment as ae, jsx as z, jsxs as B } from "react/jsx-runtime";
7
- import { Link as oe, NavLink as V, useLocation as H } from "react-router-dom";
8
- import { DndContext as U, KeyboardSensor as se, PointerSensor as ce, closestCenter as W, useSensor as G, useSensors as le } from "@dnd-kit/core";
9
- import { SortableContext as ue, arrayMove as de, useSortable as fe, verticalListSortingStrategy as pe } from "@dnd-kit/sortable";
10
- import { CSS as me } from "@dnd-kit/utilities";
11
- import { menuItemToNavigationItem as he } from "@object-ui/types";
12
- import { resolveI18nLabel as ge } from "@objectstack/spec/ui";
13
- //#region src/PageHeader.tsx
14
- var _e = (e) => {
15
- let t = e?.name ?? e?.full_name ?? e?.display_name ?? e?.label ?? e?.title ?? e?.subject;
16
- return t != null && String(t).trim() ? String(t) : [
17
- e?.salutation,
18
- e?.first_name,
19
- e?.last_name
20
- ].filter((e) => typeof e == "string" && e.trim()).map((e) => e.trim()).join(" ") || (typeof e?.email == "string" && e.email.trim() ? e.email.trim() : null);
21
- }, ve = (e, t) => !e || typeof e != "string" ? e ?? "" : e.includes("{") ? e.replace(/\{([a-zA-Z0-9_.]+)\}/g, (e, n) => {
22
- let r = n.split(".").reduce((e, t) => e == null ? e : e[t], t);
23
- return r == null ? "" : typeof r == "object" ? _e(r) ?? "" : String(r);
24
- }).replace(/\s*[-–—|/·,:]\s*(?=\s*[-–—|/·,:]|$)/g, "").replace(/^\s*[-–—|/·,:]\s*/, "").replace(/\s+/g, " ").trim() : e;
25
- function ye({ title: e, subtitle: n, icon: r, action: i, actions: a, showBack: s, schema: c, className: l, children: u, ...f }) {
26
- let p = R(), m = typeof e == "string" && /\{[a-zA-Z0-9_.]+\}/.test(e), h = ve(e, p?.data) || (m ? "" : e), g = n, _ = typeof g == "string" && /\{[a-zA-Z0-9_.]+\}/.test(g), v = ve(g, p?.data) || (_ ? "" : g), y = !!p?.recordId, b = !!p?.embedded, x = s ?? (y && !b), S = t.useCallback(() => {
27
- if (typeof window > "u") return;
28
- let e = window.location.pathname, t = e.replace(/\/record\/[^/]+\/?$/, "");
29
- t === e ? window.history.length > 1 && window.history.back() : (window.history.pushState({}, "", t + window.location.search), window.dispatchEvent(new PopStateEvent("popstate")));
30
- }, []), C = Array.isArray(c?.children) ? c.children.filter(Boolean).map((e, t) => /* @__PURE__ */ z(L, { schema: e }, e?.id || `pgh-child-${t}`)) : null, w = Array.isArray(a) && a.length > 0 && a || Array.isArray(c?.actions) && c.actions.length > 0 && c.actions || Array.isArray(c?.properties?.actions) && c.properties.actions.length > 0 && c.properties.actions || null, T = i || u || (w ? /* @__PURE__ */ z(L, { schema: {
31
- type: "record:quick_actions",
32
- properties: {
33
- actions: w,
34
- location: "record_header",
35
- align: "end",
36
- inline: !0
37
- }
38
- } }) : null) || C;
39
- return /* @__PURE__ */ z("div", {
40
- className: A("flex flex-col gap-3 pb-4 border-b", l),
41
- ...f,
42
- children: /* @__PURE__ */ B("div", {
43
- className: "flex flex-wrap items-center gap-x-4 gap-y-2",
44
- children: [
45
- x && /* @__PURE__ */ z(o, {
46
- type: "button",
47
- variant: "ghost",
48
- size: "icon",
49
- onClick: S,
50
- "aria-label": "Back to list",
51
- className: "flex-shrink-0 -ml-2",
52
- children: /* @__PURE__ */ z(N, { className: "size-4" })
53
- }),
54
- r && (h || v) && /* @__PURE__ */ z("div", {
55
- className: "flex-shrink-0 grid place-items-center size-10 rounded-md bg-primary/10 text-primary",
56
- children: typeof r == "string" ? /* @__PURE__ */ z(d, {
57
- name: r,
58
- className: "size-5"
59
- }) : r
60
- }),
61
- /* @__PURE__ */ B("div", {
62
- className: "flex flex-col min-w-0 flex-1",
63
- children: [h ? /* @__PURE__ */ z("h1", {
64
- className: "text-2xl font-bold tracking-tight md:text-3xl truncate",
65
- children: h
66
- }) : null, v && /* @__PURE__ */ z("p", {
67
- className: "text-sm text-muted-foreground truncate",
68
- children: v
69
- })]
70
- }),
71
- T && /* @__PURE__ */ z("div", {
72
- className: "flex items-center gap-2 ml-auto",
73
- children: T
74
- })
75
- ]
76
- })
77
- });
78
- }
79
- //#endregion
1
+ import e, { createElement as t, useEffect as n, useMemo as r, useState as i } from "react";
2
+ import { ComponentRegistry as a } from "@object-ui/core";
3
+ import { Badge as o, Button as s, Collapsible as c, CollapsibleContent as l, CollapsibleTrigger as u, Input as d, LazyIcon as f, Separator as p, Sidebar as m, SidebarContent as h, SidebarFooter as g, SidebarGroup as _, SidebarGroupContent as v, SidebarGroupLabel as y, SidebarHeader as b, SidebarInput as x, SidebarInset as S, SidebarMenu as C, SidebarMenuAction as w, SidebarMenuButton as T, SidebarMenuItem as E, SidebarMenuSub as D, SidebarMenuSubButton as O, SidebarMenuSubItem as k, SidebarProvider as A, cn as j, getLazyIcon as M, useIsMobile as N } from "@object-ui/components";
4
+ import { Fragment as P, jsx as F, jsxs as I } from "react/jsx-runtime";
5
+ import { Link as L, NavLink as R, useLocation as z } from "react-router-dom";
6
+ import { ArrowLeft as ee, ChevronRight as te, FileText as B, GripVertical as ne, Layers as re, Pin as ie, PinOff as ae, Search as V, Star as oe } from "lucide-react";
7
+ import { menuItemToNavigationItem as H } from "@object-ui/types";
8
+ import { resolveI18nLabel as se } from "@objectstack/spec/ui";
9
+ import { DndContext as ce, KeyboardSensor as U, PointerSensor as W, closestCenter as le, useSensor as ue, useSensors as de } from "@dnd-kit/core";
10
+ import { SortableContext as fe, arrayMove as pe, useSortable as me, verticalListSortingStrategy as he } from "@dnd-kit/sortable";
11
+ import { CSS as ge } from "@dnd-kit/utilities";
12
+ import { SchemaRenderer as _e, useRecordContext as ve } from "@object-ui/react";
80
13
  //#region src/PageCard.tsx
81
- function be({ className: e, children: t, ...n }) {
82
- return /* @__PURE__ */ z("div", {
83
- className: A("rounded-xl border bg-card text-card-foreground shadow", e),
14
+ function ye({ className: e, children: t, ...n }) {
15
+ return /* @__PURE__ */ F("div", {
16
+ className: j("rounded-xl border bg-card text-card-foreground shadow", e),
84
17
  ...n,
85
- children: /* @__PURE__ */ z("div", {
18
+ children: /* @__PURE__ */ F("div", {
86
19
  className: "p-6",
87
20
  children: t
88
21
  })
89
22
  });
90
23
  }
91
24
  //#endregion
92
- //#region src/ResponsiveGrid.tsx
93
- var xe = {
94
- xs: {
95
- 1: "grid-cols-1",
96
- 2: "grid-cols-2",
97
- 3: "grid-cols-3",
98
- 4: "grid-cols-4",
99
- 6: "grid-cols-6",
100
- 12: "grid-cols-12"
101
- },
102
- sm: {
103
- 1: "sm:grid-cols-1",
104
- 2: "sm:grid-cols-2",
105
- 3: "sm:grid-cols-3",
106
- 4: "sm:grid-cols-4",
107
- 6: "sm:grid-cols-6",
108
- 12: "sm:grid-cols-12"
109
- },
110
- md: {
111
- 1: "md:grid-cols-1",
112
- 2: "md:grid-cols-2",
113
- 3: "md:grid-cols-3",
114
- 4: "md:grid-cols-4",
115
- 6: "md:grid-cols-6",
116
- 12: "md:grid-cols-12"
117
- },
118
- lg: {
119
- 1: "lg:grid-cols-1",
120
- 2: "lg:grid-cols-2",
121
- 3: "lg:grid-cols-3",
122
- 4: "lg:grid-cols-4",
123
- 6: "lg:grid-cols-6",
124
- 12: "lg:grid-cols-12"
125
- },
126
- xl: {
127
- 1: "xl:grid-cols-1",
128
- 2: "xl:grid-cols-2",
129
- 3: "xl:grid-cols-3",
130
- 4: "xl:grid-cols-4",
131
- 6: "xl:grid-cols-6",
132
- 12: "xl:grid-cols-12"
133
- },
134
- "2xl": {
135
- 1: "2xl:grid-cols-1",
136
- 2: "2xl:grid-cols-2",
137
- 3: "2xl:grid-cols-3",
138
- 4: "2xl:grid-cols-4",
139
- 6: "2xl:grid-cols-6",
140
- 12: "2xl:grid-cols-12"
25
+ //#region src/AppShell.tsx
26
+ function be(e) {
27
+ let t = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);
28
+ if (!t) return null;
29
+ let n = parseInt(t[1], 16) / 255, r = parseInt(t[2], 16) / 255, i = parseInt(t[3], 16) / 255, a = Math.max(n, r, i), o = Math.min(n, r, i), s = 0, c = 0, l = (a + o) / 2;
30
+ if (a !== o) {
31
+ let e = a - o;
32
+ switch (c = l > .5 ? e / (2 - a - o) : e / (a + o), a) {
33
+ case n:
34
+ s = ((r - i) / e + (r < i ? 6 : 0)) / 6;
35
+ break;
36
+ case r:
37
+ s = ((i - n) / e + 2) / 6;
38
+ break;
39
+ case i: s = ((n - r) / e + 4) / 6;
40
+ }
141
41
  }
142
- };
42
+ return {
43
+ h: s * 360,
44
+ s: c * 100,
45
+ l: l * 100
46
+ };
47
+ }
48
+ function xe(e) {
49
+ let t = be(e);
50
+ return t ? `${Math.round(t.h)} ${Math.round(t.s)}% ${Math.round(t.l)}%` : null;
51
+ }
143
52
  function Se(e) {
144
- if (!e) return "grid-cols-1";
145
- let t = [];
146
- for (let [n, r] of Object.entries(e)) {
147
- let e = xe[n];
148
- if (e && r) {
149
- let n = Object.keys(e).map(Number).reduce((e, t) => Math.abs(t - r) < Math.abs(e - r) ? t : e);
150
- t.push(e[n]);
53
+ let t = be(e);
54
+ if (!t) return null;
55
+ let n = Math.max(t.l, 65), r = t.s > 80 ? Math.max(t.s - 10, 70) : t.s;
56
+ return `${Math.round(t.h)} ${Math.round(r)}% ${Math.round(n)}%`;
57
+ }
58
+ function Ce(e) {
59
+ let t = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);
60
+ if (!t) return "0 0% 100%";
61
+ let n = (e) => {
62
+ let t = e / 255;
63
+ return t <= .03928 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
64
+ }, r = n(parseInt(t[1], 16)), i = n(parseInt(t[2], 16)), a = n(parseInt(t[3], 16));
65
+ return .2126 * r + .7152 * i + .0722 * a > .6 ? "222 47% 11%" : "0 0% 100%";
66
+ }
67
+ function we(e, t) {
68
+ n(() => {
69
+ let n = document.documentElement, r = () => n.classList.contains("dark"), i = () => {
70
+ if (e?.primaryColor) {
71
+ let t = xe(e.primaryColor), i = Se(e.primaryColor), a = r() && i || t;
72
+ a && (n.style.setProperty("--brand-primary", e.primaryColor), n.style.setProperty("--brand-primary-hsl", t || a), n.style.setProperty("--primary", a), n.style.setProperty("--primary-foreground", r() ? "222 47% 11%" : Ce(e.primaryColor)), n.style.setProperty("--ring", a), n.style.setProperty("--sidebar-primary", a), n.style.setProperty("--sidebar-ring", a));
73
+ } else n.style.removeProperty("--brand-primary"), n.style.removeProperty("--brand-primary-hsl"), n.style.removeProperty("--primary"), n.style.removeProperty("--primary-foreground"), n.style.removeProperty("--ring"), n.style.removeProperty("--sidebar-primary"), n.style.removeProperty("--sidebar-ring");
74
+ if (e?.accentColor) {
75
+ let t = xe(e.accentColor), i = Se(e.accentColor), a = r() && i || t;
76
+ a && (n.style.setProperty("--brand-accent", e.accentColor), n.style.setProperty("--brand-accent-hsl", t || a), n.style.setProperty("--accent", a), n.style.setProperty("--accent-foreground", r() ? "222 47% 11%" : Ce(e.accentColor)));
77
+ } else n.style.removeProperty("--brand-accent"), n.style.removeProperty("--brand-accent-hsl"), n.style.removeProperty("--accent"), n.style.removeProperty("--accent-foreground");
78
+ };
79
+ i();
80
+ let a = new MutationObserver((e) => {
81
+ for (let t of e) if (t.type === "attributes" && t.attributeName === "class") {
82
+ i();
83
+ break;
84
+ }
85
+ });
86
+ a.observe(n, {
87
+ attributes: !0,
88
+ attributeFilter: ["class"]
89
+ });
90
+ let o = null, s = null;
91
+ if (e?.favicon) {
92
+ let t = document.querySelector("#favicon") || document.querySelector("link[rel=\"icon\"]");
93
+ t && (o = t, s = t.getAttribute("href"), t.href = e.favicon);
151
94
  }
152
- }
153
- return t.join(" ") || "grid-cols-1";
95
+ let c = null;
96
+ return t && (c = document.title, document.title = t), () => {
97
+ a.disconnect(), c !== null && (document.title = c), o && (s === null ? o.removeAttribute("href") : o.setAttribute("href", s)), n.style.removeProperty("--brand-primary"), n.style.removeProperty("--brand-primary-hsl"), n.style.removeProperty("--brand-accent"), n.style.removeProperty("--brand-accent-hsl"), n.style.removeProperty("--primary"), n.style.removeProperty("--primary-foreground"), n.style.removeProperty("--ring"), n.style.removeProperty("--sidebar-primary"), n.style.removeProperty("--sidebar-ring"), n.style.removeProperty("--accent"), n.style.removeProperty("--accent-foreground");
98
+ };
99
+ }, [
100
+ e?.primaryColor,
101
+ e?.accentColor,
102
+ e?.favicon,
103
+ t
104
+ ]);
154
105
  }
155
- var Ce = {
156
- 0: "gap-0",
157
- 1: "gap-1",
158
- 2: "gap-2",
159
- 3: "gap-3",
160
- 4: "gap-4",
161
- 5: "gap-5",
162
- 6: "gap-6",
163
- 8: "gap-8"
164
- }, we = ({ columns: e, gap: t = 4, className: n, children: r }) => {
165
- let i = Se(e), a = typeof t == "number" ? Ce[t] || `gap-${t}` : "";
166
- return /* @__PURE__ */ z("div", {
167
- className: A("grid", i, a, n),
168
- children: r
106
+ function Te({ sidebar: e, navbar: t, children: n, className: r, defaultOpen: i = !0, branding: a, rightRail: o }) {
107
+ return we(a, a?.title), /* @__PURE__ */ I(A, {
108
+ defaultOpen: i,
109
+ className: "!flex-col h-svh overflow-hidden",
110
+ children: [/* @__PURE__ */ F("header", {
111
+ className: "sticky top-0 z-30 flex h-14 w-full shrink-0 items-center gap-2 border-b bg-background px-2 sm:px-4",
112
+ children: t
113
+ }), /* @__PURE__ */ I("div", {
114
+ className: "flex flex-1 min-h-0 w-full",
115
+ children: [
116
+ e,
117
+ /* @__PURE__ */ F(S, {
118
+ className: "min-w-0",
119
+ children: /* @__PURE__ */ F("main", {
120
+ className: j("flex-1 min-w-0 overflow-auto p-3 sm:p-4 md:p-6 pb-20 sm:pb-4 md:pb-6", r),
121
+ children: n
122
+ })
123
+ }),
124
+ o
125
+ ]
126
+ })]
169
127
  });
170
- };
128
+ }
129
+ //#endregion
130
+ //#region src/navOrder.ts
131
+ function G(e, t) {
132
+ return (e.order ?? 0) - (t.order ?? 0);
133
+ }
171
134
  //#endregion
172
135
  //#region src/NavigationRenderer.tsx
173
136
  function K(e) {
174
- return e ? j(e) : ee;
137
+ return e ? M(e) : B;
175
138
  }
176
- function q(e, t) {
139
+ function Ee(e, t) {
177
140
  if (typeof e == "string") return e;
178
141
  if (t) {
179
142
  let n = t(e.key, {
@@ -184,53 +147,106 @@ function q(e, t) {
184
147
  }
185
148
  return e.defaultValue || e.key;
186
149
  }
187
- function Te(e, t, n, r, i) {
188
- let a = q(e.label, n);
189
- if (typeof e.label != "string") return a;
190
- let o = (e) => !!e && a.trim().toLowerCase() !== e.trim().toLowerCase();
191
- if (e.type === "object" && e.objectName) {
192
- if (e.viewName) return o(e.viewName) ? a : i ? i(e.objectName, e.viewName, a) : a;
193
- if (o(e.objectName)) return a;
194
- if (t) return t(e.objectName, a);
195
- }
196
- if (e.type === "dashboard" && e.dashboardName) {
197
- if (o(e.dashboardName)) return a;
198
- if (r) return r(e.dashboardName, a);
150
+ function q(e, t, n, r) {
151
+ return e.type === "separator" ? "" : e.label === void 0 ? ke(e, n) : De(e.label, t, r);
152
+ }
153
+ function De(e, t, n) {
154
+ return typeof e == "string" ? e : Oe(e) ? Ee(e, t) : se(e, n) ?? "";
155
+ }
156
+ function Oe(e) {
157
+ return typeof e == "object" && !!e && ("key" in e || "defaultValue" in e);
158
+ }
159
+ function ke(e, t) {
160
+ let n = (e) => {
161
+ let n = t?.(e);
162
+ return typeof n == "string" && n.trim() !== "" ? n : void 0;
163
+ };
164
+ switch (e.type) {
165
+ case "object":
166
+ if (!e.objectName) break;
167
+ return e.viewName ? n({
168
+ kind: "view",
169
+ objectName: e.objectName,
170
+ viewName: e.viewName
171
+ }) ?? n({
172
+ kind: "object",
173
+ objectName: e.objectName
174
+ }) ?? e.viewName : n({
175
+ kind: "object",
176
+ objectName: e.objectName
177
+ }) ?? e.objectName;
178
+ case "dashboard":
179
+ if (!e.dashboardName) break;
180
+ return n({
181
+ kind: "dashboard",
182
+ dashboardName: e.dashboardName
183
+ }) ?? e.dashboardName;
184
+ case "page":
185
+ if (e.pageName) return e.pageName;
186
+ break;
187
+ case "report":
188
+ if (e.reportName) return e.reportName;
189
+ break;
190
+ case "url":
191
+ if (e.url) return e.url;
192
+ break;
193
+ case "component":
194
+ if (e.componentRef) return e.componentRef;
195
+ break;
196
+ case "action":
197
+ if (e.actionDef?.actionName) return e.actionDef.actionName;
198
+ break;
199
+ case "doc":
200
+ if (e.doc) return e.doc;
201
+ if (e.book) return e.book;
199
202
  }
200
- return a;
203
+ return e.id;
201
204
  }
202
- var Ee = (e) => e !== !1 && e !== "false", De = () => !0, Oe = () => !0;
203
- function J(e, t = {}) {
204
- let { evaluateVisibility: n = Ee, checkPermission: r = De, checkCapability: i = Oe, hasActionHandler: a = !1 } = t;
205
- for (let o of e) if (n(o.visible) && !(o.requiredPermissions?.length && !r(o.requiredPermissions)) && !(o.requiresObject && !i("object", o.requiresObject)) && !(o.requiresService && !i("service", o.requiresService)) && o.type !== "separator") {
206
- if (o.type === "group") {
207
- if (J(o.children ?? [], t)) return !0;
205
+ var Ae = (e) => e !== !1 && e !== "false", je = () => !0, Me = () => !0;
206
+ function J(e, t) {
207
+ let { evaluateVisibility: n = Ae, checkPermission: r = je, checkCapability: i = Me, checkDocTarget: a } = t;
208
+ if (!n(e.visible) || e.requiredPermissions?.length && !r(e.requiredPermissions)) return !1;
209
+ let o = e.requiresObject, s = e.requiresService;
210
+ return !(o && !i("object", o) || s && !i("service", s) || e.type === "doc" && a && !a({
211
+ book: e.book,
212
+ doc: e.doc
213
+ }));
214
+ }
215
+ function Y(e, t = {}) {
216
+ let { hasActionHandler: n = !1 } = t;
217
+ for (let r of e) if (J(r, t) && r.type !== "separator") {
218
+ if (r.type === "group") {
219
+ if (Y(r.children ?? [], t)) return !0;
208
220
  continue;
209
221
  }
210
- if (!(o.type === "action" && !a)) return !0;
222
+ if (r.type !== "action" || n) return !0;
211
223
  }
212
224
  return !1;
213
225
  }
214
- var ke = /\{(current_user_id|current_org_id|[a-z][a-z0-9_]*)\}/g;
215
- function Y(e, t) {
226
+ var Ne = /\{(current_user_id|current_org_id|[a-z][a-z0-9_]*)\}/g;
227
+ function X(e, t) {
216
228
  if (!e.includes("{")) return e;
217
- let n = !1, r = e.replace(ke, (e, r) => {
229
+ let n = !1, r = e.replace(Ne, (e, r) => {
218
230
  let i;
219
231
  return i = r === "current_user_id" ? t?.currentUserId : r === "current_org_id" ? t?.currentOrgId : t?.contextValues?.[r], i || (n = !0, "");
220
232
  });
221
233
  return n ? null : r;
222
234
  }
223
- var Ae = "runAction";
224
- function je(e, t) {
235
+ var Pe = "runAction";
236
+ function Fe(e, t) {
225
237
  let n = t.runAction;
226
- return typeof n != "string" || n === "" ? e : `${e}${e.includes("?") ? "&" : "?"}${Ae}=${encodeURIComponent(n)}`;
238
+ return typeof n != "string" || n === "" ? e : `${e}${e.includes("?") ? "&" : "?"}${Pe}=${encodeURIComponent(n)}`;
239
+ }
240
+ function Ie(e, t, n) {
241
+ let r = (e) => encodeURIComponent(e);
242
+ return e && t ? `${n}/docs/${r(e)}/${r(t)}` : t ? `${n}/docs/${r(t)}` : e ? `${n}/docs/${r(e)}` : "#";
227
243
  }
228
- function X(e, t, n) {
244
+ function Z(e, t, n) {
229
245
  switch (e.type) {
230
246
  case "object": {
231
247
  let r = `${t}/${e.objectName ?? ""}`, i = e.recordId;
232
248
  if (i) {
233
- let t = Y(i, n);
249
+ let t = X(i, n);
234
250
  if (t) {
235
251
  let n = `${r}/record/${encodeURIComponent(t)}`;
236
252
  return {
@@ -244,17 +260,17 @@ function X(e, t, n) {
244
260
  let t = new URLSearchParams();
245
261
  for (let [e, r] of Object.entries(a)) {
246
262
  if (r == null || e === "") continue;
247
- let i = Y(String(r), n);
263
+ let i = X(String(r), n);
248
264
  i !== null && t.set(`filter[${e}]`, i);
249
265
  }
250
266
  let i = t.toString();
251
267
  return {
252
- href: je(i ? `${r}/data?${i}` : `${r}/data`, e),
268
+ href: Fe(i ? `${r}/data?${i}` : `${r}/data`, e),
253
269
  external: !1
254
270
  };
255
271
  }
256
272
  return {
257
- href: je(e.viewName ? `${r}/view/${e.viewName}` : r, e),
273
+ href: Fe(e.viewName ? `${r}/view/${e.viewName}` : r, e),
258
274
  external: !1
259
275
  };
260
276
  }
@@ -272,7 +288,7 @@ function X(e, t, n) {
272
288
  let e = new URLSearchParams();
273
289
  for (let [t, i] of Object.entries(r)) if (i != null) {
274
290
  if (typeof i == "string") {
275
- let r = Y(i, n);
291
+ let r = X(i, n);
276
292
  r !== null && e.set(t, r);
277
293
  } else e.set(t, JSON.stringify(i));
278
294
  }
@@ -310,7 +326,7 @@ function X(e, t, n) {
310
326
  let e = new URLSearchParams();
311
327
  for (let [t, r] of Object.entries(a)) if (t !== "type" && t !== "name" && r != null) {
312
328
  if (typeof r == "string") {
313
- let i = Y(r, n);
329
+ let i = X(r, n);
314
330
  i && e.set(t, i);
315
331
  } else e.set(t, JSON.stringify(r));
316
332
  }
@@ -340,33 +356,37 @@ function X(e, t, n) {
340
356
  external: !1
341
357
  };
342
358
  }
359
+ case "doc": return {
360
+ href: Ie(e.book, e.doc, t),
361
+ external: !1
362
+ };
343
363
  default: return {
344
364
  href: "#",
345
365
  external: !1
346
366
  };
347
367
  }
348
368
  }
349
- var Me = 50, Ne = 40, Pe = 30, Fe = 25, Ie = 10, Le = 5;
350
- function Re(e) {
369
+ var Le = 50, Re = 40, ze = 30, Be = 25, Ve = 10, He = 5;
370
+ function Ue(e) {
351
371
  let t = /* @__PURE__ */ new Map();
352
372
  return new URLSearchParams(e).forEach((e, n) => {
353
373
  let r = /^filter\[(.+)\]$/.exec(n);
354
374
  r && r[1] && e !== "" && t.set(r[1], e);
355
375
  }), t;
356
376
  }
357
- function ze(e, t) {
377
+ function We(e, t) {
358
378
  return t.startsWith(`${e}.`) ? t.slice(e.length + 1) : t;
359
379
  }
360
- function Be(e, t, n, r, i) {
361
- let { href: a, external: o } = X(e, r, i);
380
+ function Ge(e, t, n, r, i) {
381
+ let { href: a, external: o } = Z(e, r, i);
362
382
  if (o || a === "#") return 0;
363
383
  if (e.type === "object" && e.objectName) {
364
384
  let a = `${r}/${e.objectName}`;
365
385
  if (t !== a && !t.startsWith(`${a}/`)) return 0;
366
386
  let o = t === a ? [] : t.slice(a.length + 1).split("/"), s = e.recordId;
367
387
  if (s) {
368
- let e = Y(s, i);
369
- if (e) return o[0] === "record" && decodeURIComponent(o[1] ?? "") === e ? Me : 0;
388
+ let e = X(s, i);
389
+ if (e) return o[0] === "record" && decodeURIComponent(o[1] ?? "") === e ? Le : 0;
370
390
  }
371
391
  let c = e.filters;
372
392
  if (c && typeof c == "object" && !Array.isArray(c)) {
@@ -374,212 +394,235 @@ function Be(e, t, n, r, i) {
374
394
  let e = /* @__PURE__ */ new Map();
375
395
  for (let [t, n] of Object.entries(c)) {
376
396
  if (n == null || t === "") continue;
377
- let r = Y(String(n), i);
397
+ let r = X(String(n), i);
378
398
  r !== null && e.set(t, r);
379
399
  }
380
400
  if (e.size !== n.size) return 0;
381
401
  for (let [t, r] of e) if (n.get(t) !== r) return 0;
382
- return Ne;
402
+ return Re;
383
403
  }
384
- return e.viewName ? o[0] !== "view" || !o[1] ? 0 : ze(e.objectName, decodeURIComponent(o[1])) === ze(e.objectName, e.viewName) ? Pe : 0 : o.length === 0 ? Fe : Ie;
404
+ return e.viewName ? o[0] !== "view" || !o[1] ? 0 : We(e.objectName, decodeURIComponent(o[1])) === We(e.objectName, e.viewName) ? ze : 0 : o.length === 0 ? Be : Ve;
385
405
  }
386
406
  let s = a.split("?")[0];
387
- if (t === s) return Fe;
407
+ if (t === s) return Be;
388
408
  let c = e.componentRef;
389
- return c && c.split(":")[1] === "directory" ? 0 : t.startsWith(`${s}/`) ? Le : 0;
409
+ return c && c.split(":")[1] === "directory" ? 0 : t.startsWith(`${s}/`) ? He : 0;
390
410
  }
391
- function Ve(e, t, n, r, i) {
392
- let a = Re(n), o = null, s = 0, c = (e) => {
411
+ function Q(e, t, n, r, i) {
412
+ let a = Ue(n), o = null, s = 0, c = (e) => {
393
413
  if (e) for (let n of e) {
394
414
  if (n.type === "group") {
395
415
  c(n.children);
396
416
  continue;
397
417
  }
398
- let e = Be(n, t, a, r, i);
418
+ let e = Ge(n, t, a, r, i);
399
419
  e > s && (o = n, s = e);
400
420
  }
401
421
  };
402
422
  return c(e), o;
403
423
  }
404
- var Z = t.createContext(null);
405
- function Q(e, t) {
424
+ var Ke = e.createContext(null);
425
+ function qe(e, t, n = (e) => q(e)) {
406
426
  if (!t.trim()) return e;
407
- let n = t.toLowerCase().trim();
408
- return e.reduce((e, r) => {
409
- if (r.type === "separator") return e;
410
- if (r.type === "group" && r.children?.length) {
411
- let n = Q(r.children, t);
412
- return n.length > 0 && e.push({
413
- ...r,
414
- children: n
427
+ let r = t.toLowerCase().trim();
428
+ return e.reduce((e, i) => {
429
+ if (i.type === "separator") return e;
430
+ if (i.type === "group" && i.children?.length) {
431
+ let r = qe(i.children, t, n);
432
+ return r.length > 0 && e.push({
433
+ ...i,
434
+ children: r
415
435
  }), e;
416
436
  }
417
- return q(r.label).toLowerCase().includes(n) && e.push(r), e;
437
+ return n(i).toLowerCase().includes(r) && e.push(i), e;
418
438
  }, []);
419
439
  }
420
- var He = 5;
421
- function Ue({ item: e, basePath: t, evalVis: n, checkPerm: r, checkCap: i, onAction: a, enablePinning: o, onPinToggle: s, enableReorder: c, resolveObjectLabel: l, resolveDashboardLabel: u, resolveViewLabel: d, t: f, templateContext: p }) {
422
- let { attributes: m, listeners: h, setNodeRef: g, transform: _, transition: v, isDragging: y } = fe({
440
+ var Je = 5;
441
+ function Ye({ item: e, basePath: t, evalVis: n, checkPerm: r, checkCap: i, checkDocTarget: a, onAction: o, enablePinning: s, onPinToggle: c, enableReorder: l, resolveTargetLabel: u, locale: d, t: f, templateContext: p }) {
442
+ let { attributes: m, listeners: h, setNodeRef: g, transform: _, transition: v, isDragging: y } = me({
423
443
  id: e.id,
424
- disabled: !c
444
+ disabled: !l
425
445
  }), b = {
426
- transform: me.Transform.toString(_),
446
+ transform: ge.Transform.toString(_),
427
447
  transition: v,
428
448
  opacity: y ? .5 : void 0,
429
449
  zIndex: y ? 10 : void 0
430
450
  };
431
- return /* @__PURE__ */ z("div", {
451
+ return /* @__PURE__ */ F("div", {
432
452
  ref: g,
433
453
  style: b,
434
454
  ...m,
435
- children: /* @__PURE__ */ z($, {
455
+ children: /* @__PURE__ */ F($, {
436
456
  item: e,
437
457
  basePath: t,
438
458
  evalVis: n,
439
459
  checkPerm: r,
440
460
  checkCap: i,
441
- onAction: a,
442
- enablePinning: o,
443
- onPinToggle: s,
444
- dragListeners: c ? h : void 0,
445
- resolveObjectLabel: l,
446
- resolveDashboardLabel: u,
447
- resolveViewLabel: d,
461
+ checkDocTarget: a,
462
+ onAction: o,
463
+ enablePinning: s,
464
+ onPinToggle: c,
465
+ dragListeners: l ? h : void 0,
466
+ resolveTargetLabel: u,
467
+ locale: d,
448
468
  t: f,
449
469
  templateContext: p
450
470
  })
451
471
  });
452
472
  }
453
- function $({ item: e, basePath: n, evalVis: r, checkPerm: o, checkCap: u, onAction: d, enablePinning: p, onPinToggle: m, dragListeners: h, resolveObjectLabel: y, resolveDashboardLabel: b, resolveViewLabel: x, t: E, templateContext: D }) {
454
- let O = M(), k = O ? "min-h-[44px] text-[15px] gap-3 rounded-xl" : void 0, j = A("shrink-0", O ? "h-5 w-5" : "h-4 w-4"), N = (() => {
455
- if (typeof e.expanded == "boolean") return e.expanded;
456
- if (typeof e.defaultOpen == "boolean") return e.defaultOpen;
457
- })(), ee = e.type === "group" ? e.children?.length ?? 0 : 0, F = t.useContext(Z), ie = t.useMemo(() => {
458
- if (e.type !== "group" || !F) return !1;
459
- let t = (e) => !!e?.some((e) => e.id === F || e.type === "group" && t(e.children));
460
- return t(e.children);
461
- }, [e, F]) ? !0 : N ?? !(ee >= 8), [I, L] = i(ie);
462
- if (!r(e.visible) || e.requiredPermissions?.length && !o(e.requiredPermissions)) return null;
463
- let R = e.requiresObject, V = e.requiresService;
464
- if (R && !u("object", R) || V && !u("service", V)) return null;
465
- if (e.type === "separator") return /* @__PURE__ */ z(f, { className: "my-2" });
466
- if (e.type === "group") {
467
- let t = (e.children ?? []).slice().sort((e, t) => (e.order ?? 0) - (t.order ?? 0)), i = Te(e, y, E, b, x);
468
- return /* @__PURE__ */ z(s, {
469
- open: I,
470
- onOpenChange: L,
471
- children: /* @__PURE__ */ B(g, { children: [/* @__PURE__ */ z(v, {
473
+ function $({ item: t, basePath: n, evalVis: r, checkPerm: a, checkCap: s, checkDocTarget: d, onAction: f, enablePinning: m, onPinToggle: h, dragListeners: g, resolveTargetLabel: b, locale: x, t: S, templateContext: D }) {
474
+ let O = N(), k = O ? "min-h-[44px] text-[15px] gap-3 rounded-xl" : void 0, A = j("shrink-0", O ? "h-5 w-5" : "h-4 w-4"), M = (() => {
475
+ if (typeof t.expanded == "boolean") return t.expanded;
476
+ if (typeof t.defaultOpen == "boolean") return t.defaultOpen;
477
+ })(), R = t.type === "group" ? t.children?.length ?? 0 : 0, z = e.useContext(Ke), ee = e.useMemo(() => {
478
+ if (t.type !== "group" || !z) return !1;
479
+ let e = (t) => !!t?.some((t) => t.id === z || t.type === "group" && e(t.children));
480
+ return e(t.children);
481
+ }, [t, z]) ? !0 : M ?? !(R >= 8), [B, re] = i(ee), V = {
482
+ evaluateVisibility: r,
483
+ checkPermission: a,
484
+ checkCapability: s,
485
+ checkDocTarget: d,
486
+ hasActionHandler: !!f
487
+ };
488
+ if (!J(t, V)) return null;
489
+ if (t.type === "separator") return /* @__PURE__ */ F(p, { className: "my-2" });
490
+ if (t.type === "group") {
491
+ let e = (t.children ?? []).slice().sort(G);
492
+ if (!Y(e, V)) return null;
493
+ let i = q(t, S, b, x);
494
+ return /* @__PURE__ */ F(c, {
495
+ open: B,
496
+ onOpenChange: re,
497
+ children: /* @__PURE__ */ I(_, { children: [/* @__PURE__ */ F(y, {
472
498
  asChild: !0,
473
- children: /* @__PURE__ */ B(l, {
474
- className: A("flex w-full items-center justify-between", O && "min-h-[44px] text-[15px] rounded-xl"),
475
- children: [i, /* @__PURE__ */ z(P, { className: A("ml-auto transition-transform", O ? "h-5 w-5" : "h-4 w-4", I && "rotate-90") })]
499
+ children: /* @__PURE__ */ I(u, {
500
+ className: j("flex w-full items-center justify-between", O && "min-h-[44px] text-[15px] rounded-xl"),
501
+ children: [i, /* @__PURE__ */ F(te, { className: j("ml-auto transition-transform", O ? "h-5 w-5" : "h-4 w-4", B && "rotate-90") })]
476
502
  })
477
- }), /* @__PURE__ */ z(c, { children: /* @__PURE__ */ z(_, { children: /* @__PURE__ */ z(S, { children: t.map((e) => /* @__PURE__ */ z($, {
503
+ }), /* @__PURE__ */ F(l, { children: /* @__PURE__ */ F(v, { children: /* @__PURE__ */ F(C, { children: e.map((e) => /* @__PURE__ */ F($, {
478
504
  item: e,
479
505
  basePath: n,
480
506
  evalVis: r,
481
- checkPerm: o,
482
- checkCap: u,
483
- onAction: d,
484
- enablePinning: p,
485
- onPinToggle: m,
486
- resolveObjectLabel: y,
487
- resolveDashboardLabel: b,
488
- resolveViewLabel: x,
489
- t: E,
507
+ checkPerm: a,
508
+ checkCap: s,
509
+ checkDocTarget: d,
510
+ onAction: f,
511
+ enablePinning: m,
512
+ onPinToggle: h,
513
+ resolveTargetLabel: b,
514
+ locale: x,
515
+ t: S,
490
516
  templateContext: D
491
517
  }, e.id)) }) }) })] })
492
518
  });
493
519
  }
494
- if (e.type === "action") {
495
- if (!d) return null;
496
- let t = K(e.icon), r = q(e.label, E);
497
- return /* @__PURE__ */ B(T, { children: [
498
- h && /* @__PURE__ */ z("span", {
520
+ if (t.type === "action") {
521
+ if (!f) return null;
522
+ let e = K(t.icon), r = q(t, S, b, x);
523
+ return /* @__PURE__ */ I(E, { children: [
524
+ g && /* @__PURE__ */ F("span", {
499
525
  className: "absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground",
500
- "aria-label": E ? E("console.nav.dragToReorder", { defaultValue: "Drag to reorder" }) : "Drag to reorder",
501
- ...h,
502
- children: /* @__PURE__ */ z(te, { className: "h-3.5 w-3.5" })
526
+ "aria-label": S ? S("console.nav.dragToReorder", { defaultValue: "Drag to reorder" }) : "Drag to reorder",
527
+ ...g,
528
+ children: /* @__PURE__ */ F(ne, { className: "h-3.5 w-3.5" })
503
529
  }),
504
- /* @__PURE__ */ B(w, {
530
+ /* @__PURE__ */ I(T, {
505
531
  tooltip: r,
506
- onClick: () => d?.(e),
532
+ onClick: () => f?.(t),
507
533
  className: k,
508
534
  children: [
509
- /* @__PURE__ */ z(t, { className: j }),
510
- /* @__PURE__ */ z("span", { children: r }),
511
- e.badge != null && /* @__PURE__ */ z(a, {
512
- variant: e.badgeVariant ?? "default",
535
+ /* @__PURE__ */ F(e, { className: A }),
536
+ /* @__PURE__ */ F("span", { children: r }),
537
+ t.badge != null && /* @__PURE__ */ F(o, {
538
+ variant: t.badgeVariant ?? "default",
513
539
  className: "ml-auto text-[10px] px-1.5 py-0",
514
- children: e.badge
540
+ children: t.badge
515
541
  })
516
542
  ]
517
543
  }),
518
- p && m && /* @__PURE__ */ z(C, {
544
+ m && h && /* @__PURE__ */ F(w, {
519
545
  showOnHover: !0,
520
- onClick: () => m(e.id, !e.pinned, e, n),
521
- "aria-label": E ? E(e.pinned ? "console.nav.unpinItem" : "console.nav.pinItem", {
522
- defaultValue: e.pinned ? `Unpin ${r}` : `Pin ${r}`,
546
+ onClick: () => h(t.id, !t.pinned, t, n),
547
+ "aria-label": S ? S(t.pinned ? "console.nav.unpinItem" : "console.nav.pinItem", {
548
+ defaultValue: t.pinned ? `Unpin ${r}` : `Pin ${r}`,
523
549
  name: r
524
- }) : e.pinned ? `Unpin ${r}` : `Pin ${r}`,
525
- children: e.pinned ? /* @__PURE__ */ z(re, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ z(ne, { className: "h-3.5 w-3.5" })
550
+ }) : t.pinned ? `Unpin ${r}` : `Pin ${r}`,
551
+ children: t.pinned ? /* @__PURE__ */ F(ae, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ F(ie, { className: "h-3.5 w-3.5" })
526
552
  })
527
553
  ] });
528
554
  }
529
- let H = K(e.icon), { href: U, external: se } = X(e, n, D), ce = F !== null && e.id === F, W = Te(e, y, E, b, x), G = /* @__PURE__ */ B(ae, { children: [
530
- /* @__PURE__ */ z(H, { className: j }),
531
- /* @__PURE__ */ z("span", { children: W }),
532
- e.badge != null && /* @__PURE__ */ z(a, {
533
- variant: e.badgeVariant ?? "default",
555
+ let oe = K(t.icon), { href: H, external: se } = Z(t, n, D), ce = z !== null && t.id === z, U = q(t, S, b, x), W = /* @__PURE__ */ I(P, { children: [
556
+ /* @__PURE__ */ F(oe, { className: A }),
557
+ /* @__PURE__ */ F("span", { children: U }),
558
+ t.badge != null && /* @__PURE__ */ F(o, {
559
+ variant: t.badgeVariant ?? "default",
534
560
  className: "ml-auto text-[10px] px-1.5 py-0",
535
- children: e.badge
561
+ children: t.badge
536
562
  })
537
563
  ] });
538
- return /* @__PURE__ */ B(T, { children: [
539
- h && /* @__PURE__ */ z("span", {
564
+ return /* @__PURE__ */ I(E, { children: [
565
+ g && /* @__PURE__ */ F("span", {
540
566
  className: "absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground",
541
- "aria-label": E ? E("console.nav.dragToReorder", { defaultValue: "Drag to reorder" }) : "Drag to reorder",
542
- ...h,
543
- children: /* @__PURE__ */ z(te, { className: "h-3.5 w-3.5" })
567
+ "aria-label": S ? S("console.nav.dragToReorder", { defaultValue: "Drag to reorder" }) : "Drag to reorder",
568
+ ...g,
569
+ children: /* @__PURE__ */ F(ne, { className: "h-3.5 w-3.5" })
544
570
  }),
545
- /* @__PURE__ */ z(w, {
571
+ /* @__PURE__ */ F(T, {
546
572
  asChild: !0,
547
573
  isActive: ce,
548
- tooltip: W,
574
+ tooltip: U,
549
575
  className: k,
550
- children: se ? /* @__PURE__ */ z("a", {
551
- href: U,
576
+ children: se ? /* @__PURE__ */ F("a", {
577
+ href: H,
552
578
  target: "_blank",
553
579
  rel: "noopener noreferrer",
554
- children: G
555
- }) : /* @__PURE__ */ z(oe, {
556
- to: U,
557
- children: G
580
+ children: W
581
+ }) : /* @__PURE__ */ F(L, {
582
+ to: H,
583
+ children: W
558
584
  })
559
585
  }),
560
- p && m && /* @__PURE__ */ z(C, {
586
+ m && h && /* @__PURE__ */ F(w, {
561
587
  showOnHover: !0,
562
- onClick: () => m(e.id, !e.pinned, e, n),
563
- "aria-label": E ? E(e.pinned ? "console.nav.unpinItem" : "console.nav.pinItem", {
564
- defaultValue: e.pinned ? `Unpin ${W}` : `Pin ${W}`,
565
- name: W
566
- }) : e.pinned ? `Unpin ${W}` : `Pin ${W}`,
567
- children: e.pinned ? /* @__PURE__ */ z(re, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ z(ne, { className: "h-3.5 w-3.5" })
588
+ onClick: () => h(t.id, !t.pinned, t, n),
589
+ "aria-label": S ? S(t.pinned ? "console.nav.unpinItem" : "console.nav.pinItem", {
590
+ defaultValue: t.pinned ? `Unpin ${U}` : `Pin ${U}`,
591
+ name: U
592
+ }) : t.pinned ? `Unpin ${U}` : `Pin ${U}`,
593
+ children: t.pinned ? /* @__PURE__ */ F(ae, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ F(ie, { className: "h-3.5 w-3.5" })
568
594
  })
569
595
  ] });
570
596
  }
571
- function We({ items: e, basePath: t = "", evaluateVisibility: n = Ee, checkPermission: i = De, checkCapability: a = Oe, onAction: o, searchQuery: s, enablePinning: c, onPinToggle: l, enableReorder: u, onReorder: d, resolveObjectLabel: f, resolveDashboardLabel: p, resolveViewLabel: m, t: h, templateContext: y }) {
572
- let b = H(), x = r(() => Ve(e, b.pathname, b.search, t, y)?.id ?? null, [
597
+ function Xe({ items: e, basePath: t = "", evaluateVisibility: n = Ae, checkPermission: i = je, checkCapability: a = Me, checkDocTarget: o, onAction: s, searchQuery: c, enablePinning: l, onPinToggle: u, enableReorder: d, onReorder: f, resolveTargetLabel: p, locale: m, t: h, templateContext: g }) {
598
+ let b = z(), x = r(() => Q(e, b.pathname, b.search, t, g)?.id ?? null, [
573
599
  e,
574
600
  b.pathname,
575
601
  b.search,
576
602
  t,
577
- y
578
- ]), C = r(() => s ? Q(e, s) : e, [e, s]), w = r(() => Ge(C), [C]), T = C.slice().sort((e, t) => (e.order ?? 0) - (t.order ?? 0)), E = le(G(ce, { activationConstraint: { distance: He } }), G(se)), D = (e) => {
603
+ g
604
+ ]), S = r(() => c ? qe(e, c, (e) => q(e, h, p, m)) : e, [
605
+ e,
606
+ c,
607
+ h,
608
+ p,
609
+ m
610
+ ]), w = r(() => Ze(S, {
611
+ evaluateVisibility: n,
612
+ checkPermission: i,
613
+ checkCapability: a,
614
+ checkDocTarget: o
615
+ }), [
616
+ S,
617
+ n,
618
+ i,
619
+ a,
620
+ o
621
+ ]), T = S.slice().sort(G), E = de(ue(W, { activationConstraint: { distance: Je } }), ue(U)), D = (e) => {
579
622
  let { active: t, over: n } = e;
580
- if (!n || t.id === n.id || !d) return;
623
+ if (!n || t.id === n.id || !f) return;
581
624
  let r = T.findIndex((e) => e.id === t.id), i = T.findIndex((e) => e.id === n.id);
582
- r !== -1 && i !== -1 && d(de(T, r, i).map((e, t) => ({
625
+ r !== -1 && i !== -1 && f(pe(T, r, i).map((e, t) => ({
583
626
  ...e,
584
627
  order: t
585
628
  })));
@@ -588,369 +631,341 @@ function We({ items: e, basePath: t = "", evaluateVisibility: n = Ee, checkPermi
588
631
  evalVis: n,
589
632
  checkPerm: i,
590
633
  checkCap: a,
591
- onAction: o,
592
- enablePinning: c,
593
- onPinToggle: l,
594
- resolveObjectLabel: f,
595
- resolveDashboardLabel: p,
596
- resolveViewLabel: m,
634
+ checkDocTarget: o,
635
+ onAction: s,
636
+ enablePinning: l,
637
+ onPinToggle: u,
638
+ resolveTargetLabel: p,
639
+ locale: m,
597
640
  t: h,
598
- templateContext: y
599
- }, k = T.some((e) => e.type === "group"), A = w.length > 0 && c ? /* @__PURE__ */ B(g, { children: [/* @__PURE__ */ B(v, {
641
+ templateContext: g
642
+ }, k = T.some((e) => e.type === "group"), A = w.length > 0 && l ? /* @__PURE__ */ I(_, { children: [/* @__PURE__ */ I(y, {
600
643
  className: "flex items-center gap-1.5",
601
- children: [/* @__PURE__ */ z(I, { className: "h-3.5 w-3.5" }), h ? h("console.nav.favorites", { defaultValue: "Favorites" }) : "Favorites"]
602
- }), /* @__PURE__ */ z(_, { children: /* @__PURE__ */ z(S, { children: w.map((e) => /* @__PURE__ */ z($, {
644
+ children: [/* @__PURE__ */ F(oe, { className: "h-3.5 w-3.5" }), h ? h("console.nav.favorites", { defaultValue: "Favorites" }) : "Favorites"]
645
+ }), /* @__PURE__ */ F(v, { children: /* @__PURE__ */ F(C, { children: w.map((e) => /* @__PURE__ */ F($, {
603
646
  item: e,
604
647
  ...O
605
648
  }, `fav-${e.id}`)) }) })] }) : null;
606
649
  if (!k) {
607
- let e = T.filter((e) => e.type !== "group").map((e) => e.id), t = u ? /* @__PURE__ */ z(U, {
650
+ let e = T.filter((e) => e.type !== "group").map((e) => e.id), t = d ? /* @__PURE__ */ F(ce, {
608
651
  sensors: E,
609
- collisionDetection: W,
652
+ collisionDetection: le,
610
653
  onDragEnd: D,
611
- children: /* @__PURE__ */ z(ue, {
654
+ children: /* @__PURE__ */ F(fe, {
612
655
  items: e,
613
- strategy: pe,
614
- children: /* @__PURE__ */ z(S, { children: T.map((e) => /* @__PURE__ */ z(Ue, {
656
+ strategy: he,
657
+ children: /* @__PURE__ */ F(C, { children: T.map((e) => /* @__PURE__ */ F(Ye, {
615
658
  item: e,
616
- enableReorder: u,
659
+ enableReorder: d,
617
660
  ...O
618
661
  }, e.id)) })
619
662
  })
620
- }) : /* @__PURE__ */ z(S, { children: T.map((e) => /* @__PURE__ */ z($, {
663
+ }) : /* @__PURE__ */ F(C, { children: T.map((e) => /* @__PURE__ */ F($, {
621
664
  item: e,
622
665
  ...O
623
666
  }, e.id)) });
624
- return /* @__PURE__ */ B(Z.Provider, {
667
+ return /* @__PURE__ */ I(Ke.Provider, {
625
668
  value: x,
626
- children: [A, /* @__PURE__ */ z(g, { children: /* @__PURE__ */ z(_, { children: t }) })]
669
+ children: [A, /* @__PURE__ */ F(_, { children: /* @__PURE__ */ F(v, { children: t }) })]
627
670
  });
628
671
  }
629
672
  let j = [], M = [], N = (e) => {
630
673
  if (M.length === 0) return;
631
674
  let t = M;
632
- M = [], j.push(/* @__PURE__ */ z(g, { children: /* @__PURE__ */ z(_, { children: /* @__PURE__ */ z(S, { children: t.map((e) => /* @__PURE__ */ z($, {
675
+ M = [], j.push(/* @__PURE__ */ F(_, { children: /* @__PURE__ */ F(v, { children: /* @__PURE__ */ F(C, { children: t.map((e) => /* @__PURE__ */ F($, {
633
676
  item: e,
634
677
  ...O
635
678
  }, e.id)) }) }) }, e));
636
679
  };
637
680
  return T.forEach((e, t) => {
638
- e.type === "group" ? (N(`leaf-${t}`), j.push(/* @__PURE__ */ z($, {
681
+ e.type === "group" ? (N(`leaf-${t}`), j.push(/* @__PURE__ */ F($, {
639
682
  item: e,
640
683
  ...O
641
684
  }, e.id))) : M.push(e);
642
- }), N("leaf-end"), /* @__PURE__ */ B(Z.Provider, {
685
+ }), N("leaf-end"), /* @__PURE__ */ I(Ke.Provider, {
643
686
  value: x,
644
687
  children: [A, j]
645
688
  });
646
689
  }
647
- function Ge(e) {
648
- let t = [];
649
- for (let n of e) n.pinned && n.type !== "group" && n.type !== "separator" && t.push(n), n.children?.length && t.push(...Ge(n.children));
650
- return t;
651
- }
652
- //#endregion
653
- //#region src/AppShell.tsx
654
- function Ke(e) {
655
- let t = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);
656
- if (!t) return null;
657
- let n = parseInt(t[1], 16) / 255, r = parseInt(t[2], 16) / 255, i = parseInt(t[3], 16) / 255, a = Math.max(n, r, i), o = Math.min(n, r, i), s = 0, c = 0, l = (a + o) / 2;
658
- if (a !== o) {
659
- let e = a - o;
660
- switch (c = l > .5 ? e / (2 - a - o) : e / (a + o), a) {
661
- case n:
662
- s = ((r - i) / e + (r < i ? 6 : 0)) / 6;
663
- break;
664
- case r:
665
- s = ((i - n) / e + 2) / 6;
666
- break;
667
- case i: s = ((n - r) / e + 4) / 6;
668
- }
669
- }
670
- return {
671
- h: s * 360,
672
- s: c * 100,
673
- l: l * 100
674
- };
675
- }
676
- function qe(e) {
677
- let t = Ke(e);
678
- return t ? `${Math.round(t.h)} ${Math.round(t.s)}% ${Math.round(t.l)}%` : null;
679
- }
680
- function Je(e) {
681
- let t = Ke(e);
682
- if (!t) return null;
683
- let n = Math.max(t.l, 65), r = t.s > 80 ? Math.max(t.s - 10, 70) : t.s;
684
- return `${Math.round(t.h)} ${Math.round(r)}% ${Math.round(n)}%`;
685
- }
686
- function Ye(e) {
687
- let t = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);
688
- if (!t) return "0 0% 100%";
689
- let n = (e) => {
690
- let t = e / 255;
691
- return t <= .03928 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
692
- }, r = n(parseInt(t[1], 16)), i = n(parseInt(t[2], 16)), a = n(parseInt(t[3], 16));
693
- return .2126 * r + .7152 * i + .0722 * a > .6 ? "222 47% 11%" : "0 0% 100%";
694
- }
695
- function Xe(e, t) {
696
- n(() => {
697
- let n = document.documentElement, r = () => n.classList.contains("dark"), i = () => {
698
- if (e?.primaryColor) {
699
- let t = qe(e.primaryColor), i = Je(e.primaryColor), a = r() && i || t;
700
- a && (n.style.setProperty("--brand-primary", e.primaryColor), n.style.setProperty("--brand-primary-hsl", t || a), n.style.setProperty("--primary", a), n.style.setProperty("--primary-foreground", r() ? "222 47% 11%" : Ye(e.primaryColor)), n.style.setProperty("--ring", a), n.style.setProperty("--sidebar-primary", a), n.style.setProperty("--sidebar-ring", a));
701
- } else n.style.removeProperty("--brand-primary"), n.style.removeProperty("--brand-primary-hsl"), n.style.removeProperty("--primary"), n.style.removeProperty("--primary-foreground"), n.style.removeProperty("--ring"), n.style.removeProperty("--sidebar-primary"), n.style.removeProperty("--sidebar-ring");
702
- if (e?.accentColor) {
703
- let t = qe(e.accentColor), i = Je(e.accentColor), a = r() && i || t;
704
- a && (n.style.setProperty("--brand-accent", e.accentColor), n.style.setProperty("--brand-accent-hsl", t || a), n.style.setProperty("--accent", a), n.style.setProperty("--accent-foreground", r() ? "222 47% 11%" : Ye(e.accentColor)));
705
- } else n.style.removeProperty("--brand-accent"), n.style.removeProperty("--brand-accent-hsl"), n.style.removeProperty("--accent"), n.style.removeProperty("--accent-foreground");
706
- };
707
- i();
708
- let a = new MutationObserver((e) => {
709
- for (let t of e) if (t.type === "attributes" && t.attributeName === "class") {
710
- i();
711
- break;
712
- }
713
- });
714
- if (a.observe(n, {
715
- attributes: !0,
716
- attributeFilter: ["class"]
717
- }), e?.favicon) {
718
- let t = document.querySelector("#favicon") || document.querySelector("link[rel=\"icon\"]");
719
- t && (t.href = e.favicon);
720
- }
721
- return t && (document.title = t), () => {
722
- a.disconnect(), n.style.removeProperty("--brand-primary"), n.style.removeProperty("--brand-primary-hsl"), n.style.removeProperty("--brand-accent"), n.style.removeProperty("--brand-accent-hsl"), n.style.removeProperty("--primary"), n.style.removeProperty("--primary-foreground"), n.style.removeProperty("--ring"), n.style.removeProperty("--sidebar-primary"), n.style.removeProperty("--sidebar-ring"), n.style.removeProperty("--accent"), n.style.removeProperty("--accent-foreground");
723
- };
724
- }, [
725
- e?.primaryColor,
726
- e?.accentColor,
727
- e?.favicon,
728
- t
729
- ]);
730
- }
731
- function Ze({ sidebar: e, navbar: t, children: n, className: r, defaultOpen: i = !0, branding: a, rightRail: o }) {
732
- return Xe(a, a?.title), /* @__PURE__ */ B(k, {
733
- defaultOpen: i,
734
- className: "!flex-col h-svh overflow-hidden",
735
- children: [/* @__PURE__ */ z("header", {
736
- className: "sticky top-0 z-30 flex h-14 w-full shrink-0 items-center gap-2 border-b bg-background px-2 sm:px-4",
737
- children: t
738
- }), /* @__PURE__ */ B("div", {
739
- className: "flex flex-1 min-h-0 w-full",
740
- children: [
741
- e,
742
- /* @__PURE__ */ z(x, {
743
- className: "min-w-0",
744
- children: /* @__PURE__ */ z("main", {
745
- className: A("flex-1 min-w-0 overflow-auto p-3 sm:p-4 md:p-6 pb-20 sm:pb-4 md:pb-6", r),
746
- children: n
747
- })
748
- }),
749
- o
750
- ]
751
- })]
752
- });
690
+ function Ze(e, t) {
691
+ let n = [];
692
+ for (let r of e) J(r, t) && (r.type !== "group" && r.type !== "separator" && r.pinned && n.push(r), r.children?.length && n.push(...Ze(r.children, t)));
693
+ return n;
753
694
  }
754
695
  //#endregion
755
696
  //#region src/AppSchemaRenderer.tsx
756
697
  function Qe(e) {
757
- return ge(e, void 0) ?? "";
698
+ return se(e, void 0) ?? "";
758
699
  }
759
700
  function $e({ areas: e, activeAreaId: t, onAreaChange: n }) {
760
- return e.length <= 1 ? null : /* @__PURE__ */ B(g, { children: [/* @__PURE__ */ B(v, {
701
+ return e.length <= 1 ? null : /* @__PURE__ */ I(_, { children: [/* @__PURE__ */ I(y, {
761
702
  className: "flex items-center gap-1.5",
762
- children: [/* @__PURE__ */ z(F, { className: "h-3.5 w-3.5" }), "Area"]
763
- }), /* @__PURE__ */ z(_, { children: /* @__PURE__ */ z(S, { children: e.map((e) => {
703
+ children: [/* @__PURE__ */ F(re, { className: "h-3.5 w-3.5" }), "Area"]
704
+ }), /* @__PURE__ */ F(v, { children: /* @__PURE__ */ F(C, { children: e.map((e) => {
764
705
  let r = K(e.icon), i = Qe(e.label);
765
- return /* @__PURE__ */ z(T, { children: /* @__PURE__ */ B(w, {
706
+ return /* @__PURE__ */ F(E, { children: /* @__PURE__ */ I(T, {
766
707
  isActive: e.id === t,
767
708
  tooltip: i,
768
709
  onClick: () => n(e.id),
769
- children: [/* @__PURE__ */ z(r, { className: "h-4 w-4" }), /* @__PURE__ */ z("span", { children: i })]
710
+ children: [/* @__PURE__ */ F(r, { className: "h-4 w-4" }), /* @__PURE__ */ F("span", { children: i })]
770
711
  }) }, e.id);
771
712
  }) }) })] });
772
713
  }
773
- function et({ items: e, basePath: t }) {
774
- let n = H(), r = (e) => {
714
+ function et({ items: e, basePath: t, guards: n, onAction: r }) {
715
+ let i = z(), a = (e) => {
775
716
  let t = [];
776
- for (let n of e) n.type !== "separator" && (n.type === "group" ? t.push(...r(n.children || [])) : t.push(n));
717
+ for (let r of e.slice().sort(G)) Y([r], n) && r.type !== "separator" && (r.type === "group" ? t.push(...a(r.children || [])) : t.push(r));
777
718
  return t;
778
- }, i = r(e).slice(0, 5);
779
- return i.length === 0 ? null : /* @__PURE__ */ z("div", {
719
+ }, s = a(e).slice(0, 5);
720
+ if (s.length === 0) return null;
721
+ let c = Q(e, i.pathname, i.search, t)?.id ?? null;
722
+ return /* @__PURE__ */ F("div", {
780
723
  className: "fixed bottom-0 left-0 right-0 z-50 flex items-center justify-around border-t bg-background/95 backdrop-blur-sm px-2 py-1 sm:hidden safe-area-bottom",
781
724
  role: "navigation",
782
725
  "aria-label": "Mobile navigation",
783
- children: i.map((e) => {
784
- let r = K(e.icon), i = "#";
785
- if (e.type === "object") i = `${t}/${e.objectName}`, e.viewName && (i += `/view/${e.viewName}`);
786
- else if (e.type === "dashboard") i = e.dashboardName ? `${t}/dashboard/${e.dashboardName}` : "#";
787
- else if (e.type === "page") i = e.pageName ? `${t}/page/${e.pageName}` : "#";
788
- else if (e.type === "report") i = e.reportName ? `${t}/report/${e.reportName}` : "#";
789
- else if (e.type === "url") i = e.url ?? "#";
790
- else if (e.type === "component") {
791
- let n = e.componentRef;
792
- if (n) {
793
- i = `${t}/component/${n.split(":").filter(Boolean).join("/")}`;
794
- let r = e.params;
795
- if (r) {
796
- let e = new URLSearchParams();
797
- for (let [t, n] of Object.entries(r)) n != null && e.set(t, typeof n == "string" ? n : JSON.stringify(n));
798
- let t = e.toString();
799
- t && (i += `?${t}`);
800
- }
801
- }
802
- }
803
- let a = i !== "#" && n.pathname.startsWith(i);
804
- return /* @__PURE__ */ B(oe, {
805
- to: i,
806
- className: `flex flex-col items-center gap-0.5 px-2 py-1.5 transition-colors min-w-[44px] min-h-[44px] justify-center ${a ? "text-primary" : "text-muted-foreground hover:text-foreground"}`,
807
- children: [/* @__PURE__ */ z(r, { className: "h-5 w-5" }), /* @__PURE__ */ z("span", {
726
+ children: s.map((e) => {
727
+ let n = K(e.icon), { href: i, external: a } = Z(e, t), s = `relative flex flex-col items-center gap-0.5 px-2 py-1.5 transition-colors min-w-[44px] min-h-[44px] justify-center ${e.id === c ? "text-primary" : "text-muted-foreground hover:text-foreground"}`, l = /* @__PURE__ */ I(P, { children: [
728
+ /* @__PURE__ */ F(n, { className: "h-5 w-5" }),
729
+ /* @__PURE__ */ F("span", {
808
730
  className: "text-[10px] truncate max-w-[60px]",
809
- children: q(e.label)
810
- })]
731
+ children: q(e)
732
+ }),
733
+ e.badge != null && /* @__PURE__ */ F(o, {
734
+ variant: e.badgeVariant,
735
+ className: "absolute top-0.5 left-1/2 ml-1.5 px-1 py-0 text-[9px] leading-tight",
736
+ children: e.badge
737
+ })
738
+ ] });
739
+ return e.type === "action" ? /* @__PURE__ */ F("button", {
740
+ type: "button",
741
+ onClick: () => r?.(e),
742
+ className: s,
743
+ children: l
744
+ }, e.id) : a ? /* @__PURE__ */ F("a", {
745
+ href: i,
746
+ target: "_blank",
747
+ rel: "noopener noreferrer",
748
+ className: s,
749
+ children: l
750
+ }, e.id) : /* @__PURE__ */ F(L, {
751
+ to: i,
752
+ className: s,
753
+ children: l
811
754
  }, e.id);
812
755
  })
813
756
  });
814
757
  }
815
- function tt({ schema: e, basePath: t, evalVis: n, checkPerm: r, checkCap: a, onAction: o, sidebarHeader: s, sidebarFooter: c, sidebarExtra: l, visibleAreas: u, activeAreaId: d, setActiveAreaId: f, resolvedNavigation: g, enableSearch: _, enablePinning: v, onPinToggle: x, enableReorder: C, onReorder: E }) {
816
- let D = K(e.logo), [O, k] = i("");
817
- return /* @__PURE__ */ B(p, {
758
+ function tt({ schema: e, basePath: t, evalVis: n, checkPerm: r, checkCap: a, checkDocTarget: o, onAction: s, sidebarHeader: c, sidebarFooter: l, sidebarExtra: u, visibleAreas: d, activeAreaId: f, setActiveAreaId: p, resolvedNavigation: _, enableSearch: v, enablePinning: y, onPinToggle: S, enableReorder: w, onReorder: D }) {
759
+ let O = e.branding?.logo, k = K(e.icon), [A, j] = i("");
760
+ return /* @__PURE__ */ I(m, {
818
761
  collapsible: "icon",
819
762
  children: [
820
- /* @__PURE__ */ B(y, { children: [s ?? /* @__PURE__ */ z(S, { children: /* @__PURE__ */ z(T, { children: /* @__PURE__ */ B(w, {
763
+ /* @__PURE__ */ I(b, { children: [c ?? /* @__PURE__ */ F(C, { children: /* @__PURE__ */ F(E, { children: /* @__PURE__ */ I(T, {
821
764
  size: "lg",
822
765
  tooltip: e.title ?? e.name,
823
- children: [/* @__PURE__ */ z("div", {
766
+ children: [/* @__PURE__ */ F("div", {
824
767
  className: "flex aspect-square size-8 items-center justify-center rounded-lg bg-primary text-primary-foreground",
825
- children: e.logo && e.logo.startsWith("http") ? /* @__PURE__ */ z("img", {
826
- src: e.logo,
768
+ children: O ? /* @__PURE__ */ F("img", {
769
+ src: O,
827
770
  alt: e.title ?? "",
828
771
  className: "size-6 object-contain"
829
- }) : /* @__PURE__ */ z(D, { className: "size-4" })
830
- }), /* @__PURE__ */ B("div", {
772
+ }) : /* @__PURE__ */ F(k, { className: "size-4" })
773
+ }), /* @__PURE__ */ I("div", {
831
774
  className: "grid flex-1 text-left text-sm leading-tight",
832
- children: [/* @__PURE__ */ z("span", {
775
+ children: [/* @__PURE__ */ F("span", {
833
776
  className: "truncate font-semibold",
834
777
  children: e.title ?? e.name ?? "App"
835
- }), e.description && /* @__PURE__ */ z("span", {
778
+ }), e.description && /* @__PURE__ */ F("span", {
836
779
  className: "truncate text-xs text-muted-foreground",
837
780
  children: e.description
838
781
  })]
839
782
  })]
840
- }) }) }), _ && /* @__PURE__ */ z(b, {
783
+ }) }) }), v && /* @__PURE__ */ F(x, {
841
784
  placeholder: "Search navigation…",
842
- value: O,
843
- onChange: (e) => k(e.target.value),
785
+ value: A,
786
+ onChange: (e) => j(e.target.value),
844
787
  "aria-label": "Search navigation"
845
788
  })] }),
846
- /* @__PURE__ */ B(m, { children: [
847
- u.length > 1 && d && /* @__PURE__ */ z($e, {
848
- areas: u,
849
- activeAreaId: d,
850
- onAreaChange: f
789
+ /* @__PURE__ */ I(h, { children: [
790
+ d.length > 1 && f && /* @__PURE__ */ F($e, {
791
+ areas: d,
792
+ activeAreaId: f,
793
+ onAreaChange: p
851
794
  }),
852
- /* @__PURE__ */ z(We, {
853
- items: g,
795
+ /* @__PURE__ */ F(Xe, {
796
+ items: _,
854
797
  basePath: t,
855
798
  evaluateVisibility: n,
856
799
  checkPermission: r,
857
800
  checkCapability: a,
858
- onAction: o,
859
- searchQuery: O,
860
- enablePinning: v,
861
- onPinToggle: x,
862
- enableReorder: C,
863
- onReorder: E
801
+ checkDocTarget: o,
802
+ onAction: s,
803
+ searchQuery: A,
804
+ enablePinning: y,
805
+ onPinToggle: S,
806
+ enableReorder: w,
807
+ onReorder: D
864
808
  }),
865
- l
809
+ u
866
810
  ] }),
867
- c && /* @__PURE__ */ z(h, { children: c })
811
+ l && /* @__PURE__ */ F(g, { children: l })
868
812
  ]
869
813
  });
870
814
  }
871
- function nt({ schema: e, basePath: t = "", mobileNavMode: a = "drawer", evaluateVisibility: o, checkPermission: s, checkCapability: c, onAction: l, navbar: u, sidebarHeader: d, sidebarFooter: f, sidebarExtra: p, children: m, className: h, defaultOpen: g = !0, enableSearch: _, enablePinning: v, onPinToggle: y, enableReorder: b, onReorder: x }) {
872
- let S = o ?? ((e) => e !== !1 && e !== "false"), C = s ?? (() => !0), w = c ?? (() => !0), T = r(() => (e.menu ?? []).map((e, t) => he(e, t)), [e.menu]), E = e.navigation ?? T, D = (e.areas ?? []).filter((e) => J(e.navigation, {
873
- evaluateVisibility: S,
874
- checkPermission: C,
875
- checkCapability: w,
876
- hasActionHandler: !!l
877
- })), [O, k] = i(() => D.length > 0 ? D[0].id : null), A = D.map((e) => e.id).join(",");
815
+ function nt({ schema: e, basePath: t = "", mobileNavMode: a = "drawer", evaluateVisibility: o, checkPermission: s, checkCapability: c, checkDocTarget: l, onAction: u, navbar: d, sidebarHeader: f, sidebarFooter: p, sidebarExtra: m, children: h, className: g, defaultOpen: _ = !0, enableSearch: v, enablePinning: y, onPinToggle: b, enableReorder: x, onReorder: S }) {
816
+ let C = o ?? ((e) => e !== !1 && e !== "false"), w = s ?? (() => !0), T = c ?? (() => !0), E = r(() => (e.menu ?? []).map((e, t) => H(e, t)), [e.menu]), D = e.navigation ?? E, O = {
817
+ evaluateVisibility: C,
818
+ checkPermission: w,
819
+ checkCapability: T,
820
+ checkDocTarget: l,
821
+ hasActionHandler: !!u
822
+ }, k = (e.areas ?? []).filter((e) => Y(e.navigation, O)), [A, j] = i(() => k.length > 0 ? k[0].id : null), M = k.map((e) => e.id).join(",");
878
823
  n(() => {
879
- D.length > 0 ? k((e) => D.some((t) => t.id === e) ? e : D[0].id) : k(null);
880
- }, [e.name, A]);
881
- let j = D.find((e) => e.id === O) ?? D[0], M = j?.navigation ?? E, N = {
824
+ k.length > 0 ? j((e) => k.some((t) => t.id === e) ? e : k[0].id) : j(null);
825
+ }, [e.name, M]);
826
+ let N = k.find((e) => e.id === A) ?? k[0], L = N?.navigation ?? D, R = {
882
827
  title: e.title,
883
- favicon: e.favicon
884
- }, P = /* @__PURE__ */ z(tt, {
828
+ favicon: e.branding?.favicon
829
+ }, z = /* @__PURE__ */ F(tt, {
885
830
  schema: e,
886
831
  basePath: t,
887
- evalVis: S,
888
- checkPerm: C,
889
- checkCap: w,
890
- onAction: l,
891
- sidebarHeader: d,
892
- sidebarFooter: f,
893
- sidebarExtra: p,
894
- visibleAreas: D,
895
- activeAreaId: j?.id ?? null,
896
- setActiveAreaId: k,
897
- resolvedNavigation: M,
898
- enableSearch: _,
899
- enablePinning: v,
900
- onPinToggle: y,
901
- enableReorder: b,
902
- onReorder: x
832
+ evalVis: C,
833
+ checkPerm: w,
834
+ checkCap: T,
835
+ checkDocTarget: l,
836
+ onAction: u,
837
+ sidebarHeader: f,
838
+ sidebarFooter: p,
839
+ sidebarExtra: m,
840
+ visibleAreas: k,
841
+ activeAreaId: N?.id ?? null,
842
+ setActiveAreaId: j,
843
+ resolvedNavigation: L,
844
+ enableSearch: v,
845
+ enablePinning: y,
846
+ onPinToggle: b,
847
+ enableReorder: x,
848
+ onReorder: S
903
849
  });
904
- return /* @__PURE__ */ B(ae, { children: [/* @__PURE__ */ z(Ze, {
905
- sidebar: P,
906
- navbar: u,
907
- className: h,
908
- defaultOpen: g,
909
- branding: N,
910
- children: m
911
- }), a === "bottom_nav" && /* @__PURE__ */ z(et, {
912
- items: M,
913
- basePath: t
850
+ return /* @__PURE__ */ I(P, { children: [/* @__PURE__ */ F(Te, {
851
+ sidebar: z,
852
+ navbar: d,
853
+ className: g,
854
+ defaultOpen: _,
855
+ branding: R,
856
+ children: h
857
+ }), a === "bottom_nav" && /* @__PURE__ */ F(et, {
858
+ items: L,
859
+ basePath: t,
860
+ guards: O,
861
+ onAction: u
914
862
  })] });
915
863
  }
916
864
  //#endregion
865
+ //#region src/PageHeader.tsx
866
+ var rt = (e) => {
867
+ let t = e?.name ?? e?.full_name ?? e?.display_name ?? e?.label ?? e?.title ?? e?.subject;
868
+ return t != null && String(t).trim() ? String(t) : [
869
+ e?.salutation,
870
+ e?.first_name,
871
+ e?.last_name
872
+ ].filter((e) => typeof e == "string" && e.trim()).map((e) => e.trim()).join(" ") || (typeof e?.email == "string" && e.email.trim() ? e.email.trim() : null);
873
+ }, it = (e, t) => !e || typeof e != "string" ? e ?? "" : e.includes("{") ? e.replace(/\{([a-zA-Z0-9_.]+)\}/g, (e, n) => {
874
+ let r = n.split(".").reduce((e, t) => e == null ? e : e[t], t);
875
+ return r == null ? "" : typeof r == "object" ? rt(r) ?? "" : String(r);
876
+ }).replace(/\s*[-–—|/·,:]\s*(?=\s*[-–—|/·,:]|$)/g, "").replace(/^\s*[-–—|/·,:]\s*/, "").replace(/\s+/g, " ").trim() : e;
877
+ function at({ title: t, subtitle: n, icon: r, action: i, actions: a, showBack: o, schema: c, className: l, children: u, ...d }) {
878
+ let p = ve(), m = typeof t == "string" && /\{[a-zA-Z0-9_.]+\}/.test(t), h = it(t, p?.data) || (m ? "" : t), g = n, _ = typeof g == "string" && /\{[a-zA-Z0-9_.]+\}/.test(g), v = it(g, p?.data) || (_ ? "" : g), y = !!p?.recordId, b = !!p?.embedded, x = o ?? (y && !b), S = e.useCallback(() => {
879
+ if (typeof window > "u") return;
880
+ let e = window.location.pathname, t = e.replace(/\/record\/[^/]+\/?$/, "");
881
+ t === e ? window.history.length > 1 && window.history.back() : (window.history.pushState({}, "", t + window.location.search), window.dispatchEvent(new PopStateEvent("popstate")));
882
+ }, []), C = Array.isArray(c?.children) ? c.children.filter(Boolean).map((e, t) => /* @__PURE__ */ F(_e, { schema: e }, e?.id || `pgh-child-${t}`)) : null, w = Array.isArray(a) && a.length > 0 && a || Array.isArray(c?.actions) && c.actions.length > 0 && c.actions || Array.isArray(c?.properties?.actions) && c.properties.actions.length > 0 && c.properties.actions || null, T = i || u || (w ? /* @__PURE__ */ F(_e, { schema: {
883
+ type: "record:quick_actions",
884
+ properties: {
885
+ actions: w,
886
+ location: "record_header",
887
+ align: "end",
888
+ inline: !0
889
+ }
890
+ } }) : null) || C;
891
+ return /* @__PURE__ */ F("div", {
892
+ className: j("flex flex-col gap-3 pb-4 border-b", l),
893
+ ...d,
894
+ children: /* @__PURE__ */ I("div", {
895
+ className: "flex flex-wrap items-center gap-x-4 gap-y-2",
896
+ children: [
897
+ x && /* @__PURE__ */ F(s, {
898
+ type: "button",
899
+ variant: "ghost",
900
+ size: "icon",
901
+ onClick: S,
902
+ "aria-label": "Back to list",
903
+ className: "flex-shrink-0 -ml-2",
904
+ children: /* @__PURE__ */ F(ee, { className: "size-4" })
905
+ }),
906
+ r && (h || v) && /* @__PURE__ */ F("div", {
907
+ className: "flex-shrink-0 grid place-items-center size-10 rounded-md bg-primary/10 text-primary",
908
+ children: typeof r == "string" ? /* @__PURE__ */ F(f, {
909
+ name: r,
910
+ className: "size-5"
911
+ }) : r
912
+ }),
913
+ /* @__PURE__ */ I("div", {
914
+ className: "flex flex-col min-w-48 flex-1",
915
+ children: [h ? /* @__PURE__ */ F("h1", {
916
+ className: "text-2xl font-bold tracking-tight md:text-3xl truncate",
917
+ children: h
918
+ }) : null, v && /* @__PURE__ */ F("p", {
919
+ className: "text-sm text-muted-foreground truncate",
920
+ children: v
921
+ })]
922
+ }),
923
+ T && /* @__PURE__ */ F("div", {
924
+ className: "flex items-center gap-2 ml-auto",
925
+ children: T
926
+ })
927
+ ]
928
+ })
929
+ });
930
+ }
931
+ //#endregion
917
932
  //#region src/SidebarNav.tsx
918
- function rt(e) {
933
+ function ot(e) {
919
934
  return "items" in e && !("href" in e);
920
935
  }
921
- function it({ item: e, pathname: t }) {
922
- return e.children && e.children.length > 0 ? /* @__PURE__ */ z(s, {
936
+ function st({ item: e, pathname: t }) {
937
+ return e.children && e.children.length > 0 ? /* @__PURE__ */ F(c, {
923
938
  asChild: !0,
924
939
  defaultOpen: !0,
925
940
  className: "group/collapsible",
926
- children: /* @__PURE__ */ B(T, { children: [/* @__PURE__ */ z(l, {
941
+ children: /* @__PURE__ */ I(E, { children: [/* @__PURE__ */ F(u, {
927
942
  asChild: !0,
928
- children: /* @__PURE__ */ B(w, {
943
+ children: /* @__PURE__ */ I(T, {
929
944
  tooltip: e.title,
930
945
  className: "motion-safe:transition-colors motion-safe:duration-150",
931
946
  children: [
932
- e.icon && /* @__PURE__ */ z(e.icon, {}),
933
- /* @__PURE__ */ z("span", { children: e.title }),
934
- e.badge != null && /* @__PURE__ */ z(a, {
947
+ e.icon && /* @__PURE__ */ F(e.icon, {}),
948
+ /* @__PURE__ */ F("span", { children: e.title }),
949
+ e.badge != null && /* @__PURE__ */ F(o, {
935
950
  variant: e.badgeVariant || "default",
936
951
  className: "ml-auto mr-1 h-5 min-w-5 px-1 text-xs",
937
952
  children: e.badge
938
953
  }),
939
- /* @__PURE__ */ z(P, { className: "ml-auto h-4 w-4 transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90" })
954
+ /* @__PURE__ */ F(te, { className: "ml-auto h-4 w-4 transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90" })
940
955
  ]
941
956
  })
942
- }), /* @__PURE__ */ z(c, {
957
+ }), /* @__PURE__ */ F(l, {
943
958
  className: "motion-safe:data-[state=open]:animate-in motion-safe:data-[state=closed]:animate-out motion-safe:data-[state=closed]:fade-out-0 motion-safe:data-[state=open]:fade-in-0 motion-safe:data-[state=closed]:slide-out-to-top-1 motion-safe:data-[state=open]:slide-in-from-top-1 motion-safe:duration-150",
944
- children: /* @__PURE__ */ z(E, { children: e.children.map((e) => /* @__PURE__ */ z(O, { children: /* @__PURE__ */ z(D, {
959
+ children: /* @__PURE__ */ F(D, { children: e.children.map((e) => /* @__PURE__ */ F(k, { children: /* @__PURE__ */ F(O, {
945
960
  asChild: !0,
946
961
  isActive: t === e.href,
947
962
  className: "motion-safe:transition-colors motion-safe:duration-150",
948
- children: /* @__PURE__ */ B(V, {
963
+ children: /* @__PURE__ */ I(R, {
949
964
  to: e.href,
950
965
  children: [
951
- e.icon && /* @__PURE__ */ z(e.icon, {}),
952
- /* @__PURE__ */ z("span", { children: e.title }),
953
- e.badge != null && /* @__PURE__ */ z(a, {
966
+ e.icon && /* @__PURE__ */ F(e.icon, {}),
967
+ /* @__PURE__ */ F("span", { children: e.title }),
968
+ e.badge != null && /* @__PURE__ */ F(o, {
954
969
  variant: e.badgeVariant || "default",
955
970
  className: "ml-auto h-5 min-w-5 px-1 text-xs",
956
971
  children: e.badge
@@ -959,17 +974,17 @@ function it({ item: e, pathname: t }) {
959
974
  })
960
975
  }) }, e.href)) })
961
976
  })] })
962
- }) : /* @__PURE__ */ z(T, { children: /* @__PURE__ */ z(w, {
977
+ }) : /* @__PURE__ */ F(E, { children: /* @__PURE__ */ F(T, {
963
978
  asChild: !0,
964
979
  isActive: t === e.href,
965
980
  tooltip: e.title,
966
981
  className: "motion-safe:transition-colors motion-safe:duration-150",
967
- children: /* @__PURE__ */ B(V, {
982
+ children: /* @__PURE__ */ I(R, {
968
983
  to: e.href,
969
984
  children: [
970
- e.icon && /* @__PURE__ */ z(e.icon, {}),
971
- /* @__PURE__ */ z("span", { children: e.title }),
972
- e.badge != null && /* @__PURE__ */ z(a, {
985
+ e.icon && /* @__PURE__ */ F(e.icon, {}),
986
+ /* @__PURE__ */ F("span", { children: e.title }),
987
+ e.badge != null && /* @__PURE__ */ F(o, {
973
988
  variant: e.badgeVariant || "default",
974
989
  className: "ml-auto h-5 min-w-5 px-1 text-xs",
975
990
  children: e.badge
@@ -978,26 +993,26 @@ function it({ item: e, pathname: t }) {
978
993
  })
979
994
  }) });
980
995
  }
981
- function at({ items: e, title: n = "Application", className: r, collapsible: i = "icon", searchEnabled: a = !1, searchPlaceholder: o = "Search…" }) {
982
- let s = H(), [c, l] = t.useState(""), d = t.useMemo(() => e.length === 0 ? [] : rt(e[0]) ? e.map((e) => ({
996
+ function ct({ items: t, title: n = "Application", className: r, collapsible: i = "icon", searchEnabled: a = !1, searchPlaceholder: o = "Search…" }) {
997
+ let s = z(), [c, l] = e.useState(""), u = e.useMemo(() => t.length === 0 ? [] : ot(t[0]) ? t.map((e) => ({
983
998
  groupLabel: e.label,
984
999
  items: e.items
985
- })) : [{ items: e }], [e]), f = t.useMemo(() => {
986
- if (!c) return d;
1000
+ })) : [{ items: t }], [t]), f = e.useMemo(() => {
1001
+ if (!c) return u;
987
1002
  let e = c.toLowerCase();
988
- return d.map((t) => ({
1003
+ return u.map((t) => ({
989
1004
  ...t,
990
1005
  items: t.items.filter((t) => t.title.toLowerCase().includes(e) || t.children?.some((t) => t.title.toLowerCase().includes(e)))
991
1006
  })).filter((e) => e.items.length > 0);
992
- }, [d, c]);
993
- return /* @__PURE__ */ z(p, {
1007
+ }, [u, c]);
1008
+ return /* @__PURE__ */ F(m, {
994
1009
  className: r,
995
1010
  collapsible: i,
996
- children: /* @__PURE__ */ B(m, { children: [a && /* @__PURE__ */ z("div", {
1011
+ children: /* @__PURE__ */ I(h, { children: [a && /* @__PURE__ */ F("div", {
997
1012
  className: "px-3 py-2",
998
- children: /* @__PURE__ */ B("div", {
1013
+ children: /* @__PURE__ */ I("div", {
999
1014
  className: "relative",
1000
- children: [/* @__PURE__ */ z(ie, { className: "absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground" }), /* @__PURE__ */ z(u, {
1015
+ children: [/* @__PURE__ */ F(V, { className: "absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground" }), /* @__PURE__ */ F(d, {
1001
1016
  type: "search",
1002
1017
  placeholder: o,
1003
1018
  value: c,
@@ -1005,16 +1020,16 @@ function at({ items: e, title: n = "Application", className: r, collapsible: i =
1005
1020
  className: "pl-8 h-9"
1006
1021
  })]
1007
1022
  })
1008
- }), f.map((e, t) => /* @__PURE__ */ B(g, { children: [
1009
- t > 0 && /* @__PURE__ */ z("div", {
1023
+ }), f.map((e, t) => /* @__PURE__ */ I(_, { children: [
1024
+ t > 0 && /* @__PURE__ */ F("div", {
1010
1025
  className: "mx-3 mb-1 h-px bg-sidebar-border/60",
1011
1026
  "aria-hidden": !0
1012
1027
  }),
1013
- /* @__PURE__ */ z(v, {
1028
+ /* @__PURE__ */ F(y, {
1014
1029
  className: "text-[10px] font-semibold uppercase tracking-wider text-sidebar-foreground/60",
1015
1030
  children: e.groupLabel || n
1016
1031
  }),
1017
- /* @__PURE__ */ z(_, { children: /* @__PURE__ */ z(S, { children: e.items.map((e) => /* @__PURE__ */ z(it, {
1032
+ /* @__PURE__ */ F(v, { children: /* @__PURE__ */ F(C, { children: e.items.map((e) => /* @__PURE__ */ F(st, {
1018
1033
  item: e,
1019
1034
  pathname: s.pathname
1020
1035
  }, e.href)) }) })
@@ -1022,68 +1037,97 @@ function at({ items: e, title: n = "Application", className: r, collapsible: i =
1022
1037
  });
1023
1038
  }
1024
1039
  //#endregion
1025
- //#region src/index.ts
1026
- function ot() {
1027
- e.register("page-header", ye, {
1028
- namespace: "layout",
1029
- label: "Page Header",
1030
- category: "Layout",
1031
- isContainer: !0,
1032
- inputs: [
1033
- {
1034
- name: "title",
1035
- type: "string",
1036
- label: "Title"
1037
- },
1038
- {
1039
- name: "subtitle",
1040
- type: "string",
1041
- label: "Subtitle"
1042
- },
1043
- {
1044
- name: "icon",
1045
- type: "string",
1046
- label: "Icon",
1047
- description: "Lucide icon name"
1048
- },
1049
- {
1050
- name: "actions",
1051
- type: "array",
1052
- label: "Actions",
1053
- description: "ActionDef list (or action ids) rendered through record:quick_actions"
1054
- }
1055
- ]
1056
- }), e.register("page:card", be, {
1040
+ //#region src/ResponsiveGrid.tsx
1041
+ var lt = {
1042
+ xs: {
1043
+ 1: "grid-cols-1",
1044
+ 2: "grid-cols-2",
1045
+ 3: "grid-cols-3",
1046
+ 4: "grid-cols-4",
1047
+ 6: "grid-cols-6",
1048
+ 12: "grid-cols-12"
1049
+ },
1050
+ sm: {
1051
+ 1: "sm:grid-cols-1",
1052
+ 2: "sm:grid-cols-2",
1053
+ 3: "sm:grid-cols-3",
1054
+ 4: "sm:grid-cols-4",
1055
+ 6: "sm:grid-cols-6",
1056
+ 12: "sm:grid-cols-12"
1057
+ },
1058
+ md: {
1059
+ 1: "md:grid-cols-1",
1060
+ 2: "md:grid-cols-2",
1061
+ 3: "md:grid-cols-3",
1062
+ 4: "md:grid-cols-4",
1063
+ 6: "md:grid-cols-6",
1064
+ 12: "md:grid-cols-12"
1065
+ },
1066
+ lg: {
1067
+ 1: "lg:grid-cols-1",
1068
+ 2: "lg:grid-cols-2",
1069
+ 3: "lg:grid-cols-3",
1070
+ 4: "lg:grid-cols-4",
1071
+ 6: "lg:grid-cols-6",
1072
+ 12: "lg:grid-cols-12"
1073
+ },
1074
+ xl: {
1075
+ 1: "xl:grid-cols-1",
1076
+ 2: "xl:grid-cols-2",
1077
+ 3: "xl:grid-cols-3",
1078
+ 4: "xl:grid-cols-4",
1079
+ 6: "xl:grid-cols-6",
1080
+ 12: "xl:grid-cols-12"
1081
+ },
1082
+ "2xl": {
1083
+ 1: "2xl:grid-cols-1",
1084
+ 2: "2xl:grid-cols-2",
1085
+ 3: "2xl:grid-cols-3",
1086
+ 4: "2xl:grid-cols-4",
1087
+ 6: "2xl:grid-cols-6",
1088
+ 12: "2xl:grid-cols-12"
1089
+ }
1090
+ };
1091
+ function ut(e) {
1092
+ if (!e) return "grid-cols-1";
1093
+ let t = [];
1094
+ for (let [n, r] of Object.entries(e)) {
1095
+ let e = lt[n];
1096
+ if (e && r) {
1097
+ let n = Object.keys(e).map(Number).reduce((e, t) => Math.abs(t - r) < Math.abs(e - r) ? t : e);
1098
+ t.push(e[n]);
1099
+ }
1100
+ }
1101
+ return t.join(" ") || "grid-cols-1";
1102
+ }
1103
+ var dt = {
1104
+ 0: "gap-0",
1105
+ 1: "gap-1",
1106
+ 2: "gap-2",
1107
+ 3: "gap-3",
1108
+ 4: "gap-4",
1109
+ 5: "gap-5",
1110
+ 6: "gap-6",
1111
+ 8: "gap-8"
1112
+ }, ft = ({ columns: e, gap: t = 4, className: n, children: r }) => {
1113
+ let i = ut(e), a = typeof t == "number" ? dt[t] || `gap-${t}` : "";
1114
+ return /* @__PURE__ */ F("div", {
1115
+ className: j("grid", i, a, n),
1116
+ children: r
1117
+ });
1118
+ }, pt = { type: "app" }, mt = ({ schema: e, children: n, ...r }) => t(nt, {
1119
+ ...r,
1120
+ schema: e?.schema ?? pt,
1121
+ children: n
1122
+ });
1123
+ function ht() {
1124
+ a.register("page:card", ye, {
1057
1125
  namespace: "layout",
1058
1126
  skipFallback: !0,
1059
1127
  label: "Page Card",
1060
1128
  category: "Layout",
1061
1129
  isContainer: !0
1062
- }), e.register("responsive-grid", we, {
1063
- namespace: "layout",
1064
- label: "Responsive Grid",
1065
- category: "Layout",
1066
- isContainer: !0,
1067
- inputs: [{
1068
- name: "columns",
1069
- type: "object"
1070
- }, {
1071
- name: "gap",
1072
- type: "number"
1073
- }]
1074
- }), e.register("navigation-renderer", We, {
1075
- namespace: "layout",
1076
- label: "Navigation Renderer",
1077
- category: "Layout",
1078
- inputs: [{
1079
- name: "items",
1080
- type: "array",
1081
- required: !0
1082
- }, {
1083
- name: "basePath",
1084
- type: "string"
1085
- }]
1086
- }), e.register("app-schema-renderer", nt, {
1130
+ }), a.register("app-schema-renderer", mt, {
1087
1131
  namespace: "layout",
1088
1132
  label: "App Schema Renderer",
1089
1133
  category: "Layout",
@@ -1101,15 +1145,13 @@ function ot() {
1101
1145
  name: "mobileNavMode",
1102
1146
  type: "enum",
1103
1147
  enum: ["drawer", "bottom_nav"],
1104
- defaultValue: "drawer",
1105
- label: "Mobile Nav Mode",
1106
1148
  description: "Mobile navigation mode. \"drawer\" (default) puts the sidebar in the mobile sheet overlay; \"bottom_nav\" additionally renders a fixed bottom bar. These are the only two modes the renderer implements."
1107
1149
  }
1108
1150
  ]
1109
1151
  });
1110
1152
  }
1111
1153
  try {
1112
- ot();
1154
+ ht();
1113
1155
  } catch {}
1114
1156
  //#endregion
1115
- export { nt as AppSchemaRenderer, Ze as AppShell, Ae as NAV_RUN_ACTION_PARAM, We as NavigationRenderer, be as PageCard, ye as PageHeader, we as ResponsiveGrid, at as SidebarNav, Q as filterNavigationItems, J as hasVisibleNavigationItems, ot as registerLayout, Ve as resolveActiveNavItem, X as resolveHref, K as resolveIcon, q as resolveLabel, Xe as useAppShellBranding };
1157
+ export { nt as AppSchemaRenderer, Te as AppShell, Pe as NAV_RUN_ACTION_PARAM, Xe as NavigationRenderer, ye as PageCard, at as PageHeader, ft as ResponsiveGrid, ct as SidebarNav, qe as filterNavigationItems, Y as hasVisibleNavigationItems, ht as registerLayout, Q as resolveActiveNavItem, Z as resolveHref, K as resolveIcon, Ee as resolveLabel, q as resolveNavItemLabel, we as useAppShellBranding };