@getsoren/shared-module 2.43.4
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/LICENSE +21 -0
- package/README.md +154 -0
- package/dist/axios/axiosCustomInstance.d.ts +5 -0
- package/dist/axiosCustomInstance.ts +23 -0
- package/dist/chat/ChatClient.d.ts +35 -0
- package/dist/chat/tests/ChatClient.test.d.ts +1 -0
- package/dist/chat/types.d.ts +116 -0
- package/dist/components/Inputs/MaskTextField.d.ts +32 -0
- package/dist/components/Utils/GTMSendPageView.d.ts +23 -0
- package/dist/components/Utils/InitializeAmplitude.d.ts +27 -0
- package/dist/components/Utils/InitializeAxiosConfig.d.ts +41 -0
- package/dist/components/Utils/InitializeDaysJSConfig.d.ts +27 -0
- package/dist/components/Utils/InitializeHubSpot.d.ts +27 -0
- package/dist/components/Utils/InitializeI18nConfig.d.ts +26 -0
- package/dist/components/Utils/InitializeSentryConfig.d.ts +81 -0
- package/dist/components/Utils/RequireAuth.d.ts +48 -0
- package/dist/components/Utils/ShowHubSpotBubble.d.ts +10 -0
- package/dist/config/orval/index.d.ts +2 -0
- package/dist/config/orval/orval.d.ts +81 -0
- package/dist/config/orval/orval.test.d.ts +1 -0
- package/dist/constants/hubspot.d.ts +12 -0
- package/dist/context/ChatProvider.d.ts +33 -0
- package/dist/context/InjectDependenciesProvider.d.ts +72 -0
- package/dist/context/QueryClientProviderWithConfig.d.ts +26 -0
- package/dist/hooks/tests/useFilters.test.d.ts +1 -0
- package/dist/hooks/useAdapter.d.ts +22 -0
- package/dist/hooks/useAmplitude.d.ts +16 -0
- package/dist/hooks/useAuth.d.ts +20 -0
- package/dist/hooks/useChat.d.ts +13 -0
- package/dist/hooks/useCurrentLanguage/useCurrentLanguage.d.ts +13 -0
- package/dist/hooks/useCurrentLanguage/useCurrentLanguage.test.d.ts +1 -0
- package/dist/hooks/useFilters.d.ts +44 -0
- package/dist/hooks/useHubSpot.d.ts +9 -0
- package/dist/hooks/useInfiniteDataGrid.d.ts +30 -0
- package/dist/hooks/useResponseError/useResponseError.d.ts +33 -0
- package/dist/hooks/useResponseError/useResponseError.test.d.ts +1 -0
- package/dist/main.d.ts +52 -0
- package/dist/main.js +823 -0
- package/dist/utils/adapter/dateAdapter.d.ts +17 -0
- package/dist/utils/adapter/distanceAdapter.d.ts +12 -0
- package/dist/utils/adapter/worksiteNameAdapter/worksiteNameAdapter.d.ts +9 -0
- package/dist/utils/adapter/worksiteNameAdapter/worksiteNameAdapter.test.d.ts +1 -0
- package/dist/utils/isReactNative.d.ts +5 -0
- package/dist/utils/lazyWithRetry.d.ts +18 -0
- package/package.json +117 -0
package/dist/main.js
ADDED
|
@@ -0,0 +1,823 @@
|
|
|
1
|
+
import e from "axios";
|
|
2
|
+
import { Suspense as t, createContext as n, lazy as r, useCallback as i, useContext as a, useEffect as o, useMemo as s, useRef as c, useState as l } from "react";
|
|
3
|
+
import { jsx as u } from "react/jsx-runtime";
|
|
4
|
+
//#region src/axios/axiosCustomInstance.ts
|
|
5
|
+
var d = (t, n) => {
|
|
6
|
+
let r = e.CancelToken.source(), i = e({
|
|
7
|
+
...t,
|
|
8
|
+
...n,
|
|
9
|
+
cancelToken: r.token
|
|
10
|
+
}).then(({ data: e }) => e);
|
|
11
|
+
return i.cancel = () => {
|
|
12
|
+
r.cancel("Query was cancelled");
|
|
13
|
+
}, i;
|
|
14
|
+
}, f = 3e4, p = 1e3, m = 1e4, h = (e) => Array.isArray(e) ? e.map(h) : typeof e == "object" && e ? Object.fromEntries(Object.entries(e).map(([e, t]) => [e.replace(/_([a-z])/g, (e, t) => t.toUpperCase()), h(t)])) : e, g = (e) => Array.isArray(e) ? e.map(g) : typeof e == "object" && e ? Object.fromEntries(Object.entries(e).map(([e, t]) => [e.replace(/[A-Z]/g, (e) => `_${e.toLowerCase()}`), g(t)])) : e, _ = class {
|
|
15
|
+
url;
|
|
16
|
+
getToken;
|
|
17
|
+
onEvent;
|
|
18
|
+
onConnectionChange;
|
|
19
|
+
shouldReconnect;
|
|
20
|
+
maxReconnectAttempts;
|
|
21
|
+
reconnectBaseDelay;
|
|
22
|
+
maxMessageBodyLength;
|
|
23
|
+
ws = null;
|
|
24
|
+
reconnectAttempt = 0;
|
|
25
|
+
reconnectTimer = null;
|
|
26
|
+
intentionalClose = !1;
|
|
27
|
+
joinedThreads = /* @__PURE__ */ new Set();
|
|
28
|
+
pendingMessages = [];
|
|
29
|
+
_connected = !1;
|
|
30
|
+
_ready = !1;
|
|
31
|
+
constructor(e) {
|
|
32
|
+
this.url = e.url, this.getToken = e.getToken, this.onEvent = e.onEvent, this.onConnectionChange = e.onConnectionChange, this.shouldReconnect = e.reconnect ?? !0, this.maxReconnectAttempts = e.maxReconnectAttempts ?? Infinity, this.reconnectBaseDelay = e.reconnectBaseDelay ?? p, this.maxMessageBodyLength = e.maxMessageBodyLength ?? m;
|
|
33
|
+
}
|
|
34
|
+
get connected() {
|
|
35
|
+
return this._connected;
|
|
36
|
+
}
|
|
37
|
+
get ready() {
|
|
38
|
+
return this._ready;
|
|
39
|
+
}
|
|
40
|
+
connect() {
|
|
41
|
+
let e = this.getToken();
|
|
42
|
+
if (!e) return;
|
|
43
|
+
this.intentionalClose = !1;
|
|
44
|
+
let t = this.url.includes("?") ? "&" : "?", n = `${this.url}${t}token=${e}`;
|
|
45
|
+
this.ws = new WebSocket(n), this.ws.onopen = () => {
|
|
46
|
+
this._connected = !0, this.reconnectAttempt = 0, this.onConnectionChange?.(!0), this.rejoinThreads(), this.flushPendingMessages();
|
|
47
|
+
}, this.ws.onmessage = (e) => {
|
|
48
|
+
try {
|
|
49
|
+
let t = h(JSON.parse(e.data));
|
|
50
|
+
t.type === "ready" && (this._ready = !0), this.onEvent?.(t);
|
|
51
|
+
} catch {}
|
|
52
|
+
}, this.ws.onclose = () => {
|
|
53
|
+
this._connected = !1, this._ready = !1, this.onConnectionChange?.(!1), !this.intentionalClose && this.shouldReconnect && this.reconnectAttempt < this.maxReconnectAttempts && this.scheduleReconnect();
|
|
54
|
+
}, this.ws.onerror = () => {};
|
|
55
|
+
}
|
|
56
|
+
disconnect() {
|
|
57
|
+
this.intentionalClose = !0, this.pendingMessages = [], this.clearReconnectTimer(), this.ws &&= (this.ws.close(), null);
|
|
58
|
+
}
|
|
59
|
+
joinThread(e) {
|
|
60
|
+
this.joinedThreads.add(e), this.send({
|
|
61
|
+
threadId: e,
|
|
62
|
+
type: "join_thread"
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
leaveThread(e) {
|
|
66
|
+
this.joinedThreads.delete(e), this.send({
|
|
67
|
+
threadId: e,
|
|
68
|
+
type: "leave_thread"
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
sendMessage(e, t) {
|
|
72
|
+
if (t.length > this.maxMessageBodyLength) throw Error(`Message body exceeds maximum length of ${this.maxMessageBodyLength} characters`);
|
|
73
|
+
this.send({
|
|
74
|
+
body: t,
|
|
75
|
+
threadId: e,
|
|
76
|
+
type: "send_message"
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
markRead(e) {
|
|
80
|
+
this.send({
|
|
81
|
+
threadId: e,
|
|
82
|
+
type: "mark_read"
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
listThreads(e, t) {
|
|
86
|
+
this.send({
|
|
87
|
+
limit: e,
|
|
88
|
+
offset: t,
|
|
89
|
+
type: "list_threads"
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
send(e) {
|
|
93
|
+
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
|
|
94
|
+
this.pendingMessages.push(e);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
this.ws.send(JSON.stringify(g(e)));
|
|
98
|
+
}
|
|
99
|
+
flushPendingMessages() {
|
|
100
|
+
let e = [...this.pendingMessages];
|
|
101
|
+
this.pendingMessages = [];
|
|
102
|
+
for (let t of e) this.send(t);
|
|
103
|
+
}
|
|
104
|
+
rejoinThreads() {
|
|
105
|
+
for (let e of this.joinedThreads) this.send({
|
|
106
|
+
threadId: e,
|
|
107
|
+
type: "join_thread"
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
scheduleReconnect() {
|
|
111
|
+
this.clearReconnectTimer();
|
|
112
|
+
let e = Math.min(this.reconnectBaseDelay * 2 ** this.reconnectAttempt, f);
|
|
113
|
+
this.reconnectAttempt++, this.reconnectTimer = setTimeout(() => {
|
|
114
|
+
this.connect();
|
|
115
|
+
}, e);
|
|
116
|
+
}
|
|
117
|
+
clearReconnectTimer() {
|
|
118
|
+
this.reconnectTimer !== null && (clearTimeout(this.reconnectTimer), this.reconnectTimer = null);
|
|
119
|
+
}
|
|
120
|
+
}, v = ({ IMaskMixin: e, ...t }) => /* @__PURE__ */ u(s(() => e(({ TextField: e, ...t }) => /* @__PURE__ */ u(e, { ...t })), [e]), { ...t }), y = n({}), b = ({ children: e, apiURL: t, libraries: n, localStorageKeys: r }) => {
|
|
121
|
+
let i = s(() => ({
|
|
122
|
+
apiURL: t,
|
|
123
|
+
libraries: n,
|
|
124
|
+
localStorageKeys: r
|
|
125
|
+
}), [
|
|
126
|
+
t,
|
|
127
|
+
n,
|
|
128
|
+
r
|
|
129
|
+
]);
|
|
130
|
+
return /* @__PURE__ */ u(y.Provider, {
|
|
131
|
+
value: i,
|
|
132
|
+
children: e
|
|
133
|
+
});
|
|
134
|
+
}, x = ({ data: e, ...t }) => {
|
|
135
|
+
let { libraries: n } = a(y), r = t?.reactRouter || n?.reactRouter, i = t?.gtm || n?.gtm;
|
|
136
|
+
if (!r) throw Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");
|
|
137
|
+
if (!i) throw Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");
|
|
138
|
+
let { useGoogleTagManager: s } = i, { useLocation: c, Outlet: l } = r, { pathname: d } = c(), { sendEvent: f } = s();
|
|
139
|
+
return o(() => {
|
|
140
|
+
f({
|
|
141
|
+
event: "pageView",
|
|
142
|
+
pathname: d,
|
|
143
|
+
...e
|
|
144
|
+
});
|
|
145
|
+
}, [
|
|
146
|
+
e,
|
|
147
|
+
d,
|
|
148
|
+
f
|
|
149
|
+
]), /* @__PURE__ */ u(l, {});
|
|
150
|
+
}, S = ({ apiKey: e, platform: t = "desktop", sessionReplaySampleRate: n = .25, ...r }) => {
|
|
151
|
+
let { libraries: i } = a(y), s = r.amplitude || i?.amplitude;
|
|
152
|
+
return o(() => {
|
|
153
|
+
let r = s?.analytics, i = s?.sessionReplayPlugin;
|
|
154
|
+
if (!(e && r)) return;
|
|
155
|
+
let a = "platform-enrichment";
|
|
156
|
+
return r.init(e, { autocapture: { elementInteractions: !1 } }), i && r.add(i({ sampleRate: n })), r.add({
|
|
157
|
+
execute: async (e) => ({
|
|
158
|
+
...e,
|
|
159
|
+
event_properties: {
|
|
160
|
+
...e.event_properties,
|
|
161
|
+
platform: t
|
|
162
|
+
}
|
|
163
|
+
}),
|
|
164
|
+
name: a,
|
|
165
|
+
type: "enrichment"
|
|
166
|
+
}), () => {
|
|
167
|
+
i && r.remove("@amplitude/plugin-session-replay-browser"), r.remove(a);
|
|
168
|
+
};
|
|
169
|
+
}, [
|
|
170
|
+
e,
|
|
171
|
+
s,
|
|
172
|
+
t,
|
|
173
|
+
n
|
|
174
|
+
]), null;
|
|
175
|
+
}, C = (() => {
|
|
176
|
+
try {
|
|
177
|
+
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;
|
|
178
|
+
} catch {
|
|
179
|
+
return !1;
|
|
180
|
+
}
|
|
181
|
+
})(), w = "user", T = ({ tokenTypeKey: e = "tokenType", tokenKey: t = "accessToken", postContentType: n = "application/json", ...r }) => {
|
|
182
|
+
let { apiURL: i = r.apiURL, libraries: o, localStorageKeys: s } = a(y), c = r?.userLocalStorageKey || s?.user || w, l = r?.axios || o?.axios;
|
|
183
|
+
if (!l) throw Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
184
|
+
if (!l?.defaults || C) return null;
|
|
185
|
+
if (typeof window < "u" && window.localStorage) {
|
|
186
|
+
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;
|
|
187
|
+
o && (l.defaults.headers.common.Authorization = o);
|
|
188
|
+
}
|
|
189
|
+
return l.defaults.baseURL = i, l.defaults.headers.post["Content-Type"] = n, null;
|
|
190
|
+
}, E = ({ language: e, ...t }) => {
|
|
191
|
+
let { libraries: n } = a(y), r = t?.dayjs || n?.dayjs, i = t?.plugin || n?.dayjsPlugin;
|
|
192
|
+
if (!r) throw Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig.");
|
|
193
|
+
return o(() => {
|
|
194
|
+
(async () => {
|
|
195
|
+
let n = e || navigator.language?.slice(0, 2) || "en";
|
|
196
|
+
r.extend(t.localizedFormat), i && i.forEach((e) => {
|
|
197
|
+
e && r.extend(e);
|
|
198
|
+
}), await import("dayjs/locale/en"), await import("dayjs/locale/fr"), r.locale(n);
|
|
199
|
+
})().then();
|
|
200
|
+
}, [
|
|
201
|
+
r,
|
|
202
|
+
i,
|
|
203
|
+
e,
|
|
204
|
+
t.localizedFormat
|
|
205
|
+
]), null;
|
|
206
|
+
}, D = "hubspot-messages-iframe-container", O = "hs-show", k = "data-hs-hidden", A = ({ hubId: e }) => (o(() => {
|
|
207
|
+
if (!e) return;
|
|
208
|
+
let t = document.createElement("script");
|
|
209
|
+
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), () => {
|
|
210
|
+
t.remove();
|
|
211
|
+
};
|
|
212
|
+
}, [e]), o(() => {
|
|
213
|
+
let e = document.createElement("style");
|
|
214
|
+
return e.textContent = `
|
|
215
|
+
html[${k}] div#${D} { display: none !important; }
|
|
216
|
+
html[${k}] div#${D}.${O} { display: initial !important; }
|
|
217
|
+
`, document.head.appendChild(e), document.documentElement.setAttribute(k, ""), () => {
|
|
218
|
+
e.remove(), document.documentElement.removeAttribute(k);
|
|
219
|
+
};
|
|
220
|
+
}, []), null), j = ({ debug: e, resources: t, ...n }) => {
|
|
221
|
+
let { libraries: r } = a(y), i = n?.i18 || r?.i18, { i18next: o, initReactI18next: s, languageDetector: c } = i || {};
|
|
222
|
+
if (C) return null;
|
|
223
|
+
if (!(i && o && c && s)) throw Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
224
|
+
return o.isInitialized ? null : (o.use(c).use(s).init({
|
|
225
|
+
debug: e,
|
|
226
|
+
fallbackLng: "en",
|
|
227
|
+
interpolation: { escapeValue: !1 },
|
|
228
|
+
load: "languageOnly",
|
|
229
|
+
react: {
|
|
230
|
+
bindI18n: "languageChanged loaded",
|
|
231
|
+
useSuspense: !0
|
|
232
|
+
},
|
|
233
|
+
resources: t,
|
|
234
|
+
returnNull: !1
|
|
235
|
+
}).then(() => {
|
|
236
|
+
document.documentElement.lang !== o.resolvedLanguage && o.resolvedLanguage && document.documentElement.setAttribute("lang", o.resolvedLanguage);
|
|
237
|
+
}), o.on("languageChanged", (e) => {
|
|
238
|
+
document.documentElement.setAttribute("lang", e);
|
|
239
|
+
}), null);
|
|
240
|
+
}, M = ({ dsn: e, integrations: t, tracesSampleRate: n, replaysSessionSampleRate: r, replaysOnErrorSampleRate: i, tracePropagationTargets: s, ignoreErrors: c, debug: l, environment: u, release: d, ...f }) => {
|
|
241
|
+
let { libraries: p } = a(y), m = f?.sentry || p?.sentry, h = f?.reactRouter || p?.reactRouter;
|
|
242
|
+
if (!m) throw Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
243
|
+
if (!h) throw Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
244
|
+
if (m.isInitialized()) return null;
|
|
245
|
+
let { createRoutesFromChildren: g, matchRoutes: _, useLocation: v, useNavigationType: b } = h;
|
|
246
|
+
return (l || process.env.NODE_ENV === "prod" || process.env.NODE_ENV === "production") && m.init({
|
|
247
|
+
debug: l,
|
|
248
|
+
dsn: e,
|
|
249
|
+
environment: u || "production",
|
|
250
|
+
ignoreErrors: [
|
|
251
|
+
...c || [],
|
|
252
|
+
/dynamically imported module/,
|
|
253
|
+
/Cannot read properties of undefined \(reading 'default'\)/,
|
|
254
|
+
/Loading chunk \d+ failed/,
|
|
255
|
+
/ChunkLoadError/,
|
|
256
|
+
/Failed to fetch dynamically imported module/,
|
|
257
|
+
/vite:preloadError/
|
|
258
|
+
],
|
|
259
|
+
integrations: [m.reactRouterV6BrowserTracingIntegration({
|
|
260
|
+
createRoutesFromChildren: g,
|
|
261
|
+
matchRoutes: _,
|
|
262
|
+
useEffect: o,
|
|
263
|
+
useLocation: v,
|
|
264
|
+
useNavigationType: b
|
|
265
|
+
}), ...t || []],
|
|
266
|
+
release: d,
|
|
267
|
+
replaysOnErrorSampleRate: i || 1,
|
|
268
|
+
replaysSessionSampleRate: r || .1,
|
|
269
|
+
tracePropagationTargets: s,
|
|
270
|
+
tracesSampleRate: n || 1
|
|
271
|
+
}), null;
|
|
272
|
+
}, N = /* @__PURE__ */ new WeakMap(), P = "user", F = ({ Fallback: e, isLogged: n, loginPath: r = "/login", redirect401Path: i = "/login", ...s }) => {
|
|
273
|
+
let { libraries: c, localStorageKeys: d } = a(y), f = s?.reactRouter || c?.reactRouter, p = s?.axios || c?.axios, m = s?.localStorageKey || d?.user || P;
|
|
274
|
+
if (!f) throw Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
275
|
+
let [h, g] = l(null), { useLocation: _, Navigate: v, Outlet: b } = f, x = _(), S = typeof n == "function" ? n() : !!n, C = typeof S == "boolean" ? S : S?.isLogged;
|
|
276
|
+
return o(() => {
|
|
277
|
+
p && (N.has(p) || (N.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)))));
|
|
278
|
+
}, [
|
|
279
|
+
p,
|
|
280
|
+
m,
|
|
281
|
+
i
|
|
282
|
+
]), C && !h ? /* @__PURE__ */ u(t, {
|
|
283
|
+
fallback: e,
|
|
284
|
+
children: x.state?.from?.state && x.state?.from?.pathname === r ? /* @__PURE__ */ u(v, {
|
|
285
|
+
to: x.state.from.state.from.pathname + x.state.from.state.from.search,
|
|
286
|
+
replace: !0
|
|
287
|
+
}) : /* @__PURE__ */ u(b, {})
|
|
288
|
+
}) : /* @__PURE__ */ u(v, {
|
|
289
|
+
to: r + x.search,
|
|
290
|
+
state: { from: x },
|
|
291
|
+
replace: !0
|
|
292
|
+
});
|
|
293
|
+
}, I = /* @__PURE__ */ new Set(), L = () => (o(() => {
|
|
294
|
+
let e = Symbol();
|
|
295
|
+
return I.add(e), document.documentElement.removeAttribute(k), () => {
|
|
296
|
+
I.delete(e), I.size === 0 && document.documentElement.setAttribute(k, "");
|
|
297
|
+
};
|
|
298
|
+
}, []), null), R = (e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase(), ee = (e) => {
|
|
299
|
+
let t = e.split(/[/\\]/).pop() || "";
|
|
300
|
+
return t.substring(0, t.lastIndexOf("."));
|
|
301
|
+
}, z = (e) => {
|
|
302
|
+
let t = e.split("/").filter((e) => e.length > 0).map((e) => e.replace(/\${([^}]*)}/g, "$1").split(/[_-]/).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join("")).join("");
|
|
303
|
+
return t.charAt(0).toLowerCase() + t.slice(1);
|
|
304
|
+
}, te = (e) => (e.split("/").pop() || e).replace(/\.json$/, "").replace(/^openapi\./, ""), ne = (e, t, n, r) => {
|
|
305
|
+
let i = `${z(t)}${R(n)}`;
|
|
306
|
+
return e && typeof e == "object" && "operationId" in e && r?.includes(String(e.operationId)) ? `${i}AsQuery` : i;
|
|
307
|
+
}, re = (e, t) => {
|
|
308
|
+
let n = {};
|
|
309
|
+
return e?.forEach((e) => {
|
|
310
|
+
n[e] = { query: {
|
|
311
|
+
useInfinite: !0,
|
|
312
|
+
useInfiniteQueryParam: "offset",
|
|
313
|
+
useQuery: !0
|
|
314
|
+
} };
|
|
315
|
+
}), t?.filter((e) => !n[e]).forEach((e) => {
|
|
316
|
+
n[e] = { query: { useQuery: !0 } };
|
|
317
|
+
}), Object.keys(n).length ? n : void 0;
|
|
318
|
+
}, ie = (e) => (Array.isArray(e) ? e : [e]).reduce((e, t) => {
|
|
319
|
+
let { output: n, useInfiniteIds: r, useQueryIds: i, input: a = "./openapi.json", customAxiosInstancePath: o, overrideApiName: s } = t || {}, c = s || te(a), l = o || "./node_modules/@getsoren/shared-module/dist/axiosCustomInstance.ts";
|
|
320
|
+
return {
|
|
321
|
+
...e,
|
|
322
|
+
[c]: {
|
|
323
|
+
input: a,
|
|
324
|
+
output: {
|
|
325
|
+
baseUrl: n?.baseUrl,
|
|
326
|
+
client: "react-query",
|
|
327
|
+
mode: "tags-split",
|
|
328
|
+
override: {
|
|
329
|
+
...(r?.length || i?.length) && { operations: re(r, i) },
|
|
330
|
+
header: (e) => [
|
|
331
|
+
"Generated by orval 🍺",
|
|
332
|
+
...e.title ? [e.title] : [],
|
|
333
|
+
...e.description ? [e.description] : []
|
|
334
|
+
],
|
|
335
|
+
mutator: {
|
|
336
|
+
name: ee(l),
|
|
337
|
+
path: l
|
|
338
|
+
},
|
|
339
|
+
operationName: (e, t, n) => ne(e, t, n, i),
|
|
340
|
+
query: { useQuery: !0 }
|
|
341
|
+
},
|
|
342
|
+
schemas: n?.schemas || `src/api/${c}/model`,
|
|
343
|
+
target: n?.target || `src/api/${c}/services/api.ts`,
|
|
344
|
+
...n
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
}, {}), ae = "user", oe = {
|
|
349
|
+
client: "/v2/threads/ws",
|
|
350
|
+
supplier: "/v1/threads/ws"
|
|
351
|
+
}, se = (e, t) => `${e.startsWith("https") ? "wss" : "ws"}://${e.replace(/^https?:\/\//, "")}${t}`, ce = (e) => {
|
|
352
|
+
try {
|
|
353
|
+
let t = localStorage.getItem(e);
|
|
354
|
+
return t ? JSON.parse(t)?.accessToken ?? null : null;
|
|
355
|
+
} catch {
|
|
356
|
+
return null;
|
|
357
|
+
}
|
|
358
|
+
}, B = n(null), le = ({ children: e, token: t, url: n, wsPath: r, maxReconnectAttempts: s, reconnectBaseDelay: d, maxMessageBodyLength: f = 1e4, reconnect: p = !0, enabled: m = !0, context: h = "client" }) => {
|
|
359
|
+
let [g, v] = l(!1), [b, x] = l(!1), [S, C] = l(0), [w, T] = l(m), E = m && w, { apiURL: D, localStorageKeys: O } = a(y), k = O?.user || ae, A = c(null), j = c(/* @__PURE__ */ new Set());
|
|
360
|
+
o(() => {
|
|
361
|
+
if (!E) return;
|
|
362
|
+
let e = r ?? oe[h], i = n || (D ? se(D, e) : null);
|
|
363
|
+
if (!i) return;
|
|
364
|
+
let a = () => t ?? ce(k), o = (e) => {
|
|
365
|
+
switch (e.type) {
|
|
366
|
+
case "ready":
|
|
367
|
+
x(!0), C(e.unreadCount ?? 0);
|
|
368
|
+
break;
|
|
369
|
+
}
|
|
370
|
+
for (let t of j.current) t(e);
|
|
371
|
+
}, c = setTimeout(() => {
|
|
372
|
+
let e = new _({
|
|
373
|
+
getToken: a,
|
|
374
|
+
maxMessageBodyLength: f,
|
|
375
|
+
maxReconnectAttempts: s,
|
|
376
|
+
onConnectionChange: (e) => {
|
|
377
|
+
v(e), e || x(!1);
|
|
378
|
+
},
|
|
379
|
+
onEvent: o,
|
|
380
|
+
reconnect: p,
|
|
381
|
+
reconnectBaseDelay: d,
|
|
382
|
+
url: i
|
|
383
|
+
});
|
|
384
|
+
A.current = e, e.connect();
|
|
385
|
+
}, 0);
|
|
386
|
+
return () => {
|
|
387
|
+
clearTimeout(c), A.current?.disconnect(), A.current = null;
|
|
388
|
+
};
|
|
389
|
+
}, [
|
|
390
|
+
E,
|
|
391
|
+
n,
|
|
392
|
+
r,
|
|
393
|
+
h,
|
|
394
|
+
t,
|
|
395
|
+
p,
|
|
396
|
+
D,
|
|
397
|
+
k,
|
|
398
|
+
f,
|
|
399
|
+
s,
|
|
400
|
+
d
|
|
401
|
+
]);
|
|
402
|
+
let M = i((e) => {
|
|
403
|
+
A.current?.joinThread(e);
|
|
404
|
+
}, []), N = i((e) => {
|
|
405
|
+
A.current?.leaveThread(e);
|
|
406
|
+
}, []), P = i((e, t) => {
|
|
407
|
+
A.current?.sendMessage(e, t);
|
|
408
|
+
}, []), F = i((e) => {
|
|
409
|
+
A.current?.markRead(e);
|
|
410
|
+
}, []), I = i((e, t) => {
|
|
411
|
+
A.current?.listThreads(e, t);
|
|
412
|
+
}, []), L = i((e = 1) => {
|
|
413
|
+
C((t) => t + e);
|
|
414
|
+
}, []), R = {
|
|
415
|
+
decrementUnreadCount: i((e = 1) => {
|
|
416
|
+
C((t) => Math.max(0, t - e));
|
|
417
|
+
}, []),
|
|
418
|
+
disconnect: i(() => {
|
|
419
|
+
A.current?.disconnect(), A.current = null;
|
|
420
|
+
}, []),
|
|
421
|
+
incrementUnreadCount: L,
|
|
422
|
+
isConnected: g,
|
|
423
|
+
isReady: b,
|
|
424
|
+
joinThread: M,
|
|
425
|
+
leaveThread: N,
|
|
426
|
+
listThreads: I,
|
|
427
|
+
markRead: F,
|
|
428
|
+
sendMessage: P,
|
|
429
|
+
setEnabled: i((e) => {
|
|
430
|
+
T(e);
|
|
431
|
+
}, []),
|
|
432
|
+
subscribe: i((e) => (j.current.add(e), () => {
|
|
433
|
+
j.current.delete(e);
|
|
434
|
+
}), []),
|
|
435
|
+
unreadCount: S
|
|
436
|
+
};
|
|
437
|
+
return /* @__PURE__ */ u(B.Provider, {
|
|
438
|
+
value: R,
|
|
439
|
+
children: e
|
|
440
|
+
});
|
|
441
|
+
}, ue = (e) => e && typeof e == "function", de = (e) => e && typeof e == "function", fe = ({ children: e, defaultQueriesOptions: t, defaultMutationsOptions: n, ...r }) => {
|
|
442
|
+
let { libraries: i } = a(y), o = r?.QueryClient || i?.reactQuery?.QueryClient, s = r?.QueryClientProvider || i?.reactQuery?.QueryClientProvider;
|
|
443
|
+
if (!o) throw Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
444
|
+
if (!s) throw Error("QueryClientProvider is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
445
|
+
if (!ue(s)) throw Error("Provided QueryClientProvider dependencies are not valid.");
|
|
446
|
+
if (!de(o)) throw Error("Provided QueryClient dependencies are not valid.");
|
|
447
|
+
let l = c(null);
|
|
448
|
+
return l.current ||= new o({ defaultOptions: {
|
|
449
|
+
mutations: { ...n },
|
|
450
|
+
queries: {
|
|
451
|
+
getNextPageParam: (e, t, n) => e.length + (n || 0),
|
|
452
|
+
refetchOnWindowFocus: !1,
|
|
453
|
+
retry: 3,
|
|
454
|
+
...t
|
|
455
|
+
}
|
|
456
|
+
} }), /* @__PURE__ */ u(s, {
|
|
457
|
+
client: l.current,
|
|
458
|
+
children: e
|
|
459
|
+
});
|
|
460
|
+
}, V = ({ library: e, date: t, format: n = "ll" }) => e(t).format(n), H = (e, t) => {
|
|
461
|
+
let { fractionDigits: n = 0, metric: r = "km", spacingBetween: i = !0 } = t || {}, a = Number(e), o = i ? " " : "";
|
|
462
|
+
return Number.isNaN(a) ? `0${o}${r}` : `${a.toFixed(n)}${o}${r}`;
|
|
463
|
+
}, U = (e) => !e || typeof e != "string" ? "" : e.replace(/_/g, " ").toLowerCase().split(" ").map((e) => e.length > 0 ? e.charAt(0).toUpperCase() + e.slice(1) : e).join(" "), pe = (e) => e?.startsWith("/") ? e?.startsWith("/files") ? e : `/files${e}` : e?.startsWith("files") ? `/${e}` : `/files/${e}`, me = ({ path: e, size: t, apiURL: n }) => {
|
|
464
|
+
if (!e) return "";
|
|
465
|
+
let r = `${n}${pe(e)}`, i = r.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/) !== null;
|
|
466
|
+
return typeof t == "number" && i ? `${r.replace("/files", `/thumbs/${t}`)}` : r;
|
|
467
|
+
}, he = (e) => {
|
|
468
|
+
let { apiURL: t, libraries: n } = a(y), r = e?.dayjs || n?.dayjs;
|
|
469
|
+
return {
|
|
470
|
+
dateAdapter: (e, t) => {
|
|
471
|
+
if (!r) throw Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
472
|
+
return V({
|
|
473
|
+
date: e,
|
|
474
|
+
format: t,
|
|
475
|
+
library: r
|
|
476
|
+
});
|
|
477
|
+
},
|
|
478
|
+
distanceAdapter: H,
|
|
479
|
+
filePathAdapter: (e, n) => {
|
|
480
|
+
if (!t) throw Error("API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter.");
|
|
481
|
+
return typeof e == "string" && /^https?:\/\//.test(e) ? e : me({
|
|
482
|
+
apiURL: t,
|
|
483
|
+
path: e,
|
|
484
|
+
size: n
|
|
485
|
+
});
|
|
486
|
+
},
|
|
487
|
+
worksiteNameAdapter: U
|
|
488
|
+
};
|
|
489
|
+
}, ge = () => {
|
|
490
|
+
let { libraries: e } = a(y), t = e?.amplitude?.analytics, n = i((e, n) => {
|
|
491
|
+
if (!t || (t.setUserId(e), !n)) return;
|
|
492
|
+
let r = new t.Identify();
|
|
493
|
+
Object.entries(n).forEach(([e, t]) => {
|
|
494
|
+
r.set(e, t);
|
|
495
|
+
}), t.identify(r);
|
|
496
|
+
}, [t]), r = i((e, n, r) => {
|
|
497
|
+
if (!t || (t.setGroup(e, n), !r)) return;
|
|
498
|
+
let i = new t.Identify();
|
|
499
|
+
Object.entries(r).forEach(([e, t]) => {
|
|
500
|
+
i.set(e, t);
|
|
501
|
+
}), t.groupIdentify(e, n, i);
|
|
502
|
+
}, [t]), o = i((e, n) => {
|
|
503
|
+
t && t.track(e, n);
|
|
504
|
+
}, [t]);
|
|
505
|
+
return {
|
|
506
|
+
identify: n,
|
|
507
|
+
reset: i(() => {
|
|
508
|
+
t && t.reset();
|
|
509
|
+
}, [t]),
|
|
510
|
+
setGroup: r,
|
|
511
|
+
track: o
|
|
512
|
+
};
|
|
513
|
+
}, _e = (e) => {
|
|
514
|
+
let { libraries: t, localStorageKeys: n } = a(y), r = e?.axios || t?.axios, s = e?.localStorageKey || n?.user || "user";
|
|
515
|
+
if (!r) throw Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");
|
|
516
|
+
let c = i(({ tokenType: e, accessToken: t }) => {
|
|
517
|
+
r.defaults.headers.common.Authorization = `${e} ${t}`;
|
|
518
|
+
}, [r.defaults.headers.common]);
|
|
519
|
+
return o(() => {
|
|
520
|
+
if (C) return;
|
|
521
|
+
let e = ({ newValue: e, key: t }) => {
|
|
522
|
+
if (t === s && e) try {
|
|
523
|
+
let { accessToken: t, tokenType: n } = JSON.parse(e);
|
|
524
|
+
c({
|
|
525
|
+
accessToken: t,
|
|
526
|
+
tokenType: n
|
|
527
|
+
});
|
|
528
|
+
} catch (e) {
|
|
529
|
+
console.error("Failed to parse newValue from localStorage:", e);
|
|
530
|
+
}
|
|
531
|
+
};
|
|
532
|
+
return window.addEventListener("storage", e), () => {
|
|
533
|
+
window.removeEventListener("storage", e);
|
|
534
|
+
};
|
|
535
|
+
}, [s, c]), {
|
|
536
|
+
clearAuthenticationToken: () => {
|
|
537
|
+
r.defaults.headers.common.Authorization = null;
|
|
538
|
+
},
|
|
539
|
+
setAuthenticationToken: c
|
|
540
|
+
};
|
|
541
|
+
}, ve = "New message", ye = (e, t) => {
|
|
542
|
+
if (!("Notification" in window) || typeof Notification != "function" || Notification.permission !== "granted" || !document.hidden) return;
|
|
543
|
+
let n = new Notification(t.title ?? ve, {
|
|
544
|
+
badge: t?.badge,
|
|
545
|
+
body: t?.body || e.bodyPreview,
|
|
546
|
+
data: t?.data,
|
|
547
|
+
dir: t?.dir,
|
|
548
|
+
icon: t?.icon,
|
|
549
|
+
lang: t?.lang,
|
|
550
|
+
requireInteraction: t?.requireInteraction,
|
|
551
|
+
silent: t?.silent,
|
|
552
|
+
tag: t?.tag || e.messageId
|
|
553
|
+
});
|
|
554
|
+
if (t.onClick) {
|
|
555
|
+
let { onClick: r } = t;
|
|
556
|
+
n.onclick = () => r(e);
|
|
557
|
+
}
|
|
558
|
+
}, be = (e) => {
|
|
559
|
+
let t = a(B);
|
|
560
|
+
if (!t) throw Error("useChat must be used within ChatProvider");
|
|
561
|
+
let { subscribe: n, setEnabled: r, ...i } = t, s = c(e);
|
|
562
|
+
return s.current = e, o(() => {
|
|
563
|
+
e?.enabled !== void 0 && r(e.enabled);
|
|
564
|
+
}, [e?.enabled, r]), o(() => {
|
|
565
|
+
e?.browserNotification && e.browserNotification.enabled !== !1 && "Notification" in window && Notification.permission === "default" && typeof Notification.requestPermission == "function" && Notification.requestPermission();
|
|
566
|
+
}, [e?.browserNotification]), o(() => n((e) => {
|
|
567
|
+
let { browserNotification: t, onReady: n, onNewMessage: r, onNewMessageNotification: i, onPresence: a, onError: o, onJoinedThread: c, onLeftThread: l, onMarkedRead: u, onThreadArchived: d, onThreadsList: f } = s.current ?? {};
|
|
568
|
+
switch (e.type) {
|
|
569
|
+
case "ready":
|
|
570
|
+
n?.(e);
|
|
571
|
+
break;
|
|
572
|
+
case "new_message":
|
|
573
|
+
r?.(e);
|
|
574
|
+
break;
|
|
575
|
+
case "new_message_notification":
|
|
576
|
+
i?.(e), t && t.enabled !== !1 && ye(e, t);
|
|
577
|
+
break;
|
|
578
|
+
case "presence":
|
|
579
|
+
a?.(e);
|
|
580
|
+
break;
|
|
581
|
+
case "error":
|
|
582
|
+
o?.(e);
|
|
583
|
+
break;
|
|
584
|
+
case "joined_thread":
|
|
585
|
+
c?.(e);
|
|
586
|
+
break;
|
|
587
|
+
case "left_thread":
|
|
588
|
+
l?.(e);
|
|
589
|
+
break;
|
|
590
|
+
case "marked_read":
|
|
591
|
+
u?.(e);
|
|
592
|
+
break;
|
|
593
|
+
case "thread_archived":
|
|
594
|
+
d?.(e);
|
|
595
|
+
break;
|
|
596
|
+
case "threads_list":
|
|
597
|
+
f?.(e);
|
|
598
|
+
break;
|
|
599
|
+
}
|
|
600
|
+
}), [n]), i;
|
|
601
|
+
}, W = (e, t) => t === "short" ? e.split("-")[0] : e, xe = (e, t = "full") => {
|
|
602
|
+
let [n, r] = l(() => {
|
|
603
|
+
let n = e?.language || navigator.language;
|
|
604
|
+
return e && "isInitialized" in e && e.isInitialized, W(n, t);
|
|
605
|
+
});
|
|
606
|
+
return o(() => {
|
|
607
|
+
e && "isInitialized" in e && e.isInitialized && e.language && r(W(e.language, t));
|
|
608
|
+
let n = (e) => {
|
|
609
|
+
r(W(e, t));
|
|
610
|
+
};
|
|
611
|
+
return e?.on?.("languageChanged", n), () => {
|
|
612
|
+
e?.off?.("languageChanged", n);
|
|
613
|
+
};
|
|
614
|
+
}, [e, t]), n;
|
|
615
|
+
}, Se = "tracktor.filter", Ce = {
|
|
616
|
+
getFilter: () => void 0,
|
|
617
|
+
getFilters: () => ({}),
|
|
618
|
+
handleFilter: () => () => {},
|
|
619
|
+
setFilter: () => {}
|
|
620
|
+
}, G = (e) => {
|
|
621
|
+
try {
|
|
622
|
+
return JSON.parse(e);
|
|
623
|
+
} catch {
|
|
624
|
+
return e;
|
|
625
|
+
}
|
|
626
|
+
}, K = (e, t, n) => `${n}_${e}=>${t}`, we = (e) => e.reduce((e, t) => {
|
|
627
|
+
let n = localStorage.getItem(t);
|
|
628
|
+
if (n) try {
|
|
629
|
+
let t = JSON.parse(n), r = Object.keys(t)?.[0];
|
|
630
|
+
r && (e[r] = Object.values(t)?.[0]);
|
|
631
|
+
} catch {}
|
|
632
|
+
return e;
|
|
633
|
+
}, {}), q = (e) => {
|
|
634
|
+
let { libraries: t, localStorageKeys: n } = a(y), r = e?.reactRouter || t?.reactRouter, { pathname: i } = r?.useLocation?.() ?? { pathname: "/" }, [o, s] = r?.useSearchParams?.() ?? [new URLSearchParams(), () => {}], [c, u] = l({}), d = n?.filter || Se, f = e?.syncWithUrl === void 0 ? !0 : e?.syncWithUrl, p = e?.persistToLocalStorage === void 0 ? !0 : e?.persistToLocalStorage;
|
|
635
|
+
if (C) return Ce;
|
|
636
|
+
if (!r) throw Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter.");
|
|
637
|
+
let m = () => Object.keys(localStorage).filter((t) => t.startsWith(d) && t.endsWith(e?.pathname || i)), h = (t, n, r = !0) => {
|
|
638
|
+
let a = K(t, e?.pathname || i, d);
|
|
639
|
+
if (!n || Array.isArray(n) && !n.length) {
|
|
640
|
+
f ? (o.delete(t), s(o)) : u((e) => {
|
|
641
|
+
let n = { ...e };
|
|
642
|
+
return delete n[t], n;
|
|
643
|
+
}), p && localStorage.removeItem(a);
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
p && r && n && localStorage.setItem(a, JSON.stringify({
|
|
647
|
+
...o,
|
|
648
|
+
[t]: n
|
|
649
|
+
})), f && n ? (o.set(t, JSON.stringify(n)), s(o)) : !f && n && u((e) => ({
|
|
650
|
+
...e,
|
|
651
|
+
[t]: n
|
|
652
|
+
}));
|
|
653
|
+
};
|
|
654
|
+
return {
|
|
655
|
+
getFilter: (t, n) => {
|
|
656
|
+
if (f) {
|
|
657
|
+
let e = o.get(t);
|
|
658
|
+
if (e) return G(e);
|
|
659
|
+
} else {
|
|
660
|
+
let e = c[t];
|
|
661
|
+
if (e !== void 0) return e;
|
|
662
|
+
}
|
|
663
|
+
if (p) {
|
|
664
|
+
let n = K(t, e?.pathname || i, d), r = localStorage.getItem(n);
|
|
665
|
+
if (r) try {
|
|
666
|
+
let e = JSON.parse(r)[t];
|
|
667
|
+
return !f && e !== void 0 && u((n) => ({
|
|
668
|
+
...n,
|
|
669
|
+
[t]: e
|
|
670
|
+
})), e;
|
|
671
|
+
} catch {}
|
|
672
|
+
}
|
|
673
|
+
return n;
|
|
674
|
+
},
|
|
675
|
+
getFilters: () => {
|
|
676
|
+
let e = p ? we(m()) : {};
|
|
677
|
+
if (f) {
|
|
678
|
+
let t = Array.from(o.entries()).reduce((e, [t, n]) => (e[t] = G(n), e), {});
|
|
679
|
+
return {
|
|
680
|
+
...e,
|
|
681
|
+
...t
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
return {
|
|
685
|
+
...e,
|
|
686
|
+
...c
|
|
687
|
+
};
|
|
688
|
+
},
|
|
689
|
+
handleFilter: (e, t) => (n, r) => {
|
|
690
|
+
if (r || Array.isArray(r) && r.length === 0) {
|
|
691
|
+
let n = t || "value";
|
|
692
|
+
h(e, typeof r == "object" && n in r ? r[n || "value"] : r);
|
|
693
|
+
return;
|
|
694
|
+
}
|
|
695
|
+
h(e, void 0);
|
|
696
|
+
},
|
|
697
|
+
setFilter: h
|
|
698
|
+
};
|
|
699
|
+
}, J = () => document.getElementById(D), Te = () => {
|
|
700
|
+
let [e, t] = l(() => !!window.HubSpotConversations);
|
|
701
|
+
return o(() => {
|
|
702
|
+
if (window.HubSpotConversations) {
|
|
703
|
+
t(!0);
|
|
704
|
+
return;
|
|
705
|
+
}
|
|
706
|
+
window.hsConversationsOnReady = [() => t(!0)];
|
|
707
|
+
}, []), o(() => {
|
|
708
|
+
e && window.HubSpotConversations?.on("widgetClosed", () => {
|
|
709
|
+
J()?.classList.remove(O);
|
|
710
|
+
});
|
|
711
|
+
}, [e]), {
|
|
712
|
+
isAvailable: e,
|
|
713
|
+
toggle: i(() => {
|
|
714
|
+
let e = window.HubSpotConversations, t = J();
|
|
715
|
+
e && t && (t.classList.contains("hs-show") ? (e.widget.close(), t.classList.remove(O)) : (t.classList.add(O), e.widget.open()));
|
|
716
|
+
}, [])
|
|
717
|
+
};
|
|
718
|
+
}, Ee = ({ data: e, fetchNextPage: t, isFetchingNextPage: n, isInitialLoading: r, isLoading: a, enabled: o = !0 }) => {
|
|
719
|
+
let c = i(async (e) => {
|
|
720
|
+
n || !o || await t({ pageParam: e?.pageParam || e.visibleRowsCount });
|
|
721
|
+
}, [
|
|
722
|
+
o,
|
|
723
|
+
t,
|
|
724
|
+
n
|
|
725
|
+
]), l = s(() => {
|
|
726
|
+
if (e) return e.pages.reduce((e, t) => [...e, ...t], []);
|
|
727
|
+
}, [e]);
|
|
728
|
+
return {
|
|
729
|
+
fetchNextPageOnRowsScrollEnd: c,
|
|
730
|
+
isLoading: n || a,
|
|
731
|
+
loadingVariant: r ? "skeleton" : "linear-progress",
|
|
732
|
+
rows: l
|
|
733
|
+
};
|
|
734
|
+
}, De = (e) => {
|
|
735
|
+
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) => {
|
|
736
|
+
if (e && typeof e == "object" && "response" in e) {
|
|
737
|
+
let { response: t } = e || {};
|
|
738
|
+
if (t && typeof t == "object" && "reason" in t && t.reason) return String(t.reason);
|
|
739
|
+
if (t && typeof t == "object" && "data" in t && t.data && typeof t.data == "object" && "reason" in t.data && t.data.reason) return String(t.data.reason);
|
|
740
|
+
if (t && typeof t == "object" && "data" in t && t.data && typeof t.data == "object" && "message" in t.data && t.data.message) return String(t.data.message);
|
|
741
|
+
if (t && typeof t == "object" && "data" in t && t.data && typeof t.data == "object" && "detail" in t.data) {
|
|
742
|
+
let { detail: e } = t.data;
|
|
743
|
+
if (Array.isArray(e) && e.length > 0 && typeof e[0] == "object" && e[0] !== null && "msg" in e[0]) {
|
|
744
|
+
let { msg: t } = e[0];
|
|
745
|
+
if (typeof t == "string") return String(t);
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
return e instanceof Error ? e.message : c;
|
|
750
|
+
}, [c]);
|
|
751
|
+
return {
|
|
752
|
+
getErrorCode: i((e) => {
|
|
753
|
+
let { response: t } = e || {};
|
|
754
|
+
return t?.error_code ? String(t?.error_code) : t?.data?.error_code ? String(t?.data?.error_code) : t?.error_code ? String(t?.error_code) : t?.data?.error_code ? String(t.data.error_code) : "unknown_error_code";
|
|
755
|
+
}, []),
|
|
756
|
+
printError: l
|
|
757
|
+
};
|
|
758
|
+
}, Y = "chunk-reload-timestamp", X = "chunk-reload", Oe = 1e4, Z = 2, Q = !1;
|
|
759
|
+
if (!C && typeof window < "u") {
|
|
760
|
+
try {
|
|
761
|
+
let e = new URL(window.location.href);
|
|
762
|
+
e.searchParams.has(X) && (Q = !0, e.searchParams.delete(X), window.history.replaceState(null, "", e.toString()));
|
|
763
|
+
} catch {}
|
|
764
|
+
window.addEventListener("vite:preloadError", (e) => {
|
|
765
|
+
e.preventDefault();
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
var ke = (e) => {
|
|
769
|
+
if (!(e instanceof Error)) return !1;
|
|
770
|
+
let t = e.message.toLowerCase();
|
|
771
|
+
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";
|
|
772
|
+
}, Ae = /import\s*\(\s*(['"])((\w+:(\/?\/?))?[^\s,]+)\1/, je = (e) => e.toString().match(Ae)?.[2] ?? null, Me = (e) => {
|
|
773
|
+
try {
|
|
774
|
+
return sessionStorage.getItem(e);
|
|
775
|
+
} catch {
|
|
776
|
+
return null;
|
|
777
|
+
}
|
|
778
|
+
}, Ne = (e, t) => {
|
|
779
|
+
try {
|
|
780
|
+
sessionStorage.setItem(e, t);
|
|
781
|
+
} catch {}
|
|
782
|
+
}, Pe = (e) => Function("url", "return import(url)")(e), Fe = async (e) => {
|
|
783
|
+
for (let t = 0; t < Z; t++) try {
|
|
784
|
+
return await Pe(`${e}?t=${Date.now()}`);
|
|
785
|
+
} catch {
|
|
786
|
+
t < Z - 1 && await new Promise((e) => setTimeout(e, 500 * 2 ** t));
|
|
787
|
+
}
|
|
788
|
+
throw Error(`Failed to import ${e} after ${Z} retries`);
|
|
789
|
+
}, Ie = async () => {
|
|
790
|
+
try {
|
|
791
|
+
if (typeof navigator < "u" && "serviceWorker" in navigator) {
|
|
792
|
+
let e = await navigator.serviceWorker.getRegistrations();
|
|
793
|
+
await Promise.all(e.map((e) => e.unregister()));
|
|
794
|
+
}
|
|
795
|
+
if (typeof caches < "u") {
|
|
796
|
+
let e = await caches.keys();
|
|
797
|
+
await Promise.all(e.map((e) => caches.delete(e)));
|
|
798
|
+
}
|
|
799
|
+
} catch {}
|
|
800
|
+
}, Le = async () => {
|
|
801
|
+
await Ie();
|
|
802
|
+
let e = new URL(window.location.href);
|
|
803
|
+
e.searchParams.set(X, String(Date.now())), window.location.replace(e.toString());
|
|
804
|
+
}, $ = (e) => e != null && e.default !== void 0, Re = (e) => r(async () => {
|
|
805
|
+
let t;
|
|
806
|
+
try {
|
|
807
|
+
let n = await e();
|
|
808
|
+
if ($(n)) return n;
|
|
809
|
+
t = /* @__PURE__ */ Error("Module resolved without a valid default export");
|
|
810
|
+
} catch (e) {
|
|
811
|
+
t = e;
|
|
812
|
+
}
|
|
813
|
+
if (C || !ke(t)) throw t;
|
|
814
|
+
let n = je(e);
|
|
815
|
+
if (n) try {
|
|
816
|
+
let e = await Fe(n);
|
|
817
|
+
if ($(e)) return e;
|
|
818
|
+
} catch {}
|
|
819
|
+
let r = Number(Me(Y) || "0");
|
|
820
|
+
return Date.now() - r < Oe || Q || (Ne(Y, String(Date.now())), await Le()), { default: () => null };
|
|
821
|
+
});
|
|
822
|
+
//#endregion
|
|
823
|
+
export { _ as ChatClient, B as ChatContext, le as ChatProvider, x as GTMSendPageView, S as InitializeAmplitude, T as InitializeAxiosConfig, E as InitializeDaysJSConfig, A as InitializeHubSpot, j as InitializeI18nConfig, M as InitializeSentryConfig, y as InjectDependenciesContext, b as InjectDependenciesProvider, v as MaskTextField, fe as QueryProvider, F as RequireAuth, L as ShowHubSpotBubble, d as axiosCustomInstance, V as dateAdapter, H as distanceAdapter, ie as getOrvalConfig, Re as lazyWithRetry, he as useAdapter, ge as useAmplitude, _e as useAuth, be as useChat, xe as useCurrentLanguage, q as useFilters, Te as useHubSpot, Ee as useInfiniteDataGrid, De as useResponseError, U as worksiteNameAdapter };
|