@indxsearch/intrface 3.12.0 β†’ 3.13.0

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