@indxsearch/intrface 3.15.0 β 4.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +88 -0
- package/README.md +4 -3
- package/dist/components/AskPanel.d.ts +8 -1
- package/dist/components/QuickAnswer.d.ts +4 -2
- package/dist/components/SearchInput.d.ts +5 -3
- package/dist/components/SearchResults.d.ts +20 -3
- package/dist/context/SearchContext.d.ts +40 -14
- package/dist/hooks/useAsk.d.ts +41 -5
- package/dist/hooks/useSearchOrAsk.d.ts +25 -11
- package/dist/index.cjs.js +3 -3
- package/dist/index.d.ts +3 -5
- package/dist/index.es.js +1583 -1311
- package/dist/intrface.css +1 -1
- package/dist/utils/searchOrAsk.d.ts +20 -42
- package/package.json +3 -3
- package/dist/utils/askPhrases.d.ts +0 -24
package/dist/index.es.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
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
|
-
import {
|
|
4
|
-
import { Fragment as
|
|
5
|
-
import { Alert as
|
|
6
|
-
import { Ai_agent as
|
|
3
|
+
import { Rungs as u, SearchMode as d, SystemState as f, Tolerance as p } from "@indxsearch/indx-types";
|
|
4
|
+
import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
5
|
+
import { Alert as _, AlertDescription as v, AlertTitle as y, AnswerActions as b, AssistantMessage as x, Button as S, Checkbox as C, Chip as w, CitationList as T, CitationRef as E, Composer as D, FilterPanelBase as O, InputField as k, Kbd as A, Popover as j, RadioButton as M, SearchField as N, Select as P, ShimmerText as F, Skeleton as I, Slider as L, StreamStatus as R, ToggleSwitch as z, Tooltip as B, UserMessage as V } from "@indxsearch/systm";
|
|
6
|
+
import { Ai_agent as H, ArrowDown as U, ArrowRight as W, Cloud as G, Filter as K, Fuzzy_search as ee, Hour_glass as q, Indx as te, Key as ne, Lock as J, Refresh as Y, Search as X, Speedometer as re, Warning as ie, X_or_error as ae } from "@indxsearch/pixl";
|
|
7
7
|
// src/context/IndxApiError.ts
|
|
8
|
-
var
|
|
8
|
+
var Z = class e extends Error {
|
|
9
9
|
status;
|
|
10
10
|
code;
|
|
11
11
|
problem;
|
|
@@ -29,14 +29,14 @@ var Y = 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
|
+
}, oe = class extends Error {
|
|
33
33
|
constructor(e) {
|
|
34
34
|
super(e), this.name = "SearchSetupError";
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
-
function
|
|
37
|
+
function se(e, t) {
|
|
38
38
|
let n = e instanceof Error ? e.message : String(e);
|
|
39
|
-
if (e instanceof
|
|
39
|
+
if (e instanceof oe) return {
|
|
40
40
|
kind: "setup",
|
|
41
41
|
message: n,
|
|
42
42
|
technical: n,
|
|
@@ -48,7 +48,7 @@ function ae(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 Z) {
|
|
52
52
|
let r = {
|
|
53
53
|
message: n,
|
|
54
54
|
status: e.status,
|
|
@@ -114,15 +114,15 @@ function ae(e, t) {
|
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
116
|
// src/context/useIndxAuth.ts
|
|
117
|
-
function
|
|
118
|
-
let [a, s] = l(null), [c,
|
|
117
|
+
function ce({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebugLogs: i = !1 }) {
|
|
118
|
+
let [a, s] = l(null), [c, u] = l(!0), [d, 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);
|
|
119
119
|
return o(() => {
|
|
120
120
|
(async () => {
|
|
121
|
-
D(null), k(null),
|
|
121
|
+
D(null), k(null), u(!0);
|
|
122
122
|
try {
|
|
123
|
-
if (!r) throw console.error("[Auth] β Missing bearer token"), console.error("[Auth] π‘ Pass preAuthenticatedToken to SearchProvider (create a token on the Indx Dashboard)"), new
|
|
124
|
-
if (!e) throw console.error("[Auth] β Missing INDX server URL"), console.error("[Auth] π‘ Pass a url to SearchProvider"), new
|
|
125
|
-
if (!n) throw console.error("[Auth] β Missing dataset name"), console.error("[Auth] π‘ Pass dataset=\"your-dataset-name\" to SearchProvider"), new
|
|
123
|
+
if (!r) throw console.error("[Auth] β Missing bearer token"), console.error("[Auth] π‘ Pass preAuthenticatedToken to SearchProvider (create a token on the Indx Dashboard)"), new oe("A bearer token is required. Check console for instructions.");
|
|
124
|
+
if (!e) throw console.error("[Auth] β Missing INDX server URL"), console.error("[Auth] π‘ Pass a url to SearchProvider"), new oe("INDX server URL is required. Check console for instructions.");
|
|
125
|
+
if (!n) throw console.error("[Auth] β Missing dataset name"), console.error("[Auth] π‘ Pass dataset=\"your-dataset-name\" to SearchProvider"), new oe("Dataset name is required. Check console for instructions.");
|
|
126
126
|
i && console.log("[Auth] β
Using bearer token");
|
|
127
127
|
let a = r, o = (e) => fetch(e, {
|
|
128
128
|
method: "GET",
|
|
@@ -133,26 +133,26 @@ function oe({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebug
|
|
|
133
133
|
});
|
|
134
134
|
i && console.log("[Auth] π Checking dataset status...");
|
|
135
135
|
let c = await o(`${e}/api/teams/${t}/datasets/${n}/status`);
|
|
136
|
-
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
|
|
136
|
+
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 Z.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 Z.fromResponse("Dataset status", c)) : (console.error("[Auth] β Failed to get dataset status:", c.status), await Z.fromResponse("Dataset status", c));
|
|
137
137
|
let l = await c.json();
|
|
138
|
-
i && console.log("[Auth] π Dataset status:", l), s(a), i && console.log("[Auth] β
Dataset session established"), l.systemState !== void 0 && l.systemState !==
|
|
139
|
-
let
|
|
140
|
-
|
|
141
|
-
let [
|
|
138
|
+
i && console.log("[Auth] π Dataset status:", l), s(a), i && console.log("[Auth] β
Dataset session established"), l.systemState !== void 0 && l.systemState !== f.Ready && (console.warn("[Auth] β οΈ Dataset is not ready yet. Current state:", l.systemState), console.warn("[Auth] π‘ Wait for indexing to complete before searching"));
|
|
139
|
+
let u = l.documentCount ?? l.numberOfRecords ?? 0;
|
|
140
|
+
u === 0 ? (console.warn("[Auth] β οΈ Dataset \"" + n + "\" is empty (0 records)"), console.warn("[Auth] π‘ Add documents to your dataset before searching"), console.warn("[Auth] π‘ Search will work but return no results")) : i && console.log("[Auth] β
Dataset has", u, "records");
|
|
141
|
+
let [d, m, g, v] = await Promise.all([
|
|
142
142
|
o(`${e}/api/teams/${t}/datasets/${n}/fields/filterable`),
|
|
143
143
|
o(`${e}/api/teams/${t}/datasets/${n}/fields/facetable`),
|
|
144
144
|
o(`${e}/api/teams/${t}/datasets/${n}/fields/sortable`),
|
|
145
145
|
o(`${e}/api/teams/${t}/datasets/${n}/fields/configuration`).catch(() => null)
|
|
146
146
|
]);
|
|
147
|
-
if (!
|
|
148
|
-
if (!m.ok) throw console.error("[Auth] β GetFacetableFields failed:", m.status), await
|
|
149
|
-
if (!g.ok) throw console.error("[Auth] β GetSortableFields failed:", g.status), await
|
|
147
|
+
if (!d.ok) throw console.error("[Auth] β GetFilterableFields failed:", d.status), await Z.fromResponse("Filterable fields", d);
|
|
148
|
+
if (!m.ok) throw console.error("[Auth] β GetFacetableFields failed:", m.status), await Z.fromResponse("Facetable fields", m);
|
|
149
|
+
if (!g.ok) throw console.error("[Auth] β GetSortableFields failed:", g.status), await Z.fromResponse("Sortable fields", g);
|
|
150
150
|
let [b, S, w] = await Promise.all([
|
|
151
|
-
|
|
151
|
+
d.json().catch((e) => (console.error("Failed to parse GetFilterableFields response:", e), [])),
|
|
152
152
|
m.json().catch((e) => (console.error("Failed to parse GetFacetableFields response:", e), [])),
|
|
153
153
|
g.json().catch((e) => (console.error("Failed to parse GetSortableFields response:", e), []))
|
|
154
154
|
]);
|
|
155
|
-
p(b || []), h(S || []), _(w || []), T(
|
|
155
|
+
p(b || []), h(S || []), _(w || []), T(u);
|
|
156
156
|
let E = {};
|
|
157
157
|
if (v?.ok) {
|
|
158
158
|
let e = await v.json().catch((e) => (console.error("Failed to parse GetFieldConfiguration response:", e), []));
|
|
@@ -191,12 +191,12 @@ function oe({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebug
|
|
|
191
191
|
if (D.facets) for (let [e, t] of Object.entries(D.facets)) Array.isArray(t) && (k[e] = t.map((e) => e.key));
|
|
192
192
|
x(O), C(k), i && console.log("[Auth] β
Initialization complete");
|
|
193
193
|
} catch (r) {
|
|
194
|
-
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(
|
|
194
|
+
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(se(r, {
|
|
195
195
|
team: t,
|
|
196
196
|
dataset: n
|
|
197
197
|
}));
|
|
198
198
|
} finally {
|
|
199
|
-
|
|
199
|
+
u(!1);
|
|
200
200
|
}
|
|
201
201
|
})();
|
|
202
202
|
}, [
|
|
@@ -212,7 +212,7 @@ function oe({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebug
|
|
|
212
212
|
retry: () => j((e) => e + 1),
|
|
213
213
|
initialFacetStats: b,
|
|
214
214
|
initialFacetKeys: S,
|
|
215
|
-
filterableFields:
|
|
215
|
+
filterableFields: d,
|
|
216
216
|
facetableFields: m,
|
|
217
217
|
sortableFields: g,
|
|
218
218
|
fieldTypes: v,
|
|
@@ -220,30 +220,25 @@ function oe({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebug
|
|
|
220
220
|
};
|
|
221
221
|
}
|
|
222
222
|
// src/context/buildFilterProxy.ts
|
|
223
|
-
async function
|
|
223
|
+
async function le(e, t, n, r, i, a, o) {
|
|
224
224
|
let s = await o(`${r}/api/teams/${i}/datasets/${a}/filters/${e}`, {
|
|
225
225
|
method: "POST",
|
|
226
226
|
headers: { "Content-Type": "application/json" },
|
|
227
227
|
body: JSON.stringify(t)
|
|
228
228
|
});
|
|
229
|
-
if (!s.ok) throw await
|
|
229
|
+
if (!s.ok) throw await Z.fromResponse(n, s);
|
|
230
230
|
let c = await s.json();
|
|
231
231
|
if (!c || typeof c.hashString != "string") throw Error(`${n} failed: server returned no filter token`);
|
|
232
232
|
return c;
|
|
233
233
|
}
|
|
234
|
-
async function
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
let o = e[0];
|
|
238
|
-
for (let s = 1; s < e.length; s++) o = await se("combine", {
|
|
239
|
-
a: o,
|
|
240
|
-
b: e[s],
|
|
234
|
+
async function ue(e, t, n, r, i, a) {
|
|
235
|
+
return e.length === 0 ? null : e.length === 1 ? e[0] : le("combine", {
|
|
236
|
+
filters: e,
|
|
241
237
|
useAndOperation: t === "and"
|
|
242
238
|
}, "CombineFilters", n, r, i, a);
|
|
243
|
-
return o;
|
|
244
239
|
}
|
|
245
|
-
async function
|
|
246
|
-
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 }) =>
|
|
240
|
+
async function de(e, t, n, r, i, a, o = {}, s = {}, c = {}) {
|
|
241
|
+
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 }) => le("range", {
|
|
247
242
|
fieldName: e,
|
|
248
243
|
lowerLimit: t,
|
|
249
244
|
upperLimit: o
|
|
@@ -252,29 +247,29 @@ async function le(e, t, n, r, i, a, o = {}, s = {}, c = {}) {
|
|
|
252
247
|
return Number.isFinite(o) ? f(e, {
|
|
253
248
|
min: o,
|
|
254
249
|
max: o
|
|
255
|
-
}) :
|
|
250
|
+
}) : le("value", {
|
|
256
251
|
fieldName: e,
|
|
257
252
|
value: t
|
|
258
253
|
}, `Value filter '${e}'`, n, r, i, a);
|
|
259
254
|
}, [m, h, g] = await Promise.all([
|
|
260
|
-
Promise.all(l.map(async ([e, t]) =>
|
|
255
|
+
Promise.all(l.map(async ([e, t]) => ue(await Promise.all(t.map((t) => p(e, t))), o[e] === "any" ? "or" : "and", n, r, i, a))),
|
|
261
256
|
Promise.all(u.map(([e, t]) => f(e, t))),
|
|
262
|
-
Promise.all(d.map(async ([e, t]) =>
|
|
257
|
+
Promise.all(d.map(async ([e, t]) => ue(await Promise.all(t.map((t) => f(e, t))), "or", n, r, i, a)))
|
|
263
258
|
]);
|
|
264
|
-
return
|
|
259
|
+
return ue([
|
|
265
260
|
...m,
|
|
266
261
|
...h,
|
|
267
262
|
...g
|
|
268
263
|
], "and", n, r, i, a);
|
|
269
264
|
}
|
|
270
265
|
// src/context/useSearchExecution.ts
|
|
271
|
-
function
|
|
266
|
+
function fe(e, t) {
|
|
272
267
|
let n, r = (...r) => {
|
|
273
268
|
clearTimeout(n), n = setTimeout(() => e(...r), t);
|
|
274
269
|
};
|
|
275
270
|
return r.cancel = () => clearTimeout(n), r;
|
|
276
271
|
}
|
|
277
|
-
function
|
|
272
|
+
function pe({ 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, locale: _, count: v, searchTextOf: y }) {
|
|
278
273
|
let b = y ? y(e.query) : e.query, x = c(e.query);
|
|
279
274
|
x.current = e.query;
|
|
280
275
|
let S = c(0), C = c(void 0), w = c(!1), [T, E] = l({}), [D, O] = l(""), [k, A] = l("");
|
|
@@ -299,18 +294,17 @@ function de({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, tea
|
|
|
299
294
|
r.sortableFields,
|
|
300
295
|
t
|
|
301
296
|
]);
|
|
302
|
-
let j = e.searchSettings.maxNumberOfRecordsToReturn, M = e.searchSettings.
|
|
297
|
+
let j = e.searchSettings.maxNumberOfRecordsToReturn, M = e.searchSettings.mode, N = e.searchSettings.removeDuplicates, P = e.searchSettings.refocus, F = e.searchSettings.match, I = e.searchSettings.candidates, L = e.searchSettings.ranking, R = e.searchSettings.minimumScore, z = e.sortBy, B = e.sortAscending, V = i(async ({ enableFacets: i }) => {
|
|
303
298
|
if (!r.token) return;
|
|
304
|
-
let o =
|
|
305
|
-
if (
|
|
299
|
+
let o = b.trim() === "";
|
|
300
|
+
if (o && !d) return;
|
|
301
|
+
let c = ++S.current;
|
|
302
|
+
t((e) => ({
|
|
306
303
|
...e,
|
|
307
304
|
isLoading: !0
|
|
308
|
-
})),
|
|
309
|
-
if (!d) return;
|
|
310
|
-
i = !0;
|
|
311
|
-
}
|
|
305
|
+
})), o && (i = !0);
|
|
312
306
|
try {
|
|
313
|
-
let
|
|
307
|
+
let o = i ? Array.from(/* @__PURE__ */ 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([de(e.filters, e.rangeFilters, a, s, u, n, e.valueMatch, e.bucketFilters, e.fieldTypes), ...o.map((t) => de({
|
|
314
308
|
...e.filters,
|
|
315
309
|
[t]: []
|
|
316
310
|
}, e.rangeFilters, a, s, u, n, e.valueMatch, {
|
|
@@ -318,122 +312,135 @@ function de({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, tea
|
|
|
318
312
|
[t]: []
|
|
319
313
|
}, e.fieldTypes))]), m = d || b.trim() !== "", y = {
|
|
320
314
|
text: b,
|
|
321
|
-
|
|
315
|
+
mode: M,
|
|
322
316
|
removeDuplicates: N,
|
|
323
|
-
|
|
324
|
-
|
|
317
|
+
match: F,
|
|
318
|
+
candidates: I,
|
|
319
|
+
ranking: L
|
|
325
320
|
}, C = {
|
|
326
321
|
...y,
|
|
327
322
|
maxNumberOfRecordsToReturn: m ? j : 0,
|
|
328
323
|
enableFacets: i,
|
|
324
|
+
...m ? { includeDocuments: !0 } : {},
|
|
329
325
|
...l ? { filter: l } : {},
|
|
330
|
-
...
|
|
331
|
-
...
|
|
326
|
+
...z ? { sortBy: z } : {},
|
|
327
|
+
...B === void 0 ? {} : { sortAscending: B }
|
|
332
328
|
};
|
|
333
329
|
p && console.log("[performSearch] request body:", JSON.stringify(C, null, 2));
|
|
334
330
|
let w = new URLSearchParams({ session: h });
|
|
335
331
|
g && w.set("source", g);
|
|
336
|
-
let
|
|
337
|
-
|
|
338
|
-
let
|
|
332
|
+
let V = _ ?? me();
|
|
333
|
+
V && w.set("locale", V), v || w.set("count", "false"), P && w.set("refocus", "true"), x.current.trim() !== b.trim() && w.set("typed", x.current);
|
|
334
|
+
let H = (e) => n(`${a}/api/teams/${s}/datasets/${u}/search?${w}`, {
|
|
339
335
|
method: "POST",
|
|
340
336
|
headers: { "Content-Type": "application/json" },
|
|
341
337
|
body: JSON.stringify(e)
|
|
342
|
-
}), [
|
|
338
|
+
}), [U, ...W] = await Promise.all([H(C), ...f.map((e) => H({
|
|
343
339
|
...y,
|
|
344
340
|
maxNumberOfRecordsToReturn: 0,
|
|
345
341
|
enableFacets: !0,
|
|
346
342
|
...e ? { filter: e } : {}
|
|
347
343
|
}))]);
|
|
348
|
-
if (!
|
|
349
|
-
let
|
|
350
|
-
for (let e = 0; e <
|
|
351
|
-
let t =
|
|
352
|
-
if (!
|
|
353
|
-
let n = await
|
|
354
|
-
n.facets?.[t] !== void 0 && (
|
|
344
|
+
if (!U.ok) throw await Z.fromResponse("Search", U);
|
|
345
|
+
let G = await U.json(), K = U.headers.get("Indx-Query-Id") ?? void 0, ee = G.isFallback ? void 0 : G.count, q = G.isFallback === !0, te = G.toleranceCounts ?? null, ne = G.countedTolerance ?? null, J = G.ranked, Y = G.reranked, X = G.fill ?? null, re = {};
|
|
346
|
+
for (let e = 0; e < o.length; e++) {
|
|
347
|
+
let t = o[e];
|
|
348
|
+
if (!W[e].ok) throw await Z.fromResponse(`Facets for '${t}'`, W[e]);
|
|
349
|
+
let n = await W[e].json();
|
|
350
|
+
n.facets?.[t] !== void 0 && (re[t] = n.facets[t]);
|
|
355
351
|
}
|
|
356
|
-
let
|
|
357
|
-
if (m &&
|
|
358
|
-
let e
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
352
|
+
let ie = G.records || [], ae = ie.map((e) => e.documentKey), oe = ie.map((e) => e.score), se = [];
|
|
353
|
+
if (m && ae.length > 0) {
|
|
354
|
+
let e;
|
|
355
|
+
if (Array.isArray(G.documents) && G.documents.length === ae.length) e = G.documents;
|
|
356
|
+
else {
|
|
357
|
+
let t = await n(`${a}/api/teams/${s}/datasets/${u}/documents/lookup`, {
|
|
358
|
+
method: "POST",
|
|
359
|
+
headers: { "Content-Type": "application/json" },
|
|
360
|
+
body: JSON.stringify(ae)
|
|
361
|
+
});
|
|
362
|
+
if (!t.ok) throw await Z.fromResponse("Document lookup", t);
|
|
363
|
+
e = await t.json();
|
|
364
|
+
}
|
|
365
|
+
se = e.map((e, t) => ({
|
|
365
366
|
document: e,
|
|
366
|
-
documentKey:
|
|
367
|
-
score:
|
|
367
|
+
documentKey: ae[t],
|
|
368
|
+
score: oe[t]
|
|
368
369
|
}));
|
|
369
370
|
}
|
|
370
|
-
let
|
|
371
|
-
if (i &&
|
|
372
|
-
for (let [e, t] of Object.entries(
|
|
371
|
+
let ce = {};
|
|
372
|
+
if (i && G.facets) {
|
|
373
|
+
for (let [e, t] of Object.entries(G.facets)) if (Array.isArray(t) && t.length > 0) {
|
|
373
374
|
let n = t.map((e) => Number(e.key)).filter((e) => !isNaN(e));
|
|
374
|
-
n.length > 0 && (
|
|
375
|
+
n.length > 0 && (ce[e] = {
|
|
375
376
|
min: Math.min(...n),
|
|
376
377
|
max: Math.max(...n)
|
|
377
378
|
});
|
|
378
379
|
}
|
|
379
380
|
}
|
|
380
|
-
if (
|
|
381
|
-
let
|
|
382
|
-
if (
|
|
381
|
+
if (c !== S.current) return;
|
|
382
|
+
let le = b !== D, ue = b !== k, fe = e.facetStats ?? {};
|
|
383
|
+
if (le ? (fe = {
|
|
383
384
|
...r.initialFacetStats,
|
|
384
|
-
...
|
|
385
|
-
}, E(
|
|
385
|
+
...ce
|
|
386
|
+
}, E(fe), O(b)) : fe = {
|
|
386
387
|
...T,
|
|
387
|
-
...
|
|
388
|
-
},
|
|
388
|
+
...ce
|
|
389
|
+
}, ue && i) {
|
|
389
390
|
let n = { ...e.rangeBounds };
|
|
390
|
-
for (let [e, t] of Object.entries(
|
|
391
|
+
for (let [e, t] of Object.entries(ce)) n[e] = t;
|
|
391
392
|
t((e) => ({
|
|
392
393
|
...e,
|
|
393
394
|
rangeBounds: n
|
|
394
395
|
})), A(b);
|
|
395
396
|
}
|
|
396
|
-
let
|
|
397
|
-
...
|
|
398
|
-
...
|
|
399
|
-
} :
|
|
400
|
-
if (i && (!
|
|
401
|
-
|
|
402
|
-
for (let [e, t] of Object.entries(r.initialFacetKeys))
|
|
397
|
+
let pe = Object.keys(re).length > 0 ? {
|
|
398
|
+
...G.facets ?? {},
|
|
399
|
+
...re
|
|
400
|
+
} : G.facets;
|
|
401
|
+
if (i && (!pe || Object.keys(pe).length === 0)) {
|
|
402
|
+
pe = {};
|
|
403
|
+
for (let [e, t] of Object.entries(r.initialFacetKeys)) pe[e] = t.map((e) => ({
|
|
403
404
|
key: e,
|
|
404
405
|
value: null
|
|
405
406
|
}));
|
|
406
407
|
}
|
|
407
|
-
let
|
|
408
|
+
let he = se.filter((e) => {
|
|
408
409
|
let t = b.trim();
|
|
409
|
-
return t === "" || t.length === 1 || e.score >=
|
|
410
|
+
return t === "" || t.length === 1 || e.score >= R;
|
|
410
411
|
}).map((e, t) => ({
|
|
411
412
|
...e,
|
|
412
413
|
position: t + 1
|
|
413
414
|
}));
|
|
414
415
|
t((e) => ({
|
|
415
416
|
...e,
|
|
416
|
-
results:
|
|
417
|
+
results: he,
|
|
417
418
|
error: void 0,
|
|
418
419
|
errorInfo: void 0,
|
|
419
420
|
resultsSuppressed: !m,
|
|
420
421
|
...i ? {
|
|
421
|
-
facets:
|
|
422
|
-
facetStats:
|
|
422
|
+
facets: pe,
|
|
423
|
+
facetStats: fe
|
|
423
424
|
} : {},
|
|
424
425
|
isLoading: !1,
|
|
425
|
-
|
|
426
|
-
|
|
426
|
+
countedTotal: ee,
|
|
427
|
+
isFallback: q,
|
|
428
|
+
toleranceCounts: te,
|
|
429
|
+
countedTolerance: ne,
|
|
430
|
+
ranked: J,
|
|
431
|
+
reranked: Y,
|
|
432
|
+
fill: X,
|
|
433
|
+
queryId: K
|
|
427
434
|
}));
|
|
428
435
|
} catch (e) {
|
|
429
|
-
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)),
|
|
436
|
+
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)), c !== S.current) return;
|
|
430
437
|
t((t) => ({
|
|
431
438
|
...t,
|
|
432
439
|
results: null,
|
|
433
440
|
isLoading: !1,
|
|
434
441
|
resultsSuppressed: !1,
|
|
435
442
|
error: e instanceof Error ? e.message : "Search failed",
|
|
436
|
-
errorInfo:
|
|
443
|
+
errorInfo: se(e, {
|
|
437
444
|
team: s,
|
|
438
445
|
dataset: u
|
|
439
446
|
})
|
|
@@ -446,14 +453,16 @@ function de({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, tea
|
|
|
446
453
|
e.rangeFilters,
|
|
447
454
|
e.bucketFilters,
|
|
448
455
|
e.facetStats,
|
|
449
|
-
|
|
450
|
-
|
|
456
|
+
z,
|
|
457
|
+
B,
|
|
451
458
|
j,
|
|
452
459
|
M,
|
|
453
460
|
N,
|
|
454
461
|
P,
|
|
455
|
-
I,
|
|
456
462
|
F,
|
|
463
|
+
I,
|
|
464
|
+
L,
|
|
465
|
+
R,
|
|
457
466
|
n,
|
|
458
467
|
r.initialFacetStats,
|
|
459
468
|
r.initialFacetKeys,
|
|
@@ -474,15 +483,15 @@ function de({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, tea
|
|
|
474
483
|
v
|
|
475
484
|
]);
|
|
476
485
|
o(() => {
|
|
477
|
-
C.current =
|
|
478
|
-
}, [
|
|
479
|
-
let
|
|
480
|
-
o(() => (
|
|
486
|
+
C.current = V;
|
|
487
|
+
}, [V]);
|
|
488
|
+
let H = c(null);
|
|
489
|
+
o(() => (H.current?.cancel(), H.current = fe(() => {
|
|
481
490
|
p && console.log("Debounced searchWithFacets fired"), C.current?.({ enableFacets: !0 });
|
|
482
491
|
}, e.facetDebounceDelayMillis ?? 500), () => {
|
|
483
|
-
|
|
492
|
+
H.current?.cancel();
|
|
484
493
|
}), [e.facetDebounceDelayMillis]), o(() => {
|
|
485
|
-
!r.isFetchingInitial && r.token && !w.current && (d && C.current?.({ enableFacets: f }), w.current = !0);
|
|
494
|
+
!r.isFetchingInitial && r.token && !w.current && ((d || b.trim() !== "") && C.current?.({ enableFacets: f }), w.current = !0);
|
|
486
495
|
}, [
|
|
487
496
|
r.isFetchingInitial,
|
|
488
497
|
r.token,
|
|
@@ -490,13 +499,14 @@ function de({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, tea
|
|
|
490
499
|
f
|
|
491
500
|
]), o(() => {
|
|
492
501
|
if (!r.token || !w.current) return;
|
|
493
|
-
let
|
|
494
|
-
if (
|
|
502
|
+
let e = b.trim(), n = e === "" && d;
|
|
503
|
+
if (e === "" && !d) S.current++, H.current?.cancel(), t((e) => e.resultsSuppressed && !e.isLoading ? e : {
|
|
495
504
|
...e,
|
|
496
|
-
resultsSuppressed: !0
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
505
|
+
resultsSuppressed: !0,
|
|
506
|
+
isLoading: !1
|
|
507
|
+
});
|
|
508
|
+
else return n ? (H.current?.cancel(), C.current?.({ enableFacets: f })) : f ? (p && console.log("Search fired"), C.current?.({ enableFacets: !1 }), H.current?.()) : C.current?.({ enableFacets: !1 }), () => {
|
|
509
|
+
H.current?.cancel();
|
|
500
510
|
};
|
|
501
511
|
}, [
|
|
502
512
|
b,
|
|
@@ -510,14 +520,14 @@ function de({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, tea
|
|
|
510
520
|
if (!w.current || !r.token) return;
|
|
511
521
|
let e = b.trim();
|
|
512
522
|
(d || e !== "") && C.current?.({ enableFacets: f });
|
|
513
|
-
}, [
|
|
514
|
-
let
|
|
523
|
+
}, [z, B]);
|
|
524
|
+
let U = c(!0), W = c(b);
|
|
515
525
|
return o(() => {
|
|
516
|
-
if (
|
|
517
|
-
|
|
526
|
+
if (U.current) {
|
|
527
|
+
U.current = !1;
|
|
518
528
|
return;
|
|
519
529
|
}
|
|
520
|
-
if (
|
|
530
|
+
if (W.current !== b || !w.current || !r.token) return;
|
|
521
531
|
if (m.current) {
|
|
522
532
|
m.current = !1, C.current?.({ enableFacets: !1 });
|
|
523
533
|
return;
|
|
@@ -529,32 +539,27 @@ function de({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, tea
|
|
|
529
539
|
M,
|
|
530
540
|
N,
|
|
531
541
|
P,
|
|
542
|
+
F,
|
|
532
543
|
I,
|
|
533
|
-
|
|
544
|
+
L,
|
|
545
|
+
R
|
|
534
546
|
]), o(() => {
|
|
535
|
-
|
|
547
|
+
W.current = b;
|
|
536
548
|
}, [b]), { retrySearch: i(() => {
|
|
537
549
|
C.current?.({ enableFacets: f });
|
|
538
550
|
}, [f]) };
|
|
539
551
|
}
|
|
540
|
-
function
|
|
552
|
+
function me() {
|
|
541
553
|
if (typeof document < "u" && document.documentElement.lang) return document.documentElement.lang;
|
|
542
554
|
if (typeof navigator < "u" && navigator.language) return navigator.language;
|
|
543
555
|
}
|
|
544
556
|
// src/context/SearchContext.tsx
|
|
545
|
-
function
|
|
557
|
+
function he() {
|
|
546
558
|
let e = globalThis.crypto;
|
|
547
559
|
return e?.randomUUID ? e.randomUUID() : Math.random().toString(36).slice(2) + Date.now().toString(36);
|
|
548
560
|
}
|
|
549
|
-
var
|
|
550
|
-
let
|
|
551
|
-
let t = S ?? T.fn;
|
|
552
|
-
return !t || e === D ? e : t(e);
|
|
553
|
-
}, [
|
|
554
|
-
S,
|
|
555
|
-
T,
|
|
556
|
-
D
|
|
557
|
-
]), A = i((e) => E({ fn: e }), []), j = c(s), [M, N] = l({
|
|
561
|
+
var ge = "Type to search", _e = n(void 0), ve = ({ children: e, url: t, team: n, dataset: r, allowEmptySearch: a = !1, maxResults: s = 10, facetDebounceDelayMillis: u = 500, enableFacets: d = !0, removeDuplicates: f = !0, mode: p, match: m = {}, candidates: g = {}, ranking: _ = {}, enableDebugLogs: v = !1, preAuthenticatedToken: y, source: b, locale: x, count: S = !0, searchTextOf: C }) => {
|
|
562
|
+
let w = c(!1), T = c(he()).current, [E, D] = l(null), [O, k] = l(null), A = i((e) => !C || e === E ? e : C(e), [C, E]), j = c(s), [M, N] = l({
|
|
558
563
|
query: "",
|
|
559
564
|
results: null,
|
|
560
565
|
isLoading: !1,
|
|
@@ -574,29 +579,30 @@ var me = "Type to search", he = n(void 0), ge = ({ children: e, url: t, team: n,
|
|
|
574
579
|
rangeBounds: {},
|
|
575
580
|
searchSettings: {
|
|
576
581
|
maxNumberOfRecordsToReturn: s,
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
582
|
+
mode: p,
|
|
583
|
+
match: m,
|
|
584
|
+
candidates: g,
|
|
585
|
+
ranking: _,
|
|
586
|
+
removeDuplicates: f,
|
|
580
587
|
minimumScore: 0,
|
|
581
588
|
showScore: !0,
|
|
582
|
-
placeholderText:
|
|
583
|
-
coverageSetup: { ...g }
|
|
589
|
+
placeholderText: ge
|
|
584
590
|
}
|
|
585
591
|
});
|
|
586
592
|
o(() => {
|
|
587
|
-
|
|
588
|
-
}, [
|
|
593
|
+
v && console.log("SearchContext mounted on client");
|
|
594
|
+
}, [v]), o(() => {
|
|
589
595
|
N((e) => ({
|
|
590
596
|
...e,
|
|
591
597
|
facetDebounceDelayMillis: u
|
|
592
598
|
}));
|
|
593
599
|
}, [u]);
|
|
594
|
-
let [P] = l(d), F =
|
|
600
|
+
let [P] = l(d), F = ce({
|
|
595
601
|
url: t,
|
|
596
602
|
team: n,
|
|
597
603
|
dataset: r,
|
|
598
|
-
preAuthenticatedToken:
|
|
599
|
-
enableDebugLogs:
|
|
604
|
+
preAuthenticatedToken: y,
|
|
605
|
+
enableDebugLogs: v
|
|
600
606
|
}), I = i((e, t = {}) => {
|
|
601
607
|
if (!F.token) throw Error("No authentication token available");
|
|
602
608
|
return fetch(e, {
|
|
@@ -606,7 +612,7 @@ var me = "Type to search", he = n(void 0), ge = ({ children: e, url: t, team: n,
|
|
|
606
612
|
Authorization: `Bearer ${F.token}`
|
|
607
613
|
}
|
|
608
614
|
});
|
|
609
|
-
}, [F.token]), { retrySearch: L } =
|
|
615
|
+
}, [F.token]), { retrySearch: L } = pe({
|
|
610
616
|
state: M,
|
|
611
617
|
setState: N,
|
|
612
618
|
authenticatedFetch: I,
|
|
@@ -616,13 +622,13 @@ var me = "Type to search", he = n(void 0), ge = ({ children: e, url: t, team: n,
|
|
|
616
622
|
dataset: r,
|
|
617
623
|
allowEmptySearch: a,
|
|
618
624
|
facetsEnabled: P,
|
|
619
|
-
enableDebugLogs:
|
|
620
|
-
shouldFetchMore:
|
|
621
|
-
sessionId:
|
|
622
|
-
source:
|
|
623
|
-
locale:
|
|
624
|
-
count:
|
|
625
|
-
searchTextOf:
|
|
625
|
+
enableDebugLogs: v,
|
|
626
|
+
shouldFetchMore: w,
|
|
627
|
+
sessionId: T,
|
|
628
|
+
source: b,
|
|
629
|
+
locale: x,
|
|
630
|
+
count: S,
|
|
631
|
+
searchTextOf: A
|
|
626
632
|
}), R = c(void 0);
|
|
627
633
|
R.current = M.queryId;
|
|
628
634
|
let z = c(/* @__PURE__ */ new Map()), B = i(async (e) => {
|
|
@@ -636,12 +642,12 @@ var me = "Type to search", he = n(void 0), ge = ({ children: e, url: t, team: n,
|
|
|
636
642
|
queryId: R.current,
|
|
637
643
|
documentKey: e.documentKey,
|
|
638
644
|
position: e.position,
|
|
639
|
-
...
|
|
645
|
+
...S ? {} : { count: !1 }
|
|
640
646
|
})
|
|
641
647
|
});
|
|
642
|
-
|
|
648
|
+
v && (i.ok ? console.log(`[select] document ${e.documentKey} at position ${e.position}`) : console.warn(`[select] not recorded: ${i.status}`));
|
|
643
649
|
} catch (e) {
|
|
644
|
-
|
|
650
|
+
v && console.warn("[select] failed:", e);
|
|
645
651
|
}
|
|
646
652
|
}
|
|
647
653
|
}, [
|
|
@@ -650,8 +656,8 @@ var me = "Type to search", he = n(void 0), ge = ({ children: e, url: t, team: n,
|
|
|
650
656
|
t,
|
|
651
657
|
n,
|
|
652
658
|
r,
|
|
653
|
-
|
|
654
|
-
|
|
659
|
+
v,
|
|
660
|
+
S
|
|
655
661
|
]), V = i(async (e, i, a) => {
|
|
656
662
|
if (!F.token || !i.trim()) return;
|
|
657
663
|
let o = a?.queryId ?? z.current.get(e) ?? R.current;
|
|
@@ -664,12 +670,12 @@ var me = "Type to search", he = n(void 0), ge = ({ children: e, url: t, team: n,
|
|
|
664
670
|
documentKey: e,
|
|
665
671
|
type: i.trim(),
|
|
666
672
|
...a?.quantity == null ? {} : { quantity: a.quantity },
|
|
667
|
-
...
|
|
673
|
+
...S ? {} : { count: !1 }
|
|
668
674
|
})
|
|
669
675
|
});
|
|
670
|
-
|
|
676
|
+
v && (s.ok ? console.log(`[convert] ${i} on document ${e}`) : console.warn(`[convert] not recorded: ${s.status}`));
|
|
671
677
|
} catch (e) {
|
|
672
|
-
|
|
678
|
+
v && console.warn("[convert] failed:", e);
|
|
673
679
|
}
|
|
674
680
|
}, [
|
|
675
681
|
F.token,
|
|
@@ -677,8 +683,8 @@ var me = "Type to search", he = n(void 0), ge = ({ children: e, url: t, team: n,
|
|
|
677
683
|
t,
|
|
678
684
|
n,
|
|
679
685
|
r,
|
|
680
|
-
|
|
681
|
-
|
|
686
|
+
v,
|
|
687
|
+
S
|
|
682
688
|
]), H = i((e) => {
|
|
683
689
|
N((t) => {
|
|
684
690
|
let n = Object.keys(t.filters).length > 0, r = Object.keys(t.rangeFilters).length > 0, i = Object.keys(t.bucketFilters).length > 0;
|
|
@@ -704,24 +710,24 @@ var me = "Type to search", he = n(void 0), ge = ({ children: e, url: t, team: n,
|
|
|
704
710
|
let n = {
|
|
705
711
|
...t.searchSettings,
|
|
706
712
|
...e
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
...
|
|
710
|
-
|
|
711
|
-
|
|
713
|
+
}, r = (n) => n in e ? e[n] === void 0 ? {} : {
|
|
714
|
+
...t.searchSettings[n],
|
|
715
|
+
...e[n]
|
|
716
|
+
} : t.searchSettings[n];
|
|
717
|
+
return n.match = r("match"), n.candidates = r("candidates"), n.ranking = r("ranking"), {
|
|
712
718
|
...t,
|
|
713
719
|
searchSettings: n
|
|
714
720
|
};
|
|
715
721
|
});
|
|
716
|
-
}, []),
|
|
717
|
-
|
|
722
|
+
}, []), G = i((e) => {
|
|
723
|
+
w.current = !0, N((t) => ({
|
|
718
724
|
...t,
|
|
719
725
|
searchSettings: {
|
|
720
726
|
...t.searchSettings,
|
|
721
727
|
maxNumberOfRecordsToReturn: e
|
|
722
728
|
}
|
|
723
729
|
}));
|
|
724
|
-
}, []),
|
|
730
|
+
}, []), K = i((e, t, n = !1) => {
|
|
725
731
|
N((r) => {
|
|
726
732
|
let i = { ...r.filters }, a = i[e] || [], o = a.includes(t) ? a.filter((e) => e !== t) : n ? [t] : [...a, t];
|
|
727
733
|
return o.length ? i[e] = o : delete i[e], {
|
|
@@ -730,7 +736,7 @@ var me = "Type to search", he = n(void 0), ge = ({ children: e, url: t, team: n,
|
|
|
730
736
|
filterRevision: r.filterRevision + 1
|
|
731
737
|
};
|
|
732
738
|
});
|
|
733
|
-
}, []),
|
|
739
|
+
}, []), ee = i((e, t) => {
|
|
734
740
|
N((n) => n.valueMatch[e] === t ? n : {
|
|
735
741
|
...n,
|
|
736
742
|
valueMatch: {
|
|
@@ -738,7 +744,7 @@ var me = "Type to search", he = n(void 0), ge = ({ children: e, url: t, team: n,
|
|
|
738
744
|
[e]: t
|
|
739
745
|
}
|
|
740
746
|
});
|
|
741
|
-
}, []),
|
|
747
|
+
}, []), q = i((e, t, n) => {
|
|
742
748
|
N((r) => ({
|
|
743
749
|
...r,
|
|
744
750
|
rangeFilters: {
|
|
@@ -750,7 +756,7 @@ var me = "Type to search", he = n(void 0), ge = ({ children: e, url: t, team: n,
|
|
|
750
756
|
},
|
|
751
757
|
filterRevision: r.filterRevision + 1
|
|
752
758
|
}));
|
|
753
|
-
}, []),
|
|
759
|
+
}, []), te = i(() => {
|
|
754
760
|
N((e) => ({
|
|
755
761
|
...e,
|
|
756
762
|
filters: {},
|
|
@@ -758,7 +764,7 @@ var me = "Type to search", he = n(void 0), ge = ({ children: e, url: t, team: n,
|
|
|
758
764
|
bucketFilters: {},
|
|
759
765
|
filterRevision: e.filterRevision + 1
|
|
760
766
|
}));
|
|
761
|
-
}, []),
|
|
767
|
+
}, []), ne = i((e, t, n = !0) => {
|
|
762
768
|
N((r) => {
|
|
763
769
|
let i = { ...r.filters }, a = (i[e] || []).filter((e) => e !== t);
|
|
764
770
|
return a.length > 0 ? i[e] = a : delete i[e], {
|
|
@@ -767,7 +773,7 @@ var me = "Type to search", he = n(void 0), ge = ({ children: e, url: t, team: n,
|
|
|
767
773
|
filterRevision: r.filterRevision + +!!n
|
|
768
774
|
};
|
|
769
775
|
});
|
|
770
|
-
}, []),
|
|
776
|
+
}, []), J = i((e, t = !0) => {
|
|
771
777
|
N((n) => {
|
|
772
778
|
if (!(e in n.rangeFilters)) return n;
|
|
773
779
|
let r = { ...n.rangeFilters };
|
|
@@ -777,32 +783,32 @@ var me = "Type to search", he = n(void 0), ge = ({ children: e, url: t, team: n,
|
|
|
777
783
|
filterRevision: n.filterRevision + +!!t
|
|
778
784
|
};
|
|
779
785
|
});
|
|
780
|
-
}, []),
|
|
786
|
+
}, []), Y = (e, t) => e.min === t.min && e.max === t.max, X = i((e, t, n = !1) => {
|
|
781
787
|
N((r) => {
|
|
782
|
-
let i = r.bucketFilters[e] ?? [], a = i.some((e) =>
|
|
788
|
+
let i = r.bucketFilters[e] ?? [], a = i.some((e) => Y(e, t)) ? i.filter((e) => !Y(e, t)) : n ? [t] : [...i, t], o = { ...r.bucketFilters };
|
|
783
789
|
return a.length > 0 ? o[e] = a : delete o[e], {
|
|
784
790
|
...r,
|
|
785
791
|
bucketFilters: o,
|
|
786
792
|
filterRevision: r.filterRevision + 1
|
|
787
793
|
};
|
|
788
794
|
});
|
|
789
|
-
}, []),
|
|
795
|
+
}, []), re = i((e, t, n = !0) => {
|
|
790
796
|
N((r) => {
|
|
791
|
-
let i = { ...r.bucketFilters }, a = t ? (i[e] ?? []).filter((e) => !
|
|
797
|
+
let i = { ...r.bucketFilters }, a = t ? (i[e] ?? []).filter((e) => !Y(e, t)) : [];
|
|
792
798
|
return a.length > 0 ? i[e] = a : delete i[e], {
|
|
793
799
|
...r,
|
|
794
800
|
bucketFilters: i,
|
|
795
801
|
filterRevision: r.filterRevision + +!!n
|
|
796
802
|
};
|
|
797
803
|
});
|
|
798
|
-
}, []),
|
|
804
|
+
}, []), ie = i((e, t) => {
|
|
799
805
|
N((n) => ({
|
|
800
806
|
...n,
|
|
801
807
|
sortBy: e || void 0,
|
|
802
808
|
sortAscending: e ? t : void 0
|
|
803
809
|
}));
|
|
804
810
|
}, []);
|
|
805
|
-
return /* @__PURE__ */
|
|
811
|
+
return /* @__PURE__ */ h(_e.Provider, {
|
|
806
812
|
value: {
|
|
807
813
|
state: M,
|
|
808
814
|
isFetchingInitial: F.isFetchingInitial || !M.fieldsSeeded,
|
|
@@ -817,82 +823,77 @@ var me = "Type to search", he = n(void 0), ge = ({ children: e, url: t, team: n,
|
|
|
817
823
|
dataset: r,
|
|
818
824
|
authenticatedFetch: I,
|
|
819
825
|
setQuery: H,
|
|
820
|
-
toggleFilter:
|
|
821
|
-
setValueMatch:
|
|
822
|
-
setRangeFilter:
|
|
823
|
-
resetFilters:
|
|
824
|
-
resetSingleFilter:
|
|
825
|
-
resetRangeFilter:
|
|
826
|
-
toggleBucketFilter:
|
|
827
|
-
resetBucketFilter:
|
|
828
|
-
setSort:
|
|
826
|
+
toggleFilter: K,
|
|
827
|
+
setValueMatch: ee,
|
|
828
|
+
setRangeFilter: q,
|
|
829
|
+
resetFilters: te,
|
|
830
|
+
resetSingleFilter: ne,
|
|
831
|
+
resetRangeFilter: J,
|
|
832
|
+
toggleBucketFilter: X,
|
|
833
|
+
resetBucketFilter: re,
|
|
834
|
+
setSort: ie,
|
|
829
835
|
setDebounceDelay: U,
|
|
830
836
|
setSearchSettings: W,
|
|
831
|
-
fetchMoreResults:
|
|
837
|
+
fetchMoreResults: G,
|
|
832
838
|
selectResult: B,
|
|
833
839
|
convertResult: V,
|
|
834
|
-
sessionId:
|
|
835
|
-
source:
|
|
836
|
-
count:
|
|
837
|
-
searchText:
|
|
838
|
-
|
|
839
|
-
|
|
840
|
+
sessionId: T,
|
|
841
|
+
source: b,
|
|
842
|
+
count: S,
|
|
843
|
+
searchText: A(M.query),
|
|
844
|
+
picks: O && O.query === M.query ? O.picks : null,
|
|
845
|
+
showPicks: (e) => k(e ? {
|
|
846
|
+
picks: e,
|
|
847
|
+
query: M.query
|
|
848
|
+
} : null),
|
|
849
|
+
searchAsTyped: () => D(M.query)
|
|
840
850
|
},
|
|
841
851
|
children: e
|
|
842
852
|
});
|
|
843
|
-
},
|
|
844
|
-
let e = a(
|
|
853
|
+
}, ye = () => {
|
|
854
|
+
let e = a(_e);
|
|
845
855
|
if (!e) throw Error("useSearchContext must be used within a SearchProvider");
|
|
846
856
|
return e;
|
|
847
857
|
};
|
|
848
858
|
// src/utils/searchOrAsk.ts
|
|
849
|
-
function
|
|
859
|
+
function be(e, t) {
|
|
850
860
|
return t ? t === "proactive" && e !== "proactive" ? "inviting" : t : e;
|
|
851
861
|
}
|
|
852
|
-
var
|
|
862
|
+
var xe = {
|
|
853
863
|
strong: .65,
|
|
854
864
|
strongHide: .45,
|
|
855
865
|
invite: .4,
|
|
856
866
|
inviteHide: .3,
|
|
857
867
|
hint: .31,
|
|
858
|
-
finished: .5
|
|
859
|
-
|
|
860
|
-
|
|
868
|
+
finished: .5,
|
|
869
|
+
found: .3,
|
|
870
|
+
refocus: 0
|
|
871
|
+
}, Se = /^[\d\s\-_.:/]+$|^\w+\.\w+|^[A-Za-z]*[a-z][A-Z]\w*$|^[A-Za-z]+[-_]?\d[\w-]*$/;
|
|
872
|
+
function Ce(e) {
|
|
861
873
|
let t = e.trim();
|
|
862
|
-
return t.length > 0 && !t.includes(" ") &&
|
|
874
|
+
return t.length > 0 && !t.includes(" ") && Se.test(t);
|
|
863
875
|
}
|
|
864
|
-
function
|
|
876
|
+
function we(e) {
|
|
865
877
|
let t = e.trim();
|
|
866
|
-
return !!t && !
|
|
878
|
+
return !!t && !Ce(t) && (t.endsWith("?") || t.split(/\s+/).length >= 3);
|
|
867
879
|
}
|
|
868
|
-
function
|
|
880
|
+
function Te(e, t = 4) {
|
|
869
881
|
let n = e.trim();
|
|
870
|
-
return !n ||
|
|
882
|
+
return !n || Ce(n) ? !1 : we(n) || n.length >= t;
|
|
871
883
|
}
|
|
872
|
-
function
|
|
884
|
+
function Ee(e, t, n = xe) {
|
|
873
885
|
return t >= n.strong || e === "strong" && t >= n.strongHide ? "strong" : t >= n.invite || e !== "none" && t >= n.inviteHide ? "invite" : "none";
|
|
874
886
|
}
|
|
875
|
-
var
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
coverJoinedWords: !1,
|
|
882
|
-
minWordSize: 3
|
|
883
|
-
}, De = 65535;
|
|
884
|
-
function Oe(e, t, n, r = Te) {
|
|
885
|
-
if (!n || e.length === 0) return e;
|
|
886
|
-
let i = e[0].score;
|
|
887
|
-
if (i < r.topFloor * 65535) return [];
|
|
888
|
-
let a = t == null ? e : t < 0 ? [] : e.slice(0, t + 1), o = r.shareOfTop * i, s = a.findIndex((e) => e.score < o);
|
|
889
|
-
return s < 0 ? a : a.slice(0, s);
|
|
890
|
-
}
|
|
891
|
-
function ke(e) {
|
|
887
|
+
var De = {
|
|
888
|
+
tolerance: p.Exact,
|
|
889
|
+
typingPrefixFrom: 0,
|
|
890
|
+
joinedWords: !1
|
|
891
|
+
};
|
|
892
|
+
function Oe(e) {
|
|
892
893
|
let t = e.trim();
|
|
893
894
|
return t.includes(" ") || t.endsWith("?");
|
|
894
895
|
}
|
|
895
|
-
async function*
|
|
896
|
+
async function* ke(e) {
|
|
896
897
|
let t = e.getReader(), n = new TextDecoder(), r = "";
|
|
897
898
|
try {
|
|
898
899
|
for (;;) {
|
|
@@ -915,68 +916,24 @@ async function* Ae(e) {
|
|
|
915
916
|
t.releaseLock();
|
|
916
917
|
}
|
|
917
918
|
}
|
|
918
|
-
function
|
|
919
|
+
function Ae(e) {
|
|
919
920
|
let t = new URLSearchParams();
|
|
920
921
|
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");
|
|
921
922
|
let n = t.toString();
|
|
922
923
|
return n ? `?${n}` : "";
|
|
923
924
|
}
|
|
924
|
-
// src/utils/askPhrases.ts
|
|
925
|
-
var Me = (e) => e.toLowerCase().replace(/β/g, "'").split(/\s+/).filter(Boolean), Ne = /[?!.,]+$/, Pe = 2;
|
|
926
|
-
function Fe(e, t) {
|
|
927
|
-
let n = 0;
|
|
928
|
-
for (let r of t) {
|
|
929
|
-
let t = Me(r);
|
|
930
|
-
t.length > n && t.length <= e.length && t.every((n, r) => e[e.length - t.length + r].replace(Ne, "") === n) && (n = t.length);
|
|
931
|
-
}
|
|
932
|
-
return n;
|
|
933
|
-
}
|
|
934
|
-
function Ie(e, t, n) {
|
|
935
|
-
let r = 0;
|
|
936
|
-
for (let i of n) {
|
|
937
|
-
let n = Me(i);
|
|
938
|
-
n.length > r && t + n.length <= e.length && n.every((n, r) => e[t + r].replace(Ne, "") === n) && (r = n.length);
|
|
939
|
-
}
|
|
940
|
-
return r;
|
|
941
|
-
}
|
|
942
|
-
function Le(e, t) {
|
|
943
|
-
let n = e.trim().split(/\s+/).filter(Boolean), r = Me(e), i = 0, a = [], o = (e) => {
|
|
944
|
-
let t = Ie(r, i, e);
|
|
945
|
-
return t && (a.push(n.slice(i, i + t).join(" ")), i += t), t > 0;
|
|
946
|
-
}, s = Ie(r, 0, t.leadIns), c = o(t.leadIns), l = o(t.frames), u = o(t.links);
|
|
947
|
-
if (!(c && (s > 1 || l) || l && u)) return {
|
|
948
|
-
text: e,
|
|
949
|
-
taken: []
|
|
950
|
-
};
|
|
951
|
-
o(t.articles);
|
|
952
|
-
let d = n.slice(i).join(" ").replace(/[?!.]+$/, "").trim();
|
|
953
|
-
if (!/\p{L}{3,}/u.test(d)) return {
|
|
954
|
-
text: e,
|
|
955
|
-
taken: []
|
|
956
|
-
};
|
|
957
|
-
let f = d.split(/\s+/).filter(Boolean), p = Fe(Me(d), t.frames);
|
|
958
|
-
if (p > 0 && f.length - p >= Pe) {
|
|
959
|
-
let e = f.slice(0, f.length - p).join(" ");
|
|
960
|
-
if (/\p{L}{3,}/u.test(e)) return {
|
|
961
|
-
text: e,
|
|
962
|
-
taken: [...a, f.slice(-p).join(" ")]
|
|
963
|
-
};
|
|
964
|
-
}
|
|
965
|
-
return {
|
|
966
|
-
text: d,
|
|
967
|
-
taken: a
|
|
968
|
-
};
|
|
969
|
-
}
|
|
970
925
|
// src/hooks/useSearchOrAsk.ts
|
|
971
|
-
function
|
|
926
|
+
function je(e) {
|
|
972
927
|
return {
|
|
973
|
-
...
|
|
928
|
+
...xe,
|
|
974
929
|
...e,
|
|
975
|
-
hint: e?.hint ??
|
|
976
|
-
finished: e?.finished ??
|
|
930
|
+
hint: e?.hint ?? xe.hint,
|
|
931
|
+
finished: e?.finished ?? xe.finished,
|
|
932
|
+
found: e?.found ?? xe.found,
|
|
933
|
+
refocus: e?.refocus ?? xe.refocus
|
|
977
934
|
};
|
|
978
935
|
}
|
|
979
|
-
var
|
|
936
|
+
var Me = .1, Ne = {
|
|
980
937
|
available: !1,
|
|
981
938
|
offer: "none",
|
|
982
939
|
p: null,
|
|
@@ -984,9 +941,11 @@ var ze = {
|
|
|
984
941
|
text: "",
|
|
985
942
|
criteria: null,
|
|
986
943
|
describes: !1,
|
|
987
|
-
|
|
988
|
-
|
|
944
|
+
found: null,
|
|
945
|
+
notFound: !1,
|
|
946
|
+
held: !1,
|
|
989
947
|
strictCoverage: !1,
|
|
948
|
+
refocus: !1,
|
|
990
949
|
filtersWhileTyping: "off",
|
|
991
950
|
mode: "soft",
|
|
992
951
|
askAnytime: !1,
|
|
@@ -995,48 +954,51 @@ var ze = {
|
|
|
995
954
|
quick: "none",
|
|
996
955
|
stands: !1
|
|
997
956
|
};
|
|
998
|
-
function
|
|
999
|
-
let { enabled: t = !0, pauseMs: n = 300, prefetch: r = !0, mode: i, answerAfterMs: a = 1e3 } = e, s =
|
|
957
|
+
function Pe(e = {}) {
|
|
958
|
+
let { enabled: t = !0, pauseMs: n = 300, prefetch: r = !0, mode: i, answerAfterMs: a = 1e3 } = e, s = ye(), { url: u, team: d, dataset: f, authenticatedFetch: p, isFetchingInitial: m, authError: h, state: g } = s, _ = c(s);
|
|
1000
959
|
_.current = s;
|
|
1001
|
-
let v = (e.text ?? g.query).trim(), [y, b] = l(!1), [x, S] = l(
|
|
1002
|
-
|
|
1003
|
-
let
|
|
1004
|
-
return
|
|
1005
|
-
} },
|
|
1006
|
-
|
|
1007
|
-
let
|
|
1008
|
-
|
|
1009
|
-
let
|
|
1010
|
-
|
|
1011
|
-
let
|
|
960
|
+
let v = (e.text ?? g.query).trim(), [y, b] = l(!1), [x, S] = l(Ne), C = c(xe), w = c(!0), T = c("off"), E = c("soft"), D = c(i);
|
|
961
|
+
D.current = i;
|
|
962
|
+
let O = { get current() {
|
|
963
|
+
return be(E.current, D.current);
|
|
964
|
+
} }, k = c(null), A = c("none"), j = c(""), M = c(0), N = c(0);
|
|
965
|
+
A.current = x.offer;
|
|
966
|
+
let P = c(null), F = c(/* @__PURE__ */ new Set()), I = c(0), L = c(v);
|
|
967
|
+
L.current = v;
|
|
968
|
+
let R = c(!1);
|
|
969
|
+
R.current = y;
|
|
970
|
+
let [z, B] = l(0);
|
|
1012
971
|
o(() => {
|
|
1013
|
-
if (
|
|
972
|
+
if (!z) return;
|
|
973
|
+
let e = setTimeout(() => B(0), Math.max(0, z - Date.now()));
|
|
974
|
+
return () => clearTimeout(e);
|
|
975
|
+
}, [z]);
|
|
976
|
+
let V = `${u}/api/teams/${d}/datasets/${f}/search-or-ask`, H = () => O.current === "inviting" || O.current === "proactive" ? 3 : 4, U = (e) => e != null && e >= (C.current.finished ?? .5), W = (e) => O.current !== "proactive" && A.current === "strong" && !!j.current && e.startsWith(j.current), G = t && !m && !h;
|
|
977
|
+
o(() => {
|
|
978
|
+
if (b(!1), !G) return;
|
|
1014
979
|
let e = !1;
|
|
1015
980
|
return (async () => {
|
|
1016
981
|
try {
|
|
1017
|
-
let t = await p(
|
|
982
|
+
let t = await p(V);
|
|
1018
983
|
if (!t.ok) return;
|
|
1019
984
|
let n = await t.json();
|
|
1020
985
|
if (e || !n.available || !n.settings?.enabled) return;
|
|
1021
|
-
|
|
1022
|
-
shareOfTop: n.settings.cutShareOfTop ?? Te.shareOfTop,
|
|
1023
|
-
topFloor: n.settings.cutTopFloor ?? Te.topFloor
|
|
1024
|
-
}, b(!0);
|
|
986
|
+
T.current = n.settings.filtersWhileTyping ?? "off", E.current = n.settings.mode ?? "soft", C.current = je(n.settings.thresholds), w.current = n.settings.strictCoverageWhileAsking ?? !0, b(!0);
|
|
1025
987
|
} catch {}
|
|
1026
988
|
})(), () => {
|
|
1027
989
|
e = !0;
|
|
1028
990
|
};
|
|
1029
991
|
}, [
|
|
1030
|
-
|
|
1031
|
-
|
|
992
|
+
G,
|
|
993
|
+
V,
|
|
1032
994
|
p
|
|
1033
995
|
]);
|
|
1034
|
-
let
|
|
1035
|
-
|
|
1036
|
-
if (!r || !
|
|
996
|
+
let K = c(() => {});
|
|
997
|
+
K.current = (e) => {
|
|
998
|
+
if (!r || !R.current || P.current || !e || !Te(e, H()) || F.current.has(e) || W(e) || Date.now() < N.current || Date.now() < I.current) return;
|
|
1037
999
|
let t = (async () => {
|
|
1038
1000
|
try {
|
|
1039
|
-
let t = await p(`${
|
|
1001
|
+
let t = await p(`${V}/intent`, {
|
|
1040
1002
|
method: "POST",
|
|
1041
1003
|
headers: { "Content-Type": "application/json" },
|
|
1042
1004
|
body: JSON.stringify({
|
|
@@ -1046,35 +1008,32 @@ function Be(e = {}) {
|
|
|
1046
1008
|
});
|
|
1047
1009
|
if (t.status === 429) {
|
|
1048
1010
|
let e = Number(t.headers.get("Retry-After"));
|
|
1049
|
-
|
|
1011
|
+
I.current = Date.now() + (Number.isFinite(e) && e > 0 ? e : 60) * 1e3;
|
|
1050
1012
|
return;
|
|
1051
1013
|
}
|
|
1052
|
-
t.ok && (
|
|
1014
|
+
t.ok && (F.current.size > 200 && F.current.clear(), F.current.add(e));
|
|
1053
1015
|
} catch {}
|
|
1054
1016
|
})();
|
|
1055
|
-
|
|
1017
|
+
P.current = {
|
|
1056
1018
|
text: e,
|
|
1057
1019
|
done: t
|
|
1058
1020
|
}, t.then(() => {
|
|
1059
|
-
|
|
1021
|
+
P.current?.done === t && (P.current = null), L.current !== e && K.current(L.current);
|
|
1060
1022
|
});
|
|
1061
1023
|
}, o(() => {
|
|
1062
|
-
let { setSearchRewrite: e } = _.current, t = j.current;
|
|
1063
|
-
if (y && t && M.current && e) return e((e) => Le(e, t).text), () => e(null);
|
|
1064
|
-
}, [y]), o(() => {
|
|
1065
1024
|
if (!y) {
|
|
1066
|
-
S(
|
|
1025
|
+
S(Ne);
|
|
1067
1026
|
return;
|
|
1068
1027
|
}
|
|
1069
1028
|
if (!v) {
|
|
1070
|
-
|
|
1071
|
-
...
|
|
1029
|
+
j.current = "", S({
|
|
1030
|
+
...Ne,
|
|
1072
1031
|
available: y
|
|
1073
1032
|
});
|
|
1074
1033
|
return;
|
|
1075
1034
|
}
|
|
1076
|
-
if (!
|
|
1077
|
-
|
|
1035
|
+
if (!Te(v, H())) {
|
|
1036
|
+
Ce(v) && S((e) => ({
|
|
1078
1037
|
...e,
|
|
1079
1038
|
available: y,
|
|
1080
1039
|
offer: "none",
|
|
@@ -1082,63 +1041,66 @@ function Be(e = {}) {
|
|
|
1082
1041
|
}));
|
|
1083
1042
|
return;
|
|
1084
1043
|
}
|
|
1085
|
-
|
|
1086
|
-
...e,
|
|
1087
|
-
available: y,
|
|
1088
|
-
offer: "invite",
|
|
1089
|
-
text: v
|
|
1090
|
-
} : e), ne.current(v);
|
|
1044
|
+
K.current(v);
|
|
1091
1045
|
let e = !1, t = setTimeout(async () => {
|
|
1092
|
-
if (
|
|
1046
|
+
if (W(v)) {
|
|
1093
1047
|
S((e) => ({
|
|
1094
1048
|
...e,
|
|
1095
1049
|
text: v
|
|
1096
1050
|
}));
|
|
1097
1051
|
return;
|
|
1098
1052
|
}
|
|
1099
|
-
if (Date.now() <
|
|
1100
|
-
let t = ++
|
|
1101
|
-
|
|
1053
|
+
if (Date.now() < N.current || (P.current?.text === v && await P.current.done, e)) return;
|
|
1054
|
+
let t = ++M.current;
|
|
1055
|
+
j.current = v;
|
|
1102
1056
|
try {
|
|
1103
|
-
let e = await p(`${
|
|
1057
|
+
let e = await p(`${V}/intent${Ae(_.current)}`, {
|
|
1104
1058
|
method: "POST",
|
|
1105
1059
|
headers: { "Content-Type": "application/json" },
|
|
1106
1060
|
body: JSON.stringify({ text: v })
|
|
1107
1061
|
});
|
|
1108
1062
|
if (e.status === 429) {
|
|
1109
|
-
let
|
|
1110
|
-
|
|
1063
|
+
let n = Number(e.headers.get("Retry-After"));
|
|
1064
|
+
N.current = Date.now() + (Number.isFinite(n) && n > 0 ? n : 60) * 1e3;
|
|
1065
|
+
let { code: r } = await e.json().catch(() => ({}));
|
|
1066
|
+
r === "searchOrAskBudgetSpent" && t === M.current && (B(N.current), S((e) => ({
|
|
1067
|
+
...e,
|
|
1068
|
+
offer: "none",
|
|
1069
|
+
answerNow: null,
|
|
1070
|
+
strictCoverage: !1,
|
|
1071
|
+
refocus: !1,
|
|
1072
|
+
notFound: !1
|
|
1073
|
+
})));
|
|
1111
1074
|
return;
|
|
1112
1075
|
}
|
|
1113
|
-
if (e.status === 409) {
|
|
1076
|
+
if (e.status === 409 || e.status === 404) {
|
|
1114
1077
|
b(!1);
|
|
1115
1078
|
return;
|
|
1116
1079
|
}
|
|
1117
1080
|
if (!e.ok) return;
|
|
1118
|
-
let { p: n, answerable: r, criteria: i, finished: a,
|
|
1119
|
-
if (
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
topFloor: l
|
|
1123
|
-
}), S((e) => {
|
|
1124
|
-
let t = we(e.offer, n, C.current), o = i ?? null, s = o != null && o >= C.current.strong, c = t === "strong" && !ke(v) ? "invite" : t, l = s ? "strong" : c, u = A.current === "strict" && l === "invite" ? "none" : l, d = u === "strong" && !(s && o > n);
|
|
1081
|
+
let { p: n, answerable: r, criteria: i, finished: a, found: o, reason: s, thresholds: c, strictCoverageWhileAsking: l, filtersWhileTyping: u, mode: d, refocus: f } = await e.json();
|
|
1082
|
+
if (u != null && (T.current = u), t !== M.current) return;
|
|
1083
|
+
l != null && (w.current = l), d != null && (E.current = d), c && (C.current = je(c)), S((e) => {
|
|
1084
|
+
let t = Ee(e.offer, n, C.current), c = i ?? null, l = c != null && c >= C.current.strong, u = e.offer === "strong" && !!e.text && v.startsWith(e.text) || Oe(v) && (a == null || U(a)), d = l && u ? "strong" : l || t === "strong" && !u ? "invite" : t, p = O.current === "strict" && d === "invite" ? "none" : d, m = p === "strong" && !(l && c > n), h = o ?? null, g = C.current.found ?? 0, _ = C.current.refocus ?? 0, y = e.refocus && _ > 0 && !!e.text && v.startsWith(e.text) && Math.max(n, c ?? 0) >= _ - Me;
|
|
1125
1085
|
return {
|
|
1126
1086
|
available: !0,
|
|
1127
|
-
offer:
|
|
1087
|
+
offer: p,
|
|
1128
1088
|
p: n,
|
|
1129
1089
|
answerable: r ?? null,
|
|
1130
1090
|
text: v,
|
|
1131
|
-
criteria:
|
|
1132
|
-
describes:
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1091
|
+
criteria: c,
|
|
1092
|
+
describes: l,
|
|
1093
|
+
found: h,
|
|
1094
|
+
notFound: m && h != null && g > 0 && h < g,
|
|
1095
|
+
held: s === "paused",
|
|
1096
|
+
strictCoverage: w.current && m,
|
|
1097
|
+
refocus: !!f || y,
|
|
1098
|
+
filtersWhileTyping: T.current,
|
|
1099
|
+
mode: O.current,
|
|
1138
1100
|
askAnytime: !1,
|
|
1139
1101
|
quick: "none",
|
|
1140
1102
|
finished: a ?? null,
|
|
1141
|
-
answerNow:
|
|
1103
|
+
answerNow: O.current === "proactive" && p === "strong" && U(a) ? v : null,
|
|
1142
1104
|
stands: !0
|
|
1143
1105
|
};
|
|
1144
1106
|
});
|
|
@@ -1150,16 +1112,16 @@ function Be(e = {}) {
|
|
|
1150
1112
|
}, [
|
|
1151
1113
|
v,
|
|
1152
1114
|
y,
|
|
1153
|
-
|
|
1115
|
+
V,
|
|
1154
1116
|
p,
|
|
1155
1117
|
n
|
|
1156
1118
|
]);
|
|
1157
|
-
let [
|
|
1119
|
+
let [ee, q] = l(null);
|
|
1158
1120
|
o(() => {
|
|
1159
|
-
|
|
1121
|
+
q(null);
|
|
1160
1122
|
let e = x.answerNow;
|
|
1161
1123
|
if (!e || e !== v) return;
|
|
1162
|
-
let t = setTimeout(() =>
|
|
1124
|
+
let t = setTimeout(() => q(e), Math.max(0, a - n));
|
|
1163
1125
|
return () => clearTimeout(t);
|
|
1164
1126
|
}, [
|
|
1165
1127
|
x.answerNow,
|
|
@@ -1167,27 +1129,47 @@ function Be(e = {}) {
|
|
|
1167
1129
|
a,
|
|
1168
1130
|
n
|
|
1169
1131
|
]);
|
|
1170
|
-
let
|
|
1171
|
-
|
|
1132
|
+
let te = y && x.strictCoverage;
|
|
1133
|
+
o(() => {
|
|
1172
1134
|
let { setSearchSettings: e, state: t } = _.current;
|
|
1173
|
-
if (
|
|
1174
|
-
if (
|
|
1175
|
-
let n = t.searchSettings.
|
|
1176
|
-
|
|
1177
|
-
} else
|
|
1178
|
-
}, [
|
|
1179
|
-
let
|
|
1135
|
+
if (te) {
|
|
1136
|
+
if (k.current) return;
|
|
1137
|
+
let n = t.searchSettings.match ?? {};
|
|
1138
|
+
k.current = Object.fromEntries(Object.keys(De).map((e) => [e, n[e]])), e({ match: { ...De } });
|
|
1139
|
+
} else k.current &&= (e({ match: { ...k.current } }), null);
|
|
1140
|
+
}, [te]);
|
|
1141
|
+
let ne = y && x.refocus && !x.held && z === 0 && !!x.text && v.startsWith(x.text);
|
|
1142
|
+
if (o(() => {
|
|
1143
|
+
_.current.setSearchSettings({ refocus: ne });
|
|
1144
|
+
}, [ne]), !y) return Ne;
|
|
1145
|
+
let J = O.current, Y = !!x.text && v.startsWith(x.text), X = x.held || z > 0;
|
|
1146
|
+
if (X) return {
|
|
1147
|
+
...x,
|
|
1148
|
+
mode: J,
|
|
1149
|
+
held: X,
|
|
1150
|
+
offer: "none",
|
|
1151
|
+
askAnytime: !1,
|
|
1152
|
+
answerNow: null,
|
|
1153
|
+
quick: "none",
|
|
1154
|
+
notFound: !1,
|
|
1155
|
+
strictCoverage: !1,
|
|
1156
|
+
refocus: !1,
|
|
1157
|
+
stands: Y
|
|
1158
|
+
};
|
|
1159
|
+
let re = J === "inviting" || J === "proactive", ie = re && !!v && (Y && x.p != null && x.p >= (C.current.hint ?? 1) || we(v)), ae = v ? Y && x.offer === "strong" ? J === "proactive" ? U(x.finished) ? "thinking" : "hint" : "ready" : Y && x.offer === "invite" ? re ? "hint" : "invite" : ie ? "hint" : J === "open" || re ? "ask" : "none" : "none";
|
|
1180
1160
|
return {
|
|
1181
1161
|
...x,
|
|
1162
|
+
refocus: ne,
|
|
1182
1163
|
mode: J,
|
|
1183
|
-
askAnytime: J === "open" ||
|
|
1184
|
-
answerNow:
|
|
1185
|
-
text:
|
|
1186
|
-
|
|
1164
|
+
askAnytime: J === "open" || re,
|
|
1165
|
+
answerNow: ee !== null && ee === v && x.answerNow === v ? ee : null,
|
|
1166
|
+
text: (ae === "hint" || ae === "ask") && !Y ? v : x.text,
|
|
1167
|
+
notFound: Y && x.notFound,
|
|
1168
|
+
quick: ae,
|
|
1187
1169
|
stands: Y
|
|
1188
1170
|
};
|
|
1189
1171
|
}
|
|
1190
|
-
var
|
|
1172
|
+
var Fe = {
|
|
1191
1173
|
row: "_row_epo6h_3",
|
|
1192
1174
|
icon: "_icon_epo6h_17",
|
|
1193
1175
|
line: "_line_epo6h_24",
|
|
@@ -1195,55 +1177,71 @@ var Ve = {
|
|
|
1195
1177
|
question: "_question_epo6h_43",
|
|
1196
1178
|
actions: "_actions_epo6h_52",
|
|
1197
1179
|
enter: "_enter_epo6h_59"
|
|
1198
|
-
},
|
|
1180
|
+
}, Ie = {
|
|
1199
1181
|
invite: "Ask about this",
|
|
1200
1182
|
hint: "For a quick answer, type a bit more",
|
|
1201
1183
|
ready: "Ask the assistant",
|
|
1202
|
-
thinking: "Thinking"
|
|
1203
|
-
|
|
1184
|
+
thinking: "Thinking",
|
|
1185
|
+
ask: "Ask"
|
|
1186
|
+
}, Le = ({ searchOrAsk: e, onAsk: t, labels: n, className: r = "" }) => {
|
|
1204
1187
|
let i = {
|
|
1205
|
-
...
|
|
1188
|
+
...Ie,
|
|
1206
1189
|
...n
|
|
1207
1190
|
}, a = e.text.trim();
|
|
1208
1191
|
if (!e.available || e.quick === "none" || !a) return null;
|
|
1209
1192
|
let o = () => t(a);
|
|
1210
|
-
return /* @__PURE__ */
|
|
1211
|
-
className: `${
|
|
1193
|
+
return /* @__PURE__ */ g("div", {
|
|
1194
|
+
className: `${Fe.row} ${Fe[e.quick]} ${r}`,
|
|
1212
1195
|
"aria-live": "polite",
|
|
1213
1196
|
children: [
|
|
1214
|
-
/* @__PURE__ */
|
|
1215
|
-
className:
|
|
1197
|
+
/* @__PURE__ */ h("span", {
|
|
1198
|
+
className: Fe.icon,
|
|
1216
1199
|
"aria-hidden": "true",
|
|
1217
|
-
children: /* @__PURE__ */
|
|
1200
|
+
children: /* @__PURE__ */ h(H, {
|
|
1218
1201
|
size: 14,
|
|
1219
1202
|
color: "currentColor"
|
|
1220
1203
|
})
|
|
1221
1204
|
}),
|
|
1222
|
-
e.quick === "thinking" && /* @__PURE__ */
|
|
1223
|
-
className:
|
|
1205
|
+
e.quick === "thinking" && /* @__PURE__ */ h(F, {
|
|
1206
|
+
className: Fe.text,
|
|
1224
1207
|
children: i.thinking
|
|
1225
1208
|
}),
|
|
1226
|
-
e.quick === "hint" && /* @__PURE__ */
|
|
1209
|
+
e.quick === "hint" && /* @__PURE__ */ h("button", {
|
|
1227
1210
|
type: "button",
|
|
1228
|
-
className:
|
|
1211
|
+
className: Fe.line,
|
|
1229
1212
|
onClick: o,
|
|
1230
|
-
children: /* @__PURE__ */
|
|
1213
|
+
children: /* @__PURE__ */ h(F, { children: i.hint })
|
|
1231
1214
|
}),
|
|
1232
|
-
e.quick === "invite" && /* @__PURE__ */
|
|
1215
|
+
e.quick === "invite" && /* @__PURE__ */ h("button", {
|
|
1233
1216
|
type: "button",
|
|
1234
|
-
className:
|
|
1217
|
+
className: Fe.line,
|
|
1235
1218
|
onClick: o,
|
|
1236
1219
|
children: i.invite
|
|
1237
1220
|
}),
|
|
1238
|
-
e.quick === "
|
|
1239
|
-
className:
|
|
1221
|
+
e.quick === "ask" && /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h("span", {
|
|
1222
|
+
className: Fe.question,
|
|
1240
1223
|
children: a
|
|
1241
|
-
}), /* @__PURE__ */
|
|
1242
|
-
className:
|
|
1243
|
-
children: [/* @__PURE__ */
|
|
1244
|
-
className:
|
|
1245
|
-
children: [/* @__PURE__ */
|
|
1246
|
-
}), /* @__PURE__ */
|
|
1224
|
+
}), /* @__PURE__ */ g("span", {
|
|
1225
|
+
className: Fe.actions,
|
|
1226
|
+
children: [/* @__PURE__ */ g("span", {
|
|
1227
|
+
className: Fe.enter,
|
|
1228
|
+
children: [/* @__PURE__ */ h(A, { children: "β΅" }), " to ask"]
|
|
1229
|
+
}), /* @__PURE__ */ h(S, {
|
|
1230
|
+
variant: "ghost",
|
|
1231
|
+
size: "micro",
|
|
1232
|
+
onClick: o,
|
|
1233
|
+
children: i.ask
|
|
1234
|
+
})]
|
|
1235
|
+
})] }),
|
|
1236
|
+
e.quick === "ready" && /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h("span", {
|
|
1237
|
+
className: Fe.question,
|
|
1238
|
+
children: a
|
|
1239
|
+
}), /* @__PURE__ */ g("span", {
|
|
1240
|
+
className: Fe.actions,
|
|
1241
|
+
children: [/* @__PURE__ */ g("span", {
|
|
1242
|
+
className: Fe.enter,
|
|
1243
|
+
children: [/* @__PURE__ */ h(A, { children: "β΅" }), " to ask"]
|
|
1244
|
+
}), /* @__PURE__ */ h(S, {
|
|
1247
1245
|
variant: "primary",
|
|
1248
1246
|
size: "micro",
|
|
1249
1247
|
onClick: o,
|
|
@@ -1252,34 +1250,34 @@ var Ve = {
|
|
|
1252
1250
|
})] })
|
|
1253
1251
|
]
|
|
1254
1252
|
});
|
|
1255
|
-
},
|
|
1253
|
+
}, Re = {
|
|
1256
1254
|
grid: "_grid_1xjna_2",
|
|
1257
1255
|
chip: "_chip_1xjna_21",
|
|
1258
1256
|
chipLabel: "_chipLabel_1xjna_32"
|
|
1259
|
-
},
|
|
1257
|
+
}, ze = r(({ field: e, value: t, onReset: n }) => /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(S, {
|
|
1260
1258
|
onClick: n,
|
|
1261
|
-
iconRight: /* @__PURE__ */
|
|
1259
|
+
iconRight: /* @__PURE__ */ h(ae, {}),
|
|
1262
1260
|
variant: "primary",
|
|
1263
1261
|
size: "micro",
|
|
1264
|
-
className:
|
|
1262
|
+
className: Re.chip,
|
|
1265
1263
|
title: `${e}: ${t}`,
|
|
1266
|
-
children: /* @__PURE__ */
|
|
1267
|
-
className:
|
|
1264
|
+
children: /* @__PURE__ */ g("span", {
|
|
1265
|
+
className: Re.chipLabel,
|
|
1268
1266
|
children: [
|
|
1269
1267
|
e,
|
|
1270
1268
|
": ",
|
|
1271
1269
|
t
|
|
1272
1270
|
]
|
|
1273
1271
|
})
|
|
1274
|
-
}) })),
|
|
1272
|
+
}) })), Be = r(({ field: e, min: t, max: n, onReset: r }) => /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(S, {
|
|
1275
1273
|
onClick: r,
|
|
1276
|
-
iconRight: /* @__PURE__ */
|
|
1274
|
+
iconRight: /* @__PURE__ */ h(ae, {}),
|
|
1277
1275
|
variant: "primary",
|
|
1278
1276
|
size: "micro",
|
|
1279
|
-
className:
|
|
1277
|
+
className: Re.chip,
|
|
1280
1278
|
title: `${e}: ${t} β ${n}`,
|
|
1281
|
-
children: /* @__PURE__ */
|
|
1282
|
-
className:
|
|
1279
|
+
children: /* @__PURE__ */ g("span", {
|
|
1280
|
+
className: Re.chipLabel,
|
|
1283
1281
|
children: [
|
|
1284
1282
|
e,
|
|
1285
1283
|
": ",
|
|
@@ -1288,15 +1286,15 @@ var Ve = {
|
|
|
1288
1286
|
n
|
|
1289
1287
|
]
|
|
1290
1288
|
})
|
|
1291
|
-
}) })),
|
|
1289
|
+
}) })), Ve = r(({ field: e, label: t, onReset: n }) => /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(S, {
|
|
1292
1290
|
onClick: n,
|
|
1293
|
-
iconRight: /* @__PURE__ */
|
|
1291
|
+
iconRight: /* @__PURE__ */ h(ae, {}),
|
|
1294
1292
|
variant: "primary",
|
|
1295
1293
|
size: "micro",
|
|
1296
|
-
className:
|
|
1294
|
+
className: Re.chip,
|
|
1297
1295
|
title: `${e}: ${t}`,
|
|
1298
|
-
children: /* @__PURE__ */
|
|
1299
|
-
className:
|
|
1296
|
+
children: /* @__PURE__ */ g("span", {
|
|
1297
|
+
className: Re.chipLabel,
|
|
1300
1298
|
children: [
|
|
1301
1299
|
e,
|
|
1302
1300
|
": ",
|
|
@@ -1304,8 +1302,8 @@ var Ve = {
|
|
|
1304
1302
|
]
|
|
1305
1303
|
})
|
|
1306
1304
|
}) }));
|
|
1307
|
-
function
|
|
1308
|
-
let { state: { filters: e, rangeFilters: t, bucketFilters: n }, resetFilters: r, resetSingleFilter: i, resetRangeFilter: a, resetBucketFilter: o } =
|
|
1305
|
+
function He() {
|
|
1306
|
+
let { state: { filters: e, rangeFilters: t, bucketFilters: n }, resetFilters: r, resetSingleFilter: i, resetRangeFilter: a, resetBucketFilter: o } = ye(), c = s(() => Object.entries(e).map(([e, t]) => t.map((t) => ({
|
|
1309
1307
|
field: e,
|
|
1310
1308
|
value: t
|
|
1311
1309
|
}))).flat(), [e]), l = s(() => Object.entries(t).map(([e, { min: t, max: n }]) => ({
|
|
@@ -1321,29 +1319,29 @@ function Je() {
|
|
|
1321
1319
|
e,
|
|
1322
1320
|
t,
|
|
1323
1321
|
u
|
|
1324
|
-
]) ? /* @__PURE__ */
|
|
1322
|
+
]) ? /* @__PURE__ */ h(O, {
|
|
1325
1323
|
collapsible: !1,
|
|
1326
1324
|
title: "Active filters",
|
|
1327
|
-
children: /* @__PURE__ */
|
|
1328
|
-
className:
|
|
1325
|
+
children: /* @__PURE__ */ g("ul", {
|
|
1326
|
+
className: Re.grid,
|
|
1329
1327
|
children: [
|
|
1330
|
-
c.map(({ field: e, value: t }) => /* @__PURE__ */
|
|
1328
|
+
c.map(({ field: e, value: t }) => /* @__PURE__ */ h(ze, {
|
|
1331
1329
|
field: e,
|
|
1332
1330
|
value: t,
|
|
1333
1331
|
onReset: () => i(e, t)
|
|
1334
1332
|
}, `${e}-${t}`)),
|
|
1335
|
-
l.map(({ field: e, min: t, max: n }) => /* @__PURE__ */
|
|
1333
|
+
l.map(({ field: e, min: t, max: n }) => /* @__PURE__ */ h(Be, {
|
|
1336
1334
|
field: e,
|
|
1337
1335
|
min: t,
|
|
1338
1336
|
max: n,
|
|
1339
1337
|
onReset: () => a(e)
|
|
1340
1338
|
}, e)),
|
|
1341
|
-
u.map(({ field: e, range: t, label: n }) => /* @__PURE__ */
|
|
1339
|
+
u.map(({ field: e, range: t, label: n }) => /* @__PURE__ */ h(Ve, {
|
|
1342
1340
|
field: e,
|
|
1343
1341
|
label: n,
|
|
1344
1342
|
onReset: () => o(e, t)
|
|
1345
1343
|
}, `${e}-${t.min}-${t.max}`)),
|
|
1346
|
-
/* @__PURE__ */
|
|
1344
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(S, {
|
|
1347
1345
|
onClick: r,
|
|
1348
1346
|
size: "micro",
|
|
1349
1347
|
variant: "ghost",
|
|
@@ -1353,7 +1351,7 @@ function Je() {
|
|
|
1353
1351
|
})
|
|
1354
1352
|
}) : null;
|
|
1355
1353
|
}
|
|
1356
|
-
var
|
|
1354
|
+
var Ue = {
|
|
1357
1355
|
withOffer: "_withOffer_1zrln_2",
|
|
1358
1356
|
offerRow: "_offerRow_1zrln_10",
|
|
1359
1357
|
offerHint: "_offerHint_1zrln_18",
|
|
@@ -1363,231 +1361,238 @@ var Ye = {
|
|
|
1363
1361
|
offerQuick: "_offerQuick_1zrln_56",
|
|
1364
1362
|
filterChip: "_filterChip_1zrln_59",
|
|
1365
1363
|
filtersPopover: "_filtersPopover_1zrln_63"
|
|
1366
|
-
},
|
|
1367
|
-
let { state: { query:
|
|
1364
|
+
}, We = ({ className: t = "", autoFocus: n = !1, inputSize: r = "default", showClear: i = !0, showFocus: a = !1, showStatus: o = !0, onAsk: s, searchOrAsk: c, askOffer: l = "chip", onKeyDown: u, ...d }) => {
|
|
1365
|
+
let { state: { query: f, filters: p, rangeFilters: m, bucketFilters: _, results: v, isFallback: y, searchSettings: b }, setQuery: x, resetFilters: C, picks: T, showPicks: E } = ye(), D = !!T, O = Object.values(p).reduce((e, t) => e + t.length, 0) + Object.keys(m).length + Object.values(_ ?? {}).reduce((e, t) => e + t.length, 0), k = f.length > 0, M = k && !D && v !== null && v.length === 0, P = k && !D && v !== null && v.length > 0 && y === !0, I = Pe({ enabled: !!s && !c }), L = c ?? I, R = L.quick === "ready" || L.askAnytime, z = e.useRef(null);
|
|
1368
1366
|
e.useEffect(() => {
|
|
1369
|
-
let e =
|
|
1370
|
-
s && e && e ===
|
|
1367
|
+
let e = L.answerNow;
|
|
1368
|
+
s && e && e === f.trim() && z.current !== e && (z.current = e, s(e, { proactive: !0 }));
|
|
1371
1369
|
}, [
|
|
1372
|
-
|
|
1373
|
-
|
|
1370
|
+
L.answerNow,
|
|
1371
|
+
f,
|
|
1374
1372
|
s
|
|
1375
1373
|
]);
|
|
1376
|
-
let
|
|
1377
|
-
u?.(e), !e.defaultPrevented && e.key === "Enter" && s &&
|
|
1378
|
-
}, [
|
|
1374
|
+
let V = z.current !== null && z.current === f.trim(), U = !s || !k || V ? "none" : L.quick, W = L.available && b.placeholderText === "Type to search" ? "Search or ask" : b.placeholderText, G = (e) => {
|
|
1375
|
+
u?.(e), !e.defaultPrevented && e.key === "Enter" && s && R && f.trim() && (e.preventDefault(), J());
|
|
1376
|
+
}, [q, te] = e.useState(!1);
|
|
1379
1377
|
e.useEffect(() => {
|
|
1380
|
-
|
|
1381
|
-
}, [
|
|
1382
|
-
let
|
|
1383
|
-
|
|
1384
|
-
},
|
|
1385
|
-
|
|
1386
|
-
},
|
|
1378
|
+
O === 0 && te(!1);
|
|
1379
|
+
}, [O]);
|
|
1380
|
+
let ne = () => {
|
|
1381
|
+
E?.(null), x(""), O > 0 && C();
|
|
1382
|
+
}, J = () => {
|
|
1383
|
+
z.current = f.trim(), s(f.trim());
|
|
1384
|
+
}, Y = /* @__PURE__ */ g(N, {
|
|
1387
1385
|
type: "text",
|
|
1388
|
-
value:
|
|
1389
|
-
onChange: (e) =>
|
|
1390
|
-
placeholder:
|
|
1386
|
+
value: f,
|
|
1387
|
+
onChange: (e) => x(e.target.value),
|
|
1388
|
+
placeholder: W,
|
|
1391
1389
|
autoFocus: n,
|
|
1392
1390
|
className: t,
|
|
1393
1391
|
showSearchIcon: !0,
|
|
1394
1392
|
inputSize: r,
|
|
1395
1393
|
showFocusBorder: a,
|
|
1396
1394
|
clearable: !1,
|
|
1397
|
-
onKeyDown:
|
|
1395
|
+
onKeyDown: G,
|
|
1398
1396
|
...d,
|
|
1399
1397
|
children: [
|
|
1400
|
-
l === "chip" &&
|
|
1401
|
-
className:
|
|
1398
|
+
l === "chip" && U === "thinking" && /* @__PURE__ */ g("span", {
|
|
1399
|
+
className: Ue.thinking,
|
|
1402
1400
|
"aria-live": "polite",
|
|
1403
|
-
children: [/* @__PURE__ */
|
|
1401
|
+
children: [/* @__PURE__ */ h(H, {}), /* @__PURE__ */ h(F, { children: "Thinking" })]
|
|
1404
1402
|
}),
|
|
1405
|
-
l === "chip" && (
|
|
1406
|
-
variant:
|
|
1407
|
-
className:
|
|
1403
|
+
l === "chip" && (U === "ready" || U === "invite" || U === "hint" || U === "ask") && /* @__PURE__ */ h(S, {
|
|
1404
|
+
variant: U === "ready" ? "primary" : "ghost",
|
|
1405
|
+
className: U === "ready" ? Ue.askStrong : void 0,
|
|
1408
1406
|
size: "micro",
|
|
1409
|
-
iconLeft: /* @__PURE__ */
|
|
1410
|
-
iconRight:
|
|
1411
|
-
onClick:
|
|
1412
|
-
title:
|
|
1413
|
-
children:
|
|
1407
|
+
iconLeft: /* @__PURE__ */ h(H, {}),
|
|
1408
|
+
iconRight: U === "ready" ? /* @__PURE__ */ h(A, { children: "Enter β΅" }) : void 0,
|
|
1409
|
+
onClick: J,
|
|
1410
|
+
title: R ? "Enter asks" : void 0,
|
|
1411
|
+
children: U === "ready" ? "Ask" : U === "hint" ? /* @__PURE__ */ h(F, { children: "For a quick answer, type a bit more" }) : U === "invite" ? "Ask about this" : "Ask"
|
|
1414
1412
|
}),
|
|
1415
|
-
o &&
|
|
1416
|
-
o &&
|
|
1413
|
+
o && M && /* @__PURE__ */ h(w, { children: "No results" }),
|
|
1414
|
+
o && P && /* @__PURE__ */ h(B, {
|
|
1417
1415
|
content: "No direct match. Showing the nearest results.",
|
|
1418
|
-
children: /* @__PURE__ */
|
|
1419
|
-
icon: /* @__PURE__ */
|
|
1416
|
+
children: /* @__PURE__ */ h("span", { children: /* @__PURE__ */ h(w, {
|
|
1417
|
+
icon: /* @__PURE__ */ h(ee, {}),
|
|
1420
1418
|
children: "Nearest"
|
|
1421
1419
|
}) })
|
|
1422
1420
|
}),
|
|
1423
|
-
o &&
|
|
1424
|
-
open:
|
|
1425
|
-
onOpenChange:
|
|
1421
|
+
o && O > 0 && /* @__PURE__ */ h(j, {
|
|
1422
|
+
open: q,
|
|
1423
|
+
onOpenChange: te,
|
|
1426
1424
|
align: "end",
|
|
1427
1425
|
sideOffset: 6,
|
|
1428
|
-
className:
|
|
1426
|
+
className: Ue.filtersPopover,
|
|
1429
1427
|
"aria-label": "Active filters",
|
|
1430
|
-
trigger: /* @__PURE__ */
|
|
1428
|
+
trigger: /* @__PURE__ */ h(S, {
|
|
1431
1429
|
variant: "ghost",
|
|
1432
1430
|
size: "micro",
|
|
1433
|
-
className:
|
|
1434
|
-
"aria-label": `${
|
|
1435
|
-
title: `${
|
|
1436
|
-
children: /* @__PURE__ */
|
|
1437
|
-
icon: /* @__PURE__ */
|
|
1431
|
+
className: Ue.filterChip,
|
|
1432
|
+
"aria-label": `${O} filter${O === 1 ? "" : "s"} active: show them`,
|
|
1433
|
+
title: `${O} filter${O === 1 ? "" : "s"} active`,
|
|
1434
|
+
children: /* @__PURE__ */ h(w, {
|
|
1435
|
+
icon: /* @__PURE__ */ h(K, {}),
|
|
1438
1436
|
color: "var(--CLightBlue)",
|
|
1439
1437
|
textColor: "#080809",
|
|
1440
|
-
children:
|
|
1438
|
+
children: O
|
|
1441
1439
|
})
|
|
1442
1440
|
}),
|
|
1443
|
-
children: /* @__PURE__ */
|
|
1441
|
+
children: /* @__PURE__ */ h(He, {})
|
|
1444
1442
|
}),
|
|
1445
|
-
i && (
|
|
1443
|
+
i && (k || O > 0) && /* @__PURE__ */ h(S, {
|
|
1446
1444
|
variant: "ghost",
|
|
1447
1445
|
size: "micro",
|
|
1448
|
-
onClick:
|
|
1449
|
-
"aria-label":
|
|
1446
|
+
onClick: ne,
|
|
1447
|
+
"aria-label": O > 0 ? "Clear search and filters" : "Clear search",
|
|
1450
1448
|
children: "Clear"
|
|
1451
1449
|
})
|
|
1452
1450
|
]
|
|
1453
1451
|
});
|
|
1454
|
-
return l !== "below" || !s || !
|
|
1455
|
-
className:
|
|
1456
|
-
children: [
|
|
1457
|
-
className:
|
|
1458
|
-
children: !
|
|
1459
|
-
searchOrAsk:
|
|
1460
|
-
onAsk:
|
|
1461
|
-
className:
|
|
1452
|
+
return l !== "below" || !s || !L.available ? Y : /* @__PURE__ */ g("div", {
|
|
1453
|
+
className: Ue.withOffer,
|
|
1454
|
+
children: [Y, /* @__PURE__ */ h("div", {
|
|
1455
|
+
className: Ue.offerRow,
|
|
1456
|
+
children: !V && /* @__PURE__ */ h(Le, {
|
|
1457
|
+
searchOrAsk: L,
|
|
1458
|
+
onAsk: J,
|
|
1459
|
+
className: Ue.offerQuick
|
|
1462
1460
|
})
|
|
1463
1461
|
})]
|
|
1464
1462
|
});
|
|
1465
|
-
},
|
|
1463
|
+
}, Ge = {
|
|
1466
1464
|
message: "_message_1mgfk_1",
|
|
1467
1465
|
icon: "_icon_1mgfk_10",
|
|
1468
1466
|
title: "_title_1mgfk_15",
|
|
1469
1467
|
detail: "_detail_1mgfk_20",
|
|
1470
1468
|
technical: "_technical_1mgfk_25",
|
|
1471
1469
|
button: "_button_1mgfk_33"
|
|
1472
|
-
},
|
|
1470
|
+
}, Ke = {
|
|
1473
1471
|
unreachable: {
|
|
1474
|
-
icon:
|
|
1472
|
+
icon: G,
|
|
1475
1473
|
title: "Search is unavailable",
|
|
1476
1474
|
detail: "The search server canβt be reached right now."
|
|
1477
1475
|
},
|
|
1478
1476
|
unauthorized: {
|
|
1479
|
-
icon:
|
|
1477
|
+
icon: ne,
|
|
1480
1478
|
title: "Search is unavailable",
|
|
1481
1479
|
detail: "The search key was not accepted."
|
|
1482
1480
|
},
|
|
1483
1481
|
forbidden: {
|
|
1484
|
-
icon:
|
|
1482
|
+
icon: J,
|
|
1485
1483
|
title: "Search is unavailable",
|
|
1486
1484
|
detail: "This search key doesnβt have access to these results."
|
|
1487
1485
|
},
|
|
1488
1486
|
notFound: {
|
|
1489
|
-
icon:
|
|
1487
|
+
icon: X,
|
|
1490
1488
|
title: "Nothing to search here",
|
|
1491
1489
|
detail: "The collection this page searches doesnβt exist."
|
|
1492
1490
|
},
|
|
1493
1491
|
notReady: {
|
|
1494
|
-
icon:
|
|
1492
|
+
icon: q,
|
|
1495
1493
|
title: "Search is getting ready",
|
|
1496
1494
|
detail: "Results will appear in a moment."
|
|
1497
1495
|
},
|
|
1498
1496
|
unavailable: {
|
|
1499
|
-
icon:
|
|
1497
|
+
icon: ie,
|
|
1500
1498
|
title: "Search is unavailable",
|
|
1501
1499
|
detail: "The collection canβt be searched right now."
|
|
1502
1500
|
},
|
|
1503
1501
|
rateLimited: {
|
|
1504
|
-
icon:
|
|
1502
|
+
icon: re,
|
|
1505
1503
|
title: "Too many searches",
|
|
1506
1504
|
detail: "Wait a moment, then try again."
|
|
1507
1505
|
},
|
|
1508
1506
|
server: {
|
|
1509
|
-
icon:
|
|
1507
|
+
icon: ie,
|
|
1510
1508
|
title: "Something went wrong",
|
|
1511
1509
|
detail: "The search server ran into a problem."
|
|
1512
1510
|
},
|
|
1513
1511
|
setup: {
|
|
1514
|
-
icon:
|
|
1512
|
+
icon: ie,
|
|
1515
1513
|
title: "Search isnβt set up",
|
|
1516
1514
|
detail: "This page is missing part of its search setup."
|
|
1517
1515
|
},
|
|
1518
1516
|
unknown: {
|
|
1519
|
-
icon:
|
|
1517
|
+
icon: ie,
|
|
1520
1518
|
title: "Something went wrong",
|
|
1521
1519
|
detail: "The search couldnβt be completed."
|
|
1522
1520
|
}
|
|
1523
|
-
},
|
|
1524
|
-
let { icon: r, title: i, detail: a } =
|
|
1521
|
+
}, qe = ({ error: e, onRetry: t, hideTechnical: n = !1 }) => {
|
|
1522
|
+
let { icon: r, title: i, detail: a } = Ke[e.kind];
|
|
1525
1523
|
o(() => {
|
|
1526
1524
|
if (e.kind !== "notReady" || !t) return;
|
|
1527
1525
|
let n = setTimeout(t, (e.retryAfterSeconds ?? 2) * 1e3);
|
|
1528
1526
|
return () => clearTimeout(n);
|
|
1529
1527
|
}, [e, t]);
|
|
1530
1528
|
let s = e.retryable && e.kind !== "notReady" && t;
|
|
1531
|
-
return /* @__PURE__ */
|
|
1532
|
-
className:
|
|
1529
|
+
return /* @__PURE__ */ g("div", {
|
|
1530
|
+
className: Ge.message,
|
|
1533
1531
|
role: "alert",
|
|
1534
1532
|
children: [
|
|
1535
|
-
/* @__PURE__ */
|
|
1536
|
-
className:
|
|
1537
|
-
children: /* @__PURE__ */
|
|
1533
|
+
/* @__PURE__ */ h("span", {
|
|
1534
|
+
className: Ge.icon,
|
|
1535
|
+
children: /* @__PURE__ */ h(r, {
|
|
1538
1536
|
size: 70,
|
|
1539
1537
|
color: "var(--lv4)"
|
|
1540
1538
|
})
|
|
1541
1539
|
}),
|
|
1542
|
-
/* @__PURE__ */
|
|
1543
|
-
className:
|
|
1540
|
+
/* @__PURE__ */ h("div", {
|
|
1541
|
+
className: Ge.title,
|
|
1544
1542
|
children: i
|
|
1545
1543
|
}),
|
|
1546
|
-
/* @__PURE__ */
|
|
1547
|
-
className:
|
|
1544
|
+
/* @__PURE__ */ h("div", {
|
|
1545
|
+
className: Ge.detail,
|
|
1548
1546
|
children: a
|
|
1549
1547
|
}),
|
|
1550
|
-
!n && /* @__PURE__ */
|
|
1551
|
-
className:
|
|
1548
|
+
!n && /* @__PURE__ */ h("code", {
|
|
1549
|
+
className: Ge.technical,
|
|
1552
1550
|
children: e.technical
|
|
1553
1551
|
}),
|
|
1554
|
-
s && /* @__PURE__ */
|
|
1552
|
+
s && /* @__PURE__ */ h(S, {
|
|
1555
1553
|
variant: "secondary",
|
|
1556
1554
|
size: "micro",
|
|
1557
|
-
className:
|
|
1555
|
+
className: Ge.button,
|
|
1558
1556
|
onClick: t,
|
|
1559
1557
|
children: "Try again"
|
|
1560
1558
|
})
|
|
1561
1559
|
]
|
|
1562
1560
|
});
|
|
1563
|
-
},
|
|
1564
|
-
placeholder: "
|
|
1565
|
-
invalid: "
|
|
1566
|
-
searchedFor: "
|
|
1567
|
-
|
|
1561
|
+
}, Je = {
|
|
1562
|
+
placeholder: "_placeholder_1m5kj_1",
|
|
1563
|
+
invalid: "_invalid_1m5kj_11",
|
|
1564
|
+
searchedFor: "_searchedFor_1m5kj_17",
|
|
1565
|
+
notFound: "_notFound_1m5kj_21",
|
|
1566
|
+
dimmed: "_dimmed_1m5kj_22",
|
|
1567
|
+
picksHead: "_picksHead_1m5kj_25",
|
|
1568
|
+
picksTitle: "_picksTitle_1m5kj_26",
|
|
1569
|
+
picksCount: "_picksCount_1m5kj_27",
|
|
1570
|
+
picksSpacer: "_picksSpacer_1m5kj_28",
|
|
1571
|
+
why: "_why_1m5kj_29"
|
|
1572
|
+
}, Ye = {
|
|
1568
1573
|
row: "_row_11svi_1",
|
|
1569
1574
|
content: "_content_11svi_22",
|
|
1570
1575
|
indexNumber: "_indexNumber_11svi_36",
|
|
1571
1576
|
scoreNumber: "_scoreNumber_11svi_44",
|
|
1572
1577
|
skeletonBars: "_skeletonBars_11svi_53"
|
|
1573
|
-
},
|
|
1574
|
-
className:
|
|
1578
|
+
}, Xe = ({ skeleton: e = !1, index: t, score: n, showScore: r = !1, children: i, skeletonDelay: a = 0, skeletonWidths: o = [62, 38] }) => /* @__PURE__ */ g("div", {
|
|
1579
|
+
className: Ye.row,
|
|
1575
1580
|
children: [
|
|
1576
|
-
t !== void 0 && /* @__PURE__ */
|
|
1577
|
-
className:
|
|
1581
|
+
t !== void 0 && /* @__PURE__ */ h("div", {
|
|
1582
|
+
className: Ye.indexNumber,
|
|
1578
1583
|
children: t
|
|
1579
1584
|
}),
|
|
1580
|
-
/* @__PURE__ */
|
|
1581
|
-
className:
|
|
1582
|
-
children: e ? /* @__PURE__ */
|
|
1583
|
-
className:
|
|
1584
|
-
children: [/* @__PURE__ */
|
|
1585
|
+
/* @__PURE__ */ h("div", {
|
|
1586
|
+
className: Ye.content,
|
|
1587
|
+
children: e ? /* @__PURE__ */ g("div", {
|
|
1588
|
+
className: Ye.skeletonBars,
|
|
1589
|
+
children: [/* @__PURE__ */ h(I, {
|
|
1585
1590
|
level: 3,
|
|
1586
1591
|
height: 12,
|
|
1587
1592
|
width: `${o[0]}%`,
|
|
1588
1593
|
delay: a,
|
|
1589
1594
|
appear: !1
|
|
1590
|
-
}), /* @__PURE__ */
|
|
1595
|
+
}), /* @__PURE__ */ h(I, {
|
|
1591
1596
|
level: 3,
|
|
1592
1597
|
height: 8,
|
|
1593
1598
|
width: `${o[1]}%`,
|
|
@@ -1596,15 +1601,15 @@ var Ye = {
|
|
|
1596
1601
|
})]
|
|
1597
1602
|
}) : i
|
|
1598
1603
|
}),
|
|
1599
|
-
r && n !== void 0 && /* @__PURE__ */
|
|
1600
|
-
className:
|
|
1604
|
+
r && n !== void 0 && /* @__PURE__ */ h("div", {
|
|
1605
|
+
className: Ye.scoreNumber,
|
|
1601
1606
|
children: n
|
|
1602
1607
|
})
|
|
1603
1608
|
]
|
|
1604
|
-
}),
|
|
1609
|
+
}), Ze = {
|
|
1605
1610
|
wrapper: "_wrapper_f970z_6",
|
|
1606
1611
|
skeletonAppear: "_skeletonAppear_f970z_1"
|
|
1607
|
-
},
|
|
1612
|
+
}, Qe = [
|
|
1608
1613
|
[62, 38],
|
|
1609
1614
|
[75, 45],
|
|
1610
1615
|
[58, 33],
|
|
@@ -1613,130 +1618,363 @@ var Ye = {
|
|
|
1613
1618
|
[55, 35],
|
|
1614
1619
|
[72, 40],
|
|
1615
1620
|
[60, 30]
|
|
1616
|
-
],
|
|
1617
|
-
className:
|
|
1618
|
-
children: Array.from({ length: e }).map((e, t) => /* @__PURE__ */
|
|
1621
|
+
], $e = ({ rows: e = 6 }) => /* @__PURE__ */ h("div", {
|
|
1622
|
+
className: Ze.wrapper,
|
|
1623
|
+
children: Array.from({ length: e }).map((e, t) => /* @__PURE__ */ h(Xe, {
|
|
1619
1624
|
skeleton: !0,
|
|
1620
1625
|
skeletonDelay: t * .1,
|
|
1621
|
-
skeletonWidths:
|
|
1626
|
+
skeletonWidths: Qe[t % Qe.length]
|
|
1622
1627
|
}, t))
|
|
1623
|
-
})
|
|
1624
|
-
|
|
1628
|
+
});
|
|
1629
|
+
// src/hooks/useFilterSuggestion.ts
|
|
1630
|
+
function et(e) {
|
|
1631
|
+
let t = e.trim().toLowerCase();
|
|
1632
|
+
return t === "true" || t === "false" || t !== "" && !Number.isNaN(Number(t));
|
|
1633
|
+
}
|
|
1634
|
+
function tt(e, t) {
|
|
1635
|
+
if (!t) return null;
|
|
1636
|
+
let n = [];
|
|
1637
|
+
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({
|
|
1638
|
+
field: e,
|
|
1639
|
+
value: t.key
|
|
1640
|
+
});
|
|
1641
|
+
n.sort((e, t) => t.value.length - e.value.length);
|
|
1642
|
+
let r = " " + e.toLowerCase() + " ", i = [];
|
|
1643
|
+
for (let e of n) {
|
|
1644
|
+
let t = " " + e.value.toLowerCase().trim() + " ", n = r.indexOf(t);
|
|
1645
|
+
n < 0 || (i.push({
|
|
1646
|
+
field: e.field,
|
|
1647
|
+
value: e.value
|
|
1648
|
+
}), r = r.slice(0, n) + " " + r.slice(n + t.length));
|
|
1649
|
+
}
|
|
1650
|
+
return i.length === 0 ? null : {
|
|
1651
|
+
filters: i,
|
|
1652
|
+
text: r.replace(/[?!.,]+\s*$/, "").replace(/\s+/g, " ").trim(),
|
|
1653
|
+
sort: null
|
|
1654
|
+
};
|
|
1655
|
+
}
|
|
1656
|
+
function nt(e = {}) {
|
|
1657
|
+
let t = ye(), { url: n, team: r, dataset: a, authenticatedFetch: s, setQuery: u, toggleFilter: d, setRangeFilter: f, setSort: p } = t, { auto: m } = e, h = c(t);
|
|
1658
|
+
h.current = t;
|
|
1659
|
+
let [g, _] = l(null), [v, y] = l(""), [b, x] = l(!1), S = c(0), C = i(async (e) => {
|
|
1660
|
+
let t = ++S.current;
|
|
1661
|
+
x(!0);
|
|
1662
|
+
try {
|
|
1663
|
+
let i = await s(`${n}/api/teams/${r}/datasets/${a}/search-or-ask/filters${Ae(h.current)}`, {
|
|
1664
|
+
method: "POST",
|
|
1665
|
+
headers: { "Content-Type": "application/json" },
|
|
1666
|
+
body: JSON.stringify({ text: e })
|
|
1667
|
+
});
|
|
1668
|
+
if (t !== S.current) return;
|
|
1669
|
+
let o = i.ok ? await i.json() : null;
|
|
1670
|
+
_(o && o.filters.length > 0 ? o : null), y(e);
|
|
1671
|
+
} catch {
|
|
1672
|
+
t === S.current && _(null);
|
|
1673
|
+
} finally {
|
|
1674
|
+
t === S.current && x(!1);
|
|
1675
|
+
}
|
|
1676
|
+
}, [
|
|
1677
|
+
n,
|
|
1678
|
+
r,
|
|
1679
|
+
a,
|
|
1680
|
+
s
|
|
1681
|
+
]), w = i((e) => {
|
|
1682
|
+
u(e.text);
|
|
1683
|
+
let t = {
|
|
1684
|
+
...h.current.state.rangeBounds,
|
|
1685
|
+
...h.current.datasetBounds
|
|
1686
|
+
};
|
|
1687
|
+
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);
|
|
1688
|
+
e.sort && p(e.sort.field, !e.sort.descending), _(null);
|
|
1689
|
+
}, [
|
|
1690
|
+
u,
|
|
1691
|
+
d,
|
|
1692
|
+
f,
|
|
1693
|
+
p
|
|
1694
|
+
]), T = i(() => {
|
|
1695
|
+
S.current++, _(null), x(!1);
|
|
1696
|
+
}, []), 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);
|
|
1697
|
+
M.current = j;
|
|
1698
|
+
let N = t.state.facets, P = t.state.isLoading || t.facetsEnabled && N == null;
|
|
1699
|
+
return o(() => {
|
|
1700
|
+
if (!A || !j || P || E.current.has(j)) return;
|
|
1701
|
+
E.current.add(j);
|
|
1702
|
+
let e = tt(j, N);
|
|
1703
|
+
if (e && (E.current.add(e.text), w(e), O(j)), k !== "model") return;
|
|
1704
|
+
let t = e ? e.text : j;
|
|
1705
|
+
if (!t) return;
|
|
1706
|
+
let i = () => M.current === j || M.current === t;
|
|
1707
|
+
(async () => {
|
|
1708
|
+
let o = ++S.current;
|
|
1709
|
+
x(!0);
|
|
1710
|
+
try {
|
|
1711
|
+
let c = await s(`${n}/api/teams/${r}/datasets/${a}/search-or-ask/filters${Ae(h.current)}`, {
|
|
1712
|
+
method: "POST",
|
|
1713
|
+
headers: { "Content-Type": "application/json" },
|
|
1714
|
+
body: JSON.stringify({ text: t })
|
|
1715
|
+
});
|
|
1716
|
+
if (o !== S.current || !i()) return;
|
|
1717
|
+
let l = c.ok ? await c.json() : null;
|
|
1718
|
+
l && l.filters.length > 0 && (E.current.add(l.text), w({
|
|
1719
|
+
filters: [...e?.filters ?? [], ...l.filters],
|
|
1720
|
+
text: l.text,
|
|
1721
|
+
sort: l.sort
|
|
1722
|
+
}), O(j));
|
|
1723
|
+
} catch {} finally {
|
|
1724
|
+
o === S.current && x(!1);
|
|
1725
|
+
}
|
|
1726
|
+
})();
|
|
1727
|
+
}, [
|
|
1728
|
+
A,
|
|
1729
|
+
j,
|
|
1730
|
+
k,
|
|
1731
|
+
P,
|
|
1732
|
+
N,
|
|
1733
|
+
w,
|
|
1734
|
+
n,
|
|
1735
|
+
r,
|
|
1736
|
+
a,
|
|
1737
|
+
s
|
|
1738
|
+
]), {
|
|
1739
|
+
suggestion: g,
|
|
1740
|
+
forText: v,
|
|
1741
|
+
loading: b,
|
|
1742
|
+
suggest: C,
|
|
1743
|
+
apply: w,
|
|
1744
|
+
clear: T,
|
|
1745
|
+
appliedText: D
|
|
1746
|
+
};
|
|
1747
|
+
}
|
|
1748
|
+
// src/components/SearchResults.tsx
|
|
1749
|
+
var rt = /^\[\s*(?:'[^']*'(?:\s*,\s*'[^']*')*)?\s*\]$/;
|
|
1750
|
+
function it(e) {
|
|
1625
1751
|
let t = e.trim();
|
|
1626
1752
|
if (!t.startsWith("[") || !t.endsWith("]")) return;
|
|
1627
1753
|
try {
|
|
1628
1754
|
let e = JSON.parse(t);
|
|
1629
1755
|
if (Array.isArray(e)) return e.map((e) => String(e));
|
|
1630
1756
|
} catch {}
|
|
1631
|
-
if (!
|
|
1757
|
+
if (!rt.test(t)) return;
|
|
1632
1758
|
let n = [], r = /'([^']*)'/g, i;
|
|
1633
1759
|
for (; (i = r.exec(t)) !== null;) n.push(i[1]);
|
|
1634
1760
|
return n;
|
|
1635
1761
|
}
|
|
1636
|
-
|
|
1637
|
-
let
|
|
1762
|
+
function at(e, t, n) {
|
|
1763
|
+
let r;
|
|
1764
|
+
try {
|
|
1765
|
+
r = typeof e == "string" ? JSON.parse(e) : e;
|
|
1766
|
+
} catch {
|
|
1767
|
+
return null;
|
|
1768
|
+
}
|
|
1769
|
+
let i;
|
|
1770
|
+
if (t && t.length > 0) {
|
|
1771
|
+
i = {};
|
|
1772
|
+
for (let e of t) e in r && (i[e] = r[e]);
|
|
1773
|
+
} else i = { ...r };
|
|
1774
|
+
if (n) for (let e in i) {
|
|
1775
|
+
let t = i[e];
|
|
1776
|
+
if (typeof t == "string") {
|
|
1777
|
+
let n = it(t);
|
|
1778
|
+
n && (i[e] = n);
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1781
|
+
return i;
|
|
1782
|
+
}
|
|
1783
|
+
var ot = ({ picks: e, fields: t, parseArrayStrings: n, label: r, onShowSearch: i, children: a }) => {
|
|
1784
|
+
let { url: s, team: c, dataset: u, authenticatedFetch: d, count: f } = ye(), [p, _] = l(null);
|
|
1638
1785
|
o(() => {
|
|
1639
|
-
let
|
|
1640
|
-
(
|
|
1786
|
+
let t = !1;
|
|
1787
|
+
_(null);
|
|
1788
|
+
let n = e.picks.map((e) => e.documentKey);
|
|
1789
|
+
return (async () => {
|
|
1790
|
+
try {
|
|
1791
|
+
let e = await d(`${s}/api/teams/${c}/datasets/${u}/documents/lookup`, {
|
|
1792
|
+
method: "POST",
|
|
1793
|
+
headers: { "Content-Type": "application/json" },
|
|
1794
|
+
body: JSON.stringify(n)
|
|
1795
|
+
}), r = e.ok ? await e.json() : [];
|
|
1796
|
+
t || _(new Map(n.map((e, t) => [e, r[t]])));
|
|
1797
|
+
} catch {
|
|
1798
|
+
t || _(/* @__PURE__ */ new Map());
|
|
1799
|
+
}
|
|
1800
|
+
})(), () => {
|
|
1801
|
+
t = !0;
|
|
1802
|
+
};
|
|
1641
1803
|
}, [
|
|
1804
|
+
e,
|
|
1642
1805
|
s,
|
|
1643
|
-
|
|
1644
|
-
|
|
1806
|
+
c,
|
|
1807
|
+
u,
|
|
1808
|
+
d
|
|
1809
|
+
]);
|
|
1810
|
+
let v = (t, n) => async () => {
|
|
1811
|
+
if (e.askId) try {
|
|
1812
|
+
await d(`${s}/api/teams/${c}/datasets/${u}/events/select`, {
|
|
1813
|
+
method: "POST",
|
|
1814
|
+
headers: { "Content-Type": "application/json" },
|
|
1815
|
+
body: JSON.stringify({
|
|
1816
|
+
queryId: e.askId,
|
|
1817
|
+
documentKey: t,
|
|
1818
|
+
position: n,
|
|
1819
|
+
...f === !1 ? { count: !1 } : {}
|
|
1820
|
+
})
|
|
1821
|
+
});
|
|
1822
|
+
} catch {}
|
|
1823
|
+
}, y = e.search;
|
|
1824
|
+
return /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ g("div", {
|
|
1825
|
+
className: Je.picksHead,
|
|
1826
|
+
children: [
|
|
1827
|
+
/* @__PURE__ */ g("span", {
|
|
1828
|
+
className: Je.picksTitle,
|
|
1829
|
+
children: [/* @__PURE__ */ h(H, {
|
|
1830
|
+
size: 14,
|
|
1831
|
+
color: "currentColor"
|
|
1832
|
+
}), r]
|
|
1833
|
+
}),
|
|
1834
|
+
/* @__PURE__ */ h("span", {
|
|
1835
|
+
className: Je.picksCount,
|
|
1836
|
+
children: e.picks.length
|
|
1837
|
+
}),
|
|
1838
|
+
/* @__PURE__ */ h("span", { className: Je.picksSpacer }),
|
|
1839
|
+
i && /* @__PURE__ */ h(S, {
|
|
1840
|
+
variant: "ghost",
|
|
1841
|
+
size: "micro",
|
|
1842
|
+
onClick: i,
|
|
1843
|
+
children: y ? `Show all ${y.found}${y.more ? "+" : ""} found` : "Show the search instead"
|
|
1844
|
+
})
|
|
1845
|
+
]
|
|
1846
|
+
}), p === null ? /* @__PURE__ */ h($e, { rows: Math.max(1, e.picks.length) }) : /* @__PURE__ */ h("div", { children: e.picks.map((e) => {
|
|
1847
|
+
let r = p.get(e.documentKey), i = r == null ? null : at(r, t, n);
|
|
1848
|
+
return i ? /* @__PURE__ */ g(Xe, {
|
|
1849
|
+
index: e.n,
|
|
1850
|
+
showScore: !1,
|
|
1851
|
+
children: [a(i, {
|
|
1852
|
+
result: {
|
|
1853
|
+
document: r,
|
|
1854
|
+
documentKey: e.documentKey,
|
|
1855
|
+
score: 0,
|
|
1856
|
+
position: e.n
|
|
1857
|
+
},
|
|
1858
|
+
select: v(e.documentKey, e.n)
|
|
1859
|
+
}), e.why && /* @__PURE__ */ g("div", {
|
|
1860
|
+
className: Je.why,
|
|
1861
|
+
children: [/* @__PURE__ */ h(H, {
|
|
1862
|
+
size: 12,
|
|
1863
|
+
color: "currentColor"
|
|
1864
|
+
}), /* @__PURE__ */ h("span", { children: e.why })]
|
|
1865
|
+
})]
|
|
1866
|
+
}, e.documentKey) : null;
|
|
1867
|
+
}) })] });
|
|
1868
|
+
}, st = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk: r, notFoundLabel: i = "These results may not hold what you are asking about", picks: a, onShowSearch: s, picksLabel: u = "Picked by the assistant", showScore: d, children: f }) => {
|
|
1869
|
+
let { state: { results: p, resultsSuppressed: _, searchSettings: v, countedTotal: y, query: b, error: x, errorInfo: C }, isFetchingInitial: w, authError: T, authErrorInfo: E, retry: D, allowEmptySearch: O, fetchMoreResults: k, selectResult: A, searchText: j, searchAsTyped: M, picks: N, showPicks: P } = ye(), { apply: F } = nt(), I = a === void 0 ? N : a, L = s ?? (() => {
|
|
1870
|
+
I?.search && F(I.search), P?.(null);
|
|
1871
|
+
}), R = c(null);
|
|
1872
|
+
I && R.current?.picks !== I && (R.current = {
|
|
1873
|
+
picks: I,
|
|
1874
|
+
query: b
|
|
1875
|
+
});
|
|
1876
|
+
let z = !!I && R.current?.query === b, B = t ?? 30, [V, H] = l(B), U = c(0), W = c("");
|
|
1877
|
+
o(() => {
|
|
1878
|
+
let e = b !== W.current;
|
|
1879
|
+
(!p || p.length < U.current || e) && H(B), U.current = p?.length ?? 0, W.current = b;
|
|
1880
|
+
}, [
|
|
1881
|
+
p,
|
|
1882
|
+
B,
|
|
1883
|
+
b
|
|
1645
1884
|
]);
|
|
1646
|
-
let
|
|
1647
|
-
let e =
|
|
1648
|
-
|
|
1885
|
+
let G = p ?? [], K = !!r?.notFound, ee = j != null && j.trim() !== b.trim() ? j : null, q = !!p && p.length >= v.maxNumberOfRecordsToReturn && (y === void 0 || y > p.length), ne = !!p && (G.length > V || q), J = () => {
|
|
1886
|
+
let e = V + B;
|
|
1887
|
+
H(e), p && e >= p.length && q && k(p.length + B);
|
|
1649
1888
|
};
|
|
1650
|
-
if (
|
|
1651
|
-
|
|
1652
|
-
|
|
1889
|
+
if (I && z && !w && !T) return /* @__PURE__ */ h(ot, {
|
|
1890
|
+
picks: I,
|
|
1891
|
+
fields: e,
|
|
1892
|
+
parseArrayStrings: n,
|
|
1893
|
+
label: u,
|
|
1894
|
+
onShowSearch: L,
|
|
1895
|
+
children: f
|
|
1896
|
+
});
|
|
1897
|
+
if (w) return O ? /* @__PURE__ */ h($e, { rows: B }) : /* @__PURE__ */ h("div", {
|
|
1898
|
+
className: Je.placeholder,
|
|
1899
|
+
children: /* @__PURE__ */ h(te, {
|
|
1653
1900
|
size: 200,
|
|
1654
1901
|
color: "var(--lv5)"
|
|
1655
1902
|
})
|
|
1656
1903
|
});
|
|
1657
|
-
let
|
|
1658
|
-
return
|
|
1659
|
-
error: (
|
|
1904
|
+
let Y = T ?? x;
|
|
1905
|
+
return Y ? /* @__PURE__ */ h(qe, {
|
|
1906
|
+
error: (T ? E : C) ?? {
|
|
1660
1907
|
kind: "unknown",
|
|
1661
|
-
message:
|
|
1662
|
-
technical:
|
|
1908
|
+
message: Y,
|
|
1909
|
+
technical: Y,
|
|
1663
1910
|
retryable: !1
|
|
1664
1911
|
},
|
|
1665
|
-
onRetry:
|
|
1666
|
-
}) :
|
|
1667
|
-
className:
|
|
1668
|
-
children: /* @__PURE__ */
|
|
1912
|
+
onRetry: D
|
|
1913
|
+
}) : _ || p === null ? /* @__PURE__ */ h("div", {
|
|
1914
|
+
className: Je.placeholder,
|
|
1915
|
+
children: /* @__PURE__ */ h(te, {
|
|
1669
1916
|
size: 200,
|
|
1670
1917
|
color: "var(--lv5)"
|
|
1671
1918
|
})
|
|
1672
|
-
}) :
|
|
1673
|
-
|
|
1674
|
-
className:
|
|
1919
|
+
}) : G.length === 0 ? null : /* @__PURE__ */ g(m, { children: [
|
|
1920
|
+
ee && /* @__PURE__ */ g("div", {
|
|
1921
|
+
className: Je.searchedFor,
|
|
1675
1922
|
"aria-live": "polite",
|
|
1676
|
-
children: [/* @__PURE__ */
|
|
1923
|
+
children: [/* @__PURE__ */ g("span", { children: ["Searching for ", /* @__PURE__ */ h("strong", { children: ee })] }), M && /* @__PURE__ */ h(S, {
|
|
1677
1924
|
variant: "ghost",
|
|
1678
1925
|
size: "micro",
|
|
1679
|
-
onClick:
|
|
1926
|
+
onClick: M,
|
|
1680
1927
|
children: "Search for your exact words"
|
|
1681
1928
|
})]
|
|
1682
1929
|
}),
|
|
1683
|
-
/* @__PURE__ */
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1930
|
+
K && /* @__PURE__ */ h("p", {
|
|
1931
|
+
className: Je.notFound,
|
|
1932
|
+
"aria-live": "polite",
|
|
1933
|
+
children: i
|
|
1934
|
+
}),
|
|
1935
|
+
/* @__PURE__ */ h("div", {
|
|
1936
|
+
className: K ? Je.dimmed : void 0,
|
|
1937
|
+
children: G.slice(0, V).map((t, r) => {
|
|
1938
|
+
let i = t.score, a = at(t.document, e, n);
|
|
1939
|
+
return a ? /* @__PURE__ */ h(Xe, {
|
|
1940
|
+
index: r,
|
|
1941
|
+
score: i,
|
|
1942
|
+
showScore: d ?? v.showScore,
|
|
1943
|
+
children: f(a, {
|
|
1944
|
+
result: t,
|
|
1945
|
+
select: () => A?.(t) ?? Promise.resolve()
|
|
1946
|
+
})
|
|
1947
|
+
}, r) : /* @__PURE__ */ h("div", {
|
|
1948
|
+
className: Je.invalid,
|
|
1949
|
+
children: /* @__PURE__ */ h("p", { children: "Invalid JSON" })
|
|
1691
1950
|
}, r);
|
|
1692
|
-
}
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
l = {};
|
|
1696
|
-
for (let t of e) t in c && (l[t] = c[t]);
|
|
1697
|
-
} else l = { ...c };
|
|
1698
|
-
if (n) for (let e in l) {
|
|
1699
|
-
let t = l[e];
|
|
1700
|
-
if (typeof t == "string") {
|
|
1701
|
-
let n = st(t);
|
|
1702
|
-
n && (l[e] = n);
|
|
1703
|
-
}
|
|
1704
|
-
}
|
|
1705
|
-
return /* @__PURE__ */ f(nt, {
|
|
1706
|
-
index: r,
|
|
1707
|
-
score: s,
|
|
1708
|
-
showScore: i ?? m.showScore,
|
|
1709
|
-
children: a(l, {
|
|
1710
|
-
result: t,
|
|
1711
|
-
select: () => E?.(t) ?? Promise.resolve()
|
|
1712
|
-
})
|
|
1713
|
-
}, r);
|
|
1714
|
-
}) }),
|
|
1715
|
-
I && /* @__PURE__ */ f("div", {
|
|
1951
|
+
})
|
|
1952
|
+
}),
|
|
1953
|
+
ne && /* @__PURE__ */ h("div", {
|
|
1716
1954
|
style: {
|
|
1717
1955
|
textAlign: "center",
|
|
1718
1956
|
marginTop: "20px"
|
|
1719
1957
|
},
|
|
1720
|
-
children: /* @__PURE__ */
|
|
1958
|
+
children: /* @__PURE__ */ h(S, {
|
|
1721
1959
|
variant: "secondary",
|
|
1722
1960
|
size: "micro",
|
|
1723
|
-
onClick:
|
|
1724
|
-
children:
|
|
1961
|
+
onClick: J,
|
|
1962
|
+
children: b.trim() === "" ? "Load more" : y !== void 0 && y > 0 ? `Load results ${V + 1}-${Math.min(V + B, p.length, y)} of ${y}` : "Load more"
|
|
1725
1963
|
})
|
|
1726
1964
|
})
|
|
1727
1965
|
] });
|
|
1728
|
-
},
|
|
1966
|
+
}, ct = {
|
|
1729
1967
|
row: "_row_ujwhc_1",
|
|
1730
1968
|
title: "_title_ujwhc_8"
|
|
1731
|
-
},
|
|
1732
|
-
className: [
|
|
1969
|
+
}, lt = ({ variant: e = "default", children: t }) => /* @__PURE__ */ h("div", {
|
|
1970
|
+
className: [ct.row, e === "title" ? ct.title : ""].filter(Boolean).join(" "),
|
|
1733
1971
|
children: t
|
|
1734
|
-
}),
|
|
1972
|
+
}), ut = {
|
|
1735
1973
|
listRows: "_listRows_13obt_2",
|
|
1736
1974
|
sliderArea: "_sliderArea_13obt_8",
|
|
1737
1975
|
inputRow: "_inputRow_13obt_15",
|
|
1738
1976
|
histogramRow: "_histogramRow_13obt_22"
|
|
1739
|
-
},
|
|
1977
|
+
}, dt = [
|
|
1740
1978
|
65,
|
|
1741
1979
|
80,
|
|
1742
1980
|
55,
|
|
@@ -1745,36 +1983,36 @@ var ct = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1745
1983
|
75,
|
|
1746
1984
|
50,
|
|
1747
1985
|
68
|
|
1748
|
-
],
|
|
1986
|
+
], ft = ({ title: e, rows: t = 5, variant: n = "list", withHistogram: r = !1, collapsible: i = !0, startCollapsed: a = !1 }) => /* @__PURE__ */ h(O, {
|
|
1749
1987
|
title: e,
|
|
1750
1988
|
collapsible: i,
|
|
1751
1989
|
collapsed: a,
|
|
1752
|
-
children: n === "slider" ? /* @__PURE__ */
|
|
1753
|
-
className:
|
|
1990
|
+
children: n === "slider" ? /* @__PURE__ */ g("div", {
|
|
1991
|
+
className: ut.sliderArea,
|
|
1754
1992
|
children: [
|
|
1755
|
-
r && /* @__PURE__ */
|
|
1756
|
-
/* @__PURE__ */
|
|
1757
|
-
/* @__PURE__ */
|
|
1758
|
-
className:
|
|
1759
|
-
children: [/* @__PURE__ */
|
|
1993
|
+
r && /* @__PURE__ */ h("div", { className: ut.histogramRow }),
|
|
1994
|
+
/* @__PURE__ */ h(I, { height: 6 }),
|
|
1995
|
+
/* @__PURE__ */ g("div", {
|
|
1996
|
+
className: ut.inputRow,
|
|
1997
|
+
children: [/* @__PURE__ */ h(I, {
|
|
1760
1998
|
width: 40,
|
|
1761
1999
|
height: 20,
|
|
1762
2000
|
delay: .1
|
|
1763
|
-
}), /* @__PURE__ */
|
|
2001
|
+
}), /* @__PURE__ */ h(I, {
|
|
1764
2002
|
width: 40,
|
|
1765
2003
|
height: 20,
|
|
1766
2004
|
delay: .15
|
|
1767
2005
|
})]
|
|
1768
2006
|
})
|
|
1769
2007
|
]
|
|
1770
|
-
}) : /* @__PURE__ */
|
|
1771
|
-
className:
|
|
1772
|
-
children: Array.from({ length: t }).map((e, t) => /* @__PURE__ */
|
|
1773
|
-
width: `${
|
|
2008
|
+
}) : /* @__PURE__ */ h("div", {
|
|
2009
|
+
className: ut.listRows,
|
|
2010
|
+
children: Array.from({ length: t }).map((e, t) => /* @__PURE__ */ h(I, {
|
|
2011
|
+
width: `${dt[t % dt.length]}%`,
|
|
1774
2012
|
delay: t * .05
|
|
1775
2013
|
}, t))
|
|
1776
2014
|
})
|
|
1777
|
-
}),
|
|
2015
|
+
}), pt = {
|
|
1778
2016
|
list: "_list_18vbb_2",
|
|
1779
2017
|
count: "_count_18vbb_7",
|
|
1780
2018
|
countValue: "_countValue_18vbb_17",
|
|
@@ -1789,12 +2027,12 @@ var ct = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1789
2027
|
let r = n.map((e) => e[0].toUpperCase() + e.slice(1)).join(" and ");
|
|
1790
2028
|
return o(() => {
|
|
1791
2029
|
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).`);
|
|
1792
|
-
}, [t, r]), /* @__PURE__ */
|
|
2030
|
+
}, [t, r]), /* @__PURE__ */ h(O, {
|
|
1793
2031
|
title: e ?? t,
|
|
1794
2032
|
collapsible: !1,
|
|
1795
|
-
children: /* @__PURE__ */
|
|
2033
|
+
children: /* @__PURE__ */ g("div", {
|
|
1796
2034
|
className: mt.notice,
|
|
1797
|
-
children: [/* @__PURE__ */
|
|
2035
|
+
children: [/* @__PURE__ */ h("span", { children: "Not available" }), /* @__PURE__ */ g("code", {
|
|
1798
2036
|
className: mt.technical,
|
|
1799
2037
|
children: [
|
|
1800
2038
|
t,
|
|
@@ -1804,65 +2042,65 @@ var ct = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1804
2042
|
})]
|
|
1805
2043
|
})
|
|
1806
2044
|
});
|
|
1807
|
-
}, gt = ({ 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:
|
|
1808
|
-
let { state: { facets: w, filterableFields:
|
|
2045
|
+
}, gt = ({ 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: f, layout: p = "list", showActivePanel: m = !1, showCount: _ = !0, showNull: v = !1, match: y = "all", displayIfEmptyQuery: b = !0, displayCondition: x = (e) => !0 }) => {
|
|
2046
|
+
let { state: { facets: w, filterableFields: T, facetableFields: E, filters: D, query: k }, toggleFilter: A, setValueMatch: j, authError: N, isFetchingInitial: P, allowEmptySearch: F } = ye(), I = d ?? f ?? "checkbox", L = I === "radio" ? "any" : y;
|
|
1809
2047
|
o(() => {
|
|
1810
|
-
|
|
2048
|
+
j(e, L);
|
|
1811
2049
|
}, [
|
|
1812
2050
|
e,
|
|
1813
|
-
|
|
1814
|
-
|
|
2051
|
+
L,
|
|
2052
|
+
j
|
|
1815
2053
|
]);
|
|
1816
|
-
let
|
|
2054
|
+
let R = c(null), [B, V] = l(a);
|
|
1817
2055
|
if (o(() => {
|
|
1818
2056
|
V(a);
|
|
1819
|
-
}, [w?.[e], a]), !F && !
|
|
1820
|
-
if (P || !w) return
|
|
2057
|
+
}, [w?.[e], a]), !F && !k || N) return null;
|
|
2058
|
+
if (P || !w) return I === "toggle" ? /* @__PURE__ */ h(ft, {
|
|
1821
2059
|
rows: 1,
|
|
1822
2060
|
collapsible: !1
|
|
1823
|
-
}) : /* @__PURE__ */
|
|
2061
|
+
}) : /* @__PURE__ */ h(ft, {
|
|
1824
2062
|
title: t,
|
|
1825
2063
|
rows: Math.min(a, 6),
|
|
1826
2064
|
collapsible: s,
|
|
1827
2065
|
startCollapsed: u
|
|
1828
2066
|
});
|
|
1829
|
-
if (!
|
|
1830
|
-
query:
|
|
1831
|
-
filters:
|
|
2067
|
+
if (!x({
|
|
2068
|
+
query: k ?? "",
|
|
2069
|
+
filters: D,
|
|
1832
2070
|
facets: w
|
|
1833
|
-
}) || !
|
|
1834
|
-
if (!
|
|
2071
|
+
}) || !b && !k && Object.keys(D).length < 1) return null;
|
|
2072
|
+
if (!T?.includes(e) || !E?.includes(e)) {
|
|
1835
2073
|
let n = [];
|
|
1836
|
-
return
|
|
2074
|
+
return T?.includes(e) || n.push("filterable"), E?.includes(e) || n.push("facetable"), /* @__PURE__ */ h(ht, {
|
|
1837
2075
|
label: t,
|
|
1838
2076
|
field: e,
|
|
1839
2077
|
missing: n
|
|
1840
2078
|
});
|
|
1841
2079
|
}
|
|
1842
|
-
let H = w?.[e] ?? (
|
|
2080
|
+
let H = w?.[e] ?? (I === "toggle" ? [] : void 0);
|
|
1843
2081
|
if (!H || !Array.isArray(H)) return null;
|
|
1844
|
-
let U =
|
|
1845
|
-
n && !
|
|
2082
|
+
let U = D?.[e] ?? [];
|
|
2083
|
+
n && !R.current && H.length > 0 && (R.current = H.reduce((e, t) => (e[t.key] = t.value, e), {}));
|
|
1846
2084
|
let W = /* @__PURE__ */ new Map();
|
|
1847
|
-
n &&
|
|
2085
|
+
n && R.current && Object.keys(R.current).forEach((e) => {
|
|
1848
2086
|
W.set(e, 0);
|
|
1849
2087
|
}), H.forEach((e) => {
|
|
1850
2088
|
W.set(e.key, e.value);
|
|
1851
2089
|
});
|
|
1852
|
-
let
|
|
2090
|
+
let G = /* @__PURE__ */ new Set([
|
|
1853
2091
|
"true",
|
|
1854
2092
|
"false",
|
|
1855
2093
|
"null"
|
|
1856
|
-
]),
|
|
1857
|
-
if (
|
|
2094
|
+
]), K = Array.from(W.keys()), ee = I === "toggle" && (K.length > 0 && K.every((e) => G.has(e)) || K.length === 0 && U.length > 0);
|
|
2095
|
+
if (ee && W.has("null")) {
|
|
1858
2096
|
let e = W.get("null") ?? 0, t = W.get("false") ?? 0;
|
|
1859
2097
|
W.set("false", t + e), W.delete("null");
|
|
1860
2098
|
}
|
|
1861
|
-
if (
|
|
2099
|
+
if (I === "toggle" && !ee) return /* @__PURE__ */ h(O, {
|
|
1862
2100
|
collapsible: !1,
|
|
1863
|
-
children: /* @__PURE__ */
|
|
1864
|
-
className:
|
|
1865
|
-
children: /* @__PURE__ */
|
|
2101
|
+
children: /* @__PURE__ */ h("div", {
|
|
2102
|
+
className: pt.count,
|
|
2103
|
+
children: /* @__PURE__ */ h(z, {
|
|
1866
2104
|
label: t,
|
|
1867
2105
|
checked: !1,
|
|
1868
2106
|
onChange: () => {},
|
|
@@ -1870,17 +2108,17 @@ var ct = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1870
2108
|
})
|
|
1871
2109
|
})
|
|
1872
2110
|
});
|
|
1873
|
-
if (
|
|
2111
|
+
if (ee) {
|
|
1874
2112
|
let n = W.get("true"), r = typeof n == "number" ? n : null, i = U.includes("true"), a = r === 0 && !i, o = _ && (r ?? 0) > 0 ? `${r}` : "";
|
|
1875
|
-
return /* @__PURE__ */
|
|
2113
|
+
return /* @__PURE__ */ h(O, {
|
|
1876
2114
|
collapsible: !1,
|
|
1877
|
-
children: /* @__PURE__ */
|
|
1878
|
-
className:
|
|
2115
|
+
children: /* @__PURE__ */ g("div", {
|
|
2116
|
+
className: pt.count,
|
|
1879
2117
|
children: [
|
|
1880
|
-
/* @__PURE__ */
|
|
2118
|
+
/* @__PURE__ */ h(z, {
|
|
1881
2119
|
label: t,
|
|
1882
2120
|
checked: i,
|
|
1883
|
-
onChange: () =>
|
|
2121
|
+
onChange: () => A(e, "true"),
|
|
1884
2122
|
disabled: a
|
|
1885
2123
|
}),
|
|
1886
2124
|
" ",
|
|
@@ -1889,92 +2127,92 @@ var ct = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1889
2127
|
})
|
|
1890
2128
|
});
|
|
1891
2129
|
}
|
|
1892
|
-
let
|
|
1893
|
-
if (v || (
|
|
2130
|
+
let q = Array.from(W.entries());
|
|
2131
|
+
if (v || (q = q.filter(([e]) => e !== "null")), q.length === 0 && !n) return null;
|
|
1894
2132
|
if (!r) {
|
|
1895
2133
|
if (i === "alphabetical") {
|
|
1896
|
-
let e =
|
|
1897
|
-
|
|
2134
|
+
let e = q.filter(([, e]) => typeof e == "number" && e > 0).sort(([e], [t]) => e.localeCompare(t)), t = q.filter(([, e]) => e === 0 || e === null).sort(([e], [t]) => e.localeCompare(t));
|
|
2135
|
+
q = [...e, ...t];
|
|
1898
2136
|
} else if (i === "numeric") {
|
|
1899
2137
|
let e = (e, t) => {
|
|
1900
2138
|
let n = Number(e), r = Number(t);
|
|
1901
2139
|
return !isNaN(n) && !isNaN(r) ? n - r : e.localeCompare(t);
|
|
1902
|
-
}, t =
|
|
1903
|
-
|
|
2140
|
+
}, t = q.filter(([, e]) => typeof e == "number" && e > 0).sort(([t], [n]) => e(t, n)), n = q.filter(([, e]) => e === 0 || e === null).sort(([t], [n]) => e(t, n));
|
|
2141
|
+
q = [...t, ...n];
|
|
1904
2142
|
} else {
|
|
1905
|
-
let e =
|
|
1906
|
-
|
|
2143
|
+
let e = q.filter(([, e]) => typeof e == "number" && e > 0), t = q.filter(([, e]) => e === 0 || e === null);
|
|
2144
|
+
q = [...e, ...t];
|
|
1907
2145
|
}
|
|
1908
2146
|
}
|
|
1909
|
-
let
|
|
1910
|
-
let r = U.includes(t), i = n === 0, a = _ && (n ?? 0) > 0 ? ` (${n})` : "", o = _ && (n ?? 0) > 0 ? n : "", s = () =>
|
|
1911
|
-
switch (
|
|
1912
|
-
case "button": return
|
|
1913
|
-
className:
|
|
1914
|
-
children: [/* @__PURE__ */
|
|
2147
|
+
let te = typeof a == "number" && q.length > a, ne = te ? q.slice(0, B) : q, J = (t, n) => {
|
|
2148
|
+
let r = U.includes(t), i = n === 0, a = _ && (n ?? 0) > 0 ? ` (${n})` : "", o = _ && (n ?? 0) > 0 ? n : "", s = () => A(e, t, I === "radio");
|
|
2149
|
+
switch (I) {
|
|
2150
|
+
case "button": return p === "list" ? /* @__PURE__ */ g("div", {
|
|
2151
|
+
className: pt.count,
|
|
2152
|
+
children: [/* @__PURE__ */ h(S, {
|
|
1915
2153
|
variant: r ? "primary" : "secondary",
|
|
1916
2154
|
onClick: s,
|
|
1917
2155
|
disabled: i,
|
|
1918
2156
|
size: "micro",
|
|
1919
|
-
className:
|
|
2157
|
+
className: pt.chip,
|
|
1920
2158
|
title: t,
|
|
1921
|
-
children: /* @__PURE__ */
|
|
1922
|
-
className:
|
|
2159
|
+
children: /* @__PURE__ */ h("span", {
|
|
2160
|
+
className: pt.chipLabel,
|
|
1923
2161
|
children: t
|
|
1924
2162
|
})
|
|
1925
|
-
}), /* @__PURE__ */
|
|
1926
|
-
className:
|
|
2163
|
+
}), /* @__PURE__ */ h("span", {
|
|
2164
|
+
className: pt.countValue,
|
|
1927
2165
|
children: o
|
|
1928
2166
|
})]
|
|
1929
|
-
}) : /* @__PURE__ */
|
|
2167
|
+
}) : /* @__PURE__ */ h(S, {
|
|
1930
2168
|
variant: r ? "primary" : "secondary",
|
|
1931
2169
|
onClick: s,
|
|
1932
2170
|
disabled: i,
|
|
1933
2171
|
size: "micro",
|
|
1934
|
-
className:
|
|
2172
|
+
className: pt.chip,
|
|
1935
2173
|
title: `${t}${a}`,
|
|
1936
|
-
children: /* @__PURE__ */
|
|
1937
|
-
className:
|
|
2174
|
+
children: /* @__PURE__ */ h("span", {
|
|
2175
|
+
className: pt.chipLabel,
|
|
1938
2176
|
children: `${t}${a}`
|
|
1939
2177
|
})
|
|
1940
2178
|
});
|
|
1941
|
-
case "toggle": return /* @__PURE__ */
|
|
2179
|
+
case "toggle": return /* @__PURE__ */ h(z, {
|
|
1942
2180
|
label: t,
|
|
1943
2181
|
checked: r,
|
|
1944
2182
|
onChange: s,
|
|
1945
2183
|
disabled: i
|
|
1946
2184
|
});
|
|
1947
2185
|
case "radio": {
|
|
1948
|
-
let n = /* @__PURE__ */
|
|
2186
|
+
let n = /* @__PURE__ */ h(M, {
|
|
1949
2187
|
id: `${e}-${t}`,
|
|
1950
2188
|
name: e,
|
|
1951
2189
|
value: t,
|
|
1952
|
-
label:
|
|
2190
|
+
label: p === "grid" ? `${t}${a}` : t,
|
|
1953
2191
|
checked: r,
|
|
1954
2192
|
onChange: s,
|
|
1955
2193
|
disabled: i
|
|
1956
2194
|
});
|
|
1957
|
-
return
|
|
1958
|
-
className:
|
|
1959
|
-
children: [n, /* @__PURE__ */
|
|
1960
|
-
className:
|
|
2195
|
+
return p === "list" ? /* @__PURE__ */ g("div", {
|
|
2196
|
+
className: pt.count,
|
|
2197
|
+
children: [n, /* @__PURE__ */ h("span", {
|
|
2198
|
+
className: pt.countValue,
|
|
1961
2199
|
children: o
|
|
1962
2200
|
})]
|
|
1963
2201
|
}) : n;
|
|
1964
2202
|
}
|
|
1965
|
-
default: return
|
|
1966
|
-
className:
|
|
1967
|
-
children: [/* @__PURE__ */
|
|
2203
|
+
default: return p === "list" ? /* @__PURE__ */ g("div", {
|
|
2204
|
+
className: pt.count,
|
|
2205
|
+
children: [/* @__PURE__ */ h(C, {
|
|
1968
2206
|
label: t,
|
|
1969
2207
|
score: "",
|
|
1970
2208
|
checked: r,
|
|
1971
2209
|
onChange: s,
|
|
1972
2210
|
disabled: i
|
|
1973
|
-
}), /* @__PURE__ */
|
|
1974
|
-
className:
|
|
2211
|
+
}), /* @__PURE__ */ h("span", {
|
|
2212
|
+
className: pt.countValue,
|
|
1975
2213
|
children: o
|
|
1976
2214
|
})]
|
|
1977
|
-
}) : /* @__PURE__ */
|
|
2215
|
+
}) : /* @__PURE__ */ h(C, {
|
|
1978
2216
|
label: t,
|
|
1979
2217
|
score: a,
|
|
1980
2218
|
checked: r,
|
|
@@ -1983,27 +2221,27 @@ var ct = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1983
2221
|
});
|
|
1984
2222
|
}
|
|
1985
2223
|
};
|
|
1986
|
-
return /* @__PURE__ */
|
|
2224
|
+
return /* @__PURE__ */ h(O, {
|
|
1987
2225
|
title: t,
|
|
1988
2226
|
collapsible: s,
|
|
1989
2227
|
collapsed: s ? u : !1,
|
|
1990
|
-
className:
|
|
1991
|
-
children: /* @__PURE__ */
|
|
1992
|
-
className:
|
|
2228
|
+
className: m && U.length > 0 ? pt.active : void 0,
|
|
2229
|
+
children: /* @__PURE__ */ g("ul", {
|
|
2230
|
+
className: p === "grid" ? pt.grid : pt.list,
|
|
1993
2231
|
style: {
|
|
1994
2232
|
listStyle: "none",
|
|
1995
2233
|
padding: 0,
|
|
1996
2234
|
margin: 0
|
|
1997
2235
|
},
|
|
1998
|
-
children: [
|
|
1999
|
-
let e =
|
|
2000
|
-
return /* @__PURE__ */
|
|
2001
|
-
className:
|
|
2002
|
-
children: /* @__PURE__ */
|
|
2236
|
+
children: [ne.map(([e, t]) => /* @__PURE__ */ h("li", { children: J(e, t) }, e)), te && B < q.length && (() => {
|
|
2237
|
+
let e = q.length - B, t = Math.min(50, e);
|
|
2238
|
+
return /* @__PURE__ */ h("li", {
|
|
2239
|
+
className: pt.toggleItem,
|
|
2240
|
+
children: /* @__PURE__ */ h(S, {
|
|
2003
2241
|
variant: "ghost",
|
|
2004
2242
|
size: "micro",
|
|
2005
2243
|
onClick: () => V((e) => e + 50),
|
|
2006
|
-
children: `Show ${t} more of ${
|
|
2244
|
+
children: `Show ${t} more of ${q.length} total`
|
|
2007
2245
|
})
|
|
2008
2246
|
});
|
|
2009
2247
|
})()]
|
|
@@ -2044,190 +2282,190 @@ function xt(e, t, n) {
|
|
|
2044
2282
|
let r = Math.ceil(Number(((e - t) / n).toFixed(6)));
|
|
2045
2283
|
return Number((t + r * n).toFixed(_t(n)));
|
|
2046
2284
|
}
|
|
2047
|
-
var St = ({ 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:
|
|
2048
|
-
let { state: { rangeFilters:
|
|
2285
|
+
var St = ({ 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: f, stepMarks: p }) => {
|
|
2286
|
+
let { state: { rangeFilters: m, rangeBounds: _, facetStats: v, facets: y, filterableFields: b, facetableFields: x, query: S, facetDebounceDelayMillis: C }, setRangeFilter: w, resetRangeFilter: T, allowEmptySearch: E, authError: D, isFetchingInitial: A } = ye(), j = a ?? o ?? "input", M = _?.[t] !== void 0, N = _?.[t] ?? {
|
|
2049
2287
|
min: r,
|
|
2050
2288
|
max: i
|
|
2051
|
-
},
|
|
2052
|
-
if (
|
|
2053
|
-
let e = Math.max(_t(
|
|
2289
|
+
}, P = N.min, F = N.max, I = v?.[t] ?? N, R = Math.max(P, Math.min(F, I.min)), z = Math.max(P, Math.min(F, I.max)), B = e.useMemo(() => {
|
|
2290
|
+
if (f) return f;
|
|
2291
|
+
let e = Math.max(_t(P), _t(F)), n = y?.[t];
|
|
2054
2292
|
if (Array.isArray(n)) for (let t of n) e = Math.max(e, _t(Number(t.key)));
|
|
2055
2293
|
return e === 0 ? 1 : Number((10 ** -e).toFixed(e));
|
|
2056
2294
|
}, [
|
|
2057
|
-
|
|
2295
|
+
f,
|
|
2296
|
+
P,
|
|
2058
2297
|
F,
|
|
2059
|
-
I,
|
|
2060
2298
|
y,
|
|
2061
2299
|
t
|
|
2062
|
-
]), V = M &&
|
|
2300
|
+
]), V = M && P === F, H = V ? r : P, U = V ? i : F, W = xt(U + B, H, B), G = (e) => Math.min(W, Math.max(H, e)), K = m?.[t], ee = s && K !== void 0 ? Q.active : void 0, q = K ? K.min : P, te = K ? K.max : F, ne = K !== void 0, J = R !== P || z !== F, [Y, X] = e.useState([q, te]), [re, ie] = e.useState(!1), [ae, Z] = e.useState(!1), [oe, se] = e.useState(String(q)), [ce, le] = e.useState(String(te)), ue = e.useMemo(() => {
|
|
2063
2301
|
let e = _t(B);
|
|
2064
|
-
return { width: `calc(${Math.max(3,
|
|
2302
|
+
return { width: `calc(${Math.max(3, P.toFixed(e).length, F.toFixed(e).length, oe.length, ce.length) + 1}ch + 20px)` };
|
|
2065
2303
|
}, [
|
|
2066
2304
|
B,
|
|
2305
|
+
P,
|
|
2067
2306
|
F,
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
le
|
|
2307
|
+
oe,
|
|
2308
|
+
ce
|
|
2071
2309
|
]);
|
|
2072
2310
|
e.useEffect(() => {
|
|
2073
|
-
|
|
2074
|
-
}, [
|
|
2075
|
-
let { finalMin:
|
|
2076
|
-
let [e, t] =
|
|
2311
|
+
se(String(Y[0])), le(String(Y[1]));
|
|
2312
|
+
}, [Y]);
|
|
2313
|
+
let { finalMin: de, finalMax: fe, isValidMin: pe, isValidMax: me } = e.useMemo(() => {
|
|
2314
|
+
let [e, t] = Y, n = Math.max(P, Math.min(F, e)), r = Math.max(P, Math.min(F, t)), i = Math.min(n, r), a = Math.max(n, r);
|
|
2077
2315
|
return {
|
|
2078
2316
|
finalMin: i,
|
|
2079
2317
|
finalMax: a,
|
|
2080
|
-
isValidMin: i >=
|
|
2081
|
-
isValidMax: a <=
|
|
2318
|
+
isValidMin: i >= P && i <= a,
|
|
2319
|
+
isValidMax: a <= F && a >= i
|
|
2082
2320
|
};
|
|
2083
2321
|
}, [
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2322
|
+
Y,
|
|
2323
|
+
P,
|
|
2324
|
+
F
|
|
2087
2325
|
]);
|
|
2088
2326
|
e.useEffect(() => {
|
|
2089
2327
|
if (V) return;
|
|
2090
|
-
if (
|
|
2091
|
-
|
|
2328
|
+
if (Y[0] === P && Y[1] === F) {
|
|
2329
|
+
ie(!1), Z(!1);
|
|
2092
2330
|
return;
|
|
2093
2331
|
}
|
|
2094
2332
|
let e = C ?? 500, n = setTimeout(() => {
|
|
2095
|
-
|
|
2333
|
+
ie(!pe), Z(!me);
|
|
2096
2334
|
}, 300), r = setTimeout(() => {
|
|
2097
|
-
|
|
2335
|
+
pe && me && (de === P && fe === F ? T(t, !1) : w(t, de, fe));
|
|
2098
2336
|
}, e);
|
|
2099
2337
|
return () => {
|
|
2100
2338
|
clearTimeout(n), clearTimeout(r);
|
|
2101
2339
|
};
|
|
2102
2340
|
}, [
|
|
2341
|
+
de,
|
|
2103
2342
|
fe,
|
|
2104
2343
|
pe,
|
|
2105
2344
|
me,
|
|
2106
|
-
|
|
2345
|
+
P,
|
|
2107
2346
|
F,
|
|
2108
|
-
I,
|
|
2109
2347
|
t,
|
|
2110
|
-
|
|
2348
|
+
T,
|
|
2111
2349
|
w,
|
|
2112
2350
|
C,
|
|
2113
2351
|
V
|
|
2114
2352
|
]), e.useEffect(() => {
|
|
2115
|
-
|
|
2353
|
+
X([q, te]), ie(!1), Z(!1);
|
|
2116
2354
|
}, [
|
|
2117
|
-
|
|
2118
|
-
|
|
2355
|
+
q,
|
|
2356
|
+
te,
|
|
2119
2357
|
t
|
|
2120
2358
|
]);
|
|
2121
|
-
let
|
|
2359
|
+
let he = e.useCallback((e) => {
|
|
2122
2360
|
let t = yt(Math.min(e[0], e[1] - B), B);
|
|
2123
2361
|
return [t, yt(Math.max(e[1] - B, t), B)];
|
|
2124
|
-
}, [B]),
|
|
2362
|
+
}, [B]), ge = e.useCallback((e) => {
|
|
2125
2363
|
if (V) return;
|
|
2126
|
-
let [t, n] =
|
|
2127
|
-
|
|
2364
|
+
let [t, n] = he(e);
|
|
2365
|
+
X([Math.max(P, Math.min(z, t)), Math.max(R, Math.min(F, n))]);
|
|
2128
2366
|
}, [
|
|
2129
2367
|
V,
|
|
2130
|
-
|
|
2368
|
+
he,
|
|
2369
|
+
P,
|
|
2131
2370
|
F,
|
|
2132
|
-
I,
|
|
2133
2371
|
R,
|
|
2134
2372
|
z
|
|
2135
|
-
]),
|
|
2373
|
+
]), _e = e.useCallback((e) => {
|
|
2136
2374
|
if (V) return;
|
|
2137
|
-
let [n, r] =
|
|
2138
|
-
i ===
|
|
2375
|
+
let [n, r] = he(e), i = Math.max(P, Math.min(z, n)), a = Math.max(R, Math.min(F, r));
|
|
2376
|
+
i === P && a === F ? (X([P, F]), T(t, !0)) : X([i, a]);
|
|
2139
2377
|
}, [
|
|
2140
2378
|
V,
|
|
2141
|
-
|
|
2379
|
+
he,
|
|
2380
|
+
P,
|
|
2142
2381
|
F,
|
|
2143
|
-
I,
|
|
2144
2382
|
R,
|
|
2145
2383
|
z,
|
|
2146
2384
|
t,
|
|
2147
|
-
|
|
2148
|
-
]),
|
|
2385
|
+
T
|
|
2386
|
+
]), ve = e.useRef(null), be = e.useCallback((e, n) => {
|
|
2149
2387
|
if (V) return;
|
|
2150
|
-
let r =
|
|
2151
|
-
if (
|
|
2152
|
-
|
|
2388
|
+
let r = ve.current;
|
|
2389
|
+
if (K && r && r.start === e && r.last === n) {
|
|
2390
|
+
ve.current = null, X([P, F]), T(t, !0);
|
|
2153
2391
|
return;
|
|
2154
2392
|
}
|
|
2155
|
-
let i = bt(Math.max(
|
|
2156
|
-
|
|
2393
|
+
let i = bt(Math.max(P, R, e), P, B), a = Math.max(i, bt(Math.min(F, z, n), P, B));
|
|
2394
|
+
ve.current = {
|
|
2157
2395
|
start: e,
|
|
2158
2396
|
last: n
|
|
2159
|
-
},
|
|
2397
|
+
}, X([i, a]);
|
|
2160
2398
|
}, [
|
|
2161
2399
|
V,
|
|
2162
|
-
|
|
2400
|
+
K,
|
|
2401
|
+
P,
|
|
2163
2402
|
F,
|
|
2164
|
-
I,
|
|
2165
2403
|
R,
|
|
2166
2404
|
z,
|
|
2167
2405
|
B,
|
|
2168
2406
|
t,
|
|
2169
|
-
|
|
2170
|
-
]),
|
|
2407
|
+
T
|
|
2408
|
+
]), xe = e.useCallback(() => {
|
|
2171
2409
|
if (V) return;
|
|
2172
|
-
let e =
|
|
2410
|
+
let e = oe.trim(), t = e === "" ? NaN : Number(e);
|
|
2173
2411
|
if (isNaN(t)) {
|
|
2174
|
-
|
|
2412
|
+
se(String(Y[0]));
|
|
2175
2413
|
return;
|
|
2176
2414
|
}
|
|
2177
|
-
let n = Math.max(
|
|
2178
|
-
n <
|
|
2415
|
+
let n = Math.max(P, Math.min(z, t));
|
|
2416
|
+
n < Y[1] ? X([n, Y[1]]) : X([P, Y[1]]), se(String(n < Y[1] ? n : P));
|
|
2179
2417
|
}, [
|
|
2180
2418
|
V,
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2419
|
+
oe,
|
|
2420
|
+
Y,
|
|
2421
|
+
P,
|
|
2184
2422
|
z
|
|
2185
|
-
]),
|
|
2423
|
+
]), Se = e.useCallback(() => {
|
|
2186
2424
|
if (V) return;
|
|
2187
|
-
let e =
|
|
2425
|
+
let e = ce.trim(), t = e === "" ? NaN : Number(e);
|
|
2188
2426
|
if (isNaN(t)) {
|
|
2189
|
-
|
|
2427
|
+
le(String(Y[1]));
|
|
2190
2428
|
return;
|
|
2191
2429
|
}
|
|
2192
|
-
let n = Math.max(R, Math.min(
|
|
2193
|
-
n >
|
|
2430
|
+
let n = Math.max(R, Math.min(F, t));
|
|
2431
|
+
n > Y[0] ? X([Y[0], n]) : X([Y[0], F]), le(String(n > Y[0] ? n : F));
|
|
2194
2432
|
}, [
|
|
2195
2433
|
V,
|
|
2196
|
-
|
|
2197
|
-
|
|
2434
|
+
ce,
|
|
2435
|
+
Y,
|
|
2198
2436
|
R,
|
|
2199
|
-
|
|
2200
|
-
]),
|
|
2437
|
+
F
|
|
2438
|
+
]), Ce = (e) => (t) => {
|
|
2201
2439
|
t.key === "Enter" && e();
|
|
2202
|
-
}, [
|
|
2440
|
+
}, [we, Te] = e.useState(null), Ee = e.useRef(null);
|
|
2203
2441
|
e.useEffect(() => {
|
|
2204
2442
|
if (!u) return;
|
|
2205
|
-
let e = `${
|
|
2206
|
-
if (e ===
|
|
2443
|
+
let e = `${P}:${F}`;
|
|
2444
|
+
if (e === Ee.current && Ee.current !== null) return;
|
|
2207
2445
|
let n = y?.[t];
|
|
2208
2446
|
if (!Array.isArray(n) || n.length === 0) return;
|
|
2209
2447
|
let r = n.filter((e) => e.value != null && !isNaN(Number(e.key))).map((e) => ({
|
|
2210
2448
|
key: e.key,
|
|
2211
2449
|
value: e.value
|
|
2212
2450
|
}));
|
|
2213
|
-
r.length > 0 && (
|
|
2451
|
+
r.length > 0 && (Ee.current = e, Te(r));
|
|
2214
2452
|
}, [
|
|
2453
|
+
P,
|
|
2215
2454
|
F,
|
|
2216
|
-
I,
|
|
2217
2455
|
y,
|
|
2218
2456
|
t,
|
|
2219
2457
|
u
|
|
2220
2458
|
]);
|
|
2221
|
-
let
|
|
2222
|
-
if (!u || !
|
|
2223
|
-
let e =
|
|
2459
|
+
let De = e.useMemo(() => {
|
|
2460
|
+
if (!u || !we || we.length === 0) return [];
|
|
2461
|
+
let e = F - P;
|
|
2224
2462
|
if (e <= 0) return [];
|
|
2225
2463
|
let t = d ?? Math.max(B, yt(Math.ceil(e / 20 / B) * B, B)), n = Math.ceil(e / t);
|
|
2226
2464
|
return Array.from({ length: n }, (e, r) => {
|
|
2227
|
-
let i =
|
|
2465
|
+
let i = P + r * t, a = P + (r + 1) * t, o = r === n - 1, s = we.filter((e) => {
|
|
2228
2466
|
let t = Number(e.key);
|
|
2229
|
-
return t >= i && (t < a || o && t <=
|
|
2230
|
-
}).reduce((e, t) => e + t.value, 0), c = o ?
|
|
2467
|
+
return t >= i && (t < a || o && t <= F);
|
|
2468
|
+
}).reduce((e, t) => e + t.value, 0), c = o ? F : yt(a - B, B);
|
|
2231
2469
|
return {
|
|
2232
2470
|
bucketStart: i,
|
|
2233
2471
|
bucketEnd: a,
|
|
@@ -2241,91 +2479,91 @@ var St = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
2241
2479
|
}));
|
|
2242
2480
|
}, [
|
|
2243
2481
|
u,
|
|
2244
|
-
|
|
2482
|
+
we,
|
|
2483
|
+
P,
|
|
2245
2484
|
F,
|
|
2246
|
-
I,
|
|
2247
2485
|
d,
|
|
2248
2486
|
B,
|
|
2249
2487
|
W
|
|
2250
|
-
]),
|
|
2251
|
-
return u && !A && !x?.includes(t) && console.warn(`RangeFilterPanel: showHistogram=true but field "${t}" is not facetable. Add .Facetable = true to this field.`),
|
|
2488
|
+
]), Oe = e.useMemo(() => Math.max(...De.map((e) => e.count), 1), [De]);
|
|
2489
|
+
return u && !A && !x?.includes(t) && console.warn(`RangeFilterPanel: showHistogram=true but field "${t}" is not facetable. Add .Facetable = true to this field.`), D ? null : A ? /* @__PURE__ */ h(ft, {
|
|
2252
2490
|
title: n,
|
|
2253
2491
|
variant: "slider",
|
|
2254
2492
|
withHistogram: u,
|
|
2255
2493
|
collapsible: c,
|
|
2256
2494
|
startCollapsed: l
|
|
2257
|
-
}) : !
|
|
2495
|
+
}) : !E && !S ? null : b?.includes(t) ? j === "slider" ? /* @__PURE__ */ g(O, {
|
|
2258
2496
|
title: n,
|
|
2259
2497
|
collapsed: l,
|
|
2260
2498
|
collapsible: c,
|
|
2261
|
-
className:
|
|
2499
|
+
className: ee,
|
|
2262
2500
|
children: [
|
|
2263
|
-
V && /* @__PURE__ */
|
|
2501
|
+
V && /* @__PURE__ */ g("div", {
|
|
2264
2502
|
className: Q.disabledMessage,
|
|
2265
2503
|
children: [
|
|
2266
2504
|
"No adjustable range (all results have the same value: ",
|
|
2267
|
-
|
|
2505
|
+
P,
|
|
2268
2506
|
")."
|
|
2269
2507
|
]
|
|
2270
2508
|
}),
|
|
2271
|
-
u &&
|
|
2272
|
-
u &&
|
|
2273
|
-
let [e, t] = z > R && (R >
|
|
2509
|
+
u && De.length === 0 && /* @__PURE__ */ h("div", { className: Q.histogram }),
|
|
2510
|
+
u && De.length > 0 && (() => {
|
|
2511
|
+
let [e, t] = z > R && (R > P || z < F) ? [R, z] : [H, U], n = Math.max(de, e), r = Math.min(fe, 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)})`, f = `inset(0 ${u(s(t))} 0 ${u(o(e))})`, p = (n) => n.last < e || n.bucketStart > t, m = De.slice(1).map((e) => u((e.bucketStart - H) / a)), _ = De.map((e) => ({
|
|
2274
2512
|
...e,
|
|
2275
|
-
height: Math.max(1, Math.ceil(e.count /
|
|
2513
|
+
height: Math.max(1, Math.ceil(e.count / Oe * 20))
|
|
2276
2514
|
}));
|
|
2277
|
-
return /* @__PURE__ */
|
|
2515
|
+
return /* @__PURE__ */ g("div", {
|
|
2278
2516
|
className: Q.histogram,
|
|
2279
2517
|
children: [
|
|
2280
|
-
/* @__PURE__ */
|
|
2518
|
+
/* @__PURE__ */ h("div", {
|
|
2281
2519
|
className: Q.histogramLayer,
|
|
2282
|
-
children: _.map((e, t) => /* @__PURE__ */
|
|
2520
|
+
children: _.map((e, t) => /* @__PURE__ */ h("button", {
|
|
2283
2521
|
type: "button",
|
|
2284
2522
|
className: Q.histogramBar,
|
|
2285
2523
|
style: { flexGrow: e.span },
|
|
2286
2524
|
"data-testid": "histogram-bar",
|
|
2287
|
-
disabled: V ||
|
|
2525
|
+
disabled: V || p(e),
|
|
2288
2526
|
"aria-label": `${e.bucketStart} to ${e.last}: ${e.count}`,
|
|
2289
2527
|
title: `${e.bucketStart} to ${e.last}: ${e.count}`,
|
|
2290
|
-
onClick: () =>
|
|
2291
|
-
children: /* @__PURE__ */
|
|
2528
|
+
onClick: () => be(e.bucketStart, e.last),
|
|
2529
|
+
children: /* @__PURE__ */ h("span", {
|
|
2292
2530
|
className: Q.histogramFill,
|
|
2293
2531
|
style: { height: `${e.height}px` }
|
|
2294
2532
|
})
|
|
2295
2533
|
}, t))
|
|
2296
2534
|
}),
|
|
2297
|
-
/* @__PURE__ */
|
|
2535
|
+
/* @__PURE__ */ h("div", {
|
|
2298
2536
|
className: `${Q.histogramLayer} ${Q.histogramLive}`,
|
|
2299
2537
|
"aria-hidden": "true",
|
|
2300
2538
|
"data-testid": "histogram-live",
|
|
2301
|
-
style: { clipPath:
|
|
2302
|
-
children: _.map((e, t) => /* @__PURE__ */
|
|
2539
|
+
style: { clipPath: f },
|
|
2540
|
+
children: _.map((e, t) => /* @__PURE__ */ h("span", {
|
|
2303
2541
|
className: Q.histogramBar,
|
|
2304
2542
|
style: { flexGrow: e.span },
|
|
2305
|
-
children: /* @__PURE__ */
|
|
2543
|
+
children: /* @__PURE__ */ h("span", {
|
|
2306
2544
|
className: Q.histogramFill,
|
|
2307
2545
|
style: { height: `${e.height}px` }
|
|
2308
2546
|
})
|
|
2309
2547
|
}, t))
|
|
2310
2548
|
}),
|
|
2311
|
-
/* @__PURE__ */
|
|
2549
|
+
/* @__PURE__ */ h("div", {
|
|
2312
2550
|
className: `${Q.histogramLayer} ${Q.histogramLit}`,
|
|
2313
2551
|
"aria-hidden": "true",
|
|
2314
2552
|
"data-testid": "histogram-lit",
|
|
2315
2553
|
style: { clipPath: d },
|
|
2316
|
-
children: _.map((e, t) => /* @__PURE__ */
|
|
2554
|
+
children: _.map((e, t) => /* @__PURE__ */ h("span", {
|
|
2317
2555
|
className: Q.histogramBar,
|
|
2318
2556
|
style: { flexGrow: e.span },
|
|
2319
|
-
children: /* @__PURE__ */
|
|
2557
|
+
children: /* @__PURE__ */ h("span", {
|
|
2320
2558
|
className: Q.histogramFill,
|
|
2321
2559
|
style: { height: `${e.height}px` }
|
|
2322
2560
|
})
|
|
2323
2561
|
}, t))
|
|
2324
2562
|
}),
|
|
2325
|
-
/* @__PURE__ */
|
|
2563
|
+
/* @__PURE__ */ h("div", {
|
|
2326
2564
|
className: Q.histogramSeparators,
|
|
2327
2565
|
"aria-hidden": "true",
|
|
2328
|
-
children:
|
|
2566
|
+
children: m.map((e, t) => /* @__PURE__ */ h("span", {
|
|
2329
2567
|
className: Q.histogramSeparator,
|
|
2330
2568
|
style: { left: e }
|
|
2331
2569
|
}, t))
|
|
@@ -2333,102 +2571,102 @@ var St = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
2333
2571
|
]
|
|
2334
2572
|
});
|
|
2335
2573
|
})(),
|
|
2336
|
-
/* @__PURE__ */
|
|
2574
|
+
/* @__PURE__ */ h("div", {
|
|
2337
2575
|
style: { padding: "10px 10px 20px 10px" },
|
|
2338
|
-
children: /* @__PURE__ */
|
|
2576
|
+
children: /* @__PURE__ */ h(L, {
|
|
2339
2577
|
min: H,
|
|
2340
2578
|
max: W,
|
|
2341
2579
|
step: B,
|
|
2342
|
-
stepMarks:
|
|
2343
|
-
value: V ? [H, W] : [
|
|
2580
|
+
stepMarks: p,
|
|
2581
|
+
value: V ? [H, W] : [G(bt(de, H, B)), G(bt(fe + B, H, B))],
|
|
2344
2582
|
isRange: !0,
|
|
2345
|
-
onChange: (e) =>
|
|
2346
|
-
onFinalChange: (e) =>
|
|
2583
|
+
onChange: (e) => ge(e),
|
|
2584
|
+
onFinalChange: (e) => _e(e),
|
|
2347
2585
|
disabled: V,
|
|
2348
2586
|
activeMin: R,
|
|
2349
|
-
activeMax:
|
|
2350
|
-
isFaceted:
|
|
2351
|
-
highlightFaceted:
|
|
2587
|
+
activeMax: G(yt(z + B, B)),
|
|
2588
|
+
isFaceted: J,
|
|
2589
|
+
highlightFaceted: ne,
|
|
2352
2590
|
"aria-label": n || `Filter by ${t}`
|
|
2353
2591
|
})
|
|
2354
2592
|
}),
|
|
2355
|
-
/* @__PURE__ */
|
|
2593
|
+
/* @__PURE__ */ g("div", {
|
|
2356
2594
|
style: {
|
|
2357
2595
|
display: "flex",
|
|
2358
2596
|
gap: "10px",
|
|
2359
2597
|
alignItems: "flex-start",
|
|
2360
2598
|
justifyContent: "space-between"
|
|
2361
2599
|
},
|
|
2362
|
-
children: [/* @__PURE__ */
|
|
2600
|
+
children: [/* @__PURE__ */ h(k, {
|
|
2363
2601
|
label: "Min:",
|
|
2364
2602
|
type: "number",
|
|
2365
|
-
style:
|
|
2366
|
-
value: V ? String(
|
|
2367
|
-
min:
|
|
2368
|
-
max: yt(Math.min(z,
|
|
2369
|
-
onChange: (e) =>
|
|
2370
|
-
onBlur:
|
|
2371
|
-
onKeyDown:
|
|
2603
|
+
style: ue,
|
|
2604
|
+
value: V ? String(P) : oe,
|
|
2605
|
+
min: P,
|
|
2606
|
+
max: yt(Math.min(z, Y[1] - B), B),
|
|
2607
|
+
onChange: (e) => se(e.target.value),
|
|
2608
|
+
onBlur: xe,
|
|
2609
|
+
onKeyDown: Ce(xe),
|
|
2372
2610
|
disabled: V,
|
|
2373
|
-
isValid: V || !
|
|
2374
|
-
}), /* @__PURE__ */
|
|
2611
|
+
isValid: V || !re
|
|
2612
|
+
}), /* @__PURE__ */ h(k, {
|
|
2375
2613
|
label: "Max:",
|
|
2376
2614
|
type: "number",
|
|
2377
|
-
style:
|
|
2378
|
-
value: V ? String(
|
|
2379
|
-
min: yt(Math.max(R,
|
|
2380
|
-
max:
|
|
2381
|
-
onChange: (e) =>
|
|
2382
|
-
onBlur:
|
|
2383
|
-
onKeyDown:
|
|
2615
|
+
style: ue,
|
|
2616
|
+
value: V ? String(F) : ce,
|
|
2617
|
+
min: yt(Math.max(R, Y[0] + B), B),
|
|
2618
|
+
max: F,
|
|
2619
|
+
onChange: (e) => le(e.target.value),
|
|
2620
|
+
onBlur: Se,
|
|
2621
|
+
onKeyDown: Ce(Se),
|
|
2384
2622
|
disabled: V,
|
|
2385
2623
|
isValid: V || !ae
|
|
2386
2624
|
})]
|
|
2387
2625
|
})
|
|
2388
2626
|
]
|
|
2389
|
-
}) : /* @__PURE__ */
|
|
2627
|
+
}) : /* @__PURE__ */ g(O, {
|
|
2390
2628
|
title: n,
|
|
2391
|
-
className:
|
|
2392
|
-
children: [V && /* @__PURE__ */
|
|
2629
|
+
className: ee,
|
|
2630
|
+
children: [V && /* @__PURE__ */ g("div", {
|
|
2393
2631
|
className: Q.disabledMessage,
|
|
2394
2632
|
children: [
|
|
2395
2633
|
"No adjustable range (all results have the same value: ",
|
|
2396
|
-
|
|
2634
|
+
P,
|
|
2397
2635
|
")."
|
|
2398
2636
|
]
|
|
2399
|
-
}), /* @__PURE__ */
|
|
2637
|
+
}), /* @__PURE__ */ g("div", {
|
|
2400
2638
|
style: {
|
|
2401
2639
|
display: "flex",
|
|
2402
2640
|
gap: "10px",
|
|
2403
2641
|
alignItems: "flex-start"
|
|
2404
2642
|
},
|
|
2405
|
-
children: [/* @__PURE__ */
|
|
2643
|
+
children: [/* @__PURE__ */ h(k, {
|
|
2406
2644
|
label: "Min:",
|
|
2407
2645
|
type: "number",
|
|
2408
|
-
style:
|
|
2409
|
-
value: V ? String(
|
|
2410
|
-
min:
|
|
2411
|
-
max: yt(Math.min(z,
|
|
2412
|
-
onChange: (e) =>
|
|
2413
|
-
onBlur:
|
|
2414
|
-
onKeyDown:
|
|
2646
|
+
style: ue,
|
|
2647
|
+
value: V ? String(P) : oe,
|
|
2648
|
+
min: P,
|
|
2649
|
+
max: yt(Math.min(z, Y[1] - B), B),
|
|
2650
|
+
onChange: (e) => se(e.target.value),
|
|
2651
|
+
onBlur: xe,
|
|
2652
|
+
onKeyDown: Ce(xe),
|
|
2415
2653
|
disabled: V,
|
|
2416
|
-
isValid: V || !
|
|
2417
|
-
}), /* @__PURE__ */
|
|
2654
|
+
isValid: V || !re
|
|
2655
|
+
}), /* @__PURE__ */ h(k, {
|
|
2418
2656
|
label: "Max:",
|
|
2419
2657
|
type: "number",
|
|
2420
|
-
style:
|
|
2421
|
-
value: V ? String(
|
|
2422
|
-
min: yt(Math.max(R,
|
|
2423
|
-
max:
|
|
2424
|
-
onChange: (e) =>
|
|
2425
|
-
onBlur:
|
|
2426
|
-
onKeyDown:
|
|
2658
|
+
style: ue,
|
|
2659
|
+
value: V ? String(F) : ce,
|
|
2660
|
+
min: yt(Math.max(R, Y[0] + B), B),
|
|
2661
|
+
max: F,
|
|
2662
|
+
onChange: (e) => le(e.target.value),
|
|
2663
|
+
onBlur: Se,
|
|
2664
|
+
onKeyDown: Ce(Se),
|
|
2427
2665
|
disabled: V,
|
|
2428
2666
|
isValid: V || !ae
|
|
2429
2667
|
})]
|
|
2430
2668
|
})]
|
|
2431
|
-
}) : /* @__PURE__ */
|
|
2669
|
+
}) : /* @__PURE__ */ h(ht, {
|
|
2432
2670
|
label: n,
|
|
2433
2671
|
field: t,
|
|
2434
2672
|
missing: ["filterable"]
|
|
@@ -2454,12 +2692,12 @@ function wt(e, t) {
|
|
|
2454
2692
|
}
|
|
2455
2693
|
return r ? n : 0;
|
|
2456
2694
|
}
|
|
2457
|
-
var Tt = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a, layout: c = "list", showCount: u = !0, showEmpty: d = !1, limit:
|
|
2458
|
-
let { state: { facets: v, filterableFields:
|
|
2695
|
+
var Tt = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a, layout: c = "list", showCount: u = !0, showEmpty: d = !1, limit: f, showActivePanel: p = !1, collapsible: m = !0, startCollapsed: _ = !1 }) => {
|
|
2696
|
+
let { state: { facets: v, filterableFields: y, facetableFields: b, bucketFilters: x, rangeBounds: w, facetStats: T, query: E }, toggleBucketFilter: D, authError: k, isFetchingInitial: A, allowEmptySearch: j } = ye(), N = i ?? a ?? "checkbox", P = v?.[e], F = x[e] ?? [], [I, L] = l(f ?? Infinity);
|
|
2459
2697
|
o(() => {
|
|
2460
|
-
L(
|
|
2461
|
-
}, [
|
|
2462
|
-
let R = w?.[e] ??
|
|
2698
|
+
L(f ?? Infinity);
|
|
2699
|
+
}, [f, P]);
|
|
2700
|
+
let R = w?.[e] ?? T?.[e], z = s(() => {
|
|
2463
2701
|
let e = [];
|
|
2464
2702
|
if (R && e.push(R.min, R.max), Array.isArray(P)) for (let t of P) e.push(Number(t.key));
|
|
2465
2703
|
return vt(e.filter(Number.isFinite));
|
|
@@ -2490,28 +2728,28 @@ var Tt = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
2490
2728
|
R,
|
|
2491
2729
|
z
|
|
2492
2730
|
]);
|
|
2493
|
-
if (
|
|
2494
|
-
if (
|
|
2731
|
+
if (k) return null;
|
|
2732
|
+
if (A || !v) return /* @__PURE__ */ h(ft, {
|
|
2495
2733
|
title: t,
|
|
2496
2734
|
rows: Math.max(1, Math.min(B.length || 5, 8)),
|
|
2497
|
-
collapsible:
|
|
2735
|
+
collapsible: m,
|
|
2498
2736
|
startCollapsed: _
|
|
2499
2737
|
});
|
|
2500
|
-
if (!
|
|
2501
|
-
if (!
|
|
2738
|
+
if (!j && !E) return null;
|
|
2739
|
+
if (!y?.includes(e)) return /* @__PURE__ */ h(ht, {
|
|
2502
2740
|
label: t,
|
|
2503
2741
|
field: e,
|
|
2504
2742
|
missing: ["filterable"]
|
|
2505
2743
|
});
|
|
2506
|
-
let V =
|
|
2744
|
+
let V = b?.includes(e) && Array.isArray(P), H = (e) => F.some((t) => t.min === e.range.min && t.max === e.range.max), U = B.map((e) => ({
|
|
2507
2745
|
bucket: e,
|
|
2508
2746
|
count: V ? wt(e, P) : null
|
|
2509
2747
|
}));
|
|
2510
2748
|
if (d || (U = U.filter((e) => e.count !== 0 || H(e.bucket))), U.length === 0) return null;
|
|
2511
|
-
let W = U.slice(0, I),
|
|
2512
|
-
let r = H(t), i = n === 0 && !r, a = u && (n ?? 0) > 0 ? `${n}` : "", o = () =>
|
|
2749
|
+
let W = U.slice(0, I), G = (t, n) => {
|
|
2750
|
+
let r = H(t), i = n === 0 && !r, a = u && (n ?? 0) > 0 ? `${n}` : "", o = () => D(e, t.range, N === "radio");
|
|
2513
2751
|
if (N === "radio") {
|
|
2514
|
-
let n = /* @__PURE__ */
|
|
2752
|
+
let n = /* @__PURE__ */ h(M, {
|
|
2515
2753
|
id: `${e}-${t.range.min}-${t.range.max}`,
|
|
2516
2754
|
name: e,
|
|
2517
2755
|
value: t.label,
|
|
@@ -2520,16 +2758,16 @@ var Tt = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
2520
2758
|
onChange: o,
|
|
2521
2759
|
disabled: i
|
|
2522
2760
|
});
|
|
2523
|
-
return c === "list" ? /* @__PURE__ */
|
|
2761
|
+
return c === "list" ? /* @__PURE__ */ g("div", {
|
|
2524
2762
|
className: Ct.count,
|
|
2525
|
-
children: [n, /* @__PURE__ */
|
|
2763
|
+
children: [n, /* @__PURE__ */ h("span", {
|
|
2526
2764
|
className: Ct.countValue,
|
|
2527
2765
|
children: a
|
|
2528
2766
|
})]
|
|
2529
2767
|
}) : n;
|
|
2530
2768
|
}
|
|
2531
2769
|
if (N === "button") {
|
|
2532
|
-
let e = /* @__PURE__ */
|
|
2770
|
+
let e = /* @__PURE__ */ h(S, {
|
|
2533
2771
|
variant: r ? "primary" : "secondary",
|
|
2534
2772
|
onClick: o,
|
|
2535
2773
|
disabled: i,
|
|
@@ -2537,27 +2775,27 @@ var Tt = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
2537
2775
|
className: Ct.chip,
|
|
2538
2776
|
children: c === "grid" && a ? `${t.label} (${a})` : t.label
|
|
2539
2777
|
});
|
|
2540
|
-
return c === "list" ? /* @__PURE__ */
|
|
2778
|
+
return c === "list" ? /* @__PURE__ */ g("div", {
|
|
2541
2779
|
className: Ct.count,
|
|
2542
|
-
children: [e, /* @__PURE__ */
|
|
2780
|
+
children: [e, /* @__PURE__ */ h("span", {
|
|
2543
2781
|
className: Ct.countValue,
|
|
2544
2782
|
children: a
|
|
2545
2783
|
})]
|
|
2546
2784
|
}) : e;
|
|
2547
2785
|
}
|
|
2548
|
-
return c === "list" ? /* @__PURE__ */
|
|
2786
|
+
return c === "list" ? /* @__PURE__ */ g("div", {
|
|
2549
2787
|
className: Ct.count,
|
|
2550
|
-
children: [/* @__PURE__ */
|
|
2788
|
+
children: [/* @__PURE__ */ h(C, {
|
|
2551
2789
|
label: t.label,
|
|
2552
2790
|
score: "",
|
|
2553
2791
|
checked: r,
|
|
2554
2792
|
onChange: o,
|
|
2555
2793
|
disabled: i
|
|
2556
|
-
}), /* @__PURE__ */
|
|
2794
|
+
}), /* @__PURE__ */ h("span", {
|
|
2557
2795
|
className: Ct.countValue,
|
|
2558
2796
|
children: a
|
|
2559
2797
|
})]
|
|
2560
|
-
}) : /* @__PURE__ */
|
|
2798
|
+
}) : /* @__PURE__ */ h(C, {
|
|
2561
2799
|
label: t.label,
|
|
2562
2800
|
score: a ? ` (${a})` : "",
|
|
2563
2801
|
checked: r,
|
|
@@ -2565,19 +2803,19 @@ var Tt = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
2565
2803
|
disabled: i
|
|
2566
2804
|
});
|
|
2567
2805
|
};
|
|
2568
|
-
return /* @__PURE__ */
|
|
2806
|
+
return /* @__PURE__ */ h(O, {
|
|
2569
2807
|
title: t,
|
|
2570
|
-
collapsible:
|
|
2571
|
-
collapsed:
|
|
2572
|
-
className:
|
|
2573
|
-
children: /* @__PURE__ */
|
|
2808
|
+
collapsible: m,
|
|
2809
|
+
collapsed: m ? _ : !1,
|
|
2810
|
+
className: p && F.length > 0 ? Ct.active : void 0,
|
|
2811
|
+
children: /* @__PURE__ */ g("ul", {
|
|
2574
2812
|
className: c === "grid" ? Ct.grid : Ct.list,
|
|
2575
2813
|
style: {
|
|
2576
2814
|
listStyle: "none",
|
|
2577
2815
|
padding: 0,
|
|
2578
2816
|
margin: 0
|
|
2579
2817
|
},
|
|
2580
|
-
children: [W.map(({ bucket: e, count: t }) => /* @__PURE__ */
|
|
2818
|
+
children: [W.map(({ bucket: e, count: t }) => /* @__PURE__ */ h("li", { children: G(e, t) }, `${e.range.min}-${e.range.max}`)), W.length < U.length && /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(S, {
|
|
2581
2819
|
variant: "ghost",
|
|
2582
2820
|
size: "micro",
|
|
2583
2821
|
onClick: () => L(U.length),
|
|
@@ -2589,15 +2827,15 @@ var Tt = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
2589
2827
|
select: "_select_nwf7i_1",
|
|
2590
2828
|
radioGroup: "_radioGroup_nwf7i_6"
|
|
2591
2829
|
}, Dt = ({ options: e, noneLabel: t = "None", control: n, displayType: r, collapsible: i = !0, startCollapsed: a = !1 }) => {
|
|
2592
|
-
let o = n ?? (r === "radio" ? "radio" : "select"), { state: { sortableFields: s, sortBy: c, sortAscending: l }, setSort: u, isFetchingInitial: d } =
|
|
2593
|
-
if (d) return /* @__PURE__ */
|
|
2830
|
+
let o = n ?? (r === "radio" ? "radio" : "select"), { state: { sortableFields: s, sortBy: c, sortAscending: l }, setSort: u, isFetchingInitial: d } = ye();
|
|
2831
|
+
if (d) return /* @__PURE__ */ h(ft, {
|
|
2594
2832
|
title: "Sort by",
|
|
2595
2833
|
rows: o === "radio" ? 3 : 1,
|
|
2596
2834
|
collapsible: i,
|
|
2597
2835
|
startCollapsed: a
|
|
2598
2836
|
});
|
|
2599
2837
|
if (!s || s.length === 0) return null;
|
|
2600
|
-
let
|
|
2838
|
+
let f = c ? `${c}:${l ? "asc" : "desc"}` : "none", p = e ? e.filter((e) => s.includes(e.field) ? !0 : (console.warn(`[SortByPanel] '${e.field}' is not sortable, so "${e.label}" is left out. Mark the field Sortable in the dataset's field configuration.`), !1)).map((e) => ({
|
|
2601
2839
|
label: e.label,
|
|
2602
2840
|
value: `${e.field}:${e.ascending ? "asc" : "desc"}`
|
|
2603
2841
|
})) : s.flatMap((e) => [{
|
|
@@ -2606,60 +2844,64 @@ var Tt = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
2606
2844
|
}, {
|
|
2607
2845
|
label: `${e} (desc)`,
|
|
2608
2846
|
value: `${e}:desc`
|
|
2609
|
-
}]),
|
|
2847
|
+
}]), m = t === null ? p : [{
|
|
2610
2848
|
label: t,
|
|
2611
2849
|
value: "none"
|
|
2612
|
-
}, ...
|
|
2850
|
+
}, ...p], g = (e) => {
|
|
2613
2851
|
if (e === "none" || e === "") u(null, !0);
|
|
2614
2852
|
else {
|
|
2615
2853
|
let [t, n] = e.split(":");
|
|
2616
2854
|
u(t, n === "asc");
|
|
2617
2855
|
}
|
|
2618
2856
|
};
|
|
2619
|
-
return /* @__PURE__ */
|
|
2857
|
+
return /* @__PURE__ */ h(O, {
|
|
2620
2858
|
title: "Sort by",
|
|
2621
2859
|
collapsible: i,
|
|
2622
2860
|
collapsed: i ? a : !1,
|
|
2623
|
-
children: o === "select" ? /* @__PURE__ */
|
|
2624
|
-
value:
|
|
2861
|
+
children: o === "select" ? /* @__PURE__ */ h(P, {
|
|
2862
|
+
value: f,
|
|
2625
2863
|
onValueChange: g,
|
|
2626
|
-
options:
|
|
2864
|
+
options: m,
|
|
2627
2865
|
placeholder: "Select sort...",
|
|
2628
2866
|
"aria-label": "Sort by"
|
|
2629
|
-
}) : /* @__PURE__ */
|
|
2867
|
+
}) : /* @__PURE__ */ h("div", {
|
|
2630
2868
|
className: Et.radioGroup,
|
|
2631
|
-
children:
|
|
2869
|
+
children: m.map((e) => /* @__PURE__ */ h(M, {
|
|
2632
2870
|
id: `sort-${e.value}`,
|
|
2633
2871
|
name: "sort-by",
|
|
2634
2872
|
value: e.value,
|
|
2635
2873
|
label: e.label,
|
|
2636
|
-
checked:
|
|
2874
|
+
checked: f === e.value,
|
|
2637
2875
|
onChange: (e) => g(e.target.value)
|
|
2638
2876
|
}, e.value))
|
|
2639
2877
|
})
|
|
2640
2878
|
});
|
|
2641
2879
|
}, Ot = { list: "_list_1y4fk_1" }, kt = {
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2880
|
+
tolerance: p.TwoEdits,
|
|
2881
|
+
rungs: u.Fewest,
|
|
2882
|
+
oneEditFrom: 3,
|
|
2883
|
+
twoEditsFrom: 6,
|
|
2884
|
+
threeEditsFrom: 9,
|
|
2885
|
+
typingPrefixFrom: 3,
|
|
2886
|
+
typingPrefixOneEditFrom: 6,
|
|
2887
|
+
joinedWords: !0
|
|
2888
|
+
}, At = {
|
|
2889
|
+
candidatesPerRow: 4,
|
|
2890
|
+
fallback: !0,
|
|
2891
|
+
rest: !1
|
|
2892
|
+
}, jt = {
|
|
2893
|
+
rerank: !0,
|
|
2894
|
+
share: .2,
|
|
2895
|
+
typingShift: .5,
|
|
2896
|
+
wholeQueryFloor: !0
|
|
2655
2897
|
};
|
|
2656
|
-
function
|
|
2657
|
-
let { state: { searchSettings: e }, setSearchSettings: t, url: n, team: r, dataset: i, authenticatedFetch: a } =
|
|
2898
|
+
function Mt() {
|
|
2899
|
+
let { state: { searchSettings: e }, setSearchSettings: t, url: n, team: r, dataset: i, authenticatedFetch: a } = ye(), [s, c] = l(!1), { match: f, candidates: _, ranking: v } = e, [y, b] = l(null);
|
|
2658
2900
|
o(() => {
|
|
2659
2901
|
let e = !0;
|
|
2660
2902
|
try {
|
|
2661
2903
|
a(`${n}/api/teams/${r}/datasets/${i}/query-parameters`).then((e) => e.ok ? e.json() : null).then((t) => {
|
|
2662
|
-
e && t?.effective &&
|
|
2904
|
+
e && t?.effective && b(t.effective);
|
|
2663
2905
|
}).catch(() => {});
|
|
2664
2906
|
} catch {}
|
|
2665
2907
|
return () => {
|
|
@@ -2671,42 +2913,62 @@ function At() {
|
|
|
2671
2913
|
i,
|
|
2672
2914
|
a
|
|
2673
2915
|
]);
|
|
2674
|
-
let
|
|
2916
|
+
let x = (e) => Object.fromEntries(Object.entries(e ?? {}).filter(([, e]) => e != null)), C = {
|
|
2917
|
+
...kt,
|
|
2918
|
+
...x(y?.match)
|
|
2919
|
+
}, w = {
|
|
2920
|
+
...At,
|
|
2921
|
+
...x(y?.candidates)
|
|
2922
|
+
}, T = {
|
|
2923
|
+
...jt,
|
|
2924
|
+
...x(y?.ranking)
|
|
2925
|
+
}, E = e.mode ?? y?.mode ?? d.EditDistance, D = E === d.Bm25f, A = v.rerank ?? T.rerank, j = D && !A, M = e.mode !== void 0 || [
|
|
2926
|
+
f,
|
|
2927
|
+
_,
|
|
2928
|
+
v
|
|
2929
|
+
].some((e) => Object.values(e ?? {}).some((e) => e != null)), N = (e, n) => {
|
|
2675
2930
|
let r = parseInt(n, 10);
|
|
2676
2931
|
isNaN(r) || t({ [e]: r });
|
|
2677
|
-
},
|
|
2932
|
+
}, F = (e, n) => {
|
|
2678
2933
|
t({ [e]: n });
|
|
2679
|
-
},
|
|
2680
|
-
let
|
|
2681
|
-
isNaN(
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
}, O = (n, r) => {
|
|
2686
|
-
t({ coverageSetup: {
|
|
2687
|
-
...e.coverageSetup,
|
|
2688
|
-
[n]: r
|
|
2689
|
-
} });
|
|
2934
|
+
}, I = (e) => t({ match: e }), R = (e) => t({ candidates: e }), B = (e) => t({ ranking: e }), V = (e, t) => {
|
|
2935
|
+
let n = parseInt(e, 10);
|
|
2936
|
+
isNaN(n) || t(n);
|
|
2937
|
+
}, H = (e, t) => {
|
|
2938
|
+
let n = parseFloat(e);
|
|
2939
|
+
isNaN(n) || t(Math.max(0, Math.min(100, n)) / 100);
|
|
2690
2940
|
};
|
|
2691
|
-
return /* @__PURE__ */
|
|
2941
|
+
return /* @__PURE__ */ h(O, {
|
|
2692
2942
|
collapsed: !0,
|
|
2693
2943
|
title: "Settings",
|
|
2694
|
-
children: /* @__PURE__ */
|
|
2944
|
+
children: /* @__PURE__ */ g("ul", {
|
|
2695
2945
|
className: Ot.list,
|
|
2696
2946
|
children: [
|
|
2697
|
-
/* @__PURE__ */
|
|
2947
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(P, {
|
|
2948
|
+
label: "Mode",
|
|
2949
|
+
size: "micro",
|
|
2950
|
+
value: E,
|
|
2951
|
+
onValueChange: (e) => t({ mode: e }),
|
|
2952
|
+
options: [{
|
|
2953
|
+
label: "Edit distance",
|
|
2954
|
+
value: d.EditDistance
|
|
2955
|
+
}, {
|
|
2956
|
+
label: "BM25F",
|
|
2957
|
+
value: d.Bm25f
|
|
2958
|
+
}]
|
|
2959
|
+
}) }),
|
|
2960
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(z, {
|
|
2961
|
+
label: "Rerank (Coverage)",
|
|
2962
|
+
checked: A,
|
|
2963
|
+
onChange: (e) => B({ rerank: e })
|
|
2964
|
+
}) }),
|
|
2965
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(k, {
|
|
2698
2966
|
label: "Max Results",
|
|
2699
2967
|
type: "number",
|
|
2700
2968
|
value: e.maxNumberOfRecordsToReturn.toString(),
|
|
2701
|
-
onChange: (e) =>
|
|
2702
|
-
}) }),
|
|
2703
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(E, {
|
|
2704
|
-
label: x("Coverage Depth", e.coverageDepth !== void 0),
|
|
2705
|
-
type: "number",
|
|
2706
|
-
value: v.toString(),
|
|
2707
|
-
onChange: (e) => C("coverageDepth", e.target.value)
|
|
2969
|
+
onChange: (e) => N("maxNumberOfRecordsToReturn", e.target.value)
|
|
2708
2970
|
}) }),
|
|
2709
|
-
/* @__PURE__ */
|
|
2971
|
+
/* @__PURE__ */ g("li", { children: [/* @__PURE__ */ h(k, {
|
|
2710
2972
|
label: "Minimum Score (16 bit)",
|
|
2711
2973
|
type: "number",
|
|
2712
2974
|
value: e.minimumScore.toString(),
|
|
@@ -2716,9 +2978,9 @@ function At() {
|
|
|
2716
2978
|
let n = parseFloat(e.target.value);
|
|
2717
2979
|
isNaN(n) || t({ minimumScore: n });
|
|
2718
2980
|
}
|
|
2719
|
-
}), /* @__PURE__ */
|
|
2981
|
+
}), /* @__PURE__ */ h("div", {
|
|
2720
2982
|
style: { padding: "10px 10px 20px 10px" },
|
|
2721
|
-
children: /* @__PURE__ */
|
|
2983
|
+
children: /* @__PURE__ */ h(L, {
|
|
2722
2984
|
min: 0,
|
|
2723
2985
|
max: 65535,
|
|
2724
2986
|
step: 1,
|
|
@@ -2729,7 +2991,7 @@ function At() {
|
|
|
2729
2991
|
"aria-label": "Minimum score"
|
|
2730
2992
|
})
|
|
2731
2993
|
})] }),
|
|
2732
|
-
/* @__PURE__ */
|
|
2994
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(k, {
|
|
2733
2995
|
label: "Placeholder text",
|
|
2734
2996
|
type: "text",
|
|
2735
2997
|
value: e.placeholderText,
|
|
@@ -2737,94 +2999,143 @@ function At() {
|
|
|
2737
2999
|
t({ placeholderText: e.target.value });
|
|
2738
3000
|
}
|
|
2739
3001
|
}) }),
|
|
2740
|
-
/* @__PURE__ */
|
|
3002
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(z, {
|
|
2741
3003
|
label: "Show score",
|
|
2742
3004
|
checked: e.showScore,
|
|
2743
|
-
onChange: (e) =>
|
|
3005
|
+
onChange: (e) => F("showScore", e)
|
|
2744
3006
|
}) }),
|
|
2745
|
-
/* @__PURE__ */
|
|
2746
|
-
label: "Enable Coverage",
|
|
2747
|
-
checked: e.enableCoverage,
|
|
2748
|
-
onChange: (e) => w("enableCoverage", e)
|
|
2749
|
-
}) }),
|
|
2750
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(I, {
|
|
3007
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(z, {
|
|
2751
3008
|
label: "Remove Duplicates",
|
|
2752
3009
|
checked: e.removeDuplicates,
|
|
2753
|
-
onChange: (e) =>
|
|
3010
|
+
onChange: (e) => F("removeDuplicates", e)
|
|
2754
3011
|
}) }),
|
|
2755
|
-
/* @__PURE__ */
|
|
3012
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(S, {
|
|
2756
3013
|
variant: "ghost",
|
|
2757
3014
|
size: "micro",
|
|
2758
|
-
iconRight:
|
|
3015
|
+
iconRight: h(s ? U : W, {}),
|
|
2759
3016
|
onClick: () => c((e) => !e),
|
|
2760
|
-
children: s ? "Hide
|
|
3017
|
+
children: s ? "Hide Match, Candidates and Ranking" : "Show Match, Candidates and Ranking"
|
|
2761
3018
|
}) }),
|
|
2762
|
-
s && /* @__PURE__ */
|
|
2763
|
-
/* @__PURE__ */
|
|
2764
|
-
label:
|
|
2765
|
-
|
|
2766
|
-
|
|
3019
|
+
s && /* @__PURE__ */ g(m, { children: [
|
|
3020
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(P, {
|
|
3021
|
+
label: "Tolerance",
|
|
3022
|
+
size: "micro",
|
|
3023
|
+
disabled: D,
|
|
3024
|
+
value: f.tolerance ?? C.tolerance,
|
|
3025
|
+
onValueChange: (e) => I({ tolerance: e }),
|
|
3026
|
+
options: [
|
|
3027
|
+
{
|
|
3028
|
+
label: "Exact",
|
|
3029
|
+
value: p.Exact
|
|
3030
|
+
},
|
|
3031
|
+
{
|
|
3032
|
+
label: "One edit",
|
|
3033
|
+
value: p.OneEdit
|
|
3034
|
+
},
|
|
3035
|
+
{
|
|
3036
|
+
label: "Two edits",
|
|
3037
|
+
value: p.TwoEdits
|
|
3038
|
+
},
|
|
3039
|
+
{
|
|
3040
|
+
label: "Three edits",
|
|
3041
|
+
value: p.ThreeEdits
|
|
3042
|
+
}
|
|
3043
|
+
]
|
|
2767
3044
|
}) }),
|
|
2768
|
-
/* @__PURE__ */
|
|
2769
|
-
label:
|
|
2770
|
-
|
|
2771
|
-
|
|
3045
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(z, {
|
|
3046
|
+
label: "Every rung",
|
|
3047
|
+
disabled: D,
|
|
3048
|
+
checked: (f.rungs ?? C.rungs) === u.All,
|
|
3049
|
+
onChange: (e) => I({ rungs: e ? u.All : u.Fewest })
|
|
2772
3050
|
}) }),
|
|
2773
|
-
/* @__PURE__ */
|
|
2774
|
-
label:
|
|
2775
|
-
|
|
2776
|
-
|
|
3051
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(k, {
|
|
3052
|
+
label: "One edit from",
|
|
3053
|
+
type: "number",
|
|
3054
|
+
disabled: D,
|
|
3055
|
+
value: (f.oneEditFrom ?? C.oneEditFrom).toString(),
|
|
3056
|
+
onChange: (e) => V(e.target.value, (e) => I({ oneEditFrom: e }))
|
|
2777
3057
|
}) }),
|
|
2778
|
-
/* @__PURE__ */
|
|
2779
|
-
label:
|
|
2780
|
-
|
|
2781
|
-
|
|
3058
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(k, {
|
|
3059
|
+
label: "Two edits from",
|
|
3060
|
+
type: "number",
|
|
3061
|
+
disabled: D,
|
|
3062
|
+
value: (f.twoEditsFrom ?? C.twoEditsFrom).toString(),
|
|
3063
|
+
onChange: (e) => V(e.target.value, (e) => I({ twoEditsFrom: e }))
|
|
2782
3064
|
}) }),
|
|
2783
|
-
/* @__PURE__ */
|
|
2784
|
-
label:
|
|
2785
|
-
|
|
2786
|
-
|
|
3065
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(k, {
|
|
3066
|
+
label: "Three edits from",
|
|
3067
|
+
type: "number",
|
|
3068
|
+
disabled: D,
|
|
3069
|
+
value: (f.threeEditsFrom ?? C.threeEditsFrom).toString(),
|
|
3070
|
+
onChange: (e) => V(e.target.value, (e) => I({ threeEditsFrom: e }))
|
|
2787
3071
|
}) }),
|
|
2788
|
-
/* @__PURE__ */
|
|
2789
|
-
label:
|
|
2790
|
-
|
|
2791
|
-
|
|
3072
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(k, {
|
|
3073
|
+
label: "Typing prefix from",
|
|
3074
|
+
type: "number",
|
|
3075
|
+
disabled: D,
|
|
3076
|
+
value: (f.typingPrefixFrom ?? C.typingPrefixFrom).toString(),
|
|
3077
|
+
onChange: (e) => V(e.target.value, (e) => I({ typingPrefixFrom: e }))
|
|
2792
3078
|
}) }),
|
|
2793
|
-
/* @__PURE__ */
|
|
2794
|
-
label:
|
|
2795
|
-
|
|
2796
|
-
|
|
3079
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(z, {
|
|
3080
|
+
label: "Joined words",
|
|
3081
|
+
disabled: D,
|
|
3082
|
+
checked: f.joinedWords ?? C.joinedWords,
|
|
3083
|
+
onChange: (e) => I({ joinedWords: e })
|
|
2797
3084
|
}) }),
|
|
2798
|
-
/* @__PURE__ */
|
|
2799
|
-
label:
|
|
3085
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(k, {
|
|
3086
|
+
label: "Candidates per row",
|
|
2800
3087
|
type: "number",
|
|
2801
|
-
|
|
2802
|
-
|
|
3088
|
+
disabled: j,
|
|
3089
|
+
value: (_.candidatesPerRow ?? w.candidatesPerRow).toString(),
|
|
3090
|
+
onChange: (e) => V(e.target.value, (e) => R({ candidatesPerRow: e }))
|
|
2803
3091
|
}) }),
|
|
2804
|
-
/* @__PURE__ */
|
|
2805
|
-
label:
|
|
3092
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(k, {
|
|
3093
|
+
label: "Max candidates (0: per row)",
|
|
2806
3094
|
type: "number",
|
|
2807
|
-
|
|
2808
|
-
|
|
3095
|
+
disabled: j,
|
|
3096
|
+
value: (_.maxCandidates ?? 0).toString(),
|
|
3097
|
+
onChange: (e) => V(e.target.value, (e) => R({ maxCandidates: e > 0 ? e : null }))
|
|
2809
3098
|
}) }),
|
|
2810
|
-
/* @__PURE__ */
|
|
2811
|
-
label:
|
|
3099
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(z, {
|
|
3100
|
+
label: "Fallback (most words when none holds every word)",
|
|
3101
|
+
disabled: D,
|
|
3102
|
+
checked: _.fallback ?? w.fallback,
|
|
3103
|
+
onChange: (e) => R({ fallback: e })
|
|
3104
|
+
}) }),
|
|
3105
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(z, {
|
|
3106
|
+
label: "Rest (BM25F below the counted set)",
|
|
3107
|
+
disabled: D,
|
|
3108
|
+
checked: _.rest ?? w.rest,
|
|
3109
|
+
onChange: (e) => R({ rest: e })
|
|
3110
|
+
}) }),
|
|
3111
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(k, {
|
|
3112
|
+
label: "Coverage share %",
|
|
2812
3113
|
type: "number",
|
|
2813
|
-
|
|
2814
|
-
|
|
3114
|
+
disabled: !A,
|
|
3115
|
+
value: Math.round((v.share ?? T.share) * 100).toString(),
|
|
3116
|
+
onChange: (e) => H(e.target.value, (e) => B({ share: e }))
|
|
2815
3117
|
}) }),
|
|
2816
|
-
/* @__PURE__ */
|
|
2817
|
-
label:
|
|
3118
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(k, {
|
|
3119
|
+
label: "Typing shift %",
|
|
2818
3120
|
type: "number",
|
|
2819
|
-
|
|
2820
|
-
|
|
3121
|
+
disabled: !A,
|
|
3122
|
+
value: Math.round((v.typingShift ?? T.typingShift) * 100).toString(),
|
|
3123
|
+
onChange: (e) => H(e.target.value, (e) => B({ typingShift: e }))
|
|
2821
3124
|
}) }),
|
|
2822
|
-
|
|
3125
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(z, {
|
|
3126
|
+
label: "Whole query floor",
|
|
3127
|
+
disabled: !A,
|
|
3128
|
+
checked: v.wholeQueryFloor ?? T.wholeQueryFloor,
|
|
3129
|
+
onChange: (e) => B({ wholeQueryFloor: e })
|
|
3130
|
+
}) }),
|
|
3131
|
+
M && /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(S, {
|
|
2823
3132
|
variant: "ghost",
|
|
2824
3133
|
size: "micro",
|
|
2825
3134
|
onClick: () => t({
|
|
2826
|
-
|
|
2827
|
-
|
|
3135
|
+
mode: void 0,
|
|
3136
|
+
match: void 0,
|
|
3137
|
+
candidates: void 0,
|
|
3138
|
+
ranking: void 0
|
|
2828
3139
|
}),
|
|
2829
3140
|
children: "Use the dataset's values"
|
|
2830
3141
|
}) })
|
|
@@ -2834,7 +3145,7 @@ function At() {
|
|
|
2834
3145
|
});
|
|
2835
3146
|
}
|
|
2836
3147
|
// src/components/SearchErrorBoundary.tsx
|
|
2837
|
-
var
|
|
3148
|
+
var Nt = class extends t {
|
|
2838
3149
|
constructor(e) {
|
|
2839
3150
|
super(e), this.state = {
|
|
2840
3151
|
hasError: !1,
|
|
@@ -2857,7 +3168,7 @@ var jt = class extends t {
|
|
|
2857
3168
|
});
|
|
2858
3169
|
};
|
|
2859
3170
|
render() {
|
|
2860
|
-
return this.state.hasError && this.state.error ? this.props.fallback ? this.props.fallback(this.state.error, this.reset) : /* @__PURE__ */
|
|
3171
|
+
return this.state.hasError && this.state.error ? this.props.fallback ? this.props.fallback(this.state.error, this.reset) : /* @__PURE__ */ g("div", {
|
|
2861
3172
|
style: {
|
|
2862
3173
|
padding: "2rem",
|
|
2863
3174
|
backgroundColor: "#fee",
|
|
@@ -2867,22 +3178,22 @@ var jt = class extends t {
|
|
|
2867
3178
|
margin: "2rem auto"
|
|
2868
3179
|
},
|
|
2869
3180
|
children: [
|
|
2870
|
-
/* @__PURE__ */
|
|
3181
|
+
/* @__PURE__ */ h("h2", {
|
|
2871
3182
|
style: {
|
|
2872
3183
|
color: "#c33",
|
|
2873
3184
|
marginTop: 0
|
|
2874
3185
|
},
|
|
2875
3186
|
children: "β οΈ Search Initialization Error"
|
|
2876
3187
|
}),
|
|
2877
|
-
/* @__PURE__ */
|
|
3188
|
+
/* @__PURE__ */ g("p", {
|
|
2878
3189
|
style: { marginBottom: "1rem" },
|
|
2879
3190
|
children: [
|
|
2880
|
-
/* @__PURE__ */
|
|
3191
|
+
/* @__PURE__ */ h("strong", { children: "Error:" }),
|
|
2881
3192
|
" ",
|
|
2882
3193
|
this.state.error.message
|
|
2883
3194
|
]
|
|
2884
3195
|
}),
|
|
2885
|
-
/* @__PURE__ */
|
|
3196
|
+
/* @__PURE__ */ g("div", {
|
|
2886
3197
|
style: {
|
|
2887
3198
|
backgroundColor: "#fff",
|
|
2888
3199
|
padding: "1rem",
|
|
@@ -2890,21 +3201,21 @@ var jt = class extends t {
|
|
|
2890
3201
|
marginBottom: "1rem",
|
|
2891
3202
|
fontSize: "0.9rem"
|
|
2892
3203
|
},
|
|
2893
|
-
children: [/* @__PURE__ */
|
|
3204
|
+
children: [/* @__PURE__ */ h("strong", { children: "π‘ Common fixes:" }), /* @__PURE__ */ g("ul", {
|
|
2894
3205
|
style: {
|
|
2895
3206
|
marginBottom: 0,
|
|
2896
3207
|
paddingLeft: "1.5rem"
|
|
2897
3208
|
},
|
|
2898
3209
|
children: [
|
|
2899
|
-
/* @__PURE__ */
|
|
2900
|
-
/* @__PURE__ */
|
|
2901
|
-
/* @__PURE__ */
|
|
2902
|
-
/* @__PURE__ */
|
|
2903
|
-
/* @__PURE__ */
|
|
3210
|
+
/* @__PURE__ */ h("li", { children: "Check browser console for detailed error messages" }),
|
|
3211
|
+
/* @__PURE__ */ h("li", { children: "Verify the url passed to SearchProvider is correct" }),
|
|
3212
|
+
/* @__PURE__ */ h("li", { children: "Verify your bearer token is valid (create or check it on the Indx Dashboard)" }),
|
|
3213
|
+
/* @__PURE__ */ h("li", { children: "Ensure INDX server is running" }),
|
|
3214
|
+
/* @__PURE__ */ h("li", { children: "Check dataset name spelling" })
|
|
2904
3215
|
]
|
|
2905
3216
|
})]
|
|
2906
3217
|
}),
|
|
2907
|
-
/* @__PURE__ */
|
|
3218
|
+
/* @__PURE__ */ h(S, {
|
|
2908
3219
|
variant: "primary",
|
|
2909
3220
|
size: "micro",
|
|
2910
3221
|
onClick: this.reset,
|
|
@@ -2915,48 +3226,58 @@ var jt = class extends t {
|
|
|
2915
3226
|
}
|
|
2916
3227
|
};
|
|
2917
3228
|
// src/hooks/useVectorSearch.ts
|
|
2918
|
-
function
|
|
2919
|
-
let { url: n, team: r, dataset: a, authenticatedFetch:
|
|
2920
|
-
return {
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
3229
|
+
function Pt(e, t) {
|
|
3230
|
+
let { url: n, team: r, dataset: a, authenticatedFetch: s } = ye(), [u, d] = l(null), [f, p] = l(!1), [m, h] = l(void 0), g = c(0);
|
|
3231
|
+
return o(() => () => {
|
|
3232
|
+
g.current++;
|
|
3233
|
+
}, [
|
|
3234
|
+
n,
|
|
3235
|
+
r,
|
|
3236
|
+
a
|
|
3237
|
+
]), {
|
|
3238
|
+
results: u,
|
|
3239
|
+
isLoading: f,
|
|
3240
|
+
error: m,
|
|
2924
3241
|
search: i(async (i) => {
|
|
2925
|
-
|
|
3242
|
+
let o = ++g.current, c = () => o === g.current;
|
|
3243
|
+
p(!0), h(void 0);
|
|
2926
3244
|
try {
|
|
2927
|
-
let
|
|
3245
|
+
let o = await e(i), l = {
|
|
2928
3246
|
fieldName: t.fieldName,
|
|
2929
|
-
vector:
|
|
3247
|
+
vector: o,
|
|
2930
3248
|
maxResults: t.maxResults ?? 10
|
|
2931
3249
|
};
|
|
2932
3250
|
t.filter && (l.filter = t.filter);
|
|
2933
|
-
let u = await
|
|
3251
|
+
let u = await s(`${n}/api/teams/${r}/datasets/${a}/search/vector`, {
|
|
2934
3252
|
method: "POST",
|
|
2935
3253
|
headers: { "Content-Type": "application/json" },
|
|
2936
3254
|
body: JSON.stringify(l)
|
|
2937
3255
|
});
|
|
2938
|
-
if (!u.ok) throw await
|
|
2939
|
-
let
|
|
2940
|
-
if (
|
|
2941
|
-
|
|
3256
|
+
if (!u.ok) throw await Z.fromResponse("VectorSearch", u);
|
|
3257
|
+
let f = await u.json();
|
|
3258
|
+
if (!c()) return;
|
|
3259
|
+
if (f.length === 0) {
|
|
3260
|
+
d([]);
|
|
2942
3261
|
return;
|
|
2943
3262
|
}
|
|
2944
|
-
let
|
|
3263
|
+
let p = f.map((e) => e.documentKey), m = await s(`${n}/api/teams/${r}/datasets/${a}/documents/lookup`, {
|
|
2945
3264
|
method: "POST",
|
|
2946
3265
|
headers: { "Content-Type": "application/json" },
|
|
2947
|
-
body: JSON.stringify(
|
|
3266
|
+
body: JSON.stringify(p)
|
|
2948
3267
|
});
|
|
2949
|
-
if (!
|
|
2950
|
-
let
|
|
2951
|
-
c(
|
|
3268
|
+
if (!m.ok) throw await Z.fromResponse("GetJson", m);
|
|
3269
|
+
let h = await m.json();
|
|
3270
|
+
if (!c()) return;
|
|
3271
|
+
d(h.map((e, t) => ({
|
|
2952
3272
|
document: e,
|
|
2953
|
-
documentKey:
|
|
2954
|
-
score:
|
|
3273
|
+
documentKey: p[t],
|
|
3274
|
+
score: f[t].score
|
|
2955
3275
|
})));
|
|
2956
3276
|
} catch (e) {
|
|
2957
|
-
|
|
3277
|
+
if (!c()) return;
|
|
3278
|
+
h(e instanceof Error ? e.message : "Vector search failed"), d(null);
|
|
2958
3279
|
} finally {
|
|
2959
|
-
|
|
3280
|
+
c() && p(!1);
|
|
2960
3281
|
}
|
|
2961
3282
|
}, [
|
|
2962
3283
|
e,
|
|
@@ -2966,55 +3287,65 @@ function Mt(e, t) {
|
|
|
2966
3287
|
n,
|
|
2967
3288
|
r,
|
|
2968
3289
|
a,
|
|
2969
|
-
|
|
3290
|
+
s
|
|
2970
3291
|
])
|
|
2971
3292
|
};
|
|
2972
3293
|
}
|
|
2973
3294
|
// src/hooks/useHybridSearch.ts
|
|
2974
|
-
function
|
|
2975
|
-
let { url: n, team: r, dataset: a, authenticatedFetch:
|
|
2976
|
-
return {
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
3295
|
+
function Ft(e, t) {
|
|
3296
|
+
let { url: n, team: r, dataset: a, authenticatedFetch: s } = ye(), [u, d] = l(null), [f, p] = l(!1), [m, h] = l(void 0), g = c(0);
|
|
3297
|
+
return o(() => () => {
|
|
3298
|
+
g.current++;
|
|
3299
|
+
}, [
|
|
3300
|
+
n,
|
|
3301
|
+
r,
|
|
3302
|
+
a
|
|
3303
|
+
]), {
|
|
3304
|
+
results: u,
|
|
3305
|
+
isLoading: f,
|
|
3306
|
+
error: m,
|
|
2980
3307
|
search: i(async (i) => {
|
|
2981
|
-
|
|
3308
|
+
let o = ++g.current, c = () => o === g.current;
|
|
3309
|
+
p(!0), h(void 0);
|
|
2982
3310
|
try {
|
|
2983
|
-
let
|
|
3311
|
+
let o = await e(i), l = {
|
|
2984
3312
|
text: i,
|
|
2985
3313
|
embeddingField: t.fieldName,
|
|
2986
|
-
vector:
|
|
3314
|
+
vector: o,
|
|
2987
3315
|
maxNumberOfRecordsToReturn: t.maxResults ?? 10,
|
|
2988
3316
|
alpha: t.alpha ?? .5
|
|
2989
3317
|
};
|
|
2990
3318
|
t.filter && (l.filter = t.filter), t.timeoutMs && (l.timeOutLimitMilliseconds = t.timeoutMs);
|
|
2991
|
-
let u = await
|
|
3319
|
+
let u = await s(`${n}/api/teams/${r}/datasets/${a}/search/hybrid`, {
|
|
2992
3320
|
method: "POST",
|
|
2993
3321
|
headers: { "Content-Type": "application/json" },
|
|
2994
3322
|
body: JSON.stringify(l)
|
|
2995
3323
|
});
|
|
2996
|
-
if (!u.ok) throw await
|
|
2997
|
-
let
|
|
2998
|
-
if (
|
|
2999
|
-
|
|
3324
|
+
if (!u.ok) throw await Z.fromResponse("HybridSearch", u);
|
|
3325
|
+
let f = await u.json();
|
|
3326
|
+
if (!c()) return;
|
|
3327
|
+
if (f.length === 0) {
|
|
3328
|
+
d([]);
|
|
3000
3329
|
return;
|
|
3001
3330
|
}
|
|
3002
|
-
let
|
|
3331
|
+
let p = f.map((e) => e.documentKey), m = await s(`${n}/api/teams/${r}/datasets/${a}/documents/lookup`, {
|
|
3003
3332
|
method: "POST",
|
|
3004
3333
|
headers: { "Content-Type": "application/json" },
|
|
3005
|
-
body: JSON.stringify(
|
|
3334
|
+
body: JSON.stringify(p)
|
|
3006
3335
|
});
|
|
3007
|
-
if (!
|
|
3008
|
-
let
|
|
3009
|
-
c(
|
|
3336
|
+
if (!m.ok) throw await Z.fromResponse("GetJson", m);
|
|
3337
|
+
let h = await m.json();
|
|
3338
|
+
if (!c()) return;
|
|
3339
|
+
d(h.map((e, t) => ({
|
|
3010
3340
|
document: e,
|
|
3011
|
-
documentKey:
|
|
3012
|
-
score:
|
|
3341
|
+
documentKey: p[t],
|
|
3342
|
+
score: f[t].score
|
|
3013
3343
|
})));
|
|
3014
3344
|
} catch (e) {
|
|
3015
|
-
|
|
3345
|
+
if (!c()) return;
|
|
3346
|
+
h(e instanceof Error ? e.message : "Hybrid search failed"), d(null);
|
|
3016
3347
|
} finally {
|
|
3017
|
-
|
|
3348
|
+
c() && p(!1);
|
|
3018
3349
|
}
|
|
3019
3350
|
}, [
|
|
3020
3351
|
e,
|
|
@@ -3026,141 +3357,22 @@ function Nt(e, t) {
|
|
|
3026
3357
|
n,
|
|
3027
3358
|
r,
|
|
3028
3359
|
a,
|
|
3029
|
-
|
|
3360
|
+
s
|
|
3030
3361
|
])
|
|
3031
3362
|
};
|
|
3032
3363
|
}
|
|
3033
|
-
// src/hooks/useFilterSuggestion.ts
|
|
3034
|
-
function Pt(e) {
|
|
3035
|
-
let t = e.trim().toLowerCase();
|
|
3036
|
-
return t === "true" || t === "false" || t !== "" && !Number.isNaN(Number(t));
|
|
3037
|
-
}
|
|
3038
|
-
function Ft(e, t) {
|
|
3039
|
-
if (!t) return null;
|
|
3040
|
-
let n = [];
|
|
3041
|
-
for (let [e, r] of Object.entries(t)) for (let t of r ?? []) t?.key && t.key.trim().length >= 2 && !Pt(t.key) && n.push({
|
|
3042
|
-
field: e,
|
|
3043
|
-
value: t.key
|
|
3044
|
-
});
|
|
3045
|
-
n.sort((e, t) => t.value.length - e.value.length);
|
|
3046
|
-
let r = " " + e.toLowerCase() + " ", i = [];
|
|
3047
|
-
for (let e of n) {
|
|
3048
|
-
let t = " " + e.value.toLowerCase().trim() + " ", n = r.indexOf(t);
|
|
3049
|
-
n < 0 || (i.push({
|
|
3050
|
-
field: e.field,
|
|
3051
|
-
value: e.value
|
|
3052
|
-
}), r = r.slice(0, n) + " " + r.slice(n + t.length));
|
|
3053
|
-
}
|
|
3054
|
-
return i.length === 0 ? null : {
|
|
3055
|
-
filters: i,
|
|
3056
|
-
text: r.replace(/[?!.,]+\s*$/, "").replace(/\s+/g, " ").trim(),
|
|
3057
|
-
sort: null
|
|
3058
|
-
};
|
|
3059
|
-
}
|
|
3060
|
-
function It(e = {}) {
|
|
3061
|
-
let t = _e(), { url: n, team: r, dataset: a, authenticatedFetch: s, setQuery: u, toggleFilter: d, setRangeFilter: f, setSort: p } = t, { auto: m } = e, h = c(t);
|
|
3062
|
-
h.current = t;
|
|
3063
|
-
let [g, _] = l(null), [v, y] = l(""), [b, x] = l(!1), S = c(0), C = i(async (e) => {
|
|
3064
|
-
let t = ++S.current;
|
|
3065
|
-
x(!0);
|
|
3066
|
-
try {
|
|
3067
|
-
let i = await s(`${n}/api/teams/${r}/datasets/${a}/search-or-ask/filters${je(h.current)}`, {
|
|
3068
|
-
method: "POST",
|
|
3069
|
-
headers: { "Content-Type": "application/json" },
|
|
3070
|
-
body: JSON.stringify({ text: e })
|
|
3071
|
-
});
|
|
3072
|
-
if (t !== S.current) return;
|
|
3073
|
-
let o = i.ok ? await i.json() : null;
|
|
3074
|
-
_(o && o.filters.length > 0 ? o : null), y(e);
|
|
3075
|
-
} catch {
|
|
3076
|
-
t === S.current && _(null);
|
|
3077
|
-
} finally {
|
|
3078
|
-
t === S.current && x(!1);
|
|
3079
|
-
}
|
|
3080
|
-
}, [
|
|
3081
|
-
n,
|
|
3082
|
-
r,
|
|
3083
|
-
a,
|
|
3084
|
-
s
|
|
3085
|
-
]), w = i((e) => {
|
|
3086
|
-
u(e.text);
|
|
3087
|
-
let t = {
|
|
3088
|
-
...h.current.state.rangeBounds,
|
|
3089
|
-
...h.current.datasetBounds
|
|
3090
|
-
};
|
|
3091
|
-
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);
|
|
3092
|
-
e.sort && p(e.sort.field, !e.sort.descending), _(null);
|
|
3093
|
-
}, [
|
|
3094
|
-
u,
|
|
3095
|
-
d,
|
|
3096
|
-
f,
|
|
3097
|
-
p
|
|
3098
|
-
]), T = i(() => {
|
|
3099
|
-
S.current++, _(null), x(!1);
|
|
3100
|
-
}, []), 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);
|
|
3101
|
-
M.current = j;
|
|
3102
|
-
let N = t.state.facets, P = t.state.isLoading || t.facetsEnabled && N == null;
|
|
3103
|
-
return o(() => {
|
|
3104
|
-
if (!A || !j || P || E.current.has(j)) return;
|
|
3105
|
-
E.current.add(j);
|
|
3106
|
-
let e = Ft(j, N);
|
|
3107
|
-
if (e && (E.current.add(e.text), w(e), O(j)), k !== "model") return;
|
|
3108
|
-
let t = e ? e.text : j;
|
|
3109
|
-
if (!t) return;
|
|
3110
|
-
let i = () => M.current === j || M.current === t;
|
|
3111
|
-
(async () => {
|
|
3112
|
-
let o = ++S.current;
|
|
3113
|
-
x(!0);
|
|
3114
|
-
try {
|
|
3115
|
-
let c = await s(`${n}/api/teams/${r}/datasets/${a}/search-or-ask/filters${je(h.current)}`, {
|
|
3116
|
-
method: "POST",
|
|
3117
|
-
headers: { "Content-Type": "application/json" },
|
|
3118
|
-
body: JSON.stringify({ text: t })
|
|
3119
|
-
});
|
|
3120
|
-
if (o !== S.current || !i()) return;
|
|
3121
|
-
let l = c.ok ? await c.json() : null;
|
|
3122
|
-
l && l.filters.length > 0 && (E.current.add(l.text), w({
|
|
3123
|
-
filters: [...e?.filters ?? [], ...l.filters],
|
|
3124
|
-
text: l.text,
|
|
3125
|
-
sort: l.sort
|
|
3126
|
-
}), O(j));
|
|
3127
|
-
} catch {} finally {
|
|
3128
|
-
o === S.current && x(!1);
|
|
3129
|
-
}
|
|
3130
|
-
})();
|
|
3131
|
-
}, [
|
|
3132
|
-
A,
|
|
3133
|
-
j,
|
|
3134
|
-
k,
|
|
3135
|
-
P,
|
|
3136
|
-
N,
|
|
3137
|
-
w,
|
|
3138
|
-
n,
|
|
3139
|
-
r,
|
|
3140
|
-
a,
|
|
3141
|
-
s
|
|
3142
|
-
]), {
|
|
3143
|
-
suggestion: g,
|
|
3144
|
-
forText: v,
|
|
3145
|
-
loading: b,
|
|
3146
|
-
suggest: C,
|
|
3147
|
-
apply: w,
|
|
3148
|
-
clear: T,
|
|
3149
|
-
appliedText: D
|
|
3150
|
-
};
|
|
3151
|
-
}
|
|
3152
3364
|
// src/hooks/useAsk.ts
|
|
3153
|
-
var
|
|
3365
|
+
var It = {
|
|
3154
3366
|
question: "",
|
|
3155
3367
|
status: "idle",
|
|
3156
3368
|
answer: "",
|
|
3157
3369
|
sources: [],
|
|
3158
3370
|
steps: []
|
|
3159
3371
|
};
|
|
3160
|
-
function
|
|
3161
|
-
let e =
|
|
3372
|
+
function Lt() {
|
|
3373
|
+
let e = ye(), { url: t, team: n, dataset: r, authenticatedFetch: a } = e, s = c(e);
|
|
3162
3374
|
s.current = e;
|
|
3163
|
-
let [u, d] = l(
|
|
3375
|
+
let [u, d] = l(It), f = c(u);
|
|
3164
3376
|
f.current = u;
|
|
3165
3377
|
let p = c(null), m = i(async (e, i = [], o = {}) => {
|
|
3166
3378
|
let c = e.trim();
|
|
@@ -3192,7 +3404,7 @@ function Rt() {
|
|
|
3192
3404
|
}
|
|
3193
3405
|
}));
|
|
3194
3406
|
try {
|
|
3195
|
-
let e = await a(`${t}/api/teams/${n}/datasets/${r}/search-or-ask/ask${
|
|
3407
|
+
let e = await a(`${t}/api/teams/${n}/datasets/${r}/search-or-ask/ask${Ae(s.current)}`, {
|
|
3196
3408
|
method: "POST",
|
|
3197
3409
|
headers: {
|
|
3198
3410
|
"Content-Type": "application/json",
|
|
@@ -3206,10 +3418,16 @@ function Rt() {
|
|
|
3206
3418
|
signal: l.signal
|
|
3207
3419
|
});
|
|
3208
3420
|
if (e.status === 429) {
|
|
3209
|
-
let t = await e.json().catch(() => ({}))
|
|
3421
|
+
let t = await e.json().catch(() => ({}));
|
|
3422
|
+
if (o.proactive) {
|
|
3423
|
+
d(It);
|
|
3424
|
+
return;
|
|
3425
|
+
}
|
|
3426
|
+
let n = Number(e.headers.get("Retry-After"));
|
|
3210
3427
|
d((e) => ({
|
|
3211
3428
|
...e,
|
|
3212
3429
|
status: "limited",
|
|
3430
|
+
limit: t.code === "searchOrAskBudgetSpent" ? "budget" : "address",
|
|
3213
3431
|
retryAfterSeconds: t.retryAfterSeconds ?? (Number.isFinite(n) ? n : void 0)
|
|
3214
3432
|
}));
|
|
3215
3433
|
return;
|
|
@@ -3220,10 +3438,15 @@ function Rt() {
|
|
|
3220
3438
|
askId: p
|
|
3221
3439
|
})), !e.ok || !e.body) {
|
|
3222
3440
|
let t = await e.json().catch(() => ({}));
|
|
3223
|
-
|
|
3441
|
+
if (o.proactive) {
|
|
3442
|
+
d(It);
|
|
3443
|
+
return;
|
|
3444
|
+
}
|
|
3445
|
+
let n = e.status === 409 || e.status === 404;
|
|
3446
|
+
g(t.code ?? `http${e.status}`, n ? "Answers are not available here right now. Search still works." : "The question could not be asked.");
|
|
3224
3447
|
return;
|
|
3225
3448
|
}
|
|
3226
|
-
for await (let { event: t, data: n } of
|
|
3449
|
+
for await (let { event: t, data: n } of ke(e.body)) switch (t) {
|
|
3227
3450
|
case "status": {
|
|
3228
3451
|
let e = n.step;
|
|
3229
3452
|
e && d((t) => ({
|
|
@@ -3238,6 +3461,15 @@ function Rt() {
|
|
|
3238
3461
|
filters: n
|
|
3239
3462
|
}));
|
|
3240
3463
|
break;
|
|
3464
|
+
case "picks":
|
|
3465
|
+
d((e) => ({
|
|
3466
|
+
...e,
|
|
3467
|
+
picks: {
|
|
3468
|
+
...n,
|
|
3469
|
+
askId: e.askId
|
|
3470
|
+
}
|
|
3471
|
+
}));
|
|
3472
|
+
break;
|
|
3241
3473
|
case "sources":
|
|
3242
3474
|
d((e) => ({
|
|
3243
3475
|
...e,
|
|
@@ -3246,7 +3478,10 @@ function Rt() {
|
|
|
3246
3478
|
}));
|
|
3247
3479
|
break;
|
|
3248
3480
|
case "text":
|
|
3249
|
-
u
|
|
3481
|
+
u || d((e) => e.status === "searching" ? {
|
|
3482
|
+
...e,
|
|
3483
|
+
status: "writing"
|
|
3484
|
+
} : e), u += n.delta, f ??= requestAnimationFrame(m);
|
|
3250
3485
|
break;
|
|
3251
3486
|
case "done":
|
|
3252
3487
|
h(), d((e) => ({
|
|
@@ -3299,7 +3534,7 @@ function Rt() {
|
|
|
3299
3534
|
r,
|
|
3300
3535
|
a
|
|
3301
3536
|
]), g = i(() => p.current?.abort(), []), _ = i(() => {
|
|
3302
|
-
p.current?.abort(), d(
|
|
3537
|
+
p.current?.abort(), d(It);
|
|
3303
3538
|
}, []);
|
|
3304
3539
|
return o(() => () => p.current?.abort(), []), {
|
|
3305
3540
|
...u,
|
|
@@ -3326,32 +3561,32 @@ var $ = {
|
|
|
3326
3561
|
searchedLabel: "_searchedLabel_gjc13_23",
|
|
3327
3562
|
steps: "_steps_gjc13_26",
|
|
3328
3563
|
stepDone: "_stepDone_gjc13_27"
|
|
3329
|
-
},
|
|
3330
|
-
function
|
|
3564
|
+
}, Rt = /(`[^`\n]+`)|(\*\*[^*\n]+\*\*)|(\*[^*\n]+\*|_[^_\n]+_)|(\[[^\]\n]+\]\(https?:\/\/[^)\s]+\))|(\[\d+\])/g;
|
|
3565
|
+
function zt(t, n, r) {
|
|
3331
3566
|
let i = [], a = 0, o = 0;
|
|
3332
|
-
for (let s of t.matchAll(
|
|
3567
|
+
for (let s of t.matchAll(Rt)) {
|
|
3333
3568
|
s.index > a && i.push(t.slice(a, s.index));
|
|
3334
|
-
let c = `${r}-${o++}`, [l, u, d, p, m
|
|
3335
|
-
if (u) i.push(/* @__PURE__ */
|
|
3569
|
+
let c = `${r}-${o++}`, [l, u, d, f, p, m] = s;
|
|
3570
|
+
if (u) i.push(/* @__PURE__ */ h("code", {
|
|
3336
3571
|
className: $.inlineCode,
|
|
3337
3572
|
children: u.slice(1, -1)
|
|
3338
3573
|
}, c));
|
|
3339
|
-
else if (d) i.push(/* @__PURE__ */
|
|
3340
|
-
else if (
|
|
3341
|
-
else if (
|
|
3342
|
-
let [, e, t] = /^\[([^\]]+)\]\(([^)]+)\)$/.exec(
|
|
3343
|
-
i.push(/* @__PURE__ */
|
|
3574
|
+
else if (d) i.push(/* @__PURE__ */ h("strong", { children: zt(d.slice(2, -2), n, c) }, c));
|
|
3575
|
+
else if (f) i.push(/* @__PURE__ */ h("em", { children: zt(f.slice(1, -1), n, c) }, c));
|
|
3576
|
+
else if (p) {
|
|
3577
|
+
let [, e, t] = /^\[([^\]]+)\]\(([^)]+)\)$/.exec(p);
|
|
3578
|
+
i.push(/* @__PURE__ */ h("a", {
|
|
3344
3579
|
href: t,
|
|
3345
3580
|
target: "_blank",
|
|
3346
3581
|
rel: "noopener noreferrer",
|
|
3347
3582
|
children: e
|
|
3348
3583
|
}, c));
|
|
3349
|
-
} else
|
|
3584
|
+
} else m ? i.push(/* @__PURE__ */ h(e.Fragment, { children: n(Number(m.slice(1, -1))) }, c)) : i.push(l);
|
|
3350
3585
|
a = s.index + l.length;
|
|
3351
3586
|
}
|
|
3352
3587
|
return a < t.length && i.push(t.slice(a)), i;
|
|
3353
3588
|
}
|
|
3354
|
-
function
|
|
3589
|
+
function Bt(e) {
|
|
3355
3590
|
let t = e.replace(/\r\n/g, "\n").split("\n"), n = [], r = [], i = () => {
|
|
3356
3591
|
r.length && (n.push({
|
|
3357
3592
|
kind: "paragraph",
|
|
@@ -3400,75 +3635,100 @@ function Vt(e) {
|
|
|
3400
3635
|
}
|
|
3401
3636
|
return i(), n;
|
|
3402
3637
|
}
|
|
3403
|
-
function
|
|
3404
|
-
return
|
|
3638
|
+
function Vt(e, t) {
|
|
3639
|
+
return Bt(e).map((e, n) => {
|
|
3405
3640
|
let r = `b${n}`;
|
|
3406
3641
|
switch (e.kind) {
|
|
3407
|
-
case "code": return /* @__PURE__ */
|
|
3642
|
+
case "code": return /* @__PURE__ */ h("pre", {
|
|
3408
3643
|
className: $.codeBlock,
|
|
3409
3644
|
"data-lang": e.lang || void 0,
|
|
3410
|
-
children: /* @__PURE__ */
|
|
3645
|
+
children: /* @__PURE__ */ h("code", { children: e.text })
|
|
3411
3646
|
}, r);
|
|
3412
|
-
case "heading": return /* @__PURE__ */
|
|
3647
|
+
case "heading": return /* @__PURE__ */ h("p", {
|
|
3413
3648
|
className: $.heading,
|
|
3414
|
-
children:
|
|
3649
|
+
children: zt(e.text, t, r)
|
|
3415
3650
|
}, r);
|
|
3416
3651
|
case "list": {
|
|
3417
3652
|
let n = e.ordered ? "ol" : "ul";
|
|
3418
|
-
return /* @__PURE__ */
|
|
3653
|
+
return /* @__PURE__ */ h(n, {
|
|
3419
3654
|
className: $.list,
|
|
3420
|
-
children: e.items.map((e, n) => /* @__PURE__ */
|
|
3655
|
+
children: e.items.map((e, n) => /* @__PURE__ */ h("li", { children: zt(e, t, `${r}-${n}`) }, n))
|
|
3421
3656
|
}, r);
|
|
3422
3657
|
}
|
|
3423
|
-
default: return /* @__PURE__ */
|
|
3658
|
+
default: return /* @__PURE__ */ h("p", {
|
|
3424
3659
|
className: $.paragraph,
|
|
3425
|
-
children:
|
|
3660
|
+
children: zt(e.text, t, r)
|
|
3426
3661
|
}, r);
|
|
3427
3662
|
}
|
|
3428
3663
|
});
|
|
3429
3664
|
}
|
|
3430
3665
|
// src/components/AskPanel.tsx
|
|
3431
|
-
var
|
|
3666
|
+
var Ht = /\[(\d+)\]/g, Ut = /* @__PURE__ */ new Set([
|
|
3667
|
+
"nothingFound",
|
|
3668
|
+
"searchOrAskDisabled",
|
|
3669
|
+
"searchOrAskUnavailable",
|
|
3670
|
+
"http404"
|
|
3671
|
+
]);
|
|
3432
3672
|
function Wt(e) {
|
|
3433
3673
|
let t = e.field.split(".")[0];
|
|
3434
3674
|
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;
|
|
3435
3675
|
}
|
|
3436
|
-
var Gt = ({ question: e, proactive: t = !1, followUps: n = !1, onSourceClick: r, label: i = "Answer", renderAnswer: a =
|
|
3437
|
-
let
|
|
3676
|
+
var Gt = ({ question: e, proactive: t = !1, followUps: n = !1, onSourceClick: r, label: i = "Answer", renderAnswer: a = Vt, onFollowUp: s, onStatusChange: u, onFilters: d, onPicks: f, listPicks: p = !0, filterLabel: m = Wt, fill: C = !1, className: O = "" }) => {
|
|
3677
|
+
let k = Lt(), { showPicks: A } = ye(), j = c(A);
|
|
3678
|
+
j.current = A, o(() => () => j.current?.(null), []);
|
|
3679
|
+
let { ask: M, reset: N, stop: P, status: F, openSource: I } = k, [L, z] = l(!1), [B, H] = l([]), [U, W] = l(""), G = c([]), K = c(null), ee = c(null), q = c(!0);
|
|
3438
3680
|
o(() => {
|
|
3439
|
-
|
|
3681
|
+
H([]), G.current = [], j.current?.(null), e?.trim() ? M(e, [], { proactive: t }) : N();
|
|
3440
3682
|
}, [
|
|
3441
3683
|
e,
|
|
3442
|
-
|
|
3443
|
-
|
|
3684
|
+
M,
|
|
3685
|
+
N
|
|
3444
3686
|
]), o(() => {
|
|
3445
|
-
u?.(
|
|
3446
|
-
}, [
|
|
3447
|
-
let
|
|
3687
|
+
u?.(F);
|
|
3688
|
+
}, [F, u]);
|
|
3689
|
+
let te = c(void 0);
|
|
3448
3690
|
o(() => {
|
|
3449
|
-
|
|
3450
|
-
}, [
|
|
3451
|
-
|
|
3452
|
-
|
|
3691
|
+
k.filters && k.filters !== te.current && (te.current = k.filters, d?.(k.filters));
|
|
3692
|
+
}, [k.filters, d]);
|
|
3693
|
+
let ne = c(void 0);
|
|
3694
|
+
o(() => {
|
|
3695
|
+
if (k.picks && k.picks !== ne.current) {
|
|
3696
|
+
ne.current = k.picks;
|
|
3697
|
+
let e = {
|
|
3698
|
+
...k.picks,
|
|
3699
|
+
askId: k.picks.askId ?? k.askId
|
|
3700
|
+
};
|
|
3701
|
+
f?.(e), p && !t && A?.(e);
|
|
3702
|
+
}
|
|
3453
3703
|
}, [
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3704
|
+
k.picks,
|
|
3705
|
+
k.askId,
|
|
3706
|
+
f,
|
|
3707
|
+
p,
|
|
3708
|
+
t,
|
|
3709
|
+
A
|
|
3710
|
+
]), o(() => {
|
|
3711
|
+
let e = ee.current;
|
|
3712
|
+
C && e && q.current && (e.scrollTop = e.scrollHeight);
|
|
3713
|
+
}, [
|
|
3714
|
+
C,
|
|
3715
|
+
k.answer,
|
|
3716
|
+
k.steps.length,
|
|
3717
|
+
F,
|
|
3718
|
+
B.length
|
|
3459
3719
|
]);
|
|
3460
|
-
let
|
|
3461
|
-
let e =
|
|
3462
|
-
e && (
|
|
3463
|
-
},
|
|
3720
|
+
let J = () => {
|
|
3721
|
+
let e = ee.current;
|
|
3722
|
+
e && (q.current = e.scrollHeight - e.scrollTop - e.clientHeight < 40);
|
|
3723
|
+
}, X = (e) => e && /* @__PURE__ */ g("div", {
|
|
3464
3724
|
className: $.searched,
|
|
3465
3725
|
children: [
|
|
3466
|
-
/* @__PURE__ */
|
|
3726
|
+
/* @__PURE__ */ g("span", {
|
|
3467
3727
|
className: $.searchedLabel,
|
|
3468
3728
|
children: [e.more ? `${e.found}+` : e.found, " found"]
|
|
3469
3729
|
}),
|
|
3470
|
-
e.filters.map((e, t) => /* @__PURE__ */
|
|
3471
|
-
e.text && /* @__PURE__ */
|
|
3730
|
+
e.filters.map((e, t) => /* @__PURE__ */ h(w, { children: m(e) }, t)),
|
|
3731
|
+
e.text && /* @__PURE__ */ g("span", {
|
|
3472
3732
|
className: $.searchedLabel,
|
|
3473
3733
|
children: [
|
|
3474
3734
|
"β",
|
|
@@ -3476,7 +3736,7 @@ var Gt = ({ question: e, proactive: t = !1, followUps: n = !1, onSourceClick: r,
|
|
|
3476
3736
|
"β"
|
|
3477
3737
|
]
|
|
3478
3738
|
}),
|
|
3479
|
-
e.sort && /* @__PURE__ */
|
|
3739
|
+
e.sort && /* @__PURE__ */ g("span", {
|
|
3480
3740
|
className: $.searchedLabel,
|
|
3481
3741
|
children: [
|
|
3482
3742
|
"sorted by ",
|
|
@@ -3488,140 +3748,152 @@ var Gt = ({ question: e, proactive: t = !1, followUps: n = !1, onSourceClick: r,
|
|
|
3488
3748
|
})
|
|
3489
3749
|
]
|
|
3490
3750
|
});
|
|
3491
|
-
if (
|
|
3492
|
-
let
|
|
3493
|
-
n.preventDefault(),
|
|
3494
|
-
},
|
|
3751
|
+
if (F === "idle" && B.length === 0) return null;
|
|
3752
|
+
let re = (e, t) => (n) => {
|
|
3753
|
+
n.preventDefault(), I(e, t), r?.(e);
|
|
3754
|
+
}, ie = (e, t) => (n) => {
|
|
3495
3755
|
let i = e.find((e) => e.n === n);
|
|
3496
|
-
return /* @__PURE__ */
|
|
3756
|
+
return /* @__PURE__ */ h(E, {
|
|
3497
3757
|
n,
|
|
3498
3758
|
title: i?.title,
|
|
3499
|
-
onClick: i && r ?
|
|
3759
|
+
onClick: i && r ? re(i, t) : void 0
|
|
3500
3760
|
});
|
|
3501
|
-
},
|
|
3502
|
-
let r = new Set([...e.matchAll(
|
|
3761
|
+
}, ae = (e, t, n) => {
|
|
3762
|
+
let r = new Set([...e.matchAll(Ht)].map((e) => Number(e[1])));
|
|
3503
3763
|
return n && r.size > 0 ? t.filter((e) => r.has(e.n)) : t.slice(0, 3);
|
|
3504
|
-
},
|
|
3505
|
-
let
|
|
3506
|
-
return
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3764
|
+
}, Z = (e, t, n, i, a = !1) => {
|
|
3765
|
+
let o = a ? t : ae(e, t, n);
|
|
3766
|
+
return o.length > 0 && /* @__PURE__ */ h(T, {
|
|
3767
|
+
label: a ? "Picked" : void 0,
|
|
3768
|
+
items: o.map((e) => ({
|
|
3769
|
+
n: e.n,
|
|
3770
|
+
title: e.title,
|
|
3771
|
+
onClick: r ? re(e, i) : void 0
|
|
3772
|
+
}))
|
|
3773
|
+
});
|
|
3774
|
+
}, oe = () => {
|
|
3775
|
+
navigator.clipboard?.writeText(k.answer.replace(Ht, "")).catch(() => {}), z(!0), setTimeout(() => z(!1), 2e3);
|
|
3776
|
+
}, se = (e) => {
|
|
3777
|
+
if (!k.busy && e.trim()) {
|
|
3778
|
+
if (F === "answered" && k.answer) {
|
|
3516
3779
|
let e = {
|
|
3517
|
-
question:
|
|
3518
|
-
answer:
|
|
3519
|
-
sources:
|
|
3520
|
-
askId:
|
|
3521
|
-
filters:
|
|
3780
|
+
question: k.question,
|
|
3781
|
+
answer: k.answer,
|
|
3782
|
+
sources: k.sources,
|
|
3783
|
+
askId: k.askId,
|
|
3784
|
+
filters: k.filters,
|
|
3785
|
+
picks: k.picks
|
|
3522
3786
|
};
|
|
3523
|
-
|
|
3787
|
+
H((t) => [...t, e]), G.current = [...G.current, {
|
|
3524
3788
|
question: e.question,
|
|
3525
3789
|
answer: e.answer,
|
|
3526
|
-
...e.
|
|
3790
|
+
...e.picks ? { shown: { picks: e.picks.picks.map((e) => ({
|
|
3791
|
+
documentKey: e.documentKey,
|
|
3792
|
+
title: e.title
|
|
3793
|
+
})) } } : e.filters ? { shown: {
|
|
3527
3794
|
filters: e.filters.filters,
|
|
3528
3795
|
text: e.filters.text,
|
|
3529
3796
|
sort: e.filters.sort ?? null
|
|
3530
3797
|
} } : {}
|
|
3531
3798
|
}];
|
|
3532
3799
|
}
|
|
3533
|
-
|
|
3800
|
+
W(""), M(e, G.current);
|
|
3534
3801
|
}
|
|
3535
|
-
},
|
|
3536
|
-
return /* @__PURE__ */
|
|
3537
|
-
className: `${$.panel} ${
|
|
3802
|
+
}, ce = n ? () => K.current?.focus() : s;
|
|
3803
|
+
return /* @__PURE__ */ g("div", {
|
|
3804
|
+
className: `${$.panel} ${C ? $.fill : ""} ${O}`,
|
|
3538
3805
|
"aria-live": "polite",
|
|
3539
|
-
"aria-busy":
|
|
3540
|
-
children: [/* @__PURE__ */
|
|
3541
|
-
ref:
|
|
3806
|
+
"aria-busy": k.busy,
|
|
3807
|
+
children: [/* @__PURE__ */ g("div", {
|
|
3808
|
+
ref: ee,
|
|
3542
3809
|
className: $.thread,
|
|
3543
|
-
onScroll:
|
|
3544
|
-
children: [
|
|
3810
|
+
onScroll: C ? J : void 0,
|
|
3811
|
+
children: [B.map((e, t) => /* @__PURE__ */ g("div", {
|
|
3545
3812
|
className: $.turn,
|
|
3546
|
-
children: [/* @__PURE__ */
|
|
3813
|
+
children: [/* @__PURE__ */ h(V, { children: e.question }), /* @__PURE__ */ g(x, {
|
|
3547
3814
|
label: i,
|
|
3548
3815
|
children: [
|
|
3549
|
-
|
|
3550
|
-
/* @__PURE__ */
|
|
3816
|
+
X(e.filters),
|
|
3817
|
+
/* @__PURE__ */ h("div", {
|
|
3551
3818
|
className: $.answer,
|
|
3552
|
-
children: a(e.answer,
|
|
3819
|
+
children: a(e.answer, ie(e.sources, e.askId))
|
|
3553
3820
|
}),
|
|
3554
|
-
|
|
3821
|
+
Z(e.answer, e.sources, !0, e.askId, !!e.picks)
|
|
3555
3822
|
]
|
|
3556
3823
|
})]
|
|
3557
|
-
}, t)),
|
|
3824
|
+
}, t)), F !== "idle" && /* @__PURE__ */ g("div", {
|
|
3558
3825
|
className: $.turn,
|
|
3559
|
-
children: [/* @__PURE__ */
|
|
3826
|
+
children: [/* @__PURE__ */ h(V, { children: k.question }), /* @__PURE__ */ g(x, {
|
|
3560
3827
|
label: i,
|
|
3561
3828
|
children: [
|
|
3562
|
-
|
|
3563
|
-
|
|
3829
|
+
X(k.filters),
|
|
3830
|
+
k.answer && /* @__PURE__ */ h("div", {
|
|
3564
3831
|
className: $.answer,
|
|
3565
|
-
children: a(
|
|
3832
|
+
children: a(k.answer, ie(k.sources))
|
|
3566
3833
|
}),
|
|
3567
|
-
|
|
3834
|
+
F === "searching" && k.steps.length > 0 && /* @__PURE__ */ g("div", {
|
|
3568
3835
|
className: $.steps,
|
|
3569
|
-
children: [
|
|
3836
|
+
children: [k.steps.slice(0, -1).map((e, t) => /* @__PURE__ */ h("span", {
|
|
3570
3837
|
className: $.stepDone,
|
|
3571
3838
|
children: e
|
|
3572
|
-
}, t)), /* @__PURE__ */
|
|
3839
|
+
}, t)), /* @__PURE__ */ g(R, { children: [k.steps[k.steps.length - 1], "β¦"] })]
|
|
3573
3840
|
}),
|
|
3574
|
-
|
|
3575
|
-
|
|
3841
|
+
F === "searching" && k.steps.length === 0 && /* @__PURE__ */ h(R, { children: "Searchingβ¦" }),
|
|
3842
|
+
F === "writing" && /* @__PURE__ */ h(R, {
|
|
3576
3843
|
spinner: "grow",
|
|
3577
3844
|
children: "Writingβ¦"
|
|
3578
3845
|
}),
|
|
3579
|
-
|
|
3846
|
+
F === "error" && /* @__PURE__ */ g(_, {
|
|
3580
3847
|
variant: "default",
|
|
3581
3848
|
icon: null,
|
|
3582
3849
|
children: [
|
|
3583
|
-
/* @__PURE__ */
|
|
3584
|
-
/* @__PURE__ */
|
|
3585
|
-
|
|
3850
|
+
/* @__PURE__ */ h(y, { children: k.error?.code === "nothingFound" ? "Nothing to answer from" : "The answer did not come through" }),
|
|
3851
|
+
/* @__PURE__ */ h(v, { children: k.error?.code === "nothingFound" ? "The search found no records about this. Try other words, or search instead." : k.error?.message }),
|
|
3852
|
+
!Ut.has(k.error?.code ?? "") && /* @__PURE__ */ h("div", {
|
|
3586
3853
|
className: $.action,
|
|
3587
|
-
children: /* @__PURE__ */
|
|
3854
|
+
children: /* @__PURE__ */ h(S, {
|
|
3588
3855
|
variant: "secondary",
|
|
3589
3856
|
size: "micro",
|
|
3590
|
-
iconLeft: /* @__PURE__ */
|
|
3591
|
-
onClick: () =>
|
|
3857
|
+
iconLeft: /* @__PURE__ */ h(Y, {}),
|
|
3858
|
+
onClick: () => M(k.question, G.current),
|
|
3592
3859
|
children: "Try again"
|
|
3593
3860
|
})
|
|
3594
3861
|
})
|
|
3595
3862
|
]
|
|
3596
3863
|
}),
|
|
3597
|
-
|
|
3864
|
+
F === "limited" && k.limit === "budget" && /* @__PURE__ */ g(_, {
|
|
3865
|
+
variant: "default",
|
|
3866
|
+
icon: null,
|
|
3867
|
+
children: [/* @__PURE__ */ h(y, { children: "No more answers today" }), /* @__PURE__ */ h(v, { children: "This site has answered all the questions it can for today. Search still works, and asking is back tomorrow." })]
|
|
3868
|
+
}),
|
|
3869
|
+
F === "limited" && k.limit !== "budget" && /* @__PURE__ */ g(_, {
|
|
3598
3870
|
variant: "default",
|
|
3599
3871
|
icon: null,
|
|
3600
|
-
children: [/* @__PURE__ */
|
|
3872
|
+
children: [/* @__PURE__ */ h(y, { children: "Too many questions for now" }), /* @__PURE__ */ g(v, { children: [
|
|
3601
3873
|
"You can ask again in about ",
|
|
3602
|
-
|
|
3874
|
+
k.retryAfterSeconds && k.retryAfterSeconds > 90 ? `${Math.ceil(k.retryAfterSeconds / 60)} minutes` : "a minute",
|
|
3603
3875
|
". Search still works in the meantime."
|
|
3604
3876
|
] })]
|
|
3605
3877
|
}),
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
onCopy:
|
|
3609
|
-
copied:
|
|
3610
|
-
onFollowUp:
|
|
3878
|
+
F !== "error" && F !== "limited" && Z(k.answer, k.sources, F === "answered", void 0, !!k.picks),
|
|
3879
|
+
F === "answered" && /* @__PURE__ */ h(b, {
|
|
3880
|
+
onCopy: oe,
|
|
3881
|
+
copied: L,
|
|
3882
|
+
onFollowUp: ce
|
|
3611
3883
|
})
|
|
3612
3884
|
]
|
|
3613
3885
|
})]
|
|
3614
3886
|
})]
|
|
3615
|
-
}), n && /* @__PURE__ */
|
|
3616
|
-
ref:
|
|
3617
|
-
value:
|
|
3618
|
-
onChange:
|
|
3619
|
-
onSend:
|
|
3620
|
-
onStop:
|
|
3621
|
-
streaming:
|
|
3887
|
+
}), n && /* @__PURE__ */ h(D, {
|
|
3888
|
+
ref: K,
|
|
3889
|
+
value: U,
|
|
3890
|
+
onChange: W,
|
|
3891
|
+
onSend: se,
|
|
3892
|
+
onStop: P,
|
|
3893
|
+
streaming: k.busy,
|
|
3622
3894
|
placeholder: "Ask a follow-upβ¦",
|
|
3623
3895
|
"aria-label": "Ask a follow-up"
|
|
3624
3896
|
})]
|
|
3625
3897
|
});
|
|
3626
3898
|
};
|
|
3627
|
-
export {
|
|
3899
|
+
export { He as ActiveFiltersPanel, Gt as AskPanel, Tt as BucketFilterPanel, xe as DEFAULT_THRESHOLDS, ft as FilterPanelSkeleton, Z as IndxApiError, Le as QuickAnswer, St as RangeFilterPanel, De as STRICT_MATCH, _e as SearchContext, Nt as SearchErrorBoundary, We as SearchInput, ve as SearchProvider, Xe as SearchResult, lt as SearchResultRow, st as SearchResults, qe as SearchResultsMessage, $e as SearchResultsSkeleton, Mt as SearchSettingsPanel, oe as SearchSetupError, Dt as SortByPanel, gt as ValueFilterPanel, se as describeSearchError, Ce as isIdentifier, tt as localFilters, Ee as nextOffer, be as pageMode, Te as triggers, Lt as useAsk, nt as useFilterSuggestion, Ft as useHybridSearch, ye as useSearch, ye as useSearchContext, Pe as useSearchOrAsk, Pt as useVectorSearch };
|