@getsoren/shared-module 2.51.1 → 2.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -57,6 +57,11 @@ interface InitializeSentryConfigProps {
57
57
  * By default, all errors will be sent.
58
58
  */
59
59
  ignoreErrors?: Array<string | RegExp>;
60
+ /**
61
+ * Outgoing request URLs that should not get an `http.client` span (a string matches as a substring).
62
+ * Added to `SENTRY_IGNORED_REQUEST_URLS` (Mapbox), which is always ignored.
63
+ */
64
+ ignoreRequestUrls?: Array<string | RegExp>;
60
65
  /**
61
66
  * The current environment of your application (e.g. "production").
62
67
  */
@@ -78,9 +83,10 @@ interface InitializeSentryConfigProps {
78
83
  * @param replayBeforeErrorSampling
79
84
  * @param tracePropagationTargets
80
85
  * @param ignoreErrors
86
+ * @param ignoreRequestUrls
81
87
  * @param debug
82
88
  * @param environment
83
89
  * @constructor
84
90
  */
85
- declare const InitializeSentryConfig: ({ dsn, integrations, tracesSampleRate, tracePropagationTargets, ignoreErrors, debug, environment, release, replaysSessionSampleRate, replaysOnErrorSampleRate, replayBeforeErrorSampling, ...props }: InitializeSentryConfigProps) => null;
91
+ declare const InitializeSentryConfig: ({ dsn, integrations, tracesSampleRate, tracePropagationTargets, ignoreErrors, ignoreRequestUrls, debug, environment, release, replaysSessionSampleRate, replaysOnErrorSampleRate, replayBeforeErrorSampling, ...props }: InitializeSentryConfigProps) => null;
86
92
  export default InitializeSentryConfig;
@@ -11,3 +11,12 @@ export declare const SENTRY_KEEP_REPLAY: {
11
11
  * buffered replay, so a noisy error never burns the replay quota by itself.
12
12
  */
13
13
  export declare const isReplayKeptForError: (event: ErrorEvent) => boolean;
14
+ /**
15
+ * Outgoing requests that never get an `http.client` span. Mapbox GL fetches its glyph ranges and telemetry in
16
+ * parallel bursts that Sentry flags as "N+1 API Call", while we cannot batch them.
17
+ */
18
+ export declare const SENTRY_IGNORED_REQUEST_URLS: Array<string | RegExp>;
19
+ /**
20
+ * Whether `url` matches one of `patterns`: a string matches as a substring, a RegExp is tested against the full URL.
21
+ */
22
+ export declare const matchesRequestUrl: (url: string, patterns: Array<string | RegExp>) => boolean;
@@ -0,0 +1 @@
1
+ export {};
package/dist/main.js CHANGED
@@ -195,18 +195,18 @@ var f = 3e4, p = 1e3, m = 1e4, h = (e) => Array.isArray(e) ? e.map(h) : typeof e
195
195
  "[contenteditable=\"true\" i]",
196
196
  "[data-amp-default-track]",
197
197
  ".amp-default-track"
198
- ], M = { defaultMaskLevel: "medium" }, N = (e, t) => {
198
+ ], ee = { defaultMaskLevel: "medium" }, M = (e, t) => {
199
199
  if (e === !1) return !1;
200
200
  let n = e === !0 ? {} : e;
201
201
  return {
202
202
  cssSelectorAllowlist: [...t, A],
203
203
  ...n
204
204
  };
205
- }, P = (e, t) => !t || e === !1 ? !1 : {
205
+ }, N = (e, t) => !t || e === !1 ? !1 : {
206
206
  deadClicks: !0,
207
207
  rageClicks: !0,
208
208
  ...e === !0 ? {} : e
209
- }, F = ({ apiKey: e, appVersion: t, sessionReplaySampleRate: n, serverZone: r, elementInteractions: i = !0, frustrationInteractions: c = !0, platform: u = "desktop", sessionReplayPrivacy: d = M, ...f }) => {
209
+ }, P = ({ apiKey: e, appVersion: t, sessionReplaySampleRate: n, serverZone: r, elementInteractions: i = !0, frustrationInteractions: c = !0, platform: u = "desktop", sessionReplayPrivacy: d = ee, ...f }) => {
210
210
  let { libraries: p } = a(y), m = f.amplitude || p?.amplitude, h = l({
211
211
  elementInteractions: i,
212
212
  frustrationInteractions: c,
@@ -221,12 +221,12 @@ var f = 3e4, p = 1e3, m = 1e4, h = (e) => Array.isArray(e) ? e.map(h) : typeof e
221
221
  }), o(() => {
222
222
  let i = m?.analytics, a = m?.sessionReplayPlugin;
223
223
  if (!(e && i)) return;
224
- let { elementInteractions: o, frustrationInteractions: s, sessionReplayPrivacy: c } = h.current, l = "platform-enrichment", d = N(o, i.Types?.DEFAULT_CSS_SELECTOR_ALLOWLIST ?? j);
224
+ let { elementInteractions: o, frustrationInteractions: s, sessionReplayPrivacy: c } = h.current, l = "platform-enrichment", d = M(o, i.Types?.DEFAULT_CSS_SELECTOR_ALLOWLIST ?? j);
225
225
  return i.init(e, {
226
226
  appVersion: t,
227
227
  autocapture: {
228
228
  elementInteractions: d,
229
- frustrationInteractions: P(s, d !== !1),
229
+ frustrationInteractions: N(s, d !== !1),
230
230
  pageViews: { trackHistoryChanges: "pathOnly" }
231
231
  },
232
232
  serverZone: r
@@ -254,22 +254,22 @@ var f = 3e4, p = 1e3, m = 1e4, h = (e) => Array.isArray(e) ? e.map(h) : typeof e
254
254
  r,
255
255
  n
256
256
  ]), null;
257
- }, I = (() => {
257
+ }, F = (() => {
258
258
  try {
259
259
  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;
260
260
  } catch {
261
261
  return !1;
262
262
  }
263
- })(), L = "user", R = ({ tokenTypeKey: e = "tokenType", tokenKey: t = "accessToken", postContentType: n = "application/json", ...r }) => {
264
- let { apiURL: i = r.apiURL, libraries: o, localStorageKeys: s } = a(y), c = r?.userLocalStorageKey || s?.user || L, l = r?.axios || o?.axios;
263
+ })(), I = "user", L = ({ tokenTypeKey: e = "tokenType", tokenKey: t = "accessToken", postContentType: n = "application/json", ...r }) => {
264
+ let { apiURL: i = r.apiURL, libraries: o, localStorageKeys: s } = a(y), c = r?.userLocalStorageKey || s?.user || I, l = r?.axios || o?.axios;
265
265
  if (!l) throw Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
266
- if (!l?.defaults || I) return null;
266
+ if (!l?.defaults || F) return null;
267
267
  if (typeof window < "u" && window.localStorage) {
268
268
  let n = localStorage.getItem(c), r = n ? JSON.parse(n) : null, i = r?.[e] ? r[e] : null, a = r?.[t] ? r[t] : null, o = n ? `${i} ${a}` : null;
269
269
  o && (l.defaults.headers.common.Authorization = o);
270
270
  }
271
271
  return l.defaults.baseURL = i, l.defaults.headers.post["Content-Type"] = n, null;
272
- }, z = [
272
+ }, R = [
273
273
  "ar",
274
274
  "de",
275
275
  "en",
@@ -277,15 +277,15 @@ var f = 3e4, p = 1e3, m = 1e4, h = (e) => Array.isArray(e) ? e.map(h) : typeof e
277
277
  "fr",
278
278
  "it",
279
279
  "pt"
280
- ], ee = (e) => z.includes(e), te = ({ language: e, ...t }) => {
280
+ ], te = (e) => R.includes(e), ne = ({ language: e, ...t }) => {
281
281
  let { libraries: n } = a(y), r = t?.dayjs || n?.dayjs, i = t?.plugin || n?.dayjsPlugin;
282
282
  if (!r) throw Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig.");
283
283
  r.extend(t.localizedFormat), i && i.forEach((e) => {
284
284
  e && r.extend(e);
285
285
  });
286
- let o = e || navigator.language?.slice(0, 2) || "en", s = ee(o) ? o : "en";
286
+ let o = e || navigator.language?.slice(0, 2) || "en", s = te(o) ? o : "en";
287
287
  return r.locale() !== s && r.locale(s), null;
288
- }, B = "hubspot-messages-iframe-container", V = "hs-show", H = "data-hs-hidden", ne = ({ hubId: e }) => (o(() => {
288
+ }, z = "hubspot-messages-iframe-container", B = "hs-show", V = "data-hs-hidden", re = ({ hubId: e }) => (o(() => {
289
289
  if (!e) return;
290
290
  let t = document.createElement("script");
291
291
  return t.id = "hs-script-loader", t.src = `//js-eu1.hs-scripts.com/${e}.js`, t.async = !0, t.defer = !0, document.body.appendChild(t), () => {
@@ -294,14 +294,14 @@ var f = 3e4, p = 1e3, m = 1e4, h = (e) => Array.isArray(e) ? e.map(h) : typeof e
294
294
  }, [e]), o(() => {
295
295
  let e = document.createElement("style");
296
296
  return e.textContent = `
297
- html[${H}] div#${B} { display: none !important; }
298
- html[${H}] div#${B}.${V} { display: initial !important; }
299
- `, document.head.appendChild(e), document.documentElement.setAttribute(H, ""), () => {
300
- e.remove(), document.documentElement.removeAttribute(H);
297
+ html[${V}] div#${z} { display: none !important; }
298
+ html[${V}] div#${z}.${B} { display: initial !important; }
299
+ `, document.head.appendChild(e), document.documentElement.setAttribute(V, ""), () => {
300
+ e.remove(), document.documentElement.removeAttribute(V);
301
301
  };
302
- }, []), null), re = ({ debug: e, resources: t, ...n }) => {
302
+ }, []), null), ie = ({ debug: e, resources: t, ...n }) => {
303
303
  let { libraries: r } = a(y), i = n?.i18 || r?.i18, { i18next: o, initReactI18next: s, languageDetector: c } = i || {};
304
- if (I) return null;
304
+ if (F) return null;
305
305
  if (!(i && o && c && s)) throw Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
306
306
  return o.isInitialized ? null : (o.use(c).use(s).init({
307
307
  debug: e,
@@ -319,16 +319,16 @@ var f = 3e4, p = 1e3, m = 1e4, h = (e) => Array.isArray(e) ? e.map(h) : typeof e
319
319
  }), o.on("languageChanged", (e) => {
320
320
  document.documentElement.setAttribute("lang", e);
321
321
  }), null);
322
- }, U = { replay: "keep" }, W = (e) => e.tags?.replay === U.replay, ie = ({ dsn: e, integrations: t, tracesSampleRate: n, tracePropagationTargets: r, ignoreErrors: i, debug: s, environment: c, release: l, replaysSessionSampleRate: u = 0, replaysOnErrorSampleRate: d = 1, replayBeforeErrorSampling: f = W, ...p }) => {
323
- let { libraries: m } = a(y), h = p?.sentry || m?.sentry, g = p?.reactRouter || m?.reactRouter;
324
- if (!h) throw Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
325
- if (!g) throw Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
326
- if (h.isInitialized()) return null;
327
- let { createRoutesFromChildren: _, matchRoutes: v, useLocation: b, useNavigationType: x } = g, S = u > 0 || d > 0;
328
- return (s || process.env.NODE_ENV === "prod" || process.env.NODE_ENV === "production") && h.init({
329
- debug: s,
322
+ }, H = { replay: "keep" }, U = (e) => e.tags?.replay === H.replay, W = [/^https:\/\/(api|events)\.mapbox\.com\//], G = (e, t) => t.some((t) => typeof t == "string" ? e.includes(t) : t.test(e)), ae = ({ dsn: e, integrations: t, tracesSampleRate: n, tracePropagationTargets: r, ignoreErrors: i, ignoreRequestUrls: s, debug: c, environment: l, release: u, replaysSessionSampleRate: d = 0, replaysOnErrorSampleRate: f = 1, replayBeforeErrorSampling: p = U, ...m }) => {
323
+ let { libraries: h } = a(y), g = m?.sentry || h?.sentry, _ = m?.reactRouter || h?.reactRouter;
324
+ if (!g) throw Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
325
+ if (!_) throw Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
326
+ if (g.isInitialized()) return null;
327
+ let { createRoutesFromChildren: v, matchRoutes: b, useLocation: x, useNavigationType: S } = _, C = d > 0 || f > 0, w = [...s || [], ...W];
328
+ return (c || process.env.NODE_ENV === "prod" || process.env.NODE_ENV === "production") && g.init({
329
+ debug: c,
330
330
  dsn: e,
331
- environment: c || "production",
331
+ environment: l || "production",
332
332
  ignoreErrors: [
333
333
  ...i || [],
334
334
  /dynamically imported module/,
@@ -339,28 +339,29 @@ var f = 3e4, p = 1e3, m = 1e4, h = (e) => Array.isArray(e) ? e.map(h) : typeof e
339
339
  /vite:preloadError/
340
340
  ],
341
341
  integrations: [
342
- h.reactRouterV6BrowserTracingIntegration({
343
- createRoutesFromChildren: _,
344
- matchRoutes: v,
342
+ g.reactRouterV6BrowserTracingIntegration({
343
+ createRoutesFromChildren: v,
344
+ matchRoutes: b,
345
+ shouldCreateSpanForRequest: (e) => !G(e, w),
345
346
  useEffect: o,
346
- useLocation: b,
347
- useNavigationType: x
347
+ useLocation: x,
348
+ useNavigationType: S
348
349
  }),
349
- ...S ? [h.replayIntegration({ beforeErrorSampling: f })] : [],
350
+ ...C ? [g.replayIntegration({ beforeErrorSampling: p })] : [],
350
351
  ...t || []
351
352
  ],
352
- release: l,
353
- replaysOnErrorSampleRate: d,
354
- replaysSessionSampleRate: u,
353
+ release: u,
354
+ replaysOnErrorSampleRate: f,
355
+ replaysSessionSampleRate: d,
355
356
  tracePropagationTargets: r,
356
357
  tracesSampleRate: n ?? 1
357
358
  }), null;
358
- }, G = /* @__PURE__ */ new WeakMap(), ae = "user", oe = ({ Fallback: e, isLogged: n, loginPath: r = "/login", redirect401Path: i = "/login", ...s }) => {
359
- let { libraries: c, localStorageKeys: l } = a(y), f = s?.reactRouter || c?.reactRouter, p = s?.axios || c?.axios, m = s?.localStorageKey || l?.user || ae;
359
+ }, K = /* @__PURE__ */ new WeakMap(), oe = "user", se = ({ Fallback: e, isLogged: n, loginPath: r = "/login", redirect401Path: i = "/login", ...s }) => {
360
+ let { libraries: c, localStorageKeys: l } = a(y), f = s?.reactRouter || c?.reactRouter, p = s?.axios || c?.axios, m = s?.localStorageKey || l?.user || oe;
360
361
  if (!f) throw Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
361
362
  let [h, g] = u(null), { useLocation: _, Navigate: v, Outlet: b } = f, x = _(), S = typeof n == "function" ? n() : !!n, C = typeof S == "boolean" ? S : S?.isLogged;
362
363
  return o(() => {
363
- p && (G.has(p) || (G.set(p, !0), p.interceptors.response.use((e) => e, (e) => (typeof e == "object" && e && "response" in e && e.response && typeof e.response == "object" && "status" in e.response && e.response && typeof e.response == "object" && "status" in e.response && e?.response?.status === 401 && (typeof e == "object" && e && "config" in e && e.config && typeof e.config == "object" && "headers" in e.config && e.config.headers && typeof e.config.headers == "object" && "Authorization" in e.config.headers && e.config.headers.Authorization && (p.defaults.headers.common.Authorization = null, typeof window < "u" && window.localStorage && localStorage.removeItem(m)), g(i)), Promise.reject(e)))));
364
+ p && (K.has(p) || (K.set(p, !0), p.interceptors.response.use((e) => e, (e) => (typeof e == "object" && e && "response" in e && e.response && typeof e.response == "object" && "status" in e.response && e.response && typeof e.response == "object" && "status" in e.response && e?.response?.status === 401 && (typeof e == "object" && e && "config" in e && e.config && typeof e.config == "object" && "headers" in e.config && e.config.headers && typeof e.config.headers == "object" && "Authorization" in e.config.headers && e.config.headers.Authorization && (p.defaults.headers.common.Authorization = null, typeof window < "u" && window.localStorage && localStorage.removeItem(m)), g(i)), Promise.reject(e)))));
364
365
  }, [
365
366
  p,
366
367
  m,
@@ -376,28 +377,28 @@ var f = 3e4, p = 1e3, m = 1e4, h = (e) => Array.isArray(e) ? e.map(h) : typeof e
376
377
  state: { from: x },
377
378
  replace: !0
378
379
  });
379
- }, K = /* @__PURE__ */ new Set(), se = () => (o(() => {
380
+ }, q = /* @__PURE__ */ new Set(), ce = () => (o(() => {
380
381
  let e = Symbol();
381
- return K.add(e), document.documentElement.removeAttribute(H), () => {
382
- K.delete(e), K.size === 0 && document.documentElement.setAttribute(H, "");
382
+ return q.add(e), document.documentElement.removeAttribute(V), () => {
383
+ q.delete(e), q.size === 0 && document.documentElement.setAttribute(V, "");
383
384
  };
384
- }, []), null), ce = "user", le = {
385
+ }, []), null), le = "user", ue = {
385
386
  client: "/v2/threads/ws",
386
387
  supplier: "/v1/threads/ws"
387
- }, ue = (e, t) => `${e.startsWith("https") ? "wss" : "ws"}://${e.replace(/^https?:\/\//, "")}${t}`, de = (e) => {
388
+ }, de = (e, t) => `${e.startsWith("https") ? "wss" : "ws"}://${e.replace(/^https?:\/\//, "")}${t}`, fe = (e) => {
388
389
  try {
389
390
  let t = localStorage.getItem(e);
390
391
  return t ? JSON.parse(t)?.accessToken ?? null : null;
391
392
  } catch {
392
393
  return null;
393
394
  }
394
- }, q = n(null), fe = ({ children: e, token: t, url: n, wsPath: r, maxReconnectAttempts: s, reconnectBaseDelay: c, maxMessageBodyLength: f = 1e4, reconnect: p = !0, enabled: m = !0, context: h = "client" }) => {
395
- let [g, v] = u(!1), [b, x] = u(!1), [S, C] = u(0), [w, T] = u(m), E = m && w, { apiURL: D, localStorageKeys: O } = a(y), k = O?.user || ce, A = l(null), j = l(/* @__PURE__ */ new Set());
395
+ }, J = n(null), pe = ({ children: e, token: t, url: n, wsPath: r, maxReconnectAttempts: s, reconnectBaseDelay: c, maxMessageBodyLength: f = 1e4, reconnect: p = !0, enabled: m = !0, context: h = "client" }) => {
396
+ let [g, v] = u(!1), [b, x] = u(!1), [S, C] = u(0), [w, T] = u(m), E = m && w, { apiURL: D, localStorageKeys: O } = a(y), k = O?.user || le, A = l(null), j = l(/* @__PURE__ */ new Set());
396
397
  o(() => {
397
398
  if (!E) return;
398
- let e = r ?? le[h], i = n || (D ? ue(D, e) : null);
399
+ let e = r ?? ue[h], i = n || (D ? de(D, e) : null);
399
400
  if (!i) return;
400
- let a = () => t ?? de(k), o = (e) => {
401
+ let a = () => t ?? fe(k), o = (e) => {
401
402
  switch (e.type) {
402
403
  case "ready":
403
404
  x(!0), C(e.unreadCount ?? 0);
@@ -435,33 +436,33 @@ var f = 3e4, p = 1e3, m = 1e4, h = (e) => Array.isArray(e) ? e.map(h) : typeof e
435
436
  s,
436
437
  c
437
438
  ]);
438
- let M = i((e) => {
439
+ let ee = i((e) => {
439
440
  A.current?.joinThread(e);
440
- }, []), N = i((e) => {
441
+ }, []), M = i((e) => {
441
442
  A.current?.leaveThread(e);
442
- }, []), P = i((e, t) => {
443
+ }, []), N = i((e, t) => {
443
444
  A.current?.sendMessage(e, t);
444
- }, []), F = i((e) => {
445
+ }, []), P = i((e) => {
445
446
  A.current?.markRead(e);
446
- }, []), I = i((e, t) => {
447
+ }, []), F = i((e, t) => {
447
448
  A.current?.listThreads(e, t);
448
- }, []), L = i((e = 1) => {
449
+ }, []), I = i((e = 1) => {
449
450
  C((t) => t + e);
450
- }, []), R = {
451
+ }, []), L = {
451
452
  decrementUnreadCount: i((e = 1) => {
452
453
  C((t) => Math.max(0, t - e));
453
454
  }, []),
454
455
  disconnect: i(() => {
455
456
  A.current?.disconnect(), A.current = null;
456
457
  }, []),
457
- incrementUnreadCount: L,
458
+ incrementUnreadCount: I,
458
459
  isConnected: g,
459
460
  isReady: b,
460
- joinThread: M,
461
- leaveThread: N,
462
- listThreads: I,
463
- markRead: F,
464
- sendMessage: P,
461
+ joinThread: ee,
462
+ leaveThread: M,
463
+ listThreads: F,
464
+ markRead: P,
465
+ sendMessage: N,
465
466
  setEnabled: i((e) => {
466
467
  T(e);
467
468
  }, []),
@@ -470,27 +471,27 @@ var f = 3e4, p = 1e3, m = 1e4, h = (e) => Array.isArray(e) ? e.map(h) : typeof e
470
471
  }), []),
471
472
  unreadCount: S
472
473
  };
473
- return /* @__PURE__ */ d(q.Provider, {
474
- value: R,
474
+ return /* @__PURE__ */ d(J.Provider, {
475
+ value: L,
475
476
  children: e
476
477
  });
477
- }, pe = 3, me = new Set([
478
+ }, me = 3, he = new Set([
478
479
  400,
479
480
  401,
480
481
  403,
481
482
  404
482
- ]), he = (e) => e?.response?.status, J = (e, t) => {
483
- let n = he(t);
484
- return e < pe && !(n !== void 0 && me.has(n));
485
- }, ge = (e, t, n) => (Array.isArray(e) ? e.length : 0) + (typeof n == "number" ? n : 0), _e = ({ children: e, defaultQueriesOptions: t, defaultMutationsOptions: n, ...r }) => {
483
+ ]), ge = (e) => e?.response?.status, Y = (e, t) => {
484
+ let n = ge(t);
485
+ return e < me && !(n !== void 0 && he.has(n));
486
+ }, _e = (e, t, n) => (Array.isArray(e) ? e.length : 0) + (typeof n == "number" ? n : 0), ve = ({ children: e, defaultQueriesOptions: t, defaultMutationsOptions: n, ...r }) => {
486
487
  let { libraries: i } = a(y), o = r.QueryClient || i?.reactQuery?.QueryClient, s = r.QueryClientProvider || i?.reactQuery?.QueryClientProvider;
487
488
  if (!o) throw Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
488
489
  if (!s) throw Error("QueryClientProvider is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
489
490
  let [c] = u(() => new o({ defaultOptions: {
490
491
  mutations: n,
491
492
  queries: {
492
- getNextPageParam: ge,
493
- retry: J,
493
+ getNextPageParam: _e,
494
+ retry: Y,
494
495
  ...t
495
496
  }
496
497
  } }));
@@ -498,17 +499,17 @@ var f = 3e4, p = 1e3, m = 1e4, h = (e) => Array.isArray(e) ? e.map(h) : typeof e
498
499
  client: c,
499
500
  children: e
500
501
  });
501
- }, Y = ({ library: e, date: t, format: n = "ll" }) => e(t).format(n), X = (e, t) => {
502
+ }, X = ({ library: e, date: t, format: n = "ll" }) => e(t).format(n), ye = (e, t) => {
502
503
  let { fractionDigits: n = 0, metric: r = "km", spacingBetween: i = !0 } = t || {}, a = Number(e), o = i ? " " : "";
503
504
  return Number.isNaN(a) ? `0${o}${r}` : `${a.toFixed(n)}${o}${r}`;
504
- }, ve = (e) => !e || typeof e != "string" ? "" : e.replace(/_/g, " ").toLowerCase().split(" ").map((e) => e.length > 0 ? e.charAt(0).toUpperCase() + e.slice(1) : e).join(" "), ye = (e) => e?.startsWith("/") ? e?.startsWith("/files") ? e : `/files${e}` : e?.startsWith("files") ? `/${e}` : `/files/${e}`, be = ({ path: e, size: t, apiURL: n }) => {
505
+ }, be = (e) => !e || typeof e != "string" ? "" : e.replace(/_/g, " ").toLowerCase().split(" ").map((e) => e.length > 0 ? e.charAt(0).toUpperCase() + e.slice(1) : e).join(" "), xe = (e) => e?.startsWith("/") ? e?.startsWith("/files") ? e : `/files${e}` : e?.startsWith("files") ? `/${e}` : `/files/${e}`, Se = ({ path: e, size: t, apiURL: n }) => {
505
506
  if (!e) return "";
506
- let r = `${n}${ye(e)}`, i = r.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/) !== null;
507
+ let r = `${n}${xe(e)}`, i = r.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/) !== null;
507
508
  return typeof t == "number" && i ? `${r.replace("/files", `/thumbs/${t}`)}` : r;
508
- }, xe = (e) => {
509
+ }, Ce = (e) => {
509
510
  let { apiURL: t, libraries: n } = a(y), r = e?.dayjs || n?.dayjs, o = i((e, n) => {
510
511
  if (!t) throw Error("API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter.");
511
- return typeof e == "string" && /^https?:\/\//.test(e) ? e : be({
512
+ return typeof e == "string" && /^https?:\/\//.test(e) ? e : Se({
512
513
  apiURL: t,
513
514
  path: e,
514
515
  size: n
@@ -517,17 +518,17 @@ var f = 3e4, p = 1e3, m = 1e4, h = (e) => Array.isArray(e) ? e.map(h) : typeof e
517
518
  return {
518
519
  dateAdapter: i((e, t) => {
519
520
  if (!r) throw Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
520
- return Y({
521
+ return X({
521
522
  date: e,
522
523
  format: t,
523
524
  library: r
524
525
  });
525
526
  }, [r]),
526
- distanceAdapter: X,
527
+ distanceAdapter: ye,
527
528
  filePathAdapter: o,
528
- worksiteNameAdapter: ve
529
+ worksiteNameAdapter: be
529
530
  };
530
- }, Se = () => {
531
+ }, we = () => {
531
532
  let { libraries: e } = a(y), t = e?.amplitude?.analytics, n = i((e, n) => {
532
533
  if (!t || (t.setUserId(e), !n)) return;
533
534
  let r = new t.Identify();
@@ -551,7 +552,7 @@ var f = 3e4, p = 1e3, m = 1e4, h = (e) => Array.isArray(e) ? e.map(h) : typeof e
551
552
  setGroup: r,
552
553
  track: o
553
554
  };
554
- }, Ce = (e) => {
555
+ }, Te = (e) => {
555
556
  let { libraries: t, localStorageKeys: n } = a(y), r = e?.axios || t?.axios, s = e?.localStorageKey || n?.user || "user";
556
557
  if (!r) throw Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");
557
558
  let c = i(({ tokenType: e, accessToken: t }) => {
@@ -560,10 +561,14 @@ var f = 3e4, p = 1e3, m = 1e4, h = (e) => Array.isArray(e) ? e.map(h) : typeof e
560
561
  r.defaults.headers.common.Authorization = null;
561
562
  }, [r.defaults.headers.common]);
562
563
  return o(() => {
563
- if (I) return;
564
+ if (F) return;
564
565
  let e = ({ newValue: e, key: t }) => {
565
- if (t === s && e) try {
566
- let { accessToken: t, tokenType: n } = JSON.parse(e);
566
+ if (t === s) try {
567
+ let { accessToken: t, tokenType: n } = JSON.parse(e ?? "null") ?? {};
568
+ if (!t) {
569
+ l();
570
+ return;
571
+ }
567
572
  c({
568
573
  accessToken: t,
569
574
  tokenType: n
@@ -575,13 +580,17 @@ var f = 3e4, p = 1e3, m = 1e4, h = (e) => Array.isArray(e) ? e.map(h) : typeof e
575
580
  return window.addEventListener("storage", e), () => {
576
581
  window.removeEventListener("storage", e);
577
582
  };
578
- }, [s, c]), {
583
+ }, [
584
+ l,
585
+ s,
586
+ c
587
+ ]), {
579
588
  clearAuthenticationToken: l,
580
589
  setAuthenticationToken: c
581
590
  };
582
- }, we = "New message", Te = (e, t) => {
591
+ }, Ee = "New message", De = (e, t) => {
583
592
  if (!("Notification" in window) || typeof Notification != "function" || Notification.permission !== "granted" || !document.hidden) return;
584
- let n = new Notification(t.title ?? we, {
593
+ let n = new Notification(t.title ?? Ee, {
585
594
  badge: t?.badge,
586
595
  body: t?.body || e.bodyPreview,
587
596
  data: t?.data,
@@ -596,8 +605,8 @@ var f = 3e4, p = 1e3, m = 1e4, h = (e) => Array.isArray(e) ? e.map(h) : typeof e
596
605
  let { onClick: r } = t;
597
606
  n.onclick = () => r(e);
598
607
  }
599
- }, Ee = (e) => {
600
- let t = a(q);
608
+ }, Oe = (e) => {
609
+ let t = a(J);
601
610
  if (!t) throw Error("useChat must be used within ChatProvider");
602
611
  let { subscribe: n, setEnabled: r, ...i } = t, s = l(e);
603
612
  return s.current = e, o(() => {
@@ -614,7 +623,7 @@ var f = 3e4, p = 1e3, m = 1e4, h = (e) => Array.isArray(e) ? e.map(h) : typeof e
614
623
  r?.(e);
615
624
  break;
616
625
  case "new_message_notification":
617
- i?.(e), t && t.enabled !== !1 && Te(e, t);
626
+ i?.(e), t && t.enabled !== !1 && De(e, t);
618
627
  break;
619
628
  case "presence":
620
629
  a?.(e);
@@ -639,7 +648,7 @@ var f = 3e4, p = 1e3, m = 1e4, h = (e) => Array.isArray(e) ? e.map(h) : typeof e
639
648
  break;
640
649
  }
641
650
  }), [n]), i;
642
- }, Z = (e, t) => t === "short" ? e.split("-")[0] : e, De = (e, t = "full") => {
651
+ }, Z = (e, t) => t === "short" ? e.split("-")[0] : e, ke = (e, t = "full") => {
643
652
  let [n, r] = u(() => {
644
653
  let n = e?.language || navigator.language;
645
654
  return e && "isInitialized" in e && e.isInitialized, Z(n, t);
@@ -653,30 +662,30 @@ var f = 3e4, p = 1e3, m = 1e4, h = (e) => Array.isArray(e) ? e.map(h) : typeof e
653
662
  e?.off?.("languageChanged", n);
654
663
  };
655
664
  }, [e, t]), n;
656
- }, Oe = "tracktor.filter", ke = {
665
+ }, Ae = "tracktor.filter", je = {
657
666
  getFilter: () => void 0,
658
667
  getFilters: () => ({}),
659
668
  handleFilter: () => () => {},
660
669
  setFilter: () => {}
661
- }, Ae = (e) => {
670
+ }, Me = (e) => {
662
671
  try {
663
672
  return JSON.parse(e);
664
673
  } catch {
665
674
  return e;
666
675
  }
667
- }, je = (e, t, n) => `${n}_${e}=>${t}`, Me = (e) => e.reduce((e, t) => {
676
+ }, Ne = (e, t, n) => `${n}_${e}=>${t}`, Pe = (e) => e.reduce((e, t) => {
668
677
  let n = localStorage.getItem(t);
669
678
  if (n) try {
670
679
  let t = JSON.parse(n), r = Object.keys(t)?.[0];
671
680
  r && (e[r] = Object.values(t)?.[0]);
672
681
  } catch {}
673
682
  return e;
674
- }, {}), Ne = (e) => {
675
- let { libraries: t, localStorageKeys: n } = a(y), r = e?.reactRouter || t?.reactRouter, { pathname: i } = r?.useLocation?.() ?? { pathname: "/" }, [o, s] = r?.useSearchParams?.() ?? [new URLSearchParams(), () => {}], [c, l] = u({}), d = n?.filter || Oe, f = e?.syncWithUrl === void 0 ? !0 : e?.syncWithUrl, p = e?.persistToLocalStorage === void 0 ? !0 : e?.persistToLocalStorage;
676
- if (I) return ke;
683
+ }, {}), Fe = (e) => {
684
+ let { libraries: t, localStorageKeys: n } = a(y), r = e?.reactRouter || t?.reactRouter, { pathname: i } = r?.useLocation?.() ?? { pathname: "/" }, [o, s] = r?.useSearchParams?.() ?? [new URLSearchParams(), () => {}], [c, l] = u({}), d = n?.filter || Ae, f = e?.syncWithUrl === void 0 ? !0 : e?.syncWithUrl, p = e?.persistToLocalStorage === void 0 ? !0 : e?.persistToLocalStorage;
685
+ if (F) return je;
677
686
  if (!r) throw Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter.");
678
687
  let m = () => Object.keys(localStorage).filter((t) => t.startsWith(d) && t.endsWith(e?.pathname || i)), h = (t, n, r = !0) => {
679
- let a = je(t, e?.pathname || i, d);
688
+ let a = Ne(t, e?.pathname || i, d);
680
689
  if (!n || Array.isArray(n) && !n.length) {
681
690
  f ? (o.delete(t), s(o)) : l((e) => {
682
691
  let n = { ...e };
@@ -696,13 +705,13 @@ var f = 3e4, p = 1e3, m = 1e4, h = (e) => Array.isArray(e) ? e.map(h) : typeof e
696
705
  getFilter: (t, n) => {
697
706
  if (f) {
698
707
  let e = o.get(t);
699
- if (e) return Ae(e);
708
+ if (e) return Me(e);
700
709
  } else {
701
710
  let e = c[t];
702
711
  if (e !== void 0) return e;
703
712
  }
704
713
  if (p) {
705
- let n = je(t, e?.pathname || i, d), r = localStorage.getItem(n);
714
+ let n = Ne(t, e?.pathname || i, d), r = localStorage.getItem(n);
706
715
  if (r) try {
707
716
  let e = JSON.parse(r)[t];
708
717
  return !f && e !== void 0 && l((n) => ({
@@ -714,9 +723,9 @@ var f = 3e4, p = 1e3, m = 1e4, h = (e) => Array.isArray(e) ? e.map(h) : typeof e
714
723
  return n;
715
724
  },
716
725
  getFilters: () => {
717
- let e = p ? Me(m()) : {};
726
+ let e = p ? Pe(m()) : {};
718
727
  if (f) {
719
- let t = Array.from(o.entries()).reduce((e, [t, n]) => (e[t] = Ae(n), e), {});
728
+ let t = Array.from(o.entries()).reduce((e, [t, n]) => (e[t] = Me(n), e), {});
720
729
  return {
721
730
  ...e,
722
731
  ...t
@@ -737,7 +746,7 @@ var f = 3e4, p = 1e3, m = 1e4, h = (e) => Array.isArray(e) ? e.map(h) : typeof e
737
746
  },
738
747
  setFilter: h
739
748
  };
740
- }, Pe = () => document.getElementById(B), Fe = () => {
749
+ }, Ie = () => document.getElementById(z), Le = () => {
741
750
  let [e, t] = u(() => !!window.HubSpotConversations);
742
751
  return o(() => {
743
752
  if (window.HubSpotConversations) {
@@ -747,16 +756,16 @@ var f = 3e4, p = 1e3, m = 1e4, h = (e) => Array.isArray(e) ? e.map(h) : typeof e
747
756
  window.hsConversationsOnReady = [() => t(!0)];
748
757
  }, []), o(() => {
749
758
  e && window.HubSpotConversations?.on("widgetClosed", () => {
750
- Pe()?.classList.remove(V);
759
+ Ie()?.classList.remove(B);
751
760
  });
752
761
  }, [e]), {
753
762
  isAvailable: e,
754
763
  toggle: i(() => {
755
- let e = window.HubSpotConversations, t = Pe();
756
- e && t && (t.classList.contains("hs-show") ? (e.widget.close(), t.classList.remove(V)) : (t.classList.add(V), e.widget.open()));
764
+ let e = window.HubSpotConversations, t = Ie();
765
+ e && t && (t.classList.contains("hs-show") ? (e.widget.close(), t.classList.remove(B)) : (t.classList.add(B), e.widget.open()));
757
766
  }, [])
758
767
  };
759
- }, Ie = ({ data: e, fetchNextPage: t, isFetchingNextPage: n, isInitialLoading: r, isLoading: a, enabled: o = !0 }) => {
768
+ }, Re = ({ data: e, fetchNextPage: t, isFetchingNextPage: n, isInitialLoading: r, isLoading: a, enabled: o = !0 }) => {
760
769
  let s = i(async (e) => {
761
770
  n || !o || await t({ pageParam: e?.pageParam || e.visibleRowsCount });
762
771
  }, [
@@ -772,7 +781,7 @@ var f = 3e4, p = 1e3, m = 1e4, h = (e) => Array.isArray(e) ? e.map(h) : typeof e
772
781
  loadingVariant: r ? "skeleton" : "linear-progress",
773
782
  rows: l
774
783
  };
775
- }, Le = (e) => {
784
+ }, ze = (e) => {
776
785
  let { libraries: t } = a(y), n = e?.i18 || t?.i18, r = e?.i18?.translateFunction || t?.i18?.translateFunction, o = n?.i18next?.t || r || ((e) => e), { unknownErrorTranslationKey: s = "error.unknownError" } = e || {}, c = o(s), l = i((e) => {
777
786
  if (e && typeof e == "object" && "response" in e) {
778
787
  let { response: t } = e || {};
@@ -796,38 +805,38 @@ var f = 3e4, p = 1e3, m = 1e4, h = (e) => Array.isArray(e) ? e.map(h) : typeof e
796
805
  }, []),
797
806
  printError: l
798
807
  };
799
- }, Re = "chunk-reload-timestamp", Q = "chunk-reload", ze = 1e4, $ = 2, Be = !1;
800
- if (!I && typeof window < "u") {
808
+ }, Be = "chunk-reload-timestamp", Q = "chunk-reload", Ve = 1e4, $ = 2, He = !1;
809
+ if (!F && typeof window < "u") {
801
810
  try {
802
811
  let e = new URL(window.location.href);
803
- e.searchParams.has(Q) && (Be = !0, e.searchParams.delete(Q), window.history.replaceState(null, "", e.toString()));
812
+ e.searchParams.has(Q) && (He = !0, e.searchParams.delete(Q), window.history.replaceState(null, "", e.toString()));
804
813
  } catch {}
805
814
  window.addEventListener("vite:preloadError", (e) => {
806
815
  e.preventDefault();
807
816
  });
808
817
  }
809
- var Ve = (e) => {
818
+ var Ue = (e) => {
810
819
  if (!(e instanceof Error)) return !1;
811
820
  let t = e.message.toLowerCase();
812
821
  return t.includes("dynamically imported module") || t.includes("importing a module script failed") || t.includes("loading chunk") || t.includes("loading css chunk") || t.includes("unable to preload css") || t.includes("failed to fetch") || t.includes("error loading dynamically imported module") || t.includes("load failed") || t.includes("without a valid default export") || e.name === "ChunkLoadError";
813
- }, He = /import\s*\(\s*(['"])((\w+:(\/?\/?))?[^\s,]+)\1/, Ue = (e) => e.toString().match(He)?.[2] ?? null, We = (e) => {
822
+ }, We = /import\s*\(\s*(['"])((\w+:(\/?\/?))?[^\s,]+)\1/, Ge = (e) => e.toString().match(We)?.[2] ?? null, Ke = (e) => {
814
823
  try {
815
824
  return sessionStorage.getItem(e);
816
825
  } catch {
817
826
  return null;
818
827
  }
819
- }, Ge = (e, t) => {
828
+ }, qe = (e, t) => {
820
829
  try {
821
830
  sessionStorage.setItem(e, t);
822
831
  } catch {}
823
- }, Ke = (e) => Function("url", "return import(url)")(e), qe = async (e) => {
832
+ }, Je = (e) => Function("url", "return import(url)")(e), Ye = async (e) => {
824
833
  for (let t = 0; t < $; t++) try {
825
- return await Ke(`${e}?t=${Date.now()}`);
834
+ return await Je(`${e}?t=${Date.now()}`);
826
835
  } catch {
827
836
  t < $ - 1 && await new Promise((e) => setTimeout(e, 500 * 2 ** t));
828
837
  }
829
838
  throw Error(`Failed to import ${e} after ${$} retries`);
830
- }, Je = async () => {
839
+ }, Xe = async () => {
831
840
  try {
832
841
  if (typeof navigator < "u" && "serviceWorker" in navigator) {
833
842
  let e = await navigator.serviceWorker.getRegistrations();
@@ -838,27 +847,27 @@ var Ve = (e) => {
838
847
  await Promise.all(e.map((e) => caches.delete(e)));
839
848
  }
840
849
  } catch {}
841
- }, Ye = async () => {
842
- await Je();
850
+ }, Ze = async () => {
851
+ await Xe();
843
852
  let e = new URL(window.location.href);
844
853
  e.searchParams.set(Q, String(Date.now())), window.location.replace(e.toString());
845
- }, Xe = (e) => e != null && e.default !== void 0, Ze = (e) => r(async () => {
854
+ }, Qe = (e) => e != null && e.default !== void 0, $e = (e) => r(async () => {
846
855
  let t;
847
856
  try {
848
857
  let n = await e();
849
- if (Xe(n)) return n;
858
+ if (Qe(n)) return n;
850
859
  t = /* @__PURE__ */ Error("Module resolved without a valid default export");
851
860
  } catch (e) {
852
861
  t = e;
853
862
  }
854
- if (I || !Ve(t)) throw t;
855
- let n = Ue(e);
863
+ if (F || !Ue(t)) throw t;
864
+ let n = Ge(e);
856
865
  if (n) try {
857
- let e = await qe(n);
858
- if (Xe(e)) return e;
866
+ let e = await Ye(n);
867
+ if (Qe(e)) return e;
859
868
  } catch {}
860
- let r = Number(We(Re) || "0");
861
- return Date.now() - r < ze || Be || (Ge(Re, String(Date.now())), await Ye()), { default: () => null };
869
+ let r = Number(Ke(Be) || "0");
870
+ return Date.now() - r < Ve || He || (qe(Be, String(Date.now())), await Ze()), { default: () => null };
862
871
  });
863
872
  //#endregion
864
- export { A as AMPLITUDE_FEATURE_SELECTOR, O as AutoReloadOnNewVersion, _ as ChatClient, q as ChatContext, fe as ChatProvider, k as GTMSendPageView, F as InitializeAmplitude, R as InitializeAxiosConfig, te as InitializeDaysJSConfig, ne as InitializeHubSpot, re as InitializeI18nConfig, ie as InitializeSentryConfig, y as InjectDependenciesContext, b as InjectDependenciesProvider, v as MaskTextField, _e as QueryProvider, oe as RequireAuth, U as SENTRY_KEEP_REPLAY, z as SUPPORTED_LANGUAGE, se as ShowHubSpotBubble, Y as dateAdapter, X as distanceAdapter, e as getOrvalConfig, W as isReplayKeptForError, Ze as lazyWithRetry, J as shouldRetryQuery, xe as useAdapter, Se as useAmplitude, Ce as useAuth, Ee as useChat, De as useCurrentLanguage, Ne as useFilters, Fe as useHubSpot, Ie as useInfiniteDataGrid, Le as useResponseError, ve as worksiteNameAdapter };
873
+ export { A as AMPLITUDE_FEATURE_SELECTOR, O as AutoReloadOnNewVersion, _ as ChatClient, J as ChatContext, pe as ChatProvider, k as GTMSendPageView, P as InitializeAmplitude, L as InitializeAxiosConfig, ne as InitializeDaysJSConfig, re as InitializeHubSpot, ie as InitializeI18nConfig, ae as InitializeSentryConfig, y as InjectDependenciesContext, b as InjectDependenciesProvider, v as MaskTextField, ve as QueryProvider, se as RequireAuth, W as SENTRY_IGNORED_REQUEST_URLS, H as SENTRY_KEEP_REPLAY, R as SUPPORTED_LANGUAGE, ce as ShowHubSpotBubble, X as dateAdapter, ye as distanceAdapter, e as getOrvalConfig, U as isReplayKeptForError, $e as lazyWithRetry, G as matchesRequestUrl, Y as shouldRetryQuery, Ce as useAdapter, we as useAmplitude, Te as useAuth, Oe as useChat, ke as useCurrentLanguage, Fe as useFilters, Le as useHubSpot, Re as useInfiniteDataGrid, ze as useResponseError, be as worksiteNameAdapter };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getsoren/shared-module",
3
- "version": "2.51.1",
3
+ "version": "2.53.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "types": "./dist/main.d.ts",