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