@tracktor/shared-module 2.17.1 → 2.18.1

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/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # Changelog
2
2
 
3
- ## [2.17.1] - 2025-07-15
3
+ ## [2.18.0] - 2025-09-30
4
4
 
5
- ### 🔧 Fixes
6
- - fix behavior `syncWithUrl` to `useFilters`
5
+ ### Features
6
+ - introduce `UpdateNotifier` component to monitor Service Worker updates and prompt users when a new version of the app is available
7
+
8
+
9
+ ## [2.18.1] - 2025-10-01
10
+
11
+ ### ✨ Features
12
+ - `UpdateNotifier`: add `autoUpdate` prop to automatically reload the app when an update is detected, bypassing confirmation dialogs and custom UI.
@@ -0,0 +1,52 @@
1
+ import { ReactNode } from 'react';
2
+ export interface UpdateNotifierProps {
3
+ /**
4
+ * If true, automatically reloads the app when an update is detected,
5
+ * bypassing both window.confirm and custom UI.
6
+ */
7
+ autoUpdate?: boolean;
8
+ /**
9
+ * If true, clears all CacheStorage entries before reloading.
10
+ * Default false to avoid wiping host-origin caches unexpectedly.
11
+ */
12
+ clearCachesOnReload?: boolean;
13
+ /**
14
+ * Optional custom component to display when an update is available.
15
+ * It receives an `onReload` callback that should be called to reload the app.
16
+ */
17
+ renderDialog?: (handleReloadApp: () => void) => ReactNode;
18
+ }
19
+ /**
20
+ * UpdateNotifier monitors Service Worker updates and informs the user
21
+ * when a new version of the app is available.
22
+ *
23
+ * Behavior:
24
+ * - Detects when a new Service Worker has been installed and is waiting to activate.
25
+ * - If a custom `renderDialog` component is provided, it will be rendered when an update is available,
26
+ * and will receive an `onReload` callback to trigger the reload flow.
27
+ * - If no `renderDialog` is provided, a default `window.confirm` prompt is shown,
28
+ * and the app reloads automatically after user confirmation.
29
+ * - If `clearCachesOnReload` is true, all entries in CacheStorage will be cleared before reloading
30
+ * (use with caution, as this removes *all* caches for the current origin).
31
+ * - If `autoUpdate` is true, the app will reload automatically when an update is detected,
32
+ * bypassing both `window.confirm` and any custom UI.
33
+ *
34
+ * Usage:
35
+ * Place <UpdateNotifier /> once at the root of your app (e.g., in App.tsx).
36
+ *
37
+ * Example with a custom banner:
38
+ * ```tsx
39
+ * <UpdateNotifier
40
+ * renderDialog={(handleReloadApp) => (
41
+ * <div style={{ position: "fixed", bottom: 0, width: "100%", background: "orange", padding: "1rem" }}>
42
+ * <span>A new version is available.</span>
43
+ * <button onClick={onReload} style={{ marginLeft: "1rem" }}>
44
+ * Reload now
45
+ * </button>
46
+ * </div>
47
+ * )}
48
+ * />
49
+ * ```
50
+ */
51
+ declare const UpdateNotifier: ({ autoUpdate, renderDialog, clearCachesOnReload }: UpdateNotifierProps) => ReactNode;
52
+ export default UpdateNotifier;
package/dist/main.d.ts CHANGED
@@ -15,6 +15,8 @@ export { default as InitializeDaysJSConfig } from './components/Utils/Initialize
15
15
  export * from './components/Utils/InitializeDaysJSConfig';
16
16
  export { default as PreloadErrorHandler } from './components/Utils/PreloadErrorHandler';
17
17
  export * from './components/Utils/PreloadErrorHandler';
18
+ export { default as UpdateNotifier } from './components/Utils/UpdateNotifier';
19
+ export * from './components/Utils/UpdateNotifier';
18
20
  export { default as InjectDependenciesProvider } from './context/InjectDependenciesProvider';
19
21
  export * from './context/InjectDependenciesProvider';
20
22
  export { default as QueryClientProviderWithConfig } from './context/QueryClientProviderWithConfig';
