@tracktor/shared-module 2.24.0 → 2.26.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/dist/chat/types.d.ts +1 -4
- package/dist/context/ChatProvider.d.ts +11 -2
- package/dist/hooks/useChat.d.ts +4 -1
- package/dist/main.js +232 -210
- package/dist/main.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/chat/types.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ export type ClientMessage = JoinThread | LeaveThread | SendMessage | MarkRead |
|
|
|
39
39
|
export interface ReadyEvent {
|
|
40
40
|
type: "ready";
|
|
41
41
|
userId: string;
|
|
42
|
+
unreadCount?: number;
|
|
42
43
|
}
|
|
43
44
|
export interface JoinedThread {
|
|
44
45
|
type: "joined_thread";
|
|
@@ -89,10 +90,6 @@ export interface ChatClientOptions {
|
|
|
89
90
|
reconnectBaseDelay?: number;
|
|
90
91
|
}
|
|
91
92
|
export interface UseChatParams {
|
|
92
|
-
token?: string;
|
|
93
|
-
url?: string;
|
|
94
|
-
enabled?: boolean;
|
|
95
|
-
reconnect?: boolean;
|
|
96
93
|
onReady?: (event: ReadyEvent) => void;
|
|
97
94
|
onNewMessage?: (event: NewMessageEvent) => void;
|
|
98
95
|
onNewMessageNotification?: (event: NewMessageNotification) => void;
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { ServerEvent } from '../chat/types';
|
|
3
|
+
type EventListener = (event: ServerEvent) => void;
|
|
4
|
+
export interface ChatProviderProps {
|
|
5
|
+
token?: string;
|
|
6
|
+
url?: string;
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
reconnect?: boolean;
|
|
9
|
+
}
|
|
3
10
|
export interface ChatContextValue {
|
|
4
11
|
isConnected: boolean;
|
|
5
12
|
isReady: boolean;
|
|
13
|
+
unreadCount: number;
|
|
14
|
+
addListener: (callback: EventListener) => () => void;
|
|
6
15
|
joinThread: (threadId: string) => void;
|
|
7
16
|
leaveThread: (threadId: string) => void;
|
|
8
17
|
listThreads: (limit?: number, offset?: number) => void;
|
|
@@ -10,5 +19,5 @@ export interface ChatContextValue {
|
|
|
10
19
|
sendMessage: (threadId: string, body: string) => void;
|
|
11
20
|
}
|
|
12
21
|
export declare const ChatContext: import('react').Context<ChatContextValue | null>;
|
|
13
|
-
declare const ChatProvider: ({ children,
|
|
22
|
+
declare const ChatProvider: ({ children, reconnect, enabled, url, token }: PropsWithChildren<ChatProviderProps>) => import("react/jsx-runtime").JSX.Element;
|
|
14
23
|
export default ChatProvider;
|
package/dist/hooks/useChat.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { UseChatParams } from '../chat/types';
|
|
1
2
|
import { ChatContextValue } from '../context/ChatProvider';
|
|
3
|
+
type UseChatReturn = Omit<ChatContextValue, "addListener">;
|
|
2
4
|
/**
|
|
3
5
|
* Hook to access the shared WebSocket chat connection.
|
|
4
6
|
* Provides methods to join/leave threads, send messages, mark as read, and list threads.
|
|
7
|
+
* Accepts optional event handlers (onNewMessage, onNewMessageNotification, etc.).
|
|
5
8
|
* Must be used within a ChatProvider.
|
|
6
9
|
*/
|
|
7
|
-
export declare const useChat: () =>
|
|
10
|
+
export declare const useChat: (handlers?: UseChatParams) => UseChatReturn;
|
|
8
11
|
export default useChat;
|
package/dist/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import oe from "axios";
|
|
2
|
-
import me, { useMemo as
|
|
2
|
+
import me, { useMemo as H, createContext as fe, useContext as j, useEffect as N, useState as D, Suspense as ye, useRef as B, useCallback as x } from "react";
|
|
3
3
|
const Je = (e, t) => {
|
|
4
4
|
const n = oe.CancelToken.source(), s = oe({
|
|
5
5
|
...e,
|
|
@@ -9,8 +9,8 @@ const Je = (e, t) => {
|
|
|
9
9
|
return s.cancel = () => {
|
|
10
10
|
n.cancel("Query was cancelled");
|
|
11
11
|
}, s;
|
|
12
|
-
},
|
|
13
|
-
class
|
|
12
|
+
}, we = 3e4, se = 1e3;
|
|
13
|
+
class ve {
|
|
14
14
|
url;
|
|
15
15
|
getToken;
|
|
16
16
|
onEvent;
|
|
@@ -64,8 +64,8 @@ class we {
|
|
|
64
64
|
this.joinedThreads.delete(t), this.send({ threadId: t, type: "leave_thread" });
|
|
65
65
|
}
|
|
66
66
|
sendMessage(t, n) {
|
|
67
|
-
if (n.length >
|
|
68
|
-
throw new Error(`Message body exceeds maximum length of ${
|
|
67
|
+
if (n.length > se)
|
|
68
|
+
throw new Error(`Message body exceeds maximum length of ${se} characters`);
|
|
69
69
|
this.send({ body: n, threadId: t, type: "send_message" });
|
|
70
70
|
}
|
|
71
71
|
markRead(t) {
|
|
@@ -93,7 +93,7 @@ class we {
|
|
|
93
93
|
}
|
|
94
94
|
scheduleReconnect() {
|
|
95
95
|
this.clearReconnectTimer();
|
|
96
|
-
const t = Math.min(this.reconnectBaseDelay * 2 ** this.reconnectAttempt,
|
|
96
|
+
const t = Math.min(this.reconnectBaseDelay * 2 ** this.reconnectAttempt, we);
|
|
97
97
|
this.reconnectAttempt++, this.reconnectTimer = setTimeout(() => {
|
|
98
98
|
this.connect();
|
|
99
99
|
}, t);
|
|
@@ -102,11 +102,11 @@ class we {
|
|
|
102
102
|
this.reconnectTimer !== null && (clearTimeout(this.reconnectTimer), this.reconnectTimer = null);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
var
|
|
106
|
-
var
|
|
105
|
+
var Q = { exports: {} }, U = {};
|
|
106
|
+
var ae;
|
|
107
107
|
function Ee() {
|
|
108
|
-
if (
|
|
109
|
-
|
|
108
|
+
if (ae) return U;
|
|
109
|
+
ae = 1;
|
|
110
110
|
var e = /* @__PURE__ */ Symbol.for("react.transitional.element"), t = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
111
111
|
function n(s, o, a) {
|
|
112
112
|
var c = null;
|
|
@@ -123,29 +123,29 @@ function Ee() {
|
|
|
123
123
|
props: a
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
|
-
return
|
|
126
|
+
return U.Fragment = t, U.jsx = n, U.jsxs = n, U;
|
|
127
127
|
}
|
|
128
|
-
var
|
|
129
|
-
var
|
|
128
|
+
var z = {};
|
|
129
|
+
var ie;
|
|
130
130
|
function Re() {
|
|
131
|
-
return
|
|
131
|
+
return ie || (ie = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
132
132
|
function e(r) {
|
|
133
133
|
if (r == null) return null;
|
|
134
134
|
if (typeof r == "function")
|
|
135
|
-
return r.$$typeof ===
|
|
135
|
+
return r.$$typeof === L ? null : r.displayName || r.name || null;
|
|
136
136
|
if (typeof r == "string") return r;
|
|
137
137
|
switch (r) {
|
|
138
|
-
case
|
|
138
|
+
case k:
|
|
139
139
|
return "Fragment";
|
|
140
140
|
case d:
|
|
141
141
|
return "Profiler";
|
|
142
142
|
case g:
|
|
143
143
|
return "StrictMode";
|
|
144
|
-
case
|
|
144
|
+
case P:
|
|
145
145
|
return "Suspense";
|
|
146
|
-
case
|
|
146
|
+
case T:
|
|
147
147
|
return "SuspenseList";
|
|
148
|
-
case
|
|
148
|
+
case M:
|
|
149
149
|
return "Activity";
|
|
150
150
|
}
|
|
151
151
|
if (typeof r == "object")
|
|
@@ -158,12 +158,12 @@ function Re() {
|
|
|
158
158
|
return r.displayName || "Context";
|
|
159
159
|
case b:
|
|
160
160
|
return (r._context.displayName || "Context") + ".Consumer";
|
|
161
|
-
case
|
|
161
|
+
case S:
|
|
162
162
|
var p = r.render;
|
|
163
163
|
return r = r.displayName, r || (r = p.displayName || p.name || "", r = r !== "" ? "ForwardRef(" + r + ")" : "ForwardRef"), r;
|
|
164
|
-
case
|
|
164
|
+
case $:
|
|
165
165
|
return p = r.displayName || null, p !== null ? p : e(r.type) || "Memo";
|
|
166
|
-
case
|
|
166
|
+
case Y:
|
|
167
167
|
p = r._payload, r = r._init;
|
|
168
168
|
try {
|
|
169
169
|
return e(r(p));
|
|
@@ -193,8 +193,8 @@ function Re() {
|
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
function s(r) {
|
|
196
|
-
if (r ===
|
|
197
|
-
if (typeof r == "object" && r !== null && r.$$typeof ===
|
|
196
|
+
if (r === k) return "<>";
|
|
197
|
+
if (typeof r == "object" && r !== null && r.$$typeof === Y)
|
|
198
198
|
return "<...>";
|
|
199
199
|
try {
|
|
200
200
|
var p = e(r);
|
|
@@ -204,14 +204,14 @@ function Re() {
|
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
function o() {
|
|
207
|
-
var r =
|
|
207
|
+
var r = I.A;
|
|
208
208
|
return r === null ? null : r.getOwner();
|
|
209
209
|
}
|
|
210
210
|
function a() {
|
|
211
211
|
return Error("react-stack-top-frame");
|
|
212
212
|
}
|
|
213
213
|
function c(r) {
|
|
214
|
-
if (
|
|
214
|
+
if (X.call(r, "key")) {
|
|
215
215
|
var p = Object.getOwnPropertyDescriptor(r, "key").get;
|
|
216
216
|
if (p && p.isReactWarning) return !1;
|
|
217
217
|
}
|
|
@@ -219,7 +219,7 @@ function Re() {
|
|
|
219
219
|
}
|
|
220
220
|
function u(r, p) {
|
|
221
221
|
function w() {
|
|
222
|
-
|
|
222
|
+
Z || (Z = !0, console.error(
|
|
223
223
|
"%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
224
|
p
|
|
225
225
|
));
|
|
@@ -231,14 +231,14 @@ function Re() {
|
|
|
231
231
|
}
|
|
232
232
|
function l() {
|
|
233
233
|
var r = e(this.type);
|
|
234
|
-
return
|
|
234
|
+
return ee[r] || (ee[r] = !0, console.error(
|
|
235
235
|
"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
236
|
)), r = this.props.ref, r !== void 0 ? r : null;
|
|
237
237
|
}
|
|
238
|
-
function f(r, p, w, R,
|
|
238
|
+
function f(r, p, w, R, V, K) {
|
|
239
239
|
var _ = w.ref;
|
|
240
240
|
return r = {
|
|
241
|
-
$$typeof:
|
|
241
|
+
$$typeof: v,
|
|
242
242
|
type: r,
|
|
243
243
|
key: p,
|
|
244
244
|
props: w,
|
|
@@ -260,19 +260,19 @@ function Re() {
|
|
|
260
260
|
configurable: !1,
|
|
261
261
|
enumerable: !1,
|
|
262
262
|
writable: !0,
|
|
263
|
-
value:
|
|
263
|
+
value: V
|
|
264
264
|
}), Object.defineProperty(r, "_debugTask", {
|
|
265
265
|
configurable: !1,
|
|
266
266
|
enumerable: !1,
|
|
267
267
|
writable: !0,
|
|
268
|
-
value:
|
|
268
|
+
value: K
|
|
269
269
|
}), Object.freeze && (Object.freeze(r.props), Object.freeze(r)), r;
|
|
270
270
|
}
|
|
271
|
-
function i(r, p, w, R,
|
|
271
|
+
function i(r, p, w, R, V, K) {
|
|
272
272
|
var _ = p.children;
|
|
273
273
|
if (_ !== void 0)
|
|
274
274
|
if (R)
|
|
275
|
-
if (
|
|
275
|
+
if (he(_)) {
|
|
276
276
|
for (R = 0; R < _.length; R++)
|
|
277
277
|
h(_[R]);
|
|
278
278
|
Object.freeze && Object.freeze(_);
|
|
@@ -281,12 +281,12 @@ function Re() {
|
|
|
281
281
|
"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
282
|
);
|
|
283
283
|
else h(_);
|
|
284
|
-
if (
|
|
284
|
+
if (X.call(p, "key")) {
|
|
285
285
|
_ = e(r);
|
|
286
|
-
var
|
|
286
|
+
var F = Object.keys(p).filter(function(ge) {
|
|
287
287
|
return ge !== "key";
|
|
288
288
|
});
|
|
289
|
-
R = 0 <
|
|
289
|
+
R = 0 < F.length ? "{key: someKey, " + F.join(": ..., ") + ": ...}" : "{key: someKey}", ne[_ + R] || (F = 0 < F.length ? "{" + F.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
290
290
|
`A props object containing a "key" prop is being spread into JSX:
|
|
291
291
|
let props = %s;
|
|
292
292
|
<%s {...props} />
|
|
@@ -295,14 +295,14 @@ React keys must be passed directly to JSX without using spread:
|
|
|
295
295
|
<%s key={someKey} {...props} />`,
|
|
296
296
|
R,
|
|
297
297
|
_,
|
|
298
|
-
|
|
298
|
+
F,
|
|
299
299
|
_
|
|
300
300
|
), ne[_ + R] = !0);
|
|
301
301
|
}
|
|
302
302
|
if (_ = null, w !== void 0 && (n(w), _ = "" + w), c(p) && (n(p.key), _ = "" + p.key), "key" in p) {
|
|
303
303
|
w = {};
|
|
304
|
-
for (var
|
|
305
|
-
|
|
304
|
+
for (var q in p)
|
|
305
|
+
q !== "key" && (w[q] = p[q]);
|
|
306
306
|
} else w = p;
|
|
307
307
|
return _ && u(
|
|
308
308
|
w,
|
|
@@ -312,65 +312,65 @@ React keys must be passed directly to JSX without using spread:
|
|
|
312
312
|
_,
|
|
313
313
|
w,
|
|
314
314
|
o(),
|
|
315
|
-
|
|
316
|
-
|
|
315
|
+
V,
|
|
316
|
+
K
|
|
317
317
|
);
|
|
318
318
|
}
|
|
319
319
|
function h(r) {
|
|
320
|
-
|
|
320
|
+
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
321
|
}
|
|
322
|
-
function
|
|
323
|
-
return typeof r == "object" && r !== null && r.$$typeof ===
|
|
322
|
+
function m(r) {
|
|
323
|
+
return typeof r == "object" && r !== null && r.$$typeof === v;
|
|
324
324
|
}
|
|
325
|
-
var
|
|
325
|
+
var y = me, v = /* @__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"), E = /* @__PURE__ */ Symbol.for("react.context"), S = /* @__PURE__ */ Symbol.for("react.forward_ref"), P = /* @__PURE__ */ Symbol.for("react.suspense"), T = /* @__PURE__ */ Symbol.for("react.suspense_list"), $ = /* @__PURE__ */ Symbol.for("react.memo"), Y = /* @__PURE__ */ Symbol.for("react.lazy"), M = /* @__PURE__ */ Symbol.for("react.activity"), L = /* @__PURE__ */ Symbol.for("react.client.reference"), I = y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, X = Object.prototype.hasOwnProperty, he = Array.isArray, G = console.createTask ? console.createTask : function() {
|
|
326
326
|
return null;
|
|
327
327
|
};
|
|
328
|
-
|
|
328
|
+
y = {
|
|
329
329
|
react_stack_bottom_frame: function(r) {
|
|
330
330
|
return r();
|
|
331
331
|
}
|
|
332
332
|
};
|
|
333
|
-
var
|
|
334
|
-
|
|
333
|
+
var Z, ee = {}, te = y.react_stack_bottom_frame.bind(
|
|
334
|
+
y,
|
|
335
335
|
a
|
|
336
|
-
)(), re =
|
|
337
|
-
|
|
338
|
-
var R = 1e4 >
|
|
336
|
+
)(), re = G(s(a)), ne = {};
|
|
337
|
+
z.Fragment = k, z.jsx = function(r, p, w) {
|
|
338
|
+
var R = 1e4 > I.recentlyCreatedOwnerStacks++;
|
|
339
339
|
return i(
|
|
340
340
|
r,
|
|
341
341
|
p,
|
|
342
342
|
w,
|
|
343
343
|
!1,
|
|
344
|
-
R ? Error("react-stack-top-frame") :
|
|
345
|
-
R ?
|
|
344
|
+
R ? Error("react-stack-top-frame") : te,
|
|
345
|
+
R ? G(s(r)) : re
|
|
346
346
|
);
|
|
347
|
-
},
|
|
348
|
-
var R = 1e4 >
|
|
347
|
+
}, z.jsxs = function(r, p, w) {
|
|
348
|
+
var R = 1e4 > I.recentlyCreatedOwnerStacks++;
|
|
349
349
|
return i(
|
|
350
350
|
r,
|
|
351
351
|
p,
|
|
352
352
|
w,
|
|
353
353
|
!0,
|
|
354
|
-
R ? Error("react-stack-top-frame") :
|
|
355
|
-
R ?
|
|
354
|
+
R ? Error("react-stack-top-frame") : te,
|
|
355
|
+
R ? G(s(r)) : re
|
|
356
356
|
);
|
|
357
357
|
};
|
|
358
|
-
})()),
|
|
358
|
+
})()), z;
|
|
359
359
|
}
|
|
360
|
-
var
|
|
360
|
+
var ce;
|
|
361
361
|
function _e() {
|
|
362
|
-
return
|
|
362
|
+
return ce || (ce = 1, process.env.NODE_ENV === "production" ? Q.exports = Ee() : Q.exports = Re()), Q.exports;
|
|
363
363
|
}
|
|
364
|
-
var
|
|
364
|
+
var O = _e();
|
|
365
365
|
const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
366
|
-
const n =
|
|
366
|
+
const n = H(
|
|
367
367
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
368
|
-
() => e(({ TextField: s, ...o }) => /* @__PURE__ */
|
|
368
|
+
() => e(({ TextField: s, ...o }) => /* @__PURE__ */ O.jsx(s, { ...o })),
|
|
369
369
|
[e]
|
|
370
370
|
);
|
|
371
|
-
return /* @__PURE__ */
|
|
372
|
-
}, C =
|
|
373
|
-
const o =
|
|
371
|
+
return /* @__PURE__ */ O.jsx(n, { ...t });
|
|
372
|
+
}, C = fe({}), Ke = ({ children: e, apiURL: t, libraries: n, localStorageKeys: s }) => {
|
|
373
|
+
const o = H(
|
|
374
374
|
() => ({
|
|
375
375
|
apiURL: t,
|
|
376
376
|
libraries: n,
|
|
@@ -378,7 +378,7 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
378
378
|
}),
|
|
379
379
|
[t, n, s]
|
|
380
380
|
);
|
|
381
|
-
return /* @__PURE__ */
|
|
381
|
+
return /* @__PURE__ */ O.jsx(C.Provider, { value: o, children: e });
|
|
382
382
|
}, qe = ({ data: e, ...t }) => {
|
|
383
383
|
const { libraries: n } = j(C), s = t?.reactRouter || n?.reactRouter, o = t?.gtm || n?.gtm;
|
|
384
384
|
if (!s)
|
|
@@ -388,14 +388,14 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
388
388
|
if (!o)
|
|
389
389
|
throw new Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");
|
|
390
390
|
const { useGoogleTagManager: a } = o, { useLocation: c, Outlet: u } = s, { pathname: l } = c(), { sendEvent: f } = a();
|
|
391
|
-
return
|
|
391
|
+
return N(() => {
|
|
392
392
|
f({
|
|
393
393
|
event: "pageView",
|
|
394
394
|
pathname: l,
|
|
395
395
|
...e
|
|
396
396
|
});
|
|
397
|
-
}, [e, l, f]), /* @__PURE__ */
|
|
398
|
-
},
|
|
397
|
+
}, [e, l, f]), /* @__PURE__ */ O.jsx(u, {});
|
|
398
|
+
}, W = (() => {
|
|
399
399
|
try {
|
|
400
400
|
return typeof global == "object" && global !== null && ("HermesInternal" in global || // Hermes JS engine
|
|
401
401
|
"__fbBatchedBridge" in global || // RN Bridge
|
|
@@ -412,11 +412,11 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
412
412
|
const { apiURL: o = s.apiURL, libraries: a, localStorageKeys: c } = j(C), u = s?.userLocalStorageKey || c?.user || be, l = s?.axios || a?.axios;
|
|
413
413
|
if (!l)
|
|
414
414
|
throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
415
|
-
if (!l?.defaults ||
|
|
415
|
+
if (!l?.defaults || W)
|
|
416
416
|
return null;
|
|
417
417
|
if (typeof window < "u" && window.localStorage) {
|
|
418
|
-
const f = localStorage.getItem(u), i = f ? JSON.parse(f) : null, h = i?.[e] ? i[e] : null,
|
|
419
|
-
|
|
418
|
+
const f = localStorage.getItem(u), i = f ? JSON.parse(f) : null, h = i?.[e] ? i[e] : null, m = i?.[t] ? i[t] : null, y = f ? `${h} ${m}` : null;
|
|
419
|
+
y && (l.defaults.headers.common.Authorization = y);
|
|
420
420
|
}
|
|
421
421
|
return l.defaults.baseURL = o, l.defaults.headers.post["Content-Type"] = n, null;
|
|
422
422
|
}, He = ({ language: e, ...t }) => {
|
|
@@ -425,7 +425,7 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
425
425
|
throw new Error(
|
|
426
426
|
"Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig."
|
|
427
427
|
);
|
|
428
|
-
return
|
|
428
|
+
return N(() => {
|
|
429
429
|
(async () => {
|
|
430
430
|
const c = e || navigator.language?.slice(0, 2) || "en";
|
|
431
431
|
o && o.forEach((u) => {
|
|
@@ -435,7 +435,7 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
435
435
|
}, [s, o, e]), null;
|
|
436
436
|
}, Xe = ({ debug: e, resources: t, ...n }) => {
|
|
437
437
|
const { libraries: s } = j(C), o = n?.i18 || s?.i18, { i18next: a, initReactI18next: c, languageDetector: u } = o || {};
|
|
438
|
-
if (
|
|
438
|
+
if (W)
|
|
439
439
|
return null;
|
|
440
440
|
if (!o)
|
|
441
441
|
throw new Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
@@ -470,15 +470,15 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
470
470
|
release: f,
|
|
471
471
|
...i
|
|
472
472
|
}) => {
|
|
473
|
-
const { libraries: h } = j(C),
|
|
474
|
-
if (!v)
|
|
475
|
-
throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
473
|
+
const { libraries: h } = j(C), m = i?.sentry || h?.sentry, y = i?.reactRouter || h?.reactRouter;
|
|
476
474
|
if (!m)
|
|
475
|
+
throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
476
|
+
if (!y)
|
|
477
477
|
throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
478
|
-
if (
|
|
478
|
+
if (m.isInitialized())
|
|
479
479
|
return null;
|
|
480
|
-
const { createRoutesFromChildren:
|
|
481
|
-
return (u || process.env.NODE_ENV === "prod" || process.env.NODE_ENV === "production") &&
|
|
480
|
+
const { createRoutesFromChildren: v, matchRoutes: A, useLocation: k, useNavigationType: g } = y;
|
|
481
|
+
return (u || process.env.NODE_ENV === "prod" || process.env.NODE_ENV === "production") && m.init({
|
|
482
482
|
debug: u,
|
|
483
483
|
dsn: e,
|
|
484
484
|
environment: l || "production",
|
|
@@ -492,11 +492,11 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
492
492
|
/vite:preloadError/
|
|
493
493
|
],
|
|
494
494
|
integrations: [
|
|
495
|
-
|
|
496
|
-
createRoutesFromChildren:
|
|
495
|
+
m.reactRouterV6BrowserTracingIntegration({
|
|
496
|
+
createRoutesFromChildren: v,
|
|
497
497
|
matchRoutes: A,
|
|
498
|
-
useEffect:
|
|
499
|
-
useLocation:
|
|
498
|
+
useEffect: N,
|
|
499
|
+
useLocation: k,
|
|
500
500
|
useNavigationType: g
|
|
501
501
|
}),
|
|
502
502
|
...t || []
|
|
@@ -507,8 +507,8 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
507
507
|
tracePropagationTargets: a,
|
|
508
508
|
tracesSampleRate: n || 1
|
|
509
509
|
}), null;
|
|
510
|
-
}, et = () => (
|
|
511
|
-
if (
|
|
510
|
+
}, et = () => (N(() => {
|
|
511
|
+
if (W)
|
|
512
512
|
return;
|
|
513
513
|
const e = (t) => {
|
|
514
514
|
try {
|
|
@@ -519,17 +519,17 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
519
519
|
return window.addEventListener("vite:preloadError", e), () => {
|
|
520
520
|
window.removeEventListener("vite:preloadError", e);
|
|
521
521
|
};
|
|
522
|
-
}, []), null),
|
|
522
|
+
}, []), null), le = /* @__PURE__ */ new WeakMap(), Te = "user", tt = ({ Fallback: e, isLogged: t, loginPath: n = "/login", redirect401Path: s = "/login", ...o }) => {
|
|
523
523
|
const { libraries: a, localStorageKeys: c } = j(C), u = o?.reactRouter || a?.reactRouter, l = o?.axios || a?.axios, f = o?.localStorageKey || c?.user || Te;
|
|
524
524
|
if (!u)
|
|
525
525
|
throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
526
|
-
const [i, h] =
|
|
527
|
-
return
|
|
528
|
-
|
|
526
|
+
const [i, h] = D(null), { useLocation: m, Navigate: y, Outlet: v } = u, A = m(), k = typeof t == "function" ? t() : !!t, g = typeof k == "boolean" ? k : k?.isLogged;
|
|
527
|
+
return N(() => {
|
|
528
|
+
le.has(l) || (le.set(l, !0), l.interceptors.response.use(
|
|
529
529
|
(d) => d,
|
|
530
530
|
(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
531
|
));
|
|
532
|
-
}, [l, f, s]), g && !i ? /* @__PURE__ */
|
|
532
|
+
}, [l, f, s]), g && !i ? /* @__PURE__ */ O.jsx(ye, { fallback: e, children: A.state?.from?.state && A.state?.from?.pathname === n ? /* @__PURE__ */ O.jsx(y, { to: A.state.from.state.from.pathname + A.state.from.state.from.search, replace: !0 }) : /* @__PURE__ */ O.jsx(v, {}) }) : /* @__PURE__ */ O.jsx(y, { to: n + A.search, state: { from: A }, replace: !0 });
|
|
533
533
|
}, Se = (e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase(), Ae = (e) => {
|
|
534
534
|
const t = e.split(/[/\\]/).pop() || "";
|
|
535
535
|
return t.substring(0, t.lastIndexOf("."));
|
|
@@ -570,16 +570,16 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
570
570
|
...(a?.length || c?.length) && {
|
|
571
571
|
operations: Pe(a, c)
|
|
572
572
|
},
|
|
573
|
-
header: (
|
|
573
|
+
header: (m) => [
|
|
574
574
|
"Generated by orval 🍺",
|
|
575
|
-
...
|
|
576
|
-
...
|
|
575
|
+
...m.title ? [m.title] : [],
|
|
576
|
+
...m.description ? [m.description] : []
|
|
577
577
|
],
|
|
578
578
|
mutator: {
|
|
579
579
|
name: Ae(h),
|
|
580
580
|
path: h
|
|
581
581
|
},
|
|
582
|
-
operationName: (
|
|
582
|
+
operationName: (m, y, v) => ke(m, y, v, c),
|
|
583
583
|
query: {
|
|
584
584
|
useQuery: !0
|
|
585
585
|
}
|
|
@@ -600,88 +600,65 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
600
600
|
} catch {
|
|
601
601
|
return null;
|
|
602
602
|
}
|
|
603
|
-
},
|
|
604
|
-
const [
|
|
605
|
-
|
|
606
|
-
if (!
|
|
603
|
+
}, pe = fe(null), nt = ({ children: e, reconnect: t = !0, enabled: n = !0, url: s, token: o }) => {
|
|
604
|
+
const [a, c] = D(!1), [u, l] = D(!1), [f, i] = D(0), { apiURL: h, localStorageKeys: m } = j(C), y = m?.user || xe, v = B(null), A = B(/* @__PURE__ */ new Set());
|
|
605
|
+
N(() => {
|
|
606
|
+
if (!n || v.current?.connected)
|
|
607
607
|
return;
|
|
608
|
-
const
|
|
609
|
-
if (!
|
|
608
|
+
const T = s || (h ? Oe(h) : null);
|
|
609
|
+
if (!T)
|
|
610
610
|
return;
|
|
611
|
-
const
|
|
612
|
-
|
|
613
|
-
onError: B,
|
|
614
|
-
onReady: H,
|
|
615
|
-
onNewMessage: $,
|
|
616
|
-
onNewMessageNotification: z,
|
|
617
|
-
onPresence: X,
|
|
618
|
-
onJoinedThread: F,
|
|
619
|
-
onLeftThread: W,
|
|
620
|
-
onMarkedRead: V,
|
|
621
|
-
onThreadsList: Q
|
|
622
|
-
} = k.current || {};
|
|
623
|
-
switch (T.type) {
|
|
611
|
+
const $ = () => o ?? Ie(y), Y = (L) => {
|
|
612
|
+
switch (L.type) {
|
|
624
613
|
case "ready":
|
|
625
|
-
|
|
626
|
-
break;
|
|
627
|
-
case "new_message":
|
|
628
|
-
$?.(T);
|
|
614
|
+
l(!0), i(L.unreadCount ?? 0);
|
|
629
615
|
break;
|
|
630
616
|
case "new_message_notification":
|
|
631
|
-
|
|
632
|
-
break;
|
|
633
|
-
case "presence":
|
|
634
|
-
X?.(T);
|
|
635
|
-
break;
|
|
636
|
-
case "error":
|
|
637
|
-
B?.(T);
|
|
638
|
-
break;
|
|
639
|
-
case "joined_thread":
|
|
640
|
-
F?.(T);
|
|
641
|
-
break;
|
|
642
|
-
case "left_thread":
|
|
643
|
-
W?.(T);
|
|
617
|
+
i((I) => I + 1);
|
|
644
618
|
break;
|
|
645
619
|
case "marked_read":
|
|
646
|
-
|
|
647
|
-
break;
|
|
648
|
-
case "threads_list":
|
|
649
|
-
Q?.(T);
|
|
620
|
+
i((I) => Math.max(0, I - 1));
|
|
650
621
|
break;
|
|
651
622
|
}
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
623
|
+
for (const I of A.current)
|
|
624
|
+
I(L);
|
|
625
|
+
}, M = new ve({
|
|
626
|
+
getToken: $,
|
|
627
|
+
onConnectionChange: (L) => {
|
|
628
|
+
c(L), L || l(!1);
|
|
656
629
|
},
|
|
657
|
-
onEvent:
|
|
658
|
-
reconnect:
|
|
659
|
-
url:
|
|
630
|
+
onEvent: Y,
|
|
631
|
+
reconnect: t,
|
|
632
|
+
url: T
|
|
660
633
|
});
|
|
661
|
-
return
|
|
662
|
-
|
|
634
|
+
return v.current = M, M.connect(), () => {
|
|
635
|
+
M.disconnect(), v.current = null;
|
|
663
636
|
};
|
|
664
|
-
}, [
|
|
665
|
-
const
|
|
666
|
-
|
|
667
|
-
}, []),
|
|
668
|
-
|
|
669
|
-
}, []),
|
|
670
|
-
|
|
671
|
-
}, []),
|
|
672
|
-
|
|
673
|
-
}, []),
|
|
674
|
-
|
|
675
|
-
}, []),
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
637
|
+
}, [n, s, o, h, t, y]);
|
|
638
|
+
const k = x((T) => {
|
|
639
|
+
v.current?.joinThread(T);
|
|
640
|
+
}, []), g = x((T) => {
|
|
641
|
+
v.current?.leaveThread(T);
|
|
642
|
+
}, []), d = x((T, $) => {
|
|
643
|
+
v.current?.sendMessage(T, $);
|
|
644
|
+
}, []), b = x((T) => {
|
|
645
|
+
v.current?.markRead(T);
|
|
646
|
+
}, []), E = x((T, $) => {
|
|
647
|
+
v.current?.listThreads(T, $);
|
|
648
|
+
}, []), P = {
|
|
649
|
+
addListener: x((T) => (A.current.add(T), () => {
|
|
650
|
+
A.current.delete(T);
|
|
651
|
+
}), []),
|
|
652
|
+
isConnected: a,
|
|
653
|
+
isReady: u,
|
|
654
|
+
joinThread: k,
|
|
655
|
+
leaveThread: g,
|
|
656
|
+
listThreads: E,
|
|
657
|
+
markRead: b,
|
|
658
|
+
sendMessage: d,
|
|
659
|
+
unreadCount: f
|
|
683
660
|
};
|
|
684
|
-
return /* @__PURE__ */
|
|
661
|
+
return /* @__PURE__ */ O.jsx(pe.Provider, { value: P, children: e });
|
|
685
662
|
}, Ne = (e) => e && typeof e == "function", Le = (e) => e && typeof e == "function", ot = ({
|
|
686
663
|
children: e,
|
|
687
664
|
defaultQueriesOptions: t,
|
|
@@ -710,7 +687,7 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
710
687
|
}
|
|
711
688
|
}
|
|
712
689
|
});
|
|
713
|
-
return /* @__PURE__ */
|
|
690
|
+
return /* @__PURE__ */ O.jsx(c, { client: u, children: e });
|
|
714
691
|
}, $e = ({ library: e, date: t, format: n = "ll" }) => e(t).format(n), Fe = (e, t) => {
|
|
715
692
|
const { fractionDigits: n = 0, metric: s = "km", spacingBetween: o = !0 } = t || {}, a = Number(e), c = o ? " " : "";
|
|
716
693
|
return Number.isNaN(a) ? `0${c}${s}` : `${a.toFixed(n)}${c}${s}`;
|
|
@@ -749,7 +726,7 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
749
726
|
const { libraries: t, localStorageKeys: n } = j(C), s = e?.axios || t?.axios, o = e?.localStorageKey || n?.user || "user";
|
|
750
727
|
if (!s)
|
|
751
728
|
throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");
|
|
752
|
-
const a =
|
|
729
|
+
const a = x(
|
|
753
730
|
({ tokenType: u, accessToken: l }) => {
|
|
754
731
|
s.defaults.headers.common.Authorization = `${u} ${l}`;
|
|
755
732
|
},
|
|
@@ -757,8 +734,8 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
757
734
|
), c = () => {
|
|
758
735
|
s.defaults.headers.common.Authorization = null;
|
|
759
736
|
};
|
|
760
|
-
return
|
|
761
|
-
if (
|
|
737
|
+
return N(() => {
|
|
738
|
+
if (W)
|
|
762
739
|
return;
|
|
763
740
|
const u = ({ newValue: l, key: f }) => {
|
|
764
741
|
if (f === o && l)
|
|
@@ -776,20 +753,65 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
776
753
|
clearAuthenticationToken: c,
|
|
777
754
|
setAuthenticationToken: a
|
|
778
755
|
};
|
|
779
|
-
}, it = () => {
|
|
780
|
-
const
|
|
781
|
-
if (!
|
|
756
|
+
}, it = (e) => {
|
|
757
|
+
const t = j(pe);
|
|
758
|
+
if (!t)
|
|
782
759
|
throw new Error("useChat must be used within ChatProvider");
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
760
|
+
const { addListener: n, ...s } = t, o = B(e);
|
|
761
|
+
return o.current = e, N(
|
|
762
|
+
() => n((a) => {
|
|
763
|
+
const {
|
|
764
|
+
onReady: c,
|
|
765
|
+
onNewMessage: u,
|
|
766
|
+
onNewMessageNotification: l,
|
|
767
|
+
onPresence: f,
|
|
768
|
+
onError: i,
|
|
769
|
+
onJoinedThread: h,
|
|
770
|
+
onLeftThread: m,
|
|
771
|
+
onMarkedRead: y,
|
|
772
|
+
onThreadsList: v
|
|
773
|
+
} = o.current ?? {};
|
|
774
|
+
switch (a.type) {
|
|
775
|
+
case "ready":
|
|
776
|
+
c?.(a);
|
|
777
|
+
break;
|
|
778
|
+
case "new_message":
|
|
779
|
+
u?.(a);
|
|
780
|
+
break;
|
|
781
|
+
case "new_message_notification":
|
|
782
|
+
l?.(a);
|
|
783
|
+
break;
|
|
784
|
+
case "presence":
|
|
785
|
+
f?.(a);
|
|
786
|
+
break;
|
|
787
|
+
case "error":
|
|
788
|
+
i?.(a);
|
|
789
|
+
break;
|
|
790
|
+
case "joined_thread":
|
|
791
|
+
h?.(a);
|
|
792
|
+
break;
|
|
793
|
+
case "left_thread":
|
|
794
|
+
m?.(a);
|
|
795
|
+
break;
|
|
796
|
+
case "marked_read":
|
|
797
|
+
y?.(a);
|
|
798
|
+
break;
|
|
799
|
+
case "threads_list":
|
|
800
|
+
v?.(a);
|
|
801
|
+
break;
|
|
802
|
+
}
|
|
803
|
+
}),
|
|
804
|
+
[n]
|
|
805
|
+
), s;
|
|
806
|
+
}, J = (e, t) => t === "short" ? e.split("-")[0] : e, ct = (e, t = "full") => {
|
|
807
|
+
const [n, s] = D(() => {
|
|
786
808
|
const o = e?.language || navigator.language;
|
|
787
|
-
return e && "isInitialized" in e && e.isInitialized,
|
|
809
|
+
return e && "isInitialized" in e && e.isInitialized, J(o, t);
|
|
788
810
|
});
|
|
789
|
-
return
|
|
790
|
-
e && "isInitialized" in e && e.isInitialized && e.language && s(
|
|
811
|
+
return N(() => {
|
|
812
|
+
e && "isInitialized" in e && e.isInitialized && e.language && s(J(e.language, t));
|
|
791
813
|
const o = (a) => {
|
|
792
|
-
s(
|
|
814
|
+
s(J(a, t));
|
|
793
815
|
};
|
|
794
816
|
return e?.on?.("languageChanged", o), () => {
|
|
795
817
|
e?.off?.("languageChanged", o);
|
|
@@ -803,13 +825,13 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
803
825
|
},
|
|
804
826
|
setFilter: () => {
|
|
805
827
|
}
|
|
806
|
-
},
|
|
828
|
+
}, ue = (e) => {
|
|
807
829
|
try {
|
|
808
830
|
return JSON.parse(e);
|
|
809
831
|
} catch {
|
|
810
832
|
return e;
|
|
811
833
|
}
|
|
812
|
-
},
|
|
834
|
+
}, de = (e, t, n) => `${n}_${e}=>${t}`, We = (e) => e.reduce((t, n) => {
|
|
813
835
|
const s = localStorage.getItem(n);
|
|
814
836
|
if (s)
|
|
815
837
|
try {
|
|
@@ -820,52 +842,52 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
820
842
|
return t;
|
|
821
843
|
}, {}), lt = (e) => {
|
|
822
844
|
const { libraries: t, localStorageKeys: n } = j(C), s = e?.reactRouter || t?.reactRouter, { pathname: o } = s?.useLocation?.() ?? { pathname: "/" }, [a, c] = s?.useSearchParams?.() ?? [new URLSearchParams(), () => {
|
|
823
|
-
}], [u, l] =
|
|
824
|
-
if (
|
|
845
|
+
}], [u, l] = D({}), f = n?.filter || Ue, i = e?.syncWithUrl === void 0 ? !0 : e?.syncWithUrl, h = e?.persistToLocalStorage === void 0 ? !0 : e?.persistToLocalStorage;
|
|
846
|
+
if (W)
|
|
825
847
|
return ze;
|
|
826
848
|
if (!s)
|
|
827
849
|
throw new Error(
|
|
828
850
|
"React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter."
|
|
829
851
|
);
|
|
830
|
-
const
|
|
852
|
+
const m = () => Object.keys(localStorage).filter(
|
|
831
853
|
(g) => g.startsWith(f) && g.endsWith(e?.pathname || o)
|
|
832
|
-
),
|
|
833
|
-
const E =
|
|
854
|
+
), y = (g, d, b = !0) => {
|
|
855
|
+
const E = de(g, e?.pathname || o, f);
|
|
834
856
|
if (!d || Array.isArray(d) && !d.length) {
|
|
835
|
-
i ? (a.delete(g), c(a)) : l((
|
|
836
|
-
const
|
|
837
|
-
return delete
|
|
857
|
+
i ? (a.delete(g), c(a)) : l((S) => {
|
|
858
|
+
const P = { ...S };
|
|
859
|
+
return delete P[g], P;
|
|
838
860
|
}), h && localStorage.removeItem(E);
|
|
839
861
|
return;
|
|
840
862
|
}
|
|
841
|
-
h && b && d && localStorage.setItem(E, JSON.stringify({ ...a, [g]: d })), i && d ? (a.set(g, JSON.stringify(d)), c(a)) : !i && d && l((
|
|
863
|
+
h && b && d && localStorage.setItem(E, JSON.stringify({ ...a, [g]: d })), i && d ? (a.set(g, JSON.stringify(d)), c(a)) : !i && d && l((S) => ({ ...S, [g]: d }));
|
|
842
864
|
};
|
|
843
865
|
return {
|
|
844
866
|
getFilter: (g, d) => {
|
|
845
867
|
if (i) {
|
|
846
868
|
const b = a.get(g);
|
|
847
869
|
if (b)
|
|
848
|
-
return
|
|
870
|
+
return ue(b);
|
|
849
871
|
} else {
|
|
850
872
|
const b = u[g];
|
|
851
873
|
if (b !== void 0)
|
|
852
874
|
return b;
|
|
853
875
|
}
|
|
854
876
|
if (h) {
|
|
855
|
-
const b =
|
|
877
|
+
const b = de(g, e?.pathname || o, f), E = localStorage.getItem(b);
|
|
856
878
|
if (E)
|
|
857
879
|
try {
|
|
858
|
-
const
|
|
859
|
-
return !i &&
|
|
880
|
+
const S = JSON.parse(E)[g];
|
|
881
|
+
return !i && S !== void 0 && l((P) => ({ ...P, [g]: S })), S;
|
|
860
882
|
} catch {
|
|
861
883
|
}
|
|
862
884
|
}
|
|
863
885
|
return d;
|
|
864
886
|
},
|
|
865
887
|
getFilters: () => {
|
|
866
|
-
const g = h ? We(
|
|
888
|
+
const g = h ? We(m()) : {};
|
|
867
889
|
if (i) {
|
|
868
|
-
const d = Array.from(a.entries()).reduce((b, [E,
|
|
890
|
+
const d = Array.from(a.entries()).reduce((b, [E, S]) => (b[E] = ue(S), b), {});
|
|
869
891
|
return {
|
|
870
892
|
...g,
|
|
871
893
|
...d
|
|
@@ -878,13 +900,13 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
878
900
|
},
|
|
879
901
|
handleFilter: (g, d) => (b, E) => {
|
|
880
902
|
if (E || Array.isArray(E) && E.length === 0) {
|
|
881
|
-
const
|
|
882
|
-
|
|
903
|
+
const S = d || "value", P = typeof E == "object" && S in E ? E[S] : E;
|
|
904
|
+
y(g, P);
|
|
883
905
|
return;
|
|
884
906
|
}
|
|
885
|
-
|
|
907
|
+
y(g, void 0);
|
|
886
908
|
},
|
|
887
|
-
setFilter:
|
|
909
|
+
setFilter: y
|
|
888
910
|
};
|
|
889
911
|
}, ut = ({
|
|
890
912
|
data: e,
|
|
@@ -894,12 +916,12 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
894
916
|
isLoading: o,
|
|
895
917
|
enabled: a = !0
|
|
896
918
|
}) => {
|
|
897
|
-
const c =
|
|
919
|
+
const c = x(
|
|
898
920
|
async (l) => {
|
|
899
921
|
n || !a || await t({ pageParam: l?.pageParam || l.visibleRowsCount });
|
|
900
922
|
},
|
|
901
923
|
[a, t, n]
|
|
902
|
-
), u =
|
|
924
|
+
), u = H(() => {
|
|
903
925
|
if (e)
|
|
904
926
|
return e.pages.reduce((l, f) => [...l, ...f], []);
|
|
905
927
|
}, [e]);
|
|
@@ -910,7 +932,7 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
910
932
|
rows: u
|
|
911
933
|
};
|
|
912
934
|
}, dt = (e) => {
|
|
913
|
-
const { libraries: t } = j(C), 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 =
|
|
935
|
+
const { libraries: t } = j(C), 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 = x(
|
|
914
936
|
(f) => {
|
|
915
937
|
if (f && typeof f == "object" && "response" in f) {
|
|
916
938
|
const { response: i } = f || {};
|
|
@@ -923,9 +945,9 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
923
945
|
if (i && typeof i == "object" && "data" in i && i.data && typeof i.data == "object" && "detail" in i.data) {
|
|
924
946
|
const { detail: h } = i.data;
|
|
925
947
|
if (Array.isArray(h) && h.length > 0 && typeof h[0] == "object" && h[0] !== null && "msg" in h[0]) {
|
|
926
|
-
const { msg:
|
|
927
|
-
if (typeof
|
|
928
|
-
return String(
|
|
948
|
+
const { msg: m } = h[0];
|
|
949
|
+
if (typeof m == "string")
|
|
950
|
+
return String(m);
|
|
929
951
|
}
|
|
930
952
|
}
|
|
931
953
|
}
|
|
@@ -933,14 +955,14 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
933
955
|
},
|
|
934
956
|
[c]
|
|
935
957
|
);
|
|
936
|
-
return { getErrorCode:
|
|
958
|
+
return { getErrorCode: x((f) => {
|
|
937
959
|
const { response: i } = f || {};
|
|
938
960
|
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";
|
|
939
961
|
}, []), printError: u };
|
|
940
962
|
};
|
|
941
963
|
export {
|
|
942
|
-
|
|
943
|
-
|
|
964
|
+
ve as ChatClient,
|
|
965
|
+
pe as ChatContext,
|
|
944
966
|
nt as ChatProvider,
|
|
945
967
|
qe as GTMSendPageView,
|
|
946
968
|
Be as InitializeAxiosConfig,
|
package/dist/main.umd.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(function(g,
|
|
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 fe=(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};class X{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);a.type==="ready"&&(this._ready=!0),this.onEvent?.(a)}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(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 G={exports:{}},M={};var Z;function he(){if(Z)return M;Z=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 q;function pe(){return q||(q=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 O:return"Suspense";case S:return"SuspenseList";case W: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 j:return"Portal";case C:return n.displayName||"Context";case T:return(n._context.displayName||"Context")+".Consumer";case A: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 w=p.error,R=typeof Symbol=="function"&&Symbol.toStringTag&&n[Symbol.toStringTag]||n.constructor.name||"Object";return w.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=N.A;return n===null?null:n.getOwner()}function a(){return Error("react-stack-top-frame")}function c(n){if(ae.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 w(){ie||(ie=!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))}w.isReactWarning=!0,Object.defineProperty(n,"key",{get:w,configurable:!0})}function u(){var n=e(this.type);return ce[n]||(ce[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,w,R,Q,B){var b=w.ref;return n={$$typeof:_,type:n,key:p,props:w,_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:Q}),Object.defineProperty(n,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:B}),Object.freeze&&(Object.freeze(n.props),Object.freeze(n)),n}function i(n,p,w,R,Q,B){var b=p.children;if(b!==void 0)if(R)if($e(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(ae.call(p,"key")){b=e(n);var D=Object.keys(p).filter(function(et){return et!=="key"});R=0<D.length?"{key: someKey, "+D.join(": ..., ")+": ...}":"{key: someKey}",de[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} />`,C,b,x,b),fe[b+C]=!0)}if(b=null,_!==void 0&&(r(_),b=""+_),c(p)&&(r(p.key),b=""+p.key),"key"in p){_={};for(var ee in p)ee!=="key"&&(_[ee]=p[ee])}else _=p;return b&&d(_,typeof n=="function"?n.displayName||n.name||"Unknown":n),h(n,b,_,o(),K,$)}function m(n){w(n)?n._store&&(n._store.validated=1):typeof n=="object"&&n!==null&&n.$$typeof===S&&(n._payload.status==="fulfilled"?w(n._payload.value)&&n._payload.value._store&&(n._payload.value._store.validated=1):n._store&&(n._store.validated=1))}function w(n){return typeof n=="object"&&n!==null&&n.$$typeof===P}var E=u,P=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),I=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),R=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),j=Symbol.for("react.suspense"),H=Symbol.for("react.suspense_list"),M=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),X=Symbol.for("react.activity"),Z=Symbol.for("react.client.reference"),Y=E.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,G=Object.prototype.hasOwnProperty,q=Array.isArray,z=console.createTask?console.createTask:function(){return null};E={react_stack_bottom_frame:function(n){return n()}};var V,Q={},J=E.react_stack_bottom_frame.bind(E,a)(),de=z(s(a)),fe={};F.Fragment=I,F.jsx=function(n,p,_){var C=1e4>Y.recentlyCreatedOwnerStacks++;return i(n,p,_,!1,C?Error("react-stack-top-frame"):J,C?z(s(n)):de)},F.jsxs=function(n,p,_){var C=1e4>Y.recentlyCreatedOwnerStacks++;return i(n,p,_,!0,C?Error("react-stack-top-frame"):J,C?z(s(n)):de)}})()),F}var oe;function me(){return oe||(oe=1,process.env.NODE_ENV==="production"?U.exports=pe():U.exports=ge()),U.exports}var O=me();const ye=({IMaskMixin:e,...t})=>{const r=u.useMemo(()=>e(({TextField:s,...o})=>O.jsx(s,{...o})),[e]);return O.jsx(r,{...t})},A=u.createContext({}),Ee=({children:e,apiURL:t,libraries:r,localStorageKeys:s})=>{const o=u.useMemo(()=>({apiURL:t,libraries:r,localStorageKeys:s}),[t,r,s]);return O.jsx(A.Provider,{value:o,children:e})},ve=({data:e,...t})=>{const{libraries:r}=u.useContext(A),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:l}=c(),{sendEvent:h}=a();return u.useEffect(()=>{h({event:"pageView",pathname:l,...e})},[e,l,h]),O.jsx(d,{})},D=(()=>{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}})(),we="user",_e=({tokenTypeKey:e="tokenType",tokenKey:t="accessToken",postContentType:r="application/json",...s})=>{const{apiURL:o=s.apiURL,libraries:a,localStorageKeys:c}=u.useContext(A),d=s?.userLocalStorageKey||c?.user||we,l=s?.axios||a?.axios;if(!l)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!l?.defaults||D)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,w=i?.[t]?i[t]:null,E=h?`${m} ${w}`:null;E&&(l.defaults.headers.common.Authorization=E)}return l.defaults.baseURL=o,l.defaults.headers.post["Content-Type"]=r,null},Re=({language:e,...t})=>{const{libraries:r}=u.useContext(A),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 u.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}=u.useContext(A),o=r?.i18||s?.i18,{i18next:a,initReactI18next:c,languageDetector:d}=o||{};if(D)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",l=>{document.documentElement.setAttribute("lang",l)})),null},be=({dsn:e,integrations:t,tracesSampleRate:r,replaysSessionSampleRate:s,replaysOnErrorSampleRate:o,tracePropagationTargets:a,ignoreErrors:c,debug:d,environment:l,release:h,...i})=>{const{libraries:m}=u.useContext(A),w=i?.sentry||m?.sentry,E=i?.reactRouter||m?.reactRouter;if(!w)throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!E)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(w.isInitialized())return null;const{createRoutesFromChildren:P,matchRoutes:k,useLocation:I,useNavigationType:y}=E;return(d||process.env.NODE_ENV==="prod"||process.env.NODE_ENV==="production")&&w.init({debug:d,dsn:e,environment:l||"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:[w.reactRouterV6BrowserTracingIntegration({createRoutesFromChildren:P,matchRoutes:k,useEffect:u.useEffect,useLocation:I,useNavigationType:y}),...t||[]],release:h,replaysOnErrorSampleRate:o||1,replaysSessionSampleRate:s||.1,tracePropagationTargets:a,tracesSampleRate:r||1}),null},Te=()=>(u.useEffect(()=>{if(D)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),se=new WeakMap,Se="user",Ae=({Fallback:e,isLogged:t,loginPath:r="/login",redirect401Path:s="/login",...o})=>{const{libraries:a,localStorageKeys:c}=u.useContext(A),d=o?.reactRouter||a?.reactRouter,l=o?.axios||a?.axios,h=o?.localStorageKey||c?.user||Se;if(!d)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");const[i,m]=u.useState(null),{useLocation:w,Navigate:E,Outlet:P}=d,k=w(),I=typeof t=="function"?t():!!t,y=typeof I=="boolean"?I:I?.isLogged;return u.useEffect(()=>{se.has(l)||(se.set(l,!0),l.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&&(l.defaults.headers.common.Authorization=null,typeof window<"u"&&window.localStorage&&localStorage.removeItem(h)),m(s)),Promise.reject(f))))},[l,h,s]),y&&!i?O.jsx(u.Suspense,{fallback:e,children:k.state?.from?.state&&k.state?.from?.pathname===r?O.jsx(E,{to:k.state.from.state.from.pathname+k.state.from.state.from.search,replace:!0}):O.jsx(P,{})}):O.jsx(E,{to:r+k.search,state:{from:k},replace:!0})},je=e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),ke=e=>{const t=e.split(/[/\\]/).pop()||"";return t.substring(0,t.lastIndexOf("."))},Pe=e=>{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("");return s.charAt(0).toLowerCase()+s.slice(1)},Ie=e=>(e.split("/").pop()||e).replace(/\.json$/,"").replace(/^openapi\./,""),Oe=(e,t,r,s)=>{const o=Pe(t),a=je(r),c=`${o}${a}`;return e&&typeof e=="object"&&"operationId"in e&&s?.includes(String(e.operationId))?`${c}AsQuery`:c},Ne=(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},xe=e=>(Array.isArray(e)?e:[e]).reduce((r,s)=>{const{output:o,useInfiniteIds:a,useQueryIds:c,input:d="./openapi.json",customAxiosInstancePath:l,overrideApiName:h}=s||{},i=h||Ie(d),m=l||"./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:Ne(a,c)},header:w=>["Generated by orval 🍺",...w.title?[w.title]:[],...w.description?[w.description]:[]],mutator:{name:ke(m),path:m},operationName:(w,E,P)=>Oe(w,E,P,c),query:{useQuery:!0}},schemas:o?.schemas||`src/api/${i}/model`,target:o?.target||`src/api/${i}/services/api.ts`,...o}}}},{}),Le="user",Fe=e=>{const t=e.startsWith("https")?"wss":"ws",r=e.replace(/^https?:\/\//,"");return`${t}://${r}/v2/threads/ws`},De=e=>{try{const t=localStorage.getItem(e);return t?JSON.parse(t)?.accessToken??null:null}catch{return null}},B=u.createContext(null),Me=({children:e,...t})=>{const[r,s]=u.useState(!1),[o,a]=u.useState(!1),{apiURL:c,localStorageKeys:d}=u.useContext(A),{reconnect:l=!0,enabled:h=!0,url:i,token:m}=t,w=d?.user||Le,E=u.useRef(null),P=u.useRef(t);P.current=t,u.useEffect(()=>{if(!h||E.current?.connected)return;const v=i||(c?Fe(c):null);if(!v)return;const j=()=>m??De(w),H=S=>{const{onError:X,onReady:Z,onNewMessage:Y,onNewMessageNotification:G,onPresence:q,onJoinedThread:z,onLeftThread:V,onMarkedRead:Q,onThreadsList:J}=P.current||{};switch(S.type){case"ready":a(!0),Z?.(S);break;case"new_message":Y?.(S);break;case"new_message_notification":G?.(S);break;case"presence":q?.(S);break;case"error":X?.(S);break;case"joined_thread":z?.(S);break;case"left_thread":V?.(S);break;case"marked_read":Q?.(S);break;case"threads_list":J?.(S);break}},M=new te({getToken:j,onConnectionChange:S=>{s(S),S||a(!1)},onEvent:H,reconnect:l,url:v});return E.current=M,M.connect(),()=>{M.disconnect(),E.current=null}},[h,i,m,c,l,w]);const k=u.useCallback(v=>{E.current?.joinThread(v)},[]),I=u.useCallback(v=>{E.current?.leaveThread(v)},[]),y=u.useCallback((v,j)=>{E.current?.sendMessage(v,j)},[]),f=u.useCallback(v=>{E.current?.markRead(v)},[]),T=u.useCallback((v,j)=>{E.current?.listThreads(v,j)},[]),R={isConnected:r,isReady:o,joinThread:k,leaveThread:I,listThreads:T,markRead:f,sendMessage:y};return O.jsx(B.Provider,{value:R,children:e})},Ye=e=>e&&typeof e=="function",ze=e=>e&&typeof e=="function",Ue=({children:e,defaultQueriesOptions:t,defaultMutationsOptions:r,...s})=>{const{libraries:o}=u.useContext(A),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(!Ye(c))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!ze(a))throw new Error("Provided QueryClient dependencies are not valid.");const d=new a({defaultOptions:{mutations:{...r},queries:{getNextPageParam:(l,h,i)=>l.length+(i||0),refetchOnWindowFocus:!1,retry:3,...t}}});return O.jsx(c,{client:d,children:e})},ae=({library:e,date:t,format:r="ll"})=>e(t).format(r),ie=(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}`},ce=e=>!e||typeof e!="string"?"":e.replace(/_/g," ").toLowerCase().split(" ").map(r=>r.length>0?r.charAt(0).toUpperCase()+r.slice(1):r).join(" "),We=e=>e?.startsWith("/")?e?.startsWith("/files")?e:`/files${e}`:e?.startsWith("files")?`/${e}`:`/files/${e}`,Ge=({path:e,size:t,apiURL:r})=>{if(!e)return"";const s=We(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},Ve=e=>{const{apiURL:t,libraries:r}=u.useContext(A),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 ae({date:c,format:d,library:s})},distanceAdapter:ie,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:Ge({apiURL:t,path:c,size:d})},worksiteNameAdapter:ce}},Qe=e=>{const{libraries:t,localStorageKeys:r}=u.useContext(A),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=u.useCallback(({tokenType:d,accessToken:l})=>{s.defaults.headers.common.Authorization=`${d} ${l}`},[s.defaults.headers.common]),c=()=>{s.defaults.headers.common.Authorization=null};return u.useEffect(()=>{if(D)return;const d=({newValue:l,key:h})=>{if(h===o&&l)try{const{accessToken:i,tokenType:m}=JSON.parse(l);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}},Je=()=>{const e=u.useContext(B);if(!e)throw new Error("useChat must be used within ChatProvider");return e},W=(e,t)=>t==="short"?e.split("-")[0]:e,Ke=(e,t="full")=>{const[r,s]=u.useState(()=>{const o=e?.language||navigator.language;return e&&"isInitialized"in e&&e.isInitialized,W(o,t)});return u.useEffect(()=>{e&&"isInitialized"in e&&e.isInitialized&&e.language&&s(W(e.language,t));const o=a=>{s(W(a,t))};return e?.on?.("languageChanged",o),()=>{e?.off?.("languageChanged",o)}},[e,t]),r},Be="tracktor.filter",He={getFilter:()=>{},getFilters:()=>({}),handleFilter:()=>()=>{},setFilter:()=>{}},le=e=>{try{return JSON.parse(e)}catch{return e}},ue=(e,t,r)=>`${r}_${e}=>${t}`,Xe=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},{}),Ze=e=>{const{libraries:t,localStorageKeys:r}=u.useContext(A),s=e?.reactRouter||t?.reactRouter,{pathname:o}=s?.useLocation?.()??{pathname:"/"},[a,c]=s?.useSearchParams?.()??[new URLSearchParams,()=>{}],[d,l]=u.useState({}),h=r?.filter||Be,i=e?.syncWithUrl===void 0?!0:e?.syncWithUrl,m=e?.persistToLocalStorage===void 0?!0:e?.persistToLocalStorage;if(D)return He;if(!s)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter.");const w=()=>Object.keys(localStorage).filter(y=>y.startsWith(h)&&y.endsWith(e?.pathname||o)),E=(y,f,T=!0)=>{const R=ue(y,e?.pathname||o,h);if(!f||Array.isArray(f)&&!f.length){i?(a.delete(y),c(a)):l(v=>{const j={...v};return delete j[y],j}),m&&localStorage.removeItem(R);return}m&&T&&f&&localStorage.setItem(R,JSON.stringify({...a,[y]:f})),i&&f?(a.set(y,JSON.stringify(f)),c(a)):!i&&f&&l(v=>({...v,[y]:f}))};return{getFilter:(y,f)=>{if(i){const T=a.get(y);if(T)return le(T)}else{const T=d[y];if(T!==void 0)return T}if(m){const T=ue(y,e?.pathname||o,h),R=localStorage.getItem(T);if(R)try{const v=JSON.parse(R)[y];return!i&&v!==void 0&&l(j=>({...j,[y]:v})),v}catch{}}return f},getFilters:()=>{const y=m?Xe(w()):{};if(i){const f=Array.from(a.entries()).reduce((T,[R,v])=>(T[R]=le(v),T),{});return{...y,...f}}return{...y,...d}},handleFilter:(y,f)=>(T,R)=>{if(R||Array.isArray(R)&&R.length===0){const v=f||"value",j=typeof R=="object"&&v in R?R[v]:R;E(y,j);return}E(y,void 0)},setFilter:E}},qe=({data:e,fetchNextPage:t,isFetchingNextPage:r,isInitialLoading:s,isLoading:o,enabled:a=!0})=>{const c=u.useCallback(async l=>{r||!a||await t({pageParam:l?.pageParam||l.visibleRowsCount})},[a,t,r]),d=u.useMemo(()=>{if(e)return e.pages.reduce((l,h)=>[...l,...h],[])},[e]);return{fetchNextPageOnRowsScrollEnd:c,isLoading:r||o,loadingVariant:s?"skeleton":"linear-progress",rows:d}},$e=e=>{const{libraries:t}=u.useContext(A),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=u.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:w}=m[0];if(typeof w=="string")return String(w)}}}return h instanceof Error?h.message:c},[c]);return{getErrorCode:u.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=te,g.ChatContext=B,g.ChatProvider=Me,g.GTMSendPageView=ve,g.InitializeAxiosConfig=_e,g.InitializeDaysJSConfig=Re,g.InitializeI18nConfig=Ce,g.InitializeSentryConfig=be,g.InjectDependenciesContext=A,g.InjectDependenciesProvider=Ee,g.MaskTextField=ye,g.PreloadErrorHandler=Te,g.QueryClientProviderWithConfig=Ue,g.RequireAuth=Ae,g.axiosCustomInstance=he,g.dateAdapter=ae,g.distanceAdapter=ie,g.getOrvalConfig=xe,g.useAdapter=Ve,g.useAuth=Qe,g.useChat=Je,g.useCurrentLanguage=Ke,g.useFilters=Ze,g.useInfiniteDataGrid=qe,g.useResponseError=$e,g.worksiteNameAdapter=ce,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}));
|
|
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(),Q,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"),A=Symbol.for("react.forward_ref"),O=Symbol.for("react.suspense"),S=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),W=Symbol.for("react.activity"),x=Symbol.for("react.client.reference"),N=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>N.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>N.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"?G.exports=he():G.exports=pe()),G.exports}var I=ge();const me=({IMaskMixin:e,...t})=>{const r=l.useMemo(()=>e(({TextField:s,...o})=>I.jsx(s,{...o})),[e]);return I.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 I.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]),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}})(),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?I.jsx(l.Suspense,{fallback:e,children:j.state?.from?.state&&j.state?.from?.pathname===r?I.jsx(v,{to:j.state.from.state.from.pathname+j.state.from.state.from.search,replace:!0}):I.jsx(_,{})}):I.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}},J=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||_.current?.connected)return;const S=s||(m?Le(m):null);if(!S)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(N=>N+1);break;case"marked_read":i(N=>Math.max(0,N-1));break}for(const N of j.current)N(x)},W=new X({getToken:L,onConnectionChange:x=>{c(x),x||u(!1)},onEvent:U,reconnect:t,url:S});return _.current=W,W.connect(),()=>{W.disconnect(),_.current=null}},[r,s,o,m,t,v]);const P=l.useCallback(S=>{_.current?.joinThread(S)},[]),y=l.useCallback(S=>{_.current?.leaveThread(S)},[]),f=l.useCallback((S,L)=>{_.current?.sendMessage(S,L)},[]),T=l.useCallback(S=>{_.current?.markRead(S)},[]),C=l.useCallback((S,L)=>{_.current?.listThreads(S,L)},[]),O={addListener:l.useCallback(S=>(j.current.add(S),()=>{j.current.delete(S)}),[]),isConnected:a,isReady:d,joinThread:P,leaveThread:y,listThreads:C,markRead:T,sendMessage:f,unreadCount:h};return I.jsx(J.Provider,{value:O,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 I.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(J);if(!t)throw new Error("useChat must be used within ChatProvider");const{addListener: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},V=(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,V(o,t)});return l.useEffect(()=>{e&&"isInitialized"in e&&e.isInitialized&&e.language&&s(V(e.language,t));const o=a=>{s(V(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(A=>{const O={...A};return delete O[y],O}),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(A=>({...A,[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 A=JSON.parse(C)[y];return!i&&A!==void 0&&u(O=>({...O,[y]:A})),A}catch{}}return f},getFilters:()=>{const y=m?He(E()):{};if(i){const f=Array.from(a.entries()).reduce((T,[C,A])=>(T[C]=oe(A),T),{});return{...y,...f}}return{...y,...d}},handleFilter:(y,f)=>(T,C)=>{if(C||Array.isArray(C)&&C.length===0){const A=f||"value",O=typeof C=="object"&&A in C?C[A]:C;v(y,O);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=J,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"})}));
|