@sinequa/atomic 0.0.113 → 0.0.121

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