@indxsearch/intrface 4.0.0-beta.2 β†’ 4.0.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -2,10 +2,10 @@ import "@indxsearch/systm/styles.css";
2
2
  import e, { Component as t, createContext as n, memo as r, useCallback as i, useContext as a, useEffect as o, useMemo as s, useRef as c, useState as l } from "react";
3
3
  import { Rungs as u, SearchMode as d, SystemState as f, Tolerance as p } from "@indxsearch/indx-types";
4
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";
5
+ import { Alert as _, AlertDescription as v, AlertTitle as y, AnswerActions as b, AssistantMessage as x, Base as S, Button as C, ChatLauncher as w, Checkbox as T, Chip as E, CitationList as D, CitationRef as O, Composer as k, FilterPanelBase as A, InputField as j, Kbd as M, Popover as N, RadioButton as P, SearchField as F, Select as I, ShimmerText as L, Skeleton as R, Slider as z, StreamStatus as B, Suggestions as V, ToggleSwitch as H, Tooltip as U, UserMessage as W } from "@indxsearch/systm";
6
+ import { Ai_agent as G, ArrowDown as K, ArrowRight as ee, Chevron_left as q, Cloud as te, Compose as J, Filter as Y, Fuzzy_search as X, Hour_glass as Z, Indx as ne, Key as re, Lock as ie, Refresh as Q, Search as ae, Sliders_horizontal as oe, Speedometer as se, Warning as ce, X_or_error as le } from "@indxsearch/pixl";
7
7
  // src/context/IndxApiError.ts
