@tracktor/shared-module 2.20.1 → 2.21.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.
@@ -0,0 +1,10 @@
1
+ /**
2
+ * ServiceWorkerCleaner unregisters all existing service workers on mount.
3
+ *
4
+ * Use this component when a PWA has been disabled but users may still
5
+ * have stale service workers registered in their browsers.
6
+ *
7
+ * Renders nothing (returns null).
8
+ */
9
+ declare const ServiceWorkerCleaner: () => null;
10
+ export default ServiceWorkerCleaner;
package/dist/main.d.ts CHANGED
@@ -15,6 +15,8 @@ export * from './components/Utils/PreloadErrorHandler';
15
15
  export { default as PreloadErrorHandler } from './components/Utils/PreloadErrorHandler';
16
16
  export * from './components/Utils/RequireAuth';
17
17
  export { default as RequireAuth } from './components/Utils/RequireAuth';
18
+ export * from './components/Utils/ServiceWorkerCleaner';
19
+ export { default as ServiceWorkerCleaner } from './components/Utils/ServiceWorkerCleaner';
18
20
  export * from './components/Utils/UpdateNotifier';
19
21
  export { default as UpdateNotifier } from './components/Utils/UpdateNotifier';
20
22
  export * from './config/orval';
package/dist/main.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import Z from "axios";
2
- import fe, { useMemo as G, createContext as pe, useContext as P, useEffect as j, useState as W, Suspense as ge, useRef as me, useCallback as O } from "react";
3
- const We = (e, r) => {
4
- const o = Z.CancelToken.source(), a = Z({
2
+ import fe, { useMemo as G, createContext as pe, useContext as P, useEffect as S, useState as Y, Suspense as ge, useRef as me, useCallback as O } from "react";
3
+ const ze = (e, r) => {
4
+ const a = Z.CancelToken.source(), o = Z({
5
5
  ...e,
6
6
  ...r,
7
- cancelToken: o.token
7
+ cancelToken: a.token
8
8
  }).then(({ data: n }) => n);
9
- return a.cancel = () => {
10
- o.cancel("Query was cancelled");
11
- }, a;
9
+ return o.cancel = () => {
10
+ a.cancel("Query was cancelled");
11
+ }, o;
12
12
  };
13
13
  var D = { exports: {} }, L = {};
14
14
  var ee;
@@ -16,7 +16,7 @@ function he() {
16
16
  if (ee) return L;
17
17
  ee = 1;
18
18
  var e = /* @__PURE__ */ Symbol.for("react.transitional.element"), r = /* @__PURE__ */ Symbol.for("react.fragment");
19
- function o(a, n, s) {
19
+ function a(o, n, s) {
20
20
  var c = null;
21
21
  if (s !== void 0 && (c = "" + s), n.key !== void 0 && (c = "" + n.key), "key" in n) {
22
22
  s = {};
@@ -25,13 +25,13 @@ function he() {
25
25
  } else s = n;
26
26
  return n = s.ref, {
27
27
  $$typeof: e,
28
- type: a,
28
+ type: o,
29
29
  key: c,
30
30
  ref: n !== void 0 ? n : null,
31
31
  props: s
32
32
  };
33
33
  }
34
- return L.Fragment = r, L.jsx = o, L.jsxs = o, L;
34
+ return L.Fragment = r, L.jsx = a, L.jsxs = a, L;
35
35
  }
36
36
  var N = {};
37
37
  var te;
@@ -45,7 +45,7 @@ function ye() {
45
45
  switch (t) {
46
46
  case T:
47
47
  return "Fragment";
48
- case f:
48
+ case d:
49
49
  return "Profiler";
50
50
  case h:
51
51
  return "StrictMode";
@@ -60,7 +60,7 @@ function ye() {
60
60
  switch (typeof t.tag == "number" && console.error(
61
61
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
62
62
  ), t.$$typeof) {
63
- case A:
63
+ case j:
64
64
  return "Portal";
65
65
  case R:
66
66
  return t.displayName || "Context";
@@ -83,7 +83,7 @@ function ye() {
83
83
  function r(t) {
84
84
  return "" + t;
85
85
  }
86
- function o(t) {
86
+ function a(t) {
87
87
  try {
88
88
  r(t);
89
89
  var p = !1;
@@ -100,7 +100,7 @@ function ye() {
100
100
  ), r(t);
101
101
  }
102
102
  }
103
- function a(t) {
103
+ function o(t) {
104
104
  if (t === T) return "<>";
105
105
  if (typeof t == "object" && t !== null && t.$$typeof === z)
106
106
  return "<...>";
@@ -143,7 +143,7 @@ function ye() {
143
143
  "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
144
  )), t = this.props.ref, t !== void 0 ? t : null;
145
145
  }
146
- function d(t, p, y, w, $, V) {
146
+ function f(t, p, y, w, $, V) {
147
147
  var E = y.ref;
148
148
  return t = {
149
149
  $$typeof: k,
@@ -207,7 +207,7 @@ React keys must be passed directly to JSX without using spread:
207
207
  E
208
208
  ), X[E + w] = !0);
209
209
  }
210
- if (E = null, y !== void 0 && (o(y), E = "" + y), c(p) && (o(p.key), E = "" + p.key), "key" in p) {
210
+ if (E = null, y !== void 0 && (a(y), E = "" + y), c(p) && (a(p.key), E = "" + p.key), "key" in p) {
211
211
  y = {};
212
212
  for (var M in p)
213
213
  M !== "key" && (y[M] = p[M]);
@@ -215,7 +215,7 @@ React keys must be passed directly to JSX without using spread:
215
215
  return E && u(
216
216
  y,
217
217
  typeof t == "function" ? t.displayName || t.name || "Unknown" : t
218
- ), d(
218
+ ), f(
219
219
  t,
220
220
  E,
221
221
  y,
@@ -230,7 +230,7 @@ React keys must be passed directly to JSX without using spread:
230
230
  function g(t) {
231
231
  return typeof t == "object" && t !== null && t.$$typeof === k;
232
232
  }
233
- var v = fe, k = /* @__PURE__ */ Symbol.for("react.transitional.element"), A = /* @__PURE__ */ Symbol.for("react.portal"), T = /* @__PURE__ */ Symbol.for("react.fragment"), h = /* @__PURE__ */ Symbol.for("react.strict_mode"), f = /* @__PURE__ */ Symbol.for("react.profiler"), b = /* @__PURE__ */ Symbol.for("react.consumer"), R = /* @__PURE__ */ Symbol.for("react.context"), _ = /* @__PURE__ */ Symbol.for("react.forward_ref"), I = /* @__PURE__ */ Symbol.for("react.suspense"), ie = /* @__PURE__ */ Symbol.for("react.suspense_list"), se = /* @__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, J = Object.prototype.hasOwnProperty, ue = Array.isArray, Q = console.createTask ? console.createTask : function() {
233
+ var v = fe, k = /* @__PURE__ */ Symbol.for("react.transitional.element"), j = /* @__PURE__ */ Symbol.for("react.portal"), T = /* @__PURE__ */ Symbol.for("react.fragment"), h = /* @__PURE__ */ Symbol.for("react.strict_mode"), d = /* @__PURE__ */ Symbol.for("react.profiler"), b = /* @__PURE__ */ Symbol.for("react.consumer"), R = /* @__PURE__ */ Symbol.for("react.context"), _ = /* @__PURE__ */ Symbol.for("react.forward_ref"), I = /* @__PURE__ */ Symbol.for("react.suspense"), ie = /* @__PURE__ */ Symbol.for("react.suspense_list"), se = /* @__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, J = Object.prototype.hasOwnProperty, ue = Array.isArray, Q = console.createTask ? console.createTask : function() {
234
234
  return null;
235
235
  };
236
236
  v = {
@@ -241,7 +241,7 @@ React keys must be passed directly to JSX without using spread:
241
241
  var q, K = {}, H = v.react_stack_bottom_frame.bind(
242
242
  v,
243
243
  s
244
- )(), B = Q(a(s)), X = {};
244
+ )(), B = Q(o(s)), X = {};
245
245
  N.Fragment = T, N.jsx = function(t, p, y) {
246
246
  var w = 1e4 > U.recentlyCreatedOwnerStacks++;
247
247
  return i(
@@ -250,7 +250,7 @@ React keys must be passed directly to JSX without using spread:
250
250
  y,
251
251
  !1,
252
252
  w ? Error("react-stack-top-frame") : H,
253
- w ? Q(a(t)) : B
253
+ w ? Q(o(t)) : B
254
254
  );
255
255
  }, N.jsxs = function(t, p, y) {
256
256
  var w = 1e4 > U.recentlyCreatedOwnerStacks++;
@@ -260,7 +260,7 @@ React keys must be passed directly to JSX without using spread:
260
260
  y,
261
261
  !0,
262
262
  w ? Error("react-stack-top-frame") : H,
263
- w ? Q(a(t)) : B
263
+ w ? Q(o(t)) : B
264
264
  );
265
265
  };
266
266
  })()), N;
@@ -270,39 +270,39 @@ function ve() {
270
270
  return re || (re = 1, process.env.NODE_ENV === "production" ? D.exports = he() : D.exports = ye()), D.exports;
271
271
  }
272
272
  var C = ve();
273
- const ze = ({ IMaskMixin: e, ...r }) => {
274
- const o = G(
273
+ const Ue = ({ IMaskMixin: e, ...r }) => {
274
+ const a = G(
275
275
  // eslint-disable-next-line react/jsx-props-no-spreading
276
- () => e(({ TextField: a, ...n }) => /* @__PURE__ */ C.jsx(a, { ...n })),
276
+ () => e(({ TextField: o, ...n }) => /* @__PURE__ */ C.jsx(o, { ...n })),
277
277
  [e]
278
278
  );
279
- return /* @__PURE__ */ C.jsx(o, { ...r });
280
- }, S = pe({}), Ue = ({ children: e, apiURL: r, libraries: o, localStorageKeys: a }) => {
279
+ return /* @__PURE__ */ C.jsx(a, { ...r });
280
+ }, A = pe({}), Qe = ({ children: e, apiURL: r, libraries: a, localStorageKeys: o }) => {
281
281
  const n = G(
282
282
  () => ({
283
283
  apiURL: r,
284
- libraries: o,
285
- localStorageKeys: a
284
+ libraries: a,
285
+ localStorageKeys: o
286
286
  }),
287
- [r, o, a]
287
+ [r, a, o]
288
288
  );
289
- return /* @__PURE__ */ C.jsx(S.Provider, { value: n, children: e });
290
- }, Qe = ({ data: e, ...r }) => {
291
- const { libraries: o } = P(S), a = r?.reactRouter || o?.reactRouter, n = r?.gtm || o?.gtm;
292
- if (!a)
289
+ return /* @__PURE__ */ C.jsx(A.Provider, { value: n, children: e });
290
+ }, Ve = ({ data: e, ...r }) => {
291
+ const { libraries: a } = P(A), o = r?.reactRouter || a?.reactRouter, n = r?.gtm || a?.gtm;
292
+ if (!o)
293
293
  throw new Error(
294
294
  "React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView."
295
295
  );
296
296
  if (!n)
297
297
  throw new Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");
298
- const { useGoogleTagManager: s } = n, { useLocation: c, Outlet: u } = a, { pathname: l } = c(), { sendEvent: d } = s();
299
- return j(() => {
300
- d({
298
+ const { useGoogleTagManager: s } = n, { useLocation: c, Outlet: u } = o, { pathname: l } = c(), { sendEvent: f } = s();
299
+ return S(() => {
300
+ f({
301
301
  event: "pageView",
302
302
  pathname: l,
303
303
  ...e
304
304
  });
305
- }, [e, l, d]), /* @__PURE__ */ C.jsx(u, {});
305
+ }, [e, l, f]), /* @__PURE__ */ C.jsx(u, {});
306
306
  }, F = (() => {
307
307
  try {
308
308
  return typeof global == "object" && global !== null && ("HermesInternal" in global || // Hermes JS engine
@@ -311,38 +311,38 @@ const ze = ({ IMaskMixin: e, ...r }) => {
311
311
  } catch {
312
312
  return !1;
313
313
  }
314
- })(), we = "user", Ve = ({
314
+ })(), we = "user", Me = ({
315
315
  tokenTypeKey: e = "tokenType",
316
316
  tokenKey: r = "accessToken",
317
- postContentType: o = "application/json",
318
- ...a
317
+ postContentType: a = "application/json",
318
+ ...o
319
319
  }) => {
320
- const { apiURL: n = a.apiURL, libraries: s, localStorageKeys: c } = P(S), u = a?.userLocalStorageKey || c?.user || we, l = a?.axios || s?.axios;
320
+ const { apiURL: n = o.apiURL, libraries: s, localStorageKeys: c } = P(A), u = o?.userLocalStorageKey || c?.user || we, l = o?.axios || s?.axios;
321
321
  if (!l)
322
322
  throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
323
323
  if (!l?.defaults || F)
324
324
  return null;
325
325
  if (typeof window < "u" && window.localStorage) {
326
- const d = localStorage.getItem(u), i = d ? JSON.parse(d) : null, m = i?.[e] ? i[e] : null, g = i?.[r] ? i[r] : null, v = d ? `${m} ${g}` : null;
326
+ const f = localStorage.getItem(u), i = f ? JSON.parse(f) : null, m = i?.[e] ? i[e] : null, g = i?.[r] ? i[r] : null, v = f ? `${m} ${g}` : null;
327
327
  v && (l.defaults.headers.common.Authorization = v);
328
328
  }
329
- return l.defaults.baseURL = n, l.defaults.headers.post["Content-Type"] = o, null;
330
- }, Me = ({ language: e, ...r }) => {
331
- const { libraries: o } = P(S), a = r?.dayjs || o?.dayjs, n = r?.plugin || o?.dayjsPlugin;
332
- if (!a)
329
+ return l.defaults.baseURL = n, l.defaults.headers.post["Content-Type"] = a, null;
330
+ }, Ge = ({ language: e, ...r }) => {
331
+ const { libraries: a } = P(A), o = r?.dayjs || a?.dayjs, n = r?.plugin || a?.dayjsPlugin;
332
+ if (!o)
333
333
  throw new Error(
334
334
  "Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig."
335
335
  );
336
- return j(() => {
336
+ return S(() => {
337
337
  (async () => {
338
338
  const c = e || navigator.language?.slice(0, 2) || "en";
339
339
  n && n.forEach((u) => {
340
- u && a.extend(u);
341
- }), await import("dayjs/locale/en"), await import("dayjs/locale/fr"), a.locale(c);
340
+ u && o.extend(u);
341
+ }), await import("dayjs/locale/en"), await import("dayjs/locale/fr"), o.locale(c);
342
342
  })().then();
343
- }, [a, n, e]), null;
344
- }, Ge = ({ debug: e, resources: r, ...o }) => {
345
- const { libraries: a } = P(S), n = o?.i18 || a?.i18, { i18next: s, initReactI18next: c, languageDetector: u } = n || {};
343
+ }, [o, n, e]), null;
344
+ }, Je = ({ debug: e, resources: r, ...a }) => {
345
+ const { libraries: o } = P(A), n = a?.i18 || o?.i18, { i18next: s, initReactI18next: c, languageDetector: u } = n || {};
346
346
  if (F)
347
347
  return null;
348
348
  if (!n)
@@ -365,27 +365,27 @@ const ze = ({ IMaskMixin: e, ...r }) => {
365
365
  }), s.on("languageChanged", (l) => {
366
366
  document.documentElement.setAttribute("lang", l);
367
367
  })), null;
368
- }, Je = ({
368
+ }, qe = ({
369
369
  dsn: e,
370
370
  integrations: r,
371
- tracesSampleRate: o,
372
- replaysSessionSampleRate: a,
371
+ tracesSampleRate: a,
372
+ replaysSessionSampleRate: o,
373
373
  replaysOnErrorSampleRate: n,
374
374
  tracePropagationTargets: s,
375
375
  ignoreErrors: c,
376
376
  debug: u,
377
377
  environment: l,
378
- release: d,
378
+ release: f,
379
379
  ...i
380
380
  }) => {
381
- const { libraries: m } = P(S), g = i?.sentry || m?.sentry, v = i?.reactRouter || m?.reactRouter;
381
+ const { libraries: m } = P(A), g = i?.sentry || m?.sentry, v = i?.reactRouter || m?.reactRouter;
382
382
  if (!g)
383
383
  throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
384
384
  if (!v)
385
385
  throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
386
386
  if (g.isInitialized())
387
387
  return null;
388
- const { createRoutesFromChildren: k, matchRoutes: A, useLocation: T, useNavigationType: h } = v;
388
+ const { createRoutesFromChildren: k, matchRoutes: j, useLocation: T, useNavigationType: h } = v;
389
389
  return (u || process.env.NODE_ENV === "prod" || process.env.NODE_ENV === "production") && g.init({
390
390
  debug: u,
391
391
  dsn: e,
@@ -402,20 +402,20 @@ const ze = ({ IMaskMixin: e, ...r }) => {
402
402
  integrations: [
403
403
  g.reactRouterV6BrowserTracingIntegration({
404
404
  createRoutesFromChildren: k,
405
- matchRoutes: A,
406
- useEffect: j,
405
+ matchRoutes: j,
406
+ useEffect: S,
407
407
  useLocation: T,
408
408
  useNavigationType: h
409
409
  }),
410
410
  ...r || []
411
411
  ],
412
- release: d,
412
+ release: f,
413
413
  replaysOnErrorSampleRate: n || 1,
414
- replaysSessionSampleRate: a || 0.1,
414
+ replaysSessionSampleRate: o || 0.1,
415
415
  tracePropagationTargets: s,
416
- tracesSampleRate: o || 1
416
+ tracesSampleRate: a || 1
417
417
  }), null;
418
- }, qe = () => (j(() => {
418
+ }, Ke = () => (S(() => {
419
419
  if (F)
420
420
  return;
421
421
  const e = (r) => {
@@ -427,18 +427,28 @@ const ze = ({ IMaskMixin: e, ...r }) => {
427
427
  return window.addEventListener("vite:preloadError", e), () => {
428
428
  window.removeEventListener("vite:preloadError", e);
429
429
  };
430
- }, []), null), ne = /* @__PURE__ */ new WeakMap(), Ee = "user", Ke = ({ Fallback: e, isLogged: r, loginPath: o = "/login", redirect401Path: a = "/login", ...n }) => {
431
- const { libraries: s, localStorageKeys: c } = P(S), u = n?.reactRouter || s?.reactRouter, l = n?.axios || s?.axios, d = n?.localStorageKey || c?.user || Ee;
430
+ }, []), null), ne = /* @__PURE__ */ new WeakMap(), Ee = "user", He = ({ Fallback: e, isLogged: r, loginPath: a = "/login", redirect401Path: o = "/login", ...n }) => {
431
+ const { libraries: s, localStorageKeys: c } = P(A), u = n?.reactRouter || s?.reactRouter, l = n?.axios || s?.axios, f = n?.localStorageKey || c?.user || Ee;
432
432
  if (!u)
433
433
  throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
434
- const [i, m] = W(null), { useLocation: g, Navigate: v, Outlet: k } = u, A = g(), T = typeof r == "function" ? r() : !!r, h = typeof T == "boolean" ? T : T?.isLogged;
435
- return j(() => {
434
+ const [i, m] = Y(null), { useLocation: g, Navigate: v, Outlet: k } = u, j = g(), T = typeof r == "function" ? r() : !!r, h = typeof T == "boolean" ? T : T?.isLogged;
435
+ return S(() => {
436
436
  ne.has(l) || (ne.set(l, !0), l.interceptors.response.use(
437
- (f) => f,
438
- (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(d)), m(a)), Promise.reject(f))
437
+ (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 && (l.defaults.headers.common.Authorization = null, typeof window < "u" && window.localStorage && localStorage.removeItem(f)), m(o)), Promise.reject(d))
439
439
  ));
440
- }, [l, d, a]), h && !i ? /* @__PURE__ */ C.jsx(ge, { fallback: e, children: A.state?.from?.state && A.state?.from?.pathname === o ? /* @__PURE__ */ C.jsx(v, { to: A.state.from.state.from.pathname + A.state.from.state.from.search, replace: !0 }) : /* @__PURE__ */ C.jsx(k, {}) }) : /* @__PURE__ */ C.jsx(v, { to: o + A.search, state: { from: A }, replace: !0 });
440
+ }, [l, f, o]), h && !i ? /* @__PURE__ */ C.jsx(ge, { fallback: e, children: j.state?.from?.state && j.state?.from?.pathname === a ? /* @__PURE__ */ C.jsx(v, { to: j.state.from.state.from.pathname + j.state.from.state.from.search, replace: !0 }) : /* @__PURE__ */ C.jsx(k, {}) }) : /* @__PURE__ */ C.jsx(v, { to: a + j.search, state: { from: j }, replace: !0 });
441
441
  }, Re = async () => {
442
+ if ("serviceWorker" in navigator)
443
+ try {
444
+ const e = await navigator.serviceWorker.getRegistrations();
445
+ await Promise.all(e.map((r) => r.unregister()));
446
+ } catch (e) {
447
+ console.error("Failed to unregister service workers:", e);
448
+ }
449
+ }, Be = () => (S(() => {
450
+ Re();
451
+ }, []), null), be = async () => {
442
452
  if ("caches" in window)
443
453
  try {
444
454
  const e = await caches.keys();
@@ -446,68 +456,76 @@ const ze = ({ IMaskMixin: e, ...r }) => {
446
456
  } catch (e) {
447
457
  console.error("Failed to clear caches:", e);
448
458
  }
449
- }, He = ({ autoUpdate: e, renderDialog: r, clearCachesOnReload: o }) => {
450
- const a = me(null), [n, s] = W(!1), c = O(() => {
451
- a.current && a.current.postMessage({ type: "SKIP_WAITING" }), o && localStorage.setItem("tracktor_clear_caches", "1"), window.location.reload();
452
- }, [o]);
453
- j(() => {
454
- localStorage.getItem("tracktor_clear_caches") === "1" && (localStorage.removeItem("tracktor_clear_caches"), Re().catch(console.error));
459
+ }, Xe = ({ autoUpdate: e, renderDialog: r, clearCachesOnReload: a }) => {
460
+ const o = me(null), [n, s] = Y(!1), c = O(() => {
461
+ if (o.current && o.current.postMessage({ type: "SKIP_WAITING" }), a)
462
+ try {
463
+ localStorage.setItem("tracktor_clear_caches", "1");
464
+ } catch {
465
+ }
466
+ window.location.reload();
467
+ }, [a]);
468
+ S(() => {
469
+ try {
470
+ localStorage.getItem("tracktor_clear_caches") === "1" && (localStorage.removeItem("tracktor_clear_caches"), be().catch(console.error));
471
+ } catch {
472
+ }
455
473
  }, []);
456
474
  const u = O(() => {
457
475
  window.confirm("A new version is available. The app will reload now.") && c();
458
476
  }, [c]);
459
- return j(() => {
477
+ return S(() => {
460
478
  if (!("serviceWorker" in navigator))
461
479
  return;
462
- let l, d;
480
+ let l, f;
463
481
  const i = (g) => {
464
- g && navigator.serviceWorker.controller && (a.current = g, s(!0));
482
+ g && navigator.serviceWorker.controller && (o.current = g, s(!0));
465
483
  }, m = () => {
466
484
  const g = l?.installing;
467
- g && (d = () => {
485
+ g && (f = () => {
468
486
  g.state === "installed" && i(g);
469
- }, g.addEventListener("statechange", d));
487
+ }, g.addEventListener("statechange", f));
470
488
  };
471
489
  return (async () => {
472
490
  l = await navigator.serviceWorker.getRegistration(), l && (i(l.waiting), l.addEventListener("updatefound", m));
473
491
  })().catch(console.error), () => {
474
- l?.removeEventListener("updatefound", m), d && l?.installing && l.installing.removeEventListener("statechange", d);
492
+ l?.removeEventListener("updatefound", m), f && l?.installing && l.installing.removeEventListener("statechange", f);
475
493
  };
476
- }, []), j(() => {
494
+ }, []), S(() => {
477
495
  n && e && c();
478
- }, [e, n, c]), j(() => {
496
+ }, [e, n, c]), S(() => {
479
497
  n && !e && !r && u();
480
498
  }, [r, u, n, e]), n && !e && r ? r(c) : null;
481
- }, be = (e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase(), _e = (e) => {
499
+ }, _e = (e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase(), Se = (e) => {
482
500
  const r = e.split(/[/\\]/).pop() || "";
483
501
  return r.substring(0, r.lastIndexOf("."));
484
- }, Se = (e) => {
485
- const a = e.split("/").filter((n) => n.length > 0).map((n) => n.replace(/\${([^}]*)}/g, "$1").split(/[_-]/).map((l) => l.charAt(0).toUpperCase() + l.slice(1)).join("")).join("");
486
- return a.charAt(0).toLowerCase() + a.slice(1);
487
- }, Ae = (e) => (e.split("/").pop() || e).replace(/\.json$/, "").replace(/^openapi\./, ""), je = (e, r, o, a) => {
488
- const n = Se(r), s = be(o), c = `${n}${s}`;
489
- return e && typeof e == "object" && "operationId" in e && a?.includes(String(e.operationId)) ? `${c}AsQuery` : c;
490
- }, Pe = (e, r) => {
491
- const o = {};
492
- return e?.forEach((a) => {
493
- o[a] = {
502
+ }, Ae = (e) => {
503
+ const o = e.split("/").filter((n) => n.length > 0).map((n) => n.replace(/\${([^}]*)}/g, "$1").split(/[_-]/).map((l) => l.charAt(0).toUpperCase() + l.slice(1)).join("")).join("");
504
+ return o.charAt(0).toLowerCase() + o.slice(1);
505
+ }, je = (e) => (e.split("/").pop() || e).replace(/\.json$/, "").replace(/^openapi\./, ""), Pe = (e, r, a, o) => {
506
+ const n = Ae(r), s = _e(a), c = `${n}${s}`;
507
+ return e && typeof e == "object" && "operationId" in e && o?.includes(String(e.operationId)) ? `${c}AsQuery` : c;
508
+ }, Te = (e, r) => {
509
+ const a = {};
510
+ return e?.forEach((o) => {
511
+ a[o] = {
494
512
  query: {
495
513
  useInfinite: !0,
496
514
  useInfiniteQueryParam: "offset",
497
515
  useQuery: !0
498
516
  }
499
517
  };
500
- }), r?.filter((a) => !o[a]).forEach((a) => {
501
- o[a] = {
518
+ }), r?.filter((o) => !a[o]).forEach((o) => {
519
+ a[o] = {
502
520
  query: {
503
521
  useQuery: !0
504
522
  }
505
523
  };
506
- }), Object.keys(o).length ? o : void 0;
507
- }, Be = (e) => (Array.isArray(e) ? e : [e]).reduce((o, a) => {
508
- const { output: n, useInfiniteIds: s, useQueryIds: c, input: u = "./openapi.json", customAxiosInstancePath: l, overrideApiName: d } = a || {}, i = d || Ae(u), m = l || "./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts";
524
+ }), Object.keys(a).length ? a : void 0;
525
+ }, Ze = (e) => (Array.isArray(e) ? e : [e]).reduce((a, o) => {
526
+ const { output: n, useInfiniteIds: s, useQueryIds: c, input: u = "./openapi.json", customAxiosInstancePath: l, overrideApiName: f } = o || {}, i = f || je(u), m = l || "./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts";
509
527
  return {
510
- ...o,
528
+ ...a,
511
529
  [i]: {
512
530
  input: u,
513
531
  output: {
@@ -516,7 +534,7 @@ const ze = ({ IMaskMixin: e, ...r }) => {
516
534
  mode: "tags-split",
517
535
  override: {
518
536
  ...(s?.length || c?.length) && {
519
- operations: Pe(s, c)
537
+ operations: Te(s, c)
520
538
  },
521
539
  header: (g) => [
522
540
  "Generated by orval 🍺",
@@ -524,10 +542,10 @@ const ze = ({ IMaskMixin: e, ...r }) => {
524
542
  ...g.description ? [g.description] : []
525
543
  ],
526
544
  mutator: {
527
- name: _e(m),
545
+ name: Se(m),
528
546
  path: m
529
547
  },
530
- operationName: (g, v, k) => je(g, v, k, c),
548
+ operationName: (g, v, k) => Pe(g, v, k, c),
531
549
  query: {
532
550
  useQuery: !0
533
551
  }
@@ -538,28 +556,28 @@ const ze = ({ IMaskMixin: e, ...r }) => {
538
556
  }
539
557
  }
540
558
  };
541
- }, {}), Te = (e) => e && typeof e == "function", ke = (e) => e && typeof e == "function", Xe = ({
559
+ }, {}), ke = (e) => e && typeof e == "function", Ce = (e) => e && typeof e == "function", et = ({
542
560
  children: e,
543
561
  defaultQueriesOptions: r,
544
- defaultMutationsOptions: o,
545
- ...a
562
+ defaultMutationsOptions: a,
563
+ ...o
546
564
  }) => {
547
- const { libraries: n } = P(S), s = a?.QueryClient || n?.reactQuery?.QueryClient, c = a?.QueryClientProvider || n?.reactQuery?.QueryClientProvider;
565
+ const { libraries: n } = P(A), s = o?.QueryClient || n?.reactQuery?.QueryClient, c = o?.QueryClientProvider || n?.reactQuery?.QueryClientProvider;
548
566
  if (!s)
549
567
  throw new Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
550
568
  if (!c)
551
569
  throw new Error("QueryClientProvider is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
552
- if (!Te(c))
570
+ if (!ke(c))
553
571
  throw new Error("Provided QueryClientProvider dependencies are not valid.");
554
- if (!ke(s))
572
+ if (!Ce(s))
555
573
  throw new Error("Provided QueryClient dependencies are not valid.");
556
574
  const u = new s({
557
575
  defaultOptions: {
558
576
  mutations: {
559
- ...o
577
+ ...a
560
578
  },
561
579
  queries: {
562
- getNextPageParam: (l, d, i) => l.length + (i || 0),
580
+ getNextPageParam: (l, f, i) => l.length + (i || 0),
563
581
  refetchOnWindowFocus: !1,
564
582
  retry: 3,
565
583
  ...r
@@ -567,86 +585,86 @@ const ze = ({ IMaskMixin: e, ...r }) => {
567
585
  }
568
586
  });
569
587
  return /* @__PURE__ */ C.jsx(c, { client: u, children: e });
570
- }, Ce = ({ library: e, date: r, format: o = "ll" }) => e(r).format(o), Ie = (e, r) => {
571
- const { fractionDigits: o = 0, metric: a = "km", spacingBetween: n = !0 } = r || {}, s = Number(e), c = n ? " " : "";
572
- return Number.isNaN(s) ? `0${c}${a}` : `${s.toFixed(o)}${c}${a}`;
573
- }, xe = (e) => !e || typeof e != "string" ? "" : e.replace(/_/g, " ").toLowerCase().split(" ").map((o) => o.length > 0 ? o.charAt(0).toUpperCase() + o.slice(1) : o).join(" "), Oe = (e) => e?.startsWith("/") ? e?.startsWith("/files") ? e : `/files${e}` : e?.startsWith("files") ? `/${e}` : `/files/${e}`, Le = ({ path: e, size: r, apiURL: o }) => {
588
+ }, Ie = ({ library: e, date: r, format: a = "ll" }) => e(r).format(a), xe = (e, r) => {
589
+ const { fractionDigits: a = 0, metric: o = "km", spacingBetween: n = !0 } = r || {}, s = Number(e), c = n ? " " : "";
590
+ return Number.isNaN(s) ? `0${c}${o}` : `${s.toFixed(a)}${c}${o}`;
591
+ }, Oe = (e) => !e || typeof e != "string" ? "" : e.replace(/_/g, " ").toLowerCase().split(" ").map((a) => a.length > 0 ? a.charAt(0).toUpperCase() + a.slice(1) : a).join(" "), Le = (e) => e?.startsWith("/") ? e?.startsWith("/files") ? e : `/files${e}` : e?.startsWith("files") ? `/${e}` : `/files/${e}`, Ne = ({ path: e, size: r, apiURL: a }) => {
574
592
  if (!e)
575
593
  return "";
576
- const a = Oe(e), n = `${o}${a}`, s = n.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/) !== null;
594
+ const o = Le(e), n = `${a}${o}`, s = n.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/) !== null;
577
595
  return typeof r == "number" && s ? `${n.replace("/files", `/thumbs/${r}`)}` : n;
578
- }, Ze = (e) => {
579
- const { apiURL: r, libraries: o } = P(S), a = e?.dayjs || o?.dayjs;
596
+ }, tt = (e) => {
597
+ const { apiURL: r, libraries: a } = P(A), o = e?.dayjs || a?.dayjs;
580
598
  return {
581
599
  dateAdapter: (c, u) => {
582
- if (!a)
600
+ if (!o)
583
601
  throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
584
- return Ce({
602
+ return Ie({
585
603
  date: c,
586
604
  format: u,
587
- library: a
605
+ library: o
588
606
  });
589
607
  },
590
- distanceAdapter: Ie,
608
+ distanceAdapter: xe,
591
609
  filePathAdapter: (c, u) => {
592
610
  if (!r)
593
611
  throw new Error(
594
612
  "API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter."
595
613
  );
596
- return typeof c == "string" && /^https?:\/\//.test(c) ? c : Le({
614
+ return typeof c == "string" && /^https?:\/\//.test(c) ? c : Ne({
597
615
  apiURL: r,
598
616
  path: c,
599
617
  size: u
600
618
  });
601
619
  },
602
- worksiteNameAdapter: xe
620
+ worksiteNameAdapter: Oe
603
621
  };
604
- }, et = (e) => {
605
- const { libraries: r } = P(S), o = e?.axios || r?.axios, a = e?.localStorageKey || "user";
622
+ }, rt = (e) => {
623
+ const { libraries: r, localStorageKeys: a } = P(A), o = e?.axios || r?.axios, n = e?.localStorageKey || a?.user || "user";
606
624
  if (!o)
607
625
  throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");
608
- const n = O(
609
- ({ tokenType: c, accessToken: u }) => {
610
- o.defaults.headers.common.Authorization = `${c} ${u}`;
626
+ const s = O(
627
+ ({ tokenType: u, accessToken: l }) => {
628
+ o.defaults.headers.common.Authorization = `${u} ${l}`;
611
629
  },
612
630
  [o.defaults.headers.common]
613
- ), s = () => {
631
+ ), c = () => {
614
632
  o.defaults.headers.common.Authorization = null;
615
633
  };
616
- return j(() => {
634
+ return S(() => {
617
635
  if (F)
618
636
  return;
619
- const c = ({ newValue: u, key: l }) => {
620
- if (l === a && u)
637
+ const u = ({ newValue: l, key: f }) => {
638
+ if (f === n && l)
621
639
  try {
622
- const { accessToken: d, tokenType: i } = JSON.parse(u);
623
- n({ accessToken: d, tokenType: i });
624
- } catch (d) {
625
- console.error("Failed to parse newValue from localStorage:", d);
640
+ const { accessToken: i, tokenType: m } = JSON.parse(l);
641
+ s({ accessToken: i, tokenType: m });
642
+ } catch (i) {
643
+ console.error("Failed to parse newValue from localStorage:", i);
626
644
  }
627
645
  };
628
- return window.addEventListener("storage", c), () => {
629
- window.removeEventListener("storage", c);
646
+ return window.addEventListener("storage", u), () => {
647
+ window.removeEventListener("storage", u);
630
648
  };
631
- }, [a, n]), {
632
- clearAuthenticationToken: s,
633
- setAuthenticationToken: n
649
+ }, [n, s]), {
650
+ clearAuthenticationToken: c,
651
+ setAuthenticationToken: s
634
652
  };
635
- }, Y = (e, r) => r === "short" ? e.split("-")[0] : e, tt = (e, r = "full") => {
636
- const [o, a] = W(() => {
653
+ }, W = (e, r) => r === "short" ? e.split("-")[0] : e, nt = (e, r = "full") => {
654
+ const [a, o] = Y(() => {
637
655
  const n = e?.language || navigator.language;
638
- return e && "isInitialized" in e && e.isInitialized, Y(n, r);
656
+ return e && "isInitialized" in e && e.isInitialized, W(n, r);
639
657
  });
640
- return j(() => {
641
- e && "isInitialized" in e && e.isInitialized && e.language && a(Y(e.language, r));
658
+ return S(() => {
659
+ e && "isInitialized" in e && e.isInitialized && e.language && o(W(e.language, r));
642
660
  const n = (s) => {
643
- a(Y(s, r));
661
+ o(W(s, r));
644
662
  };
645
663
  return e?.on?.("languageChanged", n), () => {
646
664
  e?.off?.("languageChanged", n);
647
665
  };
648
- }, [e, r]), o;
649
- }, Ne = "tracktor.filter", Fe = {
666
+ }, [e, r]), a;
667
+ }, Fe = "tracktor.filter", $e = {
650
668
  getFilter: () => {
651
669
  },
652
670
  getFilters: () => ({}),
@@ -660,39 +678,39 @@ const ze = ({ IMaskMixin: e, ...r }) => {
660
678
  } catch {
661
679
  return e;
662
680
  }
663
- }, ae = (e, r, o) => `${o}_${e}=>${r}`, $e = (e) => e.reduce((r, o) => {
664
- const a = localStorage.getItem(o);
665
- if (a)
681
+ }, ae = (e, r, a) => `${a}_${e}=>${r}`, De = (e) => e.reduce((r, a) => {
682
+ const o = localStorage.getItem(a);
683
+ if (o)
666
684
  try {
667
- const n = JSON.parse(a), s = Object.keys(n)?.[0];
685
+ const n = JSON.parse(o), s = Object.keys(n)?.[0];
668
686
  s && (r[s] = Object.values(n)?.[0]);
669
687
  } catch {
670
688
  }
671
689
  return r;
672
- }, {}), rt = (e) => {
673
- const { libraries: r, localStorageKeys: o } = P(S), a = e?.reactRouter || r?.reactRouter, { pathname: n } = a?.useLocation?.() ?? { pathname: "/" }, [s, c] = a?.useSearchParams?.() ?? [new URLSearchParams(), () => {
674
- }], [u, l] = W({}), d = o?.filter || Ne, i = e?.syncWithUrl === void 0 ? !0 : e?.syncWithUrl, m = e?.persistToLocalStorage === void 0 ? !0 : e?.persistToLocalStorage;
690
+ }, {}), ot = (e) => {
691
+ const { libraries: r, localStorageKeys: a } = P(A), o = e?.reactRouter || r?.reactRouter, { pathname: n } = o?.useLocation?.() ?? { pathname: "/" }, [s, c] = o?.useSearchParams?.() ?? [new URLSearchParams(), () => {
692
+ }], [u, l] = Y({}), f = a?.filter || Fe, i = e?.syncWithUrl === void 0 ? !0 : e?.syncWithUrl, m = e?.persistToLocalStorage === void 0 ? !0 : e?.persistToLocalStorage;
675
693
  if (F)
676
- return Fe;
677
- if (!a)
694
+ return $e;
695
+ if (!o)
678
696
  throw new Error(
679
697
  "React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter."
680
698
  );
681
699
  const g = () => Object.keys(localStorage).filter(
682
- (h) => h.startsWith(d) && h.endsWith(e?.pathname || n)
683
- ), v = (h, f, b = !0) => {
684
- const R = ae(h, e?.pathname || n, d);
685
- if (!f || Array.isArray(f) && !f.length) {
700
+ (h) => h.startsWith(f) && h.endsWith(e?.pathname || n)
701
+ ), v = (h, d, b = !0) => {
702
+ const R = ae(h, e?.pathname || n, f);
703
+ if (!d || Array.isArray(d) && !d.length) {
686
704
  i ? (s.delete(h), c(s)) : l((_) => {
687
705
  const I = { ..._ };
688
706
  return delete I[h], I;
689
707
  }), m && localStorage.removeItem(R);
690
708
  return;
691
709
  }
692
- m && b && f && localStorage.setItem(R, JSON.stringify({ ...s, [h]: f })), i && f ? (s.set(h, JSON.stringify(f)), c(s)) : !i && f && l((_) => ({ ..._, [h]: f }));
710
+ m && b && d && localStorage.setItem(R, JSON.stringify({ ...s, [h]: d })), i && d ? (s.set(h, JSON.stringify(d)), c(s)) : !i && d && l((_) => ({ ..._, [h]: d }));
693
711
  };
694
712
  return {
695
- getFilter: (h, f) => {
713
+ getFilter: (h, d) => {
696
714
  if (i) {
697
715
  const b = s.get(h);
698
716
  if (b)
@@ -703,7 +721,7 @@ const ze = ({ IMaskMixin: e, ...r }) => {
703
721
  return b;
704
722
  }
705
723
  if (m) {
706
- const b = ae(h, e?.pathname || n, d), R = localStorage.getItem(b);
724
+ const b = ae(h, e?.pathname || n, f), R = localStorage.getItem(b);
707
725
  if (R)
708
726
  try {
709
727
  const _ = JSON.parse(R)[h];
@@ -711,15 +729,15 @@ const ze = ({ IMaskMixin: e, ...r }) => {
711
729
  } catch {
712
730
  }
713
731
  }
714
- return f;
732
+ return d;
715
733
  },
716
734
  getFilters: () => {
717
- const h = m ? $e(g()) : {};
735
+ const h = m ? De(g()) : {};
718
736
  if (i) {
719
- const f = Array.from(s.entries()).reduce((b, [R, _]) => (b[R] = oe(_), b), {});
737
+ const d = Array.from(s.entries()).reduce((b, [R, _]) => (b[R] = oe(_), b), {});
720
738
  return {
721
739
  ...h,
722
- ...f
740
+ ...d
723
741
  };
724
742
  }
725
743
  return {
@@ -727,9 +745,9 @@ const ze = ({ IMaskMixin: e, ...r }) => {
727
745
  ...u
728
746
  };
729
747
  },
730
- handleFilter: (h, f) => (b, R) => {
748
+ handleFilter: (h, d) => (b, R) => {
731
749
  if (R || Array.isArray(R) && R.length === 0) {
732
- const _ = f || "value", I = typeof R == "object" && _ in R ? R[_] : R;
750
+ const _ = d || "value", I = typeof R == "object" && _ in R ? R[_] : R;
733
751
  v(h, I);
734
752
  return;
735
753
  }
@@ -737,34 +755,34 @@ const ze = ({ IMaskMixin: e, ...r }) => {
737
755
  },
738
756
  setFilter: v
739
757
  };
740
- }, nt = ({
758
+ }, at = ({
741
759
  data: e,
742
760
  fetchNextPage: r,
743
- isFetchingNextPage: o,
744
- isInitialLoading: a,
761
+ isFetchingNextPage: a,
762
+ isInitialLoading: o,
745
763
  isLoading: n,
746
764
  enabled: s = !0
747
765
  }) => {
748
766
  const c = O(
749
767
  async (l) => {
750
- o || !s || await r({ pageParam: l?.pageParam || l.visibleRowsCount });
768
+ a || !s || await r({ pageParam: l?.pageParam || l.visibleRowsCount });
751
769
  },
752
- [s, r, o]
770
+ [s, r, a]
753
771
  ), u = G(() => {
754
772
  if (e)
755
- return e.pages.reduce((l, d) => [...l, ...d], []);
773
+ return e.pages.reduce((l, f) => [...l, ...f], []);
756
774
  }, [e]);
757
775
  return {
758
776
  fetchNextPageOnRowsScrollEnd: c,
759
- isLoading: o || n,
760
- loadingVariant: a ? "skeleton" : "linear-progress",
777
+ isLoading: a || n,
778
+ loadingVariant: o ? "skeleton" : "linear-progress",
761
779
  rows: u
762
780
  };
763
- }, ot = (e) => {
764
- const { libraries: r } = P(S), o = e?.i18 || r?.i18, a = e?.i18?.translateFunction || r?.i18?.translateFunction, n = o?.i18next?.t || a || ((d) => d), { unknownErrorTranslationKey: s = "error.unknownError" } = e || {}, c = n(s), u = O(
765
- (d) => {
766
- if (d && typeof d == "object" && "response" in d) {
767
- const { response: i } = d || {};
781
+ }, it = (e) => {
782
+ const { libraries: r } = P(A), a = e?.i18 || r?.i18, o = e?.i18?.translateFunction || r?.i18?.translateFunction, n = a?.i18next?.t || o || ((f) => f), { unknownErrorTranslationKey: s = "error.unknownError" } = e || {}, c = n(s), u = O(
783
+ (f) => {
784
+ if (f && typeof f == "object" && "response" in f) {
785
+ const { response: i } = f || {};
768
786
  if (i && typeof i == "object" && "reason" in i && i.reason)
769
787
  return String(i.reason);
770
788
  if (i && typeof i == "object" && "data" in i && i.data && typeof i.data == "object" && "reason" in i.data && i.data.reason)
@@ -780,37 +798,38 @@ const ze = ({ IMaskMixin: e, ...r }) => {
780
798
  }
781
799
  }
782
800
  }
783
- return d instanceof Error ? d.message : c;
801
+ return f instanceof Error ? f.message : c;
784
802
  },
785
803
  [c]
786
804
  );
787
- return { getErrorCode: O((d) => {
788
- const { response: i } = d || {};
805
+ return { getErrorCode: O((f) => {
806
+ const { response: i } = f || {};
789
807
  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";
790
808
  }, []), printError: u };
791
809
  };
792
810
  export {
793
- Qe as GTMSendPageView,
794
- Ve as InitializeAxiosConfig,
795
- Me as InitializeDaysJSConfig,
796
- Ge as InitializeI18nConfig,
797
- Je as InitializeSentryConfig,
798
- S as InjectDependenciesContext,
799
- Ue as InjectDependenciesProvider,
800
- ze as MaskTextField,
801
- qe as PreloadErrorHandler,
802
- Xe as QueryClientProviderWithConfig,
803
- Ke as RequireAuth,
804
- He as UpdateNotifier,
805
- We as axiosCustomInstance,
806
- Ce as dateAdapter,
807
- Ie as distanceAdapter,
808
- Be as getOrvalConfig,
809
- Ze as useAdapter,
810
- et as useAuth,
811
- tt as useCurrentLanguage,
812
- rt as useFilters,
813
- nt as useInfiniteDataGrid,
814
- ot as useResponseError,
815
- xe as worksiteNameAdapter
811
+ Ve as GTMSendPageView,
812
+ Me as InitializeAxiosConfig,
813
+ Ge as InitializeDaysJSConfig,
814
+ Je as InitializeI18nConfig,
815
+ qe as InitializeSentryConfig,
816
+ A as InjectDependenciesContext,
817
+ Qe as InjectDependenciesProvider,
818
+ Ue as MaskTextField,
819
+ Ke as PreloadErrorHandler,
820
+ et as QueryClientProviderWithConfig,
821
+ He as RequireAuth,
822
+ Be as ServiceWorkerCleaner,
823
+ Xe as UpdateNotifier,
824
+ ze as axiosCustomInstance,
825
+ Ie as dateAdapter,
826
+ xe as distanceAdapter,
827
+ Ze as getOrvalConfig,
828
+ tt as useAdapter,
829
+ rt as useAuth,
830
+ nt as useCurrentLanguage,
831
+ ot as useFilters,
832
+ at as useInfiniteDataGrid,
833
+ it as useResponseError,
834
+ Oe as worksiteNameAdapter
816
835
  };
package/dist/main.umd.cjs CHANGED
@@ -1,6 +1,6 @@
1
- (function(h,O){typeof exports=="object"&&typeof module<"u"?O(exports,require("axios"),require("react")):typeof define=="function"&&define.amd?define(["exports","axios","react"],O):(h=typeof globalThis<"u"?globalThis:h||self,O(h["@tracktor/shared-module"]={},h.axios,h.React))})(this,(function(h,O,p){"use strict";const se=(e,r)=>{const o=O.CancelToken.source(),a=O({...e,...r,cancelToken:o.token}).then(({data:n})=>n);return a.cancel=()=>{o.cancel("Query was cancelled")},a};var D={exports:{}},N={};var G;function ie(){if(G)return N;G=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function o(a,n,i){var c=null;if(i!==void 0&&(c=""+i),n.key!==void 0&&(c=""+n.key),"key"in n){i={};for(var u in n)u!=="key"&&(i[u]=n[u])}else i=n;return n=i.ref,{$$typeof:e,type:a,key:c,ref:n!==void 0?n:null,props:i}}return N.Fragment=r,N.jsx=o,N.jsxs=o,N}var L={};var J;function ce(){return J||(J=1,process.env.NODE_ENV!=="production"&&(function(){function e(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===Ke?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case P:return"Fragment";case f:return"Profiler";case v:return"StrictMode";case I:return"Suspense";case Ve:return"SuspenseList";case Je:return"Activity"}if(typeof t=="object")switch(typeof t.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),t.$$typeof){case j:return"Portal";case _:return t.displayName||"Context";case S:return(t._context.displayName||"Context")+".Consumer";case A:var g=t.render;return t=t.displayName,t||(t=g.displayName||g.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Ge:return g=t.displayName||null,g!==null?g:e(t.type)||"Memo";case W:g=t._payload,t=t._init;try{return e(t(g))}catch{}}return null}function r(t){return""+t}function o(t){try{r(t);var g=!1}catch{g=!0}if(g){g=console;var E=g.error,b=typeof Symbol=="function"&&Symbol.toStringTag&&t[Symbol.toStringTag]||t.constructor.name||"Object";return E.call(g,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",b),r(t)}}function a(t){if(t===P)return"<>";if(typeof t=="object"&&t!==null&&t.$$typeof===W)return"<...>";try{var g=e(t);return g?"<"+g+">":"<...>"}catch{return"<...>"}}function n(){var t=U.A;return t===null?null:t.getOwner()}function i(){return Error("react-stack-top-frame")}function c(t){if(ee.call(t,"key")){var g=Object.getOwnPropertyDescriptor(t,"key").get;if(g&&g.isReactWarning)return!1}return t.key!==void 0}function u(t,g){function E(){te||(te=!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)",g))}E.isReactWarning=!0,Object.defineProperty(t,"key",{get:E,configurable:!0})}function l(){var t=e(this.type);return re[t]||(re[t]=!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.")),t=this.props.ref,t!==void 0?t:null}function d(t,g,E,b,z,Q){var R=E.ref;return t={$$typeof:k,type:t,key:g,props:E,_owner:b},(R!==void 0?R:null)!==null?Object.defineProperty(t,"ref",{enumerable:!1,get:l}):Object.defineProperty(t,"ref",{enumerable:!1,value:null}),t._store={},Object.defineProperty(t._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(t,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(t,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:z}),Object.defineProperty(t,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Q}),Object.freeze&&(Object.freeze(t.props),Object.freeze(t)),t}function s(t,g,E,b,z,Q){var R=g.children;if(R!==void 0)if(b)if(He(R)){for(b=0;b<R.length;b++)y(R[b]);Object.freeze&&Object.freeze(R)}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 y(R);if(ee.call(g,"key")){R=e(t);var x=Object.keys(g).filter(function(Be){return Be!=="key"});b=0<x.length?"{key: someKey, "+x.join(": ..., ")+": ...}":"{key: someKey}",ae[R+b]||(x=0<x.length?"{"+x.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
1
+ (function(m,O){typeof exports=="object"&&typeof module<"u"?O(exports,require("axios"),require("react")):typeof define=="function"&&define.amd?define(["exports","axios","react"],O):(m=typeof globalThis<"u"?globalThis:m||self,O(m["@tracktor/shared-module"]={},m.axios,m.React))})(this,(function(m,O,f){"use strict";const se=(e,r)=>{const a=O.CancelToken.source(),o=O({...e,...r,cancelToken:a.token}).then(({data:n})=>n);return o.cancel=()=>{a.cancel("Query was cancelled")},o};var D={exports:{}},N={};var G;function ie(){if(G)return N;G=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function a(o,n,i){var c=null;if(i!==void 0&&(c=""+i),n.key!==void 0&&(c=""+n.key),"key"in n){i={};for(var u in n)u!=="key"&&(i[u]=n[u])}else i=n;return n=i.ref,{$$typeof:e,type:o,key:c,ref:n!==void 0?n:null,props:i}}return N.Fragment=r,N.jsx=a,N.jsxs=a,N}var L={};var J;function ce(){return J||(J=1,process.env.NODE_ENV!=="production"&&(function(){function e(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===Be?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case k:return"Fragment";case d:return"Profiler";case v:return"StrictMode";case I:return"Suspense";case Je:return"SuspenseList";case He:return"Activity"}if(typeof t=="object")switch(typeof t.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),t.$$typeof){case j:return"Portal";case S:return t.displayName||"Context";case _:return(t._context.displayName||"Context")+".Consumer";case A:var g=t.render;return t=t.displayName,t||(t=g.displayName||g.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Ke:return g=t.displayName||null,g!==null?g:e(t.type)||"Memo";case z:g=t._payload,t=t._init;try{return e(t(g))}catch{}}return null}function r(t){return""+t}function a(t){try{r(t);var g=!1}catch{g=!0}if(g){g=console;var E=g.error,b=typeof Symbol=="function"&&Symbol.toStringTag&&t[Symbol.toStringTag]||t.constructor.name||"Object";return E.call(g,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",b),r(t)}}function o(t){if(t===k)return"<>";if(typeof t=="object"&&t!==null&&t.$$typeof===z)return"<...>";try{var g=e(t);return g?"<"+g+">":"<...>"}catch{return"<...>"}}function n(){var t=U.A;return t===null?null:t.getOwner()}function i(){return Error("react-stack-top-frame")}function c(t){if(ee.call(t,"key")){var g=Object.getOwnPropertyDescriptor(t,"key").get;if(g&&g.isReactWarning)return!1}return t.key!==void 0}function u(t,g){function E(){te||(te=!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)",g))}E.isReactWarning=!0,Object.defineProperty(t,"key",{get:E,configurable:!0})}function l(){var t=e(this.type);return re[t]||(re[t]=!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.")),t=this.props.ref,t!==void 0?t:null}function p(t,g,E,b,Y,Q){var R=E.ref;return t={$$typeof:T,type:t,key:g,props:E,_owner:b},(R!==void 0?R:null)!==null?Object.defineProperty(t,"ref",{enumerable:!1,get:l}):Object.defineProperty(t,"ref",{enumerable:!1,value:null}),t._store={},Object.defineProperty(t._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(t,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(t,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:Y}),Object.defineProperty(t,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Q}),Object.freeze&&(Object.freeze(t.props),Object.freeze(t)),t}function s(t,g,E,b,Y,Q){var R=g.children;if(R!==void 0)if(b)if(Xe(R)){for(b=0;b<R.length;b++)y(R[b]);Object.freeze&&Object.freeze(R)}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 y(R);if(ee.call(g,"key")){R=e(t);var x=Object.keys(g).filter(function(Ze){return Ze!=="key"});b=0<x.length?"{key: someKey, "+x.join(": ..., ")+": ...}":"{key: someKey}",ae[R+b]||(x=0<x.length?"{"+x.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} />`,b,R,x,R),ae[R+b]=!0)}if(R=null,E!==void 0&&(o(E),R=""+E),c(g)&&(o(g.key),R=""+g.key),"key"in g){E={};for(var V in g)V!=="key"&&(E[V]=g[V])}else E=g;return R&&u(E,typeof t=="function"?t.displayName||t.name||"Unknown":t),d(t,R,E,n(),z,Q)}function y(t){m(t)?t._store&&(t._store.validated=1):typeof t=="object"&&t!==null&&t.$$typeof===W&&(t._payload.status==="fulfilled"?m(t._payload.value)&&t._payload.value._store&&(t._payload.value._store.validated=1):t._store&&(t._store.validated=1))}function m(t){return typeof t=="object"&&t!==null&&t.$$typeof===k}var w=p,k=Symbol.for("react.transitional.element"),j=Symbol.for("react.portal"),P=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),S=Symbol.for("react.consumer"),_=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),Ve=Symbol.for("react.suspense_list"),Ge=Symbol.for("react.memo"),W=Symbol.for("react.lazy"),Je=Symbol.for("react.activity"),Ke=Symbol.for("react.client.reference"),U=w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ee=Object.prototype.hasOwnProperty,He=Array.isArray,M=console.createTask?console.createTask:function(){return null};w={react_stack_bottom_frame:function(t){return t()}};var te,re={},ne=w.react_stack_bottom_frame.bind(w,i)(),oe=M(a(i)),ae={};L.Fragment=P,L.jsx=function(t,g,E){var b=1e4>U.recentlyCreatedOwnerStacks++;return s(t,g,E,!1,b?Error("react-stack-top-frame"):ne,b?M(a(t)):oe)},L.jsxs=function(t,g,E){var b=1e4>U.recentlyCreatedOwnerStacks++;return s(t,g,E,!0,b?Error("react-stack-top-frame"):ne,b?M(a(t)):oe)}})()),L}var K;function le(){return K||(K=1,process.env.NODE_ENV==="production"?D.exports=ie():D.exports=ce()),D.exports}var T=le();const ue=({IMaskMixin:e,...r})=>{const o=p.useMemo(()=>e(({TextField:a,...n})=>T.jsx(a,{...n})),[e]);return T.jsx(o,{...r})},C=p.createContext({}),de=({children:e,apiURL:r,libraries:o,localStorageKeys:a})=>{const n=p.useMemo(()=>({apiURL:r,libraries:o,localStorageKeys:a}),[r,o,a]);return T.jsx(C.Provider,{value:n,children:e})},fe=({data:e,...r})=>{const{libraries:o}=p.useContext(C),a=r?.reactRouter||o?.reactRouter,n=r?.gtm||o?.gtm;if(!a)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");if(!n)throw new Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");const{useGoogleTagManager:i}=n,{useLocation:c,Outlet:u}=a,{pathname:l}=c(),{sendEvent:d}=i();return p.useEffect(()=>{d({event:"pageView",pathname:l,...e})},[e,l,d]),T.jsx(u,{})},F=(()=>{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}})(),pe="user",ge=({tokenTypeKey:e="tokenType",tokenKey:r="accessToken",postContentType:o="application/json",...a})=>{const{apiURL:n=a.apiURL,libraries:i,localStorageKeys:c}=p.useContext(C),u=a?.userLocalStorageKey||c?.user||pe,l=a?.axios||i?.axios;if(!l)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!l?.defaults||F)return null;if(typeof window<"u"&&window.localStorage){const d=localStorage.getItem(u),s=d?JSON.parse(d):null,y=s?.[e]?s[e]:null,m=s?.[r]?s[r]:null,w=d?`${y} ${m}`:null;w&&(l.defaults.headers.common.Authorization=w)}return l.defaults.baseURL=n,l.defaults.headers.post["Content-Type"]=o,null},me=({language:e,...r})=>{const{libraries:o}=p.useContext(C),a=r?.dayjs||o?.dayjs,n=r?.plugin||o?.dayjsPlugin;if(!a)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig.");return p.useEffect(()=>{(async()=>{const c=e||navigator.language?.slice(0,2)||"en";n&&n.forEach(u=>{u&&a.extend(u)}),await import("dayjs/locale/en"),await import("dayjs/locale/fr"),a.locale(c)})().then()},[a,n,e]),null},he=({debug:e,resources:r,...o})=>{const{libraries:a}=p.useContext(C),n=o?.i18||a?.i18,{i18next:i,initReactI18next:c,languageDetector:u}=n||{};if(F)return null;if(!n)throw new Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return i?.isInitialized||(i.use(u).use(c).init({debug:e,fallbackLng:"en",interpolation:{escapeValue:!1},load:"languageOnly",react:{bindI18n:"languageChanged loaded",useSuspense:!0},resources:r,returnNull:!1}).then(()=>{document.documentElement.lang!==i.resolvedLanguage&&i.resolvedLanguage&&document.documentElement.setAttribute("lang",i.resolvedLanguage)}),i.on("languageChanged",l=>{document.documentElement.setAttribute("lang",l)})),null},ye=({dsn:e,integrations:r,tracesSampleRate:o,replaysSessionSampleRate:a,replaysOnErrorSampleRate:n,tracePropagationTargets:i,ignoreErrors:c,debug:u,environment:l,release:d,...s})=>{const{libraries:y}=p.useContext(C),m=s?.sentry||y?.sentry,w=s?.reactRouter||y?.reactRouter;if(!m)throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!w)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(m.isInitialized())return null;const{createRoutesFromChildren:k,matchRoutes:j,useLocation:P,useNavigationType:v}=w;return(u||process.env.NODE_ENV==="prod"||process.env.NODE_ENV==="production")&&m.init({debug:u,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:[m.reactRouterV6BrowserTracingIntegration({createRoutesFromChildren:k,matchRoutes:j,useEffect:p.useEffect,useLocation:P,useNavigationType:v}),...r||[]],release:d,replaysOnErrorSampleRate:n||1,replaysSessionSampleRate:a||.1,tracePropagationTargets:i,tracesSampleRate:o||1}),null},ve=()=>(p.useEffect(()=>{if(F)return;const e=r=>{try{r.preventDefault(),r.stopPropagation(),r.stopImmediatePropagation(),window.location.reload()}catch{}};return window.addEventListener("vite:preloadError",e),()=>{window.removeEventListener("vite:preloadError",e)}},[]),null),H=new WeakMap,Ee="user",we=({Fallback:e,isLogged:r,loginPath:o="/login",redirect401Path:a="/login",...n})=>{const{libraries:i,localStorageKeys:c}=p.useContext(C),u=n?.reactRouter||i?.reactRouter,l=n?.axios||i?.axios,d=n?.localStorageKey||c?.user||Ee;if(!u)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");const[s,y]=p.useState(null),{useLocation:m,Navigate:w,Outlet:k}=u,j=m(),P=typeof r=="function"?r():!!r,v=typeof P=="boolean"?P:P?.isLogged;return p.useEffect(()=>{H.has(l)||(H.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(d)),y(a)),Promise.reject(f))))},[l,d,a]),v&&!s?T.jsx(p.Suspense,{fallback:e,children:j.state?.from?.state&&j.state?.from?.pathname===o?T.jsx(w,{to:j.state.from.state.from.pathname+j.state.from.state.from.search,replace:!0}):T.jsx(k,{})}):T.jsx(w,{to:o+j.search,state:{from:j},replace:!0})},be=async()=>{if("caches"in window)try{const e=await caches.keys();await Promise.all(e.map(r=>caches.delete(r)))}catch(e){console.error("Failed to clear caches:",e)}},Re=({autoUpdate:e,renderDialog:r,clearCachesOnReload:o})=>{const a=p.useRef(null),[n,i]=p.useState(!1),c=p.useCallback(()=>{a.current&&a.current.postMessage({type:"SKIP_WAITING"}),o&&localStorage.setItem("tracktor_clear_caches","1"),window.location.reload()},[o]);p.useEffect(()=>{localStorage.getItem("tracktor_clear_caches")==="1"&&(localStorage.removeItem("tracktor_clear_caches"),be().catch(console.error))},[]);const u=p.useCallback(()=>{window.confirm("A new version is available. The app will reload now.")&&c()},[c]);return p.useEffect(()=>{if(!("serviceWorker"in navigator))return;let l,d;const s=m=>{m&&navigator.serviceWorker.controller&&(a.current=m,i(!0))},y=()=>{const m=l?.installing;m&&(d=()=>{m.state==="installed"&&s(m)},m.addEventListener("statechange",d))};return(async()=>{l=await navigator.serviceWorker.getRegistration(),l&&(s(l.waiting),l.addEventListener("updatefound",y))})().catch(console.error),()=>{l?.removeEventListener("updatefound",y),d&&l?.installing&&l.installing.removeEventListener("statechange",d)}},[]),p.useEffect(()=>{n&&e&&c()},[e,n,c]),p.useEffect(()=>{n&&!e&&!r&&u()},[r,u,n,e]),n&&!e&&r?r(c):null},_e=e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),Se=e=>{const r=e.split(/[/\\]/).pop()||"";return r.substring(0,r.lastIndexOf("."))},Ae=e=>{const a=e.split("/").filter(n=>n.length>0).map(n=>n.replace(/\${([^}]*)}/g,"$1").split(/[_-]/).map(l=>l.charAt(0).toUpperCase()+l.slice(1)).join("")).join("");return a.charAt(0).toLowerCase()+a.slice(1)},Ce=e=>(e.split("/").pop()||e).replace(/\.json$/,"").replace(/^openapi\./,""),je=(e,r,o,a)=>{const n=Ae(r),i=_e(o),c=`${n}${i}`;return e&&typeof e=="object"&&"operationId"in e&&a?.includes(String(e.operationId))?`${c}AsQuery`:c},Pe=(e,r)=>{const o={};return e?.forEach(a=>{o[a]={query:{useInfinite:!0,useInfiniteQueryParam:"offset",useQuery:!0}}}),r?.filter(a=>!o[a]).forEach(a=>{o[a]={query:{useQuery:!0}}}),Object.keys(o).length?o:void 0},Te=e=>(Array.isArray(e)?e:[e]).reduce((o,a)=>{const{output:n,useInfiniteIds:i,useQueryIds:c,input:u="./openapi.json",customAxiosInstancePath:l,overrideApiName:d}=a||{},s=d||Ce(u),y=l||"./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts";return{...o,[s]:{input:u,output:{baseUrl:n?.baseUrl,client:"react-query",mode:"tags-split",override:{...(i?.length||c?.length)&&{operations:Pe(i,c)},header:m=>["Generated by orval 🍺",...m.title?[m.title]:[],...m.description?[m.description]:[]],mutator:{name:Se(y),path:y},operationName:(m,w,k)=>je(m,w,k,c),query:{useQuery:!0}},schemas:n?.schemas||`src/api/${s}/model`,target:n?.target||`src/api/${s}/services/api.ts`,...n}}}},{}),ke=e=>e&&typeof e=="function",Ie=e=>e&&typeof e=="function",Oe=({children:e,defaultQueriesOptions:r,defaultMutationsOptions:o,...a})=>{const{libraries:n}=p.useContext(C),i=a?.QueryClient||n?.reactQuery?.QueryClient,c=a?.QueryClientProvider||n?.reactQuery?.QueryClientProvider;if(!i)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(!ke(c))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!Ie(i))throw new Error("Provided QueryClient dependencies are not valid.");const u=new i({defaultOptions:{mutations:{...o},queries:{getNextPageParam:(l,d,s)=>l.length+(s||0),refetchOnWindowFocus:!1,retry:3,...r}}});return T.jsx(c,{client:u,children:e})},B=({library:e,date:r,format:o="ll"})=>e(r).format(o),X=(e,r)=>{const{fractionDigits:o=0,metric:a="km",spacingBetween:n=!0}=r||{},i=Number(e),c=n?" ":"";return Number.isNaN(i)?`0${c}${a}`:`${i.toFixed(o)}${c}${a}`},Z=e=>!e||typeof e!="string"?"":e.replace(/_/g," ").toLowerCase().split(" ").map(o=>o.length>0?o.charAt(0).toUpperCase()+o.slice(1):o).join(" "),xe=e=>e?.startsWith("/")?e?.startsWith("/files")?e:`/files${e}`:e?.startsWith("files")?`/${e}`:`/files/${e}`,Ne=({path:e,size:r,apiURL:o})=>{if(!e)return"";const a=xe(e),n=`${o}${a}`,i=n.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/)!==null;return typeof r=="number"&&i?`${n.replace("/files",`/thumbs/${r}`)}`:n},Le=e=>{const{apiURL:r,libraries:o}=p.useContext(C),a=e?.dayjs||o?.dayjs;return{dateAdapter:(c,u)=>{if(!a)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return B({date:c,format:u,library:a})},distanceAdapter:X,filePathAdapter:(c,u)=>{if(!r)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:Ne({apiURL:r,path:c,size:u})},worksiteNameAdapter:Z}},Fe=e=>{const{libraries:r}=p.useContext(C),o=e?.axios||r?.axios,a=e?.localStorageKey||"user";if(!o)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");const n=p.useCallback(({tokenType:c,accessToken:u})=>{o.defaults.headers.common.Authorization=`${c} ${u}`},[o.defaults.headers.common]),i=()=>{o.defaults.headers.common.Authorization=null};return p.useEffect(()=>{if(F)return;const c=({newValue:u,key:l})=>{if(l===a&&u)try{const{accessToken:d,tokenType:s}=JSON.parse(u);n({accessToken:d,tokenType:s})}catch(d){console.error("Failed to parse newValue from localStorage:",d)}};return window.addEventListener("storage",c),()=>{window.removeEventListener("storage",c)}},[a,n]),{clearAuthenticationToken:i,setAuthenticationToken:n}},Y=(e,r)=>r==="short"?e.split("-")[0]:e,De=(e,r="full")=>{const[o,a]=p.useState(()=>{const n=e?.language||navigator.language;return e&&"isInitialized"in e&&e.isInitialized,Y(n,r)});return p.useEffect(()=>{e&&"isInitialized"in e&&e.isInitialized&&e.language&&a(Y(e.language,r));const n=i=>{a(Y(i,r))};return e?.on?.("languageChanged",n),()=>{e?.off?.("languageChanged",n)}},[e,r]),o},Ye="tracktor.filter",ze={getFilter:()=>{},getFilters:()=>({}),handleFilter:()=>()=>{},setFilter:()=>{}},q=e=>{try{return JSON.parse(e)}catch{return e}},$=(e,r,o)=>`${o}_${e}=>${r}`,We=e=>e.reduce((r,o)=>{const a=localStorage.getItem(o);if(a)try{const n=JSON.parse(a),i=Object.keys(n)?.[0];i&&(r[i]=Object.values(n)?.[0])}catch{}return r},{}),Ue=e=>{const{libraries:r,localStorageKeys:o}=p.useContext(C),a=e?.reactRouter||r?.reactRouter,{pathname:n}=a?.useLocation?.()??{pathname:"/"},[i,c]=a?.useSearchParams?.()??[new URLSearchParams,()=>{}],[u,l]=p.useState({}),d=o?.filter||Ye,s=e?.syncWithUrl===void 0?!0:e?.syncWithUrl,y=e?.persistToLocalStorage===void 0?!0:e?.persistToLocalStorage;if(F)return ze;if(!a)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter.");const m=()=>Object.keys(localStorage).filter(v=>v.startsWith(d)&&v.endsWith(e?.pathname||n)),w=(v,f,S=!0)=>{const _=$(v,e?.pathname||n,d);if(!f||Array.isArray(f)&&!f.length){s?(i.delete(v),c(i)):l(A=>{const I={...A};return delete I[v],I}),y&&localStorage.removeItem(_);return}y&&S&&f&&localStorage.setItem(_,JSON.stringify({...i,[v]:f})),s&&f?(i.set(v,JSON.stringify(f)),c(i)):!s&&f&&l(A=>({...A,[v]:f}))};return{getFilter:(v,f)=>{if(s){const S=i.get(v);if(S)return q(S)}else{const S=u[v];if(S!==void 0)return S}if(y){const S=$(v,e?.pathname||n,d),_=localStorage.getItem(S);if(_)try{const A=JSON.parse(_)[v];return!s&&A!==void 0&&l(I=>({...I,[v]:A})),A}catch{}}return f},getFilters:()=>{const v=y?We(m()):{};if(s){const f=Array.from(i.entries()).reduce((S,[_,A])=>(S[_]=q(A),S),{});return{...v,...f}}return{...v,...u}},handleFilter:(v,f)=>(S,_)=>{if(_||Array.isArray(_)&&_.length===0){const A=f||"value",I=typeof _=="object"&&A in _?_[A]:_;w(v,I);return}w(v,void 0)},setFilter:w}},Me=({data:e,fetchNextPage:r,isFetchingNextPage:o,isInitialLoading:a,isLoading:n,enabled:i=!0})=>{const c=p.useCallback(async l=>{o||!i||await r({pageParam:l?.pageParam||l.visibleRowsCount})},[i,r,o]),u=p.useMemo(()=>{if(e)return e.pages.reduce((l,d)=>[...l,...d],[])},[e]);return{fetchNextPageOnRowsScrollEnd:c,isLoading:o||n,loadingVariant:a?"skeleton":"linear-progress",rows:u}},Qe=e=>{const{libraries:r}=p.useContext(C),o=e?.i18||r?.i18,a=e?.i18?.translateFunction||r?.i18?.translateFunction,n=o?.i18next?.t||a||(d=>d),{unknownErrorTranslationKey:i="error.unknownError"}=e||{},c=n(i),u=p.useCallback(d=>{if(d&&typeof d=="object"&&"response"in d){const{response:s}=d||{};if(s&&typeof s=="object"&&"reason"in s&&s.reason)return String(s.reason);if(s&&typeof s=="object"&&"data"in s&&s.data&&typeof s.data=="object"&&"reason"in s.data&&s.data.reason)return String(s.data.reason);if(s&&typeof s=="object"&&"data"in s&&s.data&&typeof s.data=="object"&&"message"in s.data&&s.data.message)return String(s.data.message);if(s&&typeof s=="object"&&"data"in s&&s.data&&typeof s.data=="object"&&"detail"in s.data){const{detail:y}=s.data;if(Array.isArray(y)&&y.length>0&&typeof y[0]=="object"&&y[0]!==null&&"msg"in y[0]){const{msg:m}=y[0];if(typeof m=="string")return String(m)}}}return d instanceof Error?d.message:c},[c]);return{getErrorCode:p.useCallback(d=>{const{response:s}=d||{};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"},[]),printError:u}};h.GTMSendPageView=fe,h.InitializeAxiosConfig=ge,h.InitializeDaysJSConfig=me,h.InitializeI18nConfig=he,h.InitializeSentryConfig=ye,h.InjectDependenciesContext=C,h.InjectDependenciesProvider=de,h.MaskTextField=ue,h.PreloadErrorHandler=ve,h.QueryClientProviderWithConfig=Oe,h.RequireAuth=we,h.UpdateNotifier=Re,h.axiosCustomInstance=se,h.dateAdapter=B,h.distanceAdapter=X,h.getOrvalConfig=Te,h.useAdapter=Le,h.useAuth=Fe,h.useCurrentLanguage=De,h.useFilters=Ue,h.useInfiniteDataGrid=Me,h.useResponseError=Qe,h.worksiteNameAdapter=Z,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})}));
6
+ <%s key={someKey} {...props} />`,b,R,x,R),ae[R+b]=!0)}if(R=null,E!==void 0&&(a(E),R=""+E),c(g)&&(a(g.key),R=""+g.key),"key"in g){E={};for(var V in g)V!=="key"&&(E[V]=g[V])}else E=g;return R&&u(E,typeof t=="function"?t.displayName||t.name||"Unknown":t),p(t,R,E,n(),Y,Q)}function y(t){h(t)?t._store&&(t._store.validated=1):typeof t=="object"&&t!==null&&t.$$typeof===z&&(t._payload.status==="fulfilled"?h(t._payload.value)&&t._payload.value._store&&(t._payload.value._store.validated=1):t._store&&(t._store.validated=1))}function h(t){return typeof t=="object"&&t!==null&&t.$$typeof===T}var w=f,T=Symbol.for("react.transitional.element"),j=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),d=Symbol.for("react.profiler"),_=Symbol.for("react.consumer"),S=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),Je=Symbol.for("react.suspense_list"),Ke=Symbol.for("react.memo"),z=Symbol.for("react.lazy"),He=Symbol.for("react.activity"),Be=Symbol.for("react.client.reference"),U=w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ee=Object.prototype.hasOwnProperty,Xe=Array.isArray,M=console.createTask?console.createTask:function(){return null};w={react_stack_bottom_frame:function(t){return t()}};var te,re={},ne=w.react_stack_bottom_frame.bind(w,i)(),oe=M(o(i)),ae={};L.Fragment=k,L.jsx=function(t,g,E){var b=1e4>U.recentlyCreatedOwnerStacks++;return s(t,g,E,!1,b?Error("react-stack-top-frame"):ne,b?M(o(t)):oe)},L.jsxs=function(t,g,E){var b=1e4>U.recentlyCreatedOwnerStacks++;return s(t,g,E,!0,b?Error("react-stack-top-frame"):ne,b?M(o(t)):oe)}})()),L}var K;function le(){return K||(K=1,process.env.NODE_ENV==="production"?D.exports=ie():D.exports=ce()),D.exports}var P=le();const ue=({IMaskMixin:e,...r})=>{const a=f.useMemo(()=>e(({TextField:o,...n})=>P.jsx(o,{...n})),[e]);return P.jsx(a,{...r})},C=f.createContext({}),de=({children:e,apiURL:r,libraries:a,localStorageKeys:o})=>{const n=f.useMemo(()=>({apiURL:r,libraries:a,localStorageKeys:o}),[r,a,o]);return P.jsx(C.Provider,{value:n,children:e})},fe=({data:e,...r})=>{const{libraries:a}=f.useContext(C),o=r?.reactRouter||a?.reactRouter,n=r?.gtm||a?.gtm;if(!o)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");if(!n)throw new Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");const{useGoogleTagManager:i}=n,{useLocation:c,Outlet:u}=o,{pathname:l}=c(),{sendEvent:p}=i();return f.useEffect(()=>{p({event:"pageView",pathname:l,...e})},[e,l,p]),P.jsx(u,{})},F=(()=>{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}})(),pe="user",ge=({tokenTypeKey:e="tokenType",tokenKey:r="accessToken",postContentType:a="application/json",...o})=>{const{apiURL:n=o.apiURL,libraries:i,localStorageKeys:c}=f.useContext(C),u=o?.userLocalStorageKey||c?.user||pe,l=o?.axios||i?.axios;if(!l)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!l?.defaults||F)return null;if(typeof window<"u"&&window.localStorage){const p=localStorage.getItem(u),s=p?JSON.parse(p):null,y=s?.[e]?s[e]:null,h=s?.[r]?s[r]:null,w=p?`${y} ${h}`:null;w&&(l.defaults.headers.common.Authorization=w)}return l.defaults.baseURL=n,l.defaults.headers.post["Content-Type"]=a,null},me=({language:e,...r})=>{const{libraries:a}=f.useContext(C),o=r?.dayjs||a?.dayjs,n=r?.plugin||a?.dayjsPlugin;if(!o)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig.");return f.useEffect(()=>{(async()=>{const c=e||navigator.language?.slice(0,2)||"en";n&&n.forEach(u=>{u&&o.extend(u)}),await import("dayjs/locale/en"),await import("dayjs/locale/fr"),o.locale(c)})().then()},[o,n,e]),null},he=({debug:e,resources:r,...a})=>{const{libraries:o}=f.useContext(C),n=a?.i18||o?.i18,{i18next:i,initReactI18next:c,languageDetector:u}=n||{};if(F)return null;if(!n)throw new Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return i?.isInitialized||(i.use(u).use(c).init({debug:e,fallbackLng:"en",interpolation:{escapeValue:!1},load:"languageOnly",react:{bindI18n:"languageChanged loaded",useSuspense:!0},resources:r,returnNull:!1}).then(()=>{document.documentElement.lang!==i.resolvedLanguage&&i.resolvedLanguage&&document.documentElement.setAttribute("lang",i.resolvedLanguage)}),i.on("languageChanged",l=>{document.documentElement.setAttribute("lang",l)})),null},ye=({dsn:e,integrations:r,tracesSampleRate:a,replaysSessionSampleRate:o,replaysOnErrorSampleRate:n,tracePropagationTargets:i,ignoreErrors:c,debug:u,environment:l,release:p,...s})=>{const{libraries:y}=f.useContext(C),h=s?.sentry||y?.sentry,w=s?.reactRouter||y?.reactRouter;if(!h)throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!w)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(h.isInitialized())return null;const{createRoutesFromChildren:T,matchRoutes:j,useLocation:k,useNavigationType:v}=w;return(u||process.env.NODE_ENV==="prod"||process.env.NODE_ENV==="production")&&h.init({debug:u,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:[h.reactRouterV6BrowserTracingIntegration({createRoutesFromChildren:T,matchRoutes:j,useEffect:f.useEffect,useLocation:k,useNavigationType:v}),...r||[]],release:p,replaysOnErrorSampleRate:n||1,replaysSessionSampleRate:o||.1,tracePropagationTargets:i,tracesSampleRate:a||1}),null},ve=()=>(f.useEffect(()=>{if(F)return;const e=r=>{try{r.preventDefault(),r.stopPropagation(),r.stopImmediatePropagation(),window.location.reload()}catch{}};return window.addEventListener("vite:preloadError",e),()=>{window.removeEventListener("vite:preloadError",e)}},[]),null),H=new WeakMap,Ee="user",we=({Fallback:e,isLogged:r,loginPath:a="/login",redirect401Path:o="/login",...n})=>{const{libraries:i,localStorageKeys:c}=f.useContext(C),u=n?.reactRouter||i?.reactRouter,l=n?.axios||i?.axios,p=n?.localStorageKey||c?.user||Ee;if(!u)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");const[s,y]=f.useState(null),{useLocation:h,Navigate:w,Outlet:T}=u,j=h(),k=typeof r=="function"?r():!!r,v=typeof k=="boolean"?k:k?.isLogged;return f.useEffect(()=>{H.has(l)||(H.set(l,!0),l.interceptors.response.use(d=>d,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(p)),y(o)),Promise.reject(d))))},[l,p,o]),v&&!s?P.jsx(f.Suspense,{fallback:e,children:j.state?.from?.state&&j.state?.from?.pathname===a?P.jsx(w,{to:j.state.from.state.from.pathname+j.state.from.state.from.search,replace:!0}):P.jsx(T,{})}):P.jsx(w,{to:a+j.search,state:{from:j},replace:!0})},be=async()=>{if("serviceWorker"in navigator)try{const e=await navigator.serviceWorker.getRegistrations();await Promise.all(e.map(r=>r.unregister()))}catch(e){console.error("Failed to unregister service workers:",e)}},Re=()=>(f.useEffect(()=>{be()},[]),null),Se=async()=>{if("caches"in window)try{const e=await caches.keys();await Promise.all(e.map(r=>caches.delete(r)))}catch(e){console.error("Failed to clear caches:",e)}},_e=({autoUpdate:e,renderDialog:r,clearCachesOnReload:a})=>{const o=f.useRef(null),[n,i]=f.useState(!1),c=f.useCallback(()=>{if(o.current&&o.current.postMessage({type:"SKIP_WAITING"}),a)try{localStorage.setItem("tracktor_clear_caches","1")}catch{}window.location.reload()},[a]);f.useEffect(()=>{try{localStorage.getItem("tracktor_clear_caches")==="1"&&(localStorage.removeItem("tracktor_clear_caches"),Se().catch(console.error))}catch{}},[]);const u=f.useCallback(()=>{window.confirm("A new version is available. The app will reload now.")&&c()},[c]);return f.useEffect(()=>{if(!("serviceWorker"in navigator))return;let l,p;const s=h=>{h&&navigator.serviceWorker.controller&&(o.current=h,i(!0))},y=()=>{const h=l?.installing;h&&(p=()=>{h.state==="installed"&&s(h)},h.addEventListener("statechange",p))};return(async()=>{l=await navigator.serviceWorker.getRegistration(),l&&(s(l.waiting),l.addEventListener("updatefound",y))})().catch(console.error),()=>{l?.removeEventListener("updatefound",y),p&&l?.installing&&l.installing.removeEventListener("statechange",p)}},[]),f.useEffect(()=>{n&&e&&c()},[e,n,c]),f.useEffect(()=>{n&&!e&&!r&&u()},[r,u,n,e]),n&&!e&&r?r(c):null},Ae=e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),Ce=e=>{const r=e.split(/[/\\]/).pop()||"";return r.substring(0,r.lastIndexOf("."))},je=e=>{const o=e.split("/").filter(n=>n.length>0).map(n=>n.replace(/\${([^}]*)}/g,"$1").split(/[_-]/).map(l=>l.charAt(0).toUpperCase()+l.slice(1)).join("")).join("");return o.charAt(0).toLowerCase()+o.slice(1)},ke=e=>(e.split("/").pop()||e).replace(/\.json$/,"").replace(/^openapi\./,""),Pe=(e,r,a,o)=>{const n=je(r),i=Ae(a),c=`${n}${i}`;return e&&typeof e=="object"&&"operationId"in e&&o?.includes(String(e.operationId))?`${c}AsQuery`:c},Te=(e,r)=>{const a={};return e?.forEach(o=>{a[o]={query:{useInfinite:!0,useInfiniteQueryParam:"offset",useQuery:!0}}}),r?.filter(o=>!a[o]).forEach(o=>{a[o]={query:{useQuery:!0}}}),Object.keys(a).length?a:void 0},Ie=e=>(Array.isArray(e)?e:[e]).reduce((a,o)=>{const{output:n,useInfiniteIds:i,useQueryIds:c,input:u="./openapi.json",customAxiosInstancePath:l,overrideApiName:p}=o||{},s=p||ke(u),y=l||"./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts";return{...a,[s]:{input:u,output:{baseUrl:n?.baseUrl,client:"react-query",mode:"tags-split",override:{...(i?.length||c?.length)&&{operations:Te(i,c)},header:h=>["Generated by orval 🍺",...h.title?[h.title]:[],...h.description?[h.description]:[]],mutator:{name:Ce(y),path:y},operationName:(h,w,T)=>Pe(h,w,T,c),query:{useQuery:!0}},schemas:n?.schemas||`src/api/${s}/model`,target:n?.target||`src/api/${s}/services/api.ts`,...n}}}},{}),Oe=e=>e&&typeof e=="function",xe=e=>e&&typeof e=="function",Ne=({children:e,defaultQueriesOptions:r,defaultMutationsOptions:a,...o})=>{const{libraries:n}=f.useContext(C),i=o?.QueryClient||n?.reactQuery?.QueryClient,c=o?.QueryClientProvider||n?.reactQuery?.QueryClientProvider;if(!i)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(!Oe(c))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!xe(i))throw new Error("Provided QueryClient dependencies are not valid.");const u=new i({defaultOptions:{mutations:{...a},queries:{getNextPageParam:(l,p,s)=>l.length+(s||0),refetchOnWindowFocus:!1,retry:3,...r}}});return P.jsx(c,{client:u,children:e})},B=({library:e,date:r,format:a="ll"})=>e(r).format(a),X=(e,r)=>{const{fractionDigits:a=0,metric:o="km",spacingBetween:n=!0}=r||{},i=Number(e),c=n?" ":"";return Number.isNaN(i)?`0${c}${o}`:`${i.toFixed(a)}${c}${o}`},Z=e=>!e||typeof e!="string"?"":e.replace(/_/g," ").toLowerCase().split(" ").map(a=>a.length>0?a.charAt(0).toUpperCase()+a.slice(1):a).join(" "),Le=e=>e?.startsWith("/")?e?.startsWith("/files")?e:`/files${e}`:e?.startsWith("files")?`/${e}`:`/files/${e}`,Fe=({path:e,size:r,apiURL:a})=>{if(!e)return"";const o=Le(e),n=`${a}${o}`,i=n.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/)!==null;return typeof r=="number"&&i?`${n.replace("/files",`/thumbs/${r}`)}`:n},De=e=>{const{apiURL:r,libraries:a}=f.useContext(C),o=e?.dayjs||a?.dayjs;return{dateAdapter:(c,u)=>{if(!o)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return B({date:c,format:u,library:o})},distanceAdapter:X,filePathAdapter:(c,u)=>{if(!r)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:Fe({apiURL:r,path:c,size:u})},worksiteNameAdapter:Z}},We=e=>{const{libraries:r,localStorageKeys:a}=f.useContext(C),o=e?.axios||r?.axios,n=e?.localStorageKey||a?.user||"user";if(!o)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");const i=f.useCallback(({tokenType:u,accessToken:l})=>{o.defaults.headers.common.Authorization=`${u} ${l}`},[o.defaults.headers.common]),c=()=>{o.defaults.headers.common.Authorization=null};return f.useEffect(()=>{if(F)return;const u=({newValue:l,key:p})=>{if(p===n&&l)try{const{accessToken:s,tokenType:y}=JSON.parse(l);i({accessToken:s,tokenType:y})}catch(s){console.error("Failed to parse newValue from localStorage:",s)}};return window.addEventListener("storage",u),()=>{window.removeEventListener("storage",u)}},[n,i]),{clearAuthenticationToken:c,setAuthenticationToken:i}},W=(e,r)=>r==="short"?e.split("-")[0]:e,Ye=(e,r="full")=>{const[a,o]=f.useState(()=>{const n=e?.language||navigator.language;return e&&"isInitialized"in e&&e.isInitialized,W(n,r)});return f.useEffect(()=>{e&&"isInitialized"in e&&e.isInitialized&&e.language&&o(W(e.language,r));const n=i=>{o(W(i,r))};return e?.on?.("languageChanged",n),()=>{e?.off?.("languageChanged",n)}},[e,r]),a},ze="tracktor.filter",Ue={getFilter:()=>{},getFilters:()=>({}),handleFilter:()=>()=>{},setFilter:()=>{}},q=e=>{try{return JSON.parse(e)}catch{return e}},$=(e,r,a)=>`${a}_${e}=>${r}`,Me=e=>e.reduce((r,a)=>{const o=localStorage.getItem(a);if(o)try{const n=JSON.parse(o),i=Object.keys(n)?.[0];i&&(r[i]=Object.values(n)?.[0])}catch{}return r},{}),Qe=e=>{const{libraries:r,localStorageKeys:a}=f.useContext(C),o=e?.reactRouter||r?.reactRouter,{pathname:n}=o?.useLocation?.()??{pathname:"/"},[i,c]=o?.useSearchParams?.()??[new URLSearchParams,()=>{}],[u,l]=f.useState({}),p=a?.filter||ze,s=e?.syncWithUrl===void 0?!0:e?.syncWithUrl,y=e?.persistToLocalStorage===void 0?!0:e?.persistToLocalStorage;if(F)return Ue;if(!o)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter.");const h=()=>Object.keys(localStorage).filter(v=>v.startsWith(p)&&v.endsWith(e?.pathname||n)),w=(v,d,_=!0)=>{const S=$(v,e?.pathname||n,p);if(!d||Array.isArray(d)&&!d.length){s?(i.delete(v),c(i)):l(A=>{const I={...A};return delete I[v],I}),y&&localStorage.removeItem(S);return}y&&_&&d&&localStorage.setItem(S,JSON.stringify({...i,[v]:d})),s&&d?(i.set(v,JSON.stringify(d)),c(i)):!s&&d&&l(A=>({...A,[v]:d}))};return{getFilter:(v,d)=>{if(s){const _=i.get(v);if(_)return q(_)}else{const _=u[v];if(_!==void 0)return _}if(y){const _=$(v,e?.pathname||n,p),S=localStorage.getItem(_);if(S)try{const A=JSON.parse(S)[v];return!s&&A!==void 0&&l(I=>({...I,[v]:A})),A}catch{}}return d},getFilters:()=>{const v=y?Me(h()):{};if(s){const d=Array.from(i.entries()).reduce((_,[S,A])=>(_[S]=q(A),_),{});return{...v,...d}}return{...v,...u}},handleFilter:(v,d)=>(_,S)=>{if(S||Array.isArray(S)&&S.length===0){const A=d||"value",I=typeof S=="object"&&A in S?S[A]:S;w(v,I);return}w(v,void 0)},setFilter:w}},Ve=({data:e,fetchNextPage:r,isFetchingNextPage:a,isInitialLoading:o,isLoading:n,enabled:i=!0})=>{const c=f.useCallback(async l=>{a||!i||await r({pageParam:l?.pageParam||l.visibleRowsCount})},[i,r,a]),u=f.useMemo(()=>{if(e)return e.pages.reduce((l,p)=>[...l,...p],[])},[e]);return{fetchNextPageOnRowsScrollEnd:c,isLoading:a||n,loadingVariant:o?"skeleton":"linear-progress",rows:u}},Ge=e=>{const{libraries:r}=f.useContext(C),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),u=f.useCallback(p=>{if(p&&typeof p=="object"&&"response"in p){const{response:s}=p||{};if(s&&typeof s=="object"&&"reason"in s&&s.reason)return String(s.reason);if(s&&typeof s=="object"&&"data"in s&&s.data&&typeof s.data=="object"&&"reason"in s.data&&s.data.reason)return String(s.data.reason);if(s&&typeof s=="object"&&"data"in s&&s.data&&typeof s.data=="object"&&"message"in s.data&&s.data.message)return String(s.data.message);if(s&&typeof s=="object"&&"data"in s&&s.data&&typeof s.data=="object"&&"detail"in s.data){const{detail:y}=s.data;if(Array.isArray(y)&&y.length>0&&typeof y[0]=="object"&&y[0]!==null&&"msg"in y[0]){const{msg:h}=y[0];if(typeof h=="string")return String(h)}}}return p instanceof Error?p.message:c},[c]);return{getErrorCode:f.useCallback(p=>{const{response:s}=p||{};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"},[]),printError:u}};m.GTMSendPageView=fe,m.InitializeAxiosConfig=ge,m.InitializeDaysJSConfig=me,m.InitializeI18nConfig=he,m.InitializeSentryConfig=ye,m.InjectDependenciesContext=C,m.InjectDependenciesProvider=de,m.MaskTextField=ue,m.PreloadErrorHandler=ve,m.QueryClientProviderWithConfig=Ne,m.RequireAuth=we,m.ServiceWorkerCleaner=Re,m.UpdateNotifier=_e,m.axiosCustomInstance=se,m.dateAdapter=B,m.distanceAdapter=X,m.getOrvalConfig=Ie,m.useAdapter=De,m.useAuth=We,m.useCurrentLanguage=Ye,m.useFilters=Qe,m.useInfiniteDataGrid=Ve,m.useResponseError=Ge,m.worksiteNameAdapter=Z,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tracktor/shared-module",
3
- "version": "2.20.1",
3
+ "version": "2.21.0",
4
4
  "type": "module",
5
5
  "license": "UNLICENSED",
6
6
  "types": "./dist/main.d.ts",