@indxsearch/intrface 3.15.1 β†’ 4.0.0-beta.0

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