@indxsearch/intrface 3.13.0 → 3.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/index.cjs.js +3 -3
- package/dist/index.es.js +432 -430
- package/package.json +2 -2
package/dist/index.es.js
CHANGED
|
@@ -3,9 +3,9 @@ import e, { Component as t, createContext as n, memo as r, useCallback as i, use
|
|
|
3
3
|
import { SystemState as u } from "@indxsearch/indx-types";
|
|
4
4
|
import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
5
5
|
import { Alert as m, AlertDescription as h, AlertTitle as g, AnswerActions as _, AssistantMessage as v, Button as y, Checkbox as b, Chip as x, CitationList as S, CitationRef as C, Composer as w, FilterPanelBase as T, InputField as E, RadioButton as D, SearchField as O, Select as k, Skeleton as A, Slider as j, StreamStatus as M, ToggleSwitch as N, Tooltip as P, UserMessage as F } from "@indxsearch/systm";
|
|
6
|
-
import { Ai_agent as I, ArrowDown as L, ArrowRight as R, Cloud as z, Enter_key as B, Filter as V, Fuzzy_search as H, Hour_glass as U, Indx as W, Key as ee, Lock as G, Refresh as te, Search as K, Speedometer as
|
|
6
|
+
import { Ai_agent as I, ArrowDown as L, ArrowRight as R, Cloud as z, Enter_key as B, Filter as V, Fuzzy_search as H, Hour_glass as U, Indx as W, Key as ee, Lock as G, Refresh as te, Search as K, Speedometer as q, Warning as ne, X_or_error as re } from "@indxsearch/pixl";
|
|
7
7
|
//#region src/context/IndxApiError.ts
|
|
8
|
-
var
|
|
8
|
+
var J = class e extends Error {
|
|
9
9
|
status;
|
|
10
10
|
code;
|
|
11
11
|
problem;
|
|
@@ -29,14 +29,14 @@ var q = class e extends Error {
|
|
|
29
29
|
let i = n.headers?.get?.("Retry-After"), a = i != null && /^\d+$/.test(i) ? Number(i) : void 0;
|
|
30
30
|
return new e(t, n.status, r, a);
|
|
31
31
|
}
|
|
32
|
-
},
|
|
32
|
+
}, Y = class extends Error {
|
|
33
33
|
constructor(e) {
|
|
34
34
|
super(e), this.name = "SearchSetupError";
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
-
function
|
|
37
|
+
function ie(e, t) {
|
|
38
38
|
let n = e instanceof Error ? e.message : String(e);
|
|
39
|
-
if (e instanceof
|
|
39
|
+
if (e instanceof Y) return {
|
|
40
40
|
kind: "setup",
|
|
41
41
|
message: n,
|
|
42
42
|
technical: n,
|
|
@@ -48,7 +48,7 @@ function 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 J) {
|
|
52
52
|
let r = {
|
|
53
53
|
message: n,
|
|
54
54
|
status: e.status,
|
|
@@ -115,15 +115,15 @@ function ae(e, t) {
|
|
|
115
115
|
}
|
|
116
116
|
//#endregion
|
|
117
117
|
//#region src/context/useIndxAuth.ts
|
|
118
|
-
function
|
|
118
|
+
function ae({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebugLogs: i = !1 }) {
|
|
119
119
|
let [a, s] = l(null), [c, d] = l(!0), [f, p] = l([]), [m, h] = l([]), [g, _] = l([]), [v, y] = l({}), [b, x] = l({}), [S, C] = l({}), [w, T] = l(0), [E, D] = l(null), [O, k] = l(null), [A, j] = l(0);
|
|
120
120
|
return o(() => {
|
|
121
121
|
(async () => {
|
|
122
122
|
D(null), k(null), d(!0);
|
|
123
123
|
try {
|
|
124
|
-
if (!r) throw console.error("[Auth] ❌ Missing bearer token"), console.error("[Auth] 💡 Pass preAuthenticatedToken to SearchProvider (create a token on the Indx Dashboard)"), new
|
|
125
|
-
if (!e) throw console.error("[Auth] ❌ Missing INDX server URL"), console.error("[Auth] 💡 Pass a url to SearchProvider"), new
|
|
126
|
-
if (!n) throw console.error("[Auth] ❌ Missing dataset name"), console.error("[Auth] 💡 Pass dataset=\"your-dataset-name\" to SearchProvider"), new
|
|
124
|
+
if (!r) throw console.error("[Auth] ❌ Missing bearer token"), console.error("[Auth] 💡 Pass preAuthenticatedToken to SearchProvider (create a token on the Indx Dashboard)"), new Y("A bearer token is required. Check console for instructions.");
|
|
125
|
+
if (!e) throw console.error("[Auth] ❌ Missing INDX server URL"), console.error("[Auth] 💡 Pass a url to SearchProvider"), new Y("INDX server URL is required. Check console for instructions.");
|
|
126
|
+
if (!n) throw console.error("[Auth] ❌ Missing dataset name"), console.error("[Auth] 💡 Pass dataset=\"your-dataset-name\" to SearchProvider"), new Y("Dataset name is required. Check console for instructions.");
|
|
127
127
|
i && console.log("[Auth] ✅ Using bearer token");
|
|
128
128
|
let a = r, o = (e) => fetch(e, {
|
|
129
129
|
method: "GET",
|
|
@@ -134,7 +134,7 @@ function oe({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebug
|
|
|
134
134
|
});
|
|
135
135
|
i && console.log("[Auth] 🔍 Checking dataset status...");
|
|
136
136
|
let c = await o(`${e}/api/teams/${t}/datasets/${n}/status`);
|
|
137
|
-
if (!c.ok) throw c.status === 401 ? (console.error("[Auth] ❌ Authentication failed (401 Unauthorized)"), console.error("[Auth] 💡 Your token may be expired or invalid"), console.error("[Auth] 💡 Create or refresh your token on the Indx Dashboard"), await
|
|
137
|
+
if (!c.ok) throw c.status === 401 ? (console.error("[Auth] ❌ Authentication failed (401 Unauthorized)"), console.error("[Auth] 💡 Your token may be expired or invalid"), console.error("[Auth] 💡 Create or refresh your token on the Indx Dashboard"), await J.fromResponse("Dataset status", c)) : c.status === 404 ? (console.error("[Auth] ❌ Dataset \"" + n + "\" not found (404)"), console.error("[Auth] 💡 Available datasets can be checked with: curl -X GET \"" + e + "/api/me/datasets\" -H \"Authorization: Bearer YOUR_TOKEN\""), console.error("[Auth] 💡 Make sure you spelled the dataset name correctly"), await J.fromResponse("Dataset status", c)) : (console.error("[Auth] ❌ Failed to get dataset status:", c.status), await J.fromResponse("Dataset status", c));
|
|
138
138
|
let l = await c.json();
|
|
139
139
|
i && console.log("[Auth] 📊 Dataset status:", l), s(a), i && console.log("[Auth] ✅ Dataset session established"), l.systemState !== void 0 && l.systemState !== u.Ready && (console.warn("[Auth] ⚠️ Dataset is not ready yet. Current state:", u[l.systemState]), console.warn("[Auth] 💡 Wait for indexing to complete before searching"));
|
|
140
140
|
let d = l.documentCount ?? l.numberOfRecords ?? 0;
|
|
@@ -145,9 +145,9 @@ function oe({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebug
|
|
|
145
145
|
o(`${e}/api/teams/${t}/datasets/${n}/fields/sortable`),
|
|
146
146
|
o(`${e}/api/teams/${t}/datasets/${n}/fields/configuration`).catch(() => null)
|
|
147
147
|
]);
|
|
148
|
-
if (!f.ok) throw console.error("[Auth] ❌ GetFilterableFields failed:", f.status), await
|
|
149
|
-
if (!m.ok) throw console.error("[Auth] ❌ GetFacetableFields failed:", m.status), await
|
|
150
|
-
if (!g.ok) throw console.error("[Auth] ❌ GetSortableFields failed:", g.status), await
|
|
148
|
+
if (!f.ok) throw console.error("[Auth] ❌ GetFilterableFields failed:", f.status), await J.fromResponse("Filterable fields", f);
|
|
149
|
+
if (!m.ok) throw console.error("[Auth] ❌ GetFacetableFields failed:", m.status), await J.fromResponse("Facetable fields", m);
|
|
150
|
+
if (!g.ok) throw console.error("[Auth] ❌ GetSortableFields failed:", g.status), await J.fromResponse("Sortable fields", g);
|
|
151
151
|
let [b, S, w] = await Promise.all([
|
|
152
152
|
f.json().catch((e) => (console.error("Failed to parse GetFilterableFields response:", e), [])),
|
|
153
153
|
m.json().catch((e) => (console.error("Failed to parse GetFacetableFields response:", e), [])),
|
|
@@ -192,7 +192,7 @@ function oe({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebug
|
|
|
192
192
|
if (D.facets) for (let [e, t] of Object.entries(D.facets)) Array.isArray(t) && (k[e] = t.map((e) => e.key));
|
|
193
193
|
x(O), C(k), i && console.log("[Auth] ✅ Initialization complete");
|
|
194
194
|
} catch (r) {
|
|
195
|
-
console.error("[Auth] ❌ Initialization failed:", r), (r instanceof Error || typeof r == "object" && r && "message" in r) && console.error("[Auth] 💡 Error:", r.message), r instanceof TypeError && r.message.includes("fetch") && (console.error("[Auth] ❌ Network error - cannot connect to INDX server"), console.error("[Auth] 💡 Check if the server is running at:", e), console.error("[Auth] 💡 Check the url you passed to SearchProvider"), console.error("[Auth] 💡 For local development, it should be: http://localhost:5001")), D(r instanceof Error ? r.message : String(r)), k(
|
|
195
|
+
console.error("[Auth] ❌ Initialization failed:", r), (r instanceof Error || typeof r == "object" && r && "message" in r) && console.error("[Auth] 💡 Error:", r.message), r instanceof TypeError && r.message.includes("fetch") && (console.error("[Auth] ❌ Network error - cannot connect to INDX server"), console.error("[Auth] 💡 Check if the server is running at:", e), console.error("[Auth] 💡 Check the url you passed to SearchProvider"), console.error("[Auth] 💡 For local development, it should be: http://localhost:5001")), D(r instanceof Error ? r.message : String(r)), k(ie(r, {
|
|
196
196
|
team: t,
|
|
197
197
|
dataset: n
|
|
198
198
|
}));
|
|
@@ -222,30 +222,30 @@ function oe({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebug
|
|
|
222
222
|
}
|
|
223
223
|
//#endregion
|
|
224
224
|
//#region src/context/buildFilterProxy.ts
|
|
225
|
-
async function
|
|
225
|
+
async function oe(e, t, n, r, i, a, o) {
|
|
226
226
|
let s = await o(`${r}/api/teams/${i}/datasets/${a}/filters/${e}`, {
|
|
227
227
|
method: "POST",
|
|
228
228
|
headers: { "Content-Type": "application/json" },
|
|
229
229
|
body: JSON.stringify(t)
|
|
230
230
|
});
|
|
231
|
-
if (!s.ok) throw await
|
|
231
|
+
if (!s.ok) throw await J.fromResponse(n, s);
|
|
232
232
|
let c = await s.json();
|
|
233
233
|
if (!c || typeof c.hashString != "string") throw Error(`${n} failed: server returned no filter token`);
|
|
234
234
|
return c;
|
|
235
235
|
}
|
|
236
|
-
async function
|
|
236
|
+
async function se(e, t, n, r, i, a) {
|
|
237
237
|
if (e.length === 0) return null;
|
|
238
238
|
if (e.length === 1) return e[0];
|
|
239
239
|
let o = e[0];
|
|
240
|
-
for (let s = 1; s < e.length; s++) o = await
|
|
240
|
+
for (let s = 1; s < e.length; s++) o = await oe("combine", {
|
|
241
241
|
a: o,
|
|
242
242
|
b: e[s],
|
|
243
243
|
useAndOperation: t === "and"
|
|
244
244
|
}, "CombineFilters", n, r, i, a);
|
|
245
245
|
return o;
|
|
246
246
|
}
|
|
247
|
-
async function
|
|
248
|
-
let l = Object.entries(e ?? {}).filter(([, e]) => e.length > 0), u = Object.entries(t ?? {}), d = Object.entries(s ?? {}).filter(([, e]) => e.length > 0), f = (e, { min: t, max: o }) =>
|
|
247
|
+
async function ce(e, t, n, r, i, a, o = {}, s = {}, c = {}) {
|
|
248
|
+
let l = Object.entries(e ?? {}).filter(([, e]) => e.length > 0), u = Object.entries(t ?? {}), d = Object.entries(s ?? {}).filter(([, e]) => e.length > 0), f = (e, { min: t, max: o }) => oe("range", {
|
|
249
249
|
fieldName: e,
|
|
250
250
|
lowerLimit: t,
|
|
251
251
|
upperLimit: o
|
|
@@ -254,16 +254,16 @@ async function le(e, t, n, r, i, a, o = {}, s = {}, c = {}) {
|
|
|
254
254
|
return Number.isFinite(o) ? f(e, {
|
|
255
255
|
min: o,
|
|
256
256
|
max: o
|
|
257
|
-
}) :
|
|
257
|
+
}) : oe("value", {
|
|
258
258
|
fieldName: e,
|
|
259
259
|
value: t
|
|
260
260
|
}, `Value filter '${e}'`, n, r, i, a);
|
|
261
261
|
}, [m, h, g] = await Promise.all([
|
|
262
|
-
Promise.all(l.map(async ([e, t]) =>
|
|
262
|
+
Promise.all(l.map(async ([e, t]) => se(await Promise.all(t.map((t) => p(e, t))), o[e] === "any" ? "or" : "and", n, r, i, a))),
|
|
263
263
|
Promise.all(u.map(([e, t]) => f(e, t))),
|
|
264
|
-
Promise.all(d.map(async ([e, t]) =>
|
|
264
|
+
Promise.all(d.map(async ([e, t]) => se(await Promise.all(t.map((t) => f(e, t))), "or", n, r, i, a)))
|
|
265
265
|
]);
|
|
266
|
-
return
|
|
266
|
+
return se([
|
|
267
267
|
...m,
|
|
268
268
|
...h,
|
|
269
269
|
...g
|
|
@@ -271,14 +271,16 @@ async function le(e, t, n, r, i, a, o = {}, s = {}, c = {}) {
|
|
|
271
271
|
}
|
|
272
272
|
//#endregion
|
|
273
273
|
//#region src/context/useSearchExecution.ts
|
|
274
|
-
function
|
|
274
|
+
function le(e, t) {
|
|
275
275
|
let n, r = (...r) => {
|
|
276
276
|
clearTimeout(n), n = setTimeout(() => e(...r), t);
|
|
277
277
|
};
|
|
278
278
|
return r.cancel = () => clearTimeout(n), r;
|
|
279
279
|
}
|
|
280
|
-
function
|
|
281
|
-
let y = v ? v(e.query) : e.query, b = c(
|
|
280
|
+
function ue({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team: s, dataset: u, allowEmptySearch: d, facetsEnabled: f, enableDebugLogs: p, shouldFetchMore: m, sessionId: h, source: g, count: _, searchTextOf: v }) {
|
|
281
|
+
let y = v ? v(e.query) : e.query, b = c(e.query);
|
|
282
|
+
b.current = e.query;
|
|
283
|
+
let x = c(0), S = c(void 0), C = c(!1), [w, T] = l({}), [E, D] = l(""), [O, k] = l("");
|
|
282
284
|
o(() => {
|
|
283
285
|
r.isFetchingInitial || t((e) => ({
|
|
284
286
|
...e,
|
|
@@ -300,9 +302,9 @@ function de({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, tea
|
|
|
300
302
|
r.sortableFields,
|
|
301
303
|
t
|
|
302
304
|
]);
|
|
303
|
-
let
|
|
305
|
+
let A = e.searchSettings.maxNumberOfRecordsToReturn, j = e.searchSettings.enableCoverage, M = e.searchSettings.removeDuplicates, N = e.searchSettings.coverageDepth, P = e.searchSettings.minimumScore, F = e.searchSettings.coverageSetup, I = e.sortBy, L = e.sortAscending, R = i(async ({ enableFacets: i }) => {
|
|
304
306
|
if (!r.token) return;
|
|
305
|
-
let o = ++
|
|
307
|
+
let o = ++x.current;
|
|
306
308
|
if (t((e) => ({
|
|
307
309
|
...e,
|
|
308
310
|
isLoading: !0
|
|
@@ -311,7 +313,7 @@ function de({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, tea
|
|
|
311
313
|
i = !0;
|
|
312
314
|
}
|
|
313
315
|
try {
|
|
314
|
-
let c = i ? Array.from(new Set([...Object.keys(e.filters).filter((t) => e.valueMatch[t] === "any" && (e.filters[t]?.length ?? 0) > 0), ...Object.keys(e.bucketFilters).filter((t) => (e.bucketFilters[t]?.length ?? 0) > 0)])) : [], [l, ...f] = await Promise.all([
|
|
316
|
+
let c = i ? Array.from(new Set([...Object.keys(e.filters).filter((t) => e.valueMatch[t] === "any" && (e.filters[t]?.length ?? 0) > 0), ...Object.keys(e.bucketFilters).filter((t) => (e.bucketFilters[t]?.length ?? 0) > 0)])) : [], [l, ...f] = await Promise.all([ce(e.filters, e.rangeFilters, a, s, u, n, e.valueMatch, e.bucketFilters, e.fieldTypes), ...c.map((t) => ce({
|
|
315
317
|
...e.filters,
|
|
316
318
|
[t]: []
|
|
317
319
|
}, e.rangeFilters, a, s, u, n, e.valueMatch, {
|
|
@@ -319,93 +321,93 @@ function de({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, tea
|
|
|
319
321
|
[t]: []
|
|
320
322
|
}, e.fieldTypes))]), m = d || y.trim() !== "", v = {
|
|
321
323
|
text: y,
|
|
322
|
-
enableCoverage:
|
|
323
|
-
removeDuplicates:
|
|
324
|
-
coverageDepth:
|
|
325
|
-
coverageSetup:
|
|
326
|
-
},
|
|
324
|
+
enableCoverage: j,
|
|
325
|
+
removeDuplicates: M,
|
|
326
|
+
coverageDepth: N,
|
|
327
|
+
coverageSetup: F
|
|
328
|
+
}, S = {
|
|
327
329
|
...v,
|
|
328
|
-
maxNumberOfRecordsToReturn: m ?
|
|
330
|
+
maxNumberOfRecordsToReturn: m ? A : 0,
|
|
329
331
|
enableFacets: i,
|
|
330
332
|
...l ? { filter: l } : {},
|
|
331
|
-
...
|
|
332
|
-
...
|
|
333
|
+
...I ? { sortBy: I } : {},
|
|
334
|
+
...L === void 0 ? {} : { sortAscending: L }
|
|
333
335
|
};
|
|
334
|
-
p && console.log("[performSearch] request body:", JSON.stringify(
|
|
335
|
-
let
|
|
336
|
-
g &&
|
|
337
|
-
let
|
|
336
|
+
p && console.log("[performSearch] request body:", JSON.stringify(S, null, 2));
|
|
337
|
+
let C = new URLSearchParams({ session: h });
|
|
338
|
+
g && C.set("source", g), _ || C.set("count", "false"), b.current.trim() !== y.trim() && C.set("typed", b.current);
|
|
339
|
+
let R = (e) => n(`${a}/api/teams/${s}/datasets/${u}/search?${C}`, {
|
|
338
340
|
method: "POST",
|
|
339
341
|
headers: { "Content-Type": "application/json" },
|
|
340
342
|
body: JSON.stringify(e)
|
|
341
|
-
}), [
|
|
343
|
+
}), [z, ...B] = await Promise.all([R(S), ...f.map((e) => R({
|
|
342
344
|
...v,
|
|
343
345
|
maxNumberOfRecordsToReturn: 0,
|
|
344
346
|
enableFacets: !0,
|
|
345
347
|
...e ? { filter: e } : {}
|
|
346
348
|
}))]);
|
|
347
|
-
if (!
|
|
348
|
-
let
|
|
349
|
+
if (!z.ok) throw await J.fromResponse("Search", z);
|
|
350
|
+
let V = await z.json(), H = z.headers.get("Indx-Query-Id") ?? void 0, U = V.truncationIndex ?? -1, W = {};
|
|
349
351
|
for (let e = 0; e < c.length; e++) {
|
|
350
352
|
let t = c[e];
|
|
351
|
-
if (!
|
|
352
|
-
let n = await
|
|
353
|
-
n.facets?.[t] !== void 0 && (
|
|
353
|
+
if (!B[e].ok) throw await J.fromResponse(`Facets for '${t}'`, B[e]);
|
|
354
|
+
let n = await B[e].json();
|
|
355
|
+
n.facets?.[t] !== void 0 && (W[t] = n.facets[t]);
|
|
354
356
|
}
|
|
355
|
-
let
|
|
356
|
-
if (m &&
|
|
357
|
+
let ee = V.records || [], G = ee.map((e) => e.documentKey), te = ee.map((e) => e.score), K = [];
|
|
358
|
+
if (m && G.length > 0) {
|
|
357
359
|
let e = await n(`${a}/api/teams/${s}/datasets/${u}/documents/lookup`, {
|
|
358
360
|
method: "POST",
|
|
359
361
|
headers: { "Content-Type": "application/json" },
|
|
360
|
-
body: JSON.stringify(
|
|
362
|
+
body: JSON.stringify(G)
|
|
361
363
|
});
|
|
362
|
-
if (!e.ok) throw await
|
|
363
|
-
|
|
364
|
+
if (!e.ok) throw await J.fromResponse("Document lookup", e);
|
|
365
|
+
K = (await e.json()).map((e, t) => ({
|
|
364
366
|
document: e,
|
|
365
|
-
documentKey:
|
|
366
|
-
score:
|
|
367
|
+
documentKey: G[t],
|
|
368
|
+
score: te[t]
|
|
367
369
|
}));
|
|
368
370
|
}
|
|
369
|
-
let
|
|
370
|
-
if (i &&
|
|
371
|
-
for (let [e, t] of Object.entries(
|
|
371
|
+
let q = {};
|
|
372
|
+
if (i && V.facets) {
|
|
373
|
+
for (let [e, t] of Object.entries(V.facets)) if (Array.isArray(t) && t.length > 0) {
|
|
372
374
|
let n = t.map((e) => Number(e.key)).filter((e) => !isNaN(e));
|
|
373
|
-
n.length > 0 && (
|
|
375
|
+
n.length > 0 && (q[e] = {
|
|
374
376
|
min: Math.min(...n),
|
|
375
377
|
max: Math.max(...n)
|
|
376
378
|
});
|
|
377
379
|
}
|
|
378
380
|
}
|
|
379
|
-
if (o !==
|
|
380
|
-
let ne = y !==
|
|
381
|
-
if (ne ? (
|
|
381
|
+
if (o !== x.current) return;
|
|
382
|
+
let ne = y !== E, re = y !== O, Y = e.facetStats ?? {};
|
|
383
|
+
if (ne ? (Y = {
|
|
382
384
|
...r.initialFacetStats,
|
|
383
|
-
...
|
|
384
|
-
},
|
|
385
|
-
...
|
|
386
|
-
...
|
|
385
|
+
...q
|
|
386
|
+
}, T(Y), D(y)) : Y = {
|
|
387
|
+
...w,
|
|
388
|
+
...q
|
|
387
389
|
}, re && i) {
|
|
388
390
|
let n = { ...e.rangeBounds };
|
|
389
|
-
for (let [e, t] of Object.entries(
|
|
391
|
+
for (let [e, t] of Object.entries(q)) n[e] = t;
|
|
390
392
|
t((e) => ({
|
|
391
393
|
...e,
|
|
392
394
|
rangeBounds: n
|
|
393
|
-
})),
|
|
395
|
+
})), k(y);
|
|
394
396
|
}
|
|
395
|
-
let
|
|
396
|
-
...
|
|
397
|
-
...
|
|
398
|
-
} :
|
|
399
|
-
if (i && (!
|
|
400
|
-
|
|
401
|
-
for (let [e, t] of Object.entries(r.initialFacetKeys))
|
|
397
|
+
let ie = Object.keys(W).length > 0 ? {
|
|
398
|
+
...V.facets ?? {},
|
|
399
|
+
...W
|
|
400
|
+
} : V.facets;
|
|
401
|
+
if (i && (!ie || Object.keys(ie).length === 0)) {
|
|
402
|
+
ie = {};
|
|
403
|
+
for (let [e, t] of Object.entries(r.initialFacetKeys)) ie[e] = t.map((e) => ({
|
|
402
404
|
key: e,
|
|
403
405
|
value: null
|
|
404
406
|
}));
|
|
405
407
|
}
|
|
406
|
-
let ae =
|
|
408
|
+
let ae = K.filter((e) => {
|
|
407
409
|
let t = y.trim();
|
|
408
|
-
return t === "" || t.length === 1 ? !0 : e.score >=
|
|
410
|
+
return t === "" || t.length === 1 ? !0 : e.score >= P;
|
|
409
411
|
}).map((e, t) => ({
|
|
410
412
|
...e,
|
|
411
413
|
position: t + 1
|
|
@@ -417,22 +419,22 @@ function de({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, tea
|
|
|
417
419
|
errorInfo: void 0,
|
|
418
420
|
resultsSuppressed: !m,
|
|
419
421
|
...i ? {
|
|
420
|
-
facets:
|
|
421
|
-
facetStats:
|
|
422
|
+
facets: ie,
|
|
423
|
+
facetStats: Y
|
|
422
424
|
} : {},
|
|
423
425
|
isLoading: !1,
|
|
424
|
-
truncationIndex:
|
|
425
|
-
queryId:
|
|
426
|
+
truncationIndex: U,
|
|
427
|
+
queryId: H
|
|
426
428
|
}));
|
|
427
429
|
} catch (e) {
|
|
428
|
-
if (console.error("[Search] ❌ Search failed:", e), e instanceof TypeError && e.message.includes("fetch") ? (console.error("[Search] ❌ Network error - cannot reach INDX server"), console.error("[Search] 💡 Check if server is running at:", a)) : e instanceof Error && (e.message.includes("401") ? (console.error("[Search] ❌ Authentication failed"), console.error("[Search] 💡 Your token may have expired. Create or refresh it on the Indx Dashboard.")) : e.message.includes("404") ? (console.error("[Search] ❌ Dataset not found"), console.error("[Search] 💡 Check that dataset \"" + u + "\" exists")) : console.error("[Search] 💡 Error:", e.message)), o !==
|
|
430
|
+
if (console.error("[Search] ❌ Search failed:", e), e instanceof TypeError && e.message.includes("fetch") ? (console.error("[Search] ❌ Network error - cannot reach INDX server"), console.error("[Search] 💡 Check if server is running at:", a)) : e instanceof Error && (e.message.includes("401") ? (console.error("[Search] ❌ Authentication failed"), console.error("[Search] 💡 Your token may have expired. Create or refresh it on the Indx Dashboard.")) : e.message.includes("404") ? (console.error("[Search] ❌ Dataset not found"), console.error("[Search] 💡 Check that dataset \"" + u + "\" exists")) : console.error("[Search] 💡 Error:", e.message)), o !== x.current) return;
|
|
429
431
|
t((t) => ({
|
|
430
432
|
...t,
|
|
431
433
|
results: null,
|
|
432
434
|
isLoading: !1,
|
|
433
435
|
resultsSuppressed: !1,
|
|
434
436
|
error: e instanceof Error ? e.message : "Search failed",
|
|
435
|
-
errorInfo:
|
|
437
|
+
errorInfo: ie(e, {
|
|
436
438
|
team: s,
|
|
437
439
|
dataset: u
|
|
438
440
|
})
|
|
@@ -445,21 +447,21 @@ function de({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, tea
|
|
|
445
447
|
e.rangeFilters,
|
|
446
448
|
e.bucketFilters,
|
|
447
449
|
e.facetStats,
|
|
448
|
-
F,
|
|
449
450
|
I,
|
|
450
|
-
|
|
451
|
+
L,
|
|
451
452
|
A,
|
|
452
453
|
j,
|
|
453
454
|
M,
|
|
454
|
-
P,
|
|
455
455
|
N,
|
|
456
|
+
F,
|
|
457
|
+
P,
|
|
456
458
|
n,
|
|
457
459
|
r.initialFacetStats,
|
|
458
460
|
r.initialFacetKeys,
|
|
459
461
|
r.token,
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
462
|
+
w,
|
|
463
|
+
E,
|
|
464
|
+
O,
|
|
463
465
|
e.rangeBounds,
|
|
464
466
|
a,
|
|
465
467
|
s,
|
|
@@ -472,22 +474,22 @@ function de({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, tea
|
|
|
472
474
|
_
|
|
473
475
|
]);
|
|
474
476
|
o(() => {
|
|
475
|
-
|
|
476
|
-
}, [
|
|
477
|
-
let
|
|
478
|
-
o(() => (
|
|
479
|
-
p && console.log("Debounced searchWithFacets fired"),
|
|
477
|
+
S.current = R;
|
|
478
|
+
}, [R]);
|
|
479
|
+
let z = c(null);
|
|
480
|
+
o(() => (z.current?.cancel(), z.current = le(() => {
|
|
481
|
+
p && console.log("Debounced searchWithFacets fired"), S.current?.({ enableFacets: !0 });
|
|
480
482
|
}, e.facetDebounceDelayMillis ?? 500), () => {
|
|
481
|
-
|
|
483
|
+
z.current?.cancel();
|
|
482
484
|
}), [e.facetDebounceDelayMillis]), o(() => {
|
|
483
|
-
!r.isFetchingInitial && r.token && !
|
|
485
|
+
!r.isFetchingInitial && r.token && !C.current && (d && S.current?.({ enableFacets: f }), C.current = !0);
|
|
484
486
|
}, [
|
|
485
487
|
r.isFetchingInitial,
|
|
486
488
|
r.token,
|
|
487
489
|
d,
|
|
488
490
|
f
|
|
489
491
|
]), o(() => {
|
|
490
|
-
if (!r.token || !
|
|
492
|
+
if (!r.token || !C.current) return;
|
|
491
493
|
let n = y.trim(), i = n === "" && d;
|
|
492
494
|
if (n === "" && !d) {
|
|
493
495
|
e.resultsSuppressed || t((e) => ({
|
|
@@ -496,56 +498,56 @@ function de({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, tea
|
|
|
496
498
|
}));
|
|
497
499
|
return;
|
|
498
500
|
}
|
|
499
|
-
return i ? (
|
|
500
|
-
|
|
501
|
+
return i ? (z.current?.cancel(), S.current?.({ enableFacets: f })) : f ? (p && console.log("Search fired"), S.current?.({ enableFacets: !1 }), z.current?.()) : S.current?.({ enableFacets: !1 }), () => {
|
|
502
|
+
z.current?.cancel();
|
|
501
503
|
};
|
|
502
504
|
}, [
|
|
503
505
|
y,
|
|
504
506
|
d,
|
|
505
507
|
f
|
|
506
508
|
]), o(() => {
|
|
507
|
-
if (!
|
|
509
|
+
if (!C.current || !r.token || e.filterRevision === 0) return;
|
|
508
510
|
let t = y.trim();
|
|
509
|
-
!d && t === "" ||
|
|
511
|
+
!d && t === "" || S.current?.({ enableFacets: f });
|
|
510
512
|
}, [e.filterRevision]), o(() => {
|
|
511
|
-
if (!
|
|
513
|
+
if (!C.current || !r.token) return;
|
|
512
514
|
let e = y.trim();
|
|
513
|
-
!d && e === "" ||
|
|
514
|
-
}, [
|
|
515
|
-
let
|
|
515
|
+
!d && e === "" || S.current?.({ enableFacets: f });
|
|
516
|
+
}, [I, L]);
|
|
517
|
+
let B = c(!0), V = c(y);
|
|
516
518
|
return o(() => {
|
|
517
|
-
if (
|
|
518
|
-
|
|
519
|
+
if (B.current) {
|
|
520
|
+
B.current = !1;
|
|
519
521
|
return;
|
|
520
522
|
}
|
|
521
|
-
if (
|
|
523
|
+
if (V.current !== y || !C.current || !r.token) return;
|
|
522
524
|
if (m.current) {
|
|
523
|
-
m.current = !1,
|
|
525
|
+
m.current = !1, S.current?.({ enableFacets: !1 });
|
|
524
526
|
return;
|
|
525
527
|
}
|
|
526
528
|
let e = y.trim();
|
|
527
|
-
!d && e === "" ||
|
|
529
|
+
!d && e === "" || S.current?.({ enableFacets: f });
|
|
528
530
|
}, [
|
|
529
|
-
k,
|
|
530
531
|
A,
|
|
531
532
|
j,
|
|
532
533
|
M,
|
|
533
|
-
|
|
534
|
-
|
|
534
|
+
N,
|
|
535
|
+
F,
|
|
536
|
+
P
|
|
535
537
|
]), o(() => {
|
|
536
|
-
|
|
538
|
+
V.current = y;
|
|
537
539
|
}, [y]), { retrySearch: i(() => {
|
|
538
|
-
|
|
540
|
+
S.current?.({ enableFacets: f });
|
|
539
541
|
}, [f]) };
|
|
540
542
|
}
|
|
541
543
|
//#endregion
|
|
542
544
|
//#region src/context/SearchContext.tsx
|
|
543
|
-
function
|
|
545
|
+
function de() {
|
|
544
546
|
let e = globalThis.crypto;
|
|
545
547
|
return e?.randomUUID ? e.randomUUID() : Math.random().toString(36).slice(2) + Date.now().toString(36);
|
|
546
548
|
}
|
|
547
|
-
var
|
|
548
|
-
let S = c(!1), C = c(
|
|
549
|
+
var fe = "Type to search", pe = n(void 0), me = ({ children: e, url: t, team: n, dataset: r, allowEmptySearch: a = !1, maxResults: s = 10, facetDebounceDelayMillis: u = 500, enableFacets: d = !0, coverageDepth: p, removeDuplicates: m = !0, enableCoverage: h = !0, initialCoverageSetup: g = {}, enableDebugLogs: _ = !1, preAuthenticatedToken: v, source: y, count: b = !0, searchTextOf: x }) => {
|
|
550
|
+
let S = c(!1), C = c(de()).current, [w, T] = l({ fn: null }), [E, D] = l(null), O = i((e) => {
|
|
549
551
|
let t = x ?? w.fn;
|
|
550
552
|
return !t || e === E ? e : t(e);
|
|
551
553
|
}, [
|
|
@@ -577,7 +579,7 @@ var pe = "Type to search", me = n(void 0), he = ({ children: e, url: t, team: n,
|
|
|
577
579
|
removeDuplicates: m,
|
|
578
580
|
minimumScore: 0,
|
|
579
581
|
showScore: !0,
|
|
580
|
-
placeholderText:
|
|
582
|
+
placeholderText: fe,
|
|
581
583
|
coverageSetup: { ...g }
|
|
582
584
|
}
|
|
583
585
|
});
|
|
@@ -589,7 +591,7 @@ var pe = "Type to search", me = n(void 0), he = ({ children: e, url: t, team: n,
|
|
|
589
591
|
facetDebounceDelayMillis: u
|
|
590
592
|
}));
|
|
591
593
|
}, [u]);
|
|
592
|
-
let [N] = l(d), P =
|
|
594
|
+
let [N] = l(d), P = ae({
|
|
593
595
|
url: t,
|
|
594
596
|
team: n,
|
|
595
597
|
dataset: r,
|
|
@@ -604,7 +606,7 @@ var pe = "Type to search", me = n(void 0), he = ({ children: e, url: t, team: n,
|
|
|
604
606
|
Authorization: `Bearer ${P.token}`
|
|
605
607
|
}
|
|
606
608
|
});
|
|
607
|
-
}, [P.token]), { retrySearch: I } =
|
|
609
|
+
}, [P.token]), { retrySearch: I } = ue({
|
|
608
610
|
state: j,
|
|
609
611
|
setState: M,
|
|
610
612
|
authenticatedFetch: F,
|
|
@@ -744,32 +746,32 @@ var pe = "Type to search", me = n(void 0), he = ({ children: e, url: t, team: n,
|
|
|
744
746
|
filterRevision: n.filterRevision + +!!t
|
|
745
747
|
};
|
|
746
748
|
});
|
|
747
|
-
}, []),
|
|
749
|
+
}, []), q = (e, t) => e.min === t.min && e.max === t.max, ne = i((e, t, n = !1) => {
|
|
748
750
|
M((r) => {
|
|
749
|
-
let i = r.bucketFilters[e] ?? [], a = i.some((e) =>
|
|
751
|
+
let i = r.bucketFilters[e] ?? [], a = i.some((e) => q(e, t)) ? i.filter((e) => !q(e, t)) : n ? [t] : [...i, t], o = { ...r.bucketFilters };
|
|
750
752
|
return a.length > 0 ? o[e] = a : delete o[e], {
|
|
751
753
|
...r,
|
|
752
754
|
bucketFilters: o,
|
|
753
755
|
filterRevision: r.filterRevision + 1
|
|
754
756
|
};
|
|
755
757
|
});
|
|
756
|
-
}, []),
|
|
758
|
+
}, []), re = i((e, t, n = !0) => {
|
|
757
759
|
M((r) => {
|
|
758
|
-
let i = { ...r.bucketFilters }, a = t ? (i[e] ?? []).filter((e) => !
|
|
760
|
+
let i = { ...r.bucketFilters }, a = t ? (i[e] ?? []).filter((e) => !q(e, t)) : [];
|
|
759
761
|
return a.length > 0 ? i[e] = a : delete i[e], {
|
|
760
762
|
...r,
|
|
761
763
|
bucketFilters: i,
|
|
762
764
|
filterRevision: r.filterRevision + +!!n
|
|
763
765
|
};
|
|
764
766
|
});
|
|
765
|
-
}, []),
|
|
767
|
+
}, []), J = i((e, t) => {
|
|
766
768
|
M((n) => ({
|
|
767
769
|
...n,
|
|
768
770
|
sortBy: e || void 0,
|
|
769
771
|
sortAscending: e ? t : void 0
|
|
770
772
|
}));
|
|
771
773
|
}, []);
|
|
772
|
-
return /* @__PURE__ */ f(
|
|
774
|
+
return /* @__PURE__ */ f(pe.Provider, {
|
|
773
775
|
value: {
|
|
774
776
|
state: j,
|
|
775
777
|
isFetchingInitial: P.isFetchingInitial || !j.fieldsSeeded,
|
|
@@ -790,9 +792,9 @@ var pe = "Type to search", me = n(void 0), he = ({ children: e, url: t, team: n,
|
|
|
790
792
|
resetFilters: G,
|
|
791
793
|
resetSingleFilter: te,
|
|
792
794
|
resetRangeFilter: K,
|
|
793
|
-
toggleBucketFilter:
|
|
794
|
-
resetBucketFilter:
|
|
795
|
-
setSort:
|
|
795
|
+
toggleBucketFilter: ne,
|
|
796
|
+
resetBucketFilter: re,
|
|
797
|
+
setSort: J,
|
|
796
798
|
setDebounceDelay: B,
|
|
797
799
|
setSearchSettings: V,
|
|
798
800
|
fetchMoreResults: H,
|
|
@@ -806,50 +808,50 @@ var pe = "Type to search", me = n(void 0), he = ({ children: e, url: t, team: n,
|
|
|
806
808
|
},
|
|
807
809
|
children: e
|
|
808
810
|
});
|
|
809
|
-
},
|
|
810
|
-
let e = a(
|
|
811
|
+
}, X = () => {
|
|
812
|
+
let e = a(pe);
|
|
811
813
|
if (!e) throw Error("useSearchContext must be used within a SearchProvider");
|
|
812
814
|
return e;
|
|
813
|
-
},
|
|
815
|
+
}, he = {
|
|
814
816
|
strong: .65,
|
|
815
817
|
strongHide: .45,
|
|
816
818
|
invite: .4,
|
|
817
819
|
inviteHide: .3
|
|
818
|
-
},
|
|
819
|
-
function
|
|
820
|
+
}, ge = new Set(/* @__PURE__ */ "hvordan.hva.hvorfor.hvor.hvilken.hvilke.hvilket.hvem.når.kan.skal.må.bør.er.går.finnes.trenger.how.what.why.where.which.who.when.can.should.does.do.is.are.will.could.would".split(".")), _e = /^[\d\s\-_.:/]+$|^\w+\.\w+|^[A-Za-z]*[a-z][A-Z]\w*$|^[A-Za-z]+[-_]?\d[\w-]*$/;
|
|
821
|
+
function ve(e) {
|
|
820
822
|
let t = e.trim();
|
|
821
|
-
return t.length > 0 && !t.includes(" ") &&
|
|
823
|
+
return t.length > 0 && !t.includes(" ") && _e.test(t);
|
|
822
824
|
}
|
|
823
|
-
function
|
|
825
|
+
function ye(e) {
|
|
824
826
|
let t = e.trim();
|
|
825
|
-
if (!t ||
|
|
827
|
+
if (!t || ve(t)) return !1;
|
|
826
828
|
let n = t.split(/\s+/);
|
|
827
|
-
return t.endsWith("?") || n.length > 1 &&
|
|
829
|
+
return t.endsWith("?") || n.length > 1 && ge.has(n[0].toLowerCase()) || n.length >= 3 ? !0 : t.length >= 4;
|
|
828
830
|
}
|
|
829
|
-
function
|
|
831
|
+
function be(e, t, n = he) {
|
|
830
832
|
return t >= n.strong || e === "strong" && t >= n.strongHide ? "strong" : t >= n.invite || e !== "none" && t >= n.inviteHide ? "invite" : "none";
|
|
831
833
|
}
|
|
832
|
-
var
|
|
834
|
+
var xe = {
|
|
833
835
|
shareOfTop: .5,
|
|
834
836
|
topFloor: .2
|
|
835
|
-
},
|
|
837
|
+
}, Se = {
|
|
836
838
|
coverFuzzyWords: !1,
|
|
837
839
|
coverPrefixSuffix: !1,
|
|
838
840
|
coverJoinedWords: !1,
|
|
839
841
|
minWordSize: 3
|
|
840
|
-
},
|
|
841
|
-
function
|
|
842
|
+
}, Ce = 65535;
|
|
843
|
+
function we(e, t, n, r = xe) {
|
|
842
844
|
if (!n || e.length === 0) return e;
|
|
843
845
|
let i = e[0].score;
|
|
844
846
|
if (i < r.topFloor * 65535) return [];
|
|
845
847
|
let a = t == null ? e : t < 0 ? [] : e.slice(0, t + 1), o = r.shareOfTop * i, s = a.findIndex((e) => e.score < o);
|
|
846
848
|
return s < 0 ? a : a.slice(0, s);
|
|
847
849
|
}
|
|
848
|
-
function
|
|
850
|
+
function Te(e) {
|
|
849
851
|
let t = e.trim();
|
|
850
852
|
return t.includes(" ") || t.endsWith("?");
|
|
851
853
|
}
|
|
852
|
-
async function*
|
|
854
|
+
async function* Ee(e) {
|
|
853
855
|
let t = e.getReader(), n = new TextDecoder(), r = "";
|
|
854
856
|
try {
|
|
855
857
|
for (;;) {
|
|
@@ -872,7 +874,7 @@ async function* De(e) {
|
|
|
872
874
|
t.releaseLock();
|
|
873
875
|
}
|
|
874
876
|
}
|
|
875
|
-
function
|
|
877
|
+
function De(e) {
|
|
876
878
|
let t = new URLSearchParams();
|
|
877
879
|
e.state.queryId && t.set("queryId", e.state.queryId), e.sessionId && t.set("session", e.sessionId), e.source && t.set("source", e.source), e.count === !1 && t.set("count", "false");
|
|
878
880
|
let n = t.toString();
|
|
@@ -880,28 +882,28 @@ function Oe(e) {
|
|
|
880
882
|
}
|
|
881
883
|
//#endregion
|
|
882
884
|
//#region src/utils/askPhrases.ts
|
|
883
|
-
var
|
|
884
|
-
function
|
|
885
|
+
var Oe = (e) => e.toLowerCase().replace(/’/g, "'").split(/\s+/).filter(Boolean), ke = /[?!.,]+$/, Ae = 2;
|
|
886
|
+
function je(e, t) {
|
|
885
887
|
let n = 0;
|
|
886
888
|
for (let r of t) {
|
|
887
|
-
let t =
|
|
888
|
-
t.length > n && t.length <= e.length && t.every((n, r) => e[e.length - t.length + r].replace(
|
|
889
|
+
let t = Oe(r);
|
|
890
|
+
t.length > n && t.length <= e.length && t.every((n, r) => e[e.length - t.length + r].replace(ke, "") === n) && (n = t.length);
|
|
889
891
|
}
|
|
890
892
|
return n;
|
|
891
893
|
}
|
|
892
|
-
function
|
|
894
|
+
function Me(e, t, n) {
|
|
893
895
|
let r = 0;
|
|
894
896
|
for (let i of n) {
|
|
895
|
-
let n =
|
|
896
|
-
n.length > r && t + n.length <= e.length && n.every((n, r) => e[t + r].replace(
|
|
897
|
+
let n = Oe(i);
|
|
898
|
+
n.length > r && t + n.length <= e.length && n.every((n, r) => e[t + r].replace(ke, "") === n) && (r = n.length);
|
|
897
899
|
}
|
|
898
900
|
return r;
|
|
899
901
|
}
|
|
900
|
-
function
|
|
901
|
-
let n = e.trim().split(/\s+/).filter(Boolean), r =
|
|
902
|
-
let t =
|
|
902
|
+
function Ne(e, t) {
|
|
903
|
+
let n = e.trim().split(/\s+/).filter(Boolean), r = Oe(e), i = 0, a = [], o = (e) => {
|
|
904
|
+
let t = Me(r, i, e);
|
|
903
905
|
return t && (a.push(n.slice(i, i + t).join(" ")), i += t), t > 0;
|
|
904
|
-
}, s =
|
|
906
|
+
}, s = Me(r, 0, t.leadIns), c = o(t.leadIns), l = o(t.frames), u = o(t.links);
|
|
905
907
|
if (!(c && (s > 1 || l) || l && u)) return {
|
|
906
908
|
text: e,
|
|
907
909
|
taken: []
|
|
@@ -912,8 +914,8 @@ function Pe(e, t) {
|
|
|
912
914
|
text: e,
|
|
913
915
|
taken: []
|
|
914
916
|
};
|
|
915
|
-
let f = d.split(/\s+/).filter(Boolean), p =
|
|
916
|
-
if (p > 0 && f.length - p >=
|
|
917
|
+
let f = d.split(/\s+/).filter(Boolean), p = je(Oe(d), t.frames);
|
|
918
|
+
if (p > 0 && f.length - p >= Ae) {
|
|
917
919
|
let e = f.slice(0, f.length - p).join(" ");
|
|
918
920
|
if (/\p{L}{3,}/u.test(e)) return {
|
|
919
921
|
text: e,
|
|
@@ -927,7 +929,7 @@ function Pe(e, t) {
|
|
|
927
929
|
}
|
|
928
930
|
//#endregion
|
|
929
931
|
//#region src/hooks/useSearchOrAsk.ts
|
|
930
|
-
var
|
|
932
|
+
var Pe = {
|
|
931
933
|
available: !1,
|
|
932
934
|
offer: "none",
|
|
933
935
|
p: null,
|
|
@@ -936,15 +938,15 @@ var Fe = {
|
|
|
936
938
|
criteria: null,
|
|
937
939
|
describes: !1,
|
|
938
940
|
cutResults: !1,
|
|
939
|
-
cutRule:
|
|
941
|
+
cutRule: xe,
|
|
940
942
|
strictCoverage: !1,
|
|
941
943
|
filtersWhileTyping: "off",
|
|
942
944
|
stands: !1
|
|
943
945
|
};
|
|
944
|
-
function
|
|
945
|
-
let { enabled: t = !0, pauseMs: n = 300 } = e, r =
|
|
946
|
+
function Fe(e = {}) {
|
|
947
|
+
let { enabled: t = !0, pauseMs: n = 300 } = e, r = X(), { url: i, team: a, dataset: s, authenticatedFetch: u, isFetchingInitial: d, authError: f, state: p } = r, m = c(r);
|
|
946
948
|
m.current = r;
|
|
947
|
-
let h = (e.text ?? p.query).trim(), [g, _] = l(!1), [v, y] = l(
|
|
949
|
+
let h = (e.text ?? p.query).trim(), [g, _] = l(!1), [v, y] = l(Pe), b = c(he), x = c(!0), S = c(xe), C = c(!0), w = c("off"), T = c(null), E = c(!0), D = c(!0), O = c(null), k = c("none"), A = c(""), j = c(0), M = c(0);
|
|
948
950
|
k.current = v.offer;
|
|
949
951
|
let N = `${i}/api/teams/${a}/datasets/${s}/search-or-ask`, P = t && !d && !f;
|
|
950
952
|
o(() => {
|
|
@@ -957,11 +959,11 @@ function Ie(e = {}) {
|
|
|
957
959
|
let n = await t.json();
|
|
958
960
|
if (e || !n.available || !n.settings?.enabled) return;
|
|
959
961
|
T.current = n.effective?.askPhrases ?? null, E.current = n.settings.refocusWhileTyping ?? !0, D.current = n.settings.inviteOnAskPhrase ?? !0, w.current = n.settings.filtersWhileTyping ?? "off", b.current = {
|
|
960
|
-
...
|
|
962
|
+
...he,
|
|
961
963
|
...n.settings.thresholds
|
|
962
964
|
}, x.current = n.settings.cutWhileAsking ?? !0, C.current = n.settings.strictCoverageWhileAsking ?? !0, S.current = {
|
|
963
|
-
shareOfTop: n.settings.cutShareOfTop ??
|
|
964
|
-
topFloor: n.settings.cutTopFloor ??
|
|
965
|
+
shareOfTop: n.settings.cutShareOfTop ?? xe.shareOfTop,
|
|
966
|
+
topFloor: n.settings.cutTopFloor ?? xe.topFloor
|
|
965
967
|
}, _(!0);
|
|
966
968
|
} catch {}
|
|
967
969
|
})(), () => {
|
|
@@ -973,21 +975,21 @@ function Ie(e = {}) {
|
|
|
973
975
|
u
|
|
974
976
|
]), o(() => {
|
|
975
977
|
let { setSearchRewrite: e } = m.current, t = T.current;
|
|
976
|
-
if (!(!g || !t || !E.current || !e)) return e((e) =>
|
|
978
|
+
if (!(!g || !t || !E.current || !e)) return e((e) => Ne(e, t).text), () => e(null);
|
|
977
979
|
}, [g]), o(() => {
|
|
978
980
|
if (!g) {
|
|
979
|
-
y(
|
|
981
|
+
y(Pe);
|
|
980
982
|
return;
|
|
981
983
|
}
|
|
982
984
|
if (!h) {
|
|
983
985
|
A.current = "", y({
|
|
984
|
-
...
|
|
986
|
+
...Pe,
|
|
985
987
|
available: g
|
|
986
988
|
});
|
|
987
989
|
return;
|
|
988
990
|
}
|
|
989
|
-
if (!
|
|
990
|
-
|
|
991
|
+
if (!ye(h)) {
|
|
992
|
+
ve(h) && y((e) => ({
|
|
991
993
|
...e,
|
|
992
994
|
available: g,
|
|
993
995
|
offer: "none",
|
|
@@ -995,7 +997,7 @@ function Ie(e = {}) {
|
|
|
995
997
|
}));
|
|
996
998
|
return;
|
|
997
999
|
}
|
|
998
|
-
D.current && T.current &&
|
|
1000
|
+
D.current && T.current && Ne(h, T.current).taken.length > 0 && y((e) => e.offer === "none" ? {
|
|
999
1001
|
...e,
|
|
1000
1002
|
available: g,
|
|
1001
1003
|
offer: "invite",
|
|
@@ -1013,7 +1015,7 @@ function Ie(e = {}) {
|
|
|
1013
1015
|
let e = ++j.current;
|
|
1014
1016
|
A.current = h;
|
|
1015
1017
|
try {
|
|
1016
|
-
let t = await u(`${N}/intent${
|
|
1018
|
+
let t = await u(`${N}/intent${De(m.current)}`, {
|
|
1017
1019
|
method: "POST",
|
|
1018
1020
|
headers: { "Content-Type": "application/json" },
|
|
1019
1021
|
body: JSON.stringify({ text: h })
|
|
@@ -1034,7 +1036,7 @@ function Ie(e = {}) {
|
|
|
1034
1036
|
shareOfTop: o,
|
|
1035
1037
|
topFloor: s
|
|
1036
1038
|
}), y((e) => {
|
|
1037
|
-
let t =
|
|
1039
|
+
let t = be(e.offer, n, b.current), a = i ?? null, o = a != null && a >= b.current.strong, s = t === "strong" && !Te(h) ? "invite" : t, c = o ? "strong" : s, l = c === "strong" && !(o && a > n);
|
|
1038
1040
|
return {
|
|
1039
1041
|
available: !0,
|
|
1040
1042
|
offer: c,
|
|
@@ -1066,20 +1068,20 @@ function Ie(e = {}) {
|
|
|
1066
1068
|
if (F) {
|
|
1067
1069
|
if (O.current) return;
|
|
1068
1070
|
let n = t.searchSettings.coverageSetup ?? {};
|
|
1069
|
-
O.current = Object.fromEntries(Object.keys(
|
|
1071
|
+
O.current = Object.fromEntries(Object.keys(Se).map((e) => [e, n[e]])), e({ coverageSetup: { ...Se } });
|
|
1070
1072
|
} else O.current &&= (e({ coverageSetup: { ...O.current } }), null);
|
|
1071
1073
|
}, [F]), g ? {
|
|
1072
1074
|
...v,
|
|
1073
1075
|
stands: !!v.text && h.startsWith(v.text)
|
|
1074
|
-
} :
|
|
1076
|
+
} : Pe;
|
|
1075
1077
|
}
|
|
1076
|
-
var
|
|
1078
|
+
var Ie = {
|
|
1077
1079
|
withOffer: "_withOffer_15olh_2",
|
|
1078
1080
|
offerRow: "_offerRow_15olh_10",
|
|
1079
1081
|
offerHint: "_offerHint_15olh_18",
|
|
1080
1082
|
kbd: "_kbd_15olh_27"
|
|
1081
|
-
},
|
|
1082
|
-
let { state: { query: m, filters: h, rangeFilters: g, bucketFilters: _, results: v, truncationIndex: b, searchSettings: S }, setQuery: C, resetFilters: w } =
|
|
1083
|
+
}, Le = ({ className: e = "", autoFocus: t = !1, inputSize: n = "default", showClear: r = !0, showFocus: i = !1, showStatus: a = !0, onAsk: o, searchOrAsk: s, askOffer: c = "chip", onKeyDown: l, ...u }) => {
|
|
1084
|
+
let { state: { query: m, filters: h, rangeFilters: g, bucketFilters: _, results: v, truncationIndex: b, searchSettings: S }, setQuery: C, resetFilters: w } = X(), T = Object.values(h).reduce((e, t) => e + t.length, 0) + Object.keys(g).length + Object.values(_ ?? {}).reduce((e, t) => e + t.length, 0), E = m.length > 0, D = E && v !== null && v.length === 0, k = E && S.enableCoverage && v !== null && v.length > 0 && b === -1, A = Fe({ enabled: !!o && !s }), j = s ?? A, M = !!o && E && j.offer !== "none" && j.stands, N = j.available && S.placeholderText === "Type to search" ? "Search or ask" : S.placeholderText, F = (e) => {
|
|
1083
1085
|
l?.(e), !(e.defaultPrevented || e.key !== "Enter" || !o || j.offer !== "strong" || !j.stands || !m.trim()) && (e.preventDefault(), o(m.trim()));
|
|
1084
1086
|
}, L = () => {
|
|
1085
1087
|
C(""), T > 0 && w();
|
|
@@ -1135,9 +1137,9 @@ var Le = {
|
|
|
1135
1137
|
if (c !== "below" || !o || !j.available) return z;
|
|
1136
1138
|
let U = j.offer === "strong";
|
|
1137
1139
|
return /* @__PURE__ */ p("div", {
|
|
1138
|
-
className:
|
|
1140
|
+
className: Ie.withOffer,
|
|
1139
1141
|
children: [z, /* @__PURE__ */ f("div", {
|
|
1140
|
-
className:
|
|
1142
|
+
className: Ie.offerRow,
|
|
1141
1143
|
"aria-live": "polite",
|
|
1142
1144
|
children: M && /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f(y, {
|
|
1143
1145
|
variant: U ? "primary" : "ghost",
|
|
@@ -1145,22 +1147,22 @@ var Le = {
|
|
|
1145
1147
|
onClick: R,
|
|
1146
1148
|
children: U ? "Ask the assistant" : "Ask about this"
|
|
1147
1149
|
}), U && /* @__PURE__ */ p("span", {
|
|
1148
|
-
className:
|
|
1150
|
+
className: Ie.offerHint,
|
|
1149
1151
|
children: [/* @__PURE__ */ f("kbd", {
|
|
1150
|
-
className:
|
|
1152
|
+
className: Ie.kbd,
|
|
1151
1153
|
children: "↵"
|
|
1152
1154
|
}), " to ask"]
|
|
1153
1155
|
})] })
|
|
1154
1156
|
})]
|
|
1155
1157
|
});
|
|
1156
|
-
},
|
|
1158
|
+
}, Re = {
|
|
1157
1159
|
message: "_message_1mgfk_1",
|
|
1158
1160
|
icon: "_icon_1mgfk_10",
|
|
1159
1161
|
title: "_title_1mgfk_15",
|
|
1160
1162
|
detail: "_detail_1mgfk_20",
|
|
1161
1163
|
technical: "_technical_1mgfk_25",
|
|
1162
1164
|
button: "_button_1mgfk_33"
|
|
1163
|
-
},
|
|
1165
|
+
}, ze = {
|
|
1164
1166
|
unreachable: {
|
|
1165
1167
|
icon: z,
|
|
1166
1168
|
title: "Search is unavailable",
|
|
@@ -1187,32 +1189,32 @@ var Le = {
|
|
|
1187
1189
|
detail: "Results will appear in a moment."
|
|
1188
1190
|
},
|
|
1189
1191
|
unavailable: {
|
|
1190
|
-
icon:
|
|
1192
|
+
icon: ne,
|
|
1191
1193
|
title: "Search is unavailable",
|
|
1192
1194
|
detail: "The collection can’t be searched right now."
|
|
1193
1195
|
},
|
|
1194
1196
|
rateLimited: {
|
|
1195
|
-
icon:
|
|
1197
|
+
icon: q,
|
|
1196
1198
|
title: "Too many searches",
|
|
1197
1199
|
detail: "Wait a moment, then try again."
|
|
1198
1200
|
},
|
|
1199
1201
|
server: {
|
|
1200
|
-
icon:
|
|
1202
|
+
icon: ne,
|
|
1201
1203
|
title: "Something went wrong",
|
|
1202
1204
|
detail: "The search server ran into a problem."
|
|
1203
1205
|
},
|
|
1204
1206
|
setup: {
|
|
1205
|
-
icon:
|
|
1207
|
+
icon: ne,
|
|
1206
1208
|
title: "Search isn’t set up",
|
|
1207
1209
|
detail: "This page is missing part of its search setup."
|
|
1208
1210
|
},
|
|
1209
1211
|
unknown: {
|
|
1210
|
-
icon:
|
|
1212
|
+
icon: ne,
|
|
1211
1213
|
title: "Something went wrong",
|
|
1212
1214
|
detail: "The search couldn’t be completed."
|
|
1213
1215
|
}
|
|
1214
|
-
},
|
|
1215
|
-
let { icon: r, title: i, detail: a } =
|
|
1216
|
+
}, Be = ({ error: e, onRetry: t, hideTechnical: n = !1 }) => {
|
|
1217
|
+
let { icon: r, title: i, detail: a } = ze[e.kind];
|
|
1216
1218
|
o(() => {
|
|
1217
1219
|
if (e.kind !== "notReady" || !t) return;
|
|
1218
1220
|
let n = setTimeout(t, (e.retryAfterSeconds ?? 2) * 1e3);
|
|
@@ -1220,58 +1222,58 @@ var Le = {
|
|
|
1220
1222
|
}, [e, t]);
|
|
1221
1223
|
let s = e.retryable && e.kind !== "notReady" && t;
|
|
1222
1224
|
return /* @__PURE__ */ p("div", {
|
|
1223
|
-
className:
|
|
1225
|
+
className: Re.message,
|
|
1224
1226
|
role: "alert",
|
|
1225
1227
|
children: [
|
|
1226
1228
|
/* @__PURE__ */ f("span", {
|
|
1227
|
-
className:
|
|
1229
|
+
className: Re.icon,
|
|
1228
1230
|
children: /* @__PURE__ */ f(r, {
|
|
1229
1231
|
size: 70,
|
|
1230
1232
|
color: "var(--lv4)"
|
|
1231
1233
|
})
|
|
1232
1234
|
}),
|
|
1233
1235
|
/* @__PURE__ */ f("div", {
|
|
1234
|
-
className:
|
|
1236
|
+
className: Re.title,
|
|
1235
1237
|
children: i
|
|
1236
1238
|
}),
|
|
1237
1239
|
/* @__PURE__ */ f("div", {
|
|
1238
|
-
className:
|
|
1240
|
+
className: Re.detail,
|
|
1239
1241
|
children: a
|
|
1240
1242
|
}),
|
|
1241
1243
|
!n && /* @__PURE__ */ f("code", {
|
|
1242
|
-
className:
|
|
1244
|
+
className: Re.technical,
|
|
1243
1245
|
children: e.technical
|
|
1244
1246
|
}),
|
|
1245
1247
|
s && /* @__PURE__ */ f(y, {
|
|
1246
1248
|
variant: "secondary",
|
|
1247
1249
|
size: "micro",
|
|
1248
|
-
className:
|
|
1250
|
+
className: Re.button,
|
|
1249
1251
|
onClick: t,
|
|
1250
1252
|
children: "Try again"
|
|
1251
1253
|
})
|
|
1252
1254
|
]
|
|
1253
1255
|
});
|
|
1254
|
-
},
|
|
1256
|
+
}, Ve = {
|
|
1255
1257
|
placeholder: "_placeholder_1qr5o_1",
|
|
1256
1258
|
invalid: "_invalid_1qr5o_11",
|
|
1257
1259
|
searchedFor: "_searchedFor_1qr5o_17"
|
|
1258
|
-
},
|
|
1260
|
+
}, He = {
|
|
1259
1261
|
row: "_row_11svi_1",
|
|
1260
1262
|
content: "_content_11svi_22",
|
|
1261
1263
|
indexNumber: "_indexNumber_11svi_36",
|
|
1262
1264
|
scoreNumber: "_scoreNumber_11svi_44",
|
|
1263
1265
|
skeletonBars: "_skeletonBars_11svi_53"
|
|
1264
|
-
},
|
|
1265
|
-
className:
|
|
1266
|
+
}, Ue = ({ skeleton: e = !1, index: t, score: n, showScore: r = !1, children: i, skeletonDelay: a = 0, skeletonWidths: o = [62, 38] }) => /* @__PURE__ */ p("div", {
|
|
1267
|
+
className: He.row,
|
|
1266
1268
|
children: [
|
|
1267
1269
|
t !== void 0 && /* @__PURE__ */ f("div", {
|
|
1268
|
-
className:
|
|
1270
|
+
className: He.indexNumber,
|
|
1269
1271
|
children: t
|
|
1270
1272
|
}),
|
|
1271
1273
|
/* @__PURE__ */ f("div", {
|
|
1272
|
-
className:
|
|
1274
|
+
className: He.content,
|
|
1273
1275
|
children: e ? /* @__PURE__ */ p("div", {
|
|
1274
|
-
className:
|
|
1276
|
+
className: He.skeletonBars,
|
|
1275
1277
|
children: [/* @__PURE__ */ f(A, {
|
|
1276
1278
|
level: 3,
|
|
1277
1279
|
height: 12,
|
|
@@ -1288,14 +1290,14 @@ var Le = {
|
|
|
1288
1290
|
}) : i
|
|
1289
1291
|
}),
|
|
1290
1292
|
r && n !== void 0 && /* @__PURE__ */ f("div", {
|
|
1291
|
-
className:
|
|
1293
|
+
className: He.scoreNumber,
|
|
1292
1294
|
children: n
|
|
1293
1295
|
})
|
|
1294
1296
|
]
|
|
1295
|
-
}),
|
|
1297
|
+
}), We = {
|
|
1296
1298
|
wrapper: "_wrapper_f970z_6",
|
|
1297
1299
|
skeletonAppear: "_skeletonAppear_f970z_1"
|
|
1298
|
-
},
|
|
1300
|
+
}, Ge = [
|
|
1299
1301
|
[62, 38],
|
|
1300
1302
|
[75, 45],
|
|
1301
1303
|
[58, 33],
|
|
@@ -1304,28 +1306,28 @@ var Le = {
|
|
|
1304
1306
|
[55, 35],
|
|
1305
1307
|
[72, 40],
|
|
1306
1308
|
[60, 30]
|
|
1307
|
-
],
|
|
1308
|
-
className:
|
|
1309
|
-
children: Array.from({ length: e }).map((e, t) => /* @__PURE__ */ f(
|
|
1309
|
+
], Ke = ({ rows: e = 6 }) => /* @__PURE__ */ f("div", {
|
|
1310
|
+
className: We.wrapper,
|
|
1311
|
+
children: Array.from({ length: e }).map((e, t) => /* @__PURE__ */ f(Ue, {
|
|
1310
1312
|
skeleton: !0,
|
|
1311
1313
|
skeletonDelay: t * .1,
|
|
1312
|
-
skeletonWidths:
|
|
1314
|
+
skeletonWidths: Ge[t % Ge.length]
|
|
1313
1315
|
}, t))
|
|
1314
|
-
}),
|
|
1315
|
-
function
|
|
1316
|
+
}), qe = /^\[\s*(?:'[^']*'(?:\s*,\s*'[^']*')*)?\s*\]$/;
|
|
1317
|
+
function Je(e) {
|
|
1316
1318
|
let t = e.trim();
|
|
1317
1319
|
if (!t.startsWith("[") || !t.endsWith("]")) return;
|
|
1318
1320
|
try {
|
|
1319
1321
|
let e = JSON.parse(t);
|
|
1320
1322
|
if (Array.isArray(e)) return e.map((e) => String(e));
|
|
1321
1323
|
} catch {}
|
|
1322
|
-
if (!
|
|
1324
|
+
if (!qe.test(t)) return;
|
|
1323
1325
|
let n = [], r = /'([^']*)'/g, i;
|
|
1324
1326
|
for (; (i = r.exec(t)) !== null;) n.push(i[1]);
|
|
1325
1327
|
return n;
|
|
1326
1328
|
}
|
|
1327
|
-
var
|
|
1328
|
-
let { state: { results: s, resultsSuppressed: u, searchSettings: m, truncationIndex: h, query: g, error: _, errorInfo: v }, isFetchingInitial: b, authError: x, authErrorInfo: S, retry: C, allowEmptySearch: w, fetchMoreResults: T, selectResult: E, searchText: D, searchAsTyped: O } =
|
|
1329
|
+
var Ye = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk: r, showScore: i, children: a }) => {
|
|
1330
|
+
let { state: { results: s, resultsSuppressed: u, searchSettings: m, truncationIndex: h, query: g, error: _, errorInfo: v }, isFetchingInitial: b, authError: x, authErrorInfo: S, retry: C, allowEmptySearch: w, fetchMoreResults: T, selectResult: E, searchText: D, searchAsTyped: O } = X(), k = t ?? 30, [A, j] = l(k), M = c(0), N = c("");
|
|
1329
1331
|
o(() => {
|
|
1330
1332
|
let e = g !== N.current;
|
|
1331
1333
|
(!s || s.length < M.current || e) && j(k), M.current = s?.length ?? 0, N.current = g;
|
|
@@ -1334,19 +1336,19 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1334
1336
|
k,
|
|
1335
1337
|
g
|
|
1336
1338
|
]);
|
|
1337
|
-
let P = s ?
|
|
1339
|
+
let P = s ? we(s, h, !!r?.cutResults, r?.cutRule) : [], F = D != null && D.trim() !== g.trim() ? D : null, I = s && P.length > A, L = () => {
|
|
1338
1340
|
let e = A + k;
|
|
1339
1341
|
j(e), s && e >= s.length && (!h || h === -1 || h > s.length) && T(s.length + k);
|
|
1340
1342
|
};
|
|
1341
|
-
if (b) return w ? /* @__PURE__ */ f(
|
|
1342
|
-
className:
|
|
1343
|
+
if (b) return w ? /* @__PURE__ */ f(Ke, { rows: k }) : /* @__PURE__ */ f("div", {
|
|
1344
|
+
className: Ve.placeholder,
|
|
1343
1345
|
children: /* @__PURE__ */ f(W, {
|
|
1344
1346
|
size: 200,
|
|
1345
1347
|
color: "var(--lv5)"
|
|
1346
1348
|
})
|
|
1347
1349
|
});
|
|
1348
1350
|
let R = x ?? _;
|
|
1349
|
-
return R ? /* @__PURE__ */ f(
|
|
1351
|
+
return R ? /* @__PURE__ */ f(Be, {
|
|
1350
1352
|
error: (x ? S : v) ?? {
|
|
1351
1353
|
kind: "unknown",
|
|
1352
1354
|
message: R,
|
|
@@ -1355,14 +1357,14 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1355
1357
|
},
|
|
1356
1358
|
onRetry: C
|
|
1357
1359
|
}) : u || s === null ? /* @__PURE__ */ f("div", {
|
|
1358
|
-
className:
|
|
1360
|
+
className: Ve.placeholder,
|
|
1359
1361
|
children: /* @__PURE__ */ f(W, {
|
|
1360
1362
|
size: 200,
|
|
1361
1363
|
color: "var(--lv5)"
|
|
1362
1364
|
})
|
|
1363
1365
|
}) : P.length === 0 ? null : /* @__PURE__ */ p(d, { children: [
|
|
1364
1366
|
F && /* @__PURE__ */ p("div", {
|
|
1365
|
-
className:
|
|
1367
|
+
className: Ve.searchedFor,
|
|
1366
1368
|
"aria-live": "polite",
|
|
1367
1369
|
children: [/* @__PURE__ */ p("span", { children: ["Searching for ", /* @__PURE__ */ f("strong", { children: F })] }), O && /* @__PURE__ */ f(y, {
|
|
1368
1370
|
variant: "ghost",
|
|
@@ -1377,7 +1379,7 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1377
1379
|
c = typeof o == "string" ? JSON.parse(o) : o;
|
|
1378
1380
|
} catch {
|
|
1379
1381
|
return /* @__PURE__ */ f("div", {
|
|
1380
|
-
className:
|
|
1382
|
+
className: Ve.invalid,
|
|
1381
1383
|
children: /* @__PURE__ */ f("p", { children: "Invalid JSON" })
|
|
1382
1384
|
}, r);
|
|
1383
1385
|
}
|
|
@@ -1389,11 +1391,11 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1389
1391
|
if (n) for (let e in l) {
|
|
1390
1392
|
let t = l[e];
|
|
1391
1393
|
if (typeof t == "string") {
|
|
1392
|
-
let n =
|
|
1394
|
+
let n = Je(t);
|
|
1393
1395
|
n && (l[e] = n);
|
|
1394
1396
|
}
|
|
1395
1397
|
}
|
|
1396
|
-
return /* @__PURE__ */ f(
|
|
1398
|
+
return /* @__PURE__ */ f(Ue, {
|
|
1397
1399
|
index: r,
|
|
1398
1400
|
score: s,
|
|
1399
1401
|
showScore: i ?? m.showScore,
|
|
@@ -1416,18 +1418,18 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1416
1418
|
})
|
|
1417
1419
|
})
|
|
1418
1420
|
] });
|
|
1419
|
-
},
|
|
1421
|
+
}, Xe = {
|
|
1420
1422
|
row: "_row_ujwhc_1",
|
|
1421
1423
|
title: "_title_ujwhc_8"
|
|
1422
|
-
},
|
|
1423
|
-
className: [
|
|
1424
|
+
}, Ze = ({ variant: e = "default", children: t }) => /* @__PURE__ */ f("div", {
|
|
1425
|
+
className: [Xe.row, e === "title" ? Xe.title : ""].filter(Boolean).join(" "),
|
|
1424
1426
|
children: t
|
|
1425
|
-
}),
|
|
1427
|
+
}), Qe = {
|
|
1426
1428
|
listRows: "_listRows_13obt_2",
|
|
1427
1429
|
sliderArea: "_sliderArea_13obt_8",
|
|
1428
1430
|
inputRow: "_inputRow_13obt_15",
|
|
1429
1431
|
histogramRow: "_histogramRow_13obt_22"
|
|
1430
|
-
},
|
|
1432
|
+
}, $e = [
|
|
1431
1433
|
65,
|
|
1432
1434
|
80,
|
|
1433
1435
|
55,
|
|
@@ -1436,17 +1438,17 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1436
1438
|
75,
|
|
1437
1439
|
50,
|
|
1438
1440
|
68
|
|
1439
|
-
],
|
|
1441
|
+
], et = ({ title: e, rows: t = 5, variant: n = "list", withHistogram: r = !1, collapsible: i = !0, startCollapsed: a = !1 }) => /* @__PURE__ */ f(T, {
|
|
1440
1442
|
title: e,
|
|
1441
1443
|
collapsible: i,
|
|
1442
1444
|
collapsed: a,
|
|
1443
1445
|
children: n === "slider" ? /* @__PURE__ */ p("div", {
|
|
1444
|
-
className:
|
|
1446
|
+
className: Qe.sliderArea,
|
|
1445
1447
|
children: [
|
|
1446
|
-
r && /* @__PURE__ */ f("div", { className:
|
|
1448
|
+
r && /* @__PURE__ */ f("div", { className: Qe.histogramRow }),
|
|
1447
1449
|
/* @__PURE__ */ f(A, { height: 6 }),
|
|
1448
1450
|
/* @__PURE__ */ p("div", {
|
|
1449
|
-
className:
|
|
1451
|
+
className: Qe.inputRow,
|
|
1450
1452
|
children: [/* @__PURE__ */ f(A, {
|
|
1451
1453
|
width: 40,
|
|
1452
1454
|
height: 20,
|
|
@@ -1459,13 +1461,13 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1459
1461
|
})
|
|
1460
1462
|
]
|
|
1461
1463
|
}) : /* @__PURE__ */ f("div", {
|
|
1462
|
-
className:
|
|
1464
|
+
className: Qe.listRows,
|
|
1463
1465
|
children: Array.from({ length: t }).map((e, t) => /* @__PURE__ */ f(A, {
|
|
1464
|
-
width: `${
|
|
1466
|
+
width: `${$e[t % $e.length]}%`,
|
|
1465
1467
|
delay: t * .05
|
|
1466
1468
|
}, t))
|
|
1467
1469
|
})
|
|
1468
|
-
}),
|
|
1470
|
+
}), Z = {
|
|
1469
1471
|
list: "_list_18vbb_2",
|
|
1470
1472
|
count: "_count_18vbb_7",
|
|
1471
1473
|
countValue: "_countValue_18vbb_17",
|
|
@@ -1473,10 +1475,10 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1473
1475
|
chipLabel: "_chipLabel_18vbb_32",
|
|
1474
1476
|
grid: "_grid_18vbb_40",
|
|
1475
1477
|
active: "_active_18vbb_54"
|
|
1476
|
-
},
|
|
1478
|
+
}, tt = {
|
|
1477
1479
|
notice: "_notice_4sel0_1",
|
|
1478
1480
|
technical: "_technical_4sel0_9"
|
|
1479
|
-
},
|
|
1481
|
+
}, nt = ({ label: e, field: t, missing: n }) => {
|
|
1480
1482
|
let r = n.map((e) => e[0].toUpperCase() + e.slice(1)).join(" and ");
|
|
1481
1483
|
return o(() => {
|
|
1482
1484
|
console.warn(`[intrface] The panel for "${t}" is hidden: the field is not ${r}. Mark it ${r} in the dataset's field configuration (web console → Fields).`);
|
|
@@ -1484,9 +1486,9 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1484
1486
|
title: e ?? t,
|
|
1485
1487
|
collapsible: !1,
|
|
1486
1488
|
children: /* @__PURE__ */ p("div", {
|
|
1487
|
-
className:
|
|
1489
|
+
className: tt.notice,
|
|
1488
1490
|
children: [/* @__PURE__ */ f("span", { children: "Not available" }), /* @__PURE__ */ p("code", {
|
|
1489
|
-
className:
|
|
1491
|
+
className: tt.technical,
|
|
1490
1492
|
children: [
|
|
1491
1493
|
t,
|
|
1492
1494
|
": not ",
|
|
@@ -1495,8 +1497,8 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1495
1497
|
})]
|
|
1496
1498
|
})
|
|
1497
1499
|
});
|
|
1498
|
-
},
|
|
1499
|
-
let { state: { facets: w, filterableFields: E, facetableFields: O, filters: k, query: A }, toggleFilter: j, setValueMatch: M, authError: P, isFetchingInitial: F, allowEmptySearch: I } =
|
|
1500
|
+
}, rt = ({ field: e, label: t, preserveBlankFacetState: n = !1, preserveBlankFacetStateOrder: r = !1, sortFacetsBy: i = "histogram", limit: a = 10, collapsible: s = !0, startCollapsed: u = !1, control: d, displayType: m, layout: h = "list", showActivePanel: g = !1, showCount: _ = !0, showNull: v = !1, match: x = "all", displayIfEmptyQuery: S = !0, displayCondition: C = (e) => !0 }) => {
|
|
1501
|
+
let { state: { facets: w, filterableFields: E, facetableFields: O, filters: k, query: A }, toggleFilter: j, setValueMatch: M, authError: P, isFetchingInitial: F, allowEmptySearch: I } = X(), L = d ?? m ?? "checkbox", R = L === "radio" ? "any" : x;
|
|
1500
1502
|
o(() => {
|
|
1501
1503
|
M(e, R);
|
|
1502
1504
|
}, [
|
|
@@ -1508,10 +1510,10 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1508
1510
|
if (o(() => {
|
|
1509
1511
|
V(a);
|
|
1510
1512
|
}, [w?.[e], a]), !I && !A || P) return null;
|
|
1511
|
-
if (F || !w) return L === "toggle" ? /* @__PURE__ */ f(
|
|
1513
|
+
if (F || !w) return L === "toggle" ? /* @__PURE__ */ f(et, {
|
|
1512
1514
|
rows: 1,
|
|
1513
1515
|
collapsible: !1
|
|
1514
|
-
}) : /* @__PURE__ */ f(
|
|
1516
|
+
}) : /* @__PURE__ */ f(et, {
|
|
1515
1517
|
title: t,
|
|
1516
1518
|
rows: Math.min(a, 6),
|
|
1517
1519
|
collapsible: s,
|
|
@@ -1524,7 +1526,7 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1524
1526
|
}) || !S && !A && Object.keys(k).length < 1) return null;
|
|
1525
1527
|
if (!E?.includes(e) || !O?.includes(e)) {
|
|
1526
1528
|
let n = [];
|
|
1527
|
-
return E?.includes(e) || n.push("filterable"), O?.includes(e) || n.push("facetable"), /* @__PURE__ */ f(
|
|
1529
|
+
return E?.includes(e) || n.push("filterable"), O?.includes(e) || n.push("facetable"), /* @__PURE__ */ f(nt, {
|
|
1528
1530
|
label: t,
|
|
1529
1531
|
field: e,
|
|
1530
1532
|
missing: n
|
|
@@ -1552,7 +1554,7 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1552
1554
|
if (L === "toggle" && !te) return /* @__PURE__ */ f(T, {
|
|
1553
1555
|
collapsible: !1,
|
|
1554
1556
|
children: /* @__PURE__ */ f("div", {
|
|
1555
|
-
className:
|
|
1557
|
+
className: Z.count,
|
|
1556
1558
|
children: /* @__PURE__ */ f(N, {
|
|
1557
1559
|
label: t,
|
|
1558
1560
|
checked: !1,
|
|
@@ -1566,7 +1568,7 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1566
1568
|
return /* @__PURE__ */ f(T, {
|
|
1567
1569
|
collapsible: !1,
|
|
1568
1570
|
children: /* @__PURE__ */ p("div", {
|
|
1569
|
-
className:
|
|
1571
|
+
className: Z.count,
|
|
1570
1572
|
children: [
|
|
1571
1573
|
/* @__PURE__ */ f(N, {
|
|
1572
1574
|
label: t,
|
|
@@ -1595,24 +1597,24 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1595
1597
|
let e = K.filter(([, e]) => typeof e == "number" && e > 0), t = K.filter(([, e]) => e === 0 || e === null);
|
|
1596
1598
|
K = [...e, ...t];
|
|
1597
1599
|
}
|
|
1598
|
-
let
|
|
1600
|
+
let q = typeof a == "number" && K.length > a, ne = q ? K.slice(0, B) : K, re = (t, n) => {
|
|
1599
1601
|
let r = U.includes(t), i = n === 0, a = _ && (n ?? 0) > 0 ? ` (${n})` : "", o = _ && (n ?? 0) > 0 ? n : "", s = () => j(e, t, L === "radio");
|
|
1600
1602
|
switch (L) {
|
|
1601
1603
|
case "button": return h === "list" ? /* @__PURE__ */ p("div", {
|
|
1602
|
-
className:
|
|
1604
|
+
className: Z.count,
|
|
1603
1605
|
children: [/* @__PURE__ */ f(y, {
|
|
1604
1606
|
variant: r ? "primary" : "secondary",
|
|
1605
1607
|
onClick: s,
|
|
1606
1608
|
disabled: i,
|
|
1607
1609
|
size: "micro",
|
|
1608
|
-
className:
|
|
1610
|
+
className: Z.chip,
|
|
1609
1611
|
title: t,
|
|
1610
1612
|
children: /* @__PURE__ */ f("span", {
|
|
1611
|
-
className:
|
|
1613
|
+
className: Z.chipLabel,
|
|
1612
1614
|
children: t
|
|
1613
1615
|
})
|
|
1614
1616
|
}), /* @__PURE__ */ f("span", {
|
|
1615
|
-
className:
|
|
1617
|
+
className: Z.countValue,
|
|
1616
1618
|
children: o
|
|
1617
1619
|
})]
|
|
1618
1620
|
}) : /* @__PURE__ */ f(y, {
|
|
@@ -1620,10 +1622,10 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1620
1622
|
onClick: s,
|
|
1621
1623
|
disabled: i,
|
|
1622
1624
|
size: "micro",
|
|
1623
|
-
className:
|
|
1625
|
+
className: Z.chip,
|
|
1624
1626
|
title: `${t}${a}`,
|
|
1625
1627
|
children: /* @__PURE__ */ f("span", {
|
|
1626
|
-
className:
|
|
1628
|
+
className: Z.chipLabel,
|
|
1627
1629
|
children: `${t}${a}`
|
|
1628
1630
|
})
|
|
1629
1631
|
});
|
|
@@ -1644,15 +1646,15 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1644
1646
|
disabled: i
|
|
1645
1647
|
});
|
|
1646
1648
|
return h === "list" ? /* @__PURE__ */ p("div", {
|
|
1647
|
-
className:
|
|
1649
|
+
className: Z.count,
|
|
1648
1650
|
children: [n, /* @__PURE__ */ f("span", {
|
|
1649
|
-
className:
|
|
1651
|
+
className: Z.countValue,
|
|
1650
1652
|
children: o
|
|
1651
1653
|
})]
|
|
1652
1654
|
}) : n;
|
|
1653
1655
|
}
|
|
1654
1656
|
default: return h === "list" ? /* @__PURE__ */ p("div", {
|
|
1655
|
-
className:
|
|
1657
|
+
className: Z.count,
|
|
1656
1658
|
children: [/* @__PURE__ */ f(b, {
|
|
1657
1659
|
label: t,
|
|
1658
1660
|
score: "",
|
|
@@ -1660,7 +1662,7 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1660
1662
|
onChange: s,
|
|
1661
1663
|
disabled: i
|
|
1662
1664
|
}), /* @__PURE__ */ f("span", {
|
|
1663
|
-
className:
|
|
1665
|
+
className: Z.countValue,
|
|
1664
1666
|
children: o
|
|
1665
1667
|
})]
|
|
1666
1668
|
}) : /* @__PURE__ */ f(b, {
|
|
@@ -1676,18 +1678,18 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1676
1678
|
title: t,
|
|
1677
1679
|
collapsible: s,
|
|
1678
1680
|
collapsed: s ? u : !1,
|
|
1679
|
-
className: g && U.length > 0 ?
|
|
1681
|
+
className: g && U.length > 0 ? Z.active : void 0,
|
|
1680
1682
|
children: /* @__PURE__ */ p("ul", {
|
|
1681
|
-
className: h === "grid" ?
|
|
1683
|
+
className: h === "grid" ? Z.grid : Z.list,
|
|
1682
1684
|
style: {
|
|
1683
1685
|
listStyle: "none",
|
|
1684
1686
|
padding: 0,
|
|
1685
1687
|
margin: 0
|
|
1686
1688
|
},
|
|
1687
|
-
children: [
|
|
1689
|
+
children: [ne.map(([e, t]) => /* @__PURE__ */ f("li", { children: re(e, t) }, e)), q && B < K.length && (() => {
|
|
1688
1690
|
let e = K.length - B, t = Math.min(50, e);
|
|
1689
1691
|
return /* @__PURE__ */ f("li", {
|
|
1690
|
-
className:
|
|
1692
|
+
className: Z.toggleItem,
|
|
1691
1693
|
children: /* @__PURE__ */ f(y, {
|
|
1692
1694
|
variant: "ghost",
|
|
1693
1695
|
size: "micro",
|
|
@@ -1698,7 +1700,7 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1698
1700
|
})()]
|
|
1699
1701
|
})
|
|
1700
1702
|
});
|
|
1701
|
-
},
|
|
1703
|
+
}, Q = {
|
|
1702
1704
|
disabledMessage: "_disabledMessage_adany_1",
|
|
1703
1705
|
histogram: "_histogram_adany_6",
|
|
1704
1706
|
histogramLayer: "_histogramLayer_adany_14",
|
|
@@ -1712,37 +1714,37 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1712
1714
|
};
|
|
1713
1715
|
//#endregion
|
|
1714
1716
|
//#region src/utils/numeric.ts
|
|
1715
|
-
function
|
|
1717
|
+
function it(e) {
|
|
1716
1718
|
if (!Number.isFinite(e)) return 0;
|
|
1717
1719
|
let t = String(e), n = t.indexOf(".");
|
|
1718
1720
|
return n === -1 ? 0 : Math.min(6, t.length - n - 1);
|
|
1719
1721
|
}
|
|
1720
|
-
function
|
|
1722
|
+
function at(e) {
|
|
1721
1723
|
let t = 0;
|
|
1722
|
-
for (let n of e) t = Math.max(t,
|
|
1724
|
+
for (let n of e) t = Math.max(t, it(n));
|
|
1723
1725
|
return t === 0 ? 1 : Number((10 ** -t).toFixed(t));
|
|
1724
1726
|
}
|
|
1725
|
-
function
|
|
1726
|
-
return Number(e.toFixed(
|
|
1727
|
+
function ot(e, t) {
|
|
1728
|
+
return Number(e.toFixed(it(t)));
|
|
1727
1729
|
}
|
|
1728
1730
|
//#endregion
|
|
1729
1731
|
//#region src/components/RangeFilterPanel.tsx
|
|
1730
1732
|
function st(e, t, n) {
|
|
1731
1733
|
let r = t + Math.round((e - t) / n) * n;
|
|
1732
|
-
return Number(r.toFixed(
|
|
1734
|
+
return Number(r.toFixed(it(n)));
|
|
1733
1735
|
}
|
|
1734
1736
|
function ct(e, t, n) {
|
|
1735
1737
|
let r = Math.ceil(Number(((e - t) / n).toFixed(6)));
|
|
1736
|
-
return Number((t + r * n).toFixed(
|
|
1738
|
+
return Number((t + r * n).toFixed(it(n)));
|
|
1737
1739
|
}
|
|
1738
1740
|
var lt = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, control: a, displayType: o, showActivePanel: s = !1, collapsible: c = !0, startCollapsed: l = !1, showHistogram: u = !1, resolution: d, step: m, stepMarks: h }) => {
|
|
1739
|
-
let { state: { rangeFilters: g, rangeBounds: _, facetStats: v, facets: y, filterableFields: b, facetableFields: x, query: S, facetDebounceDelayMillis: C }, setRangeFilter: w, resetRangeFilter: D, allowEmptySearch: O, authError: k, isFetchingInitial: A } =
|
|
1741
|
+
let { state: { rangeFilters: g, rangeBounds: _, facetStats: v, facets: y, filterableFields: b, facetableFields: x, query: S, facetDebounceDelayMillis: C }, setRangeFilter: w, resetRangeFilter: D, allowEmptySearch: O, authError: k, isFetchingInitial: A } = X(), M = a ?? o ?? "input", N = _?.[t] !== void 0, P = _?.[t] ?? {
|
|
1740
1742
|
min: r,
|
|
1741
1743
|
max: i
|
|
1742
1744
|
}, F = P.min, I = P.max, L = v?.[t] ?? P, R = Math.max(F, Math.min(I, L.min)), z = Math.max(F, Math.min(I, L.max)), B = e.useMemo(() => {
|
|
1743
1745
|
if (m) return m;
|
|
1744
|
-
let e = Math.max(
|
|
1745
|
-
if (Array.isArray(n)) for (let t of n) e = Math.max(e,
|
|
1746
|
+
let e = Math.max(it(F), it(I)), n = y?.[t];
|
|
1747
|
+
if (Array.isArray(n)) for (let t of n) e = Math.max(e, it(Number(t.key)));
|
|
1746
1748
|
return e === 0 ? 1 : Number((10 ** -e).toFixed(e));
|
|
1747
1749
|
}, [
|
|
1748
1750
|
m,
|
|
@@ -1750,21 +1752,21 @@ var lt = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1750
1752
|
I,
|
|
1751
1753
|
y,
|
|
1752
1754
|
t
|
|
1753
|
-
]), V = N && F === I, H = V ? r : F, U = V ? i : I, W = ct(U + B, H, B), ee = (e) => Math.min(W, Math.max(H, e)), G = g?.[t], te = s && G !== void 0 ?
|
|
1754
|
-
let e =
|
|
1755
|
-
return { width: `calc(${Math.max(3, F.toFixed(e).length, I.toFixed(e).length,
|
|
1755
|
+
]), V = N && F === I, H = V ? r : F, U = V ? i : I, W = ct(U + B, H, B), ee = (e) => Math.min(W, Math.max(H, e)), G = g?.[t], te = s && G !== void 0 ? Q.active : void 0, K = G ? G.min : F, q = G ? G.max : I, ne = G !== void 0, re = R !== F || z !== I, [J, Y] = e.useState([K, q]), [ie, ae] = e.useState(!1), [oe, se] = e.useState(!1), [ce, le] = e.useState(String(K)), [ue, de] = e.useState(String(q)), fe = e.useMemo(() => {
|
|
1756
|
+
let e = it(B);
|
|
1757
|
+
return { width: `calc(${Math.max(3, F.toFixed(e).length, I.toFixed(e).length, ce.length, ue.length) + 1}ch + 20px)` };
|
|
1756
1758
|
}, [
|
|
1757
1759
|
B,
|
|
1758
1760
|
F,
|
|
1759
1761
|
I,
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
+
ce,
|
|
1763
|
+
ue
|
|
1762
1764
|
]);
|
|
1763
1765
|
e.useEffect(() => {
|
|
1764
|
-
|
|
1765
|
-
}, [
|
|
1766
|
-
let { finalMin:
|
|
1767
|
-
let [e, t] =
|
|
1766
|
+
le(String(J[0])), de(String(J[1]));
|
|
1767
|
+
}, [J]);
|
|
1768
|
+
let { finalMin: pe, finalMax: me, isValidMin: he, isValidMax: ge } = e.useMemo(() => {
|
|
1769
|
+
let [e, t] = J, n = Math.max(F, Math.min(I, e)), r = Math.max(F, Math.min(I, t)), i = Math.min(n, r), a = Math.max(n, r);
|
|
1768
1770
|
return {
|
|
1769
1771
|
finalMin: i,
|
|
1770
1772
|
finalMax: a,
|
|
@@ -1772,29 +1774,29 @@ var lt = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1772
1774
|
isValidMax: a <= I && a >= i
|
|
1773
1775
|
};
|
|
1774
1776
|
}, [
|
|
1775
|
-
|
|
1777
|
+
J,
|
|
1776
1778
|
F,
|
|
1777
1779
|
I
|
|
1778
1780
|
]);
|
|
1779
1781
|
e.useEffect(() => {
|
|
1780
1782
|
if (V) return;
|
|
1781
|
-
if (
|
|
1782
|
-
|
|
1783
|
+
if (J[0] === F && J[1] === I) {
|
|
1784
|
+
ae(!1), se(!1);
|
|
1783
1785
|
return;
|
|
1784
1786
|
}
|
|
1785
1787
|
let e = C ?? 500, n = setTimeout(() => {
|
|
1786
|
-
|
|
1788
|
+
ae(!he), se(!ge);
|
|
1787
1789
|
}, 300), r = setTimeout(() => {
|
|
1788
|
-
|
|
1790
|
+
he && ge && (pe === F && me === I ? D(t, !1) : w(t, pe, me));
|
|
1789
1791
|
}, e);
|
|
1790
1792
|
return () => {
|
|
1791
1793
|
clearTimeout(n), clearTimeout(r);
|
|
1792
1794
|
};
|
|
1793
1795
|
}, [
|
|
1796
|
+
pe,
|
|
1794
1797
|
me,
|
|
1795
1798
|
he,
|
|
1796
1799
|
ge,
|
|
1797
|
-
_e,
|
|
1798
1800
|
F,
|
|
1799
1801
|
I,
|
|
1800
1802
|
t,
|
|
@@ -1803,51 +1805,51 @@ var lt = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1803
1805
|
C,
|
|
1804
1806
|
V
|
|
1805
1807
|
]), e.useEffect(() => {
|
|
1806
|
-
|
|
1808
|
+
Y([K, q]), ae(!1), se(!1);
|
|
1807
1809
|
}, [
|
|
1808
1810
|
K,
|
|
1809
|
-
|
|
1811
|
+
q,
|
|
1810
1812
|
t
|
|
1811
1813
|
]);
|
|
1812
|
-
let
|
|
1813
|
-
let t =
|
|
1814
|
-
return [t,
|
|
1815
|
-
}, [B]),
|
|
1814
|
+
let _e = e.useCallback((e) => {
|
|
1815
|
+
let t = ot(Math.min(e[0], e[1] - B), B);
|
|
1816
|
+
return [t, ot(Math.max(e[1] - B, t), B)];
|
|
1817
|
+
}, [B]), ve = e.useCallback((e) => {
|
|
1816
1818
|
if (V) return;
|
|
1817
|
-
let [t, n] =
|
|
1818
|
-
|
|
1819
|
+
let [t, n] = _e(e);
|
|
1820
|
+
Y([Math.max(F, Math.min(z, t)), Math.max(R, Math.min(I, n))]);
|
|
1819
1821
|
}, [
|
|
1820
1822
|
V,
|
|
1821
|
-
|
|
1823
|
+
_e,
|
|
1822
1824
|
F,
|
|
1823
1825
|
I,
|
|
1824
1826
|
R,
|
|
1825
1827
|
z
|
|
1826
|
-
]),
|
|
1828
|
+
]), ye = e.useCallback((e) => {
|
|
1827
1829
|
if (V) return;
|
|
1828
|
-
let [n, r] =
|
|
1829
|
-
i === F && a === I ? (
|
|
1830
|
+
let [n, r] = _e(e), i = Math.max(F, Math.min(z, n)), a = Math.max(R, Math.min(I, r));
|
|
1831
|
+
i === F && a === I ? (Y([F, I]), D(t, !0)) : Y([i, a]);
|
|
1830
1832
|
}, [
|
|
1831
1833
|
V,
|
|
1832
|
-
|
|
1834
|
+
_e,
|
|
1833
1835
|
F,
|
|
1834
1836
|
I,
|
|
1835
1837
|
R,
|
|
1836
1838
|
z,
|
|
1837
1839
|
t,
|
|
1838
1840
|
D
|
|
1839
|
-
]),
|
|
1841
|
+
]), be = e.useRef(null), xe = e.useCallback((e, n) => {
|
|
1840
1842
|
if (V) return;
|
|
1841
|
-
let r =
|
|
1843
|
+
let r = be.current;
|
|
1842
1844
|
if (G && r && r.start === e && r.last === n) {
|
|
1843
|
-
|
|
1845
|
+
be.current = null, Y([F, I]), D(t, !0);
|
|
1844
1846
|
return;
|
|
1845
1847
|
}
|
|
1846
1848
|
let i = st(Math.max(F, R, e), F, B), a = Math.max(i, st(Math.min(I, z, n), F, B));
|
|
1847
|
-
|
|
1849
|
+
be.current = {
|
|
1848
1850
|
start: e,
|
|
1849
1851
|
last: n
|
|
1850
|
-
},
|
|
1852
|
+
}, Y([i, a]);
|
|
1851
1853
|
}, [
|
|
1852
1854
|
V,
|
|
1853
1855
|
G,
|
|
@@ -1858,50 +1860,50 @@ var lt = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1858
1860
|
B,
|
|
1859
1861
|
t,
|
|
1860
1862
|
D
|
|
1861
|
-
]),
|
|
1863
|
+
]), Se = e.useCallback(() => {
|
|
1862
1864
|
if (V) return;
|
|
1863
|
-
let e =
|
|
1865
|
+
let e = ce.trim(), t = e === "" ? NaN : Number(e);
|
|
1864
1866
|
if (isNaN(t)) {
|
|
1865
|
-
|
|
1867
|
+
le(String(J[0]));
|
|
1866
1868
|
return;
|
|
1867
1869
|
}
|
|
1868
1870
|
let n = Math.max(F, Math.min(z, t));
|
|
1869
|
-
n <
|
|
1871
|
+
n < J[1] ? Y([n, J[1]]) : Y([F, J[1]]), le(String(n < J[1] ? n : F));
|
|
1870
1872
|
}, [
|
|
1871
1873
|
V,
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
+
ce,
|
|
1875
|
+
J,
|
|
1874
1876
|
F,
|
|
1875
1877
|
z
|
|
1876
|
-
]),
|
|
1878
|
+
]), Ce = e.useCallback(() => {
|
|
1877
1879
|
if (V) return;
|
|
1878
|
-
let e =
|
|
1880
|
+
let e = ue.trim(), t = e === "" ? NaN : Number(e);
|
|
1879
1881
|
if (isNaN(t)) {
|
|
1880
|
-
|
|
1882
|
+
de(String(J[1]));
|
|
1881
1883
|
return;
|
|
1882
1884
|
}
|
|
1883
1885
|
let n = Math.max(R, Math.min(I, t));
|
|
1884
|
-
n >
|
|
1886
|
+
n > J[0] ? Y([J[0], n]) : Y([J[0], I]), de(String(n > J[0] ? n : I));
|
|
1885
1887
|
}, [
|
|
1886
1888
|
V,
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
+
ue,
|
|
1890
|
+
J,
|
|
1889
1891
|
R,
|
|
1890
1892
|
I
|
|
1891
|
-
]),
|
|
1893
|
+
]), we = (e) => (t) => {
|
|
1892
1894
|
t.key === "Enter" && e();
|
|
1893
|
-
}, [
|
|
1895
|
+
}, [Te, Ee] = e.useState(null), De = e.useRef(null);
|
|
1894
1896
|
e.useEffect(() => {
|
|
1895
1897
|
if (!u) return;
|
|
1896
1898
|
let e = `${F}:${I}`;
|
|
1897
|
-
if (e ===
|
|
1899
|
+
if (e === De.current && De.current !== null) return;
|
|
1898
1900
|
let n = y?.[t];
|
|
1899
1901
|
if (!Array.isArray(n) || n.length === 0) return;
|
|
1900
1902
|
let r = n.filter((e) => e.value != null && !isNaN(Number(e.key))).map((e) => ({
|
|
1901
1903
|
key: e.key,
|
|
1902
1904
|
value: e.value
|
|
1903
1905
|
}));
|
|
1904
|
-
r.length > 0 && (
|
|
1906
|
+
r.length > 0 && (De.current = e, Ee(r));
|
|
1905
1907
|
}, [
|
|
1906
1908
|
F,
|
|
1907
1909
|
I,
|
|
@@ -1909,22 +1911,22 @@ var lt = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1909
1911
|
t,
|
|
1910
1912
|
u
|
|
1911
1913
|
]);
|
|
1912
|
-
let
|
|
1913
|
-
if (!u || !
|
|
1914
|
+
let Oe = e.useMemo(() => {
|
|
1915
|
+
if (!u || !Te || Te.length === 0) return [];
|
|
1914
1916
|
let e = I - F;
|
|
1915
1917
|
if (e <= 0) return [];
|
|
1916
|
-
let t = d ?? Math.max(B,
|
|
1918
|
+
let t = d ?? Math.max(B, ot(Math.ceil(e / 20 / B) * B, B)), n = Math.ceil(e / t);
|
|
1917
1919
|
return Array.from({ length: n }, (e, r) => {
|
|
1918
|
-
let i = F + r * t, a = F + (r + 1) * t, o = r === n - 1, s =
|
|
1920
|
+
let i = F + r * t, a = F + (r + 1) * t, o = r === n - 1, s = Te.filter((e) => {
|
|
1919
1921
|
let t = Number(e.key);
|
|
1920
1922
|
return t >= i && (t < a || o && t <= I);
|
|
1921
|
-
}).reduce((e, t) => e + t.value, 0), c = o ? I :
|
|
1923
|
+
}).reduce((e, t) => e + t.value, 0), c = o ? I : ot(a - B, B);
|
|
1922
1924
|
return {
|
|
1923
1925
|
bucketStart: i,
|
|
1924
1926
|
bucketEnd: a,
|
|
1925
1927
|
count: s,
|
|
1926
1928
|
last: c,
|
|
1927
|
-
barEnd:
|
|
1929
|
+
barEnd: ot(c + B, B)
|
|
1928
1930
|
};
|
|
1929
1931
|
}).map((e, t, n) => ({
|
|
1930
1932
|
...e,
|
|
@@ -1932,14 +1934,14 @@ var lt = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1932
1934
|
}));
|
|
1933
1935
|
}, [
|
|
1934
1936
|
u,
|
|
1935
|
-
|
|
1937
|
+
Te,
|
|
1936
1938
|
F,
|
|
1937
1939
|
I,
|
|
1938
1940
|
d,
|
|
1939
1941
|
B,
|
|
1940
1942
|
W
|
|
1941
|
-
]),
|
|
1942
|
-
return u && !A && !x?.includes(t) && console.warn(`RangeFilterPanel: showHistogram=true but field "${t}" is not facetable. Add .Facetable = true to this field.`), k ? null : A ? /* @__PURE__ */ f(
|
|
1943
|
+
]), ke = e.useMemo(() => Math.max(...Oe.map((e) => e.count), 1), [Oe]);
|
|
1944
|
+
return u && !A && !x?.includes(t) && console.warn(`RangeFilterPanel: showHistogram=true but field "${t}" is not facetable. Add .Facetable = true to this field.`), k ? null : A ? /* @__PURE__ */ f(et, {
|
|
1943
1945
|
title: n,
|
|
1944
1946
|
variant: "slider",
|
|
1945
1947
|
withHistogram: u,
|
|
@@ -1952,72 +1954,72 @@ var lt = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1952
1954
|
className: te,
|
|
1953
1955
|
children: [
|
|
1954
1956
|
V && /* @__PURE__ */ p("div", {
|
|
1955
|
-
className:
|
|
1957
|
+
className: Q.disabledMessage,
|
|
1956
1958
|
children: [
|
|
1957
1959
|
"No adjustable range (all results have the same value: ",
|
|
1958
1960
|
F,
|
|
1959
1961
|
")."
|
|
1960
1962
|
]
|
|
1961
1963
|
}),
|
|
1962
|
-
u &&
|
|
1963
|
-
u &&
|
|
1964
|
-
let [e, t] = z > R && (R > F || z < I) ? [R, z] : [H, U], n = Math.max(
|
|
1964
|
+
u && Oe.length === 0 && /* @__PURE__ */ f("div", { className: Q.histogram }),
|
|
1965
|
+
u && Oe.length > 0 && (() => {
|
|
1966
|
+
let [e, t] = z > R && (R > F || z < I) ? [R, z] : [H, U], n = Math.max(pe, e), r = Math.min(me, t), i = W, a = i - H || 1, o = (e) => Math.max(0, Math.min(1, (e - H) / a)), s = (e) => e >= U ? 0 : Math.max(0, Math.min(1, (i - (e + B)) / a)), c = o(n), l = r < n ? 1 - c : s(r), u = (e) => `calc(10px + (100% - 20px) * ${e})`, d = `inset(0 ${u(l)} 0 ${u(c)})`, m = `inset(0 ${u(s(t))} 0 ${u(o(e))})`, h = (n) => n.last < e || n.bucketStart > t, g = Oe.slice(1).map((e) => u((e.bucketStart - H) / a)), _ = Oe.map((e) => ({
|
|
1965
1967
|
...e,
|
|
1966
|
-
height: Math.max(1, Math.ceil(e.count /
|
|
1968
|
+
height: Math.max(1, Math.ceil(e.count / ke * 20))
|
|
1967
1969
|
}));
|
|
1968
1970
|
return /* @__PURE__ */ p("div", {
|
|
1969
|
-
className:
|
|
1971
|
+
className: Q.histogram,
|
|
1970
1972
|
children: [
|
|
1971
1973
|
/* @__PURE__ */ f("div", {
|
|
1972
|
-
className:
|
|
1974
|
+
className: Q.histogramLayer,
|
|
1973
1975
|
children: _.map((e, t) => /* @__PURE__ */ f("button", {
|
|
1974
1976
|
type: "button",
|
|
1975
|
-
className:
|
|
1977
|
+
className: Q.histogramBar,
|
|
1976
1978
|
style: { flexGrow: e.span },
|
|
1977
1979
|
"data-testid": "histogram-bar",
|
|
1978
1980
|
disabled: V || h(e),
|
|
1979
1981
|
"aria-label": `${e.bucketStart} to ${e.last}: ${e.count}`,
|
|
1980
1982
|
title: `${e.bucketStart} to ${e.last}: ${e.count}`,
|
|
1981
|
-
onClick: () =>
|
|
1983
|
+
onClick: () => xe(e.bucketStart, e.last),
|
|
1982
1984
|
children: /* @__PURE__ */ f("span", {
|
|
1983
|
-
className:
|
|
1985
|
+
className: Q.histogramFill,
|
|
1984
1986
|
style: { height: `${e.height}px` }
|
|
1985
1987
|
})
|
|
1986
1988
|
}, t))
|
|
1987
1989
|
}),
|
|
1988
1990
|
/* @__PURE__ */ f("div", {
|
|
1989
|
-
className: `${
|
|
1991
|
+
className: `${Q.histogramLayer} ${Q.histogramLive}`,
|
|
1990
1992
|
"aria-hidden": "true",
|
|
1991
1993
|
"data-testid": "histogram-live",
|
|
1992
1994
|
style: { clipPath: m },
|
|
1993
1995
|
children: _.map((e, t) => /* @__PURE__ */ f("span", {
|
|
1994
|
-
className:
|
|
1996
|
+
className: Q.histogramBar,
|
|
1995
1997
|
style: { flexGrow: e.span },
|
|
1996
1998
|
children: /* @__PURE__ */ f("span", {
|
|
1997
|
-
className:
|
|
1999
|
+
className: Q.histogramFill,
|
|
1998
2000
|
style: { height: `${e.height}px` }
|
|
1999
2001
|
})
|
|
2000
2002
|
}, t))
|
|
2001
2003
|
}),
|
|
2002
2004
|
/* @__PURE__ */ f("div", {
|
|
2003
|
-
className: `${
|
|
2005
|
+
className: `${Q.histogramLayer} ${Q.histogramLit}`,
|
|
2004
2006
|
"aria-hidden": "true",
|
|
2005
2007
|
"data-testid": "histogram-lit",
|
|
2006
2008
|
style: { clipPath: d },
|
|
2007
2009
|
children: _.map((e, t) => /* @__PURE__ */ f("span", {
|
|
2008
|
-
className:
|
|
2010
|
+
className: Q.histogramBar,
|
|
2009
2011
|
style: { flexGrow: e.span },
|
|
2010
2012
|
children: /* @__PURE__ */ f("span", {
|
|
2011
|
-
className:
|
|
2013
|
+
className: Q.histogramFill,
|
|
2012
2014
|
style: { height: `${e.height}px` }
|
|
2013
2015
|
})
|
|
2014
2016
|
}, t))
|
|
2015
2017
|
}),
|
|
2016
2018
|
/* @__PURE__ */ f("div", {
|
|
2017
|
-
className:
|
|
2019
|
+
className: Q.histogramSeparators,
|
|
2018
2020
|
"aria-hidden": "true",
|
|
2019
2021
|
children: g.map((e, t) => /* @__PURE__ */ f("span", {
|
|
2020
|
-
className:
|
|
2022
|
+
className: Q.histogramSeparator,
|
|
2021
2023
|
style: { left: e }
|
|
2022
2024
|
}, t))
|
|
2023
2025
|
})
|
|
@@ -2031,15 +2033,15 @@ var lt = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
2031
2033
|
max: W,
|
|
2032
2034
|
step: B,
|
|
2033
2035
|
stepMarks: h,
|
|
2034
|
-
value: V ? [H, W] : [ee(st(
|
|
2036
|
+
value: V ? [H, W] : [ee(st(pe, H, B)), ee(st(me + B, H, B))],
|
|
2035
2037
|
isRange: !0,
|
|
2036
|
-
onChange: (e) =>
|
|
2037
|
-
onFinalChange: (e) =>
|
|
2038
|
+
onChange: (e) => ve(e),
|
|
2039
|
+
onFinalChange: (e) => ye(e),
|
|
2038
2040
|
disabled: V,
|
|
2039
2041
|
activeMin: R,
|
|
2040
|
-
activeMax: ee(
|
|
2041
|
-
isFaceted:
|
|
2042
|
-
highlightFaceted:
|
|
2042
|
+
activeMax: ee(ot(z + B, B)),
|
|
2043
|
+
isFaceted: re,
|
|
2044
|
+
highlightFaceted: ne,
|
|
2043
2045
|
"aria-label": n || `Filter by ${t}`
|
|
2044
2046
|
})
|
|
2045
2047
|
}),
|
|
@@ -2053,27 +2055,27 @@ var lt = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
2053
2055
|
children: [/* @__PURE__ */ f(E, {
|
|
2054
2056
|
label: "Min:",
|
|
2055
2057
|
type: "number",
|
|
2056
|
-
style:
|
|
2057
|
-
value: V ? String(F) :
|
|
2058
|
+
style: fe,
|
|
2059
|
+
value: V ? String(F) : ce,
|
|
2058
2060
|
min: F,
|
|
2059
|
-
max:
|
|
2060
|
-
onChange: (e) =>
|
|
2061
|
-
onBlur:
|
|
2062
|
-
onKeyDown:
|
|
2061
|
+
max: ot(Math.min(z, J[1] - B), B),
|
|
2062
|
+
onChange: (e) => le(e.target.value),
|
|
2063
|
+
onBlur: Se,
|
|
2064
|
+
onKeyDown: we(Se),
|
|
2063
2065
|
disabled: V,
|
|
2064
|
-
isValid: V || !
|
|
2066
|
+
isValid: V || !ie
|
|
2065
2067
|
}), /* @__PURE__ */ f(E, {
|
|
2066
2068
|
label: "Max:",
|
|
2067
2069
|
type: "number",
|
|
2068
|
-
style:
|
|
2069
|
-
value: V ? String(I) :
|
|
2070
|
-
min:
|
|
2070
|
+
style: fe,
|
|
2071
|
+
value: V ? String(I) : ue,
|
|
2072
|
+
min: ot(Math.max(R, J[0] + B), B),
|
|
2071
2073
|
max: I,
|
|
2072
|
-
onChange: (e) =>
|
|
2073
|
-
onBlur:
|
|
2074
|
-
onKeyDown:
|
|
2074
|
+
onChange: (e) => de(e.target.value),
|
|
2075
|
+
onBlur: Ce,
|
|
2076
|
+
onKeyDown: we(Ce),
|
|
2075
2077
|
disabled: V,
|
|
2076
|
-
isValid: V || !
|
|
2078
|
+
isValid: V || !oe
|
|
2077
2079
|
})]
|
|
2078
2080
|
})
|
|
2079
2081
|
]
|
|
@@ -2081,7 +2083,7 @@ var lt = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
2081
2083
|
title: n,
|
|
2082
2084
|
className: te,
|
|
2083
2085
|
children: [V && /* @__PURE__ */ p("div", {
|
|
2084
|
-
className:
|
|
2086
|
+
className: Q.disabledMessage,
|
|
2085
2087
|
children: [
|
|
2086
2088
|
"No adjustable range (all results have the same value: ",
|
|
2087
2089
|
F,
|
|
@@ -2096,30 +2098,30 @@ var lt = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
2096
2098
|
children: [/* @__PURE__ */ f(E, {
|
|
2097
2099
|
label: "Min:",
|
|
2098
2100
|
type: "number",
|
|
2099
|
-
style:
|
|
2100
|
-
value: V ? String(F) :
|
|
2101
|
+
style: fe,
|
|
2102
|
+
value: V ? String(F) : ce,
|
|
2101
2103
|
min: F,
|
|
2102
|
-
max:
|
|
2103
|
-
onChange: (e) =>
|
|
2104
|
-
onBlur:
|
|
2105
|
-
onKeyDown:
|
|
2104
|
+
max: ot(Math.min(z, J[1] - B), B),
|
|
2105
|
+
onChange: (e) => le(e.target.value),
|
|
2106
|
+
onBlur: Se,
|
|
2107
|
+
onKeyDown: we(Se),
|
|
2106
2108
|
disabled: V,
|
|
2107
|
-
isValid: V || !
|
|
2109
|
+
isValid: V || !ie
|
|
2108
2110
|
}), /* @__PURE__ */ f(E, {
|
|
2109
2111
|
label: "Max:",
|
|
2110
2112
|
type: "number",
|
|
2111
|
-
style:
|
|
2112
|
-
value: V ? String(I) :
|
|
2113
|
-
min:
|
|
2113
|
+
style: fe,
|
|
2114
|
+
value: V ? String(I) : ue,
|
|
2115
|
+
min: ot(Math.max(R, J[0] + B), B),
|
|
2114
2116
|
max: I,
|
|
2115
|
-
onChange: (e) =>
|
|
2116
|
-
onBlur:
|
|
2117
|
-
onKeyDown:
|
|
2117
|
+
onChange: (e) => de(e.target.value),
|
|
2118
|
+
onBlur: Ce,
|
|
2119
|
+
onKeyDown: we(Ce),
|
|
2118
2120
|
disabled: V,
|
|
2119
|
-
isValid: V || !
|
|
2121
|
+
isValid: V || !oe
|
|
2120
2122
|
})]
|
|
2121
2123
|
})]
|
|
2122
|
-
}) : /* @__PURE__ */ f(
|
|
2124
|
+
}) : /* @__PURE__ */ f(nt, {
|
|
2123
2125
|
label: n,
|
|
2124
2126
|
field: t,
|
|
2125
2127
|
missing: ["filterable"]
|
|
@@ -2147,14 +2149,14 @@ function dt(e, t) {
|
|
|
2147
2149
|
return r ? n : 0;
|
|
2148
2150
|
}
|
|
2149
2151
|
var ft = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a, layout: c = "list", showCount: u = !0, showEmpty: d = !1, limit: m, showActivePanel: h = !1, collapsible: g = !0, startCollapsed: _ = !1 }) => {
|
|
2150
|
-
let { state: { facets: v, filterableFields: x, facetableFields: S, bucketFilters: C, rangeBounds: w, facetStats: E, query: O }, toggleBucketFilter: k, authError: A, isFetchingInitial: j, allowEmptySearch: M } =
|
|
2152
|
+
let { state: { facets: v, filterableFields: x, facetableFields: S, bucketFilters: C, rangeBounds: w, facetStats: E, query: O }, toggleBucketFilter: k, authError: A, isFetchingInitial: j, allowEmptySearch: M } = X(), N = i ?? a ?? "checkbox", P = v?.[e], F = C[e] ?? [], [I, L] = l(m ?? Infinity);
|
|
2151
2153
|
o(() => {
|
|
2152
2154
|
L(m ?? Infinity);
|
|
2153
2155
|
}, [m, P]);
|
|
2154
2156
|
let R = w?.[e] ?? E?.[e], z = s(() => {
|
|
2155
2157
|
let e = [];
|
|
2156
2158
|
if (R && e.push(R.min, R.max), Array.isArray(P)) for (let t of P) e.push(Number(t.key));
|
|
2157
|
-
return
|
|
2159
|
+
return at(e.filter(Number.isFinite));
|
|
2158
2160
|
}, [R, P]), B = s(() => {
|
|
2159
2161
|
let e = R?.min ?? -Number.MAX_VALUE, t = R?.max ?? Number.MAX_VALUE, i = (n, r, i) => ({
|
|
2160
2162
|
label: i ?? (n === void 0 ? `up to ${r}` : r === void 0 ? `${n} and up` : `${n}-${r}`),
|
|
@@ -2167,12 +2169,12 @@ var ft = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
2167
2169
|
if (r && r.length > 0) return r.map((e) => i(e.min, e.max, e.label));
|
|
2168
2170
|
if (Array.isArray(n)) {
|
|
2169
2171
|
let e = [...n].sort((e, t) => e - t), t = [];
|
|
2170
|
-
for (let n = 0; n < e.length - 1; n++) t.push(i(e[n],
|
|
2172
|
+
for (let n = 0; n < e.length - 1; n++) t.push(i(e[n], ot(e[n + 1] - z, z)));
|
|
2171
2173
|
return t;
|
|
2172
2174
|
}
|
|
2173
2175
|
if (typeof n == "number" && n > 0 && R) {
|
|
2174
2176
|
let e = [], t = Math.floor(R.min / n) * n;
|
|
2175
|
-
for (let r = t; r <= R.max; r =
|
|
2177
|
+
for (let r = t; r <= R.max; r = ot(r + n, z)) e.push(i(ot(r, z), ot(r + n - z, z)));
|
|
2176
2178
|
return e;
|
|
2177
2179
|
}
|
|
2178
2180
|
return [];
|
|
@@ -2183,14 +2185,14 @@ var ft = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
2183
2185
|
z
|
|
2184
2186
|
]);
|
|
2185
2187
|
if (A) return null;
|
|
2186
|
-
if (j || !v) return /* @__PURE__ */ f(
|
|
2188
|
+
if (j || !v) return /* @__PURE__ */ f(et, {
|
|
2187
2189
|
title: t,
|
|
2188
2190
|
rows: Math.max(1, Math.min(B.length || 5, 8)),
|
|
2189
2191
|
collapsible: g,
|
|
2190
2192
|
startCollapsed: _
|
|
2191
2193
|
});
|
|
2192
2194
|
if (!M && !O) return null;
|
|
2193
|
-
if (!x?.includes(e)) return /* @__PURE__ */ f(
|
|
2195
|
+
if (!x?.includes(e)) return /* @__PURE__ */ f(nt, {
|
|
2194
2196
|
label: t,
|
|
2195
2197
|
field: e,
|
|
2196
2198
|
missing: ["filterable"]
|
|
@@ -2283,7 +2285,7 @@ var ft = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
2283
2285
|
chipLabel: "_chipLabel_1xjna_32"
|
|
2284
2286
|
}, mt = r(({ field: e, value: t, onReset: n }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(y, {
|
|
2285
2287
|
onClick: n,
|
|
2286
|
-
iconRight: /* @__PURE__ */ f(
|
|
2288
|
+
iconRight: /* @__PURE__ */ f(re, {}),
|
|
2287
2289
|
variant: "primary",
|
|
2288
2290
|
size: "micro",
|
|
2289
2291
|
className: pt.chip,
|
|
@@ -2298,7 +2300,7 @@ var ft = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
2298
2300
|
})
|
|
2299
2301
|
}) })), ht = r(({ field: e, min: t, max: n, onReset: r }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(y, {
|
|
2300
2302
|
onClick: r,
|
|
2301
|
-
iconRight: /* @__PURE__ */ f(
|
|
2303
|
+
iconRight: /* @__PURE__ */ f(re, {}),
|
|
2302
2304
|
variant: "primary",
|
|
2303
2305
|
size: "micro",
|
|
2304
2306
|
className: pt.chip,
|
|
@@ -2315,7 +2317,7 @@ var ft = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
2315
2317
|
})
|
|
2316
2318
|
}) })), gt = r(({ field: e, label: t, onReset: n }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(y, {
|
|
2317
2319
|
onClick: n,
|
|
2318
|
-
iconRight: /* @__PURE__ */ f(
|
|
2320
|
+
iconRight: /* @__PURE__ */ f(re, {}),
|
|
2319
2321
|
variant: "primary",
|
|
2320
2322
|
size: "micro",
|
|
2321
2323
|
className: pt.chip,
|
|
@@ -2330,7 +2332,7 @@ var ft = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
2330
2332
|
})
|
|
2331
2333
|
}) }));
|
|
2332
2334
|
function _t() {
|
|
2333
|
-
let { state: { filters: e, rangeFilters: t, bucketFilters: n }, resetFilters: r, resetSingleFilter: i, resetRangeFilter: a, resetBucketFilter: o } =
|
|
2335
|
+
let { state: { filters: e, rangeFilters: t, bucketFilters: n }, resetFilters: r, resetSingleFilter: i, resetRangeFilter: a, resetBucketFilter: o } = X(), c = s(() => Object.entries(e).map(([e, t]) => t.map((t) => ({
|
|
2334
2336
|
field: e,
|
|
2335
2337
|
value: t
|
|
2336
2338
|
}))).flat(), [e]), l = s(() => Object.entries(t).map(([e, { min: t, max: n }]) => ({
|
|
@@ -2382,8 +2384,8 @@ var vt = {
|
|
|
2382
2384
|
select: "_select_nwf7i_1",
|
|
2383
2385
|
radioGroup: "_radioGroup_nwf7i_6"
|
|
2384
2386
|
}, yt = ({ options: e, noneLabel: t = "None", control: n, displayType: r, collapsible: i = !0, startCollapsed: a = !1 }) => {
|
|
2385
|
-
let o = n ?? (r === "radio" ? "radio" : "select"), { state: { sortableFields: s, sortBy: c, sortAscending: l }, setSort: u, isFetchingInitial: d } =
|
|
2386
|
-
if (d) return /* @__PURE__ */ f(
|
|
2387
|
+
let o = n ?? (r === "radio" ? "radio" : "select"), { state: { sortableFields: s, sortBy: c, sortAscending: l }, setSort: u, isFetchingInitial: d } = X();
|
|
2388
|
+
if (d) return /* @__PURE__ */ f(et, {
|
|
2387
2389
|
title: "Sort by",
|
|
2388
2390
|
rows: o === "radio" ? 3 : 1,
|
|
2389
2391
|
collapsible: i,
|
|
@@ -2447,7 +2449,7 @@ var vt = {
|
|
|
2447
2449
|
truncationScore: 65024
|
|
2448
2450
|
};
|
|
2449
2451
|
function St() {
|
|
2450
|
-
let { state: { searchSettings: e }, setSearchSettings: t, url: n, team: r, dataset: i, authenticatedFetch: a } =
|
|
2452
|
+
let { state: { searchSettings: e }, setSearchSettings: t, url: n, team: r, dataset: i, authenticatedFetch: a } = X(), [s, c] = l(!1), [u, m] = l(null);
|
|
2451
2453
|
o(() => {
|
|
2452
2454
|
let e = !0;
|
|
2453
2455
|
try {
|
|
@@ -2711,7 +2713,7 @@ var Ct = class extends t {
|
|
|
2711
2713
|
//#endregion
|
|
2712
2714
|
//#region src/hooks/useVectorSearch.ts
|
|
2713
2715
|
function wt(e, t) {
|
|
2714
|
-
let { url: n, team: r, dataset: a, authenticatedFetch: o } =
|
|
2716
|
+
let { url: n, team: r, dataset: a, authenticatedFetch: o } = X(), [s, c] = l(null), [u, d] = l(!1), [f, p] = l(void 0);
|
|
2715
2717
|
return {
|
|
2716
2718
|
results: s,
|
|
2717
2719
|
isLoading: u,
|
|
@@ -2730,7 +2732,7 @@ function wt(e, t) {
|
|
|
2730
2732
|
headers: { "Content-Type": "application/json" },
|
|
2731
2733
|
body: JSON.stringify(l)
|
|
2732
2734
|
});
|
|
2733
|
-
if (!u.ok) throw await
|
|
2735
|
+
if (!u.ok) throw await J.fromResponse("VectorSearch", u);
|
|
2734
2736
|
let d = await u.json();
|
|
2735
2737
|
if (d.length === 0) {
|
|
2736
2738
|
c([]);
|
|
@@ -2741,7 +2743,7 @@ function wt(e, t) {
|
|
|
2741
2743
|
headers: { "Content-Type": "application/json" },
|
|
2742
2744
|
body: JSON.stringify(f)
|
|
2743
2745
|
});
|
|
2744
|
-
if (!p.ok) throw await
|
|
2746
|
+
if (!p.ok) throw await J.fromResponse("GetJson", p);
|
|
2745
2747
|
c((await p.json()).map((e, t) => ({
|
|
2746
2748
|
document: e,
|
|
2747
2749
|
documentKey: f[t],
|
|
@@ -2767,7 +2769,7 @@ function wt(e, t) {
|
|
|
2767
2769
|
//#endregion
|
|
2768
2770
|
//#region src/hooks/useHybridSearch.ts
|
|
2769
2771
|
function Tt(e, t) {
|
|
2770
|
-
let { url: n, team: r, dataset: a, authenticatedFetch: o } =
|
|
2772
|
+
let { url: n, team: r, dataset: a, authenticatedFetch: o } = X(), [s, c] = l(null), [u, d] = l(!1), [f, p] = l(void 0);
|
|
2771
2773
|
return {
|
|
2772
2774
|
results: s,
|
|
2773
2775
|
isLoading: u,
|
|
@@ -2788,7 +2790,7 @@ function Tt(e, t) {
|
|
|
2788
2790
|
headers: { "Content-Type": "application/json" },
|
|
2789
2791
|
body: JSON.stringify(l)
|
|
2790
2792
|
});
|
|
2791
|
-
if (!u.ok) throw await
|
|
2793
|
+
if (!u.ok) throw await J.fromResponse("HybridSearch", u);
|
|
2792
2794
|
let d = await u.json();
|
|
2793
2795
|
if (d.length === 0) {
|
|
2794
2796
|
c([]);
|
|
@@ -2799,7 +2801,7 @@ function Tt(e, t) {
|
|
|
2799
2801
|
headers: { "Content-Type": "application/json" },
|
|
2800
2802
|
body: JSON.stringify(f)
|
|
2801
2803
|
});
|
|
2802
|
-
if (!p.ok) throw await
|
|
2804
|
+
if (!p.ok) throw await J.fromResponse("GetJson", p);
|
|
2803
2805
|
c((await p.json()).map((e, t) => ({
|
|
2804
2806
|
document: e,
|
|
2805
2807
|
documentKey: f[t],
|
|
@@ -2853,13 +2855,13 @@ function Dt(e, t) {
|
|
|
2853
2855
|
};
|
|
2854
2856
|
}
|
|
2855
2857
|
function Ot(e = {}) {
|
|
2856
|
-
let t =
|
|
2858
|
+
let t = X(), { url: n, team: r, dataset: a, authenticatedFetch: s, setQuery: u, toggleFilter: d, setRangeFilter: f, setSort: p } = t, { auto: m } = e, h = c(t);
|
|
2857
2859
|
h.current = t;
|
|
2858
2860
|
let [g, _] = l(null), [v, y] = l(""), [b, x] = l(!1), S = c(0), C = i(async (e) => {
|
|
2859
2861
|
let t = ++S.current;
|
|
2860
2862
|
x(!0);
|
|
2861
2863
|
try {
|
|
2862
|
-
let i = await s(`${n}/api/teams/${r}/datasets/${a}/search-or-ask/filters${
|
|
2864
|
+
let i = await s(`${n}/api/teams/${r}/datasets/${a}/search-or-ask/filters${De(h.current)}`, {
|
|
2863
2865
|
method: "POST",
|
|
2864
2866
|
headers: { "Content-Type": "application/json" },
|
|
2865
2867
|
body: JSON.stringify({ text: e })
|
|
@@ -2907,7 +2909,7 @@ function Ot(e = {}) {
|
|
|
2907
2909
|
let o = ++S.current;
|
|
2908
2910
|
x(!0);
|
|
2909
2911
|
try {
|
|
2910
|
-
let c = await s(`${n}/api/teams/${r}/datasets/${a}/search-or-ask/filters${
|
|
2912
|
+
let c = await s(`${n}/api/teams/${r}/datasets/${a}/search-or-ask/filters${De(h.current)}`, {
|
|
2911
2913
|
method: "POST",
|
|
2912
2914
|
headers: { "Content-Type": "application/json" },
|
|
2913
2915
|
body: JSON.stringify({ text: t })
|
|
@@ -2954,7 +2956,7 @@ var kt = {
|
|
|
2954
2956
|
steps: []
|
|
2955
2957
|
};
|
|
2956
2958
|
function At() {
|
|
2957
|
-
let e =
|
|
2959
|
+
let e = X(), { url: t, team: n, dataset: r, authenticatedFetch: a } = e, s = c(e);
|
|
2958
2960
|
s.current = e;
|
|
2959
2961
|
let [u, d] = l(kt), f = c(u);
|
|
2960
2962
|
f.current = u;
|
|
@@ -2988,7 +2990,7 @@ function At() {
|
|
|
2988
2990
|
}
|
|
2989
2991
|
}));
|
|
2990
2992
|
try {
|
|
2991
|
-
let e = await a(`${t}/api/teams/${n}/datasets/${r}/search-or-ask/ask${
|
|
2993
|
+
let e = await a(`${t}/api/teams/${n}/datasets/${r}/search-or-ask/ask${De(s.current)}`, {
|
|
2992
2994
|
method: "POST",
|
|
2993
2995
|
headers: {
|
|
2994
2996
|
"Content-Type": "application/json",
|
|
@@ -3018,7 +3020,7 @@ function At() {
|
|
|
3018
3020
|
h(t.code ?? `http${e.status}`, t.detail ?? "The question could not be asked.");
|
|
3019
3021
|
return;
|
|
3020
3022
|
}
|
|
3021
|
-
for await (let { event: t, data: n } of
|
|
3023
|
+
for await (let { event: t, data: n } of Ee(e.body)) switch (t) {
|
|
3022
3024
|
case "status": {
|
|
3023
3025
|
let e = n.step;
|
|
3024
3026
|
e && d((t) => ({
|
|
@@ -3288,26 +3290,26 @@ var Lt = ({ question: e, followUps: t = !1, onSourceClick: n, label: r = "Answer
|
|
|
3288
3290
|
if (A === "idle" && I.length === 0) return null;
|
|
3289
3291
|
let K = (e, t) => (r) => {
|
|
3290
3292
|
r.preventDefault(), j(e, t), n?.(e);
|
|
3291
|
-
},
|
|
3293
|
+
}, q = (e, t) => (r) => {
|
|
3292
3294
|
let i = e.find((e) => e.n === r);
|
|
3293
3295
|
return /* @__PURE__ */ f(C, {
|
|
3294
3296
|
n: r,
|
|
3295
3297
|
title: i?.title,
|
|
3296
3298
|
onClick: i && n ? K(i, t) : void 0
|
|
3297
3299
|
});
|
|
3298
|
-
},
|
|
3300
|
+
}, ne = (e, t, n) => {
|
|
3299
3301
|
let r = new Set([...e.matchAll(Ft)].map((e) => Number(e[1])));
|
|
3300
3302
|
return n && r.size > 0 ? t.filter((e) => r.has(e.n)) : t.slice(0, 3);
|
|
3301
|
-
},
|
|
3302
|
-
let a =
|
|
3303
|
+
}, re = (e, t, r, i) => {
|
|
3304
|
+
let a = ne(e, t, r);
|
|
3303
3305
|
return a.length > 0 && /* @__PURE__ */ f(S, { items: a.map((e) => ({
|
|
3304
3306
|
n: e.n,
|
|
3305
3307
|
title: e.title,
|
|
3306
3308
|
onClick: n ? K(e, i) : void 0
|
|
3307
3309
|
})) });
|
|
3308
|
-
},
|
|
3310
|
+
}, J = () => {
|
|
3309
3311
|
navigator.clipboard?.writeText(E.answer.replace(Ft, "")).catch(() => {}), P(!0), setTimeout(() => P(!1), 2e3);
|
|
3310
|
-
},
|
|
3312
|
+
}, Y = (e) => {
|
|
3311
3313
|
if (!(E.busy || !e.trim())) {
|
|
3312
3314
|
if (A === "answered" && E.answer) {
|
|
3313
3315
|
let e = {
|
|
@@ -3329,7 +3331,7 @@ var Lt = ({ question: e, followUps: t = !1, onSourceClick: n, label: r = "Answer
|
|
|
3329
3331
|
}
|
|
3330
3332
|
z(""), D(e, B.current);
|
|
3331
3333
|
}
|
|
3332
|
-
},
|
|
3334
|
+
}, ie = t ? () => V.current?.focus() : a;
|
|
3333
3335
|
return /* @__PURE__ */ p("div", {
|
|
3334
3336
|
className: `${$.panel} ${b ? $.fill : ""} ${T}`,
|
|
3335
3337
|
"aria-live": "polite",
|
|
@@ -3346,9 +3348,9 @@ var Lt = ({ question: e, followUps: t = !1, onSourceClick: n, label: r = "Answer
|
|
|
3346
3348
|
G(e.filters),
|
|
3347
3349
|
/* @__PURE__ */ f("div", {
|
|
3348
3350
|
className: $.answer,
|
|
3349
|
-
children: i(e.answer,
|
|
3351
|
+
children: i(e.answer, q(e.sources, e.askId))
|
|
3350
3352
|
}),
|
|
3351
|
-
|
|
3353
|
+
re(e.answer, e.sources, !0, e.askId)
|
|
3352
3354
|
]
|
|
3353
3355
|
})]
|
|
3354
3356
|
}, t)), A !== "idle" && /* @__PURE__ */ p("div", {
|
|
@@ -3359,7 +3361,7 @@ var Lt = ({ question: e, followUps: t = !1, onSourceClick: n, label: r = "Answer
|
|
|
3359
3361
|
G(E.filters),
|
|
3360
3362
|
E.answer && /* @__PURE__ */ f("div", {
|
|
3361
3363
|
className: $.answer,
|
|
3362
|
-
children: i(E.answer,
|
|
3364
|
+
children: i(E.answer, q(E.sources))
|
|
3363
3365
|
}),
|
|
3364
3366
|
A === "searching" && E.steps.length > 0 && /* @__PURE__ */ p("div", {
|
|
3365
3367
|
className: $.steps,
|
|
@@ -3400,11 +3402,11 @@ var Lt = ({ question: e, followUps: t = !1, onSourceClick: n, label: r = "Answer
|
|
|
3400
3402
|
". Search still works in the meantime."
|
|
3401
3403
|
] })]
|
|
3402
3404
|
}),
|
|
3403
|
-
A !== "error" && A !== "limited" &&
|
|
3405
|
+
A !== "error" && A !== "limited" && re(E.answer, E.sources, A === "answered"),
|
|
3404
3406
|
A === "answered" && /* @__PURE__ */ f(_, {
|
|
3405
|
-
onCopy:
|
|
3407
|
+
onCopy: J,
|
|
3406
3408
|
copied: N,
|
|
3407
|
-
onFollowUp:
|
|
3409
|
+
onFollowUp: ie
|
|
3408
3410
|
})
|
|
3409
3411
|
]
|
|
3410
3412
|
})]
|
|
@@ -3413,7 +3415,7 @@ var Lt = ({ question: e, followUps: t = !1, onSourceClick: n, label: r = "Answer
|
|
|
3413
3415
|
ref: V,
|
|
3414
3416
|
value: R,
|
|
3415
3417
|
onChange: z,
|
|
3416
|
-
onSend:
|
|
3418
|
+
onSend: Y,
|
|
3417
3419
|
onStop: k,
|
|
3418
3420
|
streaming: E.busy,
|
|
3419
3421
|
placeholder: "Ask a follow-up…",
|
|
@@ -3422,4 +3424,4 @@ var Lt = ({ question: e, followUps: t = !1, onSourceClick: n, label: r = "Answer
|
|
|
3422
3424
|
});
|
|
3423
3425
|
};
|
|
3424
3426
|
//#endregion
|
|
3425
|
-
export { _t as ActiveFiltersPanel, Lt as AskPanel, ft as BucketFilterPanel,
|
|
3427
|
+
export { _t as ActiveFiltersPanel, Lt as AskPanel, ft as BucketFilterPanel, xe as DEFAULT_CUT, he as DEFAULT_THRESHOLDS, et as FilterPanelSkeleton, J as IndxApiError, lt as RangeFilterPanel, Ce as SCORE_SCALE, Se as STRICT_COVERAGE, pe as SearchContext, Ct as SearchErrorBoundary, Le as SearchInput, me as SearchProvider, Ue as SearchResult, Ze as SearchResultRow, Ye as SearchResults, Be as SearchResultsMessage, Ke as SearchResultsSkeleton, St as SearchSettingsPanel, Y as SearchSetupError, yt as SortByPanel, rt as ValueFilterPanel, ie as describeSearchError, ve as isIdentifier, Dt as localFilters, be as nextOffer, Ne as stripAskPhrases, ye as triggers, At as useAsk, Ot as useFilterSuggestion, Tt as useHybridSearch, X as useSearch, X as useSearchContext, Fe as useSearchOrAsk, wt as useVectorSearch, we as visibleResults };
|