@sinequa/atomic 0.0.134 → 1.0.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.
Files changed (37) hide show
  1. package/dist/atomic.js +805 -712
  2. package/dist/atomic.umd.cjs +1 -1
  3. package/dist/authentication/constants.d.ts +5 -0
  4. package/dist/authentication/constants.d.ts.map +1 -0
  5. package/dist/authentication/events/emit-authenticated-event.d.ts.map +1 -1
  6. package/dist/authentication/providers/oauth-authentication.d.ts +6 -0
  7. package/dist/authentication/providers/oauth-authentication.d.ts.map +1 -1
  8. package/dist/authentication/providers/saml-authentication.d.ts +6 -0
  9. package/dist/authentication/providers/saml-authentication.d.ts.map +1 -1
  10. package/dist/authentication/session/logout.d.ts.map +1 -1
  11. package/dist/authentication/tokens/delete-web-token-cookie.d.ts +1 -1
  12. package/dist/authentication/tokens/delete-web-token-cookie.d.ts.map +1 -1
  13. package/dist/authentication/tokens/get-csrf-token.d.ts +4 -4
  14. package/dist/authentication/tokens/get-csrf-token.d.ts.map +1 -1
  15. package/dist/authentication/tokens/get-jwt-token.d.ts +10 -8
  16. package/dist/authentication/tokens/get-jwt-token.d.ts.map +1 -1
  17. package/dist/authentication/tokens/get-token.d.ts +2 -2
  18. package/dist/authentication/tokens/get-token.d.ts.map +1 -1
  19. package/dist/helpers/utils.d.ts +11 -0
  20. package/dist/helpers/utils.d.ts.map +1 -1
  21. package/dist/types/audit/AuditEventType.d.ts +9 -2
  22. package/dist/types/audit/AuditEventType.d.ts.map +1 -1
  23. package/dist/types/preview/Conversion.d.ts +10 -0
  24. package/dist/types/preview/Conversion.d.ts.map +1 -0
  25. package/dist/types/preview/PreviewData.d.ts +2 -0
  26. package/dist/types/preview/PreviewData.d.ts.map +1 -1
  27. package/dist/types/preview/index.d.ts +2 -1
  28. package/dist/types/preview/index.d.ts.map +1 -1
  29. package/dist/utils/query-params.d.ts +1 -1
  30. package/dist/utils/query-params.d.ts.map +1 -1
  31. package/dist/utils/to-sql.d.ts +3 -0
  32. package/dist/utils/to-sql.d.ts.map +1 -0
  33. package/dist/web-api/v1/fetch-suggest.d.ts +2 -2
  34. package/dist/web-api/v1/fetch-suggest.d.ts.map +1 -1
  35. package/dist/web-api/v2/fetch-user-profile.d.ts +20 -1
  36. package/dist/web-api/v2/fetch-user-profile.d.ts.map +1 -1
  37. package/package.json +10 -4
