wcz-layout
Version:
2,814 lines • 72.6 kB
JavaScript
import { c as isTestEnv, n as WISTRON_PRIMARY_COLOR, r as WISTRON_SECONDARY_COLOR, t as Platform, u as rootRouteHead } from "./utils-CgabUlDD.mjs";
import { c as withOfflineFallback, i as userQueryOptions, n as getUser, o as OFFLINE_PHOTO_KEY, r as loginProvidersQueryOptions, s as clearSessionSnapshot } from "./user-Bc2nLjAG.mjs";
import { t as getAccessToken } from "./tokens-DNe_Qifk.mjs";
import { n as RouterIconButton, t as RouterListItemButton } from "./RouterListItemButton-CF-8w-08.mjs";
import { t as DialogsContext } from "./DialogsContext-D23fJjYR.mjs";
import { c } from "react/compiler-runtime";
import createCache from "@emotion/cache";
import { CacheProvider } from "@emotion/react";
import { AppBar, Avatar, Box, Collapse, CssBaseline, Grow, IconButton, InitColorSchemeScript, List, ListItem, ListItemButton, ListItemIcon, ListItemText, ListSubheader, Popover, Stack, ThemeProvider, Toolbar, Tooltip, Typography, useColorScheme, useMediaQuery } from "@mui/material";
import { useQuery } from "@tanstack/react-query";
import { LocalizationProvider } from "@mui/x-date-pickers";
import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";
import dayjs from "dayjs";
import i18n from "i18next";
import LanguageDetector from "i18next-browser-languagedetector";
import { Fragment, useEffect, useId, useRef, useState } from "react";
import { I18nextProvider, Trans, initReactI18next, useTranslation } from "react-i18next";
import { manifest, resources } from "virtual:wcz-layout";
import z from "zod";
import AutoAwesome from "@mui/icons-material/AutoAwesome";
import Menu$1 from "@mui/icons-material/Menu";
import MenuOpen from "@mui/icons-material/MenuOpen";
import { styled } from "@mui/material/styles";
import { rootRouteId, useLocation, useMatch, useMatchRoute, useRouter } from "@tanstack/react-router";
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
import { createIsomorphicFn, createServerFn } from "@tanstack/react-start";
import AccountCircle from "@mui/icons-material/AccountCircle";
import ArrowBack from "@mui/icons-material/ArrowBack";
import Brightness4 from "@mui/icons-material/Brightness4";
import ChevronRight from "@mui/icons-material/ChevronRight";
import DarkMode from "@mui/icons-material/DarkMode";
import Done from "@mui/icons-material/Done";
import LightMode from "@mui/icons-material/LightMode";
import Login from "@mui/icons-material/Login";
import Logout from "@mui/icons-material/Logout";
import SettingsBrightness from "@mui/icons-material/SettingsBrightness";
import Translate from "@mui/icons-material/Translate";
import axios from "axios";
import Drawer from "@mui/material/Drawer";
import useMediaQuery$1 from "@mui/material/useMediaQuery";
import Box$1 from "@mui/material/Box";
import Divider$1 from "@mui/material/Divider";
import List$1 from "@mui/material/List";
import ListSubheader$1 from "@mui/material/ListSubheader";
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
import Avatar$1 from "@mui/material/Avatar";
import ListItem$1 from "@mui/material/ListItem";
import ListItemButton$1 from "@mui/material/ListItemButton";
import ListItemIcon$1 from "@mui/material/ListItemIcon";
import ListItemText$1 from "@mui/material/ListItemText";
import Paper$1 from "@mui/material/Paper";
import Typography$1 from "@mui/material/Typography";
import Close from "@mui/icons-material/Close";
import useEventCallback$1 from "@mui/utils/useEventCallback";
// src/components/chat/ChatPanel.tsx
const WIDTH_STORAGE_KEY = "chat-width";
const MIN_WIDTH = 320;
const MAX_WIDTH = 800;
const KEYBOARD_STEP = 16;
/** The width a resize lands on: 320 to 800px, and never more than half the window. */
const clampChatWidth = (width, viewport) => Math.round(Math.max(MIN_WIDTH, Math.min(width, MAX_WIDTH, viewport / 2)));
/** The chat right of the page, or over all of it on smaller screens, below the app bar. */
function ChatPanel(t0) {
const $ = c(24);
const { id, open, docked, rail, children } = t0;
const [width, setWidth] = useState(420);
const [opened, setOpened] = useState(open);
if (open && !opened) setOpened(true);
let t1;
let t2;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t1 = () => {
const stored = Number(localStorage.getItem(WIDTH_STORAGE_KEY));
if (stored) setWidth(clampChatWidth(stored, window.innerWidth));
};
t2 = [];
$[0] = t1;
$[1] = t2;
} else {
t1 = $[0];
t2 = $[1];
}
useEffect(t1, t2);
let t3;
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
t3 = (requested, t4) => {
const save = t4 === void 0 ? false : t4;
const next = clampChatWidth(requested, window.innerWidth);
setWidth(next);
if (save) localStorage.setItem(WIDTH_STORAGE_KEY, String(next));
};
$[2] = t3;
} else t3 = $[2];
const resize = t3;
const t4 = open ? "flex" : "none";
let t5;
if ($[3] !== docked || $[4] !== rail || $[5] !== width) {
t5 = docked ? {
flexShrink: 0,
width,
maxWidth: "50vw"
} : {
position: "fixed",
inset: 0,
left: {
xs: 0,
sm: rail
},
zIndex: _temp$8,
bgcolor: "background.default"
};
$[3] = docked;
$[4] = rail;
$[5] = width;
$[6] = t5;
} else t5 = $[6];
let t6;
if ($[7] !== t4 || $[8] !== t5) {
t6 = {
display: t4,
flexDirection: "column",
height: "100%",
...t5
};
$[7] = t4;
$[8] = t5;
$[9] = t6;
} else t6 = $[9];
let t7;
if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
t7 = /* @__PURE__ */ jsx(Toolbar, {});
$[10] = t7;
} else t7 = $[10];
const t8 = docked ? 1 : 0;
let t9;
if ($[11] !== t8) {
t9 = {
position: "relative",
display: "flex",
flexDirection: "column",
flex: 1,
minHeight: 0,
borderLeft: t8,
borderColor: "divider"
};
$[11] = t8;
$[12] = t9;
} else t9 = $[12];
let t10;
if ($[13] !== docked || $[14] !== width) {
t10 = docked && /* @__PURE__ */ jsx(Box, {
role: "separator",
tabIndex: 0,
"aria-orientation": "vertical",
"aria-label": "Resize the assistant",
"aria-valuemin": MIN_WIDTH,
"aria-valuemax": MAX_WIDTH,
"aria-valuenow": width,
onPointerDown: _temp2$5,
onPointerMove: (event_0) => {
if (event_0.currentTarget.hasPointerCapture(event_0.pointerId)) resize(window.innerWidth - event_0.clientX);
},
onPointerUp: (event_1) => {
if (event_1.currentTarget.hasPointerCapture(event_1.pointerId)) resize(window.innerWidth - event_1.clientX, true);
},
onKeyDown: (event_2) => {
if (event_2.key !== "ArrowLeft" && event_2.key !== "ArrowRight") return;
event_2.preventDefault();
resize(width + (event_2.key === "ArrowLeft" ? KEYBOARD_STEP : -16), true);
},
sx: {
position: "absolute",
top: 0,
bottom: 0,
left: -4,
width: 8,
zIndex: 1,
cursor: "col-resize",
touchAction: "none",
outline: "none",
"@media (forced-colors: active)": { "&:focus-visible": { outline: "2px solid" } },
"&::after": {
content: "\"\"",
position: "absolute",
top: 0,
bottom: 0,
left: 3,
width: 2,
transition: "background-color 150ms"
},
"&:hover::after, &:focus-visible::after": { bgcolor: "primary.main" }
}
});
$[13] = docked;
$[14] = width;
$[15] = t10;
} else t10 = $[15];
const t11 = opened && children;
let t12;
if ($[16] !== t10 || $[17] !== t11 || $[18] !== t9) {
t12 = /* @__PURE__ */ jsxs(Box, {
sx: t9,
children: [t10, t11]
});
$[16] = t10;
$[17] = t11;
$[18] = t9;
$[19] = t12;
} else t12 = $[19];
let t13;
if ($[20] !== id || $[21] !== t12 || $[22] !== t6) {
t13 = /* @__PURE__ */ jsxs(Box, {
component: "aside",
id,
"aria-label": "Assistant",
sx: t6,
children: [t7, t12]
});
$[20] = id;
$[21] = t12;
$[22] = t6;
$[23] = t13;
} else t13 = $[23];
return t13;
}
function _temp2$5(event) {
event.preventDefault();
event.currentTarget.setPointerCapture(event.pointerId);
}
function _temp$8(theme) {
return theme.zIndex.appBar - 1;
}
// src/components/core/account/UserAvatar.tsx
const getProfilePhoto = createServerFn({ method: "GET" }).handler(async () => {
const accessToken = await getAccessToken("graph");
try {
const response = await axios.get("https://graph.microsoft.com/v1.0/me/photos/240x240/$value", {
responseType: "arraybuffer",
headers: { Authorization: `Bearer ${accessToken}` }
});
return `data:image/jpeg;base64,${Buffer.from(response.data).toString("base64")}`;
} catch (error) {
if (axios.isAxiosError(error) && error.response?.status === 404) return "";
throw new Error("Failed to fetch profile photo");
}
});
const initials = (name) => {
const words = name.trim().split(/\s+/).filter(Boolean);
const last = words.length > 1 ? words.at(-1) ?? "" : "";
return `${words[0]?.[0] ?? ""}${last[0] ?? ""}`.toUpperCase();
};
const UserAvatar = (t0) => {
const $ = c(10);
const { user } = t0;
let t1;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t1 = [
"graph",
"me",
"photo"
];
$[0] = t1;
} else t1 = $[0];
const t2 = user.provider === "entra";
let t3;
if ($[1] !== t2) {
t3 = {
queryKey: t1,
queryFn: _temp2$4,
enabled: t2,
staleTime: Infinity,
gcTime: Infinity,
networkMode: "offlineFirst"
};
$[1] = t2;
$[2] = t3;
} else t3 = $[2];
const { data: photoUrl } = useQuery(t3);
const t4 = user.name;
const t5 = photoUrl || void 0;
let t6;
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
t6 = {
width: {
xs: 32,
sm: 40
},
height: {
xs: 32,
sm: 40
},
fontSize: 16,
fontWeight: 500,
letterSpacing: "0.06em",
pt: "2px",
pl: "0.06em",
backgroundColor: "primary.main",
color: "primary.contrastText"
};
$[3] = t6;
} else t6 = $[3];
let t7;
if ($[4] !== user.name) {
t7 = initials(user.name);
$[4] = user.name;
$[5] = t7;
} else t7 = $[5];
let t8;
if ($[6] !== t5 || $[7] !== t7 || $[8] !== user.name) {
t8 = /* @__PURE__ */ jsx(Avatar, {
alt: t4,
src: t5,
sx: t6,
children: t7
});
$[6] = t5;
$[7] = t7;
$[8] = user.name;
$[9] = t8;
} else t8 = $[9];
return t8;
};
function _temp$7() {
return getProfilePhoto();
}
function _temp2$4() {
return withOfflineFallback(OFFLINE_PHOTO_KEY, _temp$7);
}
// src/components/core/account/UserMenu.tsx
const capitalize = (value) => value && value.charAt(0).toUpperCase() + value.slice(1);
const ToolbarAccount = () => {
const $ = c(116);
const [anchorElement, setAnchorElement] = useState();
const [tab, setTab] = useState("settings");
const [previousTab, setPreviousTab] = useState();
const open = Boolean(anchorElement);
const { t, i18n } = useTranslation();
const { mode, setMode } = useColorScheme();
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t0 = { from: rootRouteId };
$[0] = t0;
} else t0 = $[0];
const user = useMatch(t0).context.user;
let t1;
if ($[1] !== i18n.options.supportedLngs) {
t1 = Array.isArray(i18n.options.supportedLngs) ? i18n.options.supportedLngs : [];
$[1] = i18n.options.supportedLngs;
$[2] = t1;
} else t1 = $[2];
let T0;
let closeMenu;
let openMenu;
let settings;
let t2;
let t3;
let theme;
if ($[3] !== i18n || $[4] !== mode || $[5] !== previousTab || $[6] !== setMode || $[7] !== t || $[8] !== t1 || $[9] !== tab) {
const supportedLanguages = t1.filter(_temp$6);
const languageDisplayNames = new Intl.DisplayNames([i18n.language], { type: "language" });
let t4;
if ($[17] !== t) {
t4 = t("Layout.Light");
$[17] = t;
$[18] = t4;
} else t4 = $[18];
let t5;
if ($[19] !== t4) {
t5 = {
mode: "light",
icon: LightMode,
label: t4
};
$[19] = t4;
$[20] = t5;
} else t5 = $[20];
let t6;
if ($[21] !== t) {
t6 = t("Layout.Dark");
$[21] = t;
$[22] = t6;
} else t6 = $[22];
let t7;
if ($[23] !== t6) {
t7 = {
mode: "dark",
icon: DarkMode,
label: t6
};
$[23] = t6;
$[24] = t7;
} else t7 = $[24];
let t8;
if ($[25] !== t) {
t8 = t("Layout.System");
$[25] = t;
$[26] = t8;
} else t8 = $[26];
let t9;
if ($[27] !== t8) {
t9 = {
mode: "system",
icon: SettingsBrightness,
label: t8
};
$[27] = t8;
$[28] = t9;
} else t9 = $[28];
let t10;
if ($[29] !== t5 || $[30] !== t7 || $[31] !== t9) {
t10 = [
t5,
t7,
t9
];
$[29] = t5;
$[30] = t7;
$[31] = t9;
$[32] = t10;
} else t10 = $[32];
const colorModes = t10;
let t11;
if ($[33] === Symbol.for("react.memo_cache_sentinel")) {
t11 = (event) => setAnchorElement(event.currentTarget);
$[33] = t11;
} else t11 = $[33];
openMenu = t11;
let t12;
if ($[34] === Symbol.for("react.memo_cache_sentinel")) {
t12 = () => setAnchorElement(void 0);
$[34] = t12;
} else t12 = $[34];
closeMenu = t12;
let t13;
if ($[35] !== tab) {
t13 = (newTab) => () => {
setPreviousTab(tab);
setTab(newTab);
};
$[35] = tab;
$[36] = t13;
} else t13 = $[36];
const changeTab = t13;
let t14;
if ($[37] !== changeTab) {
t14 = (title) => /* @__PURE__ */ jsxs(ListSubheader, {
onClick: changeTab("settings"),
sx: {
backgroundColor: "transparent",
display: "flex",
alignItems: "center",
px: 1,
cursor: "pointer"
},
children: [
/* @__PURE__ */ jsx(IconButton, {
size: "small",
sx: { mr: .5 },
"aria-label": "Back",
autoFocus: true,
children: /* @__PURE__ */ jsx(ArrowBack, { fontSize: "small" })
}),
" ",
title
]
});
$[37] = changeTab;
$[38] = t14;
} else t14 = $[38];
const backHeader = t14;
let t15;
if ($[39] === Symbol.for("react.memo_cache_sentinel")) {
t15 = { backgroundColor: "transparent" };
$[39] = t15;
} else t15 = $[39];
let t16;
if ($[40] !== t) {
t16 = t("Layout.Settings");
$[40] = t;
$[41] = t16;
} else t16 = $[41];
let t17;
if ($[42] !== t16) {
t17 = /* @__PURE__ */ jsx(ListSubheader, {
sx: t15,
children: t16
});
$[42] = t16;
$[43] = t17;
} else t17 = $[43];
let t18;
if ($[44] !== changeTab) {
t18 = changeTab("theme");
$[44] = changeTab;
$[45] = t18;
} else t18 = $[45];
const t19 = previousTab === "theme";
let t20;
if ($[46] === Symbol.for("react.memo_cache_sentinel")) {
t20 = { py: .3 };
$[46] = t20;
} else t20 = $[46];
let t21;
if ($[47] === Symbol.for("react.memo_cache_sentinel")) {
t21 = /* @__PURE__ */ jsx(ListItemIcon, { children: /* @__PURE__ */ jsx(Brightness4, {}) });
$[47] = t21;
} else t21 = $[47];
let t22;
if ($[48] !== t) {
t22 = t("Layout.Appearance");
$[48] = t;
$[49] = t22;
} else t22 = $[49];
let t23;
if ($[50] !== colorModes || $[51] !== mode || $[52] !== t) {
t23 = colorModes.find((m) => m.mode === mode)?.label ?? t("Layout.System");
$[50] = colorModes;
$[51] = mode;
$[52] = t;
$[53] = t23;
} else t23 = $[53];
let t24;
if ($[54] !== t22 || $[55] !== t23) {
t24 = /* @__PURE__ */ jsx(ListItemText, {
primary: t22,
secondary: t23
});
$[54] = t22;
$[55] = t23;
$[56] = t24;
} else t24 = $[56];
let t25;
if ($[57] === Symbol.for("react.memo_cache_sentinel")) {
t25 = /* @__PURE__ */ jsx(ChevronRight, {});
$[57] = t25;
} else t25 = $[57];
let t26;
if ($[58] !== t18 || $[59] !== t19 || $[60] !== t24) {
t26 = /* @__PURE__ */ jsxs(ListItemButton, {
onClick: t18,
autoFocus: t19,
sx: t20,
children: [
t21,
t24,
t25
]
});
$[58] = t18;
$[59] = t19;
$[60] = t24;
$[61] = t26;
} else t26 = $[61];
let t27;
if ($[62] !== changeTab) {
t27 = changeTab("language");
$[62] = changeTab;
$[63] = t27;
} else t27 = $[63];
let t28;
if ($[64] === Symbol.for("react.memo_cache_sentinel")) {
t28 = { py: .3 };
$[64] = t28;
} else t28 = $[64];
let t29;
if ($[65] === Symbol.for("react.memo_cache_sentinel")) {
t29 = /* @__PURE__ */ jsx(ListItemIcon, { children: /* @__PURE__ */ jsx(Translate, {}) });
$[65] = t29;
} else t29 = $[65];
let t30;
if ($[66] !== t) {
t30 = t("Layout.Language");
$[66] = t;
$[67] = t30;
} else t30 = $[67];
let t31;
if ($[68] === Symbol.for("react.memo_cache_sentinel")) {
t31 = /* @__PURE__ */ jsx(ChevronRight, {});
$[68] = t31;
} else t31 = $[68];
const t32 = /* @__PURE__ */ jsxs(ListItemButton, {
onClick: t27,
autoFocus: previousTab === "language",
sx: t28,
children: [
t29,
/* @__PURE__ */ jsx(ListItemText, {
primary: t30,
secondary: capitalize(languageDisplayNames.of(i18n.language))
}),
t31
]
});
let t33;
if ($[69] !== t17 || $[70] !== t26 || $[71] !== t32) {
t33 = /* @__PURE__ */ jsxs(List, {
subheader: t17,
children: [t26, t32]
});
$[69] = t17;
$[70] = t26;
$[71] = t32;
$[72] = t33;
} else t33 = $[72];
settings = t33;
let t34;
if ($[73] !== backHeader || $[74] !== t) {
t34 = backHeader(t("Layout.Appearance"));
$[73] = backHeader;
$[74] = t;
$[75] = t34;
} else t34 = $[75];
let t35;
if ($[76] !== colorModes || $[77] !== mode || $[78] !== setMode) {
t35 = colorModes.map((t36) => {
const { mode: modeValue, icon: Icon, label } = t36;
return /* @__PURE__ */ jsxs(ListItemButton, {
onClick: () => {
setMode(modeValue);
closeMenu();
},
selected: mode === modeValue,
"aria-current": mode === modeValue || void 0,
children: [
/* @__PURE__ */ jsx(ListItemIcon, { children: /* @__PURE__ */ jsx(Icon, {}) }),
/* @__PURE__ */ jsx(ListItemText, { primary: label }),
mode === modeValue && /* @__PURE__ */ jsx(Done, { fontSize: "small" })
]
}, modeValue);
});
$[76] = colorModes;
$[77] = mode;
$[78] = setMode;
$[79] = t35;
} else t35 = $[79];
let t36;
if ($[80] !== t34 || $[81] !== t35) {
t36 = /* @__PURE__ */ jsx(List, {
subheader: t34,
children: t35
});
$[80] = t34;
$[81] = t35;
$[82] = t36;
} else t36 = $[82];
theme = t36;
T0 = List;
if ($[83] !== backHeader || $[84] !== t) {
t2 = backHeader(t("Layout.Language"));
$[83] = backHeader;
$[84] = t;
$[85] = t2;
} else t2 = $[85];
t3 = supportedLanguages.map((languageCode) => /* @__PURE__ */ jsxs(ListItemButton, {
onClick: () => i18n.changeLanguage(languageCode).finally(() => closeMenu()),
selected: i18n.resolvedLanguage === languageCode,
"aria-current": i18n.resolvedLanguage === languageCode || void 0,
children: [/* @__PURE__ */ jsx(ListItemIcon, { children: i18n.resolvedLanguage === languageCode && /* @__PURE__ */ jsx(Done, {}) }), /* @__PURE__ */ jsx(ListItemText, { primary: capitalize(languageDisplayNames.of(languageCode)) })]
}, languageCode));
$[3] = i18n;
$[4] = mode;
$[5] = previousTab;
$[6] = setMode;
$[7] = t;
$[8] = t1;
$[9] = tab;
$[10] = T0;
$[11] = closeMenu;
$[12] = openMenu;
$[13] = settings;
$[14] = t2;
$[15] = t3;
$[16] = theme;
} else {
T0 = $[10];
closeMenu = $[11];
openMenu = $[12];
settings = $[13];
t2 = $[14];
t3 = $[15];
theme = $[16];
}
let t4;
if ($[86] !== T0 || $[87] !== t2 || $[88] !== t3) {
t4 = /* @__PURE__ */ jsx(T0, {
subheader: t2,
children: t3
});
$[86] = T0;
$[87] = t2;
$[88] = t3;
$[89] = t4;
} else t4 = $[89];
const language = t4;
let t5;
if ($[90] !== user) {
t5 = user ? /* @__PURE__ */ jsx(UserAvatar, { user }) : /* @__PURE__ */ jsx(AccountCircle, { sx: {
width: {
xs: 32,
sm: 40
},
height: {
xs: 32,
sm: 40
}
} });
$[90] = user;
$[91] = t5;
} else t5 = $[91];
let t6;
if ($[92] !== open || $[93] !== openMenu || $[94] !== t5) {
t6 = /* @__PURE__ */ jsx(IconButton, {
size: "small",
edge: "end",
onClick: openMenu,
"aria-label": "Account",
"aria-haspopup": "dialog",
"aria-expanded": open,
children: t5
});
$[92] = open;
$[93] = openMenu;
$[94] = t5;
$[95] = t6;
} else t6 = $[95];
let t7;
let t8;
let t9;
if ($[96] === Symbol.for("react.memo_cache_sentinel")) {
t7 = {
vertical: "bottom",
horizontal: "right"
};
t8 = {
vertical: "top",
horizontal: "right"
};
t9 = {
paper: {
role: "dialog",
"aria-label": "Account"
},
transition: { onExited: () => {
setTab("settings");
setPreviousTab(void 0);
} }
};
$[96] = t7;
$[97] = t8;
$[98] = t9;
} else {
t7 = $[96];
t8 = $[97];
t9 = $[98];
}
let t10;
if ($[99] === Symbol.for("react.memo_cache_sentinel")) {
t10 = { width: 240 };
$[99] = t10;
} else t10 = $[99];
let t11;
if ($[100] !== t || $[101] !== user) {
t11 = /* @__PURE__ */ jsx(List, {
disablePadding: true,
children: user ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ListItem, { children: /* @__PURE__ */ jsx(ListItemText, {
primary: user.name,
secondary: /* @__PURE__ */ jsxs("span", { children: [
user.employeeId && /* @__PURE__ */ jsx("span", { children: user.employeeId }),
user.employeeId && /* @__PURE__ */ jsx("br", {}),
user.department && /* @__PURE__ */ jsx("span", { children: user.department })
] })
}) }), /* @__PURE__ */ jsxs(ListItemButton, {
onClick: _temp2$3,
children: [/* @__PURE__ */ jsx(ListItemIcon, { children: /* @__PURE__ */ jsx(Logout, { color: "error" }) }), /* @__PURE__ */ jsx(ListItemText, { primary: t("Layout.Logout") })]
})] }) : /* @__PURE__ */ jsxs(ListItemButton, {
onClick: _temp3$2,
children: [/* @__PURE__ */ jsx(ListItemIcon, { children: /* @__PURE__ */ jsx(Login, { color: "success" }) }), /* @__PURE__ */ jsx(ListItemText, { primary: t("Layout.LogIn") })]
})
});
$[100] = t;
$[101] = user;
$[102] = t11;
} else t11 = $[102];
const t12 = tab === "settings" && settings;
const t13 = tab === "theme" && theme;
const t14 = tab === "language" && language;
let t15;
if ($[103] !== t11 || $[104] !== t12 || $[105] !== t13 || $[106] !== t14) {
t15 = /* @__PURE__ */ jsxs(Box, {
sx: t10,
children: [
t11,
t12,
t13,
t14
]
});
$[103] = t11;
$[104] = t12;
$[105] = t13;
$[106] = t14;
$[107] = t15;
} else t15 = $[107];
let t16;
if ($[108] !== anchorElement || $[109] !== closeMenu || $[110] !== open || $[111] !== t15) {
t16 = /* @__PURE__ */ jsx(Popover, {
anchorEl: anchorElement,
open,
onClose: closeMenu,
anchorOrigin: t7,
transformOrigin: t8,
slotProps: t9,
children: t15
});
$[108] = anchorElement;
$[109] = closeMenu;
$[110] = open;
$[111] = t15;
$[112] = t16;
} else t16 = $[112];
let t17;
if ($[113] !== t16 || $[114] !== t6) {
t17 = /* @__PURE__ */ jsxs(Fragment, { children: [t6, t16] });
$[113] = t16;
$[114] = t6;
$[115] = t17;
} else t17 = $[115];
return t17;
};
function _temp$6(lng) {
return lng !== "cimode";
}
function _temp2$3() {
clearSessionSnapshot();
location.href = "/auth/logout";
}
function _temp3$2() {
const returnTo = location.pathname + location.search;
location.href = `/auth/login?returnTo=${encodeURIComponent(returnTo)}`;
}
// src/components/core/AppTitle.tsx
const AppTitle = () => {
const $ = c(5);
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t0 = {
alignItems: "center",
flexGrow: 1,
minWidth: 0
};
$[0] = t0;
} else t0 = $[0];
let t1;
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
t1 = /* @__PURE__ */ jsx(RouterIconButton, {
to: "/",
size: "small",
"aria-label": "Go to home page",
children: /* @__PURE__ */ jsx("img", {
src: "/favicon-32x32.png",
alt: "",
width: 32,
height: 32
})
});
$[1] = t1;
} else t1 = $[1];
let t2;
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
t2 = { display: {
xs: "inline",
sm: "none"
} };
$[2] = t2;
} else t2 = $[2];
let t3;
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
t3 = /* @__PURE__ */ jsx(Box, {
component: "span",
sx: t2,
children: manifest.short_name ?? manifest.name
});
$[3] = t3;
} else t3 = $[3];
let t4;
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
t4 = /* @__PURE__ */ jsxs(Stack, {
direction: "row",
spacing: 1,
sx: t0,
children: [t1, /* @__PURE__ */ jsxs(Typography, {
variant: "h6",
component: "div",
noWrap: true,
children: [t3, /* @__PURE__ */ jsx(Box, {
component: "span",
sx: { display: {
xs: "none",
sm: "inline"
} },
children: manifest.name
})]
})]
});
$[4] = t4;
} else t4 = $[4];
return t4;
};
// src/models/Navigation.ts
const isPageItem = (item) => item.kind === "item";
const isPageGroup = (item) => item.kind === "group";
const isDivider = (item) => item.kind === "divider";
const isHeader = (item) => item.kind === "header";
// src/components/core/navigation/NavigationListItem.tsx
const ICON_SIZE = 34;
const getSelectedColor = (theme) => theme.vars?.palette.primary.dark ?? theme.palette.primary.dark;
const getActionActiveColor = (theme) => theme.vars?.palette.action.active ?? theme.palette.action.active;
const StyledNavButton = styled(ListItemButton$1)(({ theme }) => ({
borderRadius: Number(theme.shape.borderRadius) * 2,
"&.Mui-selected": {
"& .MuiListItemIcon-root, & .MuiTypography-root, & .MuiSvgIcon-root": { color: getSelectedColor(theme) },
"& .MuiAvatar-root": { backgroundColor: getSelectedColor(theme) },
"& .MuiTouchRipple-child": { backgroundColor: getSelectedColor(theme) }
},
"& .MuiSvgIcon-root": { color: getActionActiveColor(theme) },
"& .MuiAvatar-root": { backgroundColor: getActionActiveColor(theme) }
}));
const routerButtonSx = (theme) => ({
borderRadius: 2,
"&.Mui-selected": {
"& .MuiListItemIcon-root, & .MuiTypography-root, & .MuiSvgIcon-root": { color: getSelectedColor(theme) },
"& .MuiAvatar-root": { backgroundColor: getSelectedColor(theme) },
"& .MuiTouchRipple-child": { backgroundColor: getSelectedColor(theme) }
},
"& .MuiSvgIcon-root": { color: getActionActiveColor(theme) },
"& .MuiAvatar-root": { backgroundColor: getActionActiveColor(theme) }
});
const IconOrAvatar = (t0) => {
const $ = c(17);
const { item, collapsed } = t0;
if (item.icon || collapsed) {
let t1;
if ($[0] !== collapsed) {
t1 = collapsed ? {
width: "100%",
display: "flex",
flexDirection: "column",
alignItems: "center"
} : {};
$[0] = collapsed;
$[1] = t1;
} else t1 = $[1];
let t2;
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
t2 = {
display: "flex",
alignItems: "center",
justifyContent: "center",
minWidth: ICON_SIZE
};
$[2] = t2;
} else t2 = $[2];
const t3 = item.icon ?? null;
let t4;
if ($[3] !== collapsed || $[4] !== item.icon || $[5] !== item.title) {
t4 = !item.icon && collapsed ? /* @__PURE__ */ jsx(Avatar$1, {
sx: {
width: 27,
height: 27,
fontSize: 12
},
children: item.title.split(" ").slice(0, 2).map(_temp$5).join("")
}) : null;
$[3] = collapsed;
$[4] = item.icon;
$[5] = item.title;
$[6] = t4;
} else t4 = $[6];
let t5;
if ($[7] !== t3 || $[8] !== t4) {
t5 = /* @__PURE__ */ jsxs(ListItemIcon$1, {
sx: t2,
children: [t3, t4]
});
$[7] = t3;
$[8] = t4;
$[9] = t5;
} else t5 = $[9];
let t6;
if ($[10] !== collapsed || $[11] !== item.title) {
t6 = collapsed ? /* @__PURE__ */ jsx(Typography$1, {
variant: "caption",
sx: {
fontSize: 10,
fontWeight: 500,
textAlign: "center"
},
children: item.title
}) : null;
$[10] = collapsed;
$[11] = item.title;
$[12] = t6;
} else t6 = $[12];
let t7;
if ($[13] !== t1 || $[14] !== t5 || $[15] !== t6) {
t7 = /* @__PURE__ */ jsxs(Box$1, {
sx: t1,
children: [t5, t6]
});
$[13] = t1;
$[14] = t5;
$[15] = t6;
$[16] = t7;
} else t7 = $[16];
return t7;
}
return null;
};
const MiniPopover = (t0) => {
const $ = c(7);
const { open, children } = t0;
let t1;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t1 = {
position: "fixed",
left: 84,
pl: "2px",
pb: "10px"
};
$[0] = t1;
} else t1 = $[0];
let t2;
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
t2 = {
pt: .5,
pb: .5,
maxHeight: "min(calc(100vh - 100px), 560px)",
overflowY: "auto",
overscrollBehavior: "contain"
};
$[1] = t2;
} else t2 = $[1];
let t3;
if ($[2] !== children) {
t3 = /* @__PURE__ */ jsx(Box$1, {
sx: t1,
children: /* @__PURE__ */ jsx(Paper$1, {
sx: t2,
children
})
});
$[2] = children;
$[3] = t3;
} else t3 = $[3];
let t4;
if ($[4] !== open || $[5] !== t3) {
t4 = /* @__PURE__ */ jsx(Grow, {
in: open,
unmountOnExit: true,
children: t3
});
$[4] = open;
$[5] = t3;
$[6] = t4;
} else t4 = $[6];
return t4;
};
const NavigationListItem = (t0) => {
const $ = c(72);
const { item, isOpen, disabled, collapsed, isSidebarFullyExpanded: t1, isSidebarFullyCollapsed, onClick, renderNested, onClose } = t0;
const isSidebarFullyExpanded = t1 === void 0 ? true : t1;
const [miniOpen, setMiniOpen] = useState(false);
const groupButtonRef = useRef(null);
const matchRoute = useMatchRoute();
let t2;
if ($[0] !== item) {
t2 = isPageGroup(item);
$[0] = item;
$[1] = t2;
} else t2 = $[1];
const groupItem = t2;
let T0;
let itemId;
let t3;
let t4;
let t5;
let t6;
if ($[2] !== collapsed || $[3] !== disabled || $[4] !== groupItem || $[5] !== isOpen || $[6] !== isSidebarFullyCollapsed || $[7] !== isSidebarFullyExpanded || $[8] !== item || $[9] !== matchRoute || $[10] !== miniOpen || $[11] !== onClick || $[12] !== onClose) {
const containsActive = (navItem) => isPageGroup(navItem) ? navItem.children.some(containsActive) : isPageItem(navItem) && !!navItem.to && !!matchRoute({
to: navItem.to,
params: navItem.params
});
itemId = groupItem ? `group-${item.title}` : `item-${item.to ?? item.href ?? item.title}`;
let t7;
if ($[19] !== collapsed || $[20] !== groupItem || $[21] !== isOpen || $[22] !== isSidebarFullyCollapsed || $[23] !== isSidebarFullyExpanded) {
t7 = (theme) => {
if (collapsed && isSidebarFullyCollapsed && groupItem) return {
fontSize: 18,
position: "absolute",
top: 21,
right: "2px",
transform: "translateY(-50%) rotate(-90deg)"
};
if (!collapsed && isSidebarFullyExpanded && groupItem) return {
ml: .5,
transform: `rotate(${isOpen ? 0 : -90}deg)`,
transition: theme.transitions.create("transform", {
easing: theme.transitions.easing.sharp,
duration: 100
})
};
return { display: "none" };
};
$[19] = collapsed;
$[20] = groupItem;
$[21] = isOpen;
$[22] = isSidebarFullyCollapsed;
$[23] = isSidebarFullyExpanded;
$[24] = t7;
} else t7 = $[24];
const chevronSx = t7;
const shouldJustExpand = groupItem && !collapsed;
const t8 = collapsed ? 0 : 1.4;
const t9 = collapsed ? 60 : 48;
let t10;
if ($[25] !== t8 || $[26] !== t9) {
t10 = {
px: t8,
minHeight: t9
};
$[25] = t8;
$[26] = t9;
$[27] = t10;
} else t10 = $[27];
let t11;
if ($[28] !== disabled || $[29] !== t10) {
t11 = {
disabled,
sx: t10
};
$[28] = disabled;
$[29] = t10;
$[30] = t11;
} else t11 = $[30];
const buttonProps = t11;
let t12;
if ($[31] !== collapsed || $[32] !== item) {
t12 = /* @__PURE__ */ jsx(IconOrAvatar, {
item,
collapsed
});
$[31] = collapsed;
$[32] = item;
$[33] = t12;
} else t12 = $[33];
let t13;
if ($[34] !== collapsed || $[35] !== item.title) {
t13 = !collapsed && /* @__PURE__ */ jsx(ListItemText$1, {
primary: item.title,
sx: {
ml: 1.2,
flex: 1,
minWidth: 0
}
});
$[34] = collapsed;
$[35] = item.title;
$[36] = t13;
} else t13 = $[36];
let t14;
if ($[37] !== chevronSx || $[38] !== groupItem) {
t14 = groupItem ? /* @__PURE__ */ jsx(ExpandMoreIcon, { sx: chevronSx }) : null;
$[37] = chevronSx;
$[38] = groupItem;
$[39] = t14;
} else t14 = $[39];
let t15;
if ($[40] !== t12 || $[41] !== t13 || $[42] !== t14) {
t15 = /* @__PURE__ */ jsxs(Fragment$1, { children: [
t12,
t13,
t14
] });
$[40] = t12;
$[41] = t13;
$[42] = t14;
$[43] = t15;
} else t15 = $[43];
const buttonContent = t15;
T0 = ListItem$1;
if ($[44] !== collapsed || $[45] !== groupItem || $[46] !== miniOpen) {
t3 = groupItem && collapsed ? {
onMouseEnter: () => setMiniOpen(true),
onMouseLeave: () => setMiniOpen(false),
onBlur: (event) => {
if (!event.currentTarget.contains(event.relatedTarget)) setMiniOpen(false);
},
onKeyDown: (event_0) => {
if (event_0.key !== "Escape" || !miniOpen) return;
setMiniOpen(false);
groupButtonRef.current?.focus();
}
} : {};
$[44] = collapsed;
$[45] = groupItem;
$[46] = miniOpen;
$[47] = t3;
} else t3 = $[47];
t4 = "flex-start";
if ($[48] === Symbol.for("react.memo_cache_sentinel")) {
t5 = {
py: 0,
px: 1,
overflowX: "hidden"
};
$[48] = t5;
} else t5 = $[48];
t6 = groupItem ? /* @__PURE__ */ jsx(StyledNavButton, {
...buttonProps,
ref: groupButtonRef,
selected: (collapsed || !isOpen) && containsActive(item),
"aria-expanded": collapsed ? miniOpen : !!isOpen,
onClick: shouldJustExpand ? () => onClick?.(item) : () => setMiniOpen(true),
children: buttonContent
}) : /* @__PURE__ */ jsx(RouterListItemButton, {
...buttonProps,
to: item.to,
href: item.href,
params: item.params,
search: item.search,
activeOptions: {
exact: true,
includeSearch: false
},
activeProps: { selected: true },
onClick: onClose,
sx: [buttonProps.sx, routerButtonSx],
children: buttonContent
});
$[2] = collapsed;
$[3] = disabled;
$[4] = groupItem;
$[5] = isOpen;
$[6] = isSidebarFullyCollapsed;
$[7] = isSidebarFullyExpanded;
$[8] = item;
$[9] = matchRoute;
$[10] = miniOpen;
$[11] = onClick;
$[12] = onClose;
$[13] = T0;
$[14] = itemId;
$[15] = t3;
$[16] = t4;
$[17] = t5;
$[18] = t6;
} else {
T0 = $[13];
itemId = $[14];
t3 = $[15];
t4 = $[16];
t5 = $[17];
t6 = $[18];
}
let t7;
if ($[49] !== collapsed || $[50] !== groupItem || $[51] !== item.children || $[52] !== miniOpen || $[53] !== renderNested) {
t7 = groupItem && collapsed ? /* @__PURE__ */ jsx(MiniPopover, {
open: miniOpen,
children: renderNested?.(item.children)
}) : null;
$[49] = collapsed;
$[50] = groupItem;
$[51] = item.children;
$[52] = miniOpen;
$[53] = renderNested;
$[54] = t7;
} else t7 = $[54];
let t8;
if ($[55] !== T0 || $[56] !== t3 || $[57] !== t4 || $[58] !== t5 || $[59] !== t6 || $[60] !== t7) {
t8 = /* @__PURE__ */ jsxs(T0, {
...t3,
alignItems: t4,
sx: t5,
children: [t6, t7]
});
$[55] = T0;
$[56] = t3;
$[57] = t4;
$[58] = t5;
$[59] = t6;
$[60] = t7;
$[61] = t8;
} else t8 = $[61];
const listItem = t8;
let t9;
if ($[62] !== collapsed || $[63] !== groupItem || $[64] !== isOpen || $[65] !== item.children || $[66] !== renderNested) {
t9 = groupItem && !collapsed ? /* @__PURE__ */ jsx(Collapse, {
in: isOpen,
timeout: "auto",
unmountOnExit: true,
children: renderNested?.(item.children)
}) : null;
$[62] = collapsed;
$[63] = groupItem;
$[64] = isOpen;
$[65] = item.children;
$[66] = renderNested;
$[67] = t9;
} else t9 = $[67];
let t10;
if ($[68] !== itemId || $[69] !== listItem || $[70] !== t9) {
t10 = /* @__PURE__ */ jsxs(Fragment, { children: [listItem, t9] }, itemId);
$[68] = itemId;
$[69] = listItem;
$[70] = t9;
$[71] = t10;
} else t10 = $[71];
return t10;
};
function _temp$5(word) {
return word.charAt(0).toUpperCase();
}
// src/components/core/navigation/NavigationList.tsx
const NavigationList = (t0) => {
const $ = c(26);
const { subNavigation, depth: t1, collapsed, isPopover, isSidebarFullyExpanded: t2, isSidebarFullyCollapsed, renderItem, onClose } = t0;
const depth = t1 === void 0 ? 0 : t1;
const isSidebarFullyExpanded = t2 === void 0 ? true : t2;
let t3;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t3 = [];
$[0] = t3;
} else t3 = $[0];
const [openKeys, setOpenKeys] = useState(t3);
let t4;
let t5;
if ($[1] !== collapsed) {
t4 = () => {
if (collapsed) setOpenKeys([]);
};
t5 = [collapsed];
$[1] = collapsed;
$[2] = t4;
$[3] = t5;
} else {
t4 = $[2];
t5 = $[3];
}
useEffect(t4, t5);
let t6;
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
t6 = (key) => setOpenKeys((previous) => previous.includes(key) ? previous.filter((k) => k !== key) : [...previous, key]);
$[4] = t6;
} else t6 = $[4];
const toggleKey = t6;
let t7;
if ($[5] !== collapsed || $[6] !== depth || $[7] !== onClose) {
t7 = (children) => /* @__PURE__ */ jsx(NavigationList, {
subNavigation: children,
depth: depth + 1,
isPopover: collapsed,
onClose
});
$[5] = collapsed;
$[6] = depth;
$[7] = onClose;
$[8] = t7;
} else t7 = $[8];
const renderNested = t7;
let t8;
if ($[9] !== collapsed || $[10] !== depth || $[11] !== isPopover || $[12] !== isSidebarFullyCollapsed || $[13] !== isSidebarFullyExpanded || $[14] !== onClose || $[15] !== openKeys || $[16] !== renderItem || $[17] !== renderNested || $[18] !== subNavigation) {
const filteredNavigation = subNavigation.filter(_temp$4);
const t9 = isPopover && depth === 1 ? .5 : 0;
const t10 = depth === 0 && !isPopover ? 4 : .5;
const t11 = (isPopover ? 1 : 2) * (isPopover ? depth - 1 : depth);
const t12 = isPopover && depth === 1 ? 240 : "auto";
const t13 = collapsed ? 84 : "auto";
let t14;
if ($[20] !== t10 || $[21] !== t11 || $[22] !== t12 || $[23] !== t13 || $[24] !== t9) {
t14 = {
padding: 0,
mt: t9,
mb: t10,
pl: t11,
minWidth: t12,
width: t13
};
$[20] = t10;
$[21] = t11;
$[22] = t12;
$[23] = t13;
$[24] = t9;
$[25] = t14;
} else t14 = $[25];
t8 = /* @__PURE__ */ jsx(List$1, {
sx: t14,
children: filteredNavigation.map((navItem, index) => {
if (isHeader(navItem)) return /* @__PURE__ */ jsx(ListSubheader$1, {
sx: {
fontSize: 12,
fontWeight: "700",
height: collapsed ? 0 : 40,
px: 2,
overflow: "hidden",
textOverflow: "ellipsis",
whiteSpace: "nowrap",
zIndex: 2,
bgcolor: "transparent",
position: "static"
},
children: navItem.title
}, `subheader-${depth}-${index}`);
if (isDivider(navItem)) {
const nextItem = filteredNavigation[index + 1];
return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(Divider$1, { sx: {
mx: 1,
mt: 1,
mb: nextItem && isHeader(nextItem) && !collapsed ? 0 : 1
} }) }, `divider-${depth}-${index}`);
}
if (!isPageItem(navItem) && !isPageGroup(navItem)) return null;
const key_0 = `item-${depth}-${index}`;
const uniqueItemKey = `${depth}-${index}-${navItem.title}`;
if (renderItem) return /* @__PURE__ */ jsx(Fragment, { children: renderItem(navItem, { collapsed: !!collapsed }) }, key_0);
return /* @__PURE__ */ jsx(NavigationListItem, {
item: navItem,
isOpen: openKeys.includes(uniqueItemKey),
collapsed,
isSidebarFullyExpanded,
isSidebarFullyCollapsed,
onClick: isPageGroup(navItem) && !collapsed ? () => toggleKey(uniqueItemKey) : void 0,
renderNested,
onClose
}, key_0);
})
});
$[9] = collapsed;
$[10] = depth;
$[11] = isPopover;
$[12] = isSidebarFullyCollapsed;
$[13] = isSidebarFullyExpanded;
$[14] = onClose;
$[15] = openKeys;
$[16] = renderItem;
$[17] = renderNested;
$[18] = subNavigation;
$[19] = t8;
} else t8 = $[19];
return t8;
};
function _temp$4(nav) {
return !nav.hidden;
}
// src/components/core/navigation/NavigationContent.tsx
const NavigationContent = (t0) => {
const $ = c(15);
const { navigation, collapsed, expanded, setExpanded, showPermanent } = t0;
const t1 = collapsed ? "stable" : "auto";
const t2 = navigation[0] && isHeader(navigation[0]) && !collapsed ? 0 : 2;
let t3;
if ($[0] !== t1 || $[1] !== t2) {
t3 = {
height: "100%",
display: "flex",
flexDirection: "column",
justifyContent: "space-between",
overflow: "auto",
scrollbarGutter: t1,
overflowX: "hidden",
overflowWrap: "anywhere",
pt: t2
};
$[0] = t1;
$[1] = t2;
$[2] = t3;
} else t3 = $[2];
const t4 = !expanded;
let t5;
if ($[3] !== setExpanded || $[4] !== showPermanent) {
t5 = showPermanent ? void 0 : () => setExpanded(false);
$[3] = setExpanded;
$[4] = showPermanent;
$[5] = t5;
} else t5 = $[5];
let t6;
if ($[6] !== collapsed || $[7] !== expanded || $[8] !== navigation || $[9] !== t4 || $[10] !== t5) {
t6 = /* @__PURE__ */ jsx(NavigationList, {
subNavigation: navigation,
collapsed,
isSidebarFullyExpanded: expanded,
isSidebarFullyCollapsed: t4,
onClose: t5
});
$[6] = collapsed;
$[7] = expanded;
$[8] = navigation;
$[9] = t4;
$[10] = t5;
$[11] = t6;
} else t6 = $[11];
let t7;
if ($[12] !== t3 || $[13] !== t6) {
t7 = /* @__PURE__ */ jsx(Box$1, {
component: "nav",
sx: t3,
children: t6
});
$[12] = t3;
$[13] = t6;
$[14] = t7;
} else t7 = $[14];
return t7;
};
const NavigationRail = (t0) => {
const $ = c(28);
const { navigation, expanded, setExpanded } = t0;
const isMobile = useMediaQuery$1(_temp$3);
let t1;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t1 = {
xs: "none",
sm: "block"
};
$[0] = t1;
} else t1 = $[0];
const t2 = expanded ? 320 : 84;
let t3;
if ($[1] !== expanded) {
t3 = (theme_0) => ({
position: "absolute",
top: `64px`,
height: `calc(100% - 64px)`,
width: expanded ? 320 : 84,
background: "transparent",
borderTop: "1px solid",
borderColor: theme_0.vars?.palette.divider ?? theme_0.palette.divider,
boxShadow: "none"
});
$[1] = expanded;
$[2] = t3;
} else t3 = $[2];
let t4;
if ($[3] !== t2 || $[4] !== t3) {
t4 = {
display: t1,
width: t2,
"& .MuiDrawer-paper": t3
};
$[3] = t2;
$[4] = t3;
$[5] = t4;
} else t4 = $[5];
const t5 = !expanded;
let t6;
if ($[6] !== expanded || $[7] !== navigation || $[8] !== setExpanded || $[9] !== t5) {
t6 = /* @__PURE__ */ jsx(NavigationContent, {
navigation,
collapsed: t5,
expanded,
setExpanded,
showPermanent: true
});
$[6] = expanded;
$[7] = navigation;
$[8] = setExpanded;
$[9] = t5;
$[10] = t6;
} else t6 = $[10];
let t7;
if ($[11] !== t4 || $[12] !== t6) {
t7 = /* @__PURE__ */ jsx(Drawer, {
variant: "permanent",
sx: t4,
children: t6
});
$[11] = t4;
$[12] = t6;
$[13] = t7;
} else t7 = $[13];
const t8 = expanded && isMobile;
let t9;
if ($[14] !== setExpanded) {
t9 = () => setExpanded(false);
$[14] = setExpanded;
$[15] = t9;
} else t9 = $[15];
let t10;
if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
t10 = {
display: {
xs: "block",
sm: "none"
},
"& .MuiDrawer-paper": { width: "min(280px, calc(100vw - 56px))" }
};
$[16] = t10;
} else t10 = $[16];
let t11;
if ($[17] !== expanded || $[18] !== navigation || $[19] !== setExpanded) {
t11 = /* @__PURE__ */ jsx(NavigationContent, {
navigation,
collapsed: false,
expanded,
setExpanded,
showPermanent: false
});
$[17] = expanded;
$[18] = navigation;
$[19] = setExpanded;
$[20] = t11;
} else t11 = $[20];
let t12;
if ($[21] !== t11 || $[22] !== t8 || $[23] !== t9) {
t12 = /* @__PURE__ */ jsx(Drawer, {
open: t8,
onClose: t9,
sx: t10,
children: t11
});
$[21] = t11;
$[22] = t8;
$[23] = t9;
$[24] = t12;
} else t12 = $[24];
let t13;
if ($[25] !== t12 || $[26] !== t7) {
t13 = /* @__PURE__ */ jsxs(Fragment, { children: [t7, t12] });
$[25] = t12;
$[26] = t7;
$[27] = t13;
} else t13 = $[27];
return t13;
};
function _temp$3(theme) {
return theme.breakpoints.down("sm");
}
// src/components/core/TestMascot.tsx
const TEAL = "#1ec8d3";
const SKIN = "#fbe3d1";
const INK = "#17171a";
const EDGE = "#d3dde2";
/**
* Wisby, drawn inline rather than loaded from `public/`: this package ships as
* `dist` only, so a file asset would have to be copied into every consuming
* app. Approximated from the brand artwork — swap the whole <svg> when we have
* the official file, nothing outside this component reads its internals.
*
* White parts carry an explicit stroke: the AppBar is transparent over paper,
* so an unstroked white suit disappears in light mode.
*/
const Wisby = () => {
const $ = c(23);
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t0 = {
xs: 96,
sm: 140
};
$[0] = t0;
} else t0 = $[0];
let t1;
let t2;
let t3;
let t4;
let t5;
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
t1 = {
"0%, 100%": { transform: "translateY(0)" },
"50%": { transform: "translateY(-2.5px)" }
};
t2 = {
"0%, 100%": { transform: "rotate(0deg)" },
"50%": { transform: "rotate(-12deg)" }
};
t3 = {
"0%, 92%, 100%": { transform: "scaleY(1)" },
"95%": { transform: "scaleY(.1)" }
};
t4 = {
transformBox: "view-box",
transformOrigin: "42.5px 78px",
animation: "wisbyWave 1.3s ease-in-out infinite"
};
t5 = {
transformBox: "fill-box",
transformOrigin: "50% 50%",
animation: "wisbyBlink 5.5s ease-in-out infinite"
};
$[1] = t1;
$[2] = t2;
$[3] = t3;
$[4] = t4;
$[5] = t5;
} else {
t1 = $[1];
t2 = $[2];
t3 = $[3];
t4 = $[4];
t5 = $[5];
}
let t10;
let t11;
let t12;
let t13;
let t14;
let t15;
let t16;
let t17;
let t18;
let t19;
let t6;
let t7;
let t8;
let t9;
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
t6 = {
height: t0,
width: "auto",
flexShrink: 0,
display: "block",
filter: "drop-shadow(0 4px 10px rgba(0,0,0,.22))",
animation: "wisbyBob 3.2s ease-in-out infinite",
"@keyframes wisbyBob": t1,
"@keyframes wisbyWave": t2,
"@keyframes wisbyBlink": t3,
"& .wisby-wave-arm": t4,
"& .wisby-eye": t5,
"@media (prefers-reduced-motion: reduce)": {
animation: "none",
"& .wisby-wave-arm, & .wisby-eye": { animation: "none" }
}
};
t7 = /* @__PURE__ */ jsx("ellipse", {
cx: "50",
cy: "109.6",
rx: "15.5",
ry: "2.4",
fill: "#000",
opacity: ".07"
});
t8 = /* @__PURE__ */ jsx("path", {
d: "M62.5 16.6q6-11.8 16.8-9.6Q80.4 18.4 62.5 16.6z",
fill: "#56a832"
});
t9 = /* @__PURE__ */ jsx("path", {
d: "M64.8 15.4q6.8-3.4 12-6.8",
stroke: "#3d7c22",
strokeWidth: "1.1",
strokeLinecap: "round",
fill: "none"
});
t10 = /* @__PURE__ */ jsx("path", {
d: "M37 108.6c0-9.8 12.4-9.8 12.4 0v.6a1.4 1.4 0 0 1-1.4 1.4H38.4a1.4 1.4 0 0 1-1.4-1.4z",
fill: "#fff",
stroke: EDGE,
strokeWidth: ".8"
});
t11 = /* @__PURE__ */ jsx("path", {
d: "M50.6 108.6c0-9.8 12.4-9.8 12.4 0v.6a1.4 1.4 0 0 1-1.4 1.4H52a1.4 1.4 0 0 1-1.4-1.4z",
fill: "#fff",
stroke: EDGE,
strokeWidth: ".8"
});
t12 = /* @__PURE__ */ jsx("rect", {
x: "37",
y: "107.2",
width: "12.4",
height: "3.4",
rx: "1.5",
fill: TEAL
});
t13 = /* @__PURE__ */ jsx("rect", {
x: "50.6",
y: "107.2",
width: "12.4",
height: "3.4",
rx: "1.5",
fill: TEAL
});
t14 = /* @__PURE__ */ jsx("rect", {
x: "40.4",
y: "102.4",
width: "5.4",
height: "1.3",
rx: ".65",
fill: TEAL
});
t15 = /* @__PURE__ */ jsx("rect", {
x: "40.4",
y: "104.8",
width: "5.4",
height: "1.3",
rx: ".65",
fill: TEAL
});
t16 = /* @__PURE__ */ jsx("rect", {
x: "54",
y: "102.4",
width: "5.4",
height: "1.3",
rx: ".65",
fill: TEAL
});
t17 = /* @__PURE__ */ jsx("rect", {
x: "54",
y: "104.8",
width: "5.4",
height: "1.3",
rx: ".65",
fill: TEAL
});
t18 = /* @__PURE__ */ jsx("rect", {
x: "43.4",
y: "86",
width: "3.8",
height: "17",
rx: "1.9",
fill: TEAL
});
t19 = /* @__PURE__ */ jsx("rect", {
x: "52.8",
y: "86",
width: "3.8",
height: "17",
rx: "1.9",
fill: TEAL
});
$[6] = t10;
$[7] = t11;
$[8] = t12;
$[9] = t13;
$[10] = t14;
$[11] = t15;
$[12] = t16;
$[13] = t17;
$[14] = t18;
$[15] = t19;
$[16] = t6;
$[17] = t7;
$[18] = t8;
$[19] = t9;
} else {
t10 = $[6];
t11 = $[7];
t12 = $[8];
t13 = $[9];
t14 = $[10];
t15 = $[11];
t16 = $[12];
t17 = $[13];
t18 = $[14];
t19 = $[15];
t6 = $[16];
t7 = $[17];
t8 = $[18];
t9 = $[19];
}
let t20;
let t21;
if ($[20] === Symbol.for("react.memo_cache_sentinel")) {
t20 = /* @__PURE__ */ jsx("path", {
d: "M42.5 78c-5 1-10-1-17-5",
stroke: EDGE,
strokeWidth: "7",
strokeLinecap: "round",
fill: "none"
});
t21 = /* @__PURE__ */ jsx("path", {
d: "M42.5 78c-5 1-10-1-17-5",
stroke: "#fff",
strokeWidth: "5.4",
strokeLinecap: "round",
fill: "none"
});
$[20] = t20;
$[21] = t21;
} else {
t20 = $[20];
t21 = $[21];
}
let t22;
if ($[22] === Symbol.for("react.memo_cache_sentinel")) {
t22 = /* @__PURE__ */ jsxs(Box, {
component: "svg",
viewBox: "0 0 100 116",
"aria-hidden": true,
sx: t6,
children: [
t7,
t8,
t9,
t10,
t11,
t12,
t13,
t14,
t15,
t16,
t17,
t18,
t19,
/* @__PURE__ */ jsxs("g", {
className: "wisby-wave-arm",
children: [
t20,
t21,
/* @__PURE__ */ jsxs("g", {
transform: "translate(24.5 72) rotate(-20) scale(1.2)",
children: [
/* @__PURE__ */ jsx("rect", {
x: "-4.05",
y: "-8.6",
width: "1.9",
height: "6.2",
rx: ".95",
fill: TEAL
}),
/* @__PURE__ */ jsx("rect", {
x: "-2",
y: "-9.6",
width: "1.9",
height: "7.2",
rx: ".95",
fill: TEAL
}),
/* @__PURE__ */ jsx("rect", {
x: ".05",
y: "-9.2",
width: "1.9",
height: "6.8",
rx: ".95",
fill: TEAL
}),
/* @__PURE__ */ jsx("rect", {
x: "2.1",
y: "-8",
width: "1.9",
height: "5.6",
rx: ".95",
fill: TEAL
}),
/* @__PURE__ */ jsx("rect", {
x: "-6.4",
y: "-4.6",
width: "1.9",
height: "5.4",
rx: ".95",
fill: TEAL,
transform: "rotate(-32 -5.45 -1.9)"
}),
/* @__PURE__ */ jsx("rect", {
x: "-4.6",
y: "-3.4",
width: "9.2",
height: "7.6",
rx: "3.2",
fill: TEAL
}),
/* @__PURE__ */ jsx("path", {
d: "M0 2.5c-2.7-1.9-3.4-3.1-2.7-4.1a1.65 1.65 0 0 1 2.7.2 1.65 1.65 0 0 1 2.7-.2c.7 1 0 2.2-2.7 4.1z",
fill: "#fff"
})
]
})
]
}),
/* @__PURE__ */ jsxs("g", { children: [
/* @__PURE__ */ jsx("path", {
d: "M57.5 78c4.5 2 8 5 10.5 12",
stroke: EDGE,
strokeWidth: "7",
strokeLinecap: "round",
fill: "none"
}),
/* @__PURE__ */ jsx("path", {
d: "M57.5 78c4.5 2 8 5 10.5 12",
stroke: "#fff",
strokeWidth: "5.4",
strokeLinecap: "round",
fill: "none"
}),
/* @__PURE__ */ jsx("circle", {
cx: "64.3",
cy: "88",
r: "1.9",
fill: TEAL
}),
/* @__PURE__ */ jsx("rect", {
x: "63.6",
y: "84.7",
width: "8.8",
height: "11.6",
rx: "4.4",
fill: TEAL
})
] }),
/* @__PURE__ */ jsx("rect", {
x: "40.6",
y: "72",
width: "18.8",
height: "20",
rx: "7",
fill: "#fff",
stroke: EDGE,
strokeWidth: ".9"
}),
/* @__PURE__ */ jsx("rect", {
x: "46.4",
y: "70",
width: "7.2",
height: "3",
rx: "1.2",
fill: "#7ea4ac"
}),
/* @__PURE__ */ jsx("circle", {
cx: "50",
cy: "79.6",
r: "5",
fill: "#eaf7fa"
}),
/* @__PURE__ */ jsx("circle", {
cx: "50",
cy: "79.6",
r: "3.6",
fill: "#7fdfe8"
}),
/* @__PURE__ */ jsx("circle", {
cx: "50",
cy: "79.6",
r: "2.4",
fill: "#0ec6d4"
}),
/* @__PURE__ */ jsx("circle", {
cx: "50",
cy: "42.4",
r: "29.4",
fill: "#e9f6fa",
opacity: ".6"
}),
/* @__PURE__ */ jsx("circle", {
cx: "50",
cy: "42.4",
r: "27.6",
fill: "#f8fcfd",
stroke: "#e0eff4",
strokeWidth: "1.4"
}),
/* @__PURE__ */ jsx("circle", {
cx: "50",
cy: "46",
r: "24",
fill: SKIN
}),
/* @__PURE__ */ jsx("path", {
d: "M27 39a24 24 0 0 1 46 0L68.4 33.5 63.8 39 59.2 33.5 54.6 39 50 33.5 45.4 39 40.8 33.5 36.2 39 31.6 33.5z",
fill: TEAL
}),
/* @__PURE__ */ jsx("path", {
d: "M36.4 41.6q3.6-3 7.6-.6",
stroke: INK,
strokeWidth: "2.6",
strokeLinecap: "round",
fill: "none"
}),
/* @__PURE__ */ jsx("path", {
d: "M56 41q4-2.4 7.6.6",
stroke: INK,
strokeWidth: "2.6",
strokeLinecap: "round",
fill: "none"
}),
/* @__PURE__ */ jsx("ellipse", {
className: "wisby-eye",
cx: "40.4",
cy: "48.4",
rx: "3.8",
ry: "4.7",
fill: INK
}),
/* @__PURE__ */ jsx("ellipse", {
className: "wisby-eye",
cx: "59.6",
cy: "48.4",
rx: "3.8",
ry: "4.7",
fill: INK
}),
/* @__PURE__ */ jsx("circle", {
cx: "41.6",
cy: "46.6",
r: "1.3",
fill: "#fff"
}),
/* @__PURE__ */ jsx("circle", {
cx: "60.8",
cy: "46.6",
r: "1.3",
fill: "#fff"
}),
/* @__PURE__ */ jsx("ellipse", {
cx: "32.6",
cy: "53",
rx: "4.2",
ry: "2.8",
fill: "#f6b3a8",
opacity: ".9"
}),
/* @__PURE__ */ jsx("ellipse", {
cx: "67.4",
cy: "53",
rx: "4.2",
ry: "2.8",
fill: "#f6b3a8",
opacity: ".9"
}),
/* @__PURE__ */ jsx("path", {
d: "M44.8 57.4c3.4-1.6 7-1.6 10.4 0 0 4.8-2.4 6.6-5.2 6.6s-5.2-1.8-5.2-6.6z",
fill: "#e0604c"
}),
/* @__PURE__ */ jsx("path", {
d: "M26.4 36q5-16.4 18.4-21.4-11.4 8.2-14.6 22.6z",
fill: "#fff",
opacity: ".7"
}),
/* @__PURE__ */ jsx("path", {
d: "M36.6 22.3 40.8 20M63.4 22.3 59.2 20",
stroke: "#ffb020",
strokeWidth: "2.6",
strokeLinecap: "round"
}),
/* @__PURE__ */ jsx("circle", {
cx: "72",
cy: "56",
r: "1.2",
fill: "#e53935"
}),
/* @__PURE__ */ jsx("circle", {
cx: "70.2",
cy: "59.4",
r: "1.2",
fill: "#29b6d6"
})
]
});
$[22] = t22;
} else t22 = $[22];
return t22;
};
/**
* Replaces the old TEST chip. Dismissal is component state on purpose: it lasts
* the session but a reload brings him back, so nobody permanently hides the
* fact that they are not on production.
*/
const TestMascot = () => {
const $ = c(10);
const router = useRouter();
const { t } = useTranslation();
const [dismissed, setDismissed] = useState(false);
if (dismissed || !isTestEnv(router.origin)) return null;
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t0 = { env: /* @__PURE__ */ jsx(Box, {
component: "span",
sx: {
color: "warning.main",
fontWeight: 700
}
}) };
$[0] = t0;
} else t0 = $[0];
let t1;
if ($[1] !== t) {
t1 = /* @__PURE__ */ jsx(Trans, {
t,
i18nKey: "Layout.TestEnvironment",
components: t0
});
$[1] = t;
$[2] = t1;
} else t1 = $[2];
let t2;
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
t2 = () => setDismissed(true);
$[3] = t2;
} else t2 = $[3];
let t3;
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
t3 = /* @__PURE__ */ jsx(IconButton, {
size: "small",
"aria-label": "Close",
onClick: t2,
sx: _temp3$1,
children: /* @__PURE__ */ jsx(Close, { sx: { fontSize: 14 } })
});
$[4] = t3;
} else t3 = $[4];
let t4;
if ($[5] !== t1) {
t4 = /* @__PURE__ */ jsxs(Box, {
sx: _temp2$2,
children: [t1, t3]
});
$[5] = t1;
$[6] = t4;
} else t4 = $[6];
let t5;
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
t5 = /* @__PURE__ */ jsx(Wisby, {});
$[7] = t5;
} else t5 = $[7];
let t6;
if ($[8] !== t4) {
t6 = /* @__PURE__ */ jsxs(Box, {
sx: _temp$2,
children: [t4, t5]
});
$[8] = t4;
$[9] = t6;
} else t6 = $[9];
return t6;
};
function _temp$2(theme) {
return {
position: "fixed",
right: {
xs: 4,
sm: 16
},
bottom: 0,
display: "flex",
alignItems: "flex-end",
pointerEvents: "none",
zIndex: theme.zIndex.tooltip
};
}
function _temp2$2(theme_0) {
return {
position: "relative",
mb: {
xs: 5,
sm: 8
},
mr: -1,
px: 1.5,
py: 1,
maxWidth: 190,
borderRadius: 2,
border: "1px solid",
borderColor: "divider",
color: "text.primary",
backgroundColor: theme_0.palette.common.white,
fontSize: 13,
fontWeight: 500,
lineHeight: 1.35,
boxShadow: theme_0.shadows[6],
transformOrigin: "100% 50%",
animation: "wisbyTalk 5s ease-in-out infinite",
...theme_0.applyStyles("dark", { backgroundColor: theme_0.palette.grey[800] }),
"@keyframes wisbyTalk": {
"0%, 86%, 100%": { transform: "scale(1)" },
"91%": { transform: "scale(1.05)" },
"95%": { transform: "scale(.985)" }
},
"@media (prefers-reduced-motion: reduce)": { animation: "none" },
"&::after": {
content: "\"\"",
position: "absolute",
right: -5,
bottom: 14,
width: 9,
height: 9,
transform: "rotate(45deg)",
borderRight: "1px solid",
borderTop: "1px solid",
borderColor: "inherit",
backgroundColor: "inherit"
}
};
}
function _temp3$1(theme_1) {
return {
pointerEvents: "auto",
position: "absolute",
top: -12,
right: -12,
padding: "5px",
border: "1px solid",
borderColor: "divider",
color: "text.primary",
backgroundColor: theme_1.palette.common.white,
"&:hover": { backgroundColor: theme_1.palette.grey[100] },
...theme_1.applyStyles("dark", {
backgroundColor: theme_1.palette.grey[800],
"&:hover": { backgroundColor: theme_1.palette.grey[700] }
})
};
}
// src/components/core/Layout.tsx
const NAVIGATION_STORAGE_KEY = "navigation-open";
const CHAT_STORAGE_KEY = "chat-open";
const getInitialNavigationOpen = () => {
if (Platform.isWindows || Platform.isMacOS) return localStorage.getItem(NAVIGATION_STORAGE_KEY) === "true";
return false;
};
const saveNavigationState = (value) => {
if (Platform.isWindows || Platform.isMacOS) localStorage.setItem(NAVIGATION_STORAGE_KEY, String(value));
};
/** Focuses a non-interactive element without leaving it in the tab or click order. */
const focusTarget = (element) => {
if (!element.hasAttribute("tabindex")) {
element.setAttribute("tabindex", "-1");
element.addEventListener("blur", () => element.removeAttribute("tabindex"), { once: true });
}
element.focus();
};
const DrawerHeader = styled("div")(({ theme }) => ({
display: "flex",
alignItems: "center",
justifyContent: "flex-end",
padding: theme.spacing(0, 1),
...theme.mixins.toolbar
}));
const Layout = (t0) => {
const $ = c(59);
const { navigation, options, children } = t0;
const { t } = useTranslation();
const [navigationOpen, setNavigationOpen] = useState(false);
const [chatOpen, setChatOpen] = useState(false);
let t1;
if ($[0] !== navigation) {
t1 = navigation?.some(_temp$1);
$[0] = navigation;
$[1] = t1;
} else t1 = $[1];
const showNavigation = t1;
let t2;
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
t2 = { select: _temp2$1 };
$[2] = t2;
} else t2 = $[2];
const pathname = useLocation(t2);
const showShell = options?.showShell ?? pathname !== "/login";
let t3;
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
t3 = { from: rootRouteId };
$[3] = t3;
} else t3 = $[3];
const { user } = useMatch(t3).context;
const docked = useMediaQuery(_temp3);
const showChat = Boolean(options?.chat) && showShell && Boolean(user);
const mainRef = useRef(null);
let t4;
let t5;
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
t4 = () => {
if (getInitialNavigationOpen()) setNavigationOpen(true);
};
t5 = [];
$[4] = t4;
$[5] = t5;
} else {
t4 = $[4];
t5 = $[5];
}
useEffect(t4, t5);
let t6;
if ($[6] !== docked) {
t6 = () => {
setChatOpen(docked && localStorage.getItem(CHAT_STORAGE_KEY) !== "false");
};
$[6] = docked;
$[7] = t6;
} else t6 = $[7];
let t7;
if ($[8] !== docked || $[9] !== pathname) {
t7 = [docked, pathname];
$[8] = docked;
$[9] = pathname;
$[10] = t7;
} else t7 = $[10];
useEffect(t6, t7);
let t8;
if ($[11] !== chatOpen || $[12] !== docked) {
t8 = () => {
setChatOpen(!chatOpen);
if (docked) localStorage.setItem(CHAT_STORAGE_KEY, String(!chatOpen));
};
$[11] = chatOpen;
$[12] = docked;
$[13] = t8;
} else t8 = $[13];
const toggleChat = t8;
let t10;
let t9;
if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
t9 = /* @__PURE__ */ jsx(InitColorSchemeScript, {});
t10 = /* @__PURE__ */ jsx(CssBaseline, {});
$[14] = t10;
$[15] = t9;
} else {
t10 = $[14];
t9 = $[15];
}
let t11;
if ($[16] !== showShell) {
t11 = showShell && /* @__PURE__ */ jsx(Box, {
component: "a",
href: "#main-content",
onClick: (event) => {
event.preventDefault();
if (mainRef.current) focusTarget(mainRef.current);
},
sx: {
position: "fixed",
top: 8,
left: 8,
zIndex: "tooltip",
px: 2,
py: 1,
borderRadius: 1,
boxShadow: 3,
bgcolor: "background.paper",
color: "primary.main",
transform: "translateY(-200%)",
"&:focus": { transform: "none" }
},
children: "Skip to content"
});
$[16] = showShell;
$[17] = t11;
} else t11 = $[17];
let t12;
if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
t12 = /* @__PURE__ */ jsx(TestMascot, {});
$[18] = t12;
} else t12 = $[18];
let t13;
if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
t13 = {
display: "flex",
height: "100dvh",
maxHeight: "100dvh",
overflow: "hidden",
width: "100%"
};
$[19] = t13;
} else t13 = $[19];
let t14;
if ($[20] !== chatOpen || $[21] !== navigationOpen || $[22] !== options || $[23] !== showChat || $[24] !== showNavigation || $[25] !== showShell || $[26] !== t || $[27] !== toggleChat) {
t14 = showShell && /* @__PURE__ */ jsx(AppBar, {
color: "transparent",
position: "fixed",
sx: {
borderBottom: "1px solid",
borderColor: "var(--mui-palette-divider)",
boxShadow: "none"
},
children: /* @__PURE__ */ jsxs(Toolbar, { children: [
showNavigation && /* @__PURE__ */ jsx(IconButton, {
"aria-label": "Navigation",
"aria-expanded": navigationOpen,
onClick: () => {
setNavigationOpen(_temp4);
},
sx: { marginRight: 2 },
children: navigationOpen ? /* @__PURE__ */ jsx(MenuOpen, {}) : /* @__PURE__ */ jsx(Menu$1, {})
}),
/* @__PURE__ */ jsx(AppTitle, {}),
options?.appBarActions && /* @__PURE__ */ jsx(Stack, {
direction: "row",
spacing: 1,
sx: {
alignItems: "center",
mr: 1
},
children: options.appBarActions
}),
showChat && /* @__PURE__ */ jsx(Tooltip, {
title: t("Layout.Chat.Assistant"),
children: /* @__PURE__ */ jsx(IconButton, {
"aria-label": "Assistant",
"aria-expanded": chatOpen,
"aria-controls": "layout-chat",
color: chatOpen ? "primary" : "default",
onClick: toggleChat,
sx: { mr: 1 },
children: /* @__PURE__ */ jsx(AutoAwesome, {})
})
}),
/* @__PURE__ */ jsx(ToolbarAccount, {})
] })
});
$[20] = chatOpen;
$[21] = navigationOpen;
$[22] = options;
$[23] = showChat;
$[24] = showNavigation;
$[25] = showShell;
$[26] = t;
$[27] = toggleChat;
$[28] = t14;
} else t14 = $[28];
let t15;
if ($[29] !== navigation || $[30] !== navigationOpen || $[31] !== showNavigation || $[32] !== showShell) {
t15 = showNavigation && showShell && /* @__PURE__ */ jsx(NavigationRail, {
navigation,
expanded: navigationOpen,
setExpanded: (newValue_0) => {
setNavigationOpen(newValue_0);
saveNavigationState(newValue_0);
}
});
$[29] = navigation;
$[30] = navigationOpen;
$[31] = showNavigation;
$[32] = showShell;
$[33] = t15;
} else t15 = $[33];
const t16 = showChat && chatOpen && !docked;
let t17;
if ($[34] === Symbol.for("react.memo_cache_sentinel")) {
t17 = {
flexGrow: 1,
display: "flex",
flexDirection: "column",
minWidth: 0,
height: "100%",
overflow: "hidden"
};
$[34] = t17;
} else t17 = $[34];
let t18;
if ($[35] !== showShell) {
t18 = showShell && /* @__PURE__ */ jsx(DrawerHeader, {});
$[35] = showShell;
$[36] = t18;
} else t18 = $[36];
let t19;
if ($[37] === Symbol.for("react.memo_cache_sentinel")) {
t19 = {
flex: 1,
overflow: "auto",
position: "relative"
};
$[37] = t19;
} else t19 = $[37];
let t20;
if ($[38] !== children) {
t20 = /* @__PURE__ */ jsx(Box, {
sx: t19,
children
});
$[38] = children;
$[39] = t20;
} else t20 = $[39];
let t21;
if ($[40] !== t16 || $[41] !== t18 || $[42] !== t20) {
t21 = /* @__PURE__ */ jsxs(Box, {
component: "main",
id: "main-content",
ref: mainRef,
inert: t16,
sx: t17,
children: [t18, t20]
});
$[40] = t16;
$[41] = t18;
$[42] = t20;
$[43] = t21;
} else t21 = $[43];
let t22;
if ($[44] !== chatOpen || $[45] !== docked || $[46] !== navigationOpen || $[47] !== options?.chat || $[48] !== showChat || $[49] !== showNavigation) {
t22 = showChat && /* @__PURE__ */ jsx(ChatPanel, {
id: "layout-chat",
open: chatOpen,
docked,
rail: showNavigation ? navigationOpen ? 320 : 84 : 0,
children: options?.chat
});
$[44] = chatOpen;
$[45] = docked;
$[46] = navigationOpen;
$[47] = options?.chat;
$[48] = showChat;
$[49] = showNavigation;
$[50] = t22;
} else t22 = $[50];
let t23;
if ($[51] !== t14 || $[52] !== t15 || $[53] !== t21 || $[54] !== t22) {
t23 = /* @__PURE__ */ jsxs(Box, {
sx: t13,
children: [
t14,
t15,
t21,
t22
]
});
$[51] = t14;
$[52] = t15;
$[53] = t21;
$[54] = t22;
$[55] = t23;
} else t23 = $[55];
let t24;
if ($[56] !== t11 || $[57] !== t23) {
t24 = /* @__PURE__ */ jsxs(Fragment, { children: [
t9,
t10,
t11,
t12,
t23
] });
$[56] = t11;
$[57] = t23;
$[58] = t24;
} else t24 = $[58];
return t24;
};
function _temp$1(item) {
return item.hidden !== true;
}
function _temp2$1(location) {
return location.pathname;
}
function _temp3(theme) {
return theme.breakpoints.up("lg");
}
function _temp4(previous) {
const newValue = !previous;
saveNavigationState(newValue);
return newValue;
}
// src/providers/DialogsProvider.tsx
function DialogsProvider({ children }) {
const [stack, setStack] = useState([]);
const keyPrefix = useId();
const nextId = useRef(0);
const dialogMetadata = useRef(/* @__PURE__ */ new WeakMap());
const requestDialog = useEventCallback$1(function open(Component, payload, options = {}) {
const { onClose = async () => {} } = options;
let resolve;
const promise = new Promise((resolveImpl) => {
resolve = resolveImpl;
});
const key = `${keyPrefix}-${nextId.current}`;
nextId.current += 1;
const newEntry = {
key,
open: true,
promise,
Component,
payload,
onClose,
resolve
};
dialogMetadata.current.set(promise, newEntry);
setStack((previousStack) => [...previousStack, newEntry]);
return promise;
});
const removeDialogFromStack = (dialog) => {
setStack((previousStack) => previousStack.filter((entry) => entry.promise !== dialog));
dialogMetadata.current.delete(dialog);
};
const closeDialogUi = useEventCallback$1(function closeDialogUi(dialog) {
setStack((previousStack) => previousStack.map((entry) => entry.promise === dialog ? {
...entry,
open: false
} : entry));
setTimeout(() => removeDialogFromStack(dialog), 1e3);
});
const closeDialog = useEventCallback$1(async function closeDialog(dialog, result) {
const entryToClose = dialogMetadata.current.get(dialog);
if (!entryToClose) throw new Error("Dialog not found in stack");
try {
await entryToClose.onClose(result);
} finally {
entryToClose.resolve(result);
closeDialogUi(dialog);
}
return dialog;
});
return /* @__PURE__ */ jsxs(DialogsContext.Provider, {
value: {
open: requestDialog,
close: closeDialog
},
children: [children, stack.map(({ key, open, Component, payload, promise }) => /* @__PURE__ */ jsx(Component, {
payload,
open,
onClose: async (result) => {
await closeDialog(promise, result);
}
}, key))]
});
}
// src/providers/LayoutProvider.tsx
const YEAR_IN_SECONDS = 31536e3;
const LANGUAGE_COOKIE = "i18next";
const normalizeLocale = (locale) => locale.replace(/[^a-z]/gi, "").toLowerCase();
const zodLocales = new Map(Object.entries(z.core.locales).map(([locale, createLocale]) => [normalizeLocale(locale), createLocale]));
const setLocale = (language) => {
const baseLanguage = language.split(/[-_]/)[0];
const createLocale = zodLocales.get(normalizeLocale(language)) ?? zodLocales.get(normalizeLocale(baseLanguage)) ?? z.core.locales.en;
z.config(createLocale());
if (!dayjs.locale(language).startsWith(baseLanguage)) dayjs.locale("en");
};
i18n.use(LanguageDetector).use(initReactI18next).init({
resources,
lng: typeof document !== "undefined" && document.documentElement.lang || "en",
fallbackLng: "en",
supportedLngs: Object.keys(resources),
detection: { caches: [] },
interpolation: { escapeValue: false }
});
setLocale(i18n.resolvedLanguage ?? i18n.language);
i18n.on("languageChanged", (language) => {
setLocale(language);
if (typeof document !== "undefined") document.cookie = `${LANGUAGE_COOKIE}=${language};path=/;max-age=${YEAR_IN_SECONDS};SameSite=Lax`;
});
const LayoutProvider = (t0) => {
const $ = c(16);
const { options, navigation, theme, children } = t0;
let t1;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t1 = createCache({ key: "css" });
$[0] = t1;
} else t1 = $[0];
const emotionCache = t1;
const { i18n: activeI18n } = useTranslation();
useQuery(userQueryOptions);
let t2;
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
t2 = [];
$[1] = t2;
} else t2 = $[1];
useEffect(_temp, t2);
let t3;
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
t3 = [];
$[2] = t3;
} else t3 = $[2];
useEffect(_temp2, t3);
let t4;
if ($[3] !== activeI18n.language || $[4] !== children) {
t4 = /* @__PURE__ */ jsx(Fragment, { children }, activeI18n.language);
$[3] = activeI18n.language;
$[4] = children;
$[5] = t4;
} else t4 = $[5];
let t5;
if ($[6] !== navigation || $[7] !== options || $[8] !== t4) {
t5 = /* @__PURE__ */ jsx(DialogsProvider, { children: /* @__PURE__ */ jsx(Layout, {
navigation,
options,
children: t4
}) });
$[6] = navigation;
$[7] = options;
$[8] = t4;
$[9] = t5;
} else t5 = $[9];
let t6;
if ($[10] !== activeI18n.language || $[11] !== t5) {
t6 = /* @__PURE__ */ jsx(LocalizationProvider, {
dateAdapter: AdapterDayjs,
adapterLocale: activeI18n.language,
children: t5
});
$[10] = activeI18n.language;
$[11] = t5;
$[12] = t6;
} else t6 = $[12];
let t7;
if ($[13] !== t6 || $[14] !== theme) {
t7 = /* @__PURE__ */ jsx(CacheProvider, {
value: emotionCache,
children: /* @__PURE__ */ jsx(I18nextProvider, {
i18n,
children: /* @__PURE__ */ jsx(ThemeProvider, {
theme,
children: t6
})
})
});
$[13] = t6;
$[14] = theme;
$[15] = t7;
} else t7 = $[15];
return t7;
};
function _temp() {
i18n.changeLanguage();
}
function _temp2() {
if ("serviceWorker" in navigator) navigator.serviceWorker.register("/sw.js");
}
// src/lib/language.ts
/**
* Server-renders the request's language — the `i18next` cookie the browser writes on every
* switch, then `Accept-Language` — so `LayoutProvider`'s language-keyed page hydrates instead
* of being rebuilt when the browser detects a language other than English. No-op in the browser,
* where i18next detects the language itself.
*/
const setLanguageFromRequest = createIsomorphicFn().server(async () => {
const { getCookie, getRequestHeader } = await import("@tanstack/react-start/server");
const accepted = (getRequestHeader("accept-language") ?? "").split(",").map((part) => part.split(";")[0].trim());
const codes = [getCookie("i18next"), ...accepted].filter((code) => !!code);
const language = i18n.services.languageUtils.getBestMatchFromCodes(codes) ?? "en";
if (i18n.language !== language) await i18n.changeLanguage(language);
}).client(async () => {});
export { LayoutProvider, WISTRON_PRIMARY_COLOR, WISTRON_SECONDARY_COLOR, getUser, loginProvidersQueryOptions, rootRouteHead, setLanguageFromRequest };
//# sourceMappingURL=index.mjs.map