@sinequa/atomic 0.0.100 → 0.0.108

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/atomic.js CHANGED
@@ -1,15 +1,48 @@
1
- var T = Object.defineProperty;
2
- var ee = (e, t, r) => t in e ? T(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var G = (e, t, r) => ee(e, typeof t != "symbol" ? t + "" : t, r);
4
- const u = { apiPath: "api/v1", loginPath: "/login", backendUrl: window.location.origin };
5
- function m(e) {
1
+ var oe = Object.defineProperty;
2
+ var se = (e, t, r) => t in e ? oe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var H = (e, t, r) => se(e, typeof t != "symbol" ? t + "" : t, r);
4
+ const u = { apiPath: "api/v1", loginPath: "/login", backendUrl: typeof window < "u" ? window.location.origin : "http://localhost", createRoutes: !1 };
5
+ function S(e) {
6
6
  Object.assign(u, e);
7
7
  }
8
- function je(e, t) {
9
- var n;
10
- return !(e != null && e.items) || ((n = e == null ? void 0 : e.items) == null ? void 0 : n.length) === 0 ? [] : e.items.reduce((o, s) => {
8
+ const y = {
9
+ store: {},
10
+ getItem(e) {
11
+ return this.store[e] ?? null;
12
+ },
13
+ setItem(e, t) {
14
+ this.store[e] = t.toString();
15
+ },
16
+ removeItem(e) {
17
+ delete this.store[e];
18
+ },
19
+ clear() {
20
+ this.store = {};
21
+ }
22
+ }, Q = y;
23
+ function F(e) {
24
+ return typeof window > "u" || !window.localStorage ? y.getItem(e) : window.localStorage.getItem(e);
25
+ }
26
+ function E(e, t) {
27
+ typeof window > "u" || !window.localStorage ? y.setItem(e, t) : window.localStorage.setItem(e, t);
28
+ }
29
+ function x(e) {
30
+ typeof window > "u" || !window.localStorage ? y.removeItem(e) : window.localStorage.removeItem(e);
31
+ }
32
+ function ce(e) {
33
+ return typeof window > "u" || !window.sessionStorage ? Q.getItem(e) : window.sessionStorage.getItem(e);
34
+ }
35
+ function ie(e, t) {
36
+ typeof window > "u" || !window.sessionStorage ? Q.setItem(e, t) : window.sessionStorage.setItem(e, t);
37
+ }
38
+ function le(e) {
39
+ typeof window > "u" || !window.sessionStorage ? Q.removeItem(e) : window.sessionStorage.removeItem(e);
40
+ }
41
+ function Ze(e, t) {
42
+ var a;
43
+ return !(e != null && e.items) || ((a = e == null ? void 0 : e.items) == null ? void 0 : a.length) === 0 ? [] : e.items.reduce((o, s) => {
11
44
  if (!s.value || s.value === "") return o;
12
- const c = te(s, e.column);
45
+ const c = ue(s, e.column);
13
46
  return o.push({
14
47
  operator: c.operator,
15
48
  value: c.value,
@@ -20,10 +53,10 @@ function je(e, t) {
20
53
  }), o;
21
54
  }, []);
22
55
  }
23
- function te(e, t) {
24
- const r = t, a = e.value.match(/.*\:\(?([><=\d\-\.AND ]+)\)?/);
25
- if (a != null && a[1]) {
26
- const o = (a == null ? void 0 : a[1].split(" AND ")).map((s) => {
56
+ function ue(e, t) {
57
+ const r = t, n = e.value.match(/.*\:\(?([><=\d\-\.AND ]+)\)?/);
58
+ if (n != null && n[1]) {
59
+ const o = (n == null ? void 0 : n[1].split(" AND ")).map((s) => {
27
60
  const c = s.indexOf(">=") !== -1 ? "gte" : "lt";
28
61
  let i = s.substring(s.indexOf(" ") + 1);
29
62
  return { field: r, operator: c, value: i, display: e.display || e.value };
@@ -36,51 +69,51 @@ function te(e, t) {
36
69
  }
37
70
  return { field: r, operator: "eq", value: e.value, display: e.display };
38
71
  }
39
- function Ve(e, t, r) {
72
+ function Me(e, t, r) {
40
73
  return e.valuesAreExpressions ? t.display === r.display : t.value === r.value;
41
74
  }
42
- function ze(e, t) {
75
+ function Ee(e, t) {
43
76
  const r = [];
44
77
  if (e.length > 0) {
45
- const a = /* @__PURE__ */ new Map(), n = t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), o = new RegExp("\\b" + n, "i");
78
+ const n = /* @__PURE__ */ new Map(), a = t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), o = new RegExp("\\b" + a, "i");
46
79
  e.forEach((s) => {
47
80
  if (s.display.length > 1) {
48
81
  const c = o.exec(s.display);
49
- X(r, a, "/", s.display, +(s.frequency || 0), 1, ((c == null ? void 0 : c.index) || 0) + t.length);
82
+ T(r, n, "/", s.display, +(s.frequency || 0), 1, ((c == null ? void 0 : c.index) || 0) + t.length);
50
83
  }
51
84
  });
52
85
  }
53
86
  return r;
54
87
  }
55
- function X(e, t, r, a, n, o, s) {
56
- const c = a.indexOf("/", r.length), i = a.substring(0, c + 1);
88
+ function T(e, t, r, n, a, o, s) {
89
+ const c = n.indexOf("/", r.length), i = n.substring(0, c + 1);
57
90
  let l = t.get(i);
58
91
  if (!l) {
59
- const f = i.replace(/^\/|\/$/g, "");
92
+ const h = i.replace(/^\/|\/$/g, "");
60
93
  l = {
61
- value: a.substring(r.length, c),
62
- count: n,
94
+ value: n.substring(r.length, c),
95
+ count: a,
63
96
  items: [],
64
97
  hasChildren: !1,
65
98
  $level: o,
66
99
  $opened: s >= i.length,
67
- $path: f
100
+ $path: h
68
101
  }, t.set(i, l), e.push(l);
69
102
  }
70
- i.length < a.length && (l.hasChildren = !0, X(l.items, t, i, a, n, o + 1, s));
103
+ i.length < n.length && (l.hasChildren = !0, T(l.items, t, i, n, a, o + 1, s));
71
104
  }
72
- function Je(e, t) {
73
- return e.reduce((r, a) => (t(a) ? r.true.push(a) : r.false.push(a), r), { true: [], false: [] });
105
+ function Te(e, t) {
106
+ return e.reduce((r, n) => (t(n) ? r.true.push(n) : r.false.push(n), r), { true: [], false: [] });
74
107
  }
75
- const re = /(([\+\-])?\(([^\)]+)\))|(([\+\-])?\[([^\]]+)\])|(([\+\-])?\"([^\"]+)\")|(([\+\-])?\/([^\/]+)\/)|(([\+\-])?(\S+))/g, ae = 2, j = 3, ne = 5, V = 6, oe = 8, z = 9, se = 11, J = 12, ce = 14, H = 15;
76
- function U(e) {
108
+ const de = /(([\+\-])?\(([^\)]+)\))|(([\+\-])?\[([^\]]+)\])|(([\+\-])?\"([^\"]+)\")|(([\+\-])?\/([^\/]+)\/)|(([\+\-])?(\S+))/g, fe = 2, W = 3, he = 5, X = 6, _e = 8, Y = 9, we = 11, K = 12, Se = 14, Z = 15;
109
+ function I(e) {
77
110
  if (!e) return [];
78
- const t = [], r = e.matchAll(re);
79
- for (let a of r)
80
- a[j] ? t.push({ type: "group", value: a[j], op: a[ae] }) : a[V] ? t.push({ type: "adjacent", value: a[V], op: a[ne] }) : a[z] ? t.push({ type: "exact", value: a[z], op: a[oe] }) : a[J] ? t.push({ type: "regex", value: a[J], op: a[se] }) : a[H] && t.push({ type: "token", value: a[H], op: a[ce] });
111
+ const t = [], r = e.matchAll(de);
112
+ for (let n of r)
113
+ n[W] ? t.push({ type: "group", value: n[W], op: n[fe] }) : n[X] ? t.push({ type: "adjacent", value: n[X], op: n[he] }) : n[Y] ? t.push({ type: "exact", value: n[Y], op: n[_e] }) : n[K] ? t.push({ type: "regex", value: n[K], op: n[we] }) : n[Z] && t.push({ type: "token", value: n[Z], op: n[Se] });
81
114
  return t;
82
115
  }
83
- function N(e) {
116
+ function G(e) {
84
117
  return e.map((t) => {
85
118
  const r = t.op || "";
86
119
  switch (t.type) {
@@ -97,59 +130,66 @@ function N(e) {
97
130
  }
98
131
  }).join(" ");
99
132
  }
100
- function He(e, t, r) {
101
- let a = U(e);
102
- for (let n of t)
103
- a.push({ type: "adjacent", value: n, op: r });
104
- return N(a);
133
+ function et(e, t, r) {
134
+ let n = I(e);
135
+ for (let a of t)
136
+ n.push({ type: "adjacent", value: a, op: r });
137
+ return G(n);
105
138
  }
106
- function We(e, t) {
107
- const r = U(t), a = r.findIndex((n) => n.value === e);
108
- return a !== -1 ? (r.splice(a, 1), t = N(r)) : t;
139
+ function tt(e, t) {
140
+ const r = I(t), n = r.findIndex((a) => a.value === e);
141
+ return n !== -1 ? (r.splice(n, 1), t = G(r)) : t;
109
142
  }
110
- function Xe(e) {
111
- const t = U(e).filter((r) => r.type !== "adjacent");
112
- return N(t);
143
+ function rt(e) {
144
+ const t = I(e).filter((r) => r.type !== "adjacent");
145
+ return G(t);
113
146
  }
114
- function Ye(e) {
115
- return U(e).filter((t) => t.type === "adjacent").map((t) => t.value);
147
+ function nt(e) {
148
+ return I(e).filter((t) => t.type === "adjacent").map((t) => t.value);
116
149
  }
117
- function Ke(e, t, r) {
118
- const a = new Intl.RelativeTimeFormat(e, { numeric: "auto" }), { offset: n, unit: o, isFuture: s } = ie(t, r);
119
- return a.format(n * (s ? 1 : -1), o);
150
+ function at(e, t, r) {
151
+ const n = new Intl.RelativeTimeFormat(e, { numeric: "auto" }), { offset: a, unit: o, isFuture: s } = me(t, r);
152
+ return n.format(a * (s ? 1 : -1), o);
120
153
  }
121
- function ie(e, t) {
122
- const r = new Date(e), a = t ? new Date(t) : /* @__PURE__ */ new Date(), n = Math.abs(a.getTime() - r.getTime());
154
+ function me(e, t) {
155
+ const r = new Date(e), n = t ? new Date(t) : /* @__PURE__ */ new Date(), a = Math.abs(n.getTime() - r.getTime());
123
156
  return {
124
- offset: Math.floor(n / (1e3 * 60 * 60 * 24)),
157
+ offset: Math.floor(a / (1e3 * 60 * 60 * 24)),
125
158
  unit: "day",
126
- isFuture: r > a
159
+ isFuture: r > n
127
160
  };
128
161
  }
129
- function Ze(e) {
162
+ function ot(e) {
130
163
  const t = e.target;
131
164
  return t && t.nodeName !== "INPUT" && t.nodeName !== "TEXTAREA";
132
165
  }
133
- function Me(e) {
166
+ function st(e) {
134
167
  if (e === void 0) return;
135
- const { q: t, f: r, p: a, s: n, t: o, n: s, b: c } = R(e), [i] = e.split("?");
168
+ const { q: t, f: r, p: n, s: a, t: o, n: s, b: c } = R(e), [i] = e.split("?");
136
169
  return {
137
170
  path: i,
138
171
  text: t,
139
- filters: r ? Y(r) : void 0,
140
- page: a ? parseInt(a, 10) : void 0,
141
- sort: n,
172
+ filters: r ? ee(r) : void 0,
173
+ page: n ? parseInt(n, 10) : void 0,
174
+ sort: a,
142
175
  tab: o,
143
176
  name: s,
144
177
  basket: c
145
178
  };
146
179
  }
147
- function Ee(e) {
180
+ function ct(e) {
181
+ if (!e) return "";
182
+ const { text: t, filters: r, page: n, sort: a, tab: o, name: s, basket: c } = e, i = {};
183
+ t && (i.q = t), r && (i.f = JSON.stringify(r)), n && (i.p = n.toString()), a && (i.s = a), o && (i.t = o), s && (i.n = s), c && (i.b = c);
184
+ const l = new URLSearchParams(i).toString();
185
+ return l || "";
186
+ }
187
+ function it(e) {
148
188
  if (e === void 0) return [];
149
189
  const { f: t } = R(e);
150
- return Y(t);
190
+ return ee(t);
151
191
  }
152
- function Y(e) {
192
+ function ee(e) {
153
193
  const t = decodeURIComponent(e);
154
194
  try {
155
195
  return JSON.parse(t ?? "[]");
@@ -163,55 +203,55 @@ function R(e) {
163
203
  const r = new URLSearchParams(t);
164
204
  return Object.fromEntries(r);
165
205
  }
166
- function Te(e) {
206
+ function lt(e) {
167
207
  const { q: t = "" } = R(e);
168
208
  return t;
169
209
  }
170
- function et(e) {
210
+ function ut(e) {
171
211
  const { id: t } = R(e);
172
212
  return decodeURIComponent(t);
173
213
  }
174
- function tt(e) {
214
+ function dt(e) {
175
215
  const { p: t = "0" } = R(e);
176
216
  return parseInt(t, 10);
177
217
  }
178
- function rt(e) {
218
+ function ft(e) {
179
219
  const { t } = R(e);
180
220
  return t;
181
221
  }
182
- function at(e, t) {
222
+ function ht(e, t) {
183
223
  if (!e)
184
224
  return e;
185
225
  let r = 0;
186
- const a = e.length;
187
- let n = 0;
188
- if (e[n] === "[") {
189
- for (; n < a && /[0-9]/.test(e[n]); )
190
- n++;
191
- e[n] === "]" && (r = n + 1);
226
+ const n = e.length;
227
+ let a = 0;
228
+ if (e[a] === "[") {
229
+ for (; a < n && /[0-9]/.test(e[a]); )
230
+ a++;
231
+ e[a] === "]" && (r = a + 1);
192
232
  }
193
- const o = y(e, r, !1);
233
+ const o = B(e, r, !1);
194
234
  if (!o)
195
235
  return e;
196
236
  const s = t.charCodeAt(0), c = t.charCodeAt(1);
197
237
  let i = o;
198
238
  for (; i; )
199
239
  if (s === i.lang1 && c === i.lang2) {
200
- const f = y(e, i.end + 4, !0);
201
- return e.substring(f.start, f.end);
240
+ const h = B(e, i.end + 4, !0);
241
+ return e.substring(h.start, h.end);
202
242
  } else
203
- i = y(e, i.end + 4, !1);
243
+ i = B(e, i.end + 4, !1);
204
244
  const l = e.substring(o.start, o.end);
205
245
  return l || e;
206
246
  }
207
- function y(e, t, r) {
208
- for (let a = t, n = e.length - 3; a < n; a++)
209
- if (e[a] === "[" && e[a + 3] === "]")
247
+ function B(e, t, r) {
248
+ for (let n = t, a = e.length - 3; n < a; n++)
249
+ if (e[n] === "[" && e[n + 3] === "]")
210
250
  return {
211
251
  start: t,
212
- end: a,
213
- lang1: e.charCodeAt(a + 1),
214
- lang2: e.charCodeAt(a + 2)
252
+ end: n,
253
+ lang1: e.charCodeAt(n + 1),
254
+ lang2: e.charCodeAt(n + 2)
215
255
  };
216
256
  if (r)
217
257
  return {
@@ -221,22 +261,60 @@ function y(e, t, r) {
221
261
  lang2: -1
222
262
  };
223
263
  }
224
- function nt(e, t) {
225
- const { useLocale: r, useLocaleAsPrefix: a, indexFile: n, path: o, folder: s } = t, c = r ? `${e}/` : null, i = a ? `${e}.${n}` : n ?? "";
264
+ function _t(e, t) {
265
+ const { useLocale: r, useLocaleAsPrefix: n, indexFile: a, path: o, folder: s } = t, c = r ? `${e}/` : null, i = n ? `${e}.${a}` : a ?? "";
226
266
  return [o, s, `${c || ""}${i}`].filter((l) => l !== void 0).join("/");
227
267
  }
228
- var K = /* @__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))(K || {});
229
- let L = {
268
+ function O(e) {
269
+ const t = new CustomEvent("notification", {
270
+ bubbles: !0,
271
+ cancelable: !1,
272
+ detail: e
273
+ });
274
+ dispatchEvent(t);
275
+ }
276
+ const wt = {
277
+ success: (e, t) => {
278
+ O({
279
+ type: "success",
280
+ message: e,
281
+ options: t
282
+ });
283
+ },
284
+ info: (e, t) => {
285
+ O({
286
+ type: "info",
287
+ message: e,
288
+ options: t
289
+ });
290
+ },
291
+ warning: (e, t) => {
292
+ O({
293
+ type: "warning",
294
+ message: e,
295
+ options: t
296
+ });
297
+ },
298
+ error: (e, t) => {
299
+ O({
300
+ type: "error",
301
+ message: e,
302
+ options: t
303
+ });
304
+ }
305
+ };
306
+ 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 || {});
307
+ let U = {
230
308
  level: 1,
231
309
  enableConsoleOutput: !0
232
310
  };
233
- function ot(e) {
234
- L = { ...L, ...e };
311
+ function St(e) {
312
+ U = { ...U, ...e };
235
313
  }
236
- function $(e, t, r) {
237
- if (e < L.level) return;
238
- const a = (/* @__PURE__ */ new Date()).toISOString(), o = `${`[${K[e]}][${a}]`} ${t}`;
239
- if (L.enableConsoleOutput)
314
+ function D(e, t, r) {
315
+ if (e < U.level) return;
316
+ const n = (/* @__PURE__ */ new Date()).toISOString(), o = `${`[${te[e]}][${n}]`} ${t}`;
317
+ if (U.enableConsoleOutput)
240
318
  switch (e) {
241
319
  case 0:
242
320
  console.debug(o, r || "");
@@ -252,135 +330,135 @@ function $(e, t, r) {
252
330
  break;
253
331
  }
254
332
  }
255
- function x(e, t) {
256
- $(0, e, t);
333
+ function p(e, t) {
334
+ D(0, e, t);
257
335
  }
258
- function S(e, t) {
259
- $(1, e, t);
336
+ function w(e, t) {
337
+ D(1, e, t);
260
338
  }
261
339
  function C(e, t) {
262
- $(2, e, t);
340
+ D(2, e, t);
263
341
  }
264
- function h(e, t) {
265
- $(3, e, t);
342
+ function f(e, t) {
343
+ D(3, e, t);
266
344
  }
267
- function st(e, t, r) {
345
+ function mt(e, t, r) {
268
346
  var o, s, c, i;
269
347
  if (!e || !t) return;
270
348
  if (r) {
271
- const l = Object.keys(t.queries).find((I) => I === (r == null ? void 0 : r.toLowerCase()));
272
- let f;
273
- l && (f = t.queries[l]);
274
- const p = (s = ((o = f == null ? void 0 : f.columnsInfo) == null ? void 0 : o.columns) || []) == null ? void 0 : s.find((I) => {
275
- var q, Q;
276
- return (Q = (q = I.aliases) == null ? void 0 : q.split(",")) == null ? void 0 : Q.includes(e);
349
+ const l = Object.keys(t.queries).find((N) => N === (r == null ? void 0 : r.toLowerCase()));
350
+ let h;
351
+ l && (h = t.queries[l]);
352
+ const v = (s = ((o = h == null ? void 0 : h.columnsInfo) == null ? void 0 : o.columns) || []) == null ? void 0 : s.find((N) => {
353
+ var J, z;
354
+ return (z = (J = N.aliases) == null ? void 0 : J.split(",")) == null ? void 0 : z.includes(e);
277
355
  });
278
- if (p) return p.name;
356
+ if (v) return v.name;
279
357
  }
280
- const a = (i = (c = t.indexes) == null ? void 0 : c._) == null ? void 0 : i.columns, n = Object.entries(a).find((l) => {
281
- var f;
282
- return (f = l[1].aliases) == null ? void 0 : f.includes(e);
358
+ const n = (i = (c = t.indexes) == null ? void 0 : c._) == null ? void 0 : i.columns, a = Object.entries(n).find((l) => {
359
+ var h;
360
+ return (h = l[1].aliases) == null ? void 0 : h.includes(e);
283
361
  });
284
- if (n) return n[0];
362
+ if (a) return a[0];
285
363
  }
286
- function ct(e, t) {
364
+ function kt(e, t) {
287
365
  const r = e[t];
288
- return r === void 0 ? [] : Array.isArray(r) ? r.map((a) => {
289
- if (typeof a == "string")
290
- return a;
291
- if (typeof a == "object" && a !== null && "display" in a)
292
- return a.display;
293
- }).filter((a) => a !== void 0) : [String(r)];
294
- }
295
- function D(e) {
366
+ return r === void 0 ? [] : Array.isArray(r) ? r.map((n) => {
367
+ if (typeof n == "string")
368
+ return n;
369
+ if (typeof n == "object" && n !== null && "display" in n)
370
+ return n.display;
371
+ }).filter((n) => n !== void 0) : [String(r)];
372
+ }
373
+ function A(e) {
296
374
  return e !== null && typeof e == "object";
297
375
  }
298
- function le(e) {
299
- return D(e) && Object.prototype.toString.call(e) === "[object ArrayBuffer]";
376
+ function ke(e) {
377
+ return A(e) && Object.prototype.toString.call(e) === "[object ArrayBuffer]";
300
378
  }
301
- function ue(e) {
302
- return D(e) && Object.prototype.toString.call(e) === "[object Blob]";
379
+ function ge(e) {
380
+ return A(e) && Object.prototype.toString.call(e) === "[object Blob]";
303
381
  }
304
- function de(e) {
382
+ function be(e) {
305
383
  return typeof e == "string";
306
384
  }
307
- function it(e) {
308
- return (D(e) || Array.isArray(e)) && !le(e) && !ue(e) && !de(e);
385
+ function gt(e) {
386
+ return (A(e) || Array.isArray(e)) && !ke(e) && !ge(e) && !be(e);
309
387
  }
310
- function fe(e = !0) {
388
+ function Ce(e = !0) {
311
389
  let t = Date.now();
312
- return (e ? "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx" : "xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx").replace(/[xy]/g, (a) => {
313
- const n = (t + Math.random() * 16) % 16 | 0;
314
- return t = Math.floor(t / 16), (a === "x" ? n : n & 3 | 8).toString(16);
390
+ return (e ? "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx" : "xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx").replace(/[xy]/g, (n) => {
391
+ const a = (t + Math.random() * 16) % 16 | 0;
392
+ return t = Math.floor(t / 16), (n === "x" ? a : a & 3 | 8).toString(16);
315
393
  });
316
394
  }
317
- function lt(e) {
395
+ function bt(e) {
318
396
  if (!e)
319
397
  return "``";
320
398
  if (e = String(e), e.search(/[\\`]/) === -1)
321
399
  return "`" + e + "`";
322
400
  const t = ["`"];
323
- for (let r = 0, a = e.length; r < a; r++) {
324
- const n = e[r];
325
- (n === "\\" || n === "`") && t.push("\\"), t.push(n);
401
+ for (let r = 0, n = e.length; r < n; r++) {
402
+ const a = e[r];
403
+ (a === "\\" || a === "`") && t.push("\\"), t.push(a);
326
404
  }
327
405
  return t.push("`"), t.join("");
328
406
  }
329
- function ut(e) {
407
+ function Ct(e) {
330
408
  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(""));
331
409
  }
332
- var k = /* @__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))(k || {}), he = /* @__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))(he || {}), _e = /* @__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))(_e || {});
333
- const dt = "1.0";
334
- var Se = /* @__PURE__ */ ((e) => (e[e.Original = 0] = "Original", e[e.Corrected = 1] = "Corrected", e))(Se || {}), me = /* @__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))(me || {});
335
- class w extends Error {
336
- constructor(r, a) {
410
+ var k = /* @__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))(k || {}), Re = /* @__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))(Re || {}), pe = /* @__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))(pe || {});
411
+ const Rt = "1.0";
412
+ var ve = /* @__PURE__ */ ((e) => (e[e.Original = 0] = "Original", e[e.Corrected = 1] = "Corrected", e))(ve || {}), xe = /* @__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))(xe || {});
413
+ class m extends Error {
414
+ constructor(r, n) {
337
415
  super(r);
338
- G(this, "status");
339
- this.name = "ApiError", this.status = a;
416
+ H(this, "status");
417
+ this.name = "ApiError", this.status = n;
340
418
  }
341
419
  }
342
- class Z extends w {
420
+ class re extends m {
343
421
  constructor(t = "Unauthorized access") {
344
422
  super(t, 401), this.name = "UnauthorizedError";
345
423
  }
346
424
  }
347
- class we extends w {
425
+ class Pe extends m {
348
426
  constructor(t = "Server error") {
349
427
  super(t, 500), this.name = "ServerError";
350
428
  }
351
429
  }
352
- class ke extends w {
430
+ class Le extends m {
353
431
  constructor(t = "Request timed out") {
354
432
  super(t, 408), this.name = "TimeoutError";
355
433
  }
356
434
  }
357
- function ft(e) {
435
+ function pt(e) {
358
436
  const t = new AbortController(), { signal: r } = t;
359
437
  return e && setTimeout(() => {
360
- r.aborted || t.abort(new ke(`Request timed out after ${e}ms`));
438
+ r.aborted || t.abort(new Le(`Request timed out after ${e}ms`));
361
439
  }, e), { controller: t, signal: r };
362
440
  }
363
- async function ht(e, t = 0, r = 1e3) {
364
- let a;
365
- for (let n = 0; n <= t; n++)
441
+ async function vt(e, t = 0, r = 1e3) {
442
+ let n;
443
+ for (let a = 0; a <= t; a++)
366
444
  try {
367
445
  return await e();
368
446
  } catch (o) {
369
- if (a = o, o instanceof w && o.status >= 400 && o.status < 500 && o.status !== 429 || o instanceof DOMException && o.name === "AbortError")
447
+ if (n = o, o instanceof m && o.status >= 400 && o.status < 500 && o.status !== 429 || o instanceof DOMException && o.name === "AbortError")
370
448
  throw o;
371
- n < t && (C(`Retrying request (${n + 1}/${t})`, { error: o }), await new Promise((s) => setTimeout(s, r)));
449
+ a < t && (C(`Retrying request (${a + 1}/${t})`, { error: o }), await new Promise((s) => setTimeout(s, r)));
372
450
  }
373
- throw a;
451
+ throw n;
374
452
  }
375
- function v(e) {
376
- const t = O(), r = new Headers(e);
453
+ function P(e) {
454
+ const t = $(), r = new Headers(e);
377
455
  r.append("Sinequa-Force-Camel-Case", "true"), r.append("accept", "application/json"), t && r.append("Sinequa-csrf-token", t);
378
- const { userOverride: a, userOverrideActive: n, bearerToken: o } = u;
379
- return o && r.append("Authorization", `Bearer ${o}`), a && n && (r.append("sinequa-override-user", a.username), r.append("sinequa-override-domain", a.domain)), r;
456
+ const { userOverride: n, userOverrideActive: a, bearerToken: o } = u;
457
+ return o && r.append("Authorization", `Bearer ${o}`), n && a && (r.append("sinequa-override-user", n.username), r.append("sinequa-override-domain", n.domain)), r;
380
458
  }
381
459
  async function g(e, t = "json") {
382
460
  const r = e.headers.get("sinequa-jwt-refresh");
383
- if (r !== null && F(r), e.status === 200)
461
+ if (r !== null && V(r), e.status === 200)
384
462
  switch (t) {
385
463
  case "arraybuffer":
386
464
  return await e.arrayBuffer();
@@ -394,143 +472,141 @@ async function g(e, t = "json") {
394
472
  }
395
473
  if (e.status === 401) {
396
474
  if (u.userOverrideActive)
397
- throw u.userOverrideActive = !1, C("Unauthorized access attempt with user override", { endpoint: e.url }), new Z("Unauthorized... User override failed.");
398
- await W(e, 401);
475
+ throw u.userOverrideActive = !1, C("Unauthorized access attempt with user override", { endpoint: e.url }), new re("Unauthorized... User override failed.");
476
+ await M(e, 401);
399
477
  }
400
- throw e.status === 500 && (h("Server error occurred", { endpoint: e.url }), await W(e, 500)), C(`Unexpected response status: ${e.status}`, { endpoint: e.url }), new w(`Request failed with status ${e.status}`, e.status);
478
+ throw e.status === 500 && (f("Server error occurred", { endpoint: e.url }), await M(e, 500)), C(`Unexpected response status: ${e.status}`, { endpoint: e.url }), new m(`Request failed with status ${e.status}`, e.status);
401
479
  }
402
- async function W(e, t) {
480
+ async function M(e, t) {
403
481
  var r;
404
482
  try {
405
- const { done: a, value: n } = await ((r = e.body) == null ? void 0 : r.getReader().read()) || { done: !0, value: void 0 };
406
- if (a || !n)
407
- throw new w(`Request failed with status ${t}`, t);
408
- const o = JSON.parse(new TextDecoder().decode(n));
483
+ const { done: n, value: a } = await ((r = e.body) == null ? void 0 : r.getReader().read()) || { done: !0, value: void 0 };
484
+ if (n || !a)
485
+ throw new m(`Request failed with status ${t}`, t);
486
+ const o = JSON.parse(new TextDecoder().decode(a));
409
487
  throw o.status = t, o;
410
- } catch (a) {
411
- throw a instanceof w ? a : t === 401 ? new Z("Failed to parse error response") : t === 500 ? new we("Failed to parse error response") : new w(`Request failed with status ${t}`, t);
488
+ } catch (n) {
489
+ throw n instanceof m ? n : t === 401 ? new re() : t === 500 ? new Pe() : new m(`Request failed with status ${t}`, t);
412
490
  }
413
491
  }
414
492
  async function d(e, t, r) {
415
- const a = v(r == null ? void 0 : r.headers), { app: n, backendUrl: o, apiPath: s } = u, c = {
416
- app: n,
493
+ const n = P(r == null ? void 0 : r.headers), { app: a, backendUrl: o, apiPath: s } = u, c = {
494
+ app: a,
417
495
  ...t,
418
496
  locale: t.locale || navigator.language,
419
497
  noUserOverride: !0,
420
498
  noAutoAuthentication: !0
421
499
  }, i = `${o}/${s}/${e}`;
422
- x(`Making POST request to: ${i}`);
500
+ p(`Making POST request to: ${i}`);
423
501
  try {
424
502
  const l = await fetch(
425
503
  i,
426
504
  {
427
505
  method: "POST",
428
- headers: a,
506
+ headers: n,
429
507
  credentials: "include",
430
508
  body: JSON.stringify(c)
431
509
  }
432
510
  );
433
511
  return g(l, r == null ? void 0 : r.responseType);
434
512
  } catch (l) {
435
- throw h("Error making POST request:", l), l;
513
+ throw f("Error making POST request:", l), l;
436
514
  }
437
515
  }
438
516
  async function b(e, t, r) {
439
- const a = v(r == null ? void 0 : r.headers), { backendUrl: n, apiPath: o, bearerToken: s } = u;
440
- s && a.append("Authorization", `Bearer ${s}`);
441
- const c = t ? `?${new URLSearchParams(t)}` : "", i = `${n}/${o}/${e}${c}`;
442
- x(`Making GET request to: ${i}`);
517
+ const n = P(r == null ? void 0 : r.headers), { backendUrl: a, apiPath: o } = u, s = t ? `?${new URLSearchParams(t)}` : "", c = `${a}/${o}/${e}${s}`;
518
+ p(`Making GET request to: ${c}`);
443
519
  try {
444
- const l = await fetch(
445
- i,
520
+ const i = await fetch(
521
+ c,
446
522
  {
447
523
  method: "GET",
448
524
  credentials: "include",
449
- headers: a
525
+ headers: n
450
526
  }
451
527
  );
452
- return g(l, r == null ? void 0 : r.responseType);
453
- } catch (l) {
454
- throw h("Error making GET request:", l), l;
528
+ return g(i, r == null ? void 0 : r.responseType);
529
+ } catch (i) {
530
+ throw f("Error making GET request:", i), i;
455
531
  }
456
532
  }
457
- async function _t(e, t, r) {
458
- const a = v(r == null ? void 0 : r.headers), { app: n, backendUrl: o, apiPath: s } = u, c = {
459
- app: n,
533
+ async function xt(e, t, r) {
534
+ const n = P(r == null ? void 0 : r.headers), { app: a, backendUrl: o, apiPath: s } = u, c = {
535
+ app: a,
460
536
  ...t,
461
537
  locale: t.locale || navigator.language,
462
538
  noUserOverride: !0,
463
539
  noAutoAuthentication: !0
464
540
  }, i = `${o}/${s}/${e}`;
465
- x(`Making PUT request to: ${i}`);
541
+ p(`Making PUT request to: ${i}`);
466
542
  try {
467
543
  const l = await fetch(
468
544
  i,
469
545
  {
470
546
  method: "PUT",
471
- headers: a,
547
+ headers: n,
472
548
  credentials: "include",
473
549
  body: JSON.stringify(c)
474
550
  }
475
551
  );
476
552
  return g(l, r == null ? void 0 : r.responseType);
477
553
  } catch (l) {
478
- throw h("Error making PUT request:", l), l;
554
+ throw f("Error making PUT request:", l), l;
479
555
  }
480
556
  }
481
- async function St(e, t, r) {
482
- const a = v(r == null ? void 0 : r.headers), { backendUrl: n, apiPath: o } = u, s = t ? `?${new URLSearchParams(t)}` : "", c = `${n}/${o}/${e}${s}`;
483
- x(`Making DELETE request to: ${c}`);
557
+ async function Pt(e, t, r) {
558
+ const n = P(r == null ? void 0 : r.headers), { backendUrl: a, apiPath: o } = u, s = t ? `?${new URLSearchParams(t)}` : "", c = `${a}/${o}/${e}${s}`;
559
+ p(`Making DELETE request to: ${c}`);
484
560
  try {
485
561
  const i = await fetch(
486
562
  c,
487
563
  {
488
564
  method: "DELETE",
489
565
  credentials: "include",
490
- headers: a
566
+ headers: n
491
567
  }
492
568
  );
493
569
  return g(i, r == null ? void 0 : r.responseType);
494
570
  } catch (i) {
495
- throw h("Error making DELETE request:", i), i;
571
+ throw f("Error making DELETE request:", i), i;
496
572
  }
497
573
  }
498
- async function mt(e, t, r) {
499
- const a = v(r == null ? void 0 : r.headers), { app: n, backendUrl: o, apiPath: s } = u, c = {
500
- app: n,
574
+ async function Lt(e, t, r) {
575
+ const n = P(r == null ? void 0 : r.headers), { app: a, backendUrl: o, apiPath: s } = u, c = {
576
+ app: a,
501
577
  ...t,
502
578
  locale: t.locale || navigator.language,
503
579
  noUserOverride: !0,
504
580
  noAutoAuthentication: !0
505
581
  }, i = `${o}/${s}/${e}`;
506
- x(`Making PATCH request to: ${i}`);
582
+ p(`Making PATCH request to: ${i}`);
507
583
  try {
508
584
  const l = await fetch(
509
585
  i,
510
586
  {
511
587
  method: "PATCH",
512
- headers: a,
588
+ headers: n,
513
589
  credentials: "include",
514
590
  body: JSON.stringify(c)
515
591
  }
516
592
  );
517
593
  return g(l, r == null ? void 0 : r.responseType);
518
594
  } catch (l) {
519
- throw h("Error making PATCH request:", l), l;
595
+ throw f("Error making PATCH request:", l), l;
520
596
  }
521
597
  }
522
- let A, M;
523
- function P(e, t = !0) {
524
- let r = ge(e.$auditRecord);
525
- r && (be(r), t && Ce(r)), e.$auditRecord = r;
598
+ let q, ne;
599
+ function L(e, t = !0) {
600
+ let r = Oe(e.$auditRecord);
601
+ r && (Ue(r), t && $e(r)), e.$auditRecord = r;
526
602
  }
527
- function ge(e) {
603
+ function Oe(e) {
528
604
  if (!e)
529
605
  return;
530
606
  let t;
531
607
  if (Array.isArray(e))
532
608
  t = e;
533
- else if (D(e)) {
609
+ else if (A(e)) {
534
610
  const r = e;
535
611
  if (r.auditEvents || r.mlAuditEvents)
536
612
  return r;
@@ -538,91 +614,97 @@ function ge(e) {
538
614
  }
539
615
  return { auditEvents: t };
540
616
  }
541
- function be(e) {
617
+ function Ue(e) {
542
618
  var r;
543
- const t = Re();
544
- return (r = e.auditEvents) == null || r.forEach((a) => {
545
- a.detail || (a.detail = {}), a.detail.sessionid = t;
619
+ const t = ye();
620
+ return (r = e.auditEvents) == null || r.forEach((n) => {
621
+ n.detail || (n.detail = {}), n.detail.sessionid = t;
546
622
  }), e;
547
623
  }
548
- function Ce(e) {
624
+ function $e(e) {
549
625
  var r;
550
- const t = decodeURIComponent(window.location.href);
551
- return (r = e == null ? void 0 : e.auditEvents) == null || r.forEach((a) => {
552
- a.detail || (a.detail = {}), a.detail.url = t;
626
+ const t = typeof window < "u" ? decodeURIComponent(window.location.href) : "http://localhost";
627
+ return (r = e == null ? void 0 : e.auditEvents) == null || r.forEach((n) => {
628
+ n.detail || (n.detail = {}), n.detail.url = t;
553
629
  }), e;
554
630
  }
555
- function Re() {
556
- return (!A || xe()) && (A = fe()), M = /* @__PURE__ */ new Date(), A;
631
+ function ye() {
632
+ return (!q || Ie()) && (q = Ce()), ne = /* @__PURE__ */ new Date(), q;
557
633
  }
558
- function xe() {
559
- return (/* @__PURE__ */ new Date()).getTime() - M.getTime() > 10 * 60 * 1e3;
634
+ function Ie() {
635
+ return (/* @__PURE__ */ new Date()).getTime() - ne.getTime() > 10 * 60 * 1e3;
560
636
  }
561
- async function pe(e, t = !0) {
637
+ async function De(e, t = !0) {
562
638
  const r = {
563
639
  event: k.None,
564
640
  $auditRecord: e
565
641
  };
566
- return P(r, t), d("audit.notify", r);
642
+ return L(r, t), d("audit.notify", r);
567
643
  }
568
- const wt = { notify: pe };
569
- async function kt(e, t, r) {
570
- var f;
571
- const a = ((f = e.items) == null ? void 0 : f.length) || 0, n = 10, o = {
572
- query: { ...t, action: "aggregate", aggregations: { [e.name]: { skip: a, count: n } } },
644
+ const Ot = { notify: De };
645
+ async function Ut(e, t, r) {
646
+ var h;
647
+ const n = ((h = e.items) == null ? void 0 : h.length) || 0, a = 10, o = {
648
+ query: { ...t, action: "aggregate", aggregations: { [e.name]: { skip: n, count: a } } },
573
649
  $auditRecord: { auditEvents: [r] }
574
650
  };
575
- P(o);
651
+ L(o);
576
652
  const s = await d("query", o), c = await g(s), { aggregations: i } = c, l = i[0];
577
- return l.$hasMore = l.items.length > n, l.items = [...e.items, ...l.items], Promise.resolve(l);
653
+ return l.$hasMore = l.items.length > a, l.items = [...e.items, ...l.items], Promise.resolve(l);
578
654
  }
579
- async function gt() {
655
+ async function $t() {
580
656
  const { app: e } = u, t = new URLSearchParams({ app: e || "" });
581
657
  return b("app", t);
582
658
  }
583
- async function ve() {
659
+ async function Ae() {
584
660
  const { app: e } = u, t = new URLSearchParams({
585
661
  app: e || "",
586
662
  preLogin: "true"
587
663
  });
588
664
  return b("app", t);
589
665
  }
590
- function bt() {
666
+ function yt() {
591
667
  let { backendUrl: e, app: t } = u;
592
- if (e || (e = window.location.origin), !t) {
593
- const r = window.location.pathname.match(/\/app(?:-debug)?\/([^\/#]+)/);
594
- r && (t = r[1]);
668
+ if (typeof window < "u") {
669
+ if (e || (e = window.location.origin), !t) {
670
+ const r = window.location.pathname.match(
671
+ /\/app(?:-debug)?\/([^\/#]+)/
672
+ );
673
+ r && (t = r[1]);
674
+ }
675
+ S({
676
+ ...u,
677
+ backendUrl: e,
678
+ app: t
679
+ });
595
680
  }
596
- return m({
597
- ...u,
598
- backendUrl: e,
599
- app: t
600
- }), ve().then((r) => {
601
- const { autoOAuthProvider: a, autoSAMLProvider: n } = u, o = !a && !r.autoOAuthProvider && !n && !r.autoSAMLProvider;
602
- return m({
681
+ return Ae().then((r) => {
682
+ const { autoOAuthProvider: n, autoSAMLProvider: a } = u, o = !n && !r.autoOAuthProvider && !a && !r.autoSAMLProvider;
683
+ return S({
603
684
  ...u,
604
- autoOAuthProvider: a || r.autoOAuthProvider,
605
- autoSAMLProvider: n || r.autoSAMLProvider,
606
- useCredentialsOrSSO: o
685
+ autoOAuthProvider: n || r.autoOAuthProvider,
686
+ autoSAMLProvider: a || r.autoSAMLProvider,
687
+ useCredentials: o,
688
+ useSSO: o
607
689
  }), r;
608
690
  }).catch((r) => {
609
691
  throw console.error("atomic:fetchAppPreLogin error", r), r;
610
692
  });
611
693
  }
612
- async function Ct(e, t, r = {}) {
613
- const a = `search.dataset/${e}/${t}`, n = await d(a, { parameters: r }), o = t[0].toLowerCase() + t.slice(1), s = n.datasets[o];
694
+ async function It(e, t, r = {}) {
695
+ const n = `search.dataset/${e}/${t}`, a = await d(n, { parameters: r }), o = t[0].toLowerCase() + t.slice(1), s = a.datasets[o];
614
696
  if ("errorCode" in s && "errorMessage" in s)
615
697
  throw new Error(s.errorMessage);
616
698
  return s;
617
699
  }
618
- async function Rt(e, t) {
619
- const r = `search.dataset/${e}`, { parameters: a = {}, datasets: n = [] } = t;
620
- return (await d(r, { parameters: a, datasets: n })).datasets;
700
+ async function Dt(e, t) {
701
+ const r = `search.dataset/${e}`, { parameters: n = {}, datasets: a = [] } = t;
702
+ return (await d(r, { parameters: n, datasets: a })).datasets;
621
703
  }
622
- async function xt(e) {
704
+ async function At(e) {
623
705
  return await b(`search.dataset/${e}`);
624
706
  }
625
- async function pt(e, t = !0, r) {
707
+ async function Nt(e, t = !0, r) {
626
708
  try {
627
709
  return (await d("labels", {
628
710
  action: "list",
@@ -631,11 +713,11 @@ async function pt(e, t = !0, r) {
631
713
  locale: r,
632
714
  localize: !1
633
715
  })).labels;
634
- } catch (a) {
635
- throw h("Error in fetchLabels", a), a;
716
+ } catch (n) {
717
+ throw f("Error in fetchLabels", n), n;
636
718
  }
637
719
  }
638
- async function Pe() {
720
+ async function Ne() {
639
721
  try {
640
722
  const { app: e = "" } = u, t = new URLSearchParams({
641
723
  app: e,
@@ -643,12 +725,12 @@ async function Pe() {
643
725
  });
644
726
  return b("labels", t);
645
727
  } catch (e) {
646
- throw h("Error in getUserRights", e), e;
728
+ throw f("Error in getUserRights", e), e;
647
729
  }
648
730
  }
649
- async function Le(e, t, r = !0) {
731
+ async function Be(e, t, r = !0) {
650
732
  try {
651
- const a = {
733
+ const n = {
652
734
  action: "add",
653
735
  labels: e,
654
736
  ids: t,
@@ -672,14 +754,14 @@ async function Le(e, t, r = !0) {
672
754
  ]
673
755
  }
674
756
  };
675
- return d("labels", a);
676
- } catch (a) {
677
- throw h("Error in add", a), a;
757
+ return d("labels", n);
758
+ } catch (n) {
759
+ throw f("Error in add", n), n;
678
760
  }
679
761
  }
680
- async function Oe(e, t, r = !0) {
762
+ async function qe(e, t, r = !0) {
681
763
  try {
682
- const a = {
764
+ const n = {
683
765
  action: "remove",
684
766
  labels: e,
685
767
  ids: t,
@@ -703,14 +785,14 @@ async function Oe(e, t, r = !0) {
703
785
  ]
704
786
  }
705
787
  };
706
- return d("labels", a);
707
- } catch (a) {
708
- throw h("Error in remove", a), a;
788
+ return d("labels", n);
789
+ } catch (n) {
790
+ throw f("Error in remove", n), n;
709
791
  }
710
792
  }
711
- async function Ue(e, t, r = !0) {
793
+ async function Fe(e, t, r = !0) {
712
794
  try {
713
- const a = {
795
+ const n = {
714
796
  action: "rename",
715
797
  labels: e,
716
798
  newLabel: t,
@@ -724,12 +806,12 @@ async function Ue(e, t, r = !0) {
724
806
  }
725
807
  }
726
808
  };
727
- return d("labels", a);
728
- } catch (a) {
729
- throw h("Error in rename", a), a;
809
+ return d("labels", n);
810
+ } catch (n) {
811
+ throw f("Error in rename", n), n;
730
812
  }
731
813
  }
732
- async function $e(e, t = !0) {
814
+ async function Qe(e, t = !0) {
733
815
  try {
734
816
  const r = {
735
817
  action: "delete",
@@ -745,12 +827,12 @@ async function $e(e, t = !0) {
745
827
  };
746
828
  return d("labels", r);
747
829
  } catch (r) {
748
- throw h("Error in deleteLabels", r), r;
830
+ throw f("Error in deleteLabels", r), r;
749
831
  }
750
832
  }
751
- async function De(e, t, r = !0) {
833
+ async function Ge(e, t, r = !0) {
752
834
  try {
753
- const a = {
835
+ const n = {
754
836
  action: "bulkAdd",
755
837
  labels: e,
756
838
  query: t,
@@ -764,14 +846,14 @@ async function De(e, t, r = !0) {
764
846
  }
765
847
  }
766
848
  };
767
- return d("labels", a);
768
- } catch (a) {
769
- throw h("Error in bulkAdd", a), a;
849
+ return d("labels", n);
850
+ } catch (n) {
851
+ throw f("Error in bulkAdd", n), n;
770
852
  }
771
853
  }
772
- async function Ie(e, t, r = !0) {
854
+ async function je(e, t, r = !0) {
773
855
  try {
774
- const a = {
856
+ const n = {
775
857
  action: "bulkRemove",
776
858
  labels: e,
777
859
  query: t,
@@ -785,30 +867,36 @@ async function Ie(e, t, r = !0) {
785
867
  }
786
868
  }
787
869
  };
788
- return d("labels", a);
789
- } catch (a) {
790
- throw h("Error in bulkRemove", a), a;
870
+ return d("labels", n);
871
+ } catch (n) {
872
+ throw f("Error in bulkRemove", n), n;
791
873
  }
792
874
  }
793
- const vt = {
794
- getUserRights: Pe,
795
- add: Le,
796
- remove: Oe,
797
- rename: Ue,
798
- delete: $e,
799
- bulkAdd: De,
800
- bulkRemove: Ie
875
+ const Bt = {
876
+ getUserRights: Ne,
877
+ add: Be,
878
+ remove: qe,
879
+ rename: Fe,
880
+ delete: Qe,
881
+ bulkAdd: Ge,
882
+ bulkRemove: je
801
883
  };
802
- async function Pt(e, t) {
803
- const r = `${window.location.origin}${window.location.pathname}`, a = { name: t == null ? void 0 : t.name, text: t == null ? void 0 : t.text };
884
+ async function qt(e, t) {
885
+ if (typeof window > "u")
886
+ return d("preview", {
887
+ action: "get",
888
+ id: e,
889
+ query: t
890
+ });
891
+ const r = `${window.location.origin}${window.location.pathname}`, n = { name: t == null ? void 0 : t.name, text: t == null ? void 0 : t.text };
804
892
  return d("preview", {
805
893
  action: "get",
806
894
  id: e,
807
- query: a,
895
+ query: n,
808
896
  browserUrl: r
809
897
  });
810
898
  }
811
- async function Lt(e) {
899
+ async function Ft(e) {
812
900
  const t = new Headers();
813
901
  t.append("content-type", "text");
814
902
  const r = await fetch(
@@ -820,44 +908,44 @@ async function Lt(e) {
820
908
  );
821
909
  g(r);
822
910
  }
823
- async function ye() {
911
+ async function Ve() {
824
912
  const e = new URLSearchParams({
825
913
  action: "get",
826
914
  noAutoAuthentication: "true"
827
915
  });
828
916
  return b("principal", e);
829
917
  }
830
- const E = 11;
831
- async function Ot(e, t, r) {
918
+ const ae = 11;
919
+ async function Qt(e, t, r) {
832
920
  var s;
833
- const n = await d("query", {
921
+ const a = await d("query", {
834
922
  query: e,
835
923
  $auditRecord: t,
836
924
  queryIntentData: r
837
925
  });
838
- n.aggregations.forEach((c) => {
839
- c.$hasMore = !1, !c.isDistribution && !c.isTree && c.items && (c.$hasMore = c.items.length === E), c.isTree && c.items && B(c);
840
- }), (s = n.records) == null || s.map((c) => Object.assign(c, { value: c.title, type: "default" }));
841
- const o = { ...n, nextPage: n.page < Math.ceil(n.rowCount / n.pageSize) ? n.page + 1 : void 0, previousPage: n.page > 1 ? n.page - 1 : void 0 };
926
+ a.aggregations.forEach((c) => {
927
+ c.$hasMore = !1, !c.isDistribution && !c.isTree && c.items && (c.$hasMore = c.items.length === ae), c.isTree && c.items && j(c);
928
+ }), (s = a.records) == null || s.map((c) => Object.assign(c, { value: c.title, type: "default" }));
929
+ 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 };
842
930
  return Promise.resolve(o);
843
931
  }
844
- async function Ut(e, t, r) {
845
- const { app: a = "" } = u, n = {
932
+ async function Gt(e, t, r) {
933
+ const { app: n = "" } = u, a = {
846
934
  methods: [],
847
935
  mode: t,
848
936
  propagateErrors: !0,
849
937
  $auditRecord: { auditEvents: [r] }
850
938
  };
851
939
  for (const c of e)
852
- n.methods.push({
940
+ a.methods.push({
853
941
  method: "query",
854
- app: a,
942
+ app: n,
855
943
  query: c
856
944
  });
857
- const o = await d("multi", n);
945
+ const o = await d("multi", a);
858
946
  o.results.forEach((c) => {
859
947
  c.aggregations.forEach((i) => {
860
- i.$hasMore = !1, !i.isDistribution && !i.isTree && i.items && (i.$hasMore = i.items.length === E), i.isTree && B(i);
948
+ i.$hasMore = !1, !i.isDistribution && !i.isTree && i.items && (i.$hasMore = i.items.length === ae), i.isTree && j(i);
861
949
  });
862
950
  }), o.results.forEach((c) => {
863
951
  var i;
@@ -866,23 +954,23 @@ async function Ut(e, t, r) {
866
954
  const s = o.results.map((c) => ({ ...c, nextPage: c.page < Math.ceil(c.rowCount / c.pageSize) ? c.page + 1 : void 0, previousPage: c.page > 1 ? c.page - 1 : void 0 }));
867
955
  return Promise.resolve(s);
868
956
  }
869
- function B(e, t = "", r = 0) {
870
- let a = [];
871
- return e.items && e.items.forEach((n) => {
872
- let o = t ? `${t}/${n.value}` : n.value, s = r + 1;
873
- a.push({ path: o, level: s }), n.$path = o, n.$level = s, n.hasChildren ? a = a.concat(B(n, o, s)) : n.hasChildren = !1;
874
- }), a;
957
+ function j(e, t = "", r = 0) {
958
+ let n = [];
959
+ return e.items && e.items.forEach((a) => {
960
+ let o = t ? `${t}/${a.value}` : a.value, s = r + 1;
961
+ n.push({ path: o, level: s }), a.$path = o, a.$level = s, a.hasChildren ? n = n.concat(j(a, o, s)) : a.hasChildren = !1;
962
+ }), n;
875
963
  }
876
- async function $t(e) {
964
+ async function jt(e) {
877
965
  const r = await d("queryintent", {
878
966
  query: e
879
967
  });
880
968
  return r == null ? void 0 : r.intents;
881
969
  }
882
- async function Dt({ model: e, appName: t, query: r, article: a }) {
883
- const { webservice: n, format: o, maxcount: s, exportedColumns: c, export: i } = e, l = {
970
+ async function Vt({ model: e, appName: t, query: r, article: n }) {
971
+ const { webservice: a, format: o, maxcount: s, exportedColumns: c, export: i } = e, l = {
884
972
  app: t,
885
- webservice: n,
973
+ webservice: a,
886
974
  query: r,
887
975
  type: i,
888
976
  format: o,
@@ -892,14 +980,14 @@ async function Dt({ model: e, appName: t, query: r, article: a }) {
892
980
  auditEvents: [{
893
981
  type: "Search_ExportCSV",
894
982
  detail: {
895
- resultid: a ? a.id : void 0
983
+ resultid: n ? n.id : void 0
896
984
  }
897
985
  }]
898
986
  }
899
987
  };
900
- return P(l), await d("search.queryexport", l, { responseType: "blob" });
988
+ return L(l), await d("search.queryexport", l, { responseType: "blob" });
901
989
  }
902
- async function It(e, t) {
990
+ async function Jt(e, t) {
903
991
  return await d(
904
992
  "similardocuments",
905
993
  {
@@ -910,22 +998,22 @@ async function It(e, t) {
910
998
  }
911
999
  );
912
1000
  }
913
- async function yt(e, t) {
914
- var n;
915
- const a = await d("query.links", {
1001
+ async function zt(e, t) {
1002
+ var a;
1003
+ const n = await d("query.links", {
916
1004
  webservice: e,
917
1005
  query: t
918
1006
  });
919
- return (n = a == null ? void 0 : a.links) == null ? void 0 : n.map((o) => ({ ...o, query: t }));
1007
+ return (a = n == null ? void 0 : n.links) == null ? void 0 : a.map((o) => ({ ...o, query: t }));
920
1008
  }
921
- async function At(e, t, r, a, n) {
1009
+ async function Ht(e, t, r, n, a) {
922
1010
  const { app: o } = u, s = {
923
1011
  app: o || "",
924
1012
  suggestQuery: e,
925
1013
  text: t,
926
1014
  filter: r,
927
- kinds: a,
928
- showSource: n
1015
+ kinds: n,
1016
+ showSource: a
929
1017
  };
930
1018
  try {
931
1019
  return (await d("search.suggest", s)).suggests;
@@ -933,17 +1021,17 @@ async function At(e, t, r, a, n) {
933
1021
  throw console.error("Error fetching suggestions:", c), c;
934
1022
  }
935
1023
  }
936
- async function Nt(e, t, r, a) {
937
- const { app: n } = u;
1024
+ async function Wt(e, t, r, n) {
1025
+ const { app: a } = u;
938
1026
  return (await d("suggestquery", {
939
- app: n || "",
1027
+ app: a || "",
940
1028
  suggestQuery: e,
941
1029
  text: t,
942
1030
  query: r,
943
- kinds: a
1031
+ kinds: n
944
1032
  })).suggests;
945
1033
  }
946
- async function Bt(e, t) {
1034
+ async function Xt(e, t) {
947
1035
  if (!t) return Promise.resolve([]);
948
1036
  const { app: r } = u;
949
1037
  return (await d("suggestfield", {
@@ -953,41 +1041,41 @@ async function Bt(e, t) {
953
1041
  fields: t
954
1042
  })).suggests;
955
1043
  }
956
- async function Ft(e, t, r, a, n, o) {
1044
+ async function Yt(e, t, r, n, a, o) {
957
1045
  return d("doc.textchunks", {
958
1046
  id: e,
959
1047
  textChunks: t,
960
1048
  highlights: r,
961
- query: a,
962
- leftSentencesCount: n,
1049
+ query: n,
1050
+ leftSentencesCount: a,
963
1051
  rightSentencesCount: o
964
1052
  });
965
1053
  }
966
- async function qt() {
1054
+ async function Kt() {
967
1055
  const { app: e } = u, t = new URLSearchParams({
968
1056
  app: e || "",
969
1057
  action: "load"
970
1058
  });
971
1059
  return b("usersettings", t);
972
1060
  }
973
- async function Ae(e, t) {
1061
+ async function Je(e, t) {
974
1062
  const r = {
975
1063
  action: "save",
976
1064
  userSettings: e,
977
1065
  $auditRecord: { auditEvents: [t] }
978
1066
  };
979
- return P(r), d("usersettings", r);
1067
+ return L(r), d("usersettings", r);
980
1068
  }
981
- async function Qt(e, t) {
982
- const a = {
1069
+ async function Zt(e, t) {
1070
+ const n = {
983
1071
  action: "patch",
984
1072
  userSettings: e,
985
1073
  $auditRecord: t ? { auditEvents: [t] } : void 0
986
1074
  };
987
- return P(a), d("usersettings", a);
1075
+ return L(n), d("usersettings", n);
988
1076
  }
989
- async function Gt() {
990
- return Ae({}, { type: "UserSettings_Reset" });
1077
+ async function Mt() {
1078
+ return Je({}, { type: "UserSettings_Reset" });
991
1079
  }
992
1080
  function _(e) {
993
1081
  const t = new CustomEvent(
@@ -1000,8 +1088,16 @@ function _(e) {
1000
1088
  );
1001
1089
  dispatchEvent(t);
1002
1090
  }
1003
- const Ne = async () => {
1004
- const { autoOAuthProvider: e } = u, t = {
1091
+ const ze = async () => {
1092
+ const { autoOAuthProvider: e } = u;
1093
+ if (typeof window > "u")
1094
+ return d("security.oauth", {
1095
+ action: "getcode",
1096
+ provider: e,
1097
+ tokenInCookie: !0,
1098
+ originalUrl: "http://localhost"
1099
+ });
1100
+ const t = {
1005
1101
  action: "getcode",
1006
1102
  provider: e,
1007
1103
  tokenInCookie: !0,
@@ -1009,12 +1105,20 @@ const Ne = async () => {
1009
1105
  };
1010
1106
  try {
1011
1107
  const r = await d("security.oauth", t);
1012
- return r.redirectUrl && (localStorage.setItem("oauthRedirectUrl", r.redirectUrl), window.location.href = r.redirectUrl), r;
1108
+ return r.redirectUrl && (E("oauthRedirectUrl", r.redirectUrl), window.location.href = r.redirectUrl), r;
1013
1109
  } catch (r) {
1014
1110
  throw console.error("Failed to authenticate with OAuth", r), r;
1015
1111
  }
1016
- }, Be = async () => {
1017
- const { autoSAMLProvider: e } = u, t = {
1112
+ }, He = async () => {
1113
+ const { autoSAMLProvider: e } = u;
1114
+ if (typeof window > "u")
1115
+ return d("security.saml", {
1116
+ action: "getresponse",
1117
+ provider: e,
1118
+ tokenInCookie: !0,
1119
+ originalUrl: "http://localhost"
1120
+ });
1121
+ const t = {
1018
1122
  action: "getresponse",
1019
1123
  provider: e,
1020
1124
  tokenInCookie: !0,
@@ -1022,12 +1126,12 @@ const Ne = async () => {
1022
1126
  };
1023
1127
  try {
1024
1128
  const r = await d("security.saml", t);
1025
- return r.redirectUrl && (localStorage.setItem("samlRedirectUrl", r.redirectUrl), window.location.href = r.redirectUrl), r;
1129
+ return r.redirectUrl && (E("samlRedirectUrl", r.redirectUrl), window.location.href = r.redirectUrl), r;
1026
1130
  } catch (r) {
1027
1131
  throw console.error("Failed to authenticate with SAML", r), r;
1028
1132
  }
1029
- }, Fe = async (e) => {
1030
- const { username: t, password: r } = e || {}, a = {
1133
+ }, We = async (e) => {
1134
+ const { username: t, password: r } = e || {}, n = {
1031
1135
  action: "get",
1032
1136
  tokenInCookie: !0,
1033
1137
  user: t,
@@ -1036,179 +1140,180 @@ const Ne = async () => {
1036
1140
  noAutoAuthentication: !0
1037
1141
  };
1038
1142
  try {
1039
- const n = await d("security.webtoken", a);
1040
- return n.csrfToken ? (F(n.csrfToken), n.csrfToken) : null;
1041
- } catch (n) {
1042
- throw console.error("Failed to get JWT", n), n;
1143
+ const a = await d("security.webtoken", n);
1144
+ return a.csrfToken ? (V(a.csrfToken), a.csrfToken) : null;
1145
+ } catch (a) {
1146
+ throw console.error("Failed to get JWT", a), a;
1043
1147
  }
1044
- }, qe = async () => {
1148
+ }, Xe = async () => {
1045
1149
  const e = new URLSearchParams({
1046
1150
  action: "deleteWebTokenCookie",
1047
1151
  noUserOverride: "true",
1048
1152
  noAutoAuthentication: "true"
1049
1153
  });
1050
1154
  return b("challenge", e);
1051
- }, O = () => {
1052
- const e = localStorage.getItem("csrfToken"), t = sessionStorage.getItem("sinequa-credentials");
1155
+ }, $ = () => {
1156
+ const e = F("csrfToken"), t = ce("sinequa-credentials");
1053
1157
  return t ? JSON.parse(t).data.csrfToken : e || null;
1054
- }, F = (e) => sessionStorage.setItem("sinequa-credentials", JSON.stringify({ data: { csrfToken: e } })), jt = async (e) => {
1158
+ }, V = (e) => ie("sinequa-credentials", JSON.stringify({ data: { csrfToken: e } })), Et = async (e) => {
1055
1159
  if (e)
1056
- S("Attempting authentication using credentials"), m({ useCredentials: !0, useCredentialsOrSSO: !1, useSSO: !1 });
1160
+ w("Attempting authentication using credentials"), S({ useCredentials: !0, useSSO: !1 });
1057
1161
  else
1058
1162
  try {
1059
- const s = localStorage.getItem("oauthRedirectUrl"), c = localStorage.getItem("samlRedirectUrl");
1060
- S("Attempting to retrieve CSRF token");
1061
- const i = await Qe();
1062
- if (x("CSRF token retrieval result", i ? "success" : "failed"), i === null) {
1163
+ const s = F("oauthRedirectUrl"), c = F("samlRedirectUrl");
1164
+ w("Attempting to retrieve CSRF token");
1165
+ const i = await Ye();
1166
+ if (p("CSRF token retrieval result", i ? "success" : "failed"), i === null) {
1063
1167
  if (s || c)
1064
- return C("Redirection from provider failed after previous attempt"), localStorage.removeItem("oauthRedirectUrl"), localStorage.removeItem("samlRedirectUrl"), _(!1), !1;
1065
- const { autoOAuthProvider: l, autoSAMLProvider: f, useSAML: p } = u;
1066
- if (l && !p)
1067
- return S("Initiating OAuth authentication flow"), await Ne(), C("OAuth authentication flow did not redirect as expected"), _(!1), !1;
1068
- if (f)
1069
- return S("Initiating SAML authentication flow"), await Be(), C("SAML authentication flow did not redirect as expected"), _(!1), !1;
1070
- S("No direct authentication method available, will try SSO then credentials"), m({ useCredentials: !0, useSSO: !0, useCredentialsOrSSO: !0 });
1168
+ return C("Redirection from provider failed after previous attempt"), x("oauthRedirectUrl"), x("samlRedirectUrl"), _(!1), !1;
1169
+ const { autoOAuthProvider: l, autoSAMLProvider: h, useSAML: v } = u;
1170
+ if (l && !v)
1171
+ return w("Initiating OAuth authentication flow"), await ze(), C("OAuth authentication flow did not redirect as expected"), _(!1), !1;
1172
+ if (h)
1173
+ return w("Initiating SAML authentication flow"), await He(), C("SAML authentication flow did not redirect as expected"), _(!1), !1;
1174
+ w("No direct authentication method available, will try SSO then credentials"), S({ useCredentials: !0, useSSO: !0 });
1071
1175
  } else
1072
- return localStorage.removeItem("oauthRedirectUrl"), localStorage.removeItem("samlRedirectUrl"), S("User authenticated via existing token"), _(!0), !0;
1176
+ return x("oauthRedirectUrl"), x("samlRedirectUrl"), w("User authenticated via existing token"), _(!0), !0;
1073
1177
  } catch (s) {
1074
- throw h("Unexpected error during authentication", s), _(!1), s;
1178
+ throw f("Unexpected error during authentication", s), _(!1), s;
1075
1179
  }
1076
- const { useSSO: t, useCredentialsOrSSO: r, useCredentials: a } = u;
1077
- if (r)
1180
+ if (u.useCredentials && u.useSSO)
1078
1181
  try {
1079
- if (S("Checking if user is authenticated via SSO"), await ye())
1080
- return S("User authenticated using SSO"), m({ useCredentials: !1, useCredentialsOrSSO: !1, useSSO: !0 }), _(!0), !0;
1182
+ if (w("Checking if user is authenticated via SSO"), await Ve())
1183
+ return w("User authenticated using SSO"), S({ useCredentials: !1, useSSO: !0 }), _(!0), !0;
1081
1184
  } catch (s) {
1082
1185
  if ((s == null ? void 0 : s.status) === 401)
1083
- S("SSO authentication failed with 401, falling back to credentials"), m({ useCredentials: !0, useSSO: !1, useCredentialsOrSSO: !1 });
1084
- else
1085
- throw h("SSO authentication failed with unexpected error", s), _(!1), h;
1186
+ return w("SSO authentication failed with 401, falling back to credentials"), S({ useCredentials: !0, useSSO: !1 }), !1;
1187
+ throw f("SSO authentication failed with unexpected error", s), _(!1), f;
1086
1188
  }
1087
- if (O() || t)
1088
- return console.log("user already authenticated", O()), m({ isRedirectUrl: !1 }), _(!0), !0;
1089
- const { username: n, password: o } = e || {};
1090
- if (a && !n && !o)
1091
- return console.error("Credentials are required for authentication"), _(!1), !1;
1092
- if (n && o)
1189
+ const { useSSO: r } = u;
1190
+ if ($() !== null || r)
1191
+ return w("user already authenticated", $()), S({ isRedirectUrl: !1 }), _(!0), !0;
1192
+ const { useCredentials: n } = u, { username: a, password: o } = e || {};
1193
+ if (n && !a && !o)
1194
+ return f("Credentials are required for authentication"), _(!1), !1;
1195
+ if (a && o)
1093
1196
  try {
1094
- return console.log("authentication using credentials..."), m({ useCredentials: !0 }), await Fe(e), _(!0), !0;
1197
+ return w("authentication using credentials..."), S({ useCredentials: !0, useSSO: !1 }), await We(e), _(!0), !0;
1095
1198
  } catch (s) {
1096
1199
  throw _(!1), s;
1097
1200
  }
1098
- return _(!1), console.error("No authentication method available. Please provide credentials or configure OAuth/SAML."), !1;
1099
- }, Vt = async () => {
1201
+ return _(!1), f("No authentication method available. Please provide credentials or configure OAuth/SAML."), !1;
1202
+ }, Tt = async () => {
1100
1203
  const { useCredentials: e, userOverrideActive: t } = u;
1101
- localStorage.removeItem("csrfToken"), sessionStorage.removeItem("sinequa-credentials"), e && !t ? (await qe()).methodresult === "ok" ? _(!1) : console.error("logout failed") : _(!1);
1102
- }, zt = () => !!O(), Qe = async () => {
1204
+ x("csrfToken"), le("sinequa-credentials"), e && !t ? (await Xe()).methodresult === "ok" ? _(!1) : console.error("logout failed") : _(!1);
1205
+ }, er = () => !!$(), Ye = async () => {
1103
1206
  const { backendUrl: e, apiPath: t } = u;
1104
1207
  try {
1105
- const a = await (await fetch(`${e}/${t}/challenge?action=getCsrfToken&suppressErrors=true`)).json();
1106
- return a != null && a.csrfToken ? (F(a.csrfToken), a.csrfToken) : null;
1208
+ const n = await (await fetch(`${e}/${t}/challenge?action=getCsrfToken&suppressErrors=true`)).json();
1209
+ return n != null && n.csrfToken ? (V(n.csrfToken), n.csrfToken) : null;
1107
1210
  } catch (r) {
1108
1211
  throw console.error("Failed to get CSRF token", r), r;
1109
1212
  }
1110
1213
  };
1111
1214
  export {
1112
- w as ApiError,
1113
- wt as Audit,
1215
+ m as ApiError,
1216
+ Ot as Audit,
1114
1217
  k as AuditEventType,
1115
- Se as DidYouMeanKind,
1116
- he as EngineType,
1117
- _e as EngineTypeModifier,
1118
- K as LogLevel,
1119
- dt as MINIMUM_COMPATIBLE_SERVER_API_VERSION,
1120
- me as RFMDisplay,
1121
- we as ServerError,
1122
- ke as TimeoutError,
1123
- Z as UnauthorizedError,
1124
- P as addAuditAdditionalInfo,
1125
- He as addConcepts,
1126
- be as addSessionId,
1127
- Ce as addUrl,
1128
- Ve as aggregationItemStrictCompare,
1129
- bt as appInitializerFn,
1130
- Je as bisect,
1131
- B as buildPathsAndLevels,
1132
- ot as configureLogger,
1133
- v as createHeaders,
1134
- ft as createTimeoutController,
1135
- x as debug,
1136
- St as del,
1137
- Gt as deleteUserSettings,
1138
- qe as deleteWebTokenCookie,
1139
- h as error,
1140
- lt as escapeExpr,
1141
- kt as fetchAggregation,
1142
- gt as fetchApp,
1143
- ve as fetchAppPreLogin,
1144
- Ut as fetchBulkQuery,
1145
- Ct as fetchDataset,
1146
- xt as fetchDatasetList,
1147
- Rt as fetchDatasets,
1148
- pt as fetchLabels,
1149
- Pt as fetchPreview,
1150
- Lt as fetchPreviewUrl,
1151
- ye as fetchPrincipal,
1152
- Ot as fetchQuery,
1153
- Dt as fetchQueryExport,
1154
- $t as fetchQueryIntent,
1155
- It as fetchSimilarDocuments,
1156
- yt as fetchSponsoredLinks,
1157
- At as fetchSuggest,
1158
- Bt as fetchSuggestField,
1159
- Nt as fetchSuggestQuery,
1160
- Ft as fetchTextChunks,
1161
- qt as fetchUserSettings,
1218
+ ve as DidYouMeanKind,
1219
+ Re as EngineType,
1220
+ pe as EngineTypeModifier,
1221
+ te as LogLevel,
1222
+ Rt as MINIMUM_COMPATIBLE_SERVER_API_VERSION,
1223
+ xe as RFMDisplay,
1224
+ Pe as ServerError,
1225
+ Le as TimeoutError,
1226
+ re as UnauthorizedError,
1227
+ L as addAuditAdditionalInfo,
1228
+ et as addConcepts,
1229
+ Ue as addSessionId,
1230
+ $e as addUrl,
1231
+ Me as aggregationItemStrictCompare,
1232
+ yt as appInitializerFn,
1233
+ Te as bisect,
1234
+ j as buildPathsAndLevels,
1235
+ St as configureLogger,
1236
+ P as createHeaders,
1237
+ pt as createTimeoutController,
1238
+ p as debug,
1239
+ Pt as del,
1240
+ Mt as deleteUserSettings,
1241
+ Xe as deleteWebTokenCookie,
1242
+ f as error,
1243
+ bt as escapeExpr,
1244
+ Ut as fetchAggregation,
1245
+ $t as fetchApp,
1246
+ Ae as fetchAppPreLogin,
1247
+ Gt as fetchBulkQuery,
1248
+ It as fetchDataset,
1249
+ At as fetchDatasetList,
1250
+ Dt as fetchDatasets,
1251
+ Nt as fetchLabels,
1252
+ qt as fetchPreview,
1253
+ Ft as fetchPreviewUrl,
1254
+ Ve as fetchPrincipal,
1255
+ Qt as fetchQuery,
1256
+ Vt as fetchQueryExport,
1257
+ jt as fetchQueryIntent,
1258
+ Jt as fetchSimilarDocuments,
1259
+ zt as fetchSponsoredLinks,
1260
+ Ht as fetchSuggest,
1261
+ Xt as fetchSuggestField,
1262
+ Wt as fetchSuggestQuery,
1263
+ Yt as fetchTextChunks,
1264
+ Kt as fetchUserSettings,
1162
1265
  b as get,
1163
- Ye as getConcepts,
1164
- Qe as getCsrfToken,
1165
- Y as getFiltersFromURI,
1166
- Ee as getFiltersFromUrl,
1167
- nt as getHelpIndexUrl,
1168
- et as getIdFromUrl,
1169
- Fe as getJWToken,
1170
- ct as getMetadata,
1171
- ie as getOffsetFromDates,
1172
- tt as getQueryPageFromUrl,
1173
- Me as getQueryParamsFromUrl,
1174
- rt as getQueryTabFromUrl,
1175
- Te as getQueryTextFromUrl,
1176
- Ke as getRelativeDate,
1177
- O as getToken,
1266
+ nt as getConcepts,
1267
+ Ye as getCsrfToken,
1268
+ ee as getFiltersFromURI,
1269
+ it as getFiltersFromUrl,
1270
+ _t as getHelpIndexUrl,
1271
+ ut as getIdFromUrl,
1272
+ We as getJWToken,
1273
+ kt as getMetadata,
1274
+ me as getOffsetFromDates,
1275
+ dt as getQueryPageFromUrl,
1276
+ st as getQueryParamsFromUrl,
1277
+ ft as getQueryTabFromUrl,
1278
+ lt as getQueryTextFromUrl,
1279
+ at as getRelativeDate,
1280
+ $ as getToken,
1281
+ ct as getUrlParamsFromQueryParams,
1178
1282
  u as globalConfig,
1179
- fe as guid,
1283
+ Ce as guid,
1180
1284
  g as handleResponse,
1181
- S as info,
1182
- le as isArrayBuffer,
1183
- zt as isAuthenticated,
1184
- ue as isBlob,
1185
- it as isJsonable,
1186
- Ze as isNotInputEvent,
1187
- D as isObject,
1188
- de as isString,
1189
- vt as labels,
1190
- jt as login,
1191
- Vt as logout,
1192
- U as parseText,
1193
- te as parseValueAndOperatorFromItem,
1194
- mt as patch,
1195
- Qt as patchUserSettings,
1285
+ w as info,
1286
+ ke as isArrayBuffer,
1287
+ er as isAuthenticated,
1288
+ ge as isBlob,
1289
+ gt as isJsonable,
1290
+ ot as isNotInputEvent,
1291
+ A as isObject,
1292
+ be as isString,
1293
+ Bt as labels,
1294
+ Et as login,
1295
+ Tt as logout,
1296
+ wt as notify,
1297
+ I as parseText,
1298
+ ue as parseValueAndOperatorFromItem,
1299
+ Lt as patch,
1300
+ Zt as patchUserSettings,
1196
1301
  d as post,
1197
- _t as put,
1302
+ xt as put,
1198
1303
  R as queryParamsFromUrl,
1199
- We as removeConcept,
1200
- Xe as removeConcepts,
1201
- st as resolveToColumnName,
1202
- N as rewriteText,
1203
- Ae as saveUserSettings,
1204
- m as setGlobalConfig,
1205
- F as setToken,
1206
- ut as sha512,
1207
- ze as suggestionsToTreeAggregationNodes,
1208
- at as sysLang,
1209
- je as translateAggregationToDateOptions,
1210
- Ne as tryOAuthAuthentication,
1211
- Be as trySAMLAuthentication,
1304
+ tt as removeConcept,
1305
+ rt as removeConcepts,
1306
+ mt as resolveToColumnName,
1307
+ G as rewriteText,
1308
+ Je as saveUserSettings,
1309
+ S as setGlobalConfig,
1310
+ V as setToken,
1311
+ Ct as sha512,
1312
+ Ee as suggestionsToTreeAggregationNodes,
1313
+ ht as sysLang,
1314
+ Ze as translateAggregationToDateOptions,
1315
+ ze as tryOAuthAuthentication,
1316
+ He as trySAMLAuthentication,
1212
1317
  C as warn,
1213
- ht as withRetry
1318
+ vt as withRetry
1214
1319
  };