@tracktor/shared-module 2.20.1 → 2.20.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import Z from "axios";
2
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
3
  const We = (e, r) => {
4
- const o = Z.CancelToken.source(), a = Z({
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";
@@ -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"), A = /* @__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;
@@ -271,38 +271,38 @@ function ve() {
271
271
  }
272
272
  var C = ve();
273
273
  const ze = ({ IMaskMixin: e, ...r }) => {
274
- const o = G(
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
+ }, S = pe({}), Ue = ({ 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
289
  return /* @__PURE__ */ C.jsx(S.Provider, { value: n, children: e });
290
290
  }, Qe = ({ data: e, ...r }) => {
291
- const { libraries: o } = P(S), a = r?.reactRouter || o?.reactRouter, n = r?.gtm || o?.gtm;
292
- if (!a)
291
+ const { libraries: a } = P(S), 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();
298
+ const { useGoogleTagManager: s } = n, { useLocation: c, Outlet: u } = o, { pathname: l } = c(), { sendEvent: f } = s();
299
299
  return j(() => {
300
- d({
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
@@ -314,22 +314,22 @@ const ze = ({ IMaskMixin: e, ...r }) => {
314
314
  })(), we = "user", Ve = ({
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(S), 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;
329
+ return l.defaults.baseURL = n, l.defaults.headers.post["Content-Type"] = a, null;
330
330
  }, Me = ({ language: e, ...r }) => {
331
- const { libraries: o } = P(S), a = r?.dayjs || o?.dayjs, n = r?.plugin || o?.dayjsPlugin;
332
- if (!a)
331
+ const { libraries: a } = P(S), 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
  );
@@ -337,12 +337,12 @@ const ze = ({ IMaskMixin: e, ...r }) => {
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
+ }, Ge = ({ debug: e, resources: r, ...a }) => {
345
+ const { libraries: o } = P(S), n = a?.i18 || o?.i18, { i18next: s, initReactI18next: c, languageDetector: u } = n || {};
346
346
  if (F)
347
347
  return null;
348
348
  if (!n)
@@ -368,14 +368,14 @@ const ze = ({ IMaskMixin: e, ...r }) => {
368
368
  }, Je = ({
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
381
  const { libraries: m } = P(S), g = i?.sentry || m?.sentry, v = i?.reactRouter || m?.reactRouter;
@@ -409,11 +409,11 @@ const ze = ({ IMaskMixin: e, ...r }) => {
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
418
  }, qe = () => (j(() => {
419
419
  if (F)
@@ -427,17 +427,17 @@ 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", Ke = ({ Fallback: e, isLogged: r, loginPath: a = "/login", redirect401Path: o = "/login", ...n }) => {
431
+ const { libraries: s, localStorageKeys: c } = P(S), 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
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
435
  return j(() => {
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: 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(k, {}) }) : /* @__PURE__ */ C.jsx(v, { to: a + A.search, state: { from: A }, replace: !0 });
441
441
  }, Re = async () => {
442
442
  if ("caches" in window)
443
443
  try {
@@ -446,10 +446,10 @@ const ze = ({ IMaskMixin: e, ...r }) => {
446
446
  } catch (e) {
447
447
  console.error("Failed to clear caches:", e);
448
448
  }
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]);
449
+ }, He = ({ autoUpdate: e, renderDialog: r, clearCachesOnReload: a }) => {
450
+ const o = me(null), [n, s] = W(!1), c = O(() => {
451
+ o.current && o.current.postMessage({ type: "SKIP_WAITING" }), a && localStorage.setItem("tracktor_clear_caches", "1"), window.location.reload();
452
+ }, [a]);
453
453
  j(() => {
454
454
  localStorage.getItem("tracktor_clear_caches") === "1" && (localStorage.removeItem("tracktor_clear_caches"), Re().catch(console.error));
455
455
  }, []);
@@ -459,19 +459,19 @@ const ze = ({ IMaskMixin: e, ...r }) => {
459
459
  return j(() => {
460
460
  if (!("serviceWorker" in navigator))
461
461
  return;
462
- let l, d;
462
+ let l, f;
463
463
  const i = (g) => {
464
- g && navigator.serviceWorker.controller && (a.current = g, s(!0));
464
+ g && navigator.serviceWorker.controller && (o.current = g, s(!0));
465
465
  }, m = () => {
466
466
  const g = l?.installing;
467
- g && (d = () => {
467
+ g && (f = () => {
468
468
  g.state === "installed" && i(g);
469
- }, g.addEventListener("statechange", d));
469
+ }, g.addEventListener("statechange", f));
470
470
  };
471
471
  return (async () => {
472
472
  l = await navigator.serviceWorker.getRegistration(), l && (i(l.waiting), l.addEventListener("updatefound", m));
473
473
  })().catch(console.error), () => {
474
- l?.removeEventListener("updatefound", m), d && l?.installing && l.installing.removeEventListener("statechange", d);
474
+ l?.removeEventListener("updatefound", m), f && l?.installing && l.installing.removeEventListener("statechange", f);
475
475
  };
476
476
  }, []), j(() => {
477
477
  n && e && c();
@@ -482,32 +482,32 @@ const ze = ({ IMaskMixin: e, ...r }) => {
482
482
  const r = e.split(/[/\\]/).pop() || "";
483
483
  return r.substring(0, r.lastIndexOf("."));
484
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;
485
+ 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("");
486
+ return o.charAt(0).toLowerCase() + o.slice(1);
487
+ }, Ae = (e) => (e.split("/").pop() || e).replace(/\.json$/, "").replace(/^openapi\./, ""), je = (e, r, a, o) => {
488
+ const n = Se(r), s = be(a), c = `${n}${s}`;
489
+ return e && typeof e == "object" && "operationId" in e && o?.includes(String(e.operationId)) ? `${c}AsQuery` : c;
490
490
  }, Pe = (e, r) => {
491
- const o = {};
492
- return e?.forEach((a) => {
493
- o[a] = {
491
+ const a = {};
492
+ return e?.forEach((o) => {
493
+ a[o] = {
494
494
  query: {
495
495
  useInfinite: !0,
496
496
  useInfiniteQueryParam: "offset",
497
497
  useQuery: !0
498
498
  }
499
499
  };
500
- }), r?.filter((a) => !o[a]).forEach((a) => {
501
- o[a] = {
500
+ }), r?.filter((o) => !a[o]).forEach((o) => {
501
+ a[o] = {
502
502
  query: {
503
503
  useQuery: !0
504
504
  }
505
505
  };
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";
506
+ }), Object.keys(a).length ? a : void 0;
507
+ }, Be = (e) => (Array.isArray(e) ? e : [e]).reduce((a, o) => {
508
+ const { output: n, useInfiniteIds: s, useQueryIds: c, input: u = "./openapi.json", customAxiosInstancePath: l, overrideApiName: f } = o || {}, i = f || Ae(u), m = l || "./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts";
509
509
  return {
510
- ...o,
510
+ ...a,
511
511
  [i]: {
512
512
  input: u,
513
513
  output: {
@@ -541,10 +541,10 @@ const ze = ({ IMaskMixin: e, ...r }) => {
541
541
  }, {}), Te = (e) => e && typeof e == "function", ke = (e) => e && typeof e == "function", Xe = ({
542
542
  children: e,
543
543
  defaultQueriesOptions: r,
544
- defaultMutationsOptions: o,
545
- ...a
544
+ defaultMutationsOptions: a,
545
+ ...o
546
546
  }) => {
547
- const { libraries: n } = P(S), s = a?.QueryClient || n?.reactQuery?.QueryClient, c = a?.QueryClientProvider || n?.reactQuery?.QueryClientProvider;
547
+ const { libraries: n } = P(S), s = o?.QueryClient || n?.reactQuery?.QueryClient, c = o?.QueryClientProvider || n?.reactQuery?.QueryClientProvider;
548
548
  if (!s)
549
549
  throw new Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
550
550
  if (!c)
@@ -556,10 +556,10 @@ const ze = ({ IMaskMixin: e, ...r }) => {
556
556
  const u = new s({
557
557
  defaultOptions: {
558
558
  mutations: {
559
- ...o
559
+ ...a
560
560
  },
561
561
  queries: {
562
- getNextPageParam: (l, d, i) => l.length + (i || 0),
562
+ getNextPageParam: (l, f, i) => l.length + (i || 0),
563
563
  refetchOnWindowFocus: !1,
564
564
  retry: 3,
565
565
  ...r
@@ -567,24 +567,24 @@ const ze = ({ IMaskMixin: e, ...r }) => {
567
567
  }
568
568
  });
569
569
  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 }) => {
570
+ }, Ce = ({ library: e, date: r, format: a = "ll" }) => e(r).format(a), Ie = (e, r) => {
571
+ const { fractionDigits: a = 0, metric: o = "km", spacingBetween: n = !0 } = r || {}, s = Number(e), c = n ? " " : "";
572
+ return Number.isNaN(s) ? `0${c}${o}` : `${s.toFixed(a)}${c}${o}`;
573
+ }, 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(" "), Oe = (e) => e?.startsWith("/") ? e?.startsWith("/files") ? e : `/files${e}` : e?.startsWith("files") ? `/${e}` : `/files/${e}`, Le = ({ path: e, size: r, apiURL: a }) => {
574
574
  if (!e)
575
575
  return "";
576
- const a = Oe(e), n = `${o}${a}`, s = n.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/) !== null;
576
+ const o = Oe(e), n = `${a}${o}`, s = n.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/) !== null;
577
577
  return typeof r == "number" && s ? `${n.replace("/files", `/thumbs/${r}`)}` : n;
578
578
  }, Ze = (e) => {
579
- const { apiURL: r, libraries: o } = P(S), a = e?.dayjs || o?.dayjs;
579
+ const { apiURL: r, libraries: a } = P(S), o = e?.dayjs || a?.dayjs;
580
580
  return {
581
581
  dateAdapter: (c, u) => {
582
- if (!a)
582
+ if (!o)
583
583
  throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
584
584
  return Ce({
585
585
  date: c,
586
586
  format: u,
587
- library: a
587
+ library: o
588
588
  });
589
589
  },
590
590
  distanceAdapter: Ie,
@@ -602,50 +602,50 @@ const ze = ({ IMaskMixin: e, ...r }) => {
602
602
  worksiteNameAdapter: xe
603
603
  };
604
604
  }, et = (e) => {
605
- const { libraries: r } = P(S), o = e?.axios || r?.axios, a = e?.localStorageKey || "user";
605
+ const { libraries: r, localStorageKeys: a } = P(S), o = e?.axios || r?.axios, n = e?.localStorageKey || a?.user || "user";
606
606
  if (!o)
607
607
  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}`;
608
+ const s = O(
609
+ ({ tokenType: u, accessToken: l }) => {
610
+ o.defaults.headers.common.Authorization = `${u} ${l}`;
611
611
  },
612
612
  [o.defaults.headers.common]
613
- ), s = () => {
613
+ ), c = () => {
614
614
  o.defaults.headers.common.Authorization = null;
615
615
  };
616
616
  return j(() => {
617
617
  if (F)
618
618
  return;
619
- const c = ({ newValue: u, key: l }) => {
620
- if (l === a && u)
619
+ const u = ({ newValue: l, key: f }) => {
620
+ if (f === n && l)
621
621
  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);
622
+ const { accessToken: i, tokenType: m } = JSON.parse(l);
623
+ s({ accessToken: i, tokenType: m });
624
+ } catch (i) {
625
+ console.error("Failed to parse newValue from localStorage:", i);
626
626
  }
627
627
  };
628
- return window.addEventListener("storage", c), () => {
629
- window.removeEventListener("storage", c);
628
+ return window.addEventListener("storage", u), () => {
629
+ window.removeEventListener("storage", u);
630
630
  };
631
- }, [a, n]), {
632
- clearAuthenticationToken: s,
633
- setAuthenticationToken: n
631
+ }, [n, s]), {
632
+ clearAuthenticationToken: c,
633
+ setAuthenticationToken: s
634
634
  };
635
635
  }, Y = (e, r) => r === "short" ? e.split("-")[0] : e, tt = (e, r = "full") => {
636
- const [o, a] = W(() => {
636
+ const [a, o] = W(() => {
637
637
  const n = e?.language || navigator.language;
638
638
  return e && "isInitialized" in e && e.isInitialized, Y(n, r);
639
639
  });
640
640
  return j(() => {
641
- e && "isInitialized" in e && e.isInitialized && e.language && a(Y(e.language, r));
641
+ e && "isInitialized" in e && e.isInitialized && e.language && o(Y(e.language, r));
642
642
  const n = (s) => {
643
- a(Y(s, r));
643
+ o(Y(s, r));
644
644
  };
645
645
  return e?.on?.("languageChanged", n), () => {
646
646
  e?.off?.("languageChanged", n);
647
647
  };
648
- }, [e, r]), o;
648
+ }, [e, r]), a;
649
649
  }, Ne = "tracktor.filter", Fe = {
650
650
  getFilter: () => {
651
651
  },
@@ -660,39 +660,39 @@ const ze = ({ IMaskMixin: e, ...r }) => {
660
660
  } catch {
661
661
  return e;
662
662
  }
663
- }, ae = (e, r, o) => `${o}_${e}=>${r}`, $e = (e) => e.reduce((r, o) => {
664
- const a = localStorage.getItem(o);
665
- if (a)
663
+ }, ae = (e, r, a) => `${a}_${e}=>${r}`, $e = (e) => e.reduce((r, a) => {
664
+ const o = localStorage.getItem(a);
665
+ if (o)
666
666
  try {
667
- const n = JSON.parse(a), s = Object.keys(n)?.[0];
667
+ const n = JSON.parse(o), s = Object.keys(n)?.[0];
668
668
  s && (r[s] = Object.values(n)?.[0]);
669
669
  } catch {
670
670
  }
671
671
  return r;
672
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;
673
+ const { libraries: r, localStorageKeys: a } = P(S), o = e?.reactRouter || r?.reactRouter, { pathname: n } = o?.useLocation?.() ?? { pathname: "/" }, [s, c] = o?.useSearchParams?.() ?? [new URLSearchParams(), () => {
674
+ }], [u, l] = W({}), f = a?.filter || Ne, i = e?.syncWithUrl === void 0 ? !0 : e?.syncWithUrl, m = e?.persistToLocalStorage === void 0 ? !0 : e?.persistToLocalStorage;
675
675
  if (F)
676
676
  return Fe;
677
- if (!a)
677
+ if (!o)
678
678
  throw new Error(
679
679
  "React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter."
680
680
  );
681
681
  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) {
682
+ (h) => h.startsWith(f) && h.endsWith(e?.pathname || n)
683
+ ), v = (h, d, b = !0) => {
684
+ const R = ae(h, e?.pathname || n, f);
685
+ if (!d || Array.isArray(d) && !d.length) {
686
686
  i ? (s.delete(h), c(s)) : l((_) => {
687
687
  const I = { ..._ };
688
688
  return delete I[h], I;
689
689
  }), m && localStorage.removeItem(R);
690
690
  return;
691
691
  }
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 }));
692
+ 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
693
  };
694
694
  return {
695
- getFilter: (h, f) => {
695
+ getFilter: (h, d) => {
696
696
  if (i) {
697
697
  const b = s.get(h);
698
698
  if (b)
@@ -703,7 +703,7 @@ const ze = ({ IMaskMixin: e, ...r }) => {
703
703
  return b;
704
704
  }
705
705
  if (m) {
706
- const b = ae(h, e?.pathname || n, d), R = localStorage.getItem(b);
706
+ const b = ae(h, e?.pathname || n, f), R = localStorage.getItem(b);
707
707
  if (R)
708
708
  try {
709
709
  const _ = JSON.parse(R)[h];
@@ -711,15 +711,15 @@ const ze = ({ IMaskMixin: e, ...r }) => {
711
711
  } catch {
712
712
  }
713
713
  }
714
- return f;
714
+ return d;
715
715
  },
716
716
  getFilters: () => {
717
717
  const h = m ? $e(g()) : {};
718
718
  if (i) {
719
- const f = Array.from(s.entries()).reduce((b, [R, _]) => (b[R] = oe(_), b), {});
719
+ const d = Array.from(s.entries()).reduce((b, [R, _]) => (b[R] = oe(_), b), {});
720
720
  return {
721
721
  ...h,
722
- ...f
722
+ ...d
723
723
  };
724
724
  }
725
725
  return {
@@ -727,9 +727,9 @@ const ze = ({ IMaskMixin: e, ...r }) => {
727
727
  ...u
728
728
  };
729
729
  },
730
- handleFilter: (h, f) => (b, R) => {
730
+ handleFilter: (h, d) => (b, R) => {
731
731
  if (R || Array.isArray(R) && R.length === 0) {
732
- const _ = f || "value", I = typeof R == "object" && _ in R ? R[_] : R;
732
+ const _ = d || "value", I = typeof R == "object" && _ in R ? R[_] : R;
733
733
  v(h, I);
734
734
  return;
735
735
  }
@@ -740,31 +740,31 @@ const ze = ({ IMaskMixin: e, ...r }) => {
740
740
  }, nt = ({
741
741
  data: e,
742
742
  fetchNextPage: r,
743
- isFetchingNextPage: o,
744
- isInitialLoading: a,
743
+ isFetchingNextPage: a,
744
+ isInitialLoading: o,
745
745
  isLoading: n,
746
746
  enabled: s = !0
747
747
  }) => {
748
748
  const c = O(
749
749
  async (l) => {
750
- o || !s || await r({ pageParam: l?.pageParam || l.visibleRowsCount });
750
+ a || !s || await r({ pageParam: l?.pageParam || l.visibleRowsCount });
751
751
  },
752
- [s, r, o]
752
+ [s, r, a]
753
753
  ), u = G(() => {
754
754
  if (e)
755
- return e.pages.reduce((l, d) => [...l, ...d], []);
755
+ return e.pages.reduce((l, f) => [...l, ...f], []);
756
756
  }, [e]);
757
757
  return {
758
758
  fetchNextPageOnRowsScrollEnd: c,
759
- isLoading: o || n,
760
- loadingVariant: a ? "skeleton" : "linear-progress",
759
+ isLoading: a || n,
760
+ loadingVariant: o ? "skeleton" : "linear-progress",
761
761
  rows: u
762
762
  };
763
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 || {};
764
+ const { libraries: r } = P(S), 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(
765
+ (f) => {
766
+ if (f && typeof f == "object" && "response" in f) {
767
+ const { response: i } = f || {};
768
768
  if (i && typeof i == "object" && "reason" in i && i.reason)
769
769
  return String(i.reason);
770
770
  if (i && typeof i == "object" && "data" in i && i.data && typeof i.data == "object" && "reason" in i.data && i.data.reason)
@@ -780,12 +780,12 @@ const ze = ({ IMaskMixin: e, ...r }) => {
780
780
  }
781
781
  }
782
782
  }
783
- return d instanceof Error ? d.message : c;
783
+ return f instanceof Error ? f.message : c;
784
784
  },
785
785
  [c]
786
786
  );
787
- return { getErrorCode: O((d) => {
788
- const { response: i } = d || {};
787
+ return { getErrorCode: O((f) => {
788
+ const { response: i } = f || {};
789
789
  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
790
  }, []), printError: u };
791
791
  };
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(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 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===Ke?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case P:return"Fragment";case d: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 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===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 f(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:
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),f(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"),d=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(o(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(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 T=le();const ue=({IMaskMixin:e,...r})=>{const a=p.useMemo(()=>e(({TextField:o,...n})=>T.jsx(o,{...n})),[e]);return T.jsx(a,{...r})},C=p.createContext({}),de=({children:e,apiURL:r,libraries:a,localStorageKeys:o})=>{const n=p.useMemo(()=>({apiURL:r,libraries:a,localStorageKeys:o}),[r,a,o]);return T.jsx(C.Provider,{value:n,children:e})},fe=({data:e,...r})=>{const{libraries:a}=p.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:f}=i();return p.useEffect(()=>{f({event:"pageView",pathname:l,...e})},[e,l,f]),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:a="application/json",...o})=>{const{apiURL:n=o.apiURL,libraries:i,localStorageKeys:c}=p.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 f=localStorage.getItem(u),s=f?JSON.parse(f):null,y=s?.[e]?s[e]:null,m=s?.[r]?s[r]:null,w=f?`${y} ${m}`: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}=p.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 p.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}=p.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:f,...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:f,replaysOnErrorSampleRate:n||1,replaysSessionSampleRate:o||.1,tracePropagationTargets:i,tracesSampleRate:a||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:a="/login",redirect401Path:o="/login",...n})=>{const{libraries:i,localStorageKeys:c}=p.useContext(C),u=n?.reactRouter||i?.reactRouter,l=n?.axios||i?.axios,f=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(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(f)),y(o)),Promise.reject(d))))},[l,f,o]),v&&!s?T.jsx(p.Suspense,{fallback:e,children:j.state?.from?.state&&j.state?.from?.pathname===a?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:a+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:a})=>{const o=p.useRef(null),[n,i]=p.useState(!1),c=p.useCallback(()=>{o.current&&o.current.postMessage({type:"SKIP_WAITING"}),a&&localStorage.setItem("tracktor_clear_caches","1"),window.location.reload()},[a]);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,f;const s=m=>{m&&navigator.serviceWorker.controller&&(o.current=m,i(!0))},y=()=>{const m=l?.installing;m&&(f=()=>{m.state==="installed"&&s(m)},m.addEventListener("statechange",f))};return(async()=>{l=await navigator.serviceWorker.getRegistration(),l&&(s(l.waiting),l.addEventListener("updatefound",y))})().catch(console.error),()=>{l?.removeEventListener("updatefound",y),f&&l?.installing&&l.installing.removeEventListener("statechange",f)}},[]),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 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)},Ce=e=>(e.split("/").pop()||e).replace(/\.json$/,"").replace(/^openapi\./,""),je=(e,r,a,o)=>{const n=Ae(r),i=_e(a),c=`${n}${i}`;return e&&typeof e=="object"&&"operationId"in e&&o?.includes(String(e.operationId))?`${c}AsQuery`:c},Pe=(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},Te=e=>(Array.isArray(e)?e:[e]).reduce((a,o)=>{const{output:n,useInfiniteIds:i,useQueryIds:c,input:u="./openapi.json",customAxiosInstancePath:l,overrideApiName:f}=o||{},s=f||Ce(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: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:a,...o})=>{const{libraries:n}=p.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(!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:{...a},queries:{getNextPageParam:(l,f,s)=>l.length+(s||0),refetchOnWindowFocus:!1,retry:3,...r}}});return T.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(" "),xe=e=>e?.startsWith("/")?e?.startsWith("/files")?e:`/files${e}`:e?.startsWith("files")?`/${e}`:`/files/${e}`,Ne=({path:e,size:r,apiURL:a})=>{if(!e)return"";const o=xe(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},Le=e=>{const{apiURL:r,libraries:a}=p.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:Ne({apiURL:r,path:c,size:u})},worksiteNameAdapter:Z}},Fe=e=>{const{libraries:r,localStorageKeys:a}=p.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=p.useCallback(({tokenType:u,accessToken:l})=>{o.defaults.headers.common.Authorization=`${u} ${l}`},[o.defaults.headers.common]),c=()=>{o.defaults.headers.common.Authorization=null};return p.useEffect(()=>{if(F)return;const u=({newValue:l,key:f})=>{if(f===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}},Y=(e,r)=>r==="short"?e.split("-")[0]:e,De=(e,r="full")=>{const[a,o]=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&&o(Y(e.language,r));const n=i=>{o(Y(i,r))};return e?.on?.("languageChanged",n),()=>{e?.off?.("languageChanged",n)}},[e,r]),a},Ye="tracktor.filter",ze={getFilter:()=>{},getFilters:()=>({}),handleFilter:()=>()=>{},setFilter:()=>{}},q=e=>{try{return JSON.parse(e)}catch{return e}},$=(e,r,a)=>`${a}_${e}=>${r}`,We=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},{}),Ue=e=>{const{libraries:r,localStorageKeys:a}=p.useContext(C),o=e?.reactRouter||r?.reactRouter,{pathname:n}=o?.useLocation?.()??{pathname:"/"},[i,c]=o?.useSearchParams?.()??[new URLSearchParams,()=>{}],[u,l]=p.useState({}),f=a?.filter||Ye,s=e?.syncWithUrl===void 0?!0:e?.syncWithUrl,y=e?.persistToLocalStorage===void 0?!0:e?.persistToLocalStorage;if(F)return ze;if(!o)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(f)&&v.endsWith(e?.pathname||n)),w=(v,d,S=!0)=>{const _=$(v,e?.pathname||n,f);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(_);return}y&&S&&d&&localStorage.setItem(_,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 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,f),_=localStorage.getItem(S);if(_)try{const A=JSON.parse(_)[v];return!s&&A!==void 0&&l(I=>({...I,[v]:A})),A}catch{}}return d},getFilters:()=>{const v=y?We(m()):{};if(s){const d=Array.from(i.entries()).reduce((S,[_,A])=>(S[_]=q(A),S),{});return{...v,...d}}return{...v,...u}},handleFilter:(v,d)=>(S,_)=>{if(_||Array.isArray(_)&&_.length===0){const A=d||"value",I=typeof _=="object"&&A in _?_[A]:_;w(v,I);return}w(v,void 0)},setFilter:w}},Me=({data:e,fetchNextPage:r,isFetchingNextPage:a,isInitialLoading:o,isLoading:n,enabled:i=!0})=>{const c=p.useCallback(async l=>{a||!i||await r({pageParam:l?.pageParam||l.visibleRowsCount})},[i,r,a]),u=p.useMemo(()=>{if(e)return e.pages.reduce((l,f)=>[...l,...f],[])},[e]);return{fetchNextPageOnRowsScrollEnd:c,isLoading:a||n,loadingVariant:o?"skeleton":"linear-progress",rows:u}},Qe=e=>{const{libraries:r}=p.useContext(C),a=e?.i18||r?.i18,o=e?.i18?.translateFunction||r?.i18?.translateFunction,n=a?.i18next?.t||o||(f=>f),{unknownErrorTranslationKey:i="error.unknownError"}=e||{},c=n(i),u=p.useCallback(f=>{if(f&&typeof f=="object"&&"response"in f){const{response:s}=f||{};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 f instanceof Error?f.message:c},[c]);return{getErrorCode:p.useCallback(f=>{const{response:s}=f||{};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"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tracktor/shared-module",
3
- "version": "2.20.1",
3
+ "version": "2.20.2",
4
4
  "type": "module",
5
5
  "license": "UNLICENSED",
6
6
  "types": "./dist/main.d.ts",