@iowas/toolpad 1.0.4 → 1.0.6

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.mjs CHANGED
@@ -1,110 +1,2850 @@
1
- import {
2
- Account,
3
- AccountPopoverFooter,
4
- AccountPopoverHeader,
5
- AccountPreview,
6
- AlertDialog,
7
- ConfirmDialog,
8
- DashboardHeader,
9
- DashboardLayout,
10
- DashboardSidebarPageItem,
11
- PageContainer,
12
- PageHeader,
13
- PageHeaderToolbar,
14
- PromptDialog,
15
- SignInButton,
16
- SignOutButton,
17
- ThemeSwitcher,
18
- ToolbarActions,
19
- useActivePage,
20
- useDialogs,
21
- useNotifications
22
- } from "./chunk-ZXM3V5SD.mjs";
23
- import {
24
- AppProvider,
25
- AuthenticationContext,
26
- DialogsProvider,
27
- LocalizationContext,
28
- LocalizationProvider,
29
- NotificationsProvider,
30
- SessionContext,
31
- en_default,
32
- useLocalStorageState,
33
- useLocaleText,
34
- useStorageState,
35
- useStorageStateServer
36
- } from "./chunk-LUTZBKSG.mjs";
37
- import {
38
- asArray,
39
- equalProperties,
40
- filterKeys,
41
- filterValues,
42
- hasOwnProperty,
43
- mapKeys,
44
- mapProperties,
45
- mapValues,
46
- useBoolean,
47
- usePageTitle
48
- } from "./chunk-PMIWCP25.mjs";
49
- import {
50
- warnOnce
51
- } from "./chunk-F6JD4MSY.mjs";
52
- import {
53
- createGlobalState,
54
- createProvidedContext,
55
- interleave,
56
- useAssertedContext,
57
- useNonNullableContext,
58
- useTraceUpdates
59
- } from "./chunk-3JWXE2JW.mjs";
60
- export {
61
- Account,
62
- AccountPopoverFooter,
63
- AccountPopoverHeader,
64
- AccountPreview,
65
- AlertDialog,
66
- AppProvider,
67
- AuthenticationContext,
68
- ConfirmDialog,
69
- DashboardHeader,
70
- DashboardLayout,
71
- DashboardSidebarPageItem,
72
- DialogsProvider,
73
- LocalizationContext,
74
- LocalizationProvider,
75
- NotificationsProvider,
76
- PageContainer,
77
- PageHeader,
78
- PageHeaderToolbar,
79
- PromptDialog,
80
- SessionContext,
81
- SignInButton,
82
- SignOutButton,
83
- ThemeSwitcher,
84
- ToolbarActions,
85
- asArray,
86
- createGlobalState,
87
- createProvidedContext,
88
- en_default as en,
89
- equalProperties,
90
- filterKeys,
91
- filterValues,
92
- hasOwnProperty,
93
- interleave,
94
- mapKeys,
95
- mapProperties,
96
- mapValues,
97
- useActivePage,
98
- useAssertedContext,
99
- useBoolean,
100
- useDialogs,
101
- useLocalStorageState,
102
- useLocaleText,
103
- useNonNullableContext,
104
- useNotifications,
105
- usePageTitle,
106
- useStorageState,
107
- useStorageStateServer,
108
- useTraceUpdates,
109
- warnOnce
1
+ 'use client';
2
+ import * as React26 from 'react';
3
+ import PropTypes11 from 'prop-types';
4
+ import Popover from '@mui/material/Popover';
5
+ import Divider from '@mui/material/Divider';
6
+ import Stack from '@mui/material/Stack';
7
+ import Button2 from '@mui/material/Button';
8
+ import { styled as styled$1, useTheme, createTheme, ThemeProvider, useColorScheme } from '@mui/material/styles';
9
+ import { styled, useTheme as useTheme$1, Button, IconButton, Snackbar, Badge, Alert, SnackbarContent, useMediaQuery } from '@mui/material';
10
+ import CloseIcon from '@mui/icons-material/Close';
11
+ import useSlotProps from '@mui/utils/useSlotProps';
12
+ import { jsx, jsxs } from 'react/jsx-runtime';
13
+ import 'react-is';
14
+ import Dialog from '@mui/material/Dialog';
15
+ import DialogTitle from '@mui/material/DialogTitle';
16
+ import DialogContent from '@mui/material/DialogContent';
17
+ import DialogActions from '@mui/material/DialogActions';
18
+ import TextField from '@mui/material/TextField';
19
+ import DialogContentText from '@mui/material/DialogContentText';
20
+ import invariant2 from 'invariant';
21
+ import useEventCallback from '@mui/utils/useEventCallback';
22
+ import InitColorSchemeScript from '@mui/material/InitColorSchemeScript';
23
+ import CssBaseline from '@mui/material/CssBaseline';
24
+ import LogoutIcon from '@mui/icons-material/Logout';
25
+ import Avatar from '@mui/material/Avatar';
26
+ import Typography from '@mui/material/Typography';
27
+ import Tooltip from '@mui/material/Tooltip';
28
+ import IconButton2 from '@mui/material/IconButton';
29
+ import MoreVertIcon from '@mui/icons-material/MoreVert';
30
+ import Box4 from '@mui/material/Box';
31
+ import useMediaQuery2 from '@mui/material/useMediaQuery';
32
+ import Drawer from '@mui/material/Drawer';
33
+ import Toolbar2 from '@mui/material/Toolbar';
34
+ import MuiAppBar from '@mui/material/AppBar';
35
+ import MenuIcon from '@mui/icons-material/Menu';
36
+ import MenuOpenIcon from '@mui/icons-material/MenuOpen';
37
+ import DarkModeIcon from '@mui/icons-material/DarkMode';
38
+ import LightModeIcon from '@mui/icons-material/LightMode';
39
+ import List from '@mui/material/List';
40
+ import ListSubheader from '@mui/material/ListSubheader';
41
+ import { pathToRegexp } from 'path-to-regexp';
42
+ import Collapse from '@mui/material/Collapse';
43
+ import Grow from '@mui/material/Grow';
44
+ import ListItem from '@mui/material/ListItem';
45
+ import ListItemButton from '@mui/material/ListItemButton';
46
+ import ListItemIcon from '@mui/material/ListItemIcon';
47
+ import ListItemText from '@mui/material/ListItemText';
48
+ import Paper from '@mui/material/Paper';
49
+ import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
50
+ import Container from '@mui/material/Container';
51
+ import Breadcrumbs from '@mui/material/Breadcrumbs';
52
+ import Link4 from '@mui/material/Link';
53
+ import NextLink from 'next/link.js';
54
+ import { usePathname, useSearchParams, useRouter } from 'next/navigation.js';
55
+
56
+ var __defProp = Object.defineProperty;
57
+ var __defProps = Object.defineProperties;
58
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
59
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
60
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
61
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
62
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
63
+ var __spreadValues = (a, b) => {
64
+ for (var prop in b || (b = {}))
65
+ if (__hasOwnProp.call(b, prop))
66
+ __defNormalProp(a, prop, b[prop]);
67
+ if (__getOwnPropSymbols)
68
+ for (var prop of __getOwnPropSymbols(b)) {
69
+ if (__propIsEnum.call(b, prop))
70
+ __defNormalProp(a, prop, b[prop]);
71
+ }
72
+ return a;
110
73
  };
74
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
75
+ var __objRest = (source, exclude) => {
76
+ var target = {};
77
+ for (var prop in source)
78
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
79
+ target[prop] = source[prop];
80
+ if (source != null && __getOwnPropSymbols)
81
+ for (var prop of __getOwnPropSymbols(source)) {
82
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
83
+ target[prop] = source[prop];
84
+ }
85
+ return target;
86
+ };
87
+ var NotificationsContext = React26.createContext(null);
88
+
89
+ // src/toolpad-core/useNotifications/useNotifications.tsx
90
+ var serverNotifications = {
91
+ show: () => {
92
+ throw new Error("Not supported on server side");
93
+ },
94
+ close: () => {
95
+ throw new Error("Not supported on server side");
96
+ }
97
+ };
98
+ function useNotifications() {
99
+ const context = React26.useContext(NotificationsContext);
100
+ if (context) {
101
+ return context;
102
+ }
103
+ return serverNotifications;
104
+ }
105
+
106
+ // src/toolpad-core/locales/getLocalization.ts
107
+ var getLocalization = (translations) => {
108
+ return {
109
+ components: {
110
+ MuiLocalizationProvider: {
111
+ defaultProps: {
112
+ localeText: __spreadValues({}, translations)
113
+ }
114
+ }
115
+ }
116
+ };
117
+ };
118
+
119
+ // src/toolpad-core/locales/en.tsx
120
+ var enLabels = {
121
+ // Account
122
+ accountSignInLabel: "Sign In",
123
+ accountSignOutLabel: "Sign Out",
124
+ // AccountPreview
125
+ accountPreviewTitle: "Account",
126
+ accountPreviewIconButtonLabel: "Current User",
127
+ // SignInPage
128
+ signInTitle: (brandingTitle) => brandingTitle ? `Sign in to ${brandingTitle}` : "Sign in",
129
+ signInSubtitle: "Welcome user, please sign in to continue",
130
+ signInRememberMe: "Remember Me",
131
+ providerSignInTitle: (provider) => `Sign in with ${provider}`,
132
+ // Common authentication labels
133
+ email: "Email",
134
+ password: "Password",
135
+ username: "Username",
136
+ passkey: "Passkey",
137
+ // Common action labels
138
+ save: "Save",
139
+ cancel: "Cancel",
140
+ ok: "Ok",
141
+ or: "Or",
142
+ to: "To",
143
+ with: "With",
144
+ close: "Close",
145
+ delete: "Delete",
146
+ alert: "Alert",
147
+ confirm: "Confirm",
148
+ loading: "Loading...",
149
+ // CRUD
150
+ createNewButtonLabel: "Create new",
151
+ reloadButtonLabel: "Reload data",
152
+ createLabel: "Create",
153
+ createSuccessMessage: "Item created successfully.",
154
+ createErrorMessage: "Failed to create item. Reason:",
155
+ editLabel: "Edit",
156
+ editSuccessMessage: "Item edited successfully.",
157
+ editErrorMessage: "Failed to edit item. Reason:",
158
+ deleteLabel: "Delete",
159
+ deleteConfirmTitle: "Delete item?",
160
+ deleteConfirmMessage: "Do you wish to delete this item?",
161
+ deleteConfirmLabel: "Delete",
162
+ deleteCancelLabel: "Cancel",
163
+ deleteSuccessMessage: "Item deleted successfully.",
164
+ deleteErrorMessage: "Failed to delete item. Reason:",
165
+ deletedItemMessage: "This item has been deleted."
166
+ };
167
+ var en_default = getLocalization(enLabels);
168
+ var LocalizationContext = React26.createContext({});
169
+ var LocalizationProvider = function LocalizationProvider2(props) {
170
+ var _a, _b, _c;
171
+ const { localeText: propsLocaleText, children } = props;
172
+ const theme = useTheme();
173
+ const themeLocaleText = (_c = (_b = (_a = theme == null ? void 0 : theme.components) == null ? void 0 : _a.MuiLocalizationProvider) == null ? void 0 : _b.defaultProps) == null ? void 0 : _c.localeText;
174
+ const defaultLocaleText3 = en_default.components.MuiLocalizationProvider.defaultProps.localeText;
175
+ const localeText = React26.useMemo(
176
+ () => __spreadValues(__spreadValues(__spreadValues({}, defaultLocaleText3), themeLocaleText), propsLocaleText),
177
+ [defaultLocaleText3, themeLocaleText, propsLocaleText]
178
+ );
179
+ return /* @__PURE__ */ jsx(LocalizationContext.Provider, { value: localeText, children });
180
+ };
181
+ LocalizationProvider.propTypes = {
182
+ // ┌────────────────────────────── Warning ──────────────────────────────┐
183
+ // │ These PropTypes are generated from the TypeScript type definitions. │
184
+ // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
185
+ // └─────────────────────────────────────────────────────────────────────┘
186
+ /**
187
+ * @ignore
188
+ */
189
+ children: PropTypes11.node,
190
+ /**
191
+ * Locale for components texts
192
+ */
193
+ localeText: PropTypes11.object
194
+ };
195
+ function useLocaleText() {
196
+ return React26.useContext(LocalizationContext);
197
+ }
198
+ function useNonNullableContext(context, name) {
199
+ const maybeContext = React26.useContext(context);
200
+ if (maybeContext === null || maybeContext === void 0) {
201
+ throw new Error(`context "${name}" was used without a Provider`);
202
+ }
203
+ return maybeContext;
204
+ }
205
+ var RootPropsContext = React26.createContext(null);
206
+ var defaultLocaleText = {
207
+ close: "Close"
208
+ };
209
+ function Notification({ notificationKey, open, message, options, badge }) {
210
+ var _a, _b, _c;
211
+ const globalLocaleText = useLocaleText();
212
+ const localeText = __spreadValues(__spreadValues({}, defaultLocaleText), globalLocaleText);
213
+ const { close } = useNonNullableContext(NotificationsContext);
214
+ const { severity, actionText, onAction, autoHideDuration } = options;
215
+ const handleClose = React26.useCallback(
216
+ (event, reason) => {
217
+ if (reason === "clickaway") {
218
+ return;
219
+ }
220
+ close(notificationKey);
221
+ },
222
+ [notificationKey, close]
223
+ );
224
+ const action = /* @__PURE__ */ jsxs(React26.Fragment, { children: [
225
+ onAction ? /* @__PURE__ */ jsx(Button, { color: "inherit", size: "small", onClick: onAction, children: actionText != null ? actionText : "Action" }) : null,
226
+ /* @__PURE__ */ jsx(
227
+ IconButton,
228
+ {
229
+ size: "small",
230
+ "aria-label": localeText == null ? void 0 : localeText.close,
231
+ title: localeText == null ? void 0 : localeText.close,
232
+ color: "inherit",
233
+ onClick: handleClose,
234
+ children: /* @__PURE__ */ jsx(CloseIcon, { fontSize: "small" })
235
+ }
236
+ )
237
+ ] });
238
+ const props = React26.useContext(RootPropsContext);
239
+ const SnackbarComponent = (_b = (_a = props == null ? void 0 : props.slots) == null ? void 0 : _a.snackbar) != null ? _b : Snackbar;
240
+ const snackbarSlotProps = useSlotProps({
241
+ elementType: SnackbarComponent,
242
+ ownerState: props,
243
+ externalSlotProps: (_c = props == null ? void 0 : props.slotProps) == null ? void 0 : _c.snackbar,
244
+ additionalProps: {
245
+ open,
246
+ autoHideDuration,
247
+ onClose: handleClose,
248
+ action
249
+ }
250
+ });
251
+ return /* @__PURE__ */ jsx(SnackbarComponent, __spreadProps(__spreadValues({}, snackbarSlotProps), { children: /* @__PURE__ */ jsx(Badge, { badgeContent: badge, color: "primary", sx: { width: "100%" }, children: severity ? /* @__PURE__ */ jsx(Alert, { severity, sx: { width: "100%" }, action, children: message }) : /* @__PURE__ */ jsx(SnackbarContent, { message, action }) }) }), notificationKey);
252
+ }
253
+ function Notifications({ state }) {
254
+ var _a;
255
+ const currentNotification = (_a = state.queue[0]) != null ? _a : null;
256
+ return currentNotification ? /* @__PURE__ */ jsx(
257
+ Notification,
258
+ __spreadProps(__spreadValues({}, currentNotification), {
259
+ badge: state.queue.length > 1 ? String(state.queue.length) : null
260
+ })
261
+ ) : null;
262
+ }
263
+ var nextId = 0;
264
+ var generateId = () => {
265
+ const id = nextId;
266
+ nextId += 1;
267
+ return id;
268
+ };
269
+ function NotificationsProvider(props) {
270
+ const { children } = props;
271
+ const [state, setState] = React26.useState({ queue: [] });
272
+ const show = React26.useCallback((message, options = {}) => {
273
+ var _a;
274
+ const notificationKey = (_a = options.key) != null ? _a : `::toolpad-internal::notification::${generateId()}`;
275
+ setState((prev) => {
276
+ if (prev.queue.some((n) => n.notificationKey === notificationKey)) {
277
+ return prev;
278
+ }
279
+ return __spreadProps(__spreadValues({}, prev), {
280
+ queue: [...prev.queue, { message, options, notificationKey, open: true }]
281
+ });
282
+ });
283
+ return notificationKey;
284
+ }, []);
285
+ const close = React26.useCallback((key) => {
286
+ setState((prev) => __spreadProps(__spreadValues({}, prev), {
287
+ queue: prev.queue.filter((n) => n.notificationKey !== key)
288
+ }));
289
+ }, []);
290
+ const contextValue = React26.useMemo(() => ({ show, close }), [show, close]);
291
+ return /* @__PURE__ */ jsx(RootPropsContext.Provider, { value: props, children: /* @__PURE__ */ jsxs(NotificationsContext.Provider, { value: contextValue, children: [
292
+ children,
293
+ /* @__PURE__ */ jsx(Notifications, { state })
294
+ ] }) });
295
+ }
296
+ var DialogsContext = React26.createContext(null);
297
+ var BrandingContext = React26.createContext(null);
298
+ var NavigationContext = React26.createContext([]);
299
+ var PaletteModeContext = React26.createContext({
300
+ paletteMode: "light",
301
+ setPaletteMode: () => {
302
+ },
303
+ isDualTheme: false
304
+ });
305
+ var RouterContext = React26.createContext(null);
306
+ var DashboardSidebarPageItemContext = React26.createContext(null);
307
+ var WindowContext = React26.createContext(void 0);
308
+ var defaultLocaleText2 = {
309
+ alert: "Alert",
310
+ confirm: "Confirm",
311
+ cancel: "Cancel",
312
+ ok: "Ok"
313
+ };
314
+ function useDialogLoadingButton(onClose) {
315
+ const [loading, setLoading] = React26.useState(false);
316
+ const handleClick = async () => {
317
+ try {
318
+ setLoading(true);
319
+ await onClose();
320
+ } finally {
321
+ setLoading(false);
322
+ }
323
+ };
324
+ return {
325
+ onClick: handleClick,
326
+ loading
327
+ };
328
+ }
329
+ function AlertDialog({ open, payload, onClose }) {
330
+ var _a, _b;
331
+ const appWindowContext = React26.useContext(WindowContext);
332
+ const globalLocaleText = useLocaleText();
333
+ const localeText = __spreadValues(__spreadValues({}, defaultLocaleText2), globalLocaleText);
334
+ const okButtonProps = useDialogLoadingButton(() => onClose());
335
+ return /* @__PURE__ */ jsxs(
336
+ Dialog,
337
+ {
338
+ maxWidth: "xs",
339
+ fullWidth: true,
340
+ open,
341
+ onClose: () => onClose(),
342
+ container: appWindowContext == null ? void 0 : appWindowContext.document.body,
343
+ children: [
344
+ /* @__PURE__ */ jsx(DialogTitle, { children: (_a = payload.title) != null ? _a : localeText.alert }),
345
+ /* @__PURE__ */ jsx(DialogContent, { children: payload.msg }),
346
+ /* @__PURE__ */ jsx(DialogActions, { children: /* @__PURE__ */ jsx(Button2, __spreadProps(__spreadValues({ disabled: !open }, okButtonProps), { children: (_b = payload.okText) != null ? _b : localeText.ok })) })
347
+ ]
348
+ }
349
+ );
350
+ }
351
+ function ConfirmDialog({ open, payload, onClose }) {
352
+ var _a, _b, _c;
353
+ const appWindowContext = React26.useContext(WindowContext);
354
+ const globalLocaleText = useLocaleText();
355
+ const localeText = __spreadValues(__spreadValues({}, defaultLocaleText2), globalLocaleText);
356
+ const cancelButtonProps = useDialogLoadingButton(() => onClose(false));
357
+ const okButtonProps = useDialogLoadingButton(() => onClose(true));
358
+ return /* @__PURE__ */ jsxs(
359
+ Dialog,
360
+ {
361
+ maxWidth: "xs",
362
+ fullWidth: true,
363
+ open,
364
+ onClose: () => onClose(false),
365
+ container: appWindowContext == null ? void 0 : appWindowContext.document.body,
366
+ children: [
367
+ /* @__PURE__ */ jsx(DialogTitle, { children: (_a = payload.title) != null ? _a : localeText.confirm }),
368
+ /* @__PURE__ */ jsx(DialogContent, { children: payload.msg }),
369
+ /* @__PURE__ */ jsxs(DialogActions, { children: [
370
+ /* @__PURE__ */ jsx(Button2, __spreadProps(__spreadValues({ autoFocus: true, disabled: !open }, cancelButtonProps), { children: (_b = payload.cancelText) != null ? _b : localeText.cancel })),
371
+ /* @__PURE__ */ jsx(Button2, __spreadProps(__spreadValues({ color: payload.severity, disabled: !open }, okButtonProps), { children: (_c = payload.okText) != null ? _c : localeText.ok }))
372
+ ] })
373
+ ]
374
+ }
375
+ );
376
+ }
377
+ function PromptDialog({ open, payload, onClose }) {
378
+ var _a, _b, _c;
379
+ const appWindowContext = React26.useContext(WindowContext);
380
+ const globalLocaleText = useLocaleText();
381
+ const localeText = __spreadValues(__spreadValues({}, defaultLocaleText2), globalLocaleText);
382
+ const [input, setInput] = React26.useState("");
383
+ const cancelButtonProps = useDialogLoadingButton(() => onClose(null));
384
+ const [loading, setLoading] = React26.useState(false);
385
+ const name = "input";
386
+ return /* @__PURE__ */ jsxs(
387
+ Dialog,
388
+ {
389
+ maxWidth: "xs",
390
+ fullWidth: true,
391
+ open,
392
+ onClose: () => onClose(null),
393
+ PaperProps: {
394
+ component: "form",
395
+ onSubmit: async (event) => {
396
+ var _a2;
397
+ event.preventDefault();
398
+ try {
399
+ setLoading(true);
400
+ const formData = new FormData(event.currentTarget);
401
+ const value = (_a2 = formData.get(name)) != null ? _a2 : "";
402
+ invariant2(typeof value === "string", "Value must come from a text input");
403
+ await onClose(value);
404
+ } finally {
405
+ setLoading(false);
406
+ }
407
+ }
408
+ },
409
+ container: appWindowContext == null ? void 0 : appWindowContext.document.body,
410
+ children: [
411
+ /* @__PURE__ */ jsx(DialogTitle, { children: (_a = payload.title) != null ? _a : localeText.confirm }),
412
+ /* @__PURE__ */ jsxs(DialogContent, { children: [
413
+ /* @__PURE__ */ jsxs(DialogContentText, { children: [
414
+ payload.msg,
415
+ " "
416
+ ] }),
417
+ /* @__PURE__ */ jsx(
418
+ TextField,
419
+ {
420
+ autoFocus: true,
421
+ required: true,
422
+ margin: "dense",
423
+ id: "name",
424
+ name,
425
+ type: "text",
426
+ fullWidth: true,
427
+ variant: "standard",
428
+ value: input,
429
+ onChange: (event) => setInput(event.target.value)
430
+ }
431
+ )
432
+ ] }),
433
+ /* @__PURE__ */ jsxs(DialogActions, { children: [
434
+ /* @__PURE__ */ jsx(Button2, __spreadProps(__spreadValues({ disabled: !open }, cancelButtonProps), { children: (_b = payload.cancelText) != null ? _b : localeText.cancel })),
435
+ /* @__PURE__ */ jsx(Button2, { disabled: !open, loading, type: "submit", children: (_c = payload.okText) != null ? _c : localeText.ok })
436
+ ] })
437
+ ]
438
+ }
439
+ );
440
+ }
441
+ function useDialogs() {
442
+ const { open, close } = useNonNullableContext(DialogsContext);
443
+ const alert = useEventCallback(
444
+ (msg, _a = {}) => {
445
+ var _b = _a, { onClose } = _b, options = __objRest(_b, ["onClose"]);
446
+ return open(AlertDialog, __spreadProps(__spreadValues({}, options), { msg }), { onClose });
447
+ }
448
+ );
449
+ const confirm = useEventCallback(
450
+ (msg, _c = {}) => {
451
+ var _d = _c, { onClose } = _d, options = __objRest(_d, ["onClose"]);
452
+ return open(ConfirmDialog, __spreadProps(__spreadValues({}, options), { msg }), { onClose });
453
+ }
454
+ );
455
+ const prompt = useEventCallback(
456
+ (msg, _e = {}) => {
457
+ var _f = _e, { onClose } = _f, options = __objRest(_f, ["onClose"]);
458
+ return open(PromptDialog, __spreadProps(__spreadValues({}, options), { msg }), { onClose });
459
+ }
460
+ );
461
+ return React26.useMemo(
462
+ () => ({
463
+ alert,
464
+ confirm,
465
+ prompt,
466
+ open,
467
+ close
468
+ }),
469
+ [alert, close, confirm, open, prompt]
470
+ );
471
+ }
472
+ function DialogsProvider(props) {
473
+ const { children, unmountAfter = 1e3 } = props;
474
+ const [stack, setStack] = React26.useState([]);
475
+ const keyPrefix = React26.useId();
476
+ const nextId2 = React26.useRef(0);
477
+ const dialogMetadata = React26.useRef(/* @__PURE__ */ new WeakMap());
478
+ const requestDialog = useEventCallback(function open(Component, payload, options = {}) {
479
+ const { onClose = async () => {
480
+ } } = options;
481
+ let resolve;
482
+ const promise = new Promise((resolveImpl) => {
483
+ resolve = resolveImpl;
484
+ });
485
+ invariant2(resolve, "resolve not set");
486
+ const key = `${keyPrefix}-${nextId2.current}`;
487
+ nextId2.current += 1;
488
+ const newEntry = {
489
+ key,
490
+ open: true,
491
+ promise,
492
+ Component,
493
+ payload,
494
+ onClose,
495
+ resolve
496
+ };
497
+ dialogMetadata.current.set(promise, newEntry);
498
+ setStack((prevStack) => [...prevStack, newEntry]);
499
+ return promise;
500
+ });
501
+ const closeDialogUi = useEventCallback(function closeDialogUi2(dialog) {
502
+ setStack(
503
+ (prevStack) => prevStack.map((entry) => entry.promise === dialog ? __spreadProps(__spreadValues({}, entry), { open: false }) : entry)
504
+ );
505
+ setTimeout(() => {
506
+ setStack((prevStack) => prevStack.filter((entry) => entry.promise !== dialog));
507
+ }, unmountAfter);
508
+ });
509
+ const closeDialog = useEventCallback(async function closeDialog2(dialog, result) {
510
+ const entryToClose = dialogMetadata.current.get(dialog);
511
+ invariant2(entryToClose, "dialog not found");
512
+ try {
513
+ await entryToClose.onClose(result);
514
+ } finally {
515
+ entryToClose.resolve(result);
516
+ closeDialogUi(dialog);
517
+ }
518
+ return dialog;
519
+ });
520
+ const contextValue = React26.useMemo(
521
+ () => ({ open: requestDialog, close: closeDialog }),
522
+ [requestDialog, closeDialog]
523
+ );
524
+ return /* @__PURE__ */ jsxs(DialogsContext.Provider, { value: contextValue, children: [
525
+ children,
526
+ stack.map(({ key, open, Component, payload, promise }) => /* @__PURE__ */ jsx(
527
+ Component,
528
+ {
529
+ payload,
530
+ open,
531
+ onClose: async (result) => {
532
+ await closeDialog(promise, result);
533
+ }
534
+ },
535
+ key
536
+ ))
537
+ ] });
538
+ }
539
+
540
+ // src/toolpad-core/persistence/codec.tsx
541
+ var CODEC_STRING = {
542
+ parse: (value) => value,
543
+ stringify: (value) => value
544
+ };
545
+
546
+ // src/toolpad-core/persistence/useStorageState.tsx
547
+ var currentTabChangeListeners = /* @__PURE__ */ new Map();
548
+ function onCurrentTabStorageChange(key, handler) {
549
+ let listeners = currentTabChangeListeners.get(key);
550
+ if (!listeners) {
551
+ listeners = /* @__PURE__ */ new Set();
552
+ currentTabChangeListeners.set(key, listeners);
553
+ }
554
+ listeners.add(handler);
555
+ }
556
+ function offCurrentTabStorageChange(key, handler) {
557
+ const listeners = currentTabChangeListeners.get(key);
558
+ if (!listeners) {
559
+ return;
560
+ }
561
+ listeners.delete(handler);
562
+ if (listeners.size === 0) {
563
+ currentTabChangeListeners.delete(key);
564
+ }
565
+ }
566
+ function emitCurrentTabStorageChange(key) {
567
+ const listeners = currentTabChangeListeners.get(key);
568
+ if (listeners) {
569
+ listeners.forEach((listener) => listener());
570
+ }
571
+ }
572
+ if (typeof window !== "undefined") {
573
+ const origSetItem = window.localStorage.setItem;
574
+ window.localStorage.setItem = function setItem(key, value) {
575
+ const result = origSetItem.call(this, key, value);
576
+ emitCurrentTabStorageChange(key);
577
+ return result;
578
+ };
579
+ }
580
+ function subscribe(area, key, callback) {
581
+ if (!key) {
582
+ return () => {
583
+ };
584
+ }
585
+ const storageHandler = (event) => {
586
+ if (event.storageArea === area && event.key === key) {
587
+ callback();
588
+ }
589
+ };
590
+ window.addEventListener("storage", storageHandler);
591
+ onCurrentTabStorageChange(key, callback);
592
+ return () => {
593
+ window.removeEventListener("storage", storageHandler);
594
+ offCurrentTabStorageChange(key, callback);
595
+ };
596
+ }
597
+ function getSnapshot(area, key) {
598
+ if (!key) {
599
+ return null;
600
+ }
601
+ try {
602
+ return area.getItem(key);
603
+ } catch (e) {
604
+ return null;
605
+ }
606
+ }
607
+ function setValue(area, key, value) {
608
+ if (!key) {
609
+ return;
610
+ }
611
+ try {
612
+ if (value === null) {
613
+ area.removeItem(key);
614
+ } else {
615
+ area.setItem(key, String(value));
616
+ }
617
+ } catch (e) {
618
+ return;
619
+ }
620
+ emitCurrentTabStorageChange(key);
621
+ }
622
+ var serverValue = [null, () => {
623
+ }];
624
+ function useStorageStateServer() {
625
+ return serverValue;
626
+ }
627
+ function encode(codec, value) {
628
+ return value === null ? null : codec.stringify(value);
629
+ }
630
+ function decode(codec, value) {
631
+ return value === null ? null : codec.parse(value);
632
+ }
633
+ var getKeyServerSnapshot = () => null;
634
+ function useStorageState(area, key, initializer = null, options) {
635
+ var _a;
636
+ const codec = (_a = options == null ? void 0 : options.codec) != null ? _a : CODEC_STRING;
637
+ const [initialValue] = React26.useState(initializer);
638
+ const encodedInitialValue = React26.useMemo(
639
+ () => encode(codec, initialValue),
640
+ [codec, initialValue]
641
+ );
642
+ const subscribeKey = React26.useCallback(
643
+ (callback) => subscribe(area, key, callback),
644
+ [area, key]
645
+ );
646
+ const getKeySnapshot = React26.useCallback(
647
+ () => {
648
+ var _a2;
649
+ return (_a2 = getSnapshot(area, key)) != null ? _a2 : encodedInitialValue;
650
+ },
651
+ [area, encodedInitialValue, key]
652
+ );
653
+ const encodedStoredValue = React26.useSyncExternalStore(
654
+ subscribeKey,
655
+ getKeySnapshot,
656
+ getKeyServerSnapshot
657
+ );
658
+ const storedValue = React26.useMemo(
659
+ () => decode(codec, encodedStoredValue),
660
+ [codec, encodedStoredValue]
661
+ );
662
+ const setStoredValue = React26.useCallback(
663
+ (value) => {
664
+ const valueToStore = value instanceof Function ? value(storedValue) : value;
665
+ const encodedValueToStore = encode(codec, valueToStore);
666
+ setValue(area, key, encodedValueToStore);
667
+ },
668
+ [area, codec, storedValue, key]
669
+ );
670
+ const [nonStoredValue, setNonStoredValue] = React26.useState(initialValue);
671
+ if (!key) {
672
+ return [nonStoredValue, setNonStoredValue];
673
+ }
674
+ return [storedValue, setStoredValue];
675
+ }
676
+
677
+ // src/toolpad-core/useLocalStorageState/useLocalStorageState.tsx
678
+ var useLocalStorageStateBrowser = (...args) => useStorageState(window.localStorage, ...args);
679
+ var useLocalStorageState = typeof window === "undefined" ? useStorageStateServer : useLocalStorageStateBrowser;
680
+ var COLOR_SCHEME_STORAGE_KEY = "toolpad-color-scheme";
681
+ var MODE_STORAGE_KEY = "toolpad-mode";
682
+ function usePreferredMode(window2) {
683
+ const prefersDarkMode = useMediaQuery(
684
+ "(prefers-color-scheme: dark)",
685
+ window2 && {
686
+ matchMedia: window2.matchMedia
687
+ }
688
+ );
689
+ return prefersDarkMode ? "dark" : "light";
690
+ }
691
+ function isCssVarsTheme(theme) {
692
+ return "vars" in theme;
693
+ }
694
+ function LegacyThemeProvider(props) {
695
+ const { children, theme, window: appWindow } = props;
696
+ invariant2(!isCssVarsTheme(theme), "This provider only accepts legacy themes.");
697
+ const isDualTheme = "light" in theme || "dark" in theme;
698
+ const preferredMode = usePreferredMode(appWindow);
699
+ const [userMode, setUserMode] = useLocalStorageState(MODE_STORAGE_KEY, "system");
700
+ const paletteMode = !userMode || userMode === "system" ? preferredMode : userMode;
701
+ const dualAwareTheme = React26.useMemo(
702
+ () => {
703
+ var _a;
704
+ return isDualTheme ? (_a = theme[paletteMode === "dark" ? "dark" : "light"]) != null ? _a : theme[paletteMode === "dark" ? "light" : "dark"] : theme;
705
+ },
706
+ [isDualTheme, paletteMode, theme]
707
+ );
708
+ const paletteModeContextValue = React26.useMemo(
709
+ () => ({
710
+ paletteMode,
711
+ setPaletteMode: setUserMode,
712
+ isDualTheme
713
+ }),
714
+ [isDualTheme, paletteMode, setUserMode]
715
+ );
716
+ return /* @__PURE__ */ jsx(ThemeProvider, { theme: dualAwareTheme, children: /* @__PURE__ */ jsxs(PaletteModeContext.Provider, { value: paletteModeContextValue, children: [
717
+ /* @__PURE__ */ jsx(CssBaseline, { enableColorScheme: true }),
718
+ children
719
+ ] }) });
720
+ }
721
+ function CssVarsPaletteModeProvider(props) {
722
+ const { children, window: appWindow } = props;
723
+ const preferredMode = usePreferredMode(appWindow);
724
+ const { mode, setMode, allColorSchemes } = useColorScheme();
725
+ const paletteModeContextValue = React26.useMemo(() => {
726
+ return {
727
+ paletteMode: !mode || mode === "system" ? preferredMode : mode,
728
+ setPaletteMode: setMode,
729
+ isDualTheme: allColorSchemes.length > 1
730
+ };
731
+ }, [allColorSchemes, mode, preferredMode, setMode]);
732
+ return /* @__PURE__ */ jsx(PaletteModeContext.Provider, { value: paletteModeContextValue, children });
733
+ }
734
+ function CssVarsThemeProvider(props) {
735
+ const { children, theme, window: appWindow, nonce } = props;
736
+ invariant2(isCssVarsTheme(theme), "This provider only accepts CSS vars themes.");
737
+ return /* @__PURE__ */ jsxs(
738
+ ThemeProvider,
739
+ {
740
+ theme,
741
+ documentNode: appWindow == null ? void 0 : appWindow.document,
742
+ colorSchemeNode: appWindow == null ? void 0 : appWindow.document.documentElement,
743
+ disableNestedContext: true,
744
+ colorSchemeStorageKey: COLOR_SCHEME_STORAGE_KEY,
745
+ modeStorageKey: MODE_STORAGE_KEY,
746
+ children: [
747
+ /* @__PURE__ */ jsx(
748
+ InitColorSchemeScript,
749
+ {
750
+ attribute: theme.colorSchemeSelector,
751
+ colorSchemeStorageKey: COLOR_SCHEME_STORAGE_KEY,
752
+ modeStorageKey: MODE_STORAGE_KEY,
753
+ nonce
754
+ }
755
+ ),
756
+ /* @__PURE__ */ jsxs(CssVarsPaletteModeProvider, { window: appWindow, children: [
757
+ /* @__PURE__ */ jsx(CssBaseline, { enableColorScheme: true }),
758
+ children
759
+ ] })
760
+ ]
761
+ }
762
+ );
763
+ }
764
+ function AppThemeProvider(props) {
765
+ const _a = props, { children, theme } = _a, rest = __objRest(_a, ["children", "theme"]);
766
+ const useCssVarsProvider = isCssVarsTheme(theme);
767
+ return useCssVarsProvider ? /* @__PURE__ */ jsx(CssVarsThemeProvider, __spreadProps(__spreadValues({ theme }, rest), { children })) : /* @__PURE__ */ jsx(LegacyThemeProvider, __spreadProps(__spreadValues({ theme }, rest), { children }));
768
+ }
769
+ var AuthenticationContext = React26.createContext(null);
770
+ var SessionContext = React26.createContext(null);
771
+ function createDefaultTheme() {
772
+ return createTheme({
773
+ cssVariables: {
774
+ colorSchemeSelector: "data-toolpad-color-scheme"
775
+ },
776
+ colorSchemes: { dark: true }
777
+ });
778
+ }
779
+ function AppProvider(props) {
780
+ const {
781
+ children,
782
+ theme = createDefaultTheme(),
783
+ branding = null,
784
+ navigation = [],
785
+ localeText,
786
+ router = null,
787
+ authentication = null,
788
+ session = null,
789
+ window: appWindow,
790
+ nonce
791
+ } = props;
792
+ return /* @__PURE__ */ jsx(WindowContext.Provider, { value: appWindow, children: /* @__PURE__ */ jsx(AuthenticationContext.Provider, { value: authentication, children: /* @__PURE__ */ jsx(SessionContext.Provider, { value: session, children: /* @__PURE__ */ jsx(RouterContext.Provider, { value: router, children: /* @__PURE__ */ jsx(AppThemeProvider, { theme, window: appWindow, nonce, children: /* @__PURE__ */ jsx(LocalizationProvider, { localeText, children: /* @__PURE__ */ jsx(NotificationsProvider, { children: /* @__PURE__ */ jsx(DialogsProvider, { children: /* @__PURE__ */ jsx(BrandingContext.Provider, { value: branding, children: /* @__PURE__ */ jsx(NavigationContext.Provider, { value: navigation, children }) }) }) }) }) }) }) }) }) });
793
+ }
794
+ AppProvider.propTypes = {
795
+ // ┌────────────────────────────── Warning ──────────────────────────────┐
796
+ // │ These PropTypes are generated from the TypeScript type definitions. │
797
+ // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
798
+ // └─────────────────────────────────────────────────────────────────────┘
799
+ /**
800
+ * Authentication methods.
801
+ * @default null
802
+ */
803
+ authentication: PropTypes11.shape({
804
+ signIn: PropTypes11.func.isRequired,
805
+ signOut: PropTypes11.func.isRequired
806
+ }),
807
+ /**
808
+ * Branding options for the app.
809
+ * @default null
810
+ */
811
+ branding: PropTypes11.shape({
812
+ homeUrl: PropTypes11.string,
813
+ logo: PropTypes11.node,
814
+ title: PropTypes11.string
815
+ }),
816
+ /**
817
+ * The content of the app provider.
818
+ */
819
+ children: PropTypes11.node,
820
+ /**
821
+ * Locale text for components
822
+ */
823
+ localeText: PropTypes11.object,
824
+ /**
825
+ * Navigation definition for the app. [Find out more](https://mui.com/toolpad/core/react-app-provider/#navigation).
826
+ * @default []
827
+ */
828
+ navigation: PropTypes11.arrayOf(
829
+ PropTypes11.oneOfType([
830
+ PropTypes11.shape({
831
+ action: PropTypes11.node,
832
+ children: PropTypes11.arrayOf(
833
+ PropTypes11.oneOfType([
834
+ PropTypes11.object,
835
+ PropTypes11.shape({
836
+ kind: PropTypes11.oneOf(["header"]).isRequired,
837
+ title: PropTypes11.string.isRequired
838
+ }),
839
+ PropTypes11.shape({
840
+ kind: PropTypes11.oneOf(["divider"]).isRequired
841
+ })
842
+ ]).isRequired
843
+ ),
844
+ icon: PropTypes11.node,
845
+ kind: PropTypes11.oneOf(["page"]),
846
+ pattern: PropTypes11.string,
847
+ segment: PropTypes11.string,
848
+ title: PropTypes11.string
849
+ }),
850
+ PropTypes11.shape({
851
+ kind: PropTypes11.oneOf(["header"]).isRequired,
852
+ title: PropTypes11.string.isRequired
853
+ }),
854
+ PropTypes11.shape({
855
+ kind: PropTypes11.oneOf(["divider"]).isRequired
856
+ })
857
+ ]).isRequired
858
+ ),
859
+ /**
860
+ * The nonce to be used for inline scripts.
861
+ */
862
+ nonce: PropTypes11.string,
863
+ /**
864
+ * Router implementation used inside Toolpad components.
865
+ * @default null
866
+ */
867
+ router: PropTypes11.shape({
868
+ Link: PropTypes11.elementType,
869
+ navigate: PropTypes11.func.isRequired,
870
+ pathname: PropTypes11.string.isRequired,
871
+ searchParams: PropTypes11.instanceOf(URLSearchParams).isRequired
872
+ }),
873
+ /**
874
+ * Session info about the current user.
875
+ * @default null
876
+ */
877
+ session: PropTypes11.shape({
878
+ user: PropTypes11.shape({
879
+ email: PropTypes11.string,
880
+ id: PropTypes11.string,
881
+ image: PropTypes11.string,
882
+ name: PropTypes11.string
883
+ })
884
+ }),
885
+ /**
886
+ * [Theme or themes](https://mui.com/toolpad/core/react-app-provider/#theming) to be used by the app in light/dark mode. A [CSS variables theme](https://mui.com/material-ui/customization/css-theme-variables/overview/) is recommended.
887
+ * @default createDefaultTheme()
888
+ */
889
+ theme: PropTypes11.object,
890
+ /**
891
+ * The window where the application is rendered.
892
+ * This is needed when rendering the app inside an iframe, for example.
893
+ * @default window
894
+ */
895
+ window: PropTypes11.object
896
+ };
897
+ var AccountLocaleContext = React26.createContext(null);
898
+ function SignInButton(props) {
899
+ const authentication = React26.useContext(AuthenticationContext);
900
+ const globalLocaleText = useLocaleText();
901
+ const accountLocaleText = React26.useContext(AccountLocaleContext);
902
+ const localeText = __spreadValues(__spreadValues({}, globalLocaleText), accountLocaleText);
903
+ return /* @__PURE__ */ jsx(
904
+ Button2,
905
+ __spreadProps(__spreadValues({
906
+ disableElevation: true,
907
+ variant: "contained",
908
+ size: "small",
909
+ onClick: authentication == null ? void 0 : authentication.signIn,
910
+ sx: {
911
+ textTransform: "capitalize",
912
+ filter: "opacity(0.9)",
913
+ width: "50%",
914
+ margin: (theme) => `${theme.spacing(1)} auto`,
915
+ transition: "filter 0.2s ease-in",
916
+ "&:hover": {
917
+ filter: "opacity(1)"
918
+ }
919
+ }
920
+ }, props), {
921
+ children: localeText == null ? void 0 : localeText.accountSignInLabel
922
+ })
923
+ );
924
+ }
925
+ SignInButton.propTypes = {
926
+ // ┌────────────────────────────── Warning ──────────────────────────────┐
927
+ // │ These PropTypes are generated from the TypeScript type definitions. │
928
+ // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
929
+ // └─────────────────────────────────────────────────────────────────────┘
930
+ /**
931
+ * The content of the component.
932
+ */
933
+ children: PropTypes11.node
934
+ };
935
+ function SignOutButton(props) {
936
+ const authentication = React26.useContext(AuthenticationContext);
937
+ const globalLocaleText = useLocaleText();
938
+ const accountLocaleText = React26.useContext(AccountLocaleContext);
939
+ const localeText = __spreadValues(__spreadValues({}, globalLocaleText), accountLocaleText);
940
+ return /* @__PURE__ */ jsx(
941
+ Button2,
942
+ __spreadProps(__spreadValues({
943
+ disabled: !authentication,
944
+ variant: "outlined",
945
+ size: "small",
946
+ disableElevation: true,
947
+ onClick: authentication == null ? void 0 : authentication.signOut,
948
+ sx: {
949
+ textTransform: "capitalize",
950
+ fontWeight: "normal",
951
+ filter: "opacity(0.9)",
952
+ transition: "filter 0.2s ease-in",
953
+ "&:hover": {
954
+ filter: "opacity(1)"
955
+ }
956
+ },
957
+ startIcon: /* @__PURE__ */ jsx(LogoutIcon, {})
958
+ }, props), {
959
+ children: localeText == null ? void 0 : localeText.accountSignOutLabel
960
+ })
961
+ );
962
+ }
963
+ SignOutButton.propTypes = {
964
+ // ┌────────────────────────────── Warning ──────────────────────────────┐
965
+ // │ These PropTypes are generated from the TypeScript type definitions. │
966
+ // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
967
+ // └─────────────────────────────────────────────────────────────────────┘
968
+ /**
969
+ * The content of the component.
970
+ */
971
+ children: PropTypes11.node
972
+ };
973
+ function AccountPreview(props) {
974
+ var _a, _b, _c, _d, _e, _f, _g, _h;
975
+ const { slots, variant = "condensed", slotProps, open, handleClick, sx } = props;
976
+ const session = React26.useContext(SessionContext);
977
+ const globalLocaleText = useLocaleText();
978
+ const accountLocaleText = React26.useContext(AccountLocaleContext);
979
+ const localeText = __spreadValues(__spreadValues({}, globalLocaleText), accountLocaleText);
980
+ if (!session || !session.user) {
981
+ return null;
982
+ }
983
+ const avatarContent = (slots == null ? void 0 : slots.avatar) ? /* @__PURE__ */ jsx(slots.avatar, {}) : /* @__PURE__ */ jsx(
984
+ Avatar,
985
+ __spreadValues({
986
+ src: ((_a = session.user) == null ? void 0 : _a.image) || "",
987
+ alt: ((_b = session.user) == null ? void 0 : _b.name) || ((_c = session.user) == null ? void 0 : _c.email) || "",
988
+ sx: { height: variant === "expanded" ? 48 : 32, width: variant === "expanded" ? 48 : 32 }
989
+ }, slotProps == null ? void 0 : slotProps.avatar)
990
+ );
991
+ if (variant === "expanded") {
992
+ return /* @__PURE__ */ jsxs(Stack, { direction: "row", justifyContent: "space-between", sx: __spreadValues({ py: 1, px: 2, gap: 2 }, sx), children: [
993
+ /* @__PURE__ */ jsxs(Stack, { direction: "row", justifyContent: "flex-start", spacing: 2, overflow: "hidden", children: [
994
+ avatarContent,
995
+ /* @__PURE__ */ jsxs(Stack, { direction: "column", justifyContent: "space-evenly", overflow: "hidden", children: [
996
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", fontWeight: "bolder", noWrap: true, children: (_d = session.user) == null ? void 0 : _d.name }),
997
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", noWrap: true, children: (_e = session.user) == null ? void 0 : _e.email })
998
+ ] })
999
+ ] }),
1000
+ handleClick && ((slots == null ? void 0 : slots.moreIconButton) ? /* @__PURE__ */ jsx(slots.moreIconButton, {}) : /* @__PURE__ */ jsx(
1001
+ IconButton2,
1002
+ __spreadProps(__spreadValues({
1003
+ size: "small",
1004
+ onClick: handleClick
1005
+ }, slotProps == null ? void 0 : slotProps.moreIconButton), {
1006
+ sx: __spreadValues({ alignSelf: "center" }, (_f = slotProps == null ? void 0 : slotProps.moreIconButton) == null ? void 0 : _f.sx),
1007
+ children: /* @__PURE__ */ jsx(MoreVertIcon, { fontSize: "small" })
1008
+ })
1009
+ ))
1010
+ ] });
1011
+ }
1012
+ return /* @__PURE__ */ jsx(Tooltip, { title: (_g = session.user.name) != null ? _g : accountLocaleText == null ? void 0 : accountLocaleText.accountPreviewTitle, children: (slots == null ? void 0 : slots.avatarIconButton) ? /* @__PURE__ */ jsx(slots.avatarIconButton, __spreadValues({}, slotProps == null ? void 0 : slotProps.avatarIconButton)) : /* @__PURE__ */ jsx(Stack, { sx: __spreadValues({ py: 0.5 }, sx), children: /* @__PURE__ */ jsx(
1013
+ IconButton2,
1014
+ __spreadProps(__spreadValues({
1015
+ onClick: handleClick,
1016
+ "aria-label": localeText == null ? void 0 : localeText.accountPreviewIconButtonLabel,
1017
+ size: "small",
1018
+ "aria-controls": open ? "account-menu" : void 0,
1019
+ "aria-haspopup": "true",
1020
+ "aria-expanded": open ? "true" : void 0
1021
+ }, slotProps == null ? void 0 : slotProps.avatarIconButton), {
1022
+ sx: __spreadValues({ width: "fit-content", margin: "0 auto" }, (_h = slotProps == null ? void 0 : slotProps.avatarIconButton) == null ? void 0 : _h.sx),
1023
+ children: avatarContent
1024
+ })
1025
+ ) }) });
1026
+ }
1027
+ AccountPreview.propTypes = {
1028
+ // ┌────────────────────────────── Warning ──────────────────────────────┐
1029
+ // │ These PropTypes are generated from the TypeScript type definitions. │
1030
+ // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
1031
+ // └─────────────────────────────────────────────────────────────────────┘
1032
+ /**
1033
+ * The handler used when the preview is expanded
1034
+ */
1035
+ handleClick: PropTypes11.func,
1036
+ /**
1037
+ * The state of the Account popover
1038
+ * @default false
1039
+ */
1040
+ open: PropTypes11.bool,
1041
+ /**
1042
+ * The props used for each slot inside.
1043
+ */
1044
+ slotProps: PropTypes11.shape({
1045
+ avatar: PropTypes11.object,
1046
+ avatarIconButton: PropTypes11.object,
1047
+ moreIconButton: PropTypes11.object
1048
+ }),
1049
+ /**
1050
+ * The components used for each slot inside.
1051
+ */
1052
+ slots: PropTypes11.shape({
1053
+ avatar: PropTypes11.elementType,
1054
+ avatarIconButton: PropTypes11.elementType,
1055
+ moreIconButton: PropTypes11.elementType
1056
+ }),
1057
+ /**
1058
+ * The prop used to customize the styling of the preview
1059
+ */
1060
+ sx: PropTypes11.oneOfType([
1061
+ PropTypes11.arrayOf(PropTypes11.oneOfType([PropTypes11.func, PropTypes11.object, PropTypes11.bool])),
1062
+ PropTypes11.func,
1063
+ PropTypes11.object
1064
+ ]),
1065
+ /**
1066
+ * The type of account details to display.
1067
+ * @property {'condensed'} condensed - Shows only the user's avatar.
1068
+ * @property {'expanded'} expanded - Displays the user's avatar, name, and email if available.
1069
+ * @default 'condensed'
1070
+ */
1071
+ variant: PropTypes11.oneOf(["condensed", "expanded"])
1072
+ };
1073
+ function AccountPopoverHeader(props) {
1074
+ const _a = props, { children } = _a, rest = __objRest(_a, ["children"]);
1075
+ return /* @__PURE__ */ jsx(Stack, __spreadProps(__spreadValues({}, rest), { children }));
1076
+ }
1077
+ AccountPopoverHeader.propTypes = {
1078
+ // ┌────────────────────────────── Warning ──────────────────────────────┐
1079
+ // │ These PropTypes are generated from the TypeScript type definitions. │
1080
+ // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
1081
+ // └─────────────────────────────────────────────────────────────────────┘
1082
+ /**
1083
+ * The content of the component.
1084
+ */
1085
+ children: PropTypes11.node
1086
+ };
1087
+ function AccountPopoverFooter(props) {
1088
+ const _a = props, { children } = _a, rest = __objRest(_a, ["children"]);
1089
+ return /* @__PURE__ */ jsx(
1090
+ Box4,
1091
+ __spreadProps(__spreadValues({}, rest), {
1092
+ sx: __spreadValues({ display: "flex", flexDirection: "row", p: 1, justifyContent: "flex-end" }, rest.sx),
1093
+ children
1094
+ })
1095
+ );
1096
+ }
1097
+ AccountPopoverFooter.propTypes = {
1098
+ // ┌────────────────────────────── Warning ──────────────────────────────┐
1099
+ // │ These PropTypes are generated from the TypeScript type definitions. │
1100
+ // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
1101
+ // └─────────────────────────────────────────────────────────────────────┘
1102
+ /**
1103
+ * @ignore
1104
+ */
1105
+ children: PropTypes11.node,
1106
+ /**
1107
+ * The system prop that allows defining system overrides as well as additional CSS styles.
1108
+ */
1109
+ sx: PropTypes11.oneOfType([
1110
+ PropTypes11.arrayOf(PropTypes11.oneOfType([PropTypes11.func, PropTypes11.object, PropTypes11.bool])),
1111
+ PropTypes11.func,
1112
+ PropTypes11.object
1113
+ ])
1114
+ };
1115
+ var defaultAccountLocaleText = {
1116
+ accountPreviewIconButtonLabel: "Current User",
1117
+ accountPreviewTitle: "Account",
1118
+ accountSignInLabel: "Sign in",
1119
+ accountSignOutLabel: "Sign out"
1120
+ };
1121
+ function Account(props) {
1122
+ var _a;
1123
+ const { localeText: propsLocaleText } = props;
1124
+ const globalLocaleText = useLocaleText();
1125
+ const localeText = React26.useMemo(
1126
+ () => __spreadValues(__spreadValues(__spreadValues({}, defaultAccountLocaleText), globalLocaleText), propsLocaleText),
1127
+ [globalLocaleText, propsLocaleText]
1128
+ );
1129
+ const { slots, slotProps } = props;
1130
+ const [anchorEl, setAnchorEl] = React26.useState(null);
1131
+ const session = React26.useContext(SessionContext);
1132
+ const authentication = React26.useContext(AuthenticationContext);
1133
+ const open = Boolean(anchorEl);
1134
+ const handleClick = (event) => {
1135
+ setAnchorEl(event.currentTarget);
1136
+ };
1137
+ const handleClose = () => {
1138
+ setAnchorEl(null);
1139
+ };
1140
+ if (!authentication) {
1141
+ return null;
1142
+ }
1143
+ let accountContent = null;
1144
+ if (!(session == null ? void 0 : session.user)) {
1145
+ accountContent = (slots == null ? void 0 : slots.signInButton) ? /* @__PURE__ */ jsx(slots.signInButton, { onClick: authentication.signIn }) : /* @__PURE__ */ jsx(SignInButton, __spreadValues({}, slotProps == null ? void 0 : slotProps.signInButton));
1146
+ } else {
1147
+ accountContent = /* @__PURE__ */ jsxs(React26.Fragment, { children: [
1148
+ (slots == null ? void 0 : slots.preview) ? /* @__PURE__ */ jsx(slots.preview, { handleClick, open }) : /* @__PURE__ */ jsx(
1149
+ AccountPreview,
1150
+ __spreadValues({
1151
+ variant: "condensed",
1152
+ handleClick,
1153
+ open
1154
+ }, slotProps == null ? void 0 : slotProps.preview)
1155
+ ),
1156
+ (slots == null ? void 0 : slots.popover) ? /* @__PURE__ */ jsx(
1157
+ slots.popover,
1158
+ __spreadValues({
1159
+ open,
1160
+ onClick: handleClick,
1161
+ onClose: handleClose
1162
+ }, slotProps == null ? void 0 : slotProps.popover)
1163
+ ) : /* @__PURE__ */ jsx(
1164
+ Popover,
1165
+ __spreadProps(__spreadValues({
1166
+ anchorEl,
1167
+ id: "account-menu",
1168
+ open,
1169
+ onClose: handleClose,
1170
+ onClick: handleClose,
1171
+ transformOrigin: { horizontal: "right", vertical: "top" },
1172
+ anchorOrigin: { horizontal: "right", vertical: "bottom" }
1173
+ }, slotProps == null ? void 0 : slotProps.popover), {
1174
+ slotProps: __spreadValues({
1175
+ paper: {
1176
+ elevation: 0,
1177
+ sx: {
1178
+ overflow: "visible",
1179
+ filter: (theme) => `drop-shadow(0px 2px 8px ${theme.palette.mode === "dark" ? "rgba(255,255,255,0.10)" : "rgba(0,0,0,0.32)"})`,
1180
+ mt: 1,
1181
+ "&::before": {
1182
+ content: '""',
1183
+ display: "block",
1184
+ position: "absolute",
1185
+ top: 0,
1186
+ right: 14,
1187
+ width: 10,
1188
+ height: 10,
1189
+ bgcolor: "background.paper",
1190
+ transform: "translateY(-50%) rotate(45deg)",
1191
+ zIndex: 0
1192
+ }
1193
+ }
1194
+ }
1195
+ }, (_a = slotProps == null ? void 0 : slotProps.popover) == null ? void 0 : _a.slotProps),
1196
+ children: (slots == null ? void 0 : slots.popoverContent) ? /* @__PURE__ */ jsx(slots.popoverContent, __spreadValues({}, slotProps == null ? void 0 : slotProps.popoverContent)) : /* @__PURE__ */ jsxs(Stack, __spreadProps(__spreadValues({ direction: "column" }, slotProps == null ? void 0 : slotProps.popoverContent), { children: [
1197
+ /* @__PURE__ */ jsx(AccountPopoverHeader, { children: /* @__PURE__ */ jsx(AccountPreview, { variant: "expanded" }) }),
1198
+ /* @__PURE__ */ jsx(Divider, {}),
1199
+ /* @__PURE__ */ jsx(AccountPopoverFooter, { children: /* @__PURE__ */ jsx(SignOutButton, __spreadValues({}, slotProps == null ? void 0 : slotProps.signOutButton)) })
1200
+ ] }))
1201
+ })
1202
+ )
1203
+ ] });
1204
+ }
1205
+ return /* @__PURE__ */ jsx(AccountLocaleContext.Provider, { value: localeText, children: accountContent });
1206
+ }
1207
+ Account.propTypes = {
1208
+ // ┌────────────────────────────── Warning ──────────────────────────────┐
1209
+ // │ These PropTypes are generated from the TypeScript type definitions. │
1210
+ // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
1211
+ // └─────────────────────────────────────────────────────────────────────┘
1212
+ /**
1213
+ * The labels for the account component.
1214
+ */
1215
+ localeText: PropTypes11.object,
1216
+ /**
1217
+ * The props used for each slot inside.
1218
+ */
1219
+ slotProps: PropTypes11.shape({
1220
+ popover: PropTypes11.object,
1221
+ popoverContent: PropTypes11.object,
1222
+ preview: PropTypes11.shape({
1223
+ handleClick: PropTypes11.func,
1224
+ open: PropTypes11.bool,
1225
+ slotProps: PropTypes11.shape({
1226
+ avatar: PropTypes11.object,
1227
+ avatarIconButton: PropTypes11.object,
1228
+ moreIconButton: PropTypes11.object
1229
+ }),
1230
+ slots: PropTypes11.shape({
1231
+ avatar: PropTypes11.elementType,
1232
+ avatarIconButton: PropTypes11.elementType,
1233
+ moreIconButton: PropTypes11.elementType
1234
+ }),
1235
+ sx: PropTypes11.oneOfType([
1236
+ PropTypes11.arrayOf(PropTypes11.oneOfType([PropTypes11.func, PropTypes11.object, PropTypes11.bool])),
1237
+ PropTypes11.func,
1238
+ PropTypes11.object
1239
+ ]),
1240
+ variant: PropTypes11.oneOf(["condensed", "expanded"])
1241
+ }),
1242
+ signInButton: PropTypes11.object,
1243
+ signOutButton: PropTypes11.object
1244
+ }),
1245
+ /**
1246
+ * The components used for each slot inside.
1247
+ */
1248
+ slots: PropTypes11.shape({
1249
+ popover: PropTypes11.elementType,
1250
+ popoverContent: PropTypes11.elementType,
1251
+ preview: PropTypes11.elementType,
1252
+ signInButton: PropTypes11.elementType,
1253
+ signOutButton: PropTypes11.elementType
1254
+ })
1255
+ };
1256
+ var DefaultLink = React26.forwardRef(function Link(props, ref) {
1257
+ const _a = props, { children, href, onClick, history: history2 } = _a, rest = __objRest(_a, ["children", "href", "onClick", "history"]);
1258
+ const routerContext = React26.useContext(RouterContext);
1259
+ const handleLinkClick = React26.useMemo(() => {
1260
+ if (!routerContext) {
1261
+ return onClick;
1262
+ }
1263
+ return (event) => {
1264
+ event.preventDefault();
1265
+ const url = new URL(event.currentTarget.href);
1266
+ routerContext.navigate(url.pathname, { history: history2 });
1267
+ onClick == null ? void 0 : onClick(event);
1268
+ };
1269
+ }, [routerContext, onClick, history2]);
1270
+ return /* @__PURE__ */ jsx("a", __spreadProps(__spreadValues({ ref, href }, rest), { onClick: handleLinkClick, children }));
1271
+ });
1272
+ var Link2 = React26.forwardRef(function Link3(props, ref) {
1273
+ var _a;
1274
+ const routerContext = React26.useContext(RouterContext);
1275
+ const LinkComponent = (_a = routerContext == null ? void 0 : routerContext.Link) != null ? _a : DefaultLink;
1276
+ return /* @__PURE__ */ jsx(LinkComponent, __spreadProps(__spreadValues({ ref }, props), { children: props.children }));
1277
+ });
1278
+ function ToolpadLogo({ size = 40 }) {
1279
+ return /* @__PURE__ */ jsxs("svg", { width: size, height: size, fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
1280
+ /* @__PURE__ */ jsxs("g", { mask: "url(#a)", children: [
1281
+ /* @__PURE__ */ jsx("path", { d: "M22.74 27.73v-7.6l6.64-3.79v7.6l-6.64 3.79Z", fill: "#007FFF" }),
1282
+ /* @__PURE__ */ jsx("path", { d: "M16.1 23.93v-7.59l6.64 3.8v7.59l-6.65-3.8Z", fill: "#39F" }),
1283
+ /* @__PURE__ */ jsx("path", { d: "m16.1 16.34 6.64-3.8 6.64 3.8-6.64 3.8-6.65-3.8Z", fill: "#A5D8FF" })
1284
+ ] }),
1285
+ /* @__PURE__ */ jsx(
1286
+ "mask",
1287
+ {
1288
+ id: "b",
1289
+ style: {
1290
+ maskType: "alpha"
1291
+ },
1292
+ maskUnits: "userSpaceOnUse",
1293
+ x: "8",
1294
+ y: "17",
1295
+ width: "14",
1296
+ height: "15",
1297
+ children: /* @__PURE__ */ jsx(
1298
+ "path",
1299
+ {
1300
+ d: "M8.5 22.3c0-1.05.56-2 1.46-2.53l3.75-2.14c.89-.5 1.98-.5 2.87 0l3.75 2.14a2.9 2.9 0 0 1 1.46 2.52v4.23c0 1.04-.56 2-1.46 2.52l-3.75 2.14c-.89.5-1.98.5-2.87 0l-3.75-2.14a2.9 2.9 0 0 1-1.46-2.52v-4.23Z",
1301
+ fill: "#D7DCE1"
1302
+ }
1303
+ )
1304
+ }
1305
+ ),
1306
+ /* @__PURE__ */ jsxs("g", { mask: "url(#b)", children: [
1307
+ /* @__PURE__ */ jsx("path", { d: "M15.14 32v-7.6l6.65-3.8v7.6L15.14 32Z", fill: "#007FFF" }),
1308
+ /* @__PURE__ */ jsx("path", { d: "M8.5 28.2v-7.6l6.64 3.8V32L8.5 28.2Z", fill: "#39F" }),
1309
+ /* @__PURE__ */ jsx("path", { d: "m8.5 20.6 6.64-3.79 6.65 3.8-6.65 3.8-6.64-3.8Z", fill: "#A5D8FF" })
1310
+ ] }),
1311
+ /* @__PURE__ */ jsx(
1312
+ "mask",
1313
+ {
1314
+ id: "c",
1315
+ style: {
1316
+ maskType: "alpha"
1317
+ },
1318
+ maskUnits: "userSpaceOnUse",
1319
+ x: "8",
1320
+ y: "4",
1321
+ width: "22",
1322
+ height: "20",
1323
+ children: /* @__PURE__ */ jsx(
1324
+ "path",
1325
+ {
1326
+ d: "M24.17 4.82a2.9 2.9 0 0 0-2.87 0L9.97 11.22a2.9 2.9 0 0 0-1.47 2.53v4.22c0 1.04.56 2 1.46 2.52l3.75 2.14c.89.5 1.98.5 2.87 0l11.33-6.42a2.9 2.9 0 0 0 1.47-2.52V9.48c0-1.04-.56-2-1.46-2.52l-3.75-2.14Z",
1327
+ fill: "#D7DCE1"
1328
+ }
1329
+ )
1330
+ }
1331
+ ),
1332
+ /* @__PURE__ */ jsxs("g", { mask: "url(#c)", children: [
1333
+ /* @__PURE__ */ jsx("path", { d: "M15.14 23.46v-7.6L29.38 7.8v7.59l-14.24 8.07Z", fill: "#007FFF" }),
1334
+ /* @__PURE__ */ jsx("path", { d: "M8.5 19.66v-7.6l6.64 3.8v7.6l-6.64-3.8Z", fill: "#39F" }),
1335
+ /* @__PURE__ */ jsx("path", { d: "M8.5 12.07 22.74 4l6.64 3.8-14.24 8.06-6.64-3.8Z", fill: "#A5D8FF" })
1336
+ ] })
1337
+ ] });
1338
+ }
1339
+ function useApplicationTitle() {
1340
+ var _a;
1341
+ const branding = React26.useContext(BrandingContext);
1342
+ return (_a = branding == null ? void 0 : branding.title) != null ? _a : "Toolpad";
1343
+ }
1344
+ var LogoContainer = styled("div")({
1345
+ position: "relative",
1346
+ height: 40,
1347
+ display: "flex",
1348
+ alignItems: "center",
1349
+ "& img": {
1350
+ maxHeight: 40
1351
+ }
1352
+ });
1353
+ function AppTitle(props) {
1354
+ var _a, _b, _c, _d, _e, _f, _g;
1355
+ const theme = useTheme$1();
1356
+ const defaultTitle = useApplicationTitle();
1357
+ const title = (_b = (_a = props == null ? void 0 : props.branding) == null ? void 0 : _a.title) != null ? _b : defaultTitle;
1358
+ return /* @__PURE__ */ jsx(Link2, { href: (_d = (_c = props == null ? void 0 : props.branding) == null ? void 0 : _c.homeUrl) != null ? _d : "/", style: { textDecoration: "none" }, children: /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", children: [
1359
+ /* @__PURE__ */ jsx(LogoContainer, { children: (_f = (_e = props == null ? void 0 : props.branding) == null ? void 0 : _e.logo) != null ? _f : /* @__PURE__ */ jsx(ToolpadLogo, { size: 40 }) }),
1360
+ /* @__PURE__ */ jsx(
1361
+ Typography,
1362
+ {
1363
+ variant: "h6",
1364
+ sx: {
1365
+ color: ((_g = theme.vars) != null ? _g : theme).palette.primary.main,
1366
+ fontWeight: "700",
1367
+ ml: 1,
1368
+ whiteSpace: "nowrap",
1369
+ lineHeight: 1
1370
+ },
1371
+ children: title
1372
+ }
1373
+ )
1374
+ ] }) });
1375
+ }
1376
+ function subscribe2() {
1377
+ return () => {
1378
+ };
1379
+ }
1380
+ function getSnapshot2() {
1381
+ return false;
1382
+ }
1383
+ function getServerSnapshot() {
1384
+ return true;
1385
+ }
1386
+ function useSsr() {
1387
+ return React26.useSyncExternalStore(subscribe2, getSnapshot2, getServerSnapshot);
1388
+ }
1389
+ function ThemeSwitcher() {
1390
+ var _a;
1391
+ const isSsr = useSsr();
1392
+ const theme = useTheme$1();
1393
+ const { paletteMode, setPaletteMode, isDualTheme } = React26.useContext(PaletteModeContext);
1394
+ const toggleMode = React26.useCallback(() => {
1395
+ setPaletteMode(paletteMode === "dark" ? "light" : "dark");
1396
+ }, [paletteMode, setPaletteMode]);
1397
+ return isDualTheme ? /* @__PURE__ */ jsx(
1398
+ Tooltip,
1399
+ {
1400
+ title: isSsr ? "Switch mode" : `${paletteMode === "dark" ? "Light" : "Dark"} mode`,
1401
+ enterDelay: 1e3,
1402
+ children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
1403
+ IconButton2,
1404
+ {
1405
+ "aria-label": isSsr ? "Switch theme mode" : `Switch to ${paletteMode === "dark" ? "light" : "dark"} mode`,
1406
+ onClick: toggleMode,
1407
+ sx: {
1408
+ color: ((_a = theme.vars) != null ? _a : theme).palette.primary.dark
1409
+ },
1410
+ children: theme.getColorSchemeSelector ? /* @__PURE__ */ jsxs(React26.Fragment, { children: [
1411
+ /* @__PURE__ */ jsx(
1412
+ DarkModeIcon,
1413
+ {
1414
+ sx: {
1415
+ display: "inline",
1416
+ [theme.getColorSchemeSelector("dark")]: {
1417
+ display: "none"
1418
+ }
1419
+ }
1420
+ }
1421
+ ),
1422
+ /* @__PURE__ */ jsx(
1423
+ LightModeIcon,
1424
+ {
1425
+ sx: {
1426
+ display: "none",
1427
+ [theme.getColorSchemeSelector("dark")]: {
1428
+ display: "inline"
1429
+ }
1430
+ }
1431
+ }
1432
+ )
1433
+ ] }) : /* @__PURE__ */ jsx(React26.Fragment, { children: isSsr || paletteMode !== "dark" ? /* @__PURE__ */ jsx(DarkModeIcon, {}) : /* @__PURE__ */ jsx(LightModeIcon, {}) })
1434
+ }
1435
+ ) })
1436
+ }
1437
+ ) : null;
1438
+ }
1439
+ function ToolbarActions() {
1440
+ return /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", children: [
1441
+ /* @__PURE__ */ jsx(ThemeSwitcher, {}),
1442
+ /* @__PURE__ */ jsx(Account, {})
1443
+ ] });
1444
+ }
1445
+ var AppBar = styled$1(MuiAppBar)(({ theme }) => {
1446
+ var _a;
1447
+ return {
1448
+ borderWidth: 0,
1449
+ borderBottomWidth: 1,
1450
+ borderStyle: "solid",
1451
+ borderColor: ((_a = theme.vars) != null ? _a : theme).palette.divider,
1452
+ boxShadow: "none",
1453
+ zIndex: theme.zIndex.drawer + 1
1454
+ };
1455
+ });
1456
+ function DashboardHeader(props) {
1457
+ var _a, _b;
1458
+ const {
1459
+ branding: brandingProp,
1460
+ menuOpen,
1461
+ onToggleMenu,
1462
+ hideMenuButton,
1463
+ slots,
1464
+ slotProps
1465
+ } = props;
1466
+ const brandingContext = React26.useContext(BrandingContext);
1467
+ const branding = __spreadValues(__spreadValues({}, brandingContext), brandingProp);
1468
+ const handleMenuOpen = React26.useCallback(() => {
1469
+ onToggleMenu(!menuOpen);
1470
+ }, [menuOpen, onToggleMenu]);
1471
+ const getMenuIcon = React26.useCallback(
1472
+ (isExpanded) => {
1473
+ const expandMenuActionText = "Expand";
1474
+ const collapseMenuActionText = "Collapse";
1475
+ return /* @__PURE__ */ jsx(
1476
+ Tooltip,
1477
+ {
1478
+ title: `${isExpanded ? collapseMenuActionText : expandMenuActionText} menu`,
1479
+ enterDelay: 1e3,
1480
+ children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
1481
+ IconButton2,
1482
+ {
1483
+ "aria-label": `${isExpanded ? collapseMenuActionText : expandMenuActionText} navigation menu`,
1484
+ onClick: handleMenuOpen,
1485
+ children: isExpanded ? /* @__PURE__ */ jsx(MenuOpenIcon, {}) : /* @__PURE__ */ jsx(MenuIcon, {})
1486
+ }
1487
+ ) })
1488
+ }
1489
+ );
1490
+ },
1491
+ [handleMenuOpen]
1492
+ );
1493
+ const ToolbarActionsSlot = (_a = slots == null ? void 0 : slots.toolbarActions) != null ? _a : ToolbarActions;
1494
+ const ToolbarAccountSlot = (_b = slots == null ? void 0 : slots.toolbarAccount) != null ? _b : (() => null);
1495
+ return /* @__PURE__ */ jsx(AppBar, { color: "inherit", position: "absolute", sx: { displayPrint: "none" }, children: /* @__PURE__ */ jsx(Toolbar2, { sx: { backgroundColor: "inherit", mx: { xs: -0.75, sm: -1 } }, children: /* @__PURE__ */ jsxs(
1496
+ Stack,
1497
+ {
1498
+ direction: "row",
1499
+ justifyContent: "space-between",
1500
+ alignItems: "center",
1501
+ sx: {
1502
+ flexWrap: "wrap",
1503
+ width: "100%"
1504
+ },
1505
+ children: [
1506
+ /* @__PURE__ */ jsxs(Stack, { direction: "row", children: [
1507
+ !hideMenuButton ? /* @__PURE__ */ jsxs(React26.Fragment, { children: [
1508
+ /* @__PURE__ */ jsx(
1509
+ Box4,
1510
+ {
1511
+ sx: {
1512
+ display: { xs: "block", md: "none" },
1513
+ mr: { sm: 1 }
1514
+ },
1515
+ children: getMenuIcon(menuOpen)
1516
+ }
1517
+ ),
1518
+ /* @__PURE__ */ jsx(
1519
+ Box4,
1520
+ {
1521
+ sx: {
1522
+ display: { xs: "none", md: "block" },
1523
+ mr: 1
1524
+ },
1525
+ children: getMenuIcon(menuOpen)
1526
+ }
1527
+ )
1528
+ ] }) : null,
1529
+ (slots == null ? void 0 : slots.appTitle) ? /* @__PURE__ */ jsx(slots.appTitle, __spreadValues({}, slotProps == null ? void 0 : slotProps.appTitle)) : (
1530
+ /* Hierarchy of application of `branding`
1531
+ * 1. Branding prop passed in the `slotProps.appTitle`
1532
+ * 2. Branding prop passed to the `DashboardLayout`
1533
+ * 3. Branding prop passed to the `AppProvider`
1534
+ */
1535
+ /* @__PURE__ */ jsx(AppTitle, __spreadValues({ branding }, slotProps == null ? void 0 : slotProps.appTitle))
1536
+ )
1537
+ ] }),
1538
+ /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", spacing: 1, sx: { marginLeft: "auto" }, children: [
1539
+ /* @__PURE__ */ jsx(ToolbarActionsSlot, __spreadValues({}, slotProps == null ? void 0 : slotProps.toolbarActions)),
1540
+ /* @__PURE__ */ jsx(ToolbarAccountSlot, __spreadValues({}, slotProps == null ? void 0 : slotProps.toolbarAccount))
1541
+ ] })
1542
+ ]
1543
+ }
1544
+ ) }) });
1545
+ }
1546
+ DashboardHeader.propTypes = {
1547
+ // ┌────────────────────────────── Warning ──────────────────────────────┐
1548
+ // │ These PropTypes are generated from the TypeScript type definitions. │
1549
+ // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
1550
+ // └─────────────────────────────────────────────────────────────────────┘
1551
+ /**
1552
+ * Branding options for the header.
1553
+ * @default null
1554
+ */
1555
+ branding: PropTypes11.shape({
1556
+ homeUrl: PropTypes11.string,
1557
+ logo: PropTypes11.node,
1558
+ title: PropTypes11.string
1559
+ }),
1560
+ /**
1561
+ * Whether the menu icon should always be hidden.
1562
+ * @default false
1563
+ */
1564
+ hideMenuButton: PropTypes11.bool,
1565
+ /**
1566
+ * If `true`, show menu button as if menu is expanded, otherwise show it as if menu is collapsed.
1567
+ */
1568
+ menuOpen: PropTypes11.bool.isRequired,
1569
+ /**
1570
+ * Callback fired when the menu button is clicked.
1571
+ */
1572
+ onToggleMenu: PropTypes11.func.isRequired,
1573
+ /**
1574
+ * The props used for each slot inside.
1575
+ * @default {}
1576
+ */
1577
+ slotProps: PropTypes11.shape({
1578
+ appTitle: PropTypes11.shape({
1579
+ branding: PropTypes11.shape({
1580
+ homeUrl: PropTypes11.string,
1581
+ logo: PropTypes11.node,
1582
+ title: PropTypes11.string
1583
+ })
1584
+ }),
1585
+ toolbarAccount: PropTypes11.shape({
1586
+ localeText: PropTypes11.object,
1587
+ slotProps: PropTypes11.shape({
1588
+ popover: PropTypes11.object,
1589
+ popoverContent: PropTypes11.object,
1590
+ preview: PropTypes11.object,
1591
+ signInButton: PropTypes11.object,
1592
+ signOutButton: PropTypes11.object
1593
+ }),
1594
+ slots: PropTypes11.shape({
1595
+ popover: PropTypes11.elementType,
1596
+ popoverContent: PropTypes11.elementType,
1597
+ preview: PropTypes11.elementType,
1598
+ signInButton: PropTypes11.elementType,
1599
+ signOutButton: PropTypes11.elementType
1600
+ })
1601
+ }),
1602
+ toolbarActions: PropTypes11.object
1603
+ }),
1604
+ /**
1605
+ * The components used for each slot inside.
1606
+ * @default {}
1607
+ */
1608
+ slots: PropTypes11.shape({
1609
+ appTitle: PropTypes11.elementType,
1610
+ toolbarAccount: PropTypes11.elementType,
1611
+ toolbarActions: PropTypes11.elementType
1612
+ })
1613
+ };
1614
+ var getItemKind = (item) => {
1615
+ var _a;
1616
+ return (_a = item.kind) != null ? _a : "page";
1617
+ };
1618
+ var isPageItem = (item) => getItemKind(item) === "page";
1619
+ var getItemTitle = (item) => {
1620
+ var _a, _b;
1621
+ return isPageItem(item) ? (_b = (_a = item.title) != null ? _a : item.segment) != null ? _b : "" : item.title;
1622
+ };
1623
+ function buildItemToPathMap(navigation) {
1624
+ const map = /* @__PURE__ */ new Map();
1625
+ const visit = (item, base) => {
1626
+ if (isPageItem(item)) {
1627
+ const path = `${base.startsWith("/") ? base : `/${base}`}${base && base !== "/" && item.segment ? "/" : ""}${item.segment || ""}` || "/";
1628
+ map.set(item, path);
1629
+ if (item.children) {
1630
+ for (const child of item.children) {
1631
+ visit(child, path);
1632
+ }
1633
+ }
1634
+ }
1635
+ };
1636
+ for (const item of navigation) {
1637
+ visit(item, "");
1638
+ }
1639
+ return map;
1640
+ }
1641
+ var itemToPathMapCache = /* @__PURE__ */ new WeakMap();
1642
+ function getItemToPathMap(navigation) {
1643
+ let map = itemToPathMapCache.get(navigation);
1644
+ if (!map) {
1645
+ map = buildItemToPathMap(navigation);
1646
+ itemToPathMapCache.set(navigation, map);
1647
+ }
1648
+ return map;
1649
+ }
1650
+ function buildItemLookup(navigation) {
1651
+ const map = /* @__PURE__ */ new Map();
1652
+ const visit = (item) => {
1653
+ if (isPageItem(item)) {
1654
+ const path = getItemPath(navigation, item);
1655
+ if (map.has(path)) {
1656
+ console.warn(`Duplicate path in navigation: ${path}`);
1657
+ }
1658
+ map.set(path, item);
1659
+ if (item.pattern) {
1660
+ const basePath = item.segment ? path.slice(0, -item.segment.length) : path;
1661
+ map.set(pathToRegexp(basePath + item.pattern).regexp, item);
1662
+ }
1663
+ if (item.children) {
1664
+ for (const child of item.children) {
1665
+ visit(child);
1666
+ }
1667
+ }
1668
+ }
1669
+ };
1670
+ for (const item of navigation) {
1671
+ visit(item);
1672
+ }
1673
+ return map;
1674
+ }
1675
+ var itemLookupMapCache = /* @__PURE__ */ new WeakMap();
1676
+ function getItemLookup(navigation) {
1677
+ let map = itemLookupMapCache.get(navigation);
1678
+ if (!map) {
1679
+ map = buildItemLookup(navigation);
1680
+ itemLookupMapCache.set(navigation, map);
1681
+ }
1682
+ return map;
1683
+ }
1684
+ function matchPath(navigation, path) {
1685
+ const lookup = getItemLookup(navigation);
1686
+ for (const [key, item] of lookup.entries()) {
1687
+ if (typeof key === "string" && key === path) {
1688
+ return item;
1689
+ }
1690
+ if (key instanceof RegExp && key.test(path)) {
1691
+ return item;
1692
+ }
1693
+ }
1694
+ return null;
1695
+ }
1696
+ function getItemPath(navigation, item) {
1697
+ const map = getItemToPathMap(navigation);
1698
+ const path = map.get(item);
1699
+ invariant2(path, `Item not found in navigation: ${item.title}`);
1700
+ return path;
1701
+ }
1702
+ function hasSelectedNavigationChildren(navigation, item, activePagePath) {
1703
+ if (item.children) {
1704
+ return item.children.some((nestedItem) => {
1705
+ if (!isPageItem(nestedItem)) {
1706
+ return false;
1707
+ }
1708
+ if (nestedItem.children) {
1709
+ return hasSelectedNavigationChildren(navigation, nestedItem, activePagePath);
1710
+ }
1711
+ return activePagePath === getItemPath(navigation, nestedItem);
1712
+ });
1713
+ }
1714
+ return false;
1715
+ }
1716
+
1717
+ // src/toolpad-core/DashboardLayout/utils.ts
1718
+ function getDrawerSxTransitionMixin(isExpanded, property) {
1719
+ return {
1720
+ transition: (theme) => theme.transitions.create(property, {
1721
+ easing: theme.transitions.easing.sharp,
1722
+ duration: isExpanded ? theme.transitions.duration.enteringScreen : theme.transitions.duration.leavingScreen
1723
+ })
1724
+ };
1725
+ }
1726
+ function getDrawerWidthTransitionMixin(isExpanded) {
1727
+ return __spreadProps(__spreadValues({}, getDrawerSxTransitionMixin(isExpanded, "width")), {
1728
+ overflowX: "hidden"
1729
+ });
1730
+ }
1731
+ function useActivePage() {
1732
+ var _a;
1733
+ const navigationContext = React26.useContext(NavigationContext);
1734
+ const routerContext = React26.useContext(RouterContext);
1735
+ const pathname = (_a = routerContext == null ? void 0 : routerContext.pathname) != null ? _a : "/";
1736
+ const activeItem = matchPath(navigationContext, pathname);
1737
+ const rootItem = matchPath(navigationContext, "/");
1738
+ return React26.useMemo(() => {
1739
+ if (!activeItem) {
1740
+ return null;
1741
+ }
1742
+ const breadcrumbs = [];
1743
+ if (rootItem) {
1744
+ breadcrumbs.push({
1745
+ title: getItemTitle(rootItem),
1746
+ path: "/"
1747
+ });
1748
+ }
1749
+ const segments = pathname.split("/").filter(Boolean);
1750
+ let prefix = "";
1751
+ for (const segment of segments) {
1752
+ const path = `${prefix}/${segment}`;
1753
+ prefix = path;
1754
+ const item = matchPath(navigationContext, path);
1755
+ if (!item) {
1756
+ continue;
1757
+ }
1758
+ const itemPath = getItemPath(navigationContext, item);
1759
+ const lastCrumb = breadcrumbs[breadcrumbs.length - 1];
1760
+ if ((lastCrumb == null ? void 0 : lastCrumb.path) !== itemPath) {
1761
+ breadcrumbs.push({
1762
+ title: getItemTitle(item),
1763
+ path: itemPath
1764
+ });
1765
+ }
1766
+ }
1767
+ return {
1768
+ title: getItemTitle(activeItem),
1769
+ path: getItemPath(navigationContext, activeItem),
1770
+ breadcrumbs
1771
+ };
1772
+ }, [activeItem, rootItem, pathname, navigationContext]);
1773
+ }
1774
+
1775
+ // src/toolpad-core/DashboardLayout/shared.ts
1776
+ var MINI_DRAWER_WIDTH = 84;
1777
+ var NavigationListItemButton = styled(ListItemButton)(({ theme }) => {
1778
+ var _a, _b, _c, _d, _e, _f, _g;
1779
+ return {
1780
+ borderRadius: 8,
1781
+ "&.Mui-selected": {
1782
+ "& .MuiListItemIcon-root": {
1783
+ color: ((_a = theme.vars) != null ? _a : theme).palette.primary.dark
1784
+ },
1785
+ "& .MuiTypography-root": {
1786
+ color: ((_b = theme.vars) != null ? _b : theme).palette.primary.dark
1787
+ },
1788
+ "& .MuiSvgIcon-root": {
1789
+ color: ((_c = theme.vars) != null ? _c : theme).palette.primary.dark
1790
+ },
1791
+ "& .MuiAvatar-root": {
1792
+ backgroundColor: ((_d = theme.vars) != null ? _d : theme).palette.primary.dark
1793
+ },
1794
+ "& .MuiTouchRipple-child": {
1795
+ backgroundColor: ((_e = theme.vars) != null ? _e : theme).palette.primary.dark
1796
+ }
1797
+ },
1798
+ "& .MuiSvgIcon-root": {
1799
+ color: ((_f = theme.vars) != null ? _f : theme).palette.action.active
1800
+ },
1801
+ "& .MuiAvatar-root": {
1802
+ backgroundColor: ((_g = theme.vars) != null ? _g : theme).palette.action.active
1803
+ }
1804
+ };
1805
+ });
1806
+ var LIST_ITEM_ICON_SIZE = 34;
1807
+ function DashboardSidebarPageItem(props) {
1808
+ var _a;
1809
+ const navigationContext = React26.useContext(NavigationContext);
1810
+ const pageItemContextProps = React26.useContext(DashboardSidebarPageItemContext);
1811
+ invariant2(pageItemContextProps, "No navigation page item context provided.");
1812
+ const contextAwareProps = __spreadValues(__spreadValues({}, pageItemContextProps), props);
1813
+ const {
1814
+ item,
1815
+ href = getItemPath(navigationContext, item),
1816
+ LinkComponent: LinkComponentProp,
1817
+ expanded = false,
1818
+ selected = false,
1819
+ disabled = false,
1820
+ id,
1821
+ onClick,
1822
+ isMini = false,
1823
+ isSidebarFullyExpanded = true,
1824
+ isSidebarFullyCollapsed = false,
1825
+ renderNestedNavigation
1826
+ } = contextAwareProps;
1827
+ const [hoveredMiniSidebarItemId, setHoveredMiniSidebarItemId] = React26.useState(
1828
+ null
1829
+ );
1830
+ const handleClick = React26.useCallback(() => {
1831
+ onClick(id, item);
1832
+ }, [id, item, onClick]);
1833
+ let nestedNavigationCollapseSx = { display: "none" };
1834
+ if (isMini && isSidebarFullyCollapsed) {
1835
+ nestedNavigationCollapseSx = {
1836
+ fontSize: 18,
1837
+ position: "absolute",
1838
+ top: "41.5%",
1839
+ right: "2px",
1840
+ transform: "translateY(-50%) rotate(-90deg)"
1841
+ };
1842
+ } else if (!isMini && isSidebarFullyExpanded) {
1843
+ nestedNavigationCollapseSx = {
1844
+ ml: 0.5,
1845
+ transform: `rotate(${expanded ? 0 : -90}deg)`,
1846
+ transition: (theme) => theme.transitions.create("transform", {
1847
+ easing: theme.transitions.easing.sharp,
1848
+ duration: 100
1849
+ })
1850
+ };
1851
+ }
1852
+ const hasExternalHref = href.startsWith("http://") || href.startsWith("https://");
1853
+ const LinkComponent = LinkComponentProp != null ? LinkComponentProp : hasExternalHref ? "a" : Link2;
1854
+ const title = getItemTitle(item);
1855
+ const listItem = /* @__PURE__ */ jsxs(
1856
+ ListItem,
1857
+ __spreadProps(__spreadValues({}, item.children && isMini ? {
1858
+ onMouseEnter: () => {
1859
+ setHoveredMiniSidebarItemId(id);
1860
+ },
1861
+ onMouseLeave: () => {
1862
+ setHoveredMiniSidebarItemId(null);
1863
+ }
1864
+ } : {}), {
1865
+ sx: {
1866
+ py: 0,
1867
+ px: 1,
1868
+ overflowX: "hidden"
1869
+ },
1870
+ children: [
1871
+ /* @__PURE__ */ jsxs(
1872
+ NavigationListItemButton,
1873
+ __spreadProps(__spreadValues(__spreadValues({
1874
+ selected,
1875
+ disabled,
1876
+ sx: {
1877
+ px: 1.4,
1878
+ height: isMini ? 60 : 48
1879
+ }
1880
+ }, item.children && !isMini ? {
1881
+ onClick: handleClick
1882
+ } : {}), !item.children ? __spreadProps(__spreadValues({
1883
+ LinkComponent
1884
+ }, hasExternalHref ? {
1885
+ target: "_blank",
1886
+ rel: "noopener noreferrer"
1887
+ } : {}), {
1888
+ href,
1889
+ onClick: handleClick
1890
+ }) : {}), {
1891
+ children: [
1892
+ item.icon || isMini ? /* @__PURE__ */ jsxs(
1893
+ Box4,
1894
+ {
1895
+ sx: isMini ? {
1896
+ position: "absolute",
1897
+ left: "50%",
1898
+ top: "calc(50% - 6px)",
1899
+ transform: "translate(-50%, -50%)"
1900
+ } : {},
1901
+ children: [
1902
+ /* @__PURE__ */ jsxs(
1903
+ ListItemIcon,
1904
+ {
1905
+ sx: {
1906
+ display: "flex",
1907
+ alignItems: "center",
1908
+ justifyContent: "center",
1909
+ minWidth: LIST_ITEM_ICON_SIZE
1910
+ },
1911
+ children: [
1912
+ (_a = item.icon) != null ? _a : null,
1913
+ !item.icon && isMini ? /* @__PURE__ */ jsx(
1914
+ Avatar,
1915
+ {
1916
+ sx: {
1917
+ width: LIST_ITEM_ICON_SIZE - 7,
1918
+ height: LIST_ITEM_ICON_SIZE - 7,
1919
+ fontSize: 12
1920
+ },
1921
+ children: title.split(" ").slice(0, 2).map((titleWord) => titleWord.charAt(0).toUpperCase())
1922
+ }
1923
+ ) : null
1924
+ ]
1925
+ }
1926
+ ),
1927
+ isMini ? /* @__PURE__ */ jsx(
1928
+ Typography,
1929
+ {
1930
+ variant: "caption",
1931
+ sx: {
1932
+ position: "absolute",
1933
+ bottom: -18,
1934
+ left: "50%",
1935
+ transform: "translateX(-50%)",
1936
+ fontSize: 10,
1937
+ fontWeight: 500,
1938
+ textAlign: "center",
1939
+ whiteSpace: "nowrap",
1940
+ overflow: "hidden",
1941
+ textOverflow: "ellipsis",
1942
+ maxWidth: MINI_DRAWER_WIDTH - 28
1943
+ },
1944
+ children: title
1945
+ }
1946
+ ) : null
1947
+ ]
1948
+ }
1949
+ ) : null,
1950
+ !isMini ? /* @__PURE__ */ jsx(
1951
+ ListItemText,
1952
+ {
1953
+ primary: title,
1954
+ sx: {
1955
+ ml: 1.2,
1956
+ whiteSpace: "nowrap",
1957
+ zIndex: 1
1958
+ }
1959
+ }
1960
+ ) : null,
1961
+ item.action && !isMini && isSidebarFullyExpanded ? item.action : null,
1962
+ item.children ? /* @__PURE__ */ jsx(ExpandMoreIcon, { sx: nestedNavigationCollapseSx }) : null
1963
+ ]
1964
+ })
1965
+ ),
1966
+ item.children && isMini ? /* @__PURE__ */ jsx(Grow, { in: id === hoveredMiniSidebarItemId, children: /* @__PURE__ */ jsx(
1967
+ Box4,
1968
+ {
1969
+ sx: {
1970
+ position: "fixed",
1971
+ left: MINI_DRAWER_WIDTH - 2,
1972
+ pl: "6px"
1973
+ },
1974
+ children: /* @__PURE__ */ jsx(
1975
+ Paper,
1976
+ {
1977
+ sx: {
1978
+ pt: 0.5,
1979
+ pb: 0.5,
1980
+ transform: "translateY(calc(50% - 30px))"
1981
+ },
1982
+ children: renderNestedNavigation(item.children)
1983
+ }
1984
+ )
1985
+ }
1986
+ ) }) : null
1987
+ ]
1988
+ })
1989
+ );
1990
+ return /* @__PURE__ */ jsxs(React26.Fragment, { children: [
1991
+ listItem,
1992
+ item.children && !isMini ? /* @__PURE__ */ jsx(Collapse, { in: expanded, timeout: "auto", unmountOnExit: true, children: renderNestedNavigation(item.children) }) : null
1993
+ ] }, id);
1994
+ }
1995
+ DashboardSidebarPageItem.propTypes = {
1996
+ // ┌────────────────────────────── Warning ──────────────────────────────┐
1997
+ // │ These PropTypes are generated from the TypeScript type definitions. │
1998
+ // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
1999
+ // └─────────────────────────────────────────────────────────────────────┘
2000
+ /**
2001
+ * If `true`, the item is disabled.
2002
+ * @default false
2003
+ */
2004
+ disabled: PropTypes11.bool,
2005
+ /**
2006
+ * If `true`, expands any nested navigation in the item, otherwise collapse it.
2007
+ * @default false
2008
+ */
2009
+ expanded: PropTypes11.bool,
2010
+ /**
2011
+ * Link `href` for when the item is rendered as a link.
2012
+ * @default getItemPath(navigationContext, item)
2013
+ */
2014
+ href: PropTypes11.string,
2015
+ /**
2016
+ * Navigation page item definition.
2017
+ */
2018
+ item: PropTypes11.shape({
2019
+ action: PropTypes11.node,
2020
+ children: PropTypes11.arrayOf(
2021
+ PropTypes11.oneOfType([
2022
+ PropTypes11.object,
2023
+ PropTypes11.shape({
2024
+ kind: PropTypes11.oneOf(["header"]).isRequired,
2025
+ title: PropTypes11.string.isRequired
2026
+ }),
2027
+ PropTypes11.shape({
2028
+ kind: PropTypes11.oneOf(["divider"]).isRequired
2029
+ })
2030
+ ]).isRequired
2031
+ ),
2032
+ icon: PropTypes11.node,
2033
+ kind: PropTypes11.oneOf(["page"]),
2034
+ pattern: PropTypes11.string,
2035
+ segment: PropTypes11.string,
2036
+ title: PropTypes11.string
2037
+ }).isRequired,
2038
+ /**
2039
+ * The component used to render the item as a link.
2040
+ * @default Link
2041
+ */
2042
+ LinkComponent: PropTypes11.elementType,
2043
+ /**
2044
+ * Use to apply selected styling.
2045
+ * @default false
2046
+ */
2047
+ selected: PropTypes11.bool
2048
+ };
2049
+ function DashboardSidebarSubNavigationPageItem({
2050
+ id,
2051
+ item,
2052
+ isExpanded,
2053
+ onClick,
2054
+ depth,
2055
+ onLinkClick,
2056
+ isMini,
2057
+ isFullyExpanded,
2058
+ isFullyCollapsed,
2059
+ sidebarExpandedWidth,
2060
+ renderPageItem
2061
+ }) {
2062
+ const navigationContext = React26.useContext(NavigationContext);
2063
+ const activePage = useActivePage();
2064
+ const isActive = !!activePage && activePage.path === getItemPath(navigationContext, item);
2065
+ const isSelected = activePage && item.children && isMini ? hasSelectedNavigationChildren(navigationContext, item, activePage.path) : isActive && !item.children;
2066
+ const pageItemContextProps = React26.useMemo(
2067
+ () => ({
2068
+ expanded: isExpanded,
2069
+ selected: isSelected,
2070
+ id,
2071
+ onClick,
2072
+ isMini,
2073
+ isSidebarFullyExpanded: isFullyExpanded,
2074
+ isSidebarFullyCollapsed: isFullyCollapsed,
2075
+ renderNestedNavigation: () => {
2076
+ var _a;
2077
+ return /* @__PURE__ */ jsx(
2078
+ DashboardSidebarSubNavigation,
2079
+ {
2080
+ subNavigation: (_a = item.children) != null ? _a : [],
2081
+ depth: depth + 1,
2082
+ onLinkClick,
2083
+ isPopover: isMini,
2084
+ sidebarExpandedWidth
2085
+ }
2086
+ );
2087
+ }
2088
+ }),
2089
+ [
2090
+ depth,
2091
+ id,
2092
+ isExpanded,
2093
+ isFullyCollapsed,
2094
+ isFullyExpanded,
2095
+ isMini,
2096
+ isSelected,
2097
+ item.children,
2098
+ onClick,
2099
+ onLinkClick,
2100
+ sidebarExpandedWidth
2101
+ ]
2102
+ );
2103
+ return /* @__PURE__ */ jsx(DashboardSidebarPageItemContext.Provider, { value: pageItemContextProps, children: renderPageItem ? renderPageItem(item, { mini: isMini }) : /* @__PURE__ */ jsx(DashboardSidebarPageItem, { item }) });
2104
+ }
2105
+ function DashboardSidebarSubNavigation({
2106
+ subNavigation,
2107
+ depth = 0,
2108
+ onLinkClick,
2109
+ isMini = false,
2110
+ isPopover = false,
2111
+ isFullyExpanded = true,
2112
+ isFullyCollapsed = false,
2113
+ hasDrawerTransitions = false,
2114
+ sidebarExpandedWidth,
2115
+ renderPageItem
2116
+ }) {
2117
+ const navigationContext = React26.useContext(NavigationContext);
2118
+ const activePage = useActivePage();
2119
+ const initialExpandedItemIds = React26.useMemo(
2120
+ () => subNavigation.map((navigationItem, navigationItemIndex) => ({
2121
+ navigationItem,
2122
+ originalIndex: navigationItemIndex
2123
+ })).filter(
2124
+ ({ navigationItem }) => isPageItem(navigationItem) && !!activePage && hasSelectedNavigationChildren(navigationContext, navigationItem, activePage.path)
2125
+ ).map(({ originalIndex }) => `page-${depth}-${originalIndex}`),
2126
+ [activePage, depth, navigationContext, subNavigation]
2127
+ );
2128
+ const [expandedItemIds, setExpandedItemIds] = React26.useState(initialExpandedItemIds);
2129
+ const handlePageItemClick = React26.useCallback(
2130
+ (itemId, item) => {
2131
+ if (item.children && !isMini) {
2132
+ setExpandedItemIds(
2133
+ (previousValue) => previousValue.includes(itemId) ? previousValue.filter((previousValueItemId) => previousValueItemId !== itemId) : [...previousValue, itemId]
2134
+ );
2135
+ } else if (!item.children) {
2136
+ onLinkClick();
2137
+ }
2138
+ },
2139
+ [isMini, onLinkClick]
2140
+ );
2141
+ return /* @__PURE__ */ jsx(
2142
+ List,
2143
+ {
2144
+ sx: {
2145
+ padding: 0,
2146
+ mt: isPopover && depth === 1 ? 0.5 : 0,
2147
+ mb: depth === 0 && !isPopover ? 4 : 0.5,
2148
+ pl: (isPopover ? 1 : 2) * (isPopover ? depth - 1 : depth),
2149
+ minWidth: isPopover && depth === 1 ? 240 : "auto",
2150
+ width: isMini ? MINI_DRAWER_WIDTH : "auto"
2151
+ },
2152
+ children: subNavigation.map((navigationItem, navigationItemIndex) => {
2153
+ if (navigationItem.kind === "header") {
2154
+ return /* @__PURE__ */ jsx(
2155
+ ListSubheader,
2156
+ {
2157
+ sx: __spreadProps(__spreadValues({
2158
+ fontSize: 12,
2159
+ fontWeight: "700",
2160
+ height: isMini ? 0 : 40
2161
+ }, hasDrawerTransitions ? getDrawerSxTransitionMixin(isFullyExpanded, "height") : {}), {
2162
+ px: 2,
2163
+ minWidth: sidebarExpandedWidth,
2164
+ overflow: "hidden",
2165
+ textOverflow: "ellipsis",
2166
+ whiteSpace: "nowrap",
2167
+ zIndex: 2
2168
+ }),
2169
+ children: getItemTitle(navigationItem)
2170
+ },
2171
+ `subheader-${depth}-${navigationItemIndex}`
2172
+ );
2173
+ }
2174
+ if (navigationItem.kind === "divider") {
2175
+ const nextItem = subNavigation[navigationItemIndex + 1];
2176
+ return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
2177
+ Divider,
2178
+ {
2179
+ sx: __spreadValues({
2180
+ borderBottomWidth: 2,
2181
+ mx: 1,
2182
+ mt: 1,
2183
+ mb: (nextItem == null ? void 0 : nextItem.kind) === "header" && !isMini ? 0 : 1
2184
+ }, hasDrawerTransitions ? getDrawerSxTransitionMixin(isFullyExpanded, "margin") : {})
2185
+ }
2186
+ ) }, `divider-${depth}-${navigationItemIndex}`);
2187
+ }
2188
+ const pageItemId = `page-${depth}-${navigationItemIndex}`;
2189
+ return /* @__PURE__ */ jsx(
2190
+ DashboardSidebarSubNavigationPageItem,
2191
+ {
2192
+ id: pageItemId,
2193
+ item: navigationItem,
2194
+ isExpanded: expandedItemIds.includes(pageItemId),
2195
+ onClick: handlePageItemClick,
2196
+ depth,
2197
+ onLinkClick,
2198
+ isMini,
2199
+ isFullyExpanded,
2200
+ isFullyCollapsed,
2201
+ sidebarExpandedWidth,
2202
+ renderPageItem
2203
+ },
2204
+ pageItemId
2205
+ );
2206
+ })
2207
+ }
2208
+ );
2209
+ }
2210
+
2211
+ // src/toolpad-utils/warnOnce.ts
2212
+ var history = /* @__PURE__ */ new Set();
2213
+ function warnOnce(msg) {
2214
+ if (!history.has(msg)) {
2215
+ history.add(msg);
2216
+ console.warn(msg);
2217
+ }
2218
+ }
2219
+ function DashboardLayout(props) {
2220
+ var _a, _b;
2221
+ const {
2222
+ children,
2223
+ branding,
2224
+ navigation: navigationProp,
2225
+ defaultSidebarCollapsed = false,
2226
+ disableCollapsibleSidebar = false,
2227
+ hideNavigation = false,
2228
+ sidebarExpandedWidth = 320,
2229
+ renderPageItem,
2230
+ slots,
2231
+ slotProps,
2232
+ sx
2233
+ } = props;
2234
+ if (navigationProp && process.env.NODE_ENV !== "production") {
2235
+ warnOnce(
2236
+ "The navigation prop in the DashboardLayout component is deprecated and will eventually be removed. Set the navigation prop in the AppProvider instead (https://mui.com/toolpad/core/react-app-provider/#navigation)."
2237
+ );
2238
+ }
2239
+ const theme = useTheme();
2240
+ const navigationContext = React26.useContext(NavigationContext);
2241
+ const appWindowContext = React26.useContext(WindowContext);
2242
+ const navigation = navigationProp != null ? navigationProp : navigationContext;
2243
+ const [isDesktopNavigationExpanded, setIsDesktopNavigationExpanded] = React26.useState(!defaultSidebarCollapsed);
2244
+ const [isMobileNavigationExpanded, setIsMobileNavigationExpanded] = React26.useState(false);
2245
+ const isOverSmViewport = useMediaQuery2(
2246
+ theme.breakpoints.up("sm"),
2247
+ appWindowContext && {
2248
+ matchMedia: appWindowContext.matchMedia
2249
+ }
2250
+ );
2251
+ const isOverMdViewport = useMediaQuery2(
2252
+ theme.breakpoints.up("md"),
2253
+ appWindowContext && {
2254
+ matchMedia: appWindowContext.matchMedia
2255
+ }
2256
+ );
2257
+ const isNavigationExpanded = isOverMdViewport ? isDesktopNavigationExpanded : isMobileNavigationExpanded;
2258
+ const setIsNavigationExpanded = React26.useCallback(
2259
+ (newExpanded) => {
2260
+ if (isOverMdViewport) {
2261
+ setIsDesktopNavigationExpanded(newExpanded);
2262
+ } else {
2263
+ setIsMobileNavigationExpanded(newExpanded);
2264
+ }
2265
+ },
2266
+ [isOverMdViewport]
2267
+ );
2268
+ const [isNavigationFullyExpanded, setIsNavigationFullyExpanded] = React26.useState(isNavigationExpanded);
2269
+ const [isNavigationFullyCollapsed, setIsNavigationFullyCollapsed] = React26.useState(!isNavigationExpanded);
2270
+ React26.useEffect(() => {
2271
+ if (isNavigationExpanded) {
2272
+ const drawerWidthTransitionTimeout = setTimeout(() => {
2273
+ setIsNavigationFullyExpanded(true);
2274
+ }, theme.transitions.duration.enteringScreen);
2275
+ return () => clearTimeout(drawerWidthTransitionTimeout);
2276
+ }
2277
+ setIsNavigationFullyExpanded(false);
2278
+ return () => {
2279
+ };
2280
+ }, [isNavigationExpanded, theme]);
2281
+ React26.useEffect(() => {
2282
+ if (!isNavigationExpanded) {
2283
+ const drawerWidthTransitionTimeout = setTimeout(() => {
2284
+ setIsNavigationFullyCollapsed(true);
2285
+ }, theme.transitions.duration.leavingScreen);
2286
+ return () => clearTimeout(drawerWidthTransitionTimeout);
2287
+ }
2288
+ setIsNavigationFullyCollapsed(false);
2289
+ return () => {
2290
+ };
2291
+ }, [isNavigationExpanded, theme]);
2292
+ const handleSetNavigationExpanded = React26.useCallback(
2293
+ (newExpanded) => () => {
2294
+ setIsNavigationExpanded(newExpanded);
2295
+ },
2296
+ [setIsNavigationExpanded]
2297
+ );
2298
+ const handleToggleHeaderMenu = React26.useCallback(
2299
+ (isExpanded) => {
2300
+ setIsNavigationExpanded(isExpanded);
2301
+ },
2302
+ [setIsNavigationExpanded]
2303
+ );
2304
+ const handleNavigationLinkClick = React26.useCallback(() => {
2305
+ setIsMobileNavigationExpanded(false);
2306
+ }, [setIsMobileNavigationExpanded]);
2307
+ const isDesktopMini = !disableCollapsibleSidebar && !isDesktopNavigationExpanded;
2308
+ const isMobileMini = !disableCollapsibleSidebar && !isMobileNavigationExpanded;
2309
+ const hasDrawerTransitions = isOverSmViewport && (!disableCollapsibleSidebar || isOverMdViewport);
2310
+ const SidebarFooterSlot = (_a = slots == null ? void 0 : slots.sidebarFooter) != null ? _a : null;
2311
+ const HeaderSlot = (_b = slots == null ? void 0 : slots.header) != null ? _b : DashboardHeader;
2312
+ const headerSlotProps = React26.useMemo(
2313
+ () => __spreadValues({
2314
+ branding,
2315
+ menuOpen: isNavigationExpanded,
2316
+ onToggleMenu: handleToggleHeaderMenu,
2317
+ hideMenuButton: hideNavigation || isOverMdViewport && disableCollapsibleSidebar,
2318
+ slots: {
2319
+ appTitle: slots == null ? void 0 : slots.appTitle,
2320
+ toolbarActions: slots == null ? void 0 : slots.toolbarActions,
2321
+ toolbarAccount: slots == null ? void 0 : slots.toolbarAccount
2322
+ },
2323
+ slotProps: {
2324
+ appTitle: slotProps == null ? void 0 : slotProps.appTitle,
2325
+ toolbarActions: slotProps == null ? void 0 : slotProps.toolbarActions,
2326
+ toolbarAccount: slotProps == null ? void 0 : slotProps.toolbarAccount
2327
+ }
2328
+ }, slotProps == null ? void 0 : slotProps.header),
2329
+ [
2330
+ branding,
2331
+ isNavigationExpanded,
2332
+ handleToggleHeaderMenu,
2333
+ hideNavigation,
2334
+ isOverMdViewport,
2335
+ disableCollapsibleSidebar,
2336
+ slotProps,
2337
+ slots
2338
+ ]
2339
+ );
2340
+ const getDrawerContent = React26.useCallback(
2341
+ (isMini, viewport) => {
2342
+ var _a2;
2343
+ return /* @__PURE__ */ jsxs(React26.Fragment, { children: [
2344
+ /* @__PURE__ */ jsx(Toolbar2, {}),
2345
+ /* @__PURE__ */ jsxs(
2346
+ Box4,
2347
+ {
2348
+ component: "nav",
2349
+ "aria-label": `${viewport.charAt(0).toUpperCase()}${viewport.slice(1)}`,
2350
+ sx: __spreadValues({
2351
+ height: "100%",
2352
+ display: "flex",
2353
+ flexDirection: "column",
2354
+ justifyContent: "space-between",
2355
+ overflow: "auto",
2356
+ scrollbarGutter: isMini ? "stable" : "auto",
2357
+ overflowX: "hidden",
2358
+ pt: ((_a2 = navigation[0]) == null ? void 0 : _a2.kind) === "header" && !isMini ? 0 : 2
2359
+ }, hasDrawerTransitions ? getDrawerSxTransitionMixin(isNavigationFullyExpanded, "padding") : {}),
2360
+ children: [
2361
+ /* @__PURE__ */ jsx(
2362
+ DashboardSidebarSubNavigation,
2363
+ {
2364
+ subNavigation: navigation,
2365
+ onLinkClick: handleNavigationLinkClick,
2366
+ isMini,
2367
+ isFullyExpanded: isNavigationFullyExpanded,
2368
+ isFullyCollapsed: isNavigationFullyCollapsed,
2369
+ hasDrawerTransitions,
2370
+ sidebarExpandedWidth,
2371
+ renderPageItem
2372
+ }
2373
+ ),
2374
+ SidebarFooterSlot ? /* @__PURE__ */ jsx(SidebarFooterSlot, __spreadValues({ mini: isMini }, slotProps == null ? void 0 : slotProps.sidebarFooter)) : null
2375
+ ]
2376
+ }
2377
+ )
2378
+ ] });
2379
+ },
2380
+ [
2381
+ SidebarFooterSlot,
2382
+ handleNavigationLinkClick,
2383
+ hasDrawerTransitions,
2384
+ isNavigationFullyCollapsed,
2385
+ isNavigationFullyExpanded,
2386
+ navigation,
2387
+ sidebarExpandedWidth,
2388
+ renderPageItem,
2389
+ slotProps == null ? void 0 : slotProps.sidebarFooter
2390
+ ]
2391
+ );
2392
+ const getDrawerSharedSx = React26.useCallback(
2393
+ (isMini, isTemporary) => {
2394
+ const drawerWidth = isMini ? MINI_DRAWER_WIDTH : sidebarExpandedWidth;
2395
+ return __spreadProps(__spreadValues(__spreadValues({
2396
+ displayPrint: "none",
2397
+ width: drawerWidth,
2398
+ flexShrink: 0
2399
+ }, getDrawerWidthTransitionMixin(isNavigationExpanded)), isTemporary ? { position: "absolute" } : {}), {
2400
+ [`& .MuiDrawer-paper`]: __spreadValues({
2401
+ position: "absolute",
2402
+ width: drawerWidth,
2403
+ boxSizing: "border-box",
2404
+ backgroundImage: "none"
2405
+ }, getDrawerWidthTransitionMixin(isNavigationExpanded))
2406
+ });
2407
+ },
2408
+ [isNavigationExpanded, sidebarExpandedWidth]
2409
+ );
2410
+ return /* @__PURE__ */ jsxs(
2411
+ Box4,
2412
+ {
2413
+ sx: __spreadValues({
2414
+ position: "relative",
2415
+ display: "flex",
2416
+ overflow: "hidden",
2417
+ height: "100vh",
2418
+ width: "100vw"
2419
+ }, sx),
2420
+ children: [
2421
+ /* @__PURE__ */ jsx(HeaderSlot, __spreadValues({}, headerSlotProps)),
2422
+ !hideNavigation ? /* @__PURE__ */ jsxs(React26.Fragment, { children: [
2423
+ /* @__PURE__ */ jsx(
2424
+ Drawer,
2425
+ {
2426
+ container: appWindowContext == null ? void 0 : appWindowContext.document.body,
2427
+ variant: "temporary",
2428
+ open: isMobileNavigationExpanded,
2429
+ onClose: handleSetNavigationExpanded(false),
2430
+ ModalProps: {
2431
+ keepMounted: true
2432
+ // Better open performance on mobile.
2433
+ },
2434
+ sx: __spreadValues({
2435
+ display: {
2436
+ xs: "block",
2437
+ sm: disableCollapsibleSidebar ? "block" : "none",
2438
+ md: "none"
2439
+ }
2440
+ }, getDrawerSharedSx(false, true)),
2441
+ children: getDrawerContent(false, "phone")
2442
+ }
2443
+ ),
2444
+ /* @__PURE__ */ jsx(
2445
+ Drawer,
2446
+ {
2447
+ variant: "permanent",
2448
+ sx: __spreadValues({
2449
+ display: {
2450
+ xs: "none",
2451
+ sm: disableCollapsibleSidebar ? "none" : "block",
2452
+ md: "none"
2453
+ }
2454
+ }, getDrawerSharedSx(isMobileMini, false)),
2455
+ children: getDrawerContent(isMobileMini, "tablet")
2456
+ }
2457
+ ),
2458
+ /* @__PURE__ */ jsx(
2459
+ Drawer,
2460
+ {
2461
+ variant: "permanent",
2462
+ sx: __spreadValues({
2463
+ display: { xs: "none", md: "block" }
2464
+ }, getDrawerSharedSx(isDesktopMini, false)),
2465
+ children: getDrawerContent(isDesktopMini, "desktop")
2466
+ }
2467
+ )
2468
+ ] }) : null,
2469
+ /* @__PURE__ */ jsxs(
2470
+ Box4,
2471
+ {
2472
+ sx: {
2473
+ display: "flex",
2474
+ flexDirection: "column",
2475
+ flex: 1,
2476
+ minWidth: 0
2477
+ },
2478
+ children: [
2479
+ /* @__PURE__ */ jsx(Toolbar2, { sx: { displayPrint: "none" } }),
2480
+ /* @__PURE__ */ jsx(
2481
+ Box4,
2482
+ {
2483
+ component: "main",
2484
+ sx: {
2485
+ display: "flex",
2486
+ flexDirection: "column",
2487
+ flex: 1,
2488
+ overflow: "auto"
2489
+ },
2490
+ children
2491
+ }
2492
+ )
2493
+ ]
2494
+ }
2495
+ )
2496
+ ]
2497
+ }
2498
+ );
2499
+ }
2500
+ DashboardLayout.propTypes = {
2501
+ // ┌────────────────────────────── Warning ──────────────────────────────┐
2502
+ // │ These PropTypes are generated from the TypeScript type definitions. │
2503
+ // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
2504
+ // └─────────────────────────────────────────────────────────────────────┘
2505
+ /**
2506
+ * Branding options for the dashboard.
2507
+ * @default null
2508
+ */
2509
+ branding: PropTypes11.shape({
2510
+ homeUrl: PropTypes11.string,
2511
+ logo: PropTypes11.node,
2512
+ title: PropTypes11.string
2513
+ }),
2514
+ /**
2515
+ * The content of the dashboard.
2516
+ */
2517
+ children: PropTypes11.node,
2518
+ /**
2519
+ * Whether the sidebar should start collapsed in desktop size screens.
2520
+ * @default false
2521
+ */
2522
+ defaultSidebarCollapsed: PropTypes11.bool,
2523
+ /**
2524
+ * Whether the sidebar should not be collapsible to a mini variant in desktop and tablet viewports.
2525
+ * @default false
2526
+ */
2527
+ disableCollapsibleSidebar: PropTypes11.bool,
2528
+ /**
2529
+ * Whether the navigation bar and menu icon should be hidden.
2530
+ * @default false
2531
+ */
2532
+ hideNavigation: PropTypes11.bool,
2533
+ /**
2534
+ * Navigation definition for the dashboard. [Find out more](https://mui.com/toolpad/core/react-dashboard-layout/#navigation).
2535
+ * @default []
2536
+ * @deprecated Set the navigation in the [AppProvider](https://mui.com/toolpad/core/react-app-provider/#navigation) instead.
2537
+ */
2538
+ navigation: PropTypes11.arrayOf(
2539
+ PropTypes11.oneOfType([
2540
+ PropTypes11.shape({
2541
+ action: PropTypes11.node,
2542
+ children: PropTypes11.arrayOf(
2543
+ PropTypes11.oneOfType([
2544
+ PropTypes11.object,
2545
+ PropTypes11.shape({
2546
+ kind: PropTypes11.oneOf(["header"]).isRequired,
2547
+ title: PropTypes11.string.isRequired
2548
+ }),
2549
+ PropTypes11.shape({
2550
+ kind: PropTypes11.oneOf(["divider"]).isRequired
2551
+ })
2552
+ ]).isRequired
2553
+ ),
2554
+ icon: PropTypes11.node,
2555
+ kind: PropTypes11.oneOf(["page"]),
2556
+ pattern: PropTypes11.string,
2557
+ segment: PropTypes11.string,
2558
+ title: PropTypes11.string
2559
+ }),
2560
+ PropTypes11.shape({
2561
+ kind: PropTypes11.oneOf(["header"]).isRequired,
2562
+ title: PropTypes11.string.isRequired
2563
+ }),
2564
+ PropTypes11.shape({
2565
+ kind: PropTypes11.oneOf(["divider"]).isRequired
2566
+ })
2567
+ ]).isRequired
2568
+ ),
2569
+ /**
2570
+ * Render each page item.
2571
+ *
2572
+ * @param {NavigationPageItem} item
2573
+ * @param {{ mini: boolean }} params
2574
+ * @returns {ReactNode}
2575
+ */
2576
+ renderPageItem: PropTypes11.func,
2577
+ /**
2578
+ * Width of the sidebar when expanded.
2579
+ * @default 320
2580
+ */
2581
+ sidebarExpandedWidth: PropTypes11.oneOfType([PropTypes11.number, PropTypes11.string]),
2582
+ /**
2583
+ * The props used for each slot inside.
2584
+ * @default {}
2585
+ */
2586
+ slotProps: PropTypes11.shape({
2587
+ appTitle: PropTypes11.shape({
2588
+ branding: PropTypes11.shape({
2589
+ homeUrl: PropTypes11.string,
2590
+ logo: PropTypes11.node,
2591
+ title: PropTypes11.string
2592
+ })
2593
+ }),
2594
+ header: PropTypes11.shape({
2595
+ branding: PropTypes11.shape({
2596
+ homeUrl: PropTypes11.string,
2597
+ logo: PropTypes11.node,
2598
+ title: PropTypes11.string
2599
+ }),
2600
+ hideMenuButton: PropTypes11.bool,
2601
+ menuOpen: PropTypes11.bool.isRequired,
2602
+ onToggleMenu: PropTypes11.func.isRequired,
2603
+ slotProps: PropTypes11.shape({
2604
+ appTitle: PropTypes11.object,
2605
+ toolbarAccount: PropTypes11.object,
2606
+ toolbarActions: PropTypes11.object
2607
+ }),
2608
+ slots: PropTypes11.shape({
2609
+ appTitle: PropTypes11.elementType,
2610
+ toolbarAccount: PropTypes11.elementType,
2611
+ toolbarActions: PropTypes11.elementType
2612
+ })
2613
+ }),
2614
+ sidebarFooter: PropTypes11.shape({
2615
+ mini: PropTypes11.bool.isRequired
2616
+ }),
2617
+ toolbarAccount: PropTypes11.shape({
2618
+ localeText: PropTypes11.object,
2619
+ slotProps: PropTypes11.shape({
2620
+ popover: PropTypes11.object,
2621
+ popoverContent: PropTypes11.object,
2622
+ preview: PropTypes11.object,
2623
+ signInButton: PropTypes11.object,
2624
+ signOutButton: PropTypes11.object
2625
+ }),
2626
+ slots: PropTypes11.shape({
2627
+ popover: PropTypes11.elementType,
2628
+ popoverContent: PropTypes11.elementType,
2629
+ preview: PropTypes11.elementType,
2630
+ signInButton: PropTypes11.elementType,
2631
+ signOutButton: PropTypes11.elementType
2632
+ })
2633
+ }),
2634
+ toolbarActions: PropTypes11.object
2635
+ }),
2636
+ /**
2637
+ * The components used for each slot inside.
2638
+ * @default {}
2639
+ */
2640
+ slots: PropTypes11.shape({
2641
+ appTitle: PropTypes11.elementType,
2642
+ header: PropTypes11.elementType,
2643
+ sidebarFooter: PropTypes11.elementType,
2644
+ toolbarAccount: PropTypes11.elementType,
2645
+ toolbarActions: PropTypes11.elementType
2646
+ }),
2647
+ /**
2648
+ * The system prop that allows defining system overrides as well as additional CSS styles.
2649
+ */
2650
+ sx: PropTypes11.oneOfType([
2651
+ PropTypes11.arrayOf(PropTypes11.oneOfType([PropTypes11.func, PropTypes11.object, PropTypes11.bool])),
2652
+ PropTypes11.func,
2653
+ PropTypes11.object
2654
+ ])
2655
+ };
2656
+ var PageHeaderToolbarRoot = styled("div")(({ theme }) => ({
2657
+ display: "flex",
2658
+ flexDirection: "row",
2659
+ gap: theme.spacing(1),
2660
+ // Ensure the toolbar is always on the right side, even after wrapping
2661
+ marginLeft: "auto"
2662
+ }));
2663
+ function PageHeaderToolbar(props) {
2664
+ return /* @__PURE__ */ jsx(PageHeaderToolbarRoot, __spreadValues({}, props));
2665
+ }
2666
+ PageHeaderToolbar.propTypes = {
2667
+ // ┌────────────────────────────── Warning ──────────────────────────────┐
2668
+ // │ These PropTypes are generated from the TypeScript type definitions. │
2669
+ // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
2670
+ // └─────────────────────────────────────────────────────────────────────┘
2671
+ /**
2672
+ * @ignore
2673
+ */
2674
+ children: PropTypes11.node
2675
+ };
2676
+ var PageContentHeader = styled("div")(({ theme }) => ({
2677
+ display: "flex",
2678
+ flexDirection: "row",
2679
+ justifyContent: "space-between",
2680
+ gap: theme.spacing(2)
2681
+ }));
2682
+ function PageHeader(props) {
2683
+ var _a, _b, _c, _d, _e;
2684
+ const { breadcrumbs, title } = props;
2685
+ const activePage = useActivePage();
2686
+ const resolvedBreadcrumbs = (_a = breadcrumbs != null ? breadcrumbs : activePage == null ? void 0 : activePage.breadcrumbs) != null ? _a : [];
2687
+ const resolvedTitle = (_b = title != null ? title : activePage == null ? void 0 : activePage.title) != null ? _b : "";
2688
+ const ToolbarComponent = (_d = (_c = props == null ? void 0 : props.slots) == null ? void 0 : _c.toolbar) != null ? _d : PageHeaderToolbar;
2689
+ const toolbarSlotProps = useSlotProps({
2690
+ elementType: ToolbarComponent,
2691
+ ownerState: props,
2692
+ externalSlotProps: (_e = props == null ? void 0 : props.slotProps) == null ? void 0 : _e.toolbar,
2693
+ additionalProps: {}
2694
+ });
2695
+ return /* @__PURE__ */ jsxs(Stack, { children: [
2696
+ /* @__PURE__ */ jsx(Breadcrumbs, { "aria-label": "breadcrumb", children: resolvedBreadcrumbs ? resolvedBreadcrumbs.map((item, index) => {
2697
+ return item.path ? /* @__PURE__ */ jsx(
2698
+ Link4,
2699
+ {
2700
+ component: Link2,
2701
+ underline: "hover",
2702
+ color: "inherit",
2703
+ href: item.path,
2704
+ children: getItemTitle(item)
2705
+ },
2706
+ index
2707
+ ) : /* @__PURE__ */ jsx(Typography, { color: "text.primary", children: getItemTitle(item) }, index);
2708
+ }) : null }),
2709
+ /* @__PURE__ */ jsxs(PageContentHeader, { children: [
2710
+ resolvedTitle ? /* @__PURE__ */ jsx(Typography, { variant: "h4", children: resolvedTitle }) : null,
2711
+ /* @__PURE__ */ jsx(ToolbarComponent, __spreadValues({}, toolbarSlotProps))
2712
+ ] })
2713
+ ] });
2714
+ }
2715
+ PageHeader.propTypes = {
2716
+ // ┌────────────────────────────── Warning ──────────────────────────────┐
2717
+ // │ These PropTypes are generated from the TypeScript type definitions. │
2718
+ // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
2719
+ // └─────────────────────────────────────────────────────────────────────┘
2720
+ /**
2721
+ * The breadcrumbs of the page. Leave blank to use the active page breadcrumbs.
2722
+ */
2723
+ breadcrumbs: PropTypes11.arrayOf(
2724
+ PropTypes11.shape({
2725
+ path: PropTypes11.string,
2726
+ title: PropTypes11.string.isRequired
2727
+ })
2728
+ ),
2729
+ /**
2730
+ * The props used for each slot inside.
2731
+ */
2732
+ slotProps: PropTypes11.shape({
2733
+ toolbar: PropTypes11.shape({
2734
+ children: PropTypes11.node
2735
+ }).isRequired
2736
+ }),
2737
+ /**
2738
+ * The components used for each slot inside.
2739
+ */
2740
+ slots: PropTypes11.shape({
2741
+ toolbar: PropTypes11.elementType
2742
+ }),
2743
+ /**
2744
+ * The title of the page. Leave blank to use the active page title.
2745
+ */
2746
+ title: PropTypes11.string
2747
+ };
2748
+ function PageContainer(props) {
2749
+ var _b;
2750
+ const _a = props, { children, breadcrumbs, slots, slotProps, title } = _a, rest = __objRest(_a, ["children", "breadcrumbs", "slots", "slotProps", "title"]);
2751
+ const PageHeaderSlot = (_b = slots == null ? void 0 : slots.header) != null ? _b : PageHeader;
2752
+ return /* @__PURE__ */ jsx(Container, __spreadProps(__spreadValues({}, rest), { sx: __spreadValues({ flex: 1, display: "flex", flexDirection: "column" }, rest.sx), children: /* @__PURE__ */ jsxs(Stack, { sx: { flex: 1, my: 2 }, spacing: 2, children: [
2753
+ /* @__PURE__ */ jsx(PageHeaderSlot, __spreadValues({ title, breadcrumbs }, slotProps == null ? void 0 : slotProps.header)),
2754
+ /* @__PURE__ */ jsx(Box4, { sx: { flex: 1, display: "flex", flexDirection: "column" }, children })
2755
+ ] }) }));
2756
+ }
2757
+ PageContainer.propTypes = {
2758
+ // ┌────────────────────────────── Warning ──────────────────────────────┐
2759
+ // │ These PropTypes are generated from the TypeScript type definitions. │
2760
+ // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
2761
+ // └─────────────────────────────────────────────────────────────────────┘
2762
+ /**
2763
+ * The breadcrumbs of the page. Leave blank to use the active page breadcrumbs.
2764
+ */
2765
+ breadcrumbs: PropTypes11.arrayOf(
2766
+ PropTypes11.shape({
2767
+ path: PropTypes11.string,
2768
+ title: PropTypes11.string.isRequired
2769
+ })
2770
+ ),
2771
+ /**
2772
+ * @ignore
2773
+ */
2774
+ children: PropTypes11.node,
2775
+ /**
2776
+ * The props used for each slot inside.
2777
+ */
2778
+ slotProps: PropTypes11.shape({
2779
+ header: PropTypes11.shape({
2780
+ breadcrumbs: PropTypes11.arrayOf(
2781
+ PropTypes11.shape({
2782
+ path: PropTypes11.string,
2783
+ title: PropTypes11.string.isRequired
2784
+ })
2785
+ ),
2786
+ slotProps: PropTypes11.shape({
2787
+ toolbar: PropTypes11.object.isRequired
2788
+ }),
2789
+ slots: PropTypes11.shape({
2790
+ toolbar: PropTypes11.elementType
2791
+ }),
2792
+ title: PropTypes11.string
2793
+ }).isRequired
2794
+ }),
2795
+ /**
2796
+ * The components used for each slot inside.
2797
+ */
2798
+ slots: PropTypes11.shape({
2799
+ header: PropTypes11.elementType
2800
+ }),
2801
+ /**
2802
+ * The system prop that allows defining system overrides as well as additional CSS styles.
2803
+ */
2804
+ sx: PropTypes11.oneOfType([
2805
+ PropTypes11.arrayOf(PropTypes11.oneOfType([PropTypes11.func, PropTypes11.object, PropTypes11.bool])),
2806
+ PropTypes11.func,
2807
+ PropTypes11.object
2808
+ ]),
2809
+ /**
2810
+ * The title of the page. Leave blank to use the active page title.
2811
+ */
2812
+ title: PropTypes11.string
2813
+ };
2814
+ var Link5 = React26.forwardRef((props, ref) => {
2815
+ const _a = props, { href, history: history2 } = _a, rest = __objRest(_a, ["href", "history"]);
2816
+ return /* @__PURE__ */ jsx(NextLink, __spreadValues({ ref, href, replace: history2 === "replace" }, rest));
2817
+ });
2818
+ function NextAppProviderApp(props) {
2819
+ const pathname = usePathname();
2820
+ const searchParams = useSearchParams();
2821
+ const { push, replace } = useRouter();
2822
+ const navigate = React26.useCallback(
2823
+ (url, { history: history2 = "auto" } = {}) => {
2824
+ if (history2 === "auto" || history2 === "push") {
2825
+ return push(String(url));
2826
+ }
2827
+ if (history2 === "replace") {
2828
+ return replace(String(url));
2829
+ }
2830
+ throw new Error(`Invalid history option: ${history2}`);
2831
+ },
2832
+ [push, replace]
2833
+ );
2834
+ const routerImpl = React26.useMemo(
2835
+ () => ({
2836
+ pathname,
2837
+ searchParams,
2838
+ navigate,
2839
+ Link: Link5
2840
+ }),
2841
+ [pathname, navigate, searchParams]
2842
+ );
2843
+ return /* @__PURE__ */ jsx(AppProvider, __spreadValues({ router: routerImpl }, props));
2844
+ }
2845
+ function NextAppProvider(props) {
2846
+ const AppProvider2 = NextAppProviderApp;
2847
+ return /* @__PURE__ */ jsx(AppProvider2, __spreadValues({}, props));
2848
+ }
2849
+
2850
+ export { Account, AccountPopoverFooter, AccountPopoverHeader, AccountPreview, AlertDialog, AppProvider, AuthenticationContext, ConfirmDialog, DashboardHeader, DashboardLayout, DashboardSidebarPageItem, DialogsProvider, LocalizationContext, LocalizationProvider, NextAppProvider, NotificationsProvider, PageContainer, PageHeader, PageHeaderToolbar, PromptDialog, SessionContext, SignInButton, SignOutButton, ThemeSwitcher, ToolbarActions, en_default as en, useActivePage, useDialogs, useLocalStorageState, useLocaleText, useNotifications, useStorageState, useStorageStateServer };