@tracktor/shared-module 2.26.1 → 2.26.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat/types.d.ts +1 -0
- package/dist/main.js +193 -183
- package/dist/main.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/chat/types.d.ts
CHANGED
package/dist/main.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
const
|
|
4
|
-
const n =
|
|
1
|
+
import ae from "axios";
|
|
2
|
+
import we, { useMemo as Z, createContext as he, useContext as C, useEffect as N, useState as D, Suspense as Ee, useRef as B, useCallback as O } from "react";
|
|
3
|
+
const Ke = (e, t) => {
|
|
4
|
+
const n = ae.CancelToken.source(), s = ae({
|
|
5
5
|
...e,
|
|
6
6
|
...t,
|
|
7
7
|
cancelToken: n.token
|
|
@@ -9,8 +9,18 @@ const Je = (e, t) => {
|
|
|
9
9
|
return s.cancel = () => {
|
|
10
10
|
n.cancel("Query was cancelled");
|
|
11
11
|
}, s;
|
|
12
|
-
},
|
|
13
|
-
|
|
12
|
+
}, ve = 3e4, ie = 1e3, H = (e) => Array.isArray(e) ? e.map(H) : e !== null && typeof e == "object" ? Object.fromEntries(
|
|
13
|
+
Object.entries(e).map(([t, n]) => [
|
|
14
|
+
t.replace(/_([a-z])/g, (s, o) => o.toUpperCase()),
|
|
15
|
+
H(n)
|
|
16
|
+
])
|
|
17
|
+
) : e, X = (e) => Array.isArray(e) ? e.map(X) : e !== null && typeof e == "object" ? Object.fromEntries(
|
|
18
|
+
Object.entries(e).map(([t, n]) => [
|
|
19
|
+
t.replace(/[A-Z]/g, (s) => `_${s.toLowerCase()}`),
|
|
20
|
+
X(n)
|
|
21
|
+
])
|
|
22
|
+
) : e;
|
|
23
|
+
class _e {
|
|
14
24
|
url;
|
|
15
25
|
getToken;
|
|
16
26
|
onEvent;
|
|
@@ -45,8 +55,8 @@ class ve {
|
|
|
45
55
|
this._connected = !0, this.reconnectAttempt = 0, this.onConnectionChange?.(!0), this.rejoinThreads(), this.flushPendingMessages();
|
|
46
56
|
}, this.ws.onmessage = (o) => {
|
|
47
57
|
try {
|
|
48
|
-
const a = JSON.parse(o.data);
|
|
49
|
-
|
|
58
|
+
const a = JSON.parse(o.data), c = H(a);
|
|
59
|
+
c.type === "ready" && (this._ready = !0), this.onEvent?.(c);
|
|
50
60
|
} catch {
|
|
51
61
|
}
|
|
52
62
|
}, this.ws.onclose = () => {
|
|
@@ -64,8 +74,8 @@ class ve {
|
|
|
64
74
|
this.joinedThreads.delete(t), this.send({ threadId: t, type: "leave_thread" });
|
|
65
75
|
}
|
|
66
76
|
sendMessage(t, n) {
|
|
67
|
-
if (n.length >
|
|
68
|
-
throw new Error(`Message body exceeds maximum length of ${
|
|
77
|
+
if (n.length > ie)
|
|
78
|
+
throw new Error(`Message body exceeds maximum length of ${ie} characters`);
|
|
69
79
|
this.send({ body: n, threadId: t, type: "send_message" });
|
|
70
80
|
}
|
|
71
81
|
markRead(t) {
|
|
@@ -79,7 +89,7 @@ class ve {
|
|
|
79
89
|
this.pendingMessages.push(t);
|
|
80
90
|
return;
|
|
81
91
|
}
|
|
82
|
-
this.ws.send(JSON.stringify(t));
|
|
92
|
+
this.ws.send(JSON.stringify(X(t)));
|
|
83
93
|
}
|
|
84
94
|
flushPendingMessages() {
|
|
85
95
|
const t = [...this.pendingMessages];
|
|
@@ -93,7 +103,7 @@ class ve {
|
|
|
93
103
|
}
|
|
94
104
|
scheduleReconnect() {
|
|
95
105
|
this.clearReconnectTimer();
|
|
96
|
-
const t = Math.min(this.reconnectBaseDelay * 2 ** this.reconnectAttempt,
|
|
106
|
+
const t = Math.min(this.reconnectBaseDelay * 2 ** this.reconnectAttempt, ve);
|
|
97
107
|
this.reconnectAttempt++, this.reconnectTimer = setTimeout(() => {
|
|
98
108
|
this.connect();
|
|
99
109
|
}, t);
|
|
@@ -103,10 +113,10 @@ class ve {
|
|
|
103
113
|
}
|
|
104
114
|
}
|
|
105
115
|
var V = { exports: {} }, M = {};
|
|
106
|
-
var
|
|
107
|
-
function
|
|
108
|
-
if (
|
|
109
|
-
|
|
116
|
+
var ce;
|
|
117
|
+
function Re() {
|
|
118
|
+
if (ce) return M;
|
|
119
|
+
ce = 1;
|
|
110
120
|
var e = /* @__PURE__ */ Symbol.for("react.transitional.element"), t = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
111
121
|
function n(s, o, a) {
|
|
112
122
|
var c = null;
|
|
@@ -126,9 +136,9 @@ function Ee() {
|
|
|
126
136
|
return M.Fragment = t, M.jsx = n, M.jsxs = n, M;
|
|
127
137
|
}
|
|
128
138
|
var U = {};
|
|
129
|
-
var
|
|
130
|
-
function
|
|
131
|
-
return
|
|
139
|
+
var le;
|
|
140
|
+
function be() {
|
|
141
|
+
return le || (le = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
132
142
|
function e(r) {
|
|
133
143
|
if (r == null) return null;
|
|
134
144
|
if (typeof r == "function")
|
|
@@ -154,7 +164,7 @@ function Re() {
|
|
|
154
164
|
), r.$$typeof) {
|
|
155
165
|
case A:
|
|
156
166
|
return "Portal";
|
|
157
|
-
case
|
|
167
|
+
case v:
|
|
158
168
|
return r.displayName || "Context";
|
|
159
169
|
case b:
|
|
160
170
|
return (r._context.displayName || "Context") + ".Consumer";
|
|
@@ -184,11 +194,11 @@ function Re() {
|
|
|
184
194
|
}
|
|
185
195
|
if (p) {
|
|
186
196
|
p = console;
|
|
187
|
-
var w = p.error,
|
|
197
|
+
var w = p.error, _ = typeof Symbol == "function" && Symbol.toStringTag && r[Symbol.toStringTag] || r.constructor.name || "Object";
|
|
188
198
|
return w.call(
|
|
189
199
|
p,
|
|
190
200
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
191
|
-
|
|
201
|
+
_
|
|
192
202
|
), t(r);
|
|
193
203
|
}
|
|
194
204
|
}
|
|
@@ -211,7 +221,7 @@ function Re() {
|
|
|
211
221
|
return Error("react-stack-top-frame");
|
|
212
222
|
}
|
|
213
223
|
function c(r) {
|
|
214
|
-
if (
|
|
224
|
+
if (ee.call(r, "key")) {
|
|
215
225
|
var p = Object.getOwnPropertyDescriptor(r, "key").get;
|
|
216
226
|
if (p && p.isReactWarning) return !1;
|
|
217
227
|
}
|
|
@@ -219,7 +229,7 @@ function Re() {
|
|
|
219
229
|
}
|
|
220
230
|
function u(r, p) {
|
|
221
231
|
function w() {
|
|
222
|
-
|
|
232
|
+
te || (te = !0, console.error(
|
|
223
233
|
"%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://react.dev/link/special-props)",
|
|
224
234
|
p
|
|
225
235
|
));
|
|
@@ -231,19 +241,19 @@ function Re() {
|
|
|
231
241
|
}
|
|
232
242
|
function l() {
|
|
233
243
|
var r = e(this.type);
|
|
234
|
-
return
|
|
244
|
+
return re[r] || (re[r] = !0, console.error(
|
|
235
245
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
236
246
|
)), r = this.props.ref, r !== void 0 ? r : null;
|
|
237
247
|
}
|
|
238
|
-
function f(r, p, w,
|
|
239
|
-
var
|
|
248
|
+
function f(r, p, w, _, W, K) {
|
|
249
|
+
var R = w.ref;
|
|
240
250
|
return r = {
|
|
241
|
-
$$typeof:
|
|
251
|
+
$$typeof: E,
|
|
242
252
|
type: r,
|
|
243
253
|
key: p,
|
|
244
254
|
props: w,
|
|
245
|
-
_owner:
|
|
246
|
-
}, (
|
|
255
|
+
_owner: _
|
|
256
|
+
}, (R !== void 0 ? R : null) !== null ? Object.defineProperty(r, "ref", {
|
|
247
257
|
enumerable: !1,
|
|
248
258
|
get: l
|
|
249
259
|
}) : Object.defineProperty(r, "ref", { enumerable: !1, value: null }), r._store = {}, Object.defineProperty(r._store, "validated", {
|
|
@@ -268,48 +278,48 @@ function Re() {
|
|
|
268
278
|
value: K
|
|
269
279
|
}), Object.freeze && (Object.freeze(r.props), Object.freeze(r)), r;
|
|
270
280
|
}
|
|
271
|
-
function i(r, p, w,
|
|
272
|
-
var
|
|
273
|
-
if (
|
|
274
|
-
if (
|
|
275
|
-
if (
|
|
276
|
-
for (
|
|
277
|
-
h(_
|
|
278
|
-
Object.freeze && Object.freeze(
|
|
281
|
+
function i(r, p, w, _, W, K) {
|
|
282
|
+
var R = p.children;
|
|
283
|
+
if (R !== void 0)
|
|
284
|
+
if (_)
|
|
285
|
+
if (me(R)) {
|
|
286
|
+
for (_ = 0; _ < R.length; _++)
|
|
287
|
+
h(R[_]);
|
|
288
|
+
Object.freeze && Object.freeze(R);
|
|
279
289
|
} else
|
|
280
290
|
console.error(
|
|
281
291
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
282
292
|
);
|
|
283
|
-
else h(
|
|
284
|
-
if (
|
|
285
|
-
|
|
286
|
-
var F = Object.keys(p).filter(function(
|
|
287
|
-
return
|
|
293
|
+
else h(R);
|
|
294
|
+
if (ee.call(p, "key")) {
|
|
295
|
+
R = e(r);
|
|
296
|
+
var F = Object.keys(p).filter(function(ye) {
|
|
297
|
+
return ye !== "key";
|
|
288
298
|
});
|
|
289
|
-
|
|
299
|
+
_ = 0 < F.length ? "{key: someKey, " + F.join(": ..., ") + ": ...}" : "{key: someKey}", se[R + _] || (F = 0 < F.length ? "{" + F.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
290
300
|
`A props object containing a "key" prop is being spread into JSX:
|
|
291
301
|
let props = %s;
|
|
292
302
|
<%s {...props} />
|
|
293
303
|
React keys must be passed directly to JSX without using spread:
|
|
294
304
|
let props = %s;
|
|
295
305
|
<%s key={someKey} {...props} />`,
|
|
296
|
-
R,
|
|
297
306
|
_,
|
|
307
|
+
R,
|
|
298
308
|
F,
|
|
299
|
-
|
|
300
|
-
),
|
|
309
|
+
R
|
|
310
|
+
), se[R + _] = !0);
|
|
301
311
|
}
|
|
302
|
-
if (
|
|
312
|
+
if (R = null, w !== void 0 && (n(w), R = "" + w), c(p) && (n(p.key), R = "" + p.key), "key" in p) {
|
|
303
313
|
w = {};
|
|
304
314
|
for (var q in p)
|
|
305
315
|
q !== "key" && (w[q] = p[q]);
|
|
306
316
|
} else w = p;
|
|
307
|
-
return
|
|
317
|
+
return R && u(
|
|
308
318
|
w,
|
|
309
319
|
typeof r == "function" ? r.displayName || r.name || "Unknown" : r
|
|
310
320
|
), f(
|
|
311
321
|
r,
|
|
312
|
-
|
|
322
|
+
R,
|
|
313
323
|
w,
|
|
314
324
|
o(),
|
|
315
325
|
W,
|
|
@@ -320,9 +330,9 @@ React keys must be passed directly to JSX without using spread:
|
|
|
320
330
|
m(r) ? r._store && (r._store.validated = 1) : typeof r == "object" && r !== null && r.$$typeof === Y && (r._payload.status === "fulfilled" ? m(r._payload.value) && r._payload.value._store && (r._payload.value._store.validated = 1) : r._store && (r._store.validated = 1));
|
|
321
331
|
}
|
|
322
332
|
function m(r) {
|
|
323
|
-
return typeof r == "object" && r !== null && r.$$typeof ===
|
|
333
|
+
return typeof r == "object" && r !== null && r.$$typeof === E;
|
|
324
334
|
}
|
|
325
|
-
var y =
|
|
335
|
+
var y = we, E = /* @__PURE__ */ Symbol.for("react.transitional.element"), A = /* @__PURE__ */ Symbol.for("react.portal"), k = /* @__PURE__ */ Symbol.for("react.fragment"), g = /* @__PURE__ */ Symbol.for("react.strict_mode"), d = /* @__PURE__ */ Symbol.for("react.profiler"), b = /* @__PURE__ */ Symbol.for("react.consumer"), v = /* @__PURE__ */ Symbol.for("react.context"), T = /* @__PURE__ */ Symbol.for("react.forward_ref"), x = /* @__PURE__ */ Symbol.for("react.suspense"), S = /* @__PURE__ */ Symbol.for("react.suspense_list"), $ = /* @__PURE__ */ Symbol.for("react.memo"), Y = /* @__PURE__ */ Symbol.for("react.lazy"), J = /* @__PURE__ */ Symbol.for("react.activity"), L = /* @__PURE__ */ Symbol.for("react.client.reference"), P = y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, ee = Object.prototype.hasOwnProperty, me = Array.isArray, G = console.createTask ? console.createTask : function() {
|
|
326
336
|
return null;
|
|
327
337
|
};
|
|
328
338
|
y = {
|
|
@@ -330,47 +340,47 @@ React keys must be passed directly to JSX without using spread:
|
|
|
330
340
|
return r();
|
|
331
341
|
}
|
|
332
342
|
};
|
|
333
|
-
var
|
|
343
|
+
var te, re = {}, ne = y.react_stack_bottom_frame.bind(
|
|
334
344
|
y,
|
|
335
345
|
a
|
|
336
|
-
)(),
|
|
346
|
+
)(), oe = G(s(a)), se = {};
|
|
337
347
|
U.Fragment = k, U.jsx = function(r, p, w) {
|
|
338
|
-
var
|
|
348
|
+
var _ = 1e4 > P.recentlyCreatedOwnerStacks++;
|
|
339
349
|
return i(
|
|
340
350
|
r,
|
|
341
351
|
p,
|
|
342
352
|
w,
|
|
343
353
|
!1,
|
|
344
|
-
|
|
345
|
-
|
|
354
|
+
_ ? Error("react-stack-top-frame") : ne,
|
|
355
|
+
_ ? G(s(r)) : oe
|
|
346
356
|
);
|
|
347
357
|
}, U.jsxs = function(r, p, w) {
|
|
348
|
-
var
|
|
358
|
+
var _ = 1e4 > P.recentlyCreatedOwnerStacks++;
|
|
349
359
|
return i(
|
|
350
360
|
r,
|
|
351
361
|
p,
|
|
352
362
|
w,
|
|
353
363
|
!0,
|
|
354
|
-
|
|
355
|
-
|
|
364
|
+
_ ? Error("react-stack-top-frame") : ne,
|
|
365
|
+
_ ? G(s(r)) : oe
|
|
356
366
|
);
|
|
357
367
|
};
|
|
358
368
|
})()), U;
|
|
359
369
|
}
|
|
360
|
-
var
|
|
361
|
-
function
|
|
362
|
-
return
|
|
370
|
+
var ue;
|
|
371
|
+
function Te() {
|
|
372
|
+
return ue || (ue = 1, process.env.NODE_ENV === "production" ? V.exports = Re() : V.exports = be()), V.exports;
|
|
363
373
|
}
|
|
364
|
-
var I =
|
|
365
|
-
const
|
|
366
|
-
const n =
|
|
374
|
+
var I = Te();
|
|
375
|
+
const qe = ({ IMaskMixin: e, ...t }) => {
|
|
376
|
+
const n = Z(
|
|
367
377
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
368
378
|
() => e(({ TextField: s, ...o }) => /* @__PURE__ */ I.jsx(s, { ...o })),
|
|
369
379
|
[e]
|
|
370
380
|
);
|
|
371
381
|
return /* @__PURE__ */ I.jsx(n, { ...t });
|
|
372
|
-
},
|
|
373
|
-
const o =
|
|
382
|
+
}, j = he({}), Be = ({ children: e, apiURL: t, libraries: n, localStorageKeys: s }) => {
|
|
383
|
+
const o = Z(
|
|
374
384
|
() => ({
|
|
375
385
|
apiURL: t,
|
|
376
386
|
libraries: n,
|
|
@@ -378,9 +388,9 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
378
388
|
}),
|
|
379
389
|
[t, n, s]
|
|
380
390
|
);
|
|
381
|
-
return /* @__PURE__ */ I.jsx(
|
|
382
|
-
},
|
|
383
|
-
const { libraries: n } = j
|
|
391
|
+
return /* @__PURE__ */ I.jsx(j.Provider, { value: o, children: e });
|
|
392
|
+
}, He = ({ data: e, ...t }) => {
|
|
393
|
+
const { libraries: n } = C(j), s = t?.reactRouter || n?.reactRouter, o = t?.gtm || n?.gtm;
|
|
384
394
|
if (!s)
|
|
385
395
|
throw new Error(
|
|
386
396
|
"React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView."
|
|
@@ -403,13 +413,13 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
403
413
|
} catch {
|
|
404
414
|
return !1;
|
|
405
415
|
}
|
|
406
|
-
})(),
|
|
416
|
+
})(), Se = "user", Xe = ({
|
|
407
417
|
tokenTypeKey: e = "tokenType",
|
|
408
418
|
tokenKey: t = "accessToken",
|
|
409
419
|
postContentType: n = "application/json",
|
|
410
420
|
...s
|
|
411
421
|
}) => {
|
|
412
|
-
const { apiURL: o = s.apiURL, libraries: a, localStorageKeys: c } = j
|
|
422
|
+
const { apiURL: o = s.apiURL, libraries: a, localStorageKeys: c } = C(j), u = s?.userLocalStorageKey || c?.user || Se, l = s?.axios || a?.axios;
|
|
413
423
|
if (!l)
|
|
414
424
|
throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
415
425
|
if (!l?.defaults || z)
|
|
@@ -419,8 +429,8 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
419
429
|
y && (l.defaults.headers.common.Authorization = y);
|
|
420
430
|
}
|
|
421
431
|
return l.defaults.baseURL = o, l.defaults.headers.post["Content-Type"] = n, null;
|
|
422
|
-
},
|
|
423
|
-
const { libraries: n } = j
|
|
432
|
+
}, Ze = ({ language: e, ...t }) => {
|
|
433
|
+
const { libraries: n } = C(j), s = t?.dayjs || n?.dayjs, o = t?.plugin || n?.dayjsPlugin;
|
|
424
434
|
if (!s)
|
|
425
435
|
throw new Error(
|
|
426
436
|
"Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig."
|
|
@@ -433,8 +443,8 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
433
443
|
}), await import("dayjs/locale/en"), await import("dayjs/locale/fr"), s.locale(c);
|
|
434
444
|
})().then();
|
|
435
445
|
}, [s, o, e]), null;
|
|
436
|
-
},
|
|
437
|
-
const { libraries: s } = j
|
|
446
|
+
}, et = ({ debug: e, resources: t, ...n }) => {
|
|
447
|
+
const { libraries: s } = C(j), o = n?.i18 || s?.i18, { i18next: a, initReactI18next: c, languageDetector: u } = o || {};
|
|
438
448
|
if (z)
|
|
439
449
|
return null;
|
|
440
450
|
if (!o)
|
|
@@ -457,7 +467,7 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
457
467
|
}), a.on("languageChanged", (l) => {
|
|
458
468
|
document.documentElement.setAttribute("lang", l);
|
|
459
469
|
})), null;
|
|
460
|
-
},
|
|
470
|
+
}, tt = ({
|
|
461
471
|
dsn: e,
|
|
462
472
|
integrations: t,
|
|
463
473
|
tracesSampleRate: n,
|
|
@@ -470,14 +480,14 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
470
480
|
release: f,
|
|
471
481
|
...i
|
|
472
482
|
}) => {
|
|
473
|
-
const { libraries: h } = j
|
|
483
|
+
const { libraries: h } = C(j), m = i?.sentry || h?.sentry, y = i?.reactRouter || h?.reactRouter;
|
|
474
484
|
if (!m)
|
|
475
485
|
throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
476
486
|
if (!y)
|
|
477
487
|
throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
478
488
|
if (m.isInitialized())
|
|
479
489
|
return null;
|
|
480
|
-
const { createRoutesFromChildren:
|
|
490
|
+
const { createRoutesFromChildren: E, matchRoutes: A, useLocation: k, useNavigationType: g } = y;
|
|
481
491
|
return (u || process.env.NODE_ENV === "prod" || process.env.NODE_ENV === "production") && m.init({
|
|
482
492
|
debug: u,
|
|
483
493
|
dsn: e,
|
|
@@ -493,7 +503,7 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
493
503
|
],
|
|
494
504
|
integrations: [
|
|
495
505
|
m.reactRouterV6BrowserTracingIntegration({
|
|
496
|
-
createRoutesFromChildren:
|
|
506
|
+
createRoutesFromChildren: E,
|
|
497
507
|
matchRoutes: A,
|
|
498
508
|
useEffect: N,
|
|
499
509
|
useLocation: k,
|
|
@@ -507,7 +517,7 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
507
517
|
tracePropagationTargets: a,
|
|
508
518
|
tracesSampleRate: n || 1
|
|
509
519
|
}), null;
|
|
510
|
-
},
|
|
520
|
+
}, rt = () => (N(() => {
|
|
511
521
|
if (z)
|
|
512
522
|
return;
|
|
513
523
|
const e = (t) => {
|
|
@@ -519,27 +529,27 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
519
529
|
return window.addEventListener("vite:preloadError", e), () => {
|
|
520
530
|
window.removeEventListener("vite:preloadError", e);
|
|
521
531
|
};
|
|
522
|
-
}, []), null),
|
|
523
|
-
const { libraries: a, localStorageKeys: c } = j
|
|
532
|
+
}, []), null), de = /* @__PURE__ */ new WeakMap(), Ae = "user", nt = ({ Fallback: e, isLogged: t, loginPath: n = "/login", redirect401Path: s = "/login", ...o }) => {
|
|
533
|
+
const { libraries: a, localStorageKeys: c } = C(j), u = o?.reactRouter || a?.reactRouter, l = o?.axios || a?.axios, f = o?.localStorageKey || c?.user || Ae;
|
|
524
534
|
if (!u)
|
|
525
535
|
throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
526
|
-
const [i, h] = D(null), { useLocation: m, Navigate: y, Outlet:
|
|
536
|
+
const [i, h] = D(null), { useLocation: m, Navigate: y, Outlet: E } = u, A = m(), k = typeof t == "function" ? t() : !!t, g = typeof k == "boolean" ? k : k?.isLogged;
|
|
527
537
|
return N(() => {
|
|
528
|
-
|
|
538
|
+
de.has(l) || (de.set(l, !0), l.interceptors.response.use(
|
|
529
539
|
(d) => d,
|
|
530
540
|
(d) => (typeof d == "object" && d && "response" in d && d.response && typeof d.response == "object" && "status" in d.response && d.response && typeof d.response == "object" && "status" in d.response && d?.response?.status === 401 && (typeof d == "object" && d && "config" in d && d.config && typeof d.config == "object" && "headers" in d.config && d.config.headers && typeof d.config.headers == "object" && "Authorization" in d.config.headers && d.config.headers.Authorization && (l.defaults.headers.common.Authorization = null, typeof window < "u" && window.localStorage && localStorage.removeItem(f)), h(s)), Promise.reject(d))
|
|
531
541
|
));
|
|
532
|
-
}, [l, f, s]), g && !i ? /* @__PURE__ */ I.jsx(
|
|
533
|
-
},
|
|
542
|
+
}, [l, f, s]), g && !i ? /* @__PURE__ */ I.jsx(Ee, { fallback: e, children: A.state?.from?.state && A.state?.from?.pathname === n ? /* @__PURE__ */ I.jsx(y, { to: A.state.from.state.from.pathname + A.state.from.state.from.search, replace: !0 }) : /* @__PURE__ */ I.jsx(E, {}) }) : /* @__PURE__ */ I.jsx(y, { to: n + A.search, state: { from: A }, replace: !0 });
|
|
543
|
+
}, Ce = (e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase(), je = (e) => {
|
|
534
544
|
const t = e.split(/[/\\]/).pop() || "";
|
|
535
545
|
return t.substring(0, t.lastIndexOf("."));
|
|
536
|
-
},
|
|
546
|
+
}, ke = (e) => {
|
|
537
547
|
const s = e.split("/").filter((o) => o.length > 0).map((o) => o.replace(/\${([^}]*)}/g, "$1").split(/[_-]/).map((l) => l.charAt(0).toUpperCase() + l.slice(1)).join("")).join("");
|
|
538
548
|
return s.charAt(0).toLowerCase() + s.slice(1);
|
|
539
|
-
},
|
|
540
|
-
const o =
|
|
549
|
+
}, Pe = (e) => (e.split("/").pop() || e).replace(/\.json$/, "").replace(/^openapi\./, ""), xe = (e, t, n, s) => {
|
|
550
|
+
const o = ke(t), a = Ce(n), c = `${o}${a}`;
|
|
541
551
|
return e && typeof e == "object" && "operationId" in e && s?.includes(String(e.operationId)) ? `${c}AsQuery` : c;
|
|
542
|
-
},
|
|
552
|
+
}, Oe = (e, t) => {
|
|
543
553
|
const n = {};
|
|
544
554
|
return e?.forEach((s) => {
|
|
545
555
|
n[s] = {
|
|
@@ -556,8 +566,8 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
556
566
|
}
|
|
557
567
|
};
|
|
558
568
|
}), Object.keys(n).length ? n : void 0;
|
|
559
|
-
},
|
|
560
|
-
const { output: o, useInfiniteIds: a, useQueryIds: c, input: u = "./openapi.json", customAxiosInstancePath: l, overrideApiName: f } = s || {}, i = f ||
|
|
569
|
+
}, ot = (e) => (Array.isArray(e) ? e : [e]).reduce((n, s) => {
|
|
570
|
+
const { output: o, useInfiniteIds: a, useQueryIds: c, input: u = "./openapi.json", customAxiosInstancePath: l, overrideApiName: f } = s || {}, i = f || Pe(u), h = l || "./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts";
|
|
561
571
|
return {
|
|
562
572
|
...n,
|
|
563
573
|
[i]: {
|
|
@@ -568,7 +578,7 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
568
578
|
mode: "tags-split",
|
|
569
579
|
override: {
|
|
570
580
|
...(a?.length || c?.length) && {
|
|
571
|
-
operations:
|
|
581
|
+
operations: Oe(a, c)
|
|
572
582
|
},
|
|
573
583
|
header: (m) => [
|
|
574
584
|
"Generated by orval 🍺",
|
|
@@ -576,10 +586,10 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
576
586
|
...m.description ? [m.description] : []
|
|
577
587
|
],
|
|
578
588
|
mutator: {
|
|
579
|
-
name:
|
|
589
|
+
name: je(h),
|
|
580
590
|
path: h
|
|
581
591
|
},
|
|
582
|
-
operationName: (m, y,
|
|
592
|
+
operationName: (m, y, E) => xe(m, y, E, c),
|
|
583
593
|
query: {
|
|
584
594
|
useQuery: !0
|
|
585
595
|
}
|
|
@@ -590,25 +600,25 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
590
600
|
}
|
|
591
601
|
}
|
|
592
602
|
};
|
|
593
|
-
}, {}),
|
|
603
|
+
}, {}), Ie = "user", Ne = (e) => {
|
|
594
604
|
const t = e.startsWith("https") ? "wss" : "ws", n = e.replace(/^https?:\/\//, "");
|
|
595
605
|
return `${t}://${n}/v2/threads/ws`;
|
|
596
|
-
},
|
|
606
|
+
}, Le = (e) => {
|
|
597
607
|
try {
|
|
598
608
|
const t = localStorage.getItem(e);
|
|
599
609
|
return t ? JSON.parse(t)?.accessToken ?? null : null;
|
|
600
610
|
} catch {
|
|
601
611
|
return null;
|
|
602
612
|
}
|
|
603
|
-
},
|
|
604
|
-
const [a, c] = D(!1), [u, l] = D(!1), [f, i] = D(0), { apiURL: h, localStorageKeys: m } = j
|
|
613
|
+
}, ge = he(null), st = ({ children: e, reconnect: t = !0, enabled: n = !0, url: s, token: o }) => {
|
|
614
|
+
const [a, c] = D(!1), [u, l] = D(!1), [f, i] = D(0), { apiURL: h, localStorageKeys: m } = C(j), y = m?.user || Ie, E = B(null), A = B(/* @__PURE__ */ new Set());
|
|
605
615
|
N(() => {
|
|
606
616
|
if (!n)
|
|
607
617
|
return;
|
|
608
|
-
const S = s || (h ?
|
|
618
|
+
const S = s || (h ? Ne(h) : null);
|
|
609
619
|
if (!S)
|
|
610
620
|
return;
|
|
611
|
-
const $ = () => o ??
|
|
621
|
+
const $ = () => o ?? Le(y), Y = (L) => {
|
|
612
622
|
switch (L.type) {
|
|
613
623
|
case "ready":
|
|
614
624
|
l(!0), i(L.unreadCount ?? 0);
|
|
@@ -623,7 +633,7 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
623
633
|
for (const P of A.current)
|
|
624
634
|
P(L);
|
|
625
635
|
}, J = setTimeout(() => {
|
|
626
|
-
const L = new
|
|
636
|
+
const L = new _e({
|
|
627
637
|
getToken: $,
|
|
628
638
|
onConnectionChange: (P) => {
|
|
629
639
|
c(P), P || l(!1);
|
|
@@ -632,22 +642,22 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
632
642
|
reconnect: t,
|
|
633
643
|
url: S
|
|
634
644
|
});
|
|
635
|
-
|
|
645
|
+
E.current = L, L.connect();
|
|
636
646
|
}, 0);
|
|
637
647
|
return () => {
|
|
638
|
-
clearTimeout(J),
|
|
648
|
+
clearTimeout(J), E.current?.disconnect(), E.current = null;
|
|
639
649
|
};
|
|
640
650
|
}, [n, s, o, h, t, y]);
|
|
641
651
|
const k = O((S) => {
|
|
642
|
-
|
|
652
|
+
E.current?.joinThread(S);
|
|
643
653
|
}, []), g = O((S) => {
|
|
644
|
-
|
|
654
|
+
E.current?.leaveThread(S);
|
|
645
655
|
}, []), d = O((S, $) => {
|
|
646
|
-
|
|
656
|
+
E.current?.sendMessage(S, $);
|
|
647
657
|
}, []), b = O((S) => {
|
|
648
|
-
|
|
649
|
-
}, []),
|
|
650
|
-
|
|
658
|
+
E.current?.markRead(S);
|
|
659
|
+
}, []), v = O((S, $) => {
|
|
660
|
+
E.current?.listThreads(S, $);
|
|
651
661
|
}, []), T = O((S) => (A.current.add(S), () => {
|
|
652
662
|
A.current.delete(S);
|
|
653
663
|
}), []), x = {
|
|
@@ -655,27 +665,27 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
655
665
|
isReady: u,
|
|
656
666
|
joinThread: k,
|
|
657
667
|
leaveThread: g,
|
|
658
|
-
listThreads:
|
|
668
|
+
listThreads: v,
|
|
659
669
|
markRead: b,
|
|
660
670
|
sendMessage: d,
|
|
661
671
|
subscribe: T,
|
|
662
672
|
unreadCount: f
|
|
663
673
|
};
|
|
664
|
-
return /* @__PURE__ */ I.jsx(
|
|
665
|
-
},
|
|
674
|
+
return /* @__PURE__ */ I.jsx(ge.Provider, { value: x, children: e });
|
|
675
|
+
}, $e = (e) => e && typeof e == "function", Fe = (e) => e && typeof e == "function", at = ({
|
|
666
676
|
children: e,
|
|
667
677
|
defaultQueriesOptions: t,
|
|
668
678
|
defaultMutationsOptions: n,
|
|
669
679
|
...s
|
|
670
680
|
}) => {
|
|
671
|
-
const { libraries: o } = j
|
|
681
|
+
const { libraries: o } = C(j), a = s?.QueryClient || o?.reactQuery?.QueryClient, c = s?.QueryClientProvider || o?.reactQuery?.QueryClientProvider;
|
|
672
682
|
if (!a)
|
|
673
683
|
throw new Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
674
684
|
if (!c)
|
|
675
685
|
throw new Error("QueryClientProvider is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
676
|
-
if (
|
|
686
|
+
if (!$e(c))
|
|
677
687
|
throw new Error("Provided QueryClientProvider dependencies are not valid.");
|
|
678
|
-
if (!
|
|
688
|
+
if (!Fe(a))
|
|
679
689
|
throw new Error("Provided QueryClient dependencies are not valid.");
|
|
680
690
|
const u = new a({
|
|
681
691
|
defaultOptions: {
|
|
@@ -691,42 +701,42 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
691
701
|
}
|
|
692
702
|
});
|
|
693
703
|
return /* @__PURE__ */ I.jsx(c, { client: u, children: e });
|
|
694
|
-
},
|
|
704
|
+
}, De = ({ library: e, date: t, format: n = "ll" }) => e(t).format(n), Ye = (e, t) => {
|
|
695
705
|
const { fractionDigits: n = 0, metric: s = "km", spacingBetween: o = !0 } = t || {}, a = Number(e), c = o ? " " : "";
|
|
696
706
|
return Number.isNaN(a) ? `0${c}${s}` : `${a.toFixed(n)}${c}${s}`;
|
|
697
|
-
},
|
|
707
|
+
}, Me = (e) => !e || typeof e != "string" ? "" : e.replace(/_/g, " ").toLowerCase().split(" ").map((n) => n.length > 0 ? n.charAt(0).toUpperCase() + n.slice(1) : n).join(" "), Ue = (e) => e?.startsWith("/") ? e?.startsWith("/files") ? e : `/files${e}` : e?.startsWith("files") ? `/${e}` : `/files/${e}`, ze = ({ path: e, size: t, apiURL: n }) => {
|
|
698
708
|
if (!e)
|
|
699
709
|
return "";
|
|
700
|
-
const s =
|
|
710
|
+
const s = Ue(e), o = `${n}${s}`, a = o.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/) !== null;
|
|
701
711
|
return typeof t == "number" && a ? `${o.replace("/files", `/thumbs/${t}`)}` : o;
|
|
702
|
-
},
|
|
703
|
-
const { apiURL: t, libraries: n } = j
|
|
712
|
+
}, it = (e) => {
|
|
713
|
+
const { apiURL: t, libraries: n } = C(j), s = e?.dayjs || n?.dayjs;
|
|
704
714
|
return {
|
|
705
715
|
dateAdapter: (c, u) => {
|
|
706
716
|
if (!s)
|
|
707
717
|
throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
708
|
-
return
|
|
718
|
+
return De({
|
|
709
719
|
date: c,
|
|
710
720
|
format: u,
|
|
711
721
|
library: s
|
|
712
722
|
});
|
|
713
723
|
},
|
|
714
|
-
distanceAdapter:
|
|
724
|
+
distanceAdapter: Ye,
|
|
715
725
|
filePathAdapter: (c, u) => {
|
|
716
726
|
if (!t)
|
|
717
727
|
throw new Error(
|
|
718
728
|
"API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter."
|
|
719
729
|
);
|
|
720
|
-
return typeof c == "string" && /^https?:\/\//.test(c) ? c :
|
|
730
|
+
return typeof c == "string" && /^https?:\/\//.test(c) ? c : ze({
|
|
721
731
|
apiURL: t,
|
|
722
732
|
path: c,
|
|
723
733
|
size: u
|
|
724
734
|
});
|
|
725
735
|
},
|
|
726
|
-
worksiteNameAdapter:
|
|
736
|
+
worksiteNameAdapter: Me
|
|
727
737
|
};
|
|
728
|
-
},
|
|
729
|
-
const { libraries: t, localStorageKeys: n } = j
|
|
738
|
+
}, ct = (e) => {
|
|
739
|
+
const { libraries: t, localStorageKeys: n } = C(j), s = e?.axios || t?.axios, o = e?.localStorageKey || n?.user || "user";
|
|
730
740
|
if (!s)
|
|
731
741
|
throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");
|
|
732
742
|
const a = O(
|
|
@@ -756,8 +766,8 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
756
766
|
clearAuthenticationToken: c,
|
|
757
767
|
setAuthenticationToken: a
|
|
758
768
|
};
|
|
759
|
-
},
|
|
760
|
-
const t =
|
|
769
|
+
}, lt = (e) => {
|
|
770
|
+
const t = C(ge);
|
|
761
771
|
if (!t)
|
|
762
772
|
throw new Error("useChat must be used within ChatProvider");
|
|
763
773
|
const { subscribe: n, ...s } = t, o = B(e);
|
|
@@ -771,7 +781,7 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
771
781
|
onJoinedThread: h,
|
|
772
782
|
onLeftThread: m,
|
|
773
783
|
onMarkedRead: y,
|
|
774
|
-
onThreadsList:
|
|
784
|
+
onThreadsList: E
|
|
775
785
|
} = o.current ?? {};
|
|
776
786
|
switch (a.type) {
|
|
777
787
|
case "ready":
|
|
@@ -799,11 +809,11 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
799
809
|
y?.(a);
|
|
800
810
|
break;
|
|
801
811
|
case "threads_list":
|
|
802
|
-
|
|
812
|
+
E?.(a);
|
|
803
813
|
break;
|
|
804
814
|
}
|
|
805
815
|
}), [n]), s;
|
|
806
|
-
}, Q = (e, t) => t === "short" ? e.split("-")[0] : e,
|
|
816
|
+
}, Q = (e, t) => t === "short" ? e.split("-")[0] : e, ut = (e, t = "full") => {
|
|
807
817
|
const [n, s] = D(() => {
|
|
808
818
|
const o = e?.language || navigator.language;
|
|
809
819
|
return e && "isInitialized" in e && e.isInitialized, Q(o, t);
|
|
@@ -817,7 +827,7 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
817
827
|
e?.off?.("languageChanged", o);
|
|
818
828
|
};
|
|
819
829
|
}, [e, t]), n;
|
|
820
|
-
},
|
|
830
|
+
}, We = "tracktor.filter", Ve = {
|
|
821
831
|
getFilter: () => {
|
|
822
832
|
},
|
|
823
833
|
getFilters: () => ({}),
|
|
@@ -825,13 +835,13 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
825
835
|
},
|
|
826
836
|
setFilter: () => {
|
|
827
837
|
}
|
|
828
|
-
},
|
|
838
|
+
}, fe = (e) => {
|
|
829
839
|
try {
|
|
830
840
|
return JSON.parse(e);
|
|
831
841
|
} catch {
|
|
832
842
|
return e;
|
|
833
843
|
}
|
|
834
|
-
},
|
|
844
|
+
}, pe = (e, t, n) => `${n}_${e}=>${t}`, Qe = (e) => e.reduce((t, n) => {
|
|
835
845
|
const s = localStorage.getItem(n);
|
|
836
846
|
if (s)
|
|
837
847
|
try {
|
|
@@ -840,11 +850,11 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
840
850
|
} catch {
|
|
841
851
|
}
|
|
842
852
|
return t;
|
|
843
|
-
}, {}),
|
|
844
|
-
const { libraries: t, localStorageKeys: n } = j
|
|
845
|
-
}], [u, l] = D({}), f = n?.filter ||
|
|
853
|
+
}, {}), dt = (e) => {
|
|
854
|
+
const { libraries: t, localStorageKeys: n } = C(j), s = e?.reactRouter || t?.reactRouter, { pathname: o } = s?.useLocation?.() ?? { pathname: "/" }, [a, c] = s?.useSearchParams?.() ?? [new URLSearchParams(), () => {
|
|
855
|
+
}], [u, l] = D({}), f = n?.filter || We, i = e?.syncWithUrl === void 0 ? !0 : e?.syncWithUrl, h = e?.persistToLocalStorage === void 0 ? !0 : e?.persistToLocalStorage;
|
|
846
856
|
if (z)
|
|
847
|
-
return
|
|
857
|
+
return Ve;
|
|
848
858
|
if (!s)
|
|
849
859
|
throw new Error(
|
|
850
860
|
"React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter."
|
|
@@ -852,32 +862,32 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
852
862
|
const m = () => Object.keys(localStorage).filter(
|
|
853
863
|
(g) => g.startsWith(f) && g.endsWith(e?.pathname || o)
|
|
854
864
|
), y = (g, d, b = !0) => {
|
|
855
|
-
const
|
|
865
|
+
const v = pe(g, e?.pathname || o, f);
|
|
856
866
|
if (!d || Array.isArray(d) && !d.length) {
|
|
857
867
|
i ? (a.delete(g), c(a)) : l((T) => {
|
|
858
868
|
const x = { ...T };
|
|
859
869
|
return delete x[g], x;
|
|
860
|
-
}), h && localStorage.removeItem(
|
|
870
|
+
}), h && localStorage.removeItem(v);
|
|
861
871
|
return;
|
|
862
872
|
}
|
|
863
|
-
h && b && d && localStorage.setItem(
|
|
873
|
+
h && b && d && localStorage.setItem(v, JSON.stringify({ ...a, [g]: d })), i && d ? (a.set(g, JSON.stringify(d)), c(a)) : !i && d && l((T) => ({ ...T, [g]: d }));
|
|
864
874
|
};
|
|
865
875
|
return {
|
|
866
876
|
getFilter: (g, d) => {
|
|
867
877
|
if (i) {
|
|
868
878
|
const b = a.get(g);
|
|
869
879
|
if (b)
|
|
870
|
-
return
|
|
880
|
+
return fe(b);
|
|
871
881
|
} else {
|
|
872
882
|
const b = u[g];
|
|
873
883
|
if (b !== void 0)
|
|
874
884
|
return b;
|
|
875
885
|
}
|
|
876
886
|
if (h) {
|
|
877
|
-
const b =
|
|
878
|
-
if (
|
|
887
|
+
const b = pe(g, e?.pathname || o, f), v = localStorage.getItem(b);
|
|
888
|
+
if (v)
|
|
879
889
|
try {
|
|
880
|
-
const T = JSON.parse(
|
|
890
|
+
const T = JSON.parse(v)[g];
|
|
881
891
|
return !i && T !== void 0 && l((x) => ({ ...x, [g]: T })), T;
|
|
882
892
|
} catch {
|
|
883
893
|
}
|
|
@@ -885,9 +895,9 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
885
895
|
return d;
|
|
886
896
|
},
|
|
887
897
|
getFilters: () => {
|
|
888
|
-
const g = h ?
|
|
898
|
+
const g = h ? Qe(m()) : {};
|
|
889
899
|
if (i) {
|
|
890
|
-
const d = Array.from(a.entries()).reduce((b, [
|
|
900
|
+
const d = Array.from(a.entries()).reduce((b, [v, T]) => (b[v] = fe(T), b), {});
|
|
891
901
|
return {
|
|
892
902
|
...g,
|
|
893
903
|
...d
|
|
@@ -898,9 +908,9 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
898
908
|
...u
|
|
899
909
|
};
|
|
900
910
|
},
|
|
901
|
-
handleFilter: (g, d) => (b,
|
|
902
|
-
if (
|
|
903
|
-
const T = d || "value", x = typeof
|
|
911
|
+
handleFilter: (g, d) => (b, v) => {
|
|
912
|
+
if (v || Array.isArray(v) && v.length === 0) {
|
|
913
|
+
const T = d || "value", x = typeof v == "object" && T in v ? v[T] : v;
|
|
904
914
|
y(g, x);
|
|
905
915
|
return;
|
|
906
916
|
}
|
|
@@ -908,7 +918,7 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
908
918
|
},
|
|
909
919
|
setFilter: y
|
|
910
920
|
};
|
|
911
|
-
},
|
|
921
|
+
}, ft = ({
|
|
912
922
|
data: e,
|
|
913
923
|
fetchNextPage: t,
|
|
914
924
|
isFetchingNextPage: n,
|
|
@@ -921,7 +931,7 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
921
931
|
n || !a || await t({ pageParam: l?.pageParam || l.visibleRowsCount });
|
|
922
932
|
},
|
|
923
933
|
[a, t, n]
|
|
924
|
-
), u =
|
|
934
|
+
), u = Z(() => {
|
|
925
935
|
if (e)
|
|
926
936
|
return e.pages.reduce((l, f) => [...l, ...f], []);
|
|
927
937
|
}, [e]);
|
|
@@ -931,8 +941,8 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
931
941
|
loadingVariant: s ? "skeleton" : "linear-progress",
|
|
932
942
|
rows: u
|
|
933
943
|
};
|
|
934
|
-
},
|
|
935
|
-
const { libraries: t } = j
|
|
944
|
+
}, pt = (e) => {
|
|
945
|
+
const { libraries: t } = C(j), n = e?.i18 || t?.i18, s = e?.i18?.translateFunction || t?.i18?.translateFunction, o = n?.i18next?.t || s || ((f) => f), { unknownErrorTranslationKey: a = "error.unknownError" } = e || {}, c = o(a), u = O(
|
|
936
946
|
(f) => {
|
|
937
947
|
if (f && typeof f == "object" && "response" in f) {
|
|
938
948
|
const { response: i } = f || {};
|
|
@@ -961,30 +971,30 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
961
971
|
}, []), printError: u };
|
|
962
972
|
};
|
|
963
973
|
export {
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
974
|
+
_e as ChatClient,
|
|
975
|
+
ge as ChatContext,
|
|
976
|
+
st as ChatProvider,
|
|
977
|
+
He as GTMSendPageView,
|
|
978
|
+
Xe as InitializeAxiosConfig,
|
|
979
|
+
Ze as InitializeDaysJSConfig,
|
|
980
|
+
et as InitializeI18nConfig,
|
|
981
|
+
tt as InitializeSentryConfig,
|
|
982
|
+
j as InjectDependenciesContext,
|
|
983
|
+
Be as InjectDependenciesProvider,
|
|
984
|
+
qe as MaskTextField,
|
|
985
|
+
rt as PreloadErrorHandler,
|
|
986
|
+
at as QueryClientProviderWithConfig,
|
|
987
|
+
nt as RequireAuth,
|
|
988
|
+
Ke as axiosCustomInstance,
|
|
989
|
+
De as dateAdapter,
|
|
990
|
+
Ye as distanceAdapter,
|
|
991
|
+
ot as getOrvalConfig,
|
|
992
|
+
it as useAdapter,
|
|
993
|
+
ct as useAuth,
|
|
994
|
+
lt as useChat,
|
|
995
|
+
ut as useCurrentLanguage,
|
|
996
|
+
dt as useFilters,
|
|
997
|
+
ft as useInfiniteDataGrid,
|
|
998
|
+
pt as useResponseError,
|
|
999
|
+
Me as worksiteNameAdapter
|
|
990
1000
|
};
|
package/dist/main.umd.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(function(g,F){typeof exports=="object"&&typeof module<"u"?F(exports,require("axios"),require("react")):typeof define=="function"&&define.amd?define(["exports","axios","react"],F):(g=typeof globalThis<"u"?globalThis:g||self,F(g["@tracktor/shared-module"]={},g.axios,g.React))})(this,(function(g,F,l){"use strict";const
|
|
1
|
+
(function(g,F){typeof exports=="object"&&typeof module<"u"?F(exports,require("axios"),require("react")):typeof define=="function"&&define.amd?define(["exports","axios","react"],F):(g=typeof globalThis<"u"?globalThis:g||self,F(g["@tracktor/shared-module"]={},g.axios,g.React))})(this,(function(g,F,l){"use strict";const pe=(e,t)=>{const r=F.CancelToken.source(),s=F({...e,...t,cancelToken:r.token}).then(({data:o})=>o);return s.cancel=()=>{r.cancel("Query was cancelled")},s},Q=e=>Array.isArray(e)?e.map(Q):e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([t,r])=>[t.replace(/_([a-z])/g,(s,o)=>o.toUpperCase()),Q(r)])):e,J=e=>Array.isArray(e)?e.map(J):e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([t,r])=>[t.replace(/[A-Z]/g,s=>`_${s.toLowerCase()}`),J(r)])):e;class q{url;getToken;onEvent;onConnectionChange;shouldReconnect;maxReconnectAttempts;reconnectBaseDelay;ws=null;reconnectAttempt=0;reconnectTimer=null;intentionalClose=!1;joinedThreads=new Set;pendingMessages=[];_connected=!1;_ready=!1;constructor(t){this.url=t.url,this.getToken=t.getToken,this.onEvent=t.onEvent,this.onConnectionChange=t.onConnectionChange,this.shouldReconnect=t.reconnect??!0,this.maxReconnectAttempts=t.maxReconnectAttempts??Number.POSITIVE_INFINITY,this.reconnectBaseDelay=t.reconnectBaseDelay??1e3}get connected(){return this._connected}get ready(){return this._ready}connect(){const t=this.getToken();if(!t)return;this.intentionalClose=!1;const r=this.url.includes("?")?"&":"?",s=`${this.url}${r}token=${t}`;this.ws=new WebSocket(s),this.ws.onopen=()=>{this._connected=!0,this.reconnectAttempt=0,this.onConnectionChange?.(!0),this.rejoinThreads(),this.flushPendingMessages()},this.ws.onmessage=o=>{try{const a=JSON.parse(o.data),c=Q(a);c.type==="ready"&&(this._ready=!0),this.onEvent?.(c)}catch{}},this.ws.onclose=()=>{this._connected=!1,this._ready=!1,this.onConnectionChange?.(!1),!this.intentionalClose&&this.shouldReconnect&&this.reconnectAttempt<this.maxReconnectAttempts&&this.scheduleReconnect()},this.ws.onerror=()=>{}}disconnect(){this.intentionalClose=!0,this.pendingMessages=[],this.clearReconnectTimer(),this.ws&&(this.ws.close(),this.ws=null)}joinThread(t){this.joinedThreads.add(t),this.send({threadId:t,type:"join_thread"})}leaveThread(t){this.joinedThreads.delete(t),this.send({threadId:t,type:"leave_thread"})}sendMessage(t,r){if(r.length>1e3)throw new Error("Message body exceeds maximum length of 1000 characters");this.send({body:r,threadId:t,type:"send_message"})}markRead(t){this.send({threadId:t,type:"mark_read"})}listThreads(t,r){this.send({limit:t,offset:r,type:"list_threads"})}send(t){if(!this.ws||this.ws.readyState!==WebSocket.OPEN){this.pendingMessages.push(t);return}this.ws.send(JSON.stringify(J(t)))}flushPendingMessages(){const t=[...this.pendingMessages];this.pendingMessages=[];for(const r of t)this.send(r)}rejoinThreads(){for(const t of this.joinedThreads)this.send({threadId:t,type:"join_thread"})}scheduleReconnect(){this.clearReconnectTimer();const t=Math.min(this.reconnectBaseDelay*2**this.reconnectAttempt,3e4);this.reconnectAttempt++,this.reconnectTimer=setTimeout(()=>{this.connect()},t)}clearReconnectTimer(){this.reconnectTimer!==null&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}}var W={exports:{}},M={};var $;function ge(){if($)return M;$=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(s,o,a){var c=null;if(a!==void 0&&(c=""+a),o.key!==void 0&&(c=""+o.key),"key"in o){a={};for(var d in o)d!=="key"&&(a[d]=o[d])}else a=o;return o=a.ref,{$$typeof:e,type:s,key:c,ref:o!==void 0?o:null,props:a}}return M.Fragment=t,M.jsx=r,M.jsxs=r,M}var Y={};var ee;function me(){return ee||(ee=1,process.env.NODE_ENV!=="production"&&(function(){function e(n){if(n==null)return null;if(typeof n=="function")return n.$$typeof===x?null:n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case P:return"Fragment";case f:return"Profiler";case y:return"StrictMode";case N:return"Suspense";case A:return"SuspenseList";case B:return"Activity"}if(typeof n=="object")switch(typeof n.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),n.$$typeof){case k:return"Portal";case _:return n.displayName||"Context";case T:return(n._context.displayName||"Context")+".Consumer";case S:var p=n.render;return n=n.displayName,n||(n=p.displayName||p.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case L:return p=n.displayName||null,p!==null?p:e(n.type)||"Memo";case U:p=n._payload,n=n._init;try{return e(n(p))}catch{}}return null}function t(n){return""+n}function r(n){try{t(n);var p=!1}catch{p=!0}if(p){p=console;var v=p.error,R=typeof Symbol=="function"&&Symbol.toStringTag&&n[Symbol.toStringTag]||n.constructor.name||"Object";return v.call(p,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",R),t(n)}}function s(n){if(n===P)return"<>";if(typeof n=="object"&&n!==null&&n.$$typeof===U)return"<...>";try{var p=e(n);return p?"<"+p+">":"<...>"}catch{return"<...>"}}function o(){var n=O.A;return n===null?null:n.getOwner()}function a(){return Error("react-stack-top-frame")}function c(n){if(ce.call(n,"key")){var p=Object.getOwnPropertyDescriptor(n,"key").get;if(p&&p.isReactWarning)return!1}return n.key!==void 0}function d(n,p){function v(){le||(le=!0,console.error("%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://react.dev/link/special-props)",p))}v.isReactWarning=!0,Object.defineProperty(n,"key",{get:v,configurable:!0})}function u(){var n=e(this.type);return ue[n]||(ue[n]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),n=this.props.ref,n!==void 0?n:null}function h(n,p,v,R,V,X){var b=v.ref;return n={$$typeof:C,type:n,key:p,props:v,_owner:R},(b!==void 0?b:null)!==null?Object.defineProperty(n,"ref",{enumerable:!1,get:u}):Object.defineProperty(n,"ref",{enumerable:!1,value:null}),n._store={},Object.defineProperty(n._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(n,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(n,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:V}),Object.defineProperty(n,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:X}),Object.freeze&&(Object.freeze(n.props),Object.freeze(n)),n}function i(n,p,v,R,V,X){var b=p.children;if(b!==void 0)if(R)if(tt(b)){for(R=0;R<b.length;R++)m(b[R]);Object.freeze&&Object.freeze(b)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else m(b);if(ce.call(p,"key")){b=e(n);var D=Object.keys(p).filter(function(nt){return nt!=="key"});R=0<D.length?"{key: someKey, "+D.join(": ..., ")+": ...}":"{key: someKey}",he[b+R]||(D=0<D.length?"{"+D.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
2
|
let props = %s;
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
|
5
5
|
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,R,b,D,b),de[b+R]=!0)}if(b=null,w!==void 0&&(r(w),b=""+w),c(p)&&(r(p.key),b=""+p.key),"key"in p){w={};for(var H in p)H!=="key"&&(w[H]=p[H])}else w=p;return b&&d(w,typeof n=="function"?n.displayName||n.name||"Unknown":n),h(n,b,w,o(),V,B)}function m(n){E(n)?n._store&&(n._store.validated=1):typeof n=="object"&&n!==null&&n.$$typeof===U&&(n._payload.status==="fulfilled"?E(n._payload.value)&&n._payload.value._store&&(n._payload.value._store.validated=1):n._store&&(n._store.validated=1))}function E(n){return typeof n=="object"&&n!==null&&n.$$typeof===_}var v=l,_=Symbol.for("react.transitional.element"),j=Symbol.for("react.portal"),P=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),C=Symbol.for("react.context"),S=Symbol.for("react.forward_ref"),N=Symbol.for("react.suspense"),A=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),J=Symbol.for("react.activity"),x=Symbol.for("react.client.reference"),I=v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ae=Object.prototype.hasOwnProperty,$e=Array.isArray,K=console.createTask?console.createTask:function(){return null};v={react_stack_bottom_frame:function(n){return n()}};var ie,ce={},le=v.react_stack_bottom_frame.bind(v,a)(),ue=K(s(a)),de={};Y.Fragment=P,Y.jsx=function(n,p,w){var R=1e4>I.recentlyCreatedOwnerStacks++;return i(n,p,w,!1,R?Error("react-stack-top-frame"):le,R?K(s(n)):ue)},Y.jsxs=function(n,p,w){var R=1e4>I.recentlyCreatedOwnerStacks++;return i(n,p,w,!0,R?Error("react-stack-top-frame"):le,R?K(s(n)):ue)}})()),Y}var $;function ge(){return $||($=1,process.env.NODE_ENV==="production"?W.exports=he():W.exports=pe()),W.exports}var O=ge();const me=({IMaskMixin:e,...t})=>{const r=l.useMemo(()=>e(({TextField:s,...o})=>O.jsx(s,{...o})),[e]);return O.jsx(r,{...t})},k=l.createContext({}),ye=({children:e,apiURL:t,libraries:r,localStorageKeys:s})=>{const o=l.useMemo(()=>({apiURL:t,libraries:r,localStorageKeys:s}),[t,r,s]);return O.jsx(k.Provider,{value:o,children:e})},Ee=({data:e,...t})=>{const{libraries:r}=l.useContext(k),s=t?.reactRouter||r?.reactRouter,o=t?.gtm||r?.gtm;if(!s)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");if(!o)throw new Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");const{useGoogleTagManager:a}=o,{useLocation:c,Outlet:d}=s,{pathname:u}=c(),{sendEvent:h}=a();return l.useEffect(()=>{h({event:"pageView",pathname:u,...e})},[e,u,h]),O.jsx(d,{})},z=(()=>{try{return typeof global=="object"&&global!==null&&("HermesInternal"in global||"__fbBatchedBridge"in global||"__metro"in global)||typeof window>"u"&&typeof global<"u"?!0:typeof navigator<"u"&&navigator.userAgent?/react.native|ReactNative/i.test(navigator.userAgent):!1}catch{return!1}})(),ve="user",we=({tokenTypeKey:e="tokenType",tokenKey:t="accessToken",postContentType:r="application/json",...s})=>{const{apiURL:o=s.apiURL,libraries:a,localStorageKeys:c}=l.useContext(k),d=s?.userLocalStorageKey||c?.user||ve,u=s?.axios||a?.axios;if(!u)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!u?.defaults||z)return null;if(typeof window<"u"&&window.localStorage){const h=localStorage.getItem(d),i=h?JSON.parse(h):null,m=i?.[e]?i[e]:null,E=i?.[t]?i[t]:null,v=h?`${m} ${E}`:null;v&&(u.defaults.headers.common.Authorization=v)}return u.defaults.baseURL=o,u.defaults.headers.post["Content-Type"]=r,null},_e=({language:e,...t})=>{const{libraries:r}=l.useContext(k),s=t?.dayjs||r?.dayjs,o=t?.plugin||r?.dayjsPlugin;if(!s)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig.");return l.useEffect(()=>{(async()=>{const c=e||navigator.language?.slice(0,2)||"en";o&&o.forEach(d=>{d&&s.extend(d)}),await import("dayjs/locale/en"),await import("dayjs/locale/fr"),s.locale(c)})().then()},[s,o,e]),null},Ce=({debug:e,resources:t,...r})=>{const{libraries:s}=l.useContext(k),o=r?.i18||s?.i18,{i18next:a,initReactI18next:c,languageDetector:d}=o||{};if(z)return null;if(!o)throw new Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return a?.isInitialized||(a.use(d).use(c).init({debug:e,fallbackLng:"en",interpolation:{escapeValue:!1},load:"languageOnly",react:{bindI18n:"languageChanged loaded",useSuspense:!0},resources:t,returnNull:!1}).then(()=>{document.documentElement.lang!==a.resolvedLanguage&&a.resolvedLanguage&&document.documentElement.setAttribute("lang",a.resolvedLanguage)}),a.on("languageChanged",u=>{document.documentElement.setAttribute("lang",u)})),null},Re=({dsn:e,integrations:t,tracesSampleRate:r,replaysSessionSampleRate:s,replaysOnErrorSampleRate:o,tracePropagationTargets:a,ignoreErrors:c,debug:d,environment:u,release:h,...i})=>{const{libraries:m}=l.useContext(k),E=i?.sentry||m?.sentry,v=i?.reactRouter||m?.reactRouter;if(!E)throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!v)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(E.isInitialized())return null;const{createRoutesFromChildren:_,matchRoutes:j,useLocation:P,useNavigationType:y}=v;return(d||process.env.NODE_ENV==="prod"||process.env.NODE_ENV==="production")&&E.init({debug:d,dsn:e,environment:u||"production",ignoreErrors:[...c||[],/dynamically imported module/,/Cannot read properties of undefined \(reading 'default'\)/,/Loading chunk \d+ failed/,/ChunkLoadError/,/Failed to fetch dynamically imported module/,/vite:preloadError/],integrations:[E.reactRouterV6BrowserTracingIntegration({createRoutesFromChildren:_,matchRoutes:j,useEffect:l.useEffect,useLocation:P,useNavigationType:y}),...t||[]],release:h,replaysOnErrorSampleRate:o||1,replaysSessionSampleRate:s||.1,tracePropagationTargets:a,tracesSampleRate:r||1}),null},be=()=>(l.useEffect(()=>{if(z)return;const e=t=>{try{t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),window.location.reload()}catch{}};return window.addEventListener("vite:preloadError",e),()=>{window.removeEventListener("vite:preloadError",e)}},[]),null),ee=new WeakMap,Te="user",Se=({Fallback:e,isLogged:t,loginPath:r="/login",redirect401Path:s="/login",...o})=>{const{libraries:a,localStorageKeys:c}=l.useContext(k),d=o?.reactRouter||a?.reactRouter,u=o?.axios||a?.axios,h=o?.localStorageKey||c?.user||Te;if(!d)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");const[i,m]=l.useState(null),{useLocation:E,Navigate:v,Outlet:_}=d,j=E(),P=typeof t=="function"?t():!!t,y=typeof P=="boolean"?P:P?.isLogged;return l.useEffect(()=>{ee.has(u)||(ee.set(u,!0),u.interceptors.response.use(f=>f,f=>(typeof f=="object"&&f&&"response"in f&&f.response&&typeof f.response=="object"&&"status"in f.response&&f.response&&typeof f.response=="object"&&"status"in f.response&&f?.response?.status===401&&(typeof f=="object"&&f&&"config"in f&&f.config&&typeof f.config=="object"&&"headers"in f.config&&f.config.headers&&typeof f.config.headers=="object"&&"Authorization"in f.config.headers&&f.config.headers.Authorization&&(u.defaults.headers.common.Authorization=null,typeof window<"u"&&window.localStorage&&localStorage.removeItem(h)),m(s)),Promise.reject(f))))},[u,h,s]),y&&!i?O.jsx(l.Suspense,{fallback:e,children:j.state?.from?.state&&j.state?.from?.pathname===r?O.jsx(v,{to:j.state.from.state.from.pathname+j.state.from.state.from.search,replace:!0}):O.jsx(_,{})}):O.jsx(v,{to:r+j.search,state:{from:j},replace:!0})},Ae=e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),je=e=>{const t=e.split(/[/\\]/).pop()||"";return t.substring(0,t.lastIndexOf("."))},ke=e=>{const s=e.split("/").filter(o=>o.length>0).map(o=>o.replace(/\${([^}]*)}/g,"$1").split(/[_-]/).map(u=>u.charAt(0).toUpperCase()+u.slice(1)).join("")).join("");return s.charAt(0).toLowerCase()+s.slice(1)},Pe=e=>(e.split("/").pop()||e).replace(/\.json$/,"").replace(/^openapi\./,""),Ie=(e,t,r,s)=>{const o=ke(t),a=Ae(r),c=`${o}${a}`;return e&&typeof e=="object"&&"operationId"in e&&s?.includes(String(e.operationId))?`${c}AsQuery`:c},Oe=(e,t)=>{const r={};return e?.forEach(s=>{r[s]={query:{useInfinite:!0,useInfiniteQueryParam:"offset",useQuery:!0}}}),t?.filter(s=>!r[s]).forEach(s=>{r[s]={query:{useQuery:!0}}}),Object.keys(r).length?r:void 0},Ne=e=>(Array.isArray(e)?e:[e]).reduce((r,s)=>{const{output:o,useInfiniteIds:a,useQueryIds:c,input:d="./openapi.json",customAxiosInstancePath:u,overrideApiName:h}=s||{},i=h||Pe(d),m=u||"./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts";return{...r,[i]:{input:d,output:{baseUrl:o?.baseUrl,client:"react-query",mode:"tags-split",override:{...(a?.length||c?.length)&&{operations:Oe(a,c)},header:E=>["Generated by orval 🍺",...E.title?[E.title]:[],...E.description?[E.description]:[]],mutator:{name:je(m),path:m},operationName:(E,v,_)=>Ie(E,v,_,c),query:{useQuery:!0}},schemas:o?.schemas||`src/api/${i}/model`,target:o?.target||`src/api/${i}/services/api.ts`,...o}}}},{}),xe="user",Le=e=>{const t=e.startsWith("https")?"wss":"ws",r=e.replace(/^https?:\/\//,"");return`${t}://${r}/v2/threads/ws`},Fe=e=>{try{const t=localStorage.getItem(e);return t?JSON.parse(t)?.accessToken??null:null}catch{return null}},Q=l.createContext(null),De=({children:e,reconnect:t=!0,enabled:r=!0,url:s,token:o})=>{const[a,c]=l.useState(!1),[d,u]=l.useState(!1),[h,i]=l.useState(0),{apiURL:m,localStorageKeys:E}=l.useContext(k),v=E?.user||xe,_=l.useRef(null),j=l.useRef(new Set);l.useEffect(()=>{if(!r)return;const A=s||(m?Le(m):null);if(!A)return;const L=()=>o??Fe(v),U=x=>{switch(x.type){case"ready":u(!0),i(x.unreadCount??0);break;case"new_message_notification":i(I=>I+1);break;case"marked_read":i(I=>Math.max(0,I-1));break}for(const I of j.current)I(x)},J=setTimeout(()=>{const x=new X({getToken:L,onConnectionChange:I=>{c(I),I||u(!1)},onEvent:U,reconnect:t,url:A});_.current=x,x.connect()},0);return()=>{clearTimeout(J),_.current?.disconnect(),_.current=null}},[r,s,o,m,t,v]);const P=l.useCallback(A=>{_.current?.joinThread(A)},[]),y=l.useCallback(A=>{_.current?.leaveThread(A)},[]),f=l.useCallback((A,L)=>{_.current?.sendMessage(A,L)},[]),T=l.useCallback(A=>{_.current?.markRead(A)},[]),C=l.useCallback((A,L)=>{_.current?.listThreads(A,L)},[]),S=l.useCallback(A=>(j.current.add(A),()=>{j.current.delete(A)}),[]),N={isConnected:a,isReady:d,joinThread:P,leaveThread:y,listThreads:C,markRead:T,sendMessage:f,subscribe:S,unreadCount:h};return O.jsx(Q.Provider,{value:N,children:e})},Me=e=>e&&typeof e=="function",Ye=e=>e&&typeof e=="function",ze=({children:e,defaultQueriesOptions:t,defaultMutationsOptions:r,...s})=>{const{libraries:o}=l.useContext(k),a=s?.QueryClient||o?.reactQuery?.QueryClient,c=s?.QueryClientProvider||o?.reactQuery?.QueryClientProvider;if(!a)throw new Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!c)throw new Error("QueryClientProvider is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!Me(c))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!Ye(a))throw new Error("Provided QueryClient dependencies are not valid.");const d=new a({defaultOptions:{mutations:{...r},queries:{getNextPageParam:(u,h,i)=>u.length+(i||0),refetchOnWindowFocus:!1,retry:3,...t}}});return O.jsx(c,{client:d,children:e})},te=({library:e,date:t,format:r="ll"})=>e(t).format(r),ne=(e,t)=>{const{fractionDigits:r=0,metric:s="km",spacingBetween:o=!0}=t||{},a=Number(e),c=o?" ":"";return Number.isNaN(a)?`0${c}${s}`:`${a.toFixed(r)}${c}${s}`},re=e=>!e||typeof e!="string"?"":e.replace(/_/g," ").toLowerCase().split(" ").map(r=>r.length>0?r.charAt(0).toUpperCase()+r.slice(1):r).join(" "),Ue=e=>e?.startsWith("/")?e?.startsWith("/files")?e:`/files${e}`:e?.startsWith("files")?`/${e}`:`/files/${e}`,We=({path:e,size:t,apiURL:r})=>{if(!e)return"";const s=Ue(e),o=`${r}${s}`,a=o.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/)!==null;return typeof t=="number"&&a?`${o.replace("/files",`/thumbs/${t}`)}`:o},Ge=e=>{const{apiURL:t,libraries:r}=l.useContext(k),s=e?.dayjs||r?.dayjs;return{dateAdapter:(c,d)=>{if(!s)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return te({date:c,format:d,library:s})},distanceAdapter:ne,filePathAdapter:(c,d)=>{if(!t)throw new Error("API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter.");return typeof c=="string"&&/^https?:\/\//.test(c)?c:We({apiURL:t,path:c,size:d})},worksiteNameAdapter:re}},Ve=e=>{const{libraries:t,localStorageKeys:r}=l.useContext(k),s=e?.axios||t?.axios,o=e?.localStorageKey||r?.user||"user";if(!s)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");const a=l.useCallback(({tokenType:d,accessToken:u})=>{s.defaults.headers.common.Authorization=`${d} ${u}`},[s.defaults.headers.common]),c=()=>{s.defaults.headers.common.Authorization=null};return l.useEffect(()=>{if(z)return;const d=({newValue:u,key:h})=>{if(h===o&&u)try{const{accessToken:i,tokenType:m}=JSON.parse(u);a({accessToken:i,tokenType:m})}catch(i){console.error("Failed to parse newValue from localStorage:",i)}};return window.addEventListener("storage",d),()=>{window.removeEventListener("storage",d)}},[o,a]),{clearAuthenticationToken:c,setAuthenticationToken:a}},Qe=e=>{const t=l.useContext(Q);if(!t)throw new Error("useChat must be used within ChatProvider");const{subscribe:r,...s}=t,o=l.useRef(e);return o.current=e,l.useEffect(()=>r(a=>{const{onReady:c,onNewMessage:d,onNewMessageNotification:u,onPresence:h,onError:i,onJoinedThread:m,onLeftThread:E,onMarkedRead:v,onThreadsList:_}=o.current??{};switch(a.type){case"ready":c?.(a);break;case"new_message":d?.(a);break;case"new_message_notification":u?.(a);break;case"presence":h?.(a);break;case"error":i?.(a);break;case"joined_thread":m?.(a);break;case"left_thread":E?.(a);break;case"marked_read":v?.(a);break;case"threads_list":_?.(a);break}}),[r]),s},G=(e,t)=>t==="short"?e.split("-")[0]:e,Je=(e,t="full")=>{const[r,s]=l.useState(()=>{const o=e?.language||navigator.language;return e&&"isInitialized"in e&&e.isInitialized,G(o,t)});return l.useEffect(()=>{e&&"isInitialized"in e&&e.isInitialized&&e.language&&s(G(e.language,t));const o=a=>{s(G(a,t))};return e?.on?.("languageChanged",o),()=>{e?.off?.("languageChanged",o)}},[e,t]),r},Ke="tracktor.filter",Be={getFilter:()=>{},getFilters:()=>({}),handleFilter:()=>()=>{},setFilter:()=>{}},oe=e=>{try{return JSON.parse(e)}catch{return e}},se=(e,t,r)=>`${r}_${e}=>${t}`,He=e=>e.reduce((t,r)=>{const s=localStorage.getItem(r);if(s)try{const o=JSON.parse(s),a=Object.keys(o)?.[0];a&&(t[a]=Object.values(o)?.[0])}catch{}return t},{}),Xe=e=>{const{libraries:t,localStorageKeys:r}=l.useContext(k),s=e?.reactRouter||t?.reactRouter,{pathname:o}=s?.useLocation?.()??{pathname:"/"},[a,c]=s?.useSearchParams?.()??[new URLSearchParams,()=>{}],[d,u]=l.useState({}),h=r?.filter||Ke,i=e?.syncWithUrl===void 0?!0:e?.syncWithUrl,m=e?.persistToLocalStorage===void 0?!0:e?.persistToLocalStorage;if(z)return Be;if(!s)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter.");const E=()=>Object.keys(localStorage).filter(y=>y.startsWith(h)&&y.endsWith(e?.pathname||o)),v=(y,f,T=!0)=>{const C=se(y,e?.pathname||o,h);if(!f||Array.isArray(f)&&!f.length){i?(a.delete(y),c(a)):u(S=>{const N={...S};return delete N[y],N}),m&&localStorage.removeItem(C);return}m&&T&&f&&localStorage.setItem(C,JSON.stringify({...a,[y]:f})),i&&f?(a.set(y,JSON.stringify(f)),c(a)):!i&&f&&u(S=>({...S,[y]:f}))};return{getFilter:(y,f)=>{if(i){const T=a.get(y);if(T)return oe(T)}else{const T=d[y];if(T!==void 0)return T}if(m){const T=se(y,e?.pathname||o,h),C=localStorage.getItem(T);if(C)try{const S=JSON.parse(C)[y];return!i&&S!==void 0&&u(N=>({...N,[y]:S})),S}catch{}}return f},getFilters:()=>{const y=m?He(E()):{};if(i){const f=Array.from(a.entries()).reduce((T,[C,S])=>(T[C]=oe(S),T),{});return{...y,...f}}return{...y,...d}},handleFilter:(y,f)=>(T,C)=>{if(C||Array.isArray(C)&&C.length===0){const S=f||"value",N=typeof C=="object"&&S in C?C[S]:C;v(y,N);return}v(y,void 0)},setFilter:v}},Ze=({data:e,fetchNextPage:t,isFetchingNextPage:r,isInitialLoading:s,isLoading:o,enabled:a=!0})=>{const c=l.useCallback(async u=>{r||!a||await t({pageParam:u?.pageParam||u.visibleRowsCount})},[a,t,r]),d=l.useMemo(()=>{if(e)return e.pages.reduce((u,h)=>[...u,...h],[])},[e]);return{fetchNextPageOnRowsScrollEnd:c,isLoading:r||o,loadingVariant:s?"skeleton":"linear-progress",rows:d}},qe=e=>{const{libraries:t}=l.useContext(k),r=e?.i18||t?.i18,s=e?.i18?.translateFunction||t?.i18?.translateFunction,o=r?.i18next?.t||s||(h=>h),{unknownErrorTranslationKey:a="error.unknownError"}=e||{},c=o(a),d=l.useCallback(h=>{if(h&&typeof h=="object"&&"response"in h){const{response:i}=h||{};if(i&&typeof i=="object"&&"reason"in i&&i.reason)return String(i.reason);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"reason"in i.data&&i.data.reason)return String(i.data.reason);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"message"in i.data&&i.data.message)return String(i.data.message);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"detail"in i.data){const{detail:m}=i.data;if(Array.isArray(m)&&m.length>0&&typeof m[0]=="object"&&m[0]!==null&&"msg"in m[0]){const{msg:E}=m[0];if(typeof E=="string")return String(E)}}}return h instanceof Error?h.message:c},[c]);return{getErrorCode:l.useCallback(h=>{const{response:i}=h||{};return i?.error_code?String(i?.error_code):i?.data?.error_code?String(i?.data?.error_code):i?.error_code?String(i?.error_code):i?.data?.error_code?String(i.data.error_code):"unknown_error_code"},[]),printError:d}};g.ChatClient=X,g.ChatContext=Q,g.ChatProvider=De,g.GTMSendPageView=Ee,g.InitializeAxiosConfig=we,g.InitializeDaysJSConfig=_e,g.InitializeI18nConfig=Ce,g.InitializeSentryConfig=Re,g.InjectDependenciesContext=k,g.InjectDependenciesProvider=ye,g.MaskTextField=me,g.PreloadErrorHandler=be,g.QueryClientProviderWithConfig=ze,g.RequireAuth=Se,g.axiosCustomInstance=fe,g.dateAdapter=te,g.distanceAdapter=ne,g.getOrvalConfig=Ne,g.useAdapter=Ge,g.useAuth=Ve,g.useChat=Qe,g.useCurrentLanguage=Je,g.useFilters=Xe,g.useInfiniteDataGrid=Ze,g.useResponseError=qe,g.worksiteNameAdapter=re,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}));
|
|
6
|
+
<%s key={someKey} {...props} />`,R,b,D,b),he[b+R]=!0)}if(b=null,v!==void 0&&(r(v),b=""+v),c(p)&&(r(p.key),b=""+p.key),"key"in p){v={};for(var Z in p)Z!=="key"&&(v[Z]=p[Z])}else v=p;return b&&d(v,typeof n=="function"?n.displayName||n.name||"Unknown":n),h(n,b,v,o(),V,X)}function m(n){E(n)?n._store&&(n._store.validated=1):typeof n=="object"&&n!==null&&n.$$typeof===U&&(n._payload.status==="fulfilled"?E(n._payload.value)&&n._payload.value._store&&(n._payload.value._store.validated=1):n._store&&(n._store.validated=1))}function E(n){return typeof n=="object"&&n!==null&&n.$$typeof===C}var w=l,C=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),P=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),_=Symbol.for("react.context"),S=Symbol.for("react.forward_ref"),N=Symbol.for("react.suspense"),A=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),B=Symbol.for("react.activity"),x=Symbol.for("react.client.reference"),O=w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ce=Object.prototype.hasOwnProperty,tt=Array.isArray,H=console.createTask?console.createTask:function(){return null};w={react_stack_bottom_frame:function(n){return n()}};var le,ue={},de=w.react_stack_bottom_frame.bind(w,a)(),fe=H(s(a)),he={};Y.Fragment=P,Y.jsx=function(n,p,v){var R=1e4>O.recentlyCreatedOwnerStacks++;return i(n,p,v,!1,R?Error("react-stack-top-frame"):de,R?H(s(n)):fe)},Y.jsxs=function(n,p,v){var R=1e4>O.recentlyCreatedOwnerStacks++;return i(n,p,v,!0,R?Error("react-stack-top-frame"):de,R?H(s(n)):fe)}})()),Y}var te;function ye(){return te||(te=1,process.env.NODE_ENV==="production"?W.exports=ge():W.exports=me()),W.exports}var I=ye();const Ee=({IMaskMixin:e,...t})=>{const r=l.useMemo(()=>e(({TextField:s,...o})=>I.jsx(s,{...o})),[e]);return I.jsx(r,{...t})},j=l.createContext({}),we=({children:e,apiURL:t,libraries:r,localStorageKeys:s})=>{const o=l.useMemo(()=>({apiURL:t,libraries:r,localStorageKeys:s}),[t,r,s]);return I.jsx(j.Provider,{value:o,children:e})},ve=({data:e,...t})=>{const{libraries:r}=l.useContext(j),s=t?.reactRouter||r?.reactRouter,o=t?.gtm||r?.gtm;if(!s)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");if(!o)throw new Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");const{useGoogleTagManager:a}=o,{useLocation:c,Outlet:d}=s,{pathname:u}=c(),{sendEvent:h}=a();return l.useEffect(()=>{h({event:"pageView",pathname:u,...e})},[e,u,h]),I.jsx(d,{})},z=(()=>{try{return typeof global=="object"&&global!==null&&("HermesInternal"in global||"__fbBatchedBridge"in global||"__metro"in global)||typeof window>"u"&&typeof global<"u"?!0:typeof navigator<"u"&&navigator.userAgent?/react.native|ReactNative/i.test(navigator.userAgent):!1}catch{return!1}})(),Ce="user",_e=({tokenTypeKey:e="tokenType",tokenKey:t="accessToken",postContentType:r="application/json",...s})=>{const{apiURL:o=s.apiURL,libraries:a,localStorageKeys:c}=l.useContext(j),d=s?.userLocalStorageKey||c?.user||Ce,u=s?.axios||a?.axios;if(!u)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!u?.defaults||z)return null;if(typeof window<"u"&&window.localStorage){const h=localStorage.getItem(d),i=h?JSON.parse(h):null,m=i?.[e]?i[e]:null,E=i?.[t]?i[t]:null,w=h?`${m} ${E}`:null;w&&(u.defaults.headers.common.Authorization=w)}return u.defaults.baseURL=o,u.defaults.headers.post["Content-Type"]=r,null},Re=({language:e,...t})=>{const{libraries:r}=l.useContext(j),s=t?.dayjs||r?.dayjs,o=t?.plugin||r?.dayjsPlugin;if(!s)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig.");return l.useEffect(()=>{(async()=>{const c=e||navigator.language?.slice(0,2)||"en";o&&o.forEach(d=>{d&&s.extend(d)}),await import("dayjs/locale/en"),await import("dayjs/locale/fr"),s.locale(c)})().then()},[s,o,e]),null},be=({debug:e,resources:t,...r})=>{const{libraries:s}=l.useContext(j),o=r?.i18||s?.i18,{i18next:a,initReactI18next:c,languageDetector:d}=o||{};if(z)return null;if(!o)throw new Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return a?.isInitialized||(a.use(d).use(c).init({debug:e,fallbackLng:"en",interpolation:{escapeValue:!1},load:"languageOnly",react:{bindI18n:"languageChanged loaded",useSuspense:!0},resources:t,returnNull:!1}).then(()=>{document.documentElement.lang!==a.resolvedLanguage&&a.resolvedLanguage&&document.documentElement.setAttribute("lang",a.resolvedLanguage)}),a.on("languageChanged",u=>{document.documentElement.setAttribute("lang",u)})),null},Te=({dsn:e,integrations:t,tracesSampleRate:r,replaysSessionSampleRate:s,replaysOnErrorSampleRate:o,tracePropagationTargets:a,ignoreErrors:c,debug:d,environment:u,release:h,...i})=>{const{libraries:m}=l.useContext(j),E=i?.sentry||m?.sentry,w=i?.reactRouter||m?.reactRouter;if(!E)throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!w)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(E.isInitialized())return null;const{createRoutesFromChildren:C,matchRoutes:k,useLocation:P,useNavigationType:y}=w;return(d||process.env.NODE_ENV==="prod"||process.env.NODE_ENV==="production")&&E.init({debug:d,dsn:e,environment:u||"production",ignoreErrors:[...c||[],/dynamically imported module/,/Cannot read properties of undefined \(reading 'default'\)/,/Loading chunk \d+ failed/,/ChunkLoadError/,/Failed to fetch dynamically imported module/,/vite:preloadError/],integrations:[E.reactRouterV6BrowserTracingIntegration({createRoutesFromChildren:C,matchRoutes:k,useEffect:l.useEffect,useLocation:P,useNavigationType:y}),...t||[]],release:h,replaysOnErrorSampleRate:o||1,replaysSessionSampleRate:s||.1,tracePropagationTargets:a,tracesSampleRate:r||1}),null},Se=()=>(l.useEffect(()=>{if(z)return;const e=t=>{try{t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),window.location.reload()}catch{}};return window.addEventListener("vite:preloadError",e),()=>{window.removeEventListener("vite:preloadError",e)}},[]),null),ne=new WeakMap,Ae="user",ke=({Fallback:e,isLogged:t,loginPath:r="/login",redirect401Path:s="/login",...o})=>{const{libraries:a,localStorageKeys:c}=l.useContext(j),d=o?.reactRouter||a?.reactRouter,u=o?.axios||a?.axios,h=o?.localStorageKey||c?.user||Ae;if(!d)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");const[i,m]=l.useState(null),{useLocation:E,Navigate:w,Outlet:C}=d,k=E(),P=typeof t=="function"?t():!!t,y=typeof P=="boolean"?P:P?.isLogged;return l.useEffect(()=>{ne.has(u)||(ne.set(u,!0),u.interceptors.response.use(f=>f,f=>(typeof f=="object"&&f&&"response"in f&&f.response&&typeof f.response=="object"&&"status"in f.response&&f.response&&typeof f.response=="object"&&"status"in f.response&&f?.response?.status===401&&(typeof f=="object"&&f&&"config"in f&&f.config&&typeof f.config=="object"&&"headers"in f.config&&f.config.headers&&typeof f.config.headers=="object"&&"Authorization"in f.config.headers&&f.config.headers.Authorization&&(u.defaults.headers.common.Authorization=null,typeof window<"u"&&window.localStorage&&localStorage.removeItem(h)),m(s)),Promise.reject(f))))},[u,h,s]),y&&!i?I.jsx(l.Suspense,{fallback:e,children:k.state?.from?.state&&k.state?.from?.pathname===r?I.jsx(w,{to:k.state.from.state.from.pathname+k.state.from.state.from.search,replace:!0}):I.jsx(C,{})}):I.jsx(w,{to:r+k.search,state:{from:k},replace:!0})},je=e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),Pe=e=>{const t=e.split(/[/\\]/).pop()||"";return t.substring(0,t.lastIndexOf("."))},Oe=e=>{const s=e.split("/").filter(o=>o.length>0).map(o=>o.replace(/\${([^}]*)}/g,"$1").split(/[_-]/).map(u=>u.charAt(0).toUpperCase()+u.slice(1)).join("")).join("");return s.charAt(0).toLowerCase()+s.slice(1)},Ie=e=>(e.split("/").pop()||e).replace(/\.json$/,"").replace(/^openapi\./,""),Ne=(e,t,r,s)=>{const o=Oe(t),a=je(r),c=`${o}${a}`;return e&&typeof e=="object"&&"operationId"in e&&s?.includes(String(e.operationId))?`${c}AsQuery`:c},xe=(e,t)=>{const r={};return e?.forEach(s=>{r[s]={query:{useInfinite:!0,useInfiniteQueryParam:"offset",useQuery:!0}}}),t?.filter(s=>!r[s]).forEach(s=>{r[s]={query:{useQuery:!0}}}),Object.keys(r).length?r:void 0},Le=e=>(Array.isArray(e)?e:[e]).reduce((r,s)=>{const{output:o,useInfiniteIds:a,useQueryIds:c,input:d="./openapi.json",customAxiosInstancePath:u,overrideApiName:h}=s||{},i=h||Ie(d),m=u||"./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts";return{...r,[i]:{input:d,output:{baseUrl:o?.baseUrl,client:"react-query",mode:"tags-split",override:{...(a?.length||c?.length)&&{operations:xe(a,c)},header:E=>["Generated by orval 🍺",...E.title?[E.title]:[],...E.description?[E.description]:[]],mutator:{name:Pe(m),path:m},operationName:(E,w,C)=>Ne(E,w,C,c),query:{useQuery:!0}},schemas:o?.schemas||`src/api/${i}/model`,target:o?.target||`src/api/${i}/services/api.ts`,...o}}}},{}),Fe="user",De=e=>{const t=e.startsWith("https")?"wss":"ws",r=e.replace(/^https?:\/\//,"");return`${t}://${r}/v2/threads/ws`},Me=e=>{try{const t=localStorage.getItem(e);return t?JSON.parse(t)?.accessToken??null:null}catch{return null}},K=l.createContext(null),Ye=({children:e,reconnect:t=!0,enabled:r=!0,url:s,token:o})=>{const[a,c]=l.useState(!1),[d,u]=l.useState(!1),[h,i]=l.useState(0),{apiURL:m,localStorageKeys:E}=l.useContext(j),w=E?.user||Fe,C=l.useRef(null),k=l.useRef(new Set);l.useEffect(()=>{if(!r)return;const A=s||(m?De(m):null);if(!A)return;const L=()=>o??Me(w),U=x=>{switch(x.type){case"ready":u(!0),i(x.unreadCount??0);break;case"new_message_notification":i(O=>O+1);break;case"marked_read":i(O=>Math.max(0,O-1));break}for(const O of k.current)O(x)},B=setTimeout(()=>{const x=new q({getToken:L,onConnectionChange:O=>{c(O),O||u(!1)},onEvent:U,reconnect:t,url:A});C.current=x,x.connect()},0);return()=>{clearTimeout(B),C.current?.disconnect(),C.current=null}},[r,s,o,m,t,w]);const P=l.useCallback(A=>{C.current?.joinThread(A)},[]),y=l.useCallback(A=>{C.current?.leaveThread(A)},[]),f=l.useCallback((A,L)=>{C.current?.sendMessage(A,L)},[]),T=l.useCallback(A=>{C.current?.markRead(A)},[]),_=l.useCallback((A,L)=>{C.current?.listThreads(A,L)},[]),S=l.useCallback(A=>(k.current.add(A),()=>{k.current.delete(A)}),[]),N={isConnected:a,isReady:d,joinThread:P,leaveThread:y,listThreads:_,markRead:T,sendMessage:f,subscribe:S,unreadCount:h};return I.jsx(K.Provider,{value:N,children:e})},ze=e=>e&&typeof e=="function",Ue=e=>e&&typeof e=="function",We=({children:e,defaultQueriesOptions:t,defaultMutationsOptions:r,...s})=>{const{libraries:o}=l.useContext(j),a=s?.QueryClient||o?.reactQuery?.QueryClient,c=s?.QueryClientProvider||o?.reactQuery?.QueryClientProvider;if(!a)throw new Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!c)throw new Error("QueryClientProvider is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!ze(c))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!Ue(a))throw new Error("Provided QueryClient dependencies are not valid.");const d=new a({defaultOptions:{mutations:{...r},queries:{getNextPageParam:(u,h,i)=>u.length+(i||0),refetchOnWindowFocus:!1,retry:3,...t}}});return I.jsx(c,{client:d,children:e})},re=({library:e,date:t,format:r="ll"})=>e(t).format(r),oe=(e,t)=>{const{fractionDigits:r=0,metric:s="km",spacingBetween:o=!0}=t||{},a=Number(e),c=o?" ":"";return Number.isNaN(a)?`0${c}${s}`:`${a.toFixed(r)}${c}${s}`},se=e=>!e||typeof e!="string"?"":e.replace(/_/g," ").toLowerCase().split(" ").map(r=>r.length>0?r.charAt(0).toUpperCase()+r.slice(1):r).join(" "),Ge=e=>e?.startsWith("/")?e?.startsWith("/files")?e:`/files${e}`:e?.startsWith("files")?`/${e}`:`/files/${e}`,Ve=({path:e,size:t,apiURL:r})=>{if(!e)return"";const s=Ge(e),o=`${r}${s}`,a=o.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/)!==null;return typeof t=="number"&&a?`${o.replace("/files",`/thumbs/${t}`)}`:o},Qe=e=>{const{apiURL:t,libraries:r}=l.useContext(j),s=e?.dayjs||r?.dayjs;return{dateAdapter:(c,d)=>{if(!s)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return re({date:c,format:d,library:s})},distanceAdapter:oe,filePathAdapter:(c,d)=>{if(!t)throw new Error("API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter.");return typeof c=="string"&&/^https?:\/\//.test(c)?c:Ve({apiURL:t,path:c,size:d})},worksiteNameAdapter:se}},Je=e=>{const{libraries:t,localStorageKeys:r}=l.useContext(j),s=e?.axios||t?.axios,o=e?.localStorageKey||r?.user||"user";if(!s)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");const a=l.useCallback(({tokenType:d,accessToken:u})=>{s.defaults.headers.common.Authorization=`${d} ${u}`},[s.defaults.headers.common]),c=()=>{s.defaults.headers.common.Authorization=null};return l.useEffect(()=>{if(z)return;const d=({newValue:u,key:h})=>{if(h===o&&u)try{const{accessToken:i,tokenType:m}=JSON.parse(u);a({accessToken:i,tokenType:m})}catch(i){console.error("Failed to parse newValue from localStorage:",i)}};return window.addEventListener("storage",d),()=>{window.removeEventListener("storage",d)}},[o,a]),{clearAuthenticationToken:c,setAuthenticationToken:a}},Ke=e=>{const t=l.useContext(K);if(!t)throw new Error("useChat must be used within ChatProvider");const{subscribe:r,...s}=t,o=l.useRef(e);return o.current=e,l.useEffect(()=>r(a=>{const{onReady:c,onNewMessage:d,onNewMessageNotification:u,onPresence:h,onError:i,onJoinedThread:m,onLeftThread:E,onMarkedRead:w,onThreadsList:C}=o.current??{};switch(a.type){case"ready":c?.(a);break;case"new_message":d?.(a);break;case"new_message_notification":u?.(a);break;case"presence":h?.(a);break;case"error":i?.(a);break;case"joined_thread":m?.(a);break;case"left_thread":E?.(a);break;case"marked_read":w?.(a);break;case"threads_list":C?.(a);break}}),[r]),s},G=(e,t)=>t==="short"?e.split("-")[0]:e,Be=(e,t="full")=>{const[r,s]=l.useState(()=>{const o=e?.language||navigator.language;return e&&"isInitialized"in e&&e.isInitialized,G(o,t)});return l.useEffect(()=>{e&&"isInitialized"in e&&e.isInitialized&&e.language&&s(G(e.language,t));const o=a=>{s(G(a,t))};return e?.on?.("languageChanged",o),()=>{e?.off?.("languageChanged",o)}},[e,t]),r},He="tracktor.filter",Xe={getFilter:()=>{},getFilters:()=>({}),handleFilter:()=>()=>{},setFilter:()=>{}},ae=e=>{try{return JSON.parse(e)}catch{return e}},ie=(e,t,r)=>`${r}_${e}=>${t}`,Ze=e=>e.reduce((t,r)=>{const s=localStorage.getItem(r);if(s)try{const o=JSON.parse(s),a=Object.keys(o)?.[0];a&&(t[a]=Object.values(o)?.[0])}catch{}return t},{}),qe=e=>{const{libraries:t,localStorageKeys:r}=l.useContext(j),s=e?.reactRouter||t?.reactRouter,{pathname:o}=s?.useLocation?.()??{pathname:"/"},[a,c]=s?.useSearchParams?.()??[new URLSearchParams,()=>{}],[d,u]=l.useState({}),h=r?.filter||He,i=e?.syncWithUrl===void 0?!0:e?.syncWithUrl,m=e?.persistToLocalStorage===void 0?!0:e?.persistToLocalStorage;if(z)return Xe;if(!s)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter.");const E=()=>Object.keys(localStorage).filter(y=>y.startsWith(h)&&y.endsWith(e?.pathname||o)),w=(y,f,T=!0)=>{const _=ie(y,e?.pathname||o,h);if(!f||Array.isArray(f)&&!f.length){i?(a.delete(y),c(a)):u(S=>{const N={...S};return delete N[y],N}),m&&localStorage.removeItem(_);return}m&&T&&f&&localStorage.setItem(_,JSON.stringify({...a,[y]:f})),i&&f?(a.set(y,JSON.stringify(f)),c(a)):!i&&f&&u(S=>({...S,[y]:f}))};return{getFilter:(y,f)=>{if(i){const T=a.get(y);if(T)return ae(T)}else{const T=d[y];if(T!==void 0)return T}if(m){const T=ie(y,e?.pathname||o,h),_=localStorage.getItem(T);if(_)try{const S=JSON.parse(_)[y];return!i&&S!==void 0&&u(N=>({...N,[y]:S})),S}catch{}}return f},getFilters:()=>{const y=m?Ze(E()):{};if(i){const f=Array.from(a.entries()).reduce((T,[_,S])=>(T[_]=ae(S),T),{});return{...y,...f}}return{...y,...d}},handleFilter:(y,f)=>(T,_)=>{if(_||Array.isArray(_)&&_.length===0){const S=f||"value",N=typeof _=="object"&&S in _?_[S]:_;w(y,N);return}w(y,void 0)},setFilter:w}},$e=({data:e,fetchNextPage:t,isFetchingNextPage:r,isInitialLoading:s,isLoading:o,enabled:a=!0})=>{const c=l.useCallback(async u=>{r||!a||await t({pageParam:u?.pageParam||u.visibleRowsCount})},[a,t,r]),d=l.useMemo(()=>{if(e)return e.pages.reduce((u,h)=>[...u,...h],[])},[e]);return{fetchNextPageOnRowsScrollEnd:c,isLoading:r||o,loadingVariant:s?"skeleton":"linear-progress",rows:d}},et=e=>{const{libraries:t}=l.useContext(j),r=e?.i18||t?.i18,s=e?.i18?.translateFunction||t?.i18?.translateFunction,o=r?.i18next?.t||s||(h=>h),{unknownErrorTranslationKey:a="error.unknownError"}=e||{},c=o(a),d=l.useCallback(h=>{if(h&&typeof h=="object"&&"response"in h){const{response:i}=h||{};if(i&&typeof i=="object"&&"reason"in i&&i.reason)return String(i.reason);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"reason"in i.data&&i.data.reason)return String(i.data.reason);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"message"in i.data&&i.data.message)return String(i.data.message);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"detail"in i.data){const{detail:m}=i.data;if(Array.isArray(m)&&m.length>0&&typeof m[0]=="object"&&m[0]!==null&&"msg"in m[0]){const{msg:E}=m[0];if(typeof E=="string")return String(E)}}}return h instanceof Error?h.message:c},[c]);return{getErrorCode:l.useCallback(h=>{const{response:i}=h||{};return i?.error_code?String(i?.error_code):i?.data?.error_code?String(i?.data?.error_code):i?.error_code?String(i?.error_code):i?.data?.error_code?String(i.data.error_code):"unknown_error_code"},[]),printError:d}};g.ChatClient=q,g.ChatContext=K,g.ChatProvider=Ye,g.GTMSendPageView=ve,g.InitializeAxiosConfig=_e,g.InitializeDaysJSConfig=Re,g.InitializeI18nConfig=be,g.InitializeSentryConfig=Te,g.InjectDependenciesContext=j,g.InjectDependenciesProvider=we,g.MaskTextField=Ee,g.PreloadErrorHandler=Se,g.QueryClientProviderWithConfig=We,g.RequireAuth=ke,g.axiosCustomInstance=pe,g.dateAdapter=re,g.distanceAdapter=oe,g.getOrvalConfig=Le,g.useAdapter=Qe,g.useAuth=Je,g.useChat=Ke,g.useCurrentLanguage=Be,g.useFilters=qe,g.useInfiniteDataGrid=$e,g.useResponseError=et,g.worksiteNameAdapter=se,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}));
|