@declarion/react 0.154.0 → 0.162.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.
@@ -0,0 +1,666 @@
1
+ import { useUiPreferences as e } from "../../hooks/useUiPreferences.js";
2
+ import { Rail as t } from "./Rail.js";
3
+ import { Sidebar as n, buildSections as r } from "./Sidebar.js";
4
+ import { TopBar as i } from "./TopBar.js";
5
+ import { TabStrip as a } from "./TabStrip.js";
6
+ import { DirtyTabsCloseDialog as o } from "./DirtyTabsCloseDialog.js";
7
+ import { ImpersonationBanner as s } from "./ImpersonationBanner.js";
8
+ import { ImpersonationFrame as c } from "./ImpersonationFrame.js";
9
+ import { buildPendingTabClose as l, tabCloseRoute as u } from "./tab-close.js";
10
+ import { CommandPalette as d } from "./CommandPalette.js";
11
+ import { Icon as f } from "../primitives/Icons.js";
12
+ import { IconBtn as p } from "../primitives/IconBtn.js";
13
+ import { AgentChatPanel as ee } from "../agents/AgentChatPanel.js";
14
+ import { ActionRunnerProvider as m } from "../actions/ActionRunner.js";
15
+ import { useEmbed as te } from "../../embed/EmbedContext.js";
16
+ import { useGlobalLinkInterceptor as ne } from "../../embed/useGlobalLinkInterceptor.js";
17
+ import { EmbedLocationReporter as re } from "../../embed/EmbedLocationReporter.js";
18
+ import { EmbedHistoryTracker as ie } from "../../embed/EmbedHistoryTracker.js";
19
+ import { EmbedUnsavedGuard as ae } from "../../embed/EmbedUnsavedGuard.js";
20
+ import { EmbedResizeReporter as oe } from "../../embed/EmbedResizeReporter.js";
21
+ import { EmbedDirtyReporter as se } from "../../embed/EmbedDirtyReporter.js";
22
+ import { useAuthStore as ce } from "../../stores/auth.js";
23
+ import { useTabStore as h } from "../../stores/tabs.js";
24
+ import { startListLayoutCrossTabSync as le, useListLayoutStore as ue } from "../../stores/list-layout.js";
25
+ import { useTabNavigate as de } from "../../hooks/useTabNavigate.js";
26
+ import { usePageStateRuntime as fe } from "../../hooks/usePageStateRuntime.js";
27
+ import { UI_PREFERENCES_PARAM_CODE as pe, usePreferencesStore as g } from "../../stores/preferences.js";
28
+ import { useSchema as me } from "../../hooks/useSchema.js";
29
+ import { AgentOpenFollower as he } from "../agents/AgentOpenFollower.js";
30
+ import { useCurrentLocation as ge } from "../../hooks/useCurrentLocation.js";
31
+ import { useImpersonation as _e } from "../../hooks/useImpersonation.js";
32
+ import { useResponsiveMode as ve } from "../../hooks/useResponsiveMode.js";
33
+ import { useBrandingIdentity as ye } from "../../hooks/useBranding.js";
34
+ import { useEffectiveParam as be } from "../../hooks/useParams.js";
35
+ import { useBrandingShell as xe } from "../../hooks/useBrandingChrome.js";
36
+ import { areaRoute as Se, findNavMatch as Ce } from "../../lib/schema-routing.js";
37
+ import { useText as _ } from "../../hooks/useText.js";
38
+ import { builtInPageTitle as we, useTabTitle as v } from "../../hooks/useTabTitle.js";
39
+ import { useActiveTabFollowsRoute as Te } from "../../hooks/useActiveTabFollowsRoute.js";
40
+ import { useDocumentTitle as Ee } from "../../hooks/useDocumentTitle.js";
41
+ import { useCallback as y, useEffect as b, useMemo as De, useRef as x, useState as S } from "react";
42
+ import { Fragment as C, jsx as w, jsxs as T } from "react/jsx-runtime";
43
+ import { Outlet as Oe, useLocation as ke, useNavigate as Ae } from "react-router";
44
+ // src/components/layout/Layout.impl.tsx
45
+ var E = "default";
46
+ function D() {
47
+ let r = _();
48
+ ne(), fe();
49
+ let { user: f, activeTenant: p } = ce(), we = te(), v = Ae(), C = de(), D = y((e) => C(e, { topLevel: !0 }), [C]), O = ke(), { data: k } = me(), A = ve(), j = g((e) => e.sidebar), Ie = g((e) => e.tabsPosition), M = g((e) => e.aiSurface), Le = g((e) => e.colorScheme), { set: N } = e(), Re = g((e) => e.hydrateFromParameter), P = be(pe), ze = P.source && P.source !== "public" ? f?.id : void 0, F = xe(), I = h((e) => e.tabs), Be = h((e) => e.activeTabId), Ve = h((e) => e.closeTabs), He = h((e) => e.switchTab), [L, R] = S(E), [Ue, z] = S(!1), [We, Ge] = S("default"), [B, V] = S(!1), [Ke, H] = S(), [qe, U] = S(!1), [Je, W] = S(!1), Ye = x(null), Xe = x(null), [G, K] = S(null), q = M !== "off" && F.isVisible("show_command_palette"), J = M === "panel" || M === "both", Ze = M === "command" || M === "both", Qe = ye(), $e = Qe?.ai_name?.trim() ?? "", Y = A.category === "phone" || A.category === "tablet", et = F.isVisible("show_topbar"), X = !Y && F.isVisible("show_rail"), tt = !Y && F.isVisible("show_sidebar"), nt = !Y && F.isVisible("show_tabs"), rt = Y && F.isVisible("show_sidebar"), it = Y && F.isVisible("show_tabs"), at = je(!Y && J && B), ot = F.isVisible("show_tenant_switcher"), st = F.isVisible("show_breadcrumbs"), ct = F.isVisible("show_theme_toggle"), Z = y((e = "default") => {
50
+ q && (Ge(e), z(!0));
51
+ }, [q]), Q = y((e) => {
52
+ if (e.length === 0) return;
53
+ let t = h.getState(), n = !t.activeTabId || e.includes(t.activeTabId), r = Ve(e);
54
+ if (!n) return;
55
+ let i = u(r);
56
+ v({
57
+ pathname: i.pathname,
58
+ search: i.search
59
+ }, { replace: i.replace });
60
+ }, [Ve, v]), $ = y((e, t) => {
61
+ let n = h.getState(), r = l(n.tabs, n.activeTabId, e, t);
62
+ r && (r.dirtyTabs.length > 0 ? K(r) : Q(r.ids));
63
+ }, [Q]), lt = y(() => {
64
+ K(null);
65
+ }, []), ut = y(() => {
66
+ G && (K(null), Q(G.cleanIds));
67
+ }, [G, Q]), dt = y(() => {
68
+ G && (K(null), Q(G.ids));
69
+ }, [G, Q]), ft = ge(), { isImpersonating: pt } = _e();
70
+ b(() => {
71
+ let e = f?.id || null, t = p?.id || null;
72
+ h.getState().setScope(t, e), ue.getState().setScope(t, e), e && t && (h.getState().hydrate(), ue.getState().hydrate(), le());
73
+ }, [f?.id, p?.id]), Te(), Ee(), b(() => {
74
+ Re(P.value, ze);
75
+ }, [
76
+ P.value,
77
+ ze,
78
+ f?.id,
79
+ Re
80
+ ]), b(() => {
81
+ if (!k) return;
82
+ let e = Ce(k.navigation, k.screens, O.pathname)?.area;
83
+ if (e) {
84
+ R(e);
85
+ return;
86
+ }
87
+ let t = L;
88
+ if ((k.navigation ?? []).some((e) => (e.area || E) === t)) return;
89
+ let n = (k.navigation ?? [])[0]?.area || E;
90
+ n !== t && R(n);
91
+ }, [
92
+ k,
93
+ O.pathname,
94
+ L
95
+ ]), b(() => {
96
+ U(!1), W(!1);
97
+ }, [O.pathname, O.search]), b(() => {
98
+ let e = (e) => {
99
+ let t = document.activeElement, n = !!t && (t.tagName === "INPUT" || t.tagName === "TEXTAREA" || t.isContentEditable), r = e.metaKey || e.ctrlKey;
100
+ r && e.key.toLowerCase() === "k" ? (e.preventDefault(), Z("default")) : r && e.key.toLowerCase() === "t" ? (e.preventDefault(), Z("new")) : r && e.key.toLowerCase() === "b" ? (e.preventDefault(), N("sidebar", j === "collapsed" ? "wide" : "collapsed")) : r && e.key.toLowerCase() === "w" ? (e.preventDefault(), $("current")) : r && e.key === "/" ? (e.preventDefault(), J && V((e) => !e)) : e.key === "/" && !n ? (e.preventDefault(), Z("default")) : e.key === "Escape" && z(!1);
101
+ };
102
+ return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
103
+ }, [
104
+ Z,
105
+ $,
106
+ N,
107
+ j,
108
+ J
109
+ ]);
110
+ let mt = De(() => k ? Fe(r, k.navigation, k.screens, O.pathname, I, D) : [], [
111
+ r,
112
+ k,
113
+ O.pathname,
114
+ I,
115
+ D
116
+ ]), ht = (e) => {
117
+ R(e);
118
+ let t = k ? Se(k, e) ?? void 0 : void 0;
119
+ t && D(t);
120
+ }, gt = (e) => {
121
+ switch (e.type) {
122
+ case "nav":
123
+ e.route && D(e.route);
124
+ break;
125
+ case "new":
126
+ e.route && D(e.route + "/new");
127
+ break;
128
+ case "open":
129
+ e.route && D(e.route);
130
+ break;
131
+ case "ai":
132
+ J && (H(e.q), V(!0));
133
+ break;
134
+ case "ai-panel":
135
+ J && (H(void 0), V(!0));
136
+ break;
137
+ case "theme":
138
+ N("colorScheme", Le === "dark" ? "light" : "dark");
139
+ break;
140
+ case "tab-close": e.tabCloseScope && $(e.tabCloseScope);
141
+ }
142
+ };
143
+ return we.enabled ? /* @__PURE__ */ T(m, { children: [
144
+ /* @__PURE__ */ w(re, {}),
145
+ /* @__PURE__ */ w(ie, {}),
146
+ /* @__PURE__ */ w(ae, {}),
147
+ /* @__PURE__ */ w(se, {}),
148
+ /* @__PURE__ */ w(oe, {}),
149
+ /* @__PURE__ */ w("div", {
150
+ id: "app-embed",
151
+ className: "flex min-h-0 flex-col overflow-auto",
152
+ style: { height: "var(--app-height)" },
153
+ children: /* @__PURE__ */ w(Oe, {})
154
+ })
155
+ ] }) : /* @__PURE__ */ w(m, { children: /* @__PURE__ */ T("div", {
156
+ id: "app",
157
+ "data-sidebar": j,
158
+ "data-mobile-shell": Y ? "true" : void 0,
159
+ style: Me({
160
+ mobileShell: Y,
161
+ showBanner: pt,
162
+ showTopbar: et,
163
+ showRail: X,
164
+ showSidebar: tt,
165
+ sidebarMode: j,
166
+ showAssistant: at
167
+ }),
168
+ children: [
169
+ pt && /* @__PURE__ */ w(s, {}),
170
+ /* @__PURE__ */ w(c, {}),
171
+ et && /* @__PURE__ */ w(i, {
172
+ breadcrumbs: mt,
173
+ onCrumbClick: (e) => e.onClick && e.onClick(),
174
+ showNavButton: rt,
175
+ navButtonRef: Ye,
176
+ onOpenNav: () => U(!0),
177
+ showTabsButton: it,
178
+ tabsButtonRef: Xe,
179
+ onOpenTabs: () => W(!0),
180
+ mobileTabCount: I.length,
181
+ onCmdK: () => Z("default"),
182
+ onToggleAI: () => J && V((e) => !e),
183
+ aiOpen: B,
184
+ onOpenProfile: () => D("/profile"),
185
+ onOpenPrefs: () => D("/preferences"),
186
+ showTenantSwitcher: ot,
187
+ showBreadcrumbs: st,
188
+ showThemeToggle: ct
189
+ }),
190
+ X && /* @__PURE__ */ w(t, {
191
+ activeArea: L,
192
+ onPick: ht,
193
+ onToggleAI: () => J && V((e) => !e),
194
+ aiOpen: B,
195
+ onCmdK: () => Z("default"),
196
+ areas: k?.areas,
197
+ branding: Qe
198
+ }),
199
+ tt && /* @__PURE__ */ w(n, { activeArea: L }),
200
+ /* @__PURE__ */ T("main", {
201
+ style: {
202
+ gridArea: "main",
203
+ overflow: "hidden",
204
+ display: "flex",
205
+ flexDirection: "column",
206
+ minWidth: 0
207
+ },
208
+ children: [
209
+ nt && Ie === "top" && /* @__PURE__ */ w(a, {
210
+ onNew: () => Z("new"),
211
+ onCloseRequest: $
212
+ }),
213
+ /* @__PURE__ */ w("div", {
214
+ style: {
215
+ flex: 1,
216
+ overflow: "auto",
217
+ minHeight: 0,
218
+ display: "flex",
219
+ flexDirection: "column"
220
+ },
221
+ children: /* @__PURE__ */ w(Oe, {})
222
+ }),
223
+ nt && Ie === "bottom" && /* @__PURE__ */ w(a, {
224
+ onNew: () => Z("new"),
225
+ onCloseRequest: $
226
+ })
227
+ ]
228
+ }),
229
+ q && /* @__PURE__ */ w(d, {
230
+ open: Ue,
231
+ mode: We,
232
+ onClose: () => z(!1),
233
+ onAction: (e) => gt(e),
234
+ schema: k,
235
+ includeAI: Ze,
236
+ aiName: $e
237
+ }),
238
+ /* @__PURE__ */ w(he, {}),
239
+ J && B && /* @__PURE__ */ w(ee, {
240
+ open: B,
241
+ docked: at,
242
+ onClose: () => {
243
+ V(!1), H(void 0);
244
+ },
245
+ title: $e,
246
+ askOnOpen: Ke,
247
+ context: ft ?? void 0
248
+ }),
249
+ rt && /* @__PURE__ */ w(Ne, {
250
+ open: qe,
251
+ activeArea: L,
252
+ schema: k,
253
+ returnFocusRef: Ye,
254
+ onClose: () => U(!1),
255
+ onNavigate: D
256
+ }),
257
+ it && /* @__PURE__ */ w(Pe, {
258
+ open: Je,
259
+ tabs: I,
260
+ activeTabId: Be,
261
+ returnFocusRef: Xe,
262
+ onClose: () => W(!1),
263
+ onSwitch: (e) => {
264
+ He(e.id), v({
265
+ pathname: e.pathname,
266
+ search: e.search
267
+ }, { replace: !1 }), W(!1);
268
+ },
269
+ onCloseTab: (e) => $("current", e)
270
+ }),
271
+ /* @__PURE__ */ w(o, {
272
+ pending: G,
273
+ onCancel: lt,
274
+ onCloseClean: ut,
275
+ onDiscardAll: dt
276
+ })
277
+ ]
278
+ }) });
279
+ }
280
+ function je(e) {
281
+ return b(() => {
282
+ let t = document.documentElement.style;
283
+ return t.setProperty("--assistant-open-w", e ? "var(--assistant-w)" : "0px"), () => {
284
+ t.removeProperty("--assistant-open-w");
285
+ };
286
+ }, [e]), e;
287
+ }
288
+ function Me({ mobileShell: e, showBanner: t, showTopbar: n, showRail: r, showSidebar: i, sidebarMode: a, showAssistant: o }) {
289
+ let s = [
290
+ ...t ? ["auto"] : [],
291
+ ...n ? ["var(--topbar-h)"] : [],
292
+ "minmax(0, 1fr)"
293
+ ].join(" "), c = (e) => {
294
+ let r = (t) => `"${e.map(() => t).join(" ")}"`;
295
+ return [
296
+ ...t ? [r("banner")] : [],
297
+ ...n ? [r("topbar")] : [],
298
+ `"${e.join(" ")}"`
299
+ ].join(" ");
300
+ };
301
+ if (e) return {
302
+ height: "var(--app-height)",
303
+ display: "grid",
304
+ gridTemplateRows: s,
305
+ gridTemplateColumns: "minmax(0, 1fr)",
306
+ gridTemplateAreas: c(["main"]),
307
+ overflow: "hidden"
308
+ };
309
+ let l = [], u = [];
310
+ return r && (l.push("var(--rail-w)"), u.push("rail")), i && (l.push(a === "collapsed" || a === "icon-only" ? "56px" : "var(--sidebar-w)"), u.push("sidebar")), l.push("minmax(0, 1fr)"), u.push("main"), o && (l.push("var(--assistant-w)"), u.push("assistant")), {
311
+ height: "var(--app-height)",
312
+ display: "grid",
313
+ gridTemplateRows: s,
314
+ gridTemplateColumns: l.join(" "),
315
+ gridTemplateAreas: c(u),
316
+ overflow: "hidden"
317
+ };
318
+ }
319
+ var O = "a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex='-1'])";
320
+ function k(e) {
321
+ return e ? Array.from(e.querySelectorAll(O)).filter((e) => !e.hasAttribute("disabled") && e.getAttribute("aria-hidden") !== "true") : [];
322
+ }
323
+ function A(e) {
324
+ k(e)[0]?.focus();
325
+ }
326
+ function j(e, t) {
327
+ let n = k(e);
328
+ if (n.length === 0) {
329
+ t.preventDefault();
330
+ return;
331
+ }
332
+ let r = n[0], i = n[n.length - 1], a = document.activeElement;
333
+ t.shiftKey && a === r ? (t.preventDefault(), i.focus()) : !t.shiftKey && a === i && (t.preventDefault(), r.focus());
334
+ }
335
+ function Ne({ open: e, activeArea: t, schema: n, returnFocusRef: i, onClose: a, onNavigate: o }) {
336
+ let s = _(), [c, l] = S(t), u = x(null);
337
+ if (b(() => {
338
+ e && l(t);
339
+ }, [e, t]), b(() => {
340
+ if (!e) return;
341
+ let t = document.activeElement instanceof HTMLElement ? document.activeElement : null, n = i.current;
342
+ requestAnimationFrame(() => A(u.current));
343
+ let r = (e) => {
344
+ e.key === "Escape" ? (e.preventDefault(), a()) : e.key === "Tab" && j(u.current, e);
345
+ };
346
+ return window.addEventListener("keydown", r), () => {
347
+ window.removeEventListener("keydown", r), (n ?? t)?.focus();
348
+ };
349
+ }, [
350
+ e,
351
+ a,
352
+ i
353
+ ]), !e || !n) return null;
354
+ let d = Array.from(new Set((n.navigation ?? []).map((e) => e.area || E)));
355
+ d.length === 0 && d.push(E);
356
+ let ee = (e) => {
357
+ let t = n.areas?.find((t) => t.code === e);
358
+ return s(t?.name) || (e === E ? s("shell.nav.title", "Navigation") : e);
359
+ }, m = (e, t) => {
360
+ let r = e.screen ? n.screens[e.screen] : void 0, i = [...e.items ?? [], ...e.children ?? []], c = s(e.name) || (r ? s(r.display?.name) : "");
361
+ return /* @__PURE__ */ T("div", {
362
+ style: {
363
+ display: "flex",
364
+ flexDirection: "column",
365
+ gap: 2
366
+ },
367
+ children: [r?.route ? /* @__PURE__ */ T("button", {
368
+ type: "button",
369
+ onClick: () => {
370
+ o(r.route), a();
371
+ },
372
+ style: {
373
+ minHeight: 40,
374
+ border: 0,
375
+ borderRadius: "var(--radius-md)",
376
+ background: "transparent",
377
+ color: "var(--text-2)",
378
+ display: "flex",
379
+ alignItems: "center",
380
+ gap: 8,
381
+ padding: `0 10px 0 ${10 + t * 14}px`,
382
+ fontSize: 13,
383
+ textAlign: "left",
384
+ cursor: "pointer"
385
+ },
386
+ children: [/* @__PURE__ */ w("span", { style: { width: 12 } }), /* @__PURE__ */ w("span", {
387
+ style: {
388
+ minWidth: 0,
389
+ overflow: "hidden",
390
+ textOverflow: "ellipsis",
391
+ whiteSpace: "nowrap"
392
+ },
393
+ children: c || r.route
394
+ })]
395
+ }) : c ? /* @__PURE__ */ w("div", {
396
+ style: {
397
+ padding: `7px 10px 5px ${10 + t * 14}px`,
398
+ color: "var(--text-3)",
399
+ fontSize: 10.5,
400
+ fontWeight: 700,
401
+ letterSpacing: "0.08em",
402
+ textTransform: "uppercase"
403
+ },
404
+ children: c
405
+ }) : null, i.map((e) => m(e, t + 1))]
406
+ }, `${t}-${e.screen ?? c}`);
407
+ };
408
+ return /* @__PURE__ */ T(C, { children: [/* @__PURE__ */ w("div", {
409
+ "data-testid": "mobile-nav-backdrop",
410
+ onClick: a,
411
+ style: {
412
+ position: "fixed",
413
+ inset: 0,
414
+ background: "var(--scrim-lite)",
415
+ zIndex: 120
416
+ }
417
+ }), /* @__PURE__ */ T("aside", {
418
+ ref: u,
419
+ role: "dialog",
420
+ "aria-modal": "true",
421
+ "aria-label": s("shell.nav.title", "Navigation"),
422
+ "data-testid": "mobile-nav-drawer",
423
+ style: {
424
+ position: "fixed",
425
+ top: 0,
426
+ bottom: 0,
427
+ left: 0,
428
+ width: 320,
429
+ maxWidth: "calc(100vw - var(--safe-area-right) - 24px)",
430
+ background: "var(--sidebar)",
431
+ color: "var(--sidebar-fg)",
432
+ borderRight: "1px solid var(--border)",
433
+ boxShadow: "var(--shadow-lg)",
434
+ zIndex: 121,
435
+ display: "flex",
436
+ flexDirection: "column",
437
+ padding: "calc(10px + var(--safe-area-top)) 10px calc(10px + var(--safe-area-bottom)) calc(10px + var(--safe-area-left))",
438
+ boxSizing: "border-box",
439
+ overflow: "hidden"
440
+ },
441
+ children: [/* @__PURE__ */ T("div", {
442
+ style: {
443
+ display: "flex",
444
+ alignItems: "center",
445
+ gap: 8,
446
+ minHeight: 36,
447
+ padding: "0 2px 8px"
448
+ },
449
+ children: [/* @__PURE__ */ w("strong", {
450
+ style: {
451
+ fontSize: 13,
452
+ flex: 1
453
+ },
454
+ children: s("shell.nav.title", "Navigation")
455
+ }), /* @__PURE__ */ w(p, {
456
+ icon: /* @__PURE__ */ w(f.x, { size: 15 }),
457
+ title: s("shell.nav.close", "Close navigation"),
458
+ onClick: a
459
+ })]
460
+ }), /* @__PURE__ */ w("nav", {
461
+ style: {
462
+ overflowY: "auto",
463
+ overscrollBehavior: "contain",
464
+ display: "flex",
465
+ flexDirection: "column",
466
+ gap: 6
467
+ },
468
+ children: d.map((e) => {
469
+ let i = c === e, a = r(s, n.navigation ?? [], e);
470
+ return /* @__PURE__ */ T("section", { children: [/* @__PURE__ */ T("button", {
471
+ type: "button",
472
+ onClick: () => l(i ? "" : e),
473
+ style: {
474
+ width: "100%",
475
+ minHeight: 42,
476
+ border: "1px solid var(--border)",
477
+ borderRadius: "var(--radius-md)",
478
+ background: e === t ? "var(--sidebar-active)" : "var(--sidebar-hover)",
479
+ color: "var(--sidebar-fg)",
480
+ display: "flex",
481
+ alignItems: "center",
482
+ gap: 8,
483
+ padding: "0 10px",
484
+ fontSize: 13,
485
+ fontWeight: 650,
486
+ cursor: "pointer"
487
+ },
488
+ "aria-expanded": i,
489
+ children: [/* @__PURE__ */ w("span", {
490
+ style: {
491
+ flex: 1,
492
+ textAlign: "left"
493
+ },
494
+ children: ee(e)
495
+ }), w(i ? f.down : f.right, { size: 13 })]
496
+ }), i && /* @__PURE__ */ w("div", {
497
+ style: { padding: "6px 0 4px" },
498
+ children: a.flatMap((t) => [t.title ? /* @__PURE__ */ w("div", {
499
+ style: {
500
+ padding: "8px 10px 4px",
501
+ color: "var(--text-3)",
502
+ fontSize: 10,
503
+ fontWeight: 700,
504
+ letterSpacing: "0.08em",
505
+ textTransform: "uppercase"
506
+ },
507
+ children: t.title
508
+ }, `${e}-${t.title}`) : null, ...t.items.map((e) => m(e, 0))])
509
+ })] }, e);
510
+ })
511
+ })]
512
+ })] });
513
+ }
514
+ function Pe({ open: e, tabs: t, activeTabId: n, returnFocusRef: r, onClose: i, onSwitch: a, onCloseTab: o }) {
515
+ let s = _(), c = v(), l = x(null);
516
+ return b(() => {
517
+ if (!e) return;
518
+ let t = document.activeElement instanceof HTMLElement ? document.activeElement : null, n = r.current;
519
+ requestAnimationFrame(() => A(l.current));
520
+ let a = (e) => {
521
+ e.key === "Escape" ? (e.preventDefault(), i()) : e.key === "Tab" && j(l.current, e);
522
+ };
523
+ return window.addEventListener("keydown", a), () => {
524
+ window.removeEventListener("keydown", a), (n ?? t)?.focus();
525
+ };
526
+ }, [
527
+ e,
528
+ i,
529
+ r
530
+ ]), e ? /* @__PURE__ */ T(C, { children: [/* @__PURE__ */ w("div", {
531
+ "data-testid": "mobile-tabs-backdrop",
532
+ onClick: i,
533
+ style: {
534
+ position: "fixed",
535
+ inset: 0,
536
+ background: "var(--scrim-lite)",
537
+ zIndex: 122
538
+ }
539
+ }), /* @__PURE__ */ T("section", {
540
+ ref: l,
541
+ role: "dialog",
542
+ "aria-modal": "true",
543
+ "aria-label": s("shell.tabs.open_tabs", "Open tabs"),
544
+ "data-testid": "mobile-tabs-menu",
545
+ style: {
546
+ position: "fixed",
547
+ top: "calc(var(--topbar-h) + var(--safe-area-top) + 8px)",
548
+ right: "calc(var(--safe-area-right) + 10px)",
549
+ width: 320,
550
+ maxWidth: "calc(100vw - var(--safe-area-left) - var(--safe-area-right) - 20px)",
551
+ maxHeight: "calc(var(--app-height) - var(--topbar-h) - var(--safe-area-top) - var(--safe-area-bottom) - 16px)",
552
+ overflowY: "auto",
553
+ overscrollBehavior: "contain",
554
+ background: "var(--surface)",
555
+ border: "1px solid var(--border)",
556
+ borderRadius: "var(--radius-md)",
557
+ boxShadow: "var(--shadow-lg)",
558
+ zIndex: 123,
559
+ padding: 6,
560
+ boxSizing: "border-box"
561
+ },
562
+ children: [/* @__PURE__ */ T("div", {
563
+ style: {
564
+ display: "flex",
565
+ alignItems: "center",
566
+ gap: 8,
567
+ padding: "4px 4px 8px"
568
+ },
569
+ children: [/* @__PURE__ */ w("strong", {
570
+ style: {
571
+ flex: 1,
572
+ fontSize: 13
573
+ },
574
+ children: s("shell.tabs.open_tabs", "Open tabs")
575
+ }), /* @__PURE__ */ w(p, {
576
+ icon: /* @__PURE__ */ w(f.x, { size: 14 }),
577
+ title: s("shell.tabs.close_menu", "Close tabs menu"),
578
+ onClick: i
579
+ })]
580
+ }), t.length === 0 ? /* @__PURE__ */ w("div", {
581
+ style: {
582
+ padding: 10,
583
+ color: "var(--text-3)",
584
+ fontSize: 12
585
+ },
586
+ children: s("shell.tabs.none_open", "No open tabs")
587
+ }) : t.map((e) => /* @__PURE__ */ T("div", {
588
+ style: {
589
+ display: "grid",
590
+ gridTemplateColumns: "minmax(0, 1fr) auto",
591
+ gap: 4,
592
+ alignItems: "center",
593
+ borderRadius: "var(--radius-md)",
594
+ background: e.id === n ? "var(--surface-3)" : "transparent"
595
+ },
596
+ children: [/* @__PURE__ */ T("button", {
597
+ type: "button",
598
+ onClick: () => a(e),
599
+ style: {
600
+ minHeight: 38,
601
+ border: 0,
602
+ background: "transparent",
603
+ color: "var(--text-2)",
604
+ display: "flex",
605
+ alignItems: "center",
606
+ gap: 8,
607
+ minWidth: 0,
608
+ padding: "0 8px",
609
+ textAlign: "left",
610
+ cursor: "pointer"
611
+ },
612
+ children: [/* @__PURE__ */ w(f.layers, { size: 13 }), /* @__PURE__ */ w("span", {
613
+ style: {
614
+ overflow: "hidden",
615
+ textOverflow: "ellipsis",
616
+ whiteSpace: "nowrap"
617
+ },
618
+ children: c(e)
619
+ })]
620
+ }), e.closable && /* @__PURE__ */ w(p, {
621
+ icon: /* @__PURE__ */ w(f.x, { size: 12 }),
622
+ title: s("shell.tabs.close_named", "Close {title}", { title: c(e) }),
623
+ onClick: () => o(e.id)
624
+ })]
625
+ }, e.id))]
626
+ })] }) : null;
627
+ }
628
+ function Fe(e, t, n, r, i, a) {
629
+ let o = Ce(t, n, r)?.chain;
630
+ if (!o || o.length === 0) {
631
+ let t = Object.values(n).find((e) => e.route === r);
632
+ if (t?.display?.name) return [{
633
+ label: e(t.display.name),
634
+ icon: t.display.icon,
635
+ isLast: !0
636
+ }];
637
+ let i = we(e, r);
638
+ return i ? [{
639
+ label: i,
640
+ isLast: !0
641
+ }] : [];
642
+ }
643
+ let s = [];
644
+ for (let t = 0; t < o.length; t++) {
645
+ let i = o[t], c = t === o.length - 1, l = i.screen ? n[i.screen] : void 0;
646
+ s.push({
647
+ label: e(i.name) || i.screen || "",
648
+ icon: i.icon,
649
+ onClick: l ? () => {
650
+ a(l.route);
651
+ } : void 0,
652
+ isLast: c && (!l || l.route === r)
653
+ });
654
+ }
655
+ let c = o[o.length - 1], l = c.screen ? n[c.screen] : void 0;
656
+ if (l && r !== l.route && r.startsWith(l.route + "/")) {
657
+ let t = i.find((e) => e.pathname === r);
658
+ s.push({
659
+ label: t?.title || e("shell.crumbs.record", "Record"),
660
+ icon: "file",
661
+ isLast: !0
662
+ });
663
+ }
664
+ return s;
665
+ }
666
+ export { D as Layout, Fe as buildCrumbs };