package/dist/atomic.js CHANGED
@@ -1,7 +1,6 @@
1
- var le = Object.defineProperty;
2
- var ue = (e, t, r) => t in e ? le(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var Y = (e, t, r) => ue(e, typeof t != "symbol" ? t + "" : t, r);
4
- function _(e) {
1
+ function g(e) {
2
+ if (typeof CustomEvent > "u" || typeof dispatchEvent > "u")
3
+ return;
5
4
  const t = new CustomEvent("authenticated", {
6
5
  bubbles: !0,
7
6
  cancelable: !1,
@@ -9,118 +8,89 @@ function _(e) {
9
8
  });
10
9
  dispatchEvent(t);
11
10
  }
12
- const d = {
11
+ const u = {
13
12
  loginPath: "/login",
14
13
  createRoutes: !1
15
14
  };
16
15
  function k(e) {
17
- Object.assign(d, e);
18
- }
19
- function L(e) {
20
- const t = W(), r = new Headers(e);
21
- r.append("Sinequa-Force-Camel-Case", "true"), r.append("accept", "application/json"), t && r.append("Sinequa-csrf-token", t);
22
- const { userOverride: n, userOverrideActive: a, bearerToken: s } = d;
23
- return s && r.append("Authorization", `Bearer ${s}`), n && a && (r.append("sinequa-override-user", n.username), r.append("sinequa-override-domain", n.domain)), r;
24
- }
25
- class b extends Error {
26
- constructor(r, n) {
27
- super(r);
28
- Y(this, "status");
29
- this.name = "ApiError", this.status = n;
30
- }
31
- }
32
- class K extends b {
33
- constructor(t = "Server error") {
34
- super(t, 500), this.name = "ServerError";
35
- }
36
- }
37
- class de extends b {
38
- constructor(t = "Request timed out") {
39
- super(t, 408), this.name = "TimeoutError";
40
- }
41
- }
42
- class V extends b {
43
- constructor(t = "Unauthorized access") {
44
- super(t, 401), this.name = "UnauthorizedError";
45
- }
46
- }
47
- const fe = /.*\:\(?([><=\d\-\.AND ]+)\)?/;
48
- function ct(e, t) {
49
- var a;
50
- return !(e != null && e.items) || ((a = e == null ? void 0 : e.items) == null ? void 0 : a.length) === 0 ? [] : e.items.reduce((s, i) => {
51
- if (!i.value || i.value === "") return s;
52
- const o = he(i, e.column);
53
- return s.push({
54
- operator: o.operator,
55
- value: o.value,
56
- display: i.display || o.display,
57
- filters: o.filters,
58
- disabled: i.count === 0,
59
- hidden: i.count === 0 && e.isDistribution ? !t : !1
60
- }), s;
16
+ Object.assign(u, e);
17
+ }
18
+ const se = /.*\:\(?([><=\d\-\.AND ]+)\)?/;
19
+ function it(e, t) {
20
+ return !e?.items || e?.items?.length === 0 ? [] : e.items.reduce((a, o) => {
21
+ if (!o.value || o.value === "") return a;
22
+ const s = ie(o, e.column);
23
+ return a.push({
24
+ operator: s.operator,
25
+ value: s.value,
26
+ display: o.display || s.display,
27
+ filters: s.filters,
28
+ disabled: o.count === 0,
29
+ hidden: o.count === 0 && e.isDistribution ? !t : !1
30
+ }), a;
61
31
  }, []);
62
32
  }
63
- function he(e, t) {
64
- const r = t, n = e.value.match(fe);
65
- if (n != null && n[1]) {
66
- const s = (n == null ? void 0 : n[1].split(" AND ")).map((i) => {
67
- const o = i.indexOf(">=") !== -1 ? "gte" : "lt";
68
- let c = i.substring(i.indexOf(" ") + 1);
69
- return { field: r, operator: o, value: c, display: e.display || e.value };
33
+ function ie(e, t) {
34
+ const r = t, n = e.value.match(se);
35
+ if (n?.[1]) {
36
+ const o = (n?.[1].split(" AND ")).map((s) => {
37
+ const i = s.indexOf(">=") !== -1 ? "gte" : "lt";
38
+ let c = s.substring(s.indexOf(" ") + 1);
39
+ return { field: r, operator: i, value: c, display: e.display || e.value };
70
40
  });
71
- if (s.length === 2)
72
- return { field: r, operator: "and", filters: s, value: e.value, display: s[0].display || s[0].value };
73
- if (s.length === 1)
74
- return { ...s[0], field: r };
41
+ if (o.length === 2)
42
+ return { field: r, operator: "and", filters: o, value: e.value, display: o[0].display || o[0].value };
43
+ if (o.length === 1)
44
+ return { ...o[0], field: r };
75
45
  throw new Error("Failed to parse distribution expression");
76
46
  }
77
47
  return { field: r, operator: "eq", value: e.value, display: e.display };
78
48
  }
79
- function it(e, t, r) {
49
+ function ct(e, t, r) {
80
50
  return e.valuesAreExpressions ? t.display === r.display : t.value === r.value;
81
51
  }
82
- function me(e) {
83
- return e.items && (e.items = e.items.map((t) => me(t))), e.items && e.items.some((t) => t.$selected || t.$opened) && (e.$opened = !0), e;
52
+ function ce(e) {
53
+ return e.items && (e.items = e.items.map((t) => ce(t))), e.items && e.items.some((t) => t.$selected || t.$opened) && (e.$opened = !0), e;
84
54
  }
85
55
  function lt(e, t) {
86
56
  const r = [];
87
57
  if (e.length > 0) {
88
- const n = /* @__PURE__ */ new Map(), s = t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").normalize("NFD").replace(/[\u0300-\u036f]/g, ""), i = new RegExp("\\b" + s, "i");
89
- e.forEach((o) => {
90
- if (o.display.length > 1) {
91
- const c = o.display.normalize("NFD").replace(/[\u0300-\u036f]/g, ""), l = i.exec(c);
92
- re(r, n, "/", o.display, +(o.frequency || 0), 1, ((l == null ? void 0 : l.index) || 0) + t.length);
58
+ const n = /* @__PURE__ */ new Map(), o = t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").normalize("NFD").replace(/[\u0300-\u036f]/g, ""), s = new RegExp("\\b" + o, "i");
59
+ e.forEach((i) => {
60
+ if (i.display.length > 1) {
61
+ const c = i.display.normalize("NFD").replace(/[\u0300-\u036f]/g, ""), d = s.exec(c);
62
+ T(r, n, "/", i.display, +(i.frequency || 0), 1, (d?.index || 0) + t.length);
93
63
  }
94
64
  });
95
65
  }
96
66
  return r;
97
67
  }
98
- function re(e, t, r, n, a, s, i) {
99
- const o = n.indexOf("/", r.length), c = n.substring(0, o + 1);
100
- let l = t.get(c);
101
- if (!l) {
102
- const f = c.replace(/^\/|\/$/g, "");
103
- l = {
104
- value: n.substring(r.length, o),
68
+ function T(e, t, r, n, a, o, s) {
69
+ const i = n.indexOf("/", r.length), c = n.substring(0, i + 1);
70
+ let d = t.get(c);
71
+ if (!d) {
72
+ const _ = c.replace(/^\/|\/$/g, "");
73
+ d = {
74
+ value: n.substring(r.length, i),
105
75
  count: a,
106
76
  items: [],
107
77
  hasChildren: !1,
108
- $level: s,
109
- $opened: i >= c.length,
110
- $path: f
111
- }, t.set(c, l), e.push(l);
78
+ $level: o,
79
+ $opened: s >= c.length,
80
+ $path: _
81
+ }, t.set(c, d), e.push(d);
112
82
  }
113
- c.length < n.length && (l.hasChildren = !0, re(l.items, t, c, n, a, s + 1, i));
83
+ c.length < n.length && (d.hasChildren = !0, T(d.items, t, c, n, a, o + 1, s));
114
84
  }
115
85
  function ut(e, t) {
116
86
  return e.reduce((r, n) => (t(n) ? r.true.push(n) : r.false.push(n), r), { true: [], false: [] });
117
87
  }
118
- const we = /(([\+\-])?\(([^\)]+)\))|(([\+\-])?\[([^\]]+)\])|(([\+\-])?\"([^\"]+)\")|(([\+\-])?\/([^\/]+)\/)|(([\+\-])?(\S+))/g, _e = 2, Z = 3, ge = 5, E = 6, Se = 8, T = 9, pe = 11, ee = 12, ke = 14, te = 15;
119
- function I(e) {
88
+ const le = /(([\+\-])?\(([^\)]+)\))|(([\+\-])?\[([^\]]+)\])|(([\+\-])?\"([^\"]+)\")|(([\+\-])?\/([^\/]+)\/)|(([\+\-])?(\S+))/g, ue = 2, M = 3, de = 5, X = 6, fe = 8, Y = 9, he = 11, K = 12, ge = 14, Z = 15;
89
+ function A(e) {
120
90
  if (!e) return [];
121
- const t = [], r = e.matchAll(we);
91
+ const t = [], r = e.matchAll(le);
122
92
  for (let n of r)
123
- n[Z] ? t.push({ type: "group", value: n[Z], op: n[_e] }) : n[E] ? t.push({ type: "adjacent", value: n[E], op: n[ge] }) : n[T] ? t.push({ type: "exact", value: n[T], op: n[Se] }) : n[ee] ? t.push({ type: "regex", value: n[ee], op: n[pe] }) : n[te] && t.push({ type: "token", value: n[te], op: n[ke] });
93
+ n[M] ? t.push({ type: "group", value: n[M], op: n[ue] }) : n[X] ? t.push({ type: "adjacent", value: n[X], op: n[de] }) : n[Y] ? t.push({ type: "exact", value: n[Y], op: n[fe] }) : n[K] ? t.push({ type: "regex", value: n[K], op: n[he] }) : n[Z] && t.push({ type: "token", value: n[Z], op: n[ge] });
124
94
  return t;
125
95
  }
126
96
  function G(e) {
@@ -141,27 +111,27 @@ function G(e) {
141
111
  }).join(" ");
142
112
  }
143
113
  function dt(e, t, r) {
144
- let n = I(e);
114
+ let n = A(e);
145
115
  for (let a of t)
146
116
  n.push({ type: "adjacent", value: a, op: r });
147
117
  return G(n);
148
118
  }
149
119
  function ft(e, t) {
150
- const r = I(t), n = r.findIndex((a) => a.value === e);
120
+ const r = A(t), n = r.findIndex((a) => a.value === e);
151
121
  return n !== -1 ? (r.splice(n, 1), t = G(r)) : t;
152
122
  }
153
123
  function ht(e) {
154
- const t = I(e).filter((r) => r.type !== "adjacent");
124
+ const t = A(e).filter((r) => r.type !== "adjacent");
155
125
  return G(t);
156
126
  }
157
- function mt(e) {
158
- return I(e).filter((t) => t.type === "adjacent").map((t) => t.value);
127
+ function gt(e) {
128
+ return A(e).filter((t) => t.type === "adjacent").map((t) => t.value);
159
129
  }
160
- function wt(e, t, r) {
161
- const n = new Intl.RelativeTimeFormat(e, { numeric: "auto" }), { offset: a, unit: s, isFuture: i } = ve(t, r);
162
- return n.format(a * (i ? 1 : -1), s);
130
+ function pt(e, t, r) {
131
+ const n = new Intl.RelativeTimeFormat(e, { numeric: "auto" }), { offset: a, unit: o, isFuture: s } = pe(t, r);
132
+ return n.format(a * (s ? 1 : -1), o);
163
133
  }
164
- function ve(e, t) {
134
+ function pe(e, t) {
165
135
  const r = new Date(e), n = t ? new Date(t) : /* @__PURE__ */ new Date(), a = Math.abs(n.getTime() - r.getTime());
166
136
  return {
167
137
  offset: Math.floor(a / (1e3 * 60 * 60 * 24)),
@@ -169,37 +139,37 @@ function ve(e, t) {
169
139
  isFuture: r > n
170
140
  };
171
141
  }
172
- function _t(e) {
142
+ function mt(e) {
173
143
  const t = e.target;
174
144
  return t && t.nodeName !== "INPUT" && t.nodeName !== "TEXTAREA";
175
145
  }
176
- function gt(e) {
146
+ function wt(e) {
177
147
  if (e === void 0) return;
178
- const { q: t, f: r, p: n, s: a, t: s, n: i, b: o } = R(e), [c] = e.split("?");
148
+ const { q: t, f: r, p: n, s: a, t: o, n: s, b: i } = x(e), [c] = e.split("?");
179
149
  return {
180
150
  path: c,
181
151
  text: t,
182
- filters: r ? ne(r) : void 0,
152
+ filters: r ? ee(r) : void 0,
183
153
  page: n ? parseInt(n, 10) : void 0,
184
154
  sort: a,
185
- tab: s,
186
- name: i,
187
- basket: o
155
+ tab: o,
156
+ name: s,
157
+ basket: i
188
158
  };
189
159
  }
190
- function St(e) {
160
+ function _t(e) {
191
161
  if (!e) return "";
192
- const { text: t, filters: r, page: n, sort: a, tab: s, name: i, basket: o } = e, c = {};
193
- t && (c.q = t), r && (c.f = JSON.stringify(r)), n && (c.p = n.toString()), a && (c.s = a), s && (c.t = s), i && (c.n = i), o && (c.b = o);
194
- const l = new URLSearchParams(c).toString();
195
- return l || "";
162
+ const { text: t, filters: r, page: n, sort: a, tab: o, name: s, basket: i } = e, c = {};
163
+ t && (c.q = t), r && (c.f = JSON.stringify(r)), n && (c.p = n.toString()), a && (c.s = a), o && (c.t = o), s && (c.n = s), i && (c.b = i);
164
+ const d = new URLSearchParams(c).toString();
165
+ return d || "";
196
166
  }
197
- function pt(e) {
167
+ function St(e) {
198
168
  if (e === void 0) return [];
199
- const { f: t } = R(e);
200
- return ne(t);
169
+ const { f: t } = x(e);
170
+ return ee(t);
201
171
  }
202
- function ne(e) {
172
+ function ee(e) {
203
173
  const t = decodeURIComponent(e);
204
174
  try {
205
175
  return JSON.parse(t ?? "[]");
@@ -207,26 +177,26 @@ function ne(e) {
207
177
  return console.error(`Error parsing filters from URI: ${e}`), [];
208
178
  }
209
179
  }
210
- function R(e) {
180
+ function x(e) {
211
181
  const t = e.split("?")[1];
212
182
  if (t === void 0) return {};
213
183
  const r = new URLSearchParams(t);
214
184
  return Object.fromEntries(r);
215
185
  }
216
186
  function kt(e) {
217
- const { q: t = "" } = R(e);
187
+ const { q: t = "" } = x(e);
218
188
  return t;
219
189
  }
220
- function vt(e) {
221
- const { id: t } = R(e);
190
+ function bt(e) {
191
+ const { id: t } = x(e);
222
192
  return decodeURIComponent(t);
223
193
  }
224
- function bt(e) {
225
- const { p: t = "0" } = R(e);
194
+ function vt(e) {
195
+ const { p: t = "0" } = x(e);
226
196
  return parseInt(t, 10);
227
197
  }
228
198
  function Ct(e) {
229
- const { t } = R(e);
199
+ const { t } = x(e);
230
200
  return t;
231
201
  }
232
202
  function Rt(e, t) {
@@ -240,21 +210,21 @@ function Rt(e, t) {
240
210
  a++;
241
211
  e[a] === "]" && (r = a + 1);
242
212
  }
243
- const s = B(e, r, !1);
244
- if (!s)
213
+ const o = q(e, r, !1);
214
+ if (!o)
245
215
  return e;
246
- const i = t.charCodeAt(0), o = t.charCodeAt(1);
247
- let c = s;
216
+ const s = t.charCodeAt(0), i = t.charCodeAt(1);
217
+ let c = o;
248
218
  for (; c; )
249
- if (i === c.lang1 && o === c.lang2) {
250
- const f = B(e, c.end + 4, !0);
251
- return e.substring(f.start, f.end);
219
+ if (s === c.lang1 && i === c.lang2) {
220
+ const _ = q(e, c.end + 4, !0);
221
+ return e.substring(_.start, _.end);
252
222
  } else
253
- c = B(e, c.end + 4, !1);
254
- const l = e.substring(s.start, s.end);
255
- return l || e;
223
+ c = q(e, c.end + 4, !1);
224
+ const d = e.substring(o.start, o.end);
225
+ return d || e;
256
226
  }
257
- function B(e, t, r) {
227
+ function q(e, t, r) {
258
228
  for (let n = t, a = e.length - 3; n < a; n++)
259
229
  if (e[n] === "[" && e[n + 3] === "]")
260
230
  return {
@@ -271,11 +241,11 @@ function B(e, t, r) {
271
241
  lang2: -1
272
242
  };
273
243
  }
274
- function xt(e, t) {
275
- const { useLocale: r, useLocaleAsPrefix: n, indexFile: a, path: s, folder: i } = t, o = r ? `${e}/` : null, c = n ? `${e}.${a}` : a ?? "";
276
- return [s, i, `${o || ""}${c}`].filter((l) => l !== void 0).join("/");
244
+ function Pt(e, t) {
245
+ const { useLocale: r, useLocaleAsPrefix: n, indexFile: a, path: o, folder: s } = t, i = r ? `${e}/` : null, c = n ? `${e}.${a}` : a ?? "";
246
+ return [o, s, `${i || ""}${c}`].filter((d) => d !== void 0).join("/");
277
247
  }
278
- function O(e) {
248
+ function U(e) {
279
249
  const t = new CustomEvent("notification", {
280
250
  bubbles: !0,
281
251
  cancelable: !1,
@@ -283,48 +253,48 @@ function O(e) {
283
253
  });
284
254
  dispatchEvent(t);
285
255
  }
286
- const Pt = {
256
+ const yt = {
287
257
  success: (e, t) => {
288
- O({
258
+ U({
289
259
  type: "success",
290
260
  message: e,
291
261
  options: t
292
262
  });
293
263
  },
294
264
  info: (e, t) => {
295
- O({
265
+ U({
296
266
  type: "info",
297
267
  message: e,
298
268
  options: t
299
269
  });
300
270
  },
301
271
  warning: (e, t) => {
302
- O({
272
+ U({
303
273
  type: "warning",
304
274
  message: e,
305
275
  options: t
306
276
  });
307
277
  },
308
278
  error: (e, t) => {
309
- O({
279
+ U({
310
280
  type: "error",
311
281
  message: e,
312
282
  options: t
313
283
  });
314
284
  }
315
285
  };
316
- var ae = /* @__PURE__ */ ((e) => (e[e.DEBUG = 0] = "DEBUG", e[e.INFO = 1] = "INFO", e[e.WARN = 2] = "WARN", e[e.ERROR = 3] = "ERROR", e[e.NONE = 4] = "NONE", e))(ae || {});
317
- let U = {
286
+ var te = /* @__PURE__ */ ((e) => (e[e.DEBUG = 0] = "DEBUG", e[e.INFO = 1] = "INFO", e[e.WARN = 2] = "WARN", e[e.ERROR = 3] = "ERROR", e[e.NONE = 4] = "NONE", e))(te || {});
287
+ let D = {
318
288
  level: 1,
319
289
  enableConsoleOutput: !0
320
290
  };
321
- function Lt(e) {
322
- U = { ...U, ...e };
291
+ function xt(e) {
292
+ D = { ...D, ...e };
323
293
  }
324
- function D(e, t, r) {
325
- if (e < U.level) return;
326
- const a = `${`[${ae[e]}]`} ${t}`;
327
- if (U.enableConsoleOutput)
294
+ function N(e, t, r) {
295
+ if (e < D.level) return;
296
+ const a = `${`[${te[e]}]`} ${t}`;
297
+ if (D.enableConsoleOutput)
328
298
  switch (e) {
329
299
  case 0:
330
300
  console.debug(a, r || "");
@@ -340,21 +310,48 @@ function D(e, t, r) {
340
310
  break;
341
311
  }
342
312
  }
343
- function x(e, t) {
344
- D(0, e, t);
313
+ function L(e, t) {
314
+ N(0, e, t);
345
315
  }
346
- function p(e, t) {
347
- D(1, e, t);
316
+ function S(e, t) {
317
+ N(1, e, t);
348
318
  }
349
- function P(e, t) {
350
- D(2, e, t);
319
+ function y(e, t) {
320
+ N(2, e, t);
351
321
  }
352
- function h(e, t) {
353
- D(3, e, t);
322
+ function f(e, t) {
323
+ N(3, e, t);
354
324
  }
355
- async function C(e, t = "json") {
325
+ function O(e) {
326
+ const t = W(), r = new Headers(e);
327
+ r.append("Sinequa-Force-Camel-Case", "true"), r.append("accept", "application/json"), t && r.append("Sinequa-csrf-token", t);
328
+ const { userOverride: n, userOverrideActive: a, bearerToken: o } = u;
329
+ return o && r.append("Authorization", `Bearer ${o}`), n && a && (r.append("sinequa-override-user", n.username), r.append("sinequa-override-domain", n.domain)), r;
330
+ }
331
+ class R extends Error {
332
+ status;
333
+ constructor(t, r) {
334
+ super(t), this.name = "ApiError", this.status = r;
335
+ }
336
+ }
337
+ class E extends R {
338
+ constructor(t = "Server error") {
339
+ super(t, 500), this.name = "ServerError";
340
+ }
341
+ }
342
+ class me extends R {
343
+ constructor(t = "Request timed out") {
344
+ super(t, 408), this.name = "TimeoutError";
345
+ }
346
+ }
347
+ class V extends R {
348
+ constructor(t = "Unauthorized access") {
349
+ super(t, 401), this.name = "UnauthorizedError";
350
+ }
351
+ }
352
+ async function P(e, t = "json") {
356
353
  const r = e.headers.get("sinequa-jwt-refresh");
357
- if (r !== null && $(r), e.status === 200)
354
+ if (r !== null && I(r), e.status === 200)
358
355
  switch (t) {
359
356
  case "arraybuffer":
360
357
  return await e.arrayBuffer();
@@ -366,100 +363,99 @@ async function C(e, t = "json") {
366
363
  return await e.json();
367
364
  }
368
365
  if (e.status === 401) {
369
- if (d.userOverrideActive)
370
- throw P("Unauthorized access attempt with user override", {
366
+ if (u.userOverrideActive)
367
+ throw y("Unauthorized access attempt with user override", {
371
368
  endpoint: e.url
372
369
  }), new V("Unauthorized... User override failed.");
373
- return await q(e, 401);
370
+ return await B(e, 401);
374
371
  }
375
- return e.status === 500 ? (h("Server error occurred", { endpoint: e.url }), await q(e, 500)) : (P(`Unexpected response status: ${e.status}`, {
372
+ return e.status === 500 ? (f("Server error occurred", { endpoint: e.url }), await B(e, 500)) : (y(`Unexpected response status: ${e.status}`, {
376
373
  endpoint: e.url
377
- }), await q(e, e.status));
374
+ }), await B(e, e.status));
378
375
  }
379
- async function q(e, t) {
380
- var r;
376
+ async function B(e, t) {
381
377
  try {
382
- const { done: n, value: a } = await ((r = e.body) == null ? void 0 : r.getReader().read()) || {
378
+ const { done: r, value: n } = await e.body?.getReader().read() || {
383
379
  done: !0,
384
380
  value: void 0
385
381
  };
386
- if (n || !a)
387
- throw t === 401 ? new V() : t === 500 ? new K() : new b(`Request failed with status ${t}`, t);
388
- const s = JSON.parse(new TextDecoder().decode(a));
382
+ if (r || !n)
383
+ throw t === 401 ? new V() : t === 500 ? new E() : new R(`Request failed with status ${t}`, t);
384
+ const a = JSON.parse(new TextDecoder().decode(n));
389
385
  throw new Error(
390
- s.errorMessage || s.message || `Request failed with status ${t}`,
386
+ a.errorMessage || a.message || `Request failed with status ${t}`,
391
387
  {
392
388
  cause: {
393
- errorCode: s.errorCode,
394
- errorCodeTest: s.errorCodeTest
389
+ errorCode: a.errorCode,
390
+ errorCodeTest: a.errorCodeTest
395
391
  }
396
392
  }
397
393
  );
398
- } catch (n) {
399
- throw n instanceof b ? n : t === 401 ? new V(n.message) : t === 500 ? new K(n.message) : new b(
400
- n.message ?? `Request failed with status ${t}`,
394
+ } catch (r) {
395
+ throw r instanceof R ? r : t === 401 ? new V(r.message) : t === 500 ? new E(r.message) : new R(
396
+ r.message ?? `Request failed with status ${t}`,
401
397
  t
402
398
  );
403
399
  }
404
400
  }
405
- async function yt(e, t, r) {
406
- const n = L(r == null ? void 0 : r.headers), { backendUrl: a } = d, s = t ? `?${new URLSearchParams(t)}` : "", i = a ? `${a}/${e}${s}` : `${e}${s}`;
407
- x(`Making DELETE request to: ${i}`);
401
+ async function we(e, t, r) {
402
+ const n = O(r?.headers), { backendUrl: a } = u, o = t ? `?${new URLSearchParams(t)}` : "", s = a ? `${a}/${e}${o}` : `${e}${o}`;
403
+ L(`Making DELETE request to: ${s}`);
408
404
  try {
409
- const o = await fetch(i, {
405
+ const i = await fetch(s, {
410
406
  method: "DELETE",
411
407
  credentials: "include",
412
408
  headers: n
413
409
  });
414
- return C(o, r == null ? void 0 : r.responseType);
415
- } catch (o) {
416
- throw h("Error making DELETE request:", o), o;
410
+ return P(i, r?.responseType);
411
+ } catch (i) {
412
+ throw f("Error making DELETE request:", i), i;
417
413
  }
418
414
  }
419
- async function S(e, t, r) {
420
- const n = L(r == null ? void 0 : r.headers), { backendUrl: a } = d, s = t ? `?${new URLSearchParams(t)}` : "";
415
+ async function w(e, t, r) {
416
+ const n = O(r?.headers), { backendUrl: a } = u, o = t ? `?${new URLSearchParams(t)}` : "";
421
417
  e.startsWith("plugin") && (e = `api/v1/${e}`);
422
- const i = a ? `${a}/${e}${s}` : `${e}${s}`;
423
- x(`Making GET request to: ${i}`);
418
+ const s = a ? `${a}/${e}${o}` : `${e}${o}`;
419
+ L(`Making GET request to: ${s}`);
424
420
  try {
425
- const o = await fetch(i, {
421
+ const i = await fetch(s, {
426
422
  method: "GET",
427
423
  credentials: "include",
428
424
  headers: n,
429
- signal: r == null ? void 0 : r.signal
425
+ signal: r?.signal
430
426
  });
431
- return C(o, r == null ? void 0 : r.responseType);
432
- } catch (o) {
433
- throw h("Error making GET request:", o), o;
427
+ return P(i, r?.responseType);
428
+ } catch (i) {
429
+ throw f("Error making GET request:", i), i;
434
430
  }
435
431
  }
436
- async function be(e, t, r) {
437
- const n = L(r == null ? void 0 : r.headers);
432
+ async function _e(e, t, r) {
433
+ const n = O(r?.headers);
438
434
  n.append("content-type", "application/json");
439
- const { app: a, backendUrl: s } = d, i = {
435
+ const { app: a, backendUrl: o } = u, s = {
440
436
  app: a,
441
437
  ...t,
442
438
  locale: t.locale || navigator.language,
443
439
  noUserOverride: !0,
444
440
  noAutoAuthentication: !0
445
- }, o = s ? `${s}/${e}` : `${e}`;
446
- x(`Making PATCH request to: ${o}`);
441
+ }, i = o ? `${o}/${e}` : `${e}`;
442
+ L(`Making PATCH request to: ${i}`);
447
443
  try {
448
- const c = await fetch(o, {
444
+ const c = await fetch(i, {
449
445
  method: "PATCH",
450
446
  headers: n,
451
447
  credentials: "include",
452
- body: JSON.stringify(i)
448
+ body: JSON.stringify(s)
453
449
  });
454
- return C(c, r == null ? void 0 : r.responseType);
450
+ return P(c, r?.responseType);
455
451
  } catch (c) {
456
- throw h("Error making PATCH request:", c), c;
452
+ throw f("Error making PATCH request:", c), c;
457
453
  }
458
454
  }
459
- async function u(e, t, r) {
460
- const n = L(r == null ? void 0 : r.headers), { app: a, backendUrl: s } = d;
455
+ async function l(e, t, r) {
456
+ const n = O(r?.headers), { app: a, backendUrl: o } = u;
461
457
  n.has("Content-Type") || n.set("Content-Type", "application/json");
462
- const i = {
458
+ const s = {
463
459
  app: a,
464
460
  ...t,
465
461
  locale: t.locale || navigator.language,
@@ -467,200 +463,193 @@ async function u(e, t, r) {
467
463
  noAutoAuthentication: !0
468
464
  };
469
465
  e.startsWith("plugin") && (e = `api/v1/${e}`);
470
- const o = s ? `${s}/${e}` : `${e}`;
471
- x(`Making POST request to: ${o}`);
466
+ const i = o ? `${o}/${e}` : `${e}`;
467
+ L(`Making POST request to: ${i}`);
472
468
  try {
473
- const c = await fetch(o, {
469
+ const c = await fetch(i, {
474
470
  method: "POST",
475
471
  headers: n,
476
472
  credentials: "include",
477
- body: JSON.stringify(i),
478
- signal: r == null ? void 0 : r.signal
473
+ body: JSON.stringify(s),
474
+ signal: r?.signal
479
475
  });
480
- return C(c, r == null ? void 0 : r.responseType);
476
+ return P(c, r?.responseType);
481
477
  } catch (c) {
482
- throw h("Error making POST request:", c), c;
478
+ throw f("Error making POST request:", c), c;
483
479
  }
484
480
  }
485
- async function Ot(e, t, r) {
486
- const n = L(r == null ? void 0 : r.headers), { app: a, backendUrl: s } = d, i = {
481
+ async function Lt(e, t, r) {
482
+ const n = O(r?.headers), { app: a, backendUrl: o } = u, s = {
487
483
  app: a,
488
484
  ...t,
489
485
  locale: t.locale || navigator.language,
490
486
  noUserOverride: !0,
491
487
  noAutoAuthentication: !0
492
- }, o = `${s}/${e}`;
493
- x(`Making PUT request to: ${o}`);
488
+ }, i = `${o}/${e}`;
489
+ L(`Making PUT request to: ${i}`);
494
490
  try {
495
- const c = await fetch(o, {
491
+ const c = await fetch(i, {
496
492
  method: "PUT",
497
493
  headers: n,
498
494
  credentials: "include",
499
- body: JSON.stringify(i)
495
+ body: JSON.stringify(s)
500
496
  });
501
- return C(c, r == null ? void 0 : r.responseType);
497
+ return P(c, r?.responseType);
502
498
  } catch (c) {
503
- throw h("Error making PUT request:", c), c;
499
+ throw f("Error making PUT request:", c), c;
504
500
  }
505
501
  }
506
- function Ut(e) {
502
+ function b(e) {
507
503
  const t = new AbortController(), { signal: r } = t;
508
504
  return e && setTimeout(() => {
509
- r.aborted || t.abort(new de(`Request timed out after ${e}ms`));
505
+ r.aborted || t.abort(new me(`Request timed out after ${e}ms`));
510
506
  }, e), { controller: t, signal: r };
511
507
  }
512
- function se(e) {
508
+ function re(e) {
513
509
  if (!e) return;
514
510
  const t = new Date(e);
515
511
  return Number.isNaN(t.getTime()) ? void 0 : t;
516
512
  }
517
- function $t(e) {
518
- const t = se(e);
513
+ function Ot(e) {
514
+ const t = re(e);
519
515
  return !!t && t.getTime() <= Date.now();
520
516
  }
521
- function It(e, t = 7) {
522
- const r = se(e);
517
+ function $t(e, t = 7) {
518
+ const r = re(e);
523
519
  if (!r) return !1;
524
- const n = Date.now(), a = n + t * 24 * 60 * 60 * 1e3, s = r.getTime();
525
- return s > n && s <= a;
520
+ const n = Date.now(), a = n + t * 24 * 60 * 60 * 1e3, o = r.getTime();
521
+ return o > n && o <= a;
526
522
  }
527
- async function Dt(e, t = 0, r = 1e3) {
523
+ async function Ut(e, t = 0, r = 1e3) {
528
524
  let n;
529
525
  for (let a = 0; a <= t; a++)
530
526
  try {
531
527
  return await e();
532
- } catch (s) {
533
- if (n = s, s instanceof b && s.status >= 400 && s.status < 500 && s.status !== 429 || s instanceof DOMException && s.name === "AbortError")
534
- throw s;
535
- a < t && (P(`Retrying request (${a + 1}/${t})`, { error: s }), await new Promise((i) => setTimeout(i, r)));
528
+ } catch (o) {
529
+ if (n = o, o instanceof R && o.status >= 400 && o.status < 500 && o.status !== 429 || o instanceof DOMException && o.name === "AbortError")
530
+ throw o;
531
+ a < t && (y(`Retrying request (${a + 1}/${t})`, { error: o }), await new Promise((s) => setTimeout(s, r)));
536
532
  }
537
533
  throw n;
538
534
  }
539
- function At(e, t, r) {
540
- var s, i, o, c;
535
+ function Dt(e, t, r) {
541
536
  if (!e || !t) return;
542
537
  if (r) {
543
- const l = Object.keys(t.queries).find((F) => F === (r == null ? void 0 : r.toLowerCase()));
544
- let f;
545
- l && (f = t.queries[l]);
546
- const N = (i = ((s = f == null ? void 0 : f.columnsInfo) == null ? void 0 : s.columns) || []) == null ? void 0 : i.find((F) => {
547
- var X, M;
548
- return (M = (X = F.aliases) == null ? void 0 : X.split(",")) == null ? void 0 : M.includes(e);
549
- });
550
- if (N) return N.name;
538
+ const o = Object.keys(t.queries).find((c) => c === r?.toLowerCase());
539
+ let s;
540
+ o && (s = t.queries[o]);
541
+ const i = (s?.columnsInfo?.columns || [])?.find((c) => c.aliases?.split(",")?.includes(e));
542
+ if (i) return i.name;
551
543
  }
552
- const n = (c = (o = t.indexes) == null ? void 0 : o._) == null ? void 0 : c.columns, a = Object.entries(n).find((l) => {
553
- var f;
554
- return (f = l[1].aliases) == null ? void 0 : f.includes(e);
555
- });
544
+ const n = t.indexes?._?.columns, a = Object.entries(n).find((o) => o[1].aliases?.includes(e));
556
545
  if (a) return a[0];
557
546
  }
558
- var v = /* @__PURE__ */ ((e) => (e.None = "None", e.Search_FirstPage = "Search_FirstPage", e.Search_Text = "Search_Text", e.Search_Refine = "Search_Refine", e.Search_Select_Item = "Search_Select_Item", e.Search_Select_Custom = "Search_Select_Custom", e.Search_Select_Concept = "Search_Select_Concept", e.Search_Select_Correction = "Search_Select_Correction", e.Search_GotoPage = "Search_GotoPage", e.Search_GotoTab = "Search_GotoTab", e.Search_DisplayResult = "Search_DisplayResult", e.Search_RemoveResult = "Search_RemoveResult", e.Search_RemoveAdvanced = "Search_RemoveAdvanced", e.Search_SavedQuery = "Search_SavedQuery", e.Search_WebService = "Search_WebService", e.Search_DidYouMean_Original = "Search_DidYouMean_Original", e.Search_DidYouMean_Correction = "Search_DidYouMean_Correction", e.Search_ExportCSV = "Search_ExportCSV", e.Search_SavedQuery_ExportCSV = "Search_SavedQuery_ExportCSV", e.Search_Selection_ExportCSV = "Search_Selection_ExportCSV", e.Search_AlertQuery = "Search_AlertQuery", e.Search_Select_AnalyticsItem = "Search_Select_AnalyticsItem", e.Search_Sort = "Search_Sort", e.Search_Exit_Logout = "Search_Exit_Logout", e.Search_Timeline_Usage = "Search_Timeline_Usage", e.Search_AutoComplete = "Search_Autocomplete", e.Search_Login_Success = "Login_Success_Form", e.Search_QueryIntent_Detected = "Search_QueryIntent_Detected", e.SavedQuery_Add = "SavedQuery_Add", e.SavedQuery_Delete = "SavedQuery_Delete", e.SavedQuery_DeleteAll = "SavedQuery_DeleteAll", e.SavedQuery_Rename = "SavedQuery_Rename", e.Alert_Edit = "Alert_Edit", e.Alert_Delete = "Alert_Delete", e.Alert_DeleteAll = "Alert_DeleteAll", e.Link_Display = "Link_Display", e.Link_Click = "Link_Click", e.Basket_Add = "Basket_Add", e.Basket_Delete = "Basket_Delete", e.Basket_DeleteAll = "Basket_DeleteAll", e.Basket_Rename = "Basket_Rename", e.Basket_AddDoc = "Basket_AddDoc", e.Basket_RemoveDoc = "Basket_RemoveDoc", e.Basket_Open = "Basket_Open", e.Basket_ExportCSV = "Basket_ExportCSV", e.Label_Add = "Label_Add", e.Label_Delete = "Label_Delete", e.Label_Rename = "Label_Rename", e.Label_Open = "Label_Open", e.Label_AddDoc = "Label_AddDoc", e.Label_RemoveDoc = "Label_RemoveDoc", e.Label_ExportCSV = "Label_ExportCSV", e.Label_Menu_ExportCSV = "Label_Menu_ExportCSV", e.Rating_Set = "Rating_Set", e.Rating_Delete = "Rating_Delete", e.Doc_Preview = "Doc_Preview", e.Doc_CacheHtml = "Doc_CacheHtml", e.Doc_CachePdf = "Doc_CachePdf", e.Doc_CacheOriginal = "Doc_CacheOriginal", e.Doc_Url1 = "Doc_Url1", e.Doc_Url2 = "Doc_Url2", e.Preview_Close = "Preview_Close", e.Click_ResultLink = "Click_ResultLink", e.Click_ResultLink1 = "Click_ResultLink1", e.Click_ResultLink2 = "Click_ResultLink2", e.Click_ResultLink3 = "Click_ResultLink3", e.Click_ResultLink4 = "Click_ResultLink4", e.Click_ResultLink5 = "Click_ResultLink5", e.Click_ResultLink6 = "Click_ResultLink6", e.Click_ResultLink7 = "Click_ResultLink7", e.Click_ResultLink8 = "Click_ResultLink8", e.Click_ResultLink9 = "Click_ResultLink9", e.Click_ResultLink10 = "Click_ResultLink10", e.Click_PreviewLink1 = "Click_PreviewLink1", e.Click_PreviewLink2 = "Click_PreviewLink2", e.Click_PreviewLink3 = "Click_PreviewLink3", e.Click_PreviewLink4 = "Click_PreviewLink4", e.Click_PreviewLink5 = "Click_PreviewLink5", e.Click_PreviewLink6 = "Click_PreviewLink6", e.Click_PreviewLink7 = "Click_PreviewLink7", e.Click_PreviewLink8 = "Click_PreviewLink8", e.Click_PreviewLink9 = "Click_PreviewLink9", e.Click_PreviewLink10 = "Click_PreviewLink10", e.RFM_ClickSet = "RFM_ClickSet", e.RFM_ClickReset = "RFM_ClickReset", e.RFM_Like = "RFM_Like", e.RFM_LikeReset = "RFM_LikeReset", e.RFM_Dislike = "RFM_Dislike", e.RFM_Important = "RFM_Important", e.RFM_ImportantReset = "RFM_ImportantReset", e.RFM_Ban = "RFM_Ban", e.Navigation_Exit = "Navigation_Exit", e.Navigation_Return = "Navigation_Return", e.Navigation_Route = "Navigation_Route", e.Answer_Display = "Answer_Display", e.Answer_Click = "Answer_Click", e.Answer_Result = "Answer_Result", e.Answer_Liked = "Answer_Liked", e.Answer_Disliked = "Answer_Disliked", e.Answer_Liked_Cancelled = "Answer_Liked_Cancelled", e.Answer_Disliked_Cancelled = "Answer_Disliked_Cancelled", e.TopPassages_Display = "TopPassages_Display", e.TopPassages_Click = "TopPassages_Click", e.UserSettings_Reset = "UserSettings_Reset", e))(v || {}), m = /* @__PURE__ */ ((e) => (e[e.none = 0] = "none", e[e.bool = 1] = "bool", e[e.date = 2] = "date", e[e.dateTime = 3] = "dateTime", e[e.time = 4] = "time", e[e.unsigned = 5] = "unsigned", e[e.integer = 6] = "integer", e[e.float = 7] = "float", e[e.double = 8] = "double", e[e.dates = 9] = "dates", e[e.dateTimes = 10] = "dateTimes", e[e.times = 11] = "times", e[e.varchar = 12] = "varchar", e[e.binary = 13] = "binary", e[e.string = 14] = "string", e[e.csv = 15] = "csv", e))(m || {}), g = /* @__PURE__ */ ((e) => (e[e.none = 0] = "none", e[e.a = 2053] = "a", e[e.c = 4] = "c", e[e.d = 8] = "d", e[e.e = 2068] = "e", e[e.i = 256] = "i", e[e.l = 2052] = "l", e[e.n = 8192] = "n", e[e.t = 524292] = "t", e[e.x = 8388608] = "x", e[e.z = 33554432] = "z", e[e.f_ordinal = 8192] = "f_ordinal", e[e.f_multidates = 8192] = "f_multidates", e[e.f_varchar = 33554432] = "f_varchar", e[e.f_binary = 33562624] = "f_binary", e[e.f_string = 33562888] = "f_string", e[e.f_csv = 42477853] = "f_csv", e[e.f_overridable = 33554696] = "f_overridable", e))(g || {});
559
- const Nt = "1.0";
560
- var Ce = /* @__PURE__ */ ((e) => (e[e.Original = 0] = "Original", e[e.Corrected = 1] = "Corrected", e))(Ce || {}), Re = /* @__PURE__ */ ((e) => (e[e.none = 0] = "none", e[e.positiveRate = 1] = "positiveRate", e[e.mainlyPosRate = 2] = "mainlyPosRate", e[e.unrate = 4] = "unrate", e[e.mainlyNegRate = 8] = "mainlyNegRate", e[e.negativeRate = 16] = "negativeRate", e[e.all = 31] = "all", e[e.positiveOnly = 7] = "positiveOnly", e[e.negativeOnly = 28] = "negativeOnly", e[e.personalAll = 21] = "personalAll", e[e.personalPosOnly = 5] = "personalPosOnly", e[e.personalNegOnly = 20] = "personalNegOnly", e))(Re || {});
561
- function xe(e) {
547
+ var C = /* @__PURE__ */ ((e) => (e.None = "None", e.Search_FirstPage = "Search_FirstPage", e.Search_Text = "Search_Text", e.Search_Refine = "Search_Refine", e.Search_Select_Item = "Search_Select_Item", e.Search_Select_Custom = "Search_Select_Custom", e.Search_Select_Concept = "Search_Select_Concept", e.Search_Select_Correction = "Search_Select_Correction", e.Search_GotoPage = "Search_GotoPage", e.Search_GotoTab = "Search_GotoTab", e.Search_DisplayResult = "Search_DisplayResult", e.Search_RemoveResult = "Search_RemoveResult", e.Search_RemoveAdvanced = "Search_RemoveAdvanced", e.Search_SavedQuery = "Search_SavedQuery", e.Search_WebService = "Search_WebService", e.Search_DidYouMean_Original = "Search_DidYouMean_Original", e.Search_DidYouMean_Correction = "Search_DidYouMean_Correction", e.Search_ExportCSV = "Search_ExportCSV", e.Search_SavedQuery_ExportCSV = "Search_SavedQuery_ExportCSV", e.Search_Selection_ExportCSV = "Search_Selection_ExportCSV", e.Search_AlertQuery = "Search_AlertQuery", e.Search_Select_AnalyticsItem = "Search_Select_AnalyticsItem", e.Search_Sort = "Search_Sort", e.Search_Exit_Logout = "Search_Exit_Logout", e.Search_Timeline_Usage = "Search_Timeline_Usage", e.Search_AutoComplete = "Search_Autocomplete", e.Search_Login_Success = "Login_Success_Form", e.Search_QueryIntent_Detected = "Search_QueryIntent_Detected", e.SavedQuery_Add = "SavedQuery_Add", e.SavedQuery_Delete = "SavedQuery_Delete", e.SavedQuery_DeleteAll = "SavedQuery_DeleteAll", e.SavedQuery_Rename = "SavedQuery_Rename", e.Alert_Edit = "Alert_Edit", e.Alert_Delete = "Alert_Delete", e.Alert_DeleteAll = "Alert_DeleteAll", e.Link_Display = "Link_Display", e.Link_Click = "Link_Click", e.Basket_Add = "Basket_Add", e.Basket_Delete = "Basket_Delete", e.Basket_DeleteAll = "Basket_DeleteAll", e.Basket_Rename = "Basket_Rename", e.Basket_AddDoc = "Basket_AddDoc", e.Basket_RemoveDoc = "Basket_RemoveDoc", e.Basket_Open = "Basket_Open", e.Basket_ExportCSV = "Basket_ExportCSV", e.Label_Add = "Label_Add", e.Label_Delete = "Label_Delete", e.Label_Rename = "Label_Rename", e.Label_Open = "Label_Open", e.Label_AddDoc = "Label_AddDoc", e.Label_RemoveDoc = "Label_RemoveDoc", e.Label_ExportCSV = "Label_ExportCSV", e.Label_Menu_ExportCSV = "Label_Menu_ExportCSV", e.Rating_Set = "Rating_Set", e.Rating_Delete = "Rating_Delete", e.Doc_Preview = "Doc_Preview", e.Doc_CacheHtml = "Doc_CacheHtml", e.Doc_CachePdf = "Doc_CachePdf", e.Doc_CacheOriginal = "Doc_CacheOriginal", e.Doc_Url1 = "Doc_Url1", e.Doc_Url2 = "Doc_Url2", e.Preview_Close = "Preview_Close", e.Click_ResultLink = "Click_ResultLink", e.Click_ResultLink1 = "Click_ResultLink1", e.Click_ResultLink2 = "Click_ResultLink2", e.Click_ResultLink3 = "Click_ResultLink3", e.Click_ResultLink4 = "Click_ResultLink4", e.Click_ResultLink5 = "Click_ResultLink5", e.Click_ResultLink6 = "Click_ResultLink6", e.Click_ResultLink7 = "Click_ResultLink7", e.Click_ResultLink8 = "Click_ResultLink8", e.Click_ResultLink9 = "Click_ResultLink9", e.Click_ResultLink10 = "Click_ResultLink10", e.Click_PreviewLink1 = "Click_PreviewLink1", e.Click_PreviewLink2 = "Click_PreviewLink2", e.Click_PreviewLink3 = "Click_PreviewLink3", e.Click_PreviewLink4 = "Click_PreviewLink4", e.Click_PreviewLink5 = "Click_PreviewLink5", e.Click_PreviewLink6 = "Click_PreviewLink6", e.Click_PreviewLink7 = "Click_PreviewLink7", e.Click_PreviewLink8 = "Click_PreviewLink8", e.Click_PreviewLink9 = "Click_PreviewLink9", e.Click_PreviewLink10 = "Click_PreviewLink10", e.RFM_ClickSet = "RFM_ClickSet", e.RFM_ClickReset = "RFM_ClickReset", e.RFM_Like = "RFM_Like", e.RFM_LikeReset = "RFM_LikeReset", e.RFM_Dislike = "RFM_Dislike", e.RFM_Important = "RFM_Important", e.RFM_ImportantReset = "RFM_ImportantReset", e.RFM_Ban = "RFM_Ban", e.Navigation_Exit = "Navigation_Exit", e.Navigation_Return = "Navigation_Return", e.Navigation_Route = "Navigation_Route", e.Answer_Display = "Answer_Display", e.Answer_Click = "Answer_Click", e.Answer_Result = "Answer_Result", e.Answer_Liked = "Answer_Liked", e.Answer_Disliked = "Answer_Disliked", e.Answer_Liked_Cancelled = "Answer_Liked_Cancelled", e.Answer_Disliked_Cancelled = "Answer_Disliked_Cancelled", e.TopPassages_Display = "TopPassages_Display", e.TopPassages_Click = "TopPassages_Click", e.UserSettings_Reset = "UserSettings_Reset", e.Change_Password_Failed = "change.password.failed", e.Change_Password_Success_Form = "change.password.success.form", e.Forgot_Password_Request = "forgot.password.request", e.Login_Denied = "login.denied", e.Login_Success_Form = "login.success.form", e.Send_Reset_Password_Link = "send.reset.password.link", e.Xrest_ChangePassword = "xrest.changepassword", e))(C || {}), h = /* @__PURE__ */ ((e) => (e[e.none = 0] = "none", e[e.bool = 1] = "bool", e[e.date = 2] = "date", e[e.dateTime = 3] = "dateTime", e[e.time = 4] = "time", e[e.unsigned = 5] = "unsigned", e[e.integer = 6] = "integer", e[e.float = 7] = "float", e[e.double = 8] = "double", e[e.dates = 9] = "dates", e[e.dateTimes = 10] = "dateTimes", e[e.times = 11] = "times", e[e.varchar = 12] = "varchar", e[e.binary = 13] = "binary", e[e.string = 14] = "string", e[e.csv = 15] = "csv", e))(h || {}), m = /* @__PURE__ */ ((e) => (e[e.none = 0] = "none", e[e.a = 2053] = "a", e[e.c = 4] = "c", e[e.d = 8] = "d", e[e.e = 2068] = "e", e[e.i = 256] = "i", e[e.l = 2052] = "l", e[e.n = 8192] = "n", e[e.t = 524292] = "t", e[e.x = 8388608] = "x", e[e.z = 33554432] = "z", e[e.f_ordinal = 8192] = "f_ordinal", e[e.f_multidates = 8192] = "f_multidates", e[e.f_varchar = 33554432] = "f_varchar", e[e.f_binary = 33562624] = "f_binary", e[e.f_string = 33562888] = "f_string", e[e.f_csv = 42477853] = "f_csv", e[e.f_overridable = 33554696] = "f_overridable", e))(m || {});
548
+ const It = "1.0";
549
+ var Se = /* @__PURE__ */ ((e) => (e[e.Original = 0] = "Original", e[e.Corrected = 1] = "Corrected", e))(Se || {}), ke = /* @__PURE__ */ ((e) => (e[e.none = 0] = "none", e[e.positiveRate = 1] = "positiveRate", e[e.mainlyPosRate = 2] = "mainlyPosRate", e[e.unrate = 4] = "unrate", e[e.mainlyNegRate = 8] = "mainlyNegRate", e[e.negativeRate = 16] = "negativeRate", e[e.all = 31] = "all", e[e.positiveOnly = 7] = "positiveOnly", e[e.negativeOnly = 28] = "negativeOnly", e[e.personalAll = 21] = "personalAll", e[e.personalPosOnly = 5] = "personalPosOnly", e[e.personalNegOnly = 20] = "personalNegOnly", e))(ke || {});
550
+ function be(e) {
562
551
  if (!e)
563
- return m.none;
552
+ return h.none;
564
553
  switch (e.toLocaleLowerCase()) {
565
554
  case "bool":
566
555
  case "boolean":
567
- return m.bool;
556
+ return h.bool;
568
557
  case "date":
569
- return m.date;
558
+ return h.date;
570
559
  case "datetime":
571
- return m.dateTime;
560
+ return h.dateTime;
572
561
  case "time":
573
- return m.time;
562
+ return h.time;
574
563
  case "unsigned":
575
- return m.unsigned;
564
+ return h.unsigned;
576
565
  case "integer":
577
- return m.integer;
566
+ return h.integer;
578
567
  case "float":
579
- return m.float;
568
+ return h.float;
580
569
  case "double":
581
- return m.double;
570
+ return h.double;
582
571
  case "dates":
583
- return m.dates;
572
+ return h.dates;
584
573
  case "datetimes":
585
- return m.dateTimes;
574
+ return h.dateTimes;
586
575
  case "times":
587
- return m.times;
576
+ return h.times;
588
577
  case "varchar":
589
- return m.varchar;
578
+ return h.varchar;
590
579
  case "binary":
591
- return m.binary;
580
+ return h.binary;
592
581
  case "string":
593
- return m.string;
582
+ return h.string;
594
583
  case "csv":
595
- return m.csv;
584
+ return h.csv;
596
585
  default:
597
- return m.none;
586
+ return h.none;
598
587
  }
599
588
  }
600
- function Pe(e) {
589
+ function ve(e) {
601
590
  switch (e) {
602
591
  case "a":
603
- return g.a;
592
+ return m.a;
604
593
  case "c":
605
- return g.c;
594
+ return m.c;
606
595
  case "d":
607
- return g.d;
596
+ return m.d;
608
597
  case "e":
609
- return g.e;
598
+ return m.e;
610
599
  case "i":
611
- return g.i;
600
+ return m.i;
612
601
  case "l":
613
- return g.l;
602
+ return m.l;
614
603
  case "n":
615
- return g.n;
604
+ return m.n;
616
605
  case "t":
617
- return g.t;
606
+ return m.t;
618
607
  case "x":
619
- return g.x;
608
+ return m.x;
620
609
  case "z":
621
- return g.z;
610
+ return m.z;
622
611
  default:
623
- return g.none;
612
+ return m.none;
624
613
  }
625
614
  }
626
- function Le(e) {
627
- let t = g.none;
615
+ function Ce(e) {
616
+ let t = m.none;
628
617
  if (e)
629
618
  for (const r of e)
630
- t |= Pe(r);
619
+ t |= ve(r);
631
620
  return t;
632
621
  }
633
- function w(e, t, r, n) {
634
- const a = xe(t), s = Le(r || "");
622
+ function p(e, t, r, n) {
623
+ const a = be(t), o = Ce(r || "");
635
624
  return {
636
625
  name: e,
637
626
  type: t,
638
627
  typeModifier: r,
639
628
  eType: a,
640
- eTypeModifier: s,
629
+ eTypeModifier: o,
641
630
  aliases: n
642
631
  };
643
632
  }
644
- const Ft = {
645
- id: w("id", "string"),
646
- text: w("text", "varchar"),
647
- documentlanguages: w("documentlanguages", "csv", "ci", ["language"]),
648
- databasealias: w("databasealias", "varchar"),
649
- globalrelevance: w("globalrelevance", "double"),
650
- matchingpartnames: w("matchingpartnames", "csv"),
651
- matchlocations: w("matchlocations", "csv"),
652
- matchlocationsperpartname: w("matchlocationsperpartname", "varchar"),
633
+ const At = {
634
+ id: p("id", "string"),
635
+ text: p("text", "varchar"),
636
+ documentlanguages: p("documentlanguages", "csv", "ci", ["language"]),
637
+ databasealias: p("databasealias", "varchar"),
638
+ globalrelevance: p("globalrelevance", "double"),
639
+ matchingpartnames: p("matchingpartnames", "csv"),
640
+ matchlocations: p("matchlocations", "csv"),
641
+ matchlocationsperpartname: p("matchlocationsperpartname", "varchar"),
653
642
  // json
654
- extracts: w("extracts", "csv"),
655
- extractsperpartname: w("extractsperpartname", "varchar"),
643
+ extracts: p("extracts", "csv"),
644
+ extractsperpartname: p("extractsperpartname", "varchar"),
656
645
  // json
657
- extractslocations: w("extractslocations", "csv"),
658
- documentweight: w("documentweight", "varchar"),
659
- groupcount: w("groupcount", "integer"),
660
- accesslists: w("accesslists", "varchar", void 0, ["accessLists"])
646
+ extractslocations: p("extractslocations", "csv"),
647
+ documentweight: p("documentweight", "varchar"),
648
+ groupcount: p("groupcount", "integer"),
649
+ accesslists: p("accesslists", "varchar", void 0, ["accessLists"])
661
650
  // json
662
651
  };
663
- function Bt(e, t) {
652
+ function Nt(e, t) {
664
653
  let r = e[t];
665
654
  return r === void 0 ? [] : (typeof r == "string" && (r = String(r).split(",")), Array.isArray(r) ? r.map((n) => {
666
655
  if (typeof n == "string") return n.trim();
@@ -668,7 +657,7 @@ function Bt(e, t) {
668
657
  return n.display.trim();
669
658
  }).filter((n) => n !== void 0) : [String(r).trim()]);
670
659
  }
671
- function qt(e, t) {
660
+ function Ft(e, t) {
672
661
  let r = e[t];
673
662
  if (r === void 0) return [];
674
663
  if (typeof r == "string" && (r = String(r).split(",")), Array.isArray(r))
@@ -676,8 +665,8 @@ function qt(e, t) {
676
665
  if (typeof a == "string")
677
666
  return { display: a.trim(), value: a.trim() };
678
667
  if (typeof a == "object" && a !== null && "display" in a) {
679
- const s = a.display.trim(), i = "value" in a ? String(a.value).trim() : s;
680
- return { display: s, value: i };
668
+ const o = a.display.trim(), s = "value" in a ? String(a.value).trim() : o;
669
+ return { display: o, value: s };
681
670
  }
682
671
  }).filter(
683
672
  (a) => a !== void 0
@@ -685,33 +674,39 @@ function qt(e, t) {
685
674
  const n = String(r).trim();
686
675
  return [{ display: n, value: n }];
687
676
  }
688
- function A(e) {
677
+ function F(e) {
689
678
  return e !== null && typeof e == "object";
690
679
  }
691
- function ye(e) {
692
- return A(e) && Object.prototype.toString.call(e) === "[object ArrayBuffer]";
680
+ function Re(e) {
681
+ return F(e) && Object.prototype.toString.call(e) === "[object ArrayBuffer]";
693
682
  }
694
- function Oe(e) {
695
- return A(e) && Object.prototype.toString.call(e) === "[object Blob]";
683
+ function Pe(e) {
684
+ return F(e) && Object.prototype.toString.call(e) === "[object Blob]";
696
685
  }
697
- function Ue(e) {
686
+ function ye(e) {
687
+ return Object.prototype.toString.call(e) === "[object Date]";
688
+ }
689
+ function xe(e) {
698
690
  return typeof e == "string";
699
691
  }
700
- function Qt(e) {
701
- return (A(e) || Array.isArray(e)) && !ye(e) && !Oe(e) && !Ue(e);
692
+ function qt(e) {
693
+ return (F(e) || Array.isArray(e)) && !Re(e) && !Pe(e) && !xe(e);
694
+ }
695
+ function Le(e) {
696
+ return e ? (e.getHours() * 60 * 60 + e.getMinutes() * 60 + e.getSeconds()) * 1e3 + e.getMilliseconds() : 0;
702
697
  }
703
- function $e(e = !0) {
698
+ function Oe(e = !0) {
704
699
  let t = Date.now();
705
700
  return (e ? "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx" : "xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx").replace(/[xy]/g, (n) => {
706
701
  const a = (t + Math.random() * 16) % 16 | 0;
707
702
  return t = Math.floor(t / 16), (n === "x" ? a : a & 3 | 8).toString(16);
708
703
  });
709
704
  }
710
- function jt(e) {
705
+ function Bt(e) {
711
706
  if (!e)
712
707
  return "``";
713
708
  if (e = String(e), e.search(/[\\`]/) === -1)
714
- return "`" + e + "`";
709
+ return `\`${e}\``;
715
710
  const t = ["`"];
716
711
  for (let r = 0, n = e.length; r < n; r++) {
717
712
  const a = e[r];
@@ -719,34 +714,36 @@ function jt(e) {
719
714
  }
720
715
  return t.push("`"), t.join("");
721
716
  }
722
- function Vt(e) {
717
+ function jt(e) {
723
718
  if (typeof crypto < "u" && crypto.subtle && typeof crypto.subtle.digest == "function")
724
719
  try {
725
- return crypto.subtle.digest("SHA-512", new TextEncoder().encode(e)).then((t) => Array.prototype.map.call(new Uint8Array(t), (r) => ("00" + r.toString(16)).slice(-2)).join("")).catch(() => Promise.resolve(Q(e)));
720
+ return crypto.subtle.digest("SHA-512", new TextEncoder().encode(e)).then(
721
+ (t) => Array.prototype.map.call(new Uint8Array(t), (r) => `00${r.toString(16)}`.slice(-2)).join("")
722
+ ).catch(() => Promise.resolve(j(e)));
726
723
  } catch {
727
- return Promise.resolve(Q(e));
724
+ return Promise.resolve(j(e));
728
725
  }
729
- return Promise.resolve(Q(e));
726
+ return Promise.resolve(j(e));
730
727
  }
731
- function Q(e) {
728
+ function j(e) {
732
729
  let n = 2166136261;
733
- for (let f = 0; f < e.length; f++)
734
- n ^= e.charCodeAt(f), n = n * 16777619 >>> 0;
735
- const a = n.toString(16).padStart(8, "0"), s = ((n ^ 2863311530) >>> 0).toString(16).padStart(8, "0"), i = ((n ^ 1431655765) >>> 0).toString(16).padStart(8, "0"), o = ((n ^ 3435973836) >>> 0).toString(16).padStart(8, "0"), c = a + s + i + o;
730
+ for (let _ = 0; _ < e.length; _++)
731
+ n ^= e.charCodeAt(_), n = n * 16777619 >>> 0;
732
+ const a = n.toString(16).padStart(8, "0"), o = ((n ^ 2863311530) >>> 0).toString(16).padStart(8, "0"), s = ((n ^ 1431655765) >>> 0).toString(16).padStart(8, "0"), i = ((n ^ 3435973836) >>> 0).toString(16).padStart(8, "0"), c = a + o + s + i;
736
733
  return (c + c + c + c).substring(0, 128);
737
734
  }
738
- let j, oe;
739
- function y(e, t = !0) {
740
- let r = Ie(e.$auditRecord);
741
- r && (De(r), t && Ae(r)), e.$auditRecord = r;
735
+ let Q, ne;
736
+ function $(e, t = !0) {
737
+ let r = $e(e.$auditRecord);
738
+ r && (Ue(r), t && De(r)), e.$auditRecord = r;
742
739
  }
743
- function Ie(e) {
740
+ function $e(e) {
744
741
  if (!e)
745
742
  return;
746
743
  let t;
747
744
  if (Array.isArray(e))
748
745
  t = e;
749
- else if (A(e)) {
746
+ else if (F(e)) {
750
747
  const r = e;
751
748
  if (r.auditEvents || r.mlAuditEvents)
752
749
  return r;
@@ -754,57 +751,54 @@ function Ie(e) {
754
751
  }
755
752
  return { auditEvents: t };
756
753
  }
757
- function De(e) {
758
- var r;
759
- const t = Ne();
760
- return (r = e.auditEvents) == null || r.forEach((n) => {
761
- n.detail || (n.detail = {}), n.detail.sessionid = t;
754
+ function Ue(e) {
755
+ const t = Ie();
756
+ return e.auditEvents?.forEach((r) => {
757
+ r.detail || (r.detail = {}), r.detail.sessionid = t;
762
758
  }), e;
763
759
  }
764
- function Ae(e) {
765
- var r;
760
+ function De(e) {
766
761
  const t = typeof window < "u" ? decodeURIComponent(window.location.href) : "http://localhost";
767
- return (r = e == null ? void 0 : e.auditEvents) == null || r.forEach((n) => {
768
- n.detail || (n.detail = {}), n.detail.url = t;
762
+ return e?.auditEvents?.forEach((r) => {
763
+ r.detail || (r.detail = {}), r.detail.url = t;
769
764
  }), e;
770
765
  }
771
- function Ne() {
772
- return (!j || Fe()) && (j = $e()), oe = /* @__PURE__ */ new Date(), j;
766
+ function Ie() {
767
+ return (!Q || Ae()) && (Q = Oe()), ne = /* @__PURE__ */ new Date(), Q;
773
768
  }
774
- function Fe() {
775
- return (/* @__PURE__ */ new Date()).getTime() - oe.getTime() > 10 * 60 * 1e3;
769
+ function Ae() {
770
+ return (/* @__PURE__ */ new Date()).getTime() - ne.getTime() > 600 * 1e3;
776
771
  }
777
- async function Be(e, t = !0) {
772
+ async function Ne(e, t = !0) {
778
773
  const r = {
779
- event: v.None,
774
+ event: C.None,
780
775
  $auditRecord: e
781
776
  };
782
- return y(r, t), u("api/v1/audit.notify", r);
777
+ return $(r, t), l("api/v1/audit.notify", r);
783
778
  }
784
- const Gt = { notify: Be };
785
- async function zt(e, t, r) {
786
- var f;
787
- const n = ((f = e.items) == null ? void 0 : f.length) || 0, a = 10, s = {
779
+ const Qt = { notify: Ne };
780
+ async function Vt(e, t, r) {
781
+ const n = e.items?.length || 0, a = 10, o = {
788
782
  query: { ...t, action: "aggregate", aggregations: { [e.name]: { skip: n, count: a } } },
789
783
  $auditRecord: { auditEvents: [r] }
790
784
  };
791
- y(s);
792
- const i = await u("api/v1/query", s), o = await C(i), { aggregations: c } = o, l = c[0];
793
- return l.$hasMore = l.items.length > a, l.items = [...e.items, ...l.items], Promise.resolve(l);
785
+ $(o);
786
+ const s = await l("api/v1/query", o), i = await P(s), { aggregations: c } = i, d = c[0];
787
+ return d.$hasMore = d.items.length > a, d.items = [...e.items, ...d.items], Promise.resolve(d);
794
788
  }
795
- async function Ht() {
796
- const { app: e } = d, t = new URLSearchParams({ app: e || "" });
797
- return S("api/v1/app", t);
789
+ async function Gt() {
790
+ const { app: e } = u, t = new URLSearchParams({ app: e || "" });
791
+ return w("api/v1/app", t);
798
792
  }
799
- async function qe() {
800
- const { app: e } = d, t = new URLSearchParams({
793
+ async function Fe() {
794
+ const { app: e } = u, t = new URLSearchParams({
801
795
  app: e || "",
802
796
  preLogin: "true"
803
797
  });
804
- return S("api/v1/app", t);
798
+ return w("api/v1/app", t);
805
799
  }
806
- function Jt() {
807
- let { backendUrl: e, app: t, useCredentials: r } = d;
800
+ function zt() {
801
+ let { backendUrl: e, app: t, useCredentials: r } = u;
808
802
  if (typeof window < "u") {
809
803
  if (e || (e = window.location.origin), !t) {
810
804
  const n = window.location.pathname.match(
@@ -813,48 +807,48 @@ function Jt() {
813
807
  n && (t = n[1]);
814
808
  }
815
809
  k({
816
- ...d,
810
+ ...u,
817
811
  backendUrl: e,
818
812
  app: t
819
813
  });
820
814
  }
821
815
  return r ? (k({
822
- ...d,
816
+ ...u,
823
817
  useCredentials: !0,
824
818
  useSSO: !1,
825
819
  autoOAuthProvider: void 0,
826
820
  autoSAMLProvider: void 0,
827
821
  bearerToken: void 0,
828
822
  useSAML: void 0
829
- }), Promise.resolve({})) : qe().then((n) => {
830
- const { autoOAuthProvider: a, autoSAMLProvider: s } = d, i = !a && !n.autoOAuthProvider && !s && !n.autoSAMLProvider;
823
+ }), Promise.resolve({})) : Fe().then((n) => {
824
+ const { autoOAuthProvider: a, autoSAMLProvider: o } = u, s = !a && !n.autoOAuthProvider && !o && !n.autoSAMLProvider;
831
825
  return k({
832
- ...d,
826
+ ...u,
833
827
  autoOAuthProvider: a || n.autoOAuthProvider,
834
- autoSAMLProvider: s || n.autoSAMLProvider,
835
- useCredentials: i,
836
- useSSO: i
828
+ autoSAMLProvider: o || n.autoSAMLProvider,
829
+ useCredentials: s,
830
+ useSSO: s
837
831
  }), n;
838
832
  }).catch((n) => {
839
- throw h("atomic:fetchAppPreLogin error", n), n;
833
+ throw f("atomic:fetchAppPreLogin error", n), n;
840
834
  });
841
835
  }
842
- async function Wt(e, t, r = {}) {
843
- const n = `api/v1/search.dataset/${e}/${t}`, a = await u(n, { parameters: r }), s = t[0].toLowerCase() + t.slice(1), i = a.datasets[s];
844
- if ("errorCode" in i && "errorMessage" in i)
845
- throw new Error(i.errorMessage);
846
- return i;
836
+ async function Ht(e, t, r = {}) {
837
+ const n = `api/v1/search.dataset/${e}/${t}`, a = await l(n, { parameters: r }), o = t[0].toLowerCase() + t.slice(1), s = a.datasets[o];
838
+ if ("errorCode" in s && "errorMessage" in s)
839
+ throw new Error(s.errorMessage);
840
+ return s;
847
841
  }
848
- async function Xt(e, t) {
842
+ async function Jt(e, t) {
849
843
  const r = `api/v1/search.dataset/${e}`, { parameters: n = {}, datasets: a = [] } = t;
850
- return (await u(r, { parameters: n, datasets: a })).datasets;
844
+ return (await l(r, { parameters: n, datasets: a })).datasets;
851
845
  }
852
- async function Mt(e) {
853
- return await S(`api/v1/search.dataset/${e}`);
846
+ async function Wt(e) {
847
+ return await w(`api/v1/search.dataset/${e}`);
854
848
  }
855
- async function Yt(e, t = !0, r) {
849
+ async function Mt(e, t = !0, r) {
856
850
  try {
857
- return (await u("api/v1/labels", {
851
+ return (await l("api/v1/labels", {
858
852
  action: "list",
859
853
  q: e,
860
854
  public: t,
@@ -862,21 +856,21 @@ async function Yt(e, t = !0, r) {
862
856
  localize: !1
863
857
  })).labels;
864
858
  } catch (n) {
865
- throw h("Error in fetchLabels", n), n;
859
+ throw f("Error in fetchLabels", n), n;
866
860
  }
867
861
  }
868
- async function Qe() {
862
+ async function qe() {
869
863
  try {
870
- const { app: e = "" } = d, t = new URLSearchParams({
864
+ const { app: e = "" } = u, t = new URLSearchParams({
871
865
  app: e,
872
866
  action: "getUserRights"
873
867
  });
874
- return S("api/v1/labels", t);
868
+ return w("api/v1/labels", t);
875
869
  } catch (e) {
876
- throw h("Error in getUserRights", e), e;
870
+ throw f("Error in getUserRights", e), e;
877
871
  }
878
872
  }
879
- async function je(e, t, r = !0) {
873
+ async function Be(e, t, r = !0) {
880
874
  try {
881
875
  const n = {
882
876
  action: "add",
@@ -886,7 +880,7 @@ async function je(e, t, r = !0) {
886
880
  $auditRecord: {
887
881
  auditEvents: [
888
882
  {
889
- type: v.Label_AddDoc,
883
+ type: C.Label_AddDoc,
890
884
  detail: {
891
885
  public: r,
892
886
  label: e ? e.toString() : null,
@@ -902,12 +896,12 @@ async function je(e, t, r = !0) {
902
896
  ]
903
897
  }
904
898
  };
905
- return u("api/v1/labels", n);
899
+ return l("api/v1/labels", n);
906
900
  } catch (n) {
907
- throw h("Error in add", n), n;
901
+ throw f("Error in add", n), n;
908
902
  }
909
903
  }
910
- async function Ve(e, t, r = !0) {
904
+ async function je(e, t, r = !0) {
911
905
  try {
912
906
  const n = {
913
907
  action: "remove",
@@ -917,7 +911,7 @@ async function Ve(e, t, r = !0) {
917
911
  $auditRecord: {
918
912
  auditEvents: [
919
913
  {
920
- type: v.Label_RemoveDoc,
914
+ type: C.Label_RemoveDoc,
921
915
  detail: {
922
916
  public: r,
923
917
  label: e ? e.toString() : null,
@@ -933,12 +927,12 @@ async function Ve(e, t, r = !0) {
933
927
  ]
934
928
  }
935
929
  };
936
- return u("api/v1/labels", n);
930
+ return l("api/v1/labels", n);
937
931
  } catch (n) {
938
- throw h("Error in remove", n), n;
932
+ throw f("Error in remove", n), n;
939
933
  }
940
934
  }
941
- async function Ge(e, t, r = !0) {
935
+ async function Qe(e, t, r = !0) {
942
936
  try {
943
937
  const n = {
944
938
  action: "rename",
@@ -946,7 +940,7 @@ async function Ge(e, t, r = !0) {
946
940
  newLabel: t,
947
941
  public: r,
948
942
  auditEvents: {
949
- type: v.Label_Rename,
943
+ type: C.Label_Rename,
950
944
  detail: {
951
945
  public: r,
952
946
  oldlabel: e ? e.toString() : null,
@@ -954,31 +948,31 @@ async function Ge(e, t, r = !0) {
954
948
  }
955
949
  }
956
950
  };
957
- return u("api/v1/labels", n);
951
+ return l("api/v1/labels", n);
958
952
  } catch (n) {
959
- throw h("Error in rename", n), n;
953
+ throw f("Error in rename", n), n;
960
954
  }
961
955
  }
962
- async function ze(e, t = !0) {
956
+ async function Ve(e, t = !0) {
963
957
  try {
964
958
  const r = {
965
959
  action: "delete",
966
960
  labels: e,
967
961
  public: t,
968
962
  auditEvents: {
969
- type: v.Label_Delete,
963
+ type: C.Label_Delete,
970
964
  detail: {
971
965
  public: t,
972
966
  label: e ? e.toString() : null
973
967
  }
974
968
  }
975
969
  };
976
- return u("api/v1/labels", r);
970
+ return l("api/v1/labels", r);
977
971
  } catch (r) {
978
- throw h("Error in deleteLabels", r), r;
972
+ throw f("Error in deleteLabels", r), r;
979
973
  }
980
974
  }
981
- async function He(e, t, r = !0) {
975
+ async function Ge(e, t, r = !0) {
982
976
  try {
983
977
  const n = {
984
978
  action: "bulkAdd",
@@ -986,7 +980,7 @@ async function He(e, t, r = !0) {
986
980
  query: t,
987
981
  public: r,
988
982
  auditEvents: {
989
- type: v.Label_Add,
983
+ type: C.Label_Add,
990
984
  detail: {
991
985
  public: r,
992
986
  label: e ? e.toString() : null,
@@ -994,12 +988,12 @@ async function He(e, t, r = !0) {
994
988
  }
995
989
  }
996
990
  };
997
- return u("api/v1/labels", n);
991
+ return l("api/v1/labels", n);
998
992
  } catch (n) {
999
- throw h("Error in bulkAdd", n), n;
993
+ throw f("Error in bulkAdd", n), n;
1000
994
  }
1001
995
  }
1002
- async function Je(e, t, r = !0) {
996
+ async function ze(e, t, r = !0) {
1003
997
  try {
1004
998
  const n = {
1005
999
  action: "bulkRemove",
@@ -1007,7 +1001,7 @@ async function Je(e, t, r = !0) {
1007
1001
  query: t,
1008
1002
  public: r,
1009
1003
  auditEvents: {
1010
- type: v.Label_Delete,
1004
+ type: C.Label_Delete,
1011
1005
  detail: {
1012
1006
  public: r,
1013
1007
  label: e ? e.toString() : null,
@@ -1015,36 +1009,36 @@ async function Je(e, t, r = !0) {
1015
1009
  }
1016
1010
  }
1017
1011
  };
1018
- return u("api/v1/labels", n);
1012
+ return l("api/v1/labels", n);
1019
1013
  } catch (n) {
1020
- throw h("Error in bulkRemove", n), n;
1014
+ throw f("Error in bulkRemove", n), n;
1021
1015
  }
1022
1016
  }
1023
- const Kt = {
1024
- getUserRights: Qe,
1025
- add: je,
1026
- remove: Ve,
1027
- rename: Ge,
1028
- delete: ze,
1029
- bulkAdd: He,
1030
- bulkRemove: Je
1017
+ const Xt = {
1018
+ getUserRights: qe,
1019
+ add: Be,
1020
+ remove: je,
1021
+ rename: Qe,
1022
+ delete: Ve,
1023
+ bulkAdd: Ge,
1024
+ bulkRemove: ze
1031
1025
  };
1032
- async function Zt(e, t) {
1026
+ async function Yt(e, t) {
1033
1027
  if (typeof window > "u")
1034
- return u("api/v1/preview", {
1028
+ return l("api/v1/preview", {
1035
1029
  action: "get",
1036
1030
  id: e,
1037
1031
  query: t
1038
1032
  });
1039
- const r = `${window.location.origin}${window.location.pathname}`, n = { name: t == null ? void 0 : t.name, text: t == null ? void 0 : t.text };
1040
- return u("api/v1/preview", {
1033
+ const r = `${window.location.origin}${window.location.pathname}`, n = { name: t?.name, text: t?.text };
1034
+ return l("api/v1/preview", {
1041
1035
  action: "get",
1042
1036
  id: e,
1043
1037
  query: n,
1044
1038
  browserUrl: r
1045
1039
  });
1046
1040
  }
1047
- async function Et(e) {
1041
+ async function Kt(e) {
1048
1042
  const t = new Headers();
1049
1043
  t.append("content-type", "text");
1050
1044
  const r = await fetch(
@@ -1054,25 +1048,25 @@ async function Et(e) {
1054
1048
  headers: t
1055
1049
  }
1056
1050
  );
1057
- C(r);
1051
+ P(r);
1058
1052
  }
1059
- async function ce() {
1053
+ async function ae() {
1060
1054
  const e = new URLSearchParams({
1061
1055
  action: "get",
1062
1056
  noAutoAuthentication: "true"
1063
1057
  });
1064
- return S("api/v1/principal", e);
1058
+ return w("api/v1/principal", e);
1065
1059
  }
1066
- async function We(e) {
1060
+ async function He(e) {
1067
1061
  const t = {
1068
1062
  noAutoAuthentication: "true",
1069
1063
  ...e
1070
1064
  }, r = new URLSearchParams();
1071
1065
  return Object.entries(t).forEach(([n, a]) => {
1072
1066
  a !== void 0 && r.append(n, String(a));
1073
- }), S("api/v1/principal/list", r);
1067
+ }), w("api/v1/principal/list", r);
1074
1068
  }
1075
- async function Xe(e) {
1069
+ async function Je(e) {
1076
1070
  if (!e)
1077
1071
  return Promise.reject(new Error("userid is required"));
1078
1072
  const t = new URLSearchParams({
@@ -1080,79 +1074,75 @@ async function Xe(e) {
1080
1074
  noAutoAuthentication: "true",
1081
1075
  userid: e
1082
1076
  });
1083
- return S("api/v1/principal", t);
1077
+ return w("api/v1/principal", t);
1084
1078
  }
1085
- async function Me(e) {
1079
+ async function We(e) {
1086
1080
  if (e.length === 0)
1087
1081
  return Promise.reject(new Error("userids is required"));
1088
1082
  const t = new URLSearchParams({
1089
1083
  noAutoAuthentication: "true",
1090
1084
  userids: [...e].join(",")
1091
1085
  });
1092
- return S("api/v1/principal/userids", t);
1086
+ return w("api/v1/principal/userids", t);
1093
1087
  }
1094
- const Tt = {
1088
+ const Zt = {
1095
1089
  principal: {
1096
- get: ce,
1097
- list: We,
1098
- userid: Xe,
1099
- userids: Me
1090
+ get: ae,
1091
+ list: He,
1092
+ userid: Je,
1093
+ userids: We
1100
1094
  }
1101
- }, ie = 11;
1102
- async function er(e, t, r) {
1103
- var i;
1104
- const a = await u("api/v1/query", {
1095
+ }, oe = 11;
1096
+ async function Et(e, t, r) {
1097
+ const a = await l("api/v1/query", {
1105
1098
  query: e,
1106
1099
  $auditRecord: t,
1107
1100
  queryIntentData: r
1108
1101
  });
1109
- a.aggregations.forEach((o) => {
1110
- o.$hasMore = !1, !o.isDistribution && !o.isTree && o.items && (o.$hasMore = o.items.length === ie), o.isTree && o.items && z(o);
1111
- }), (i = a.records) == null || i.map((o) => Object.assign(o, { value: o.title, type: "default" }));
1112
- const s = { ...a, nextPage: a.page < Math.ceil(a.rowCount / a.pageSize) ? a.page + 1 : void 0, previousPage: a.page > 1 ? a.page - 1 : void 0 };
1113
- return Promise.resolve(s);
1114
- }
1115
- async function tr(e, t, r) {
1116
- const { app: n = "" } = d, a = {
1102
+ a.aggregations.forEach((s) => {
1103
+ s.$hasMore = !1, !s.isDistribution && !s.isTree && s.items && (s.$hasMore = s.items.length === oe), s.isTree && s.items && z(s);
1104
+ }), a.records?.map((s) => Object.assign(s, { value: s.title, type: "default" }));
1105
+ const o = { ...a, nextPage: a.page < Math.ceil(a.rowCount / a.pageSize) ? a.page + 1 : void 0, previousPage: a.page > 1 ? a.page - 1 : void 0 };
1106
+ return Promise.resolve(o);
1107
+ }
1108
+ async function Tt(e, t, r) {
1109
+ const { app: n = "" } = u, a = {
1117
1110
  methods: [],
1118
1111
  mode: t,
1119
1112
  propagateErrors: !0,
1120
1113
  $auditRecord: { auditEvents: [r] }
1121
1114
  };
1122
- for (const o of e)
1115
+ for (const i of e)
1123
1116
  a.methods.push({
1124
1117
  method: "query",
1125
1118
  app: n,
1126
- query: o
1119
+ query: i
1127
1120
  });
1128
- const s = await u("api/v1/multi", a);
1129
- s.results.forEach((o) => {
1130
- o.aggregations.forEach((c) => {
1131
- c.$hasMore = !1, !c.isDistribution && !c.isTree && c.items && (c.$hasMore = c.items.length === ie), c.isTree && z(c);
1121
+ const o = await l("api/v1/multi", a);
1122
+ o.results.forEach((i) => {
1123
+ i.aggregations.forEach((c) => {
1124
+ c.$hasMore = !1, !c.isDistribution && !c.isTree && c.items && (c.$hasMore = c.items.length === oe), c.isTree && z(c);
1132
1125
  });
1133
- }), s.results.forEach((o) => {
1134
- var c;
1135
- return (c = o.records) == null ? void 0 : c.map((l) => Object.assign(l, { value: l.title, type: "default" }));
1136
- });
1137
- const i = s.results.map((o) => ({ ...o, nextPage: o.page < Math.ceil(o.rowCount / o.pageSize) ? o.page + 1 : void 0, previousPage: o.page > 1 ? o.page - 1 : void 0 }));
1138
- return Promise.resolve(i);
1126
+ }), o.results.forEach((i) => i.records?.map((c) => Object.assign(c, { value: c.title, type: "default" })));
1127
+ const s = o.results.map((i) => ({ ...i, nextPage: i.page < Math.ceil(i.rowCount / i.pageSize) ? i.page + 1 : void 0, previousPage: i.page > 1 ? i.page - 1 : void 0 }));
1128
+ return Promise.resolve(s);
1139
1129
  }
1140
1130
  function z(e, t = "", r = 0) {
1141
1131
  let n = [];
1142
1132
  return e.items && e.items.forEach((a) => {
1143
- let s = t ? `${t}/${a.value}` : a.value, i = r + 1;
1144
- n.push({ path: s, level: i }), a.$path = s, a.$level = i, a.hasChildren ? n = n.concat(z(a, s, i)) : a.hasChildren = !1;
1133
+ let o = t ? `${t}/${a.value}` : a.value, s = r + 1;
1134
+ n.push({ path: o, level: s }), a.$path = o, a.$level = s, a.hasChildren ? n = n.concat(z(a, o, s)) : a.hasChildren = !1;
1145
1135
  }), n;
1146
1136
  }
1147
- async function rr({ model: e, appName: t, query: r, article: n }) {
1148
- const { webservice: a, format: s, maxcount: i, exportedColumns: o, export: c } = e, l = {
1137
+ async function er({ model: e, appName: t, query: r, article: n }) {
1138
+ const { webservice: a, format: o, maxcount: s, exportedColumns: i, export: c } = e, d = {
1149
1139
  app: t,
1150
1140
  webservice: a,
1151
1141
  query: r,
1152
1142
  type: c,
1153
- format: s,
1154
- maxcount: i,
1155
- exportedColumns: o,
1143
+ format: o,
1144
+ maxcount: s,
1145
+ exportedColumns: i,
1156
1146
  $auditRecord: {
1157
1147
  auditEvents: [{
1158
1148
  type: "Search_ExportCSV",
@@ -1162,16 +1152,15 @@ async function rr({ model: e, appName: t, query: r, article: n }) {
1162
1152
  }]
1163
1153
  }
1164
1154
  };
1165
- return y(l), await u("api/v1/search.queryexport", l, { responseType: "blob" });
1155
+ return $(d), await l("api/v1/search.queryexport", d, { responseType: "blob" });
1166
1156
  }
1167
- async function nr(e) {
1168
- const r = await u("api/v1/queryintent", {
1157
+ async function tr(e) {
1158
+ return (await l("api/v1/queryintent", {
1169
1159
  query: e
1170
- });
1171
- return r == null ? void 0 : r.intents;
1160
+ }))?.intents;
1172
1161
  }
1173
- async function ar(e, t, r) {
1174
- return (await u(
1162
+ async function rr(e, t, r) {
1163
+ return (await l(
1175
1164
  "api/v1/similardocuments",
1176
1165
  {
1177
1166
  sourceDocumentId: e,
@@ -1182,17 +1171,55 @@ async function ar(e, t, r) {
1182
1171
  { signal: r }
1183
1172
  )).data;
1184
1173
  }
1185
- async function sr(e, t) {
1186
- var a;
1187
- const n = await u("api/v1/query.links", {
1174
+ async function nr(e, t) {
1175
+ return (await l("api/v1/query.links", {
1188
1176
  webservice: e,
1189
1177
  query: t
1190
- });
1191
- return (a = n == null ? void 0 : n.links) == null ? void 0 : a.map((s) => ({ ...s, query: t }));
1178
+ }))?.links?.map((a) => ({ ...a, query: t }));
1179
+ }
1180
+ function Me(e, t) {
1181
+ if (typeof e == "number")
1182
+ return `${e}`;
1183
+ if (ye(e))
1184
+ return Xe(e);
1185
+ if (typeof e == "boolean")
1186
+ return e ? "true" : "false";
1187
+ if (e === null)
1188
+ return "null";
1189
+ if (Array.isArray(e)) {
1190
+ const r = [];
1191
+ return e.forEach((n) => {
1192
+ r.length > 0 && r.push(","), n ? typeof n == "string" ? r.push(n) : r.push(n.display || n.value || "") : r.push("null");
1193
+ }), r.splice(0, 0, "["), r.push("]"), r.join("");
1194
+ }
1195
+ return e;
1196
+ }
1197
+ function Xe(e) {
1198
+ if (!e)
1199
+ return "";
1200
+ try {
1201
+ if (Le(e) === 0)
1202
+ return new Intl.DateTimeFormat("en-CA", {
1203
+ year: "numeric",
1204
+ month: "2-digit",
1205
+ day: "2-digit"
1206
+ }).format(e);
1207
+ {
1208
+ const t = new Intl.DateTimeFormat("en-CA").format(e), r = new Intl.DateTimeFormat("en-CA", {
1209
+ hour: "2-digit",
1210
+ minute: "2-digit",
1211
+ second: "2-digit",
1212
+ hour12: !1
1213
+ }).format(e);
1214
+ return `${t} ${r}`;
1215
+ }
1216
+ } catch {
1217
+ return "Invalid date";
1218
+ }
1192
1219
  }
1193
- async function or(e, t, r, n, a) {
1194
- const { app: s } = d, i = {
1195
- app: s || "",
1220
+ async function ar(e, t, r, n, a) {
1221
+ const { app: o } = u, s = {
1222
+ app: o || "",
1196
1223
  suggestQuery: e,
1197
1224
  text: t,
1198
1225
  filter: r,
@@ -1200,47 +1227,58 @@ async function or(e, t, r, n, a) {
1200
1227
  showSource: a
1201
1228
  };
1202
1229
  try {
1203
- return (await u("api/v1/search.suggest", i)).suggests;
1204
- } catch (o) {
1205
- throw console.error("Error fetching suggestions:", o), o;
1230
+ return (await l(
1231
+ "api/v1/search.suggest",
1232
+ s
1233
+ )).suggests;
1234
+ } catch (i) {
1235
+ throw console.error("Error fetching suggestions:", i), i;
1206
1236
  }
1207
1237
  }
1208
- async function cr(e, t, r, n) {
1209
- const { app: a } = d;
1210
- return (await u("api/v1/suggestquery", {
1211
- app: a || "",
1212
- suggestQuery: e,
1213
- text: t,
1214
- query: r,
1215
- kinds: n
1216
- })).suggests;
1238
+ async function or(e, t, r, n) {
1239
+ const { app: a } = u;
1240
+ return (await l(
1241
+ "api/v1/suggestquery",
1242
+ {
1243
+ app: a || "",
1244
+ suggestQuery: e,
1245
+ text: t,
1246
+ query: r,
1247
+ kinds: n
1248
+ }
1249
+ )).suggests;
1217
1250
  }
1218
- async function ir(e, t) {
1251
+ async function sr(e, t, r) {
1219
1252
  if (!t) return Promise.resolve([]);
1220
- const { app: r } = d;
1221
- return (await u("api/v1/suggestfield", {
1222
- app: r || "",
1223
- text: e,
1224
- action: "suggests",
1225
- fields: t
1226
- })).suggests;
1227
- }
1228
- async function lr(e, t, r, n, a, s) {
1229
- return u("api/v1/doc.textchunks", {
1253
+ const { app: n } = u, o = await l(
1254
+ "api/v1/suggestfield",
1255
+ {
1256
+ app: n || "",
1257
+ text: e,
1258
+ fields: t,
1259
+ query: r
1260
+ }
1261
+ );
1262
+ return o.suggests.forEach((s) => {
1263
+ s.display = Me(s.display);
1264
+ }), o.suggests;
1265
+ }
1266
+ async function ir(e, t, r, n, a, o) {
1267
+ return l("api/v1/doc.textchunks", {
1230
1268
  id: e,
1231
1269
  textChunks: t,
1232
1270
  highlights: r,
1233
1271
  query: n,
1234
1272
  leftSentencesCount: a,
1235
- rightSentencesCount: s
1273
+ rightSentencesCount: o
1236
1274
  });
1237
1275
  }
1238
- async function ur() {
1239
- const { app: e } = d, t = new URLSearchParams({
1276
+ async function cr() {
1277
+ const { app: e } = u, t = new URLSearchParams({
1240
1278
  app: e || "",
1241
1279
  action: "load"
1242
1280
  });
1243
- return S("api/v1/usersettings", t);
1281
+ return w("api/v1/usersettings", t);
1244
1282
  }
1245
1283
  async function Ye(e, t) {
1246
1284
  const r = {
@@ -1248,54 +1286,73 @@ async function Ye(e, t) {
1248
1286
  userSettings: e,
1249
1287
  $auditRecord: { auditEvents: [t] }
1250
1288
  };
1251
- return y(r), u("api/v1/usersettings", r);
1289
+ return $(r), l("api/v1/usersettings", r);
1252
1290
  }
1253
- async function dr(e, t) {
1291
+ async function lr(e, t) {
1254
1292
  const n = {
1255
1293
  action: "patch",
1256
1294
  userSettings: e,
1257
1295
  $auditRecord: t ? { auditEvents: [t] } : void 0
1258
1296
  };
1259
- return y(n), u("api/v1/usersettings", n);
1297
+ return $(n), l("api/v1/usersettings", n);
1260
1298
  }
1261
- async function fr() {
1299
+ async function ur() {
1262
1300
  return Ye({}, { type: "UserSettings_Reset" });
1263
1301
  }
1264
- async function hr(e, t) {
1265
- return u("api/v2/security/password/change", { newPassword: e, currentPassword: t });
1302
+ async function dr(e, t) {
1303
+ return l("api/v2/security/password/change", { newPassword: e, currentPassword: t });
1266
1304
  }
1267
- async function mr(e) {
1305
+ async function fr(e) {
1268
1306
  const t = "api/v2/security/password/ask-reset-email", n = {
1269
1307
  changePasswordRedirectUrl: `${window.location.origin}/login?mode=changepassword`,
1270
1308
  userName: e
1271
1309
  };
1272
- return u(t, n);
1310
+ return l(t, n);
1273
1311
  }
1274
- async function wr(e) {
1275
- return await S(`api/v2/user-profile/${e}`);
1312
+ async function hr(e) {
1313
+ return await w(`api/v2/user-profile/${e}`);
1276
1314
  }
1277
- async function _r(e) {
1278
- return await u("api/v2/user-profile", e);
1315
+ async function gr(e) {
1316
+ return await l("api/v2/user-profile", e);
1279
1317
  }
1280
- async function gr(e, t, r) {
1281
- var a;
1282
- return await be(
1283
- `api/v2/user-profile/${(a = e.data) == null ? void 0 : a.id}/${t}/${r}`,
1318
+ async function pr(e, t, r) {
1319
+ return await _e(
1320
+ `api/v2/user-profile/${e.data?.id}/${t}/${r}`,
1284
1321
  e
1285
1322
  );
1286
1323
  }
1287
- async function Sr() {
1288
- return await S("api/v2/version");
1324
+ async function mr(e, t, r) {
1325
+ try {
1326
+ return (await we(
1327
+ `api/v2/user-profile/${e.data?.id}/${t}/${r}`
1328
+ )).success === !0;
1329
+ } catch {
1330
+ return !1;
1331
+ }
1332
+ }
1333
+ async function wr() {
1334
+ return await w("api/v2/version");
1289
1335
  }
1290
- const Ke = async () => {
1291
- const { autoOAuthProvider: e } = d;
1336
+ const v = 1e4, Ke = async () => {
1337
+ const { autoOAuthProvider: e } = u;
1338
+ if (!e)
1339
+ throw new Error("autoOAuthProvider is not configured in globalConfig");
1292
1340
  if (typeof window > "u")
1293
- return u("security.oauth", {
1294
- action: "getcode",
1295
- provider: e,
1296
- tokenInCookie: !0,
1297
- originalUrl: "http://localhost"
1298
- });
1341
+ try {
1342
+ const { signal: r } = b(v);
1343
+ return await l(
1344
+ "security.oauth",
1345
+ {
1346
+ action: "getcode",
1347
+ provider: e,
1348
+ tokenInCookie: !0,
1349
+ originalUrl: "http://localhost"
1350
+ },
1351
+ { signal: r }
1352
+ );
1353
+ } catch (r) {
1354
+ throw f("Failed to authenticate with OAuth", r), r;
1355
+ }
1299
1356
  const t = {
1300
1357
  action: "getcode",
1301
1358
  provider: e,
@@ -1303,23 +1360,39 @@ const Ke = async () => {
1303
1360
  originalUrl: window.location.href
1304
1361
  };
1305
1362
  try {
1306
- const r = await u(
1363
+ const { signal: r } = b(v), n = await l(
1307
1364
  "api/v1/security.oauth",
1308
- t
1365
+ t,
1366
+ { signal: r }
1309
1367
  );
1310
- return r.redirectUrl && (window.location.href = r.redirectUrl), r;
1368
+ if (n.redirectUrl) {
1369
+ const a = new URL(n.redirectUrl, window.location.origin);
1370
+ (a.protocol === "https:" || a.protocol === "http:") && (window.location.href = a.href);
1371
+ }
1372
+ return n;
1311
1373
  } catch (r) {
1312
- throw console.error("Failed to authenticate with OAuth", r), r;
1374
+ throw f("Failed to authenticate with OAuth", r), r;
1313
1375
  }
1314
1376
  }, Ze = async () => {
1315
- const { autoSAMLProvider: e } = d;
1377
+ const { autoSAMLProvider: e } = u;
1378
+ if (!e)
1379
+ throw new Error("autoSAMLProvider is not configured in globalConfig");
1316
1380
  if (typeof window > "u")
1317
- return u("security.saml", {
1318
- action: "getresponse",
1319
- provider: e,
1320
- tokenInCookie: !0,
1321
- originalUrl: "http://localhost"
1322
- });
1381
+ try {
1382
+ const { signal: r } = b(v);
1383
+ return await l(
1384
+ "security.saml",
1385
+ {
1386
+ action: "getresponse",
1387
+ provider: e,
1388
+ tokenInCookie: !0,
1389
+ originalUrl: "http://localhost"
1390
+ },
1391
+ { signal: r }
1392
+ );
1393
+ } catch (r) {
1394
+ throw f("Failed to authenticate with SAML", r), r;
1395
+ }
1323
1396
  const t = {
1324
1397
  action: "getresponse",
1325
1398
  provider: e,
@@ -1327,13 +1400,18 @@ const Ke = async () => {
1327
1400
  originalUrl: window.location.href
1328
1401
  };
1329
1402
  try {
1330
- const r = await u(
1403
+ const { signal: r } = b(v), n = await l(
1331
1404
  "api/v1/security.saml",
1332
- t
1405
+ t,
1406
+ { signal: r }
1333
1407
  );
1334
- return r.redirectUrl && (window.location.href = r.redirectUrl), r;
1408
+ if (n.redirectUrl) {
1409
+ const a = new URL(n.redirectUrl, window.location.origin);
1410
+ (a.protocol === "https:" || a.protocol === "http:") && (window.location.href = a.href);
1411
+ }
1412
+ return n;
1335
1413
  } catch (r) {
1336
- throw console.error("Failed to authenticate with SAML", r), r;
1414
+ throw f("Failed to authenticate with SAML", r), r;
1337
1415
  }
1338
1416
  }, H = {
1339
1417
  store: {},
@@ -1365,17 +1443,19 @@ function tt(e, t) {
1365
1443
  function rt(e) {
1366
1444
  typeof window > "u" || !window.sessionStorage ? J.removeItem(e) : window.sessionStorage.removeItem(e);
1367
1445
  }
1368
- const $ = (e) => tt(
1446
+ const I = (e) => tt(
1369
1447
  "sinequa-credentials",
1370
1448
  JSON.stringify({ data: { csrfToken: e } })
1371
1449
  ), nt = async () => {
1372
1450
  try {
1373
- const e = await S(
1374
- "api/v1/challenge?action=getCsrfToken&suppressErrors=true"
1451
+ const { signal: e } = b(v), t = await w(
1452
+ "api/v1/challenge?action=getCsrfToken&suppressErrors=true",
1453
+ void 0,
1454
+ { signal: e }
1375
1455
  );
1376
- return e != null && e.csrfToken ? ($(e.csrfToken), e.csrfToken) : null;
1456
+ return t?.csrfToken ? (I(t.csrfToken), t.csrfToken) : null;
1377
1457
  } catch (e) {
1378
- throw h("Failed to get CSRF token", e), e;
1458
+ throw f("Failed to get CSRF token", e), e;
1379
1459
  }
1380
1460
  };
1381
1461
  async function at(e) {
@@ -1389,13 +1469,14 @@ async function at(e) {
1389
1469
  noAutoAuthentication: !0
1390
1470
  };
1391
1471
  try {
1392
- const a = await u(
1472
+ const { signal: a } = b(v), o = await l(
1393
1473
  "api/v1/security.webtoken",
1394
- n
1474
+ n,
1475
+ { signal: a }
1395
1476
  );
1396
- return a != null && a.csrfToken ? ($(a.csrfToken), a.csrfToken) : null;
1477
+ return o?.csrfToken ? (I(o.csrfToken), o.csrfToken) : null;
1397
1478
  } catch (a) {
1398
- throw console.error("Failed to get JWT", a), a;
1479
+ throw f("Failed to get JWT", a), a;
1399
1480
  }
1400
1481
  } else {
1401
1482
  const t = {
@@ -1404,7 +1485,7 @@ async function at(e) {
1404
1485
  noUserOverride: !0,
1405
1486
  noAutoAuthentication: !1
1406
1487
  // Allow auto authentication for credentialless requests
1407
- }, { bearerToken: r } = d;
1488
+ }, { bearerToken: r } = u;
1408
1489
  if (!r)
1409
1490
  throw new Error(
1410
1491
  "Bearer token is required in globalConfig for credentialless JWT retrieval."
@@ -1412,213 +1493,225 @@ async function at(e) {
1412
1493
  const n = new Headers();
1413
1494
  n.append("Sinequa-Force-Camel-Case", "true"), n.append("accept", "application/json"), n.append("Content-Type", "application/json"), n.append("Authorization", `Bearer ${r}`);
1414
1495
  try {
1415
- const a = await u(
1496
+ const { signal: a } = b(v), o = await l(
1416
1497
  "api/v1/security.webtoken",
1417
1498
  t,
1418
- { headers: n }
1499
+ { headers: n, signal: a }
1419
1500
  );
1420
- return a.csrfToken ? ($(a.csrfToken), a.csrfToken) : null;
1501
+ return o?.csrfToken ? (I(o.csrfToken), o.csrfToken) : null;
1421
1502
  } catch (a) {
1422
- throw console.error("Failed to get JWT without credentials", a), a;
1503
+ throw f("Failed to get JWT without credentials", a), a;
1423
1504
  }
1424
1505
  }
1425
1506
  }
1426
1507
  const W = () => {
1427
- var r;
1428
1508
  const e = et("sinequa-credentials");
1429
1509
  if (e)
1430
1510
  try {
1431
- const a = (r = JSON.parse(e).data) == null ? void 0 : r.csrfToken;
1432
- if (a !== void 0) return a;
1433
- } catch {
1511
+ const n = JSON.parse(e).data?.csrfToken;
1512
+ if (n) return n;
1513
+ } catch (r) {
1514
+ y(
1515
+ "Failed to parse session storage credentials, falling back to local storage",
1516
+ r
1517
+ );
1434
1518
  }
1435
1519
  const t = Ee("csrfToken");
1436
- return t !== null ? t : null;
1437
- }, pr = async (e) => {
1520
+ return t || null;
1521
+ }, _r = async (e) => {
1438
1522
  if (e)
1439
- p("Attempting authentication using credentials"), k({ useCredentials: !0, useSSO: !1 });
1523
+ S("Attempting authentication using credentials"), k({ useCredentials: !0, useSSO: !1 });
1440
1524
  else {
1441
- let o = null;
1525
+ let i = null;
1442
1526
  try {
1443
- p("Attempting to retrieve CSRF token from the backend"), o = await nt(), x("CSRF token retrieval result", o ? "success" : "failed");
1444
- } catch (c) {
1445
- h("Failed to retrieve CSRF token", c);
1527
+ S("Attempting to retrieve CSRF token from the backend"), i = await nt(), L("CSRF token retrieval result", i ? "success" : "failed");
1528
+ } catch {
1446
1529
  }
1447
1530
  try {
1448
- if (o === null) {
1449
- const { autoOAuthProvider: c, autoSAMLProvider: l, useSAML: f } = d;
1450
- if (c && !f)
1451
- return p("Initiating OAuth authentication flow"), await Ke(), P("OAuth authentication flow did not redirect as expected"), _(!1), !1;
1452
- if (l)
1453
- return p("Initiating SAML authentication flow"), await Ze(), P("SAML authentication flow did not redirect as expected"), _(!1), !1;
1454
- p(
1531
+ if (i === null) {
1532
+ const { autoOAuthProvider: c, autoSAMLProvider: d, useSAML: _ } = u;
1533
+ if (c && !_)
1534
+ return S("Initiating OAuth authentication flow"), await Ke(), y("OAuth authentication flow did not redirect as expected"), g(!1), !1;
1535
+ if (d)
1536
+ return S("Initiating SAML authentication flow"), await Ze(), y("SAML authentication flow did not redirect as expected"), g(!1), !1;
1537
+ S(
1455
1538
  "No direct authentication method available, will try SSO then credentials"
1456
1539
  ), k({ useCredentials: !0, useSSO: !0 });
1457
1540
  } else
1458
- return p("User authenticated via existing token"), _(!0), !0;
1541
+ return S("User authenticated via existing token"), g(!0), !0;
1459
1542
  } catch (c) {
1460
- throw h("Unexpected error during authentication", c), _(!1), c;
1543
+ throw f("Unexpected error during authentication", c), g(!1), c;
1461
1544
  }
1462
1545
  }
1463
- if (d.useCredentials && d.useSSO)
1546
+ if (u.useCredentials && u.useSSO)
1464
1547
  try {
1465
- if (p("Checking if user is authenticated via SSO"), await ce())
1466
- return p("User authenticated using SSO"), k({ useCredentials: !1, useSSO: !0 }), _(!0), !0;
1467
- } catch (o) {
1468
- if ((o == null ? void 0 : o.status) === 401)
1469
- return p("SSO authentication failed with 401, falling back to credentials"), k({ useCredentials: !0, useSSO: !1 }), !1;
1470
- throw h("SSO authentication failed with unexpected error", o), _(!1), h;
1548
+ if (S("Checking if user is authenticated via SSO"), await ae())
1549
+ return S("User authenticated using SSO"), k({ useCredentials: !1, useSSO: !0 }), g(!0), !0;
1550
+ } catch (i) {
1551
+ if (i?.status === 401)
1552
+ return S("SSO authentication failed with 401, falling back to credentials"), k({ useCredentials: !0, useSSO: !1 }), !1;
1553
+ throw f("SSO authentication failed with unexpected error", i), g(!1), i;
1471
1554
  }
1472
- const { useSSO: r } = d, n = W();
1473
- if (n && n !== null || r)
1474
- return p("user already authenticated", n), k({ isRedirectUrl: !1 }), _(!0), !0;
1475
- const { useCredentials: a } = d, { username: s, password: i } = e || {};
1476
- if (a && !s && !i)
1477
- return h("Credentials are required for authentication"), _(!1), !1;
1478
- if (s && i)
1555
+ const { useSSO: r } = u, n = W();
1556
+ if (n || r)
1557
+ return S("user already authenticated", n), k({ isRedirectUrl: !1 }), g(!0), !0;
1558
+ const { useCredentials: a } = u, { username: o, password: s } = e || {};
1559
+ if (a && (!o || !s))
1560
+ return f("Credentials are required for authentication"), g(!1), !1;
1561
+ if (o && s)
1479
1562
  try {
1480
- p("authentication using credentials..."), k({ useCredentials: !0, useSSO: !1 });
1481
- const { userOverrideActive: o, useroverride: c } = d;
1482
- return k({ userOverrideActive: !1, useroverride: void 0 }), await at({ username: s, password: i }), k({ userOverrideActive: o, useroverride: c }), _(!0), !0;
1483
- } catch (o) {
1484
- throw _(!1), o;
1563
+ S("authentication using credentials..."), k({ useCredentials: !0, useSSO: !1 });
1564
+ const { userOverrideActive: i, useroverride: c } = u;
1565
+ return k({ userOverrideActive: !1, useroverride: void 0 }), await at({ username: o, password: s }), k({ userOverrideActive: i, useroverride: c }), g(!0), !0;
1566
+ } catch (i) {
1567
+ throw g(!1), i;
1485
1568
  }
1486
- return _(!1), h(
1569
+ return g(!1), f(
1487
1570
  "No authentication method available. Please provide credentials or configure OAuth/SAML."
1488
1571
  ), !1;
1489
- }, st = async () => {
1572
+ }, ot = async () => {
1490
1573
  const e = new URLSearchParams({
1491
1574
  action: "deleteWebTokenCookie",
1492
1575
  noUserOverride: "true",
1493
1576
  noAutoAuthentication: "true"
1494
- });
1495
- return S("api/v1/challenge", e);
1496
- }, kr = async () => {
1497
- const { useCredentials: e, userOverrideActive: t } = d;
1498
- Te("csrfToken"), rt("sinequa-credentials"), e && !t ? (await st()).methodresult === "ok" ? _(!1) : console.error("logout failed") : _(!1);
1499
- }, vr = () => !!W();
1577
+ }), { signal: t } = b(v);
1578
+ return w("api/v1/challenge", e, { signal: t });
1579
+ }, Sr = async () => {
1580
+ const { useCredentials: e, userOverrideActive: t } = u;
1581
+ if (Te("csrfToken"), rt("sinequa-credentials"), e && !t)
1582
+ try {
1583
+ (await ot()).methodresult === "ok" || f("logout failed"), g(!1);
1584
+ } catch (r) {
1585
+ f("logout failed", r), g(!1);
1586
+ }
1587
+ else
1588
+ g(!1);
1589
+ }, kr = () => !!W();
1500
1590
  export {
1501
- Tt as API,
1502
- b as ApiError,
1503
- Gt as Audit,
1504
- v as AuditEventType,
1505
- Ce as DidYouMeanKind,
1506
- m as EngineType,
1507
- g as EngineTypeModifier,
1508
- ae as LogLevel,
1509
- Nt as MINIMUM_COMPATIBLE_SERVER_API_VERSION,
1510
- Re as RFMDisplay,
1511
- K as ServerError,
1512
- de as TimeoutError,
1591
+ Zt as API,
1592
+ R as ApiError,
1593
+ Qt as Audit,
1594
+ C as AuditEventType,
1595
+ Se as DidYouMeanKind,
1596
+ h as EngineType,
1597
+ m as EngineTypeModifier,
1598
+ te as LogLevel,
1599
+ It as MINIMUM_COMPATIBLE_SERVER_API_VERSION,
1600
+ ke as RFMDisplay,
1601
+ E as ServerError,
1602
+ me as TimeoutError,
1513
1603
  V as UnauthorizedError,
1514
- y as addAuditAdditionalInfo,
1604
+ $ as addAuditAdditionalInfo,
1515
1605
  dt as addConcepts,
1516
- De as addSessionId,
1517
- Ae as addUrl,
1518
- fe as aggItemRegex,
1519
- it as aggregationItemStrictCompare,
1520
- Jt as appInitializerFn,
1606
+ Ue as addSessionId,
1607
+ De as addUrl,
1608
+ se as aggItemRegex,
1609
+ ct as aggregationItemStrictCompare,
1610
+ zt as appInitializerFn,
1521
1611
  ut as bisect,
1522
1612
  z as buildPathsAndLevels,
1523
- Lt as configureLogger,
1524
- L as createHeaders,
1525
- Ut as createTimeoutController,
1526
- _r as createUserProfile,
1527
- x as debug,
1528
- yt as del,
1529
- fr as deleteUserSettings,
1530
- st as deleteWebTokenCookie,
1531
- _ as emitAuthenticatedEvent,
1532
- h as error,
1533
- jt as escapeExpr,
1534
- It as expiresSoon,
1535
- Ft as extraColumns,
1536
- zt as fetchAggregation,
1537
- Ht as fetchApp,
1538
- qe as fetchAppPreLogin,
1539
- tr as fetchBulkQuery,
1540
- hr as fetchChangePassword,
1541
- Wt as fetchDataset,
1542
- Mt as fetchDatasetList,
1543
- Xt as fetchDatasets,
1544
- Yt as fetchLabels,
1545
- Zt as fetchPreview,
1546
- Et as fetchPreviewUrl,
1547
- ce as fetchPrincipal,
1548
- We as fetchPrincipalList,
1549
- Xe as fetchPrincipalUserid,
1550
- Me as fetchPrincipalUserids,
1551
- er as fetchQuery,
1552
- rr as fetchQueryExport,
1553
- nr as fetchQueryIntent,
1554
- mr as fetchSendPasswordResetEmail,
1555
- ar as fetchSimilarDocuments,
1556
- sr as fetchSponsoredLinks,
1557
- or as fetchSuggest,
1558
- ir as fetchSuggestField,
1559
- cr as fetchSuggestQuery,
1560
- lr as fetchTextChunks,
1561
- wr as fetchUserProfile,
1562
- ur as fetchUserSettings,
1563
- Sr as fetchVersion,
1564
- S as get,
1565
- mt as getConcepts,
1613
+ xt as configureLogger,
1614
+ O as createHeaders,
1615
+ b as createTimeoutController,
1616
+ gr as createUserProfile,
1617
+ L as debug,
1618
+ we as del,
1619
+ mr as deleteUserProfileProperty,
1620
+ ur as deleteUserSettings,
1621
+ ot as deleteWebTokenCookie,
1622
+ g as emitAuthenticatedEvent,
1623
+ f as error,
1624
+ Bt as escapeExpr,
1625
+ $t as expiresSoon,
1626
+ At as extraColumns,
1627
+ Vt as fetchAggregation,
1628
+ Gt as fetchApp,
1629
+ Fe as fetchAppPreLogin,
1630
+ Tt as fetchBulkQuery,
1631
+ dr as fetchChangePassword,
1632
+ Ht as fetchDataset,
1633
+ Wt as fetchDatasetList,
1634
+ Jt as fetchDatasets,
1635
+ Mt as fetchLabels,
1636
+ Yt as fetchPreview,
1637
+ Kt as fetchPreviewUrl,
1638
+ ae as fetchPrincipal,
1639
+ He as fetchPrincipalList,
1640
+ Je as fetchPrincipalUserid,
1641
+ We as fetchPrincipalUserids,
1642
+ Et as fetchQuery,
1643
+ er as fetchQueryExport,
1644
+ tr as fetchQueryIntent,
1645
+ fr as fetchSendPasswordResetEmail,
1646
+ rr as fetchSimilarDocuments,
1647
+ nr as fetchSponsoredLinks,
1648
+ ar as fetchSuggest,
1649
+ sr as fetchSuggestField,
1650
+ or as fetchSuggestQuery,
1651
+ ir as fetchTextChunks,
1652
+ hr as fetchUserProfile,
1653
+ cr as fetchUserSettings,
1654
+ wr as fetchVersion,
1655
+ w as get,
1656
+ gt as getConcepts,
1566
1657
  nt as getCsrfToken,
1567
- ne as getFiltersFromURI,
1568
- pt as getFiltersFromUrl,
1569
- xt as getHelpIndexUrl,
1570
- vt as getIdFromUrl,
1658
+ ee as getFiltersFromURI,
1659
+ St as getFiltersFromUrl,
1660
+ Pt as getHelpIndexUrl,
1661
+ bt as getIdFromUrl,
1571
1662
  at as getJWToken,
1572
- Bt as getMetadata,
1573
- qt as getMetadataWithValues,
1574
- ve as getOffsetFromDates,
1575
- bt as getQueryPageFromUrl,
1576
- gt as getQueryParamsFromUrl,
1663
+ Nt as getMetadata,
1664
+ Ft as getMetadataWithValues,
1665
+ pe as getOffsetFromDates,
1666
+ vt as getQueryPageFromUrl,
1667
+ wt as getQueryParamsFromUrl,
1577
1668
  Ct as getQueryTabFromUrl,
1578
1669
  kt as getQueryTextFromUrl,
1579
- wt as getRelativeDate,
1670
+ pt as getRelativeDate,
1671
+ Le as getTime,
1580
1672
  W as getToken,
1581
- St as getUrlParamsFromQueryParams,
1582
- d as globalConfig,
1583
- $e as guid,
1584
- C as handleResponse,
1585
- p as info,
1586
- ye as isArrayBuffer,
1587
- vr as isAuthenticated,
1588
- Oe as isBlob,
1589
- $t as isExpired,
1590
- Qt as isJsonable,
1591
- _t as isNotInputEvent,
1592
- A as isObject,
1593
- Ue as isString,
1594
- Kt as labels,
1595
- pr as login,
1596
- kr as logout,
1597
- w as makeColumn,
1598
- Pt as notify,
1599
- me as openParentNodes,
1600
- I as parseText,
1601
- he as parseValueAndOperatorFromItem,
1602
- be as patch,
1603
- gr as patchUserProfile,
1604
- dr as patchUserSettings,
1605
- u as post,
1606
- Ot as put,
1607
- R as queryParamsFromUrl,
1673
+ _t as getUrlParamsFromQueryParams,
1674
+ u as globalConfig,
1675
+ Oe as guid,
1676
+ P as handleResponse,
1677
+ S as info,
1678
+ Re as isArrayBuffer,
1679
+ kr as isAuthenticated,
1680
+ Pe as isBlob,
1681
+ ye as isDate,
1682
+ Ot as isExpired,
1683
+ qt as isJsonable,
1684
+ mt as isNotInputEvent,
1685
+ F as isObject,
1686
+ xe as isString,
1687
+ Xt as labels,
1688
+ _r as login,
1689
+ Sr as logout,
1690
+ p as makeColumn,
1691
+ yt as notify,
1692
+ ce as openParentNodes,
1693
+ A as parseText,
1694
+ ie as parseValueAndOperatorFromItem,
1695
+ _e as patch,
1696
+ pr as patchUserProfile,
1697
+ lr as patchUserSettings,
1698
+ l as post,
1699
+ Lt as put,
1700
+ x as queryParamsFromUrl,
1608
1701
  ft as removeConcept,
1609
1702
  ht as removeConcepts,
1610
- At as resolveToColumnName,
1703
+ Dt as resolveToColumnName,
1611
1704
  G as rewriteText,
1612
1705
  Ye as saveUserSettings,
1613
1706
  k as setGlobalConfig,
1614
- $ as setToken,
1615
- Vt as sha512,
1707
+ I as setToken,
1708
+ jt as sha512,
1616
1709
  lt as suggestionsToTreeAggregationNodes,
1617
1710
  Rt as sysLang,
1618
- se as toDate,
1619
- ct as translateAggregationToDateOptions,
1711
+ re as toDate,
1712
+ it as translateAggregationToDateOptions,
1620
1713
  Ke as tryOAuthAuthentication,
1621
1714
  Ze as trySAMLAuthentication,
1622
- P as warn,
1623
- Dt as withRetry
1715
+ y as warn,
1716
+ Ut as withRetry
1624
1717
  };