@dashadmin/dash-utils 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/index.d.ts +3 -0
- package/index.js +935 -0
- package/package.json +31 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# INSTRUCTIONS
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,935 @@
|
|
|
1
|
+
import v, { useState as S, useEffect as L, useCallback as b, Suspense as ie, createContext as ae, useRef as ce, useContext as de } from "react";
|
|
2
|
+
import { useDispatch as le } from "react-redux";
|
|
3
|
+
import { HashRouter as V, BrowserRouter as H, Routes as ue } from "react-router-dom";
|
|
4
|
+
const He = () => {
|
|
5
|
+
const [e, t] = S({
|
|
6
|
+
width: void 0,
|
|
7
|
+
height: void 0
|
|
8
|
+
});
|
|
9
|
+
return L(() => {
|
|
10
|
+
function n() {
|
|
11
|
+
t({
|
|
12
|
+
width: window.innerWidth,
|
|
13
|
+
height: window.innerHeight
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return window.addEventListener("resize", n), n(), () => window.removeEventListener("resize", n);
|
|
17
|
+
}, []), e;
|
|
18
|
+
}, Ue = (e) => {
|
|
19
|
+
L(() => {
|
|
20
|
+
const t = window?.Capacitor?.Plugins?.App;
|
|
21
|
+
if (console.log("[useCapacitorAppStateRefresh] Checking for Capacitor App plugin:", !!t), !t) return;
|
|
22
|
+
const n = (r) => {
|
|
23
|
+
console.log("[useCapacitorAppStateRefresh] App state changed:", r), r.isActive && (console.log("[useCapacitorAppStateRefresh] App is resuming, triggering callback"), e?.());
|
|
24
|
+
};
|
|
25
|
+
return t.addListener("appStateChange", n), console.log("[useCapacitorAppStateRefresh] Added appStateChange listener"), () => {
|
|
26
|
+
t.removeAllListeners?.(), console.log("[useCapacitorAppStateRefresh] Removed all Capacitor App listeners");
|
|
27
|
+
};
|
|
28
|
+
}, [e]);
|
|
29
|
+
}, Xe = () => {
|
|
30
|
+
L(() => {
|
|
31
|
+
(async () => {
|
|
32
|
+
const t = window.electronStore;
|
|
33
|
+
t && t.getAll && console.log("[useDeviceStorageSync] Electron store detected");
|
|
34
|
+
})();
|
|
35
|
+
}, []);
|
|
36
|
+
}, F = () => {
|
|
37
|
+
const e = !!window?.Capacitor?.Plugins?.Keyboard, t = !!window?.CapacitorKeyboard;
|
|
38
|
+
return e || t;
|
|
39
|
+
}, K = () => window?.Capacitor?.Plugins?.Keyboard || window?.CapacitorKeyboard, Be = (e = {}) => {
|
|
40
|
+
const {
|
|
41
|
+
disableAccessoryBar: t = !0,
|
|
42
|
+
resizeMode: n = "body",
|
|
43
|
+
debug: r = !1
|
|
44
|
+
} = e, [i, o] = S({
|
|
45
|
+
isKeyboardOpen: !1,
|
|
46
|
+
keyboardHeight: 0
|
|
47
|
+
}), s = b((c, d) => {
|
|
48
|
+
r && console.log(`[useCapacitorKeyboard] ${c}`, d || "");
|
|
49
|
+
}, [r]), a = b(async () => {
|
|
50
|
+
if (F()) {
|
|
51
|
+
const c = K();
|
|
52
|
+
if (c?.hide)
|
|
53
|
+
try {
|
|
54
|
+
s("Hiding keyboard..."), await c.hide();
|
|
55
|
+
} catch (d) {
|
|
56
|
+
s("Error hiding keyboard:", d);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}, [s]), u = b(async () => {
|
|
60
|
+
if (F()) {
|
|
61
|
+
const c = K();
|
|
62
|
+
if (c?.show)
|
|
63
|
+
try {
|
|
64
|
+
s("Showing keyboard..."), await c.show();
|
|
65
|
+
} catch (d) {
|
|
66
|
+
s("Error showing keyboard:", d);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}, [s]);
|
|
70
|
+
return L(() => {
|
|
71
|
+
(async () => {
|
|
72
|
+
if (F()) {
|
|
73
|
+
const d = K();
|
|
74
|
+
if (d)
|
|
75
|
+
try {
|
|
76
|
+
s("Configuring Capacitor Keyboard..."), d.setAccessoryBarVisible && await d.setAccessoryBarVisible({ isVisible: !t }), d.setResizeMode && await d.setResizeMode({ mode: n }), s("Capacitor Keyboard configured successfully");
|
|
77
|
+
} catch (m) {
|
|
78
|
+
s("Error configuring Capacitor Keyboard:", m);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
})();
|
|
82
|
+
}, [t, n, s]), L(() => {
|
|
83
|
+
if (F()) {
|
|
84
|
+
const d = K();
|
|
85
|
+
if (d) {
|
|
86
|
+
s("Using Capacitor Keyboard API");
|
|
87
|
+
const m = (E) => {
|
|
88
|
+
s("Keyboard will show", { height: E.keyboardHeight }), o({
|
|
89
|
+
isKeyboardOpen: !0,
|
|
90
|
+
keyboardHeight: E.keyboardHeight
|
|
91
|
+
});
|
|
92
|
+
}, w = (E) => {
|
|
93
|
+
o({
|
|
94
|
+
isKeyboardOpen: !0,
|
|
95
|
+
keyboardHeight: E.keyboardHeight
|
|
96
|
+
});
|
|
97
|
+
}, y = () => {
|
|
98
|
+
s("Keyboard will hide"), o({
|
|
99
|
+
isKeyboardOpen: !1,
|
|
100
|
+
keyboardHeight: 0
|
|
101
|
+
});
|
|
102
|
+
}, P = () => {
|
|
103
|
+
o({
|
|
104
|
+
isKeyboardOpen: !1,
|
|
105
|
+
keyboardHeight: 0
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
return d.addListener("keyboardWillShow", m), d.addListener("keyboardDidShow", w), d.addListener("keyboardWillHide", y), d.addListener("keyboardDidHide", P), () => {
|
|
109
|
+
d.removeAllListeners?.();
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
s("Using fallback viewport-based keyboard detection");
|
|
114
|
+
const c = () => {
|
|
115
|
+
const d = window.visualViewport?.height || window.innerHeight, m = window.screen.height, w = m * 0.75, y = d < w;
|
|
116
|
+
if (y !== i.isKeyboardOpen) {
|
|
117
|
+
const P = y ? m - d : 0;
|
|
118
|
+
s(y ? "Keyboard opened (fallback)" : "Keyboard closed (fallback)", {
|
|
119
|
+
height: P
|
|
120
|
+
}), o({
|
|
121
|
+
isKeyboardOpen: y,
|
|
122
|
+
keyboardHeight: P
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
return window.addEventListener("resize", c), window.visualViewport && window.visualViewport.addEventListener("resize", c), () => {
|
|
127
|
+
window.removeEventListener("resize", c), window.visualViewport && window.visualViewport.removeEventListener("resize", c);
|
|
128
|
+
};
|
|
129
|
+
}, [s, i.isKeyboardOpen]), {
|
|
130
|
+
...i,
|
|
131
|
+
hideKeyboard: a,
|
|
132
|
+
showKeyboard: u,
|
|
133
|
+
isCapacitorAvailable: F()
|
|
134
|
+
};
|
|
135
|
+
}, U = (e = 700) => {
|
|
136
|
+
const t = document.body.className, n = t.includes("webview") || t.includes("android") || t.includes("ios") || t.includes("mobile"), i = window.innerWidth < e;
|
|
137
|
+
return n || i;
|
|
138
|
+
}, X = () => {
|
|
139
|
+
const e = navigator.userAgent.toLowerCase();
|
|
140
|
+
return /(webview|wv)/.test(e) || /android.*(wv|.net)/.test(e) || /iphone|ipod|ipad.*applewebkit(?!.*safari)/i.test(e);
|
|
141
|
+
}, B = () => /android/i.test(navigator.userAgent.toLowerCase()), j = () => /iphone|ipad|ipod/i.test(navigator.userAgent.toLowerCase()), je = () => {
|
|
142
|
+
try {
|
|
143
|
+
return globalThis.process?.platform === "win32" ? !0 : navigator.userAgent.toLowerCase().includes("windows");
|
|
144
|
+
} catch {
|
|
145
|
+
return !1;
|
|
146
|
+
}
|
|
147
|
+
}, Ze = () => {
|
|
148
|
+
try {
|
|
149
|
+
return globalThis.process?.platform === "darwin" ? !0 : /macintosh|mac os x/i.test(navigator.userAgent.toLowerCase());
|
|
150
|
+
} catch {
|
|
151
|
+
return !1;
|
|
152
|
+
}
|
|
153
|
+
}, Je = () => {
|
|
154
|
+
try {
|
|
155
|
+
return globalThis.process?.platform === "linux" ? !0 : /linux/i.test(navigator.userAgent.toLowerCase());
|
|
156
|
+
} catch {
|
|
157
|
+
return !1;
|
|
158
|
+
}
|
|
159
|
+
}, Ye = (e = {}) => {
|
|
160
|
+
const { mobileBreakpoint: t = 700, debug: n = !1 } = e, [r, i] = S(() => ({
|
|
161
|
+
isMobile: U(t),
|
|
162
|
+
isAndroid: B(),
|
|
163
|
+
isIOS: j(),
|
|
164
|
+
isWebView: X(),
|
|
165
|
+
screenWidth: window.innerWidth
|
|
166
|
+
})), o = b((s, a) => {
|
|
167
|
+
n && console.log(`[useMobileDetection] ${s}`, a || "");
|
|
168
|
+
}, [n]);
|
|
169
|
+
return L(() => {
|
|
170
|
+
const s = () => {
|
|
171
|
+
const a = {
|
|
172
|
+
isMobile: U(t),
|
|
173
|
+
isAndroid: B(),
|
|
174
|
+
isIOS: j(),
|
|
175
|
+
isWebView: X(),
|
|
176
|
+
screenWidth: window.innerWidth
|
|
177
|
+
};
|
|
178
|
+
(a.isMobile !== r.isMobile || a.screenWidth !== r.screenWidth) && (o("Mobile detection state changed", a), i(a));
|
|
179
|
+
};
|
|
180
|
+
return window.addEventListener("resize", s), window.addEventListener("orientationchange", s), () => {
|
|
181
|
+
window.removeEventListener("resize", s), window.removeEventListener("orientationchange", s);
|
|
182
|
+
};
|
|
183
|
+
}, [t, r.isMobile, r.screenWidth, o]), L(() => {
|
|
184
|
+
o("Initial mobile detection", r);
|
|
185
|
+
}, []), r;
|
|
186
|
+
}, qe = (e = {}) => {
|
|
187
|
+
const {
|
|
188
|
+
initialPosition: t = { x: 0, y: 0 },
|
|
189
|
+
minX: n = 0,
|
|
190
|
+
minY: r = 0,
|
|
191
|
+
maxX: i,
|
|
192
|
+
maxY: o,
|
|
193
|
+
elementWidth: s = 400,
|
|
194
|
+
elementHeight: a = 200,
|
|
195
|
+
onPositionChange: u,
|
|
196
|
+
onDragStart: c,
|
|
197
|
+
onDragEnd: d
|
|
198
|
+
} = e, [m, w] = S(t), [y, P] = S(!1), [E, D] = S({ x: 0, y: 0 }), N = b(() => i !== void 0 ? i : typeof window < "u" ? window.innerWidth - s : 1e3, [i, s]), O = b(() => o !== void 0 ? o : typeof window < "u" ? window.innerHeight - a : 800, [o, a]), k = b((A) => {
|
|
199
|
+
A.target.closest(".drag-handle") && (A.preventDefault(), P(!0), D({
|
|
200
|
+
x: A.clientX - m.x,
|
|
201
|
+
y: A.clientY - m.y
|
|
202
|
+
}), c?.());
|
|
203
|
+
}, [m, c]), C = b((A) => {
|
|
204
|
+
if (y) {
|
|
205
|
+
A.preventDefault();
|
|
206
|
+
const M = Math.max(n, Math.min(N(), A.clientX - E.x)), f = Math.max(r, Math.min(O(), A.clientY - E.y)), g = { x: M, y: f };
|
|
207
|
+
w(g), u?.(g);
|
|
208
|
+
}
|
|
209
|
+
}, [y, E, n, r, N, O, u]), I = b(() => {
|
|
210
|
+
y && (P(!1), d?.());
|
|
211
|
+
}, [y, d]);
|
|
212
|
+
return L(() => {
|
|
213
|
+
if (y)
|
|
214
|
+
return document.addEventListener("mousemove", C), document.addEventListener("mouseup", I), document.body.style.userSelect = "none", () => {
|
|
215
|
+
document.removeEventListener("mousemove", C), document.removeEventListener("mouseup", I), document.body.style.userSelect = "";
|
|
216
|
+
};
|
|
217
|
+
}, [y, C, I]), L(() => {
|
|
218
|
+
w(t);
|
|
219
|
+
}, [t.x, t.y]), {
|
|
220
|
+
position: m,
|
|
221
|
+
isDragging: y,
|
|
222
|
+
handleMouseDown: k,
|
|
223
|
+
setPosition: w
|
|
224
|
+
};
|
|
225
|
+
}, Z = () => `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, Ge = (e = {}) => {
|
|
226
|
+
const {
|
|
227
|
+
maxNotifications: t = 50,
|
|
228
|
+
initialZIndex: n = 1e5,
|
|
229
|
+
toastAutoDismiss: r = 8e3
|
|
230
|
+
} = e, [i, o] = S([]), [s, a] = S([]), [u, c] = S([]), [d, m] = S(n), w = i.filter((f) => !f.isRead).length, y = b((f) => {
|
|
231
|
+
const g = {
|
|
232
|
+
...f,
|
|
233
|
+
id: Z(),
|
|
234
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
235
|
+
isRead: !1
|
|
236
|
+
};
|
|
237
|
+
return o((p) => [g, ...p.slice(0, t - 1)]), g;
|
|
238
|
+
}, [t]), P = b((f) => {
|
|
239
|
+
const g = `toast-${Z()}`;
|
|
240
|
+
return a((p) => [...p, { ...f, id: g }]), g;
|
|
241
|
+
}, []), E = b((f) => {
|
|
242
|
+
const g = y(f);
|
|
243
|
+
let p;
|
|
244
|
+
return c((l) => {
|
|
245
|
+
const T = l.length, $ = 20, z = typeof window < "u" ? window.innerHeight - 250 : 500, x = T * -220;
|
|
246
|
+
return p = {
|
|
247
|
+
...g,
|
|
248
|
+
position: { x: $, y: z + x },
|
|
249
|
+
zIndex: n + T + 1
|
|
250
|
+
}, [...l, p];
|
|
251
|
+
}), m((l) => l + 1), p;
|
|
252
|
+
}, [y, n]), D = b((f) => {
|
|
253
|
+
o(
|
|
254
|
+
(g) => g.map((p) => p.id === f ? { ...p, isRead: !0 } : p)
|
|
255
|
+
);
|
|
256
|
+
}, []), N = b(() => {
|
|
257
|
+
o((f) => f.map((g) => ({ ...g, isRead: !0 })));
|
|
258
|
+
}, []), O = b((f) => {
|
|
259
|
+
o((g) => g.filter((p) => p.id !== f));
|
|
260
|
+
}, []), k = b(() => {
|
|
261
|
+
o([]);
|
|
262
|
+
}, []), C = b((f) => {
|
|
263
|
+
a((g) => g.filter((p) => p.id !== f));
|
|
264
|
+
}, []), I = b((f) => {
|
|
265
|
+
c((g) => g.filter((p) => p.id !== f)), D(f);
|
|
266
|
+
}, [D]), A = b((f) => {
|
|
267
|
+
c((g) => {
|
|
268
|
+
const p = Math.max(...g.map((l) => l.zIndex), n);
|
|
269
|
+
return g.map(
|
|
270
|
+
(l) => l.id === f ? { ...l, zIndex: p + 1 } : l
|
|
271
|
+
);
|
|
272
|
+
});
|
|
273
|
+
}, [n]), M = b((f, g) => {
|
|
274
|
+
c(
|
|
275
|
+
(p) => p.map(
|
|
276
|
+
(l) => l.id === f ? { ...l, position: g } : l
|
|
277
|
+
)
|
|
278
|
+
);
|
|
279
|
+
}, []);
|
|
280
|
+
return {
|
|
281
|
+
notifications: i,
|
|
282
|
+
toastNotifications: s,
|
|
283
|
+
dialogNotifications: u,
|
|
284
|
+
unreadCount: w,
|
|
285
|
+
addNotification: y,
|
|
286
|
+
addToast: P,
|
|
287
|
+
addDialogNotification: E,
|
|
288
|
+
markAsRead: D,
|
|
289
|
+
markAllAsRead: N,
|
|
290
|
+
removeNotification: O,
|
|
291
|
+
clearAllNotifications: k,
|
|
292
|
+
removeToast: C,
|
|
293
|
+
removeDialogNotification: I,
|
|
294
|
+
bringDialogToFront: A,
|
|
295
|
+
updateDialogPosition: M
|
|
296
|
+
};
|
|
297
|
+
}, Qe = () => {
|
|
298
|
+
const e = S(null), t = (r) => {
|
|
299
|
+
typeof window < "u" && window.dispatchEvent(
|
|
300
|
+
new MessageEvent("quickSearch", { data: { value: r } })
|
|
301
|
+
);
|
|
302
|
+
}, n = (r) => {
|
|
303
|
+
e[1](r.data?.value ?? null);
|
|
304
|
+
};
|
|
305
|
+
return L(() => {
|
|
306
|
+
if (typeof window < "u")
|
|
307
|
+
return window.addEventListener("quickSearch", n), () => {
|
|
308
|
+
window.removeEventListener("quickSearch", n);
|
|
309
|
+
};
|
|
310
|
+
}, []), {
|
|
311
|
+
quickSearchUseState: e,
|
|
312
|
+
sendQuickSearchEvent: t
|
|
313
|
+
};
|
|
314
|
+
};
|
|
315
|
+
class fe {
|
|
316
|
+
getItem(t) {
|
|
317
|
+
const n = window.localStorage.getItem(t);
|
|
318
|
+
if (!n) return null;
|
|
319
|
+
try {
|
|
320
|
+
return JSON.parse(n);
|
|
321
|
+
} catch {
|
|
322
|
+
return n;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
setItem(t, n) {
|
|
326
|
+
window.localStorage.setItem(t, JSON.stringify(n));
|
|
327
|
+
}
|
|
328
|
+
removeItem(t) {
|
|
329
|
+
window.localStorage.removeItem(t);
|
|
330
|
+
}
|
|
331
|
+
clear() {
|
|
332
|
+
window.localStorage.clear();
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
class h {
|
|
336
|
+
static localLayer = new fe();
|
|
337
|
+
static get layer() {
|
|
338
|
+
return h.localLayer;
|
|
339
|
+
}
|
|
340
|
+
static getItem(t) {
|
|
341
|
+
return this.layer.getItem(t);
|
|
342
|
+
}
|
|
343
|
+
static setItem(t, n) {
|
|
344
|
+
this.layer.setItem(t, n);
|
|
345
|
+
}
|
|
346
|
+
static removeItem(t) {
|
|
347
|
+
this.layer.removeItem(t);
|
|
348
|
+
}
|
|
349
|
+
static clear() {
|
|
350
|
+
this.layer.clear();
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
const ge = {
|
|
354
|
+
navExpandedKey: "dashNavExpanded"
|
|
355
|
+
}, et = (e = {}) => {
|
|
356
|
+
const t = le(), {
|
|
357
|
+
navExpandedKey: n = ge.navExpandedKey,
|
|
358
|
+
setNavExpandedAction: r
|
|
359
|
+
} = e;
|
|
360
|
+
L(() => {
|
|
361
|
+
if (r)
|
|
362
|
+
try {
|
|
363
|
+
const i = h.getItem(n);
|
|
364
|
+
i !== null && t(r(i === "true"));
|
|
365
|
+
} catch (i) {
|
|
366
|
+
console.error("Error accessing localStorage:", i);
|
|
367
|
+
}
|
|
368
|
+
}, [t, n, r]);
|
|
369
|
+
}, tt = (e = "dashNavExpanded") => {
|
|
370
|
+
try {
|
|
371
|
+
const t = h.getItem(e);
|
|
372
|
+
return t !== null ? t === "true" : !0;
|
|
373
|
+
} catch (t) {
|
|
374
|
+
return console.error("Error accessing localStorage:", t), !0;
|
|
375
|
+
}
|
|
376
|
+
}, nt = (e = "dashNavSize") => {
|
|
377
|
+
try {
|
|
378
|
+
return h.getItem(e) || "small";
|
|
379
|
+
} catch (t) {
|
|
380
|
+
return console.error("Error accessing localStorage:", t), "small";
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
function J(e) {
|
|
384
|
+
return getComputedStyle(document.documentElement).getPropertyValue(`--${e}`).trim() || void 0;
|
|
385
|
+
}
|
|
386
|
+
function me() {
|
|
387
|
+
const e = {};
|
|
388
|
+
for (let t = 0; t < document.styleSheets.length; t++) {
|
|
389
|
+
const n = document.styleSheets[t];
|
|
390
|
+
if (n.ownerNode?.id !== "dash-theme-variables")
|
|
391
|
+
try {
|
|
392
|
+
const i = n.cssRules;
|
|
393
|
+
if (!i) continue;
|
|
394
|
+
for (let o = 0; o < i.length; o++) {
|
|
395
|
+
const s = i[o];
|
|
396
|
+
if ("selectorText" in s && s.selectorText === ":root") {
|
|
397
|
+
const a = s.style;
|
|
398
|
+
for (let u = 0; u < a.length; u++) {
|
|
399
|
+
const c = a[u];
|
|
400
|
+
c.startsWith("--") && (e[c] = a.getPropertyValue(c).trim());
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
} catch {
|
|
405
|
+
continue;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
return e;
|
|
409
|
+
}
|
|
410
|
+
const ot = (e, t, n) => {
|
|
411
|
+
const r = `--${e}`, i = [
|
|
412
|
+
"primary-color--light",
|
|
413
|
+
"primary-color--dark",
|
|
414
|
+
"primary-contrast--light",
|
|
415
|
+
"primary-contrast--dark"
|
|
416
|
+
// "secondary-color--light",
|
|
417
|
+
// "secondary-color--dark",
|
|
418
|
+
// "highlight-color--light",
|
|
419
|
+
// "highlight-color--dark",
|
|
420
|
+
//"framed_layout-bg--light",
|
|
421
|
+
//"framed_layout-bg--dark",
|
|
422
|
+
];
|
|
423
|
+
let o = document.getElementById("dash-theme-variables");
|
|
424
|
+
o || (o = document.createElement("style"), o.id = "dash-theme-variables"), document.head.appendChild(o);
|
|
425
|
+
let s = "";
|
|
426
|
+
n && Object.entries(n).forEach(([c, d]) => {
|
|
427
|
+
s += `--${c}: ${d}; `;
|
|
428
|
+
});
|
|
429
|
+
const a = t ? void 0 : me(), u = /* @__PURE__ */ new Set();
|
|
430
|
+
t ? Object.keys(t).forEach((c) => u.add(c)) : Object.keys(a).forEach((c) => {
|
|
431
|
+
u.add(c.slice(2));
|
|
432
|
+
}), i.forEach((c) => u.add(c)), u.forEach((c) => {
|
|
433
|
+
let d = t?.[c];
|
|
434
|
+
if (!d && a && (d = a[`--${c}`]), d || (d = J(c)), d) {
|
|
435
|
+
const m = c.includes("--"), w = c.endsWith(r);
|
|
436
|
+
(!m || w) && (s += `--${c}: ${d}; `);
|
|
437
|
+
}
|
|
438
|
+
if (c.endsWith(r)) {
|
|
439
|
+
const m = c.slice(0, -r.length);
|
|
440
|
+
let w = t?.[c];
|
|
441
|
+
!w && a && (w = a[`--${c}`]), w || (w = J(c)), w && (s += `--${m}: ${w}; `);
|
|
442
|
+
}
|
|
443
|
+
}), o.textContent = `:root { ${s} }`;
|
|
444
|
+
}, pe = (e) => process.env[e] || null, W = (e) => {
|
|
445
|
+
const t = process.env.ENV_PREFIX || process.env.NEXT_PUBLIC_ENV_PREFIX || process.env.VITE_ENV_PREFIX || process.env.REACT_ENV_PREFIX || "VITE_";
|
|
446
|
+
return t === "NEXT_PUBLIC_" ? pe(t + e) : process.env[t + e] || null;
|
|
447
|
+
}, he = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/, rt = (e) => !e || typeof e != "string" ? !1 : he.test(e.trim()), we = /^\+?[\d\s\-()]{7,20}$/, st = (e) => !e || typeof e != "string" ? !1 : we.test(e.trim()), ye = /^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/i, it = (e) => !e || typeof e != "string" ? !1 : ye.test(e.trim()), at = (e) => {
|
|
448
|
+
if (!e) return "weak";
|
|
449
|
+
let t = 0;
|
|
450
|
+
return e.length >= 8 && t++, e.length >= 12 && t++, /[a-z]/.test(e) && t++, /[A-Z]/.test(e) && t++, /[0-9]/.test(e) && t++, /[^a-zA-Z0-9]/.test(e) && t++, t <= 2 ? "weak" : t <= 3 ? "fair" : t <= 4 ? "good" : "strong";
|
|
451
|
+
}, ct = (e) => e == null ? !1 : typeof e == "string" ? e.trim().length > 0 : Array.isArray(e) ? e.length > 0 : !0, dt = (e, t) => !e || typeof e != "string" ? !1 : e.trim().length >= t, lt = (e, t) => !e || typeof e != "string" ? !0 : e.trim().length <= t, ut = (e) => {
|
|
452
|
+
if (!e || typeof e != "string") return !1;
|
|
453
|
+
const t = e.replace(/[.-]/g, "").toUpperCase();
|
|
454
|
+
if (t.length < 2) return !1;
|
|
455
|
+
const n = t.slice(0, -1), r = t.slice(-1);
|
|
456
|
+
let i = 0, o = 2;
|
|
457
|
+
for (let u = n.length - 1; u >= 0; u--)
|
|
458
|
+
i += parseInt(n[u], 10) * o, o = o === 7 ? 2 : o + 1;
|
|
459
|
+
const s = 11 - i % 11;
|
|
460
|
+
let a;
|
|
461
|
+
return s === 11 ? a = "0" : s === 10 ? a = "K" : a = s.toString(), r === a;
|
|
462
|
+
}, Y = () => typeof window < "u" && !!window.DashIPCService, be = () => Y(), R = () => {
|
|
463
|
+
if (typeof window < "u")
|
|
464
|
+
return window.DashIPCService;
|
|
465
|
+
}, ve = (e) => {
|
|
466
|
+
const t = R();
|
|
467
|
+
return t ? (t.windowControls(e), !0) : !1;
|
|
468
|
+
}, Se = () => {
|
|
469
|
+
const e = R();
|
|
470
|
+
return e ? (e.startDrag(), !0) : !1;
|
|
471
|
+
}, Ee = (e, t) => {
|
|
472
|
+
const n = R();
|
|
473
|
+
return n ? (n.action(e, t), !0) : !1;
|
|
474
|
+
}, Ce = (e) => {
|
|
475
|
+
const t = R();
|
|
476
|
+
return t && t.onStdout ? (t.onStdout(e), !0) : !1;
|
|
477
|
+
}, Ae = (e) => {
|
|
478
|
+
const t = R();
|
|
479
|
+
return t && t.onElectronLog ? (t.onElectronLog(e), !0) : !1;
|
|
480
|
+
}, Ie = (e) => {
|
|
481
|
+
const t = R();
|
|
482
|
+
return t && t.onSubprocessOutput ? (t.onSubprocessOutput(e), !0) : !1;
|
|
483
|
+
}, ft = () => {
|
|
484
|
+
const e = R();
|
|
485
|
+
return {
|
|
486
|
+
isAvailable: Y(),
|
|
487
|
+
isElectron: be(),
|
|
488
|
+
service: e,
|
|
489
|
+
windowControl: ve,
|
|
490
|
+
startWindowDrag: Se,
|
|
491
|
+
executeAction: Ee,
|
|
492
|
+
onStdout: Ce,
|
|
493
|
+
onElectronLog: Ae,
|
|
494
|
+
onSubprocessOutput: Ie
|
|
495
|
+
};
|
|
496
|
+
}, Le = () => h.getItem("theme"), gt = (e) => {
|
|
497
|
+
h.setItem("theme", e), typeof document < "u" && document.documentElement.setAttribute("data-theme", e);
|
|
498
|
+
}, mt = (e) => {
|
|
499
|
+
const t = Le(), n = t || e;
|
|
500
|
+
return typeof document < "u" && document.documentElement.setAttribute("data-theme", n), t || h.setItem("theme", e), n;
|
|
501
|
+
}, pt = () => {
|
|
502
|
+
h.removeItem("theme"), typeof document < "u" && document.documentElement.removeAttribute("data-theme");
|
|
503
|
+
}, q = () => {
|
|
504
|
+
try {
|
|
505
|
+
if (typeof globalThis < "u" && globalThis.process?.env?.NODE_ENV)
|
|
506
|
+
return globalThis.process.env.NODE_ENV;
|
|
507
|
+
} catch {
|
|
508
|
+
}
|
|
509
|
+
}, G = () => {
|
|
510
|
+
if (typeof window > "u")
|
|
511
|
+
return q() === "development";
|
|
512
|
+
const { hostname: e } = window.location;
|
|
513
|
+
return e === "localhost" || e === "127.0.0.1" || e.startsWith("192.168.") || e.endsWith(".local") || e.includes("dev.");
|
|
514
|
+
}, ht = () => !G(), Pe = () => q() === "test", wt = () => Pe() ? "test" : G() ? "development" : "production", yt = (e) => {
|
|
515
|
+
if (typeof document > "u")
|
|
516
|
+
return () => {
|
|
517
|
+
};
|
|
518
|
+
const { PLATFORM_TYPE: t, IS_ELECTRON: n, IS_MAC: r, IS_WINDOWS: i, IS_LINUX: o } = e, s = [];
|
|
519
|
+
return t && (document.body.classList.add(t), s.push(t)), n && (document.body.classList.add("electron"), s.push("electron")), r && (document.body.classList.add("mac"), s.push("mac")), i && (document.body.classList.add("windows"), s.push("windows")), o && (document.body.classList.add("linux"), s.push("linux")), () => {
|
|
520
|
+
s.forEach((a) => {
|
|
521
|
+
document.body.classList.remove(a);
|
|
522
|
+
});
|
|
523
|
+
};
|
|
524
|
+
}, bt = (e) => {
|
|
525
|
+
}, De = () => {
|
|
526
|
+
if (typeof navigator > "u") return !1;
|
|
527
|
+
const e = navigator.userAgent.toLowerCase();
|
|
528
|
+
return console.log("userAgent", e), /(webview|wv)/.test(e) || /android.*(wv|.net)/.test(e) || /iphone|ipod|ipad.*applewebkit(?!.*safari)/i.test(e);
|
|
529
|
+
}, Ne = () => typeof navigator > "u" ? !1 : /android/i.test(navigator.userAgent.toLowerCase()), Te = () => typeof navigator > "u" ? !1 : /iphone|ipad|ipod/i.test(navigator.userAgent.toLowerCase()), Oe = () => {
|
|
530
|
+
try {
|
|
531
|
+
return globalThis.process?.platform === "win32" || typeof navigator < "u" && navigator.userAgent.toLowerCase().includes("windows");
|
|
532
|
+
} catch (e) {
|
|
533
|
+
return console.error("Error checking Windows platform:", e), !1;
|
|
534
|
+
}
|
|
535
|
+
}, Q = () => {
|
|
536
|
+
if (!(typeof document > "u") && (Oe() && document.body.classList.add("windows"), De() && (console.log("webview"), document.body.classList.add("webview"), Ne() && document.body.classList.add("android"), Te() && document.body.classList.add("ios")), typeof navigator < "u" && navigator.userAgent)) {
|
|
537
|
+
const t = navigator.userAgent.toLowerCase().replace(/[^a-z0-9]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "").substring(0, 100);
|
|
538
|
+
t && document.body.classList.add(`ua-${t}`);
|
|
539
|
+
}
|
|
540
|
+
}, ee = async () => {
|
|
541
|
+
if (!(typeof window > "u" || !window.electronStore))
|
|
542
|
+
try {
|
|
543
|
+
const e = await window.electronStore.syncToLocalStorage();
|
|
544
|
+
Object.entries(e).forEach(([t, n]) => {
|
|
545
|
+
window.localStorage.setItem(t, JSON.stringify(n));
|
|
546
|
+
}), console.log("Electron store synced to localStorage");
|
|
547
|
+
} catch (e) {
|
|
548
|
+
console.error("Failed to sync Electron store:", e);
|
|
549
|
+
}
|
|
550
|
+
}, vt = () => typeof window < "u" && !!window.electronStore, te = async () => "Notification" in window && Notification.permission === "default" ? await Notification.requestPermission() : Notification.permission ?? null, St = () => "Notification" in window, Et = () => "Notification" in window && Notification.permission === "granted", Ct = () => "Notification" in window && Notification.permission === "denied", At = () => "Notification" in window ? Notification.permission : null, It = async (e = {}) => {
|
|
551
|
+
const {
|
|
552
|
+
requestNotifications: t = !0,
|
|
553
|
+
syncElectron: n = !0,
|
|
554
|
+
applyPlatformClasses: r = !0
|
|
555
|
+
} = e;
|
|
556
|
+
n && await ee(), r && Q(), t && await te();
|
|
557
|
+
}, Lt = () => {
|
|
558
|
+
ee(), Q(), te();
|
|
559
|
+
}, Pt = (e) => {
|
|
560
|
+
let t = null, n = null;
|
|
561
|
+
return {
|
|
562
|
+
getResources: async () => t || n || (n = e().then((a) => (t = a, n = null, a)).catch((a) => {
|
|
563
|
+
throw n = null, console.error("Failed to load resources:", a), a;
|
|
564
|
+
}), n),
|
|
565
|
+
resources: [],
|
|
566
|
+
clearCache: () => {
|
|
567
|
+
t = null, n = null;
|
|
568
|
+
},
|
|
569
|
+
isLoaded: () => t !== null
|
|
570
|
+
};
|
|
571
|
+
}, Dt = (e) => {
|
|
572
|
+
let t = null;
|
|
573
|
+
return async () => t || (t = await e(), t);
|
|
574
|
+
}, xe = [
|
|
575
|
+
"token",
|
|
576
|
+
"authenticated",
|
|
577
|
+
"user",
|
|
578
|
+
"roles",
|
|
579
|
+
"tenant_id",
|
|
580
|
+
"user_id"
|
|
581
|
+
], Re = [
|
|
582
|
+
"token",
|
|
583
|
+
"tenant_id",
|
|
584
|
+
"user_id"
|
|
585
|
+
], Nt = (e = {}) => async (t) => {
|
|
586
|
+
console.log("🔓 logoutFromStorage called:", t || "no reason provided");
|
|
587
|
+
try {
|
|
588
|
+
e.clearAuthPersistence && e.clearAuthPersistence(), [...xe, ...e.additionalKeys || []].forEach((r) => {
|
|
589
|
+
h.removeItem(r);
|
|
590
|
+
}), e.removeCookies && e.removeCookies(Re), e.syncToDeviceStore && await e.syncToDeviceStore(), console.log("✅ Auth data cleared successfully");
|
|
591
|
+
} catch (n) {
|
|
592
|
+
console.error("❌ Error clearing auth data:", n);
|
|
593
|
+
}
|
|
594
|
+
}, Tt = () => {
|
|
595
|
+
try {
|
|
596
|
+
const e = JSON.parse(h.getItem("authenticated") || "false"), t = JSON.parse(h.getItem("user") || "null");
|
|
597
|
+
return e && t?.id;
|
|
598
|
+
} catch {
|
|
599
|
+
return !1;
|
|
600
|
+
}
|
|
601
|
+
}, Ot = () => {
|
|
602
|
+
try {
|
|
603
|
+
return JSON.parse(h.getItem("user") || "null");
|
|
604
|
+
} catch {
|
|
605
|
+
return null;
|
|
606
|
+
}
|
|
607
|
+
}, xt = () => h.getItem("token"), Rt = () => h.getItem("tenant_id"), Mt = () => {
|
|
608
|
+
try {
|
|
609
|
+
return JSON.parse(h.getItem("roles") || "[]");
|
|
610
|
+
} catch {
|
|
611
|
+
return [];
|
|
612
|
+
}
|
|
613
|
+
}, kt = (e) => {
|
|
614
|
+
e.token !== void 0 && h.setItem("token", e.token), e.user !== void 0 && h.setItem("user", JSON.stringify(e.user)), e.roles !== void 0 && h.setItem("roles", JSON.stringify(e.roles)), e.authenticated !== void 0 && h.setItem("authenticated", JSON.stringify(e.authenticated)), e.tenant_id !== void 0 && h.setItem("tenant_id", e.tenant_id), e.user_id !== void 0 && h.setItem("user_id", e.user_id);
|
|
615
|
+
};
|
|
616
|
+
class Me {
|
|
617
|
+
configs = [];
|
|
618
|
+
/**
|
|
619
|
+
* Set resource configurations
|
|
620
|
+
*/
|
|
621
|
+
setConfigs(t) {
|
|
622
|
+
this.configs = t;
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Get all resource configurations
|
|
626
|
+
*/
|
|
627
|
+
getConfigs() {
|
|
628
|
+
return this.configs;
|
|
629
|
+
}
|
|
630
|
+
/**
|
|
631
|
+
* Get resource configuration by resource path
|
|
632
|
+
*/
|
|
633
|
+
getConfig(t) {
|
|
634
|
+
const n = this.configs.find((r) => r.model === t);
|
|
635
|
+
return n || this.configs.find((r) => {
|
|
636
|
+
const i = r.model || "";
|
|
637
|
+
return t.startsWith(i) || i.startsWith(t);
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Clear all configurations
|
|
642
|
+
*/
|
|
643
|
+
clear() {
|
|
644
|
+
this.configs = [];
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
let _ = null;
|
|
648
|
+
const ne = () => (_ || (_ = new Me()), _), Ft = (e) => {
|
|
649
|
+
ne().setConfigs(e);
|
|
650
|
+
}, oe = (e) => ne().getConfig(e), Kt = (e, t, n) => {
|
|
651
|
+
const r = oe(e);
|
|
652
|
+
let i = { ...t };
|
|
653
|
+
return Object.keys(i).forEach((o) => {
|
|
654
|
+
i[o] === void 0 && delete i[o];
|
|
655
|
+
}), r?.dataTransform && (i = r.dataTransform(i, n)), i;
|
|
656
|
+
}, $t = (e, t) => {
|
|
657
|
+
const n = new FormData(), r = (i, o, s = "") => {
|
|
658
|
+
const a = s ? `${s}[${i}]` : i;
|
|
659
|
+
o != null && (o instanceof File ? n.append(a, o) : typeof FileList < "u" && o instanceof FileList ? Array.from(o).forEach((u, c) => {
|
|
660
|
+
n.append(`${a}[${c}]`, u);
|
|
661
|
+
}) : Array.isArray(o) ? o.forEach((u, c) => {
|
|
662
|
+
typeof u == "object" && !(u instanceof File) ? Object.keys(u).forEach((d) => {
|
|
663
|
+
r(d, u[d], `${a}[${c}]`);
|
|
664
|
+
}) : n.append(`${a}[${c}]`, u);
|
|
665
|
+
}) : typeof o == "object" && !(o instanceof Date) ? o.rawFile && o.rawFile instanceof File ? n.append(a, o.rawFile) : Object.keys(o).forEach((u) => {
|
|
666
|
+
r(u, o[u], a);
|
|
667
|
+
}) : typeof o == "boolean" ? n.append(a, o ? "1" : "0") : n.append(a, String(o)));
|
|
668
|
+
};
|
|
669
|
+
return Object.keys(t).forEach((i) => {
|
|
670
|
+
r(i, t[i]);
|
|
671
|
+
}), n;
|
|
672
|
+
}, zt = (e) => {
|
|
673
|
+
const t = new URLSearchParams();
|
|
674
|
+
return Object.keys(e).forEach((n) => {
|
|
675
|
+
const r = e[n];
|
|
676
|
+
r != null && (Array.isArray(r) ? r.forEach((i) => {
|
|
677
|
+
t.append(`${n}[]`, String(i));
|
|
678
|
+
}) : typeof r == "object" ? t.append(n, JSON.stringify(r)) : t.append(n, String(r)));
|
|
679
|
+
}), t.toString();
|
|
680
|
+
}, Wt = (e, t) => oe(e)?.isFormData === !0 || t?.data?.isFormData === !0 || t?.meta?.isFormData === !0, _t = ({ children: e }) => /* @__PURE__ */ v.createElement(v.Fragment, null, e), ke = (e, t) => e === "desktop" || t === "electron", Fe = ({ publicRoutes: e, loader: t, className: n, children: r }) => {
|
|
681
|
+
if (!e)
|
|
682
|
+
return /* @__PURE__ */ v.createElement(v.Fragment, null, r);
|
|
683
|
+
let i;
|
|
684
|
+
return typeof e == "function" ? i = e() : i = e, /* @__PURE__ */ v.createElement("div", { className: n }, /* @__PURE__ */ v.createElement(ie, { fallback: t || /* @__PURE__ */ v.createElement("div", null, "Loading...") }, /* @__PURE__ */ v.createElement(ue, null, i)));
|
|
685
|
+
}, re = ({
|
|
686
|
+
children: e,
|
|
687
|
+
forceType: t,
|
|
688
|
+
basename: n,
|
|
689
|
+
platformType: r,
|
|
690
|
+
platform: i,
|
|
691
|
+
loader: o,
|
|
692
|
+
publicRoutes: s,
|
|
693
|
+
className: a = "dash-public-app"
|
|
694
|
+
}) => {
|
|
695
|
+
const u = r ?? W("PLATFORM_TYPE"), c = i ?? W("PLATFORM"), d = n ?? W("BASE_PATH") ?? "/", m = /* @__PURE__ */ v.createElement(
|
|
696
|
+
Fe,
|
|
697
|
+
{
|
|
698
|
+
publicRoutes: s,
|
|
699
|
+
loader: o,
|
|
700
|
+
className: a
|
|
701
|
+
},
|
|
702
|
+
e
|
|
703
|
+
);
|
|
704
|
+
return t === "hash" ? /* @__PURE__ */ v.createElement(V, { basename: "" }, m) : t === "browser" ? /* @__PURE__ */ v.createElement(H, { basename: d }, m) : ke(u, c) ? /* @__PURE__ */ v.createElement(V, { basename: "" }, m) : /* @__PURE__ */ v.createElement(H, { basename: d }, m);
|
|
705
|
+
}, Vt = (e) => ({ children: n }) => /* @__PURE__ */ v.createElement(
|
|
706
|
+
re,
|
|
707
|
+
{
|
|
708
|
+
platformType: e.PLATFORM_TYPE,
|
|
709
|
+
platform: e.PLATFORM
|
|
710
|
+
},
|
|
711
|
+
n
|
|
712
|
+
), Ht = re, Ke = {
|
|
713
|
+
idleTime: 180 * 1e3,
|
|
714
|
+
resuscitationTime: 360 * 1e3,
|
|
715
|
+
maxLogMessages: 100,
|
|
716
|
+
maxSubprocessOutputs: 100,
|
|
717
|
+
maxInitAttempts: 5,
|
|
718
|
+
initRetryDelay: 500
|
|
719
|
+
}, se = ae({
|
|
720
|
+
lastMessage: void 0,
|
|
721
|
+
idleStatus: !1,
|
|
722
|
+
logMessages: [],
|
|
723
|
+
subprocessOutputs: [],
|
|
724
|
+
isElectronAvailable: !1
|
|
725
|
+
}), Ut = () => de(se), Xt = ({
|
|
726
|
+
children: e,
|
|
727
|
+
config: t
|
|
728
|
+
}) => {
|
|
729
|
+
const n = { ...Ke, ...t }, [r, i] = S(), [o, s] = S(!1), [a, u] = S(null), [c, d] = S([]), [m, w] = S([]), [y, P] = S(!1), E = ce(0), D = () => {
|
|
730
|
+
s(!1), a && clearTimeout(a), u(setTimeout(() => {
|
|
731
|
+
s(!0);
|
|
732
|
+
}, n.idleTime));
|
|
733
|
+
}, N = (C, I, A = null) => C && typeof C[I] == "function" ? C[I].bind(C) : (console.warn(`Method ${I} is not available on DashIPCService`), A), O = () => {
|
|
734
|
+
if (typeof window > "u") return !1;
|
|
735
|
+
if (!window.DashIPCService)
|
|
736
|
+
return console.log(`DashIPCService not available yet. Attempt ${E.current + 1}/${n.maxInitAttempts}`), E.current += 1, E.current < n.maxInitAttempts ? setTimeout(O, n.initRetryDelay) : console.warn("Failed to initialize DashIPCService after multiple attempts"), !1;
|
|
737
|
+
console.log("DashIPCService is available, setting up listeners"), P(!0);
|
|
738
|
+
const C = (l) => {
|
|
739
|
+
i(l), D();
|
|
740
|
+
}, I = (l) => {
|
|
741
|
+
console.log("Log message received:", l), d((T) => [...T.slice(-(n.maxLogMessages - 1)), l]), D();
|
|
742
|
+
}, A = (l) => {
|
|
743
|
+
console.log("Subprocess output received:", l), w((T) => [...T.slice(-(n.maxSubprocessOutputs - 1)), l]), D();
|
|
744
|
+
}, M = N(window.DashIPCService, "onServiceMessage"), f = N(window.DashIPCService, "onElectronLog"), g = N(window.DashIPCService, "onSubprocessOutput"), p = N(window.DashIPCService, "onStdout");
|
|
745
|
+
return M && M((l) => {
|
|
746
|
+
C(l);
|
|
747
|
+
}), f && f((l) => {
|
|
748
|
+
I(l);
|
|
749
|
+
}), g && g((l) => {
|
|
750
|
+
A(l);
|
|
751
|
+
}), !f && p && p((l) => {
|
|
752
|
+
try {
|
|
753
|
+
if (l.includes("{") && l.includes("}")) {
|
|
754
|
+
const T = l.indexOf("{"), $ = l.lastIndexOf("}") + 1, z = l.substring(T, $), x = JSON.parse(z);
|
|
755
|
+
if (x.level && x.message) {
|
|
756
|
+
I({
|
|
757
|
+
level: x.level,
|
|
758
|
+
message: x.message,
|
|
759
|
+
timestamp: x.timestamp || (/* @__PURE__ */ new Date()).toISOString()
|
|
760
|
+
});
|
|
761
|
+
return;
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
} catch {
|
|
765
|
+
}
|
|
766
|
+
I({
|
|
767
|
+
level: "info",
|
|
768
|
+
message: l,
|
|
769
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
770
|
+
});
|
|
771
|
+
}), D(), !0;
|
|
772
|
+
};
|
|
773
|
+
L(() => (O(), () => {
|
|
774
|
+
a && clearTimeout(a);
|
|
775
|
+
}), []), L(() => {
|
|
776
|
+
if (o && window.DashIPCService && typeof window.DashIPCService.action == "function") {
|
|
777
|
+
const C = setTimeout(() => {
|
|
778
|
+
window.DashIPCService.action("resuscitate", null);
|
|
779
|
+
}, n.resuscitationTime - n.idleTime);
|
|
780
|
+
return () => {
|
|
781
|
+
clearTimeout(C);
|
|
782
|
+
};
|
|
783
|
+
}
|
|
784
|
+
}, [o, n.resuscitationTime, n.idleTime]);
|
|
785
|
+
const k = {
|
|
786
|
+
lastMessage: r,
|
|
787
|
+
idleStatus: o,
|
|
788
|
+
logMessages: c,
|
|
789
|
+
subprocessOutputs: m,
|
|
790
|
+
isElectronAvailable: y
|
|
791
|
+
};
|
|
792
|
+
return /* @__PURE__ */ React.createElement(se.Provider, { value: k }, e);
|
|
793
|
+
}, $e = ({
|
|
794
|
+
message: e = "Failed to load application"
|
|
795
|
+
}) => /* @__PURE__ */ v.createElement("div", { style: {
|
|
796
|
+
display: "flex",
|
|
797
|
+
justifyContent: "center",
|
|
798
|
+
alignItems: "center",
|
|
799
|
+
height: "100vh",
|
|
800
|
+
background: "linear-gradient(to bottom, var(--bodybg-primary), var(--bodybg-secondary))",
|
|
801
|
+
color: "#ff4444",
|
|
802
|
+
flexDirection: "column",
|
|
803
|
+
gap: "16px"
|
|
804
|
+
} }, /* @__PURE__ */ v.createElement("div", { style: { fontSize: "18px" } }, e), /* @__PURE__ */ v.createElement(
|
|
805
|
+
"button",
|
|
806
|
+
{
|
|
807
|
+
onClick: () => window.location.reload(),
|
|
808
|
+
style: {
|
|
809
|
+
padding: "10px 20px",
|
|
810
|
+
backgroundColor: "#007bff",
|
|
811
|
+
color: "white",
|
|
812
|
+
border: "none",
|
|
813
|
+
borderRadius: "4px",
|
|
814
|
+
cursor: "pointer"
|
|
815
|
+
}
|
|
816
|
+
},
|
|
817
|
+
"Reload Page"
|
|
818
|
+
)), ze = (e) => {
|
|
819
|
+
const {
|
|
820
|
+
importFn: t,
|
|
821
|
+
initDelay: n = 150,
|
|
822
|
+
fallbackComponent: r,
|
|
823
|
+
onError: i
|
|
824
|
+
} = e;
|
|
825
|
+
return v.lazy(() => new Promise((o) => {
|
|
826
|
+
setTimeout(() => {
|
|
827
|
+
t().then((s) => {
|
|
828
|
+
o({ default: s.default });
|
|
829
|
+
}).catch((s) => {
|
|
830
|
+
console.error("Failed to load app component:", s), i?.(s), o({ default: r ? () => v.createElement(r) : () => v.createElement($e, {
|
|
831
|
+
message: `Failed to load: ${s.message}`
|
|
832
|
+
}) });
|
|
833
|
+
});
|
|
834
|
+
}, n);
|
|
835
|
+
}));
|
|
836
|
+
}, Bt = (e, t = 150) => ze({ importFn: e, initDelay: t }), jt = (e, t = "CLP") => {
|
|
837
|
+
const n = typeof e == "number" ? e : parseFloat(String(e));
|
|
838
|
+
return isNaN(n) ? "$0" : t === "CLP" ? `$${Math.round(n).toLocaleString("es-CL")}` : Number.isInteger(n) ? `$${n.toLocaleString("en-US")}` : `$${n.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
|
839
|
+
};
|
|
840
|
+
export {
|
|
841
|
+
re as DashRouterComponent,
|
|
842
|
+
$e as DefaultLoadFailedComponent,
|
|
843
|
+
he as EMAIL_REGEX,
|
|
844
|
+
se as IPCMessageBrokerContext,
|
|
845
|
+
Xt as IPCMessageBrokerProvider,
|
|
846
|
+
_t as MinimalLayout,
|
|
847
|
+
we as PHONE_REGEX,
|
|
848
|
+
Ht as RouterComponent,
|
|
849
|
+
ye as URL_REGEX,
|
|
850
|
+
Q as applyPlatformBodyClasses,
|
|
851
|
+
zt as buildQueryString,
|
|
852
|
+
U as checkMobileDevice,
|
|
853
|
+
at as checkPasswordStrength,
|
|
854
|
+
pt as clearStoredTheme,
|
|
855
|
+
ze as createLazyAppComponent,
|
|
856
|
+
Nt as createLogoutFromStorage,
|
|
857
|
+
Pt as createResourceLoader,
|
|
858
|
+
Vt as createRouterComponent,
|
|
859
|
+
Bt as createSimpleLazyApp,
|
|
860
|
+
Dt as createSimpleResourceLoader,
|
|
861
|
+
Lt as dashBootstrapApp,
|
|
862
|
+
It as dashInitializeApp,
|
|
863
|
+
h as dashStorage,
|
|
864
|
+
Ee as executeIPCAction,
|
|
865
|
+
xt as getAuthToken,
|
|
866
|
+
K as getCapacitorKeyboard,
|
|
867
|
+
Ot as getCurrentUser,
|
|
868
|
+
R as getDashIPCService,
|
|
869
|
+
W as getEnv,
|
|
870
|
+
wt as getEnvironment,
|
|
871
|
+
tt as getInitialMenuState,
|
|
872
|
+
nt as getInitialNavSize,
|
|
873
|
+
At as getNotificationPermission,
|
|
874
|
+
oe as getResourceConfig,
|
|
875
|
+
ne as getResourceConfigManager,
|
|
876
|
+
Le as getStoredTheme,
|
|
877
|
+
Rt as getTenantId,
|
|
878
|
+
Mt as getUserRoles,
|
|
879
|
+
vt as hasElectronStore,
|
|
880
|
+
Et as hasNotificationPermission,
|
|
881
|
+
mt as initializeStoredTheme,
|
|
882
|
+
B as isAndroid,
|
|
883
|
+
Ne as isAndroidPlatform,
|
|
884
|
+
F as isCapacitorKeyboardAvailable,
|
|
885
|
+
Y as isDashIPCServiceAvailable,
|
|
886
|
+
G as isDev,
|
|
887
|
+
be as isElectron,
|
|
888
|
+
Wt as isFormDataResource,
|
|
889
|
+
j as isIOS,
|
|
890
|
+
Te as isIOSPlatform,
|
|
891
|
+
Je as isLinux,
|
|
892
|
+
Ze as isMacOS,
|
|
893
|
+
Ct as isNotificationDenied,
|
|
894
|
+
St as isNotificationSupported,
|
|
895
|
+
ht as isProd,
|
|
896
|
+
Pe as isTest,
|
|
897
|
+
Tt as isUserAuthenticated,
|
|
898
|
+
X as isWebView,
|
|
899
|
+
De as isWebViewPlatform,
|
|
900
|
+
je as isWindows,
|
|
901
|
+
Oe as isWindowsPlatform,
|
|
902
|
+
Ce as onIPCStdout,
|
|
903
|
+
jt as priceFormatter,
|
|
904
|
+
$t as processFormData,
|
|
905
|
+
Kt as processPostData,
|
|
906
|
+
te as requestNotificationPermission,
|
|
907
|
+
kt as setAuthData,
|
|
908
|
+
Ft as setResourceConfigs,
|
|
909
|
+
gt as setStoredTheme,
|
|
910
|
+
yt as setupEnvironmentBodyClasses,
|
|
911
|
+
ke as shouldUseHashRouter,
|
|
912
|
+
Se as startWindowDrag,
|
|
913
|
+
ee as syncElectronStore,
|
|
914
|
+
ot as updateDomCssVariables,
|
|
915
|
+
Ue as useCapacitorAppStateRefresh,
|
|
916
|
+
Be as useCapacitorKeyboard,
|
|
917
|
+
ft as useDashIPCService,
|
|
918
|
+
Xe as useDeviceStorageSync,
|
|
919
|
+
qe as useDraggable,
|
|
920
|
+
bt as useEnvironmentBodyClasses,
|
|
921
|
+
Ut as useIPCMessageBroker,
|
|
922
|
+
et as useMenuStateInit,
|
|
923
|
+
Ye as useMobileDetection,
|
|
924
|
+
Ge as useNotifications,
|
|
925
|
+
Qe as useQuickSearch,
|
|
926
|
+
He as useWindowSize,
|
|
927
|
+
rt as validateEmail,
|
|
928
|
+
lt as validateMaxLength,
|
|
929
|
+
dt as validateMinLength,
|
|
930
|
+
st as validatePhone,
|
|
931
|
+
ct as validateRequired,
|
|
932
|
+
ut as validateRut,
|
|
933
|
+
it as validateUrl,
|
|
934
|
+
ve as windowControl
|
|
935
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dashadmin/dash-utils",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "dash-utils — DASH framework package",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Francisco Aranda <farandal@gmail.com>",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "index.js",
|
|
9
|
+
"module": "index.js",
|
|
10
|
+
"types": "index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./index.d.ts",
|
|
14
|
+
"import": "./index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"**/*"
|
|
19
|
+
],
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@mui/material": "^7.3.10",
|
|
23
|
+
"@dashadmin/dash-constants": "^1.0.0"
|
|
24
|
+
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=18"
|
|
30
|
+
}
|
|
31
|
+
}
|