@indxsearch/intrface 3.11.0 → 3.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/dist/components/AskPanel.d.ts +43 -0
- package/dist/components/FilterPanelNotice.d.ts +11 -0
- package/dist/components/SearchInput.d.ts +16 -0
- package/dist/components/SearchResults.d.ts +12 -0
- package/dist/components/SearchResultsMessage.d.ts +12 -0
- package/dist/context/SearchContext.d.ts +26 -0
- package/dist/context/searchError.d.ts +37 -0
- package/dist/context/useIndxAuth.d.ts +5 -0
- package/dist/context/useSearchExecution.d.ts +7 -2
- package/dist/hooks/useAsk.d.ts +89 -0
- package/dist/hooks/useFilterSuggestion.d.ts +42 -0
- package/dist/hooks/useSearchOrAsk.d.ts +52 -0
- package/dist/index.cjs.js +8 -1
- package/dist/index.d.ts +18 -0
- package/dist/index.es.js +1934 -813
- package/dist/intrface.css +1 -1
- package/dist/utils/answerMarkdown.d.ts +11 -0
- package/dist/utils/askPhrases.d.ts +24 -0
- package/dist/utils/searchOrAsk.d.ts +72 -0
- package/package.json +3 -3
package/dist/index.es.js
CHANGED
|
@@ -2,18 +2,128 @@ import "@indxsearch/systm/styles.css";
|
|
|
2
2
|
import e, { Component as t, createContext as n, memo as r, useCallback as i, useContext as a, useEffect as o, useMemo as s, useRef as c, useState as l } from "react";
|
|
3
3
|
import { SystemState as u } from "@indxsearch/indx-types";
|
|
4
4
|
import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
5
|
-
import {
|
|
6
|
-
import { ArrowDown as
|
|
5
|
+
import { Alert as m, AlertDescription as h, AlertTitle as g, AnswerActions as _, AssistantMessage as v, Button as y, Checkbox as b, Chip as x, CitationList as S, CitationRef as C, Composer as w, FilterPanelBase as T, InputField as E, RadioButton as D, SearchField as O, Select as k, Skeleton as A, Slider as j, StreamStatus as M, ToggleSwitch as N, Tooltip as P, UserMessage as F } from "@indxsearch/systm";
|
|
6
|
+
import { Ai_agent as I, ArrowDown as L, ArrowRight as R, Cloud as z, Enter_key as B, Filter as V, Fuzzy_search as H, Hour_glass as U, Indx as W, Key as ee, Lock as G, Refresh as te, Search as K, Speedometer as ne, Warning as re, X_or_error as ie } from "@indxsearch/pixl";
|
|
7
|
+
//#region src/context/IndxApiError.ts
|
|
8
|
+
var q = class e extends Error {
|
|
9
|
+
status;
|
|
10
|
+
code;
|
|
11
|
+
problem;
|
|
12
|
+
retryAfterSeconds;
|
|
13
|
+
constructor(e, t, n, r) {
|
|
14
|
+
let i = n?.detail ?? n?.title;
|
|
15
|
+
super(`${e} failed: HTTP ${t}${i ? ` — ${i}` : ""}`), this.name = "IndxApiError", this.status = t, this.code = n?.code, this.problem = n, this.retryAfterSeconds = r;
|
|
16
|
+
}
|
|
17
|
+
get retryable() {
|
|
18
|
+
return this.code === "invalidState" && this.problem?.retryable === !0;
|
|
19
|
+
}
|
|
20
|
+
static async fromResponse(t, n) {
|
|
21
|
+
let r;
|
|
22
|
+
try {
|
|
23
|
+
let e = await n.json();
|
|
24
|
+
e && typeof e == "object" && typeof e.code == "string" ? r = e : e && typeof e == "object" && (r = {
|
|
25
|
+
...e,
|
|
26
|
+
code: ""
|
|
27
|
+
});
|
|
28
|
+
} catch {}
|
|
29
|
+
let i = n.headers?.get?.("Retry-After"), a = i != null && /^\d+$/.test(i) ? Number(i) : void 0;
|
|
30
|
+
return new e(t, n.status, r, a);
|
|
31
|
+
}
|
|
32
|
+
}, J = class extends Error {
|
|
33
|
+
constructor(e) {
|
|
34
|
+
super(e), this.name = "SearchSetupError";
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
function ae(e, t) {
|
|
38
|
+
let n = e instanceof Error ? e.message : String(e);
|
|
39
|
+
if (e instanceof J) return {
|
|
40
|
+
kind: "setup",
|
|
41
|
+
message: n,
|
|
42
|
+
technical: n,
|
|
43
|
+
retryable: !1
|
|
44
|
+
};
|
|
45
|
+
if (e instanceof TypeError) return {
|
|
46
|
+
kind: "unreachable",
|
|
47
|
+
message: n,
|
|
48
|
+
technical: "Network error: no response from the server. Check that it is running and that the url is right.",
|
|
49
|
+
retryable: !0
|
|
50
|
+
};
|
|
51
|
+
if (e instanceof q) {
|
|
52
|
+
let r = {
|
|
53
|
+
message: n,
|
|
54
|
+
status: e.status,
|
|
55
|
+
code: e.code,
|
|
56
|
+
retryAfterSeconds: e.retryAfterSeconds
|
|
57
|
+
}, i = e.problem?.detail ?? e.problem?.title, a = (t) => `${e.status}${e.code ? ` ${e.code}` : ""}: ${t}`;
|
|
58
|
+
switch (!0) {
|
|
59
|
+
case e.status === 401: return {
|
|
60
|
+
...r,
|
|
61
|
+
kind: "unauthorized",
|
|
62
|
+
retryable: !1,
|
|
63
|
+
technical: a("the key is invalid or has expired. Create a new one in the web console.")
|
|
64
|
+
};
|
|
65
|
+
case e.status === 403: return {
|
|
66
|
+
...r,
|
|
67
|
+
kind: "forbidden",
|
|
68
|
+
retryable: !1,
|
|
69
|
+
technical: a(`the key does not reach dataset "${t.dataset}" in team "${t.team}".`)
|
|
70
|
+
};
|
|
71
|
+
case e.status === 404: return {
|
|
72
|
+
...r,
|
|
73
|
+
kind: "notFound",
|
|
74
|
+
retryable: !1,
|
|
75
|
+
technical: a(i ?? `no dataset "${t.dataset}" in team "${t.team}".`)
|
|
76
|
+
};
|
|
77
|
+
case e.retryable: return {
|
|
78
|
+
...r,
|
|
79
|
+
kind: "notReady",
|
|
80
|
+
retryable: !0,
|
|
81
|
+
technical: a(`the dataset is ${e.problem?.currentState?.toString().toLowerCase() ?? "not ready"}.`)
|
|
82
|
+
};
|
|
83
|
+
case e.status === 409: return {
|
|
84
|
+
...r,
|
|
85
|
+
kind: "unavailable",
|
|
86
|
+
retryable: !1,
|
|
87
|
+
technical: a(i ?? "the dataset cannot be searched now.")
|
|
88
|
+
};
|
|
89
|
+
case e.status === 429: return {
|
|
90
|
+
...r,
|
|
91
|
+
kind: "rateLimited",
|
|
92
|
+
retryable: !0,
|
|
93
|
+
technical: a(i ?? "too many requests for this key.")
|
|
94
|
+
};
|
|
95
|
+
case e.status >= 500: return {
|
|
96
|
+
...r,
|
|
97
|
+
kind: "server",
|
|
98
|
+
retryable: !0,
|
|
99
|
+
technical: a(i ?? "the server ran into a problem.")
|
|
100
|
+
};
|
|
101
|
+
default: return {
|
|
102
|
+
...r,
|
|
103
|
+
kind: "unknown",
|
|
104
|
+
retryable: !0,
|
|
105
|
+
technical: a(i ?? "the request failed.")
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
kind: "unknown",
|
|
111
|
+
message: n,
|
|
112
|
+
technical: n,
|
|
113
|
+
retryable: !0
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
7
117
|
//#region src/context/useIndxAuth.ts
|
|
8
|
-
function
|
|
9
|
-
let [a, s] = l(null), [c, d] = l(!0), [f, p] = l([]), [m, h] = l([]), [g, _] = l([]), [v, y] = l({}), [b, x] = l({}), [S, C] = l({}), [w, T] = l(0), [E, D] = l(null);
|
|
118
|
+
function oe({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebugLogs: i = !1 }) {
|
|
119
|
+
let [a, s] = l(null), [c, d] = l(!0), [f, p] = l([]), [m, h] = l([]), [g, _] = l([]), [v, y] = l({}), [b, x] = l({}), [S, C] = l({}), [w, T] = l(0), [E, D] = l(null), [O, k] = l(null), [A, j] = l(0);
|
|
10
120
|
return o(() => {
|
|
11
121
|
(async () => {
|
|
12
|
-
D(null);
|
|
122
|
+
D(null), k(null), d(!0);
|
|
13
123
|
try {
|
|
14
|
-
if (!r) throw console.error("[Auth] ❌ Missing bearer token"), console.error("[Auth] 💡 Pass preAuthenticatedToken to SearchProvider (create a token on the Indx Dashboard)"),
|
|
15
|
-
if (!e) throw console.error("[Auth] ❌ Missing INDX server URL"), console.error("[Auth] 💡 Pass a url to SearchProvider"),
|
|
16
|
-
if (!n) throw console.error("[Auth] ❌ Missing dataset name"), console.error("[Auth] 💡 Pass dataset=\"your-dataset-name\" to SearchProvider"),
|
|
124
|
+
if (!r) throw console.error("[Auth] ❌ Missing bearer token"), console.error("[Auth] 💡 Pass preAuthenticatedToken to SearchProvider (create a token on the Indx Dashboard)"), new J("A bearer token is required. Check console for instructions.");
|
|
125
|
+
if (!e) throw console.error("[Auth] ❌ Missing INDX server URL"), console.error("[Auth] 💡 Pass a url to SearchProvider"), new J("INDX server URL is required. Check console for instructions.");
|
|
126
|
+
if (!n) throw console.error("[Auth] ❌ Missing dataset name"), console.error("[Auth] 💡 Pass dataset=\"your-dataset-name\" to SearchProvider"), new J("Dataset name is required. Check console for instructions.");
|
|
17
127
|
i && console.log("[Auth] ✅ Using bearer token");
|
|
18
128
|
let a = r, o = (e) => fetch(e, {
|
|
19
129
|
method: "GET",
|
|
@@ -24,14 +134,7 @@ function D({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebugL
|
|
|
24
134
|
});
|
|
25
135
|
i && console.log("[Auth] 🔍 Checking dataset status...");
|
|
26
136
|
let c = await o(`${e}/api/teams/${t}/datasets/${n}/status`);
|
|
27
|
-
if (!c.ok)
|
|
28
|
-
if (c.status === 401) throw console.error("[Auth] ❌ Authentication failed (401 Unauthorized)"), console.error("[Auth] 💡 Your token may be expired or invalid"), console.error("[Auth] 💡 Create or refresh your token on the Indx Dashboard"), Error("Authentication failed (401). Token may be expired. Check console for instructions.");
|
|
29
|
-
if (c.status === 404) throw console.error("[Auth] ❌ Dataset \"" + n + "\" not found (404)"), console.error("[Auth] 💡 Available datasets can be checked with: curl -X GET \"" + e + "/api/me/datasets\" -H \"Authorization: Bearer YOUR_TOKEN\""), console.error("[Auth] 💡 Make sure you spelled the dataset name correctly"), Error("Dataset \"" + n + "\" not found. Check console for instructions.");
|
|
30
|
-
{
|
|
31
|
-
let t = await c.text();
|
|
32
|
-
throw console.error("[Auth] ❌ Failed to get dataset status:", c.status, t), console.error("[Auth] 💡 Check if your INDX server is running at:", e), Error("Failed to connect to INDX server. Check console for details.");
|
|
33
|
-
}
|
|
34
|
-
}
|
|
137
|
+
if (!c.ok) throw c.status === 401 ? (console.error("[Auth] ❌ Authentication failed (401 Unauthorized)"), console.error("[Auth] 💡 Your token may be expired or invalid"), console.error("[Auth] 💡 Create or refresh your token on the Indx Dashboard"), await q.fromResponse("Dataset status", c)) : c.status === 404 ? (console.error("[Auth] ❌ Dataset \"" + n + "\" not found (404)"), console.error("[Auth] 💡 Available datasets can be checked with: curl -X GET \"" + e + "/api/me/datasets\" -H \"Authorization: Bearer YOUR_TOKEN\""), console.error("[Auth] 💡 Make sure you spelled the dataset name correctly"), await q.fromResponse("Dataset status", c)) : (console.error("[Auth] ❌ Failed to get dataset status:", c.status), await q.fromResponse("Dataset status", c));
|
|
35
138
|
let l = await c.json();
|
|
36
139
|
i && console.log("[Auth] 📊 Dataset status:", l), s(a), i && console.log("[Auth] ✅ Dataset session established"), l.systemState !== void 0 && l.systemState !== u.Ready && (console.warn("[Auth] ⚠️ Dataset is not ready yet. Current state:", u[l.systemState]), console.warn("[Auth] 💡 Wait for indexing to complete before searching"));
|
|
37
140
|
let d = l.documentCount ?? l.numberOfRecords ?? 0;
|
|
@@ -42,9 +145,9 @@ function D({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebugL
|
|
|
42
145
|
o(`${e}/api/teams/${t}/datasets/${n}/fields/sortable`),
|
|
43
146
|
o(`${e}/api/teams/${t}/datasets/${n}/fields/configuration`).catch(() => null)
|
|
44
147
|
]);
|
|
45
|
-
if (!f.ok) throw console.error("[Auth] ❌ GetFilterableFields failed:", f.status, await
|
|
46
|
-
if (!m.ok) throw console.error("[Auth] ❌ GetFacetableFields failed:", m.status, await
|
|
47
|
-
if (!g.ok) throw console.error("[Auth] ❌ GetSortableFields failed:", g.status, await
|
|
148
|
+
if (!f.ok) throw console.error("[Auth] ❌ GetFilterableFields failed:", f.status), await q.fromResponse("Filterable fields", f);
|
|
149
|
+
if (!m.ok) throw console.error("[Auth] ❌ GetFacetableFields failed:", m.status), await q.fromResponse("Facetable fields", m);
|
|
150
|
+
if (!g.ok) throw console.error("[Auth] ❌ GetSortableFields failed:", g.status), await q.fromResponse("Sortable fields", g);
|
|
48
151
|
let [b, S, w] = await Promise.all([
|
|
49
152
|
f.json().catch((e) => (console.error("Failed to parse GetFilterableFields response:", e), [])),
|
|
50
153
|
m.json().catch((e) => (console.error("Failed to parse GetFacetableFields response:", e), [])),
|
|
@@ -88,8 +191,11 @@ function D({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebugL
|
|
|
88
191
|
let k = {};
|
|
89
192
|
if (D.facets) for (let [e, t] of Object.entries(D.facets)) Array.isArray(t) && (k[e] = t.map((e) => e.key));
|
|
90
193
|
x(O), C(k), i && console.log("[Auth] ✅ Initialization complete");
|
|
91
|
-
} catch (
|
|
92
|
-
console.error("[Auth] ❌ Initialization failed:",
|
|
194
|
+
} catch (r) {
|
|
195
|
+
console.error("[Auth] ❌ Initialization failed:", r), (r instanceof Error || typeof r == "object" && r && "message" in r) && console.error("[Auth] 💡 Error:", r.message), r instanceof TypeError && r.message.includes("fetch") && (console.error("[Auth] ❌ Network error - cannot connect to INDX server"), console.error("[Auth] 💡 Check if the server is running at:", e), console.error("[Auth] 💡 Check the url you passed to SearchProvider"), console.error("[Auth] 💡 For local development, it should be: http://localhost:5001")), D(r instanceof Error ? r.message : String(r)), k(ae(r, {
|
|
196
|
+
team: t,
|
|
197
|
+
dataset: n
|
|
198
|
+
}));
|
|
93
199
|
} finally {
|
|
94
200
|
d(!1);
|
|
95
201
|
}
|
|
@@ -97,11 +203,14 @@ function D({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebugL
|
|
|
97
203
|
}, [
|
|
98
204
|
e,
|
|
99
205
|
t,
|
|
100
|
-
n
|
|
206
|
+
n,
|
|
207
|
+
A
|
|
101
208
|
]), {
|
|
102
209
|
token: a,
|
|
103
210
|
isFetchingInitial: c,
|
|
104
211
|
authError: E,
|
|
212
|
+
authErrorInfo: O,
|
|
213
|
+
retry: () => j((e) => e + 1),
|
|
105
214
|
initialFacetStats: b,
|
|
106
215
|
initialFacetKeys: S,
|
|
107
216
|
filterableFields: f,
|
|
@@ -112,58 +221,31 @@ function D({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebugL
|
|
|
112
221
|
};
|
|
113
222
|
}
|
|
114
223
|
//#endregion
|
|
115
|
-
//#region src/context/IndxApiError.ts
|
|
116
|
-
var O = class e extends Error {
|
|
117
|
-
status;
|
|
118
|
-
code;
|
|
119
|
-
problem;
|
|
120
|
-
retryAfterSeconds;
|
|
121
|
-
constructor(e, t, n, r) {
|
|
122
|
-
let i = n?.detail ?? n?.title;
|
|
123
|
-
super(`${e} failed: HTTP ${t}${i ? ` — ${i}` : ""}`), this.name = "IndxApiError", this.status = t, this.code = n?.code, this.problem = n, this.retryAfterSeconds = r;
|
|
124
|
-
}
|
|
125
|
-
get retryable() {
|
|
126
|
-
return this.code === "invalidState" && this.problem?.retryable === !0;
|
|
127
|
-
}
|
|
128
|
-
static async fromResponse(t, n) {
|
|
129
|
-
let r;
|
|
130
|
-
try {
|
|
131
|
-
let e = await n.json();
|
|
132
|
-
e && typeof e == "object" && typeof e.code == "string" ? r = e : e && typeof e == "object" && (r = {
|
|
133
|
-
...e,
|
|
134
|
-
code: ""
|
|
135
|
-
});
|
|
136
|
-
} catch {}
|
|
137
|
-
let i = n.headers?.get?.("Retry-After"), a = i != null && /^\d+$/.test(i) ? Number(i) : void 0;
|
|
138
|
-
return new e(t, n.status, r, a);
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
//#endregion
|
|
142
224
|
//#region src/context/buildFilterProxy.ts
|
|
143
|
-
async function
|
|
225
|
+
async function se(e, t, n, r, i, a, o) {
|
|
144
226
|
let s = await o(`${r}/api/teams/${i}/datasets/${a}/filters/${e}`, {
|
|
145
227
|
method: "POST",
|
|
146
228
|
headers: { "Content-Type": "application/json" },
|
|
147
229
|
body: JSON.stringify(t)
|
|
148
230
|
});
|
|
149
|
-
if (!s.ok) throw await
|
|
231
|
+
if (!s.ok) throw await q.fromResponse(n, s);
|
|
150
232
|
let c = await s.json();
|
|
151
233
|
if (!c || typeof c.hashString != "string") throw Error(`${n} failed: server returned no filter token`);
|
|
152
234
|
return c;
|
|
153
235
|
}
|
|
154
|
-
async function
|
|
236
|
+
async function ce(e, t, n, r, i, a) {
|
|
155
237
|
if (e.length === 0) return null;
|
|
156
238
|
if (e.length === 1) return e[0];
|
|
157
239
|
let o = e[0];
|
|
158
|
-
for (let s = 1; s < e.length; s++) o = await
|
|
240
|
+
for (let s = 1; s < e.length; s++) o = await se("combine", {
|
|
159
241
|
a: o,
|
|
160
242
|
b: e[s],
|
|
161
243
|
useAndOperation: t === "and"
|
|
162
244
|
}, "CombineFilters", n, r, i, a);
|
|
163
245
|
return o;
|
|
164
246
|
}
|
|
165
|
-
async function
|
|
166
|
-
let l = Object.entries(e ?? {}).filter(([, e]) => e.length > 0), u = Object.entries(t ?? {}), d = Object.entries(s ?? {}).filter(([, e]) => e.length > 0), f = (e, { min: t, max: o }) =>
|
|
247
|
+
async function le(e, t, n, r, i, a, o = {}, s = {}, c = {}) {
|
|
248
|
+
let l = Object.entries(e ?? {}).filter(([, e]) => e.length > 0), u = Object.entries(t ?? {}), d = Object.entries(s ?? {}).filter(([, e]) => e.length > 0), f = (e, { min: t, max: o }) => se("range", {
|
|
167
249
|
fieldName: e,
|
|
168
250
|
lowerLimit: t,
|
|
169
251
|
upperLimit: o
|
|
@@ -172,16 +254,16 @@ async function j(e, t, n, r, i, a, o = {}, s = {}, c = {}) {
|
|
|
172
254
|
return Number.isFinite(o) ? f(e, {
|
|
173
255
|
min: o,
|
|
174
256
|
max: o
|
|
175
|
-
}) :
|
|
257
|
+
}) : se("value", {
|
|
176
258
|
fieldName: e,
|
|
177
259
|
value: t
|
|
178
260
|
}, `Value filter '${e}'`, n, r, i, a);
|
|
179
261
|
}, [m, h, g] = await Promise.all([
|
|
180
|
-
Promise.all(l.map(async ([e, t]) =>
|
|
262
|
+
Promise.all(l.map(async ([e, t]) => ce(await Promise.all(t.map((t) => p(e, t))), o[e] === "any" ? "or" : "and", n, r, i, a))),
|
|
181
263
|
Promise.all(u.map(([e, t]) => f(e, t))),
|
|
182
|
-
Promise.all(d.map(async ([e, t]) =>
|
|
264
|
+
Promise.all(d.map(async ([e, t]) => ce(await Promise.all(t.map((t) => f(e, t))), "or", n, r, i, a)))
|
|
183
265
|
]);
|
|
184
|
-
return
|
|
266
|
+
return ce([
|
|
185
267
|
...m,
|
|
186
268
|
...h,
|
|
187
269
|
...g
|
|
@@ -189,14 +271,14 @@ async function j(e, t, n, r, i, a, o = {}, s = {}, c = {}) {
|
|
|
189
271
|
}
|
|
190
272
|
//#endregion
|
|
191
273
|
//#region src/context/useSearchExecution.ts
|
|
192
|
-
function
|
|
274
|
+
function ue(e, t) {
|
|
193
275
|
let n, r = (...r) => {
|
|
194
276
|
clearTimeout(n), n = setTimeout(() => e(...r), t);
|
|
195
277
|
};
|
|
196
278
|
return r.cancel = () => clearTimeout(n), r;
|
|
197
279
|
}
|
|
198
|
-
function
|
|
199
|
-
let v = c(0),
|
|
280
|
+
function de({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team: s, dataset: u, allowEmptySearch: d, facetsEnabled: f, enableDebugLogs: p, shouldFetchMore: m, sessionId: h, source: g, count: _, searchTextOf: v }) {
|
|
281
|
+
let y = v ? v(e.query) : e.query, b = c(0), x = c(void 0), S = c(!1), [C, w] = l({}), [T, E] = l(""), [D, O] = l("");
|
|
200
282
|
o(() => {
|
|
201
283
|
r.isFetchingInitial || t((e) => ({
|
|
202
284
|
...e,
|
|
@@ -218,102 +300,102 @@ function N({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
218
300
|
r.sortableFields,
|
|
219
301
|
t
|
|
220
302
|
]);
|
|
221
|
-
let
|
|
303
|
+
let k = e.searchSettings.maxNumberOfRecordsToReturn, A = e.searchSettings.enableCoverage, j = e.searchSettings.removeDuplicates, M = e.searchSettings.coverageDepth, N = e.searchSettings.minimumScore, P = e.searchSettings.coverageSetup, F = e.sortBy, I = e.sortAscending, L = i(async ({ enableFacets: i }) => {
|
|
222
304
|
if (!r.token) return;
|
|
223
|
-
let o = ++
|
|
305
|
+
let o = ++b.current;
|
|
224
306
|
if (t((e) => ({
|
|
225
307
|
...e,
|
|
226
308
|
isLoading: !0
|
|
227
|
-
})),
|
|
309
|
+
})), y.trim() === "") {
|
|
228
310
|
if (!d) return;
|
|
229
311
|
i = !0;
|
|
230
312
|
}
|
|
231
313
|
try {
|
|
232
|
-
let c = i ? Array.from(new Set([...Object.keys(e.filters).filter((t) => e.valueMatch[t] === "any" && (e.filters[t]?.length ?? 0) > 0), ...Object.keys(e.bucketFilters).filter((t) => (e.bucketFilters[t]?.length ?? 0) > 0)])) : [], [l, ...f] = await Promise.all([
|
|
314
|
+
let c = i ? Array.from(new Set([...Object.keys(e.filters).filter((t) => e.valueMatch[t] === "any" && (e.filters[t]?.length ?? 0) > 0), ...Object.keys(e.bucketFilters).filter((t) => (e.bucketFilters[t]?.length ?? 0) > 0)])) : [], [l, ...f] = await Promise.all([le(e.filters, e.rangeFilters, a, s, u, n, e.valueMatch, e.bucketFilters, e.fieldTypes), ...c.map((t) => le({
|
|
233
315
|
...e.filters,
|
|
234
316
|
[t]: []
|
|
235
317
|
}, e.rangeFilters, a, s, u, n, e.valueMatch, {
|
|
236
318
|
...e.bucketFilters,
|
|
237
319
|
[t]: []
|
|
238
|
-
}, e.fieldTypes))]), m = d ||
|
|
239
|
-
text:
|
|
240
|
-
enableCoverage:
|
|
241
|
-
removeDuplicates:
|
|
242
|
-
coverageDepth:
|
|
243
|
-
coverageSetup:
|
|
244
|
-
},
|
|
245
|
-
...
|
|
246
|
-
maxNumberOfRecordsToReturn: m ?
|
|
320
|
+
}, e.fieldTypes))]), m = d || y.trim() !== "", v = {
|
|
321
|
+
text: y,
|
|
322
|
+
enableCoverage: A,
|
|
323
|
+
removeDuplicates: j,
|
|
324
|
+
coverageDepth: M,
|
|
325
|
+
coverageSetup: P
|
|
326
|
+
}, x = {
|
|
327
|
+
...v,
|
|
328
|
+
maxNumberOfRecordsToReturn: m ? k : 0,
|
|
247
329
|
enableFacets: i,
|
|
248
330
|
...l ? { filter: l } : {},
|
|
249
|
-
...
|
|
250
|
-
...
|
|
331
|
+
...F ? { sortBy: F } : {},
|
|
332
|
+
...I === void 0 ? {} : { sortAscending: I }
|
|
251
333
|
};
|
|
252
|
-
p && console.log("[performSearch] request body:", JSON.stringify(
|
|
253
|
-
let
|
|
254
|
-
g &&
|
|
255
|
-
let
|
|
334
|
+
p && console.log("[performSearch] request body:", JSON.stringify(x, null, 2));
|
|
335
|
+
let S = new URLSearchParams({ session: h });
|
|
336
|
+
g && S.set("source", g), _ || S.set("count", "false");
|
|
337
|
+
let L = (e) => n(`${a}/api/teams/${s}/datasets/${u}/search?${S}`, {
|
|
256
338
|
method: "POST",
|
|
257
339
|
headers: { "Content-Type": "application/json" },
|
|
258
340
|
body: JSON.stringify(e)
|
|
259
|
-
}), [
|
|
260
|
-
...
|
|
341
|
+
}), [R, ...z] = await Promise.all([L(x), ...f.map((e) => L({
|
|
342
|
+
...v,
|
|
261
343
|
maxNumberOfRecordsToReturn: 0,
|
|
262
344
|
enableFacets: !0,
|
|
263
345
|
...e ? { filter: e } : {}
|
|
264
346
|
}))]);
|
|
265
|
-
if (!
|
|
266
|
-
let
|
|
347
|
+
if (!R.ok) throw await q.fromResponse("Search", R);
|
|
348
|
+
let B = await R.json(), V = R.headers.get("Indx-Query-Id") ?? void 0, H = B.truncationIndex ?? -1, U = {};
|
|
267
349
|
for (let e = 0; e < c.length; e++) {
|
|
268
350
|
let t = c[e];
|
|
269
|
-
if (!
|
|
270
|
-
let n = await
|
|
271
|
-
n.facets?.[t] !== void 0 && (
|
|
351
|
+
if (!z[e].ok) throw await q.fromResponse(`Facets for '${t}'`, z[e]);
|
|
352
|
+
let n = await z[e].json();
|
|
353
|
+
n.facets?.[t] !== void 0 && (U[t] = n.facets[t]);
|
|
272
354
|
}
|
|
273
|
-
let
|
|
274
|
-
if (m &&
|
|
355
|
+
let W = B.records || [], ee = W.map((e) => e.documentKey), G = W.map((e) => e.score), te = [];
|
|
356
|
+
if (m && ee.length > 0) {
|
|
275
357
|
let e = await n(`${a}/api/teams/${s}/datasets/${u}/documents/lookup`, {
|
|
276
358
|
method: "POST",
|
|
277
359
|
headers: { "Content-Type": "application/json" },
|
|
278
|
-
body: JSON.stringify(
|
|
360
|
+
body: JSON.stringify(ee)
|
|
279
361
|
});
|
|
280
|
-
if (!e.ok) throw await
|
|
281
|
-
|
|
362
|
+
if (!e.ok) throw await q.fromResponse("Document lookup", e);
|
|
363
|
+
te = (await e.json()).map((e, t) => ({
|
|
282
364
|
document: e,
|
|
283
|
-
documentKey:
|
|
284
|
-
score:
|
|
365
|
+
documentKey: ee[t],
|
|
366
|
+
score: G[t]
|
|
285
367
|
}));
|
|
286
368
|
}
|
|
287
|
-
let
|
|
288
|
-
if (i &&
|
|
289
|
-
for (let [e, t] of Object.entries(
|
|
369
|
+
let K = {};
|
|
370
|
+
if (i && B.facets) {
|
|
371
|
+
for (let [e, t] of Object.entries(B.facets)) if (Array.isArray(t) && t.length > 0) {
|
|
290
372
|
let n = t.map((e) => Number(e.key)).filter((e) => !isNaN(e));
|
|
291
|
-
n.length > 0 && (
|
|
373
|
+
n.length > 0 && (K[e] = {
|
|
292
374
|
min: Math.min(...n),
|
|
293
375
|
max: Math.max(...n)
|
|
294
376
|
});
|
|
295
377
|
}
|
|
296
378
|
}
|
|
297
|
-
if (o !==
|
|
298
|
-
let ne =
|
|
379
|
+
if (o !== b.current) return;
|
|
380
|
+
let ne = y !== T, re = y !== D, ie = e.facetStats ?? {};
|
|
299
381
|
if (ne ? (ie = {
|
|
300
382
|
...r.initialFacetStats,
|
|
301
|
-
...
|
|
302
|
-
},
|
|
303
|
-
...
|
|
304
|
-
...
|
|
383
|
+
...K
|
|
384
|
+
}, w(ie), E(y)) : ie = {
|
|
385
|
+
...C,
|
|
386
|
+
...K
|
|
305
387
|
}, re && i) {
|
|
306
388
|
let n = { ...e.rangeBounds };
|
|
307
|
-
for (let [e, t] of Object.entries(
|
|
389
|
+
for (let [e, t] of Object.entries(K)) n[e] = t;
|
|
308
390
|
t((e) => ({
|
|
309
391
|
...e,
|
|
310
392
|
rangeBounds: n
|
|
311
|
-
})),
|
|
393
|
+
})), O(y);
|
|
312
394
|
}
|
|
313
|
-
let J = Object.keys(
|
|
314
|
-
...
|
|
315
|
-
...
|
|
316
|
-
} :
|
|
395
|
+
let J = Object.keys(U).length > 0 ? {
|
|
396
|
+
...B.facets ?? {},
|
|
397
|
+
...U
|
|
398
|
+
} : B.facets;
|
|
317
399
|
if (i && (!J || Object.keys(J).length === 0)) {
|
|
318
400
|
J = {};
|
|
319
401
|
for (let [e, t] of Object.entries(r.initialFacetKeys)) J[e] = t.map((e) => ({
|
|
@@ -321,58 +403,63 @@ function N({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
321
403
|
value: null
|
|
322
404
|
}));
|
|
323
405
|
}
|
|
324
|
-
let
|
|
325
|
-
let
|
|
326
|
-
return
|
|
406
|
+
let ae = te.filter((e) => {
|
|
407
|
+
let t = y.trim();
|
|
408
|
+
return t === "" || t.length === 1 ? !0 : e.score >= N;
|
|
327
409
|
}).map((e, t) => ({
|
|
328
410
|
...e,
|
|
329
411
|
position: t + 1
|
|
330
412
|
}));
|
|
331
413
|
t((e) => ({
|
|
332
414
|
...e,
|
|
333
|
-
results:
|
|
415
|
+
results: ae,
|
|
334
416
|
error: void 0,
|
|
417
|
+
errorInfo: void 0,
|
|
335
418
|
resultsSuppressed: !m,
|
|
336
419
|
...i ? {
|
|
337
420
|
facets: J,
|
|
338
421
|
facetStats: ie
|
|
339
422
|
} : {},
|
|
340
423
|
isLoading: !1,
|
|
341
|
-
truncationIndex:
|
|
342
|
-
queryId:
|
|
424
|
+
truncationIndex: H,
|
|
425
|
+
queryId: V
|
|
343
426
|
}));
|
|
344
427
|
} catch (e) {
|
|
345
|
-
if (console.error("[Search] ❌ Search failed:", e), e instanceof TypeError && e.message.includes("fetch") ? (console.error("[Search] ❌ Network error - cannot reach INDX server"), console.error("[Search] 💡 Check if server is running at:", a)) : e instanceof Error && (e.message.includes("401") ? (console.error("[Search] ❌ Authentication failed"), console.error("[Search] 💡 Your token may have expired. Create or refresh it on the Indx Dashboard.")) : e.message.includes("404") ? (console.error("[Search] ❌ Dataset not found"), console.error("[Search] 💡 Check that dataset \"" + u + "\" exists")) : console.error("[Search] 💡 Error:", e.message)), o !==
|
|
428
|
+
if (console.error("[Search] ❌ Search failed:", e), e instanceof TypeError && e.message.includes("fetch") ? (console.error("[Search] ❌ Network error - cannot reach INDX server"), console.error("[Search] 💡 Check if server is running at:", a)) : e instanceof Error && (e.message.includes("401") ? (console.error("[Search] ❌ Authentication failed"), console.error("[Search] 💡 Your token may have expired. Create or refresh it on the Indx Dashboard.")) : e.message.includes("404") ? (console.error("[Search] ❌ Dataset not found"), console.error("[Search] 💡 Check that dataset \"" + u + "\" exists")) : console.error("[Search] 💡 Error:", e.message)), o !== b.current) return;
|
|
346
429
|
t((t) => ({
|
|
347
430
|
...t,
|
|
348
431
|
results: null,
|
|
349
432
|
isLoading: !1,
|
|
350
433
|
resultsSuppressed: !1,
|
|
351
|
-
error: e instanceof Error ? e.message : "Search failed"
|
|
434
|
+
error: e instanceof Error ? e.message : "Search failed",
|
|
435
|
+
errorInfo: ae(e, {
|
|
436
|
+
team: s,
|
|
437
|
+
dataset: u
|
|
438
|
+
})
|
|
352
439
|
}));
|
|
353
440
|
}
|
|
354
441
|
}, [
|
|
355
|
-
|
|
442
|
+
y,
|
|
356
443
|
e.filters,
|
|
357
444
|
e.valueMatch,
|
|
358
445
|
e.rangeFilters,
|
|
359
446
|
e.bucketFilters,
|
|
360
447
|
e.facetStats,
|
|
448
|
+
F,
|
|
361
449
|
I,
|
|
362
|
-
L,
|
|
363
|
-
D,
|
|
364
450
|
k,
|
|
365
451
|
A,
|
|
366
|
-
|
|
367
|
-
|
|
452
|
+
j,
|
|
453
|
+
M,
|
|
368
454
|
P,
|
|
455
|
+
N,
|
|
369
456
|
n,
|
|
370
457
|
r.initialFacetStats,
|
|
371
458
|
r.initialFacetKeys,
|
|
372
459
|
r.token,
|
|
373
|
-
x,
|
|
374
460
|
C,
|
|
375
461
|
T,
|
|
462
|
+
D,
|
|
376
463
|
e.rangeBounds,
|
|
377
464
|
a,
|
|
378
465
|
s,
|
|
@@ -385,23 +472,23 @@ function N({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
385
472
|
_
|
|
386
473
|
]);
|
|
387
474
|
o(() => {
|
|
388
|
-
|
|
389
|
-
}, [
|
|
390
|
-
let
|
|
391
|
-
o(() => (
|
|
392
|
-
p && console.log("Debounced searchWithFacets fired"),
|
|
475
|
+
x.current = L;
|
|
476
|
+
}, [L]);
|
|
477
|
+
let R = c(null);
|
|
478
|
+
o(() => (R.current?.cancel(), R.current = ue(() => {
|
|
479
|
+
p && console.log("Debounced searchWithFacets fired"), x.current?.({ enableFacets: !0 });
|
|
393
480
|
}, e.facetDebounceDelayMillis ?? 500), () => {
|
|
394
|
-
|
|
481
|
+
R.current?.cancel();
|
|
395
482
|
}), [e.facetDebounceDelayMillis]), o(() => {
|
|
396
|
-
!r.isFetchingInitial && r.token && !
|
|
483
|
+
!r.isFetchingInitial && r.token && !S.current && (d && x.current?.({ enableFacets: f }), S.current = !0);
|
|
397
484
|
}, [
|
|
398
485
|
r.isFetchingInitial,
|
|
399
486
|
r.token,
|
|
400
487
|
d,
|
|
401
488
|
f
|
|
402
489
|
]), o(() => {
|
|
403
|
-
if (!r.token || !
|
|
404
|
-
let n =
|
|
490
|
+
if (!r.token || !S.current) return;
|
|
491
|
+
let n = y.trim(), i = n === "" && d;
|
|
405
492
|
if (n === "" && !d) {
|
|
406
493
|
e.resultsSuppressed || t((e) => ({
|
|
407
494
|
...e,
|
|
@@ -409,54 +496,63 @@ function N({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
409
496
|
}));
|
|
410
497
|
return;
|
|
411
498
|
}
|
|
412
|
-
return i ? (
|
|
413
|
-
|
|
499
|
+
return i ? (R.current?.cancel(), x.current?.({ enableFacets: f })) : f ? (p && console.log("Search fired"), x.current?.({ enableFacets: !1 }), R.current?.()) : x.current?.({ enableFacets: !1 }), () => {
|
|
500
|
+
R.current?.cancel();
|
|
414
501
|
};
|
|
415
502
|
}, [
|
|
416
|
-
|
|
503
|
+
y,
|
|
417
504
|
d,
|
|
418
505
|
f
|
|
419
506
|
]), o(() => {
|
|
420
|
-
if (!
|
|
421
|
-
let t =
|
|
422
|
-
!d && t === "" ||
|
|
507
|
+
if (!S.current || !r.token || e.filterRevision === 0) return;
|
|
508
|
+
let t = y.trim();
|
|
509
|
+
!d && t === "" || x.current?.({ enableFacets: f });
|
|
423
510
|
}, [e.filterRevision]), o(() => {
|
|
424
|
-
if (!
|
|
425
|
-
let
|
|
426
|
-
!d &&
|
|
427
|
-
}, [
|
|
428
|
-
let
|
|
429
|
-
o(() => {
|
|
430
|
-
if (
|
|
431
|
-
|
|
511
|
+
if (!S.current || !r.token) return;
|
|
512
|
+
let e = y.trim();
|
|
513
|
+
!d && e === "" || x.current?.({ enableFacets: f });
|
|
514
|
+
}, [F, I]);
|
|
515
|
+
let z = c(!0), B = c(y);
|
|
516
|
+
return o(() => {
|
|
517
|
+
if (z.current) {
|
|
518
|
+
z.current = !1;
|
|
432
519
|
return;
|
|
433
520
|
}
|
|
434
|
-
if (
|
|
521
|
+
if (B.current !== y || !S.current || !r.token) return;
|
|
435
522
|
if (m.current) {
|
|
436
|
-
m.current = !1,
|
|
523
|
+
m.current = !1, x.current?.({ enableFacets: !1 });
|
|
437
524
|
return;
|
|
438
525
|
}
|
|
439
|
-
let
|
|
440
|
-
!d &&
|
|
526
|
+
let e = y.trim();
|
|
527
|
+
!d && e === "" || x.current?.({ enableFacets: f });
|
|
441
528
|
}, [
|
|
442
|
-
D,
|
|
443
529
|
k,
|
|
444
530
|
A,
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
P
|
|
531
|
+
j,
|
|
532
|
+
M,
|
|
533
|
+
P,
|
|
534
|
+
N
|
|
448
535
|
]), o(() => {
|
|
449
|
-
|
|
450
|
-
}, [
|
|
536
|
+
B.current = y;
|
|
537
|
+
}, [y]), { retrySearch: i(() => {
|
|
538
|
+
x.current?.({ enableFacets: f });
|
|
539
|
+
}, [f]) };
|
|
451
540
|
}
|
|
452
541
|
//#endregion
|
|
453
542
|
//#region src/context/SearchContext.tsx
|
|
454
|
-
function
|
|
543
|
+
function fe() {
|
|
455
544
|
let e = globalThis.crypto;
|
|
456
545
|
return e?.randomUUID ? e.randomUUID() : Math.random().toString(36).slice(2) + Date.now().toString(36);
|
|
457
546
|
}
|
|
458
|
-
var
|
|
459
|
-
let
|
|
547
|
+
var pe = "Type to search", me = n(void 0), he = ({ children: e, url: t, team: n, dataset: r, allowEmptySearch: a = !1, maxResults: s = 10, facetDebounceDelayMillis: u = 500, enableFacets: d = !0, coverageDepth: p, removeDuplicates: m = !0, enableCoverage: h = !0, initialCoverageSetup: g = {}, enableDebugLogs: _ = !1, preAuthenticatedToken: v, source: y, count: b = !0, searchTextOf: x }) => {
|
|
548
|
+
let S = c(!1), C = c(fe()).current, [w, T] = l({ fn: null }), [E, D] = l(null), O = i((e) => {
|
|
549
|
+
let t = x ?? w.fn;
|
|
550
|
+
return !t || e === E ? e : t(e);
|
|
551
|
+
}, [
|
|
552
|
+
x,
|
|
553
|
+
w,
|
|
554
|
+
E
|
|
555
|
+
]), k = i((e) => T({ fn: e }), []), A = c(s), [j, M] = l({
|
|
460
556
|
query: "",
|
|
461
557
|
results: null,
|
|
462
558
|
isLoading: !1,
|
|
@@ -481,59 +577,58 @@ var F = n(void 0), I = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
481
577
|
removeDuplicates: m,
|
|
482
578
|
minimumScore: 0,
|
|
483
579
|
showScore: !0,
|
|
484
|
-
placeholderText:
|
|
580
|
+
placeholderText: pe,
|
|
485
581
|
coverageSetup: { ...g }
|
|
486
582
|
}
|
|
487
583
|
});
|
|
488
584
|
o(() => {
|
|
489
585
|
_ && console.log("SearchContext mounted on client");
|
|
490
586
|
}, [_]), o(() => {
|
|
491
|
-
|
|
587
|
+
M((e) => ({
|
|
492
588
|
...e,
|
|
493
589
|
facetDebounceDelayMillis: u
|
|
494
590
|
}));
|
|
495
591
|
}, [u]);
|
|
496
|
-
let [
|
|
592
|
+
let [N] = l(d), P = oe({
|
|
497
593
|
url: t,
|
|
498
594
|
team: n,
|
|
499
595
|
dataset: r,
|
|
500
596
|
preAuthenticatedToken: v,
|
|
501
597
|
enableDebugLogs: _
|
|
502
|
-
}),
|
|
503
|
-
if (!
|
|
598
|
+
}), F = i((e, t = {}) => {
|
|
599
|
+
if (!P.token) throw Error("No authentication token available");
|
|
504
600
|
return fetch(e, {
|
|
505
601
|
...t,
|
|
506
602
|
headers: {
|
|
507
603
|
...t.headers,
|
|
508
|
-
Authorization: `Bearer ${
|
|
604
|
+
Authorization: `Bearer ${P.token}`
|
|
509
605
|
}
|
|
510
606
|
});
|
|
511
|
-
}, [
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
auth: O,
|
|
607
|
+
}, [P.token]), { retrySearch: I } = de({
|
|
608
|
+
state: j,
|
|
609
|
+
setState: M,
|
|
610
|
+
authenticatedFetch: F,
|
|
611
|
+
auth: P,
|
|
517
612
|
url: t,
|
|
518
613
|
team: n,
|
|
519
614
|
dataset: r,
|
|
520
615
|
allowEmptySearch: a,
|
|
521
|
-
facetsEnabled:
|
|
616
|
+
facetsEnabled: N,
|
|
522
617
|
enableDebugLogs: _,
|
|
523
|
-
shouldFetchMore:
|
|
524
|
-
sessionId:
|
|
618
|
+
shouldFetchMore: S,
|
|
619
|
+
sessionId: C,
|
|
525
620
|
source: y,
|
|
526
|
-
count: b
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
let
|
|
531
|
-
if (
|
|
532
|
-
let i = await
|
|
621
|
+
count: b,
|
|
622
|
+
searchTextOf: O
|
|
623
|
+
}), L = c(void 0);
|
|
624
|
+
L.current = j.queryId;
|
|
625
|
+
let R = i(async (e) => {
|
|
626
|
+
if (P.token) try {
|
|
627
|
+
let i = await F(`${t}/api/teams/${n}/datasets/${r}/events/select`, {
|
|
533
628
|
method: "POST",
|
|
534
629
|
headers: { "Content-Type": "application/json" },
|
|
535
630
|
body: JSON.stringify({
|
|
536
|
-
queryId:
|
|
631
|
+
queryId: L.current,
|
|
537
632
|
documentKey: e.documentKey,
|
|
538
633
|
position: e.position,
|
|
539
634
|
...b ? {} : { count: !1 }
|
|
@@ -544,15 +639,15 @@ var F = n(void 0), I = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
544
639
|
_ && console.warn("[select] failed:", e);
|
|
545
640
|
}
|
|
546
641
|
}, [
|
|
547
|
-
|
|
548
|
-
|
|
642
|
+
P.token,
|
|
643
|
+
F,
|
|
549
644
|
t,
|
|
550
645
|
n,
|
|
551
646
|
r,
|
|
552
647
|
_,
|
|
553
648
|
b
|
|
554
|
-
]),
|
|
555
|
-
|
|
649
|
+
]), z = i((e) => {
|
|
650
|
+
M((t) => {
|
|
556
651
|
let n = Object.keys(t.filters).length > 0, r = Object.keys(t.rangeFilters).length > 0, i = Object.keys(t.bucketFilters).length > 0;
|
|
557
652
|
return {
|
|
558
653
|
...t,
|
|
@@ -562,17 +657,17 @@ var F = n(void 0), I = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
562
657
|
bucketFilters: i ? {} : t.bucketFilters,
|
|
563
658
|
searchSettings: {
|
|
564
659
|
...t.searchSettings,
|
|
565
|
-
maxNumberOfRecordsToReturn:
|
|
660
|
+
maxNumberOfRecordsToReturn: A.current
|
|
566
661
|
}
|
|
567
662
|
};
|
|
568
663
|
});
|
|
569
|
-
}, []),
|
|
570
|
-
|
|
664
|
+
}, []), B = i((e) => {
|
|
665
|
+
M((t) => ({
|
|
571
666
|
...t,
|
|
572
667
|
facetDebounceDelayMillis: e
|
|
573
668
|
}));
|
|
574
|
-
}, []),
|
|
575
|
-
typeof e.maxNumberOfRecordsToReturn == "number" && (
|
|
669
|
+
}, []), V = i((e) => {
|
|
670
|
+
typeof e.maxNumberOfRecordsToReturn == "number" && (A.current = e.maxNumberOfRecordsToReturn), M((t) => {
|
|
576
671
|
let n = {
|
|
577
672
|
...t.searchSettings,
|
|
578
673
|
...e
|
|
@@ -585,16 +680,16 @@ var F = n(void 0), I = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
585
680
|
searchSettings: n
|
|
586
681
|
};
|
|
587
682
|
});
|
|
588
|
-
}, []),
|
|
589
|
-
|
|
683
|
+
}, []), H = i((e) => {
|
|
684
|
+
S.current = !0, M((t) => ({
|
|
590
685
|
...t,
|
|
591
686
|
searchSettings: {
|
|
592
687
|
...t.searchSettings,
|
|
593
688
|
maxNumberOfRecordsToReturn: e
|
|
594
689
|
}
|
|
595
690
|
}));
|
|
596
|
-
}, []),
|
|
597
|
-
|
|
691
|
+
}, []), U = i((e, t, n = !1) => {
|
|
692
|
+
M((r) => {
|
|
598
693
|
let i = { ...r.filters }, a = i[e] || [], o = a.includes(t) ? a.filter((e) => e !== t) : n ? [t] : [...a, t];
|
|
599
694
|
return o.length ? i[e] = o : delete i[e], {
|
|
600
695
|
...r,
|
|
@@ -602,16 +697,16 @@ var F = n(void 0), I = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
602
697
|
filterRevision: r.filterRevision + 1
|
|
603
698
|
};
|
|
604
699
|
});
|
|
605
|
-
}, []),
|
|
606
|
-
|
|
700
|
+
}, []), W = i((e, t) => {
|
|
701
|
+
M((n) => n.valueMatch[e] === t ? n : {
|
|
607
702
|
...n,
|
|
608
703
|
valueMatch: {
|
|
609
704
|
...n.valueMatch,
|
|
610
705
|
[e]: t
|
|
611
706
|
}
|
|
612
707
|
});
|
|
613
|
-
}, []),
|
|
614
|
-
|
|
708
|
+
}, []), ee = i((e, t, n) => {
|
|
709
|
+
M((r) => ({
|
|
615
710
|
...r,
|
|
616
711
|
rangeFilters: {
|
|
617
712
|
...r.rangeFilters,
|
|
@@ -622,16 +717,16 @@ var F = n(void 0), I = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
622
717
|
},
|
|
623
718
|
filterRevision: r.filterRevision + 1
|
|
624
719
|
}));
|
|
625
|
-
}, []),
|
|
626
|
-
|
|
720
|
+
}, []), G = i(() => {
|
|
721
|
+
M((e) => ({
|
|
627
722
|
...e,
|
|
628
723
|
filters: {},
|
|
629
724
|
rangeFilters: {},
|
|
630
725
|
bucketFilters: {},
|
|
631
726
|
filterRevision: e.filterRevision + 1
|
|
632
727
|
}));
|
|
633
|
-
}, []),
|
|
634
|
-
|
|
728
|
+
}, []), te = i((e, t, n = !0) => {
|
|
729
|
+
M((r) => {
|
|
635
730
|
let i = { ...r.filters }, a = (i[e] || []).filter((e) => e !== t);
|
|
636
731
|
return a.length > 0 ? i[e] = a : delete i[e], {
|
|
637
732
|
...r,
|
|
@@ -639,8 +734,8 @@ var F = n(void 0), I = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
639
734
|
filterRevision: r.filterRevision + +!!n
|
|
640
735
|
};
|
|
641
736
|
});
|
|
642
|
-
}, []),
|
|
643
|
-
|
|
737
|
+
}, []), K = i((e, t = !0) => {
|
|
738
|
+
M((n) => {
|
|
644
739
|
if (!(e in n.rangeFilters)) return n;
|
|
645
740
|
let r = { ...n.rangeFilters };
|
|
646
741
|
return delete r[e], {
|
|
@@ -649,133 +744,558 @@ var F = n(void 0), I = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
649
744
|
filterRevision: n.filterRevision + +!!t
|
|
650
745
|
};
|
|
651
746
|
});
|
|
652
|
-
}, []),
|
|
653
|
-
|
|
654
|
-
let i = r.bucketFilters[e] ?? [], a = i.some((e) =>
|
|
747
|
+
}, []), ne = (e, t) => e.min === t.min && e.max === t.max, re = i((e, t, n = !1) => {
|
|
748
|
+
M((r) => {
|
|
749
|
+
let i = r.bucketFilters[e] ?? [], a = i.some((e) => ne(e, t)) ? i.filter((e) => !ne(e, t)) : n ? [t] : [...i, t], o = { ...r.bucketFilters };
|
|
655
750
|
return a.length > 0 ? o[e] = a : delete o[e], {
|
|
656
751
|
...r,
|
|
657
752
|
bucketFilters: o,
|
|
658
753
|
filterRevision: r.filterRevision + 1
|
|
659
754
|
};
|
|
660
755
|
});
|
|
661
|
-
}, []),
|
|
662
|
-
|
|
663
|
-
let i = { ...r.bucketFilters }, a = t ? (i[e] ?? []).filter((e) => !
|
|
756
|
+
}, []), ie = i((e, t, n = !0) => {
|
|
757
|
+
M((r) => {
|
|
758
|
+
let i = { ...r.bucketFilters }, a = t ? (i[e] ?? []).filter((e) => !ne(e, t)) : [];
|
|
664
759
|
return a.length > 0 ? i[e] = a : delete i[e], {
|
|
665
760
|
...r,
|
|
666
761
|
bucketFilters: i,
|
|
667
762
|
filterRevision: r.filterRevision + +!!n
|
|
668
763
|
};
|
|
669
764
|
});
|
|
670
|
-
}, []),
|
|
671
|
-
|
|
765
|
+
}, []), q = i((e, t) => {
|
|
766
|
+
M((n) => ({
|
|
672
767
|
...n,
|
|
673
768
|
sortBy: e || void 0,
|
|
674
769
|
sortAscending: e ? t : void 0
|
|
675
770
|
}));
|
|
676
771
|
}, []);
|
|
677
|
-
return /* @__PURE__ */ f(
|
|
772
|
+
return /* @__PURE__ */ f(me.Provider, {
|
|
678
773
|
value: {
|
|
679
|
-
state:
|
|
680
|
-
isFetchingInitial:
|
|
681
|
-
authError:
|
|
774
|
+
state: j,
|
|
775
|
+
isFetchingInitial: P.isFetchingInitial || !j.fieldsSeeded,
|
|
776
|
+
authError: P.authError ?? void 0,
|
|
777
|
+
authErrorInfo: P.authErrorInfo ?? void 0,
|
|
778
|
+
retry: P.authError ? P.retry : I,
|
|
682
779
|
allowEmptySearch: a,
|
|
780
|
+
facetsEnabled: N,
|
|
781
|
+
datasetBounds: P.initialFacetStats,
|
|
683
782
|
url: t,
|
|
684
783
|
team: n,
|
|
685
784
|
dataset: r,
|
|
686
|
-
authenticatedFetch:
|
|
687
|
-
setQuery:
|
|
688
|
-
toggleFilter:
|
|
689
|
-
setValueMatch:
|
|
690
|
-
setRangeFilter:
|
|
691
|
-
resetFilters:
|
|
692
|
-
resetSingleFilter:
|
|
693
|
-
resetRangeFilter:
|
|
694
|
-
toggleBucketFilter:
|
|
695
|
-
resetBucketFilter:
|
|
696
|
-
setSort:
|
|
697
|
-
setDebounceDelay:
|
|
698
|
-
setSearchSettings:
|
|
699
|
-
fetchMoreResults:
|
|
700
|
-
selectResult:
|
|
701
|
-
sessionId:
|
|
785
|
+
authenticatedFetch: F,
|
|
786
|
+
setQuery: z,
|
|
787
|
+
toggleFilter: U,
|
|
788
|
+
setValueMatch: W,
|
|
789
|
+
setRangeFilter: ee,
|
|
790
|
+
resetFilters: G,
|
|
791
|
+
resetSingleFilter: te,
|
|
792
|
+
resetRangeFilter: K,
|
|
793
|
+
toggleBucketFilter: re,
|
|
794
|
+
resetBucketFilter: ie,
|
|
795
|
+
setSort: q,
|
|
796
|
+
setDebounceDelay: B,
|
|
797
|
+
setSearchSettings: V,
|
|
798
|
+
fetchMoreResults: H,
|
|
799
|
+
selectResult: R,
|
|
800
|
+
sessionId: C,
|
|
801
|
+
source: y,
|
|
802
|
+
count: b,
|
|
803
|
+
searchText: O(j.query),
|
|
804
|
+
searchAsTyped: () => D(j.query),
|
|
805
|
+
setSearchRewrite: k
|
|
702
806
|
},
|
|
703
807
|
children: e
|
|
704
808
|
});
|
|
705
|
-
},
|
|
706
|
-
let e = a(
|
|
809
|
+
}, Y = () => {
|
|
810
|
+
let e = a(me);
|
|
707
811
|
if (!e) throw Error("useSearchContext must be used within a SearchProvider");
|
|
708
812
|
return e;
|
|
709
|
-
},
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
813
|
+
}, ge = {
|
|
814
|
+
strong: .65,
|
|
815
|
+
strongHide: .45,
|
|
816
|
+
invite: .4,
|
|
817
|
+
inviteHide: .3
|
|
818
|
+
}, _e = new Set(/* @__PURE__ */ "hvordan.hva.hvorfor.hvor.hvilken.hvilke.hvilket.hvem.når.kan.skal.må.bør.er.går.finnes.trenger.how.what.why.where.which.who.when.can.should.does.do.is.are.will.could.would".split(".")), ve = /^[\d\s\-_.:/]+$|^\w+\.\w+|^[A-Za-z]*[a-z][A-Z]\w*$|^[A-Za-z]+[-_]?\d[\w-]*$/;
|
|
819
|
+
function ye(e) {
|
|
820
|
+
let t = e.trim();
|
|
821
|
+
return t.length > 0 && !t.includes(" ") && ve.test(t);
|
|
822
|
+
}
|
|
823
|
+
function be(e) {
|
|
824
|
+
let t = e.trim();
|
|
825
|
+
if (!t || ye(t)) return !1;
|
|
826
|
+
let n = t.split(/\s+/);
|
|
827
|
+
return t.endsWith("?") || n.length > 1 && _e.has(n[0].toLowerCase()) || n.length >= 3 ? !0 : t.length >= 4;
|
|
828
|
+
}
|
|
829
|
+
function xe(e, t, n = ge) {
|
|
830
|
+
return t >= n.strong || e === "strong" && t >= n.strongHide ? "strong" : t >= n.invite || e !== "none" && t >= n.inviteHide ? "invite" : "none";
|
|
831
|
+
}
|
|
832
|
+
var Se = {
|
|
833
|
+
shareOfTop: .5,
|
|
834
|
+
topFloor: .2
|
|
835
|
+
}, Ce = {
|
|
836
|
+
coverFuzzyWords: !1,
|
|
837
|
+
coverPrefixSuffix: !1,
|
|
838
|
+
coverJoinedWords: !1,
|
|
839
|
+
minWordSize: 3
|
|
840
|
+
}, we = 65535;
|
|
841
|
+
function Te(e, t, n, r = Se) {
|
|
842
|
+
if (!n || e.length === 0) return e;
|
|
843
|
+
let i = e[0].score;
|
|
844
|
+
if (i < r.topFloor * 65535) return [];
|
|
845
|
+
let a = t == null ? e : t < 0 ? [] : e.slice(0, t + 1), o = r.shareOfTop * i, s = a.findIndex((e) => e.score < o);
|
|
846
|
+
return s < 0 ? a : a.slice(0, s);
|
|
847
|
+
}
|
|
848
|
+
function Ee(e) {
|
|
849
|
+
let t = e.trim();
|
|
850
|
+
return t.includes(" ") || t.endsWith("?");
|
|
851
|
+
}
|
|
852
|
+
async function* De(e) {
|
|
853
|
+
let t = e.getReader(), n = new TextDecoder(), r = "";
|
|
854
|
+
try {
|
|
855
|
+
for (;;) {
|
|
856
|
+
let { value: e, done: i } = await t.read();
|
|
857
|
+
if (i) break;
|
|
858
|
+
r += n.decode(e, { stream: !0 });
|
|
859
|
+
let a;
|
|
860
|
+
for (; (a = r.indexOf("\n\n")) >= 0;) {
|
|
861
|
+
let e = r.slice(0, a);
|
|
862
|
+
r = r.slice(a + 2);
|
|
863
|
+
let t = "message", n = [];
|
|
864
|
+
for (let r of e.split("\n")) r.startsWith("event:") ? t = r.slice(6).trim() : r.startsWith("data:") && n.push(r.slice(5).trimStart());
|
|
865
|
+
n.length && (yield {
|
|
866
|
+
event: t,
|
|
867
|
+
data: JSON.parse(n.join("\n"))
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
} finally {
|
|
872
|
+
t.releaseLock();
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
function Oe(e) {
|
|
876
|
+
let t = new URLSearchParams();
|
|
877
|
+
e.state.queryId && t.set("queryId", e.state.queryId), e.sessionId && t.set("session", e.sessionId), e.source && t.set("source", e.source), e.count === !1 && t.set("count", "false");
|
|
878
|
+
let n = t.toString();
|
|
879
|
+
return n ? `?${n}` : "";
|
|
880
|
+
}
|
|
881
|
+
//#endregion
|
|
882
|
+
//#region src/utils/askPhrases.ts
|
|
883
|
+
var ke = (e) => e.toLowerCase().replace(/’/g, "'").split(/\s+/).filter(Boolean), Ae = /[?!.,]+$/, je = 2;
|
|
884
|
+
function Me(e, t) {
|
|
885
|
+
let n = 0;
|
|
886
|
+
for (let r of t) {
|
|
887
|
+
let t = ke(r);
|
|
888
|
+
t.length > n && t.length <= e.length && t.every((n, r) => e[e.length - t.length + r].replace(Ae, "") === n) && (n = t.length);
|
|
889
|
+
}
|
|
890
|
+
return n;
|
|
891
|
+
}
|
|
892
|
+
function Ne(e, t, n) {
|
|
893
|
+
let r = 0;
|
|
894
|
+
for (let i of n) {
|
|
895
|
+
let n = ke(i);
|
|
896
|
+
n.length > r && t + n.length <= e.length && n.every((n, r) => e[t + r].replace(Ae, "") === n) && (r = n.length);
|
|
897
|
+
}
|
|
898
|
+
return r;
|
|
899
|
+
}
|
|
900
|
+
function Pe(e, t) {
|
|
901
|
+
let n = e.trim().split(/\s+/).filter(Boolean), r = ke(e), i = 0, a = [], o = (e) => {
|
|
902
|
+
let t = Ne(r, i, e);
|
|
903
|
+
return t && (a.push(n.slice(i, i + t).join(" ")), i += t), t > 0;
|
|
904
|
+
}, s = Ne(r, 0, t.leadIns), c = o(t.leadIns), l = o(t.frames), u = o(t.links);
|
|
905
|
+
if (!(c && (s > 1 || l) || l && u)) return {
|
|
906
|
+
text: e,
|
|
907
|
+
taken: []
|
|
908
|
+
};
|
|
909
|
+
o(t.articles);
|
|
910
|
+
let d = n.slice(i).join(" ").replace(/[?!.]+$/, "").trim();
|
|
911
|
+
if (!/\p{L}{3,}/u.test(d)) return {
|
|
912
|
+
text: e,
|
|
913
|
+
taken: []
|
|
914
|
+
};
|
|
915
|
+
let f = d.split(/\s+/).filter(Boolean), p = Me(ke(d), t.frames);
|
|
916
|
+
if (p > 0 && f.length - p >= je) {
|
|
917
|
+
let e = f.slice(0, f.length - p).join(" ");
|
|
918
|
+
if (/\p{L}{3,}/u.test(e)) return {
|
|
919
|
+
text: e,
|
|
920
|
+
taken: [...a, f.slice(-p).join(" ")]
|
|
921
|
+
};
|
|
922
|
+
}
|
|
923
|
+
return {
|
|
924
|
+
text: d,
|
|
925
|
+
taken: a
|
|
926
|
+
};
|
|
927
|
+
}
|
|
928
|
+
//#endregion
|
|
929
|
+
//#region src/hooks/useSearchOrAsk.ts
|
|
930
|
+
var Fe = {
|
|
931
|
+
available: !1,
|
|
932
|
+
offer: "none",
|
|
933
|
+
p: null,
|
|
934
|
+
answerable: null,
|
|
935
|
+
text: "",
|
|
936
|
+
criteria: null,
|
|
937
|
+
describes: !1,
|
|
938
|
+
cutResults: !1,
|
|
939
|
+
cutRule: Se,
|
|
940
|
+
strictCoverage: !1,
|
|
941
|
+
filtersWhileTyping: "off",
|
|
942
|
+
stands: !1
|
|
943
|
+
};
|
|
944
|
+
function Ie(e = {}) {
|
|
945
|
+
let { enabled: t = !0, pauseMs: n = 300 } = e, r = Y(), { url: i, team: a, dataset: s, authenticatedFetch: u, isFetchingInitial: d, authError: f, state: p } = r, m = c(r);
|
|
946
|
+
m.current = r;
|
|
947
|
+
let h = (e.text ?? p.query).trim(), [g, _] = l(!1), [v, y] = l(Fe), b = c(ge), x = c(!0), S = c(Se), C = c(!0), w = c("off"), T = c(null), E = c(!0), D = c(!0), O = c(null), k = c("none"), A = c(""), j = c(0), M = c(0);
|
|
948
|
+
k.current = v.offer;
|
|
949
|
+
let N = `${i}/api/teams/${a}/datasets/${s}/search-or-ask`, P = t && !d && !f;
|
|
950
|
+
o(() => {
|
|
951
|
+
if (_(!1), !P) return;
|
|
952
|
+
let e = !1;
|
|
953
|
+
return (async () => {
|
|
954
|
+
try {
|
|
955
|
+
let t = await u(N);
|
|
956
|
+
if (!t.ok) return;
|
|
957
|
+
let n = await t.json();
|
|
958
|
+
if (e || !n.available || !n.settings?.enabled) return;
|
|
959
|
+
T.current = n.effective?.askPhrases ?? null, E.current = n.settings.refocusWhileTyping ?? !0, D.current = n.settings.inviteOnAskPhrase ?? !0, w.current = n.settings.filtersWhileTyping ?? "off", b.current = {
|
|
960
|
+
...ge,
|
|
961
|
+
...n.settings.thresholds
|
|
962
|
+
}, x.current = n.settings.cutWhileAsking ?? !0, C.current = n.settings.strictCoverageWhileAsking ?? !0, S.current = {
|
|
963
|
+
shareOfTop: n.settings.cutShareOfTop ?? Se.shareOfTop,
|
|
964
|
+
topFloor: n.settings.cutTopFloor ?? Se.topFloor
|
|
965
|
+
}, _(!0);
|
|
966
|
+
} catch {}
|
|
967
|
+
})(), () => {
|
|
968
|
+
e = !0;
|
|
969
|
+
};
|
|
970
|
+
}, [
|
|
971
|
+
P,
|
|
972
|
+
N,
|
|
973
|
+
u
|
|
974
|
+
]), o(() => {
|
|
975
|
+
let { setSearchRewrite: e } = m.current, t = T.current;
|
|
976
|
+
if (!(!g || !t || !E.current || !e)) return e((e) => Pe(e, t).text), () => e(null);
|
|
977
|
+
}, [g]), o(() => {
|
|
978
|
+
if (!g) {
|
|
979
|
+
y(Fe);
|
|
980
|
+
return;
|
|
981
|
+
}
|
|
982
|
+
if (!h) {
|
|
983
|
+
A.current = "", y({
|
|
984
|
+
...Fe,
|
|
985
|
+
available: g
|
|
986
|
+
});
|
|
987
|
+
return;
|
|
988
|
+
}
|
|
989
|
+
if (!be(h)) {
|
|
990
|
+
ye(h) && y((e) => ({
|
|
991
|
+
...e,
|
|
992
|
+
available: g,
|
|
993
|
+
offer: "none",
|
|
994
|
+
text: h
|
|
995
|
+
}));
|
|
996
|
+
return;
|
|
997
|
+
}
|
|
998
|
+
D.current && T.current && Pe(h, T.current).taken.length > 0 && y((e) => e.offer === "none" ? {
|
|
999
|
+
...e,
|
|
1000
|
+
available: g,
|
|
1001
|
+
offer: "invite",
|
|
1002
|
+
text: h
|
|
1003
|
+
} : e);
|
|
1004
|
+
let e = setTimeout(async () => {
|
|
1005
|
+
if (k.current === "strong" && A.current && h.startsWith(A.current)) {
|
|
1006
|
+
y((e) => ({
|
|
1007
|
+
...e,
|
|
1008
|
+
text: h
|
|
1009
|
+
}));
|
|
1010
|
+
return;
|
|
1011
|
+
}
|
|
1012
|
+
if (Date.now() < M.current) return;
|
|
1013
|
+
let e = ++j.current;
|
|
1014
|
+
A.current = h;
|
|
1015
|
+
try {
|
|
1016
|
+
let t = await u(`${N}/intent${Oe(m.current)}`, {
|
|
1017
|
+
method: "POST",
|
|
1018
|
+
headers: { "Content-Type": "application/json" },
|
|
1019
|
+
body: JSON.stringify({ text: h })
|
|
1020
|
+
});
|
|
1021
|
+
if (t.status === 429) {
|
|
1022
|
+
let e = Number(t.headers.get("Retry-After"));
|
|
1023
|
+
M.current = Date.now() + (Number.isFinite(e) && e > 0 ? e : 60) * 1e3;
|
|
1024
|
+
return;
|
|
1025
|
+
}
|
|
1026
|
+
if (t.status === 409) {
|
|
1027
|
+
_(!1);
|
|
1028
|
+
return;
|
|
1029
|
+
}
|
|
1030
|
+
if (!t.ok) return;
|
|
1031
|
+
let { p: n, answerable: r, criteria: i, cutWhileAsking: a, cutShareOfTop: o, cutTopFloor: s, strictCoverageWhileAsking: c, filtersWhileTyping: l } = await t.json();
|
|
1032
|
+
if (l != null && (w.current = l), e !== j.current) return;
|
|
1033
|
+
a != null && (x.current = a), c != null && (C.current = c), o != null && s != null && (S.current = {
|
|
1034
|
+
shareOfTop: o,
|
|
1035
|
+
topFloor: s
|
|
1036
|
+
}), y((e) => {
|
|
1037
|
+
let t = xe(e.offer, n, b.current), a = i ?? null, o = a != null && a >= b.current.strong, s = t === "strong" && !Ee(h) ? "invite" : t, c = o ? "strong" : s, l = c === "strong" && !(o && a > n);
|
|
1038
|
+
return {
|
|
1039
|
+
available: !0,
|
|
1040
|
+
offer: c,
|
|
1041
|
+
p: n,
|
|
1042
|
+
answerable: r ?? null,
|
|
1043
|
+
text: h,
|
|
1044
|
+
criteria: a,
|
|
1045
|
+
describes: o,
|
|
1046
|
+
cutResults: x.current && l,
|
|
1047
|
+
cutRule: S.current,
|
|
1048
|
+
strictCoverage: C.current && l,
|
|
1049
|
+
filtersWhileTyping: w.current,
|
|
1050
|
+
stands: !0
|
|
1051
|
+
};
|
|
1052
|
+
});
|
|
1053
|
+
} catch {}
|
|
1054
|
+
}, n);
|
|
1055
|
+
return () => clearTimeout(e);
|
|
1056
|
+
}, [
|
|
1057
|
+
h,
|
|
1058
|
+
g,
|
|
1059
|
+
N,
|
|
1060
|
+
u,
|
|
1061
|
+
n
|
|
1062
|
+
]);
|
|
1063
|
+
let F = g && v.strictCoverage;
|
|
1064
|
+
return o(() => {
|
|
1065
|
+
let { setSearchSettings: e, state: t } = m.current;
|
|
1066
|
+
if (F) {
|
|
1067
|
+
if (O.current) return;
|
|
1068
|
+
let n = t.searchSettings.coverageSetup ?? {};
|
|
1069
|
+
O.current = Object.fromEntries(Object.keys(Ce).map((e) => [e, n[e]])), e({ coverageSetup: { ...Ce } });
|
|
1070
|
+
} else O.current &&= (e({ coverageSetup: { ...O.current } }), null);
|
|
1071
|
+
}, [F]), g ? {
|
|
1072
|
+
...v,
|
|
1073
|
+
stands: !!v.text && h.startsWith(v.text)
|
|
1074
|
+
} : Fe;
|
|
1075
|
+
}
|
|
1076
|
+
var Le = {
|
|
1077
|
+
withOffer: "_withOffer_15olh_2",
|
|
1078
|
+
offerRow: "_offerRow_15olh_10",
|
|
1079
|
+
offerHint: "_offerHint_15olh_18",
|
|
1080
|
+
kbd: "_kbd_15olh_27"
|
|
1081
|
+
}, Re = ({ className: e = "", autoFocus: t = !1, inputSize: n = "default", showClear: r = !0, showFocus: i = !1, showStatus: a = !0, onAsk: o, searchOrAsk: s, askOffer: c = "chip", onKeyDown: l, ...u }) => {
|
|
1082
|
+
let { state: { query: m, filters: h, rangeFilters: g, bucketFilters: _, results: v, truncationIndex: b, searchSettings: S }, setQuery: C, resetFilters: w } = Y(), T = Object.values(h).reduce((e, t) => e + t.length, 0) + Object.keys(g).length + Object.values(_ ?? {}).reduce((e, t) => e + t.length, 0), E = m.length > 0, D = E && v !== null && v.length === 0, k = E && S.enableCoverage && v !== null && v.length > 0 && b === -1, A = Ie({ enabled: !!o && !s }), j = s ?? A, M = !!o && E && j.offer !== "none" && j.stands, N = j.available && S.placeholderText === "Type to search" ? "Search or ask" : S.placeholderText, F = (e) => {
|
|
1083
|
+
l?.(e), !(e.defaultPrevented || e.key !== "Enter" || !o || j.offer !== "strong" || !j.stands || !m.trim()) && (e.preventDefault(), o(m.trim()));
|
|
1084
|
+
}, L = () => {
|
|
1085
|
+
C(""), T > 0 && w();
|
|
1086
|
+
}, R = () => o(m.trim()), z = /* @__PURE__ */ p(O, {
|
|
714
1087
|
type: "text",
|
|
715
|
-
value:
|
|
716
|
-
onChange: (e) =>
|
|
717
|
-
placeholder:
|
|
1088
|
+
value: m,
|
|
1089
|
+
onChange: (e) => C(e.target.value),
|
|
1090
|
+
placeholder: N,
|
|
718
1091
|
autoFocus: t,
|
|
719
1092
|
className: e,
|
|
720
1093
|
showSearchIcon: !0,
|
|
721
1094
|
inputSize: n,
|
|
722
1095
|
showFocusBorder: i,
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
1096
|
+
clearable: !1,
|
|
1097
|
+
onKeyDown: F,
|
|
1098
|
+
...u,
|
|
1099
|
+
children: [
|
|
1100
|
+
M && c === "chip" && /* @__PURE__ */ f(y, {
|
|
1101
|
+
variant: j.offer === "strong" ? "primary" : "ghost",
|
|
1102
|
+
size: "micro",
|
|
1103
|
+
iconLeft: /* @__PURE__ */ f(I, {}),
|
|
1104
|
+
iconRight: j.offer === "strong" ? /* @__PURE__ */ f(B, {}) : void 0,
|
|
1105
|
+
onClick: R,
|
|
1106
|
+
title: j.offer === "strong" ? "Enter asks" : void 0,
|
|
1107
|
+
children: j.offer === "strong" ? "Ask" : "Ask about this"
|
|
1108
|
+
}),
|
|
1109
|
+
a && D && /* @__PURE__ */ f(x, { children: "No results" }),
|
|
1110
|
+
a && k && /* @__PURE__ */ f(P, {
|
|
1111
|
+
content: "No direct match. Showing the nearest results.",
|
|
1112
|
+
children: /* @__PURE__ */ f("span", { children: /* @__PURE__ */ f(x, {
|
|
1113
|
+
icon: /* @__PURE__ */ f(H, {}),
|
|
1114
|
+
children: "Nearest"
|
|
1115
|
+
}) })
|
|
1116
|
+
}),
|
|
1117
|
+
a && T > 0 && /* @__PURE__ */ f(P, {
|
|
1118
|
+
content: `${T} filter${T === 1 ? "" : "s"} active`,
|
|
1119
|
+
children: /* @__PURE__ */ f("span", { children: /* @__PURE__ */ f(x, {
|
|
1120
|
+
icon: /* @__PURE__ */ f(V, {}),
|
|
1121
|
+
color: "var(--CLightBlue)",
|
|
1122
|
+
textColor: "#080809",
|
|
1123
|
+
children: T
|
|
1124
|
+
}) })
|
|
1125
|
+
}),
|
|
1126
|
+
r && (E || T > 0) && /* @__PURE__ */ f(y, {
|
|
1127
|
+
variant: "ghost",
|
|
1128
|
+
size: "micro",
|
|
1129
|
+
onClick: L,
|
|
1130
|
+
"aria-label": T > 0 ? "Clear search and filters" : "Clear search",
|
|
1131
|
+
children: "Clear"
|
|
1132
|
+
})
|
|
1133
|
+
]
|
|
1134
|
+
});
|
|
1135
|
+
if (c !== "below" || !o || !j.available) return z;
|
|
1136
|
+
let U = j.offer === "strong";
|
|
1137
|
+
return /* @__PURE__ */ p("div", {
|
|
1138
|
+
className: Le.withOffer,
|
|
1139
|
+
children: [z, /* @__PURE__ */ f("div", {
|
|
1140
|
+
className: Le.offerRow,
|
|
1141
|
+
"aria-live": "polite",
|
|
1142
|
+
children: M && /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f(y, {
|
|
1143
|
+
variant: U ? "primary" : "ghost",
|
|
1144
|
+
iconLeft: /* @__PURE__ */ f(I, {}),
|
|
1145
|
+
onClick: R,
|
|
1146
|
+
children: U ? "Ask the assistant" : "Ask about this"
|
|
1147
|
+
}), U && /* @__PURE__ */ p("span", {
|
|
1148
|
+
className: Le.offerHint,
|
|
1149
|
+
children: [/* @__PURE__ */ f("kbd", {
|
|
1150
|
+
className: Le.kbd,
|
|
1151
|
+
children: "↵"
|
|
1152
|
+
}), " to ask"]
|
|
1153
|
+
})] })
|
|
1154
|
+
})]
|
|
1155
|
+
});
|
|
1156
|
+
}, ze = {
|
|
1157
|
+
message: "_message_1mgfk_1",
|
|
1158
|
+
icon: "_icon_1mgfk_10",
|
|
1159
|
+
title: "_title_1mgfk_15",
|
|
1160
|
+
detail: "_detail_1mgfk_20",
|
|
1161
|
+
technical: "_technical_1mgfk_25",
|
|
1162
|
+
button: "_button_1mgfk_33"
|
|
1163
|
+
}, Be = {
|
|
1164
|
+
unreachable: {
|
|
1165
|
+
icon: z,
|
|
1166
|
+
title: "Search is unavailable",
|
|
1167
|
+
detail: "The search server can’t be reached right now."
|
|
1168
|
+
},
|
|
1169
|
+
unauthorized: {
|
|
1170
|
+
icon: ee,
|
|
1171
|
+
title: "Search is unavailable",
|
|
1172
|
+
detail: "The search key was not accepted."
|
|
1173
|
+
},
|
|
1174
|
+
forbidden: {
|
|
1175
|
+
icon: G,
|
|
1176
|
+
title: "Search is unavailable",
|
|
1177
|
+
detail: "This search key doesn’t have access to these results."
|
|
1178
|
+
},
|
|
1179
|
+
notFound: {
|
|
1180
|
+
icon: K,
|
|
1181
|
+
title: "Nothing to search here",
|
|
1182
|
+
detail: "The collection this page searches doesn’t exist."
|
|
1183
|
+
},
|
|
1184
|
+
notReady: {
|
|
1185
|
+
icon: U,
|
|
1186
|
+
title: "Search is getting ready",
|
|
1187
|
+
detail: "Results will appear in a moment."
|
|
1188
|
+
},
|
|
1189
|
+
unavailable: {
|
|
1190
|
+
icon: re,
|
|
1191
|
+
title: "Search is unavailable",
|
|
1192
|
+
detail: "The collection can’t be searched right now."
|
|
1193
|
+
},
|
|
1194
|
+
rateLimited: {
|
|
1195
|
+
icon: ne,
|
|
1196
|
+
title: "Too many searches",
|
|
1197
|
+
detail: "Wait a moment, then try again."
|
|
1198
|
+
},
|
|
1199
|
+
server: {
|
|
1200
|
+
icon: re,
|
|
1201
|
+
title: "Something went wrong",
|
|
1202
|
+
detail: "The search server ran into a problem."
|
|
1203
|
+
},
|
|
1204
|
+
setup: {
|
|
1205
|
+
icon: re,
|
|
1206
|
+
title: "Search isn’t set up",
|
|
1207
|
+
detail: "This page is missing part of its search setup."
|
|
1208
|
+
},
|
|
1209
|
+
unknown: {
|
|
1210
|
+
icon: re,
|
|
1211
|
+
title: "Something went wrong",
|
|
1212
|
+
detail: "The search couldn’t be completed."
|
|
1213
|
+
}
|
|
1214
|
+
}, Ve = ({ error: e, onRetry: t, hideTechnical: n = !1 }) => {
|
|
1215
|
+
let { icon: r, title: i, detail: a } = Be[e.kind];
|
|
1216
|
+
o(() => {
|
|
1217
|
+
if (e.kind !== "notReady" || !t) return;
|
|
1218
|
+
let n = setTimeout(t, (e.retryAfterSeconds ?? 2) * 1e3);
|
|
1219
|
+
return () => clearTimeout(n);
|
|
1220
|
+
}, [e, t]);
|
|
1221
|
+
let s = e.retryable && e.kind !== "notReady" && t;
|
|
1222
|
+
return /* @__PURE__ */ p("div", {
|
|
1223
|
+
className: ze.message,
|
|
1224
|
+
role: "alert",
|
|
1225
|
+
children: [
|
|
1226
|
+
/* @__PURE__ */ f("span", {
|
|
1227
|
+
className: ze.icon,
|
|
1228
|
+
children: /* @__PURE__ */ f(r, {
|
|
1229
|
+
size: 70,
|
|
1230
|
+
color: "var(--lv4)"
|
|
1231
|
+
})
|
|
1232
|
+
}),
|
|
1233
|
+
/* @__PURE__ */ f("div", {
|
|
1234
|
+
className: ze.title,
|
|
1235
|
+
children: i
|
|
1236
|
+
}),
|
|
1237
|
+
/* @__PURE__ */ f("div", {
|
|
1238
|
+
className: ze.detail,
|
|
1239
|
+
children: a
|
|
1240
|
+
}),
|
|
1241
|
+
!n && /* @__PURE__ */ f("code", {
|
|
1242
|
+
className: ze.technical,
|
|
1243
|
+
children: e.technical
|
|
1244
|
+
}),
|
|
1245
|
+
s && /* @__PURE__ */ f(y, {
|
|
1246
|
+
variant: "secondary",
|
|
1247
|
+
size: "micro",
|
|
1248
|
+
className: ze.button,
|
|
1249
|
+
onClick: t,
|
|
1250
|
+
children: "Try again"
|
|
1251
|
+
})
|
|
1252
|
+
]
|
|
731
1253
|
});
|
|
732
|
-
},
|
|
733
|
-
placeholder: "
|
|
734
|
-
invalid: "
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
}, V = ({ skeleton: e = !1, index: t, score: n, showScore: r = !1, children: i, skeletonDelay: a = 0, skeletonWidths: o = [62, 38] }) => /* @__PURE__ */ p("div", {
|
|
745
|
-
className: B.row,
|
|
1254
|
+
}, He = {
|
|
1255
|
+
placeholder: "_placeholder_1qr5o_1",
|
|
1256
|
+
invalid: "_invalid_1qr5o_11",
|
|
1257
|
+
searchedFor: "_searchedFor_1qr5o_17"
|
|
1258
|
+
}, Ue = {
|
|
1259
|
+
row: "_row_11svi_1",
|
|
1260
|
+
content: "_content_11svi_22",
|
|
1261
|
+
indexNumber: "_indexNumber_11svi_36",
|
|
1262
|
+
scoreNumber: "_scoreNumber_11svi_44",
|
|
1263
|
+
skeletonBars: "_skeletonBars_11svi_53"
|
|
1264
|
+
}, We = ({ skeleton: e = !1, index: t, score: n, showScore: r = !1, children: i, skeletonDelay: a = 0, skeletonWidths: o = [62, 38] }) => /* @__PURE__ */ p("div", {
|
|
1265
|
+
className: Ue.row,
|
|
746
1266
|
children: [
|
|
747
1267
|
t !== void 0 && /* @__PURE__ */ f("div", {
|
|
748
|
-
className:
|
|
1268
|
+
className: Ue.indexNumber,
|
|
749
1269
|
children: t
|
|
750
1270
|
}),
|
|
751
1271
|
/* @__PURE__ */ f("div", {
|
|
752
|
-
className:
|
|
1272
|
+
className: Ue.content,
|
|
753
1273
|
children: e ? /* @__PURE__ */ p("div", {
|
|
754
|
-
className:
|
|
755
|
-
children: [/* @__PURE__ */ f(
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
}), /* @__PURE__ */ f(
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
1274
|
+
className: Ue.skeletonBars,
|
|
1275
|
+
children: [/* @__PURE__ */ f(A, {
|
|
1276
|
+
level: 3,
|
|
1277
|
+
height: 12,
|
|
1278
|
+
width: `${o[0]}%`,
|
|
1279
|
+
delay: a,
|
|
1280
|
+
appear: !1
|
|
1281
|
+
}), /* @__PURE__ */ f(A, {
|
|
1282
|
+
level: 3,
|
|
1283
|
+
height: 8,
|
|
1284
|
+
width: `${o[1]}%`,
|
|
1285
|
+
delay: a + .05,
|
|
1286
|
+
appear: !1
|
|
767
1287
|
})]
|
|
768
1288
|
}) : i
|
|
769
1289
|
}),
|
|
770
1290
|
r && n !== void 0 && /* @__PURE__ */ f("div", {
|
|
771
|
-
className:
|
|
1291
|
+
className: Ue.scoreNumber,
|
|
772
1292
|
children: n
|
|
773
1293
|
})
|
|
774
1294
|
]
|
|
775
|
-
}),
|
|
776
|
-
wrapper: "
|
|
777
|
-
skeletonAppear: "
|
|
778
|
-
},
|
|
1295
|
+
}), Ge = {
|
|
1296
|
+
wrapper: "_wrapper_f970z_6",
|
|
1297
|
+
skeletonAppear: "_skeletonAppear_f970z_1"
|
|
1298
|
+
}, Ke = [
|
|
779
1299
|
[62, 38],
|
|
780
1300
|
[75, 45],
|
|
781
1301
|
[58, 33],
|
|
@@ -784,121 +1304,130 @@ var F = n(void 0), I = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
784
1304
|
[55, 35],
|
|
785
1305
|
[72, 40],
|
|
786
1306
|
[60, 30]
|
|
787
|
-
],
|
|
788
|
-
className:
|
|
789
|
-
children: Array.from({ length: e }).map((e, t) => /* @__PURE__ */ f(
|
|
1307
|
+
], qe = ({ rows: e = 6 }) => /* @__PURE__ */ f("div", {
|
|
1308
|
+
className: Ge.wrapper,
|
|
1309
|
+
children: Array.from({ length: e }).map((e, t) => /* @__PURE__ */ f(We, {
|
|
790
1310
|
skeleton: !0,
|
|
791
1311
|
skeletonDelay: t * .1,
|
|
792
|
-
skeletonWidths:
|
|
1312
|
+
skeletonWidths: Ke[t % Ke.length]
|
|
793
1313
|
}, t))
|
|
794
|
-
}),
|
|
795
|
-
function
|
|
1314
|
+
}), Je = /^\[\s*(?:'[^']*'(?:\s*,\s*'[^']*')*)?\s*\]$/;
|
|
1315
|
+
function Ye(e) {
|
|
796
1316
|
let t = e.trim();
|
|
797
1317
|
if (!t.startsWith("[") || !t.endsWith("]")) return;
|
|
798
1318
|
try {
|
|
799
1319
|
let e = JSON.parse(t);
|
|
800
1320
|
if (Array.isArray(e)) return e.map((e) => String(e));
|
|
801
1321
|
} catch {}
|
|
802
|
-
if (!
|
|
1322
|
+
if (!Je.test(t)) return;
|
|
803
1323
|
let n = [], r = /'([^']*)'/g, i;
|
|
804
1324
|
for (; (i = r.exec(t)) !== null;) n.push(i[1]);
|
|
805
1325
|
return n;
|
|
806
1326
|
}
|
|
807
|
-
var
|
|
808
|
-
let { state: { results:
|
|
1327
|
+
var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk: r, showScore: i, children: a }) => {
|
|
1328
|
+
let { state: { results: s, resultsSuppressed: u, searchSettings: m, truncationIndex: h, query: g, error: _, errorInfo: v }, isFetchingInitial: b, authError: x, authErrorInfo: S, retry: C, allowEmptySearch: w, fetchMoreResults: T, selectResult: E, searchText: D, searchAsTyped: O } = Y(), k = t ?? 30, [A, j] = l(k), M = c(0), N = c("");
|
|
809
1329
|
o(() => {
|
|
810
|
-
let e =
|
|
811
|
-
(!
|
|
1330
|
+
let e = g !== N.current;
|
|
1331
|
+
(!s || s.length < M.current || e) && j(k), M.current = s?.length ?? 0, N.current = g;
|
|
812
1332
|
}, [
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
1333
|
+
s,
|
|
1334
|
+
k,
|
|
1335
|
+
g
|
|
816
1336
|
]);
|
|
817
|
-
let
|
|
818
|
-
let e =
|
|
819
|
-
|
|
1337
|
+
let P = s ? Te(s, h, !!r?.cutResults, r?.cutRule) : [], F = D != null && D.trim() !== g.trim() ? D : null, I = s && P.length > A, L = () => {
|
|
1338
|
+
let e = A + k;
|
|
1339
|
+
j(e), s && e >= s.length && (!h || h === -1 || h > s.length) && T(s.length + k);
|
|
820
1340
|
};
|
|
821
|
-
if (
|
|
822
|
-
className:
|
|
823
|
-
children: /* @__PURE__ */ f(
|
|
1341
|
+
if (b) return w ? /* @__PURE__ */ f(qe, { rows: k }) : /* @__PURE__ */ f("div", {
|
|
1342
|
+
className: He.placeholder,
|
|
1343
|
+
children: /* @__PURE__ */ f(W, {
|
|
824
1344
|
size: 200,
|
|
825
1345
|
color: "var(--lv5)"
|
|
826
1346
|
})
|
|
827
1347
|
});
|
|
828
|
-
let
|
|
829
|
-
return
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
1348
|
+
let R = x ?? _;
|
|
1349
|
+
return R ? /* @__PURE__ */ f(Ve, {
|
|
1350
|
+
error: (x ? S : v) ?? {
|
|
1351
|
+
kind: "unknown",
|
|
1352
|
+
message: R,
|
|
1353
|
+
technical: R,
|
|
1354
|
+
retryable: !1
|
|
1355
|
+
},
|
|
1356
|
+
onRetry: C
|
|
1357
|
+
}) : u || s === null ? /* @__PURE__ */ f("div", {
|
|
1358
|
+
className: He.placeholder,
|
|
1359
|
+
children: /* @__PURE__ */ f(W, {
|
|
836
1360
|
size: 200,
|
|
837
1361
|
color: "var(--lv5)"
|
|
838
1362
|
})
|
|
839
|
-
}) :
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
if (typeof t == "string") {
|
|
860
|
-
let n = G(t);
|
|
861
|
-
n && (l[e] = n);
|
|
1363
|
+
}) : P.length === 0 ? null : /* @__PURE__ */ p(d, { children: [
|
|
1364
|
+
F && /* @__PURE__ */ p("div", {
|
|
1365
|
+
className: He.searchedFor,
|
|
1366
|
+
"aria-live": "polite",
|
|
1367
|
+
children: [/* @__PURE__ */ p("span", { children: ["Searching for ", /* @__PURE__ */ f("strong", { children: F })] }), O && /* @__PURE__ */ f(y, {
|
|
1368
|
+
variant: "ghost",
|
|
1369
|
+
size: "micro",
|
|
1370
|
+
onClick: O,
|
|
1371
|
+
children: "Search for your exact words"
|
|
1372
|
+
})]
|
|
1373
|
+
}),
|
|
1374
|
+
/* @__PURE__ */ f("div", { children: P.slice(0, A).map((t, r) => {
|
|
1375
|
+
let o = t.document, s = t.score, c;
|
|
1376
|
+
try {
|
|
1377
|
+
c = typeof o == "string" ? JSON.parse(o) : o;
|
|
1378
|
+
} catch {
|
|
1379
|
+
return /* @__PURE__ */ f("div", {
|
|
1380
|
+
className: He.invalid,
|
|
1381
|
+
children: /* @__PURE__ */ f("p", { children: "Invalid JSON" })
|
|
1382
|
+
}, r);
|
|
862
1383
|
}
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
1384
|
+
let l;
|
|
1385
|
+
if (e && e.length > 0) {
|
|
1386
|
+
l = {};
|
|
1387
|
+
for (let t of e) t in c && (l[t] = c[t]);
|
|
1388
|
+
} else l = { ...c };
|
|
1389
|
+
if (n) for (let e in l) {
|
|
1390
|
+
let t = l[e];
|
|
1391
|
+
if (typeof t == "string") {
|
|
1392
|
+
let n = Ye(t);
|
|
1393
|
+
n && (l[e] = n);
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
return /* @__PURE__ */ f(We, {
|
|
1397
|
+
index: r,
|
|
1398
|
+
score: s,
|
|
1399
|
+
showScore: i ?? m.showScore,
|
|
1400
|
+
children: a(l, {
|
|
1401
|
+
result: t,
|
|
1402
|
+
select: () => E?.(t) ?? Promise.resolve()
|
|
1403
|
+
})
|
|
1404
|
+
}, r);
|
|
1405
|
+
}) }),
|
|
1406
|
+
I && /* @__PURE__ */ f("div", {
|
|
1407
|
+
style: {
|
|
1408
|
+
textAlign: "center",
|
|
1409
|
+
marginTop: "20px"
|
|
1410
|
+
},
|
|
1411
|
+
children: /* @__PURE__ */ f(y, {
|
|
1412
|
+
variant: "secondary",
|
|
1413
|
+
size: "micro",
|
|
1414
|
+
onClick: L,
|
|
1415
|
+
children: g.trim() === "" ? "Load more" : h !== -1 && h !== void 0 && h > 0 ? `Load results ${A + 1}-${Math.min(A + k, s.length, h)} of ${h}` : "Load more"
|
|
871
1416
|
})
|
|
872
|
-
}, i);
|
|
873
|
-
}) }), O && /* @__PURE__ */ f("div", {
|
|
874
|
-
style: {
|
|
875
|
-
textAlign: "center",
|
|
876
|
-
marginTop: "20px"
|
|
877
|
-
},
|
|
878
|
-
children: /* @__PURE__ */ f(m, {
|
|
879
|
-
variant: "secondary",
|
|
880
|
-
size: "micro",
|
|
881
|
-
onClick: k,
|
|
882
|
-
children: h.trim() === "" ? "Load more" : u !== -1 && u !== void 0 && u > 0 ? `Load results ${C + 1}-${Math.min(C + S, i.length, u)} of ${u}` : "Load more"
|
|
883
1417
|
})
|
|
884
|
-
|
|
885
|
-
},
|
|
1418
|
+
] });
|
|
1419
|
+
}, Ze = {
|
|
886
1420
|
row: "_row_ujwhc_1",
|
|
887
1421
|
title: "_title_ujwhc_8"
|
|
888
|
-
},
|
|
889
|
-
className: [
|
|
1422
|
+
}, Qe = ({ variant: e = "default", children: t }) => /* @__PURE__ */ f("div", {
|
|
1423
|
+
className: [Ze.row, e === "title" ? Ze.title : ""].filter(Boolean).join(" "),
|
|
890
1424
|
children: t
|
|
891
|
-
}),
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
sliderTrack: "_sliderTrack_4nxla_32",
|
|
898
|
-
inputRow: "_inputRow_4nxla_40",
|
|
899
|
-
inputBar: "_inputBar_4nxla_45",
|
|
900
|
-
histogramRow: "_histogramRow_4nxla_55"
|
|
901
|
-
}, re = [
|
|
1425
|
+
}), $e = {
|
|
1426
|
+
listRows: "_listRows_13obt_2",
|
|
1427
|
+
sliderArea: "_sliderArea_13obt_8",
|
|
1428
|
+
inputRow: "_inputRow_13obt_15",
|
|
1429
|
+
histogramRow: "_histogramRow_13obt_22"
|
|
1430
|
+
}, et = [
|
|
902
1431
|
65,
|
|
903
1432
|
80,
|
|
904
1433
|
55,
|
|
@@ -907,37 +1436,36 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
907
1436
|
75,
|
|
908
1437
|
50,
|
|
909
1438
|
68
|
|
910
|
-
],
|
|
1439
|
+
], tt = ({ title: e, rows: t = 5, variant: n = "list", withHistogram: r = !1, collapsible: i = !0, startCollapsed: a = !1 }) => /* @__PURE__ */ f(T, {
|
|
911
1440
|
title: e,
|
|
912
1441
|
collapsible: i,
|
|
913
1442
|
collapsed: a,
|
|
914
1443
|
children: n === "slider" ? /* @__PURE__ */ p("div", {
|
|
915
|
-
className:
|
|
1444
|
+
className: $e.sliderArea,
|
|
916
1445
|
children: [
|
|
917
|
-
r && /* @__PURE__ */ f("div", { className:
|
|
918
|
-
/* @__PURE__ */ f(
|
|
1446
|
+
r && /* @__PURE__ */ f("div", { className: $e.histogramRow }),
|
|
1447
|
+
/* @__PURE__ */ f(A, { height: 6 }),
|
|
919
1448
|
/* @__PURE__ */ p("div", {
|
|
920
|
-
className:
|
|
921
|
-
children: [/* @__PURE__ */ f(
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
1449
|
+
className: $e.inputRow,
|
|
1450
|
+
children: [/* @__PURE__ */ f(A, {
|
|
1451
|
+
width: 40,
|
|
1452
|
+
height: 20,
|
|
1453
|
+
delay: .1
|
|
1454
|
+
}), /* @__PURE__ */ f(A, {
|
|
1455
|
+
width: 40,
|
|
1456
|
+
height: 20,
|
|
1457
|
+
delay: .15
|
|
927
1458
|
})]
|
|
928
1459
|
})
|
|
929
1460
|
]
|
|
930
1461
|
}) : /* @__PURE__ */ f("div", {
|
|
931
|
-
className:
|
|
932
|
-
children: Array.from({ length: t }).map((e, t) => /* @__PURE__ */ f(
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
width: `${re[t % re.length]}%`,
|
|
936
|
-
animationDelay: `${t * .05}s`
|
|
937
|
-
}
|
|
1462
|
+
className: $e.listRows,
|
|
1463
|
+
children: Array.from({ length: t }).map((e, t) => /* @__PURE__ */ f(A, {
|
|
1464
|
+
width: `${et[t % et.length]}%`,
|
|
1465
|
+
delay: t * .05
|
|
938
1466
|
}, t))
|
|
939
1467
|
})
|
|
940
|
-
}),
|
|
1468
|
+
}), X = {
|
|
941
1469
|
list: "_list_18vbb_2",
|
|
942
1470
|
count: "_count_18vbb_7",
|
|
943
1471
|
countValue: "_countValue_18vbb_17",
|
|
@@ -945,55 +1473,66 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
945
1473
|
chipLabel: "_chipLabel_18vbb_32",
|
|
946
1474
|
grid: "_grid_18vbb_40",
|
|
947
1475
|
active: "_active_18vbb_54"
|
|
948
|
-
},
|
|
949
|
-
|
|
1476
|
+
}, nt = {
|
|
1477
|
+
notice: "_notice_4sel0_1",
|
|
1478
|
+
technical: "_technical_4sel0_9"
|
|
1479
|
+
}, rt = ({ label: e, field: t, missing: n }) => {
|
|
1480
|
+
let r = n.map((e) => e[0].toUpperCase() + e.slice(1)).join(" and ");
|
|
1481
|
+
return o(() => {
|
|
1482
|
+
console.warn(`[intrface] The panel for "${t}" is hidden: the field is not ${r}. Mark it ${r} in the dataset's field configuration (web console → Fields).`);
|
|
1483
|
+
}, [t, r]), /* @__PURE__ */ f(T, {
|
|
1484
|
+
title: e ?? t,
|
|
1485
|
+
collapsible: !1,
|
|
1486
|
+
children: /* @__PURE__ */ p("div", {
|
|
1487
|
+
className: nt.notice,
|
|
1488
|
+
children: [/* @__PURE__ */ f("span", { children: "Not available" }), /* @__PURE__ */ p("code", {
|
|
1489
|
+
className: nt.technical,
|
|
1490
|
+
children: [
|
|
1491
|
+
t,
|
|
1492
|
+
": not ",
|
|
1493
|
+
r
|
|
1494
|
+
]
|
|
1495
|
+
})]
|
|
1496
|
+
})
|
|
1497
|
+
});
|
|
1498
|
+
}, it = ({ field: e, label: t, preserveBlankFacetState: n = !1, preserveBlankFacetStateOrder: r = !1, sortFacetsBy: i = "histogram", limit: a = 10, collapsible: s = !0, startCollapsed: u = !1, control: d, displayType: m, layout: h = "list", showActivePanel: g = !1, showCount: _ = !0, showNull: v = !1, match: x = "all", displayIfEmptyQuery: S = !0, displayCondition: C = (e) => !0 }) => {
|
|
1499
|
+
let { state: { facets: w, filterableFields: E, facetableFields: O, filters: k, query: A }, toggleFilter: j, setValueMatch: M, authError: P, isFetchingInitial: F, allowEmptySearch: I } = Y(), L = d ?? m ?? "checkbox", R = L === "radio" ? "any" : x;
|
|
950
1500
|
o(() => {
|
|
951
|
-
|
|
1501
|
+
M(e, R);
|
|
952
1502
|
}, [
|
|
953
1503
|
e,
|
|
954
1504
|
R,
|
|
955
|
-
|
|
1505
|
+
M
|
|
956
1506
|
]);
|
|
957
1507
|
let z = c(null), [B, V] = l(a);
|
|
958
1508
|
if (o(() => {
|
|
959
1509
|
V(a);
|
|
960
|
-
}, [
|
|
961
|
-
if (
|
|
1510
|
+
}, [w?.[e], a]), !I && !A || P) return null;
|
|
1511
|
+
if (F || !w) return L === "toggle" ? /* @__PURE__ */ f(tt, {
|
|
962
1512
|
rows: 1,
|
|
963
1513
|
collapsible: !1
|
|
964
|
-
}) : /* @__PURE__ */ f(
|
|
1514
|
+
}) : /* @__PURE__ */ f(tt, {
|
|
965
1515
|
title: t,
|
|
966
1516
|
rows: Math.min(a, 6),
|
|
967
1517
|
collapsible: s,
|
|
968
1518
|
startCollapsed: u
|
|
969
1519
|
});
|
|
970
|
-
if (!
|
|
971
|
-
query:
|
|
972
|
-
filters:
|
|
973
|
-
facets:
|
|
974
|
-
}) || !
|
|
975
|
-
if (!
|
|
976
|
-
let
|
|
977
|
-
return
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
color: "red",
|
|
982
|
-
fontSize: "12px"
|
|
983
|
-
},
|
|
984
|
-
children: [
|
|
985
|
-
"Cannot render filter for \"",
|
|
986
|
-
e,
|
|
987
|
-
"\": missing ",
|
|
988
|
-
t.join(" and "),
|
|
989
|
-
"."
|
|
990
|
-
]
|
|
991
|
-
})
|
|
1520
|
+
if (!C({
|
|
1521
|
+
query: A ?? "",
|
|
1522
|
+
filters: k,
|
|
1523
|
+
facets: w
|
|
1524
|
+
}) || !S && !A && Object.keys(k).length < 1) return null;
|
|
1525
|
+
if (!E?.includes(e) || !O?.includes(e)) {
|
|
1526
|
+
let n = [];
|
|
1527
|
+
return E?.includes(e) || n.push("filterable"), O?.includes(e) || n.push("facetable"), /* @__PURE__ */ f(rt, {
|
|
1528
|
+
label: t,
|
|
1529
|
+
field: e,
|
|
1530
|
+
missing: n
|
|
992
1531
|
});
|
|
993
1532
|
}
|
|
994
|
-
let H =
|
|
1533
|
+
let H = w?.[e] ?? (L === "toggle" ? [] : void 0);
|
|
995
1534
|
if (!H || !Array.isArray(H)) return null;
|
|
996
|
-
let U =
|
|
1535
|
+
let U = k?.[e] ?? [];
|
|
997
1536
|
n && !z.current && H.length > 0 && (z.current = H.reduce((e, t) => (e[t.key] = t.value, e), {}));
|
|
998
1537
|
let W = /* @__PURE__ */ new Map();
|
|
999
1538
|
n && z.current && Object.keys(z.current).forEach((e) => {
|
|
@@ -1005,16 +1544,16 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
1005
1544
|
"true",
|
|
1006
1545
|
"false",
|
|
1007
1546
|
"null"
|
|
1008
|
-
]), G = Array.from(W.keys()), te =
|
|
1547
|
+
]), G = Array.from(W.keys()), te = L === "toggle" && (G.length > 0 && G.every((e) => ee.has(e)) || G.length === 0 && U.length > 0);
|
|
1009
1548
|
if (te && W.has("null")) {
|
|
1010
1549
|
let e = W.get("null") ?? 0, t = W.get("false") ?? 0;
|
|
1011
1550
|
W.set("false", t + e), W.delete("null");
|
|
1012
1551
|
}
|
|
1013
|
-
if (
|
|
1552
|
+
if (L === "toggle" && !te) return /* @__PURE__ */ f(T, {
|
|
1014
1553
|
collapsible: !1,
|
|
1015
1554
|
children: /* @__PURE__ */ f("div", {
|
|
1016
|
-
className:
|
|
1017
|
-
children: /* @__PURE__ */ f(
|
|
1555
|
+
className: X.count,
|
|
1556
|
+
children: /* @__PURE__ */ f(N, {
|
|
1018
1557
|
label: t,
|
|
1019
1558
|
checked: !1,
|
|
1020
1559
|
onChange: () => {},
|
|
@@ -1023,16 +1562,16 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
1023
1562
|
})
|
|
1024
1563
|
});
|
|
1025
1564
|
if (te) {
|
|
1026
|
-
let n = W.get("true"), r = typeof n == "number" ? n : null, i = U.includes("true"), a = r === 0 && !i, o =
|
|
1027
|
-
return /* @__PURE__ */ f(
|
|
1565
|
+
let n = W.get("true"), r = typeof n == "number" ? n : null, i = U.includes("true"), a = r === 0 && !i, o = _ && (r ?? 0) > 0 ? `${r}` : "";
|
|
1566
|
+
return /* @__PURE__ */ f(T, {
|
|
1028
1567
|
collapsible: !1,
|
|
1029
1568
|
children: /* @__PURE__ */ p("div", {
|
|
1030
|
-
className:
|
|
1569
|
+
className: X.count,
|
|
1031
1570
|
children: [
|
|
1032
|
-
/* @__PURE__ */ f(
|
|
1571
|
+
/* @__PURE__ */ f(N, {
|
|
1033
1572
|
label: t,
|
|
1034
1573
|
checked: i,
|
|
1035
|
-
onChange: () =>
|
|
1574
|
+
onChange: () => j(e, "true"),
|
|
1036
1575
|
disabled: a
|
|
1037
1576
|
}),
|
|
1038
1577
|
" ",
|
|
@@ -1042,7 +1581,7 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
1042
1581
|
});
|
|
1043
1582
|
}
|
|
1044
1583
|
let K = Array.from(W.entries());
|
|
1045
|
-
if (
|
|
1584
|
+
if (v || (K = K.filter(([e]) => e !== "null")), K.length === 0 && !n) return null;
|
|
1046
1585
|
if (!r) if (i === "alphabetical") {
|
|
1047
1586
|
let e = K.filter(([, e]) => typeof e == "number" && e > 0).sort(([e], [t]) => e.localeCompare(t)), t = K.filter(([, e]) => e === 0 || e === null).sort(([e], [t]) => e.localeCompare(t));
|
|
1048
1587
|
K = [...e, ...t];
|
|
@@ -1056,75 +1595,75 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
1056
1595
|
let e = K.filter(([, e]) => typeof e == "number" && e > 0), t = K.filter(([, e]) => e === 0 || e === null);
|
|
1057
1596
|
K = [...e, ...t];
|
|
1058
1597
|
}
|
|
1059
|
-
let
|
|
1060
|
-
let r = U.includes(t), i = n === 0, a =
|
|
1061
|
-
switch (
|
|
1062
|
-
case "button": return
|
|
1063
|
-
className:
|
|
1064
|
-
children: [/* @__PURE__ */ f(
|
|
1598
|
+
let ne = typeof a == "number" && K.length > a, re = ne ? K.slice(0, B) : K, ie = (t, n) => {
|
|
1599
|
+
let r = U.includes(t), i = n === 0, a = _ && (n ?? 0) > 0 ? ` (${n})` : "", o = _ && (n ?? 0) > 0 ? n : "", s = () => j(e, t, L === "radio");
|
|
1600
|
+
switch (L) {
|
|
1601
|
+
case "button": return h === "list" ? /* @__PURE__ */ p("div", {
|
|
1602
|
+
className: X.count,
|
|
1603
|
+
children: [/* @__PURE__ */ f(y, {
|
|
1065
1604
|
variant: r ? "primary" : "secondary",
|
|
1066
1605
|
onClick: s,
|
|
1067
1606
|
disabled: i,
|
|
1068
1607
|
size: "micro",
|
|
1069
|
-
className:
|
|
1608
|
+
className: X.chip,
|
|
1070
1609
|
title: t,
|
|
1071
1610
|
children: /* @__PURE__ */ f("span", {
|
|
1072
|
-
className:
|
|
1611
|
+
className: X.chipLabel,
|
|
1073
1612
|
children: t
|
|
1074
1613
|
})
|
|
1075
1614
|
}), /* @__PURE__ */ f("span", {
|
|
1076
|
-
className:
|
|
1615
|
+
className: X.countValue,
|
|
1077
1616
|
children: o
|
|
1078
1617
|
})]
|
|
1079
|
-
}) : /* @__PURE__ */ f(
|
|
1618
|
+
}) : /* @__PURE__ */ f(y, {
|
|
1080
1619
|
variant: r ? "primary" : "secondary",
|
|
1081
1620
|
onClick: s,
|
|
1082
1621
|
disabled: i,
|
|
1083
1622
|
size: "micro",
|
|
1084
|
-
className:
|
|
1623
|
+
className: X.chip,
|
|
1085
1624
|
title: `${t}${a}`,
|
|
1086
1625
|
children: /* @__PURE__ */ f("span", {
|
|
1087
|
-
className:
|
|
1626
|
+
className: X.chipLabel,
|
|
1088
1627
|
children: `${t}${a}`
|
|
1089
1628
|
})
|
|
1090
1629
|
});
|
|
1091
|
-
case "toggle": return /* @__PURE__ */ f(
|
|
1630
|
+
case "toggle": return /* @__PURE__ */ f(N, {
|
|
1092
1631
|
label: t,
|
|
1093
1632
|
checked: r,
|
|
1094
1633
|
onChange: s,
|
|
1095
1634
|
disabled: i
|
|
1096
1635
|
});
|
|
1097
1636
|
case "radio": {
|
|
1098
|
-
let n = /* @__PURE__ */ f(
|
|
1637
|
+
let n = /* @__PURE__ */ f(D, {
|
|
1099
1638
|
id: `${e}-${t}`,
|
|
1100
1639
|
name: e,
|
|
1101
1640
|
value: t,
|
|
1102
|
-
label:
|
|
1641
|
+
label: h === "grid" ? `${t}${a}` : t,
|
|
1103
1642
|
checked: r,
|
|
1104
1643
|
onChange: s,
|
|
1105
1644
|
disabled: i
|
|
1106
1645
|
});
|
|
1107
|
-
return
|
|
1108
|
-
className:
|
|
1646
|
+
return h === "list" ? /* @__PURE__ */ p("div", {
|
|
1647
|
+
className: X.count,
|
|
1109
1648
|
children: [n, /* @__PURE__ */ f("span", {
|
|
1110
|
-
className:
|
|
1649
|
+
className: X.countValue,
|
|
1111
1650
|
children: o
|
|
1112
1651
|
})]
|
|
1113
1652
|
}) : n;
|
|
1114
1653
|
}
|
|
1115
|
-
default: return
|
|
1116
|
-
className:
|
|
1117
|
-
children: [/* @__PURE__ */ f(
|
|
1654
|
+
default: return h === "list" ? /* @__PURE__ */ p("div", {
|
|
1655
|
+
className: X.count,
|
|
1656
|
+
children: [/* @__PURE__ */ f(b, {
|
|
1118
1657
|
label: t,
|
|
1119
1658
|
score: "",
|
|
1120
1659
|
checked: r,
|
|
1121
1660
|
onChange: s,
|
|
1122
1661
|
disabled: i
|
|
1123
1662
|
}), /* @__PURE__ */ f("span", {
|
|
1124
|
-
className:
|
|
1663
|
+
className: X.countValue,
|
|
1125
1664
|
children: o
|
|
1126
1665
|
})]
|
|
1127
|
-
}) : /* @__PURE__ */ f(
|
|
1666
|
+
}) : /* @__PURE__ */ f(b, {
|
|
1128
1667
|
label: t,
|
|
1129
1668
|
score: a,
|
|
1130
1669
|
checked: r,
|
|
@@ -1133,23 +1672,23 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
1133
1672
|
});
|
|
1134
1673
|
}
|
|
1135
1674
|
};
|
|
1136
|
-
return /* @__PURE__ */ f(
|
|
1675
|
+
return /* @__PURE__ */ f(T, {
|
|
1137
1676
|
title: t,
|
|
1138
1677
|
collapsible: s,
|
|
1139
1678
|
collapsed: s ? u : !1,
|
|
1140
|
-
className:
|
|
1679
|
+
className: g && U.length > 0 ? X.active : void 0,
|
|
1141
1680
|
children: /* @__PURE__ */ p("ul", {
|
|
1142
|
-
className:
|
|
1681
|
+
className: h === "grid" ? X.grid : X.list,
|
|
1143
1682
|
style: {
|
|
1144
1683
|
listStyle: "none",
|
|
1145
1684
|
padding: 0,
|
|
1146
1685
|
margin: 0
|
|
1147
1686
|
},
|
|
1148
|
-
children: [
|
|
1687
|
+
children: [re.map(([e, t]) => /* @__PURE__ */ f("li", { children: ie(e, t) }, e)), ne && B < K.length && (() => {
|
|
1149
1688
|
let e = K.length - B, t = Math.min(50, e);
|
|
1150
1689
|
return /* @__PURE__ */ f("li", {
|
|
1151
|
-
className:
|
|
1152
|
-
children: /* @__PURE__ */ f(
|
|
1690
|
+
className: X.toggleItem,
|
|
1691
|
+
children: /* @__PURE__ */ f(y, {
|
|
1153
1692
|
variant: "ghost",
|
|
1154
1693
|
size: "micro",
|
|
1155
1694
|
onClick: () => V((e) => e + 50),
|
|
@@ -1159,7 +1698,7 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
1159
1698
|
})()]
|
|
1160
1699
|
})
|
|
1161
1700
|
});
|
|
1162
|
-
},
|
|
1701
|
+
}, Z = {
|
|
1163
1702
|
disabledMessage: "_disabledMessage_adany_1",
|
|
1164
1703
|
histogram: "_histogram_adany_6",
|
|
1165
1704
|
histogramLayer: "_histogramLayer_adany_14",
|
|
@@ -1173,219 +1712,219 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
1173
1712
|
};
|
|
1174
1713
|
//#endregion
|
|
1175
1714
|
//#region src/utils/numeric.ts
|
|
1176
|
-
function
|
|
1715
|
+
function at(e) {
|
|
1177
1716
|
if (!Number.isFinite(e)) return 0;
|
|
1178
1717
|
let t = String(e), n = t.indexOf(".");
|
|
1179
1718
|
return n === -1 ? 0 : Math.min(6, t.length - n - 1);
|
|
1180
1719
|
}
|
|
1181
|
-
function
|
|
1720
|
+
function ot(e) {
|
|
1182
1721
|
let t = 0;
|
|
1183
|
-
for (let n of e) t = Math.max(t,
|
|
1722
|
+
for (let n of e) t = Math.max(t, at(n));
|
|
1184
1723
|
return t === 0 ? 1 : Number((10 ** -t).toFixed(t));
|
|
1185
1724
|
}
|
|
1186
|
-
function
|
|
1187
|
-
return Number(e.toFixed(
|
|
1725
|
+
function Q(e, t) {
|
|
1726
|
+
return Number(e.toFixed(at(t)));
|
|
1188
1727
|
}
|
|
1189
1728
|
//#endregion
|
|
1190
1729
|
//#region src/components/RangeFilterPanel.tsx
|
|
1191
|
-
function
|
|
1730
|
+
function st(e, t, n) {
|
|
1192
1731
|
let r = t + Math.round((e - t) / n) * n;
|
|
1193
|
-
return Number(r.toFixed(
|
|
1732
|
+
return Number(r.toFixed(at(n)));
|
|
1194
1733
|
}
|
|
1195
|
-
function
|
|
1734
|
+
function ct(e, t, n) {
|
|
1196
1735
|
let r = Math.ceil(Number(((e - t) / n).toFixed(6)));
|
|
1197
|
-
return Number((t + r * n).toFixed(
|
|
1736
|
+
return Number((t + r * n).toFixed(at(n)));
|
|
1198
1737
|
}
|
|
1199
|
-
var
|
|
1200
|
-
let { state: { rangeFilters:
|
|
1738
|
+
var lt = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, control: a, displayType: o, showActivePanel: s = !1, collapsible: c = !0, startCollapsed: l = !1, showHistogram: u = !1, resolution: d, step: m, stepMarks: h }) => {
|
|
1739
|
+
let { state: { rangeFilters: g, rangeBounds: _, facetStats: v, facets: y, filterableFields: b, facetableFields: x, query: S, facetDebounceDelayMillis: C }, setRangeFilter: w, resetRangeFilter: D, allowEmptySearch: O, authError: k, isFetchingInitial: A } = Y(), M = a ?? o ?? "input", N = _?.[t] !== void 0, P = _?.[t] ?? {
|
|
1201
1740
|
min: r,
|
|
1202
1741
|
max: i
|
|
1203
|
-
},
|
|
1742
|
+
}, F = P.min, I = P.max, L = v?.[t] ?? P, R = Math.max(F, Math.min(I, L.min)), z = Math.max(F, Math.min(I, L.max)), B = e.useMemo(() => {
|
|
1204
1743
|
if (m) return m;
|
|
1205
|
-
let e = Math.max(
|
|
1206
|
-
if (Array.isArray(n)) for (let t of n) e = Math.max(e,
|
|
1744
|
+
let e = Math.max(at(F), at(I)), n = y?.[t];
|
|
1745
|
+
if (Array.isArray(n)) for (let t of n) e = Math.max(e, at(Number(t.key)));
|
|
1207
1746
|
return e === 0 ? 1 : Number((10 ** -e).toFixed(e));
|
|
1208
1747
|
}, [
|
|
1209
1748
|
m,
|
|
1210
|
-
P,
|
|
1211
1749
|
F,
|
|
1212
|
-
|
|
1750
|
+
I,
|
|
1751
|
+
y,
|
|
1213
1752
|
t
|
|
1214
|
-
]), V =
|
|
1215
|
-
let e =
|
|
1216
|
-
return { width: `calc(${Math.max(3,
|
|
1753
|
+
]), V = N && F === I, H = V ? r : F, U = V ? i : I, W = ct(U + B, H, B), ee = (e) => Math.min(W, Math.max(H, e)), G = g?.[t], te = s && G !== void 0 ? Z.active : void 0, K = G ? G.min : F, ne = G ? G.max : I, re = G !== void 0, ie = R !== F || z !== I, [q, J] = e.useState([K, ne]), [ae, oe] = e.useState(!1), [se, ce] = e.useState(!1), [le, ue] = e.useState(String(K)), [de, fe] = e.useState(String(ne)), pe = e.useMemo(() => {
|
|
1754
|
+
let e = at(B);
|
|
1755
|
+
return { width: `calc(${Math.max(3, F.toFixed(e).length, I.toFixed(e).length, le.length, de.length) + 1}ch + 20px)` };
|
|
1217
1756
|
}, [
|
|
1218
1757
|
B,
|
|
1219
|
-
P,
|
|
1220
1758
|
F,
|
|
1221
|
-
|
|
1222
|
-
|
|
1759
|
+
I,
|
|
1760
|
+
le,
|
|
1761
|
+
de
|
|
1223
1762
|
]);
|
|
1224
1763
|
e.useEffect(() => {
|
|
1225
|
-
|
|
1226
|
-
}, [
|
|
1227
|
-
let { finalMin:
|
|
1228
|
-
let [e, t] =
|
|
1764
|
+
ue(String(q[0])), fe(String(q[1]));
|
|
1765
|
+
}, [q]);
|
|
1766
|
+
let { finalMin: me, finalMax: he, isValidMin: ge, isValidMax: _e } = e.useMemo(() => {
|
|
1767
|
+
let [e, t] = q, n = Math.max(F, Math.min(I, e)), r = Math.max(F, Math.min(I, t)), i = Math.min(n, r), a = Math.max(n, r);
|
|
1229
1768
|
return {
|
|
1230
1769
|
finalMin: i,
|
|
1231
1770
|
finalMax: a,
|
|
1232
|
-
isValidMin: i >=
|
|
1233
|
-
isValidMax: a <=
|
|
1771
|
+
isValidMin: i >= F && i <= a,
|
|
1772
|
+
isValidMax: a <= I && a >= i
|
|
1234
1773
|
};
|
|
1235
1774
|
}, [
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1775
|
+
q,
|
|
1776
|
+
F,
|
|
1777
|
+
I
|
|
1239
1778
|
]);
|
|
1240
1779
|
e.useEffect(() => {
|
|
1241
1780
|
if (V) return;
|
|
1242
|
-
if (
|
|
1243
|
-
|
|
1781
|
+
if (q[0] === F && q[1] === I) {
|
|
1782
|
+
oe(!1), ce(!1);
|
|
1244
1783
|
return;
|
|
1245
1784
|
}
|
|
1246
|
-
let e =
|
|
1247
|
-
|
|
1785
|
+
let e = C ?? 500, n = setTimeout(() => {
|
|
1786
|
+
oe(!ge), ce(!_e);
|
|
1248
1787
|
}, 300), r = setTimeout(() => {
|
|
1249
|
-
|
|
1788
|
+
ge && _e && (me === F && he === I ? D(t, !1) : w(t, me, he));
|
|
1250
1789
|
}, e);
|
|
1251
1790
|
return () => {
|
|
1252
1791
|
clearTimeout(n), clearTimeout(r);
|
|
1253
1792
|
};
|
|
1254
1793
|
}, [
|
|
1794
|
+
me,
|
|
1255
1795
|
he,
|
|
1256
1796
|
ge,
|
|
1257
1797
|
_e,
|
|
1258
|
-
ve,
|
|
1259
|
-
P,
|
|
1260
1798
|
F,
|
|
1799
|
+
I,
|
|
1261
1800
|
t,
|
|
1262
|
-
O,
|
|
1263
1801
|
D,
|
|
1264
|
-
|
|
1802
|
+
w,
|
|
1803
|
+
C,
|
|
1265
1804
|
V
|
|
1266
1805
|
]), e.useEffect(() => {
|
|
1267
|
-
|
|
1806
|
+
J([K, ne]), oe(!1), ce(!1);
|
|
1268
1807
|
}, [
|
|
1269
1808
|
K,
|
|
1270
|
-
|
|
1809
|
+
ne,
|
|
1271
1810
|
t
|
|
1272
1811
|
]);
|
|
1273
|
-
let
|
|
1274
|
-
let t =
|
|
1275
|
-
return [t,
|
|
1276
|
-
}, [B]),
|
|
1812
|
+
let ve = e.useCallback((e) => {
|
|
1813
|
+
let t = Q(Math.min(e[0], e[1] - B), B);
|
|
1814
|
+
return [t, Q(Math.max(e[1] - B, t), B)];
|
|
1815
|
+
}, [B]), ye = e.useCallback((e) => {
|
|
1277
1816
|
if (V) return;
|
|
1278
|
-
let [t, n] =
|
|
1279
|
-
|
|
1817
|
+
let [t, n] = ve(e);
|
|
1818
|
+
J([Math.max(F, Math.min(z, t)), Math.max(R, Math.min(I, n))]);
|
|
1280
1819
|
}, [
|
|
1281
1820
|
V,
|
|
1282
|
-
|
|
1283
|
-
P,
|
|
1821
|
+
ve,
|
|
1284
1822
|
F,
|
|
1823
|
+
I,
|
|
1285
1824
|
R,
|
|
1286
1825
|
z
|
|
1287
|
-
]),
|
|
1826
|
+
]), be = e.useCallback((e) => {
|
|
1288
1827
|
if (V) return;
|
|
1289
|
-
let [n, r] =
|
|
1290
|
-
i ===
|
|
1828
|
+
let [n, r] = ve(e), i = Math.max(F, Math.min(z, n)), a = Math.max(R, Math.min(I, r));
|
|
1829
|
+
i === F && a === I ? (J([F, I]), D(t, !0)) : J([i, a]);
|
|
1291
1830
|
}, [
|
|
1292
1831
|
V,
|
|
1293
|
-
|
|
1294
|
-
P,
|
|
1832
|
+
ve,
|
|
1295
1833
|
F,
|
|
1834
|
+
I,
|
|
1296
1835
|
R,
|
|
1297
1836
|
z,
|
|
1298
1837
|
t,
|
|
1299
|
-
|
|
1300
|
-
]),
|
|
1838
|
+
D
|
|
1839
|
+
]), xe = e.useRef(null), Se = e.useCallback((e, n) => {
|
|
1301
1840
|
if (V) return;
|
|
1302
|
-
let r =
|
|
1841
|
+
let r = xe.current;
|
|
1303
1842
|
if (G && r && r.start === e && r.last === n) {
|
|
1304
|
-
|
|
1843
|
+
xe.current = null, J([F, I]), D(t, !0);
|
|
1305
1844
|
return;
|
|
1306
1845
|
}
|
|
1307
|
-
let i =
|
|
1308
|
-
|
|
1846
|
+
let i = st(Math.max(F, R, e), F, B), a = Math.max(i, st(Math.min(I, z, n), F, B));
|
|
1847
|
+
xe.current = {
|
|
1309
1848
|
start: e,
|
|
1310
1849
|
last: n
|
|
1311
|
-
},
|
|
1850
|
+
}, J([i, a]);
|
|
1312
1851
|
}, [
|
|
1313
1852
|
V,
|
|
1314
1853
|
G,
|
|
1315
|
-
P,
|
|
1316
1854
|
F,
|
|
1855
|
+
I,
|
|
1317
1856
|
R,
|
|
1318
1857
|
z,
|
|
1319
1858
|
B,
|
|
1320
1859
|
t,
|
|
1321
|
-
|
|
1322
|
-
]),
|
|
1860
|
+
D
|
|
1861
|
+
]), Ce = e.useCallback(() => {
|
|
1323
1862
|
if (V) return;
|
|
1324
|
-
let e =
|
|
1863
|
+
let e = le.trim(), t = e === "" ? NaN : Number(e);
|
|
1325
1864
|
if (isNaN(t)) {
|
|
1326
|
-
|
|
1865
|
+
ue(String(q[0]));
|
|
1327
1866
|
return;
|
|
1328
1867
|
}
|
|
1329
|
-
let n = Math.max(
|
|
1330
|
-
n <
|
|
1868
|
+
let n = Math.max(F, Math.min(z, t));
|
|
1869
|
+
n < q[1] ? J([n, q[1]]) : J([F, q[1]]), ue(String(n < q[1] ? n : F));
|
|
1331
1870
|
}, [
|
|
1332
1871
|
V,
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1872
|
+
le,
|
|
1873
|
+
q,
|
|
1874
|
+
F,
|
|
1336
1875
|
z
|
|
1337
|
-
]),
|
|
1876
|
+
]), we = e.useCallback(() => {
|
|
1338
1877
|
if (V) return;
|
|
1339
|
-
let e =
|
|
1878
|
+
let e = de.trim(), t = e === "" ? NaN : Number(e);
|
|
1340
1879
|
if (isNaN(t)) {
|
|
1341
|
-
|
|
1880
|
+
fe(String(q[1]));
|
|
1342
1881
|
return;
|
|
1343
1882
|
}
|
|
1344
|
-
let n = Math.max(R, Math.min(
|
|
1345
|
-
n >
|
|
1883
|
+
let n = Math.max(R, Math.min(I, t));
|
|
1884
|
+
n > q[0] ? J([q[0], n]) : J([q[0], I]), fe(String(n > q[0] ? n : I));
|
|
1346
1885
|
}, [
|
|
1347
1886
|
V,
|
|
1348
|
-
|
|
1349
|
-
|
|
1887
|
+
de,
|
|
1888
|
+
q,
|
|
1350
1889
|
R,
|
|
1351
|
-
|
|
1352
|
-
]),
|
|
1890
|
+
I
|
|
1891
|
+
]), Te = (e) => (t) => {
|
|
1353
1892
|
t.key === "Enter" && e();
|
|
1354
|
-
}, [
|
|
1893
|
+
}, [Ee, De] = e.useState(null), Oe = e.useRef(null);
|
|
1355
1894
|
e.useEffect(() => {
|
|
1356
1895
|
if (!u) return;
|
|
1357
|
-
let e = `${
|
|
1358
|
-
if (e ===
|
|
1359
|
-
let n =
|
|
1896
|
+
let e = `${F}:${I}`;
|
|
1897
|
+
if (e === Oe.current && Oe.current !== null) return;
|
|
1898
|
+
let n = y?.[t];
|
|
1360
1899
|
if (!Array.isArray(n) || n.length === 0) return;
|
|
1361
1900
|
let r = n.filter((e) => e.value != null && !isNaN(Number(e.key))).map((e) => ({
|
|
1362
1901
|
key: e.key,
|
|
1363
1902
|
value: e.value
|
|
1364
1903
|
}));
|
|
1365
|
-
r.length > 0 && (
|
|
1904
|
+
r.length > 0 && (Oe.current = e, De(r));
|
|
1366
1905
|
}, [
|
|
1367
|
-
P,
|
|
1368
1906
|
F,
|
|
1369
|
-
|
|
1907
|
+
I,
|
|
1908
|
+
y,
|
|
1370
1909
|
t,
|
|
1371
1910
|
u
|
|
1372
1911
|
]);
|
|
1373
|
-
let
|
|
1374
|
-
if (!u || !
|
|
1375
|
-
let e =
|
|
1912
|
+
let ke = e.useMemo(() => {
|
|
1913
|
+
if (!u || !Ee || Ee.length === 0) return [];
|
|
1914
|
+
let e = I - F;
|
|
1376
1915
|
if (e <= 0) return [];
|
|
1377
|
-
let t = d ?? Math.max(B,
|
|
1916
|
+
let t = d ?? Math.max(B, Q(Math.ceil(e / 20 / B) * B, B)), n = Math.ceil(e / t);
|
|
1378
1917
|
return Array.from({ length: n }, (e, r) => {
|
|
1379
|
-
let i =
|
|
1918
|
+
let i = F + r * t, a = F + (r + 1) * t, o = r === n - 1, s = Ee.filter((e) => {
|
|
1380
1919
|
let t = Number(e.key);
|
|
1381
|
-
return t >= i && (t < a || o && t <=
|
|
1382
|
-
}).reduce((e, t) => e + t.value, 0), c = o ?
|
|
1920
|
+
return t >= i && (t < a || o && t <= I);
|
|
1921
|
+
}).reduce((e, t) => e + t.value, 0), c = o ? I : Q(a - B, B);
|
|
1383
1922
|
return {
|
|
1384
1923
|
bucketStart: i,
|
|
1385
1924
|
bucketEnd: a,
|
|
1386
1925
|
count: s,
|
|
1387
1926
|
last: c,
|
|
1388
|
-
barEnd:
|
|
1927
|
+
barEnd: Q(c + B, B)
|
|
1389
1928
|
};
|
|
1390
1929
|
}).map((e, t, n) => ({
|
|
1391
1930
|
...e,
|
|
@@ -1393,92 +1932,92 @@ var le = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1393
1932
|
}));
|
|
1394
1933
|
}, [
|
|
1395
1934
|
u,
|
|
1396
|
-
|
|
1397
|
-
P,
|
|
1935
|
+
Ee,
|
|
1398
1936
|
F,
|
|
1937
|
+
I,
|
|
1399
1938
|
d,
|
|
1400
1939
|
B,
|
|
1401
1940
|
W
|
|
1402
|
-
]),
|
|
1403
|
-
return u && !A && !
|
|
1941
|
+
]), Ae = e.useMemo(() => Math.max(...ke.map((e) => e.count), 1), [ke]);
|
|
1942
|
+
return u && !A && !x?.includes(t) && console.warn(`RangeFilterPanel: showHistogram=true but field "${t}" is not facetable. Add .Facetable = true to this field.`), k ? null : A ? /* @__PURE__ */ f(tt, {
|
|
1404
1943
|
title: n,
|
|
1405
1944
|
variant: "slider",
|
|
1406
1945
|
withHistogram: u,
|
|
1407
1946
|
collapsible: c,
|
|
1408
1947
|
startCollapsed: l
|
|
1409
|
-
}) : !
|
|
1948
|
+
}) : !O && !S ? null : b?.includes(t) ? M === "slider" ? /* @__PURE__ */ p(T, {
|
|
1410
1949
|
title: n,
|
|
1411
1950
|
collapsed: l,
|
|
1412
1951
|
collapsible: c,
|
|
1413
1952
|
className: te,
|
|
1414
1953
|
children: [
|
|
1415
1954
|
V && /* @__PURE__ */ p("div", {
|
|
1416
|
-
className:
|
|
1955
|
+
className: Z.disabledMessage,
|
|
1417
1956
|
children: [
|
|
1418
1957
|
"No adjustable range (all results have the same value: ",
|
|
1419
|
-
|
|
1958
|
+
F,
|
|
1420
1959
|
")."
|
|
1421
1960
|
]
|
|
1422
1961
|
}),
|
|
1423
|
-
u &&
|
|
1424
|
-
u &&
|
|
1425
|
-
let [e, t] = z > R && (R >
|
|
1962
|
+
u && ke.length === 0 && /* @__PURE__ */ f("div", { className: Z.histogram }),
|
|
1963
|
+
u && ke.length > 0 && (() => {
|
|
1964
|
+
let [e, t] = z > R && (R > F || z < I) ? [R, z] : [H, U], n = Math.max(me, e), r = Math.min(he, t), i = W, a = i - H || 1, o = (e) => Math.max(0, Math.min(1, (e - H) / a)), s = (e) => e >= U ? 0 : Math.max(0, Math.min(1, (i - (e + B)) / a)), c = o(n), l = r < n ? 1 - c : s(r), u = (e) => `calc(10px + (100% - 20px) * ${e})`, d = `inset(0 ${u(l)} 0 ${u(c)})`, m = `inset(0 ${u(s(t))} 0 ${u(o(e))})`, h = (n) => n.last < e || n.bucketStart > t, g = ke.slice(1).map((e) => u((e.bucketStart - H) / a)), _ = ke.map((e) => ({
|
|
1426
1965
|
...e,
|
|
1427
|
-
height: Math.max(1, Math.ceil(e.count /
|
|
1966
|
+
height: Math.max(1, Math.ceil(e.count / Ae * 20))
|
|
1428
1967
|
}));
|
|
1429
1968
|
return /* @__PURE__ */ p("div", {
|
|
1430
|
-
className:
|
|
1969
|
+
className: Z.histogram,
|
|
1431
1970
|
children: [
|
|
1432
1971
|
/* @__PURE__ */ f("div", {
|
|
1433
|
-
className:
|
|
1972
|
+
className: Z.histogramLayer,
|
|
1434
1973
|
children: _.map((e, t) => /* @__PURE__ */ f("button", {
|
|
1435
1974
|
type: "button",
|
|
1436
|
-
className:
|
|
1975
|
+
className: Z.histogramBar,
|
|
1437
1976
|
style: { flexGrow: e.span },
|
|
1438
1977
|
"data-testid": "histogram-bar",
|
|
1439
1978
|
disabled: V || h(e),
|
|
1440
1979
|
"aria-label": `${e.bucketStart} to ${e.last}: ${e.count}`,
|
|
1441
1980
|
title: `${e.bucketStart} to ${e.last}: ${e.count}`,
|
|
1442
|
-
onClick: () =>
|
|
1981
|
+
onClick: () => Se(e.bucketStart, e.last),
|
|
1443
1982
|
children: /* @__PURE__ */ f("span", {
|
|
1444
|
-
className:
|
|
1983
|
+
className: Z.histogramFill,
|
|
1445
1984
|
style: { height: `${e.height}px` }
|
|
1446
1985
|
})
|
|
1447
1986
|
}, t))
|
|
1448
1987
|
}),
|
|
1449
1988
|
/* @__PURE__ */ f("div", {
|
|
1450
|
-
className: `${
|
|
1989
|
+
className: `${Z.histogramLayer} ${Z.histogramLive}`,
|
|
1451
1990
|
"aria-hidden": "true",
|
|
1452
1991
|
"data-testid": "histogram-live",
|
|
1453
1992
|
style: { clipPath: m },
|
|
1454
1993
|
children: _.map((e, t) => /* @__PURE__ */ f("span", {
|
|
1455
|
-
className:
|
|
1994
|
+
className: Z.histogramBar,
|
|
1456
1995
|
style: { flexGrow: e.span },
|
|
1457
1996
|
children: /* @__PURE__ */ f("span", {
|
|
1458
|
-
className:
|
|
1997
|
+
className: Z.histogramFill,
|
|
1459
1998
|
style: { height: `${e.height}px` }
|
|
1460
1999
|
})
|
|
1461
2000
|
}, t))
|
|
1462
2001
|
}),
|
|
1463
2002
|
/* @__PURE__ */ f("div", {
|
|
1464
|
-
className: `${
|
|
2003
|
+
className: `${Z.histogramLayer} ${Z.histogramLit}`,
|
|
1465
2004
|
"aria-hidden": "true",
|
|
1466
2005
|
"data-testid": "histogram-lit",
|
|
1467
2006
|
style: { clipPath: d },
|
|
1468
2007
|
children: _.map((e, t) => /* @__PURE__ */ f("span", {
|
|
1469
|
-
className:
|
|
2008
|
+
className: Z.histogramBar,
|
|
1470
2009
|
style: { flexGrow: e.span },
|
|
1471
2010
|
children: /* @__PURE__ */ f("span", {
|
|
1472
|
-
className:
|
|
2011
|
+
className: Z.histogramFill,
|
|
1473
2012
|
style: { height: `${e.height}px` }
|
|
1474
2013
|
})
|
|
1475
2014
|
}, t))
|
|
1476
2015
|
}),
|
|
1477
2016
|
/* @__PURE__ */ f("div", {
|
|
1478
|
-
className:
|
|
2017
|
+
className: Z.histogramSeparators,
|
|
1479
2018
|
"aria-hidden": "true",
|
|
1480
2019
|
children: g.map((e, t) => /* @__PURE__ */ f("span", {
|
|
1481
|
-
className:
|
|
2020
|
+
className: Z.histogramSeparator,
|
|
1482
2021
|
style: { left: e }
|
|
1483
2022
|
}, t))
|
|
1484
2023
|
})
|
|
@@ -1487,20 +2026,20 @@ var le = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1487
2026
|
})(),
|
|
1488
2027
|
/* @__PURE__ */ f("div", {
|
|
1489
2028
|
style: { padding: "10px 10px 20px 10px" },
|
|
1490
|
-
children: /* @__PURE__ */ f(
|
|
2029
|
+
children: /* @__PURE__ */ f(j, {
|
|
1491
2030
|
min: H,
|
|
1492
2031
|
max: W,
|
|
1493
2032
|
step: B,
|
|
1494
2033
|
stepMarks: h,
|
|
1495
|
-
value: V ? [H, W] : [ee(
|
|
2034
|
+
value: V ? [H, W] : [ee(st(me, H, B)), ee(st(he + B, H, B))],
|
|
1496
2035
|
isRange: !0,
|
|
1497
|
-
onChange: (e) =>
|
|
1498
|
-
onFinalChange: (e) =>
|
|
2036
|
+
onChange: (e) => ye(e),
|
|
2037
|
+
onFinalChange: (e) => be(e),
|
|
1499
2038
|
disabled: V,
|
|
1500
2039
|
activeMin: R,
|
|
1501
|
-
activeMax: ee(
|
|
1502
|
-
isFaceted:
|
|
1503
|
-
highlightFaceted:
|
|
2040
|
+
activeMax: ee(Q(z + B, B)),
|
|
2041
|
+
isFaceted: ie,
|
|
2042
|
+
highlightFaceted: re,
|
|
1504
2043
|
"aria-label": n || `Filter by ${t}`
|
|
1505
2044
|
})
|
|
1506
2045
|
}),
|
|
@@ -1511,41 +2050,41 @@ var le = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1511
2050
|
alignItems: "flex-start",
|
|
1512
2051
|
justifyContent: "space-between"
|
|
1513
2052
|
},
|
|
1514
|
-
children: [/* @__PURE__ */ f(
|
|
2053
|
+
children: [/* @__PURE__ */ f(E, {
|
|
1515
2054
|
label: "Min:",
|
|
1516
2055
|
type: "number",
|
|
1517
|
-
style:
|
|
1518
|
-
value: V ? String(
|
|
1519
|
-
min:
|
|
1520
|
-
max:
|
|
1521
|
-
onChange: (e) =>
|
|
1522
|
-
onBlur:
|
|
1523
|
-
onKeyDown:
|
|
2056
|
+
style: pe,
|
|
2057
|
+
value: V ? String(F) : le,
|
|
2058
|
+
min: F,
|
|
2059
|
+
max: Q(Math.min(z, q[1] - B), B),
|
|
2060
|
+
onChange: (e) => ue(e.target.value),
|
|
2061
|
+
onBlur: Ce,
|
|
2062
|
+
onKeyDown: Te(Ce),
|
|
1524
2063
|
disabled: V,
|
|
1525
|
-
isValid: V || !
|
|
1526
|
-
}), /* @__PURE__ */ f(
|
|
2064
|
+
isValid: V || !ae
|
|
2065
|
+
}), /* @__PURE__ */ f(E, {
|
|
1527
2066
|
label: "Max:",
|
|
1528
2067
|
type: "number",
|
|
1529
|
-
style:
|
|
1530
|
-
value: V ? String(
|
|
1531
|
-
min:
|
|
1532
|
-
max:
|
|
1533
|
-
onChange: (e) =>
|
|
1534
|
-
onBlur:
|
|
1535
|
-
onKeyDown:
|
|
2068
|
+
style: pe,
|
|
2069
|
+
value: V ? String(I) : de,
|
|
2070
|
+
min: Q(Math.max(R, q[0] + B), B),
|
|
2071
|
+
max: I,
|
|
2072
|
+
onChange: (e) => fe(e.target.value),
|
|
2073
|
+
onBlur: we,
|
|
2074
|
+
onKeyDown: Te(we),
|
|
1536
2075
|
disabled: V,
|
|
1537
|
-
isValid: V || !
|
|
2076
|
+
isValid: V || !se
|
|
1538
2077
|
})]
|
|
1539
2078
|
})
|
|
1540
2079
|
]
|
|
1541
|
-
}) : /* @__PURE__ */ p(
|
|
2080
|
+
}) : /* @__PURE__ */ p(T, {
|
|
1542
2081
|
title: n,
|
|
1543
2082
|
className: te,
|
|
1544
2083
|
children: [V && /* @__PURE__ */ p("div", {
|
|
1545
|
-
className:
|
|
2084
|
+
className: Z.disabledMessage,
|
|
1546
2085
|
children: [
|
|
1547
2086
|
"No adjustable range (all results have the same value: ",
|
|
1548
|
-
|
|
2087
|
+
F,
|
|
1549
2088
|
")."
|
|
1550
2089
|
]
|
|
1551
2090
|
}), /* @__PURE__ */ p("div", {
|
|
@@ -1554,58 +2093,48 @@ var le = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1554
2093
|
gap: "10px",
|
|
1555
2094
|
alignItems: "flex-start"
|
|
1556
2095
|
},
|
|
1557
|
-
children: [/* @__PURE__ */ f(
|
|
2096
|
+
children: [/* @__PURE__ */ f(E, {
|
|
1558
2097
|
label: "Min:",
|
|
1559
2098
|
type: "number",
|
|
1560
|
-
style:
|
|
1561
|
-
value: V ? String(
|
|
1562
|
-
min:
|
|
1563
|
-
max:
|
|
1564
|
-
onChange: (e) =>
|
|
1565
|
-
onBlur:
|
|
1566
|
-
onKeyDown:
|
|
2099
|
+
style: pe,
|
|
2100
|
+
value: V ? String(F) : le,
|
|
2101
|
+
min: F,
|
|
2102
|
+
max: Q(Math.min(z, q[1] - B), B),
|
|
2103
|
+
onChange: (e) => ue(e.target.value),
|
|
2104
|
+
onBlur: Ce,
|
|
2105
|
+
onKeyDown: Te(Ce),
|
|
1567
2106
|
disabled: V,
|
|
1568
|
-
isValid: V || !
|
|
1569
|
-
}), /* @__PURE__ */ f(
|
|
2107
|
+
isValid: V || !ae
|
|
2108
|
+
}), /* @__PURE__ */ f(E, {
|
|
1570
2109
|
label: "Max:",
|
|
1571
2110
|
type: "number",
|
|
1572
|
-
style:
|
|
1573
|
-
value: V ? String(
|
|
1574
|
-
min:
|
|
1575
|
-
max:
|
|
1576
|
-
onChange: (e) =>
|
|
1577
|
-
onBlur:
|
|
1578
|
-
onKeyDown:
|
|
2111
|
+
style: pe,
|
|
2112
|
+
value: V ? String(I) : de,
|
|
2113
|
+
min: Q(Math.max(R, q[0] + B), B),
|
|
2114
|
+
max: I,
|
|
2115
|
+
onChange: (e) => fe(e.target.value),
|
|
2116
|
+
onBlur: we,
|
|
2117
|
+
onKeyDown: Te(we),
|
|
1579
2118
|
disabled: V,
|
|
1580
|
-
isValid: V || !
|
|
2119
|
+
isValid: V || !se
|
|
1581
2120
|
})]
|
|
1582
2121
|
})]
|
|
1583
|
-
}) : /* @__PURE__ */ f(
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
color: "red",
|
|
1588
|
-
fontSize: "12px"
|
|
1589
|
-
},
|
|
1590
|
-
children: [
|
|
1591
|
-
"Cannot render filter for \"",
|
|
1592
|
-
t,
|
|
1593
|
-
"\": missing filterable."
|
|
1594
|
-
]
|
|
1595
|
-
})
|
|
2122
|
+
}) : /* @__PURE__ */ f(rt, {
|
|
2123
|
+
label: n,
|
|
2124
|
+
field: t,
|
|
2125
|
+
missing: ["filterable"]
|
|
1596
2126
|
});
|
|
1597
|
-
},
|
|
1598
|
-
list: "
|
|
1599
|
-
grid: "
|
|
1600
|
-
count: "
|
|
1601
|
-
countValue: "
|
|
1602
|
-
chip: "
|
|
1603
|
-
|
|
1604
|
-
active: "_active_apmmi_46"
|
|
2127
|
+
}, ut = {
|
|
2128
|
+
list: "_list_9je85_2",
|
|
2129
|
+
grid: "_grid_9je85_9",
|
|
2130
|
+
count: "_count_9je85_22",
|
|
2131
|
+
countValue: "_countValue_9je85_31",
|
|
2132
|
+
chip: "_chip_9je85_35",
|
|
2133
|
+
active: "_active_9je85_41"
|
|
1605
2134
|
};
|
|
1606
2135
|
//#endregion
|
|
1607
2136
|
//#region src/components/BucketFilterPanel.tsx
|
|
1608
|
-
function
|
|
2137
|
+
function dt(e, t) {
|
|
1609
2138
|
if (!t) return null;
|
|
1610
2139
|
let n = 0, r = !1;
|
|
1611
2140
|
for (let i of t) {
|
|
@@ -1617,16 +2146,16 @@ function ue(e, t) {
|
|
|
1617
2146
|
}
|
|
1618
2147
|
return r ? n : 0;
|
|
1619
2148
|
}
|
|
1620
|
-
var
|
|
1621
|
-
let { state: { facets:
|
|
2149
|
+
var ft = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a, layout: c = "list", showCount: u = !0, showEmpty: d = !1, limit: m, showActivePanel: h = !1, collapsible: g = !0, startCollapsed: _ = !1 }) => {
|
|
2150
|
+
let { state: { facets: v, filterableFields: x, facetableFields: S, bucketFilters: C, rangeBounds: w, facetStats: E, query: O }, toggleBucketFilter: k, authError: A, isFetchingInitial: j, allowEmptySearch: M } = Y(), N = i ?? a ?? "checkbox", P = v?.[e], F = C[e] ?? [], [I, L] = l(m ?? Infinity);
|
|
1622
2151
|
o(() => {
|
|
1623
|
-
|
|
1624
|
-
}, [
|
|
1625
|
-
let R =
|
|
2152
|
+
L(m ?? Infinity);
|
|
2153
|
+
}, [m, P]);
|
|
2154
|
+
let R = w?.[e] ?? E?.[e], z = s(() => {
|
|
1626
2155
|
let e = [];
|
|
1627
|
-
if (R && e.push(R.min, R.max), Array.isArray(
|
|
1628
|
-
return
|
|
1629
|
-
}, [R,
|
|
2156
|
+
if (R && e.push(R.min, R.max), Array.isArray(P)) for (let t of P) e.push(Number(t.key));
|
|
2157
|
+
return ot(e.filter(Number.isFinite));
|
|
2158
|
+
}, [R, P]), B = s(() => {
|
|
1630
2159
|
let e = R?.min ?? -Number.MAX_VALUE, t = R?.max ?? Number.MAX_VALUE, i = (n, r, i) => ({
|
|
1631
2160
|
label: i ?? (n === void 0 ? `up to ${r}` : r === void 0 ? `${n} and up` : `${n}-${r}`),
|
|
1632
2161
|
range: {
|
|
@@ -1638,12 +2167,12 @@ var de = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
1638
2167
|
if (r && r.length > 0) return r.map((e) => i(e.min, e.max, e.label));
|
|
1639
2168
|
if (Array.isArray(n)) {
|
|
1640
2169
|
let e = [...n].sort((e, t) => e - t), t = [];
|
|
1641
|
-
for (let n = 0; n < e.length - 1; n++) t.push(i(e[n],
|
|
2170
|
+
for (let n = 0; n < e.length - 1; n++) t.push(i(e[n], Q(e[n + 1] - z, z)));
|
|
1642
2171
|
return t;
|
|
1643
2172
|
}
|
|
1644
2173
|
if (typeof n == "number" && n > 0 && R) {
|
|
1645
2174
|
let e = [], t = Math.floor(R.min / n) * n;
|
|
1646
|
-
for (let r = t; r <= R.max; r =
|
|
2175
|
+
for (let r = t; r <= R.max; r = Q(r + n, z)) e.push(i(Q(r, z), Q(r + n - z, z)));
|
|
1647
2176
|
return e;
|
|
1648
2177
|
}
|
|
1649
2178
|
return [];
|
|
@@ -1653,33 +2182,28 @@ var de = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
1653
2182
|
R,
|
|
1654
2183
|
z
|
|
1655
2184
|
]);
|
|
1656
|
-
if (A
|
|
2185
|
+
if (A) return null;
|
|
2186
|
+
if (j || !v) return /* @__PURE__ */ f(tt, {
|
|
1657
2187
|
title: t,
|
|
1658
2188
|
rows: Math.max(1, Math.min(B.length || 5, 8)),
|
|
1659
|
-
collapsible:
|
|
1660
|
-
startCollapsed:
|
|
2189
|
+
collapsible: g,
|
|
2190
|
+
startCollapsed: _
|
|
1661
2191
|
});
|
|
1662
|
-
if (!
|
|
1663
|
-
if (!
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
children: [
|
|
1668
|
-
"Cannot render buckets for \"",
|
|
1669
|
-
e,
|
|
1670
|
-
"\": field is not filterable."
|
|
1671
|
-
]
|
|
1672
|
-
})
|
|
2192
|
+
if (!M && !O) return null;
|
|
2193
|
+
if (!x?.includes(e)) return /* @__PURE__ */ f(rt, {
|
|
2194
|
+
label: t,
|
|
2195
|
+
field: e,
|
|
2196
|
+
missing: ["filterable"]
|
|
1673
2197
|
});
|
|
1674
|
-
let V =
|
|
2198
|
+
let V = S?.includes(e) && Array.isArray(P), H = (e) => F.some((t) => t.min === e.range.min && t.max === e.range.max), U = B.map((e) => ({
|
|
1675
2199
|
bucket: e,
|
|
1676
|
-
count: V ?
|
|
2200
|
+
count: V ? dt(e, P) : null
|
|
1677
2201
|
}));
|
|
1678
2202
|
if (d || (U = U.filter((e) => e.count !== 0 || H(e.bucket))), U.length === 0) return null;
|
|
1679
|
-
let W = U.slice(0,
|
|
1680
|
-
let r = H(t), i = n === 0 && !r, a = u && (n ?? 0) > 0 ? `${n}` : "", o = () => k(e, t.range,
|
|
1681
|
-
if (
|
|
1682
|
-
let n = /* @__PURE__ */ f(
|
|
2203
|
+
let W = U.slice(0, I), ee = (t, n) => {
|
|
2204
|
+
let r = H(t), i = n === 0 && !r, a = u && (n ?? 0) > 0 ? `${n}` : "", o = () => k(e, t.range, N === "radio");
|
|
2205
|
+
if (N === "radio") {
|
|
2206
|
+
let n = /* @__PURE__ */ f(D, {
|
|
1683
2207
|
id: `${e}-${t.range.min}-${t.range.max}`,
|
|
1684
2208
|
name: e,
|
|
1685
2209
|
value: t.label,
|
|
@@ -1689,43 +2213,43 @@ var de = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
1689
2213
|
disabled: i
|
|
1690
2214
|
});
|
|
1691
2215
|
return c === "list" ? /* @__PURE__ */ p("div", {
|
|
1692
|
-
className:
|
|
2216
|
+
className: ut.count,
|
|
1693
2217
|
children: [n, /* @__PURE__ */ f("span", {
|
|
1694
|
-
className:
|
|
2218
|
+
className: ut.countValue,
|
|
1695
2219
|
children: a
|
|
1696
2220
|
})]
|
|
1697
2221
|
}) : n;
|
|
1698
2222
|
}
|
|
1699
|
-
if (
|
|
1700
|
-
let e = /* @__PURE__ */ f(
|
|
2223
|
+
if (N === "button") {
|
|
2224
|
+
let e = /* @__PURE__ */ f(y, {
|
|
1701
2225
|
variant: r ? "primary" : "secondary",
|
|
1702
2226
|
onClick: o,
|
|
1703
2227
|
disabled: i,
|
|
1704
2228
|
size: "micro",
|
|
1705
|
-
className:
|
|
2229
|
+
className: ut.chip,
|
|
1706
2230
|
children: c === "grid" && a ? `${t.label} (${a})` : t.label
|
|
1707
2231
|
});
|
|
1708
2232
|
return c === "list" ? /* @__PURE__ */ p("div", {
|
|
1709
|
-
className:
|
|
2233
|
+
className: ut.count,
|
|
1710
2234
|
children: [e, /* @__PURE__ */ f("span", {
|
|
1711
|
-
className:
|
|
2235
|
+
className: ut.countValue,
|
|
1712
2236
|
children: a
|
|
1713
2237
|
})]
|
|
1714
2238
|
}) : e;
|
|
1715
2239
|
}
|
|
1716
2240
|
return c === "list" ? /* @__PURE__ */ p("div", {
|
|
1717
|
-
className:
|
|
1718
|
-
children: [/* @__PURE__ */ f(
|
|
2241
|
+
className: ut.count,
|
|
2242
|
+
children: [/* @__PURE__ */ f(b, {
|
|
1719
2243
|
label: t.label,
|
|
1720
2244
|
score: "",
|
|
1721
2245
|
checked: r,
|
|
1722
2246
|
onChange: o,
|
|
1723
2247
|
disabled: i
|
|
1724
2248
|
}), /* @__PURE__ */ f("span", {
|
|
1725
|
-
className:
|
|
2249
|
+
className: ut.countValue,
|
|
1726
2250
|
children: a
|
|
1727
2251
|
})]
|
|
1728
|
-
}) : /* @__PURE__ */ f(
|
|
2252
|
+
}) : /* @__PURE__ */ f(b, {
|
|
1729
2253
|
label: t.label,
|
|
1730
2254
|
score: a ? ` (${a})` : "",
|
|
1731
2255
|
checked: r,
|
|
@@ -1733,54 +2257,54 @@ var de = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
1733
2257
|
disabled: i
|
|
1734
2258
|
});
|
|
1735
2259
|
};
|
|
1736
|
-
return /* @__PURE__ */ f(
|
|
2260
|
+
return /* @__PURE__ */ f(T, {
|
|
1737
2261
|
title: t,
|
|
1738
|
-
collapsible:
|
|
1739
|
-
collapsed:
|
|
1740
|
-
className:
|
|
2262
|
+
collapsible: g,
|
|
2263
|
+
collapsed: g ? _ : !1,
|
|
2264
|
+
className: h && F.length > 0 ? ut.active : void 0,
|
|
1741
2265
|
children: /* @__PURE__ */ p("ul", {
|
|
1742
|
-
className: c === "grid" ?
|
|
2266
|
+
className: c === "grid" ? ut.grid : ut.list,
|
|
1743
2267
|
style: {
|
|
1744
2268
|
listStyle: "none",
|
|
1745
2269
|
padding: 0,
|
|
1746
2270
|
margin: 0
|
|
1747
2271
|
},
|
|
1748
|
-
children: [W.map(({ bucket: e, count: t }) => /* @__PURE__ */ f("li", { children: ee(e, t) }, `${e.range.min}-${e.range.max}`)), W.length < U.length && /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2272
|
+
children: [W.map(({ bucket: e, count: t }) => /* @__PURE__ */ f("li", { children: ee(e, t) }, `${e.range.min}-${e.range.max}`)), W.length < U.length && /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(y, {
|
|
1749
2273
|
variant: "ghost",
|
|
1750
2274
|
size: "micro",
|
|
1751
|
-
onClick: () =>
|
|
2275
|
+
onClick: () => L(U.length),
|
|
1752
2276
|
children: `Show ${U.length - W.length} more of ${U.length} total`
|
|
1753
2277
|
}) })]
|
|
1754
2278
|
})
|
|
1755
2279
|
});
|
|
1756
|
-
},
|
|
2280
|
+
}, pt = {
|
|
1757
2281
|
grid: "_grid_1xjna_2",
|
|
1758
2282
|
chip: "_chip_1xjna_21",
|
|
1759
2283
|
chipLabel: "_chipLabel_1xjna_32"
|
|
1760
|
-
},
|
|
2284
|
+
}, mt = r(({ field: e, value: t, onReset: n }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(y, {
|
|
1761
2285
|
onClick: n,
|
|
1762
|
-
iconRight: /* @__PURE__ */ f(
|
|
2286
|
+
iconRight: /* @__PURE__ */ f(ie, {}),
|
|
1763
2287
|
variant: "primary",
|
|
1764
2288
|
size: "micro",
|
|
1765
|
-
className:
|
|
2289
|
+
className: pt.chip,
|
|
1766
2290
|
title: `${e}: ${t}`,
|
|
1767
2291
|
children: /* @__PURE__ */ p("span", {
|
|
1768
|
-
className:
|
|
2292
|
+
className: pt.chipLabel,
|
|
1769
2293
|
children: [
|
|
1770
2294
|
e,
|
|
1771
2295
|
": ",
|
|
1772
2296
|
t
|
|
1773
2297
|
]
|
|
1774
2298
|
})
|
|
1775
|
-
}) })),
|
|
2299
|
+
}) })), ht = r(({ field: e, min: t, max: n, onReset: r }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(y, {
|
|
1776
2300
|
onClick: r,
|
|
1777
|
-
iconRight: /* @__PURE__ */ f(
|
|
2301
|
+
iconRight: /* @__PURE__ */ f(ie, {}),
|
|
1778
2302
|
variant: "primary",
|
|
1779
2303
|
size: "micro",
|
|
1780
|
-
className:
|
|
2304
|
+
className: pt.chip,
|
|
1781
2305
|
title: `${e}: ${t} – ${n}`,
|
|
1782
2306
|
children: /* @__PURE__ */ p("span", {
|
|
1783
|
-
className:
|
|
2307
|
+
className: pt.chipLabel,
|
|
1784
2308
|
children: [
|
|
1785
2309
|
e,
|
|
1786
2310
|
": ",
|
|
@@ -1789,15 +2313,15 @@ var de = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
1789
2313
|
n
|
|
1790
2314
|
]
|
|
1791
2315
|
})
|
|
1792
|
-
}) })),
|
|
2316
|
+
}) })), gt = r(({ field: e, label: t, onReset: n }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(y, {
|
|
1793
2317
|
onClick: n,
|
|
1794
|
-
iconRight: /* @__PURE__ */ f(
|
|
2318
|
+
iconRight: /* @__PURE__ */ f(ie, {}),
|
|
1795
2319
|
variant: "primary",
|
|
1796
2320
|
size: "micro",
|
|
1797
|
-
className:
|
|
2321
|
+
className: pt.chip,
|
|
1798
2322
|
title: `${e}: ${t}`,
|
|
1799
2323
|
children: /* @__PURE__ */ p("span", {
|
|
1800
|
-
className:
|
|
2324
|
+
className: pt.chipLabel,
|
|
1801
2325
|
children: [
|
|
1802
2326
|
e,
|
|
1803
2327
|
": ",
|
|
@@ -1805,8 +2329,8 @@ var de = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
1805
2329
|
]
|
|
1806
2330
|
})
|
|
1807
2331
|
}) }));
|
|
1808
|
-
function
|
|
1809
|
-
let { state: { filters: e, rangeFilters: t, bucketFilters: n }, resetFilters: r, resetSingleFilter: i, resetRangeFilter: a, resetBucketFilter: o } =
|
|
2332
|
+
function _t() {
|
|
2333
|
+
let { state: { filters: e, rangeFilters: t, bucketFilters: n }, resetFilters: r, resetSingleFilter: i, resetRangeFilter: a, resetBucketFilter: o } = Y(), c = s(() => Object.entries(e).map(([e, t]) => t.map((t) => ({
|
|
1810
2334
|
field: e,
|
|
1811
2335
|
value: t
|
|
1812
2336
|
}))).flat(), [e]), l = s(() => Object.entries(t).map(([e, { min: t, max: n }]) => ({
|
|
@@ -1822,29 +2346,29 @@ function he() {
|
|
|
1822
2346
|
e,
|
|
1823
2347
|
t,
|
|
1824
2348
|
u
|
|
1825
|
-
]) ? /* @__PURE__ */ f(
|
|
2349
|
+
]) ? /* @__PURE__ */ f(T, {
|
|
1826
2350
|
collapsible: !1,
|
|
1827
2351
|
title: "Active filters",
|
|
1828
2352
|
children: /* @__PURE__ */ p("ul", {
|
|
1829
|
-
className:
|
|
2353
|
+
className: pt.grid,
|
|
1830
2354
|
children: [
|
|
1831
|
-
c.map(({ field: e, value: t }) => /* @__PURE__ */ f(
|
|
2355
|
+
c.map(({ field: e, value: t }) => /* @__PURE__ */ f(mt, {
|
|
1832
2356
|
field: e,
|
|
1833
2357
|
value: t,
|
|
1834
2358
|
onReset: () => i(e, t)
|
|
1835
2359
|
}, `${e}-${t}`)),
|
|
1836
|
-
l.map(({ field: e, min: t, max: n }) => /* @__PURE__ */ f(
|
|
2360
|
+
l.map(({ field: e, min: t, max: n }) => /* @__PURE__ */ f(ht, {
|
|
1837
2361
|
field: e,
|
|
1838
2362
|
min: t,
|
|
1839
2363
|
max: n,
|
|
1840
2364
|
onReset: () => a(e)
|
|
1841
2365
|
}, e)),
|
|
1842
|
-
u.map(({ field: e, range: t, label: n }) => /* @__PURE__ */ f(
|
|
2366
|
+
u.map(({ field: e, range: t, label: n }) => /* @__PURE__ */ f(gt, {
|
|
1843
2367
|
field: e,
|
|
1844
2368
|
label: n,
|
|
1845
2369
|
onReset: () => o(e, t)
|
|
1846
2370
|
}, `${e}-${t.min}-${t.max}`)),
|
|
1847
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2371
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(y, {
|
|
1848
2372
|
onClick: r,
|
|
1849
2373
|
size: "micro",
|
|
1850
2374
|
variant: "ghost",
|
|
@@ -1854,12 +2378,12 @@ function he() {
|
|
|
1854
2378
|
})
|
|
1855
2379
|
}) : null;
|
|
1856
2380
|
}
|
|
1857
|
-
var
|
|
2381
|
+
var vt = {
|
|
1858
2382
|
select: "_select_nwf7i_1",
|
|
1859
2383
|
radioGroup: "_radioGroup_nwf7i_6"
|
|
1860
|
-
},
|
|
1861
|
-
let o = n ?? (r === "radio" ? "radio" : "select"), { state: { sortableFields: s, sortBy: c, sortAscending: l }, setSort: u, isFetchingInitial: d } =
|
|
1862
|
-
if (d) return /* @__PURE__ */ f(
|
|
2384
|
+
}, yt = ({ options: e, noneLabel: t = "None", control: n, displayType: r, collapsible: i = !0, startCollapsed: a = !1 }) => {
|
|
2385
|
+
let o = n ?? (r === "radio" ? "radio" : "select"), { state: { sortableFields: s, sortBy: c, sortAscending: l }, setSort: u, isFetchingInitial: d } = Y();
|
|
2386
|
+
if (d) return /* @__PURE__ */ f(tt, {
|
|
1863
2387
|
title: "Sort by",
|
|
1864
2388
|
rows: o === "radio" ? 3 : 1,
|
|
1865
2389
|
collapsible: i,
|
|
@@ -1878,36 +2402,36 @@ var ge = {
|
|
|
1878
2402
|
}]), h = t === null ? m : [{
|
|
1879
2403
|
label: t,
|
|
1880
2404
|
value: "none"
|
|
1881
|
-
}, ...m],
|
|
2405
|
+
}, ...m], g = (e) => {
|
|
1882
2406
|
if (e === "none" || e === "") u(null, !0);
|
|
1883
2407
|
else {
|
|
1884
2408
|
let [t, n] = e.split(":");
|
|
1885
2409
|
u(t, n === "asc");
|
|
1886
2410
|
}
|
|
1887
2411
|
};
|
|
1888
|
-
return /* @__PURE__ */ f(
|
|
2412
|
+
return /* @__PURE__ */ f(T, {
|
|
1889
2413
|
title: "Sort by",
|
|
1890
2414
|
collapsible: i,
|
|
1891
2415
|
collapsed: i ? a : !1,
|
|
1892
|
-
children: o === "select" ? /* @__PURE__ */ f(
|
|
2416
|
+
children: o === "select" ? /* @__PURE__ */ f(k, {
|
|
1893
2417
|
value: p,
|
|
1894
|
-
onValueChange:
|
|
2418
|
+
onValueChange: g,
|
|
1895
2419
|
options: h,
|
|
1896
2420
|
placeholder: "Select sort...",
|
|
1897
2421
|
"aria-label": "Sort by"
|
|
1898
2422
|
}) : /* @__PURE__ */ f("div", {
|
|
1899
|
-
className:
|
|
1900
|
-
children: h.map((e) => /* @__PURE__ */ f(
|
|
2423
|
+
className: vt.radioGroup,
|
|
2424
|
+
children: h.map((e) => /* @__PURE__ */ f(D, {
|
|
1901
2425
|
id: `sort-${e.value}`,
|
|
1902
2426
|
name: "sort-by",
|
|
1903
2427
|
value: e.value,
|
|
1904
2428
|
label: e.label,
|
|
1905
2429
|
checked: p === e.value,
|
|
1906
|
-
onChange: (e) =>
|
|
2430
|
+
onChange: (e) => g(e.target.value)
|
|
1907
2431
|
}, e.value))
|
|
1908
2432
|
})
|
|
1909
2433
|
});
|
|
1910
|
-
},
|
|
2434
|
+
}, bt = { list: "_list_1y4fk_1" }, xt = {
|
|
1911
2435
|
coverageDepth: 500,
|
|
1912
2436
|
coverWholeQuery: !0,
|
|
1913
2437
|
coverWholeWords: !0,
|
|
@@ -1922,13 +2446,13 @@ var ge = {
|
|
|
1922
2446
|
truncateWordHitTolerance: 0,
|
|
1923
2447
|
truncationScore: 65024
|
|
1924
2448
|
};
|
|
1925
|
-
function
|
|
1926
|
-
let { state: { searchSettings: e }, setSearchSettings: t, url: n, team: r, dataset: i, authenticatedFetch: a } =
|
|
2449
|
+
function St() {
|
|
2450
|
+
let { state: { searchSettings: e }, setSearchSettings: t, url: n, team: r, dataset: i, authenticatedFetch: a } = Y(), [s, c] = l(!1), [u, m] = l(null);
|
|
1927
2451
|
o(() => {
|
|
1928
2452
|
let e = !0;
|
|
1929
2453
|
try {
|
|
1930
2454
|
a(`${n}/api/teams/${r}/datasets/${i}/query-parameters`).then((e) => e.ok ? e.json() : null).then((t) => {
|
|
1931
|
-
e && t?.effective &&
|
|
2455
|
+
e && t?.effective && m(t.effective);
|
|
1932
2456
|
}).catch(() => {});
|
|
1933
2457
|
} catch {}
|
|
1934
2458
|
return () => {
|
|
@@ -1940,42 +2464,42 @@ function be() {
|
|
|
1940
2464
|
i,
|
|
1941
2465
|
a
|
|
1942
2466
|
]);
|
|
1943
|
-
let
|
|
2467
|
+
let h = e.coverageSetup, g = (e) => h[e] !== void 0 && h[e] !== null, _ = (e) => h[e] ?? u?.coverageSetup?.[e] ?? xt[e], v = e.coverageDepth ?? u?.coverageDepth ?? xt.coverageDepth, b = u ? "dataset" : "default", x = (e, t) => t ? e : `${e} (${b})`, S = e.coverageDepth !== void 0 || Object.keys(h).some((e) => g(e)), C = (e, n) => {
|
|
1944
2468
|
let r = parseInt(n, 10);
|
|
1945
2469
|
isNaN(r) || t({ [e]: r });
|
|
1946
|
-
},
|
|
2470
|
+
}, w = (e, n) => {
|
|
1947
2471
|
t({ [e]: n });
|
|
1948
|
-
},
|
|
2472
|
+
}, D = (n, r) => {
|
|
1949
2473
|
let i = parseInt(r, 10);
|
|
1950
2474
|
isNaN(i) || t({ coverageSetup: {
|
|
1951
2475
|
...e.coverageSetup,
|
|
1952
2476
|
[n]: i
|
|
1953
2477
|
} });
|
|
1954
|
-
},
|
|
2478
|
+
}, O = (n, r) => {
|
|
1955
2479
|
t({ coverageSetup: {
|
|
1956
2480
|
...e.coverageSetup,
|
|
1957
2481
|
[n]: r
|
|
1958
2482
|
} });
|
|
1959
2483
|
};
|
|
1960
|
-
return /* @__PURE__ */ f(
|
|
2484
|
+
return /* @__PURE__ */ f(T, {
|
|
1961
2485
|
collapsed: !0,
|
|
1962
2486
|
title: "Settings",
|
|
1963
2487
|
children: /* @__PURE__ */ p("ul", {
|
|
1964
|
-
className:
|
|
2488
|
+
className: bt.list,
|
|
1965
2489
|
children: [
|
|
1966
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2490
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(E, {
|
|
1967
2491
|
label: "Max Results",
|
|
1968
2492
|
type: "number",
|
|
1969
2493
|
value: e.maxNumberOfRecordsToReturn.toString(),
|
|
1970
|
-
onChange: (e) =>
|
|
2494
|
+
onChange: (e) => C("maxNumberOfRecordsToReturn", e.target.value)
|
|
1971
2495
|
}) }),
|
|
1972
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
1973
|
-
label:
|
|
2496
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(E, {
|
|
2497
|
+
label: x("Coverage Depth", e.coverageDepth !== void 0),
|
|
1974
2498
|
type: "number",
|
|
1975
|
-
value:
|
|
1976
|
-
onChange: (e) =>
|
|
2499
|
+
value: v.toString(),
|
|
2500
|
+
onChange: (e) => C("coverageDepth", e.target.value)
|
|
1977
2501
|
}) }),
|
|
1978
|
-
/* @__PURE__ */ p("li", { children: [/* @__PURE__ */ f(
|
|
2502
|
+
/* @__PURE__ */ p("li", { children: [/* @__PURE__ */ f(E, {
|
|
1979
2503
|
label: "Minimum Score (16 bit)",
|
|
1980
2504
|
type: "number",
|
|
1981
2505
|
value: e.minimumScore.toString(),
|
|
@@ -1987,7 +2511,7 @@ function be() {
|
|
|
1987
2511
|
}
|
|
1988
2512
|
}), /* @__PURE__ */ f("div", {
|
|
1989
2513
|
style: { padding: "10px 10px 20px 10px" },
|
|
1990
|
-
children: /* @__PURE__ */ f(
|
|
2514
|
+
children: /* @__PURE__ */ f(j, {
|
|
1991
2515
|
min: 0,
|
|
1992
2516
|
max: 65535,
|
|
1993
2517
|
step: 1,
|
|
@@ -1998,7 +2522,7 @@ function be() {
|
|
|
1998
2522
|
"aria-label": "Minimum score"
|
|
1999
2523
|
})
|
|
2000
2524
|
})] }),
|
|
2001
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2525
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(E, {
|
|
2002
2526
|
label: "Placeholder text",
|
|
2003
2527
|
type: "text",
|
|
2004
2528
|
value: e.placeholderText,
|
|
@@ -2006,89 +2530,89 @@ function be() {
|
|
|
2006
2530
|
t({ placeholderText: e.target.value });
|
|
2007
2531
|
}
|
|
2008
2532
|
}) }),
|
|
2009
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2533
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(N, {
|
|
2010
2534
|
label: "Show score",
|
|
2011
2535
|
checked: e.showScore,
|
|
2012
|
-
onChange: (e) =>
|
|
2536
|
+
onChange: (e) => w("showScore", e)
|
|
2013
2537
|
}) }),
|
|
2014
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2538
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(N, {
|
|
2015
2539
|
label: "Enable Coverage",
|
|
2016
2540
|
checked: e.enableCoverage,
|
|
2017
|
-
onChange: (e) =>
|
|
2541
|
+
onChange: (e) => w("enableCoverage", e)
|
|
2018
2542
|
}) }),
|
|
2019
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2543
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(N, {
|
|
2020
2544
|
label: "Remove Duplicates",
|
|
2021
2545
|
checked: e.removeDuplicates,
|
|
2022
|
-
onChange: (e) =>
|
|
2546
|
+
onChange: (e) => w("removeDuplicates", e)
|
|
2023
2547
|
}) }),
|
|
2024
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2548
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(y, {
|
|
2025
2549
|
variant: "ghost",
|
|
2026
2550
|
size: "micro",
|
|
2027
|
-
iconRight: f(s ?
|
|
2551
|
+
iconRight: f(s ? L : R, {}),
|
|
2028
2552
|
onClick: () => c((e) => !e),
|
|
2029
2553
|
children: s ? "Hide Coverage Setup" : "Show Coverage Setup"
|
|
2030
2554
|
}) }),
|
|
2031
2555
|
s && /* @__PURE__ */ p(d, { children: [
|
|
2032
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2033
|
-
label:
|
|
2034
|
-
checked:
|
|
2035
|
-
onChange: (e) =>
|
|
2556
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(N, {
|
|
2557
|
+
label: x("Cover Whole Query", g("coverWholeQuery")),
|
|
2558
|
+
checked: _("coverWholeQuery"),
|
|
2559
|
+
onChange: (e) => O("coverWholeQuery", e)
|
|
2036
2560
|
}) }),
|
|
2037
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2038
|
-
label:
|
|
2039
|
-
checked:
|
|
2040
|
-
onChange: (e) =>
|
|
2561
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(N, {
|
|
2562
|
+
label: x("Cover Whole Words", g("coverWholeWords")),
|
|
2563
|
+
checked: _("coverWholeWords"),
|
|
2564
|
+
onChange: (e) => O("coverWholeWords", e)
|
|
2041
2565
|
}) }),
|
|
2042
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2043
|
-
label:
|
|
2044
|
-
checked:
|
|
2045
|
-
onChange: (e) =>
|
|
2566
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(N, {
|
|
2567
|
+
label: x("Cover Fuzzy Words", g("coverFuzzyWords")),
|
|
2568
|
+
checked: _("coverFuzzyWords"),
|
|
2569
|
+
onChange: (e) => O("coverFuzzyWords", e)
|
|
2046
2570
|
}) }),
|
|
2047
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2048
|
-
label:
|
|
2049
|
-
checked:
|
|
2050
|
-
onChange: (e) =>
|
|
2571
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(N, {
|
|
2572
|
+
label: x("Cover Joined Words", g("coverJoinedWords")),
|
|
2573
|
+
checked: _("coverJoinedWords"),
|
|
2574
|
+
onChange: (e) => O("coverJoinedWords", e)
|
|
2051
2575
|
}) }),
|
|
2052
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2053
|
-
label:
|
|
2054
|
-
checked:
|
|
2055
|
-
onChange: (e) =>
|
|
2576
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(N, {
|
|
2577
|
+
label: x("Cover Prefix Suffix", g("coverPrefixSuffix")),
|
|
2578
|
+
checked: _("coverPrefixSuffix"),
|
|
2579
|
+
onChange: (e) => O("coverPrefixSuffix", e)
|
|
2056
2580
|
}) }),
|
|
2057
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2058
|
-
label:
|
|
2059
|
-
checked:
|
|
2060
|
-
onChange: (e) =>
|
|
2581
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(N, {
|
|
2582
|
+
label: x("Truncate", g("truncate")),
|
|
2583
|
+
checked: _("truncate"),
|
|
2584
|
+
onChange: (e) => O("truncate", e)
|
|
2061
2585
|
}) }),
|
|
2062
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2063
|
-
label:
|
|
2064
|
-
checked:
|
|
2065
|
-
onChange: (e) =>
|
|
2586
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(N, {
|
|
2587
|
+
label: x("Include Pattern Matches", g("includePatternMatches")),
|
|
2588
|
+
checked: _("includePatternMatches"),
|
|
2589
|
+
onChange: (e) => O("includePatternMatches", e)
|
|
2066
2590
|
}) }),
|
|
2067
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2068
|
-
label:
|
|
2591
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(E, {
|
|
2592
|
+
label: x("Levenshtein Max Word Size", g("levenshteinMaxWordSize")),
|
|
2069
2593
|
type: "number",
|
|
2070
|
-
value:
|
|
2071
|
-
onChange: (e) =>
|
|
2594
|
+
value: _("levenshteinMaxWordSize").toString(),
|
|
2595
|
+
onChange: (e) => D("levenshteinMaxWordSize", e.target.value)
|
|
2072
2596
|
}) }),
|
|
2073
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2074
|
-
label:
|
|
2597
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(E, {
|
|
2598
|
+
label: x("Min Word Size", g("minWordSize")),
|
|
2075
2599
|
type: "number",
|
|
2076
|
-
value:
|
|
2077
|
-
onChange: (e) =>
|
|
2600
|
+
value: _("minWordSize").toString(),
|
|
2601
|
+
onChange: (e) => D("minWordSize", e.target.value)
|
|
2078
2602
|
}) }),
|
|
2079
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2080
|
-
label:
|
|
2603
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(E, {
|
|
2604
|
+
label: x("Truncate Word Hit Limit", g("truncateWordHitLimit")),
|
|
2081
2605
|
type: "number",
|
|
2082
|
-
value:
|
|
2083
|
-
onChange: (e) =>
|
|
2606
|
+
value: _("truncateWordHitLimit").toString(),
|
|
2607
|
+
onChange: (e) => D("truncateWordHitLimit", e.target.value)
|
|
2084
2608
|
}) }),
|
|
2085
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2086
|
-
label:
|
|
2609
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(E, {
|
|
2610
|
+
label: x("Truncate Word Hit Tolerance", g("truncateWordHitTolerance")),
|
|
2087
2611
|
type: "number",
|
|
2088
|
-
value:
|
|
2089
|
-
onChange: (e) =>
|
|
2612
|
+
value: _("truncateWordHitTolerance").toString(),
|
|
2613
|
+
onChange: (e) => D("truncateWordHitTolerance", e.target.value)
|
|
2090
2614
|
}) }),
|
|
2091
|
-
|
|
2615
|
+
S && /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(y, {
|
|
2092
2616
|
variant: "ghost",
|
|
2093
2617
|
size: "micro",
|
|
2094
2618
|
onClick: () => t({
|
|
@@ -2104,7 +2628,7 @@ function be() {
|
|
|
2104
2628
|
}
|
|
2105
2629
|
//#endregion
|
|
2106
2630
|
//#region src/components/SearchErrorBoundary.tsx
|
|
2107
|
-
var
|
|
2631
|
+
var Ct = class extends t {
|
|
2108
2632
|
constructor(e) {
|
|
2109
2633
|
super(e), this.state = {
|
|
2110
2634
|
hasError: !1,
|
|
@@ -2174,7 +2698,7 @@ var xe = class extends t {
|
|
|
2174
2698
|
]
|
|
2175
2699
|
})]
|
|
2176
2700
|
}),
|
|
2177
|
-
/* @__PURE__ */ f(
|
|
2701
|
+
/* @__PURE__ */ f(y, {
|
|
2178
2702
|
variant: "primary",
|
|
2179
2703
|
size: "micro",
|
|
2180
2704
|
onClick: this.reset,
|
|
@@ -2186,8 +2710,8 @@ var xe = class extends t {
|
|
|
2186
2710
|
};
|
|
2187
2711
|
//#endregion
|
|
2188
2712
|
//#region src/hooks/useVectorSearch.ts
|
|
2189
|
-
function
|
|
2190
|
-
let { url: n, team: r, dataset: a, authenticatedFetch: o } =
|
|
2713
|
+
function wt(e, t) {
|
|
2714
|
+
let { url: n, team: r, dataset: a, authenticatedFetch: o } = Y(), [s, c] = l(null), [u, d] = l(!1), [f, p] = l(void 0);
|
|
2191
2715
|
return {
|
|
2192
2716
|
results: s,
|
|
2193
2717
|
isLoading: u,
|
|
@@ -2206,7 +2730,7 @@ function Se(e, t) {
|
|
|
2206
2730
|
headers: { "Content-Type": "application/json" },
|
|
2207
2731
|
body: JSON.stringify(l)
|
|
2208
2732
|
});
|
|
2209
|
-
if (!u.ok) throw await
|
|
2733
|
+
if (!u.ok) throw await q.fromResponse("VectorSearch", u);
|
|
2210
2734
|
let d = await u.json();
|
|
2211
2735
|
if (d.length === 0) {
|
|
2212
2736
|
c([]);
|
|
@@ -2217,7 +2741,7 @@ function Se(e, t) {
|
|
|
2217
2741
|
headers: { "Content-Type": "application/json" },
|
|
2218
2742
|
body: JSON.stringify(f)
|
|
2219
2743
|
});
|
|
2220
|
-
if (!p.ok) throw await
|
|
2744
|
+
if (!p.ok) throw await q.fromResponse("GetJson", p);
|
|
2221
2745
|
c((await p.json()).map((e, t) => ({
|
|
2222
2746
|
document: e,
|
|
2223
2747
|
documentKey: f[t],
|
|
@@ -2242,8 +2766,8 @@ function Se(e, t) {
|
|
|
2242
2766
|
}
|
|
2243
2767
|
//#endregion
|
|
2244
2768
|
//#region src/hooks/useHybridSearch.ts
|
|
2245
|
-
function
|
|
2246
|
-
let { url: n, team: r, dataset: a, authenticatedFetch: o } =
|
|
2769
|
+
function Tt(e, t) {
|
|
2770
|
+
let { url: n, team: r, dataset: a, authenticatedFetch: o } = Y(), [s, c] = l(null), [u, d] = l(!1), [f, p] = l(void 0);
|
|
2247
2771
|
return {
|
|
2248
2772
|
results: s,
|
|
2249
2773
|
isLoading: u,
|
|
@@ -2264,7 +2788,7 @@ function Ce(e, t) {
|
|
|
2264
2788
|
headers: { "Content-Type": "application/json" },
|
|
2265
2789
|
body: JSON.stringify(l)
|
|
2266
2790
|
});
|
|
2267
|
-
if (!u.ok) throw await
|
|
2791
|
+
if (!u.ok) throw await q.fromResponse("HybridSearch", u);
|
|
2268
2792
|
let d = await u.json();
|
|
2269
2793
|
if (d.length === 0) {
|
|
2270
2794
|
c([]);
|
|
@@ -2275,7 +2799,7 @@ function Ce(e, t) {
|
|
|
2275
2799
|
headers: { "Content-Type": "application/json" },
|
|
2276
2800
|
body: JSON.stringify(f)
|
|
2277
2801
|
});
|
|
2278
|
-
if (!p.ok) throw await
|
|
2802
|
+
if (!p.ok) throw await q.fromResponse("GetJson", p);
|
|
2279
2803
|
c((await p.json()).map((e, t) => ({
|
|
2280
2804
|
document: e,
|
|
2281
2805
|
documentKey: f[t],
|
|
@@ -2301,4 +2825,601 @@ function Ce(e, t) {
|
|
|
2301
2825
|
};
|
|
2302
2826
|
}
|
|
2303
2827
|
//#endregion
|
|
2304
|
-
|
|
2828
|
+
//#region src/hooks/useFilterSuggestion.ts
|
|
2829
|
+
function Et(e) {
|
|
2830
|
+
let t = e.trim().toLowerCase();
|
|
2831
|
+
return t === "true" || t === "false" || t !== "" && !Number.isNaN(Number(t));
|
|
2832
|
+
}
|
|
2833
|
+
function Dt(e, t) {
|
|
2834
|
+
if (!t) return null;
|
|
2835
|
+
let n = [];
|
|
2836
|
+
for (let [e, r] of Object.entries(t)) for (let t of r ?? []) t?.key && t.key.trim().length >= 2 && !Et(t.key) && n.push({
|
|
2837
|
+
field: e,
|
|
2838
|
+
value: t.key
|
|
2839
|
+
});
|
|
2840
|
+
n.sort((e, t) => t.value.length - e.value.length);
|
|
2841
|
+
let r = " " + e.toLowerCase() + " ", i = [];
|
|
2842
|
+
for (let e of n) {
|
|
2843
|
+
let t = " " + e.value.toLowerCase().trim() + " ", n = r.indexOf(t);
|
|
2844
|
+
n < 0 || (i.push({
|
|
2845
|
+
field: e.field,
|
|
2846
|
+
value: e.value
|
|
2847
|
+
}), r = r.slice(0, n) + " " + r.slice(n + t.length));
|
|
2848
|
+
}
|
|
2849
|
+
return i.length === 0 ? null : {
|
|
2850
|
+
filters: i,
|
|
2851
|
+
text: r.replace(/[?!.,]+\s*$/, "").replace(/\s+/g, " ").trim(),
|
|
2852
|
+
sort: null
|
|
2853
|
+
};
|
|
2854
|
+
}
|
|
2855
|
+
function Ot(e = {}) {
|
|
2856
|
+
let t = Y(), { url: n, team: r, dataset: a, authenticatedFetch: s, setQuery: u, toggleFilter: d, setRangeFilter: f, setSort: p } = t, { auto: m } = e, h = c(t);
|
|
2857
|
+
h.current = t;
|
|
2858
|
+
let [g, _] = l(null), [v, y] = l(""), [b, x] = l(!1), S = c(0), C = i(async (e) => {
|
|
2859
|
+
let t = ++S.current;
|
|
2860
|
+
x(!0);
|
|
2861
|
+
try {
|
|
2862
|
+
let i = await s(`${n}/api/teams/${r}/datasets/${a}/search-or-ask/filters${Oe(h.current)}`, {
|
|
2863
|
+
method: "POST",
|
|
2864
|
+
headers: { "Content-Type": "application/json" },
|
|
2865
|
+
body: JSON.stringify({ text: e })
|
|
2866
|
+
});
|
|
2867
|
+
if (t !== S.current) return;
|
|
2868
|
+
let o = i.ok ? await i.json() : null;
|
|
2869
|
+
_(o && o.filters.length > 0 ? o : null), y(e);
|
|
2870
|
+
} catch {
|
|
2871
|
+
t === S.current && _(null);
|
|
2872
|
+
} finally {
|
|
2873
|
+
t === S.current && x(!1);
|
|
2874
|
+
}
|
|
2875
|
+
}, [
|
|
2876
|
+
n,
|
|
2877
|
+
r,
|
|
2878
|
+
a,
|
|
2879
|
+
s
|
|
2880
|
+
]), w = i((e) => {
|
|
2881
|
+
u(e.text);
|
|
2882
|
+
let t = {
|
|
2883
|
+
...h.current.state.rangeBounds,
|
|
2884
|
+
...h.current.datasetBounds
|
|
2885
|
+
};
|
|
2886
|
+
for (let n of e.filters) n.value == null ? f(n.field, n.min ?? t[n.field]?.min ?? 0, n.max ?? t[n.field]?.max ?? 2 ** 53 - 1) : d(n.field, n.value);
|
|
2887
|
+
e.sort && p(e.sort.field, !e.sort.descending), _(null);
|
|
2888
|
+
}, [
|
|
2889
|
+
u,
|
|
2890
|
+
d,
|
|
2891
|
+
f,
|
|
2892
|
+
p
|
|
2893
|
+
]), T = i(() => {
|
|
2894
|
+
S.current++, _(null), x(!1);
|
|
2895
|
+
}, []), E = c(/* @__PURE__ */ new Set()), [D, O] = l(null), k = m?.filtersWhileTyping ?? "off", A = !!m && m.available && m.describes && m.offer === "strong" && k !== "off", j = m?.text ?? "", M = c(j);
|
|
2896
|
+
M.current = j;
|
|
2897
|
+
let N = t.state.facets, P = t.state.isLoading || t.facetsEnabled && N == null;
|
|
2898
|
+
return o(() => {
|
|
2899
|
+
if (!A || !j || P || E.current.has(j)) return;
|
|
2900
|
+
E.current.add(j);
|
|
2901
|
+
let e = Dt(j, N);
|
|
2902
|
+
if (e && (E.current.add(e.text), w(e), O(j)), k !== "model") return;
|
|
2903
|
+
let t = e ? e.text : j;
|
|
2904
|
+
if (!t) return;
|
|
2905
|
+
let i = () => M.current === j || M.current === t;
|
|
2906
|
+
(async () => {
|
|
2907
|
+
let o = ++S.current;
|
|
2908
|
+
x(!0);
|
|
2909
|
+
try {
|
|
2910
|
+
let c = await s(`${n}/api/teams/${r}/datasets/${a}/search-or-ask/filters${Oe(h.current)}`, {
|
|
2911
|
+
method: "POST",
|
|
2912
|
+
headers: { "Content-Type": "application/json" },
|
|
2913
|
+
body: JSON.stringify({ text: t })
|
|
2914
|
+
});
|
|
2915
|
+
if (o !== S.current || !i()) return;
|
|
2916
|
+
let l = c.ok ? await c.json() : null;
|
|
2917
|
+
l && l.filters.length > 0 && (E.current.add(l.text), w({
|
|
2918
|
+
filters: [...e?.filters ?? [], ...l.filters],
|
|
2919
|
+
text: l.text,
|
|
2920
|
+
sort: l.sort
|
|
2921
|
+
}), O(j));
|
|
2922
|
+
} catch {} finally {
|
|
2923
|
+
o === S.current && x(!1);
|
|
2924
|
+
}
|
|
2925
|
+
})();
|
|
2926
|
+
}, [
|
|
2927
|
+
A,
|
|
2928
|
+
j,
|
|
2929
|
+
k,
|
|
2930
|
+
P,
|
|
2931
|
+
N,
|
|
2932
|
+
w,
|
|
2933
|
+
n,
|
|
2934
|
+
r,
|
|
2935
|
+
a,
|
|
2936
|
+
s
|
|
2937
|
+
]), {
|
|
2938
|
+
suggestion: g,
|
|
2939
|
+
forText: v,
|
|
2940
|
+
loading: b,
|
|
2941
|
+
suggest: C,
|
|
2942
|
+
apply: w,
|
|
2943
|
+
clear: T,
|
|
2944
|
+
appliedText: D
|
|
2945
|
+
};
|
|
2946
|
+
}
|
|
2947
|
+
//#endregion
|
|
2948
|
+
//#region src/hooks/useAsk.ts
|
|
2949
|
+
var kt = {
|
|
2950
|
+
question: "",
|
|
2951
|
+
status: "idle",
|
|
2952
|
+
answer: "",
|
|
2953
|
+
sources: [],
|
|
2954
|
+
steps: []
|
|
2955
|
+
};
|
|
2956
|
+
function At() {
|
|
2957
|
+
let e = Y(), { url: t, team: n, dataset: r, authenticatedFetch: a } = e, s = c(e);
|
|
2958
|
+
s.current = e;
|
|
2959
|
+
let [u, d] = l(kt), f = c(u);
|
|
2960
|
+
f.current = u;
|
|
2961
|
+
let p = c(null), m = i(async (e, i = []) => {
|
|
2962
|
+
let o = e.trim();
|
|
2963
|
+
if (!o) return;
|
|
2964
|
+
p.current?.abort();
|
|
2965
|
+
let c = new AbortController();
|
|
2966
|
+
p.current = c, d({
|
|
2967
|
+
question: o,
|
|
2968
|
+
status: "searching",
|
|
2969
|
+
answer: "",
|
|
2970
|
+
sources: [],
|
|
2971
|
+
steps: []
|
|
2972
|
+
});
|
|
2973
|
+
let l = "", u = null, f = () => {
|
|
2974
|
+
u = null;
|
|
2975
|
+
let e = l;
|
|
2976
|
+
d((t) => t.answer === e ? t : {
|
|
2977
|
+
...t,
|
|
2978
|
+
answer: e
|
|
2979
|
+
});
|
|
2980
|
+
}, m = () => {
|
|
2981
|
+
u !== null && (cancelAnimationFrame(u), u = null), f();
|
|
2982
|
+
}, h = (e, t) => d((n) => ({
|
|
2983
|
+
...n,
|
|
2984
|
+
status: "error",
|
|
2985
|
+
error: {
|
|
2986
|
+
code: e,
|
|
2987
|
+
message: t
|
|
2988
|
+
}
|
|
2989
|
+
}));
|
|
2990
|
+
try {
|
|
2991
|
+
let e = await a(`${t}/api/teams/${n}/datasets/${r}/search-or-ask/ask${Oe(s.current)}`, {
|
|
2992
|
+
method: "POST",
|
|
2993
|
+
headers: {
|
|
2994
|
+
"Content-Type": "application/json",
|
|
2995
|
+
Accept: "text/event-stream"
|
|
2996
|
+
},
|
|
2997
|
+
body: JSON.stringify(i.length ? {
|
|
2998
|
+
question: o,
|
|
2999
|
+
history: i
|
|
3000
|
+
} : { question: o }),
|
|
3001
|
+
signal: c.signal
|
|
3002
|
+
});
|
|
3003
|
+
if (e.status === 429) {
|
|
3004
|
+
let t = await e.json().catch(() => ({})), n = Number(e.headers.get("Retry-After"));
|
|
3005
|
+
d((e) => ({
|
|
3006
|
+
...e,
|
|
3007
|
+
status: "limited",
|
|
3008
|
+
retryAfterSeconds: t.retryAfterSeconds ?? (Number.isFinite(n) ? n : void 0)
|
|
3009
|
+
}));
|
|
3010
|
+
return;
|
|
3011
|
+
}
|
|
3012
|
+
let p = e.headers.get("Indx-Ask-Id") ?? void 0;
|
|
3013
|
+
if (p && d((e) => ({
|
|
3014
|
+
...e,
|
|
3015
|
+
askId: p
|
|
3016
|
+
})), !e.ok || !e.body) {
|
|
3017
|
+
let t = await e.json().catch(() => ({}));
|
|
3018
|
+
h(t.code ?? `http${e.status}`, t.detail ?? "The question could not be asked.");
|
|
3019
|
+
return;
|
|
3020
|
+
}
|
|
3021
|
+
for await (let { event: t, data: n } of De(e.body)) switch (t) {
|
|
3022
|
+
case "status": {
|
|
3023
|
+
let e = n.step;
|
|
3024
|
+
e && d((t) => ({
|
|
3025
|
+
...t,
|
|
3026
|
+
steps: [...t.steps, e]
|
|
3027
|
+
}));
|
|
3028
|
+
break;
|
|
3029
|
+
}
|
|
3030
|
+
case "filters":
|
|
3031
|
+
d((e) => ({
|
|
3032
|
+
...e,
|
|
3033
|
+
filters: n
|
|
3034
|
+
}));
|
|
3035
|
+
break;
|
|
3036
|
+
case "sources":
|
|
3037
|
+
d((e) => ({
|
|
3038
|
+
...e,
|
|
3039
|
+
status: "writing",
|
|
3040
|
+
sources: n
|
|
3041
|
+
}));
|
|
3042
|
+
break;
|
|
3043
|
+
case "text":
|
|
3044
|
+
l += n.delta, u ??= requestAnimationFrame(f);
|
|
3045
|
+
break;
|
|
3046
|
+
case "done":
|
|
3047
|
+
m(), d((e) => ({
|
|
3048
|
+
...e,
|
|
3049
|
+
status: "answered"
|
|
3050
|
+
}));
|
|
3051
|
+
return;
|
|
3052
|
+
case "error": {
|
|
3053
|
+
m();
|
|
3054
|
+
let e = n;
|
|
3055
|
+
h(e.code, e.message);
|
|
3056
|
+
return;
|
|
3057
|
+
}
|
|
3058
|
+
}
|
|
3059
|
+
m(), c.signal.aborted || h("dropped", "The connection dropped while the answer was being written.");
|
|
3060
|
+
} catch (e) {
|
|
3061
|
+
if (p.current !== c) return;
|
|
3062
|
+
m(), e.name === "AbortError" ? d((e) => e.answer ? {
|
|
3063
|
+
...e,
|
|
3064
|
+
status: "answered"
|
|
3065
|
+
} : {
|
|
3066
|
+
...e,
|
|
3067
|
+
status: "idle"
|
|
3068
|
+
}) : h("dropped", "The connection dropped while the answer was being written.");
|
|
3069
|
+
} finally {
|
|
3070
|
+
p.current === c && (p.current = null);
|
|
3071
|
+
}
|
|
3072
|
+
}, [
|
|
3073
|
+
t,
|
|
3074
|
+
n,
|
|
3075
|
+
r,
|
|
3076
|
+
a
|
|
3077
|
+
]), h = i(async (e, i) => {
|
|
3078
|
+
let o = i ?? f.current.askId;
|
|
3079
|
+
if (o) try {
|
|
3080
|
+
await a(`${t}/api/teams/${n}/datasets/${r}/events/select`, {
|
|
3081
|
+
method: "POST",
|
|
3082
|
+
headers: { "Content-Type": "application/json" },
|
|
3083
|
+
body: JSON.stringify({
|
|
3084
|
+
queryId: o,
|
|
3085
|
+
documentKey: e.documentKey,
|
|
3086
|
+
position: e.n,
|
|
3087
|
+
...s.current.count === !1 ? { count: !1 } : {}
|
|
3088
|
+
})
|
|
3089
|
+
});
|
|
3090
|
+
} catch {}
|
|
3091
|
+
}, [
|
|
3092
|
+
t,
|
|
3093
|
+
n,
|
|
3094
|
+
r,
|
|
3095
|
+
a
|
|
3096
|
+
]), g = i(() => p.current?.abort(), []), _ = i(() => {
|
|
3097
|
+
p.current?.abort(), d(kt);
|
|
3098
|
+
}, []);
|
|
3099
|
+
return o(() => () => p.current?.abort(), []), {
|
|
3100
|
+
...u,
|
|
3101
|
+
ask: m,
|
|
3102
|
+
stop: g,
|
|
3103
|
+
reset: _,
|
|
3104
|
+
openSource: h,
|
|
3105
|
+
busy: u.status === "searching" || u.status === "writing"
|
|
3106
|
+
};
|
|
3107
|
+
}
|
|
3108
|
+
var $ = {
|
|
3109
|
+
panel: "_panel_gjc13_1",
|
|
3110
|
+
thread: "_thread_gjc13_4",
|
|
3111
|
+
fill: "_fill_gjc13_5",
|
|
3112
|
+
answer: "_answer_gjc13_8",
|
|
3113
|
+
paragraph: "_paragraph_gjc13_9",
|
|
3114
|
+
action: "_action_gjc13_10",
|
|
3115
|
+
turn: "_turn_gjc13_11",
|
|
3116
|
+
heading: "_heading_gjc13_14",
|
|
3117
|
+
list: "_list_gjc13_15",
|
|
3118
|
+
inlineCode: "_inlineCode_gjc13_16",
|
|
3119
|
+
codeBlock: "_codeBlock_gjc13_17",
|
|
3120
|
+
searched: "_searched_gjc13_22",
|
|
3121
|
+
searchedLabel: "_searchedLabel_gjc13_23",
|
|
3122
|
+
steps: "_steps_gjc13_26",
|
|
3123
|
+
stepDone: "_stepDone_gjc13_27"
|
|
3124
|
+
}, jt = /(`[^`\n]+`)|(\*\*[^*\n]+\*\*)|(\*[^*\n]+\*|_[^_\n]+_)|(\[[^\]\n]+\]\(https?:\/\/[^)\s]+\))|(\[\d+\])/g;
|
|
3125
|
+
function Mt(t, n, r) {
|
|
3126
|
+
let i = [], a = 0, o = 0;
|
|
3127
|
+
for (let s of t.matchAll(jt)) {
|
|
3128
|
+
s.index > a && i.push(t.slice(a, s.index));
|
|
3129
|
+
let c = `${r}-${o++}`, [l, u, d, p, m, h] = s;
|
|
3130
|
+
if (u) i.push(/* @__PURE__ */ f("code", {
|
|
3131
|
+
className: $.inlineCode,
|
|
3132
|
+
children: u.slice(1, -1)
|
|
3133
|
+
}, c));
|
|
3134
|
+
else if (d) i.push(/* @__PURE__ */ f("strong", { children: Mt(d.slice(2, -2), n, c) }, c));
|
|
3135
|
+
else if (p) i.push(/* @__PURE__ */ f("em", { children: Mt(p.slice(1, -1), n, c) }, c));
|
|
3136
|
+
else if (m) {
|
|
3137
|
+
let [, e, t] = /^\[([^\]]+)\]\(([^)]+)\)$/.exec(m);
|
|
3138
|
+
i.push(/* @__PURE__ */ f("a", {
|
|
3139
|
+
href: t,
|
|
3140
|
+
target: "_blank",
|
|
3141
|
+
rel: "noopener noreferrer",
|
|
3142
|
+
children: e
|
|
3143
|
+
}, c));
|
|
3144
|
+
} else h ? i.push(/* @__PURE__ */ f(e.Fragment, { children: n(Number(h.slice(1, -1))) }, c)) : i.push(l);
|
|
3145
|
+
a = s.index + l.length;
|
|
3146
|
+
}
|
|
3147
|
+
return a < t.length && i.push(t.slice(a)), i;
|
|
3148
|
+
}
|
|
3149
|
+
function Nt(e) {
|
|
3150
|
+
let t = e.replace(/\r\n/g, "\n").split("\n"), n = [], r = [], i = () => {
|
|
3151
|
+
r.length && (n.push({
|
|
3152
|
+
kind: "paragraph",
|
|
3153
|
+
text: r.join(" ")
|
|
3154
|
+
}), r = []);
|
|
3155
|
+
};
|
|
3156
|
+
for (let e = 0; e < t.length; e++) {
|
|
3157
|
+
let a = t[e], o = /^\s*```\s*([\w+#-]*)\s*$/.exec(a);
|
|
3158
|
+
if (o) {
|
|
3159
|
+
i();
|
|
3160
|
+
let r = [];
|
|
3161
|
+
for (e++; e < t.length && !/^\s*```\s*$/.test(t[e]); e++) r.push(t[e]);
|
|
3162
|
+
n.push({
|
|
3163
|
+
kind: "code",
|
|
3164
|
+
lang: o[1] ?? "",
|
|
3165
|
+
text: r.join("\n")
|
|
3166
|
+
});
|
|
3167
|
+
continue;
|
|
3168
|
+
}
|
|
3169
|
+
let s = /^(#{1,4})\s+(.*)$/.exec(a);
|
|
3170
|
+
if (s) {
|
|
3171
|
+
i(), n.push({
|
|
3172
|
+
kind: "heading",
|
|
3173
|
+
level: s[1].length,
|
|
3174
|
+
text: s[2]
|
|
3175
|
+
});
|
|
3176
|
+
continue;
|
|
3177
|
+
}
|
|
3178
|
+
let c = /^\s*(?:([-*+])|(\d+)[.)])\s+(.*)$/.exec(a);
|
|
3179
|
+
if (c) {
|
|
3180
|
+
i();
|
|
3181
|
+
let e = !!c[2], t = n[n.length - 1];
|
|
3182
|
+
t?.kind === "list" && t.ordered === e ? t.items.push(c[3]) : n.push({
|
|
3183
|
+
kind: "list",
|
|
3184
|
+
ordered: e,
|
|
3185
|
+
items: [c[3]]
|
|
3186
|
+
});
|
|
3187
|
+
continue;
|
|
3188
|
+
}
|
|
3189
|
+
if (a.trim() === "") {
|
|
3190
|
+
i();
|
|
3191
|
+
continue;
|
|
3192
|
+
}
|
|
3193
|
+
let l = n[n.length - 1];
|
|
3194
|
+
if (r.length === 0 && l?.kind === "list" && /^\s{2,}\S/.test(a)) {
|
|
3195
|
+
l.items[l.items.length - 1] += " " + a.trim();
|
|
3196
|
+
continue;
|
|
3197
|
+
}
|
|
3198
|
+
r.push(a.trim());
|
|
3199
|
+
}
|
|
3200
|
+
return i(), n;
|
|
3201
|
+
}
|
|
3202
|
+
function Pt(e, t) {
|
|
3203
|
+
return Nt(e).map((e, n) => {
|
|
3204
|
+
let r = `b${n}`;
|
|
3205
|
+
switch (e.kind) {
|
|
3206
|
+
case "code": return /* @__PURE__ */ f("pre", {
|
|
3207
|
+
className: $.codeBlock,
|
|
3208
|
+
"data-lang": e.lang || void 0,
|
|
3209
|
+
children: /* @__PURE__ */ f("code", { children: e.text })
|
|
3210
|
+
}, r);
|
|
3211
|
+
case "heading": return /* @__PURE__ */ f("p", {
|
|
3212
|
+
className: $.heading,
|
|
3213
|
+
children: Mt(e.text, t, r)
|
|
3214
|
+
}, r);
|
|
3215
|
+
case "list": return /* @__PURE__ */ f(e.ordered ? "ol" : "ul", {
|
|
3216
|
+
className: $.list,
|
|
3217
|
+
children: e.items.map((e, n) => /* @__PURE__ */ f("li", { children: Mt(e, t, `${r}-${n}`) }, n))
|
|
3218
|
+
}, r);
|
|
3219
|
+
default: return /* @__PURE__ */ f("p", {
|
|
3220
|
+
className: $.paragraph,
|
|
3221
|
+
children: Mt(e.text, t, r)
|
|
3222
|
+
}, r);
|
|
3223
|
+
}
|
|
3224
|
+
});
|
|
3225
|
+
}
|
|
3226
|
+
//#endregion
|
|
3227
|
+
//#region src/components/AskPanel.tsx
|
|
3228
|
+
var Ft = /\[(\d+)\]/g;
|
|
3229
|
+
function It(e) {
|
|
3230
|
+
let t = e.field.split(".")[0];
|
|
3231
|
+
return e.value === "true" ? t : e.value === "false" ? `not ${t}` : e.value == null ? e.min != null && e.max != null ? e.min === e.max ? `${t} ${e.min}` : `${t} ${e.min}–${e.max}` : e.min == null ? `${t} ≤ ${e.max}` : `${t} ≥ ${e.min}` : e.value;
|
|
3232
|
+
}
|
|
3233
|
+
var Lt = ({ question: e, followUps: t = !1, onSourceClick: n, label: r = "Answer", renderAnswer: i = Pt, onFollowUp: a, onStatusChange: s, onFilters: u, filterLabel: d = It, fill: b = !1, className: T = "" }) => {
|
|
3234
|
+
let E = At(), { ask: D, reset: O, stop: k, status: A, openSource: j } = E, [N, P] = l(!1), [I, L] = l([]), [R, z] = l(""), B = c([]), V = c(null), H = c(null), U = c(!0);
|
|
3235
|
+
o(() => {
|
|
3236
|
+
L([]), B.current = [], e?.trim() ? D(e) : O();
|
|
3237
|
+
}, [
|
|
3238
|
+
e,
|
|
3239
|
+
D,
|
|
3240
|
+
O
|
|
3241
|
+
]), o(() => {
|
|
3242
|
+
s?.(A);
|
|
3243
|
+
}, [A, s]);
|
|
3244
|
+
let W = c(void 0);
|
|
3245
|
+
o(() => {
|
|
3246
|
+
E.filters && E.filters !== W.current && (W.current = E.filters, u?.(E.filters));
|
|
3247
|
+
}, [E.filters, u]), o(() => {
|
|
3248
|
+
let e = H.current;
|
|
3249
|
+
b && e && U.current && (e.scrollTop = e.scrollHeight);
|
|
3250
|
+
}, [
|
|
3251
|
+
b,
|
|
3252
|
+
E.answer,
|
|
3253
|
+
E.steps.length,
|
|
3254
|
+
A,
|
|
3255
|
+
I.length
|
|
3256
|
+
]);
|
|
3257
|
+
let ee = () => {
|
|
3258
|
+
let e = H.current;
|
|
3259
|
+
e && (U.current = e.scrollHeight - e.scrollTop - e.clientHeight < 40);
|
|
3260
|
+
}, G = (e) => e && /* @__PURE__ */ p("div", {
|
|
3261
|
+
className: $.searched,
|
|
3262
|
+
children: [
|
|
3263
|
+
/* @__PURE__ */ p("span", {
|
|
3264
|
+
className: $.searchedLabel,
|
|
3265
|
+
children: [e.more ? `${e.found}+` : e.found, " found"]
|
|
3266
|
+
}),
|
|
3267
|
+
e.filters.map((e, t) => /* @__PURE__ */ f(x, { children: d(e) }, t)),
|
|
3268
|
+
e.text && /* @__PURE__ */ p("span", {
|
|
3269
|
+
className: $.searchedLabel,
|
|
3270
|
+
children: [
|
|
3271
|
+
"“",
|
|
3272
|
+
e.text,
|
|
3273
|
+
"”"
|
|
3274
|
+
]
|
|
3275
|
+
}),
|
|
3276
|
+
e.sort && /* @__PURE__ */ p("span", {
|
|
3277
|
+
className: $.searchedLabel,
|
|
3278
|
+
children: [
|
|
3279
|
+
"sorted by ",
|
|
3280
|
+
e.sort.field.split(".")[0],
|
|
3281
|
+
", ",
|
|
3282
|
+
e.sort.descending ? "largest" : "smallest",
|
|
3283
|
+
" first"
|
|
3284
|
+
]
|
|
3285
|
+
})
|
|
3286
|
+
]
|
|
3287
|
+
});
|
|
3288
|
+
if (A === "idle" && I.length === 0) return null;
|
|
3289
|
+
let K = (e, t) => (r) => {
|
|
3290
|
+
r.preventDefault(), j(e, t), n?.(e);
|
|
3291
|
+
}, ne = (e, t) => (r) => {
|
|
3292
|
+
let i = e.find((e) => e.n === r);
|
|
3293
|
+
return /* @__PURE__ */ f(C, {
|
|
3294
|
+
n: r,
|
|
3295
|
+
title: i?.title,
|
|
3296
|
+
onClick: i && n ? K(i, t) : void 0
|
|
3297
|
+
});
|
|
3298
|
+
}, re = (e, t, n) => {
|
|
3299
|
+
let r = new Set([...e.matchAll(Ft)].map((e) => Number(e[1])));
|
|
3300
|
+
return n && r.size > 0 ? t.filter((e) => r.has(e.n)) : t.slice(0, 3);
|
|
3301
|
+
}, ie = (e, t, r, i) => {
|
|
3302
|
+
let a = re(e, t, r);
|
|
3303
|
+
return a.length > 0 && /* @__PURE__ */ f(S, { items: a.map((e) => ({
|
|
3304
|
+
n: e.n,
|
|
3305
|
+
title: e.title,
|
|
3306
|
+
onClick: n ? K(e, i) : void 0
|
|
3307
|
+
})) });
|
|
3308
|
+
}, q = () => {
|
|
3309
|
+
navigator.clipboard?.writeText(E.answer.replace(Ft, "")).catch(() => {}), P(!0), setTimeout(() => P(!1), 2e3);
|
|
3310
|
+
}, J = (e) => {
|
|
3311
|
+
if (!(E.busy || !e.trim())) {
|
|
3312
|
+
if (A === "answered" && E.answer) {
|
|
3313
|
+
let e = {
|
|
3314
|
+
question: E.question,
|
|
3315
|
+
answer: E.answer,
|
|
3316
|
+
sources: E.sources,
|
|
3317
|
+
askId: E.askId,
|
|
3318
|
+
filters: E.filters
|
|
3319
|
+
};
|
|
3320
|
+
L((t) => [...t, e]), B.current = [...B.current, {
|
|
3321
|
+
question: e.question,
|
|
3322
|
+
answer: e.answer,
|
|
3323
|
+
...e.filters ? { shown: {
|
|
3324
|
+
filters: e.filters.filters,
|
|
3325
|
+
text: e.filters.text,
|
|
3326
|
+
sort: e.filters.sort ?? null
|
|
3327
|
+
} } : {}
|
|
3328
|
+
}];
|
|
3329
|
+
}
|
|
3330
|
+
z(""), D(e, B.current);
|
|
3331
|
+
}
|
|
3332
|
+
}, ae = t ? () => V.current?.focus() : a;
|
|
3333
|
+
return /* @__PURE__ */ p("div", {
|
|
3334
|
+
className: `${$.panel} ${b ? $.fill : ""} ${T}`,
|
|
3335
|
+
"aria-live": "polite",
|
|
3336
|
+
"aria-busy": E.busy,
|
|
3337
|
+
children: [/* @__PURE__ */ p("div", {
|
|
3338
|
+
ref: H,
|
|
3339
|
+
className: $.thread,
|
|
3340
|
+
onScroll: b ? ee : void 0,
|
|
3341
|
+
children: [I.map((e, t) => /* @__PURE__ */ p("div", {
|
|
3342
|
+
className: $.turn,
|
|
3343
|
+
children: [/* @__PURE__ */ f(F, { children: e.question }), /* @__PURE__ */ p(v, {
|
|
3344
|
+
label: r,
|
|
3345
|
+
children: [
|
|
3346
|
+
G(e.filters),
|
|
3347
|
+
/* @__PURE__ */ f("div", {
|
|
3348
|
+
className: $.answer,
|
|
3349
|
+
children: i(e.answer, ne(e.sources, e.askId))
|
|
3350
|
+
}),
|
|
3351
|
+
ie(e.answer, e.sources, !0, e.askId)
|
|
3352
|
+
]
|
|
3353
|
+
})]
|
|
3354
|
+
}, t)), A !== "idle" && /* @__PURE__ */ p("div", {
|
|
3355
|
+
className: $.turn,
|
|
3356
|
+
children: [/* @__PURE__ */ f(F, { children: E.question }), /* @__PURE__ */ p(v, {
|
|
3357
|
+
label: r,
|
|
3358
|
+
children: [
|
|
3359
|
+
G(E.filters),
|
|
3360
|
+
E.answer && /* @__PURE__ */ f("div", {
|
|
3361
|
+
className: $.answer,
|
|
3362
|
+
children: i(E.answer, ne(E.sources))
|
|
3363
|
+
}),
|
|
3364
|
+
A === "searching" && E.steps.length > 0 && /* @__PURE__ */ p("div", {
|
|
3365
|
+
className: $.steps,
|
|
3366
|
+
children: [E.steps.slice(0, -1).map((e, t) => /* @__PURE__ */ f("span", {
|
|
3367
|
+
className: $.stepDone,
|
|
3368
|
+
children: e
|
|
3369
|
+
}, t)), /* @__PURE__ */ p(M, { children: [E.steps[E.steps.length - 1], "…"] })]
|
|
3370
|
+
}),
|
|
3371
|
+
A === "searching" && E.steps.length === 0 && /* @__PURE__ */ f(M, { children: "Searching…" }),
|
|
3372
|
+
A === "writing" && /* @__PURE__ */ f(M, {
|
|
3373
|
+
spinner: "grow",
|
|
3374
|
+
children: "Writing…"
|
|
3375
|
+
}),
|
|
3376
|
+
A === "error" && /* @__PURE__ */ p(m, {
|
|
3377
|
+
variant: "default",
|
|
3378
|
+
icon: null,
|
|
3379
|
+
children: [
|
|
3380
|
+
/* @__PURE__ */ f(g, { children: E.error?.code === "nothingFound" ? "Nothing to answer from" : "The answer did not come through" }),
|
|
3381
|
+
/* @__PURE__ */ f(h, { children: E.error?.code === "nothingFound" ? "The search found no records about this. Try other words, or search instead." : E.error?.message }),
|
|
3382
|
+
E.error?.code !== "nothingFound" && /* @__PURE__ */ f("div", {
|
|
3383
|
+
className: $.action,
|
|
3384
|
+
children: /* @__PURE__ */ f(y, {
|
|
3385
|
+
variant: "secondary",
|
|
3386
|
+
size: "micro",
|
|
3387
|
+
iconLeft: /* @__PURE__ */ f(te, {}),
|
|
3388
|
+
onClick: () => D(E.question, B.current),
|
|
3389
|
+
children: "Try again"
|
|
3390
|
+
})
|
|
3391
|
+
})
|
|
3392
|
+
]
|
|
3393
|
+
}),
|
|
3394
|
+
A === "limited" && /* @__PURE__ */ p(m, {
|
|
3395
|
+
variant: "default",
|
|
3396
|
+
icon: null,
|
|
3397
|
+
children: [/* @__PURE__ */ f(g, { children: "Too many questions for now" }), /* @__PURE__ */ p(h, { children: [
|
|
3398
|
+
"You can ask again in about ",
|
|
3399
|
+
E.retryAfterSeconds && E.retryAfterSeconds > 90 ? `${Math.ceil(E.retryAfterSeconds / 60)} minutes` : "a minute",
|
|
3400
|
+
". Search still works in the meantime."
|
|
3401
|
+
] })]
|
|
3402
|
+
}),
|
|
3403
|
+
A !== "error" && A !== "limited" && ie(E.answer, E.sources, A === "answered"),
|
|
3404
|
+
A === "answered" && /* @__PURE__ */ f(_, {
|
|
3405
|
+
onCopy: q,
|
|
3406
|
+
copied: N,
|
|
3407
|
+
onFollowUp: ae
|
|
3408
|
+
})
|
|
3409
|
+
]
|
|
3410
|
+
})]
|
|
3411
|
+
})]
|
|
3412
|
+
}), t && /* @__PURE__ */ f(w, {
|
|
3413
|
+
ref: V,
|
|
3414
|
+
value: R,
|
|
3415
|
+
onChange: z,
|
|
3416
|
+
onSend: J,
|
|
3417
|
+
onStop: k,
|
|
3418
|
+
streaming: E.busy,
|
|
3419
|
+
placeholder: "Ask a follow-up…",
|
|
3420
|
+
"aria-label": "Ask a follow-up"
|
|
3421
|
+
})]
|
|
3422
|
+
});
|
|
3423
|
+
};
|
|
3424
|
+
//#endregion
|
|
3425
|
+
export { _t as ActiveFiltersPanel, Lt as AskPanel, ft as BucketFilterPanel, Se as DEFAULT_CUT, ge as DEFAULT_THRESHOLDS, tt as FilterPanelSkeleton, q as IndxApiError, lt as RangeFilterPanel, we as SCORE_SCALE, Ce as STRICT_COVERAGE, me as SearchContext, Ct as SearchErrorBoundary, Re as SearchInput, he as SearchProvider, We as SearchResult, Qe as SearchResultRow, Xe as SearchResults, Ve as SearchResultsMessage, qe as SearchResultsSkeleton, St as SearchSettingsPanel, J as SearchSetupError, yt as SortByPanel, it as ValueFilterPanel, ae as describeSearchError, ye as isIdentifier, Dt as localFilters, xe as nextOffer, Pe as stripAskPhrases, be as triggers, At as useAsk, Ot as useFilterSuggestion, Tt as useHybridSearch, Y as useSearch, Y as useSearchContext, Ie as useSearchOrAsk, wt as useVectorSearch, Te as visibleResults };
|