@dashadmin/dash-boilerplate 1.3.24 → 1.3.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,127 +1,258 @@
1
- import { jsx as c, jsxs as y, Fragment as U } from "react/jsx-runtime";
2
- import A, { createContext as $, useState as v, useCallback as T, useEffect as p, useMemo as E, useContext as V, useTransition as _, Suspense as J } from "react";
3
- import { ErrorBoundary as G } from "react-error-boundary";
4
- import K from "@mui/material/CssBaseline";
5
- import { ThemeProvider as Q, createTheme as X } from "@mui/material";
6
- import { updateDomCssVariables as I, dashStorage as Y } from "@dashadmin/dash-utils";
7
- import { useDispatch as B } from "react-redux";
8
- import { syncDeviceStoreToLocalStorage as Z, syncLocalStorageToDeviceStore as D, AuthPersistenceService as f } from "@dashadmin/dash-auth";
9
- import { DASH_REDUX_ACTIONS as S } from "@dashadmin/dash-admin-state";
10
- import { ACTION_UPDATE_AUTH as P } from "@dashadmin/dash-admin-state/src/redux/reducers/Auth";
11
- import z from "@dashadmin/dash-admin/src/contexts/auth/DASHAuthenticationService";
12
- const M = (t, e) => e.split(".").reduce((o, r) => o ? o[r] : null, t), N = (t, e) => !e || !t ? t : Object.keys(e).reduce((o, r) => o.replace(new RegExp(`%\\{${r}\\}`, "g"), String(e[r])), t), ee = [
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
32
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
33
+ var __async = (__this, __arguments, generator) => {
34
+ return new Promise((resolve, reject) => {
35
+ var fulfilled = (value) => {
36
+ try {
37
+ step(generator.next(value));
38
+ } catch (e) {
39
+ reject(e);
40
+ }
41
+ };
42
+ var rejected = (value) => {
43
+ try {
44
+ step(generator.throw(value));
45
+ } catch (e) {
46
+ reject(e);
47
+ }
48
+ };
49
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
50
+ step((generator = generator.apply(__this, __arguments)).next());
51
+ });
52
+ };
53
+
54
+ // src/i18n/createSimpleI18nProvider.ts
55
+ var getNestedValue = (obj, path) => {
56
+ return path.split(".").reduce((prev, curr) => prev ? prev[curr] : null, obj);
57
+ };
58
+ var interpolate = (text, options) => {
59
+ if (!options || !text) return text;
60
+ return Object.keys(options).reduce((acc, key) => {
61
+ return acc.replace(new RegExp(`%\\{${key}\\}`, "g"), String(options[key]));
62
+ }, text);
63
+ };
64
+ var defaultLocales = [
13
65
  { locale: "en", name: "English" },
14
- { locale: "es", name: "Español" }
15
- ], Ce = (t) => {
66
+ { locale: "es", name: "Espa\xF1ol" }
67
+ ];
68
+ var createSimpleI18nProvider = (options) => {
16
69
  const {
17
- translations: e,
18
- initialLocale: o = "es",
19
- fallbackLocale: r = "en",
20
- locales: a = ee,
21
- onLocaleChange: s
22
- } = t;
23
- let n = o;
24
- return {
25
- translate: (i, b) => {
26
- const C = e[n] || e[r] || {}, x = M(C, i);
27
- if (typeof x == "string")
28
- return N(x, b);
29
- if (n !== r) {
30
- const j = e[r] || {}, R = M(j, i);
31
- if (typeof R == "string")
32
- return N(R, b);
70
+ translations,
71
+ initialLocale = "es",
72
+ fallbackLocale = "en",
73
+ locales = defaultLocales,
74
+ onLocaleChange
75
+ } = options;
76
+ let currentLocale = initialLocale;
77
+ const translate = (key, interpolationOptions) => {
78
+ const messages = translations[currentLocale] || translations[fallbackLocale] || {};
79
+ const text = getNestedValue(messages, key);
80
+ if (typeof text === "string") {
81
+ return interpolate(text, interpolationOptions);
82
+ }
83
+ if (currentLocale !== fallbackLocale) {
84
+ const fallbackMessages = translations[fallbackLocale] || {};
85
+ const fallbackText = getNestedValue(fallbackMessages, key);
86
+ if (typeof fallbackText === "string") {
87
+ return interpolate(fallbackText, interpolationOptions);
33
88
  }
34
- return i;
35
- },
36
- changeLocale: async (i) => e[i] ? (n = i, localStorage.setItem("dash-user-locale", i), s?.(i), Promise.resolve()) : Promise.reject(new Error(`Locale '${i}' not found`)),
37
- getLocale: () => n,
38
- getLocales: () => a,
39
- getMessages: (i) => e[i] || {}
89
+ }
90
+ return key;
91
+ };
92
+ const changeLocale = (newLocale) => __async(null, null, function* () {
93
+ if (translations[newLocale]) {
94
+ currentLocale = newLocale;
95
+ localStorage.setItem("dash-user-locale", newLocale);
96
+ onLocaleChange == null ? void 0 : onLocaleChange(newLocale);
97
+ return Promise.resolve();
98
+ }
99
+ return Promise.reject(new Error(`Locale '${newLocale}' not found`));
100
+ });
101
+ const getLocale = () => currentLocale;
102
+ const getLocales = () => locales;
103
+ const getMessages = (locale) => {
104
+ return translations[locale] || {};
105
+ };
106
+ return {
107
+ translate,
108
+ changeLocale,
109
+ getLocale,
110
+ getLocales,
111
+ getMessages
40
112
  };
41
- }, H = "dash:locale-change", te = {
113
+ };
114
+
115
+ // src/i18n/I18nBridgeProviderLight.tsx
116
+ import { createContext, useContext, useState, useCallback, useMemo, useEffect } from "react";
117
+ import { jsx } from "react/jsx-runtime";
118
+ var LOCALE_CHANGE_EVENT = "dash:locale-change";
119
+ var defaultContextValue = {
42
120
  i18nProvider: null,
43
121
  locale: "es",
44
122
  setI18nProvider: () => {
45
123
  },
46
124
  setLocale: () => {
47
125
  }
48
- }, q = $(te), Ee = ({
49
- children: t,
50
- defaultLocale: e = "es"
126
+ };
127
+ var I18nBridgeContext = createContext(defaultContextValue);
128
+ var I18nBridgeProviderLight = ({
129
+ children,
130
+ defaultLocale = "es"
51
131
  }) => {
52
- const [o, r] = v(null), [a, s] = v(() => typeof window < "u" && localStorage.getItem("dash-user-locale") || e), n = T(async (l) => {
53
- console.log("🌐 I18nBridgeProviderLight: Setting bridged i18nProvider", {
54
- providerLocale: l?.getLocale?.(),
55
- desiredLocale: a
56
- }), r(l);
57
- const u = l?.getLocale?.();
58
- if (u && u !== a && l?.changeLocale) {
59
- console.log(`🌐 I18nBridgeProviderLight: Provider locale (${u}) differs from desired (${a}), switching...`);
132
+ const [i18nProvider, setI18nProviderState] = useState(null);
133
+ const [locale, setLocale] = useState(() => {
134
+ if (typeof window !== "undefined") {
135
+ return localStorage.getItem("dash-user-locale") || defaultLocale;
136
+ }
137
+ return defaultLocale;
138
+ });
139
+ const setI18nProvider = useCallback((provider) => __async(null, null, function* () {
140
+ var _a, _b;
141
+ console.log("\u{1F310} I18nBridgeProviderLight: Setting bridged i18nProvider", {
142
+ providerLocale: (_a = provider == null ? void 0 : provider.getLocale) == null ? void 0 : _a.call(provider),
143
+ desiredLocale: locale
144
+ });
145
+ setI18nProviderState(provider);
146
+ const providerLocale = (_b = provider == null ? void 0 : provider.getLocale) == null ? void 0 : _b.call(provider);
147
+ if (providerLocale && providerLocale !== locale && (provider == null ? void 0 : provider.changeLocale)) {
148
+ console.log(`\u{1F310} I18nBridgeProviderLight: Provider locale (${providerLocale}) differs from desired (${locale}), switching...`);
60
149
  try {
61
- await l.changeLocale(a), console.log(`🌐 I18nBridgeProviderLight: Successfully switched provider to ${a}`);
62
- } catch (m) {
63
- console.warn("🌐 I18nBridgeProviderLight: Failed to switch provider locale:", m);
150
+ yield provider.changeLocale(locale);
151
+ console.log(`\u{1F310} I18nBridgeProviderLight: Successfully switched provider to ${locale}`);
152
+ } catch (e) {
153
+ console.warn("\u{1F310} I18nBridgeProviderLight: Failed to switch provider locale:", e);
64
154
  }
65
- } else l?.getLocale && s(l.getLocale());
66
- }, [a]);
67
- p(() => {
68
- const l = async (u) => {
69
- const g = u.detail?.locale;
70
- if (g && g !== a) {
71
- if (console.log("🌐 I18nBridgeProviderLight: Received locale change event:", g), o?.changeLocale)
155
+ } else if (provider == null ? void 0 : provider.getLocale) {
156
+ setLocale(provider.getLocale());
157
+ }
158
+ }), [locale]);
159
+ useEffect(() => {
160
+ const handleLocaleChange = (event) => __async(null, null, function* () {
161
+ var _a;
162
+ const customEvent = event;
163
+ const newLocale = (_a = customEvent.detail) == null ? void 0 : _a.locale;
164
+ if (newLocale && newLocale !== locale) {
165
+ console.log("\u{1F310} I18nBridgeProviderLight: Received locale change event:", newLocale);
166
+ if (i18nProvider == null ? void 0 : i18nProvider.changeLocale) {
72
167
  try {
73
- await o.changeLocale(g);
74
- } catch (i) {
75
- console.warn("Failed to change provider locale:", i);
168
+ yield i18nProvider.changeLocale(newLocale);
169
+ } catch (e) {
170
+ console.warn("Failed to change provider locale:", e);
76
171
  }
77
- s(g);
172
+ }
173
+ setLocale(newLocale);
78
174
  }
175
+ });
176
+ window.addEventListener(LOCALE_CHANGE_EVENT, handleLocaleChange);
177
+ return () => {
178
+ window.removeEventListener(LOCALE_CHANGE_EVENT, handleLocaleChange);
79
179
  };
80
- return window.addEventListener(H, l), () => {
81
- window.removeEventListener(H, l);
82
- };
83
- }, [o, a]);
84
- const d = E(() => ({
85
- i18nProvider: o,
86
- locale: a,
87
- setI18nProvider: n,
88
- setLocale: s
89
- }), [o, a, n]);
90
- return /* @__PURE__ */ c(q.Provider, { value: d, children: t });
91
- }, k = () => V(q), Pe = () => {
92
- const { i18nProvider: t } = k();
93
- return E(() => t?.getLocales ? t.getLocales() : [], [t]);
94
- }, Be = () => {
95
- const { i18nProvider: t, setLocale: e } = k();
96
- return T(async (r) => {
97
- t?.changeLocale && (await t.changeLocale(r), e(r));
98
- }, [t, e]);
99
- }, ke = () => {
100
- const { locale: t } = k();
101
- return t;
102
- }, Ie = () => {
103
- const { i18nProvider: t } = k();
104
- return T((o, r) => t?.translate ? t.translate(o, r) : o, [t]);
105
- }, O = '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="32px" height="32px" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd" viewBox="0 0 16 16"><g><path style="opacity:1" fill="#FFFFFF" d="M11.506 12.388q0.306 0.011 0.617 0.008v1.281h-0.89a2 2 0 0 1 -0.898 -0.215 1.24 1.24 0 0 1 -0.629 -0.761 2.5 2.5 0 0 1 -0.094 -0.554q-0.006 -1.082 -0.004 -2.163h-0.609q0.002 -0.398 -0.004 -0.796a616 616 0 0 0 -1.676 2.023 657 657 0 0 0 2.069 2.46q-0.935 0.012 -1.874 0.008L6.003 11.61q-0.006 1.035 -0.004 2.069H4.485q0.004 -2.983 -0.008 -5.966 -0.661 -0.21 -0.863 -0.875a2 2 0 0 1 -0.039 -0.258q-0.008 -2.108 0 -4.217 0.12 -0.356 0.48 -0.246 0.153 0.079 0.191 0.246l0.008 3.272q0.05 0.116 0.168 0.066 0.035 -0.027 0.051 -0.066l0.008 -3.264q0.095 -0.329 0.433 -0.269 0.191 0.059 0.238 0.254l0.008 3.272q0.065 0.14 0.195 0.055l0.023 -0.039 0.008 -3.264q0.086 -0.321 0.418 -0.285 0.197 0.057 0.254 0.254a352 352 0 0 1 0.016 3.295q0.062 0.109 0.176 0.051 0.029 -0.028 0.043 -0.066l0.008 -3.28q0.045 -0.17 0.207 -0.238 0.25 -0.074 0.41 0.129a0.5 0.5 0 0 1 0.047 0.109q0.014 1.063 0.012 2.128 0.002 1.088 -0.012 2.175 -0.137 0.844 -0.96 1.078a301 301 0 0 0 0 3.006q0.753 -1.005 1.503 -2.011 1.05 -0.006 2.101 -0.004 0.002 -0.519 -0.004 -1.039a1.82 1.82 0 0 1 -1.281 -1.101q-0.197 -0.504 -0.211 -1.046a4.7 4.7 0 0 1 0.383 -2.03q0.242 -0.547 0.668 -0.964 0.395 -0.364 0.929 -0.445 0.695 -0.056 1.218 0.398 0.476 0.438 0.73 1.035 0.513 1.212 0.32 2.514a2.26 2.26 0 0 1 -0.484 1.07 1.75 1.75 0 0 1 -0.754 0.5v1.109h0.992v1.265h-0.992q-0.002 1.042 0.004 2.085 0.05 0.323 0.379 0.32"/></g></svg>', oe = () => /* @__PURE__ */ c("span", { dangerouslySetInnerHTML: { __html: O } }), ze = ({
106
- message: t,
107
- showMessage: e = !1
108
- }) => /* @__PURE__ */ y("div", { children: [
109
- /* @__PURE__ */ y("div", { className: "initial-loader", children: [
110
- /* @__PURE__ */ c("div", { className: "initial-loader-spinner" }),
111
- /* @__PURE__ */ c("span", { className: "initial-loader-icon", children: /* @__PURE__ */ c(oe, {}) })
180
+ }, [i18nProvider, locale]);
181
+ const contextValue = useMemo(() => ({
182
+ i18nProvider,
183
+ locale,
184
+ setI18nProvider,
185
+ setLocale
186
+ }), [i18nProvider, locale, setI18nProvider]);
187
+ return /* @__PURE__ */ jsx(I18nBridgeContext.Provider, { value: contextValue, children });
188
+ };
189
+ var useI18nBridgeLight = () => {
190
+ const context = useContext(I18nBridgeContext);
191
+ return context;
192
+ };
193
+ var useBridgedLocalesLight = () => {
194
+ const { i18nProvider } = useI18nBridgeLight();
195
+ const locales = useMemo(() => {
196
+ if (!(i18nProvider == null ? void 0 : i18nProvider.getLocales)) {
197
+ return [];
198
+ }
199
+ return i18nProvider.getLocales();
200
+ }, [i18nProvider]);
201
+ return locales;
202
+ };
203
+ var useBridgedChangeLocaleLight = () => {
204
+ const { i18nProvider, setLocale } = useI18nBridgeLight();
205
+ const changeLocale = useCallback((locale) => __async(null, null, function* () {
206
+ if (i18nProvider == null ? void 0 : i18nProvider.changeLocale) {
207
+ yield i18nProvider.changeLocale(locale);
208
+ setLocale(locale);
209
+ }
210
+ }), [i18nProvider, setLocale]);
211
+ return changeLocale;
212
+ };
213
+ var useBridgedLocaleLight = () => {
214
+ const { locale } = useI18nBridgeLight();
215
+ return locale;
216
+ };
217
+ var useTranslateLight = () => {
218
+ const { i18nProvider } = useI18nBridgeLight();
219
+ const translate = useCallback((key, options) => {
220
+ if (i18nProvider == null ? void 0 : i18nProvider.translate) {
221
+ return i18nProvider.translate(key, options);
222
+ }
223
+ return key;
224
+ }, [i18nProvider]);
225
+ return translate;
226
+ };
227
+
228
+ // src/components/GlobalSmallLoader.tsx
229
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
230
+ var loaderSvgMarkup = `<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="32px" height="32px" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd" viewBox="0 0 16 16"><g><path style="opacity:1" fill="#FFFFFF" d="M11.506 12.388q0.306 0.011 0.617 0.008v1.281h-0.89a2 2 0 0 1 -0.898 -0.215 1.24 1.24 0 0 1 -0.629 -0.761 2.5 2.5 0 0 1 -0.094 -0.554q-0.006 -1.082 -0.004 -2.163h-0.609q0.002 -0.398 -0.004 -0.796a616 616 0 0 0 -1.676 2.023 657 657 0 0 0 2.069 2.46q-0.935 0.012 -1.874 0.008L6.003 11.61q-0.006 1.035 -0.004 2.069H4.485q0.004 -2.983 -0.008 -5.966 -0.661 -0.21 -0.863 -0.875a2 2 0 0 1 -0.039 -0.258q-0.008 -2.108 0 -4.217 0.12 -0.356 0.48 -0.246 0.153 0.079 0.191 0.246l0.008 3.272q0.05 0.116 0.168 0.066 0.035 -0.027 0.051 -0.066l0.008 -3.264q0.095 -0.329 0.433 -0.269 0.191 0.059 0.238 0.254l0.008 3.272q0.065 0.14 0.195 0.055l0.023 -0.039 0.008 -3.264q0.086 -0.321 0.418 -0.285 0.197 0.057 0.254 0.254a352 352 0 0 1 0.016 3.295q0.062 0.109 0.176 0.051 0.029 -0.028 0.043 -0.066l0.008 -3.28q0.045 -0.17 0.207 -0.238 0.25 -0.074 0.41 0.129a0.5 0.5 0 0 1 0.047 0.109q0.014 1.063 0.012 2.128 0.002 1.088 -0.012 2.175 -0.137 0.844 -0.96 1.078a301 301 0 0 0 0 3.006q0.753 -1.005 1.503 -2.011 1.05 -0.006 2.101 -0.004 0.002 -0.519 -0.004 -1.039a1.82 1.82 0 0 1 -1.281 -1.101q-0.197 -0.504 -0.211 -1.046a4.7 4.7 0 0 1 0.383 -2.03q0.242 -0.547 0.668 -0.964 0.395 -0.364 0.929 -0.445 0.695 -0.056 1.218 0.398 0.476 0.438 0.73 1.035 0.513 1.212 0.32 2.514a2.26 2.26 0 0 1 -0.484 1.07 1.75 1.75 0 0 1 -0.754 0.5v1.109h0.992v1.265h-0.992q-0.002 1.042 0.004 2.085 0.05 0.323 0.379 0.32"/></g></svg>`;
231
+ var KTIcon = () => /* @__PURE__ */ jsx2("span", { dangerouslySetInnerHTML: { __html: loaderSvgMarkup } });
232
+ var GlobalSmallLoader = ({
233
+ message,
234
+ showMessage = false
235
+ }) => /* @__PURE__ */ jsxs("div", { children: [
236
+ /* @__PURE__ */ jsxs("div", { className: "initial-loader", children: [
237
+ /* @__PURE__ */ jsx2("div", { className: "initial-loader-spinner" }),
238
+ /* @__PURE__ */ jsx2("span", { className: "initial-loader-icon", children: /* @__PURE__ */ jsx2(KTIcon, {}) })
112
239
  ] }),
113
- e && t && /* @__PURE__ */ c("div", { className: "initial-loader-text", children: t })
114
- ] }), Ae = `<div class="initial-loader">
240
+ showMessage && message && /* @__PURE__ */ jsx2("div", { className: "initial-loader-text", children: message })
241
+ ] });
242
+ var GlobalLoaderHtmlMarkup = `<div class="initial-loader">
115
243
  <div class="initial-loader-spinner">
116
244
  <span class="initial-loader-icon">
117
- ${O}
245
+ ${loaderSvgMarkup}
118
246
  </span>
119
247
  </div>
120
248
  <div class="initial-loader-text"></div>
121
- </div>`, Te = () => {
122
- if (typeof document > "u" || document.getElementById("critical-loading-styles")) return;
123
- const t = document.createElement("style");
124
- t.id = "critical-loading-styles", t.textContent = `
249
+ </div>`;
250
+ var injectCriticalStyles = () => {
251
+ if (typeof document === "undefined") return;
252
+ if (document.getElementById("critical-loading-styles")) return;
253
+ const style = document.createElement("style");
254
+ style.id = "critical-loading-styles";
255
+ style.textContent = `
125
256
  .initial-loader {
126
257
  position: fixed;
127
258
  top: 0;
@@ -168,61 +299,81 @@ const M = (t, e) => e.split(".").reduce((o, r) => o ? o[r] : null, t), N = (t, e
168
299
  @keyframes spin {
169
300
  to { transform: rotate(360deg); }
170
301
  }
171
- `, document.head.appendChild(t);
302
+ `;
303
+ document.head.appendChild(style);
172
304
  };
173
- class Re extends A.Component {
174
- constructor(e) {
175
- super(e), this.state = { hasError: !1 };
305
+
306
+ // src/components/CustomErrorBoundary.tsx
307
+ import React2 from "react";
308
+ import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
309
+ var CustomErrorBoundary = class extends React2.Component {
310
+ constructor(props) {
311
+ super(props);
312
+ __publicField(this, "handleReload", () => {
313
+ window.location.reload();
314
+ });
315
+ this.state = { hasError: false };
176
316
  }
177
- static getDerivedStateFromError(e) {
178
- return { hasError: !0, error: e };
317
+ static getDerivedStateFromError(error) {
318
+ return { hasError: true, error };
179
319
  }
180
- componentDidCatch(e, o) {
181
- console.error("CustomErrorBoundary caught error:", e, o), this.props.onError?.(e, o);
320
+ componentDidCatch(error, errorInfo) {
321
+ var _a, _b;
322
+ console.error("CustomErrorBoundary caught error:", error, errorInfo);
323
+ (_b = (_a = this.props).onError) == null ? void 0 : _b.call(_a, error, errorInfo);
182
324
  }
183
- handleReload = () => {
184
- window.location.reload();
185
- };
186
325
  render() {
187
- return this.state.hasError ? this.props.fallback ? this.props.fallback : /* @__PURE__ */ y(
188
- "div",
189
- {
190
- style: {
191
- display: "flex",
192
- justifyContent: "center",
193
- alignItems: "center",
194
- height: "100vh",
195
- backgroundColor: "var(--bodybg-primary, #121212)",
196
- color: "var(--text-color, #ffffff)",
197
- flexDirection: "column",
198
- gap: "20px"
199
- },
200
- children: [
201
- /* @__PURE__ */ c("h2", { children: "Something went wrong" }),
202
- /* @__PURE__ */ c("p", { style: { opacity: 0.8 }, children: this.state.error?.message }),
203
- /* @__PURE__ */ c(
204
- "button",
205
- {
206
- onClick: this.handleReload,
207
- style: {
208
- padding: "10px 20px",
209
- backgroundColor: "var(--primary-color, #007bff)",
210
- color: "white",
211
- border: "none",
212
- borderRadius: "4px",
213
- cursor: "pointer",
214
- fontSize: "14px",
215
- fontWeight: 500
216
- },
217
- children: "Reload Page"
218
- }
219
- )
220
- ]
326
+ var _a;
327
+ if (this.state.hasError) {
328
+ if (this.props.fallback) {
329
+ return this.props.fallback;
221
330
  }
222
- ) : this.props.children;
331
+ return /* @__PURE__ */ jsxs2(
332
+ "div",
333
+ {
334
+ style: {
335
+ display: "flex",
336
+ justifyContent: "center",
337
+ alignItems: "center",
338
+ height: "100vh",
339
+ backgroundColor: "var(--bodybg-primary, #121212)",
340
+ color: "var(--text-color, #ffffff)",
341
+ flexDirection: "column",
342
+ gap: "20px"
343
+ },
344
+ children: [
345
+ /* @__PURE__ */ jsx3("h2", { children: "Something went wrong" }),
346
+ /* @__PURE__ */ jsx3("p", { style: { opacity: 0.8 }, children: (_a = this.state.error) == null ? void 0 : _a.message }),
347
+ /* @__PURE__ */ jsx3(
348
+ "button",
349
+ {
350
+ onClick: this.handleReload,
351
+ style: {
352
+ padding: "10px 20px",
353
+ backgroundColor: "var(--primary-color, #007bff)",
354
+ color: "white",
355
+ border: "none",
356
+ borderRadius: "4px",
357
+ cursor: "pointer",
358
+ fontSize: "14px",
359
+ fontWeight: 500
360
+ },
361
+ children: "Reload Page"
362
+ }
363
+ )
364
+ ]
365
+ }
366
+ );
367
+ }
368
+ return this.props.children;
223
369
  }
224
- }
225
- const re = ({ error: t, resetErrorBoundary: e }) => /* @__PURE__ */ y(
370
+ };
371
+
372
+ // src/components/AppWrapperLight.tsx
373
+ import React3, { Suspense, useState as useState2, useTransition } from "react";
374
+ import { ErrorBoundary } from "react-error-boundary";
375
+ import { Fragment, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
376
+ var ErrorFallback = ({ error, resetErrorBoundary }) => /* @__PURE__ */ jsxs3(
226
377
  "div",
227
378
  {
228
379
  style: {
@@ -236,12 +387,12 @@ const re = ({ error: t, resetErrorBoundary: e }) => /* @__PURE__ */ y(
236
387
  backgroundColor: "var(--bodybg-primary)"
237
388
  },
238
389
  children: [
239
- /* @__PURE__ */ c("h1", { style: { margin: 0, fontSize: "1.5rem" }, children: "Something went wrong" }),
240
- /* @__PURE__ */ c("p", { style: { margin: 0, opacity: 0.8 }, children: t?.message || "Unknown error" }),
241
- /* @__PURE__ */ c(
390
+ /* @__PURE__ */ jsx4("h1", { style: { margin: 0, fontSize: "1.5rem" }, children: "Something went wrong" }),
391
+ /* @__PURE__ */ jsx4("p", { style: { margin: 0, opacity: 0.8 }, children: (error == null ? void 0 : error.message) || "Unknown error" }),
392
+ /* @__PURE__ */ jsx4(
242
393
  "button",
243
394
  {
244
- onClick: e,
395
+ onClick: resetErrorBoundary,
245
396
  style: {
246
397
  padding: "8px 24px",
247
398
  backgroundColor: "var(--primary-color)",
@@ -257,7 +408,8 @@ const re = ({ error: t, resetErrorBoundary: e }) => /* @__PURE__ */ y(
257
408
  )
258
409
  ]
259
410
  }
260
- ), ne = () => /* @__PURE__ */ y(
411
+ );
412
+ var SimpleLoader = () => /* @__PURE__ */ jsxs3(
261
413
  "div",
262
414
  {
263
415
  style: {
@@ -268,7 +420,7 @@ const re = ({ error: t, resetErrorBoundary: e }) => /* @__PURE__ */ y(
268
420
  backgroundColor: "var(--bodybg-primary)"
269
421
  },
270
422
  children: [
271
- /* @__PURE__ */ c(
423
+ /* @__PURE__ */ jsx4(
272
424
  "div",
273
425
  {
274
426
  className: "loading-spinner",
@@ -282,30 +434,43 @@ const re = ({ error: t, resetErrorBoundary: e }) => /* @__PURE__ */ y(
282
434
  }
283
435
  }
284
436
  ),
285
- /* @__PURE__ */ c("style", { children: `
437
+ /* @__PURE__ */ jsx4("style", { children: `
286
438
  @keyframes spin {
287
439
  to { transform: rotate(360deg); }
288
440
  }
289
441
  ` })
290
442
  ]
291
443
  }
292
- ), De = ({
293
- children: t,
294
- onReset: e,
295
- showSplash: o = !0
444
+ );
445
+ var AppWrapperLight = ({
446
+ children,
447
+ onReset,
448
+ showSplash = true
296
449
  }) => {
297
- const [r, a] = _(), [s, n] = v(!0);
298
- return A.useEffect(() => {
299
- a(() => {
300
- n(!1);
450
+ const [isPending, startTransition] = useTransition();
451
+ const [isInitialRender, setIsInitialRender] = useState2(true);
452
+ React3.useEffect(() => {
453
+ startTransition(() => {
454
+ setIsInitialRender(false);
301
455
  });
302
- }, []), /* @__PURE__ */ y(U, { children: [
303
- /* @__PURE__ */ c(G, { FallbackComponent: re, onReset: () => {
304
- e ? e() : window.location.reload();
305
- }, children: /* @__PURE__ */ c(J, { fallback: /* @__PURE__ */ c(ne, {}), children: t }) }),
306
- o && /* @__PURE__ */ c("div", { className: !r && !s ? "dash-splash fade-out" : "dash-splash" })
456
+ }, []);
457
+ const handleReset = () => {
458
+ if (onReset) {
459
+ onReset();
460
+ } else {
461
+ window.location.reload();
462
+ }
463
+ };
464
+ return /* @__PURE__ */ jsxs3(Fragment, { children: [
465
+ /* @__PURE__ */ jsx4(ErrorBoundary, { FallbackComponent: ErrorFallback, onReset: handleReset, children: /* @__PURE__ */ jsx4(Suspense, { fallback: /* @__PURE__ */ jsx4(SimpleLoader, {}), children }) }),
466
+ showSplash && /* @__PURE__ */ jsx4("div", { className: !isPending && !isInitialRender ? "dash-splash fade-out" : "dash-splash" })
307
467
  ] });
308
- }, ae = {
468
+ };
469
+
470
+ // src/components/DefaultFallbacks.tsx
471
+ import React4 from "react";
472
+ import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
473
+ var defaultContainerStyle = {
309
474
  display: "flex",
310
475
  flexDirection: "column",
311
476
  justifyContent: "center",
@@ -314,12 +479,14 @@ const re = ({ error: t, resetErrorBoundary: e }) => /* @__PURE__ */ y(
314
479
  gap: "16px",
315
480
  color: "var(--text-color, #333)",
316
481
  backgroundColor: "var(--background-color, #fff)"
317
- }, ie = {
482
+ };
483
+ var defaultErrorMessageStyle = {
318
484
  margin: 0,
319
485
  fontSize: "1.25rem",
320
486
  fontWeight: 500,
321
487
  color: "#f44336"
322
- }, se = {
488
+ };
489
+ var defaultButtonStyle = {
323
490
  marginTop: "16px",
324
491
  padding: "8px 16px",
325
492
  backgroundColor: "#1976d2",
@@ -329,36 +496,38 @@ const re = ({ error: t, resetErrorBoundary: e }) => /* @__PURE__ */ y(
329
496
  cursor: "pointer",
330
497
  fontSize: "14px",
331
498
  fontWeight: 500
332
- }, Me = ({
333
- error: t,
334
- message: e = "Failed to initialize application",
335
- onRetry: o = () => window.location.reload(),
336
- retryLabel: r = "Retry",
337
- containerStyle: a,
338
- messageStyle: s,
339
- buttonStyle: n
499
+ };
500
+ var DefaultInitializationErrorFallback = ({
501
+ error,
502
+ message = "Failed to initialize application",
503
+ onRetry = () => window.location.reload(),
504
+ retryLabel = "Retry",
505
+ containerStyle,
506
+ messageStyle,
507
+ buttonStyle
340
508
  }) => {
341
- const d = t instanceof Error ? t.message : t || e;
342
- return /* @__PURE__ */ y("div", { style: { ...ae, ...a }, children: [
343
- /* @__PURE__ */ c("h6", { style: { ...ie, ...s }, children: d }),
344
- /* @__PURE__ */ c(
509
+ const errorMessage = error instanceof Error ? error.message : error || message;
510
+ return /* @__PURE__ */ jsxs4("div", { style: __spreadValues(__spreadValues({}, defaultContainerStyle), containerStyle), children: [
511
+ /* @__PURE__ */ jsx5("h6", { style: __spreadValues(__spreadValues({}, defaultErrorMessageStyle), messageStyle), children: errorMessage }),
512
+ /* @__PURE__ */ jsx5(
345
513
  "button",
346
514
  {
347
- onClick: o,
348
- style: { ...se, ...n },
349
- children: r
515
+ onClick: onRetry,
516
+ style: __spreadValues(__spreadValues({}, defaultButtonStyle), buttonStyle),
517
+ children: retryLabel
350
518
  }
351
519
  )
352
520
  ] });
353
- }, le = ({
354
- message: t = "Failed to load application",
355
- onRetry: e = () => window.location.reload(),
356
- retryLabel: o = "Retry",
357
- containerStyle: r,
358
- messageStyle: a,
359
- buttonStyle: s
521
+ };
522
+ var DefaultAppLoadErrorFallback = ({
523
+ message = "Failed to load application",
524
+ onRetry = () => window.location.reload(),
525
+ retryLabel = "Retry",
526
+ containerStyle,
527
+ messageStyle,
528
+ buttonStyle
360
529
  }) => {
361
- const n = {
530
+ const appLoadContainerStyle = {
362
531
  display: "flex",
363
532
  flexDirection: "column",
364
533
  justifyContent: "center",
@@ -366,7 +535,8 @@ const re = ({ error: t, resetErrorBoundary: e }) => /* @__PURE__ */ y(
366
535
  height: "100vh",
367
536
  color: "#000000",
368
537
  gap: "12px"
369
- }, d = {
538
+ };
539
+ const appLoadButtonStyle = {
370
540
  padding: "8px 24px",
371
541
  backgroundColor: "#57005aff",
372
542
  color: "#fff",
@@ -374,97 +544,125 @@ const re = ({ error: t, resetErrorBoundary: e }) => /* @__PURE__ */ y(
374
544
  borderRadius: "4px",
375
545
  cursor: "pointer"
376
546
  };
377
- return /* @__PURE__ */ y("div", { style: { ...n, ...r }, children: [
378
- /* @__PURE__ */ c("h1", { style: a, children: t }),
379
- /* @__PURE__ */ c(
547
+ return /* @__PURE__ */ jsxs4("div", { style: __spreadValues(__spreadValues({}, appLoadContainerStyle), containerStyle), children: [
548
+ /* @__PURE__ */ jsx5("h1", { style: messageStyle, children: message }),
549
+ /* @__PURE__ */ jsx5(
380
550
  "button",
381
551
  {
382
- onClick: e,
383
- style: { ...d, ...s },
384
- children: o
552
+ onClick: onRetry,
553
+ style: __spreadValues(__spreadValues({}, appLoadButtonStyle), buttonStyle),
554
+ children: retryLabel
385
555
  }
386
556
  )
387
557
  ] });
388
- }, Ne = ({
389
- importFn: t,
390
- delay: e = 100,
391
- ErrorFallback: o = le,
392
- errorMessage: r = "Failed to load application"
393
- }) => A.lazy(() => new Promise((a) => {
394
- setTimeout(() => {
395
- t().then((s) => {
396
- a({ default: s.default });
397
- }).catch((s) => {
398
- console.error("Failed to load application:", s), a({
399
- default: () => /* @__PURE__ */ c(
400
- o,
401
- {
402
- error: s,
403
- message: r
404
- }
405
- )
406
- });
558
+ };
559
+ var createLazyAppLoader = ({
560
+ importFn,
561
+ delay = 100,
562
+ ErrorFallback: ErrorFallback2 = DefaultAppLoadErrorFallback,
563
+ errorMessage = "Failed to load application"
564
+ }) => {
565
+ return React4.lazy(() => {
566
+ return new Promise((resolve) => {
567
+ setTimeout(() => {
568
+ importFn().then((mod) => {
569
+ resolve({ default: mod.default });
570
+ }).catch((error) => {
571
+ console.error("Failed to load application:", error);
572
+ resolve({
573
+ default: () => /* @__PURE__ */ jsx5(
574
+ ErrorFallback2,
575
+ {
576
+ error,
577
+ message: errorMessage
578
+ }
579
+ )
580
+ });
581
+ });
582
+ }, delay);
407
583
  });
408
- }, e);
409
- })), F = (t, e) => {
410
- if (typeof document > "u") return e;
411
- const o = getComputedStyle(document.documentElement).getPropertyValue(t).trim(), r = parseInt(o, 10);
412
- return isNaN(r) ? e : r;
413
- }, h = (t) => typeof document > "u" ? null : getComputedStyle(document.documentElement).getPropertyValue(t).trim() || null, ce = (t) => {
414
- const e = {}, o = `--${t}`, r = h(`--primary-color${o}`);
415
- r && (e.primaryColor = r);
416
- const a = h(`--primary-contrast${o}`);
417
- a && (e.primaryContrast = a);
418
- const s = h(`--secondary-color${o}`);
419
- s && (e.secondaryColor = s);
420
- const n = h(`--bodybg-primary${o}`);
421
- n && (e.bodyBgPrimary = n);
422
- const d = h(`--bodybg-secondary${o}`);
423
- d && (e.bodyBgSecondary = d);
424
- const l = h(`--component-bg${o}`);
425
- l && (e.componentBg = l);
426
- const u = h(`--text-color${o}`);
427
- u && (e.textColor = u);
428
- const m = h(`--text-contrast${o}`);
429
- m && (e.textContrast = m);
430
- const g = h(`--heading-color${o}`);
431
- g && (e.headingColor = g);
432
- const i = h(`--link-color${o}`);
433
- i && (e.linkColor = i);
434
- const b = h(`--border-color${o}`);
435
- return b && (e.borderColor = b), e;
436
- }, de = (t, e) => {
437
- const o = ce(t), r = F("--font-size-base", 14), a = F("--border-radius-base", 6), { palette: s, colorSchemes: n, defaultColorScheme: d, ...l } = e || {};
438
- return X({
584
+ });
585
+ };
586
+
587
+ // src/theme/DashThemeProviderLight.tsx
588
+ import { createContext as createContext2, useContext as useContext2, useState as useState3, useEffect as useEffect2, useMemo as useMemo2 } from "react";
589
+ import CssBaseline from "@mui/material/CssBaseline";
590
+ import { createTheme, ThemeProvider } from "@mui/material";
591
+ import { updateDomCssVariables } from "dash-utils";
592
+ import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
593
+ var getCssVariableNumber = (varName, defaultValue) => {
594
+ if (typeof document === "undefined") return defaultValue;
595
+ const value = getComputedStyle(document.documentElement).getPropertyValue(varName).trim();
596
+ const parsed = parseInt(value, 10);
597
+ return isNaN(parsed) ? defaultValue : parsed;
598
+ };
599
+ var getCssVariable = (varName) => {
600
+ if (typeof document === "undefined") return null;
601
+ const value = getComputedStyle(document.documentElement).getPropertyValue(varName).trim();
602
+ return value || null;
603
+ };
604
+ var getThemeColors = (mode) => {
605
+ const colors = {};
606
+ const suffix = `--${mode}`;
607
+ const primaryColor = getCssVariable(`--primary-color${suffix}`);
608
+ if (primaryColor) colors.primaryColor = primaryColor;
609
+ const primaryContrast = getCssVariable(`--primary-contrast${suffix}`);
610
+ if (primaryContrast) colors.primaryContrast = primaryContrast;
611
+ const secondaryColor = getCssVariable(`--secondary-color${suffix}`);
612
+ if (secondaryColor) colors.secondaryColor = secondaryColor;
613
+ const bodyBgPrimary = getCssVariable(`--bodybg-primary${suffix}`);
614
+ if (bodyBgPrimary) colors.bodyBgPrimary = bodyBgPrimary;
615
+ const bodyBgSecondary = getCssVariable(`--bodybg-secondary${suffix}`);
616
+ if (bodyBgSecondary) colors.bodyBgSecondary = bodyBgSecondary;
617
+ const componentBg = getCssVariable(`--component-bg${suffix}`);
618
+ if (componentBg) colors.componentBg = componentBg;
619
+ const textColor = getCssVariable(`--text-color${suffix}`);
620
+ if (textColor) colors.textColor = textColor;
621
+ const textContrast = getCssVariable(`--text-contrast${suffix}`);
622
+ if (textContrast) colors.textContrast = textContrast;
623
+ const headingColor = getCssVariable(`--heading-color${suffix}`);
624
+ if (headingColor) colors.headingColor = headingColor;
625
+ const linkColor = getCssVariable(`--link-color${suffix}`);
626
+ if (linkColor) colors.linkColor = linkColor;
627
+ const borderColor = getCssVariable(`--border-color${suffix}`);
628
+ if (borderColor) colors.borderColor = borderColor;
629
+ return colors;
630
+ };
631
+ var createMinimalTheme = (mode, extendedOptions) => {
632
+ const colors = getThemeColors(mode);
633
+ const fontSizeBase = getCssVariableNumber("--font-size-base", 14);
634
+ const borderRadiusBase = getCssVariableNumber("--border-radius-base", 6);
635
+ const _a = extendedOptions || {}, { palette: _p, colorSchemes: _cs, defaultColorScheme: _dcs } = _a, safeExtendedOptions = __objRest(_a, ["palette", "colorSchemes", "defaultColorScheme"]);
636
+ return createTheme(__spreadValues({
439
637
  breakpoints: {
440
638
  keys: ["xs", "sm", "md", "lg", "xl"],
441
639
  values: { xs: 0, sm: 600, md: 900, lg: 1200, xl: 1536 }
442
640
  },
443
641
  palette: {
444
- mode: t,
642
+ mode,
445
643
  primary: {
446
- main: o.primaryColor,
447
- contrastText: o.primaryContrast
644
+ main: colors.primaryColor,
645
+ contrastText: colors.primaryContrast
448
646
  },
449
647
  secondary: {
450
- main: o.secondaryColor
648
+ main: colors.secondaryColor
451
649
  },
452
650
  background: {
453
- default: o.bodyBgPrimary,
454
- paper: o.componentBg
651
+ default: colors.bodyBgPrimary,
652
+ paper: colors.componentBg
455
653
  },
456
654
  text: {
457
- primary: o.textColor,
458
- secondary: o.textContrast
655
+ primary: colors.textColor,
656
+ secondary: colors.textContrast
459
657
  },
460
- divider: o.borderColor
658
+ divider: colors.borderColor
461
659
  },
462
660
  typography: {
463
661
  fontFamily: '"Montserrat", "Roboto", "Helvetica", "Arial", sans-serif',
464
- fontSize: r
662
+ fontSize: fontSizeBase
465
663
  },
466
664
  shape: {
467
- borderRadius: a
665
+ borderRadius: borderRadiusBase
468
666
  },
469
667
  components: {
470
668
  MuiButton: {
@@ -478,8 +676,8 @@ const re = ({ error: t, resetErrorBoundary: e }) => /* @__PURE__ */ y(
478
676
  MuiCssBaseline: {
479
677
  styleOverrides: {
480
678
  body: {
481
- backgroundColor: o.bodyBgPrimary,
482
- color: o.textColor
679
+ backgroundColor: colors.bodyBgPrimary,
680
+ color: colors.textColor
483
681
  }
484
682
  }
485
683
  },
@@ -490,269 +688,408 @@ const re = ({ error: t, resetErrorBoundary: e }) => /* @__PURE__ */ y(
490
688
  }
491
689
  }
492
690
  }
493
- },
494
- ...l
495
- });
496
- }, W = $(null), He = () => {
497
- const t = V(W);
498
- if (!t)
691
+ }
692
+ }, safeExtendedOptions));
693
+ };
694
+ var DashThemeContext = createContext2(null);
695
+ var useDashThemeContextLight = () => {
696
+ const context = useContext2(DashThemeContext);
697
+ if (!context) {
499
698
  throw new Error("useDashThemeContextLight must be used within a DashThemeProviderLight");
500
- return t;
501
- }, Fe = ({
502
- children: t,
503
- extendedOptions: e,
504
- defaultMode: o
699
+ }
700
+ return context;
701
+ };
702
+ var DashThemeProviderLight = ({
703
+ children,
704
+ extendedOptions,
705
+ defaultMode
505
706
  }) => {
506
- const [r, a] = v(() => {
507
- if (typeof document > "u") return o || "dark";
508
- const i = document.documentElement.getAttribute("data-theme");
509
- return i === "light" || i === "dark" ? i : o || "dark";
510
- }), [s, n] = v(0), d = E(() => de(r, e), [r, e, s]), l = (i) => {
511
- a(i), typeof document < "u" && (document.documentElement.setAttribute("data-theme", i), localStorage.setItem("theme", i), I(i));
512
- }, u = () => {
513
- l(r === "dark" ? "light" : "dark");
514
- }, m = () => {
515
- n((i) => i + 1);
707
+ const [currentMode, setCurrentMode] = useState3(() => {
708
+ if (typeof document === "undefined") return defaultMode || "dark";
709
+ const stored = document.documentElement.getAttribute("data-theme");
710
+ return stored === "light" || stored === "dark" ? stored : defaultMode || "dark";
711
+ });
712
+ const [themeVersion, setThemeVersion] = useState3(0);
713
+ const theme = useMemo2(() => {
714
+ return createMinimalTheme(currentMode, extendedOptions);
715
+ }, [currentMode, extendedOptions, themeVersion]);
716
+ const setMode = (mode) => {
717
+ setCurrentMode(mode);
718
+ if (typeof document !== "undefined") {
719
+ document.documentElement.setAttribute("data-theme", mode);
720
+ localStorage.setItem("theme", mode);
721
+ updateDomCssVariables(mode);
722
+ }
723
+ };
724
+ const toggleMode = () => {
725
+ setMode(currentMode === "dark" ? "light" : "dark");
516
726
  };
517
- p(() => {
518
- if (typeof document > "u") return;
519
- const i = new MutationObserver((b) => {
520
- b.forEach((C) => {
521
- if (C.type === "attributes" && C.attributeName === "data-theme") {
522
- const x = document.documentElement.getAttribute("data-theme");
523
- (x === "light" || x === "dark") && x !== r && a(x);
727
+ const refreshTheme = () => {
728
+ setThemeVersion((v) => v + 1);
729
+ };
730
+ useEffect2(() => {
731
+ if (typeof document === "undefined") return;
732
+ const observer = new MutationObserver((mutations) => {
733
+ mutations.forEach((mutation) => {
734
+ if (mutation.type === "attributes" && mutation.attributeName === "data-theme") {
735
+ const newMode = document.documentElement.getAttribute("data-theme");
736
+ if (newMode === "light" || newMode === "dark") {
737
+ if (newMode !== currentMode) {
738
+ setCurrentMode(newMode);
739
+ }
740
+ }
524
741
  }
525
742
  });
526
743
  });
527
- return i.observe(document.documentElement, {
528
- attributes: !0,
744
+ observer.observe(document.documentElement, {
745
+ attributes: true,
529
746
  attributeFilter: ["data-theme"]
530
- }), () => i.disconnect();
531
- }, [r]), p(() => {
532
- typeof document > "u" || I(r);
533
- }, [r]), p(() => {
534
- if (typeof window > "u") return;
535
- const i = () => {
536
- console.log("DashThemeProviderLight: Refreshing theme from CSS variables"), m();
747
+ });
748
+ return () => observer.disconnect();
749
+ }, [currentMode]);
750
+ useEffect2(() => {
751
+ if (typeof document === "undefined") return;
752
+ updateDomCssVariables(currentMode);
753
+ }, [currentMode]);
754
+ useEffect2(() => {
755
+ if (typeof window === "undefined") return;
756
+ const handler = () => {
757
+ console.log("DashThemeProviderLight: Refreshing theme from CSS variables");
758
+ refreshTheme();
537
759
  };
538
- return window.addEventListener("DASHTRefreshTheme", i), () => window.removeEventListener("DASHTRefreshTheme", i);
760
+ window.addEventListener("DASHTRefreshTheme", handler);
761
+ return () => window.removeEventListener("DASHTRefreshTheme", handler);
539
762
  }, []);
540
- const g = E(
763
+ const contextValue = useMemo2(
541
764
  () => ({
542
- theme: d,
543
- currentMode: r,
544
- setMode: l,
545
- toggleMode: u,
546
- refreshTheme: m
765
+ theme,
766
+ currentMode,
767
+ setMode,
768
+ toggleMode,
769
+ refreshTheme
547
770
  }),
548
- [d, r]
771
+ [theme, currentMode]
549
772
  );
550
- return /* @__PURE__ */ y(Q, { theme: d, children: [
551
- /* @__PURE__ */ c(K, {}),
552
- /* @__PURE__ */ c(W.Provider, { value: g, children: t })
773
+ return /* @__PURE__ */ jsxs5(ThemeProvider, { theme, children: [
774
+ /* @__PURE__ */ jsx6(CssBaseline, {}),
775
+ /* @__PURE__ */ jsx6(DashThemeContext.Provider, { value: contextValue, children })
553
776
  ] });
554
- }, $e = (t) => {
555
- const e = B();
556
- p(() => {
557
- (() => {
558
- console.log("🔍 Bootstrap: Checking for persisted auth data...");
559
- const r = f.getUser(), a = f.getToken(), s = JSON.parse(Y.getItem("authenticated") || "false"), n = f.getAuth();
560
- if (console.log("🔍 Bootstrap: Persisted data check:", {
561
- hasStoredUser: !!r,
562
- hasStoredToken: !!a,
563
- isAuthenticated: s,
564
- hasPersistedAuth: !!n,
565
- currentReduxAuth: t
566
- }), s && r && a && !t) {
567
- console.log("🔄 Bootstrap: Restoring auth session to Redux from localStorage");
568
- let d = r;
569
- if (typeof r == "string") {
570
- console.error("❌ Bootstrap: Stored user is string, this should not happen");
777
+ };
778
+
779
+ // src/utils/DashBootstrapUtils.ts
780
+ import { useEffect as useEffect3, useState as useState4 } from "react";
781
+ import { useDispatch } from "react-redux";
782
+ import { AuthPersistenceService, syncDeviceStoreToLocalStorage, syncLocalStorageToDeviceStore } from "dash-auth";
783
+ import { DASH_REDUX_ACTIONS } from "dash-admin-state";
784
+ import { ACTION_UPDATE_AUTH } from "dash-admin-state/src/redux/reducers/Auth";
785
+ import DASHAuthenticationService from "dash-admin/src/contexts/auth/DASHAuthenticationService";
786
+ import { dashStorage, updateDomCssVariables as updateDomCssVariables2 } from "dash-utils";
787
+ var useInitializeReduxFromPersisted = (currentAuthState) => {
788
+ const dispatch = useDispatch();
789
+ useEffect3(() => {
790
+ const initializeReduxFromPersisted = () => {
791
+ console.log("\u{1F50D} Bootstrap: Checking for persisted auth data...");
792
+ const storedUser = AuthPersistenceService.getUser();
793
+ const storedToken = AuthPersistenceService.getToken();
794
+ const isAuthenticated = JSON.parse(dashStorage.getItem("authenticated") || "false");
795
+ const persistedAuth = AuthPersistenceService.getAuth();
796
+ console.log("\u{1F50D} Bootstrap: Persisted data check:", {
797
+ hasStoredUser: !!storedUser,
798
+ hasStoredToken: !!storedToken,
799
+ isAuthenticated,
800
+ hasPersistedAuth: !!persistedAuth,
801
+ currentReduxAuth: currentAuthState
802
+ });
803
+ if (isAuthenticated && storedUser && storedToken && !currentAuthState) {
804
+ console.log("\u{1F504} Bootstrap: Restoring auth session to Redux from localStorage");
805
+ let userObject = storedUser;
806
+ if (typeof storedUser === "string") {
807
+ console.error("\u274C Bootstrap: Stored user is string, this should not happen");
571
808
  try {
572
- d = JSON.parse(r);
573
- } catch {
574
- console.error(" Bootstrap: Cannot parse user string, clearing auth data"), f.clearAuth();
809
+ userObject = JSON.parse(storedUser);
810
+ } catch (e) {
811
+ console.error("\u274C Bootstrap: Cannot parse user string, clearing auth data");
812
+ AuthPersistenceService.clearAuth();
575
813
  return;
576
814
  }
577
815
  }
578
- e(
579
- S.updateAuth(P, {
580
- user: d,
581
- authenticated: !0,
582
- auth: n?.auth || null
816
+ dispatch(
817
+ DASH_REDUX_ACTIONS.updateAuth(ACTION_UPDATE_AUTH, {
818
+ user: userObject,
819
+ authenticated: true,
820
+ auth: (persistedAuth == null ? void 0 : persistedAuth.auth) || null
583
821
  })
584
- ), console.log("✅ Bootstrap: Redux state restored from persisted data");
822
+ );
823
+ console.log("\u2705 Bootstrap: Redux state restored from persisted data");
585
824
  }
586
- })();
587
- }, [e, t]);
588
- }, Ve = () => {
589
- const t = B();
590
- p(() => {
591
- const e = (o) => {
592
- console.log("🔐 Bootstrap: Received logout event", o.detail), t(
593
- S.updateAuth(P, {
825
+ };
826
+ initializeReduxFromPersisted();
827
+ }, [dispatch, currentAuthState]);
828
+ };
829
+ var useLogoutEventListener = () => {
830
+ const dispatch = useDispatch();
831
+ useEffect3(() => {
832
+ const handleLogoutEvent = (event) => {
833
+ console.log("\u{1F510} Bootstrap: Received logout event", event.detail);
834
+ dispatch(
835
+ DASH_REDUX_ACTIONS.updateAuth(ACTION_UPDATE_AUTH, {
594
836
  user: null,
595
- authenticated: !1,
837
+ authenticated: false,
596
838
  auth: null
597
839
  })
598
- ), f.clearAuth(), localStorage.clear();
840
+ );
841
+ AuthPersistenceService.clearAuth();
842
+ localStorage.clear();
599
843
  };
600
- return window.addEventListener("auth:logout", e), () => {
601
- window.removeEventListener("auth:logout", e);
844
+ window.addEventListener("auth:logout", handleLogoutEvent);
845
+ return () => {
846
+ window.removeEventListener("auth:logout", handleLogoutEvent);
602
847
  };
603
- }, [t]);
604
- }, qe = () => {
605
- const [t, e] = v(!0), [o, r] = v(null), a = B();
606
- return p(() => {
607
- t && (async () => {
848
+ }, [dispatch]);
849
+ };
850
+ var useAppInitialization = () => {
851
+ const [isLoading, setIsLoading] = useState4(true);
852
+ const [initializationError, setInitializationError] = useState4(null);
853
+ const dispatch = useDispatch();
854
+ useEffect3(() => {
855
+ const initializeApp = () => __async(null, null, function* () {
856
+ var _a, _b;
608
857
  try {
609
- console.log("🚀 Bootstrap: Starting app initialization..."), await Z();
610
- const n = await z.initializeApp(!0);
611
- if (console.log("🔍 Bootstrap: Initialization result:", n), n.success) {
612
- if (console.log(" Bootstrap: Auto-login successful"), a(
613
- S.updateAuth(P, {
614
- user: n.user,
615
- authenticated: !0,
616
- auth: n.auth || null
858
+ console.log("\u{1F680} Bootstrap: Starting app initialization...");
859
+ yield syncDeviceStoreToLocalStorage();
860
+ const initResult = yield DASHAuthenticationService.initializeApp(true);
861
+ console.log("\u{1F50D} Bootstrap: Initialization result:", initResult);
862
+ if (initResult.success) {
863
+ console.log("\u2705 Bootstrap: Auto-login successful");
864
+ dispatch(
865
+ DASH_REDUX_ACTIONS.updateAuth(ACTION_UPDATE_AUTH, {
866
+ user: initResult.user,
867
+ authenticated: true,
868
+ auth: initResult.auth || null
617
869
  })
618
- ), window.DashIPCService?.speak(`${n.user?.name}, Bienvenido!`), await D(), r(null), n.redirectAfterLogin) {
619
- console.log("🔄 Bootstrap: Emitting auth:redirect event", n.redirectAfterLogin);
620
- const d = new CustomEvent("auth:redirect", {
621
- detail: { to: n.redirectAfterLogin }
870
+ );
871
+ (_b = window.DashIPCService) == null ? void 0 : _b.speak(`${(_a = initResult.user) == null ? void 0 : _a.name}, Bienvenido!`);
872
+ yield syncLocalStorageToDeviceStore();
873
+ setInitializationError(null);
874
+ if (initResult.redirectAfterLogin) {
875
+ console.log("\u{1F504} Bootstrap: Emitting auth:redirect event", initResult.redirectAfterLogin);
876
+ const event = new CustomEvent("auth:redirect", {
877
+ detail: { to: initResult.redirectAfterLogin }
622
878
  });
623
- window.dispatchEvent(d);
879
+ window.dispatchEvent(event);
624
880
  }
625
881
  } else {
626
- console.log("ℹ️ Bootstrap: No valid authentication found");
627
- const d = f.getAuth();
628
- if (d && d.auth) {
629
- console.log("🔄 Bootstrap: Found persisted auth data, attempting token initialization...");
882
+ console.log("\u2139\uFE0F Bootstrap: No valid authentication found");
883
+ const authData = AuthPersistenceService.getAuth();
884
+ if (authData && authData.auth) {
885
+ console.log("\u{1F504} Bootstrap: Found persisted auth data, attempting token initialization...");
630
886
  try {
631
- const l = await z.initializeFromToken();
632
- if (l.success) {
633
- if (console.log(" Bootstrap: Token initialization successful"), a(
634
- S.updateAuth(P, {
635
- user: l.user,
636
- authenticated: !0,
637
- auth: l.auth || null
887
+ const tokenInitResult = yield DASHAuthenticationService.initializeFromToken();
888
+ if (tokenInitResult.success) {
889
+ console.log("\u2705 Bootstrap: Token initialization successful");
890
+ dispatch(
891
+ DASH_REDUX_ACTIONS.updateAuth(ACTION_UPDATE_AUTH, {
892
+ user: tokenInitResult.user,
893
+ authenticated: true,
894
+ auth: tokenInitResult.auth || null
638
895
  })
639
- ), await D(), r(null), l.redirectAfterLogin) {
896
+ );
897
+ yield syncLocalStorageToDeviceStore();
898
+ setInitializationError(null);
899
+ if (tokenInitResult.redirectAfterLogin) {
640
900
  console.log(
641
- "🔄 Bootstrap: Emitting auth:redirect event",
642
- l.redirectAfterLogin
901
+ "\u{1F504} Bootstrap: Emitting auth:redirect event",
902
+ tokenInitResult.redirectAfterLogin
643
903
  );
644
- const u = new CustomEvent("auth:redirect", {
645
- detail: { to: l.redirectAfterLogin }
904
+ const event = new CustomEvent("auth:redirect", {
905
+ detail: { to: tokenInitResult.redirectAfterLogin }
646
906
  });
647
- window.dispatchEvent(u);
907
+ window.dispatchEvent(event);
648
908
  }
649
- } else
650
- console.log(" Bootstrap: Token initialization failed:", l.error), r(null), f.clearAuth();
651
- } catch (l) {
652
- console.error("❌ Bootstrap: Token initialization error:", l), r(null), f.clearAuth();
909
+ } else {
910
+ console.log("\u274C Bootstrap: Token initialization failed:", tokenInitResult.error);
911
+ setInitializationError(null);
912
+ AuthPersistenceService.clearAuth();
913
+ }
914
+ } catch (error) {
915
+ console.error("\u274C Bootstrap: Token initialization error:", error);
916
+ setInitializationError(null);
917
+ AuthPersistenceService.clearAuth();
653
918
  }
654
- } else
655
- console.log("ℹ️ Bootstrap: No persisted auth data found"), f.clearAuth();
919
+ } else {
920
+ console.log("\u2139\uFE0F Bootstrap: No persisted auth data found");
921
+ AuthPersistenceService.clearAuth();
922
+ }
656
923
  }
657
- } catch (n) {
658
- console.error(" Bootstrap: App initialization failed:", n), r("Failed to initialize application");
924
+ } catch (error) {
925
+ console.error("\u274C Bootstrap: App initialization failed:", error);
926
+ setInitializationError("Failed to initialize application");
659
927
  } finally {
660
- e(!1);
928
+ setIsLoading(false);
661
929
  }
662
- })();
663
- }, [a, t]), { isLoading: t, initializationError: o };
664
- }, Oe = () => {
665
- p(() => {
666
- const e = new URLSearchParams(window.location.search).get("redirect");
667
- e && e !== "/login" && (console.log("ℹ️ RedirectTO: Setting redirect to by searchParams to:", e), z.setPendingRedirect(e));
930
+ });
931
+ if (isLoading) {
932
+ initializeApp();
933
+ }
934
+ }, [dispatch, isLoading]);
935
+ return { isLoading, initializationError };
936
+ };
937
+ var usePendingRedirect = () => {
938
+ useEffect3(() => {
939
+ const searchParams = new URLSearchParams(window.location.search);
940
+ const redirectTo = searchParams.get("redirect");
941
+ if (redirectTo && redirectTo !== "/login") {
942
+ console.log("\u2139\uFE0F RedirectTO: Setting redirect to by searchParams to:", redirectTo);
943
+ DASHAuthenticationService.setPendingRedirect(redirectTo);
944
+ }
668
945
  }, []);
669
- }, ue = "dash:locale-change", We = (t = ["es", "en"], e = "es") => {
670
- const o = B();
671
- p(() => {
672
- if (typeof window > "u") return;
673
- const a = new URLSearchParams(window.location.search).get("lang"), s = localStorage.getItem("dash-user-locale");
674
- let n = e;
675
- a && t.includes(a) ? n = a : s && t.includes(s) && (n = s), s !== n ? (console.log(`🌐 Bootstrap: Locale change detected: ${s} -> ${n}`), localStorage.setItem("dash-user-locale", n)) : console.log(`🌐 Bootstrap: Initializing locale from storage: ${n}`), console.log(`🌐 Bootstrap: Dispatching locale to Redux: ${n}`), o(S.switchLanguage(n)), console.log(`🌐 Bootstrap: Emitting locale change event: ${n}`), window.dispatchEvent(new CustomEvent(ue, {
676
- detail: { locale: n }
946
+ };
947
+ var LOCALE_CHANGE_EVENT2 = "dash:locale-change";
948
+ var useUrlLocaleDetection = (availableLocales = ["es", "en"], defaultLocale = "es") => {
949
+ const dispatch = useDispatch();
950
+ useEffect3(() => {
951
+ if (typeof window === "undefined") return;
952
+ const searchParams = new URLSearchParams(window.location.search);
953
+ const langParam = searchParams.get("lang");
954
+ const storedLocale = localStorage.getItem("dash-user-locale");
955
+ let targetLocale = defaultLocale;
956
+ if (langParam && availableLocales.includes(langParam)) {
957
+ targetLocale = langParam;
958
+ } else if (storedLocale && availableLocales.includes(storedLocale)) {
959
+ targetLocale = storedLocale;
960
+ }
961
+ const isNewLocale = storedLocale !== targetLocale;
962
+ if (isNewLocale) {
963
+ console.log(`\u{1F310} Bootstrap: Locale change detected: ${storedLocale} -> ${targetLocale}`);
964
+ localStorage.setItem("dash-user-locale", targetLocale);
965
+ } else {
966
+ console.log(`\u{1F310} Bootstrap: Initializing locale from storage: ${targetLocale}`);
967
+ }
968
+ console.log(`\u{1F310} Bootstrap: Dispatching locale to Redux: ${targetLocale}`);
969
+ dispatch(DASH_REDUX_ACTIONS.switchLanguage(targetLocale));
970
+ console.log(`\u{1F310} Bootstrap: Emitting locale change event: ${targetLocale}`);
971
+ window.dispatchEvent(new CustomEvent(LOCALE_CHANGE_EVENT2, {
972
+ detail: { locale: targetLocale }
677
973
  }));
678
- }, [o, t, e]);
679
- }, je = () => {
680
- const [t, e] = v(
681
- typeof window < "u" ? window.location.pathname : "/"
974
+ }, [dispatch, availableLocales, defaultLocale]);
975
+ };
976
+ var usePathnameTracker = () => {
977
+ const [pathname, setPathname] = useState4(
978
+ typeof window !== "undefined" ? window.location.pathname : "/"
682
979
  );
683
- return p(() => {
684
- if (typeof window > "u") return;
685
- const o = () => {
686
- const r = window.location.pathname;
687
- r !== t && (console.log("🔍 Bootstrap: URL changed from", t, "to", r), e(r));
980
+ useEffect3(() => {
981
+ if (typeof window === "undefined") return;
982
+ const handleUrlChange = () => {
983
+ const newPathname = window.location.pathname;
984
+ if (newPathname !== pathname) {
985
+ console.log("\u{1F50D} Bootstrap: URL changed from", pathname, "to", newPathname);
986
+ setPathname(newPathname);
987
+ }
688
988
  };
689
- return window.addEventListener("popstate", o), () => window.removeEventListener("popstate", o);
690
- }, [t]), t;
691
- }, Ue = (t = "dark") => {
692
- p(() => {
693
- if (typeof document > "u") return;
694
- const e = localStorage.getItem("theme"), o = e === "light" || e === "dark" ? e : t;
695
- document.documentElement.setAttribute("data-theme", o), e || localStorage.setItem("theme", o);
696
- }, [t]);
697
- }, _e = (t) => {
698
- if (typeof document > "u" || typeof localStorage > "u") return;
699
- const e = localStorage.getItem("theme"), o = e === "light" || e === "dark" ? e : t;
700
- document.documentElement.setAttribute("data-theme", o), e || localStorage.setItem("theme", o);
989
+ window.addEventListener("popstate", handleUrlChange);
990
+ return () => window.removeEventListener("popstate", handleUrlChange);
991
+ }, [pathname]);
992
+ return pathname;
993
+ };
994
+ var useEarlyThemeInit = (defaultTheme = "dark") => {
995
+ useEffect3(() => {
996
+ if (typeof document === "undefined") return;
997
+ const stored = localStorage.getItem("theme");
998
+ const theme = stored === "light" || stored === "dark" ? stored : defaultTheme;
999
+ document.documentElement.setAttribute("data-theme", theme);
1000
+ if (!stored) {
1001
+ localStorage.setItem("theme", theme);
1002
+ }
1003
+ }, [defaultTheme]);
1004
+ };
1005
+ var initializeThemeEarly = (defaultTheme) => {
1006
+ if (typeof document === "undefined" || typeof localStorage === "undefined") return;
1007
+ const stored = localStorage.getItem("theme");
1008
+ const theme = stored === "light" || stored === "dark" ? stored : defaultTheme;
1009
+ document.documentElement.setAttribute("data-theme", theme);
1010
+ if (!stored) {
1011
+ localStorage.setItem("theme", theme);
1012
+ }
701
1013
  try {
702
- I(o), console.log("🎨 Bootstrap: Initialized theme variables for:", o);
703
- } catch (r) {
704
- console.warn("Failed to initialize theme variables:", r);
1014
+ updateDomCssVariables2(theme);
1015
+ console.log("\u{1F3A8} Bootstrap: Initialized theme variables for:", theme);
1016
+ } catch (error) {
1017
+ console.warn("Failed to initialize theme variables:", error);
705
1018
  }
706
- }, Je = async () => {
707
- if (typeof window > "u") return;
708
- const t = window.electronStore;
709
- if (t) {
710
- const e = await t.syncToLocalStorage();
711
- Object.entries(e).forEach(([o, r]) => {
712
- window.localStorage.setItem(o, JSON.stringify(r));
1019
+ };
1020
+ var syncElectronStore = () => __async(null, null, function* () {
1021
+ if (typeof window === "undefined") return;
1022
+ const electronStore = window.electronStore;
1023
+ if (electronStore) {
1024
+ const all = yield electronStore.syncToLocalStorage();
1025
+ Object.entries(all).forEach(([key, value]) => {
1026
+ window.localStorage.setItem(key, JSON.stringify(value));
713
1027
  });
714
1028
  }
715
- }, Ge = async () => {
716
- if (!(typeof window > "u") && window.electronStore)
1029
+ });
1030
+
1031
+ // src/utils/electronStore.ts
1032
+ var syncElectronStoreToLocalStorage = () => __async(null, null, function* () {
1033
+ if (typeof window === "undefined") return;
1034
+ if (window.electronStore) {
1035
+ try {
1036
+ const all = yield window.electronStore.syncToLocalStorage();
1037
+ Object.entries(all).forEach(([key, value]) => {
1038
+ window.localStorage.setItem(key, JSON.stringify(value));
1039
+ });
1040
+ console.log("\u2705 Electron store synced to localStorage");
1041
+ } catch (error) {
1042
+ console.error("\u274C Failed to sync Electron store:", error);
1043
+ }
1044
+ }
1045
+ });
1046
+ var isElectron = () => {
1047
+ return typeof window !== "undefined" && !!window.electronStore;
1048
+ };
1049
+ var getElectronStoreValue = (key, defaultValue) => __async(null, null, function* () {
1050
+ if (typeof window === "undefined") return defaultValue;
1051
+ if (window.electronStore) {
717
1052
  try {
718
- const t = await window.electronStore.syncToLocalStorage();
719
- Object.entries(t).forEach(([e, o]) => {
720
- window.localStorage.setItem(e, JSON.stringify(o));
721
- }), console.log("✅ Electron store synced to localStorage");
722
- } catch (t) {
723
- console.error("❌ Failed to sync Electron store:", t);
1053
+ return yield window.electronStore.get(key);
1054
+ } catch (e) {
1055
+ return defaultValue;
724
1056
  }
725
- }, Ke = () => typeof window < "u" && !!window.electronStore, Qe = async (t, e) => {
726
- if (typeof window > "u") return e;
727
- if (window.electronStore)
1057
+ }
1058
+ const stored = localStorage.getItem(key);
1059
+ if (stored) {
728
1060
  try {
729
- return await window.electronStore.get(t);
730
- } catch {
731
- return e;
1061
+ return JSON.parse(stored);
1062
+ } catch (e) {
1063
+ return stored;
732
1064
  }
733
- const o = localStorage.getItem(t);
734
- if (o)
1065
+ }
1066
+ return defaultValue;
1067
+ });
1068
+ var setElectronStoreValue = (key, value) => __async(null, null, function* () {
1069
+ if (typeof window === "undefined") return;
1070
+ if (window.electronStore) {
735
1071
  try {
736
- return JSON.parse(o);
737
- } catch {
738
- return o;
1072
+ yield window.electronStore.set(key, value);
1073
+ } catch (error) {
1074
+ console.error("Failed to set Electron store value:", error);
739
1075
  }
740
- return e;
741
- }, Xe = async (t, e) => {
742
- if (!(typeof window > "u")) {
743
- if (window.electronStore)
744
- try {
745
- await window.electronStore.set(t, e);
746
- } catch (o) {
747
- console.error("Failed to set Electron store value:", o);
748
- }
749
- localStorage.setItem(t, JSON.stringify(e));
750
1076
  }
751
- }, L = (t, e) => {
752
- if (typeof document > "u") return e;
753
- const o = getComputedStyle(document.documentElement).getPropertyValue(t).trim(), r = parseInt(o, 10);
754
- return isNaN(r) ? e : r;
755
- }, Ye = (t, e = "") => typeof document > "u" ? e : getComputedStyle(document.documentElement).getPropertyValue(t).trim() || e, w = {
1077
+ localStorage.setItem(key, JSON.stringify(value));
1078
+ });
1079
+
1080
+ // src/utils/cssVariables.ts
1081
+ var getCssVariableNumber2 = (varName, defaultValue) => {
1082
+ if (typeof document === "undefined") return defaultValue;
1083
+ const value = getComputedStyle(document.documentElement).getPropertyValue(varName).trim();
1084
+ const parsed = parseInt(value, 10);
1085
+ return isNaN(parsed) ? defaultValue : parsed;
1086
+ };
1087
+ var getCssVariableString = (varName, defaultValue = "") => {
1088
+ if (typeof document === "undefined") return defaultValue;
1089
+ const value = getComputedStyle(document.documentElement).getPropertyValue(varName).trim();
1090
+ return value || defaultValue;
1091
+ };
1092
+ var DEFAULT_LAYOUT_DIMENSIONS = {
756
1093
  sidebarLargeWidth: 255,
757
1094
  sidebarSmallWidth: 64,
758
1095
  sidebarHorizontalHeight: 120,
@@ -760,68 +1097,68 @@ const re = ({ error: t, resetErrorBoundary: e }) => /* @__PURE__ */ y(
760
1097
  logoVerticalMaxHeight: 130,
761
1098
  logoHorizontalMaxWidth: 200,
762
1099
  logoHorizontalMaxHeight: 60
763
- }, ge = () => ({
764
- sidebarLargeWidth: L("--sidebar-large-width", w.sidebarLargeWidth),
765
- sidebarSmallWidth: L("--sidebar-small-width", w.sidebarSmallWidth),
766
- sidebarHorizontalHeight: L("--sidebar-horizontal-height", w.sidebarHorizontalHeight),
767
- logoVerticalMaxWidth: L("--logo-vertical-max-width", w.logoVerticalMaxWidth),
768
- logoVerticalMaxHeight: L("--logo-vertical-max-height", w.logoVerticalMaxHeight),
769
- logoHorizontalMaxWidth: L("--logo-horizontal-max-width", w.logoHorizontalMaxWidth),
770
- logoHorizontalMaxHeight: L("--logo-horizontal-max-height", w.logoHorizontalMaxHeight)
771
- }), Ze = (t = {}) => {
772
- const e = {
773
- ...w,
774
- ...ge(),
775
- ...t.layoutDimensions
776
- };
1100
+ };
1101
+ var getLayoutDimensionsFromCss = () => {
777
1102
  return {
778
- appName: t.appName || "Dash App",
779
- horizontalLogo: t.horizontalLogo,
780
- squaredLogo: t.squaredLogo,
781
- loginBackground: t.loginBackground,
782
- sidebarPosition: t.sidebarPosition || "left",
783
- ...e,
784
- // Padding configuration (derived from sidebar sizes)
785
- paddingHorizontal: e.sidebarLargeWidth,
786
- paddingVertical: e.sidebarHorizontalHeight
1103
+ sidebarLargeWidth: getCssVariableNumber2("--sidebar-large-width", DEFAULT_LAYOUT_DIMENSIONS.sidebarLargeWidth),
1104
+ sidebarSmallWidth: getCssVariableNumber2("--sidebar-small-width", DEFAULT_LAYOUT_DIMENSIONS.sidebarSmallWidth),
1105
+ sidebarHorizontalHeight: getCssVariableNumber2("--sidebar-horizontal-height", DEFAULT_LAYOUT_DIMENSIONS.sidebarHorizontalHeight),
1106
+ logoVerticalMaxWidth: getCssVariableNumber2("--logo-vertical-max-width", DEFAULT_LAYOUT_DIMENSIONS.logoVerticalMaxWidth),
1107
+ logoVerticalMaxHeight: getCssVariableNumber2("--logo-vertical-max-height", DEFAULT_LAYOUT_DIMENSIONS.logoVerticalMaxHeight),
1108
+ logoHorizontalMaxWidth: getCssVariableNumber2("--logo-horizontal-max-width", DEFAULT_LAYOUT_DIMENSIONS.logoHorizontalMaxWidth),
1109
+ logoHorizontalMaxHeight: getCssVariableNumber2("--logo-horizontal-max-height", DEFAULT_LAYOUT_DIMENSIONS.logoHorizontalMaxHeight)
787
1110
  };
788
1111
  };
1112
+ var createDefaultPanelSettings = (options = {}) => {
1113
+ const dimensions = __spreadValues(__spreadValues(__spreadValues({}, DEFAULT_LAYOUT_DIMENSIONS), getLayoutDimensionsFromCss()), options.layoutDimensions);
1114
+ return __spreadProps(__spreadValues({
1115
+ appName: options.appName || "Dash App",
1116
+ horizontalLogo: options.horizontalLogo,
1117
+ squaredLogo: options.squaredLogo,
1118
+ loginBackground: options.loginBackground,
1119
+ sidebarPosition: options.sidebarPosition || "left"
1120
+ }, dimensions), {
1121
+ // Padding configuration (derived from sidebar sizes)
1122
+ paddingHorizontal: dimensions.sidebarLargeWidth,
1123
+ paddingVertical: dimensions.sidebarHorizontalHeight
1124
+ });
1125
+ };
789
1126
  export {
790
- De as AppWrapperLight,
791
- Re as CustomErrorBoundary,
792
- w as DEFAULT_LAYOUT_DIMENSIONS,
793
- W as DashThemeContext,
794
- Fe as DashThemeProviderLight,
795
- le as DefaultAppLoadErrorFallback,
796
- Me as DefaultInitializationErrorFallback,
797
- Ae as GlobalLoaderHtmlMarkup,
798
- ze as GlobalSmallLoader,
799
- q as I18nBridgeContext,
800
- Ee as I18nBridgeProviderLight,
801
- Ze as createDefaultPanelSettings,
802
- Ne as createLazyAppLoader,
803
- Ce as createSimpleI18nProvider,
804
- L as getCssVariableNumber,
805
- Ye as getCssVariableString,
806
- Qe as getElectronStoreValue,
807
- ge as getLayoutDimensionsFromCss,
808
- _e as initializeThemeEarly,
809
- Te as injectCriticalStyles,
810
- Ke as isElectron,
811
- Xe as setElectronStoreValue,
812
- Je as syncElectronStore,
813
- Ge as syncElectronStoreToLocalStorage,
814
- qe as useAppInitialization,
815
- Be as useBridgedChangeLocaleLight,
816
- ke as useBridgedLocaleLight,
817
- Pe as useBridgedLocalesLight,
818
- He as useDashThemeContextLight,
819
- Ue as useEarlyThemeInit,
820
- k as useI18nBridgeLight,
821
- $e as useInitializeReduxFromPersisted,
822
- Ve as useLogoutEventListener,
823
- je as usePathnameTracker,
824
- Oe as usePendingRedirect,
825
- Ie as useTranslateLight,
826
- We as useUrlLocaleDetection
1127
+ AppWrapperLight,
1128
+ CustomErrorBoundary,
1129
+ DEFAULT_LAYOUT_DIMENSIONS,
1130
+ DashThemeContext,
1131
+ DashThemeProviderLight,
1132
+ DefaultAppLoadErrorFallback,
1133
+ DefaultInitializationErrorFallback,
1134
+ GlobalLoaderHtmlMarkup,
1135
+ GlobalSmallLoader,
1136
+ I18nBridgeContext,
1137
+ I18nBridgeProviderLight,
1138
+ createDefaultPanelSettings,
1139
+ createLazyAppLoader,
1140
+ createSimpleI18nProvider,
1141
+ getCssVariableNumber2 as getCssVariableNumber,
1142
+ getCssVariableString,
1143
+ getElectronStoreValue,
1144
+ getLayoutDimensionsFromCss,
1145
+ initializeThemeEarly,
1146
+ injectCriticalStyles,
1147
+ isElectron,
1148
+ setElectronStoreValue,
1149
+ syncElectronStore,
1150
+ syncElectronStoreToLocalStorage,
1151
+ useAppInitialization,
1152
+ useBridgedChangeLocaleLight,
1153
+ useBridgedLocaleLight,
1154
+ useBridgedLocalesLight,
1155
+ useDashThemeContextLight,
1156
+ useEarlyThemeInit,
1157
+ useI18nBridgeLight,
1158
+ useInitializeReduxFromPersisted,
1159
+ useLogoutEventListener,
1160
+ usePathnameTracker,
1161
+ usePendingRedirect,
1162
+ useTranslateLight,
1163
+ useUrlLocaleDetection
827
1164
  };