package/dist/main.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import ee from "axios";
2
- import de, { createContext as fe, useMemo as M, useContext as A, useState as J, useRef as pe, useEffect as O, Suspense as ge, useCallback as Y } from "react";
3
- const $e = (e, n) => {
2
+ import fe, { createContext as pe, useMemo as G, useContext as j, useState as W, useRef as ae, useEffect as k, Suspense as ge, useCallback as L } from "react";
3
+ const De = (e, n) => {
4
4
  const o = ee.CancelToken.source(), a = ee({
5
5
  ...e,
6
6
  ...n,
@@ -10,7 +10,7 @@ const $e = (e, n) => {
10
10
  o.cancel("Query was cancelled");
11
11
  }, a;
12
12
  };
13
- var $ = { exports: {} }, N = {};
13
+ var D = { exports: {} }, N = {};
14
14
  /**
15
15
  * @license React
16
16
  * react-jsx-runtime.production.js
@@ -25,24 +25,24 @@ function me() {
25
25
  if (te) return N;
26
26
  te = 1;
27
27
  var e = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
28
- function o(a, r, s) {
28
+ function o(a, r, i) {
29
29
  var c = null;
30
- if (s !== void 0 && (c = "" + s), r.key !== void 0 && (c = "" + r.key), "key" in r) {
31
- s = {};
32
- for (var u in r)
33
- u !== "key" && (s[u] = r[u]);
34
- } else s = r;
35
- return r = s.ref, {
30
+ if (i !== void 0 && (c = "" + i), r.key !== void 0 && (c = "" + r.key), "key" in r) {
31
+ i = {};
32
+ for (var d in r)
33
+ d !== "key" && (i[d] = r[d]);
34
+ } else i = r;
35
+ return r = i.ref, {
36
36
  $$typeof: e,
37
37
  type: a,
38
38
  key: c,
39
39
  ref: r !== void 0 ? r : null,
40
- props: s
40
+ props: i
41
41
  };
42
42
  }
43
43
  return N.Fragment = n, N.jsx = o, N.jsxs = o, N;
44
44
  }
45
- var L = {};
45
+ var F = {};
46
46
  /**
47
47
  * @license React
48
48
  * react-jsx-runtime.development.js
@@ -58,38 +58,38 @@ function ye() {
58
58
  function e(t) {
59
59
  if (t == null) return null;
60
60
  if (typeof t == "function")
61
- return t.$$typeof === ce ? null : t.displayName || t.name || null;
61
+ return t.$$typeof === le ? null : t.displayName || t.name || null;
62
62
  if (typeof t == "string") return t;
63
63
  switch (t) {
64
64
  case b:
65
65
  return "Fragment";
66
- case m:
66
+ case y:
67
67
  return "Profiler";
68
- case g:
68
+ case m:
69
69
  return "StrictMode";
70
70
  case P:
71
71
  return "Suspense";
72
- case ae:
73
- return "SuspenseList";
74
72
  case ie:
73
+ return "SuspenseList";
74
+ case ce:
75
75
  return "Activity";
76
76
  }
77
77
  if (typeof t == "object")
78
78
  switch (typeof t.tag == "number" && console.error(
79
79
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
80
80
  ), t.$$typeof) {
81
- case x:
81
+ case O:
82
82
  return "Portal";
83
83
  case p:
84
84
  return (t.displayName || "Context") + ".Provider";
85
85
  case _:
86
86
  return (t._context.displayName || "Context") + ".Consumer";
87
- case h:
87
+ case w:
88
88
  var f = t.render;
89
89
  return t = t.displayName, t || (t = f.displayName || f.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
90
90
  case se:
91
91
  return f = t.displayName || null, f !== null ? f : e(t.type) || "Memo";
92
- case G:
92
+ case J:
93
93
  f = t._payload, t = t._init;
94
94
  try {
95
95
  return e(t(f));
@@ -110,17 +110,17 @@ function ye() {
110
110
  }
111
111
  if (f) {
112
112
  f = console;
113
- var y = f.error, w = typeof Symbol == "function" && Symbol.toStringTag && t[Symbol.toStringTag] || t.constructor.name || "Object";
114
- return y.call(
113
+ var v = f.error, E = typeof Symbol == "function" && Symbol.toStringTag && t[Symbol.toStringTag] || t.constructor.name || "Object";
114
+ return v.call(
115
115
  f,
116
116
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
117
- w
117
+ E
118
118
  ), n(t);
119
119
  }
120
120
  }
121
121
  function a(t) {
122
122
  if (t === b) return "<>";
123
- if (typeof t == "object" && t !== null && t.$$typeof === G)
123
+ if (typeof t == "object" && t !== null && t.$$typeof === J)
124
124
  return "<...>";
125
125
  try {
126
126
  var f = e(t);
@@ -133,7 +133,7 @@ function ye() {
133
133
  var t = z.A;
134
134
  return t === null ? null : t.getOwner();
135
135
  }
136
- function s() {
136
+ function i() {
137
137
  return Error("react-stack-top-frame");
138
138
  }
139
139
  function c(t) {
@@ -143,34 +143,34 @@ function ye() {
143
143
  }
144
144
  return t.key !== void 0;
145
145
  }
146
- function u(t, f) {
147
- function y() {
146
+ function d(t, f) {
147
+ function v() {
148
148
  q || (q = !0, console.error(
149
149
  "%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)",
150
150
  f
151
151
  ));
152
152
  }
153
- y.isReactWarning = !0, Object.defineProperty(t, "key", {
154
- get: y,
153
+ v.isReactWarning = !0, Object.defineProperty(t, "key", {
154
+ get: v,
155
155
  configurable: !0
156
156
  });
157
157
  }
158
- function d() {
158
+ function l() {
159
159
  var t = e(this.type);
160
160
  return B[t] || (B[t] = !0, console.error(
161
161
  "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."
162
162
  )), t = this.props.ref, t !== void 0 ? t : null;
163
163
  }
164
- function l(t, f, y, w, k, T, W, Q) {
165
- return y = T.ref, t = {
164
+ function u(t, f, v, E, x, T, Q, V) {
165
+ return v = T.ref, t = {
166
166
  $$typeof: S,
167
167
  type: t,
168
168
  key: f,
169
169
  props: T,
170
- _owner: k
171
- }, (y !== void 0 ? y : null) !== null ? Object.defineProperty(t, "ref", {
170
+ _owner: x
171
+ }, (v !== void 0 ? v : null) !== null ? Object.defineProperty(t, "ref", {
172
172
  enumerable: !1,
173
- get: d
173
+ get: l
174
174
  }) : Object.defineProperty(t, "ref", { enumerable: !1, value: null }), t._store = {}, Object.defineProperty(t._store, "validated", {
175
175
  configurable: !1,
176
176
  enumerable: !1,
@@ -185,113 +185,113 @@ function ye() {
185
185
  configurable: !1,
186
186
  enumerable: !1,
187
187
  writable: !0,
188
- value: W
188
+ value: Q
189
189
  }), Object.defineProperty(t, "_debugTask", {
190
190
  configurable: !1,
191
191
  enumerable: !1,
192
192
  writable: !0,
193
- value: Q
193
+ value: V
194
194
  }), Object.freeze && (Object.freeze(t.props), Object.freeze(t)), t;
195
195
  }
196
- function i(t, f, y, w, k, T, W, Q) {
196
+ function s(t, f, v, E, x, T, Q, V) {
197
197
  var R = f.children;
198
198
  if (R !== void 0)
199
- if (w)
199
+ if (E)
200
200
  if (ue(R)) {
201
- for (w = 0; w < R.length; w++)
202
- v(R[w]);
201
+ for (E = 0; E < R.length; E++)
202
+ h(R[E]);
203
203
  Object.freeze && Object.freeze(R);
204
204
  } else
205
205
  console.error(
206
206
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
207
207
  );
208
- else v(R);
208
+ else h(R);
209
209
  if (K.call(f, "key")) {
210
210
  R = e(t);
211
- var I = Object.keys(f).filter(function(le) {
212
- return le !== "key";
211
+ var I = Object.keys(f).filter(function(de) {
212
+ return de !== "key";
213
213
  });
214
- w = 0 < I.length ? "{key: someKey, " + I.join(": ..., ") + ": ...}" : "{key: someKey}", Z[R + w] || (I = 0 < I.length ? "{" + I.join(": ..., ") + ": ...}" : "{}", console.error(
214
+ E = 0 < I.length ? "{key: someKey, " + I.join(": ..., ") + ": ...}" : "{key: someKey}", Z[R + E] || (I = 0 < I.length ? "{" + I.join(": ..., ") + ": ...}" : "{}", console.error(
215
215
  `A props object containing a "key" prop is being spread into JSX:
216
216
  let props = %s;
217
217
  <%s {...props} />
218
218
  React keys must be passed directly to JSX without using spread:
219
219
  let props = %s;
220
220
  <%s key={someKey} {...props} />`,
221
- w,
221
+ E,
222
222
  R,
223
223
  I,
224
224
  R
225
- ), Z[R + w] = !0);
225
+ ), Z[R + E] = !0);
226
226
  }
227
- if (R = null, y !== void 0 && (o(y), R = "" + y), c(f) && (o(f.key), R = "" + f.key), "key" in f) {
228
- y = {};
229
- for (var V in f)
230
- V !== "key" && (y[V] = f[V]);
231
- } else y = f;
232
- return R && u(
233
- y,
227
+ if (R = null, v !== void 0 && (o(v), R = "" + v), c(f) && (o(f.key), R = "" + f.key), "key" in f) {
228
+ v = {};
229
+ for (var M in f)
230
+ M !== "key" && (v[M] = f[M]);
231
+ } else v = f;
232
+ return R && d(
233
+ v,
234
234
  typeof t == "function" ? t.displayName || t.name || "Unknown" : t
235
- ), l(
235
+ ), u(
236
236
  t,
237
237
  R,
238
238
  T,
239
- k,
239
+ x,
240
240
  r(),
241
- y,
242
- W,
243
- Q
241
+ v,
242
+ Q,
243
+ V
244
244
  );
245
245
  }
246
- function v(t) {
246
+ function h(t) {
247
247
  typeof t == "object" && t !== null && t.$$typeof === S && t._store && (t._store.validated = 1);
248
248
  }
249
- var E = de, S = Symbol.for("react.transitional.element"), x = Symbol.for("react.portal"), b = Symbol.for("react.fragment"), g = Symbol.for("react.strict_mode"), m = Symbol.for("react.profiler"), _ = Symbol.for("react.consumer"), p = Symbol.for("react.context"), h = Symbol.for("react.forward_ref"), P = Symbol.for("react.suspense"), ae = Symbol.for("react.suspense_list"), se = Symbol.for("react.memo"), G = Symbol.for("react.lazy"), ie = Symbol.for("react.activity"), ce = Symbol.for("react.client.reference"), z = E.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, K = Object.prototype.hasOwnProperty, ue = Array.isArray, U = console.createTask ? console.createTask : function() {
249
+ var g = fe, S = Symbol.for("react.transitional.element"), O = Symbol.for("react.portal"), b = Symbol.for("react.fragment"), m = Symbol.for("react.strict_mode"), y = Symbol.for("react.profiler"), _ = Symbol.for("react.consumer"), p = Symbol.for("react.context"), w = Symbol.for("react.forward_ref"), P = Symbol.for("react.suspense"), ie = Symbol.for("react.suspense_list"), se = Symbol.for("react.memo"), J = Symbol.for("react.lazy"), ce = Symbol.for("react.activity"), le = Symbol.for("react.client.reference"), z = g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, K = Object.prototype.hasOwnProperty, ue = Array.isArray, U = console.createTask ? console.createTask : function() {
250
250
  return null;
251
251
  };
252
- E = {
252
+ g = {
253
253
  "react-stack-bottom-frame": function(t) {
254
254
  return t();
255
255
  }
256
256
  };
257
- var q, B = {}, X = E["react-stack-bottom-frame"].bind(
258
- E,
259
- s
260
- )(), H = U(a(s)), Z = {};
261
- L.Fragment = b, L.jsx = function(t, f, y, w, k) {
257
+ var q, B = {}, H = g["react-stack-bottom-frame"].bind(
258
+ g,
259
+ i
260
+ )(), X = U(a(i)), Z = {};
261
+ F.Fragment = b, F.jsx = function(t, f, v, E, x) {
262
262
  var T = 1e4 > z.recentlyCreatedOwnerStacks++;
263
- return i(
263
+ return s(
264
264
  t,
265
265
  f,
266
- y,
266
+ v,
267
267
  !1,
268
- w,
269
- k,
270
- T ? Error("react-stack-top-frame") : X,
271
- T ? U(a(t)) : H
268
+ E,
269
+ x,
270
+ T ? Error("react-stack-top-frame") : H,
271
+ T ? U(a(t)) : X
272
272
  );
273
- }, L.jsxs = function(t, f, y, w, k) {
273
+ }, F.jsxs = function(t, f, v, E, x) {
274
274
  var T = 1e4 > z.recentlyCreatedOwnerStacks++;
275
- return i(
275
+ return s(
276
276
  t,
277
277
  f,
278
- y,
278
+ v,
279
279
  !0,
280
- w,
281
- k,
282
- T ? Error("react-stack-top-frame") : X,
283
- T ? U(a(t)) : H
280
+ E,
281
+ x,
282
+ T ? Error("react-stack-top-frame") : H,
283
+ T ? U(a(t)) : X
284
284
  );
285
285
  };
286
- }()), L;
286
+ }()), F;
287
287
  }
288
288
  var ne;
289
289
  function he() {
290
- return ne || (ne = 1, process.env.NODE_ENV === "production" ? $.exports = me() : $.exports = ye()), $.exports;
290
+ return ne || (ne = 1, process.env.NODE_ENV === "production" ? D.exports = me() : D.exports = ye()), D.exports;
291
291
  }
292
292
  var C = he();
293
- const j = fe({}), De = ({ children: e, apiURL: n, libraries: o, localStorageKeys: a }) => {
294
- const r = M(
293
+ const A = pe({}), Ye = ({ children: e, apiURL: n, libraries: o, localStorageKeys: a }) => {
294
+ const r = G(
295
295
  () => ({
296
296
  apiURL: n,
297
297
  libraries: o,
@@ -299,35 +299,35 @@ const j = fe({}), De = ({ children: e, apiURL: n, libraries: o, localStorageKeys
299
299
  }),
300
300
  [n, o, a]
301
301
  );
302
- return /* @__PURE__ */ C.jsx(j.Provider, { value: r, children: e });
303
- }, ve = "user", Ye = ({ Fallback: e, isLogged: n, loginPath: o = "/login", redirect401Path: a = "/login", ...r }) => {
304
- const { libraries: s, localStorageKeys: c } = A(j), u = r?.reactRouter || s?.reactRouter, d = r?.axios || s?.axios, l = r?.localStorageKey || c?.user || ve;
305
- if (!u)
302
+ return /* @__PURE__ */ C.jsx(A.Provider, { value: r, children: e });
303
+ }, ve = "user", We = ({ Fallback: e, isLogged: n, loginPath: o = "/login", redirect401Path: a = "/login", ...r }) => {
304
+ const { libraries: i, localStorageKeys: c } = j(A), d = r?.reactRouter || i?.reactRouter, l = r?.axios || i?.axios, u = r?.localStorageKey || c?.user || ve;
305
+ if (!d)
306
306
  throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
307
- const [i, v] = J(null), { useLocation: E, Navigate: S, Outlet: x } = u, b = E(), g = pe(!1), m = typeof n == "function" ? n() : !!n, _ = typeof m == "boolean" ? m : m?.isLogged;
308
- return O(() => {
309
- g.current || (g.current = !0, d.interceptors.response.use(
307
+ const [s, h] = W(null), { useLocation: g, Navigate: S, Outlet: O } = d, b = g(), m = ae(!1), y = typeof n == "function" ? n() : !!n, _ = typeof y == "boolean" ? y : y?.isLogged;
308
+ return k(() => {
309
+ m.current || (m.current = !0, l.interceptors.response.use(
310
310
  (p) => p,
311
- async (p) => (typeof p == "object" && p && "response" in p && p.response && typeof p.response == "object" && "status" in p.response && p.response && typeof p.response == "object" && "status" in p.response && p?.response?.status === 401 && (d.defaults.headers.common.Authorization = null, typeof window < "u" && window.localStorage && localStorage.removeItem(l), v(a)), Promise.reject(p))
311
+ async (p) => (typeof p == "object" && p && "response" in p && p.response && typeof p.response == "object" && "status" in p.response && p.response && typeof p.response == "object" && "status" in p.response && p?.response?.status === 401 && (l.defaults.headers.common.Authorization = null, typeof window < "u" && window.localStorage && localStorage.removeItem(u), h(a)), Promise.reject(p))
312
312
  ));
313
- }, [d.defaults.headers.common, d.interceptors.response, l, a]), _ && !i ? /* @__PURE__ */ C.jsx(ge, { fallback: e, children: b.state?.from?.state && b.state?.from?.pathname === o ? /* @__PURE__ */ C.jsx(S, { to: b.state.from.state.from.pathname + b.state.from.state.from.search, replace: !0 }) : /* @__PURE__ */ C.jsx(x, {}) }) : /* @__PURE__ */ C.jsx(S, { to: o + b.search, state: { from: b }, replace: !0 });
313
+ }, [l.defaults.headers.common, l.interceptors.response, u, a]), _ && !s ? /* @__PURE__ */ C.jsx(ge, { fallback: e, children: b.state?.from?.state && b.state?.from?.pathname === o ? /* @__PURE__ */ C.jsx(S, { to: b.state.from.state.from.pathname + b.state.from.state.from.search, replace: !0 }) : /* @__PURE__ */ C.jsx(O, {}) }) : /* @__PURE__ */ C.jsx(S, { to: o + b.search, state: { from: b }, replace: !0 });
314
314
  }, ze = ({ data: e, ...n }) => {
315
- const { libraries: o } = A(j), a = n?.reactRouter || o?.reactRouter, r = n?.gtm || o?.gtm;
315
+ const { libraries: o } = j(A), a = n?.reactRouter || o?.reactRouter, r = n?.gtm || o?.gtm;
316
316
  if (!a)
317
317
  throw new Error(
318
318
  "React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView."
319
319
  );
320
320
  if (!r)
321
321
  throw new Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");
322
- const { useGoogleTagManager: s } = r, { useLocation: c, Outlet: u } = a, { pathname: d } = c(), { sendEvent: l } = s();
323
- return O(() => {
324
- l({
322
+ const { useGoogleTagManager: i } = r, { useLocation: c, Outlet: d } = a, { pathname: l } = c(), { sendEvent: u } = i();
323
+ return k(() => {
324
+ u({
325
325
  event: "pageView",
326
- pathname: d,
326
+ pathname: l,
327
327
  ...e
328
328
  });
329
- }, [e, d, l]), /* @__PURE__ */ C.jsx(u, {});
330
- }, F = (() => {
329
+ }, [e, l, u]), /* @__PURE__ */ C.jsx(d, {});
330
+ }, $ = (() => {
331
331
  try {
332
332
  return typeof global == "object" && global !== null && ("HermesInternal" in global || // Hermes JS engine
333
333
  "__fbBatchedBridge" in global || // RN Bridge
@@ -335,29 +335,29 @@ const j = fe({}), De = ({ children: e, apiURL: n, libraries: o, localStorageKeys
335
335
  } catch {
336
336
  return !1;
337
337
  }
338
- })(), Ee = "user", Ue = ({
338
+ })(), we = "user", Ue = ({
339
339
  tokenTypeKey: e = "tokenType",
340
340
  tokenKey: n = "accessToken",
341
341
  postContentType: o = "application/json",
342
342
  ...a
343
343
  }) => {
344
- const { apiURL: r = a.apiURL, libraries: s, localStorageKeys: c } = A(j), u = a?.userLocalStorageKey || c?.user || Ee, d = a?.axios || s?.axios;
345
- if (!d)
344
+ const { apiURL: r = a.apiURL, libraries: i, localStorageKeys: c } = j(A), d = a?.userLocalStorageKey || c?.user || we, l = a?.axios || i?.axios;
345
+ if (!l)
346
346
  throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
347
- if (!d?.defaults || F)
347
+ if (!l?.defaults || $)
348
348
  return null;
349
349
  if (typeof window < "u" && window.localStorage) {
350
- const l = localStorage.getItem(u), i = l ? JSON.parse(l) : null, v = i?.[e] ? i[e] : null, E = i?.[n] ? i[n] : null, S = l ? `${v} ${E}` : null;
351
- S && (d.defaults.headers.common.Authorization = S);
350
+ const u = localStorage.getItem(d), s = u ? JSON.parse(u) : null, h = s?.[e] ? s[e] : null, g = s?.[n] ? s[n] : null, S = u ? `${h} ${g}` : null;
351
+ S && (l.defaults.headers.common.Authorization = S);
352
352
  }
353
- return d.defaults.baseURL = r, d.defaults.headers.post["Content-Type"] = o, null;
354
- }, We = ({ debug: e, resources: n, ...o }) => {
355
- const { libraries: a } = A(j), r = o?.i18 || a?.i18, { i18next: s, initReactI18next: c, languageDetector: u } = r || {};
356
- if (F)
353
+ return l.defaults.baseURL = r, l.defaults.headers.post["Content-Type"] = o, null;
354
+ }, Qe = ({ debug: e, resources: n, ...o }) => {
355
+ const { libraries: a } = j(A), r = o?.i18 || a?.i18, { i18next: i, initReactI18next: c, languageDetector: d } = r || {};
356
+ if ($)
357
357
  return null;
358
358
  if (!r)
359
359
  throw new Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
360
- return s?.isInitialized || (s.use(u).use(c).init({
360
+ return i?.isInitialized || (i.use(d).use(c).init({
361
361
  debug: e,
362
362
  fallbackLng: "en",
363
363
  interpolation: {
@@ -371,35 +371,35 @@ const j = fe({}), De = ({ children: e, apiURL: n, libraries: o, localStorageKeys
371
371
  resources: n,
372
372
  returnNull: !1
373
373
  }).then(() => {
374
- document.documentElement.lang !== s.resolvedLanguage && s.resolvedLanguage && document.documentElement.setAttribute("lang", s.resolvedLanguage);
375
- }), s.on("languageChanged", (d) => {
376
- document.documentElement.setAttribute("lang", d);
374
+ document.documentElement.lang !== i.resolvedLanguage && i.resolvedLanguage && document.documentElement.setAttribute("lang", i.resolvedLanguage);
375
+ }), i.on("languageChanged", (l) => {
376
+ document.documentElement.setAttribute("lang", l);
377
377
  })), null;
378
- }, Qe = ({
378
+ }, Ve = ({
379
379
  dsn: e,
380
380
  integrations: n,
381
381
  tracesSampleRate: o,
382
382
  replaysSessionSampleRate: a,
383
383
  replaysOnErrorSampleRate: r,
384
- tracePropagationTargets: s,
384
+ tracePropagationTargets: i,
385
385
  ignoreErrors: c,
386
- debug: u,
387
- environment: d,
388
- release: l,
389
- ...i
386
+ debug: d,
387
+ environment: l,
388
+ release: u,
389
+ ...s
390
390
  }) => {
391
- const { libraries: v } = A(j), E = i?.sentry || v?.sentry, S = i?.reactRouter || v?.reactRouter;
392
- if (!E)
391
+ const { libraries: h } = j(A), g = s?.sentry || h?.sentry, S = s?.reactRouter || h?.reactRouter;
392
+ if (!g)
393
393
  throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
394
394
  if (!S)
395
395
  throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
396
- if (E.isInitialized())
396
+ if (g.isInitialized())
397
397
  return null;
398
- const { createRoutesFromChildren: x, matchRoutes: b, useLocation: g, useNavigationType: m } = S;
399
- return (u || process.env.NODE_ENV === "prod" || process.env.NODE_ENV === "production") && E.init({
400
- debug: u,
398
+ const { createRoutesFromChildren: O, matchRoutes: b, useLocation: m, useNavigationType: y } = S;
399
+ return (d || process.env.NODE_ENV === "prod" || process.env.NODE_ENV === "production") && g.init({
400
+ debug: d,
401
401
  dsn: e,
402
- environment: d || "production",
402
+ environment: l || "production",
403
403
  ignoreErrors: [
404
404
  ...c || [],
405
405
  /dynamically imported module/,
@@ -410,44 +410,44 @@ const j = fe({}), De = ({ children: e, apiURL: n, libraries: o, localStorageKeys
410
410
  /vite:preloadError/
411
411
  ],
412
412
  integrations: [
413
- E.reactRouterV6BrowserTracingIntegration({
414
- createRoutesFromChildren: x,
413
+ g.reactRouterV6BrowserTracingIntegration({
414
+ createRoutesFromChildren: O,
415
415
  matchRoutes: b,
416
- useEffect: O,
417
- useLocation: g,
418
- useNavigationType: m
416
+ useEffect: k,
417
+ useLocation: m,
418
+ useNavigationType: y
419
419
  }),
420
420
  ...n || []
421
421
  ],
422
- release: l,
422
+ release: u,
423
423
  replaysOnErrorSampleRate: r || 1,
424
424
  replaysSessionSampleRate: a || 0.1,
425
- tracePropagationTargets: s,
425
+ tracePropagationTargets: i,
426
426
  tracesSampleRate: o || 1
427
427
  }), null;
428
- }, Ve = ({ IMaskMixin: e, ...n }) => {
429
- const o = M(
428
+ }, Me = ({ IMaskMixin: e, ...n }) => {
429
+ const o = G(
430
430
  // eslint-disable-next-line react/jsx-props-no-spreading
431
431
  () => e(({ TextField: a, ...r }) => /* @__PURE__ */ C.jsx(a, { ...r })),
432
432
  [e]
433
433
  );
434
434
  return /* @__PURE__ */ C.jsx(o, { ...n });
435
- }, Me = ({ language: e, ...n }) => {
436
- const { libraries: o } = A(j), a = n?.dayjs || o?.dayjs, r = n?.plugin || o?.dayjsPlugin;
435
+ }, Ge = ({ language: e, ...n }) => {
436
+ const { libraries: o } = j(A), a = n?.dayjs || o?.dayjs, r = n?.plugin || o?.dayjsPlugin;
437
437
  if (!a)
438
438
  throw new Error(
439
439
  "Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig."
440
440
  );
441
- return O(() => {
441
+ return k(() => {
442
442
  (async () => {
443
443
  const c = e || navigator.language?.slice(0, 2) || "en";
444
- r && r.forEach((u) => {
445
- u && a.extend(u);
444
+ r && r.forEach((d) => {
445
+ d && a.extend(d);
446
446
  }), await import("dayjs/locale/en"), await import("dayjs/locale/fr"), a.locale(c);
447
447
  })().then();
448
448
  }, [a, r, e]), null;
449
- }, Je = () => (O(() => {
450
- if (F)
449
+ }, Je = () => (k(() => {
450
+ if ($)
451
451
  return;
452
452
  const e = (n) => {
453
453
  try {
@@ -458,166 +458,201 @@ const j = fe({}), De = ({ children: e, apiURL: n, libraries: o, localStorageKeys
458
458
  return window.addEventListener("vite:preloadError", e), () => {
459
459
  window.removeEventListener("vite:preloadError", e);
460
460
  };
461
- }, []), null), we = (e) => e && typeof e == "function", Re = (e) => e && typeof e == "function", Ge = ({
461
+ }, []), null), Ee = async () => {
462
+ if ("caches" in window)
463
+ try {
464
+ const e = await caches.keys();
465
+ await Promise.all(e.map((n) => caches.delete(n)));
466
+ } catch (e) {
467
+ console.error("Failed to clear caches:", e);
468
+ }
469
+ }, Ke = ({ autoUpdate: e, renderDialog: n, clearCachesOnReload: o }) => {
470
+ const a = ae(null), [r, i] = W(!1), c = L(async () => {
471
+ a.current && a.current.postMessage({ type: "SKIP_WAITING" }), o && await Ee(), window.location.reload();
472
+ }, [o]), d = L(async () => {
473
+ window.confirm("A new version is available. The app will reload now.") && await c();
474
+ }, [c]);
475
+ return k(() => {
476
+ if (!("serviceWorker" in navigator)) return;
477
+ let l, u;
478
+ const s = (g) => {
479
+ g && navigator.serviceWorker.controller && (a.current = g, i(!0));
480
+ }, h = () => {
481
+ const g = l?.installing;
482
+ g && (u = () => {
483
+ g.state === "installed" && s(g);
484
+ }, g.addEventListener("statechange", u));
485
+ };
486
+ return (async () => {
487
+ l = await navigator.serviceWorker.getRegistration(), l && (s(l.waiting), l.addEventListener("updatefound", h));
488
+ })().catch(console.error), () => {
489
+ l?.removeEventListener("updatefound", h), u && l?.installing && l.installing.removeEventListener("statechange", u);
490
+ };
491
+ }, []), k(() => {
492
+ r && e && c().catch(console.error);
493
+ }, [e, r, c]), k(() => {
494
+ r && !e && !n && d().catch(console.error);
495
+ }, [n, d, r, e]), r && !e && n ? n(c) : null;
496
+ }, Re = (e) => e && typeof e == "function", be = (e) => e && typeof e == "function", qe = ({
462
497
  children: e,
463
498
  defaultQueriesOptions: n,
464
499
  defaultMutationsOptions: o,
465
500
  ...a
466
501
  }) => {
467
- const { libraries: r } = A(j), s = a?.QueryClient || r?.reactQuery?.QueryClient, c = a?.QueryClientProvider || r?.reactQuery?.QueryClientProvider;
468
- if (!s)
502
+ const { libraries: r } = j(A), i = a?.QueryClient || r?.reactQuery?.QueryClient, c = a?.QueryClientProvider || r?.reactQuery?.QueryClientProvider;
503
+ if (!i)
469
504
  throw new Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
470
505
  if (!c)
471
506
  throw new Error("QueryClientProvider is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
472
- if (!we(c))
507
+ if (!Re(c))
473
508
  throw new Error("Provided QueryClientProvider dependencies are not valid.");
474
- if (!Re(s))
509
+ if (!be(i))
475
510
  throw new Error("Provided QueryClient dependencies are not valid.");
476
- const u = new s({
511
+ const d = new i({
477
512
  defaultOptions: {
478
513
  mutations: {
479
514
  ...o
480
515
  },
481
516
  queries: {
482
- getNextPageParam: (d, l, i) => d.length + (i || 0),
517
+ getNextPageParam: (l, u, s) => l.length + (s || 0),
483
518
  refetchOnWindowFocus: !1,
484
519
  retry: 3,
485
520
  ...n
486
521
  }
487
522
  }
488
523
  });
489
- return /* @__PURE__ */ C.jsx(c, { client: u, children: e });
490
- }, Ke = (e) => {
491
- const { libraries: n } = A(j), o = e?.i18 || n?.i18, a = e?.i18?.translateFunction || n?.i18?.translateFunction, r = o?.i18next?.t || a || ((l) => l), { unknownErrorTranslationKey: s = "error.unknownError" } = e || {}, c = r(s), u = Y(
492
- (l) => {
493
- if (l && typeof l == "object" && "response" in l) {
494
- const { response: i } = l || {};
495
- if (i && typeof i == "object" && "reason" in i)
496
- return String(i.reason);
497
- if (i && typeof i == "object" && "data" in i && i.data && typeof i.data == "object" && "reason" in i.data)
498
- return String(i.data.reason);
499
- if (i && typeof i == "object" && "data" in i && i.data && typeof i.data == "object" && "message" in i.data)
500
- return String(i.data.message);
501
- if (i && typeof i == "object" && "data" in i && i.data && typeof i.data == "object" && "detail" in i.data) {
502
- const { detail: v } = i.data;
503
- if (Array.isArray(v) && v.length > 0 && typeof v[0] == "object" && v[0] !== null && "msg" in v[0]) {
504
- const { msg: E } = v[0];
505
- if (typeof E == "string")
506
- return String(E);
524
+ return /* @__PURE__ */ C.jsx(c, { client: d, children: e });
525
+ }, Be = (e) => {
526
+ const { libraries: n } = j(A), o = e?.i18 || n?.i18, a = e?.i18?.translateFunction || n?.i18?.translateFunction, r = o?.i18next?.t || a || ((u) => u), { unknownErrorTranslationKey: i = "error.unknownError" } = e || {}, c = r(i), d = L(
527
+ (u) => {
528
+ if (u && typeof u == "object" && "response" in u) {
529
+ const { response: s } = u || {};
530
+ if (s && typeof s == "object" && "reason" in s)
531
+ return String(s.reason);
532
+ if (s && typeof s == "object" && "data" in s && s.data && typeof s.data == "object" && "reason" in s.data)
533
+ return String(s.data.reason);
534
+ if (s && typeof s == "object" && "data" in s && s.data && typeof s.data == "object" && "message" in s.data)
535
+ return String(s.data.message);
536
+ if (s && typeof s == "object" && "data" in s && s.data && typeof s.data == "object" && "detail" in s.data) {
537
+ const { detail: h } = s.data;
538
+ if (Array.isArray(h) && h.length > 0 && typeof h[0] == "object" && h[0] !== null && "msg" in h[0]) {
539
+ const { msg: g } = h[0];
540
+ if (typeof g == "string")
541
+ return String(g);
507
542
  }
508
543
  }
509
544
  }
510
- return l instanceof Error ? l.message : c;
545
+ return u instanceof Error ? u.message : c;
511
546
  },
512
547
  [c]
513
548
  );
514
- return { getErrorCode: Y((l) => {
515
- const { response: i } = l || {};
516
- 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";
517
- }, []), printError: u };
518
- }, qe = ({
549
+ return { getErrorCode: L((u) => {
550
+ const { response: s } = u || {};
551
+ 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";
552
+ }, []), printError: d };
553
+ }, He = ({
519
554
  data: e,
520
555
  fetchNextPage: n,
521
556
  isFetchingNextPage: o,
522
557
  isInitialLoading: a,
523
558
  isLoading: r,
524
- enabled: s = !0
559
+ enabled: i = !0
525
560
  }) => {
526
- const c = Y(
527
- async (d) => {
528
- o || !s || await n({ pageParam: d?.pageParam || d.visibleRowsCount });
561
+ const c = L(
562
+ async (l) => {
563
+ o || !i || await n({ pageParam: l?.pageParam || l.visibleRowsCount });
529
564
  },
530
- [s, n, o]
531
- ), u = M(() => {
565
+ [i, n, o]
566
+ ), d = G(() => {
532
567
  if (e)
533
- return e.pages.reduce((d, l) => [...d, ...l], []);
568
+ return e.pages.reduce((l, u) => [...l, ...u], []);
534
569
  }, [e]);
535
570
  return {
536
571
  fetchNextPageOnRowsScrollEnd: c,
537
572
  isLoading: o || r,
538
573
  loadingVariant: a ? "skeleton" : "linear-progress",
539
- rows: u
574
+ rows: d
540
575
  };
541
- }, Be = (e) => {
542
- const { libraries: n } = A(j), o = e?.axios || n?.axios, a = e?.localStorageKey || "user";
576
+ }, Xe = (e) => {
577
+ const { libraries: n } = j(A), o = e?.axios || n?.axios, a = e?.localStorageKey || "user";
543
578
  if (!o)
544
579
  throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");
545
- const r = Y(
546
- ({ tokenType: c, accessToken: u }) => {
547
- o.defaults.headers.common.Authorization = `${c} ${u}`;
580
+ const r = L(
581
+ ({ tokenType: c, accessToken: d }) => {
582
+ o.defaults.headers.common.Authorization = `${c} ${d}`;
548
583
  },
549
584
  [o.defaults.headers.common]
550
- ), s = () => {
585
+ ), i = () => {
551
586
  o.defaults.headers.common.Authorization = null;
552
587
  };
553
- return O(() => {
554
- if (F)
588
+ return k(() => {
589
+ if ($)
555
590
  return;
556
- const c = ({ newValue: u, key: d }) => {
557
- if (d === a && u)
591
+ const c = ({ newValue: d, key: l }) => {
592
+ if (l === a && d)
558
593
  try {
559
- const { accessToken: l, tokenType: i } = JSON.parse(u);
560
- r({ accessToken: l, tokenType: i });
561
- } catch (l) {
562
- console.error("Failed to parse newValue from localStorage:", l);
594
+ const { accessToken: u, tokenType: s } = JSON.parse(d);
595
+ r({ accessToken: u, tokenType: s });
596
+ } catch (u) {
597
+ console.error("Failed to parse newValue from localStorage:", u);
563
598
  }
564
599
  };
565
600
  return window.addEventListener("storage", c), () => {
566
601
  window.removeEventListener("storage", c);
567
602
  };
568
603
  }, [a, r]), {
569
- clearAuthenticationToken: s,
604
+ clearAuthenticationToken: i,
570
605
  setAuthenticationToken: r
571
606
  };
572
- }, be = ({ library: e, date: n, format: o = "ll" }) => e(n).format(o), Se = (e, n) => {
573
- const { fractionDigits: o = 0, metric: a = "km", spacingBetween: r = !0 } = n || {}, s = Number(e), c = r ? " " : "";
574
- return Number.isNaN(s) ? `0${c}${a}` : `${s.toFixed(o)}${c}${a}`;
575
- }, je = (e) => !e || typeof e != "string" ? "" : e.replace(/_/g, " ").toLowerCase().split(" ").map((o) => o.length > 0 ? o.charAt(0).toUpperCase() + o.slice(1) : o).join(" "), Ae = (e) => e?.startsWith("/") ? e?.startsWith("/files") ? e : `/files${e}` : e?.startsWith("files") ? `/${e}` : `/files/${e}`, _e = ({ path: e, size: n, apiURL: o }) => {
607
+ }, Se = ({ library: e, date: n, format: o = "ll" }) => e(n).format(o), Ae = (e, n) => {
608
+ const { fractionDigits: o = 0, metric: a = "km", spacingBetween: r = !0 } = n || {}, i = Number(e), c = r ? " " : "";
609
+ return Number.isNaN(i) ? `0${c}${a}` : `${i.toFixed(o)}${c}${a}`;
610
+ }, je = (e) => !e || typeof e != "string" ? "" : e.replace(/_/g, " ").toLowerCase().split(" ").map((o) => o.length > 0 ? o.charAt(0).toUpperCase() + o.slice(1) : o).join(" "), _e = (e) => e?.startsWith("/") ? e?.startsWith("/files") ? e : `/files${e}` : e?.startsWith("files") ? `/${e}` : `/files/${e}`, Pe = ({ path: e, size: n, apiURL: o }) => {
576
611
  if (!e)
577
612
  return "";
578
- const a = Ae(e), r = `${o}${a}`, s = r.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/) !== null;
579
- return typeof n == "number" && s ? `${r.replace("/files", `/thumbs/${n}`)}` : r;
580
- }, Xe = (e) => {
581
- const { apiURL: n, libraries: o } = A(j), a = e?.dayjs || o?.dayjs;
613
+ const a = _e(e), r = `${o}${a}`, i = r.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/) !== null;
614
+ return typeof n == "number" && i ? `${r.replace("/files", `/thumbs/${n}`)}` : r;
615
+ }, Ze = (e) => {
616
+ const { apiURL: n, libraries: o } = j(A), a = e?.dayjs || o?.dayjs;
582
617
  return {
583
- dateAdapter: (c, u) => {
618
+ dateAdapter: (c, d) => {
584
619
  if (!a)
585
620
  throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
586
- return be({
621
+ return Se({
587
622
  date: c,
588
- format: u,
623
+ format: d,
589
624
  library: a
590
625
  });
591
626
  },
592
- distanceAdapter: Se,
593
- filePathAdapter: (c, u) => {
627
+ distanceAdapter: Ae,
628
+ filePathAdapter: (c, d) => {
594
629
  if (!n)
595
630
  throw new Error(
596
631
  "API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter."
597
632
  );
598
- return typeof c == "string" && /^https?:\/\//.test(c) ? c : _e({
633
+ return typeof c == "string" && /^https?:\/\//.test(c) ? c : Pe({
599
634
  apiURL: n,
600
635
  path: c,
601
- size: u
636
+ size: d
602
637
  });
603
638
  },
604
639
  worksiteNameAdapter: je
605
640
  };
606
- }, D = (e, n) => n === "short" ? e.split("-")[0] : e, He = (e, n = "full") => {
607
- const [o, a] = J(() => {
641
+ }, Y = (e, n) => n === "short" ? e.split("-")[0] : e, et = (e, n = "full") => {
642
+ const [o, a] = W(() => {
608
643
  const r = e?.language || navigator.language;
609
- return e && "isInitialized" in e && e.isInitialized, D(r, n);
644
+ return e && "isInitialized" in e && e.isInitialized, Y(r, n);
610
645
  });
611
- return O(() => {
612
- e && "isInitialized" in e && e.isInitialized && e.language && a(D(e.language, n));
613
- const r = (s) => {
614
- a(D(s, n));
646
+ return k(() => {
647
+ e && "isInitialized" in e && e.isInitialized && e.language && a(Y(e.language, n));
648
+ const r = (i) => {
649
+ a(Y(i, n));
615
650
  };
616
651
  return e?.on?.("languageChanged", r), () => {
617
652
  e?.off?.("languageChanged", r);
618
653
  };
619
654
  }, [e, n]), o;
620
- }, Pe = "tracktor.filter", Te = {
655
+ }, Te = "tracktor.filter", ke = {
621
656
  getFilter: () => {
622
657
  },
623
658
  getFilters: () => ({}),
@@ -629,87 +664,87 @@ const j = fe({}), De = ({ children: e, apiURL: n, libraries: o, localStorageKeys
629
664
  const a = localStorage.getItem(o);
630
665
  if (a)
631
666
  try {
632
- const r = JSON.parse(a), s = Object.keys(r)?.[0];
633
- s && (n[s] = Object.values(r)?.[0]);
667
+ const r = JSON.parse(a), i = Object.keys(r)?.[0];
668
+ i && (n[i] = Object.values(r)?.[0]);
634
669
  } catch {
635
670
  }
636
671
  return n;
637
- }, {}), Ze = (e) => {
638
- const { libraries: n, localStorageKeys: o } = A(j), a = e?.reactRouter || n?.reactRouter, { pathname: r } = a?.useLocation?.() ?? { pathname: "/" }, [s, c] = a?.useSearchParams?.() ?? [new URLSearchParams(), () => {
639
- }], [u, d] = J({}), l = o?.filter || Pe, i = e?.syncWithUrl === void 0 ? !0 : e?.syncWithUrl;
640
- if (F)
641
- return Te;
672
+ }, {}), tt = (e) => {
673
+ const { libraries: n, localStorageKeys: o } = j(A), a = e?.reactRouter || n?.reactRouter, { pathname: r } = a?.useLocation?.() ?? { pathname: "/" }, [i, c] = a?.useSearchParams?.() ?? [new URLSearchParams(), () => {
674
+ }], [d, l] = W({}), u = o?.filter || Te, s = e?.syncWithUrl === void 0 ? !0 : e?.syncWithUrl;
675
+ if ($)
676
+ return ke;
642
677
  if (!a)
643
678
  throw new Error(
644
679
  "React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter."
645
680
  );
646
- const v = () => Object.keys(localStorage).filter(
647
- (g) => g.startsWith(l) && g.endsWith(e?.pathname || r)
648
- ), E = (g, m, _ = !0) => {
649
- const p = oe(g, e?.pathname || r, l);
650
- if (!m || Array.isArray(m) && !m.length) {
651
- i ? (s.delete(g), c(s)) : d((h) => {
652
- const P = { ...h };
653
- return delete P[g], P;
681
+ const h = () => Object.keys(localStorage).filter(
682
+ (m) => m.startsWith(u) && m.endsWith(e?.pathname || r)
683
+ ), g = (m, y, _ = !0) => {
684
+ const p = oe(m, e?.pathname || r, u);
685
+ if (!y || Array.isArray(y) && !y.length) {
686
+ s ? (i.delete(m), c(i)) : l((w) => {
687
+ const P = { ...w };
688
+ return delete P[m], P;
654
689
  }), localStorage.removeItem(p);
655
690
  return;
656
691
  }
657
- _ && m && localStorage.setItem(p, JSON.stringify({ ...s, [g]: m })), i && m ? (s.set(g, JSON.stringify(m)), c(s)) : !i && m && d((h) => ({ ...h, [g]: m }));
692
+ _ && y && localStorage.setItem(p, JSON.stringify({ ...i, [m]: y })), s && y ? (i.set(m, JSON.stringify(y)), c(i)) : !s && y && l((w) => ({ ...w, [m]: y }));
658
693
  };
659
694
  return {
660
- getFilter: (g, m) => {
661
- if (!i) {
662
- const h = u[g];
663
- if (h !== void 0)
664
- return h;
695
+ getFilter: (m, y) => {
696
+ if (!s) {
697
+ const w = d[m];
698
+ if (w !== void 0)
699
+ return w;
665
700
  }
666
- if (i) {
667
- const h = s.get(g);
668
- if (h)
701
+ if (s) {
702
+ const w = i.get(m);
703
+ if (w)
669
704
  try {
670
- return JSON.parse(h);
705
+ return JSON.parse(w);
671
706
  } catch {
672
- return h;
707
+ return w;
673
708
  }
674
709
  }
675
- const _ = oe(g, e?.pathname || r, l), p = localStorage.getItem(_);
710
+ const _ = oe(m, e?.pathname || r, u), p = localStorage.getItem(_);
676
711
  if (p)
677
712
  try {
678
- const h = JSON.parse(p)[g];
679
- return !i && h !== void 0 && d((P) => ({ ...P, [g]: h })), h;
713
+ const w = JSON.parse(p)[m];
714
+ return !s && w !== void 0 && l((P) => ({ ...P, [m]: w })), w;
680
715
  } catch {
681
716
  }
682
- return m;
717
+ return y;
683
718
  },
684
719
  getFilters: () => {
685
- const g = v(), m = Ce(g);
686
- if (i) {
687
- const _ = Object.fromEntries(s.entries());
720
+ const m = h(), y = Ce(m);
721
+ if (s) {
722
+ const _ = Object.fromEntries(i.entries());
688
723
  return {
689
- ...m,
724
+ ...y,
690
725
  ..._
691
726
  };
692
727
  }
693
728
  return {
694
- ...m,
695
- ...u
729
+ ...y,
730
+ ...d
696
731
  };
697
732
  },
698
- handleFilter: (g, m) => (_, p) => {
733
+ handleFilter: (m, y) => (_, p) => {
699
734
  if (p || Array.isArray(p) && p.length === 0) {
700
- const h = m || "value", P = typeof p == "object" && h in p ? p[h] : p;
701
- E(g, P);
735
+ const w = y || "value", P = typeof p == "object" && w in p ? p[w] : p;
736
+ g(m, P);
702
737
  return;
703
738
  }
704
- E(g, void 0);
739
+ g(m, void 0);
705
740
  },
706
- setFilter: E
741
+ setFilter: g
707
742
  };
708
- }, ke = (e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase(), Oe = (e) => {
709
- const a = e.split("/").filter((r) => r.length > 0).map((r) => r.replace(/\${([^}]*)}/g, "$1").split(/[_-]/).map((d) => d.charAt(0).toUpperCase() + d.slice(1)).join("")).join("");
743
+ }, xe = (e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase(), Oe = (e) => {
744
+ const a = e.split("/").filter((r) => r.length > 0).map((r) => r.replace(/\${([^}]*)}/g, "$1").split(/[_-]/).map((l) => l.charAt(0).toUpperCase() + l.slice(1)).join("")).join("");
710
745
  return a.charAt(0).toLowerCase() + a.slice(1);
711
- }, xe = (e) => (e.split("/").pop() || e).replace(/\.json$/, "").replace(/^openapi\./, ""), Ie = (e, n, o, a) => {
712
- const r = Oe(n), s = ke(o), c = `${r}${s}`;
746
+ }, Ie = (e) => (e.split("/").pop() || e).replace(/\.json$/, "").replace(/^openapi\./, ""), Le = (e, n, o, a) => {
747
+ const r = Oe(n), i = xe(o), c = `${r}${i}`;
713
748
  return e && typeof e == "object" && "operationId" in e && a?.includes(String(e.operationId)) ? `${c}AsQuery` : c;
714
749
  }, Ne = (e, n) => {
715
750
  const o = {};
@@ -728,39 +763,39 @@ const j = fe({}), De = ({ children: e, apiURL: n, libraries: o, localStorageKeys
728
763
  }
729
764
  };
730
765
  }), Object.keys(o).length ? o : void 0;
731
- }, et = (e) => (Array.isArray(e) ? e : [e]).reduce((o, a) => {
732
- const { output: r, useInfiniteIds: s, useQueryIds: c, input: u = "./openapi.json" } = a || {}, d = xe(u);
766
+ }, rt = (e) => (Array.isArray(e) ? e : [e]).reduce((o, a) => {
767
+ const { output: r, useInfiniteIds: i, useQueryIds: c, input: d = "./openapi.json" } = a || {}, l = Ie(d);
733
768
  return {
734
769
  ...o,
735
- [d]: {
770
+ [l]: {
736
771
  hooks: {
737
772
  afterAllFilesWrite: "prettier src/api/ --write"
738
773
  },
739
- input: u,
774
+ input: d,
740
775
  output: {
741
776
  baseUrl: r?.baseUrl,
742
777
  client: "react-query",
743
778
  mode: "tags-split",
744
779
  override: {
745
- ...(s?.length || c?.length) && {
746
- operations: Ne(s, c)
780
+ ...(i?.length || c?.length) && {
781
+ operations: Ne(i, c)
747
782
  },
748
- header: (l) => [
783
+ header: (u) => [
749
784
  "Generated by orval 🍺",
750
- ...l.title ? [l.title] : [],
751
- ...l.description ? [l.description] : []
785
+ ...u.title ? [u.title] : [],
786
+ ...u.description ? [u.description] : []
752
787
  ],
753
788
  mutator: {
754
789
  name: "axiosCustomInstance",
755
790
  path: "./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts"
756
791
  },
757
- operationName: (l, i, v) => Ie(l, i, v, c),
792
+ operationName: (u, s, h) => Le(u, s, h, c),
758
793
  query: {
759
794
  useQuery: !0
760
795
  }
761
796
  },
762
- schemas: r?.schemas || `src/api/${d}/model`,
763
- target: r?.target || `src/api/${d}/services/api.ts`,
797
+ schemas: r?.schemas || `src/api/${l}/model`,
798
+ target: r?.target || `src/api/${l}/services/api.ts`,
764
799
  ...r
765
800
  }
766
801
  }
@@ -769,24 +804,25 @@ const j = fe({}), De = ({ children: e, apiURL: n, libraries: o, localStorageKeys
769
804
  export {
770
805
  ze as GTMSendPageView,
771
806
  Ue as InitializeAxiosConfig,
772
- Me as InitializeDaysJSConfig,
773
- We as InitializeI18nConfig,
774
- Qe as InitializeSentryConfig,
775
- j as InjectDependenciesContext,
776
- De as InjectDependenciesProvider,
777
- Ve as MaskTextField,
807
+ Ge as InitializeDaysJSConfig,
808
+ Qe as InitializeI18nConfig,
809
+ Ve as InitializeSentryConfig,
810
+ A as InjectDependenciesContext,
811
+ Ye as InjectDependenciesProvider,
812
+ Me as MaskTextField,
778
813
  Je as PreloadErrorHandler,
779
- Ge as QueryClientProviderWithConfig,
780
- Ye as RequireAuth,
781
- $e as axiosCustomInstance,
782
- be as dateAdapter,
783
- Se as distanceAdapter,
784
- et as getOrvalConfig,
785
- Xe as useAdapter,
786
- Be as useAuth,
787
- He as useCurrentLanguage,
788
- Ze as useFilters,
789
- qe as useInfiniteDataGrid,
790
- Ke as useResponseError,
814
+ qe as QueryClientProviderWithConfig,
815
+ We as RequireAuth,
816
+ Ke as UpdateNotifier,
817
+ De as axiosCustomInstance,
818
+ Se as dateAdapter,
819
+ Ae as distanceAdapter,
820
+ rt as getOrvalConfig,
821
+ Ze as useAdapter,
822
+ Xe as useAuth,
823
+ et as useCurrentLanguage,
824
+ tt as useFilters,
825
+ He as useInfiniteDataGrid,
826
+ Be as useResponseError,
791
827
  je as worksiteNameAdapter
792
828
  };
package/dist/main.umd.cjs CHANGED
@@ -1,4 +1,4 @@
1
- (function(g,O){typeof exports=="object"&&typeof module<"u"?O(exports,require("axios"),require("react")):typeof define=="function"&&define.amd?define(["exports","axios","react"],O):(g=typeof globalThis<"u"?globalThis:g||self,O(g["@tracktor/shared-module"]={},g.axios,g.React))})(this,function(g,O,p){"use strict";const ae=(e,n)=>{const o=O.CancelToken.source(),a=O({...e,...n,cancelToken:o.token}).then(({data:r})=>r);return a.cancel=()=>{o.cancel("Query was cancelled")},a};var Y={exports:{}},L={};/**
1
+ (function(g,O){typeof exports=="object"&&typeof module<"u"?O(exports,require("axios"),require("react")):typeof define=="function"&&define.amd?define(["exports","axios","react"],O):(g=typeof globalThis<"u"?globalThis:g||self,O(g["@tracktor/shared-module"]={},g.axios,g.React))})(this,function(g,O,f){"use strict";const ae=(e,n)=>{const o=O.CancelToken.source(),a=O({...e,...n,cancelToken:o.token}).then(({data:r})=>r);return a.cancel=()=>{o.cancel("Query was cancelled")},a};var Y={exports:{}},L={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.js
4
4
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var G;function se(){if(G)return L;G=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function o(a,r,s){var c=null;if(s!==void 0&&(c=""+s),r.key!==void 0&&(c=""+r.key),"key"in r){s={};for(var l in r)l!=="key"&&(s[l]=r[l])}else s=r;return r=s.ref,{$$typeof:e,type:a,key:c,ref:r!==void 0?r:null,props:s}}return L.Fragment=n,L.jsx=o,L.jsxs=o,L}var F={};/**
9
+ */var G;function se(){if(G)return L;G=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function o(a,r,s){var c=null;if(s!==void 0&&(c=""+s),r.key!==void 0&&(c=""+r.key),"key"in r){s={};for(var d in r)d!=="key"&&(s[d]=r[d])}else s=r;return r=s.ref,{$$typeof:e,type:a,key:c,ref:r!==void 0?r:null,props:s}}return L.Fragment=n,L.jsx=o,L.jsxs=o,L}var F={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,9 +14,9 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var J;function ie(){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===Qe?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case C:return"Fragment";case h:return"Profiler";case y:return"StrictMode";case P:return"Suspense";case Ue:return"SuspenseList";case Me: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 x:return"Portal";case m:return(t.displayName||"Context")+".Provider";case _:return(t._context.displayName||"Context")+".Consumer";case E:var f=t.render;return t=t.displayName,t||(t=f.displayName||f.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case We:return f=t.displayName||null,f!==null?f:e(t.type)||"Memo";case q:f=t._payload,t=t._init;try{return e(t(f))}catch{}}return null}function n(t){return""+t}function o(t){try{n(t);var f=!1}catch{f=!0}if(f){f=console;var v=f.error,R=typeof Symbol=="function"&&Symbol.toStringTag&&t[Symbol.toStringTag]||t.constructor.name||"Object";return v.call(f,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",R),n(t)}}function a(t){if(t===C)return"<>";if(typeof t=="object"&&t!==null&&t.$$typeof===q)return"<...>";try{var f=e(t);return f?"<"+f+">":"<...>"}catch{return"<...>"}}function r(){var t=U.A;return t===null?null:t.getOwner()}function s(){return Error("react-stack-top-frame")}function c(t){if($.call(t,"key")){var f=Object.getOwnPropertyDescriptor(t,"key").get;if(f&&f.isReactWarning)return!1}return t.key!==void 0}function l(t,f){function v(){ee||(ee=!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)",f))}v.isReactWarning=!0,Object.defineProperty(t,"key",{get:v,configurable:!0})}function d(){var t=e(this.type);return te[t]||(te[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 u(t,f,v,R,I,T,M,Q){return v=T.ref,t={$$typeof:j,type:t,key:f,props:T,_owner:I},(v!==void 0?v:null)!==null?Object.defineProperty(t,"ref",{enumerable:!1,get:d}):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:M}),Object.defineProperty(t,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Q}),Object.freeze&&(Object.freeze(t.props),Object.freeze(t)),t}function i(t,f,v,R,I,T,M,Q){var S=f.children;if(S!==void 0)if(R)if(Ve(S)){for(R=0;R<S.length;R++)w(S[R]);Object.freeze&&Object.freeze(S)}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 w(S);if($.call(f,"key")){S=e(t);var N=Object.keys(f).filter(function(Ge){return Ge!=="key"});R=0<N.length?"{key: someKey, "+N.join(": ..., ")+": ...}":"{key: someKey}",oe[S+R]||(N=0<N.length?"{"+N.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
17
+ */var J;function ie(){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===Ge?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case C:return"Fragment";case v:return"Profiler";case h:return"StrictMode";case P:return"Suspense";case Me:return"SuspenseList";case Ve: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 x:return"Portal";case m:return(t.displayName||"Context")+".Provider";case _:return(t._context.displayName||"Context")+".Consumer";case b:var p=t.render;return t=t.displayName,t||(t=p.displayName||p.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Qe:return p=t.displayName||null,p!==null?p:e(t.type)||"Memo";case q:p=t._payload,t=t._init;try{return e(t(p))}catch{}}return null}function n(t){return""+t}function o(t){try{n(t);var p=!1}catch{p=!0}if(p){p=console;var w=p.error,R=typeof Symbol=="function"&&Symbol.toStringTag&&t[Symbol.toStringTag]||t.constructor.name||"Object";return w.call(p,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",R),n(t)}}function a(t){if(t===C)return"<>";if(typeof t=="object"&&t!==null&&t.$$typeof===q)return"<...>";try{var p=e(t);return p?"<"+p+">":"<...>"}catch{return"<...>"}}function r(){var t=z.A;return t===null?null:t.getOwner()}function s(){return Error("react-stack-top-frame")}function c(t){if($.call(t,"key")){var p=Object.getOwnPropertyDescriptor(t,"key").get;if(p&&p.isReactWarning)return!1}return t.key!==void 0}function d(t,p){function w(){ee||(ee=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",p))}w.isReactWarning=!0,Object.defineProperty(t,"key",{get:w,configurable:!0})}function l(){var t=e(this.type);return te[t]||(te[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 u(t,p,w,R,I,T,M,Q){return w=T.ref,t={$$typeof:j,type:t,key:p,props:T,_owner:I},(w!==void 0?w: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:M}),Object.defineProperty(t,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Q}),Object.freeze&&(Object.freeze(t.props),Object.freeze(t)),t}function i(t,p,w,R,I,T,M,Q){var S=p.children;if(S!==void 0)if(R)if(Je(S)){for(R=0;R<S.length;R++)E(S[R]);Object.freeze&&Object.freeze(S)}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 E(S);if($.call(p,"key")){S=e(t);var N=Object.keys(p).filter(function(Ke){return Ke!=="key"});R=0<N.length?"{key: someKey, "+N.join(": ..., ")+": ...}":"{key: someKey}",oe[S+R]||(N=0<N.length?"{"+N.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
18
18
  let props = %s;
19
19
  <%s {...props} />
20
20
  React keys must be passed directly to JSX without using spread:
21
21
  let props = %s;
22
- <%s key={someKey} {...props} />`,R,S,N,S),oe[S+R]=!0)}if(S=null,v!==void 0&&(o(v),S=""+v),c(f)&&(o(f.key),S=""+f.key),"key"in f){v={};for(var V in f)V!=="key"&&(v[V]=f[V])}else v=f;return S&&l(v,typeof t=="function"?t.displayName||t.name||"Unknown":t),u(t,S,T,I,r(),v,M,Q)}function w(t){typeof t=="object"&&t!==null&&t.$$typeof===j&&t._store&&(t._store.validated=1)}var b=p,j=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),h=Symbol.for("react.profiler"),_=Symbol.for("react.consumer"),m=Symbol.for("react.context"),E=Symbol.for("react.forward_ref"),P=Symbol.for("react.suspense"),Ue=Symbol.for("react.suspense_list"),We=Symbol.for("react.memo"),q=Symbol.for("react.lazy"),Me=Symbol.for("react.activity"),Qe=Symbol.for("react.client.reference"),U=b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,$=Object.prototype.hasOwnProperty,Ve=Array.isArray,W=console.createTask?console.createTask:function(){return null};b={"react-stack-bottom-frame":function(t){return t()}};var ee,te={},re=b["react-stack-bottom-frame"].bind(b,s)(),ne=W(a(s)),oe={};F.Fragment=C,F.jsx=function(t,f,v,R,I){var T=1e4>U.recentlyCreatedOwnerStacks++;return i(t,f,v,!1,R,I,T?Error("react-stack-top-frame"):re,T?W(a(t)):ne)},F.jsxs=function(t,f,v,R,I){var T=1e4>U.recentlyCreatedOwnerStacks++;return i(t,f,v,!0,R,I,T?Error("react-stack-top-frame"):re,T?W(a(t)):ne)}}()),F}var K;function ce(){return K||(K=1,process.env.NODE_ENV==="production"?Y.exports=se():Y.exports=ie()),Y.exports}var k=ce();const A=p.createContext({}),le=({children:e,apiURL:n,libraries:o,localStorageKeys:a})=>{const r=p.useMemo(()=>({apiURL:n,libraries:o,localStorageKeys:a}),[n,o,a]);return k.jsx(A.Provider,{value:r,children:e})},ue="user",de=({Fallback:e,isLogged:n,loginPath:o="/login",redirect401Path:a="/login",...r})=>{const{libraries:s,localStorageKeys:c}=p.useContext(A),l=r?.reactRouter||s?.reactRouter,d=r?.axios||s?.axios,u=r?.localStorageKey||c?.user||ue;if(!l)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");const[i,w]=p.useState(null),{useLocation:b,Navigate:j,Outlet:x}=l,C=b(),y=p.useRef(!1),h=typeof n=="function"?n():!!n,_=typeof h=="boolean"?h:h?.isLogged;return p.useEffect(()=>{y.current||(y.current=!0,d.interceptors.response.use(m=>m,async m=>(typeof m=="object"&&m&&"response"in m&&m.response&&typeof m.response=="object"&&"status"in m.response&&m.response&&typeof m.response=="object"&&"status"in m.response&&m?.response?.status===401&&(d.defaults.headers.common.Authorization=null,typeof window<"u"&&window.localStorage&&localStorage.removeItem(u),w(a)),Promise.reject(m))))},[d.defaults.headers.common,d.interceptors.response,u,a]),_&&!i?k.jsx(p.Suspense,{fallback:e,children:C.state?.from?.state&&C.state?.from?.pathname===o?k.jsx(j,{to:C.state.from.state.from.pathname+C.state.from.state.from.search,replace:!0}):k.jsx(x,{})}):k.jsx(j,{to:o+C.search,state:{from:C},replace:!0})},fe=({data:e,...n})=>{const{libraries:o}=p.useContext(A),a=n?.reactRouter||o?.reactRouter,r=n?.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(!r)throw new Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");const{useGoogleTagManager:s}=r,{useLocation:c,Outlet:l}=a,{pathname:d}=c(),{sendEvent:u}=s();return p.useEffect(()=>{u({event:"pageView",pathname:d,...e})},[e,d,u]),k.jsx(l,{})},D=(()=>{try{return typeof global=="object"&&global!==null&&("HermesInternal"in global||"__fbBatchedBridge"in global||"__metro"in global)||typeof window>"u"&&typeof global<"u"?!0:typeof navigator<"u"&&navigator.userAgent?/react.native|ReactNative/i.test(navigator.userAgent):!1}catch{return!1}})(),pe="user",ge=({tokenTypeKey:e="tokenType",tokenKey:n="accessToken",postContentType:o="application/json",...a})=>{const{apiURL:r=a.apiURL,libraries:s,localStorageKeys:c}=p.useContext(A),l=a?.userLocalStorageKey||c?.user||pe,d=a?.axios||s?.axios;if(!d)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!d?.defaults||D)return null;if(typeof window<"u"&&window.localStorage){const u=localStorage.getItem(l),i=u?JSON.parse(u):null,w=i?.[e]?i[e]:null,b=i?.[n]?i[n]:null,j=u?`${w} ${b}`:null;j&&(d.defaults.headers.common.Authorization=j)}return d.defaults.baseURL=r,d.defaults.headers.post["Content-Type"]=o,null},me=({debug:e,resources:n,...o})=>{const{libraries:a}=p.useContext(A),r=o?.i18||a?.i18,{i18next:s,initReactI18next:c,languageDetector:l}=r||{};if(D)return null;if(!r)throw new Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return s?.isInitialized||(s.use(l).use(c).init({debug:e,fallbackLng:"en",interpolation:{escapeValue:!1},load:"languageOnly",react:{bindI18n:"languageChanged loaded",useSuspense:!0},resources:n,returnNull:!1}).then(()=>{document.documentElement.lang!==s.resolvedLanguage&&s.resolvedLanguage&&document.documentElement.setAttribute("lang",s.resolvedLanguage)}),s.on("languageChanged",d=>{document.documentElement.setAttribute("lang",d)})),null},ye=({dsn:e,integrations:n,tracesSampleRate:o,replaysSessionSampleRate:a,replaysOnErrorSampleRate:r,tracePropagationTargets:s,ignoreErrors:c,debug:l,environment:d,release:u,...i})=>{const{libraries:w}=p.useContext(A),b=i?.sentry||w?.sentry,j=i?.reactRouter||w?.reactRouter;if(!b)throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!j)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(b.isInitialized())return null;const{createRoutesFromChildren:x,matchRoutes:C,useLocation:y,useNavigationType:h}=j;return(l||process.env.NODE_ENV==="prod"||process.env.NODE_ENV==="production")&&b.init({debug:l,dsn:e,environment:d||"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:[b.reactRouterV6BrowserTracingIntegration({createRoutesFromChildren:x,matchRoutes:C,useEffect:p.useEffect,useLocation:y,useNavigationType:h}),...n||[]],release:u,replaysOnErrorSampleRate:r||1,replaysSessionSampleRate:a||.1,tracePropagationTargets:s,tracesSampleRate:o||1}),null},he=({IMaskMixin:e,...n})=>{const o=p.useMemo(()=>e(({TextField:a,...r})=>k.jsx(a,{...r})),[e]);return k.jsx(o,{...n})},ve=({language:e,...n})=>{const{libraries:o}=p.useContext(A),a=n?.dayjs||o?.dayjs,r=n?.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";r&&r.forEach(l=>{l&&a.extend(l)}),await import("dayjs/locale/en"),await import("dayjs/locale/fr"),a.locale(c)})().then()},[a,r,e]),null},Ee=()=>(p.useEffect(()=>{if(D)return;const e=n=>{try{n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation(),window.location.reload()}catch{}};return window.addEventListener("vite:preloadError",e),()=>{window.removeEventListener("vite:preloadError",e)}},[]),null),we=e=>e&&typeof e=="function",be=e=>e&&typeof e=="function",Re=({children:e,defaultQueriesOptions:n,defaultMutationsOptions:o,...a})=>{const{libraries:r}=p.useContext(A),s=a?.QueryClient||r?.reactQuery?.QueryClient,c=a?.QueryClientProvider||r?.reactQuery?.QueryClientProvider;if(!s)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(!we(c))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!be(s))throw new Error("Provided QueryClient dependencies are not valid.");const l=new s({defaultOptions:{mutations:{...o},queries:{getNextPageParam:(d,u,i)=>d.length+(i||0),refetchOnWindowFocus:!1,retry:3,...n}}});return k.jsx(c,{client:l,children:e})},Se=e=>{const{libraries:n}=p.useContext(A),o=e?.i18||n?.i18,a=e?.i18?.translateFunction||n?.i18?.translateFunction,r=o?.i18next?.t||a||(u=>u),{unknownErrorTranslationKey:s="error.unknownError"}=e||{},c=r(s),l=p.useCallback(u=>{if(u&&typeof u=="object"&&"response"in u){const{response:i}=u||{};if(i&&typeof i=="object"&&"reason"in i)return String(i.reason);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"reason"in i.data)return String(i.data.reason);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"message"in i.data)return String(i.data.message);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"detail"in i.data){const{detail:w}=i.data;if(Array.isArray(w)&&w.length>0&&typeof w[0]=="object"&&w[0]!==null&&"msg"in w[0]){const{msg:b}=w[0];if(typeof b=="string")return String(b)}}}return u instanceof Error?u.message:c},[c]);return{getErrorCode:p.useCallback(u=>{const{response:i}=u||{};return i?.error_code?String(i?.error_code):i?.data?.error_code?String(i?.data?.error_code):i?.error_code?String(i?.error_code):i?.data?.error_code?String(i.data.error_code):"unknown_error_code"},[]),printError:l}},Ae=({data:e,fetchNextPage:n,isFetchingNextPage:o,isInitialLoading:a,isLoading:r,enabled:s=!0})=>{const c=p.useCallback(async d=>{o||!s||await n({pageParam:d?.pageParam||d.visibleRowsCount})},[s,n,o]),l=p.useMemo(()=>{if(e)return e.pages.reduce((d,u)=>[...d,...u],[])},[e]);return{fetchNextPageOnRowsScrollEnd:c,isLoading:o||r,loadingVariant:a?"skeleton":"linear-progress",rows:l}},Ce=e=>{const{libraries:n}=p.useContext(A),o=e?.axios||n?.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 r=p.useCallback(({tokenType:c,accessToken:l})=>{o.defaults.headers.common.Authorization=`${c} ${l}`},[o.defaults.headers.common]),s=()=>{o.defaults.headers.common.Authorization=null};return p.useEffect(()=>{if(D)return;const c=({newValue:l,key:d})=>{if(d===a&&l)try{const{accessToken:u,tokenType:i}=JSON.parse(l);r({accessToken:u,tokenType:i})}catch(u){console.error("Failed to parse newValue from localStorage:",u)}};return window.addEventListener("storage",c),()=>{window.removeEventListener("storage",c)}},[a,r]),{clearAuthenticationToken:s,setAuthenticationToken:r}},B=({library:e,date:n,format:o="ll"})=>e(n).format(o),X=(e,n)=>{const{fractionDigits:o=0,metric:a="km",spacingBetween:r=!0}=n||{},s=Number(e),c=r?" ":"";return Number.isNaN(s)?`0${c}${a}`:`${s.toFixed(o)}${c}${a}`},H=e=>!e||typeof e!="string"?"":e.replace(/_/g," ").toLowerCase().split(" ").map(o=>o.length>0?o.charAt(0).toUpperCase()+o.slice(1):o).join(" "),je=e=>e?.startsWith("/")?e?.startsWith("/files")?e:`/files${e}`:e?.startsWith("files")?`/${e}`:`/files/${e}`,_e=({path:e,size:n,apiURL:o})=>{if(!e)return"";const a=je(e),r=`${o}${a}`,s=r.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/)!==null;return typeof n=="number"&&s?`${r.replace("/files",`/thumbs/${n}`)}`:r},Pe=e=>{const{apiURL:n,libraries:o}=p.useContext(A),a=e?.dayjs||o?.dayjs;return{dateAdapter:(c,l)=>{if(!a)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return B({date:c,format:l,library:a})},distanceAdapter:X,filePathAdapter:(c,l)=>{if(!n)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:_e({apiURL:n,path:c,size:l})},worksiteNameAdapter:H}},z=(e,n)=>n==="short"?e.split("-")[0]:e,Te=(e,n="full")=>{const[o,a]=p.useState(()=>{const r=e?.language||navigator.language;return e&&"isInitialized"in e&&e.isInitialized,z(r,n)});return p.useEffect(()=>{e&&"isInitialized"in e&&e.isInitialized&&e.language&&a(z(e.language,n));const r=s=>{a(z(s,n))};return e?.on?.("languageChanged",r),()=>{e?.off?.("languageChanged",r)}},[e,n]),o},ke="tracktor.filter",Ie={getFilter:()=>{},getFilters:()=>({}),handleFilter:()=>()=>{},setFilter:()=>{}},Z=(e,n,o)=>`${o}_${e}=>${n}`,Oe=e=>e.reduce((n,o)=>{const a=localStorage.getItem(o);if(a)try{const r=JSON.parse(a),s=Object.keys(r)?.[0];s&&(n[s]=Object.values(r)?.[0])}catch{}return n},{}),xe=e=>{const{libraries:n,localStorageKeys:o}=p.useContext(A),a=e?.reactRouter||n?.reactRouter,{pathname:r}=a?.useLocation?.()??{pathname:"/"},[s,c]=a?.useSearchParams?.()??[new URLSearchParams,()=>{}],[l,d]=p.useState({}),u=o?.filter||ke,i=e?.syncWithUrl===void 0?!0:e?.syncWithUrl;if(D)return Ie;if(!a)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter.");const w=()=>Object.keys(localStorage).filter(y=>y.startsWith(u)&&y.endsWith(e?.pathname||r)),b=(y,h,_=!0)=>{const m=Z(y,e?.pathname||r,u);if(!h||Array.isArray(h)&&!h.length){i?(s.delete(y),c(s)):d(E=>{const P={...E};return delete P[y],P}),localStorage.removeItem(m);return}_&&h&&localStorage.setItem(m,JSON.stringify({...s,[y]:h})),i&&h?(s.set(y,JSON.stringify(h)),c(s)):!i&&h&&d(E=>({...E,[y]:h}))};return{getFilter:(y,h)=>{if(!i){const E=l[y];if(E!==void 0)return E}if(i){const E=s.get(y);if(E)try{return JSON.parse(E)}catch{return E}}const _=Z(y,e?.pathname||r,u),m=localStorage.getItem(_);if(m)try{const E=JSON.parse(m)[y];return!i&&E!==void 0&&d(P=>({...P,[y]:E})),E}catch{}return h},getFilters:()=>{const y=w(),h=Oe(y);if(i){const _=Object.fromEntries(s.entries());return{...h,..._}}return{...h,...l}},handleFilter:(y,h)=>(_,m)=>{if(m||Array.isArray(m)&&m.length===0){const E=h||"value",P=typeof m=="object"&&E in m?m[E]:m;b(y,P);return}b(y,void 0)},setFilter:b}},Ne=e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),Le=e=>{const a=e.split("/").filter(r=>r.length>0).map(r=>r.replace(/\${([^}]*)}/g,"$1").split(/[_-]/).map(d=>d.charAt(0).toUpperCase()+d.slice(1)).join("")).join("");return a.charAt(0).toLowerCase()+a.slice(1)},Fe=e=>(e.split("/").pop()||e).replace(/\.json$/,"").replace(/^openapi\./,""),De=(e,n,o,a)=>{const r=Le(n),s=Ne(o),c=`${r}${s}`;return e&&typeof e=="object"&&"operationId"in e&&a?.includes(String(e.operationId))?`${c}AsQuery`:c},Ye=(e,n)=>{const o={};return e?.forEach(a=>{o[a]={query:{useInfinite:!0,useInfiniteQueryParam:"offset",useQuery:!0}}}),n?.filter(a=>!o[a]).forEach(a=>{o[a]={query:{useQuery:!0}}}),Object.keys(o).length?o:void 0},ze=e=>(Array.isArray(e)?e:[e]).reduce((o,a)=>{const{output:r,useInfiniteIds:s,useQueryIds:c,input:l="./openapi.json"}=a||{},d=Fe(l);return{...o,[d]:{hooks:{afterAllFilesWrite:"prettier src/api/ --write"},input:l,output:{baseUrl:r?.baseUrl,client:"react-query",mode:"tags-split",override:{...(s?.length||c?.length)&&{operations:Ye(s,c)},header:u=>["Generated by orval 🍺",...u.title?[u.title]:[],...u.description?[u.description]:[]],mutator:{name:"axiosCustomInstance",path:"./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts"},operationName:(u,i,w)=>De(u,i,w,c),query:{useQuery:!0}},schemas:r?.schemas||`src/api/${d}/model`,target:r?.target||`src/api/${d}/services/api.ts`,...r}}}},{});g.GTMSendPageView=fe,g.InitializeAxiosConfig=ge,g.InitializeDaysJSConfig=ve,g.InitializeI18nConfig=me,g.InitializeSentryConfig=ye,g.InjectDependenciesContext=A,g.InjectDependenciesProvider=le,g.MaskTextField=he,g.PreloadErrorHandler=Ee,g.QueryClientProviderWithConfig=Re,g.RequireAuth=de,g.axiosCustomInstance=ae,g.dateAdapter=B,g.distanceAdapter=X,g.getOrvalConfig=ze,g.useAdapter=Pe,g.useAuth=Ce,g.useCurrentLanguage=Te,g.useFilters=xe,g.useInfiniteDataGrid=Ae,g.useResponseError=Se,g.worksiteNameAdapter=H,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
22
+ <%s key={someKey} {...props} />`,R,S,N,S),oe[S+R]=!0)}if(S=null,w!==void 0&&(o(w),S=""+w),c(p)&&(o(p.key),S=""+p.key),"key"in p){w={};for(var V in p)V!=="key"&&(w[V]=p[V])}else w=p;return S&&d(w,typeof t=="function"?t.displayName||t.name||"Unknown":t),u(t,S,T,I,r(),w,M,Q)}function E(t){typeof t=="object"&&t!==null&&t.$$typeof===j&&t._store&&(t._store.validated=1)}var y=f,j=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),h=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),_=Symbol.for("react.consumer"),m=Symbol.for("react.context"),b=Symbol.for("react.forward_ref"),P=Symbol.for("react.suspense"),Me=Symbol.for("react.suspense_list"),Qe=Symbol.for("react.memo"),q=Symbol.for("react.lazy"),Ve=Symbol.for("react.activity"),Ge=Symbol.for("react.client.reference"),z=y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,$=Object.prototype.hasOwnProperty,Je=Array.isArray,U=console.createTask?console.createTask:function(){return null};y={"react-stack-bottom-frame":function(t){return t()}};var ee,te={},re=y["react-stack-bottom-frame"].bind(y,s)(),ne=U(a(s)),oe={};F.Fragment=C,F.jsx=function(t,p,w,R,I){var T=1e4>z.recentlyCreatedOwnerStacks++;return i(t,p,w,!1,R,I,T?Error("react-stack-top-frame"):re,T?U(a(t)):ne)},F.jsxs=function(t,p,w,R,I){var T=1e4>z.recentlyCreatedOwnerStacks++;return i(t,p,w,!0,R,I,T?Error("react-stack-top-frame"):re,T?U(a(t)):ne)}}()),F}var K;function ce(){return K||(K=1,process.env.NODE_ENV==="production"?Y.exports=se():Y.exports=ie()),Y.exports}var k=ce();const A=f.createContext({}),le=({children:e,apiURL:n,libraries:o,localStorageKeys:a})=>{const r=f.useMemo(()=>({apiURL:n,libraries:o,localStorageKeys:a}),[n,o,a]);return k.jsx(A.Provider,{value:r,children:e})},ue="user",de=({Fallback:e,isLogged:n,loginPath:o="/login",redirect401Path:a="/login",...r})=>{const{libraries:s,localStorageKeys:c}=f.useContext(A),d=r?.reactRouter||s?.reactRouter,l=r?.axios||s?.axios,u=r?.localStorageKey||c?.user||ue;if(!d)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");const[i,E]=f.useState(null),{useLocation:y,Navigate:j,Outlet:x}=d,C=y(),h=f.useRef(!1),v=typeof n=="function"?n():!!n,_=typeof v=="boolean"?v:v?.isLogged;return f.useEffect(()=>{h.current||(h.current=!0,l.interceptors.response.use(m=>m,async m=>(typeof m=="object"&&m&&"response"in m&&m.response&&typeof m.response=="object"&&"status"in m.response&&m.response&&typeof m.response=="object"&&"status"in m.response&&m?.response?.status===401&&(l.defaults.headers.common.Authorization=null,typeof window<"u"&&window.localStorage&&localStorage.removeItem(u),E(a)),Promise.reject(m))))},[l.defaults.headers.common,l.interceptors.response,u,a]),_&&!i?k.jsx(f.Suspense,{fallback:e,children:C.state?.from?.state&&C.state?.from?.pathname===o?k.jsx(j,{to:C.state.from.state.from.pathname+C.state.from.state.from.search,replace:!0}):k.jsx(x,{})}):k.jsx(j,{to:o+C.search,state:{from:C},replace:!0})},fe=({data:e,...n})=>{const{libraries:o}=f.useContext(A),a=n?.reactRouter||o?.reactRouter,r=n?.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(!r)throw new Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");const{useGoogleTagManager:s}=r,{useLocation:c,Outlet:d}=a,{pathname:l}=c(),{sendEvent:u}=s();return f.useEffect(()=>{u({event:"pageView",pathname:l,...e})},[e,l,u]),k.jsx(d,{})},D=(()=>{try{return typeof global=="object"&&global!==null&&("HermesInternal"in global||"__fbBatchedBridge"in global||"__metro"in global)||typeof window>"u"&&typeof global<"u"?!0:typeof navigator<"u"&&navigator.userAgent?/react.native|ReactNative/i.test(navigator.userAgent):!1}catch{return!1}})(),pe="user",ge=({tokenTypeKey:e="tokenType",tokenKey:n="accessToken",postContentType:o="application/json",...a})=>{const{apiURL:r=a.apiURL,libraries:s,localStorageKeys:c}=f.useContext(A),d=a?.userLocalStorageKey||c?.user||pe,l=a?.axios||s?.axios;if(!l)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!l?.defaults||D)return null;if(typeof window<"u"&&window.localStorage){const u=localStorage.getItem(d),i=u?JSON.parse(u):null,E=i?.[e]?i[e]:null,y=i?.[n]?i[n]:null,j=u?`${E} ${y}`:null;j&&(l.defaults.headers.common.Authorization=j)}return l.defaults.baseURL=r,l.defaults.headers.post["Content-Type"]=o,null},me=({debug:e,resources:n,...o})=>{const{libraries:a}=f.useContext(A),r=o?.i18||a?.i18,{i18next:s,initReactI18next:c,languageDetector:d}=r||{};if(D)return null;if(!r)throw new Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return s?.isInitialized||(s.use(d).use(c).init({debug:e,fallbackLng:"en",interpolation:{escapeValue:!1},load:"languageOnly",react:{bindI18n:"languageChanged loaded",useSuspense:!0},resources:n,returnNull:!1}).then(()=>{document.documentElement.lang!==s.resolvedLanguage&&s.resolvedLanguage&&document.documentElement.setAttribute("lang",s.resolvedLanguage)}),s.on("languageChanged",l=>{document.documentElement.setAttribute("lang",l)})),null},ye=({dsn:e,integrations:n,tracesSampleRate:o,replaysSessionSampleRate:a,replaysOnErrorSampleRate:r,tracePropagationTargets:s,ignoreErrors:c,debug:d,environment:l,release:u,...i})=>{const{libraries:E}=f.useContext(A),y=i?.sentry||E?.sentry,j=i?.reactRouter||E?.reactRouter;if(!y)throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!j)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(y.isInitialized())return null;const{createRoutesFromChildren:x,matchRoutes:C,useLocation:h,useNavigationType:v}=j;return(d||process.env.NODE_ENV==="prod"||process.env.NODE_ENV==="production")&&y.init({debug:d,dsn:e,environment:l||"production",ignoreErrors:[...c||[],/dynamically imported module/,/Cannot read properties of undefined \(reading 'default'\)/,/Loading chunk \d+ failed/,/ChunkLoadError/,/Failed to fetch dynamically imported module/,/vite:preloadError/],integrations:[y.reactRouterV6BrowserTracingIntegration({createRoutesFromChildren:x,matchRoutes:C,useEffect:f.useEffect,useLocation:h,useNavigationType:v}),...n||[]],release:u,replaysOnErrorSampleRate:r||1,replaysSessionSampleRate:a||.1,tracePropagationTargets:s,tracesSampleRate:o||1}),null},he=({IMaskMixin:e,...n})=>{const o=f.useMemo(()=>e(({TextField:a,...r})=>k.jsx(a,{...r})),[e]);return k.jsx(o,{...n})},ve=({language:e,...n})=>{const{libraries:o}=f.useContext(A),a=n?.dayjs||o?.dayjs,r=n?.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 f.useEffect(()=>{(async()=>{const c=e||navigator.language?.slice(0,2)||"en";r&&r.forEach(d=>{d&&a.extend(d)}),await import("dayjs/locale/en"),await import("dayjs/locale/fr"),a.locale(c)})().then()},[a,r,e]),null},Ee=()=>(f.useEffect(()=>{if(D)return;const e=n=>{try{n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation(),window.location.reload()}catch{}};return window.addEventListener("vite:preloadError",e),()=>{window.removeEventListener("vite:preloadError",e)}},[]),null),we=async()=>{if("caches"in window)try{const e=await caches.keys();await Promise.all(e.map(n=>caches.delete(n)))}catch(e){console.error("Failed to clear caches:",e)}},be=({autoUpdate:e,renderDialog:n,clearCachesOnReload:o})=>{const a=f.useRef(null),[r,s]=f.useState(!1),c=f.useCallback(async()=>{a.current&&a.current.postMessage({type:"SKIP_WAITING"}),o&&await we(),window.location.reload()},[o]),d=f.useCallback(async()=>{window.confirm("A new version is available. The app will reload now.")&&await c()},[c]);return f.useEffect(()=>{if(!("serviceWorker"in navigator))return;let l,u;const i=y=>{y&&navigator.serviceWorker.controller&&(a.current=y,s(!0))},E=()=>{const y=l?.installing;y&&(u=()=>{y.state==="installed"&&i(y)},y.addEventListener("statechange",u))};return(async()=>{l=await navigator.serviceWorker.getRegistration(),l&&(i(l.waiting),l.addEventListener("updatefound",E))})().catch(console.error),()=>{l?.removeEventListener("updatefound",E),u&&l?.installing&&l.installing.removeEventListener("statechange",u)}},[]),f.useEffect(()=>{r&&e&&c().catch(console.error)},[e,r,c]),f.useEffect(()=>{r&&!e&&!n&&d().catch(console.error)},[n,d,r,e]),r&&!e&&n?n(c):null},Re=e=>e&&typeof e=="function",Se=e=>e&&typeof e=="function",Ae=({children:e,defaultQueriesOptions:n,defaultMutationsOptions:o,...a})=>{const{libraries:r}=f.useContext(A),s=a?.QueryClient||r?.reactQuery?.QueryClient,c=a?.QueryClientProvider||r?.reactQuery?.QueryClientProvider;if(!s)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(!Re(c))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!Se(s))throw new Error("Provided QueryClient dependencies are not valid.");const d=new s({defaultOptions:{mutations:{...o},queries:{getNextPageParam:(l,u,i)=>l.length+(i||0),refetchOnWindowFocus:!1,retry:3,...n}}});return k.jsx(c,{client:d,children:e})},Ce=e=>{const{libraries:n}=f.useContext(A),o=e?.i18||n?.i18,a=e?.i18?.translateFunction||n?.i18?.translateFunction,r=o?.i18next?.t||a||(u=>u),{unknownErrorTranslationKey:s="error.unknownError"}=e||{},c=r(s),d=f.useCallback(u=>{if(u&&typeof u=="object"&&"response"in u){const{response:i}=u||{};if(i&&typeof i=="object"&&"reason"in i)return String(i.reason);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"reason"in i.data)return String(i.data.reason);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"message"in i.data)return String(i.data.message);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"detail"in i.data){const{detail:E}=i.data;if(Array.isArray(E)&&E.length>0&&typeof E[0]=="object"&&E[0]!==null&&"msg"in E[0]){const{msg:y}=E[0];if(typeof y=="string")return String(y)}}}return u instanceof Error?u.message:c},[c]);return{getErrorCode:f.useCallback(u=>{const{response:i}=u||{};return i?.error_code?String(i?.error_code):i?.data?.error_code?String(i?.data?.error_code):i?.error_code?String(i?.error_code):i?.data?.error_code?String(i.data.error_code):"unknown_error_code"},[]),printError:d}},je=({data:e,fetchNextPage:n,isFetchingNextPage:o,isInitialLoading:a,isLoading:r,enabled:s=!0})=>{const c=f.useCallback(async l=>{o||!s||await n({pageParam:l?.pageParam||l.visibleRowsCount})},[s,n,o]),d=f.useMemo(()=>{if(e)return e.pages.reduce((l,u)=>[...l,...u],[])},[e]);return{fetchNextPageOnRowsScrollEnd:c,isLoading:o||r,loadingVariant:a?"skeleton":"linear-progress",rows:d}},_e=e=>{const{libraries:n}=f.useContext(A),o=e?.axios||n?.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 r=f.useCallback(({tokenType:c,accessToken:d})=>{o.defaults.headers.common.Authorization=`${c} ${d}`},[o.defaults.headers.common]),s=()=>{o.defaults.headers.common.Authorization=null};return f.useEffect(()=>{if(D)return;const c=({newValue:d,key:l})=>{if(l===a&&d)try{const{accessToken:u,tokenType:i}=JSON.parse(d);r({accessToken:u,tokenType:i})}catch(u){console.error("Failed to parse newValue from localStorage:",u)}};return window.addEventListener("storage",c),()=>{window.removeEventListener("storage",c)}},[a,r]),{clearAuthenticationToken:s,setAuthenticationToken:r}},B=({library:e,date:n,format:o="ll"})=>e(n).format(o),H=(e,n)=>{const{fractionDigits:o=0,metric:a="km",spacingBetween:r=!0}=n||{},s=Number(e),c=r?" ":"";return Number.isNaN(s)?`0${c}${a}`:`${s.toFixed(o)}${c}${a}`},X=e=>!e||typeof e!="string"?"":e.replace(/_/g," ").toLowerCase().split(" ").map(o=>o.length>0?o.charAt(0).toUpperCase()+o.slice(1):o).join(" "),Pe=e=>e?.startsWith("/")?e?.startsWith("/files")?e:`/files${e}`:e?.startsWith("files")?`/${e}`:`/files/${e}`,Te=({path:e,size:n,apiURL:o})=>{if(!e)return"";const a=Pe(e),r=`${o}${a}`,s=r.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/)!==null;return typeof n=="number"&&s?`${r.replace("/files",`/thumbs/${n}`)}`:r},ke=e=>{const{apiURL:n,libraries:o}=f.useContext(A),a=e?.dayjs||o?.dayjs;return{dateAdapter:(c,d)=>{if(!a)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return B({date:c,format:d,library:a})},distanceAdapter:H,filePathAdapter:(c,d)=>{if(!n)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:Te({apiURL:n,path:c,size:d})},worksiteNameAdapter:X}},W=(e,n)=>n==="short"?e.split("-")[0]:e,Ie=(e,n="full")=>{const[o,a]=f.useState(()=>{const r=e?.language||navigator.language;return e&&"isInitialized"in e&&e.isInitialized,W(r,n)});return f.useEffect(()=>{e&&"isInitialized"in e&&e.isInitialized&&e.language&&a(W(e.language,n));const r=s=>{a(W(s,n))};return e?.on?.("languageChanged",r),()=>{e?.off?.("languageChanged",r)}},[e,n]),o},Oe="tracktor.filter",xe={getFilter:()=>{},getFilters:()=>({}),handleFilter:()=>()=>{},setFilter:()=>{}},Z=(e,n,o)=>`${o}_${e}=>${n}`,Ne=e=>e.reduce((n,o)=>{const a=localStorage.getItem(o);if(a)try{const r=JSON.parse(a),s=Object.keys(r)?.[0];s&&(n[s]=Object.values(r)?.[0])}catch{}return n},{}),Le=e=>{const{libraries:n,localStorageKeys:o}=f.useContext(A),a=e?.reactRouter||n?.reactRouter,{pathname:r}=a?.useLocation?.()??{pathname:"/"},[s,c]=a?.useSearchParams?.()??[new URLSearchParams,()=>{}],[d,l]=f.useState({}),u=o?.filter||Oe,i=e?.syncWithUrl===void 0?!0:e?.syncWithUrl;if(D)return xe;if(!a)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter.");const E=()=>Object.keys(localStorage).filter(h=>h.startsWith(u)&&h.endsWith(e?.pathname||r)),y=(h,v,_=!0)=>{const m=Z(h,e?.pathname||r,u);if(!v||Array.isArray(v)&&!v.length){i?(s.delete(h),c(s)):l(b=>{const P={...b};return delete P[h],P}),localStorage.removeItem(m);return}_&&v&&localStorage.setItem(m,JSON.stringify({...s,[h]:v})),i&&v?(s.set(h,JSON.stringify(v)),c(s)):!i&&v&&l(b=>({...b,[h]:v}))};return{getFilter:(h,v)=>{if(!i){const b=d[h];if(b!==void 0)return b}if(i){const b=s.get(h);if(b)try{return JSON.parse(b)}catch{return b}}const _=Z(h,e?.pathname||r,u),m=localStorage.getItem(_);if(m)try{const b=JSON.parse(m)[h];return!i&&b!==void 0&&l(P=>({...P,[h]:b})),b}catch{}return v},getFilters:()=>{const h=E(),v=Ne(h);if(i){const _=Object.fromEntries(s.entries());return{...v,..._}}return{...v,...d}},handleFilter:(h,v)=>(_,m)=>{if(m||Array.isArray(m)&&m.length===0){const b=v||"value",P=typeof m=="object"&&b in m?m[b]:m;y(h,P);return}y(h,void 0)},setFilter:y}},Fe=e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),De=e=>{const a=e.split("/").filter(r=>r.length>0).map(r=>r.replace(/\${([^}]*)}/g,"$1").split(/[_-]/).map(l=>l.charAt(0).toUpperCase()+l.slice(1)).join("")).join("");return a.charAt(0).toLowerCase()+a.slice(1)},Ye=e=>(e.split("/").pop()||e).replace(/\.json$/,"").replace(/^openapi\./,""),We=(e,n,o,a)=>{const r=De(n),s=Fe(o),c=`${r}${s}`;return e&&typeof e=="object"&&"operationId"in e&&a?.includes(String(e.operationId))?`${c}AsQuery`:c},ze=(e,n)=>{const o={};return e?.forEach(a=>{o[a]={query:{useInfinite:!0,useInfiniteQueryParam:"offset",useQuery:!0}}}),n?.filter(a=>!o[a]).forEach(a=>{o[a]={query:{useQuery:!0}}}),Object.keys(o).length?o:void 0},Ue=e=>(Array.isArray(e)?e:[e]).reduce((o,a)=>{const{output:r,useInfiniteIds:s,useQueryIds:c,input:d="./openapi.json"}=a||{},l=Ye(d);return{...o,[l]:{hooks:{afterAllFilesWrite:"prettier src/api/ --write"},input:d,output:{baseUrl:r?.baseUrl,client:"react-query",mode:"tags-split",override:{...(s?.length||c?.length)&&{operations:ze(s,c)},header:u=>["Generated by orval 🍺",...u.title?[u.title]:[],...u.description?[u.description]:[]],mutator:{name:"axiosCustomInstance",path:"./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts"},operationName:(u,i,E)=>We(u,i,E,c),query:{useQuery:!0}},schemas:r?.schemas||`src/api/${l}/model`,target:r?.target||`src/api/${l}/services/api.ts`,...r}}}},{});g.GTMSendPageView=fe,g.InitializeAxiosConfig=ge,g.InitializeDaysJSConfig=ve,g.InitializeI18nConfig=me,g.InitializeSentryConfig=ye,g.InjectDependenciesContext=A,g.InjectDependenciesProvider=le,g.MaskTextField=he,g.PreloadErrorHandler=Ee,g.QueryClientProviderWithConfig=Ae,g.RequireAuth=de,g.UpdateNotifier=be,g.axiosCustomInstance=ae,g.dateAdapter=B,g.distanceAdapter=H,g.getOrvalConfig=Ue,g.useAdapter=ke,g.useAuth=_e,g.useCurrentLanguage=Ie,g.useFilters=Le,g.useInfiniteDataGrid=je,g.useResponseError=Ce,g.worksiteNameAdapter=X,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tracktor/shared-module",
3
- "version": "2.17.1",
3
+ "version": "2.18.1",
4
4
  "type": "module",
5
5
  "license": "UNLICENSED",
6
6
  "types": "./dist/main.d.ts",