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

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