thecore-auth 0.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 +3 -0
- package/dist/config.json +15 -0
- package/dist/thecore-auth.es.js +1215 -0
- package/dist/thecore-auth.umd.js +30 -0
- package/package.json +64 -0
|
@@ -0,0 +1,1215 @@
|
|
|
1
|
+
import M, { createContext as ge, useState as A, useContext as ve, useEffect as V } from "react";
|
|
2
|
+
import { useNavigate as ot, Outlet as at, Navigate as Mt, useParams as zt } from "react-router-dom";
|
|
3
|
+
import Wt from "axios";
|
|
4
|
+
var le = { exports: {} }, ee = {};
|
|
5
|
+
/**
|
|
6
|
+
* @license React
|
|
7
|
+
* react-jsx-runtime.production.min.js
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
10
|
+
*
|
|
11
|
+
* This source code is licensed under the MIT license found in the
|
|
12
|
+
* LICENSE file in the root directory of this source tree.
|
|
13
|
+
*/
|
|
14
|
+
var He;
|
|
15
|
+
function Bt() {
|
|
16
|
+
if (He) return ee;
|
|
17
|
+
He = 1;
|
|
18
|
+
var t = M, n = Symbol.for("react.element"), o = Symbol.for("react.fragment"), a = Object.prototype.hasOwnProperty, c = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, u = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
19
|
+
function g(p, f, y) {
|
|
20
|
+
var w, m = {}, E = null, T = null;
|
|
21
|
+
y !== void 0 && (E = "" + y), f.key !== void 0 && (E = "" + f.key), f.ref !== void 0 && (T = f.ref);
|
|
22
|
+
for (w in f) a.call(f, w) && !u.hasOwnProperty(w) && (m[w] = f[w]);
|
|
23
|
+
if (p && p.defaultProps) for (w in f = p.defaultProps, f) m[w] === void 0 && (m[w] = f[w]);
|
|
24
|
+
return { $$typeof: n, type: p, key: E, ref: T, props: m, _owner: c.current };
|
|
25
|
+
}
|
|
26
|
+
return ee.Fragment = o, ee.jsx = g, ee.jsxs = g, ee;
|
|
27
|
+
}
|
|
28
|
+
var te = {};
|
|
29
|
+
/**
|
|
30
|
+
* @license React
|
|
31
|
+
* react-jsx-runtime.development.js
|
|
32
|
+
*
|
|
33
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
34
|
+
*
|
|
35
|
+
* This source code is licensed under the MIT license found in the
|
|
36
|
+
* LICENSE file in the root directory of this source tree.
|
|
37
|
+
*/
|
|
38
|
+
var Xe;
|
|
39
|
+
function Ut() {
|
|
40
|
+
return Xe || (Xe = 1, process.env.NODE_ENV !== "production" && function() {
|
|
41
|
+
var t = M, n = Symbol.for("react.element"), o = Symbol.for("react.portal"), a = Symbol.for("react.fragment"), c = Symbol.for("react.strict_mode"), u = Symbol.for("react.profiler"), g = Symbol.for("react.provider"), p = Symbol.for("react.context"), f = Symbol.for("react.forward_ref"), y = Symbol.for("react.suspense"), w = Symbol.for("react.suspense_list"), m = Symbol.for("react.memo"), E = Symbol.for("react.lazy"), T = Symbol.for("react.offscreen"), N = Symbol.iterator, L = "@@iterator";
|
|
42
|
+
function O(e) {
|
|
43
|
+
if (e === null || typeof e != "object")
|
|
44
|
+
return null;
|
|
45
|
+
var r = N && e[N] || e[L];
|
|
46
|
+
return typeof r == "function" ? r : null;
|
|
47
|
+
}
|
|
48
|
+
var b = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
49
|
+
function j(e) {
|
|
50
|
+
{
|
|
51
|
+
for (var r = arguments.length, s = new Array(r > 1 ? r - 1 : 0), l = 1; l < r; l++)
|
|
52
|
+
s[l - 1] = arguments[l];
|
|
53
|
+
D("error", e, s);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function D(e, r, s) {
|
|
57
|
+
{
|
|
58
|
+
var l = b.ReactDebugCurrentFrame, h = l.getStackAddendum();
|
|
59
|
+
h !== "" && (r += "%s", s = s.concat([h]));
|
|
60
|
+
var x = s.map(function(v) {
|
|
61
|
+
return String(v);
|
|
62
|
+
});
|
|
63
|
+
x.unshift("Warning: " + r), Function.prototype.apply.call(console[e], console, x);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
var I = !1, H = !1, X = !1, _ = !1, P = !1, z;
|
|
67
|
+
z = Symbol.for("react.module.reference");
|
|
68
|
+
function F(e) {
|
|
69
|
+
return !!(typeof e == "string" || typeof e == "function" || e === a || e === u || P || e === c || e === y || e === w || _ || e === T || I || H || X || typeof e == "object" && e !== null && (e.$$typeof === E || e.$$typeof === m || e.$$typeof === g || e.$$typeof === p || e.$$typeof === f || // This needs to include all possible module reference object
|
|
70
|
+
// types supported by any Flight configuration anywhere since
|
|
71
|
+
// we don't know which Flight build this will end up being used
|
|
72
|
+
// with.
|
|
73
|
+
e.$$typeof === z || e.getModuleId !== void 0));
|
|
74
|
+
}
|
|
75
|
+
function ne(e, r, s) {
|
|
76
|
+
var l = e.displayName;
|
|
77
|
+
if (l)
|
|
78
|
+
return l;
|
|
79
|
+
var h = r.displayName || r.name || "";
|
|
80
|
+
return h !== "" ? s + "(" + h + ")" : s;
|
|
81
|
+
}
|
|
82
|
+
function Y(e) {
|
|
83
|
+
return e.displayName || "Context";
|
|
84
|
+
}
|
|
85
|
+
function W(e) {
|
|
86
|
+
if (e == null)
|
|
87
|
+
return null;
|
|
88
|
+
if (typeof e.tag == "number" && j("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
|
|
89
|
+
return e.displayName || e.name || null;
|
|
90
|
+
if (typeof e == "string")
|
|
91
|
+
return e;
|
|
92
|
+
switch (e) {
|
|
93
|
+
case a:
|
|
94
|
+
return "Fragment";
|
|
95
|
+
case o:
|
|
96
|
+
return "Portal";
|
|
97
|
+
case u:
|
|
98
|
+
return "Profiler";
|
|
99
|
+
case c:
|
|
100
|
+
return "StrictMode";
|
|
101
|
+
case y:
|
|
102
|
+
return "Suspense";
|
|
103
|
+
case w:
|
|
104
|
+
return "SuspenseList";
|
|
105
|
+
}
|
|
106
|
+
if (typeof e == "object")
|
|
107
|
+
switch (e.$$typeof) {
|
|
108
|
+
case p:
|
|
109
|
+
var r = e;
|
|
110
|
+
return Y(r) + ".Consumer";
|
|
111
|
+
case g:
|
|
112
|
+
var s = e;
|
|
113
|
+
return Y(s._context) + ".Provider";
|
|
114
|
+
case f:
|
|
115
|
+
return ne(e, e.render, "ForwardRef");
|
|
116
|
+
case m:
|
|
117
|
+
var l = e.displayName || null;
|
|
118
|
+
return l !== null ? l : W(e.type) || "Memo";
|
|
119
|
+
case E: {
|
|
120
|
+
var h = e, x = h._payload, v = h._init;
|
|
121
|
+
try {
|
|
122
|
+
return W(v(x));
|
|
123
|
+
} catch {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
var B = Object.assign, Z = 0, _e, Se, Oe, Pe, ke, Ae, Ie;
|
|
131
|
+
function Ne() {
|
|
132
|
+
}
|
|
133
|
+
Ne.__reactDisabledLog = !0;
|
|
134
|
+
function dt() {
|
|
135
|
+
{
|
|
136
|
+
if (Z === 0) {
|
|
137
|
+
_e = console.log, Se = console.info, Oe = console.warn, Pe = console.error, ke = console.group, Ae = console.groupCollapsed, Ie = console.groupEnd;
|
|
138
|
+
var e = {
|
|
139
|
+
configurable: !0,
|
|
140
|
+
enumerable: !0,
|
|
141
|
+
value: Ne,
|
|
142
|
+
writable: !0
|
|
143
|
+
};
|
|
144
|
+
Object.defineProperties(console, {
|
|
145
|
+
info: e,
|
|
146
|
+
log: e,
|
|
147
|
+
warn: e,
|
|
148
|
+
error: e,
|
|
149
|
+
group: e,
|
|
150
|
+
groupCollapsed: e,
|
|
151
|
+
groupEnd: e
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
Z++;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function gt() {
|
|
158
|
+
{
|
|
159
|
+
if (Z--, Z === 0) {
|
|
160
|
+
var e = {
|
|
161
|
+
configurable: !0,
|
|
162
|
+
enumerable: !0,
|
|
163
|
+
writable: !0
|
|
164
|
+
};
|
|
165
|
+
Object.defineProperties(console, {
|
|
166
|
+
log: B({}, e, {
|
|
167
|
+
value: _e
|
|
168
|
+
}),
|
|
169
|
+
info: B({}, e, {
|
|
170
|
+
value: Se
|
|
171
|
+
}),
|
|
172
|
+
warn: B({}, e, {
|
|
173
|
+
value: Oe
|
|
174
|
+
}),
|
|
175
|
+
error: B({}, e, {
|
|
176
|
+
value: Pe
|
|
177
|
+
}),
|
|
178
|
+
group: B({}, e, {
|
|
179
|
+
value: ke
|
|
180
|
+
}),
|
|
181
|
+
groupCollapsed: B({}, e, {
|
|
182
|
+
value: Ae
|
|
183
|
+
}),
|
|
184
|
+
groupEnd: B({}, e, {
|
|
185
|
+
value: Ie
|
|
186
|
+
})
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
Z < 0 && j("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
var he = b.ReactCurrentDispatcher, me;
|
|
193
|
+
function oe(e, r, s) {
|
|
194
|
+
{
|
|
195
|
+
if (me === void 0)
|
|
196
|
+
try {
|
|
197
|
+
throw Error();
|
|
198
|
+
} catch (h) {
|
|
199
|
+
var l = h.stack.trim().match(/\n( *(at )?)/);
|
|
200
|
+
me = l && l[1] || "";
|
|
201
|
+
}
|
|
202
|
+
return `
|
|
203
|
+
` + me + e;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
var be = !1, ae;
|
|
207
|
+
{
|
|
208
|
+
var vt = typeof WeakMap == "function" ? WeakMap : Map;
|
|
209
|
+
ae = new vt();
|
|
210
|
+
}
|
|
211
|
+
function $e(e, r) {
|
|
212
|
+
if (!e || be)
|
|
213
|
+
return "";
|
|
214
|
+
{
|
|
215
|
+
var s = ae.get(e);
|
|
216
|
+
if (s !== void 0)
|
|
217
|
+
return s;
|
|
218
|
+
}
|
|
219
|
+
var l;
|
|
220
|
+
be = !0;
|
|
221
|
+
var h = Error.prepareStackTrace;
|
|
222
|
+
Error.prepareStackTrace = void 0;
|
|
223
|
+
var x;
|
|
224
|
+
x = he.current, he.current = null, dt();
|
|
225
|
+
try {
|
|
226
|
+
if (r) {
|
|
227
|
+
var v = function() {
|
|
228
|
+
throw Error();
|
|
229
|
+
};
|
|
230
|
+
if (Object.defineProperty(v.prototype, "props", {
|
|
231
|
+
set: function() {
|
|
232
|
+
throw Error();
|
|
233
|
+
}
|
|
234
|
+
}), typeof Reflect == "object" && Reflect.construct) {
|
|
235
|
+
try {
|
|
236
|
+
Reflect.construct(v, []);
|
|
237
|
+
} catch (k) {
|
|
238
|
+
l = k;
|
|
239
|
+
}
|
|
240
|
+
Reflect.construct(e, [], v);
|
|
241
|
+
} else {
|
|
242
|
+
try {
|
|
243
|
+
v.call();
|
|
244
|
+
} catch (k) {
|
|
245
|
+
l = k;
|
|
246
|
+
}
|
|
247
|
+
e.call(v.prototype);
|
|
248
|
+
}
|
|
249
|
+
} else {
|
|
250
|
+
try {
|
|
251
|
+
throw Error();
|
|
252
|
+
} catch (k) {
|
|
253
|
+
l = k;
|
|
254
|
+
}
|
|
255
|
+
e();
|
|
256
|
+
}
|
|
257
|
+
} catch (k) {
|
|
258
|
+
if (k && l && typeof k.stack == "string") {
|
|
259
|
+
for (var d = k.stack.split(`
|
|
260
|
+
`), S = l.stack.split(`
|
|
261
|
+
`), C = d.length - 1, R = S.length - 1; C >= 1 && R >= 0 && d[C] !== S[R]; )
|
|
262
|
+
R--;
|
|
263
|
+
for (; C >= 1 && R >= 0; C--, R--)
|
|
264
|
+
if (d[C] !== S[R]) {
|
|
265
|
+
if (C !== 1 || R !== 1)
|
|
266
|
+
do
|
|
267
|
+
if (C--, R--, R < 0 || d[C] !== S[R]) {
|
|
268
|
+
var $ = `
|
|
269
|
+
` + d[C].replace(" at new ", " at ");
|
|
270
|
+
return e.displayName && $.includes("<anonymous>") && ($ = $.replace("<anonymous>", e.displayName)), typeof e == "function" && ae.set(e, $), $;
|
|
271
|
+
}
|
|
272
|
+
while (C >= 1 && R >= 0);
|
|
273
|
+
break;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
} finally {
|
|
277
|
+
be = !1, he.current = x, gt(), Error.prepareStackTrace = h;
|
|
278
|
+
}
|
|
279
|
+
var J = e ? e.displayName || e.name : "", U = J ? oe(J) : "";
|
|
280
|
+
return typeof e == "function" && ae.set(e, U), U;
|
|
281
|
+
}
|
|
282
|
+
function pt(e, r, s) {
|
|
283
|
+
return $e(e, !1);
|
|
284
|
+
}
|
|
285
|
+
function ht(e) {
|
|
286
|
+
var r = e.prototype;
|
|
287
|
+
return !!(r && r.isReactComponent);
|
|
288
|
+
}
|
|
289
|
+
function se(e, r, s) {
|
|
290
|
+
if (e == null)
|
|
291
|
+
return "";
|
|
292
|
+
if (typeof e == "function")
|
|
293
|
+
return $e(e, ht(e));
|
|
294
|
+
if (typeof e == "string")
|
|
295
|
+
return oe(e);
|
|
296
|
+
switch (e) {
|
|
297
|
+
case y:
|
|
298
|
+
return oe("Suspense");
|
|
299
|
+
case w:
|
|
300
|
+
return oe("SuspenseList");
|
|
301
|
+
}
|
|
302
|
+
if (typeof e == "object")
|
|
303
|
+
switch (e.$$typeof) {
|
|
304
|
+
case f:
|
|
305
|
+
return pt(e.render);
|
|
306
|
+
case m:
|
|
307
|
+
return se(e.type, r, s);
|
|
308
|
+
case E: {
|
|
309
|
+
var l = e, h = l._payload, x = l._init;
|
|
310
|
+
try {
|
|
311
|
+
return se(x(h), r, s);
|
|
312
|
+
} catch {
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return "";
|
|
317
|
+
}
|
|
318
|
+
var Q = Object.prototype.hasOwnProperty, De = {}, Le = b.ReactDebugCurrentFrame;
|
|
319
|
+
function ie(e) {
|
|
320
|
+
if (e) {
|
|
321
|
+
var r = e._owner, s = se(e.type, e._source, r ? r.type : null);
|
|
322
|
+
Le.setExtraStackFrame(s);
|
|
323
|
+
} else
|
|
324
|
+
Le.setExtraStackFrame(null);
|
|
325
|
+
}
|
|
326
|
+
function mt(e, r, s, l, h) {
|
|
327
|
+
{
|
|
328
|
+
var x = Function.call.bind(Q);
|
|
329
|
+
for (var v in e)
|
|
330
|
+
if (x(e, v)) {
|
|
331
|
+
var d = void 0;
|
|
332
|
+
try {
|
|
333
|
+
if (typeof e[v] != "function") {
|
|
334
|
+
var S = Error((l || "React class") + ": " + s + " type `" + v + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[v] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
|
|
335
|
+
throw S.name = "Invariant Violation", S;
|
|
336
|
+
}
|
|
337
|
+
d = e[v](r, v, l, s, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
|
|
338
|
+
} catch (C) {
|
|
339
|
+
d = C;
|
|
340
|
+
}
|
|
341
|
+
d && !(d instanceof Error) && (ie(h), j("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", l || "React class", s, v, typeof d), ie(null)), d instanceof Error && !(d.message in De) && (De[d.message] = !0, ie(h), j("Failed %s type: %s", s, d.message), ie(null));
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
var bt = Array.isArray;
|
|
346
|
+
function xe(e) {
|
|
347
|
+
return bt(e);
|
|
348
|
+
}
|
|
349
|
+
function xt(e) {
|
|
350
|
+
{
|
|
351
|
+
var r = typeof Symbol == "function" && Symbol.toStringTag, s = r && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
352
|
+
return s;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
function yt(e) {
|
|
356
|
+
try {
|
|
357
|
+
return Fe(e), !1;
|
|
358
|
+
} catch {
|
|
359
|
+
return !0;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
function Fe(e) {
|
|
363
|
+
return "" + e;
|
|
364
|
+
}
|
|
365
|
+
function Me(e) {
|
|
366
|
+
if (yt(e))
|
|
367
|
+
return j("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", xt(e)), Fe(e);
|
|
368
|
+
}
|
|
369
|
+
var ze = b.ReactCurrentOwner, wt = {
|
|
370
|
+
key: !0,
|
|
371
|
+
ref: !0,
|
|
372
|
+
__self: !0,
|
|
373
|
+
__source: !0
|
|
374
|
+
}, We, Be;
|
|
375
|
+
function jt(e) {
|
|
376
|
+
if (Q.call(e, "ref")) {
|
|
377
|
+
var r = Object.getOwnPropertyDescriptor(e, "ref").get;
|
|
378
|
+
if (r && r.isReactWarning)
|
|
379
|
+
return !1;
|
|
380
|
+
}
|
|
381
|
+
return e.ref !== void 0;
|
|
382
|
+
}
|
|
383
|
+
function Et(e) {
|
|
384
|
+
if (Q.call(e, "key")) {
|
|
385
|
+
var r = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
386
|
+
if (r && r.isReactWarning)
|
|
387
|
+
return !1;
|
|
388
|
+
}
|
|
389
|
+
return e.key !== void 0;
|
|
390
|
+
}
|
|
391
|
+
function Ct(e, r) {
|
|
392
|
+
typeof e.ref == "string" && ze.current;
|
|
393
|
+
}
|
|
394
|
+
function Rt(e, r) {
|
|
395
|
+
{
|
|
396
|
+
var s = function() {
|
|
397
|
+
We || (We = !0, j("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
|
|
398
|
+
};
|
|
399
|
+
s.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
400
|
+
get: s,
|
|
401
|
+
configurable: !0
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
function Tt(e, r) {
|
|
406
|
+
{
|
|
407
|
+
var s = function() {
|
|
408
|
+
Be || (Be = !0, j("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
|
|
409
|
+
};
|
|
410
|
+
s.isReactWarning = !0, Object.defineProperty(e, "ref", {
|
|
411
|
+
get: s,
|
|
412
|
+
configurable: !0
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
var _t = function(e, r, s, l, h, x, v) {
|
|
417
|
+
var d = {
|
|
418
|
+
// This tag allows us to uniquely identify this as a React Element
|
|
419
|
+
$$typeof: n,
|
|
420
|
+
// Built-in properties that belong on the element
|
|
421
|
+
type: e,
|
|
422
|
+
key: r,
|
|
423
|
+
ref: s,
|
|
424
|
+
props: v,
|
|
425
|
+
// Record the component responsible for creating this element.
|
|
426
|
+
_owner: x
|
|
427
|
+
};
|
|
428
|
+
return d._store = {}, Object.defineProperty(d._store, "validated", {
|
|
429
|
+
configurable: !1,
|
|
430
|
+
enumerable: !1,
|
|
431
|
+
writable: !0,
|
|
432
|
+
value: !1
|
|
433
|
+
}), Object.defineProperty(d, "_self", {
|
|
434
|
+
configurable: !1,
|
|
435
|
+
enumerable: !1,
|
|
436
|
+
writable: !1,
|
|
437
|
+
value: l
|
|
438
|
+
}), Object.defineProperty(d, "_source", {
|
|
439
|
+
configurable: !1,
|
|
440
|
+
enumerable: !1,
|
|
441
|
+
writable: !1,
|
|
442
|
+
value: h
|
|
443
|
+
}), Object.freeze && (Object.freeze(d.props), Object.freeze(d)), d;
|
|
444
|
+
};
|
|
445
|
+
function St(e, r, s, l, h) {
|
|
446
|
+
{
|
|
447
|
+
var x, v = {}, d = null, S = null;
|
|
448
|
+
s !== void 0 && (Me(s), d = "" + s), Et(r) && (Me(r.key), d = "" + r.key), jt(r) && (S = r.ref, Ct(r, h));
|
|
449
|
+
for (x in r)
|
|
450
|
+
Q.call(r, x) && !wt.hasOwnProperty(x) && (v[x] = r[x]);
|
|
451
|
+
if (e && e.defaultProps) {
|
|
452
|
+
var C = e.defaultProps;
|
|
453
|
+
for (x in C)
|
|
454
|
+
v[x] === void 0 && (v[x] = C[x]);
|
|
455
|
+
}
|
|
456
|
+
if (d || S) {
|
|
457
|
+
var R = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
|
|
458
|
+
d && Rt(v, R), S && Tt(v, R);
|
|
459
|
+
}
|
|
460
|
+
return _t(e, d, S, h, l, ze.current, v);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
var ye = b.ReactCurrentOwner, Ue = b.ReactDebugCurrentFrame;
|
|
464
|
+
function q(e) {
|
|
465
|
+
if (e) {
|
|
466
|
+
var r = e._owner, s = se(e.type, e._source, r ? r.type : null);
|
|
467
|
+
Ue.setExtraStackFrame(s);
|
|
468
|
+
} else
|
|
469
|
+
Ue.setExtraStackFrame(null);
|
|
470
|
+
}
|
|
471
|
+
var we;
|
|
472
|
+
we = !1;
|
|
473
|
+
function je(e) {
|
|
474
|
+
return typeof e == "object" && e !== null && e.$$typeof === n;
|
|
475
|
+
}
|
|
476
|
+
function Ve() {
|
|
477
|
+
{
|
|
478
|
+
if (ye.current) {
|
|
479
|
+
var e = W(ye.current.type);
|
|
480
|
+
if (e)
|
|
481
|
+
return `
|
|
482
|
+
|
|
483
|
+
Check the render method of \`` + e + "`.";
|
|
484
|
+
}
|
|
485
|
+
return "";
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
function Ot(e) {
|
|
489
|
+
return "";
|
|
490
|
+
}
|
|
491
|
+
var Ye = {};
|
|
492
|
+
function Pt(e) {
|
|
493
|
+
{
|
|
494
|
+
var r = Ve();
|
|
495
|
+
if (!r) {
|
|
496
|
+
var s = typeof e == "string" ? e : e.displayName || e.name;
|
|
497
|
+
s && (r = `
|
|
498
|
+
|
|
499
|
+
Check the top-level render call using <` + s + ">.");
|
|
500
|
+
}
|
|
501
|
+
return r;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
function qe(e, r) {
|
|
505
|
+
{
|
|
506
|
+
if (!e._store || e._store.validated || e.key != null)
|
|
507
|
+
return;
|
|
508
|
+
e._store.validated = !0;
|
|
509
|
+
var s = Pt(r);
|
|
510
|
+
if (Ye[s])
|
|
511
|
+
return;
|
|
512
|
+
Ye[s] = !0;
|
|
513
|
+
var l = "";
|
|
514
|
+
e && e._owner && e._owner !== ye.current && (l = " It was passed a child from " + W(e._owner.type) + "."), q(e), j('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', s, l), q(null);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
function Je(e, r) {
|
|
518
|
+
{
|
|
519
|
+
if (typeof e != "object")
|
|
520
|
+
return;
|
|
521
|
+
if (xe(e))
|
|
522
|
+
for (var s = 0; s < e.length; s++) {
|
|
523
|
+
var l = e[s];
|
|
524
|
+
je(l) && qe(l, r);
|
|
525
|
+
}
|
|
526
|
+
else if (je(e))
|
|
527
|
+
e._store && (e._store.validated = !0);
|
|
528
|
+
else if (e) {
|
|
529
|
+
var h = O(e);
|
|
530
|
+
if (typeof h == "function" && h !== e.entries)
|
|
531
|
+
for (var x = h.call(e), v; !(v = x.next()).done; )
|
|
532
|
+
je(v.value) && qe(v.value, r);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
function kt(e) {
|
|
537
|
+
{
|
|
538
|
+
var r = e.type;
|
|
539
|
+
if (r == null || typeof r == "string")
|
|
540
|
+
return;
|
|
541
|
+
var s;
|
|
542
|
+
if (typeof r == "function")
|
|
543
|
+
s = r.propTypes;
|
|
544
|
+
else if (typeof r == "object" && (r.$$typeof === f || // Note: Memo only checks outer props here.
|
|
545
|
+
// Inner props are checked in the reconciler.
|
|
546
|
+
r.$$typeof === m))
|
|
547
|
+
s = r.propTypes;
|
|
548
|
+
else
|
|
549
|
+
return;
|
|
550
|
+
if (s) {
|
|
551
|
+
var l = W(r);
|
|
552
|
+
mt(s, e.props, "prop", l, e);
|
|
553
|
+
} else if (r.PropTypes !== void 0 && !we) {
|
|
554
|
+
we = !0;
|
|
555
|
+
var h = W(r);
|
|
556
|
+
j("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", h || "Unknown");
|
|
557
|
+
}
|
|
558
|
+
typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved && j("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
function At(e) {
|
|
562
|
+
{
|
|
563
|
+
for (var r = Object.keys(e.props), s = 0; s < r.length; s++) {
|
|
564
|
+
var l = r[s];
|
|
565
|
+
if (l !== "children" && l !== "key") {
|
|
566
|
+
q(e), j("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", l), q(null);
|
|
567
|
+
break;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
e.ref !== null && (q(e), j("Invalid attribute `ref` supplied to `React.Fragment`."), q(null));
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
var Ke = {};
|
|
574
|
+
function Ge(e, r, s, l, h, x) {
|
|
575
|
+
{
|
|
576
|
+
var v = F(e);
|
|
577
|
+
if (!v) {
|
|
578
|
+
var d = "";
|
|
579
|
+
(e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (d += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
|
|
580
|
+
var S = Ot();
|
|
581
|
+
S ? d += S : d += Ve();
|
|
582
|
+
var C;
|
|
583
|
+
e === null ? C = "null" : xe(e) ? C = "array" : e !== void 0 && e.$$typeof === n ? (C = "<" + (W(e.type) || "Unknown") + " />", d = " Did you accidentally export a JSX literal instead of a component?") : C = typeof e, j("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", C, d);
|
|
584
|
+
}
|
|
585
|
+
var R = St(e, r, s, h, x);
|
|
586
|
+
if (R == null)
|
|
587
|
+
return R;
|
|
588
|
+
if (v) {
|
|
589
|
+
var $ = r.children;
|
|
590
|
+
if ($ !== void 0)
|
|
591
|
+
if (l)
|
|
592
|
+
if (xe($)) {
|
|
593
|
+
for (var J = 0; J < $.length; J++)
|
|
594
|
+
Je($[J], e);
|
|
595
|
+
Object.freeze && Object.freeze($);
|
|
596
|
+
} else
|
|
597
|
+
j("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
|
|
598
|
+
else
|
|
599
|
+
Je($, e);
|
|
600
|
+
}
|
|
601
|
+
if (Q.call(r, "key")) {
|
|
602
|
+
var U = W(e), k = Object.keys(r).filter(function(Ft) {
|
|
603
|
+
return Ft !== "key";
|
|
604
|
+
}), Ee = k.length > 0 ? "{key: someKey, " + k.join(": ..., ") + ": ...}" : "{key: someKey}";
|
|
605
|
+
if (!Ke[U + Ee]) {
|
|
606
|
+
var Lt = k.length > 0 ? "{" + k.join(": ..., ") + ": ...}" : "{}";
|
|
607
|
+
j(`A props object containing a "key" prop is being spread into JSX:
|
|
608
|
+
let props = %s;
|
|
609
|
+
<%s {...props} />
|
|
610
|
+
React keys must be passed directly to JSX without using spread:
|
|
611
|
+
let props = %s;
|
|
612
|
+
<%s key={someKey} {...props} />`, Ee, U, Lt, U), Ke[U + Ee] = !0;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
return e === a ? At(R) : kt(R), R;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
function It(e, r, s) {
|
|
619
|
+
return Ge(e, r, s, !0);
|
|
620
|
+
}
|
|
621
|
+
function Nt(e, r, s) {
|
|
622
|
+
return Ge(e, r, s, !1);
|
|
623
|
+
}
|
|
624
|
+
var $t = Nt, Dt = It;
|
|
625
|
+
te.Fragment = a, te.jsx = $t, te.jsxs = Dt;
|
|
626
|
+
}()), te;
|
|
627
|
+
}
|
|
628
|
+
var Ze;
|
|
629
|
+
function Vt() {
|
|
630
|
+
return Ze || (Ze = 1, process.env.NODE_ENV === "production" ? le.exports = Bt() : le.exports = Ut()), le.exports;
|
|
631
|
+
}
|
|
632
|
+
var i = Vt();
|
|
633
|
+
const st = ge(), fr = ({ children: t }) => {
|
|
634
|
+
const [n, o] = A(!1);
|
|
635
|
+
return /* @__PURE__ */ i.jsx(st.Provider, { value: { isLoading: n, setIsLoading: o }, children: t });
|
|
636
|
+
}, Re = () => {
|
|
637
|
+
const t = ve(st);
|
|
638
|
+
if (t === void 0) throw new Error("Non puoi settare il loading");
|
|
639
|
+
return t;
|
|
640
|
+
}, it = ge(), dr = ({ children: t }) => {
|
|
641
|
+
const [n, o] = A({}), a = async () => {
|
|
642
|
+
try {
|
|
643
|
+
const u = await (await fetch("/config.json")).json();
|
|
644
|
+
o(u);
|
|
645
|
+
} catch (c) {
|
|
646
|
+
console.error(c);
|
|
647
|
+
}
|
|
648
|
+
};
|
|
649
|
+
return V(() => {
|
|
650
|
+
a();
|
|
651
|
+
}, []), Object.keys(n).length === 0 ? null : /* @__PURE__ */ i.jsx(it.Provider, { value: n, children: t });
|
|
652
|
+
}, pe = () => {
|
|
653
|
+
const t = ve(it);
|
|
654
|
+
if (t === void 0) throw new Error("Non puoi leggere i config");
|
|
655
|
+
return t;
|
|
656
|
+
}, lt = ge(), gr = ({ children: t }) => {
|
|
657
|
+
const [n, o] = A(!1), [a, c] = A(), [u, g] = A(), p = {
|
|
658
|
+
showAlert: n,
|
|
659
|
+
setShowAlert: o,
|
|
660
|
+
typeAlert: a,
|
|
661
|
+
setTypeAlert: c,
|
|
662
|
+
messageAlert: u,
|
|
663
|
+
setMessageAlert: g
|
|
664
|
+
};
|
|
665
|
+
return /* @__PURE__ */ i.jsx(lt.Provider, { value: p, children: t });
|
|
666
|
+
}, G = () => {
|
|
667
|
+
const t = ve(lt);
|
|
668
|
+
if (t === void 0) throw new Error("Non puoi modificare l'alert");
|
|
669
|
+
return t;
|
|
670
|
+
};
|
|
671
|
+
function Ce(t) {
|
|
672
|
+
this.message = t;
|
|
673
|
+
}
|
|
674
|
+
Ce.prototype = new Error(), Ce.prototype.name = "InvalidCharacterError";
|
|
675
|
+
var Qe = typeof window < "u" && window.atob && window.atob.bind(window) || function(t) {
|
|
676
|
+
var n = String(t).replace(/=+$/, "");
|
|
677
|
+
if (n.length % 4 == 1) throw new Ce("'atob' failed: The string to be decoded is not correctly encoded.");
|
|
678
|
+
for (var o, a, c = 0, u = 0, g = ""; a = n.charAt(u++); ~a && (o = c % 4 ? 64 * o + a : a, c++ % 4) ? g += String.fromCharCode(255 & o >> (-2 * c & 6)) : 0) a = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(a);
|
|
679
|
+
return g;
|
|
680
|
+
};
|
|
681
|
+
function Yt(t) {
|
|
682
|
+
var n = t.replace(/-/g, "+").replace(/_/g, "/");
|
|
683
|
+
switch (n.length % 4) {
|
|
684
|
+
case 0:
|
|
685
|
+
break;
|
|
686
|
+
case 2:
|
|
687
|
+
n += "==";
|
|
688
|
+
break;
|
|
689
|
+
case 3:
|
|
690
|
+
n += "=";
|
|
691
|
+
break;
|
|
692
|
+
default:
|
|
693
|
+
throw "Illegal base64url string!";
|
|
694
|
+
}
|
|
695
|
+
try {
|
|
696
|
+
return function(o) {
|
|
697
|
+
return decodeURIComponent(Qe(o).replace(/(.)/g, function(a, c) {
|
|
698
|
+
var u = c.charCodeAt(0).toString(16).toUpperCase();
|
|
699
|
+
return u.length < 2 && (u = "0" + u), "%" + u;
|
|
700
|
+
}));
|
|
701
|
+
}(n);
|
|
702
|
+
} catch {
|
|
703
|
+
return Qe(n);
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
function ce(t) {
|
|
707
|
+
this.message = t;
|
|
708
|
+
}
|
|
709
|
+
function qt(t, n) {
|
|
710
|
+
if (typeof t != "string") throw new ce("Invalid token specified");
|
|
711
|
+
var o = (n = n || {}).header === !0 ? 0 : 1;
|
|
712
|
+
try {
|
|
713
|
+
return JSON.parse(Yt(t.split(".")[o]));
|
|
714
|
+
} catch (a) {
|
|
715
|
+
throw new ce("Invalid token specified: " + a.message);
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
ce.prototype = new Error(), ce.prototype.name = "InvalidTokenError";
|
|
719
|
+
let K;
|
|
720
|
+
const ue = async (t, n, o) => {
|
|
721
|
+
if (K) return K;
|
|
722
|
+
try {
|
|
723
|
+
const c = await (await fetch("/config.json")).json(), u = c.baseUri, { unauthorized: g, notFound: p, defaultMessage: f } = c.axiosErrors;
|
|
724
|
+
return K = Wt.create({
|
|
725
|
+
baseURL: u,
|
|
726
|
+
timeout: 3e3
|
|
727
|
+
}), K.interceptors.request.use(
|
|
728
|
+
(y) => y
|
|
729
|
+
), K.interceptors.response.use(
|
|
730
|
+
(y) => y,
|
|
731
|
+
(y) => {
|
|
732
|
+
if (y.response)
|
|
733
|
+
switch (t(!0), n("danger"), y.response.status) {
|
|
734
|
+
case 401:
|
|
735
|
+
localStorage.removeItem("accessToken"), o(g);
|
|
736
|
+
break;
|
|
737
|
+
case 404:
|
|
738
|
+
o(p);
|
|
739
|
+
break;
|
|
740
|
+
default:
|
|
741
|
+
o(`${f} ${y.response.status} ${y.response.data.error}`);
|
|
742
|
+
}
|
|
743
|
+
return Promise.reject(y);
|
|
744
|
+
}
|
|
745
|
+
), K;
|
|
746
|
+
} catch (a) {
|
|
747
|
+
console.error(a);
|
|
748
|
+
}
|
|
749
|
+
}, ct = ge(), vr = ({ children: t }) => {
|
|
750
|
+
const { heartbeatEndpoint: n, infiniteSession: o, timeDeducted: a, authenticatedEndpoint: c } = pe(), { setIsLoading: u } = Re(), { setShowAlert: g, setMessageAlert: p, setTypeAlert: f } = G(), y = ot(), [w, m] = A(null), [E, T] = A(), [N, L] = A(), [O, b] = A(), j = async (_, P) => {
|
|
751
|
+
_.preventDefault();
|
|
752
|
+
try {
|
|
753
|
+
u(!0), g(!1);
|
|
754
|
+
const F = await (await ue(g, f, p)).post(c, {
|
|
755
|
+
auth: P
|
|
756
|
+
}), ne = F.data.id, Y = F.headers.token;
|
|
757
|
+
Y && (localStorage.setItem("accessToken", Y), localStorage.setItem("id", ne), m(!0), T(Y), y(`/dashboard/${ne}`));
|
|
758
|
+
} catch (z) {
|
|
759
|
+
console.error(z), u(!1);
|
|
760
|
+
}
|
|
761
|
+
}, D = () => {
|
|
762
|
+
localStorage.removeItem("accessToken"), localStorage.removeItem("id"), m(!1), T(null);
|
|
763
|
+
}, I = async () => {
|
|
764
|
+
try {
|
|
765
|
+
const _ = localStorage.getItem("accessToken"), F = (await (await ue(g, f, p)).get(
|
|
766
|
+
`${n}`,
|
|
767
|
+
{ headers: {
|
|
768
|
+
Authorization: _
|
|
769
|
+
} }
|
|
770
|
+
)).headers.token;
|
|
771
|
+
localStorage.setItem("accessToken", F), T(F);
|
|
772
|
+
} catch (_) {
|
|
773
|
+
console.error(_), D();
|
|
774
|
+
}
|
|
775
|
+
}, H = () => {
|
|
776
|
+
if (!E)
|
|
777
|
+
return;
|
|
778
|
+
const P = qt(E).exp, z = Math.floor(Date.now() / 1e3), F = (P - z) * 1e3;
|
|
779
|
+
b(F), L(F - a);
|
|
780
|
+
};
|
|
781
|
+
V(() => {
|
|
782
|
+
if (localStorage.getItem("accessToken"))
|
|
783
|
+
m(!0);
|
|
784
|
+
else {
|
|
785
|
+
m(!1);
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
}, []), V(() => {
|
|
789
|
+
H();
|
|
790
|
+
let _;
|
|
791
|
+
o && E && N && (_ = setInterval(() => {
|
|
792
|
+
I();
|
|
793
|
+
}, N));
|
|
794
|
+
let P;
|
|
795
|
+
return !o && E && O && (P = setTimeout(() => {
|
|
796
|
+
D(), g(!0), f("danger"), p("Sessione scaduta");
|
|
797
|
+
}, O)), () => {
|
|
798
|
+
_ && clearInterval(_), P && clearTimeout(P);
|
|
799
|
+
};
|
|
800
|
+
}, [E, N]);
|
|
801
|
+
const X = {
|
|
802
|
+
isAuthenticated: w,
|
|
803
|
+
setIsAuthenticated: m,
|
|
804
|
+
login: j,
|
|
805
|
+
logout: D,
|
|
806
|
+
setCurrentToken: T
|
|
807
|
+
};
|
|
808
|
+
return /* @__PURE__ */ i.jsx(ct.Provider, { value: X, children: t });
|
|
809
|
+
}, Te = () => {
|
|
810
|
+
const t = ve(ct);
|
|
811
|
+
if (t === void 0) throw new Error("Non sei dentro al Auth Provider");
|
|
812
|
+
return t;
|
|
813
|
+
}, pr = () => {
|
|
814
|
+
const { isAuthenticated: t } = Te(), { setShowAlert: n, setTypeAlert: o, setMessageAlert: a } = G(), c = localStorage.getItem("accessToken");
|
|
815
|
+
return V(() => {
|
|
816
|
+
!t && !c && (n(!0), o("danger"), a("Non sei autorizzato"));
|
|
817
|
+
}, []), t === null ? null : t ? /* @__PURE__ */ i.jsx(at, {}) : /* @__PURE__ */ i.jsx(Mt, { to: "/" });
|
|
818
|
+
};
|
|
819
|
+
var ut = {
|
|
820
|
+
color: void 0,
|
|
821
|
+
size: void 0,
|
|
822
|
+
className: void 0,
|
|
823
|
+
style: void 0,
|
|
824
|
+
attr: void 0
|
|
825
|
+
}, et = M.createContext && /* @__PURE__ */ M.createContext(ut), Jt = ["attr", "size", "title"];
|
|
826
|
+
function Kt(t, n) {
|
|
827
|
+
if (t == null) return {};
|
|
828
|
+
var o = Gt(t, n), a, c;
|
|
829
|
+
if (Object.getOwnPropertySymbols) {
|
|
830
|
+
var u = Object.getOwnPropertySymbols(t);
|
|
831
|
+
for (c = 0; c < u.length; c++)
|
|
832
|
+
a = u[c], !(n.indexOf(a) >= 0) && Object.prototype.propertyIsEnumerable.call(t, a) && (o[a] = t[a]);
|
|
833
|
+
}
|
|
834
|
+
return o;
|
|
835
|
+
}
|
|
836
|
+
function Gt(t, n) {
|
|
837
|
+
if (t == null) return {};
|
|
838
|
+
var o = {};
|
|
839
|
+
for (var a in t)
|
|
840
|
+
if (Object.prototype.hasOwnProperty.call(t, a)) {
|
|
841
|
+
if (n.indexOf(a) >= 0) continue;
|
|
842
|
+
o[a] = t[a];
|
|
843
|
+
}
|
|
844
|
+
return o;
|
|
845
|
+
}
|
|
846
|
+
function fe() {
|
|
847
|
+
return fe = Object.assign ? Object.assign.bind() : function(t) {
|
|
848
|
+
for (var n = 1; n < arguments.length; n++) {
|
|
849
|
+
var o = arguments[n];
|
|
850
|
+
for (var a in o)
|
|
851
|
+
Object.prototype.hasOwnProperty.call(o, a) && (t[a] = o[a]);
|
|
852
|
+
}
|
|
853
|
+
return t;
|
|
854
|
+
}, fe.apply(this, arguments);
|
|
855
|
+
}
|
|
856
|
+
function tt(t, n) {
|
|
857
|
+
var o = Object.keys(t);
|
|
858
|
+
if (Object.getOwnPropertySymbols) {
|
|
859
|
+
var a = Object.getOwnPropertySymbols(t);
|
|
860
|
+
n && (a = a.filter(function(c) {
|
|
861
|
+
return Object.getOwnPropertyDescriptor(t, c).enumerable;
|
|
862
|
+
})), o.push.apply(o, a);
|
|
863
|
+
}
|
|
864
|
+
return o;
|
|
865
|
+
}
|
|
866
|
+
function de(t) {
|
|
867
|
+
for (var n = 1; n < arguments.length; n++) {
|
|
868
|
+
var o = arguments[n] != null ? arguments[n] : {};
|
|
869
|
+
n % 2 ? tt(Object(o), !0).forEach(function(a) {
|
|
870
|
+
Ht(t, a, o[a]);
|
|
871
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(o)) : tt(Object(o)).forEach(function(a) {
|
|
872
|
+
Object.defineProperty(t, a, Object.getOwnPropertyDescriptor(o, a));
|
|
873
|
+
});
|
|
874
|
+
}
|
|
875
|
+
return t;
|
|
876
|
+
}
|
|
877
|
+
function Ht(t, n, o) {
|
|
878
|
+
return n = Xt(n), n in t ? Object.defineProperty(t, n, { value: o, enumerable: !0, configurable: !0, writable: !0 }) : t[n] = o, t;
|
|
879
|
+
}
|
|
880
|
+
function Xt(t) {
|
|
881
|
+
var n = Zt(t, "string");
|
|
882
|
+
return typeof n == "symbol" ? n : n + "";
|
|
883
|
+
}
|
|
884
|
+
function Zt(t, n) {
|
|
885
|
+
if (typeof t != "object" || !t) return t;
|
|
886
|
+
var o = t[Symbol.toPrimitive];
|
|
887
|
+
if (o !== void 0) {
|
|
888
|
+
var a = o.call(t, n || "default");
|
|
889
|
+
if (typeof a != "object") return a;
|
|
890
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
891
|
+
}
|
|
892
|
+
return (n === "string" ? String : Number)(t);
|
|
893
|
+
}
|
|
894
|
+
function ft(t) {
|
|
895
|
+
return t && t.map((n, o) => /* @__PURE__ */ M.createElement(n.tag, de({
|
|
896
|
+
key: o
|
|
897
|
+
}, n.attr), ft(n.child)));
|
|
898
|
+
}
|
|
899
|
+
function re(t) {
|
|
900
|
+
return (n) => /* @__PURE__ */ M.createElement(Qt, fe({
|
|
901
|
+
attr: de({}, t.attr)
|
|
902
|
+
}, n), ft(t.child));
|
|
903
|
+
}
|
|
904
|
+
function Qt(t) {
|
|
905
|
+
var n = (o) => {
|
|
906
|
+
var {
|
|
907
|
+
attr: a,
|
|
908
|
+
size: c,
|
|
909
|
+
title: u
|
|
910
|
+
} = t, g = Kt(t, Jt), p = c || o.size || "1em", f;
|
|
911
|
+
return o.className && (f = o.className), t.className && (f = (f ? f + " " : "") + t.className), /* @__PURE__ */ M.createElement("svg", fe({
|
|
912
|
+
stroke: "currentColor",
|
|
913
|
+
fill: "currentColor",
|
|
914
|
+
strokeWidth: "0"
|
|
915
|
+
}, o.attr, a, g, {
|
|
916
|
+
className: f,
|
|
917
|
+
style: de(de({
|
|
918
|
+
color: t.color || o.color
|
|
919
|
+
}, o.style), t.style),
|
|
920
|
+
height: p,
|
|
921
|
+
width: p,
|
|
922
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
923
|
+
}), u && /* @__PURE__ */ M.createElement("title", null, u), t.children);
|
|
924
|
+
};
|
|
925
|
+
return et !== void 0 ? /* @__PURE__ */ M.createElement(et.Consumer, null, (o) => n(o)) : n(ut);
|
|
926
|
+
}
|
|
927
|
+
function er(t) {
|
|
928
|
+
return re({ tag: "svg", attr: { version: "1.1", viewBox: "0 0 16 16" }, child: [{ tag: "path", attr: { d: "M8 0c-4.355 0-7.898 3.481-7.998 7.812 0.092-3.779 2.966-6.812 6.498-6.812 3.59 0 6.5 3.134 6.5 7 0 0.828 0.672 1.5 1.5 1.5s1.5-0.672 1.5-1.5c0-4.418-3.582-8-8-8zM8 16c4.355 0 7.898-3.481 7.998-7.812-0.092 3.779-2.966 6.812-6.498 6.812-3.59 0-6.5-3.134-6.5-7 0-0.828-0.672-1.5-1.5-1.5s-1.5 0.672-1.5 1.5c0 4.418 3.582 8 8 8z" }, child: [] }] })(t);
|
|
929
|
+
}
|
|
930
|
+
const tr = () => /* @__PURE__ */ i.jsxs("div", { className: "fixed top-0 bottom-0 left-0 right-0 flex items-center justify-center bg-[#00000080]", children: [
|
|
931
|
+
/* @__PURE__ */ i.jsx(er, { className: "text-[20rem] relative animate-spin text-white" }),
|
|
932
|
+
/* @__PURE__ */ i.jsx("p", { className: "text-white text-2xl select-none absolute", children: "Loading..." })
|
|
933
|
+
] });
|
|
934
|
+
function rr(t) {
|
|
935
|
+
return re({ tag: "svg", attr: { viewBox: "0 0 15 15", fill: "none" }, child: [{ tag: "path", attr: { fillRule: "evenodd", clipRule: "evenodd", d: "M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z", fill: "currentColor" }, child: [] }] })(t);
|
|
936
|
+
}
|
|
937
|
+
function nr(t) {
|
|
938
|
+
return re({ tag: "svg", attr: { viewBox: "0 0 1024 1024" }, child: [{ tag: "path", attr: { d: "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm32 664c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V456c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272zm-32-344a48.01 48.01 0 0 1 0-96 48.01 48.01 0 0 1 0 96z" }, child: [] }] })(t);
|
|
939
|
+
}
|
|
940
|
+
function or(t) {
|
|
941
|
+
return re({ tag: "svg", attr: { viewBox: "0 0 1024 1024" }, child: [{ tag: "path", attr: { d: "M955.7 856l-416-720c-6.2-10.7-16.9-16-27.7-16s-21.6 5.3-27.7 16l-416 720C56 877.4 71.4 904 96 904h832c24.6 0 40-26.6 27.7-48zM480 416c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v184c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V416zm32 352a48.01 48.01 0 0 1 0-96 48.01 48.01 0 0 1 0 96z" }, child: [] }] })(t);
|
|
942
|
+
}
|
|
943
|
+
function ar(t) {
|
|
944
|
+
return re({ tag: "svg", attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { d: "M17.47 250.9C88.82 328.1 158 397.6 224.5 485.5c72.3-143.8 146.3-288.1 268.4-444.37L460 26.06C356.9 135.4 276.8 238.9 207.2 361.9c-48.4-43.6-126.62-105.3-174.38-137z" }, child: [] }] })(t);
|
|
945
|
+
}
|
|
946
|
+
const sr = () => {
|
|
947
|
+
const { showAlert: t, setShowAlert: n, messageAlert: o, typeAlert: a } = G(), { alertTimeout: c } = pe(), [u, g] = A(0), p = {
|
|
948
|
+
danger: {
|
|
949
|
+
bgColor: "bg-red-50",
|
|
950
|
+
textColor: "text-red-700",
|
|
951
|
+
buttonBg: "bg-red-50",
|
|
952
|
+
hoverBg: "hover:bg-red-200",
|
|
953
|
+
focusRing: "focus:ring-red-400",
|
|
954
|
+
progressColor: "bg-red-400"
|
|
955
|
+
},
|
|
956
|
+
info: {
|
|
957
|
+
bgColor: "bg-blue-50",
|
|
958
|
+
textColor: "text-blue-700",
|
|
959
|
+
buttonBg: "bg-blue-50",
|
|
960
|
+
hoverBg: "hover:bg-blue-200",
|
|
961
|
+
focusRing: "focus:ring-blue-400",
|
|
962
|
+
progressColor: "bg-blue-400"
|
|
963
|
+
},
|
|
964
|
+
success: {
|
|
965
|
+
bgColor: "bg-green-50",
|
|
966
|
+
textColor: "text-green-700",
|
|
967
|
+
buttonBg: "bg-green-50",
|
|
968
|
+
hoverBg: "hover:bg-green-200",
|
|
969
|
+
focusRing: "focus:ring-green-400",
|
|
970
|
+
progressColor: "bg-green-400"
|
|
971
|
+
}
|
|
972
|
+
}, { bgColor: f, textColor: y, buttonBg: w, hoverBg: m, focusRing: E, progressColor: T } = p[a], N = (O) => {
|
|
973
|
+
switch (O) {
|
|
974
|
+
case "danger":
|
|
975
|
+
return /* @__PURE__ */ i.jsx(or, { className: "text-xl" });
|
|
976
|
+
case "info":
|
|
977
|
+
return /* @__PURE__ */ i.jsx(nr, { className: "text-xl" });
|
|
978
|
+
case "success":
|
|
979
|
+
return /* @__PURE__ */ i.jsx(ar, { className: "text-xl" });
|
|
980
|
+
}
|
|
981
|
+
}, L = () => {
|
|
982
|
+
n(!t);
|
|
983
|
+
};
|
|
984
|
+
return V(() => {
|
|
985
|
+
let O;
|
|
986
|
+
const j = 100 / (c / 100);
|
|
987
|
+
O = setInterval(() => {
|
|
988
|
+
g((I) => I >= 100 ? (clearInterval(O), 100) : I + j);
|
|
989
|
+
}, 100);
|
|
990
|
+
const D = setTimeout(() => {
|
|
991
|
+
L();
|
|
992
|
+
}, c);
|
|
993
|
+
return () => {
|
|
994
|
+
clearTimeout(D), clearInterval(O);
|
|
995
|
+
};
|
|
996
|
+
}, []), /* @__PURE__ */ i.jsxs("div", { className: `flex items-center p-4 pt-6 ${y} rounded-lg ${f} mx-auto fixed top-[calc(100vh-100px)] right-10`, role: "alert", children: [
|
|
997
|
+
/* @__PURE__ */ i.jsx("div", { className: "w-full bg-gray-200 rounded-t-lg overflow-hidden h-2.5 dark:bg-gray-700 absolute top-0 left-0 right-0", children: /* @__PURE__ */ i.jsx("div", { className: `${T} h-2.5 rounded-t-lg`, style: { width: `${u}%` } }) }),
|
|
998
|
+
N(a),
|
|
999
|
+
/* @__PURE__ */ i.jsx("div", { className: "px-4 text-sm font-medium", children: o }),
|
|
1000
|
+
/* @__PURE__ */ i.jsx(
|
|
1001
|
+
"button",
|
|
1002
|
+
{
|
|
1003
|
+
type: "button",
|
|
1004
|
+
className: `ms-auto ${w} rounded-lg focus:ring-2 ${E} p-1.5 ${m} inline-flex items-center justify-center h-8 w-8`,
|
|
1005
|
+
title: "Close",
|
|
1006
|
+
onClick: L,
|
|
1007
|
+
children: /* @__PURE__ */ i.jsx(rr, { className: "text-xl" })
|
|
1008
|
+
}
|
|
1009
|
+
)
|
|
1010
|
+
] });
|
|
1011
|
+
}, hr = () => {
|
|
1012
|
+
const { isLoading: t } = Re(), { showAlert: n } = G();
|
|
1013
|
+
return /* @__PURE__ */ i.jsxs(i.Fragment, { children: [
|
|
1014
|
+
t && /* @__PURE__ */ i.jsx(tr, {}),
|
|
1015
|
+
/* @__PURE__ */ i.jsxs("main", { className: t ? "hidden" : "", children: [
|
|
1016
|
+
n && /* @__PURE__ */ i.jsx(sr, {}),
|
|
1017
|
+
/* @__PURE__ */ i.jsx(at, {})
|
|
1018
|
+
] })
|
|
1019
|
+
] });
|
|
1020
|
+
}, rt = (t) => {
|
|
1021
|
+
const {
|
|
1022
|
+
inputType: n,
|
|
1023
|
+
inputId: o,
|
|
1024
|
+
inputPlaceholder: a,
|
|
1025
|
+
inputRequired: c,
|
|
1026
|
+
inputValue: u,
|
|
1027
|
+
inputChange: g
|
|
1028
|
+
} = t, f = ["text", "email", "password", "search", "tel", "url"].includes(n) ? n : "text";
|
|
1029
|
+
return /* @__PURE__ */ i.jsx(
|
|
1030
|
+
"input",
|
|
1031
|
+
{
|
|
1032
|
+
type: f,
|
|
1033
|
+
id: o,
|
|
1034
|
+
className: "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5",
|
|
1035
|
+
placeholder: a,
|
|
1036
|
+
required: c ?? !0,
|
|
1037
|
+
value: u,
|
|
1038
|
+
onChange: g
|
|
1039
|
+
}
|
|
1040
|
+
);
|
|
1041
|
+
}, nt = ({ label: t, labelId: n, labelStyle: o }) => /* @__PURE__ */ i.jsx("label", { htmlFor: n, className: `${o ?? "block mb-2 text-sm font-medium text-gray-900"}`, children: t }), ir = (t) => {
|
|
1042
|
+
const {
|
|
1043
|
+
// Variabili funzionamento della Login
|
|
1044
|
+
submitForm: n,
|
|
1045
|
+
formData: o,
|
|
1046
|
+
changeValue: a,
|
|
1047
|
+
// Stile form
|
|
1048
|
+
formSize: c = "w-[800px]",
|
|
1049
|
+
formBgColor: u = "bg-slate-50",
|
|
1050
|
+
formRounded: g = "rounded-lg",
|
|
1051
|
+
formShadow: p = "shadow-lg",
|
|
1052
|
+
// Input email/username
|
|
1053
|
+
userData: f,
|
|
1054
|
+
userLabel: y = "Email",
|
|
1055
|
+
userType: w = "email",
|
|
1056
|
+
userPlaceholder: m = "email@email.it",
|
|
1057
|
+
// Titolo
|
|
1058
|
+
formTitle: E = "Login",
|
|
1059
|
+
titleSize: T = "text-4xl",
|
|
1060
|
+
titlePosition: N = "text-center",
|
|
1061
|
+
titleSpacing: L = "my-12",
|
|
1062
|
+
// Bottone
|
|
1063
|
+
buttonPosition: O = "justify-center",
|
|
1064
|
+
buttonSpacing: b = "my-12",
|
|
1065
|
+
buttonColor: j = "bg-blue-500",
|
|
1066
|
+
buttonHoverColor: D = "hoverbg-blue-700",
|
|
1067
|
+
buttonTextColor: I = "text-white",
|
|
1068
|
+
buttonSize: H = "py-2 px-4",
|
|
1069
|
+
buttonRounded: X = "rounded-full",
|
|
1070
|
+
buttonText: _ = "Login"
|
|
1071
|
+
} = t;
|
|
1072
|
+
return /* @__PURE__ */ i.jsxs("form", { onSubmit: n, className: `${c} ${g} ${p} ${u}`, children: [
|
|
1073
|
+
/* @__PURE__ */ i.jsx("h1", { className: `${T} ${N} ${L}`, children: E }),
|
|
1074
|
+
/* @__PURE__ */ i.jsxs("div", { className: "flex justify-center flex-col gap-1 my-4 w-1/2 mx-auto", children: [
|
|
1075
|
+
/* @__PURE__ */ i.jsx(nt, { labelId: "user-email", label: y }),
|
|
1076
|
+
/* @__PURE__ */ i.jsx(
|
|
1077
|
+
rt,
|
|
1078
|
+
{
|
|
1079
|
+
inputType: w,
|
|
1080
|
+
inputId: "user-email",
|
|
1081
|
+
inputPlaceholder: m,
|
|
1082
|
+
inputValue: f ? o[f] : o.email,
|
|
1083
|
+
inputChange: (P) => {
|
|
1084
|
+
a(f || "email", P.target.value);
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
)
|
|
1088
|
+
] }),
|
|
1089
|
+
/* @__PURE__ */ i.jsxs("div", { className: "flex justify-center flex-col gap-1 my-4 w-1/2 mx-auto", children: [
|
|
1090
|
+
/* @__PURE__ */ i.jsx(nt, { labelId: "password", label: "Password" }),
|
|
1091
|
+
/* @__PURE__ */ i.jsx(
|
|
1092
|
+
rt,
|
|
1093
|
+
{
|
|
1094
|
+
inputType: "password",
|
|
1095
|
+
inputId: "password",
|
|
1096
|
+
inputPlaceholder: "Password",
|
|
1097
|
+
inputValue: o.password,
|
|
1098
|
+
inputChange: (P) => {
|
|
1099
|
+
a("password", P.target.value);
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
)
|
|
1103
|
+
] }),
|
|
1104
|
+
/* @__PURE__ */ i.jsx("div", { className: `flex ${O} items-center ${b}`, children: /* @__PURE__ */ i.jsx("button", { className: `${j} ${D} ${I} font-bold ${H} ${X}`, children: _ }) })
|
|
1105
|
+
] });
|
|
1106
|
+
}, mr = () => {
|
|
1107
|
+
const { login: t } = Te(), { setShowAlert: n, setTypeAlert: o, setMessageAlert: a } = G(), { clearLoginFormOnError: c } = pe(), u = ot(), g = {
|
|
1108
|
+
email: "",
|
|
1109
|
+
password: ""
|
|
1110
|
+
}, [p, f] = A(g), y = (m, E) => {
|
|
1111
|
+
f((T) => ({ ...T, [m]: E }));
|
|
1112
|
+
}, w = (m) => {
|
|
1113
|
+
t(m, p), c && f(g);
|
|
1114
|
+
};
|
|
1115
|
+
return V(() => {
|
|
1116
|
+
const m = localStorage.getItem("id");
|
|
1117
|
+
localStorage.getItem("accessToken") && m && (u(`/dashboard/${m}`), n(!0), o("info"), a("Sei già loggato"));
|
|
1118
|
+
}, []), /* @__PURE__ */ i.jsx("section", { children: /* @__PURE__ */ i.jsx("div", { className: "container mx-auto flex items-center justify-center h-screen", children: /* @__PURE__ */ i.jsx(
|
|
1119
|
+
ir,
|
|
1120
|
+
{
|
|
1121
|
+
submitForm: w,
|
|
1122
|
+
formData: p,
|
|
1123
|
+
changeValue: y
|
|
1124
|
+
}
|
|
1125
|
+
) }) });
|
|
1126
|
+
}, br = () => {
|
|
1127
|
+
const { id: t } = zt(), { logout: n, setCurrentToken: o } = Te(), { usersEndpoint: a } = pe(), { setIsLoading: c } = Re(), { setShowAlert: u, setTypeAlert: g, setMessageAlert: p } = G(), [f, y] = A({}), [w, m] = A(null), [E, T] = A(!1), N = async () => {
|
|
1128
|
+
try {
|
|
1129
|
+
c(!0);
|
|
1130
|
+
const b = localStorage.getItem("accessToken");
|
|
1131
|
+
if (!b) {
|
|
1132
|
+
n(), u(!0), g("danger"), p("Sessione scaduta");
|
|
1133
|
+
return;
|
|
1134
|
+
}
|
|
1135
|
+
o(b);
|
|
1136
|
+
const I = (await (await ue(u, g, p)).get(
|
|
1137
|
+
`${a}${t}`,
|
|
1138
|
+
{ headers: {
|
|
1139
|
+
Authorization: b
|
|
1140
|
+
} }
|
|
1141
|
+
)).data;
|
|
1142
|
+
y(I), c(!1);
|
|
1143
|
+
} catch (b) {
|
|
1144
|
+
console.error(b), c(!1), n();
|
|
1145
|
+
}
|
|
1146
|
+
}, L = async () => {
|
|
1147
|
+
try {
|
|
1148
|
+
T(!0);
|
|
1149
|
+
const b = localStorage.getItem("accessToken");
|
|
1150
|
+
if (!b) {
|
|
1151
|
+
n(), u(!0), g("danger"), p("Sessione scaduta");
|
|
1152
|
+
return;
|
|
1153
|
+
}
|
|
1154
|
+
const I = (await (await ue(u, g, p)).get(
|
|
1155
|
+
`${a}`,
|
|
1156
|
+
{ headers: {
|
|
1157
|
+
Authorization: b
|
|
1158
|
+
} }
|
|
1159
|
+
)).data;
|
|
1160
|
+
m(I), I && T(!1);
|
|
1161
|
+
} catch (b) {
|
|
1162
|
+
console.error(b), c(!1), b.status === 401 && n(), T(!1);
|
|
1163
|
+
}
|
|
1164
|
+
}, O = () => {
|
|
1165
|
+
n(), u(!0), g("info"), p("Hai effettuato il logout");
|
|
1166
|
+
};
|
|
1167
|
+
return V(() => {
|
|
1168
|
+
N();
|
|
1169
|
+
}, []), /* @__PURE__ */ i.jsx("section", { children: /* @__PURE__ */ i.jsxs("div", { className: "container mx-auto py-8", children: [
|
|
1170
|
+
/* @__PURE__ */ i.jsxs("div", { className: "flex items-center justify-center gap-8 h-20", children: [
|
|
1171
|
+
/* @__PURE__ */ i.jsxs("h1", { className: "text-4xl text-center text-slate-800", children: [
|
|
1172
|
+
"Email: ",
|
|
1173
|
+
f.email
|
|
1174
|
+
] }),
|
|
1175
|
+
/* @__PURE__ */ i.jsx(
|
|
1176
|
+
"button",
|
|
1177
|
+
{
|
|
1178
|
+
onClick: O,
|
|
1179
|
+
className: "bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-4 rounded-full",
|
|
1180
|
+
children: "Logout"
|
|
1181
|
+
}
|
|
1182
|
+
)
|
|
1183
|
+
] }),
|
|
1184
|
+
/* @__PURE__ */ i.jsx("div", { className: "flex justify-center items-center my-12", children: /* @__PURE__ */ i.jsx(
|
|
1185
|
+
"button",
|
|
1186
|
+
{
|
|
1187
|
+
onClick: L,
|
|
1188
|
+
className: "bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-full disabled:bg-blue-300 disabled:text-gray-500 disabled:cursor-not-allowed",
|
|
1189
|
+
disabled: E,
|
|
1190
|
+
children: "Lista degli utenti"
|
|
1191
|
+
}
|
|
1192
|
+
) }),
|
|
1193
|
+
/* @__PURE__ */ i.jsx("div", { className: "flex justify-center items-center", children: w && /* @__PURE__ */ i.jsx("ul", { children: w.map((b) => /* @__PURE__ */ i.jsxs("li", { className: "text-xl my-4", children: [
|
|
1194
|
+
b.id,
|
|
1195
|
+
" - ",
|
|
1196
|
+
b.email
|
|
1197
|
+
] }, `user-${b.id}`)) }) })
|
|
1198
|
+
] }) });
|
|
1199
|
+
};
|
|
1200
|
+
export {
|
|
1201
|
+
sr as Alert,
|
|
1202
|
+
gr as AlertProvider,
|
|
1203
|
+
pr as AuthPage,
|
|
1204
|
+
vr as AuthProvider,
|
|
1205
|
+
dr as ConfigProvider,
|
|
1206
|
+
br as Dashboard,
|
|
1207
|
+
hr as DefaultLayout,
|
|
1208
|
+
rt as Input,
|
|
1209
|
+
nt as InputLabel,
|
|
1210
|
+
tr as Loading,
|
|
1211
|
+
fr as LoadingProvider,
|
|
1212
|
+
mr as Login,
|
|
1213
|
+
ir as LoginForm,
|
|
1214
|
+
ue as fetchAxiosConfig
|
|
1215
|
+
};
|