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