8
- var Z = class e extends Error {
8
+ var $ = class e extends Error {
9
9
  status;
10
10
  code;
11
11
  problem;
@@ -29,14 +29,14 @@ var Z = 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
- }, oe = class extends Error {
32
+ }, ue = class extends Error {
33
33
  constructor(e) {
34
34
  super(e), this.name = "SearchSetupError";
35
35
  }
36
36
  };
37
- function se(e, t) {
37
+ function de(e, t) {
38
38
  let n = e instanceof Error ? e.message : String(e);
39
- if (e instanceof oe) return {
39
+ if (e instanceof ue) return {
40
40
  kind: "setup",
41
41
  message: n,
42
42
  technical: n,
@@ -48,7 +48,7 @@ function se(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 Z) {
51
+ if (e instanceof $) {
52
52
  let r = {
53
53
  message: n,
54
54
  status: e.status,
@@ -114,15 +114,15 @@ function se(e, t) {
114
114
  };
115
115
  }
116
116
  // src/context/useIndxAuth.ts
117
- function ce({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebugLogs: i = !1 }) {
117
+ function fe({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebugLogs: i = !1 }) {
118
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
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 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.");
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 ue("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 ue("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 ue("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,7 +133,7 @@ function ce({ 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 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));
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 $.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 $.fromResponse("Dataset status", c)) : (console.error("[Auth] ❌ Failed to get dataset status:", c.status), await $.fromResponse("Dataset status", c));
137
137
  let l = await c.json();
138
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
139
  let u = l.documentCount ?? l.numberOfRecords ?? 0;
@@ -144,9 +144,9 @@ function ce({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebug
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 (!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);
147
+ if (!d.ok) throw console.error("[Auth] ❌ GetFilterableFields failed:", d.status), await $.fromResponse("Filterable fields", d);
148
+ if (!m.ok) throw console.error("[Auth] ❌ GetFacetableFields failed:", m.status), await $.fromResponse("Facetable fields", m);
149
+ if (!g.ok) throw console.error("[Auth] ❌ GetSortableFields failed:", g.status), await $.fromResponse("Sortable fields", g);
150
150
  let [b, S, w] = await Promise.all([
151
151
  d.json().catch((e) => (console.error("Failed to parse GetFilterableFields response:", e), [])),
152
152
  m.json().catch((e) => (console.error("Failed to parse GetFacetableFields response:", e), [])),
@@ -191,7 +191,7 @@ function ce({ 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(se(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(de(r, {
195
195
  team: t,
196
196
  dataset: n
197
197
  }));
@@ -220,25 +220,25 @@ function ce({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebug
220
220
  };
221
221
  }
222
222
  // src/context/buildFilterProxy.ts
223
- async function le(e, t, n, r, i, a, o) {
223
+ async function pe(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 Z.fromResponse(n, s);
229
+ if (!s.ok) throw await $.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 ue(e, t, n, r, i, a) {
235
- return e.length === 0 ? null : e.length === 1 ? e[0] : le("combine", {
234
+ async function me(e, t, n, r, i, a) {
235
+ return e.length === 0 ? null : e.length === 1 ? e[0] : pe("combine", {
236
236
  filters: e,
237
237
  useAndOperation: t === "and"
238
238
  }, "CombineFilters", n, r, i, a);
239
239
  }
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", {
240
+ async function he(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 }) => pe("range", {
242
242
  fieldName: e,
243
243
  lowerLimit: t,
244
244
  upperLimit: o
@@ -247,32 +247,32 @@ async function de(e, t, n, r, i, a, o = {}, s = {}, c = {}) {
247
247
  return Number.isFinite(o) ? f(e, {
248
248
  min: o,
249
249
  max: o
250
- }) : le("value", {
250
+ }) : pe("value", {
251
251
  fieldName: e,
252
252
  value: t
253
253
  }, `Value filter '${e}'`, n, r, i, a);
254
254
  }, [m, h, g] = await Promise.all([
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))),
255
+ Promise.all(l.map(async ([e, t]) => me(await Promise.all(t.map((t) => p(e, t))), o[e] === "any" ? "or" : "and", n, r, i, a))),
256
256
  Promise.all(u.map(([e, t]) => f(e, t))),
257
- Promise.all(d.map(async ([e, t]) => ue(await Promise.all(t.map((t) => f(e, t))), "or", n, r, i, a)))
257
+ Promise.all(d.map(async ([e, t]) => me(await Promise.all(t.map((t) => f(e, t))), "or", n, r, i, a)))
258
258
  ]);
259
- return ue([
259
+ return me([
260
260
  ...m,
261
261
  ...h,
262
262
  ...g
263
263
  ], "and", n, r, i, a);
264
264
  }
265
265
  // src/context/useSearchExecution.ts
266
- function fe(e, t) {
266
+ function ge(e, t) {
267
267
  let n, r = (...r) => {
268
268
  clearTimeout(n), n = setTimeout(() => e(...r), t);
269
269
  };
270
270
  return r.cancel = () => clearTimeout(n), r;
271
271
  }
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 }) {
273
- let b = y ? y(e.query) : e.query, x = c(e.query);
274
- x.current = e.query;
275
- let S = c(0), C = c(void 0), w = c(!1), [T, E] = l({}), [D, O] = l(""), [k, A] = l("");
272
+ function _e({ 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, facetTiming: b = "inFlight" }) {
273
+ let x = y ? y(e.query) : e.query, S = c(e.query);
274
+ S.current = e.query;
275
+ let C = c(0), w = c(void 0), T = c(0), E = c(0), D = c(0), O = c(!1), [k, A] = l({}), [j, M] = l(""), [N, P] = l("");
276
276
  o(() => {
277
277
  r.isFetchingInitial || t((e) => ({
278
278
  ...e,
@@ -294,180 +294,202 @@ function pe({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, tea
294
294
  r.sortableFields,
295
295
  t
296
296
  ]);
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 }) => {
297
+ let F = e.searchSettings.maxNumberOfRecordsToReturn, I = e.searchSettings.mode, L = e.searchSettings.refocus, R = e.searchSettings.match, z = e.searchSettings.candidates, B = e.searchSettings.ranking, V = e.searchSettings.minimumScore, H = e.sortBy, U = e.sortAscending, W = i(async ({ enableFacets: i, pick: o, facetsOnly: c = !1 }) => {
298
298
  if (!r.token) return;
299
- let o = b.trim() === "";
300
- if (o && !d) return;
301
- let c = ++S.current;
302
- t((e) => ({
299
+ let l = x.trim() === "";
300
+ if (l && !d) return;
301
+ let f = c ? C.current : ++C.current, m = c ? ++E.current : 0;
302
+ c ? i = !0 : t((e) => ({
303
303
  ...e,
304
304
  isLoading: !0
305
- })), o && (i = !0);
305
+ })), l && (i = !0);
306
+ let y = c || !i ? T.current : ++T.current;
306
307
  try {
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({
308
+ let l = 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)])) : [], [b, ...w] = await Promise.all([he(e.filters, e.rangeFilters, a, s, u, n, e.valueMatch, e.bucketFilters, e.fieldTypes), ...l.map((t) => he({
308
309
  ...e.filters,
309
310
  [t]: []
310
311
  }, e.rangeFilters, a, s, u, n, e.valueMatch, {
311
312
  ...e.bucketFilters,
312
313
  [t]: []
313
- }, e.fieldTypes))]), m = d || b.trim() !== "", y = {
314
- text: b,
315
- mode: M,
316
- match: P,
317
- candidates: F,
318
- ranking: I
319
- }, C = {
320
- ...y,
321
- maxNumberOfRecordsToReturn: m ? j : 0,
314
+ }, e.fieldTypes))]), E = !c && (d || x.trim() !== ""), O = {
315
+ text: x,
316
+ mode: I,
317
+ match: R,
318
+ candidates: z,
319
+ ranking: B
320
+ }, W = {
321
+ ...O,
322
+ maxNumberOfRecordsToReturn: E ? F : 0,
322
323
  enableFacets: i,
323
- ...m ? { includeDocuments: !0 } : {},
324
- ...l ? { filter: l } : {},
325
- ...R ? { sortBy: R } : {},
326
- ...z === void 0 ? {} : { sortAscending: z }
324
+ ...E ? { includeDocuments: !0 } : {},
325
+ ...b ? { filter: b } : {},
326
+ ...H ? { sortBy: H } : {},
327
+ ...U === void 0 ? {} : { sortAscending: U }
327
328
  };
328
- p && console.log("[performSearch] request body:", JSON.stringify(C, null, 2));
329
- let w = new URLSearchParams({ session: h });
330
- g && w.set("source", g);
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}`, {
329
+ p && console.log("[performSearch] request body:", JSON.stringify(W, null, 2));
330
+ let G = new URLSearchParams({ session: h });
331
+ g && G.set("source", g);
332
+ let K = _ ?? ve();
333
+ K && G.set("locale", K), v || G.set("count", "false"), L && G.set("refocus", "true"), S.current.trim() !== x.trim() && G.set("typed", S.current), o && (G.set("pickField", o.field), G.set("pickValue", o.value), G.set("pickText", o.text), o.fallback && G.set("pickFallback", "true"));
334
+ let ee = (e) => n(`${a}/api/teams/${s}/datasets/${u}/search?${G}`, {
334
335
  method: "POST",
335
336
  headers: { "Content-Type": "application/json" },
336
337
  body: JSON.stringify(e)
337
- }), [H, ...U] = await Promise.all([V(C), ...f.map((e) => V({
338
- ...y,
338
+ }), [q, ...te] = await Promise.all([ee(W), ...w.map((e) => ee({
339
+ ...O,
339
340
  maxNumberOfRecordsToReturn: 0,
340
341
  enableFacets: !0,
341
342
  ...e ? { filter: e } : {}
342
343
  }))]);
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 = {};
345
- for (let e = 0; e < o.length; e++) {
346
- let t = o[e];
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]);
344
+ if (!q.ok) throw await $.fromResponse("Search", q);
345
+ let J = await q.json(), Y = q.headers.get("Indx-Query-Id") ?? void 0, X = J.isFallback ? void 0 : J.count, Z = J.isFallback === !0, ne = J.toleranceCounts ?? null, re = J.countedTolerance ?? null, ie = J.ranked, Q = J.reranked, ae = J.fill ?? null, oe = {};
346
+ for (let e = 0; e < l.length; e++) {
347
+ let t = l[e];
348
+ if (!te[e].ok) throw await $.fromResponse(`Facets for '${t}'`, te[e]);
349
+ let n = await te[e].json();
350
+ n.facets?.[t] !== void 0 && (oe[t] = n.facets[t]);
350
351
  }
351
- let re = W.records || [], ie = re.map((e) => e.documentKey), ae = re.map((e) => e.score), oe = [];
352
- if (m && ie.length > 0) {
352
+ let se = J.records || [], ce = se.map((e) => e.documentKey), le = se.map((e) => e.score), ue = [];
353
+ if (E && ce.length > 0) {
353
354
  let e;
354
- if (Array.isArray(W.documents) && W.documents.length === ie.length) e = W.documents;
355
+ if (Array.isArray(J.documents) && J.documents.length === ce.length) e = J.documents;
355
356
  else {
356
357
  let t = await n(`${a}/api/teams/${s}/datasets/${u}/documents/lookup`, {
357
358
  method: "POST",
358
359
  headers: { "Content-Type": "application/json" },
359
- body: JSON.stringify(ie)
360
+ body: JSON.stringify(ce)
360
361
  });
361
- if (!t.ok) throw await Z.fromResponse("Document lookup", t);
362
+ if (!t.ok) throw await $.fromResponse("Document lookup", t);
362
363
  e = await t.json();
363
364
  }
364
- oe = e.map((e, t) => ({
365
+ ue = e.map((e, t) => ({
365
366
  document: e,
366
- documentKey: ie[t],
367
- score: ae[t]
367
+ documentKey: ce[t],
368
+ score: le[t]
368
369
  }));
369
370
  }
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) {
371
+ let de = {};
372
+ if (i && J.facets) {
373
+ for (let [e, t] of Object.entries(J.facets)) if (Array.isArray(t) && t.length > 0) {
373
374
  let n = t.map((e) => Number(e.key)).filter((e) => !isNaN(e));
374
- n.length > 0 && (se[e] = {
375
+ n.length > 0 && (de[e] = {
375
376
  min: Math.min(...n),
376
377
  max: Math.max(...n)
377
378
  });
378
379
  }
379
380
  }
380
- if (c !== S.current) return;
381
- let ce = b !== D, le = b !== k, ue = e.facetStats ?? {};
382
- if (ce ? (ue = {
381
+ if (c) {
382
+ if (y !== T.current || m < D.current) return;
383
+ if (D.current = m, f !== C.current) {
384
+ let e = Object.keys(oe).length > 0 ? {
385
+ ...J.facets ?? {},
386
+ ...oe
387
+ } : J.facets;
388
+ e && Object.keys(e).length > 0 && t((t) => ({
389
+ ...t,
390
+ facets: e
391
+ }));
392
+ return;
393
+ }
394
+ } else if (f !== C.current) return;
395
+ let fe = x !== j, pe = x !== N, me = e.facetStats ?? {};
396
+ if (fe ? (me = {
383
397
  ...r.initialFacetStats,
384
- ...se
385
- }, E(ue), O(b)) : ue = {
386
- ...T,
387
- ...se
388
- }, le && i) {
398
+ ...de
399
+ }, A(me), M(x)) : me = {
400
+ ...k,
401
+ ...de
402
+ }, pe && i) {
389
403
  let n = { ...e.rangeBounds };
390
- for (let [e, t] of Object.entries(se)) n[e] = t;
404
+ for (let [e, t] of Object.entries(de)) n[e] = t;
391
405
  t((e) => ({
392
406
  ...e,
393
407
  rangeBounds: n
394
- })), A(b);
408
+ })), P(x);
395
409
  }
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) => ({
410
+ let ge = Object.keys(oe).length > 0 ? {
411
+ ...J.facets ?? {},
412
+ ...oe
413
+ } : J.facets;
414
+ if (i && (!ge || Object.keys(ge).length === 0)) {
415
+ ge = {};
416
+ for (let [e, t] of Object.entries(r.initialFacetKeys)) ge[e] = t.map((e) => ({
403
417
  key: e,
404
418
  value: null
405
419
  }));
406
420
  }
407
- let pe = oe.filter((e) => {
408
- let t = b.trim();
409
- return t === "" || t.length === 1 || e.score >= L;
421
+ let _e = ue.filter((e) => {
422
+ let t = x.trim();
423
+ return t === "" || t.length === 1 || e.score >= V;
410
424
  }).map((e, t) => ({
411
425
  ...e,
412
426
  position: t + 1
413
427
  }));
428
+ if (c) {
429
+ t((e) => ({
430
+ ...e,
431
+ facets: ge,
432
+ facetStats: me
433
+ }));
434
+ return;
435
+ }
414
436
  t((e) => ({
415
437
  ...e,
416
- results: pe,
438
+ results: _e,
417
439
  error: void 0,
418
440
  errorInfo: void 0,
419
- resultsSuppressed: !m,
441
+ resultsSuppressed: !E,
420
442
  ...i ? {
421
- facets: fe,
422
- facetStats: ue
443
+ facets: ge,
444
+ facetStats: me
423
445
  } : {},
424
446
  isLoading: !1,
425
- countedTotal: K,
426
- isFallback: ee,
427
- toleranceCounts: q,
428
- countedTolerance: te,
429
- ranked: ne,
430
- reranked: J,
431
- fill: Y,
432
- queryId: G
447
+ countedTotal: X,
448
+ isFallback: Z,
449
+ toleranceCounts: ne,
450
+ countedTolerance: re,
451
+ ranked: ie,
452
+ reranked: Q,
453
+ fill: ae,
454
+ queryId: Y
433
455
  }));
434
456
  } catch (e) {
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;
457
+ 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 || f !== C.current) return;
436
458
  t((t) => ({
437
459
  ...t,
438
460
  results: null,
439
461
  isLoading: !1,
440
462
  resultsSuppressed: !1,
441
463
  error: e instanceof Error ? e.message : "Search failed",
442
- errorInfo: se(e, {
464
+ errorInfo: de(e, {
443
465
  team: s,
444
466
  dataset: u
445
467
  })
446
468
  }));
447
469
  }
448
470
  }, [
449
- b,
471
+ x,
450
472
  e.filters,
451
473
  e.valueMatch,
452
474
  e.rangeFilters,
453
475
  e.bucketFilters,
454
476
  e.facetStats,
455
- R,
456
- z,
457
- j,
458
- M,
459
- N,
460
- P,
477
+ H,
478
+ U,
461
479
  F,
462
480
  I,
463
481
  L,
482
+ R,
483
+ z,
484
+ B,
485
+ V,
464
486
  n,
465
487
  r.initialFacetStats,
466
488
  r.initialFacetKeys,
467
489
  r.token,
468
- T,
469
- D,
470
490
  k,
491
+ j,
492
+ N,
471
493
  e.rangeBounds,
472
494
  a,
473
495
  s,
@@ -481,82 +503,103 @@ function pe({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, tea
481
503
  v
482
504
  ]);
483
505
  o(() => {
484
- C.current = B;
485
- }, [B]);
486
- let V = c(null);
487
- o(() => (V.current?.cancel(), V.current = fe(() => {
488
- p && console.log("Debounced searchWithFacets fired"), C.current?.({ enableFacets: !0 });
506
+ w.current = W;
507
+ }, [W]);
508
+ let G = c(null);
509
+ o(() => (G.current?.cancel(), G.current = ge(() => {
510
+ p && console.log("Debounced searchWithFacets fired"), w.current?.({ enableFacets: !0 });
489
511
  }, e.facetDebounceDelayMillis ?? 500), () => {
490
- V.current?.cancel();
491
- }), [e.facetDebounceDelayMillis]), o(() => {
492
- !r.isFetchingInitial && r.token && !w.current && ((d || b.trim() !== "") && C.current?.({ enableFacets: f }), w.current = !0);
512
+ G.current?.cancel();
513
+ }), [e.facetDebounceDelayMillis]);
514
+ let K = c(!1), ee = c(!1), q = c(() => {});
515
+ q.current = () => {
516
+ K.current ? ee.current = !0 : (K.current = !0, ee.current = !1, (w.current?.({
517
+ enableFacets: !0,
518
+ facetsOnly: !0
519
+ }) ?? Promise.resolve()).finally(() => {
520
+ K.current = !1, ee.current && q.current();
521
+ }));
522
+ };
523
+ let te = () => {
524
+ b === "debounce" ? G.current?.() : q.current();
525
+ }, J = () => {
526
+ G.current?.cancel(), ee.current = !1, T.current++;
527
+ };
528
+ o(() => {
529
+ !r.isFetchingInitial && r.token && !O.current && ((d || x.trim() !== "") && w.current?.({ enableFacets: f }), O.current = !0);
493
530
  }, [
494
531
  r.isFetchingInitial,
495
532
  r.token,
496
533
  d,
497
534
  f
498
535
  ]), o(() => {
499
- if (!r.token || !w.current) return;
500
- let e = b.trim(), n = e === "" && d;
501
- if (e === "" && !d) S.current++, V.current?.cancel(), t((e) => e.resultsSuppressed && !e.isLoading ? e : {
536
+ if (!r.token || !O.current) return;
537
+ let e = x.trim(), n = e === "" && d;
538
+ if (e === "" && !d) C.current++, J(), t((e) => e.resultsSuppressed && !e.isLoading ? e : {
502
539
  ...e,
503
540
  resultsSuppressed: !0,
504
541
  isLoading: !1
505
542
  });
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();
543
+ else return n ? (J(), w.current?.({ enableFacets: f })) : f ? (p && console.log("Search fired"), w.current?.({ enableFacets: !1 }), te()) : w.current?.({ enableFacets: !1 }), () => {
544
+ G.current?.cancel();
508
545
  };
509
546
  }, [
510
- b,
547
+ x,
511
548
  d,
512
549
  f
513
550
  ]), o(() => {
514
- if (!w.current || !r.token || e.filterRevision === 0) return;
515
- let t = b.trim();
516
- (d || t !== "") && C.current?.({ enableFacets: f });
551
+ if (!O.current || !r.token || e.filterRevision === 0) return;
552
+ let t = x.trim();
553
+ if (d || t !== "") {
554
+ let t = e.pick?.revision === e.filterRevision ? e.pick : void 0;
555
+ w.current?.({
556
+ enableFacets: f,
557
+ pick: t
558
+ });
559
+ }
517
560
  }, [e.filterRevision]), o(() => {
518
- if (!w.current || !r.token) return;
519
- let e = b.trim();
520
- (d || e !== "") && C.current?.({ enableFacets: f });
521
- }, [R, z]);
522
- let H = c(!0), U = c(b);
561
+ if (!O.current || !r.token) return;
562
+ let e = x.trim();
563
+ (d || e !== "") && w.current?.({ enableFacets: f });
564
+ }, [H, U]);
565
+ let Y = c(!0), X = c(x);
523
566
  return o(() => {
524
- if (H.current) {
525
- H.current = !1;
567
+ if (Y.current) {
568
+ Y.current = !1;
526
569
  return;
527
570
  }
528
- if (U.current !== b || !w.current || !r.token) return;
571
+ if (X.current !== x || !O.current || !r.token) return;
529
572
  if (m.current) {
530
- m.current = !1, C.current?.({ enableFacets: !1 });
573
+ m.current = !1, w.current?.({ enableFacets: !1 });
531
574
  return;
532
575
  }
533
- let e = b.trim();
534
- (d || e !== "") && C.current?.({ enableFacets: f });
576
+ let e = x.trim();
577
+ (d || e !== "") && w.current?.({ enableFacets: f });
535
578
  }, [
536
- j,
537
- M,
538
- N,
539
- P,
540
579
  F,
541
580
  I,
542
- L
581
+ L,
582
+ R,
583
+ z,
584
+ B,
585
+ V
543
586
  ]), o(() => {
544
- U.current = b;
545
- }, [b]), { retrySearch: i(() => {
546
- C.current?.({ enableFacets: f });
587
+ X.current = x;
588
+ }, [x]), { retrySearch: i(() => {
589
+ w.current?.({ enableFacets: f });
547
590
  }, [f]) };
548
591
  }
549
- function me() {
592
+ function ve() {
550
593
  if (typeof document < "u" && document.documentElement.lang) return document.documentElement.lang;
551
594
  if (typeof navigator < "u" && navigator.language) return navigator.language;
552
595
  }
553
596
  // src/context/SearchContext.tsx
554
- function he() {
597
+ function ye() {
555
598
  let e = globalThis.crypto;
556
599
  return e?.randomUUID ? e.randomUUID() : Math.random().toString(36).slice(2) + Date.now().toString(36);
557
600
  }
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({
601
+ var be = "Type to search", xe = n(void 0), Se = ({ children: e, url: t, team: n, dataset: r, allowEmptySearch: a = !1, maxResults: s = 10, facetDebounceDelayMillis: u = 500, facetTiming: d = "inFlight", enableFacets: f = !0, mode: p, match: m = {}, candidates: g = {}, ranking: _ = {}, enableDebugLogs: v = !1, preAuthenticatedToken: y, source: b, locale: x, count: S = !0, searchTextOf: C }) => {
602
+ let w = c(!1), T = c(ye()).current, [E, D] = l(null), [O, k] = l(null), A = i((e) => !C || e === E ? e : C(e), [C, E]), j = c(s), [M, N] = l({
560
603
  query: "",
561
604
  results: null,
562
605
  isLoading: !1,
@@ -576,89 +619,90 @@ var ge = "Type to search", _e = n(void 0), ve = ({ children: e, url: t, team: n,
576
619
  rangeBounds: {},
577
620
  searchSettings: {
578
621
  maxNumberOfRecordsToReturn: s,
579
- mode: f,
580
- match: p,
581
- candidates: m,
582
- ranking: g,
622
+ mode: p,
623
+ match: m,
624
+ candidates: g,
625
+ ranking: _,
583
626
  minimumScore: 0,
584
627
  showScore: !0,
585
- placeholderText: ge
628
+ placeholderText: be
586
629
  }
587
630
  });
588
631
  o(() => {
589
- _ && console.log("SearchContext mounted on client");
590
- }, [_]), o(() => {
591
- M((e) => ({
632
+ v && console.log("SearchContext mounted on client");
633
+ }, [v]), o(() => {
634
+ N((e) => ({
592
635
  ...e,
593
636
  facetDebounceDelayMillis: u
594
637
  }));
595
638
  }, [u]);
596
- let [N] = l(d), P = ce({
639
+ let [P] = l(f), F = fe({
597
640
  url: t,
598
641
  team: n,
599
642
  dataset: r,
600
- preAuthenticatedToken: v,
601
- enableDebugLogs: _
602
- }), F = i((e, t = {}) => {
603
- if (!P.token) throw Error("No authentication token available");
643
+ preAuthenticatedToken: y,
644
+ enableDebugLogs: v
645
+ }), I = i((e, t = {}) => {
646
+ if (!F.token) throw Error("No authentication token available");
604
647
  return fetch(e, {
605
648
  ...t,
606
649
  headers: {
607
650
  ...t.headers,
608
- Authorization: `Bearer ${P.token}`
651
+ Authorization: `Bearer ${F.token}`
609
652
  }
610
653
  });
611
- }, [P.token]), { retrySearch: I } = pe({
612
- state: j,
613
- setState: M,
614
- authenticatedFetch: F,
615
- auth: P,
654
+ }, [F.token]), { retrySearch: L } = _e({
655
+ state: M,
656
+ setState: N,
657
+ authenticatedFetch: I,
658
+ auth: F,
616
659
  url: t,
617
660
  team: n,
618
661
  dataset: r,
619
662
  allowEmptySearch: a,
620
- facetsEnabled: N,
621
- enableDebugLogs: _,
622
- shouldFetchMore: C,
623
- sessionId: w,
624
- source: y,
625
- locale: b,
626
- count: x,
627
- searchTextOf: k
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);
663
+ facetsEnabled: P,
664
+ enableDebugLogs: v,
665
+ shouldFetchMore: w,
666
+ sessionId: T,
667
+ source: b,
668
+ locale: x,
669
+ count: S,
670
+ searchTextOf: A,
671
+ facetTiming: d
672
+ }), R = c(void 0);
673
+ R.current = M.queryId;
674
+ let z = c(/* @__PURE__ */ new Map()), B = i(async (e) => {
675
+ if (F.token) {
676
+ z.current.set(e.documentKey, R.current);
633
677
  try {
634
- let i = await F(`${t}/api/teams/${n}/datasets/${r}/events/select`, {
678
+ let i = await I(`${t}/api/teams/${n}/datasets/${r}/events/select`, {
635
679
  method: "POST",
636
680
  headers: { "Content-Type": "application/json" },
637
681
  body: JSON.stringify({
638
- queryId: L.current,
682
+ queryId: R.current,
639
683
  documentKey: e.documentKey,
640
684
  position: e.position,
641
- ...x ? {} : { count: !1 }
685
+ ...S ? {} : { count: !1 }
642
686
  })
643
687
  });
644
- _ && (i.ok ? console.log(`[select] document ${e.documentKey} at position ${e.position}`) : console.warn(`[select] not recorded: ${i.status}`));
688
+ v && (i.ok ? console.log(`[select] document ${e.documentKey} at position ${e.position}`) : console.warn(`[select] not recorded: ${i.status}`));
645
689
  } catch (e) {
646
- _ && console.warn("[select] failed:", e);
690
+ v && console.warn("[select] failed:", e);
647
691
  }
648
692
  }
649
693
  }, [
650
- P.token,
651
- F,
694
+ F.token,
695
+ I,
652
696
  t,
653
697
  n,
654
698
  r,
655
- _,
656
- x
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;
699
+ v,
700
+ S
701
+ ]), V = i(async (e, i, a) => {
702
+ if (!F.token || !i.trim()) return;
703
+ let o = a?.queryId ?? z.current.get(e) ?? R.current;
660
704
  try {
661
- let s = await F(`${t}/api/teams/${n}/datasets/${r}/events/convert`, {
705
+ let s = await I(`${t}/api/teams/${n}/datasets/${r}/events/convert`, {
662
706
  method: "POST",
663
707
  headers: { "Content-Type": "application/json" },
664
708
  body: JSON.stringify({
@@ -666,23 +710,23 @@ var ge = "Type to search", _e = n(void 0), ve = ({ children: e, url: t, team: n,
666
710
  documentKey: e,
667
711
  type: i.trim(),
668
712
  ...a?.quantity == null ? {} : { quantity: a.quantity },
669
- ...x ? {} : { count: !1 }
713
+ ...S ? {} : { count: !1 }
670
714
  })
671
715
  });
672
- _ && (s.ok ? console.log(`[convert] ${i} on document ${e}`) : console.warn(`[convert] not recorded: ${s.status}`));
716
+ v && (s.ok ? console.log(`[convert] ${i} on document ${e}`) : console.warn(`[convert] not recorded: ${s.status}`));
673
717
  } catch (e) {
674
- _ && console.warn("[convert] failed:", e);
718
+ v && console.warn("[convert] failed:", e);
675
719
  }
676
720
  }, [
677
- P.token,
678
- F,
721
+ F.token,
722
+ I,
679
723
  t,
680
724
  n,
681
725
  r,
682
- _,
683
- x
684
- ]), V = i((e) => {
685
- M((t) => {
726
+ v,
727
+ S
728
+ ]), H = i((e) => {
729
+ N((t) => {
686
730
  let n = Object.keys(t.filters).length > 0, r = Object.keys(t.rangeFilters).length > 0, i = Object.keys(t.bucketFilters).length > 0;
687
731
  return {
688
732
  ...t,
@@ -692,17 +736,17 @@ var ge = "Type to search", _e = n(void 0), ve = ({ children: e, url: t, team: n,
692
736
  bucketFilters: i ? {} : t.bucketFilters,
693
737
  searchSettings: {
694
738
  ...t.searchSettings,
695
- maxNumberOfRecordsToReturn: A.current
739
+ maxNumberOfRecordsToReturn: j.current
696
740
  }
697
741
  };
698
742
  });
699
- }, []), H = i((e) => {
700
- M((t) => ({
743
+ }, []), U = i((e) => {
744
+ N((t) => ({
701
745
  ...t,
702
746
  facetDebounceDelayMillis: e
703
747
  }));
704
- }, []), U = i((e) => {
705
- typeof e.maxNumberOfRecordsToReturn == "number" && (A.current = e.maxNumberOfRecordsToReturn), M((t) => {
748
+ }, []), W = i((e) => {
749
+ typeof e.maxNumberOfRecordsToReturn == "number" && (j.current = e.maxNumberOfRecordsToReturn), N((t) => {
706
750
  let n = {
707
751
  ...t.searchSettings,
708
752
  ...e
@@ -715,33 +759,39 @@ var ge = "Type to search", _e = n(void 0), ve = ({ children: e, url: t, team: n,
715
759
  searchSettings: n
716
760
  };
717
761
  });
718
- }, []), W = i((e) => {
719
- C.current = !0, M((t) => ({
762
+ }, []), G = i((e) => {
763
+ w.current = !0, N((t) => ({
720
764
  ...t,
721
765
  searchSettings: {
722
766
  ...t.searchSettings,
723
767
  maxNumberOfRecordsToReturn: e
724
768
  }
725
769
  }));
726
- }, []), G = i((e, t, n = !1) => {
727
- M((r) => {
728
- let i = { ...r.filters }, a = i[e] || [], o = a.includes(t) ? a.filter((e) => e !== t) : n ? [t] : [...a, t];
729
- return o.length ? i[e] = o : delete i[e], {
730
- ...r,
731
- filters: i,
732
- filterRevision: r.filterRevision + 1
770
+ }, []), K = i((e, t, n = !1, r) => {
771
+ N((i) => {
772
+ let a = { ...i.filters }, o = a[e] || [], s = !o.includes(t), c = s ? n ? [t] : [...o, t] : o.filter((e) => e !== t);
773
+ return c.length ? a[e] = c : delete a[e], {
774
+ ...i,
775
+ filters: a,
776
+ filterRevision: i.filterRevision + 1,
777
+ pick: s && r ? {
778
+ field: e,
779
+ value: t,
780
+ ...r,
781
+ revision: i.filterRevision + 1
782
+ } : void 0
733
783
  };
734
784
  });
735
- }, []), K = i((e, t) => {
736
- M((n) => n.valueMatch[e] === t ? n : {
785
+ }, []), ee = i((e, t) => {
786
+ N((n) => n.valueMatch[e] === t ? n : {
737
787
  ...n,
738
788
  valueMatch: {
739
789
  ...n.valueMatch,
740
790
  [e]: t
741
791
  }
742
792
  });
743
- }, []), ee = i((e, t, n) => {
744
- M((r) => ({
793
+ }, []), q = i((e, t, n) => {
794
+ N((r) => ({
745
795
  ...r,
746
796
  rangeFilters: {
747
797
  ...r.rangeFilters,
@@ -752,16 +802,16 @@ var ge = "Type to search", _e = n(void 0), ve = ({ children: e, url: t, team: n,
752
802
  },
753
803
  filterRevision: r.filterRevision + 1
754
804
  }));
755
- }, []), q = i(() => {
756
- M((e) => ({
805
+ }, []), te = i(() => {
806
+ N((e) => ({
757
807
  ...e,
758
808
  filters: {},
759
809
  rangeFilters: {},
760
810
  bucketFilters: {},
761
811
  filterRevision: e.filterRevision + 1
762
812
  }));
763
- }, []), te = i((e, t, n = !0) => {
764
- M((r) => {
813
+ }, []), J = i((e, t, n = !0) => {
814
+ N((r) => {
765
815
  let i = { ...r.filters }, a = (i[e] || []).filter((e) => e !== t);
766
816
  return a.length > 0 ? i[e] = a : delete i[e], {
767
817
  ...r,
@@ -769,8 +819,8 @@ var ge = "Type to search", _e = n(void 0), ve = ({ children: e, url: t, team: n,
769
819
  filterRevision: r.filterRevision + +!!n
770
820
  };
771
821
  });
772
- }, []), ne = i((e, t = !0) => {
773
- M((n) => {
822
+ }, []), Y = i((e, t = !0) => {
823
+ N((n) => {
774
824
  if (!(e in n.rangeFilters)) return n;
775
825
  let r = { ...n.rangeFilters };
776
826
  return delete r[e], {
@@ -779,83 +829,105 @@ var ge = "Type to search", _e = n(void 0), ve = ({ children: e, url: t, team: n,
779
829
  filterRevision: n.filterRevision + +!!t
780
830
  };
781
831
  });
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 };
832
+ }, []), X = (e, t) => e.min === t.min && e.max === t.max, Z = i((e, t, n = !1) => {
833
+ N((r) => {
834
+ let i = r.bucketFilters[e] ?? [], a = i.some((e) => X(e, t)) ? i.filter((e) => !X(e, t)) : n ? [t] : [...i, t], o = { ...r.bucketFilters };
785
835
  return a.length > 0 ? o[e] = a : delete o[e], {
786
836
  ...r,
787
837
  bucketFilters: o,
788
838
  filterRevision: r.filterRevision + 1
789
839
  };
790
840
  });
791
- }, []), X = i((e, t, n = !0) => {
792
- M((r) => {
793
- let i = { ...r.bucketFilters }, a = t ? (i[e] ?? []).filter((e) => !J(e, t)) : [];
841
+ }, []), ne = i((e, t, n = !0) => {
842
+ N((r) => {
843
+ let i = { ...r.bucketFilters }, a = t ? (i[e] ?? []).filter((e) => !X(e, t)) : [];
794
844
  return a.length > 0 ? i[e] = a : delete i[e], {
795
845
  ...r,
796
846
  bucketFilters: i,
797
847
  filterRevision: r.filterRevision + +!!n
798
848
  };
799
849
  });
800
- }, []), re = i((e, t) => {
801
- M((n) => ({
850
+ }, []), re = i(async (e, i, a, o) => {
851
+ let s = await I(`${t}/api/teams/${n}/datasets/${r}/facets/${encodeURIComponent(e)}/search`, {
852
+ method: "POST",
853
+ headers: { "Content-Type": "application/json" },
854
+ body: JSON.stringify({
855
+ text: i,
856
+ rows: a,
857
+ ...o ? { values: o } : {}
858
+ })
859
+ });
860
+ if (!s.ok) return null;
861
+ let c = await s.json();
862
+ return {
863
+ values: c.values ?? [],
864
+ fallback: c.fallback === !0
865
+ };
866
+ }, [
867
+ t,
868
+ n,
869
+ r,
870
+ I
871
+ ]), ie = i((e, t) => {
872
+ N((n) => ({
802
873
  ...n,
803
874
  sortBy: e || void 0,
804
875
  sortAscending: e ? t : void 0
805
876
  }));
806
877
  }, []);
807
- return /* @__PURE__ */ h(_e.Provider, {
878
+ return /* @__PURE__ */ h(xe.Provider, {
808
879
  value: {
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,
880
+ state: M,
881
+ isFetchingInitial: F.isFetchingInitial || !M.fieldsSeeded,
882
+ authError: F.authError ?? void 0,
883
+ authErrorInfo: F.authErrorInfo ?? void 0,
884
+ retry: F.authError ? F.retry : L,
814
885
  allowEmptySearch: a,
815
- facetsEnabled: N,
816
- datasetBounds: P.initialFacetStats,
886
+ facetsEnabled: P,
887
+ datasetBounds: F.initialFacetStats,
817
888
  url: t,
818
889
  team: n,
819
890
  dataset: r,
820
- authenticatedFetch: F,
821
- setQuery: V,
822
- toggleFilter: G,
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,
836
- sessionId: w,
837
- source: y,
838
- count: x,
839
- searchText: k(j.query),
840
- picks: D && D.query === j.query ? D.picks : null,
841
- showPicks: (e) => O(e ? {
891
+ authenticatedFetch: I,
892
+ setQuery: H,
893
+ toggleFilter: K,
894
+ setValueMatch: ee,
895
+ setRangeFilter: q,
896
+ resetFilters: te,
897
+ resetSingleFilter: J,
898
+ resetRangeFilter: Y,
899
+ toggleBucketFilter: Z,
900
+ resetBucketFilter: ne,
901
+ setSort: ie,
902
+ setDebounceDelay: U,
903
+ setSearchSettings: W,
904
+ fetchMoreResults: G,
905
+ selectResult: B,
906
+ convertResult: V,
907
+ sessionId: T,
908
+ source: b,
909
+ count: S,
910
+ searchText: A(M.query),
911
+ picks: O && O.query === M.query ? O.picks : null,
912
+ showPicks: (e) => k(e ? {
842
913
  picks: e,
843
- query: j.query
914
+ query: M.query
844
915
  } : null),
845
- searchAsTyped: () => E(j.query)
916
+ searchAsTyped: () => D(M.query),
917
+ searchFacetValues: re
846
918
  },
847
919
  children: e
848
920
  });
849
- }, ye = () => {
850
- let e = a(_e);
921
+ }, Ce = () => {
922
+ let e = a(xe);
851
923
  if (!e) throw Error("useSearchContext must be used within a SearchProvider");
852
924
  return e;
853
925
  };
854
926
  // src/utils/searchOrAsk.ts
855
- function be(e, t) {
927
+ function we(e, t) {
856
928
  return t ? t === "proactive" && e !== "proactive" ? "inviting" : t : e;
857
929
  }
858
- var xe = {
930
+ var Te = {
859
931
  strong: .65,
860
932
  strongHide: .45,
861
933
  invite: .4,
@@ -864,32 +936,32 @@ var xe = {
864
936
  finished: .5,
865
937
  found: .3,
866
938
  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) {
939
+ }, Ee = /^[\d\s\-_.:/]+$|^\w+\.\w+|^[A-Za-z]*[a-z][A-Z]\w*$|^[A-Za-z]+[-_]?\d[\w-]*$/;
940
+ function De(e) {
869
941
  let t = e.trim();
870
- return t.length > 0 && !t.includes(" ") && Se.test(t);
942
+ return t.length > 0 && !t.includes(" ") && Ee.test(t);
871
943
  }
872
- function we(e) {
944
+ function Oe(e) {
873
945
  let t = e.trim();
874
- return !!t && !Ce(t) && (t.endsWith("?") || t.split(/\s+/).length >= 3);
946
+ return !!t && !De(t) && (t.endsWith("?") || t.split(/\s+/).length >= 3);
875
947
  }
876
- function Te(e, t = 4) {
948
+ function ke(e, t = 4) {
877
949
  let n = e.trim();
878
- return !n || Ce(n) ? !1 : we(n) || n.length >= t;
950
+ return !n || De(n) ? !1 : Oe(n) || n.length >= t;
879
951
  }
880
- function Ee(e, t, n = xe) {
952
+ function Ae(e, t, n = Te) {
881
953
  return t >= n.strong || e === "strong" && t >= n.strongHide ? "strong" : t >= n.invite || e !== "none" && t >= n.inviteHide ? "invite" : "none";
882
954
  }
883
- var De = {
955
+ var je = {
884
956
  tolerance: p.Exact,
885
957
  typingPrefixFrom: 0,
886
958
  joinedWords: !1
887
959
  };
888
- function Oe(e) {
960
+ function Me(e) {
889
961
  let t = e.trim();
890
962
  return t.includes(" ") || t.endsWith("?");
891
963
  }
892
- async function* ke(e) {
964
+ async function* Ne(e) {
893
965
  let t = e.getReader(), n = new TextDecoder(), r = "";
894
966
  try {
895
967
  for (;;) {
@@ -912,24 +984,24 @@ async function* ke(e) {
912
984
  t.releaseLock();
913
985
  }
914
986
  }
915
- function Ae(e) {
987
+ function Pe(e) {
916
988
  let t = new URLSearchParams();
917
989
  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");
918
990
  let n = t.toString();
919
991
  return n ? `?${n}` : "";
920
992
  }
921
993
  // src/hooks/useSearchOrAsk.ts
922
- function je(e) {
994
+ function Fe(e) {
923
995
  return {
924
- ...xe,
996
+ ...Te,
925
997
  ...e,
926
- hint: e?.hint ?? xe.hint,
927
- finished: e?.finished ?? xe.finished,
928
- found: e?.found ?? xe.found,
929
- refocus: e?.refocus ?? xe.refocus
998
+ hint: e?.hint ?? Te.hint,
999
+ finished: e?.finished ?? Te.finished,
1000
+ found: e?.found ?? Te.found,
1001
+ refocus: e?.refocus ?? Te.refocus
930
1002
  };
931
1003
  }
932
- var Me = .1, Ne = {
1004
+ var Ie = .1, Le = {
933
1005
  available: !1,
934
1006
  offer: "none",
935
1007
  p: null,
@@ -948,15 +1020,19 @@ var Me = .1, Ne = {
948
1020
  finished: null,
949
1021
  answerNow: null,
950
1022
  quick: "none",
951
- stands: !1
1023
+ stands: !1,
1024
+ door: !1,
1025
+ offerRow: "none",
1026
+ offerKind: null,
1027
+ enterAsks: !1
952
1028
  };
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);
1029
+ function Re(e = {}) {
1030
+ let { enabled: t = !0, pauseMs: n = 300, prefetch: r = !0, mode: i, answerAfterMs: a = 1e3 } = e, s = Ce(), { url: u, team: d, dataset: f, authenticatedFetch: p, isFetchingInitial: m, authError: h, state: g } = s, _ = c(s);
955
1031
  _.current = s;
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);
1032
+ let v = (e.text ?? g.query).trim(), [y, b] = l(!1), [x, S] = l(Le), C = c(Te), w = c(!0), T = c("off"), E = c("soft"), D = c(i);
957
1033
  D.current = i;
958
1034
  let O = { get current() {
959
- return be(E.current, D.current);
1035
+ return we(E.current, D.current);
960
1036
  } }, k = c(null), A = c("none"), j = c(""), M = c(0), N = c(0);
961
1037
  A.current = x.offer;
962
1038
  let P = c(null), F = c(/* @__PURE__ */ new Set()), I = c(0), L = c(v);
@@ -979,7 +1055,7 @@ function Pe(e = {}) {
979
1055
  if (!t.ok) return;
980
1056
  let n = await t.json();
981
1057
  if (e || !n.available || !n.settings?.enabled) return;
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);
1058
+ T.current = n.settings.filtersWhileTyping ?? "off", E.current = n.settings.mode ?? "soft", C.current = Fe(n.settings.thresholds), w.current = n.settings.strictCoverageWhileAsking ?? !0, b(!0);
983
1059
  } catch {}
984
1060
  })(), () => {
985
1061
  e = !0;
@@ -991,7 +1067,7 @@ function Pe(e = {}) {
991
1067
  ]);
992
1068
  let K = c(() => {});
993
1069
  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;
1070
+ if (!r || !R.current || P.current || !e || !ke(e, H()) || F.current.has(e) || W(e) || Date.now() < N.current || Date.now() < I.current) return;
995
1071
  let t = (async () => {
996
1072
  try {
997
1073
  let t = await p(`${V}/intent`, {
@@ -1018,18 +1094,18 @@ function Pe(e = {}) {
1018
1094
  });
1019
1095
  }, o(() => {
1020
1096
  if (!y) {
1021
- S(Ne);
1097
+ S(Le);
1022
1098
  return;
1023
1099
  }
1024
1100
  if (!v) {
1025
1101
  j.current = "", S({
1026
- ...Ne,
1102
+ ...Le,
1027
1103
  available: y
1028
1104
  });
1029
1105
  return;
1030
1106
  }
1031
- if (!Te(v, H())) {
1032
- Ce(v) && S((e) => ({
1107
+ if (!ke(v, H())) {
1108
+ De(v) && S((e) => ({
1033
1109
  ...e,
1034
1110
  available: y,
1035
1111
  offer: "none",
@@ -1050,7 +1126,7 @@ function Pe(e = {}) {
1050
1126
  let t = ++M.current;
1051
1127
  j.current = v;
1052
1128
  try {
1053
- let e = await p(`${V}/intent${Ae(_.current)}`, {
1129
+ let e = await p(`${V}/intent${Pe(_.current)}`, {
1054
1130
  method: "POST",
1055
1131
  headers: { "Content-Type": "application/json" },
1056
1132
  body: JSON.stringify({ text: v })
@@ -1076,8 +1152,8 @@ function Pe(e = {}) {
1076
1152
  if (!e.ok) return;
1077
1153
  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
1154
  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;
1155
+ l != null && (w.current = l), d != null && (E.current = d), c && (C.current = Fe(c)), S((e) => {
1156
+ let t = Ae(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) || Me(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) >= _ - Ie;
1081
1157
  return {
1082
1158
  available: !0,
1083
1159
  offer: p,
@@ -1095,6 +1171,10 @@ function Pe(e = {}) {
1095
1171
  mode: O.current,
1096
1172
  askAnytime: !1,
1097
1173
  quick: "none",
1174
+ door: !1,
1175
+ offerRow: "none",
1176
+ offerKind: null,
1177
+ enterAsks: !1,
1098
1178
  finished: a ?? null,
1099
1179
  answerNow: O.current === "proactive" && p === "strong" && U(a) ? v : null,
1100
1180
  stands: !0
@@ -1131,18 +1211,18 @@ function Pe(e = {}) {
1131
1211
  if (te) {
1132
1212
  if (k.current) return;
1133
1213
  let n = t.searchSettings.match ?? {};
1134
- k.current = Object.fromEntries(Object.keys(De).map((e) => [e, n[e]])), e({ match: { ...De } });
1214
+ k.current = Object.fromEntries(Object.keys(je).map((e) => [e, n[e]])), e({ match: { ...je } });
1135
1215
  } else k.current &&= (e({ match: { ...k.current } }), null);
1136
1216
  }, [te]);
1137
- let ne = y && x.refocus && !x.held && z === 0 && !!x.text && v.startsWith(x.text);
1217
+ let J = y && x.refocus && !x.held && z === 0 && !!x.text && v.startsWith(x.text);
1138
1218
  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 {
1219
+ _.current.setSearchSettings({ refocus: J });
1220
+ }, [J]), !y) return Le;
1221
+ let Y = O.current, X = !!x.text && v.startsWith(x.text), Z = x.held || z > 0;
1222
+ if (Z) return {
1143
1223
  ...x,
1144
- mode: J,
1145
- held: X,
1224
+ mode: Y,
1225
+ held: Z,
1146
1226
  offer: "none",
1147
1227
  askAnytime: !1,
1148
1228
  answerNow: null,
@@ -1150,22 +1230,30 @@ function Pe(e = {}) {
1150
1230
  notFound: !1,
1151
1231
  strictCoverage: !1,
1152
1232
  refocus: !1,
1153
- stands: Y
1233
+ stands: X,
1234
+ door: !1,
1235
+ offerRow: "none",
1236
+ offerKind: null,
1237
+ enterAsks: !1
1154
1238
  };
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";
1239
+ let ne = Y === "inviting" || Y === "proactive", re = ne && !!v && (X && x.p != null && x.p >= (C.current.hint ?? 1) || Oe(v)), ie = v ? X && x.offer === "strong" ? Y === "proactive" ? U(x.finished) ? "thinking" : "hint" : "ready" : X && x.offer === "invite" ? ne ? "hint" : "invite" : re ? "hint" : Y === "open" || ne ? "ask" : "none" : "none", Q = X && x.offer === "strong", ae = v ? Q ? Y === "proactive" ? U(x.finished) ? "thinking" : "hint" : "ready" : X && x.offer === "invite" && ne || re ? "hint" : "none" : "none", oe = ae === "ready" ? x.describes && (x.criteria ?? 0) > (x.p ?? 0) ? "describe" : x.notFound ? "notFound" : "ask" : null, se = !!v && ae !== "thinking" && (Y === "open" || ne || Y === "soft" && X && x.offer !== "none");
1156
1240
  return {
1157
1241
  ...x,
1158
- refocus: ne,
1159
- mode: J,
1160
- askAnytime: J === "open" || re,
1242
+ refocus: J,
1243
+ mode: Y,
1244
+ askAnytime: Y === "open" || ne,
1245
+ door: se,
1246
+ offerRow: ae,
1247
+ offerKind: oe,
1248
+ enterAsks: ae === "ready",
1161
1249
  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,
1165
- stands: Y
1250
+ text: (ie === "hint" || ie === "ask") && !X ? v : x.text,
1251
+ notFound: X && x.notFound,
1252
+ quick: ie,
1253
+ stands: X
1166
1254
  };
1167
1255
  }
1168
- var Fe = {
1256
+ var ze = {
1169
1257
  row: "_row_epo6h_3",
1170
1258
  icon: "_icon_epo6h_17",
1171
1259
  line: "_line_epo6h_24",
@@ -1173,107 +1261,112 @@ var Fe = {
1173
1261
  question: "_question_epo6h_43",
1174
1262
  actions: "_actions_epo6h_52",
1175
1263
  enter: "_enter_epo6h_59"
1176
- }, Ie = {
1177
- invite: "Ask about this",
1178
- hint: "For a quick answer, type a bit more",
1179
- ready: "Ask the assistant",
1180
- thinking: "Thinking",
1181
- ask: "Ask"
1182
- }, Le = ({ searchOrAsk: e, onAsk: t, labels: n, className: r = "" }) => {
1183
- let i = {
1184
- ...Ie,
1185
- ...n
1186
- }, a = e.text.trim();
1187
- if (!e.available || e.quick === "none" || !a) return null;
1188
- let o = () => t(a);
1264
+ };
1265
+ // src/components/AskOffer.tsx
1266
+ function Be(e) {
1267
+ return e.row === "hint" ? {
1268
+ text: "Type a bit more to ask the assistant",
1269
+ action: ""
1270
+ } : e.row === "thinking" ? {
1271
+ text: "Thinking",
1272
+ action: ""
1273
+ } : e.kind === "describe" ? {
1274
+ text: "Let the assistant pick the best matches",
1275
+ action: "Explore"
1276
+ } : e.kind === "notFound" ? {
1277
+ text: "Not among these results",
1278
+ action: "Ask the assistant"
1279
+ } : {
1280
+ text: "Ask the assistant about this",
1281
+ action: "Ask the assistant"
1282
+ };
1283
+ }
1284
+ var Ve = ({ searchOrAsk: e, onAsk: t, words: n, className: r = "" }) => {
1285
+ let i = e.text.trim();
1286
+ if (!e.available || e.offerRow === "none" || !i) return null;
1287
+ let a = {
1288
+ row: e.offerRow,
1289
+ kind: e.offerKind,
1290
+ p: e.p,
1291
+ criteria: e.criteria,
1292
+ found: e.found,
1293
+ text: i
1294
+ }, o = {
1295
+ ...Be(a),
1296
+ ...He(n?.(a))
1297
+ }, s = () => t(i);
1189
1298
  return /* @__PURE__ */ g("div", {
1190
- className: `${Fe.row} ${Fe[e.quick]} ${r}`,
1299
+ className: `${ze.row} ${ze[e.offerRow]} ${r}`,
1300
+ "data-kind": e.offerKind ?? void 0,
1191
1301
  "aria-live": "polite",
1192
1302
  children: [
1193
1303
  /* @__PURE__ */ h("span", {
1194
- className: Fe.icon,
1304
+ className: ze.icon,
1195
1305
  "aria-hidden": "true",
1196
- children: /* @__PURE__ */ h(H, {
1306
+ children: /* @__PURE__ */ h(G, {
1197
1307
  size: 14,
1198
1308
  color: "currentColor"
1199
1309
  })
1200
1310
  }),
1201
- e.quick === "thinking" && /* @__PURE__ */ h(F, {
1202
- className: Fe.text,
1203
- children: i.thinking
1204
- }),
1205
- e.quick === "hint" && /* @__PURE__ */ h("button", {
1206
- type: "button",
1207
- className: Fe.line,
1208
- onClick: o,
1209
- children: /* @__PURE__ */ h(F, { children: i.hint })
1311
+ e.offerRow === "thinking" && /* @__PURE__ */ h(L, {
1312
+ className: ze.text,
1313
+ children: o.text
1210
1314
  }),
1211
- e.quick === "invite" && /* @__PURE__ */ h("button", {
1315
+ e.offerRow === "hint" && /* @__PURE__ */ h("button", {
1212
1316
  type: "button",
1213
- className: Fe.line,
1214
- onClick: o,
1215
- children: i.invite
1317
+ className: ze.line,
1318
+ onClick: s,
1319
+ children: /* @__PURE__ */ h(L, { children: o.text })
1216
1320
  }),
1217
- e.quick === "ask" && /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h("span", {
1218
- className: Fe.question,
1219
- children: a
1321
+ e.offerRow === "ready" && /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h("span", {
1322
+ className: ze.question,
1323
+ children: o.text
1220
1324
  }), /* @__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, {
1325
+ className: ze.actions,
1326
+ children: [/* @__PURE__ */ h("span", {
1327
+ className: ze.enter,
1328
+ children: /* @__PURE__ */ h(M, { children: "↡" })
1329
+ }), /* @__PURE__ */ h(C, {
1241
1330
  variant: "primary",
1242
1331
  size: "micro",
1243
- onClick: o,
1244
- children: i.ready
1332
+ onClick: s,
1333
+ children: o.action
1245
1334
  })]
1246
1335
  })] })
1247
1336
  ]
1248
1337
  });
1249
- }, Re = {
1338
+ };
1339
+ function He(e) {
1340
+ return e ? Object.fromEntries(Object.entries(e).filter(([, e]) => typeof e == "string" && e.length > 0)) : {};
1341
+ }
1342
+ var Ue = {
1250
1343
  grid: "_grid_1xjna_2",
1251
1344
  chip: "_chip_1xjna_21",
1252
1345
  chipLabel: "_chipLabel_1xjna_32"
1253
- }, ze = r(({ field: e, value: t, onReset: n }) => /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(S, {
1346
+ }, We = r(({ field: e, value: t, onReset: n }) => /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(C, {
1254
1347
  onClick: n,
1255
- iconRight: /* @__PURE__ */ h(ae, {}),
1348
+ iconRight: /* @__PURE__ */ h(le, {}),
1256
1349
  variant: "primary",
1257
1350
  size: "micro",
1258
- className: Re.chip,
1351
+ className: Ue.chip,
1259
1352
  title: `${e}: ${t}`,
1260
1353
  children: /* @__PURE__ */ g("span", {
1261
- className: Re.chipLabel,
1354
+ className: Ue.chipLabel,
1262
1355
  children: [
1263
1356
  e,
1264
1357
  ": ",
1265
1358
  t
1266
1359
  ]
1267
1360
  })
1268
- }) })), Be = r(({ field: e, min: t, max: n, onReset: r }) => /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(S, {
1361
+ }) })), Ge = r(({ field: e, min: t, max: n, onReset: r }) => /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(C, {
1269
1362
  onClick: r,
1270
- iconRight: /* @__PURE__ */ h(ae, {}),
1363
+ iconRight: /* @__PURE__ */ h(le, {}),
1271
1364
  variant: "primary",
1272
1365
  size: "micro",
1273
- className: Re.chip,
1366
+ className: Ue.chip,
1274
1367
  title: `${e}: ${t} – ${n}`,
1275
1368
  children: /* @__PURE__ */ g("span", {
1276
- className: Re.chipLabel,
1369
+ className: Ue.chipLabel,
1277
1370
  children: [
1278
1371
  e,
1279
1372
  ": ",
@@ -1282,15 +1375,15 @@ var Fe = {
1282
1375
  n
1283
1376
  ]
1284
1377
  })
1285
- }) })), Ve = r(({ field: e, label: t, onReset: n }) => /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(S, {
1378
+ }) })), Ke = r(({ field: e, label: t, onReset: n }) => /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(C, {
1286
1379
  onClick: n,
1287
- iconRight: /* @__PURE__ */ h(ae, {}),
1380
+ iconRight: /* @__PURE__ */ h(le, {}),
1288
1381
  variant: "primary",
1289
1382
  size: "micro",
1290
- className: Re.chip,
1383
+ className: Ue.chip,
1291
1384
  title: `${e}: ${t}`,
1292
1385
  children: /* @__PURE__ */ g("span", {
1293
- className: Re.chipLabel,
1386
+ className: Ue.chipLabel,
1294
1387
  children: [
1295
1388
  e,
1296
1389
  ": ",
@@ -1298,8 +1391,8 @@ var Fe = {
1298
1391
  ]
1299
1392
  })
1300
1393
  }) }));
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) => ({
1394
+ function qe() {
1395
+ let { state: { filters: e, rangeFilters: t, bucketFilters: n }, resetFilters: r, resetSingleFilter: i, resetRangeFilter: a, resetBucketFilter: o } = Ce(), c = s(() => Object.entries(e).map(([e, t]) => t.map((t) => ({
1303
1396
  field: e,
1304
1397
  value: t
1305
1398
  }))).flat(), [e]), l = s(() => Object.entries(t).map(([e, { min: t, max: n }]) => ({
@@ -1315,29 +1408,29 @@ function He() {
1315
1408
  e,
1316
1409
  t,
1317
1410
  u
1318
- ]) ? /* @__PURE__ */ h(O, {
1411
+ ]) ? /* @__PURE__ */ h(A, {
1319
1412
  collapsible: !1,
1320
1413
  title: "Active filters",
1321
1414
  children: /* @__PURE__ */ g("ul", {
1322
- className: Re.grid,
1415
+ className: Ue.grid,
1323
1416
  children: [
1324
- c.map(({ field: e, value: t }) => /* @__PURE__ */ h(ze, {
1417
+ c.map(({ field: e, value: t }) => /* @__PURE__ */ h(We, {
1325
1418
  field: e,
1326
1419
  value: t,
1327
1420
  onReset: () => i(e, t)
1328
1421
  }, `${e}-${t}`)),
1329
- l.map(({ field: e, min: t, max: n }) => /* @__PURE__ */ h(Be, {
1422
+ l.map(({ field: e, min: t, max: n }) => /* @__PURE__ */ h(Ge, {
1330
1423
  field: e,
1331
1424
  min: t,
1332
1425
  max: n,
1333
1426
  onReset: () => a(e)
1334
1427
  }, e)),
1335
- u.map(({ field: e, range: t, label: n }) => /* @__PURE__ */ h(Ve, {
1428
+ u.map(({ field: e, range: t, label: n }) => /* @__PURE__ */ h(Ke, {
1336
1429
  field: e,
1337
1430
  label: n,
1338
1431
  onReset: () => o(e, t)
1339
1432
  }, `${e}-${t.min}-${t.max}`)),
1340
- /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(S, {
1433
+ /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(C, {
1341
1434
  onClick: r,
1342
1435
  size: "micro",
1343
1436
  variant: "ghost",
@@ -1347,7 +1440,7 @@ function He() {
1347
1440
  })
1348
1441
  }) : null;
1349
1442
  }
1350
- var Ue = {
1443
+ var Je = {
1351
1444
  withOffer: "_withOffer_1zrln_2",
1352
1445
  offerRow: "_offerRow_1zrln_10",
1353
1446
  offerHint: "_offerHint_1zrln_18",
@@ -1357,165 +1450,165 @@ var Ue = {
1357
1450
  offerQuick: "_offerQuick_1zrln_56",
1358
1451
  filterChip: "_filterChip_1zrln_59",
1359
1452
  filtersPopover: "_filtersPopover_1zrln_63"
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);
1453
+ }, Ye = ({ className: t = "", autoFocus: n = !1, inputSize: r = "default", showClear: i = !0, showFocus: a = !1, showStatus: o = !0, onAsk: s, searchOrAsk: c, askOffer: l = "chip", onClear: u, onKeyDown: d, ...f }) => {
1454
+ let { state: { query: p, filters: m, rangeFilters: _, bucketFilters: v, results: y, isFallback: b, searchSettings: x }, setQuery: S, resetFilters: w, picks: T, showPicks: D } = Ce(), O = !!T, k = Object.values(m).reduce((e, t) => e + t.length, 0) + Object.keys(_).length + Object.values(v ?? {}).reduce((e, t) => e + t.length, 0), A = p.length > 0, j = A && !O && y !== null && y.length === 0, P = A && !O && y !== null && y.length > 0 && b === !0, I = Re({ enabled: !!s && !c }), R = c ?? I, z = R.enterAsks, B = e.useRef(null);
1362
1455
  e.useEffect(() => {
1363
- let e = L.answerNow;
1364
- s && e && e === f.trim() && z.current !== e && (z.current = e, s(e, { proactive: !0 }));
1456
+ let e = R.answerNow;
1457
+ s && e && e === p.trim() && B.current !== e && (B.current = e, s(e, { proactive: !0 }));
1365
1458
  }, [
1366
- L.answerNow,
1367
- f,
1459
+ R.answerNow,
1460
+ p,
1368
1461
  s
1369
1462
  ]);
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());
1463
+ let V = B.current !== null && B.current === p.trim(), H = l === "below" ? "door" : l, W = !s || !A || V || H === "none" ? "none" : H === "chip" && R.offerRow !== "none" ? R.offerRow : R.door ? "door" : "none", K = R.available && x.placeholderText === "Type to search" ? "Search or ask" : x.placeholderText, ee = (e) => {
1464
+ d?.(e), !e.defaultPrevented && e.key === "Enter" && s && z && p.trim() && (e.preventDefault(), Z());
1372
1465
  }, [q, te] = e.useState(!1);
1373
1466
  e.useEffect(() => {
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, {
1467
+ k === 0 && te(!1);
1468
+ }, [k]);
1469
+ let J = () => {
1470
+ D?.(null), S(""), k > 0 && w(), u?.();
1471
+ }, Z = () => {
1472
+ B.current = p.trim(), s(p.trim());
1473
+ }, ne = /* @__PURE__ */ g(F, {
1381
1474
  type: "text",
1382
- value: f,
1383
- onChange: (e) => x(e.target.value),
1384
- placeholder: W,
1475
+ value: p,
1476
+ onChange: (e) => S(e.target.value),
1477
+ placeholder: K,
1385
1478
  autoFocus: n,
1386
1479
  className: t,
1387
1480
  showSearchIcon: !0,
1388
1481
  inputSize: r,
1389
1482
  showFocusBorder: a,
1390
1483
  clearable: !1,
1391
- onKeyDown: G,
1392
- ...d,
1484
+ onKeyDown: ee,
1485
+ ...f,
1393
1486
  children: [
1394
- l === "chip" && U === "thinking" && /* @__PURE__ */ g("span", {
1395
- className: Ue.thinking,
1487
+ W === "thinking" && /* @__PURE__ */ g("span", {
1488
+ className: Je.thinking,
1396
1489
  "aria-live": "polite",
1397
- children: [/* @__PURE__ */ h(H, {}), /* @__PURE__ */ h(F, { children: "Thinking" })]
1490
+ children: [/* @__PURE__ */ h(G, {}), /* @__PURE__ */ h(L, { children: "Thinking" })]
1398
1491
  }),
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,
1492
+ (W === "door" || W === "hint" || W === "ready") && /* @__PURE__ */ h(C, {
1493
+ variant: W === "ready" ? "primary" : "ghost",
1494
+ className: W === "ready" ? Je.askStrong : void 0,
1402
1495
  size: "micro",
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"
1496
+ iconLeft: /* @__PURE__ */ h(G, {}),
1497
+ iconRight: W === "ready" ? /* @__PURE__ */ h(M, { children: "Enter ↡" }) : void 0,
1498
+ onClick: Z,
1499
+ title: z ? "Enter asks" : "Ask the assistant",
1500
+ children: W === "hint" ? /* @__PURE__ */ h(L, { children: "Type a bit more to ask" }) : W === "ready" && R.offerKind === "describe" ? "Explore" : "Ask"
1408
1501
  }),
1409
- o && M && /* @__PURE__ */ h(w, { children: "No results" }),
1410
- o && P && /* @__PURE__ */ h(B, {
1502
+ o && j && /* @__PURE__ */ h(E, { children: "No results" }),
1503
+ o && P && /* @__PURE__ */ h(U, {
1411
1504
  content: "No direct match. Showing the nearest results.",
1412
- children: /* @__PURE__ */ h("span", { children: /* @__PURE__ */ h(w, {
1413
- icon: /* @__PURE__ */ h(ee, {}),
1505
+ children: /* @__PURE__ */ h("span", { children: /* @__PURE__ */ h(E, {
1506
+ icon: /* @__PURE__ */ h(X, {}),
1414
1507
  children: "Nearest"
1415
1508
  }) })
1416
1509
  }),
1417
- o && O > 0 && /* @__PURE__ */ h(j, {
1510
+ o && k > 0 && /* @__PURE__ */ h(N, {
1418
1511
  open: q,
1419
1512
  onOpenChange: te,
1420
1513
  align: "end",
1421
1514
  sideOffset: 6,
1422
- className: Ue.filtersPopover,
1515
+ className: Je.filtersPopover,
1423
1516
  "aria-label": "Active filters",
1424
- trigger: /* @__PURE__ */ h(S, {
1517
+ trigger: /* @__PURE__ */ h(C, {
1425
1518
  variant: "ghost",
1426
1519
  size: "micro",
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, {}),
1520
+ className: Je.filterChip,
1521
+ "aria-label": `${k} filter${k === 1 ? "" : "s"} active: show them`,
1522
+ title: `${k} filter${k === 1 ? "" : "s"} active`,
1523
+ children: /* @__PURE__ */ h(E, {
1524
+ icon: /* @__PURE__ */ h(Y, {}),
1432
1525
  color: "var(--CLightBlue)",
1433
1526
  textColor: "#080809",
1434
- children: O
1527
+ children: k
1435
1528
  })
1436
1529
  }),
1437
- children: /* @__PURE__ */ h(He, {})
1530
+ children: /* @__PURE__ */ h(qe, {})
1438
1531
  }),
1439
- i && (k || O > 0) && /* @__PURE__ */ h(S, {
1532
+ i && (A || k > 0) && /* @__PURE__ */ h(C, {
1440
1533
  variant: "ghost",
1441
1534
  size: "micro",
1442
- onClick: ne,
1443
- "aria-label": O > 0 ? "Clear search and filters" : "Clear search",
1535
+ onClick: J,
1536
+ "aria-label": k > 0 ? "Clear search and filters" : "Clear search",
1444
1537
  children: "Clear"
1445
1538
  })
1446
1539
  ]
1447
1540
  });
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
1541
+ return l !== "below" || !s || !R.available ? ne : /* @__PURE__ */ g("div", {
1542
+ className: Je.withOffer,
1543
+ children: [ne, /* @__PURE__ */ h("div", {
1544
+ className: Je.offerRow,
1545
+ children: !V && /* @__PURE__ */ h(Ve, {
1546
+ searchOrAsk: R,
1547
+ onAsk: Z,
1548
+ className: Je.offerQuick
1456
1549
  })
1457
1550
  })]
1458
1551
  });
1459
- }, Ge = {
1552
+ }, Xe = {
1460
1553
  message: "_message_1mgfk_1",
1461
1554
  icon: "_icon_1mgfk_10",
1462
1555
  title: "_title_1mgfk_15",
1463
1556
  detail: "_detail_1mgfk_20",
1464
1557
  technical: "_technical_1mgfk_25",
1465
1558
  button: "_button_1mgfk_33"
1466
- }, Ke = {
1559
+ }, Ze = {
1467
1560
  unreachable: {
1468
- icon: G,
1561
+ icon: te,
1469
1562
  title: "Search is unavailable",
1470
1563
  detail: "The search server can’t be reached right now."
1471
1564
  },
1472
1565
  unauthorized: {
1473
- icon: ne,
1566
+ icon: re,
1474
1567
  title: "Search is unavailable",
1475
1568
  detail: "The search key was not accepted."
1476
1569
  },
1477
1570
  forbidden: {
1478
- icon: J,
1571
+ icon: ie,
1479
1572
  title: "Search is unavailable",
1480
1573
  detail: "This search key doesn’t have access to these results."
1481
1574
  },
1482
1575
  notFound: {
1483
- icon: X,
1576
+ icon: ae,
1484
1577
  title: "Nothing to search here",
1485
1578
  detail: "The collection this page searches doesn’t exist."
1486
1579
  },
1487
1580
  notReady: {
1488
- icon: q,
1581
+ icon: Z,
1489
1582
  title: "Search is getting ready",
1490
1583
  detail: "Results will appear in a moment."
1491
1584
  },
1492
1585
  unavailable: {
1493
- icon: ie,
1586
+ icon: ce,
1494
1587
  title: "Search is unavailable",
1495
1588
  detail: "The collection can’t be searched right now."
1496
1589
  },
1497
1590
  rateLimited: {
1498
- icon: re,
1591
+ icon: se,
1499
1592
  title: "Too many searches",
1500
1593
  detail: "Wait a moment, then try again."
1501
1594
  },
1502
1595
  server: {
1503
- icon: ie,
1596
+ icon: ce,
1504
1597
  title: "Something went wrong",
1505
1598
  detail: "The search server ran into a problem."
1506
1599
  },
1507
1600
  setup: {
1508
- icon: ie,
1601
+ icon: ce,
1509
1602
  title: "Search isn’t set up",
1510
1603
  detail: "This page is missing part of its search setup."
1511
1604
  },
1512
1605
  unknown: {
1513
- icon: ie,
1606
+ icon: ce,
1514
1607
  title: "Something went wrong",
1515
1608
  detail: "The search couldn’t be completed."
1516
1609
  }
1517
- }, qe = ({ error: e, onRetry: t, hideTechnical: n = !1 }) => {
1518
- let { icon: r, title: i, detail: a } = Ke[e.kind];
1610
+ }, Qe = ({ error: e, onRetry: t, hideTechnical: n = !1 }) => {
1611
+ let { icon: r, title: i, detail: a } = Ze[e.kind];
1519
1612
  o(() => {
1520
1613
  if (e.kind !== "notReady" || !t) return;
1521
1614
  let n = setTimeout(t, (e.retryAfterSeconds ?? 2) * 1e3);
@@ -1523,38 +1616,38 @@ var Ue = {
1523
1616
  }, [e, t]);
1524
1617
  let s = e.retryable && e.kind !== "notReady" && t;
1525
1618
  return /* @__PURE__ */ g("div", {
1526
- className: Ge.message,
1619
+ className: Xe.message,
1527
1620
  role: "alert",
1528
1621
  children: [
1529
1622
  /* @__PURE__ */ h("span", {
1530
- className: Ge.icon,
1623
+ className: Xe.icon,
1531
1624
  children: /* @__PURE__ */ h(r, {
1532
1625
  size: 70,
1533
1626
  color: "var(--lv4)"
1534
1627
  })
1535
1628
  }),
1536
1629
  /* @__PURE__ */ h("div", {
1537
- className: Ge.title,
1630
+ className: Xe.title,
1538
1631
  children: i
1539
1632
  }),
1540
1633
  /* @__PURE__ */ h("div", {
1541
- className: Ge.detail,
1634
+ className: Xe.detail,
1542
1635
  children: a
1543
1636
  }),
1544
1637
  !n && /* @__PURE__ */ h("code", {
1545
- className: Ge.technical,
1638
+ className: Xe.technical,
1546
1639
  children: e.technical
1547
1640
  }),
1548
- s && /* @__PURE__ */ h(S, {
1641
+ s && /* @__PURE__ */ h(C, {
1549
1642
  variant: "secondary",
1550
1643
  size: "micro",
1551
- className: Ge.button,
1644
+ className: Xe.button,
1552
1645
  onClick: t,
1553
1646
  children: "Try again"
1554
1647
  })
1555
1648
  ]
1556
1649
  });
1557
- }, Je = {
1650
+ }, $e = {
1558
1651
  placeholder: "_placeholder_1m5kj_1",
1559
1652
  invalid: "_invalid_1m5kj_11",
1560
1653
  searchedFor: "_searchedFor_1m5kj_17",
@@ -1565,30 +1658,30 @@ var Ue = {
1565
1658
  picksCount: "_picksCount_1m5kj_27",
1566
1659
  picksSpacer: "_picksSpacer_1m5kj_28",
1567
1660
  why: "_why_1m5kj_29"
1568
- }, Ye = {
1661
+ }, et = {
1569
1662
  row: "_row_11svi_1",
1570
1663
  content: "_content_11svi_22",
1571
1664
  indexNumber: "_indexNumber_11svi_36",
1572
1665
  scoreNumber: "_scoreNumber_11svi_44",
1573
1666
  skeletonBars: "_skeletonBars_11svi_53"
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,
1667
+ }, tt = ({ skeleton: e = !1, index: t, score: n, showScore: r = !1, children: i, skeletonDelay: a = 0, skeletonWidths: o = [62, 38] }) => /* @__PURE__ */ g("div", {
1668
+ className: et.row,
1576
1669
  children: [
1577
1670
  t !== void 0 && /* @__PURE__ */ h("div", {
1578
- className: Ye.indexNumber,
1671
+ className: et.indexNumber,
1579
1672
  children: t
1580
1673
  }),
1581
1674
  /* @__PURE__ */ h("div", {
1582
- className: Ye.content,
1675
+ className: et.content,
1583
1676
  children: e ? /* @__PURE__ */ g("div", {
1584
- className: Ye.skeletonBars,
1585
- children: [/* @__PURE__ */ h(I, {
1677
+ className: et.skeletonBars,
1678
+ children: [/* @__PURE__ */ h(R, {
1586
1679
  level: 3,
1587
1680
  height: 12,
1588
1681
  width: `${o[0]}%`,
1589
1682
  delay: a,
1590
1683
  appear: !1
1591
- }), /* @__PURE__ */ h(I, {
1684
+ }), /* @__PURE__ */ h(R, {
1592
1685
  level: 3,
1593
1686
  height: 8,
1594
1687
  width: `${o[1]}%`,
@@ -1598,14 +1691,14 @@ var Ue = {
1598
1691
  }) : i
1599
1692
  }),
1600
1693
  r && n !== void 0 && /* @__PURE__ */ h("div", {
1601
- className: Ye.scoreNumber,
1694
+ className: et.scoreNumber,
1602
1695
  children: n
1603
1696
  })
1604
1697
  ]
1605
- }), Ze = {
1698
+ }), nt = {
1606
1699
  wrapper: "_wrapper_f970z_6",
1607
1700
  skeletonAppear: "_skeletonAppear_f970z_1"
1608
- }, Qe = [
1701
+ }, rt = [
1609
1702
  [62, 38],
1610
1703
  [75, 45],
1611
1704
  [58, 33],
@@ -1614,23 +1707,23 @@ var Ue = {
1614
1707
  [55, 35],
1615
1708
  [72, 40],
1616
1709
  [60, 30]
1617
- ], $e = ({ rows: e = 6 }) => /* @__PURE__ */ h("div", {
1618
- className: Ze.wrapper,
1619
- children: Array.from({ length: e }).map((e, t) => /* @__PURE__ */ h(Xe, {
1710
+ ], it = ({ rows: e = 6 }) => /* @__PURE__ */ h("div", {
1711
+ className: nt.wrapper,
1712
+ children: Array.from({ length: e }).map((e, t) => /* @__PURE__ */ h(tt, {
1620
1713
  skeleton: !0,
1621
1714
  skeletonDelay: t * .1,
1622
- skeletonWidths: Qe[t % Qe.length]
1715
+ skeletonWidths: rt[t % rt.length]
1623
1716
  }, t))
1624
1717
  });
1625
1718
  // src/hooks/useFilterSuggestion.ts
1626
- function et(e) {
1719
+ function at(e) {
1627
1720
  let t = e.trim().toLowerCase();
1628
1721
  return t === "true" || t === "false" || t !== "" && !Number.isNaN(Number(t));
1629
1722
  }
1630
- function tt(e, t) {
1723
+ function ot(e, t) {
1631
1724
  if (!t) return null;
1632
1725
  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({
1726
+ for (let [e, r] of Object.entries(t)) for (let t of r ?? []) t?.key && t.key.trim().length >= 2 && !at(t.key) && n.push({
1634
1727
  field: e,
1635
1728
  value: t.key
1636
1729
  });
@@ -1649,14 +1742,14 @@ function tt(e, t) {
1649
1742
  sort: null
1650
1743
  };
1651
1744
  }
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);
1745
+ function st(e = {}) {
1746
+ let t = Ce(), { url: n, team: r, dataset: a, authenticatedFetch: s, setQuery: u, toggleFilter: d, setRangeFilter: f, setSort: p } = t, { auto: m } = e, h = c(t);
1654
1747
  h.current = t;
1655
1748
  let [g, _] = l(null), [v, y] = l(""), [b, x] = l(!1), S = c(0), C = i(async (e) => {
1656
1749
  let t = ++S.current;
1657
1750
  x(!0);
1658
1751
  try {
1659
- let i = await s(`${n}/api/teams/${r}/datasets/${a}/search-or-ask/filters${Ae(h.current)}`, {
1752
+ let i = await s(`${n}/api/teams/${r}/datasets/${a}/search-or-ask/filters${Pe(h.current)}`, {
1660
1753
  method: "POST",
1661
1754
  headers: { "Content-Type": "application/json" },
1662
1755
  body: JSON.stringify({ text: e })
@@ -1695,7 +1788,7 @@ function nt(e = {}) {
1695
1788
  return o(() => {
1696
1789
  if (!A || !j || P || E.current.has(j)) return;
1697
1790
  E.current.add(j);
1698
- let e = tt(j, N);
1791
+ let e = ot(j, N);
1699
1792
  if (e && (E.current.add(e.text), w(e), O(j)), k !== "model") return;
1700
1793
  let t = e ? e.text : j;
1701
1794
  if (!t) return;
@@ -1704,7 +1797,7 @@ function nt(e = {}) {
1704
1797
  let o = ++S.current;
1705
1798
  x(!0);
1706
1799
  try {
1707
- let c = await s(`${n}/api/teams/${r}/datasets/${a}/search-or-ask/filters${Ae(h.current)}`, {
1800
+ let c = await s(`${n}/api/teams/${r}/datasets/${a}/search-or-ask/filters${Pe(h.current)}`, {
1708
1801
  method: "POST",
1709
1802
  headers: { "Content-Type": "application/json" },
1710
1803
  body: JSON.stringify({ text: t })
@@ -1742,20 +1835,20 @@ function nt(e = {}) {
1742
1835
  };
1743
1836
  }
1744
1837
  // src/components/SearchResults.tsx
1745
- var rt = /^\[\s*(?:'[^']*'(?:\s*,\s*'[^']*')*)?\s*\]$/;
1746
- function it(e) {
1838
+ var ct = /^\[\s*(?:'[^']*'(?:\s*,\s*'[^']*')*)?\s*\]$/;
1839
+ function lt(e) {
1747
1840
  let t = e.trim();
1748
1841
  if (!t.startsWith("[") || !t.endsWith("]")) return;
1749
1842
  try {
1750
1843
  let e = JSON.parse(t);
1751
1844
  if (Array.isArray(e)) return e.map((e) => String(e));
1752
1845
  } catch {}
1753
- if (!rt.test(t)) return;
1846
+ if (!ct.test(t)) return;
1754
1847
  let n = [], r = /'([^']*)'/g, i;
1755
1848
  for (; (i = r.exec(t)) !== null;) n.push(i[1]);
1756
1849
  return n;
1757
1850
  }
1758
- function at(e, t, n) {
1851
+ function ut(e, t, n) {
1759
1852
  let r;
1760
1853
  try {
1761
1854
  r = typeof e == "string" ? JSON.parse(e) : e;
@@ -1770,14 +1863,14 @@ function at(e, t, n) {
1770
1863
  if (n) for (let e in i) {
1771
1864
  let t = i[e];
1772
1865
  if (typeof t == "string") {
1773
- let n = it(t);
1866
+ let n = lt(t);
1774
1867
  n && (i[e] = n);
1775
1868
  }
1776
1869
  }
1777
1870
  return i;
1778
1871
  }
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);
1872
+ var dt = ({ picks: e, fields: t, parseArrayStrings: n, label: r, onShowSearch: i, children: a }) => {
1873
+ let { url: s, team: c, dataset: u, authenticatedFetch: d, count: f } = Ce(), [p, _] = l(null);
1781
1874
  o(() => {
1782
1875
  let t = !1;
1783
1876
  _(null);
@@ -1818,30 +1911,30 @@ var ot = ({ picks: e, fields: t, parseArrayStrings: n, label: r, onShowSearch: i
1818
1911
  } catch {}
1819
1912
  }, y = e.search;
1820
1913
  return /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ g("div", {
1821
- className: Je.picksHead,
1914
+ className: $e.picksHead,
1822
1915
  children: [
1823
1916
  /* @__PURE__ */ g("span", {
1824
- className: Je.picksTitle,
1825
- children: [/* @__PURE__ */ h(H, {
1917
+ className: $e.picksTitle,
1918
+ children: [/* @__PURE__ */ h(G, {
1826
1919
  size: 14,
1827
1920
  color: "currentColor"
1828
1921
  }), r]
1829
1922
  }),
1830
1923
  /* @__PURE__ */ h("span", {
1831
- className: Je.picksCount,
1924
+ className: $e.picksCount,
1832
1925
  children: e.picks.length
1833
1926
  }),
1834
- /* @__PURE__ */ h("span", { className: Je.picksSpacer }),
1835
- i && /* @__PURE__ */ h(S, {
1927
+ /* @__PURE__ */ h("span", { className: $e.picksSpacer }),
1928
+ i && /* @__PURE__ */ h(C, {
1836
1929
  variant: "ghost",
1837
1930
  size: "micro",
1838
1931
  onClick: i,
1839
1932
  children: y ? `Show all ${y.found}${y.more ? "+" : ""} found` : "Show the search instead"
1840
1933
  })
1841
1934
  ]
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, {
1935
+ }), p === null ? /* @__PURE__ */ h(it, { rows: Math.max(1, e.picks.length) }) : /* @__PURE__ */ h("div", { children: e.picks.map((e) => {
1936
+ let r = p.get(e.documentKey), i = r == null ? null : ut(r, t, n);
1937
+ return i ? /* @__PURE__ */ g(tt, {
1845
1938
  index: e.n,
1846
1939
  showScore: !1,
1847
1940
  children: [a(i, {
@@ -1853,16 +1946,16 @@ var ot = ({ picks: e, fields: t, parseArrayStrings: n, label: r, onShowSearch: i
1853
1946
  },
1854
1947
  select: v(e.documentKey, e.n)
1855
1948
  }), e.why && /* @__PURE__ */ g("div", {
1856
- className: Je.why,
1857
- children: [/* @__PURE__ */ h(H, {
1949
+ className: $e.why,
1950
+ children: [/* @__PURE__ */ h(G, {
1858
1951
  size: 12,
1859
1952
  color: "currentColor"
1860
1953
  }), /* @__PURE__ */ h("span", { children: e.why })]
1861
1954
  })]
1862
1955
  }, e.documentKey) : null;
1863
1956
  }) })] });
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 ?? (() => {
1957
+ }, ft = ({ 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 }) => {
1958
+ let { state: { results: p, resultsSuppressed: _, searchSettings: v, countedTotal: y, query: b, error: x, errorInfo: S }, isFetchingInitial: w, authError: T, authErrorInfo: E, retry: D, allowEmptySearch: O, fetchMoreResults: k, selectResult: A, searchText: j, searchAsTyped: M, picks: N, showPicks: P } = Ce(), { apply: F } = st(), I = a === void 0 ? N : a, L = s ?? (() => {
1866
1959
  I?.search && F(I.search), P?.(null);
1867
1960
  }), R = c(null);
1868
1961
  I && R.current?.picks !== I && (R.current = {
@@ -1878,11 +1971,11 @@ var ot = ({ picks: e, fields: t, parseArrayStrings: n, label: r, onShowSearch: i
1878
1971
  B,
1879
1972
  b
1880
1973
  ]);
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 = () => {
1974
+ 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), te = !!p && (G.length > V || q), J = () => {
1882
1975
  let e = V + B;
1883
1976
  H(e), p && e >= p.length && q && k(p.length + B);
1884
1977
  };
1885
- if (I && z && !w && !T) return /* @__PURE__ */ h(ot, {
1978
+ if (I && z && !w && !T) return /* @__PURE__ */ h(dt, {
1886
1979
  picks: I,
1887
1980
  fields: e,
1888
1981
  parseArrayStrings: n,
@@ -1890,16 +1983,16 @@ var ot = ({ picks: e, fields: t, parseArrayStrings: n, label: r, onShowSearch: i
1890
1983
  onShowSearch: L,
1891
1984
  children: f
1892
1985
  });
1893
- if (w) return O ? /* @__PURE__ */ h($e, { rows: B }) : /* @__PURE__ */ h("div", {
1894
- className: Je.placeholder,
1895
- children: /* @__PURE__ */ h(te, {
1986
+ if (w) return O ? /* @__PURE__ */ h(it, { rows: B }) : /* @__PURE__ */ h("div", {
1987
+ className: $e.placeholder,
1988
+ children: /* @__PURE__ */ h(ne, {
1896
1989
  size: 200,
1897
1990
  color: "var(--lv5)"
1898
1991
  })
1899
1992
  });
1900
1993
  let Y = T ?? x;
1901
- return Y ? /* @__PURE__ */ h(qe, {
1902
- error: (T ? E : C) ?? {
1994
+ return Y ? /* @__PURE__ */ h(Qe, {
1995
+ error: (T ? E : S) ?? {
1903
1996
  kind: "unknown",
1904
1997
  message: Y,
1905
1998
  technical: Y,
@@ -1907,16 +2000,16 @@ var ot = ({ picks: e, fields: t, parseArrayStrings: n, label: r, onShowSearch: i
1907
2000
  },
1908
2001
  onRetry: D
1909
2002
  }) : _ || p === null ? /* @__PURE__ */ h("div", {
1910
- className: Je.placeholder,
1911
- children: /* @__PURE__ */ h(te, {
2003
+ className: $e.placeholder,
2004
+ children: /* @__PURE__ */ h(ne, {
1912
2005
  size: 200,
1913
2006
  color: "var(--lv5)"
1914
2007
  })
1915
2008
  }) : G.length === 0 ? null : /* @__PURE__ */ g(m, { children: [
1916
2009
  ee && /* @__PURE__ */ g("div", {
1917
- className: Je.searchedFor,
2010
+ className: $e.searchedFor,
1918
2011
  "aria-live": "polite",
1919
- children: [/* @__PURE__ */ g("span", { children: ["Searching for ", /* @__PURE__ */ h("strong", { children: ee })] }), M && /* @__PURE__ */ h(S, {
2012
+ children: [/* @__PURE__ */ g("span", { children: ["Searching for ", /* @__PURE__ */ h("strong", { children: ee })] }), M && /* @__PURE__ */ h(C, {
1920
2013
  variant: "ghost",
1921
2014
  size: "micro",
1922
2015
  onClick: M,
@@ -1924,15 +2017,15 @@ var ot = ({ picks: e, fields: t, parseArrayStrings: n, label: r, onShowSearch: i
1924
2017
  })]
1925
2018
  }),
1926
2019
  K && /* @__PURE__ */ h("p", {
1927
- className: Je.notFound,
2020
+ className: $e.notFound,
1928
2021
  "aria-live": "polite",
1929
2022
  children: i
1930
2023
  }),
1931
2024
  /* @__PURE__ */ h("div", {
1932
- className: K ? Je.dimmed : void 0,
2025
+ className: K ? $e.dimmed : void 0,
1933
2026
  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, {
2027
+ let i = t.score, a = ut(t.document, e, n);
2028
+ return a ? /* @__PURE__ */ h(tt, {
1936
2029
  index: r,
1937
2030
  score: i,
1938
2031
  showScore: d ?? v.showScore,
@@ -1941,17 +2034,17 @@ var ot = ({ picks: e, fields: t, parseArrayStrings: n, label: r, onShowSearch: i
1941
2034
  select: () => A?.(t) ?? Promise.resolve()
1942
2035
  })
1943
2036
  }, r) : /* @__PURE__ */ h("div", {
1944
- className: Je.invalid,
2037
+ className: $e.invalid,
1945
2038
  children: /* @__PURE__ */ h("p", { children: "Invalid JSON" })
1946
2039
  }, r);
1947
2040
  })
1948
2041
  }),
1949
- ne && /* @__PURE__ */ h("div", {
2042
+ te && /* @__PURE__ */ h("div", {
1950
2043
  style: {
1951
2044
  textAlign: "center",
1952
2045
  marginTop: "20px"
1953
2046
  },
1954
- children: /* @__PURE__ */ h(S, {
2047
+ children: /* @__PURE__ */ h(C, {
1955
2048
  variant: "secondary",
1956
2049
  size: "micro",
1957
2050
  onClick: J,
@@ -1959,18 +2052,18 @@ var ot = ({ picks: e, fields: t, parseArrayStrings: n, label: r, onShowSearch: i
1959
2052
  })
1960
2053
  })
1961
2054
  ] });
1962
- }, ct = {
2055
+ }, pt = {
1963
2056
  row: "_row_ujwhc_1",
1964
2057
  title: "_title_ujwhc_8"
1965
- }, lt = ({ variant: e = "default", children: t }) => /* @__PURE__ */ h("div", {
1966
- className: [ct.row, e === "title" ? ct.title : ""].filter(Boolean).join(" "),
2058
+ }, mt = ({ variant: e = "default", children: t }) => /* @__PURE__ */ h("div", {
2059
+ className: [pt.row, e === "title" ? pt.title : ""].filter(Boolean).join(" "),
1967
2060
  children: t
1968
- }), ut = {
2061
+ }), ht = {
1969
2062
  listRows: "_listRows_13obt_2",
1970
2063
  sliderArea: "_sliderArea_13obt_8",
1971
2064
  inputRow: "_inputRow_13obt_15",
1972
2065
  histogramRow: "_histogramRow_13obt_22"
1973
- }, dt = [
2066
+ }, gt = [
1974
2067
  65,
1975
2068
  80,
1976
2069
  55,
@@ -1979,22 +2072,22 @@ var ot = ({ picks: e, fields: t, parseArrayStrings: n, label: r, onShowSearch: i
1979
2072
  75,
1980
2073
  50,
1981
2074
  68
1982
- ], ft = ({ title: e, rows: t = 5, variant: n = "list", withHistogram: r = !1, collapsible: i = !0, startCollapsed: a = !1 }) => /* @__PURE__ */ h(O, {
2075
+ ], _t = ({ title: e, rows: t = 5, variant: n = "list", withHistogram: r = !1, collapsible: i = !0, startCollapsed: a = !1 }) => /* @__PURE__ */ h(A, {
1983
2076
  title: e,
1984
2077
  collapsible: i,
1985
2078
  collapsed: a,
1986
2079
  children: n === "slider" ? /* @__PURE__ */ g("div", {
1987
- className: ut.sliderArea,
2080
+ className: ht.sliderArea,
1988
2081
  children: [
1989
- r && /* @__PURE__ */ h("div", { className: ut.histogramRow }),
1990
- /* @__PURE__ */ h(I, { height: 6 }),
2082
+ r && /* @__PURE__ */ h("div", { className: ht.histogramRow }),
2083
+ /* @__PURE__ */ h(R, { height: 6 }),
1991
2084
  /* @__PURE__ */ g("div", {
1992
- className: ut.inputRow,
1993
- children: [/* @__PURE__ */ h(I, {
2085
+ className: ht.inputRow,
2086
+ children: [/* @__PURE__ */ h(R, {
1994
2087
  width: 40,
1995
2088
  height: 20,
1996
2089
  delay: .1
1997
- }), /* @__PURE__ */ h(I, {
2090
+ }), /* @__PURE__ */ h(R, {
1998
2091
  width: 40,
1999
2092
  height: 20,
2000
2093
  delay: .15
@@ -2002,34 +2095,36 @@ var ot = ({ picks: e, fields: t, parseArrayStrings: n, label: r, onShowSearch: i
2002
2095
  })
2003
2096
  ]
2004
2097
  }) : /* @__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]}%`,
2098
+ className: ht.listRows,
2099
+ children: Array.from({ length: t }).map((e, t) => /* @__PURE__ */ h(R, {
2100
+ width: `${gt[t % gt.length]}%`,
2008
2101
  delay: t * .05
2009
2102
  }, t))
2010
2103
  })
2011
- }), pt = {
2012
- list: "_list_18vbb_2",
2013
- count: "_count_18vbb_7",
2014
- countValue: "_countValue_18vbb_17",
2015
- chip: "_chip_18vbb_22",
2016
- chipLabel: "_chipLabel_18vbb_32",
2017
- grid: "_grid_18vbb_40",
2018
- active: "_active_18vbb_54"
2019
- }, mt = {
2104
+ }), vt = {
2105
+ list: "_list_1352r_2",
2106
+ count: "_count_1352r_7",
2107
+ countValue: "_countValue_1352r_17",
2108
+ chip: "_chip_1352r_22",
2109
+ chipLabel: "_chipLabel_1352r_32",
2110
+ grid: "_grid_1352r_40",
2111
+ active: "_active_1352r_54",
2112
+ search: "_search_1352r_59",
2113
+ searchNote: "_searchNote_1352r_62"
2114
+ }, yt = {
2020
2115
  notice: "_notice_4sel0_1",
2021
2116
  technical: "_technical_4sel0_9"
2022
- }, ht = ({ label: e, field: t, missing: n }) => {
2117
+ }, bt = ({ label: e, field: t, missing: n }) => {
2023
2118
  let r = n.map((e) => e[0].toUpperCase() + e.slice(1)).join(" and ");
2024
2119
  return o(() => {
2025
2120
  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).`);
2026
- }, [t, r]), /* @__PURE__ */ h(O, {
2121
+ }, [t, r]), /* @__PURE__ */ h(A, {
2027
2122
  title: e ?? t,
2028
2123
  collapsible: !1,
2029
2124
  children: /* @__PURE__ */ g("div", {
2030
- className: mt.notice,
2125
+ className: yt.notice,
2031
2126
  children: [/* @__PURE__ */ h("span", { children: "Not available" }), /* @__PURE__ */ g("code", {
2032
- className: mt.technical,
2127
+ className: yt.technical,
2033
2128
  children: [
2034
2129
  t,
2035
2130
  ": not ",
@@ -2038,65 +2133,105 @@ var ot = ({ picks: e, fields: t, parseArrayStrings: n, label: r, onShowSearch: i
2038
2133
  })]
2039
2134
  })
2040
2135
  });
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;
2136
+ }, xt = 50, St = ({ 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, searchable: x = "auto", searchPlaceholder: S, displayCondition: w = (e) => !0 }) => {
2137
+ let { state: { facets: E, filterableFields: D, facetableFields: O, filters: k, query: j }, toggleFilter: M, setValueMatch: N, authError: I, isFetchingInitial: L, allowEmptySearch: R, searchFacetValues: z } = Ce(), B = d ?? f ?? "checkbox", V = B === "radio" ? "any" : y;
2043
2138
  o(() => {
2044
- j(e, L);
2139
+ N(e, V);
2045
2140
  }, [
2046
2141
  e,
2047
- L,
2048
- j
2142
+ V,
2143
+ N
2049
2144
  ]);
2050
- let R = c(null), [B, V] = l(a);
2145
+ let U = c(null), [W, G] = l(a);
2146
+ o(() => {
2147
+ G(a);
2148
+ }, [E?.[e], a]);
2149
+ let [K, ee] = l(""), [q, te] = l(null), J = c(0);
2051
2150
  if (o(() => {
2052
- V(a);
2053
- }, [w?.[e], a]), !F && !k || N) return null;
2054
- if (P || !w) return I === "toggle" ? /* @__PURE__ */ h(ft, {
2151
+ let t = K.trim();
2152
+ if (!t) {
2153
+ te(null);
2154
+ return;
2155
+ }
2156
+ let n = ++J.current, r = /* @__PURE__ */ new Map();
2157
+ for (let t of Array.isArray(E?.[e]) ? E[e] : []) typeof t.key == "string" && (t.value ?? 0) > 0 && r.set(t.key, t.value);
2158
+ let i = r.size > 0 && r.size <= 3e3 ? Array.from(r.keys()) : void 0;
2159
+ (async () => {
2160
+ let o = z ? await z(e, t, i ? Math.max(a, 10) : 100, i) : null;
2161
+ if (n !== J.current) return;
2162
+ let s, c = 0;
2163
+ if (o) {
2164
+ let a = o.values.filter((e) => r.has(e.value));
2165
+ if (s = a.map((e) => [e.value, r.get(e.value)]), o.fallback || s.sort((e, t) => t[1] - e[1]), c = o.values.length - a.length, s.length === 0 && i && (te({
2166
+ text: t,
2167
+ values: s,
2168
+ outside: 0,
2169
+ fallback: !1
2170
+ }), c = (await z(e, t, 10))?.values.length ?? 0, n !== J.current)) return;
2171
+ } else {
2172
+ let e = t.toLowerCase();
2173
+ s = Array.from(r.entries()).filter(([t]) => t.toLowerCase().includes(e));
2174
+ }
2175
+ te({
2176
+ text: t,
2177
+ values: s.slice(0, Math.max(a, 10)),
2178
+ outside: c,
2179
+ fallback: o?.fallback ?? !1
2180
+ });
2181
+ })();
2182
+ }, [
2183
+ K,
2184
+ e,
2185
+ a,
2186
+ z,
2187
+ E?.[e]
2188
+ ]), !R && !j || I) return null;
2189
+ if (L || !E) return B === "toggle" ? /* @__PURE__ */ h(_t, {
2055
2190
  rows: 1,
2056
2191
  collapsible: !1
2057
- }) : /* @__PURE__ */ h(ft, {
2192
+ }) : /* @__PURE__ */ h(_t, {
2058
2193
  title: t,
2059
2194
  rows: Math.min(a, 6),
2060
2195
  collapsible: s,
2061
2196
  startCollapsed: u
2062
2197
  });
2063
- if (!x({
2064
- query: k ?? "",
2065
- filters: D,
2066
- facets: w
2067
- }) || !b && !k && Object.keys(D).length < 1) return null;
2068
- if (!T?.includes(e) || !E?.includes(e)) {
2198
+ if (!w({
2199
+ query: j ?? "",
2200
+ filters: k,
2201
+ facets: E
2202
+ }) || !b && !j && Object.keys(k).length < 1) return null;
2203
+ if (!D?.includes(e) || !O?.includes(e)) {
2069
2204
  let n = [];
2070
- return T?.includes(e) || n.push("filterable"), E?.includes(e) || n.push("facetable"), /* @__PURE__ */ h(ht, {
2205
+ return D?.includes(e) || n.push("filterable"), O?.includes(e) || n.push("facetable"), /* @__PURE__ */ h(bt, {
2071
2206
  label: t,
2072
2207
  field: e,
2073
2208
  missing: n
2074
2209
  });
2075
2210
  }
2076
- let H = w?.[e] ?? (I === "toggle" ? [] : void 0);
2077
- if (!H || !Array.isArray(H)) return null;
2078
- let U = D?.[e] ?? [];
2079
- n && !R.current && H.length > 0 && (R.current = H.reduce((e, t) => (e[t.key] = t.value, e), {}));
2080
- let W = /* @__PURE__ */ new Map();
2081
- n && R.current && Object.keys(R.current).forEach((e) => {
2082
- W.set(e, 0);
2083
- }), H.forEach((e) => {
2084
- W.set(e.key, e.value);
2211
+ let Y = E?.[e] ?? (B === "toggle" ? [] : void 0);
2212
+ if (!Y || !Array.isArray(Y)) return null;
2213
+ let X = k?.[e] ?? [];
2214
+ n && !U.current && Y.length > 0 && (U.current = Y.reduce((e, t) => (e[t.key] = t.value, e), {}));
2215
+ let Z = /* @__PURE__ */ new Map();
2216
+ n && U.current && Object.keys(U.current).forEach((e) => {
2217
+ Z.set(e, 0);
2218
+ }), Y.forEach((e) => {
2219
+ Z.set(e.key, e.value);
2085
2220
  });
2086
- let G = /* @__PURE__ */ new Set([
2221
+ let ne = /* @__PURE__ */ new Set([
2087
2222
  "true",
2088
2223
  "false",
2089
2224
  "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")) {
2092
- let e = W.get("null") ?? 0, t = W.get("false") ?? 0;
2093
- W.set("false", t + e), W.delete("null");
2225
+ ]), re = Array.from(Z.keys()), ie = B === "toggle" && (re.length > 0 && re.every((e) => ne.has(e)) || re.length === 0 && X.length > 0);
2226
+ if (ie && Z.has("null")) {
2227
+ let e = Z.get("null") ?? 0, t = Z.get("false") ?? 0;
2228
+ Z.set("false", t + e), Z.delete("null");
2094
2229
  }
2095
- if (I === "toggle" && !ee) return /* @__PURE__ */ h(O, {
2230
+ if (B === "toggle" && !ie) return /* @__PURE__ */ h(A, {
2096
2231
  collapsible: !1,
2097
2232
  children: /* @__PURE__ */ h("div", {
2098
- className: pt.count,
2099
- children: /* @__PURE__ */ h(z, {
2233
+ className: vt.count,
2234
+ children: /* @__PURE__ */ h(H, {
2100
2235
  label: t,
2101
2236
  checked: !1,
2102
2237
  onChange: () => {},
@@ -2104,17 +2239,17 @@ var ot = ({ picks: e, fields: t, parseArrayStrings: n, label: r, onShowSearch: i
2104
2239
  })
2105
2240
  })
2106
2241
  });
2107
- if (ee) {
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}` : "";
2109
- return /* @__PURE__ */ h(O, {
2242
+ if (ie) {
2243
+ let n = Z.get("true"), r = typeof n == "number" ? n : null, i = X.includes("true"), a = r === 0 && !i, o = _ && (r ?? 0) > 0 ? `${r}` : "";
2244
+ return /* @__PURE__ */ h(A, {
2110
2245
  collapsible: !1,
2111
2246
  children: /* @__PURE__ */ g("div", {
2112
- className: pt.count,
2247
+ className: vt.count,
2113
2248
  children: [
2114
- /* @__PURE__ */ h(z, {
2249
+ /* @__PURE__ */ h(H, {
2115
2250
  label: t,
2116
2251
  checked: i,
2117
- onChange: () => A(e, "true"),
2252
+ onChange: () => M(e, "true"),
2118
2253
  disabled: a
2119
2254
  }),
2120
2255
  " ",
@@ -2123,127 +2258,159 @@ var ot = ({ picks: e, fields: t, parseArrayStrings: n, label: r, onShowSearch: i
2123
2258
  })
2124
2259
  });
2125
2260
  }
2126
- let q = Array.from(W.entries());
2127
- if (v || (q = q.filter(([e]) => e !== "null")), q.length === 0 && !n) return null;
2261
+ let Q = Array.from(Z.entries());
2262
+ if (v || (Q = Q.filter(([e]) => e !== "null")), Q.length === 0 && !n) return null;
2128
2263
  if (!r) {
2129
2264
  if (i === "alphabetical") {
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];
2265
+ 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));
2266
+ Q = [...e, ...t];
2132
2267
  } else if (i === "numeric") {
2133
2268
  let e = (e, t) => {
2134
2269
  let n = Number(e), r = Number(t);
2135
2270
  return !isNaN(n) && !isNaN(r) ? n - r : e.localeCompare(t);
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];
2271
+ }, 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));
2272
+ Q = [...t, ...n];
2138
2273
  } else {
2139
- let e = q.filter(([, e]) => typeof e == "number" && e > 0), t = q.filter(([, e]) => e === 0 || e === null);
2140
- q = [...e, ...t];
2274
+ let e = Q.filter(([, e]) => typeof e == "number" && e > 0), t = Q.filter(([, e]) => e === 0 || e === null);
2275
+ Q = [...e, ...t];
2141
2276
  }
2142
2277
  }
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) {
2278
+ let ae = typeof a == "number" && Q.length > a, oe = ae ? Q.slice(0, W) : Q, se = (t, n, r) => {
2279
+ let i = X.includes(t), a = n === 0, o = _ && (n ?? 0) > 0 ? ` (${n})` : "", s = _ && (n ?? 0) > 0 ? n : "", c = () => M(e, t, B === "radio", r);
2280
+ switch (B) {
2146
2281
  case "button": return p === "list" ? /* @__PURE__ */ g("div", {
2147
- className: pt.count,
2148
- children: [/* @__PURE__ */ h(S, {
2149
- variant: r ? "primary" : "secondary",
2150
- onClick: s,
2151
- disabled: i,
2282
+ className: vt.count,
2283
+ children: [/* @__PURE__ */ h(C, {
2284
+ variant: i ? "primary" : "secondary",
2285
+ onClick: c,
2286
+ disabled: a,
2152
2287
  size: "micro",
2153
- className: pt.chip,
2288
+ className: vt.chip,
2154
2289
  title: t,
2155
2290
  children: /* @__PURE__ */ h("span", {
2156
- className: pt.chipLabel,
2291
+ className: vt.chipLabel,
2157
2292
  children: t
2158
2293
  })
2159
2294
  }), /* @__PURE__ */ h("span", {
2160
- className: pt.countValue,
2161
- children: o
2295
+ className: vt.countValue,
2296
+ children: s
2162
2297
  })]
2163
- }) : /* @__PURE__ */ h(S, {
2164
- variant: r ? "primary" : "secondary",
2165
- onClick: s,
2166
- disabled: i,
2298
+ }) : /* @__PURE__ */ h(C, {
2299
+ variant: i ? "primary" : "secondary",
2300
+ onClick: c,
2301
+ disabled: a,
2167
2302
  size: "micro",
2168
- className: pt.chip,
2169
- title: `${t}${a}`,
2303
+ className: vt.chip,
2304
+ title: `${t}${o}`,
2170
2305
  children: /* @__PURE__ */ h("span", {
2171
- className: pt.chipLabel,
2172
- children: `${t}${a}`
2306
+ className: vt.chipLabel,
2307
+ children: `${t}${o}`
2173
2308
  })
2174
2309
  });
2175
- case "toggle": return /* @__PURE__ */ h(z, {
2310
+ case "toggle": return /* @__PURE__ */ h(H, {
2176
2311
  label: t,
2177
- checked: r,
2178
- onChange: s,
2179
- disabled: i
2312
+ checked: i,
2313
+ onChange: c,
2314
+ disabled: a
2180
2315
  });
2181
2316
  case "radio": {
2182
- let n = /* @__PURE__ */ h(M, {
2317
+ let n = /* @__PURE__ */ h(P, {
2183
2318
  id: `${e}-${t}`,
2184
2319
  name: e,
2185
2320
  value: t,
2186
- label: p === "grid" ? `${t}${a}` : t,
2187
- checked: r,
2188
- onChange: s,
2189
- disabled: i
2321
+ label: p === "grid" ? `${t}${o}` : t,
2322
+ checked: i,
2323
+ onChange: c,
2324
+ disabled: a
2190
2325
  });
2191
2326
  return p === "list" ? /* @__PURE__ */ g("div", {
2192
- className: pt.count,
2327
+ className: vt.count,
2193
2328
  children: [n, /* @__PURE__ */ h("span", {
2194
- className: pt.countValue,
2195
- children: o
2329
+ className: vt.countValue,
2330
+ children: s
2196
2331
  })]
2197
2332
  }) : n;
2198
2333
  }
2199
2334
  default: return p === "list" ? /* @__PURE__ */ g("div", {
2200
- className: pt.count,
2201
- children: [/* @__PURE__ */ h(C, {
2335
+ className: vt.count,
2336
+ children: [/* @__PURE__ */ h(T, {
2202
2337
  label: t,
2203
2338
  score: "",
2204
- checked: r,
2205
- onChange: s,
2206
- disabled: i
2339
+ checked: i,
2340
+ onChange: c,
2341
+ disabled: a
2207
2342
  }), /* @__PURE__ */ h("span", {
2208
- className: pt.countValue,
2209
- children: o
2343
+ className: vt.countValue,
2344
+ children: s
2210
2345
  })]
2211
- }) : /* @__PURE__ */ h(C, {
2346
+ }) : /* @__PURE__ */ h(T, {
2212
2347
  label: t,
2213
- score: a,
2214
- checked: r,
2215
- onChange: s,
2216
- disabled: i
2348
+ score: o,
2349
+ checked: i,
2350
+ onChange: c,
2351
+ disabled: a
2217
2352
  });
2218
2353
  }
2219
- };
2220
- return /* @__PURE__ */ h(O, {
2354
+ }, ce = s ? u : !1, le = B !== "toggle" && (x === !0 || x === "auto" && Q.length > a && Q.length >= xt), $ = le && K.trim() && q ? q : null, ue = $ ? [...X.map((e) => [e, Z.get(e) ?? null]), ...$.values.filter(([e]) => !X.includes(e))] : null, de = new Intl.NumberFormat("en"), fe = le && /* @__PURE__ */ h("div", {
2355
+ className: vt.search,
2356
+ children: /* @__PURE__ */ h(F, {
2357
+ inputSize: "micro",
2358
+ value: K,
2359
+ onChange: (e) => ee(e.target.value),
2360
+ onFocus: () => {
2361
+ z?.(e, "", 1);
2362
+ },
2363
+ placeholder: S ?? "Type to search",
2364
+ "aria-label": `Search ${t ?? e}`
2365
+ })
2366
+ });
2367
+ return ue ? /* @__PURE__ */ g(A, {
2221
2368
  title: t,
2222
2369
  collapsible: s,
2223
- collapsed: s ? u : !1,
2224
- className: m && U.length > 0 ? pt.active : void 0,
2225
- children: /* @__PURE__ */ g("ul", {
2226
- className: p === "grid" ? pt.grid : pt.list,
2370
+ collapsed: ce,
2371
+ className: m && X.length > 0 ? vt.active : void 0,
2372
+ children: [fe, ue.length === 0 ? /* @__PURE__ */ g("p", {
2373
+ className: vt.searchNote,
2374
+ children: [`Nothing in these results matches "${$.text}".`, $.outside > 0 && ` ${$.outside >= 10 ? "More" : de.format($.outside)} ${$.outside === 1 ? "matches" : "match"} outside them.`]
2375
+ }) : /* @__PURE__ */ h("ul", {
2376
+ className: p === "grid" ? vt.grid : vt.list,
2227
2377
  style: {
2228
2378
  listStyle: "none",
2229
2379
  padding: 0,
2230
2380
  margin: 0
2231
2381
  },
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);
2382
+ children: ue.map(([e, t]) => /* @__PURE__ */ h("li", { children: se(e, t, {
2383
+ text: $.text,
2384
+ fallback: $.fallback
2385
+ }) }, e))
2386
+ })]
2387
+ }) : /* @__PURE__ */ g(A, {
2388
+ title: t,
2389
+ collapsible: s,
2390
+ collapsed: ce,
2391
+ className: m && X.length > 0 ? vt.active : void 0,
2392
+ children: [fe, /* @__PURE__ */ g("ul", {
2393
+ className: p === "grid" ? vt.grid : vt.list,
2394
+ style: {
2395
+ listStyle: "none",
2396
+ padding: 0,
2397
+ margin: 0
2398
+ },
2399
+ children: [oe.map(([e, t]) => /* @__PURE__ */ h("li", { children: se(e, t) }, e)), ae && W < Q.length && (() => {
2400
+ let e = Q.length - W, t = Math.min(50, e);
2234
2401
  return /* @__PURE__ */ h("li", {
2235
- className: pt.toggleItem,
2236
- children: /* @__PURE__ */ h(S, {
2402
+ className: vt.toggleItem,
2403
+ children: /* @__PURE__ */ h(C, {
2237
2404
  variant: "ghost",
2238
2405
  size: "micro",
2239
- onClick: () => V((e) => e + 50),
2240
- children: `Show ${t} more of ${q.length} total`
2406
+ onClick: () => G((e) => e + 50),
2407
+ children: `Show ${t} more of ${Q.length} total`
2241
2408
  })
2242
2409
  });
2243
2410
  })()]
2244
- })
2411
+ })]
2245
2412
  });
2246
- }, Q = {
2413
+ }, Ct = {
2247
2414
  disabledMessage: "_disabledMessage_adany_1",
2248
2415
  histogram: "_histogram_adany_6",
2249
2416
  histogramLayer: "_histogramLayer_adany_14",
@@ -2256,36 +2423,36 @@ var ot = ({ picks: e, fields: t, parseArrayStrings: n, label: r, onShowSearch: i
2256
2423
  active: "_active_adany_76"
2257
2424
  };
2258
2425
  // src/utils/numeric.ts
2259
- function _t(e) {
2426
+ function wt(e) {
2260
2427
  if (!Number.isFinite(e)) return 0;
2261
2428
  let t = String(e), n = t.indexOf(".");
2262
2429
  return n === -1 ? 0 : Math.min(6, t.length - n - 1);
2263
2430
  }
2264
- function vt(e) {
2431
+ function Tt(e) {
2265
2432
  let t = 0;
2266
- for (let n of e) t = Math.max(t, _t(n));
2433
+ for (let n of e) t = Math.max(t, wt(n));
2267
2434
  return t === 0 ? 1 : Number((10 ** -t).toFixed(t));
2268
2435
  }
2269
- function yt(e, t) {
2270
- return Number(e.toFixed(_t(t)));
2436
+ function Et(e, t) {
2437
+ return Number(e.toFixed(wt(t)));
2271
2438
  }
2272
2439
  // src/components/RangeFilterPanel.tsx
2273
- function bt(e, t, n) {
2440
+ function Dt(e, t, n) {
2274
2441
  let r = t + Math.round((e - t) / n) * n;
2275
- return Number(r.toFixed(_t(n)));
2442
+ return Number(r.toFixed(wt(n)));
2276
2443
  }
2277
- function xt(e, t, n) {
2444
+ function Ot(e, t, n) {
2278
2445
  let r = Math.ceil(Number(((e - t) / n).toFixed(6)));
2279
- return Number((t + r * n).toFixed(_t(n)));
2446
+ return Number((t + r * n).toFixed(wt(n)));
2280
2447
  }
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] ?? {
2448
+ var kt = ({ 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 }) => {
2449
+ 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: O } = Ce(), k = a ?? o ?? "input", M = _?.[t] !== void 0, N = _?.[t] ?? {
2283
2450
  min: r,
2284
2451
  max: i
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(() => {
2452
+ }, P = N.min, F = N.max, I = v?.[t] ?? N, L = Math.max(P, Math.min(F, I.min)), R = Math.max(P, Math.min(F, I.max)), B = e.useMemo(() => {
2286
2453
  if (f) return f;
2287
- let e = Math.max(_t(P), _t(F)), n = y?.[t];
2288
- if (Array.isArray(n)) for (let t of n) e = Math.max(e, _t(Number(t.key)));
2454
+ let e = Math.max(wt(P), wt(F)), n = y?.[t];
2455
+ if (Array.isArray(n)) for (let t of n) e = Math.max(e, wt(Number(t.key)));
2289
2456
  return e === 0 ? 1 : Number((10 ** -e).toFixed(e));
2290
2457
  }, [
2291
2458
  f,
@@ -2293,21 +2460,21 @@ var St = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
2293
2460
  F,
2294
2461
  y,
2295
2462
  t
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(() => {
2297
- let e = _t(B);
2298
- return { width: `calc(${Math.max(3, P.toFixed(e).length, F.toFixed(e).length, oe.length, ce.length) + 1}ch + 20px)` };
2463
+ ]), V = M && P === F, H = V ? r : P, U = V ? i : F, W = Ot(U + B, H, B), G = (e) => Math.min(W, Math.max(H, e)), K = m?.[t], ee = s && K !== void 0 ? Ct.active : void 0, q = K ? K.min : P, te = K ? K.max : F, J = K !== void 0, Y = L !== P || R !== F, [X, Z] = e.useState([q, te]), [ne, re] = e.useState(!1), [ie, Q] = e.useState(!1), [ae, oe] = e.useState(String(q)), [se, ce] = e.useState(String(te)), le = e.useMemo(() => {
2464
+ let e = wt(B);
2465
+ return { width: `calc(${Math.max(3, P.toFixed(e).length, F.toFixed(e).length, ae.length, se.length) + 1}ch + 20px)` };
2299
2466
  }, [
2300
2467
  B,
2301
2468
  P,
2302
2469
  F,
2303
- oe,
2304
- ce
2470
+ ae,
2471
+ se
2305
2472
  ]);
2306
2473
  e.useEffect(() => {
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);
2474
+ oe(String(X[0])), ce(String(X[1]));
2475
+ }, [X]);
2476
+ let { finalMin: $, finalMax: ue, isValidMin: de, isValidMax: fe } = e.useMemo(() => {
2477
+ let [e, t] = X, 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);
2311
2478
  return {
2312
2479
  finalMin: i,
2313
2480
  finalMax: a,
@@ -2315,29 +2482,29 @@ var St = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
2315
2482
  isValidMax: a <= F && a >= i
2316
2483
  };
2317
2484
  }, [
2318
- Y,
2485
+ X,
2319
2486
  P,
2320
2487
  F
2321
2488
  ]);
2322
2489
  e.useEffect(() => {
2323
2490
  if (V) return;
2324
- if (Y[0] === P && Y[1] === F) {
2325
- ie(!1), Z(!1);
2491
+ if (X[0] === P && X[1] === F) {
2492
+ re(!1), Q(!1);
2326
2493
  return;
2327
2494
  }
2328
2495
  let e = C ?? 500, n = setTimeout(() => {
2329
- ie(!pe), Z(!me);
2496
+ re(!de), Q(!fe);
2330
2497
  }, 300), r = setTimeout(() => {
2331
- pe && me && (de === P && fe === F ? T(t, !1) : w(t, de, fe));
2498
+ de && fe && ($ === P && ue === F ? T(t, !1) : w(t, $, ue));
2332
2499
  }, e);
2333
2500
  return () => {
2334
2501
  clearTimeout(n), clearTimeout(r);
2335
2502
  };
2336
2503
  }, [
2504
+ $,
2505
+ ue,
2337
2506
  de,
2338
2507
  fe,
2339
- pe,
2340
- me,
2341
2508
  P,
2342
2509
  F,
2343
2510
  t,
@@ -2346,105 +2513,105 @@ var St = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
2346
2513
  C,
2347
2514
  V
2348
2515
  ]), e.useEffect(() => {
2349
- X([q, te]), ie(!1), Z(!1);
2516
+ Z([q, te]), re(!1), Q(!1);
2350
2517
  }, [
2351
2518
  q,
2352
2519
  te,
2353
2520
  t
2354
2521
  ]);
2355
- let he = e.useCallback((e) => {
2356
- let t = yt(Math.min(e[0], e[1] - B), B);
2357
- return [t, yt(Math.max(e[1] - B, t), B)];
2358
- }, [B]), ge = e.useCallback((e) => {
2522
+ let pe = e.useCallback((e) => {
2523
+ let t = Et(Math.min(e[0], e[1] - B), B);
2524
+ return [t, Et(Math.max(e[1] - B, t), B)];
2525
+ }, [B]), me = e.useCallback((e) => {
2359
2526
  if (V) return;
2360
- let [t, n] = he(e);
2361
- X([Math.max(P, Math.min(z, t)), Math.max(R, Math.min(F, n))]);
2527
+ let [t, n] = pe(e);
2528
+ Z([Math.max(P, Math.min(R, t)), Math.max(L, Math.min(F, n))]);
2362
2529
  }, [
2363
2530
  V,
2364
- he,
2531
+ pe,
2365
2532
  P,
2366
2533
  F,
2367
- R,
2368
- z
2369
- ]), _e = e.useCallback((e) => {
2534
+ L,
2535
+ R
2536
+ ]), he = e.useCallback((e) => {
2370
2537
  if (V) return;
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]);
2538
+ let [n, r] = pe(e), i = Math.max(P, Math.min(R, n)), a = Math.max(L, Math.min(F, r));
2539
+ i === P && a === F ? (Z([P, F]), T(t, !0)) : Z([i, a]);
2373
2540
  }, [
2374
2541
  V,
2375
- he,
2542
+ pe,
2376
2543
  P,
2377
2544
  F,
2545
+ L,
2378
2546
  R,
2379
- z,
2380
2547
  t,
2381
2548
  T
2382
- ]), ve = e.useRef(null), be = e.useCallback((e, n) => {
2549
+ ]), ge = e.useRef(null), _e = e.useCallback((e, n) => {
2383
2550
  if (V) return;
2384
- let r = ve.current;
2551
+ let r = ge.current;
2385
2552
  if (K && r && r.start === e && r.last === n) {
2386
- ve.current = null, X([P, F]), T(t, !0);
2553
+ ge.current = null, Z([P, F]), T(t, !0);
2387
2554
  return;
2388
2555
  }
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 = {
2556
+ let i = Dt(Math.max(P, L, e), P, B), a = Math.max(i, Dt(Math.min(F, R, n), P, B));
2557
+ ge.current = {
2391
2558
  start: e,
2392
2559
  last: n
2393
- }, X([i, a]);
2560
+ }, Z([i, a]);
2394
2561
  }, [
2395
2562
  V,
2396
2563
  K,
2397
2564
  P,
2398
2565
  F,
2566
+ L,
2399
2567
  R,
2400
- z,
2401
2568
  B,
2402
2569
  t,
2403
2570
  T
2404
- ]), xe = e.useCallback(() => {
2571
+ ]), ve = e.useCallback(() => {
2405
2572
  if (V) return;
2406
- let e = oe.trim(), t = e === "" ? NaN : Number(e);
2573
+ let e = ae.trim(), t = e === "" ? NaN : Number(e);
2407
2574
  if (isNaN(t)) {
2408
- se(String(Y[0]));
2575
+ oe(String(X[0]));
2409
2576
  return;
2410
2577
  }
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));
2578
+ let n = Math.max(P, Math.min(R, t));
2579
+ n < X[1] ? Z([n, X[1]]) : Z([P, X[1]]), oe(String(n < X[1] ? n : P));
2413
2580
  }, [
2414
2581
  V,
2415
- oe,
2416
- Y,
2582
+ ae,
2583
+ X,
2417
2584
  P,
2418
- z
2419
- ]), Se = e.useCallback(() => {
2585
+ R
2586
+ ]), ye = e.useCallback(() => {
2420
2587
  if (V) return;
2421
- let e = ce.trim(), t = e === "" ? NaN : Number(e);
2588
+ let e = se.trim(), t = e === "" ? NaN : Number(e);
2422
2589
  if (isNaN(t)) {
2423
- le(String(Y[1]));
2590
+ ce(String(X[1]));
2424
2591
  return;
2425
2592
  }
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));
2593
+ let n = Math.max(L, Math.min(F, t));
2594
+ n > X[0] ? Z([X[0], n]) : Z([X[0], F]), ce(String(n > X[0] ? n : F));
2428
2595
  }, [
2429
2596
  V,
2430
- ce,
2431
- Y,
2432
- R,
2597
+ se,
2598
+ X,
2599
+ L,
2433
2600
  F
2434
- ]), Ce = (e) => (t) => {
2601
+ ]), be = (e) => (t) => {
2435
2602
  t.key === "Enter" && e();
2436
- }, [we, Te] = e.useState(null), Ee = e.useRef(null);
2603
+ }, [xe, Se] = e.useState(null), we = e.useRef(null);
2437
2604
  e.useEffect(() => {
2438
2605
  if (!u) return;
2439
2606
  let e = `${P}:${F}`;
2440
- if (e === Ee.current && Ee.current !== null) return;
2607
+ if (e === we.current && we.current !== null) return;
2441
2608
  let n = y?.[t];
2442
2609
  if (!Array.isArray(n) || n.length === 0) return;
2443
2610
  let r = n.filter((e) => e.value != null && !isNaN(Number(e.key))).map((e) => ({
2444
2611
  key: e.key,
2445
2612
  value: e.value
2446
2613
  }));
2447
- r.length > 0 && (Ee.current = e, Te(r));
2614
+ r.length > 0 && (we.current = e, Se(r));
2448
2615
  }, [
2449
2616
  P,
2450
2617
  F,
@@ -2452,22 +2619,22 @@ var St = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
2452
2619
  t,
2453
2620
  u
2454
2621
  ]);
2455
- let De = e.useMemo(() => {
2456
- if (!u || !we || we.length === 0) return [];
2622
+ let Te = e.useMemo(() => {
2623
+ if (!u || !xe || xe.length === 0) return [];
2457
2624
  let e = F - P;
2458
2625
  if (e <= 0) return [];
2459
- let t = d ?? Math.max(B, yt(Math.ceil(e / 20 / B) * B, B)), n = Math.ceil(e / t);
2626
+ let t = d ?? Math.max(B, Et(Math.ceil(e / 20 / B) * B, B)), n = Math.ceil(e / t);
2460
2627
  return Array.from({ length: n }, (e, r) => {
2461
- let i = P + r * t, a = P + (r + 1) * t, o = r === n - 1, s = we.filter((e) => {
2628
+ let i = P + r * t, a = P + (r + 1) * t, o = r === n - 1, s = xe.filter((e) => {
2462
2629
  let t = Number(e.key);
2463
2630
  return t >= i && (t < a || o && t <= F);
2464
- }).reduce((e, t) => e + t.value, 0), c = o ? F : yt(a - B, B);
2631
+ }).reduce((e, t) => e + t.value, 0), c = o ? F : Et(a - B, B);
2465
2632
  return {
2466
2633
  bucketStart: i,
2467
2634
  bucketEnd: a,
2468
2635
  count: s,
2469
2636
  last: c,
2470
- barEnd: yt(c + B, B)
2637
+ barEnd: Et(c + B, B)
2471
2638
  };
2472
2639
  }).map((e, t, n) => ({
2473
2640
  ...e,
@@ -2475,92 +2642,92 @@ var St = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
2475
2642
  }));
2476
2643
  }, [
2477
2644
  u,
2478
- we,
2645
+ xe,
2479
2646
  P,
2480
2647
  F,
2481
2648
  d,
2482
2649
  B,
2483
2650
  W
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, {
2651
+ ]), Ee = e.useMemo(() => Math.max(...Te.map((e) => e.count), 1), [Te]);
2652
+ return u && !O && !x?.includes(t) && console.warn(`RangeFilterPanel: showHistogram=true but field "${t}" is not facetable. Add .Facetable = true to this field.`), D ? null : O ? /* @__PURE__ */ h(_t, {
2486
2653
  title: n,
2487
2654
  variant: "slider",
2488
2655
  withHistogram: u,
2489
2656
  collapsible: c,
2490
2657
  startCollapsed: l
2491
- }) : !E && !S ? null : b?.includes(t) ? j === "slider" ? /* @__PURE__ */ g(O, {
2658
+ }) : !E && !S ? null : b?.includes(t) ? k === "slider" ? /* @__PURE__ */ g(A, {
2492
2659
  title: n,
2493
2660
  collapsed: l,
2494
2661
  collapsible: c,
2495
2662
  className: ee,
2496
2663
  children: [
2497
2664
  V && /* @__PURE__ */ g("div", {
2498
- className: Q.disabledMessage,
2665
+ className: Ct.disabledMessage,
2499
2666
  children: [
2500
2667
  "No adjustable range (all results have the same value: ",
2501
2668
  P,
2502
2669
  ")."
2503
2670
  ]
2504
2671
  }),
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) => ({
2672
+ u && Te.length === 0 && /* @__PURE__ */ h("div", { className: Ct.histogram }),
2673
+ u && Te.length > 0 && (() => {
2674
+ let [e, t] = R > L && (L > P || R < F) ? [L, R] : [H, U], n = Math.max($, e), r = Math.min(ue, 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 = Te.slice(1).map((e) => u((e.bucketStart - H) / a)), _ = Te.map((e) => ({
2508
2675
  ...e,
2509
- height: Math.max(1, Math.ceil(e.count / Oe * 20))
2676
+ height: Math.max(1, Math.ceil(e.count / Ee * 20))
2510
2677
  }));
2511
2678
  return /* @__PURE__ */ g("div", {
2512
- className: Q.histogram,
2679
+ className: Ct.histogram,
2513
2680
  children: [
2514
2681
  /* @__PURE__ */ h("div", {
2515
- className: Q.histogramLayer,
2682
+ className: Ct.histogramLayer,
2516
2683
  children: _.map((e, t) => /* @__PURE__ */ h("button", {
2517
2684
  type: "button",
2518
- className: Q.histogramBar,
2685
+ className: Ct.histogramBar,
2519
2686
  style: { flexGrow: e.span },
2520
2687
  "data-testid": "histogram-bar",
2521
2688
  disabled: V || p(e),
2522
2689
  "aria-label": `${e.bucketStart} to ${e.last}: ${e.count}`,
2523
2690
  title: `${e.bucketStart} to ${e.last}: ${e.count}`,
2524
- onClick: () => be(e.bucketStart, e.last),
2691
+ onClick: () => _e(e.bucketStart, e.last),
2525
2692
  children: /* @__PURE__ */ h("span", {
2526
- className: Q.histogramFill,
2693
+ className: Ct.histogramFill,
2527
2694
  style: { height: `${e.height}px` }
2528
2695
  })
2529
2696
  }, t))
2530
2697
  }),
2531
2698
  /* @__PURE__ */ h("div", {
2532
- className: `${Q.histogramLayer} ${Q.histogramLive}`,
2699
+ className: `${Ct.histogramLayer} ${Ct.histogramLive}`,
2533
2700
  "aria-hidden": "true",
2534
2701
  "data-testid": "histogram-live",
2535
2702
  style: { clipPath: f },
2536
2703
  children: _.map((e, t) => /* @__PURE__ */ h("span", {
2537
- className: Q.histogramBar,
2704
+ className: Ct.histogramBar,
2538
2705
  style: { flexGrow: e.span },
2539
2706
  children: /* @__PURE__ */ h("span", {
2540
- className: Q.histogramFill,
2707
+ className: Ct.histogramFill,
2541
2708
  style: { height: `${e.height}px` }
2542
2709
  })
2543
2710
  }, t))
2544
2711
  }),
2545
2712
  /* @__PURE__ */ h("div", {
2546
- className: `${Q.histogramLayer} ${Q.histogramLit}`,
2713
+ className: `${Ct.histogramLayer} ${Ct.histogramLit}`,
2547
2714
  "aria-hidden": "true",
2548
2715
  "data-testid": "histogram-lit",
2549
2716
  style: { clipPath: d },
2550
2717
  children: _.map((e, t) => /* @__PURE__ */ h("span", {
2551
- className: Q.histogramBar,
2718
+ className: Ct.histogramBar,
2552
2719
  style: { flexGrow: e.span },
2553
2720
  children: /* @__PURE__ */ h("span", {
2554
- className: Q.histogramFill,
2721
+ className: Ct.histogramFill,
2555
2722
  style: { height: `${e.height}px` }
2556
2723
  })
2557
2724
  }, t))
2558
2725
  }),
2559
2726
  /* @__PURE__ */ h("div", {
2560
- className: Q.histogramSeparators,
2727
+ className: Ct.histogramSeparators,
2561
2728
  "aria-hidden": "true",
2562
2729
  children: m.map((e, t) => /* @__PURE__ */ h("span", {
2563
- className: Q.histogramSeparator,
2730
+ className: Ct.histogramSeparator,
2564
2731
  style: { left: e }
2565
2732
  }, t))
2566
2733
  })
@@ -2569,20 +2736,20 @@ var St = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
2569
2736
  })(),
2570
2737
  /* @__PURE__ */ h("div", {
2571
2738
  style: { padding: "10px 10px 20px 10px" },
2572
- children: /* @__PURE__ */ h(L, {
2739
+ children: /* @__PURE__ */ h(z, {
2573
2740
  min: H,
2574
2741
  max: W,
2575
2742
  step: B,
2576
2743
  stepMarks: p,
2577
- value: V ? [H, W] : [G(bt(de, H, B)), G(bt(fe + B, H, B))],
2744
+ value: V ? [H, W] : [G(Dt($, H, B)), G(Dt(ue + B, H, B))],
2578
2745
  isRange: !0,
2579
- onChange: (e) => ge(e),
2580
- onFinalChange: (e) => _e(e),
2746
+ onChange: (e) => me(e),
2747
+ onFinalChange: (e) => he(e),
2581
2748
  disabled: V,
2582
- activeMin: R,
2583
- activeMax: G(yt(z + B, B)),
2584
- isFaceted: J,
2585
- highlightFaceted: ne,
2749
+ activeMin: L,
2750
+ activeMax: G(Et(R + B, B)),
2751
+ isFaceted: Y,
2752
+ highlightFaceted: J,
2586
2753
  "aria-label": n || `Filter by ${t}`
2587
2754
  })
2588
2755
  }),
@@ -2593,38 +2760,38 @@ var St = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
2593
2760
  alignItems: "flex-start",
2594
2761
  justifyContent: "space-between"
2595
2762
  },
2596
- children: [/* @__PURE__ */ h(k, {
2763
+ children: [/* @__PURE__ */ h(j, {
2597
2764
  label: "Min:",
2598
2765
  type: "number",
2599
- style: ue,
2600
- value: V ? String(P) : oe,
2766
+ style: le,
2767
+ value: V ? String(P) : ae,
2601
2768
  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),
2769
+ max: Et(Math.min(R, X[1] - B), B),
2770
+ onChange: (e) => oe(e.target.value),
2771
+ onBlur: ve,
2772
+ onKeyDown: be(ve),
2606
2773
  disabled: V,
2607
- isValid: V || !re
2608
- }), /* @__PURE__ */ h(k, {
2774
+ isValid: V || !ne
2775
+ }), /* @__PURE__ */ h(j, {
2609
2776
  label: "Max:",
2610
2777
  type: "number",
2611
- style: ue,
2612
- value: V ? String(F) : ce,
2613
- min: yt(Math.max(R, Y[0] + B), B),
2778
+ style: le,
2779
+ value: V ? String(F) : se,
2780
+ min: Et(Math.max(L, X[0] + B), B),
2614
2781
  max: F,
2615
- onChange: (e) => le(e.target.value),
2616
- onBlur: Se,
2617
- onKeyDown: Ce(Se),
2782
+ onChange: (e) => ce(e.target.value),
2783
+ onBlur: ye,
2784
+ onKeyDown: be(ye),
2618
2785
  disabled: V,
2619
- isValid: V || !ae
2786
+ isValid: V || !ie
2620
2787
  })]
2621
2788
  })
2622
2789
  ]
2623
- }) : /* @__PURE__ */ g(O, {
2790
+ }) : /* @__PURE__ */ g(A, {
2624
2791
  title: n,
2625
2792
  className: ee,
2626
2793
  children: [V && /* @__PURE__ */ g("div", {
2627
- className: Q.disabledMessage,
2794
+ className: Ct.disabledMessage,
2628
2795
  children: [
2629
2796
  "No adjustable range (all results have the same value: ",
2630
2797
  P,
@@ -2636,38 +2803,38 @@ var St = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
2636
2803
  gap: "10px",
2637
2804
  alignItems: "flex-start"
2638
2805
  },
2639
- children: [/* @__PURE__ */ h(k, {
2806
+ children: [/* @__PURE__ */ h(j, {
2640
2807
  label: "Min:",
2641
2808
  type: "number",
2642
- style: ue,
2643
- value: V ? String(P) : oe,
2809
+ style: le,
2810
+ value: V ? String(P) : ae,
2644
2811
  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),
2812
+ max: Et(Math.min(R, X[1] - B), B),
2813
+ onChange: (e) => oe(e.target.value),
2814
+ onBlur: ve,
2815
+ onKeyDown: be(ve),
2649
2816
  disabled: V,
2650
- isValid: V || !re
2651
- }), /* @__PURE__ */ h(k, {
2817
+ isValid: V || !ne
2818
+ }), /* @__PURE__ */ h(j, {
2652
2819
  label: "Max:",
2653
2820
  type: "number",
2654
- style: ue,
2655
- value: V ? String(F) : ce,
2656
- min: yt(Math.max(R, Y[0] + B), B),
2821
+ style: le,
2822
+ value: V ? String(F) : se,
2823
+ min: Et(Math.max(L, X[0] + B), B),
2657
2824
  max: F,
2658
- onChange: (e) => le(e.target.value),
2659
- onBlur: Se,
2660
- onKeyDown: Ce(Se),
2825
+ onChange: (e) => ce(e.target.value),
2826
+ onBlur: ye,
2827
+ onKeyDown: be(ye),
2661
2828
  disabled: V,
2662
- isValid: V || !ae
2829
+ isValid: V || !ie
2663
2830
  })]
2664
2831
  })]
2665
- }) : /* @__PURE__ */ h(ht, {
2832
+ }) : /* @__PURE__ */ h(bt, {
2666
2833
  label: n,
2667
2834
  field: t,
2668
2835
  missing: ["filterable"]
2669
2836
  });
2670
- }, Ct = {
2837
+ }, At = {
2671
2838
  list: "_list_9je85_2",
2672
2839
  grid: "_grid_9je85_9",
2673
2840
  count: "_count_9je85_22",
@@ -2676,7 +2843,7 @@ var St = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
2676
2843
  active: "_active_9je85_41"
2677
2844
  };
2678
2845
  // src/components/BucketFilterPanel.tsx
2679
- function wt(e, t) {
2846
+ function jt(e, t) {
2680
2847
  if (!t) return null;
2681
2848
  let n = 0, r = !1;
2682
2849
  for (let i of t) {
@@ -2688,16 +2855,16 @@ function wt(e, t) {
2688
2855
  }
2689
2856
  return r ? n : 0;
2690
2857
  }
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);
2858
+ var Mt = ({ 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 }) => {
2859
+ let { state: { facets: v, filterableFields: y, facetableFields: b, bucketFilters: x, rangeBounds: S, facetStats: w, query: E }, toggleBucketFilter: D, authError: O, isFetchingInitial: k, allowEmptySearch: j } = Ce(), M = i ?? a ?? "checkbox", N = v?.[e], F = x[e] ?? [], [I, L] = l(f ?? Infinity);
2693
2860
  o(() => {
2694
2861
  L(f ?? Infinity);
2695
- }, [f, P]);
2696
- let R = w?.[e] ?? T?.[e], z = s(() => {
2862
+ }, [f, N]);
2863
+ let R = S?.[e] ?? w?.[e], z = s(() => {
2697
2864
  let e = [];
2698
- if (R && e.push(R.min, R.max), Array.isArray(P)) for (let t of P) e.push(Number(t.key));
2699
- return vt(e.filter(Number.isFinite));
2700
- }, [R, P]), B = s(() => {
2865
+ if (R && e.push(R.min, R.max), Array.isArray(N)) for (let t of N) e.push(Number(t.key));
2866
+ return Tt(e.filter(Number.isFinite));
2867
+ }, [R, N]), B = s(() => {
2701
2868
  let e = R?.min ?? -Number.MAX_VALUE, t = R?.max ?? Number.MAX_VALUE, i = (n, r, i) => ({
2702
2869
  label: i ?? (n === void 0 ? `up to ${r}` : r === void 0 ? `${n} and up` : `${n}-${r}`),
2703
2870
  range: {
@@ -2709,12 +2876,12 @@ var Tt = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
2709
2876
  if (r && r.length > 0) return r.map((e) => i(e.min, e.max, e.label));
2710
2877
  if (Array.isArray(n)) {
2711
2878
  let e = [...n].sort((e, t) => e - t), t = [];
2712
- for (let n = 0; n < e.length - 1; n++) t.push(i(e[n], yt(e[n + 1] - z, z)));
2879
+ for (let n = 0; n < e.length - 1; n++) t.push(i(e[n], Et(e[n + 1] - z, z)));
2713
2880
  return t;
2714
2881
  }
2715
2882
  if (typeof n == "number" && n > 0 && R) {
2716
2883
  let e = [], t = Math.floor(R.min / n) * n;
2717
- for (let r = t; r <= R.max; r = yt(r + n, z)) e.push(i(yt(r, z), yt(r + n - z, z)));
2884
+ for (let r = t; r <= R.max; r = Et(r + n, z)) e.push(i(Et(r, z), Et(r + n - z, z)));
2718
2885
  return e;
2719
2886
  }
2720
2887
  return [];
@@ -2724,28 +2891,28 @@ var Tt = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
2724
2891
  R,
2725
2892
  z
2726
2893
  ]);
2727
- if (k) return null;
2728
- if (A || !v) return /* @__PURE__ */ h(ft, {
2894
+ if (O) return null;
2895
+ if (k || !v) return /* @__PURE__ */ h(_t, {
2729
2896
  title: t,
2730
2897
  rows: Math.max(1, Math.min(B.length || 5, 8)),
2731
2898
  collapsible: m,
2732
2899
  startCollapsed: _
2733
2900
  });
2734
2901
  if (!j && !E) return null;
2735
- if (!y?.includes(e)) return /* @__PURE__ */ h(ht, {
2902
+ if (!y?.includes(e)) return /* @__PURE__ */ h(bt, {
2736
2903
  label: t,
2737
2904
  field: e,
2738
2905
  missing: ["filterable"]
2739
2906
  });
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) => ({
2907
+ let V = b?.includes(e) && Array.isArray(N), H = (e) => F.some((t) => t.min === e.range.min && t.max === e.range.max), U = B.map((e) => ({
2741
2908
  bucket: e,
2742
- count: V ? wt(e, P) : null
2909
+ count: V ? jt(e, N) : null
2743
2910
  }));
2744
2911
  if (d || (U = U.filter((e) => e.count !== 0 || H(e.bucket))), U.length === 0) return null;
2745
2912
  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");
2747
- if (N === "radio") {
2748
- let n = /* @__PURE__ */ h(M, {
2913
+ let r = H(t), i = n === 0 && !r, a = u && (n ?? 0) > 0 ? `${n}` : "", o = () => D(e, t.range, M === "radio");
2914
+ if (M === "radio") {
2915
+ let n = /* @__PURE__ */ h(P, {
2749
2916
  id: `${e}-${t.range.min}-${t.range.max}`,
2750
2917
  name: e,
2751
2918
  value: t.label,
@@ -2755,43 +2922,43 @@ var Tt = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
2755
2922
  disabled: i
2756
2923
  });
2757
2924
  return c === "list" ? /* @__PURE__ */ g("div", {
2758
- className: Ct.count,
2925
+ className: At.count,
2759
2926
  children: [n, /* @__PURE__ */ h("span", {
2760
- className: Ct.countValue,
2927
+ className: At.countValue,
2761
2928
  children: a
2762
2929
  })]
2763
2930
  }) : n;
2764
2931
  }
2765
- if (N === "button") {
2766
- let e = /* @__PURE__ */ h(S, {
2932
+ if (M === "button") {
2933
+ let e = /* @__PURE__ */ h(C, {
2767
2934
  variant: r ? "primary" : "secondary",
2768
2935
  onClick: o,
2769
2936
  disabled: i,
2770
2937
  size: "micro",
2771
- className: Ct.chip,
2938
+ className: At.chip,
2772
2939
  children: c === "grid" && a ? `${t.label} (${a})` : t.label
2773
2940
  });
2774
2941
  return c === "list" ? /* @__PURE__ */ g("div", {
2775
- className: Ct.count,
2942
+ className: At.count,
2776
2943
  children: [e, /* @__PURE__ */ h("span", {
2777
- className: Ct.countValue,
2944
+ className: At.countValue,
2778
2945
  children: a
2779
2946
  })]
2780
2947
  }) : e;
2781
2948
  }
2782
2949
  return c === "list" ? /* @__PURE__ */ g("div", {
2783
- className: Ct.count,
2784
- children: [/* @__PURE__ */ h(C, {
2950
+ className: At.count,
2951
+ children: [/* @__PURE__ */ h(T, {
2785
2952
  label: t.label,
2786
2953
  score: "",
2787
2954
  checked: r,
2788
2955
  onChange: o,
2789
2956
  disabled: i
2790
2957
  }), /* @__PURE__ */ h("span", {
2791
- className: Ct.countValue,
2958
+ className: At.countValue,
2792
2959
  children: a
2793
2960
  })]
2794
- }) : /* @__PURE__ */ h(C, {
2961
+ }) : /* @__PURE__ */ h(T, {
2795
2962
  label: t.label,
2796
2963
  score: a ? ` (${a})` : "",
2797
2964
  checked: r,
@@ -2799,19 +2966,19 @@ var Tt = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
2799
2966
  disabled: i
2800
2967
  });
2801
2968
  };
2802
- return /* @__PURE__ */ h(O, {
2969
+ return /* @__PURE__ */ h(A, {
2803
2970
  title: t,
2804
2971
  collapsible: m,
2805
2972
  collapsed: m ? _ : !1,
2806
- className: p && F.length > 0 ? Ct.active : void 0,
2973
+ className: p && F.length > 0 ? At.active : void 0,
2807
2974
  children: /* @__PURE__ */ g("ul", {
2808
- className: c === "grid" ? Ct.grid : Ct.list,
2975
+ className: c === "grid" ? At.grid : At.list,
2809
2976
  style: {
2810
2977
  listStyle: "none",
2811
2978
  padding: 0,
2812
2979
  margin: 0
2813
2980
  },
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, {
2981
+ 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(C, {
2815
2982
  variant: "ghost",
2816
2983
  size: "micro",
2817
2984
  onClick: () => L(U.length),
@@ -2819,12 +2986,12 @@ var Tt = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
2819
2986
  }) })]
2820
2987
  })
2821
2988
  });
2822
- }, Et = {
2989
+ }, Nt = {
2823
2990
  select: "_select_nwf7i_1",
2824
2991
  radioGroup: "_radioGroup_nwf7i_6"
2825
- }, Dt = ({ options: e, noneLabel: t = "None", control: n, displayType: r, collapsible: i = !0, startCollapsed: a = !1 }) => {
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, {
2992
+ }, Pt = ({ options: e, noneLabel: t = "None", control: n, displayType: r, collapsible: i = !0, startCollapsed: a = !1 }) => {
2993
+ let o = n ?? (r === "radio" ? "radio" : "select"), { state: { sortableFields: s, sortBy: c, sortAscending: l }, setSort: u, isFetchingInitial: d } = Ce();
2994
+ if (d) return /* @__PURE__ */ h(_t, {
2828
2995
  title: "Sort by",
2829
2996
  rows: o === "radio" ? 3 : 1,
2830
2997
  collapsible: i,
@@ -2850,19 +3017,19 @@ var Tt = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
2850
3017
  u(t, n === "asc");
2851
3018
  }
2852
3019
  };
2853
- return /* @__PURE__ */ h(O, {
3020
+ return /* @__PURE__ */ h(A, {
2854
3021
  title: "Sort by",
2855
3022
  collapsible: i,
2856
3023
  collapsed: i ? a : !1,
2857
- children: o === "select" ? /* @__PURE__ */ h(P, {
3024
+ children: o === "select" ? /* @__PURE__ */ h(I, {
2858
3025
  value: f,
2859
3026
  onValueChange: g,
2860
3027
  options: m,
2861
3028
  placeholder: "Select sort...",
2862
3029
  "aria-label": "Sort by"
2863
3030
  }) : /* @__PURE__ */ h("div", {
2864
- className: Et.radioGroup,
2865
- children: m.map((e) => /* @__PURE__ */ h(M, {
3031
+ className: Nt.radioGroup,
3032
+ children: m.map((e) => /* @__PURE__ */ h(P, {
2866
3033
  id: `sort-${e.value}`,
2867
3034
  name: "sort-by",
2868
3035
  value: e.value,
@@ -2872,27 +3039,27 @@ var Tt = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
2872
3039
  }, e.value))
2873
3040
  })
2874
3041
  });
2875
- }, Ot = { list: "_list_1y4fk_1" }, kt = {
3042
+ }, Ft = { list: "_list_1y4fk_1" }, It = {
2876
3043
  tolerance: p.TwoEdits,
2877
3044
  rungs: u.Fewest,
2878
3045
  oneEditFrom: 3,
2879
3046
  twoEditsFrom: 6,
2880
3047
  threeEditsFrom: 9,
2881
- typingPrefixFrom: 3,
3048
+ typingPrefixFrom: 2,
2882
3049
  typingPrefixOneEditFrom: 6,
2883
3050
  joinedWords: !0
2884
- }, At = {
3051
+ }, Lt = {
2885
3052
  candidatesPerRow: 4,
2886
3053
  fallback: !0,
2887
3054
  rest: !1
2888
- }, jt = {
3055
+ }, Rt = {
2889
3056
  rerank: !0,
2890
3057
  share: .2,
2891
3058
  typingShift: .5,
2892
3059
  wholeQueryFloor: !0
2893
3060
  };
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);
3061
+ function zt() {
3062
+ let { state: { searchSettings: e }, setSearchSettings: t, url: n, team: r, dataset: i, authenticatedFetch: a } = Ce(), [s, c] = l(!1), { match: f, candidates: _, ranking: v } = e, [y, b] = l(null);
2896
3063
  o(() => {
2897
3064
  let e = !0;
2898
3065
  try {
@@ -2909,38 +3076,38 @@ function Mt() {
2909
3076
  i,
2910
3077
  a
2911
3078
  ]);
2912
- let x = (e) => Object.fromEntries(Object.entries(e ?? {}).filter(([, e]) => e != null)), C = {
2913
- ...kt,
3079
+ let x = (e) => Object.fromEntries(Object.entries(e ?? {}).filter(([, e]) => e != null)), S = {
3080
+ ...It,
2914
3081
  ...x(y?.match)
2915
3082
  }, w = {
2916
- ...At,
3083
+ ...Lt,
2917
3084
  ...x(y?.candidates)
2918
3085
  }, T = {
2919
- ...jt,
3086
+ ...Rt,
2920
3087
  ...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 || [
3088
+ }, E = e.mode ?? y?.mode ?? d.EditDistance, D = E === d.Bm25f, O = v.rerank ?? T.rerank, k = D && !O, M = e.mode !== void 0 || [
2922
3089
  f,
2923
3090
  _,
2924
3091
  v
2925
3092
  ].some((e) => Object.values(e ?? {}).some((e) => e != null)), N = (e, n) => {
2926
3093
  let r = parseInt(n, 10);
2927
3094
  isNaN(r) || t({ [e]: r });
2928
- }, F = (e, n) => {
3095
+ }, P = (e, n) => {
2929
3096
  t({ [e]: n });
2930
- }, I = (e) => t({ match: e }), R = (e) => t({ candidates: e }), B = (e) => t({ ranking: e }), V = (e, t) => {
3097
+ }, F = (e) => t({ match: e }), L = (e) => t({ candidates: e }), R = (e) => t({ ranking: e }), B = (e, t) => {
2931
3098
  let n = parseInt(e, 10);
2932
3099
  isNaN(n) || t(n);
2933
- }, H = (e, t) => {
3100
+ }, V = (e, t) => {
2934
3101
  let n = parseFloat(e);
2935
3102
  isNaN(n) || t(Math.max(0, Math.min(100, n)) / 100);
2936
3103
  };
2937
- return /* @__PURE__ */ h(O, {
3104
+ return /* @__PURE__ */ h(A, {
2938
3105
  collapsed: !0,
2939
3106
  title: "Settings",
2940
3107
  children: /* @__PURE__ */ g("ul", {
2941
- className: Ot.list,
3108
+ className: Ft.list,
2942
3109
  children: [
2943
- /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(P, {
3110
+ /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(I, {
2944
3111
  label: "Mode",
2945
3112
  size: "micro",
2946
3113
  value: E,
@@ -2953,18 +3120,18 @@ function Mt() {
2953
3120
  value: d.Bm25f
2954
3121
  }]
2955
3122
  }) }),
2956
- /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(z, {
3123
+ /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(H, {
2957
3124
  label: "Rerank (Coverage)",
2958
- checked: A,
2959
- onChange: (e) => B({ rerank: e })
3125
+ checked: O,
3126
+ onChange: (e) => R({ rerank: e })
2960
3127
  }) }),
2961
- /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(k, {
3128
+ /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(j, {
2962
3129
  label: "Max Results",
2963
3130
  type: "number",
2964
3131
  value: e.maxNumberOfRecordsToReturn.toString(),
2965
3132
  onChange: (e) => N("maxNumberOfRecordsToReturn", e.target.value)
2966
3133
  }) }),
2967
- /* @__PURE__ */ g("li", { children: [/* @__PURE__ */ h(k, {
3134
+ /* @__PURE__ */ g("li", { children: [/* @__PURE__ */ h(j, {
2968
3135
  label: "Minimum Score (16 bit)",
2969
3136
  type: "number",
2970
3137
  value: e.minimumScore.toString(),
@@ -2976,7 +3143,7 @@ function Mt() {
2976
3143
  }
2977
3144
  }), /* @__PURE__ */ h("div", {
2978
3145
  style: { padding: "10px 10px 20px 10px" },
2979
- children: /* @__PURE__ */ h(L, {
3146
+ children: /* @__PURE__ */ h(z, {
2980
3147
  min: 0,
2981
3148
  max: 65535,
2982
3149
  step: 1,
@@ -2987,7 +3154,7 @@ function Mt() {
2987
3154
  "aria-label": "Minimum score"
2988
3155
  })
2989
3156
  })] }),
2990
- /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(k, {
3157
+ /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(j, {
2991
3158
  label: "Placeholder text",
2992
3159
  type: "text",
2993
3160
  value: e.placeholderText,
@@ -2995,25 +3162,25 @@ function Mt() {
2995
3162
  t({ placeholderText: e.target.value });
2996
3163
  }
2997
3164
  }) }),
2998
- /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(z, {
3165
+ /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(H, {
2999
3166
  label: "Show score",
3000
3167
  checked: e.showScore,
3001
- onChange: (e) => F("showScore", e)
3168
+ onChange: (e) => P("showScore", e)
3002
3169
  }) }),
3003
- /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(S, {
3170
+ /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(C, {
3004
3171
  variant: "ghost",
3005
3172
  size: "micro",
3006
- iconRight: h(s ? U : W, {}),
3173
+ iconRight: h(s ? K : ee, {}),
3007
3174
  onClick: () => c((e) => !e),
3008
3175
  children: s ? "Hide Match, Candidates and Ranking" : "Show Match, Candidates and Ranking"
3009
3176
  }) }),
3010
3177
  s && /* @__PURE__ */ g(m, { children: [
3011
- /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(P, {
3178
+ /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(I, {
3012
3179
  label: "Tolerance",
3013
3180
  size: "micro",
3014
3181
  disabled: D,
3015
- value: f.tolerance ?? C.tolerance,
3016
- onValueChange: (e) => I({ tolerance: e }),
3182
+ value: f.tolerance ?? S.tolerance,
3183
+ onValueChange: (e) => F({ tolerance: e }),
3017
3184
  options: [
3018
3185
  {
3019
3186
  label: "Exact",
@@ -3033,93 +3200,93 @@ function Mt() {
3033
3200
  }
3034
3201
  ]
3035
3202
  }) }),
3036
- /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(z, {
3203
+ /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(H, {
3037
3204
  label: "Every rung",
3038
3205
  disabled: D,
3039
- checked: (f.rungs ?? C.rungs) === u.All,
3040
- onChange: (e) => I({ rungs: e ? u.All : u.Fewest })
3206
+ checked: (f.rungs ?? S.rungs) === u.All,
3207
+ onChange: (e) => F({ rungs: e ? u.All : u.Fewest })
3041
3208
  }) }),
3042
- /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(k, {
3209
+ /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(j, {
3043
3210
  label: "One edit from",
3044
3211
  type: "number",
3045
3212
  disabled: D,
3046
- value: (f.oneEditFrom ?? C.oneEditFrom).toString(),
3047
- onChange: (e) => V(e.target.value, (e) => I({ oneEditFrom: e }))
3213
+ value: (f.oneEditFrom ?? S.oneEditFrom).toString(),
3214
+ onChange: (e) => B(e.target.value, (e) => F({ oneEditFrom: e }))
3048
3215
  }) }),
3049
- /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(k, {
3216
+ /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(j, {
3050
3217
  label: "Two edits from",
3051
3218
  type: "number",
3052
3219
  disabled: D,
3053
- value: (f.twoEditsFrom ?? C.twoEditsFrom).toString(),
3054
- onChange: (e) => V(e.target.value, (e) => I({ twoEditsFrom: e }))
3220
+ value: (f.twoEditsFrom ?? S.twoEditsFrom).toString(),
3221
+ onChange: (e) => B(e.target.value, (e) => F({ twoEditsFrom: e }))
3055
3222
  }) }),
3056
- /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(k, {
3223
+ /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(j, {
3057
3224
  label: "Three edits from",
3058
3225
  type: "number",
3059
3226
  disabled: D,
3060
- value: (f.threeEditsFrom ?? C.threeEditsFrom).toString(),
3061
- onChange: (e) => V(e.target.value, (e) => I({ threeEditsFrom: e }))
3227
+ value: (f.threeEditsFrom ?? S.threeEditsFrom).toString(),
3228
+ onChange: (e) => B(e.target.value, (e) => F({ threeEditsFrom: e }))
3062
3229
  }) }),
3063
- /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(k, {
3230
+ /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(j, {
3064
3231
  label: "Typing prefix from",
3065
3232
  type: "number",
3066
3233
  disabled: D,
3067
- value: (f.typingPrefixFrom ?? C.typingPrefixFrom).toString(),
3068
- onChange: (e) => V(e.target.value, (e) => I({ typingPrefixFrom: e }))
3234
+ value: (f.typingPrefixFrom ?? S.typingPrefixFrom).toString(),
3235
+ onChange: (e) => B(e.target.value, (e) => F({ typingPrefixFrom: e }))
3069
3236
  }) }),
3070
- /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(z, {
3237
+ /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(H, {
3071
3238
  label: "Joined words",
3072
3239
  disabled: D,
3073
- checked: f.joinedWords ?? C.joinedWords,
3074
- onChange: (e) => I({ joinedWords: e })
3240
+ checked: f.joinedWords ?? S.joinedWords,
3241
+ onChange: (e) => F({ joinedWords: e })
3075
3242
  }) }),
3076
- /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(k, {
3243
+ /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(j, {
3077
3244
  label: "Candidates per row",
3078
3245
  type: "number",
3079
- disabled: j,
3246
+ disabled: k,
3080
3247
  value: (_.candidatesPerRow ?? w.candidatesPerRow).toString(),
3081
- onChange: (e) => V(e.target.value, (e) => R({ candidatesPerRow: e }))
3248
+ onChange: (e) => B(e.target.value, (e) => L({ candidatesPerRow: e }))
3082
3249
  }) }),
3083
- /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(k, {
3250
+ /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(j, {
3084
3251
  label: "Max candidates (0: per row)",
3085
3252
  type: "number",
3086
- disabled: j,
3253
+ disabled: k,
3087
3254
  value: (_.maxCandidates ?? 0).toString(),
3088
- onChange: (e) => V(e.target.value, (e) => R({ maxCandidates: e > 0 ? e : null }))
3255
+ onChange: (e) => B(e.target.value, (e) => L({ maxCandidates: e > 0 ? e : null }))
3089
3256
  }) }),
3090
- /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(z, {
3257
+ /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(H, {
3091
3258
  label: "Fallback (most words when none holds every word)",
3092
3259
  disabled: D,
3093
3260
  checked: _.fallback ?? w.fallback,
3094
- onChange: (e) => R({ fallback: e })
3261
+ onChange: (e) => L({ fallback: e })
3095
3262
  }) }),
3096
- /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(z, {
3263
+ /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(H, {
3097
3264
  label: "Rest (BM25F below the counted set)",
3098
3265
  disabled: D,
3099
3266
  checked: _.rest ?? w.rest,
3100
- onChange: (e) => R({ rest: e })
3267
+ onChange: (e) => L({ rest: e })
3101
3268
  }) }),
3102
- /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(k, {
3269
+ /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(j, {
3103
3270
  label: "Coverage share %",
3104
3271
  type: "number",
3105
- disabled: !A,
3272
+ disabled: !O,
3106
3273
  value: Math.round((v.share ?? T.share) * 100).toString(),
3107
- onChange: (e) => H(e.target.value, (e) => B({ share: e }))
3274
+ onChange: (e) => V(e.target.value, (e) => R({ share: e }))
3108
3275
  }) }),
3109
- /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(k, {
3276
+ /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(j, {
3110
3277
  label: "Typing shift %",
3111
3278
  type: "number",
3112
- disabled: !A,
3279
+ disabled: !O,
3113
3280
  value: Math.round((v.typingShift ?? T.typingShift) * 100).toString(),
3114
- onChange: (e) => H(e.target.value, (e) => B({ typingShift: e }))
3281
+ onChange: (e) => V(e.target.value, (e) => R({ typingShift: e }))
3115
3282
  }) }),
3116
- /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(z, {
3283
+ /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(H, {
3117
3284
  label: "Whole query floor",
3118
- disabled: !A,
3285
+ disabled: !O,
3119
3286
  checked: v.wholeQueryFloor ?? T.wholeQueryFloor,
3120
- onChange: (e) => B({ wholeQueryFloor: e })
3287
+ onChange: (e) => R({ wholeQueryFloor: e })
3121
3288
  }) }),
3122
- M && /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(S, {
3289
+ M && /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(C, {
3123
3290
  variant: "ghost",
3124
3291
  size: "micro",
3125
3292
  onClick: () => t({
@@ -3136,7 +3303,7 @@ function Mt() {
3136
3303
  });
3137
3304
  }
3138
3305
  // src/components/SearchErrorBoundary.tsx
3139
- var Nt = class extends t {
3306
+ var Bt = class extends t {
3140
3307
  constructor(e) {
3141
3308
  super(e), this.state = {
3142
3309
  hasError: !1,
@@ -3206,7 +3373,7 @@ var Nt = class extends t {
3206
3373
  ]
3207
3374
  })]
3208
3375
  }),
3209
- /* @__PURE__ */ h(S, {
3376
+ /* @__PURE__ */ h(C, {
3210
3377
  variant: "primary",
3211
3378
  size: "micro",
3212
3379
  onClick: this.reset,
@@ -3217,8 +3384,8 @@ var Nt = class extends t {
3217
3384
  }
3218
3385
  };
3219
3386
  // src/hooks/useVectorSearch.ts
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);
3387
+ function Vt(e, t) {
3388
+ let { url: n, team: r, dataset: a, authenticatedFetch: s } = Ce(), [u, d] = l(null), [f, p] = l(!1), [m, h] = l(void 0), g = c(0);
3222
3389
  return o(() => () => {
3223
3390
  g.current++;
3224
3391
  }, [
@@ -3244,7 +3411,7 @@ function Pt(e, t) {
3244
3411
  headers: { "Content-Type": "application/json" },
3245
3412
  body: JSON.stringify(l)
3246
3413
  });
3247
- if (!u.ok) throw await Z.fromResponse("VectorSearch", u);
3414
+ if (!u.ok) throw await $.fromResponse("VectorSearch", u);
3248
3415
  let f = await u.json();
3249
3416
  if (!c()) return;
3250
3417
  if (f.length === 0) {
@@ -3256,7 +3423,7 @@ function Pt(e, t) {
3256
3423
  headers: { "Content-Type": "application/json" },
3257
3424
  body: JSON.stringify(p)
3258
3425
  });
3259
- if (!m.ok) throw await Z.fromResponse("GetJson", m);
3426
+ if (!m.ok) throw await $.fromResponse("GetJson", m);
3260
3427
  let h = await m.json();
3261
3428
  if (!c()) return;
3262
3429
  d(h.map((e, t) => ({
@@ -3283,8 +3450,8 @@ function Pt(e, t) {
3283
3450
  };
3284
3451
  }
3285
3452
  // src/hooks/useHybridSearch.ts
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);
3453
+ function Ht(e, t) {
3454
+ let { url: n, team: r, dataset: a, authenticatedFetch: s } = Ce(), [u, d] = l(null), [f, p] = l(!1), [m, h] = l(void 0), g = c(0);
3288
3455
  return o(() => () => {
3289
3456
  g.current++;
3290
3457
  }, [
@@ -3312,7 +3479,7 @@ function Ft(e, t) {
3312
3479
  headers: { "Content-Type": "application/json" },
3313
3480
  body: JSON.stringify(l)
3314
3481
  });
3315
- if (!u.ok) throw await Z.fromResponse("HybridSearch", u);
3482
+ if (!u.ok) throw await $.fromResponse("HybridSearch", u);
3316
3483
  let f = await u.json();
3317
3484
  if (!c()) return;
3318
3485
  if (f.length === 0) {
@@ -3324,7 +3491,7 @@ function Ft(e, t) {
3324
3491
  headers: { "Content-Type": "application/json" },
3325
3492
  body: JSON.stringify(p)
3326
3493
  });
3327
- if (!m.ok) throw await Z.fromResponse("GetJson", m);
3494
+ if (!m.ok) throw await $.fromResponse("GetJson", m);
3328
3495
  let h = await m.json();
3329
3496
  if (!c()) return;
3330
3497
  d(h.map((e, t) => ({
@@ -3353,7 +3520,7 @@ function Ft(e, t) {
3353
3520
  };
3354
3521
  }
3355
3522
  // src/hooks/useAsk.ts
3356
- var It = {
3523
+ var Ut = {
3357
3524
  question: "",
3358
3525
  status: "idle",
3359
3526
  answer: "",
@@ -3361,10 +3528,10 @@ var It = {
3361
3528
  steps: [],
3362
3529
  stepDetails: []
3363
3530
  };
3364
- function Lt() {
3365
- let e = ye(), { url: t, team: n, dataset: r, authenticatedFetch: a } = e, s = c(e);
3531
+ function Wt() {
3532
+ let e = Ce(), { url: t, team: n, dataset: r, authenticatedFetch: a } = e, s = c(e);
3366
3533
  s.current = e;
3367
- let [u, d] = l(It), f = c(u);
3534
+ let [u, d] = l(Ut), f = c(u);
3368
3535
  f.current = u;
3369
3536
  let p = c(null), m = i(async (e, i = [], o = {}) => {
3370
3537
  let c = e.trim();
@@ -3397,7 +3564,7 @@ function Lt() {
3397
3564
  }
3398
3565
  }));
3399
3566
  try {
3400
- let e = await a(`${t}/api/teams/${n}/datasets/${r}/search-or-ask/ask${Ae(s.current)}`, {
3567
+ let e = await a(`${t}/api/teams/${n}/datasets/${r}/search-or-ask/ask${Pe(s.current)}`, {
3401
3568
  method: "POST",
3402
3569
  headers: {
3403
3570
  "Content-Type": "application/json",
@@ -3413,7 +3580,7 @@ function Lt() {
3413
3580
  if (e.status === 429) {
3414
3581
  let t = await e.json().catch(() => ({}));
3415
3582
  if (o.proactive) {
3416
- d(It);
3583
+ d(Ut);
3417
3584
  return;
3418
3585
  }
3419
3586
  let n = Number(e.headers.get("Retry-After"));
@@ -3432,14 +3599,14 @@ function Lt() {
3432
3599
  })), !e.ok || !e.body) {
3433
3600
  let t = await e.json().catch(() => ({}));
3434
3601
  if (o.proactive) {
3435
- d(It);
3602
+ d(Ut);
3436
3603
  return;
3437
3604
  }
3438
3605
  let n = e.status === 409 || e.status === 404;
3439
3606
  g(t.code ?? `http${e.status}`, n ? "Answers are not available here right now. Search still works." : "The question could not be asked.");
3440
3607
  return;
3441
3608
  }
3442
- for await (let { event: t, data: n } of ke(e.body)) switch (t) {
3609
+ for await (let { event: t, data: n } of Ne(e.body)) switch (t) {
3443
3610
  case "status": {
3444
3611
  let e = n;
3445
3612
  e.step && d((t) => ({
@@ -3528,7 +3695,7 @@ function Lt() {
3528
3695
  r,
3529
3696
  a
3530
3697
  ]), g = i(() => p.current?.abort(), []), _ = i(() => {
3531
- p.current?.abort(), d(It);
3698
+ p.current?.abort(), d(Ut);
3532
3699
  }, []);
3533
3700
  return o(() => () => p.current?.abort(), []), {
3534
3701
  ...u,
@@ -3539,7 +3706,89 @@ function Lt() {
3539
3706
  busy: u.status === "searching" || u.status === "writing"
3540
3707
  };
3541
3708
  }
3542
- var $ = {
3709
+ // src/hooks/useAskFlow.ts
3710
+ function Gt({ searchOrAsk: e, restore: t, settleMs: n = 350, maxWaitMs: r }) {
3711
+ let a = Ce(), { state: s, setQuery: c } = a, u = st({ auto: e }), [d, f] = l(null), [p, m] = l(0), [h, g] = l(!1), [_, v] = l("idle"), [y, b] = l(null), [x, S] = l(!0), [C, w] = l(!1), T = i((e, t) => {
3712
+ let n = e?.trim();
3713
+ n && (f(n), g(!!t?.proactive), m((e) => e + 1), v("idle"), S(!!t?.proactive), b(t?.proactive ? null : { phase: "asking" }));
3714
+ }, []), E = i((e) => {
3715
+ c(e), T(e);
3716
+ }, [c, T]), D = T, O = i(() => {
3717
+ f(null), m((e) => e + 1), b(null);
3718
+ }, []), k = i((e) => {
3719
+ h || (u.apply(e), e.sort && w(!0), b({
3720
+ phase: "applied",
3721
+ before: s.queryId
3722
+ }));
3723
+ }, [
3724
+ h,
3725
+ u,
3726
+ s.queryId
3727
+ ]), A = i((e) => b(null), []);
3728
+ o(() => {
3729
+ if (y) {
3730
+ if (y.phase === "applied" && !s.isLoading && s.queryId !== y.before) {
3731
+ let e = setTimeout(() => b(null), n);
3732
+ return () => clearTimeout(e);
3733
+ }
3734
+ y.phase === "asking" && [
3735
+ "answered",
3736
+ "error",
3737
+ "limited"
3738
+ ].includes(_) && b(null);
3739
+ }
3740
+ }, [
3741
+ y,
3742
+ s.isLoading,
3743
+ s.queryId,
3744
+ _,
3745
+ n
3746
+ ]), o(() => {
3747
+ if (!y) return;
3748
+ let e = setTimeout(() => b(null), y.phase === "applied" ? r?.applied ?? 4e3 : r?.asking ?? 3e4);
3749
+ return () => clearTimeout(e);
3750
+ }, [
3751
+ y,
3752
+ r?.applied,
3753
+ r?.asking
3754
+ ]);
3755
+ let j = i((e) => {
3756
+ e.key !== "Enter" && S(!0);
3757
+ }, []), M = i(() => {
3758
+ S(!0), C && (t?.(a), w(!1));
3759
+ }, [
3760
+ C,
3761
+ t,
3762
+ a
3763
+ ]), N = s.query.trim(), P = d != null && !x;
3764
+ return {
3765
+ question: d,
3766
+ run: p,
3767
+ proactive: h,
3768
+ status: _,
3769
+ asked: P,
3770
+ waiting: P && y != null,
3771
+ offerShown: !P && (d == null || d !== N),
3772
+ ask: T,
3773
+ askExample: E,
3774
+ askHere: D,
3775
+ newConversation: O,
3776
+ inputProps: {
3777
+ searchOrAsk: e,
3778
+ onAsk: T,
3779
+ onKeyDown: j,
3780
+ onClear: M
3781
+ },
3782
+ panelProps: {
3783
+ question: d ?? "",
3784
+ proactive: h,
3785
+ onFilters: k,
3786
+ onPicks: A,
3787
+ onStatusChange: v
3788
+ }
3789
+ };
3790
+ }
3791
+ var Kt = {
3543
3792
  panel: "_panel_gjc13_1",
3544
3793
  thread: "_thread_gjc13_4",
3545
3794
  fill: "_fill_gjc13_5",
@@ -3555,18 +3804,18 @@ var $ = {
3555
3804
  searchedLabel: "_searchedLabel_gjc13_23",
3556
3805
  steps: "_steps_gjc13_26",
3557
3806
  stepDone: "_stepDone_gjc13_27"
3558
- }, Rt = /(`[^`\n]+`)|(\*\*[^*\n]+\*\*)|(\*[^*\n]+\*|_[^_\n]+_)|(\[[^\]\n]+\]\(https?:\/\/[^)\s]+\))|(\[\d+\])/g;
3559
- function zt(t, n, r) {
3807
+ }, qt = /(`[^`\n]+`)|(\*\*[^*\n]+\*\*)|(\*[^*\n]+\*|_[^_\n]+_)|(\[[^\]\n]+\]\(https?:\/\/[^)\s]+\))|(\[\d+\])/g;
3808
+ function Jt(t, n, r) {
3560
3809
  let i = [], a = 0, o = 0;
3561
- for (let s of t.matchAll(Rt)) {
3810
+ for (let s of t.matchAll(qt)) {
3562
3811
  s.index > a && i.push(t.slice(a, s.index));
3563
3812
  let c = `${r}-${o++}`, [l, u, d, f, p, m] = s;
3564
3813
  if (u) i.push(/* @__PURE__ */ h("code", {
3565
- className: $.inlineCode,
3814
+ className: Kt.inlineCode,
3566
3815
  children: u.slice(1, -1)
3567
3816
  }, c));
3568
- else if (d) i.push(/* @__PURE__ */ h("strong", { children: zt(d.slice(2, -2), n, c) }, c));
3569
- else if (f) i.push(/* @__PURE__ */ h("em", { children: zt(f.slice(1, -1), n, c) }, c));
3817
+ else if (d) i.push(/* @__PURE__ */ h("strong", { children: Jt(d.slice(2, -2), n, c) }, c));
3818
+ else if (f) i.push(/* @__PURE__ */ h("em", { children: Jt(f.slice(1, -1), n, c) }, c));
3570
3819
  else if (p) {
3571
3820
  let [, e, t] = /^\[([^\]]+)\]\(([^)]+)\)$/.exec(p);
3572
3821
  i.push(/* @__PURE__ */ h("a", {
@@ -3580,7 +3829,7 @@ function zt(t, n, r) {
3580
3829
  }
3581
3830
  return a < t.length && i.push(t.slice(a)), i;
3582
3831
  }
3583
- function Bt(e) {
3832
+ function Yt(e) {
3584
3833
  let t = e.replace(/\r\n/g, "\n").split("\n"), n = [], r = [], i = () => {
3585
3834
  r.length && (n.push({
3586
3835
  kind: "paragraph",
@@ -3629,101 +3878,101 @@ function Bt(e) {
3629
3878
  }
3630
3879
  return i(), n;
3631
3880
  }
3632
- function Vt(e, t) {
3633
- return Bt(e).map((e, n) => {
3881
+ function Xt(e, t) {
3882
+ return Yt(e).map((e, n) => {
3634
3883
  let r = `b${n}`;
3635
3884
  switch (e.kind) {
3636
3885
  case "code": return /* @__PURE__ */ h("pre", {
3637
- className: $.codeBlock,
3886
+ className: Kt.codeBlock,
3638
3887
  "data-lang": e.lang || void 0,
3639
3888
  children: /* @__PURE__ */ h("code", { children: e.text })
3640
3889
  }, r);
3641
3890
  case "heading": return /* @__PURE__ */ h("p", {
3642
- className: $.heading,
3643
- children: zt(e.text, t, r)
3891
+ className: Kt.heading,
3892
+ children: Jt(e.text, t, r)
3644
3893
  }, r);
3645
3894
  case "list": {
3646
3895
  let n = e.ordered ? "ol" : "ul";
3647
3896
  return /* @__PURE__ */ h(n, {
3648
- className: $.list,
3649
- children: e.items.map((e, n) => /* @__PURE__ */ h("li", { children: zt(e, t, `${r}-${n}`) }, n))
3897
+ className: Kt.list,
3898
+ children: e.items.map((e, n) => /* @__PURE__ */ h("li", { children: Jt(e, t, `${r}-${n}`) }, n))
3650
3899
  }, r);
3651
3900
  }
3652
3901
  default: return /* @__PURE__ */ h("p", {
3653
- className: $.paragraph,
3654
- children: zt(e.text, t, r)
3902
+ className: Kt.paragraph,
3903
+ children: Jt(e.text, t, r)
3655
3904
  }, r);
3656
3905
  }
3657
3906
  });
3658
3907
  }
3659
3908
  // src/components/AskPanel.tsx
3660
- var Ht = /\[(\d+)\]/g, Ut = /* @__PURE__ */ new Set([
3909
+ var Zt = /\[(\d+)\]/g, Qt = /* @__PURE__ */ new Set([
3661
3910
  "nothingFound",
3662
3911
  "searchOrAskDisabled",
3663
3912
  "searchOrAskUnavailable",
3664
3913
  "http404"
3665
3914
  ]);
3666
- function Wt(e) {
3915
+ function $t(e) {
3667
3916
  let t = e.field.split(".")[0];
3668
3917
  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;
3669
3918
  }
3670
- 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 = "" }) => {
3671
- let k = Lt(), { showPicks: A } = ye(), j = c(A);
3672
- j.current = A, o(() => () => j.current?.(null), []);
3673
- 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);
3919
+ var en = ({ question: e, proactive: t = !1, followUps: n = !1, onSourceClick: r, label: i = "Answer", renderAnswer: a = Xt, onFollowUp: s, onStatusChange: u, onFilters: d, onPicks: f, listPicks: p = !0, filterLabel: m = $t, showSearched: S = !0, fill: w = !1, className: T = "" }) => {
3920
+ let A = Wt(), { showPicks: j } = Ce(), M = c(j);
3921
+ M.current = j, o(() => () => M.current?.(null), []);
3922
+ let { ask: N, reset: P, stop: F, status: I, openSource: L } = A, [R, z] = l(!1), [V, H] = l([]), [U, G] = l(""), K = c([]), ee = c(null), q = c(null), te = c(!0);
3674
3923
  o(() => {
3675
- H([]), G.current = [], j.current?.(null), e?.trim() ? M(e, [], { proactive: t }) : N();
3924
+ H([]), K.current = [], M.current?.(null), e?.trim() ? N(e, [], { proactive: t }) : P();
3676
3925
  }, [
3677
3926
  e,
3678
- M,
3679
- N
3927
+ N,
3928
+ P
3680
3929
  ]), o(() => {
3681
- u?.(F);
3682
- }, [F, u]);
3683
- let te = c(void 0);
3930
+ u?.(I);
3931
+ }, [I, u]);
3932
+ let J = c(void 0);
3684
3933
  o(() => {
3685
- k.filters && k.filters !== te.current && (te.current = k.filters, d?.(k.filters));
3686
- }, [k.filters, d]);
3687
- let ne = c(void 0);
3934
+ A.filters && A.filters !== J.current && (J.current = A.filters, d?.(A.filters));
3935
+ }, [A.filters, d]);
3936
+ let Y = c(void 0);
3688
3937
  o(() => {
3689
- if (k.picks && k.picks !== ne.current) {
3690
- ne.current = k.picks;
3938
+ if (A.picks && A.picks !== Y.current) {
3939
+ Y.current = A.picks;
3691
3940
  let e = {
3692
- ...k.picks,
3693
- askId: k.picks.askId ?? k.askId
3941
+ ...A.picks,
3942
+ askId: A.picks.askId ?? A.askId
3694
3943
  };
3695
- f?.(e), p && !t && A?.(e);
3944
+ f?.(e), p && !t && j?.(e);
3696
3945
  }
3697
3946
  }, [
3698
- k.picks,
3699
- k.askId,
3947
+ A.picks,
3948
+ A.askId,
3700
3949
  f,
3701
3950
  p,
3702
3951
  t,
3703
- A
3952
+ j
3704
3953
  ]), o(() => {
3705
- let e = ee.current;
3706
- C && e && q.current && (e.scrollTop = e.scrollHeight);
3954
+ let e = q.current;
3955
+ w && e && te.current && (e.scrollTop = e.scrollHeight);
3707
3956
  }, [
3708
- C,
3709
- k.answer,
3710
- k.steps.length,
3711
- F,
3712
- B.length
3957
+ w,
3958
+ A.answer,
3959
+ A.steps.length,
3960
+ I,
3961
+ V.length
3713
3962
  ]);
3714
- let J = () => {
3715
- let e = ee.current;
3716
- e && (q.current = e.scrollHeight - e.scrollTop - e.clientHeight < 40);
3717
- }, X = (e) => e && /* @__PURE__ */ g("div", {
3718
- className: $.searched,
3963
+ let X = () => {
3964
+ let e = q.current;
3965
+ e && (te.current = e.scrollHeight - e.scrollTop - e.clientHeight < 40);
3966
+ }, Z = (e) => S && e && /* @__PURE__ */ g("div", {
3967
+ className: Kt.searched,
3719
3968
  children: [
3720
3969
  /* @__PURE__ */ g("span", {
3721
- className: $.searchedLabel,
3970
+ className: Kt.searchedLabel,
3722
3971
  children: [e.more ? `${e.found}+` : e.found, " found"]
3723
3972
  }),
3724
- e.filters.map((e, t) => /* @__PURE__ */ h(w, { children: m(e) }, t)),
3973
+ e.filters.map((e, t) => /* @__PURE__ */ h(E, { children: m(e) }, t)),
3725
3974
  e.text && /* @__PURE__ */ g("span", {
3726
- className: $.searchedLabel,
3975
+ className: Kt.searchedLabel,
3727
3976
  children: [
3728
3977
  "β€œ",
3729
3978
  e.text,
@@ -3731,7 +3980,7 @@ var Gt = ({ question: e, proactive: t = !1, followUps: n = !1, onSourceClick: r,
3731
3980
  ]
3732
3981
  }),
3733
3982
  e.sort && /* @__PURE__ */ g("span", {
3734
- className: $.searchedLabel,
3983
+ className: Kt.searchedLabel,
3735
3984
  children: [
3736
3985
  "sorted by ",
3737
3986
  e.sort.field.split(".")[0],
@@ -3742,43 +3991,43 @@ var Gt = ({ question: e, proactive: t = !1, followUps: n = !1, onSourceClick: r,
3742
3991
  })
3743
3992
  ]
3744
3993
  });
3745
- if (F === "idle" && B.length === 0) return null;
3746
- let re = (e, t) => (n) => {
3747
- n.preventDefault(), I(e, t), r?.(e);
3748
- }, ie = (e, t) => (n) => {
3994
+ if (I === "idle" && V.length === 0) return null;
3995
+ let ne = (e, t) => (n) => {
3996
+ n.preventDefault(), L(e, t), r?.(e);
3997
+ }, re = (e, t) => (n) => {
3749
3998
  let i = e.find((e) => e.n === n);
3750
- return /* @__PURE__ */ h(E, {
3999
+ return /* @__PURE__ */ h(O, {
3751
4000
  n,
3752
4001
  title: i?.title,
3753
- onClick: i && r ? re(i, t) : void 0
4002
+ onClick: i && r ? ne(i, t) : void 0
3754
4003
  });
3755
- }, ae = (e, t, n) => {
3756
- let r = new Set([...e.matchAll(Ht)].map((e) => Number(e[1])));
4004
+ }, ie = (e, t, n) => {
4005
+ let r = new Set([...e.matchAll(Zt)].map((e) => Number(e[1])));
3757
4006
  return n && r.size > 0 ? t.filter((e) => r.has(e.n)) : t.slice(0, 3);
3758
- }, Z = (e, t, n, i, a = !1) => {
3759
- let o = a ? t : ae(e, t, n);
3760
- return o.length > 0 && /* @__PURE__ */ h(T, {
4007
+ }, ae = (e, t, n, i, a = !1) => {
4008
+ let o = a ? t : ie(e, t, n);
4009
+ return o.length > 0 && /* @__PURE__ */ h(D, {
3761
4010
  label: a ? "Picked" : void 0,
3762
4011
  items: o.map((e) => ({
3763
4012
  n: e.n,
3764
4013
  title: e.title,
3765
- onClick: r ? re(e, i) : void 0
4014
+ onClick: r ? ne(e, i) : void 0
3766
4015
  }))
3767
4016
  });
3768
4017
  }, oe = () => {
3769
- navigator.clipboard?.writeText(k.answer.replace(Ht, "")).catch(() => {}), z(!0), setTimeout(() => z(!1), 2e3);
4018
+ navigator.clipboard?.writeText(A.answer.replace(Zt, "")).catch(() => {}), z(!0), setTimeout(() => z(!1), 2e3);
3770
4019
  }, se = (e) => {
3771
- if (!k.busy && e.trim()) {
3772
- if (F === "answered" && k.answer) {
4020
+ if (!A.busy && e.trim()) {
4021
+ if (I === "answered" && A.answer) {
3773
4022
  let e = {
3774
- question: k.question,
3775
- answer: k.answer,
3776
- sources: k.sources,
3777
- askId: k.askId,
3778
- filters: k.filters,
3779
- picks: k.picks
4023
+ question: A.question,
4024
+ answer: A.answer,
4025
+ sources: A.sources,
4026
+ askId: A.askId,
4027
+ filters: A.filters,
4028
+ picks: A.picks
3780
4029
  };
3781
- H((t) => [...t, e]), G.current = [...G.current, {
4030
+ H((t) => [...t, e]), K.current = [...K.current, {
3782
4031
  question: e.question,
3783
4032
  answer: e.answer,
3784
4033
  ...e.picks ? { shown: { picks: e.picks.picks.map((e) => ({
@@ -3791,103 +4040,556 @@ var Gt = ({ question: e, proactive: t = !1, followUps: n = !1, onSourceClick: r,
3791
4040
  } } : {}
3792
4041
  }];
3793
4042
  }
3794
- W(""), M(e, G.current);
4043
+ G(""), N(e, K.current);
3795
4044
  }
3796
- }, ce = n ? () => K.current?.focus() : s;
4045
+ }, ce = n ? () => ee.current?.focus() : s;
3797
4046
  return /* @__PURE__ */ g("div", {
3798
- className: `${$.panel} ${C ? $.fill : ""} ${O}`,
4047
+ className: `${Kt.panel} ${w ? Kt.fill : ""} ${T}`,
3799
4048
  "aria-live": "polite",
3800
- "aria-busy": k.busy,
4049
+ "aria-busy": A.busy,
3801
4050
  children: [/* @__PURE__ */ g("div", {
3802
- ref: ee,
3803
- className: $.thread,
3804
- onScroll: C ? J : void 0,
3805
- children: [B.map((e, t) => /* @__PURE__ */ g("div", {
3806
- className: $.turn,
3807
- children: [/* @__PURE__ */ h(V, { children: e.question }), /* @__PURE__ */ g(x, {
4051
+ ref: q,
4052
+ className: Kt.thread,
4053
+ onScroll: w ? X : void 0,
4054
+ children: [V.map((e, t) => /* @__PURE__ */ g("div", {
4055
+ className: Kt.turn,
4056
+ children: [/* @__PURE__ */ h(W, { children: e.question }), /* @__PURE__ */ g(x, {
3808
4057
  label: i,
3809
4058
  children: [
3810
- X(e.filters),
4059
+ Z(e.filters),
3811
4060
  /* @__PURE__ */ h("div", {
3812
- className: $.answer,
3813
- children: a(e.answer, ie(e.sources, e.askId))
4061
+ className: Kt.answer,
4062
+ children: a(e.answer, re(e.sources, e.askId))
3814
4063
  }),
3815
- Z(e.answer, e.sources, !0, e.askId, !!e.picks)
4064
+ ae(e.answer, e.sources, !0, e.askId, !!e.picks)
3816
4065
  ]
3817
4066
  })]
3818
- }, t)), F !== "idle" && /* @__PURE__ */ g("div", {
3819
- className: $.turn,
3820
- children: [/* @__PURE__ */ h(V, { children: k.question }), /* @__PURE__ */ g(x, {
4067
+ }, t)), I !== "idle" && /* @__PURE__ */ g("div", {
4068
+ className: Kt.turn,
4069
+ children: [/* @__PURE__ */ h(W, { children: A.question }), /* @__PURE__ */ g(x, {
3821
4070
  label: i,
3822
4071
  children: [
3823
- X(k.filters),
3824
- k.answer && /* @__PURE__ */ h("div", {
3825
- className: $.answer,
3826
- children: a(k.answer, ie(k.sources))
4072
+ Z(A.filters),
4073
+ A.answer && /* @__PURE__ */ h("div", {
4074
+ className: Kt.answer,
4075
+ children: a(A.answer, re(A.sources))
3827
4076
  }),
3828
- F === "searching" && k.steps.length > 0 && /* @__PURE__ */ g("div", {
3829
- className: $.steps,
3830
- children: [k.steps.slice(0, -1).map((e, t) => /* @__PURE__ */ h("span", {
3831
- className: $.stepDone,
4077
+ I === "searching" && A.steps.length > 0 && /* @__PURE__ */ g("div", {
4078
+ className: Kt.steps,
4079
+ children: [A.steps.slice(0, -1).map((e, t) => /* @__PURE__ */ h("span", {
4080
+ className: Kt.stepDone,
3832
4081
  children: e
3833
- }, t)), /* @__PURE__ */ g(R, { children: [k.steps[k.steps.length - 1], "…"] })]
4082
+ }, t)), /* @__PURE__ */ g(B, { children: [A.steps[A.steps.length - 1], "…"] })]
3834
4083
  }),
3835
- F === "searching" && k.steps.length === 0 && /* @__PURE__ */ h(R, { children: "Searching…" }),
3836
- F === "writing" && /* @__PURE__ */ h(R, {
4084
+ I === "searching" && A.steps.length === 0 && /* @__PURE__ */ h(B, { children: "Searching…" }),
4085
+ I === "writing" && /* @__PURE__ */ h(B, {
3837
4086
  spinner: "grow",
3838
4087
  children: "Writing…"
3839
4088
  }),
3840
- F === "error" && /* @__PURE__ */ g(_, {
4089
+ I === "error" && /* @__PURE__ */ g(_, {
3841
4090
  variant: "default",
3842
4091
  icon: null,
3843
4092
  children: [
3844
- /* @__PURE__ */ h(y, { children: k.error?.code === "nothingFound" ? "Nothing to answer from" : "The answer did not come through" }),
3845
- /* @__PURE__ */ h(v, { children: k.error?.code === "nothingFound" ? "The search found no records about this. Try other words, or search instead." : k.error?.message }),
3846
- !Ut.has(k.error?.code ?? "") && /* @__PURE__ */ h("div", {
3847
- className: $.action,
3848
- children: /* @__PURE__ */ h(S, {
4093
+ /* @__PURE__ */ h(y, { children: A.error?.code === "nothingFound" ? "Nothing to answer from" : "The answer did not come through" }),
4094
+ /* @__PURE__ */ h(v, { children: A.error?.code === "nothingFound" ? "The search found no records about this. Try other words, or search instead." : A.error?.message }),
4095
+ !Qt.has(A.error?.code ?? "") && /* @__PURE__ */ h("div", {
4096
+ className: Kt.action,
4097
+ children: /* @__PURE__ */ h(C, {
3849
4098
  variant: "secondary",
3850
4099
  size: "micro",
3851
- iconLeft: /* @__PURE__ */ h(Y, {}),
3852
- onClick: () => M(k.question, G.current),
4100
+ iconLeft: /* @__PURE__ */ h(Q, {}),
4101
+ onClick: () => N(A.question, K.current),
3853
4102
  children: "Try again"
3854
4103
  })
3855
4104
  })
3856
4105
  ]
3857
4106
  }),
3858
- F === "limited" && k.limit === "budget" && /* @__PURE__ */ g(_, {
4107
+ I === "limited" && A.limit === "budget" && /* @__PURE__ */ g(_, {
3859
4108
  variant: "default",
3860
4109
  icon: null,
3861
4110
  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." })]
3862
4111
  }),
3863
- F === "limited" && k.limit !== "budget" && /* @__PURE__ */ g(_, {
4112
+ I === "limited" && A.limit !== "budget" && /* @__PURE__ */ g(_, {
3864
4113
  variant: "default",
3865
4114
  icon: null,
3866
4115
  children: [/* @__PURE__ */ h(y, { children: "Too many questions for now" }), /* @__PURE__ */ g(v, { children: [
3867
4116
  "You can ask again in about ",
3868
- k.retryAfterSeconds && k.retryAfterSeconds > 90 ? `${Math.ceil(k.retryAfterSeconds / 60)} minutes` : "a minute",
4117
+ A.retryAfterSeconds && A.retryAfterSeconds > 90 ? `${Math.ceil(A.retryAfterSeconds / 60)} minutes` : "a minute",
3869
4118
  ". Search still works in the meantime."
3870
4119
  ] })]
3871
4120
  }),
3872
- F !== "error" && F !== "limited" && Z(k.answer, k.sources, F === "answered", void 0, !!k.picks),
3873
- F === "answered" && /* @__PURE__ */ h(b, {
4121
+ I !== "error" && I !== "limited" && ae(A.answer, A.sources, I === "answered", void 0, !!A.picks),
4122
+ I === "answered" && /* @__PURE__ */ h(b, {
3874
4123
  onCopy: oe,
3875
- copied: L,
4124
+ copied: R,
3876
4125
  onFollowUp: ce
3877
4126
  })
3878
4127
  ]
3879
4128
  })]
3880
4129
  })]
3881
- }), n && /* @__PURE__ */ h(D, {
3882
- ref: K,
4130
+ }), n && /* @__PURE__ */ h(k, {
4131
+ ref: ee,
3883
4132
  value: U,
3884
- onChange: W,
4133
+ onChange: G,
3885
4134
  onSend: se,
3886
- onStop: P,
3887
- streaming: k.busy,
4135
+ onStop: F,
4136
+ streaming: A.busy,
3888
4137
  placeholder: "Ask a follow-up…",
3889
4138
  "aria-label": "Ask a follow-up"
3890
4139
  })]
3891
4140
  });
4141
+ }, tn = {
4142
+ wrapper: "_wrapper_ssdz8_3",
4143
+ component: "_component_ssdz8_4",
4144
+ main: "_main_ssdz8_5",
4145
+ header: "_header_ssdz8_6",
4146
+ searchInput: "_searchInput_ssdz8_7",
4147
+ body: "_body_ssdz8_8",
4148
+ offer: "_offer_ssdz8_12",
4149
+ working: "_working_ssdz8_14",
4150
+ column: "_column_ssdz8_17",
4151
+ frame: "_frame_ssdz8_21",
4152
+ side: "_side_ssdz8_22",
4153
+ sidePanels: "_sidePanels_ssdz8_23",
4154
+ sideBody: "_sideBody_ssdz8_24",
4155
+ assistant: "_assistant_ssdz8_24",
4156
+ sideHead: "_sideHead_ssdz8_28",
4157
+ buttons: "_buttons_ssdz8_29",
4158
+ assistantHead: "_assistantHead_ssdz8_34",
4159
+ askFill: "_askFill_ssdz8_35",
4160
+ assistantEmpty: "_assistantEmpty_ssdz8_37",
4161
+ mobileBar: "_mobileBar_ssdz8_42",
4162
+ mobilePanel: "_mobilePanel_ssdz8_43",
4163
+ mobileBack: "_mobileBack_ssdz8_44"
4164
+ }, nn = {
4165
+ filters: "Filters",
4166
+ assistant: "Assistant",
4167
+ newConversation: "New conversation",
4168
+ searching: "The assistant is searching…",
4169
+ composer: "Ask the assistant…",
4170
+ showResults: "Show results"
4171
+ };
4172
+ function rn(e, t) {
4173
+ let n = c(t);
4174
+ n.current = t, o(() => {
4175
+ e?.(n.current);
4176
+ }, [
4177
+ e,
4178
+ t.available,
4179
+ t.p,
4180
+ t.answerable,
4181
+ t.finished,
4182
+ t.found,
4183
+ t.criteria,
4184
+ t.offer,
4185
+ t.offerRow,
4186
+ t.offerKind,
4187
+ t.door,
4188
+ t.mode,
4189
+ t.held,
4190
+ t.notFound,
4191
+ t.text,
4192
+ t.refocus
4193
+ ]);
4194
+ }
4195
+ function an(e, t) {
4196
+ let [n, r] = l(!1);
4197
+ return o(() => {
4198
+ if (!e.current || typeof ResizeObserver > "u") return;
4199
+ let n = new ResizeObserver(([e]) => r(e.contentRect.width <= t));
4200
+ return n.observe(e.current), () => n.disconnect();
4201
+ }, [e, t]), n;
4202
+ }
4203
+ function on({ intro: e, examples: t, onAsk: n, onExample: r, placeholder: i }) {
4204
+ let [a, o] = l("");
4205
+ return /* @__PURE__ */ g("div", {
4206
+ className: tn.assistantEmpty,
4207
+ children: [
4208
+ e && /* @__PURE__ */ h("p", { children: e }),
4209
+ t && t.length > 0 && /* @__PURE__ */ h(V, {
4210
+ items: t,
4211
+ onPick: r
4212
+ }),
4213
+ /* @__PURE__ */ h(k, {
4214
+ value: a,
4215
+ onChange: o,
4216
+ onSend: (e) => {
4217
+ o(""), n(e);
4218
+ },
4219
+ placeholder: i,
4220
+ "aria-label": i
4221
+ })
4222
+ ]
4223
+ });
4224
+ }
4225
+ function sn({ text: e }) {
4226
+ return /* @__PURE__ */ h("div", {
4227
+ className: tn.working,
4228
+ children: /* @__PURE__ */ h(B, {
4229
+ spinner: "searching",
4230
+ children: e
4231
+ })
4232
+ });
4233
+ }
4234
+ function cn({ filters: e, renderResult: t, results: n, mode: r, intro: i, examples: a, restore: s, offer: u = "row", words: d, labels: f, placeholder: p, autoFocus: _ = !0, narrowBelow: v = 800, onJudged: y, className: b = "" }) {
4235
+ let x = {
4236
+ ...nn,
4237
+ ...f
4238
+ }, w = c(null), T = an(w, v), E = Re({ mode: r }), D = Gt({
4239
+ searchOrAsk: E,
4240
+ restore: s
4241
+ }), [O, k] = l("filters"), [A, j] = l(!1), [M, N] = l("");
4242
+ rn(y, E), o(() => {
4243
+ T || j(!1);
4244
+ }, [T]);
4245
+ let P = (e, t) => {
4246
+ D.ask(e, t), k("assistant"), T && j(!0);
4247
+ }, F = (e) => {
4248
+ N(""), P(e);
4249
+ }, I = (e) => {
4250
+ D.askExample(e), k("assistant"), T && j(!0);
4251
+ }, L = [{
4252
+ value: "filters",
4253
+ label: x.filters,
4254
+ icon: oe
4255
+ }, {
4256
+ value: "assistant",
4257
+ label: x.assistant,
4258
+ icon: G
4259
+ }], R = /* @__PURE__ */ h("div", {
4260
+ className: tn.buttons,
4261
+ role: "group",
4262
+ "aria-label": "Side panel",
4263
+ children: L.map((e) => /* @__PURE__ */ h(C, {
4264
+ size: "micro",
4265
+ variant: O === e.value ? "secondary" : "ghost",
4266
+ "aria-pressed": O === e.value,
4267
+ iconLeft: /* @__PURE__ */ h(e.icon, {}),
4268
+ onClick: () => k(e.value),
4269
+ children: e.label
4270
+ }, e.value))
4271
+ }), z = (e) => {
4272
+ A && O === e ? j(!1) : (k(e), j(!0));
4273
+ }, B = /* @__PURE__ */ g("div", {
4274
+ className: tn.side,
4275
+ children: [!T && /* @__PURE__ */ h("div", {
4276
+ className: tn.sideHead,
4277
+ children: R
4278
+ }), /* @__PURE__ */ g("div", {
4279
+ className: tn.sidePanels,
4280
+ children: [/* @__PURE__ */ h("div", {
4281
+ className: tn.sideBody,
4282
+ hidden: O !== "filters",
4283
+ children: e
4284
+ }), /* @__PURE__ */ h("div", {
4285
+ className: `${tn.sideBody} ${tn.assistant}`,
4286
+ hidden: O !== "assistant",
4287
+ children: D.question ? /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h("div", {
4288
+ className: tn.assistantHead,
4289
+ children: /* @__PURE__ */ h(C, {
4290
+ variant: "ghost",
4291
+ size: "micro",
4292
+ iconLeft: /* @__PURE__ */ h(J, {}),
4293
+ onClick: D.newConversation,
4294
+ children: x.newConversation
4295
+ })
4296
+ }), /* @__PURE__ */ h(en, {
4297
+ ...D.panelProps,
4298
+ followUps: !0,
4299
+ fill: !0,
4300
+ className: tn.askFill
4301
+ }, D.run)] }) : /* @__PURE__ */ h(on, {
4302
+ intro: i,
4303
+ examples: a,
4304
+ onAsk: F,
4305
+ onExample: I,
4306
+ placeholder: x.composer
4307
+ })
4308
+ })]
4309
+ })]
4310
+ });
4311
+ return /* @__PURE__ */ h("div", {
4312
+ className: `${tn.wrapper} ${b}`,
4313
+ ref: w,
4314
+ children: /* @__PURE__ */ g(S, {
4315
+ className: tn.component,
4316
+ children: [/* @__PURE__ */ g("div", {
4317
+ className: tn.main,
4318
+ children: [
4319
+ /* @__PURE__ */ h("div", {
4320
+ className: tn.header,
4321
+ children: /* @__PURE__ */ h(Ye, {
4322
+ showFocus: !1,
4323
+ className: tn.searchInput,
4324
+ autoFocus: _,
4325
+ askOffer: u === "row" ? "door" : "chip",
4326
+ ...D.inputProps,
4327
+ onAsk: P,
4328
+ ...p ? { placeholder: p } : {}
4329
+ })
4330
+ }),
4331
+ T && /* @__PURE__ */ g("div", {
4332
+ className: tn.mobileBar,
4333
+ children: [A && /* @__PURE__ */ h(C, {
4334
+ variant: "secondary",
4335
+ size: "micro",
4336
+ className: tn.mobileBack,
4337
+ onClick: () => j(!1),
4338
+ children: x.showResults
4339
+ }), L.map((e) => /* @__PURE__ */ h(C, {
4340
+ size: "micro",
4341
+ variant: A && O === e.value ? "primary" : "ghost",
4342
+ "aria-pressed": A && O === e.value,
4343
+ iconLeft: /* @__PURE__ */ h(e.icon, {}),
4344
+ onClick: () => z(e.value),
4345
+ children: e.label
4346
+ }, e.value))]
4347
+ }),
4348
+ T && A && /* @__PURE__ */ h("div", {
4349
+ className: tn.mobilePanel,
4350
+ children: B
4351
+ }),
4352
+ /* @__PURE__ */ g("div", {
4353
+ className: tn.body,
4354
+ hidden: T && A,
4355
+ children: [
4356
+ u === "row" && D.offerShown && /* @__PURE__ */ h(Ve, {
4357
+ searchOrAsk: E,
4358
+ onAsk: P,
4359
+ words: d,
4360
+ className: tn.offer
4361
+ }),
4362
+ D.waiting && /* @__PURE__ */ h(sn, { text: x.searching }),
4363
+ /* @__PURE__ */ h("div", {
4364
+ hidden: D.waiting,
4365
+ children: /* @__PURE__ */ h(ft, {
4366
+ ...n,
4367
+ searchOrAsk: E,
4368
+ children: t
4369
+ })
4370
+ })
4371
+ ]
4372
+ })
4373
+ ]
4374
+ }), !T && /* @__PURE__ */ h("div", {
4375
+ className: tn.column,
4376
+ children: /* @__PURE__ */ h("div", {
4377
+ className: tn.frame,
4378
+ children: B
4379
+ })
4380
+ })]
4381
+ })
4382
+ });
4383
+ }
4384
+ var ln = {
4385
+ page: "_page_1kcpg_5",
4386
+ head: "_head_1kcpg_6",
4387
+ title: "_title_1kcpg_7",
4388
+ muted: "_muted_1kcpg_8",
4389
+ spacer: "_spacer_1kcpg_9",
4390
+ mode: "_mode_1kcpg_10",
4391
+ grid: "_grid_1kcpg_11",
4392
+ single: "_single_1kcpg_12",
4393
+ left: "_left_1kcpg_13",
4394
+ right: "_right_1kcpg_14",
4395
+ answer: "_answer_1kcpg_17",
4396
+ narrowBar: "_narrowBar_1kcpg_20",
4397
+ narrowLeft: "_narrowLeft_1kcpg_21"
4398
+ }, un = {
4399
+ filters: "Filters",
4400
+ backToSearch: "Back to search",
4401
+ assistant: "Assistant",
4402
+ searching: "The assistant is searching…"
4403
+ };
4404
+ function dn({ title: e, filters: t, renderResult: n, results: r, mode: i, examples: a, restore: o, words: s, labels: u, placeholder: d, autoFocus: f = !0, narrowBelow: p = 860, onJudged: _, className: v = "" }) {
4405
+ let y = {
4406
+ ...un,
4407
+ ...u
4408
+ }, b = c(null), x = an(b, p), { state: S, setQuery: w } = Ce(), T = Re({ mode: i }), E = Gt({
4409
+ searchOrAsk: T,
4410
+ restore: o
4411
+ }), [D, O] = l(!1);
4412
+ rn(_, T);
4413
+ let k = !!E.question && (!E.proactive || S.query.trim() === E.question);
4414
+ return /* @__PURE__ */ g("div", {
4415
+ className: `${ln.page} ${k ? ln.asking : ""} ${v}`,
4416
+ ref: b,
4417
+ children: [k ? /* @__PURE__ */ g("div", {
4418
+ className: ln.head,
4419
+ children: [
4420
+ /* @__PURE__ */ h(C, {
4421
+ variant: "ghost",
4422
+ size: "micro",
4423
+ iconLeft: /* @__PURE__ */ h(q, {}),
4424
+ onClick: () => {
4425
+ let e = E.question;
4426
+ E.newConversation(), e && w(e);
4427
+ },
4428
+ children: y.backToSearch
4429
+ }),
4430
+ /* @__PURE__ */ h("span", { className: ln.spacer }),
4431
+ /* @__PURE__ */ g("span", {
4432
+ className: ln.mode,
4433
+ children: [
4434
+ /* @__PURE__ */ h(G, {
4435
+ size: 14,
4436
+ color: "currentColor"
4437
+ }),
4438
+ " ",
4439
+ y.assistant
4440
+ ]
4441
+ })
4442
+ ]
4443
+ }) : e && /* @__PURE__ */ g("div", {
4444
+ className: ln.head,
4445
+ children: [/* @__PURE__ */ h("span", {
4446
+ className: ln.title,
4447
+ children: e
4448
+ }), S.totalDocumentCount != null && /* @__PURE__ */ h("span", {
4449
+ className: ln.muted,
4450
+ children: S.totalDocumentCount.toLocaleString("en")
4451
+ })]
4452
+ }), /* @__PURE__ */ g("div", {
4453
+ className: `${ln.grid} ${x || k ? ln.single : ""}`,
4454
+ children: [!k && !x && t && /* @__PURE__ */ h("aside", {
4455
+ className: ln.left,
4456
+ children: t
4457
+ }), /* @__PURE__ */ g("section", {
4458
+ className: ln.right,
4459
+ children: [
4460
+ !k && /* @__PURE__ */ g(m, { children: [
4461
+ /* @__PURE__ */ h(Ye, {
4462
+ showFocus: !1,
4463
+ autoFocus: f,
4464
+ askOffer: "door",
4465
+ ...E.inputProps,
4466
+ ...d ? { placeholder: d } : {}
4467
+ }),
4468
+ x && t && /* @__PURE__ */ h("div", {
4469
+ className: ln.narrowBar,
4470
+ children: /* @__PURE__ */ h(C, {
4471
+ variant: D ? "secondary" : "ghost",
4472
+ size: "micro",
4473
+ "aria-expanded": D,
4474
+ iconLeft: /* @__PURE__ */ h(oe, {}),
4475
+ onClick: () => O((e) => !e),
4476
+ children: y.filters
4477
+ })
4478
+ }),
4479
+ x && D && t && /* @__PURE__ */ h("div", {
4480
+ className: ln.narrowLeft,
4481
+ children: t
4482
+ }),
4483
+ E.offerShown && /* @__PURE__ */ h(Ve, {
4484
+ searchOrAsk: T,
4485
+ onAsk: E.ask,
4486
+ words: s
4487
+ }),
4488
+ !E.question && !S.query.trim() && a && a.length > 0 && /* @__PURE__ */ h(V, {
4489
+ items: a,
4490
+ onPick: E.askExample
4491
+ })
4492
+ ] }),
4493
+ E.question && /* @__PURE__ */ h("div", {
4494
+ className: ln.answer,
4495
+ hidden: !k,
4496
+ children: /* @__PURE__ */ h(en, {
4497
+ ...E.panelProps,
4498
+ followUps: !0
4499
+ }, E.run)
4500
+ }),
4501
+ k && E.waiting && /* @__PURE__ */ h(B, {
4502
+ spinner: "searching",
4503
+ children: y.searching
4504
+ }),
4505
+ /* @__PURE__ */ h("div", {
4506
+ hidden: k && E.waiting,
4507
+ children: /* @__PURE__ */ h(ft, {
4508
+ ...r,
4509
+ searchOrAsk: T,
4510
+ children: n
4511
+ })
4512
+ })
4513
+ ]
4514
+ })]
4515
+ })]
4516
+ });
4517
+ }
4518
+ // src/components/QuickAnswer.tsx
4519
+ var fn = ({ labels: e, ...t }) => /* @__PURE__ */ h(Ve, {
4520
+ ...t,
4521
+ words: e && ((t) => ({
4522
+ text: t.row === "hint" ? e.hint : t.row === "thinking" ? e.thinking : void 0,
4523
+ action: t.row === "ready" ? e.ready : void 0
4524
+ }))
4525
+ }), pn = {
4526
+ panel: "_panel_mv793_2",
4527
+ empty: "_empty_mv793_3",
4528
+ intro: "_intro_mv793_5"
4529
+ }, mn = ({ title: e = "Help", launcherLabel: t = "Ask", intro: n, examples: r, actions: i, onSourceClick: a, open: o, onOpenChange: s, defaultOpen: c = !1, corner: u = "bottom-right", contained: d = !1, placeholder: f = "Ask a question…", className: p = "" }) => {
4530
+ let [_, v] = l(null), [y, b] = l(0), [x, S] = l(""), T = (e) => {
4531
+ let t = e.trim();
4532
+ t && (S(""), v(t), b((e) => e + 1));
4533
+ };
4534
+ return /* @__PURE__ */ h(w, {
4535
+ className: p,
4536
+ title: /* @__PURE__ */ g(m, { children: [
4537
+ /* @__PURE__ */ h(G, {
4538
+ size: 14,
4539
+ color: "currentColor"
4540
+ }),
4541
+ " ",
4542
+ e
4543
+ ] }),
4544
+ "aria-label": e,
4545
+ label: t,
4546
+ open: o,
4547
+ onOpenChange: s,
4548
+ defaultOpen: c,
4549
+ corner: u,
4550
+ contained: d,
4551
+ headerActions: _ && /* @__PURE__ */ h(C, {
4552
+ variant: "ghost",
4553
+ size: "micro",
4554
+ iconLeft: /* @__PURE__ */ h(J, {}),
4555
+ onClick: () => {
4556
+ v(null), b((e) => e + 1);
4557
+ },
4558
+ "aria-label": "New conversation"
4559
+ }),
4560
+ footer: i && i.length > 0 && i.map((e) => /* @__PURE__ */ h(C, {
4561
+ variant: "secondary",
4562
+ size: "micro",
4563
+ onClick: e.onClick,
4564
+ children: e.label
4565
+ }, e.label)),
4566
+ children: _ ? /* @__PURE__ */ h(en, {
4567
+ question: _,
4568
+ followUps: !0,
4569
+ fill: !0,
4570
+ listPicks: !1,
4571
+ onSourceClick: a,
4572
+ className: pn.panel
4573
+ }, y) : /* @__PURE__ */ g("div", {
4574
+ className: pn.empty,
4575
+ children: [
4576
+ n && /* @__PURE__ */ h("p", {
4577
+ className: pn.intro,
4578
+ children: n
4579
+ }),
4580
+ r && r.length > 0 && /* @__PURE__ */ h(V, {
4581
+ items: r,
4582
+ onPick: T
4583
+ }),
4584
+ /* @__PURE__ */ h(k, {
4585
+ value: x,
4586
+ onChange: S,
4587
+ onSend: T,
4588
+ placeholder: f,
4589
+ "aria-label": f
4590
+ })
4591
+ ]
4592
+ })
4593
+ });
3892
4594
  };
3893
- 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 };
4595
+ export { qe as ActiveFiltersPanel, mn as AskChat, Ve as AskOffer, en as AskPanel, Mt as BucketFilterPanel, Te as DEFAULT_THRESHOLDS, _t as FilterPanelSkeleton, $ as IndxApiError, fn as QuickAnswer, kt as RangeFilterPanel, je as STRICT_MATCH, xe as SearchContext, Bt as SearchErrorBoundary, Ye as SearchInput, cn as SearchOrAsk, dn as SearchPage, Se as SearchProvider, tt as SearchResult, mt as SearchResultRow, ft as SearchResults, Qe as SearchResultsMessage, it as SearchResultsSkeleton, zt as SearchSettingsPanel, ue as SearchSetupError, Pt as SortByPanel, St as ValueFilterPanel, Be as defaultOfferWords, de as describeSearchError, De as isIdentifier, ot as localFilters, Ae as nextOffer, we as pageMode, ke as triggers, Wt as useAsk, Gt as useAskFlow, st as useFilterSuggestion, Ht as useHybridSearch, Ce as useSearch, Ce as useSearchContext, Re as useSearchOrAsk, Vt as useVectorSearch };