@indxsearch/intrface 3.11.0 → 3.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/dist/components/FilterPanelNotice.d.ts +11 -0
- package/dist/components/SearchInput.d.ts +4 -0
- package/dist/components/SearchResultsMessage.d.ts +12 -0
- package/dist/context/SearchContext.d.ts +4 -0
- package/dist/context/searchError.d.ts +37 -0
- package/dist/context/useIndxAuth.d.ts +5 -0
- package/dist/context/useSearchExecution.d.ts +4 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.es.js +790 -587
- package/dist/intrface.css +1 -1
- package/package.json +2 -2
package/dist/index.es.js
CHANGED
|
@@ -2,18 +2,128 @@ import "@indxsearch/systm/styles.css";
|
|
|
2
2
|
import e, { Component as t, createContext as n, memo as r, useCallback as i, useContext as a, useEffect as o, useMemo as s, useRef as c, useState as l } from "react";
|
|
3
3
|
import { SystemState as u } from "@indxsearch/indx-types";
|
|
4
4
|
import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
5
|
-
import { Button as m, Checkbox as h,
|
|
6
|
-
import { ArrowDown as
|
|
5
|
+
import { Button as m, Checkbox as h, Chip as g, FilterPanelBase as _, InputField as v, RadioButton as y, SearchField as b, Select as x, Slider as S, ToggleSwitch as C, Tooltip as w } from "@indxsearch/systm";
|
|
6
|
+
import { ArrowDown as T, ArrowRight as E, Cloud as D, Filter as O, Fuzzy_search as k, Hour_glass as A, Indx as j, Key as M, Lock as N, Search as P, Speedometer as F, Warning as I, X_or_error as L } from "@indxsearch/pixl";
|
|
7
|
+
//#region src/context/IndxApiError.ts
|
|
8
|
+
var R = class e extends Error {
|
|
9
|
+
status;
|
|
10
|
+
code;
|
|
11
|
+
problem;
|
|
12
|
+
retryAfterSeconds;
|
|
13
|
+
constructor(e, t, n, r) {
|
|
14
|
+
let i = n?.detail ?? n?.title;
|
|
15
|
+
super(`${e} failed: HTTP ${t}${i ? ` — ${i}` : ""}`), this.name = "IndxApiError", this.status = t, this.code = n?.code, this.problem = n, this.retryAfterSeconds = r;
|
|
16
|
+
}
|
|
17
|
+
get retryable() {
|
|
18
|
+
return this.code === "invalidState" && this.problem?.retryable === !0;
|
|
19
|
+
}
|
|
20
|
+
static async fromResponse(t, n) {
|
|
21
|
+
let r;
|
|
22
|
+
try {
|
|
23
|
+
let e = await n.json();
|
|
24
|
+
e && typeof e == "object" && typeof e.code == "string" ? r = e : e && typeof e == "object" && (r = {
|
|
25
|
+
...e,
|
|
26
|
+
code: ""
|
|
27
|
+
});
|
|
28
|
+
} catch {}
|
|
29
|
+
let i = n.headers?.get?.("Retry-After"), a = i != null && /^\d+$/.test(i) ? Number(i) : void 0;
|
|
30
|
+
return new e(t, n.status, r, a);
|
|
31
|
+
}
|
|
32
|
+
}, z = class extends Error {
|
|
33
|
+
constructor(e) {
|
|
34
|
+
super(e), this.name = "SearchSetupError";
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
function B(e, t) {
|
|
38
|
+
let n = e instanceof Error ? e.message : String(e);
|
|
39
|
+
if (e instanceof z) return {
|
|
40
|
+
kind: "setup",
|
|
41
|
+
message: n,
|
|
42
|
+
technical: n,
|
|
43
|
+
retryable: !1
|
|
44
|
+
};
|
|
45
|
+
if (e instanceof TypeError) return {
|
|
46
|
+
kind: "unreachable",
|
|
47
|
+
message: n,
|
|
48
|
+
technical: "Network error: no response from the server. Check that it is running and that the url is right.",
|
|
49
|
+
retryable: !0
|
|
50
|
+
};
|
|
51
|
+
if (e instanceof R) {
|
|
52
|
+
let r = {
|
|
53
|
+
message: n,
|
|
54
|
+
status: e.status,
|
|
55
|
+
code: e.code,
|
|
56
|
+
retryAfterSeconds: e.retryAfterSeconds
|
|
57
|
+
}, i = e.problem?.detail ?? e.problem?.title, a = (t) => `${e.status}${e.code ? ` ${e.code}` : ""}: ${t}`;
|
|
58
|
+
switch (!0) {
|
|
59
|
+
case e.status === 401: return {
|
|
60
|
+
...r,
|
|
61
|
+
kind: "unauthorized",
|
|
62
|
+
retryable: !1,
|
|
63
|
+
technical: a("the key is invalid or has expired. Create a new one in the web console.")
|
|
64
|
+
};
|
|
65
|
+
case e.status === 403: return {
|
|
66
|
+
...r,
|
|
67
|
+
kind: "forbidden",
|
|
68
|
+
retryable: !1,
|
|
69
|
+
technical: a(`the key does not reach dataset "${t.dataset}" in team "${t.team}".`)
|
|
70
|
+
};
|
|
71
|
+
case e.status === 404: return {
|
|
72
|
+
...r,
|
|
73
|
+
kind: "notFound",
|
|
74
|
+
retryable: !1,
|
|
75
|
+
technical: a(i ?? `no dataset "${t.dataset}" in team "${t.team}".`)
|
|
76
|
+
};
|
|
77
|
+
case e.retryable: return {
|
|
78
|
+
...r,
|
|
79
|
+
kind: "notReady",
|
|
80
|
+
retryable: !0,
|
|
81
|
+
technical: a(`the dataset is ${e.problem?.currentState?.toString().toLowerCase() ?? "not ready"}.`)
|
|
82
|
+
};
|
|
83
|
+
case e.status === 409: return {
|
|
84
|
+
...r,
|
|
85
|
+
kind: "unavailable",
|
|
86
|
+
retryable: !1,
|
|
87
|
+
technical: a(i ?? "the dataset cannot be searched now.")
|
|
88
|
+
};
|
|
89
|
+
case e.status === 429: return {
|
|
90
|
+
...r,
|
|
91
|
+
kind: "rateLimited",
|
|
92
|
+
retryable: !0,
|
|
93
|
+
technical: a(i ?? "too many requests for this key.")
|
|
94
|
+
};
|
|
95
|
+
case e.status >= 500: return {
|
|
96
|
+
...r,
|
|
97
|
+
kind: "server",
|
|
98
|
+
retryable: !0,
|
|
99
|
+
technical: a(i ?? "the server ran into a problem.")
|
|
100
|
+
};
|
|
101
|
+
default: return {
|
|
102
|
+
...r,
|
|
103
|
+
kind: "unknown",
|
|
104
|
+
retryable: !0,
|
|
105
|
+
technical: a(i ?? "the request failed.")
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
kind: "unknown",
|
|
111
|
+
message: n,
|
|
112
|
+
technical: n,
|
|
113
|
+
retryable: !0
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
7
117
|
//#region src/context/useIndxAuth.ts
|
|
8
|
-
function
|
|
9
|
-
let [a, s] = l(null), [c, d] = l(!0), [f, p] = l([]), [m, h] = l([]), [g, _] = l([]), [v, y] = l({}), [b, x] = l({}), [S, C] = l({}), [w, T] = l(0), [E, D] = l(null);
|
|
118
|
+
function V({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebugLogs: i = !1 }) {
|
|
119
|
+
let [a, s] = l(null), [c, d] = l(!0), [f, p] = l([]), [m, h] = l([]), [g, _] = l([]), [v, y] = l({}), [b, x] = l({}), [S, C] = l({}), [w, T] = l(0), [E, D] = l(null), [O, k] = l(null), [A, j] = l(0);
|
|
10
120
|
return o(() => {
|
|
11
121
|
(async () => {
|
|
12
|
-
D(null);
|
|
122
|
+
D(null), k(null), d(!0);
|
|
13
123
|
try {
|
|
14
|
-
if (!r) throw console.error("[Auth] ❌ Missing bearer token"), console.error("[Auth] 💡 Pass preAuthenticatedToken to SearchProvider (create a token on the Indx Dashboard)"),
|
|
15
|
-
if (!e) throw console.error("[Auth] ❌ Missing INDX server URL"), console.error("[Auth] 💡 Pass a url to SearchProvider"),
|
|
16
|
-
if (!n) throw console.error("[Auth] ❌ Missing dataset name"), console.error("[Auth] 💡 Pass dataset=\"your-dataset-name\" to SearchProvider"),
|
|
124
|
+
if (!r) throw console.error("[Auth] ❌ Missing bearer token"), console.error("[Auth] 💡 Pass preAuthenticatedToken to SearchProvider (create a token on the Indx Dashboard)"), new z("A bearer token is required. Check console for instructions.");
|
|
125
|
+
if (!e) throw console.error("[Auth] ❌ Missing INDX server URL"), console.error("[Auth] 💡 Pass a url to SearchProvider"), new z("INDX server URL is required. Check console for instructions.");
|
|
126
|
+
if (!n) throw console.error("[Auth] ❌ Missing dataset name"), console.error("[Auth] 💡 Pass dataset=\"your-dataset-name\" to SearchProvider"), new z("Dataset name is required. Check console for instructions.");
|
|
17
127
|
i && console.log("[Auth] ✅ Using bearer token");
|
|
18
128
|
let a = r, o = (e) => fetch(e, {
|
|
19
129
|
method: "GET",
|
|
@@ -24,14 +134,7 @@ function D({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebugL
|
|
|
24
134
|
});
|
|
25
135
|
i && console.log("[Auth] 🔍 Checking dataset status...");
|
|
26
136
|
let c = await o(`${e}/api/teams/${t}/datasets/${n}/status`);
|
|
27
|
-
if (!c.ok)
|
|
28
|
-
if (c.status === 401) throw 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"), Error("Authentication failed (401). Token may be expired. Check console for instructions.");
|
|
29
|
-
if (c.status === 404) throw 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"), Error("Dataset \"" + n + "\" not found. Check console for instructions.");
|
|
30
|
-
{
|
|
31
|
-
let t = await c.text();
|
|
32
|
-
throw console.error("[Auth] ❌ Failed to get dataset status:", c.status, t), console.error("[Auth] 💡 Check if your INDX server is running at:", e), Error("Failed to connect to INDX server. Check console for details.");
|
|
33
|
-
}
|
|
34
|
-
}
|
|
137
|
+
if (!c.ok) throw c.status === 401 ? (console.error("[Auth] ❌ Authentication failed (401 Unauthorized)"), console.error("[Auth] 💡 Your token may be expired or invalid"), console.error("[Auth] 💡 Create or refresh your token on the Indx Dashboard"), await R.fromResponse("Dataset status", c)) : c.status === 404 ? (console.error("[Auth] ❌ Dataset \"" + n + "\" not found (404)"), console.error("[Auth] 💡 Available datasets can be checked with: curl -X GET \"" + e + "/api/me/datasets\" -H \"Authorization: Bearer YOUR_TOKEN\""), console.error("[Auth] 💡 Make sure you spelled the dataset name correctly"), await R.fromResponse("Dataset status", c)) : (console.error("[Auth] ❌ Failed to get dataset status:", c.status), await R.fromResponse("Dataset status", c));
|
|
35
138
|
let l = await c.json();
|
|
36
139
|
i && console.log("[Auth] 📊 Dataset status:", l), s(a), i && console.log("[Auth] ✅ Dataset session established"), l.systemState !== void 0 && l.systemState !== u.Ready && (console.warn("[Auth] ⚠️ Dataset is not ready yet. Current state:", u[l.systemState]), console.warn("[Auth] 💡 Wait for indexing to complete before searching"));
|
|
37
140
|
let d = l.documentCount ?? l.numberOfRecords ?? 0;
|
|
@@ -42,9 +145,9 @@ function D({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebugL
|
|
|
42
145
|
o(`${e}/api/teams/${t}/datasets/${n}/fields/sortable`),
|
|
43
146
|
o(`${e}/api/teams/${t}/datasets/${n}/fields/configuration`).catch(() => null)
|
|
44
147
|
]);
|
|
45
|
-
if (!f.ok) throw console.error("[Auth] ❌ GetFilterableFields failed:", f.status, await
|
|
46
|
-
if (!m.ok) throw console.error("[Auth] ❌ GetFacetableFields failed:", m.status, await
|
|
47
|
-
if (!g.ok) throw console.error("[Auth] ❌ GetSortableFields failed:", g.status, await
|
|
148
|
+
if (!f.ok) throw console.error("[Auth] ❌ GetFilterableFields failed:", f.status), await R.fromResponse("Filterable fields", f);
|
|
149
|
+
if (!m.ok) throw console.error("[Auth] ❌ GetFacetableFields failed:", m.status), await R.fromResponse("Facetable fields", m);
|
|
150
|
+
if (!g.ok) throw console.error("[Auth] ❌ GetSortableFields failed:", g.status), await R.fromResponse("Sortable fields", g);
|
|
48
151
|
let [b, S, w] = await Promise.all([
|
|
49
152
|
f.json().catch((e) => (console.error("Failed to parse GetFilterableFields response:", e), [])),
|
|
50
153
|
m.json().catch((e) => (console.error("Failed to parse GetFacetableFields response:", e), [])),
|
|
@@ -88,8 +191,11 @@ function D({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebugL
|
|
|
88
191
|
let k = {};
|
|
89
192
|
if (D.facets) for (let [e, t] of Object.entries(D.facets)) Array.isArray(t) && (k[e] = t.map((e) => e.key));
|
|
90
193
|
x(O), C(k), i && console.log("[Auth] ✅ Initialization complete");
|
|
91
|
-
} catch (
|
|
92
|
-
console.error("[Auth] ❌ Initialization failed:",
|
|
194
|
+
} catch (r) {
|
|
195
|
+
console.error("[Auth] ❌ Initialization failed:", r), (r instanceof Error || typeof r == "object" && r && "message" in r) && console.error("[Auth] 💡 Error:", r.message), r instanceof TypeError && r.message.includes("fetch") && (console.error("[Auth] ❌ Network error - cannot connect to INDX server"), console.error("[Auth] 💡 Check if the server is running at:", e), console.error("[Auth] 💡 Check the url you passed to SearchProvider"), console.error("[Auth] 💡 For local development, it should be: http://localhost:5001")), D(r instanceof Error ? r.message : String(r)), k(B(r, {
|
|
196
|
+
team: t,
|
|
197
|
+
dataset: n
|
|
198
|
+
}));
|
|
93
199
|
} finally {
|
|
94
200
|
d(!1);
|
|
95
201
|
}
|
|
@@ -97,11 +203,14 @@ function D({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebugL
|
|
|
97
203
|
}, [
|
|
98
204
|
e,
|
|
99
205
|
t,
|
|
100
|
-
n
|
|
206
|
+
n,
|
|
207
|
+
A
|
|
101
208
|
]), {
|
|
102
209
|
token: a,
|
|
103
210
|
isFetchingInitial: c,
|
|
104
211
|
authError: E,
|
|
212
|
+
authErrorInfo: O,
|
|
213
|
+
retry: () => j((e) => e + 1),
|
|
105
214
|
initialFacetStats: b,
|
|
106
215
|
initialFacetKeys: S,
|
|
107
216
|
filterableFields: f,
|
|
@@ -112,58 +221,31 @@ function D({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebugL
|
|
|
112
221
|
};
|
|
113
222
|
}
|
|
114
223
|
//#endregion
|
|
115
|
-
//#region src/context/IndxApiError.ts
|
|
116
|
-
var O = class e extends Error {
|
|
117
|
-
status;
|
|
118
|
-
code;
|
|
119
|
-
problem;
|
|
120
|
-
retryAfterSeconds;
|
|
121
|
-
constructor(e, t, n, r) {
|
|
122
|
-
let i = n?.detail ?? n?.title;
|
|
123
|
-
super(`${e} failed: HTTP ${t}${i ? ` — ${i}` : ""}`), this.name = "IndxApiError", this.status = t, this.code = n?.code, this.problem = n, this.retryAfterSeconds = r;
|
|
124
|
-
}
|
|
125
|
-
get retryable() {
|
|
126
|
-
return this.code === "invalidState" && this.problem?.retryable === !0;
|
|
127
|
-
}
|
|
128
|
-
static async fromResponse(t, n) {
|
|
129
|
-
let r;
|
|
130
|
-
try {
|
|
131
|
-
let e = await n.json();
|
|
132
|
-
e && typeof e == "object" && typeof e.code == "string" ? r = e : e && typeof e == "object" && (r = {
|
|
133
|
-
...e,
|
|
134
|
-
code: ""
|
|
135
|
-
});
|
|
136
|
-
} catch {}
|
|
137
|
-
let i = n.headers?.get?.("Retry-After"), a = i != null && /^\d+$/.test(i) ? Number(i) : void 0;
|
|
138
|
-
return new e(t, n.status, r, a);
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
//#endregion
|
|
142
224
|
//#region src/context/buildFilterProxy.ts
|
|
143
|
-
async function
|
|
225
|
+
async function H(e, t, n, r, i, a, o) {
|
|
144
226
|
let s = await o(`${r}/api/teams/${i}/datasets/${a}/filters/${e}`, {
|
|
145
227
|
method: "POST",
|
|
146
228
|
headers: { "Content-Type": "application/json" },
|
|
147
229
|
body: JSON.stringify(t)
|
|
148
230
|
});
|
|
149
|
-
if (!s.ok) throw await
|
|
231
|
+
if (!s.ok) throw await R.fromResponse(n, s);
|
|
150
232
|
let c = await s.json();
|
|
151
233
|
if (!c || typeof c.hashString != "string") throw Error(`${n} failed: server returned no filter token`);
|
|
152
234
|
return c;
|
|
153
235
|
}
|
|
154
|
-
async function
|
|
236
|
+
async function U(e, t, n, r, i, a) {
|
|
155
237
|
if (e.length === 0) return null;
|
|
156
238
|
if (e.length === 1) return e[0];
|
|
157
239
|
let o = e[0];
|
|
158
|
-
for (let s = 1; s < e.length; s++) o = await
|
|
240
|
+
for (let s = 1; s < e.length; s++) o = await H("combine", {
|
|
159
241
|
a: o,
|
|
160
242
|
b: e[s],
|
|
161
243
|
useAndOperation: t === "and"
|
|
162
244
|
}, "CombineFilters", n, r, i, a);
|
|
163
245
|
return o;
|
|
164
246
|
}
|
|
165
|
-
async function
|
|
166
|
-
let l = Object.entries(e ?? {}).filter(([, e]) => e.length > 0), u = Object.entries(t ?? {}), d = Object.entries(s ?? {}).filter(([, e]) => e.length > 0), f = (e, { min: t, max: o }) =>
|
|
247
|
+
async function W(e, t, n, r, i, a, o = {}, s = {}, c = {}) {
|
|
248
|
+
let l = Object.entries(e ?? {}).filter(([, e]) => e.length > 0), u = Object.entries(t ?? {}), d = Object.entries(s ?? {}).filter(([, e]) => e.length > 0), f = (e, { min: t, max: o }) => H("range", {
|
|
167
249
|
fieldName: e,
|
|
168
250
|
lowerLimit: t,
|
|
169
251
|
upperLimit: o
|
|
@@ -172,16 +254,16 @@ async function j(e, t, n, r, i, a, o = {}, s = {}, c = {}) {
|
|
|
172
254
|
return Number.isFinite(o) ? f(e, {
|
|
173
255
|
min: o,
|
|
174
256
|
max: o
|
|
175
|
-
}) :
|
|
257
|
+
}) : H("value", {
|
|
176
258
|
fieldName: e,
|
|
177
259
|
value: t
|
|
178
260
|
}, `Value filter '${e}'`, n, r, i, a);
|
|
179
261
|
}, [m, h, g] = await Promise.all([
|
|
180
|
-
Promise.all(l.map(async ([e, t]) =>
|
|
262
|
+
Promise.all(l.map(async ([e, t]) => U(await Promise.all(t.map((t) => p(e, t))), o[e] === "any" ? "or" : "and", n, r, i, a))),
|
|
181
263
|
Promise.all(u.map(([e, t]) => f(e, t))),
|
|
182
|
-
Promise.all(d.map(async ([e, t]) =>
|
|
264
|
+
Promise.all(d.map(async ([e, t]) => U(await Promise.all(t.map((t) => f(e, t))), "or", n, r, i, a)))
|
|
183
265
|
]);
|
|
184
|
-
return
|
|
266
|
+
return U([
|
|
185
267
|
...m,
|
|
186
268
|
...h,
|
|
187
269
|
...g
|
|
@@ -189,13 +271,13 @@ async function j(e, t, n, r, i, a, o = {}, s = {}, c = {}) {
|
|
|
189
271
|
}
|
|
190
272
|
//#endregion
|
|
191
273
|
//#region src/context/useSearchExecution.ts
|
|
192
|
-
function
|
|
274
|
+
function ee(e, t) {
|
|
193
275
|
let n, r = (...r) => {
|
|
194
276
|
clearTimeout(n), n = setTimeout(() => e(...r), t);
|
|
195
277
|
};
|
|
196
278
|
return r.cancel = () => clearTimeout(n), r;
|
|
197
279
|
}
|
|
198
|
-
function
|
|
280
|
+
function G({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team: s, dataset: u, allowEmptySearch: d, facetsEnabled: f, enableDebugLogs: p, shouldFetchMore: m, sessionId: h, source: g, count: _ }) {
|
|
199
281
|
let v = c(0), y = c(void 0), b = c(!1), [x, S] = l({}), [C, w] = l(""), [T, E] = l("");
|
|
200
282
|
o(() => {
|
|
201
283
|
r.isFetchingInitial || t((e) => ({
|
|
@@ -218,7 +300,7 @@ function N({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
218
300
|
r.sortableFields,
|
|
219
301
|
t
|
|
220
302
|
]);
|
|
221
|
-
let D = e.searchSettings.maxNumberOfRecordsToReturn,
|
|
303
|
+
let D = e.searchSettings.maxNumberOfRecordsToReturn, O = e.searchSettings.enableCoverage, k = e.searchSettings.removeDuplicates, A = e.searchSettings.coverageDepth, j = e.searchSettings.minimumScore, M = e.searchSettings.coverageSetup, N = e.sortBy, P = e.sortAscending, F = i(async ({ enableFacets: i }) => {
|
|
222
304
|
if (!r.token) return;
|
|
223
305
|
let o = ++v.current;
|
|
224
306
|
if (t((e) => ({
|
|
@@ -229,7 +311,7 @@ function N({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
229
311
|
i = !0;
|
|
230
312
|
}
|
|
231
313
|
try {
|
|
232
|
-
let c = i ? Array.from(new Set([...Object.keys(e.filters).filter((t) => e.valueMatch[t] === "any" && (e.filters[t]?.length ?? 0) > 0), ...Object.keys(e.bucketFilters).filter((t) => (e.bucketFilters[t]?.length ?? 0) > 0)])) : [], [l, ...f] = await Promise.all([
|
|
314
|
+
let c = i ? Array.from(new Set([...Object.keys(e.filters).filter((t) => e.valueMatch[t] === "any" && (e.filters[t]?.length ?? 0) > 0), ...Object.keys(e.bucketFilters).filter((t) => (e.bucketFilters[t]?.length ?? 0) > 0)])) : [], [l, ...f] = await Promise.all([W(e.filters, e.rangeFilters, a, s, u, n, e.valueMatch, e.bucketFilters, e.fieldTypes), ...c.map((t) => W({
|
|
233
315
|
...e.filters,
|
|
234
316
|
[t]: []
|
|
235
317
|
}, e.rangeFilters, a, s, u, n, e.valueMatch, {
|
|
@@ -237,83 +319,83 @@ function N({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
237
319
|
[t]: []
|
|
238
320
|
}, e.fieldTypes))]), m = d || e.query.trim() !== "", y = {
|
|
239
321
|
text: e.query,
|
|
240
|
-
enableCoverage:
|
|
241
|
-
removeDuplicates:
|
|
242
|
-
coverageDepth:
|
|
243
|
-
coverageSetup:
|
|
322
|
+
enableCoverage: O,
|
|
323
|
+
removeDuplicates: k,
|
|
324
|
+
coverageDepth: A,
|
|
325
|
+
coverageSetup: M
|
|
244
326
|
}, b = {
|
|
245
327
|
...y,
|
|
246
328
|
maxNumberOfRecordsToReturn: m ? D : 0,
|
|
247
329
|
enableFacets: i,
|
|
248
330
|
...l ? { filter: l } : {},
|
|
249
|
-
...
|
|
250
|
-
...
|
|
331
|
+
...N ? { sortBy: N } : {},
|
|
332
|
+
...P === void 0 ? {} : { sortAscending: P }
|
|
251
333
|
};
|
|
252
334
|
p && console.log("[performSearch] request body:", JSON.stringify(b, null, 2));
|
|
253
|
-
let
|
|
254
|
-
g &&
|
|
255
|
-
let
|
|
335
|
+
let F = new URLSearchParams({ session: h });
|
|
336
|
+
g && F.set("source", g), _ || F.set("count", "false");
|
|
337
|
+
let I = (e) => n(`${a}/api/teams/${s}/datasets/${u}/search?${F}`, {
|
|
256
338
|
method: "POST",
|
|
257
339
|
headers: { "Content-Type": "application/json" },
|
|
258
340
|
body: JSON.stringify(e)
|
|
259
|
-
}), [
|
|
341
|
+
}), [L, ...z] = await Promise.all([I(b), ...f.map((e) => I({
|
|
260
342
|
...y,
|
|
261
343
|
maxNumberOfRecordsToReturn: 0,
|
|
262
344
|
enableFacets: !0,
|
|
263
345
|
...e ? { filter: e } : {}
|
|
264
346
|
}))]);
|
|
265
|
-
if (!
|
|
266
|
-
let
|
|
347
|
+
if (!L.ok) throw await R.fromResponse("Search", L);
|
|
348
|
+
let B = await L.json(), V = L.headers.get("Indx-Query-Id") ?? void 0, H = B.truncationIndex ?? -1, U = {};
|
|
267
349
|
for (let e = 0; e < c.length; e++) {
|
|
268
350
|
let t = c[e];
|
|
269
|
-
if (!
|
|
270
|
-
let n = await
|
|
271
|
-
n.facets?.[t] !== void 0 && (
|
|
351
|
+
if (!z[e].ok) throw await R.fromResponse(`Facets for '${t}'`, z[e]);
|
|
352
|
+
let n = await z[e].json();
|
|
353
|
+
n.facets?.[t] !== void 0 && (U[t] = n.facets[t]);
|
|
272
354
|
}
|
|
273
|
-
let ee =
|
|
355
|
+
let ee = B.records || [], G = ee.map((e) => e.documentKey), te = ee.map((e) => e.score), K = [];
|
|
274
356
|
if (m && G.length > 0) {
|
|
275
357
|
let e = await n(`${a}/api/teams/${s}/datasets/${u}/documents/lookup`, {
|
|
276
358
|
method: "POST",
|
|
277
359
|
headers: { "Content-Type": "application/json" },
|
|
278
360
|
body: JSON.stringify(G)
|
|
279
361
|
});
|
|
280
|
-
if (!e.ok) throw await
|
|
362
|
+
if (!e.ok) throw await R.fromResponse("Document lookup", e);
|
|
281
363
|
K = (await e.json()).map((e, t) => ({
|
|
282
364
|
document: e,
|
|
283
365
|
documentKey: G[t],
|
|
284
366
|
score: te[t]
|
|
285
367
|
}));
|
|
286
368
|
}
|
|
287
|
-
let
|
|
288
|
-
if (i &&
|
|
289
|
-
for (let [e, t] of Object.entries(
|
|
369
|
+
let ne = {};
|
|
370
|
+
if (i && B.facets) {
|
|
371
|
+
for (let [e, t] of Object.entries(B.facets)) if (Array.isArray(t) && t.length > 0) {
|
|
290
372
|
let n = t.map((e) => Number(e.key)).filter((e) => !isNaN(e));
|
|
291
|
-
n.length > 0 && (
|
|
373
|
+
n.length > 0 && (ne[e] = {
|
|
292
374
|
min: Math.min(...n),
|
|
293
375
|
max: Math.max(...n)
|
|
294
376
|
});
|
|
295
377
|
}
|
|
296
378
|
}
|
|
297
379
|
if (o !== v.current) return;
|
|
298
|
-
let
|
|
299
|
-
if (
|
|
380
|
+
let q = e.query !== C, re = e.query !== T, ie = e.facetStats ?? {};
|
|
381
|
+
if (q ? (ie = {
|
|
300
382
|
...r.initialFacetStats,
|
|
301
|
-
...
|
|
383
|
+
...ne
|
|
302
384
|
}, S(ie), w(e.query)) : ie = {
|
|
303
385
|
...x,
|
|
304
|
-
...
|
|
386
|
+
...ne
|
|
305
387
|
}, re && i) {
|
|
306
388
|
let n = { ...e.rangeBounds };
|
|
307
|
-
for (let [e, t] of Object.entries(
|
|
389
|
+
for (let [e, t] of Object.entries(ne)) n[e] = t;
|
|
308
390
|
t((e) => ({
|
|
309
391
|
...e,
|
|
310
392
|
rangeBounds: n
|
|
311
393
|
})), E(e.query);
|
|
312
394
|
}
|
|
313
|
-
let J = Object.keys(
|
|
314
|
-
...
|
|
315
|
-
...
|
|
316
|
-
} :
|
|
395
|
+
let J = Object.keys(U).length > 0 ? {
|
|
396
|
+
...B.facets ?? {},
|
|
397
|
+
...U
|
|
398
|
+
} : B.facets;
|
|
317
399
|
if (i && (!J || Object.keys(J).length === 0)) {
|
|
318
400
|
J = {};
|
|
319
401
|
for (let [e, t] of Object.entries(r.initialFacetKeys)) J[e] = t.map((e) => ({
|
|
@@ -323,7 +405,7 @@ function N({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
323
405
|
}
|
|
324
406
|
let Y = K.filter((t) => {
|
|
325
407
|
let n = e.query.trim();
|
|
326
|
-
return n === "" || n.length === 1 ? !0 : t.score >=
|
|
408
|
+
return n === "" || n.length === 1 ? !0 : t.score >= j;
|
|
327
409
|
}).map((e, t) => ({
|
|
328
410
|
...e,
|
|
329
411
|
position: t + 1
|
|
@@ -332,14 +414,15 @@ function N({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
332
414
|
...e,
|
|
333
415
|
results: Y,
|
|
334
416
|
error: void 0,
|
|
417
|
+
errorInfo: void 0,
|
|
335
418
|
resultsSuppressed: !m,
|
|
336
419
|
...i ? {
|
|
337
420
|
facets: J,
|
|
338
421
|
facetStats: ie
|
|
339
422
|
} : {},
|
|
340
423
|
isLoading: !1,
|
|
341
|
-
truncationIndex:
|
|
342
|
-
queryId:
|
|
424
|
+
truncationIndex: H,
|
|
425
|
+
queryId: V
|
|
343
426
|
}));
|
|
344
427
|
} catch (e) {
|
|
345
428
|
if (console.error("[Search] ❌ Search failed:", e), e instanceof TypeError && e.message.includes("fetch") ? (console.error("[Search] ❌ Network error - cannot reach INDX server"), console.error("[Search] 💡 Check if server is running at:", a)) : e instanceof Error && (e.message.includes("401") ? (console.error("[Search] ❌ Authentication failed"), console.error("[Search] 💡 Your token may have expired. Create or refresh it on the Indx Dashboard.")) : e.message.includes("404") ? (console.error("[Search] ❌ Dataset not found"), console.error("[Search] 💡 Check that dataset \"" + u + "\" exists")) : console.error("[Search] 💡 Error:", e.message)), o !== v.current) return;
|
|
@@ -348,7 +431,11 @@ function N({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
348
431
|
results: null,
|
|
349
432
|
isLoading: !1,
|
|
350
433
|
resultsSuppressed: !1,
|
|
351
|
-
error: e instanceof Error ? e.message : "Search failed"
|
|
434
|
+
error: e instanceof Error ? e.message : "Search failed",
|
|
435
|
+
errorInfo: B(e, {
|
|
436
|
+
team: s,
|
|
437
|
+
dataset: u
|
|
438
|
+
})
|
|
352
439
|
}));
|
|
353
440
|
}
|
|
354
441
|
}, [
|
|
@@ -358,14 +445,14 @@ function N({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
358
445
|
e.rangeFilters,
|
|
359
446
|
e.bucketFilters,
|
|
360
447
|
e.facetStats,
|
|
361
|
-
|
|
362
|
-
|
|
448
|
+
N,
|
|
449
|
+
P,
|
|
363
450
|
D,
|
|
451
|
+
O,
|
|
364
452
|
k,
|
|
365
453
|
A,
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
P,
|
|
454
|
+
M,
|
|
455
|
+
j,
|
|
369
456
|
n,
|
|
370
457
|
r.initialFacetStats,
|
|
371
458
|
r.initialFacetKeys,
|
|
@@ -385,13 +472,13 @@ function N({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
385
472
|
_
|
|
386
473
|
]);
|
|
387
474
|
o(() => {
|
|
388
|
-
y.current =
|
|
389
|
-
}, [
|
|
390
|
-
let
|
|
391
|
-
o(() => (
|
|
475
|
+
y.current = F;
|
|
476
|
+
}, [F]);
|
|
477
|
+
let I = c(null);
|
|
478
|
+
o(() => (I.current?.cancel(), I.current = ee(() => {
|
|
392
479
|
p && console.log("Debounced searchWithFacets fired"), y.current?.({ enableFacets: !0 });
|
|
393
480
|
}, e.facetDebounceDelayMillis ?? 500), () => {
|
|
394
|
-
|
|
481
|
+
I.current?.cancel();
|
|
395
482
|
}), [e.facetDebounceDelayMillis]), o(() => {
|
|
396
483
|
!r.isFetchingInitial && r.token && !b.current && (d && y.current?.({ enableFacets: f }), b.current = !0);
|
|
397
484
|
}, [
|
|
@@ -409,8 +496,8 @@ function N({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
409
496
|
}));
|
|
410
497
|
return;
|
|
411
498
|
}
|
|
412
|
-
return i ? (
|
|
413
|
-
|
|
499
|
+
return i ? (I.current?.cancel(), y.current?.({ enableFacets: f })) : f ? (p && console.log("Search fired"), y.current?.({ enableFacets: !1 }), I.current?.()) : y.current?.({ enableFacets: !1 }), () => {
|
|
500
|
+
I.current?.cancel();
|
|
414
501
|
};
|
|
415
502
|
}, [
|
|
416
503
|
e.query,
|
|
@@ -424,14 +511,14 @@ function N({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
424
511
|
if (!b.current || !r.token) return;
|
|
425
512
|
let t = e.query.trim();
|
|
426
513
|
!d && t === "" || y.current?.({ enableFacets: f });
|
|
427
|
-
}, [
|
|
428
|
-
let
|
|
429
|
-
o(() => {
|
|
430
|
-
if (
|
|
431
|
-
|
|
514
|
+
}, [N, P]);
|
|
515
|
+
let L = c(!0), z = c(e.query);
|
|
516
|
+
return o(() => {
|
|
517
|
+
if (L.current) {
|
|
518
|
+
L.current = !1;
|
|
432
519
|
return;
|
|
433
520
|
}
|
|
434
|
-
if (
|
|
521
|
+
if (z.current !== e.query || !b.current || !r.token) return;
|
|
435
522
|
if (m.current) {
|
|
436
523
|
m.current = !1, y.current?.({ enableFacets: !1 });
|
|
437
524
|
return;
|
|
@@ -440,23 +527,25 @@ function N({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team
|
|
|
440
527
|
!d && t === "" || y.current?.({ enableFacets: f });
|
|
441
528
|
}, [
|
|
442
529
|
D,
|
|
530
|
+
O,
|
|
443
531
|
k,
|
|
444
532
|
A,
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
P
|
|
533
|
+
M,
|
|
534
|
+
j
|
|
448
535
|
]), o(() => {
|
|
449
|
-
|
|
450
|
-
}, [e.query])
|
|
536
|
+
z.current = e.query;
|
|
537
|
+
}, [e.query]), { retrySearch: i(() => {
|
|
538
|
+
y.current?.({ enableFacets: f });
|
|
539
|
+
}, [f]) };
|
|
451
540
|
}
|
|
452
541
|
//#endregion
|
|
453
542
|
//#region src/context/SearchContext.tsx
|
|
454
|
-
function
|
|
543
|
+
function te() {
|
|
455
544
|
let e = globalThis.crypto;
|
|
456
545
|
return e?.randomUUID ? e.randomUUID() : Math.random().toString(36).slice(2) + Date.now().toString(36);
|
|
457
546
|
}
|
|
458
|
-
var
|
|
459
|
-
let x = c(!1), S = c(
|
|
547
|
+
var K = n(void 0), ne = ({ children: e, url: t, team: n, dataset: r, allowEmptySearch: a = !1, maxResults: s = 10, facetDebounceDelayMillis: u = 500, enableFacets: d = !0, coverageDepth: p, removeDuplicates: m = !0, enableCoverage: h = !0, initialCoverageSetup: g = {}, enableDebugLogs: _ = !1, preAuthenticatedToken: v, source: y, count: b = !0 }) => {
|
|
548
|
+
let x = c(!1), S = c(te()).current, C = c(s), [w, T] = l({
|
|
460
549
|
query: "",
|
|
461
550
|
results: null,
|
|
462
551
|
isLoading: !1,
|
|
@@ -493,27 +582,26 @@ var F = n(void 0), I = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
493
582
|
facetDebounceDelayMillis: u
|
|
494
583
|
}));
|
|
495
584
|
}, [u]);
|
|
496
|
-
let [E] = l(d),
|
|
585
|
+
let [E] = l(d), D = V({
|
|
497
586
|
url: t,
|
|
498
587
|
team: n,
|
|
499
588
|
dataset: r,
|
|
500
589
|
preAuthenticatedToken: v,
|
|
501
590
|
enableDebugLogs: _
|
|
502
|
-
}),
|
|
503
|
-
if (!
|
|
591
|
+
}), O = i((e, t = {}) => {
|
|
592
|
+
if (!D.token) throw Error("No authentication token available");
|
|
504
593
|
return fetch(e, {
|
|
505
594
|
...t,
|
|
506
595
|
headers: {
|
|
507
596
|
...t.headers,
|
|
508
|
-
Authorization: `Bearer ${
|
|
597
|
+
Authorization: `Bearer ${D.token}`
|
|
509
598
|
}
|
|
510
599
|
});
|
|
511
|
-
}, [
|
|
512
|
-
N({
|
|
600
|
+
}, [D.token]), { retrySearch: k } = G({
|
|
513
601
|
state: w,
|
|
514
602
|
setState: T,
|
|
515
|
-
authenticatedFetch:
|
|
516
|
-
auth:
|
|
603
|
+
authenticatedFetch: O,
|
|
604
|
+
auth: D,
|
|
517
605
|
url: t,
|
|
518
606
|
team: n,
|
|
519
607
|
dataset: r,
|
|
@@ -524,12 +612,11 @@ var F = n(void 0), I = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
524
612
|
sessionId: S,
|
|
525
613
|
source: y,
|
|
526
614
|
count: b
|
|
527
|
-
});
|
|
528
|
-
let A = c(void 0);
|
|
615
|
+
}), A = c(void 0);
|
|
529
616
|
A.current = w.queryId;
|
|
530
617
|
let j = i(async (e) => {
|
|
531
|
-
if (
|
|
532
|
-
let i = await
|
|
618
|
+
if (D.token) try {
|
|
619
|
+
let i = await O(`${t}/api/teams/${n}/datasets/${r}/events/select`, {
|
|
533
620
|
method: "POST",
|
|
534
621
|
headers: { "Content-Type": "application/json" },
|
|
535
622
|
body: JSON.stringify({
|
|
@@ -544,8 +631,8 @@ var F = n(void 0), I = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
544
631
|
_ && console.warn("[select] failed:", e);
|
|
545
632
|
}
|
|
546
633
|
}, [
|
|
547
|
-
|
|
548
|
-
|
|
634
|
+
D.token,
|
|
635
|
+
O,
|
|
549
636
|
t,
|
|
550
637
|
n,
|
|
551
638
|
r,
|
|
@@ -566,12 +653,12 @@ var F = n(void 0), I = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
566
653
|
}
|
|
567
654
|
};
|
|
568
655
|
});
|
|
569
|
-
}, []),
|
|
656
|
+
}, []), N = i((e) => {
|
|
570
657
|
T((t) => ({
|
|
571
658
|
...t,
|
|
572
659
|
facetDebounceDelayMillis: e
|
|
573
660
|
}));
|
|
574
|
-
}, []),
|
|
661
|
+
}, []), P = i((e) => {
|
|
575
662
|
typeof e.maxNumberOfRecordsToReturn == "number" && (C.current = e.maxNumberOfRecordsToReturn), T((t) => {
|
|
576
663
|
let n = {
|
|
577
664
|
...t.searchSettings,
|
|
@@ -585,7 +672,7 @@ var F = n(void 0), I = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
585
672
|
searchSettings: n
|
|
586
673
|
};
|
|
587
674
|
});
|
|
588
|
-
}, []),
|
|
675
|
+
}, []), F = i((e) => {
|
|
589
676
|
x.current = !0, T((t) => ({
|
|
590
677
|
...t,
|
|
591
678
|
searchSettings: {
|
|
@@ -593,7 +680,7 @@ var F = n(void 0), I = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
593
680
|
maxNumberOfRecordsToReturn: e
|
|
594
681
|
}
|
|
595
682
|
}));
|
|
596
|
-
}, []),
|
|
683
|
+
}, []), I = i((e, t, n = !1) => {
|
|
597
684
|
T((r) => {
|
|
598
685
|
let i = { ...r.filters }, a = i[e] || [], o = a.includes(t) ? a.filter((e) => e !== t) : n ? [t] : [...a, t];
|
|
599
686
|
return o.length ? i[e] = o : delete i[e], {
|
|
@@ -602,7 +689,7 @@ var F = n(void 0), I = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
602
689
|
filterRevision: r.filterRevision + 1
|
|
603
690
|
};
|
|
604
691
|
});
|
|
605
|
-
}, []),
|
|
692
|
+
}, []), L = i((e, t) => {
|
|
606
693
|
T((n) => n.valueMatch[e] === t ? n : {
|
|
607
694
|
...n,
|
|
608
695
|
valueMatch: {
|
|
@@ -610,7 +697,7 @@ var F = n(void 0), I = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
610
697
|
[e]: t
|
|
611
698
|
}
|
|
612
699
|
});
|
|
613
|
-
}, []),
|
|
700
|
+
}, []), R = i((e, t, n) => {
|
|
614
701
|
T((r) => ({
|
|
615
702
|
...r,
|
|
616
703
|
rangeFilters: {
|
|
@@ -622,7 +709,7 @@ var F = n(void 0), I = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
622
709
|
},
|
|
623
710
|
filterRevision: r.filterRevision + 1
|
|
624
711
|
}));
|
|
625
|
-
}, []),
|
|
712
|
+
}, []), z = i(() => {
|
|
626
713
|
T((e) => ({
|
|
627
714
|
...e,
|
|
628
715
|
filters: {},
|
|
@@ -630,7 +717,7 @@ var F = n(void 0), I = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
630
717
|
bucketFilters: {},
|
|
631
718
|
filterRevision: e.filterRevision + 1
|
|
632
719
|
}));
|
|
633
|
-
}, []),
|
|
720
|
+
}, []), B = i((e, t, n = !0) => {
|
|
634
721
|
T((r) => {
|
|
635
722
|
let i = { ...r.filters }, a = (i[e] || []).filter((e) => e !== t);
|
|
636
723
|
return a.length > 0 ? i[e] = a : delete i[e], {
|
|
@@ -639,7 +726,7 @@ var F = n(void 0), I = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
639
726
|
filterRevision: r.filterRevision + +!!n
|
|
640
727
|
};
|
|
641
728
|
});
|
|
642
|
-
}, []),
|
|
729
|
+
}, []), H = i((e, t = !0) => {
|
|
643
730
|
T((n) => {
|
|
644
731
|
if (!(e in n.rangeFilters)) return n;
|
|
645
732
|
let r = { ...n.rangeFilters };
|
|
@@ -649,90 +736,209 @@ var F = n(void 0), I = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
649
736
|
filterRevision: n.filterRevision + +!!t
|
|
650
737
|
};
|
|
651
738
|
});
|
|
652
|
-
}, []),
|
|
739
|
+
}, []), U = (e, t) => e.min === t.min && e.max === t.max, W = i((e, t, n = !1) => {
|
|
653
740
|
T((r) => {
|
|
654
|
-
let i = r.bucketFilters[e] ?? [], a = i.some((e) =>
|
|
741
|
+
let i = r.bucketFilters[e] ?? [], a = i.some((e) => U(e, t)) ? i.filter((e) => !U(e, t)) : n ? [t] : [...i, t], o = { ...r.bucketFilters };
|
|
655
742
|
return a.length > 0 ? o[e] = a : delete o[e], {
|
|
656
743
|
...r,
|
|
657
744
|
bucketFilters: o,
|
|
658
745
|
filterRevision: r.filterRevision + 1
|
|
659
746
|
};
|
|
660
747
|
});
|
|
661
|
-
}, []),
|
|
748
|
+
}, []), ee = i((e, t, n = !0) => {
|
|
662
749
|
T((r) => {
|
|
663
|
-
let i = { ...r.bucketFilters }, a = t ? (i[e] ?? []).filter((e) => !
|
|
750
|
+
let i = { ...r.bucketFilters }, a = t ? (i[e] ?? []).filter((e) => !U(e, t)) : [];
|
|
664
751
|
return a.length > 0 ? i[e] = a : delete i[e], {
|
|
665
752
|
...r,
|
|
666
753
|
bucketFilters: i,
|
|
667
754
|
filterRevision: r.filterRevision + +!!n
|
|
668
755
|
};
|
|
669
756
|
});
|
|
670
|
-
}, []),
|
|
757
|
+
}, []), ne = i((e, t) => {
|
|
671
758
|
T((n) => ({
|
|
672
759
|
...n,
|
|
673
760
|
sortBy: e || void 0,
|
|
674
761
|
sortAscending: e ? t : void 0
|
|
675
762
|
}));
|
|
676
763
|
}, []);
|
|
677
|
-
return /* @__PURE__ */ f(
|
|
764
|
+
return /* @__PURE__ */ f(K.Provider, {
|
|
678
765
|
value: {
|
|
679
766
|
state: w,
|
|
680
|
-
isFetchingInitial:
|
|
681
|
-
authError:
|
|
767
|
+
isFetchingInitial: D.isFetchingInitial || !w.fieldsSeeded,
|
|
768
|
+
authError: D.authError ?? void 0,
|
|
769
|
+
authErrorInfo: D.authErrorInfo ?? void 0,
|
|
770
|
+
retry: D.authError ? D.retry : k,
|
|
682
771
|
allowEmptySearch: a,
|
|
683
772
|
url: t,
|
|
684
773
|
team: n,
|
|
685
774
|
dataset: r,
|
|
686
|
-
authenticatedFetch:
|
|
775
|
+
authenticatedFetch: O,
|
|
687
776
|
setQuery: M,
|
|
688
|
-
toggleFilter:
|
|
689
|
-
setValueMatch:
|
|
690
|
-
setRangeFilter:
|
|
691
|
-
resetFilters:
|
|
692
|
-
resetSingleFilter:
|
|
693
|
-
resetRangeFilter:
|
|
694
|
-
toggleBucketFilter:
|
|
695
|
-
resetBucketFilter:
|
|
696
|
-
setSort:
|
|
697
|
-
setDebounceDelay:
|
|
698
|
-
setSearchSettings:
|
|
699
|
-
fetchMoreResults:
|
|
777
|
+
toggleFilter: I,
|
|
778
|
+
setValueMatch: L,
|
|
779
|
+
setRangeFilter: R,
|
|
780
|
+
resetFilters: z,
|
|
781
|
+
resetSingleFilter: B,
|
|
782
|
+
resetRangeFilter: H,
|
|
783
|
+
toggleBucketFilter: W,
|
|
784
|
+
resetBucketFilter: ee,
|
|
785
|
+
setSort: ne,
|
|
786
|
+
setDebounceDelay: N,
|
|
787
|
+
setSearchSettings: P,
|
|
788
|
+
fetchMoreResults: F,
|
|
700
789
|
selectResult: j,
|
|
701
790
|
sessionId: S
|
|
702
791
|
},
|
|
703
792
|
children: e
|
|
704
793
|
});
|
|
705
|
-
},
|
|
706
|
-
let e = a(
|
|
794
|
+
}, q = () => {
|
|
795
|
+
let e = a(K);
|
|
707
796
|
if (!e) throw Error("useSearchContext must be used within a SearchProvider");
|
|
708
797
|
return e;
|
|
709
|
-
},
|
|
710
|
-
let { state: { query:
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
return /* @__PURE__ */
|
|
798
|
+
}, re = ({ className: e = "", autoFocus: t = !1, inputSize: n = "default", showClear: r = !0, showFocus: i = !1, showStatus: a = !0, ...o }) => {
|
|
799
|
+
let { state: { query: s, filters: c, rangeFilters: l, bucketFilters: u, results: d, truncationIndex: h, searchSettings: _ }, setQuery: v, resetFilters: y } = q(), x = Object.values(c).reduce((e, t) => e + t.length, 0) + Object.keys(l).length + Object.values(u ?? {}).reduce((e, t) => e + t.length, 0), S = s.length > 0, C = S && d !== null && d.length === 0, T = S && _.enableCoverage && d !== null && d.length > 0 && h === -1, E = () => {
|
|
800
|
+
v(""), x > 0 && y();
|
|
801
|
+
};
|
|
802
|
+
return /* @__PURE__ */ p(b, {
|
|
714
803
|
type: "text",
|
|
715
|
-
value:
|
|
716
|
-
onChange: (e) =>
|
|
717
|
-
placeholder:
|
|
804
|
+
value: s,
|
|
805
|
+
onChange: (e) => v(e.target.value),
|
|
806
|
+
placeholder: _.placeholderText,
|
|
718
807
|
autoFocus: t,
|
|
719
808
|
className: e,
|
|
720
809
|
showSearchIcon: !0,
|
|
721
810
|
inputSize: n,
|
|
722
811
|
showFocusBorder: i,
|
|
723
|
-
...
|
|
724
|
-
children:
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
812
|
+
...o,
|
|
813
|
+
children: [
|
|
814
|
+
a && C && /* @__PURE__ */ f(g, { children: "No results" }),
|
|
815
|
+
a && T && /* @__PURE__ */ f(w, {
|
|
816
|
+
content: "No direct match. Showing the nearest results.",
|
|
817
|
+
children: /* @__PURE__ */ f("span", { children: /* @__PURE__ */ f(g, {
|
|
818
|
+
icon: /* @__PURE__ */ f(k, {}),
|
|
819
|
+
children: "Nearest"
|
|
820
|
+
}) })
|
|
821
|
+
}),
|
|
822
|
+
a && x > 0 && /* @__PURE__ */ f(w, {
|
|
823
|
+
content: `${x} filter${x === 1 ? "" : "s"} active`,
|
|
824
|
+
children: /* @__PURE__ */ f("span", { children: /* @__PURE__ */ f(g, {
|
|
825
|
+
icon: /* @__PURE__ */ f(O, {}),
|
|
826
|
+
color: "var(--CLightBlue)",
|
|
827
|
+
textColor: "#080809",
|
|
828
|
+
children: x
|
|
829
|
+
}) })
|
|
830
|
+
}),
|
|
831
|
+
r && (S || x > 0) && /* @__PURE__ */ f(m, {
|
|
832
|
+
variant: "ghost",
|
|
833
|
+
size: "micro",
|
|
834
|
+
onClick: E,
|
|
835
|
+
"aria-label": x > 0 ? "Clear search and filters" : "Clear search",
|
|
836
|
+
children: "Clear"
|
|
837
|
+
})
|
|
838
|
+
]
|
|
731
839
|
});
|
|
732
|
-
},
|
|
840
|
+
}, ie = {
|
|
841
|
+
message: "_message_1mgfk_1",
|
|
842
|
+
icon: "_icon_1mgfk_10",
|
|
843
|
+
title: "_title_1mgfk_15",
|
|
844
|
+
detail: "_detail_1mgfk_20",
|
|
845
|
+
technical: "_technical_1mgfk_25",
|
|
846
|
+
button: "_button_1mgfk_33"
|
|
847
|
+
}, J = {
|
|
848
|
+
unreachable: {
|
|
849
|
+
icon: D,
|
|
850
|
+
title: "Search is unavailable",
|
|
851
|
+
detail: "The search server can’t be reached right now."
|
|
852
|
+
},
|
|
853
|
+
unauthorized: {
|
|
854
|
+
icon: M,
|
|
855
|
+
title: "Search is unavailable",
|
|
856
|
+
detail: "The search key was not accepted."
|
|
857
|
+
},
|
|
858
|
+
forbidden: {
|
|
859
|
+
icon: N,
|
|
860
|
+
title: "Search is unavailable",
|
|
861
|
+
detail: "This search key doesn’t have access to these results."
|
|
862
|
+
},
|
|
863
|
+
notFound: {
|
|
864
|
+
icon: P,
|
|
865
|
+
title: "Nothing to search here",
|
|
866
|
+
detail: "The collection this page searches doesn’t exist."
|
|
867
|
+
},
|
|
868
|
+
notReady: {
|
|
869
|
+
icon: A,
|
|
870
|
+
title: "Search is getting ready",
|
|
871
|
+
detail: "Results will appear in a moment."
|
|
872
|
+
},
|
|
873
|
+
unavailable: {
|
|
874
|
+
icon: I,
|
|
875
|
+
title: "Search is unavailable",
|
|
876
|
+
detail: "The collection can’t be searched right now."
|
|
877
|
+
},
|
|
878
|
+
rateLimited: {
|
|
879
|
+
icon: F,
|
|
880
|
+
title: "Too many searches",
|
|
881
|
+
detail: "Wait a moment, then try again."
|
|
882
|
+
},
|
|
883
|
+
server: {
|
|
884
|
+
icon: I,
|
|
885
|
+
title: "Something went wrong",
|
|
886
|
+
detail: "The search server ran into a problem."
|
|
887
|
+
},
|
|
888
|
+
setup: {
|
|
889
|
+
icon: I,
|
|
890
|
+
title: "Search isn’t set up",
|
|
891
|
+
detail: "This page is missing part of its search setup."
|
|
892
|
+
},
|
|
893
|
+
unknown: {
|
|
894
|
+
icon: I,
|
|
895
|
+
title: "Something went wrong",
|
|
896
|
+
detail: "The search couldn’t be completed."
|
|
897
|
+
}
|
|
898
|
+
}, Y = ({ error: e, onRetry: t, hideTechnical: n = !1 }) => {
|
|
899
|
+
let { icon: r, title: i, detail: a } = J[e.kind];
|
|
900
|
+
o(() => {
|
|
901
|
+
if (e.kind !== "notReady" || !t) return;
|
|
902
|
+
let n = setTimeout(t, (e.retryAfterSeconds ?? 2) * 1e3);
|
|
903
|
+
return () => clearTimeout(n);
|
|
904
|
+
}, [e, t]);
|
|
905
|
+
let s = e.retryable && e.kind !== "notReady" && t;
|
|
906
|
+
return /* @__PURE__ */ p("div", {
|
|
907
|
+
className: ie.message,
|
|
908
|
+
role: "alert",
|
|
909
|
+
children: [
|
|
910
|
+
/* @__PURE__ */ f("span", {
|
|
911
|
+
className: ie.icon,
|
|
912
|
+
children: /* @__PURE__ */ f(r, {
|
|
913
|
+
size: 70,
|
|
914
|
+
color: "var(--lv4)"
|
|
915
|
+
})
|
|
916
|
+
}),
|
|
917
|
+
/* @__PURE__ */ f("div", {
|
|
918
|
+
className: ie.title,
|
|
919
|
+
children: i
|
|
920
|
+
}),
|
|
921
|
+
/* @__PURE__ */ f("div", {
|
|
922
|
+
className: ie.detail,
|
|
923
|
+
children: a
|
|
924
|
+
}),
|
|
925
|
+
!n && /* @__PURE__ */ f("code", {
|
|
926
|
+
className: ie.technical,
|
|
927
|
+
children: e.technical
|
|
928
|
+
}),
|
|
929
|
+
s && /* @__PURE__ */ f(m, {
|
|
930
|
+
variant: "secondary",
|
|
931
|
+
size: "micro",
|
|
932
|
+
className: ie.button,
|
|
933
|
+
onClick: t,
|
|
934
|
+
children: "Try again"
|
|
935
|
+
})
|
|
936
|
+
]
|
|
937
|
+
});
|
|
938
|
+
}, ae = {
|
|
733
939
|
placeholder: "_placeholder_ee9qi_1",
|
|
734
940
|
invalid: "_invalid_ee9qi_11"
|
|
735
|
-
},
|
|
941
|
+
}, oe = {
|
|
736
942
|
row: "_row_1i201_1",
|
|
737
943
|
content: "_content_1i201_19",
|
|
738
944
|
indexNumber: "_indexNumber_1i201_31",
|
|
@@ -741,25 +947,25 @@ var F = n(void 0), I = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
741
947
|
skeletonBarLg: "_skeletonBarLg_1i201_59",
|
|
742
948
|
fade: "_fade_1i201_1",
|
|
743
949
|
skeletonBarSm: "_skeletonBarSm_1i201_66"
|
|
744
|
-
},
|
|
745
|
-
className:
|
|
950
|
+
}, se = ({ skeleton: e = !1, index: t, score: n, showScore: r = !1, children: i, skeletonDelay: a = 0, skeletonWidths: o = [62, 38] }) => /* @__PURE__ */ p("div", {
|
|
951
|
+
className: oe.row,
|
|
746
952
|
children: [
|
|
747
953
|
t !== void 0 && /* @__PURE__ */ f("div", {
|
|
748
|
-
className:
|
|
954
|
+
className: oe.indexNumber,
|
|
749
955
|
children: t
|
|
750
956
|
}),
|
|
751
957
|
/* @__PURE__ */ f("div", {
|
|
752
|
-
className:
|
|
958
|
+
className: oe.content,
|
|
753
959
|
children: e ? /* @__PURE__ */ p("div", {
|
|
754
|
-
className:
|
|
960
|
+
className: oe.skeletonBars,
|
|
755
961
|
children: [/* @__PURE__ */ f("div", {
|
|
756
|
-
className:
|
|
962
|
+
className: oe.skeletonBarLg,
|
|
757
963
|
style: {
|
|
758
964
|
width: `${o[0]}%`,
|
|
759
965
|
animationDelay: `${a}s`
|
|
760
966
|
}
|
|
761
967
|
}), /* @__PURE__ */ f("div", {
|
|
762
|
-
className:
|
|
968
|
+
className: oe.skeletonBarSm,
|
|
763
969
|
style: {
|
|
764
970
|
width: `${o[1]}%`,
|
|
765
971
|
animationDelay: `${a + .05}s`
|
|
@@ -768,14 +974,14 @@ var F = n(void 0), I = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
768
974
|
}) : i
|
|
769
975
|
}),
|
|
770
976
|
r && n !== void 0 && /* @__PURE__ */ f("div", {
|
|
771
|
-
className:
|
|
977
|
+
className: oe.scoreNumber,
|
|
772
978
|
children: n
|
|
773
979
|
})
|
|
774
980
|
]
|
|
775
|
-
}),
|
|
981
|
+
}), ce = {
|
|
776
982
|
wrapper: "_wrapper_81m3c_6",
|
|
777
983
|
skeletonAppear: "_skeletonAppear_81m3c_1"
|
|
778
|
-
},
|
|
984
|
+
}, le = [
|
|
779
985
|
[62, 38],
|
|
780
986
|
[75, 45],
|
|
781
987
|
[58, 33],
|
|
@@ -784,68 +990,69 @@ var F = n(void 0), I = ({ children: e, url: t, team: n, dataset: r, allowEmptySe
|
|
|
784
990
|
[55, 35],
|
|
785
991
|
[72, 40],
|
|
786
992
|
[60, 30]
|
|
787
|
-
],
|
|
788
|
-
className:
|
|
789
|
-
children: Array.from({ length: e }).map((e, t) => /* @__PURE__ */ f(
|
|
993
|
+
], ue = ({ rows: e = 6 }) => /* @__PURE__ */ f("div", {
|
|
994
|
+
className: ce.wrapper,
|
|
995
|
+
children: Array.from({ length: e }).map((e, t) => /* @__PURE__ */ f(se, {
|
|
790
996
|
skeleton: !0,
|
|
791
997
|
skeletonDelay: t * .1,
|
|
792
|
-
skeletonWidths:
|
|
998
|
+
skeletonWidths: le[t % le.length]
|
|
793
999
|
}, t))
|
|
794
|
-
}),
|
|
795
|
-
function
|
|
1000
|
+
}), de = /^\[\s*(?:'[^']*'(?:\s*,\s*'[^']*')*)?\s*\]$/;
|
|
1001
|
+
function fe(e) {
|
|
796
1002
|
let t = e.trim();
|
|
797
1003
|
if (!t.startsWith("[") || !t.endsWith("]")) return;
|
|
798
1004
|
try {
|
|
799
1005
|
let e = JSON.parse(t);
|
|
800
1006
|
if (Array.isArray(e)) return e.map((e) => String(e));
|
|
801
1007
|
} catch {}
|
|
802
|
-
if (!
|
|
1008
|
+
if (!de.test(t)) return;
|
|
803
1009
|
let n = [], r = /'([^']*)'/g, i;
|
|
804
1010
|
for (; (i = r.exec(t)) !== null;) n.push(i[1]);
|
|
805
1011
|
return n;
|
|
806
1012
|
}
|
|
807
|
-
var
|
|
808
|
-
let { state: { results: i, resultsSuppressed: a, searchSettings: s, truncationIndex: u, query: h, error: g }, isFetchingInitial:
|
|
1013
|
+
var pe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r }) => {
|
|
1014
|
+
let { state: { results: i, resultsSuppressed: a, searchSettings: s, truncationIndex: u, query: h, error: g, errorInfo: _ }, isFetchingInitial: v, authError: y, authErrorInfo: b, retry: x, allowEmptySearch: S, fetchMoreResults: C, selectResult: w } = q(), T = t ?? 30, [E, D] = l(T), O = c(0), k = c("");
|
|
809
1015
|
o(() => {
|
|
810
|
-
let e = h !==
|
|
811
|
-
(!i || i.length <
|
|
1016
|
+
let e = h !== k.current;
|
|
1017
|
+
(!i || i.length < O.current || e) && D(T), O.current = i?.length ?? 0, k.current = h;
|
|
812
1018
|
}, [
|
|
813
1019
|
i,
|
|
814
|
-
|
|
1020
|
+
T,
|
|
815
1021
|
h
|
|
816
1022
|
]);
|
|
817
|
-
let
|
|
818
|
-
let e =
|
|
819
|
-
|
|
1023
|
+
let A = i && i.length > E, M = () => {
|
|
1024
|
+
let e = E + T;
|
|
1025
|
+
D(e), i && e >= i.length && (!u || u === -1 || u > i.length) && C(i.length + T);
|
|
820
1026
|
};
|
|
821
|
-
if (
|
|
822
|
-
className:
|
|
823
|
-
children: /* @__PURE__ */ f(
|
|
1027
|
+
if (v) return S ? /* @__PURE__ */ f(ue, { rows: T }) : /* @__PURE__ */ f("div", {
|
|
1028
|
+
className: ae.placeholder,
|
|
1029
|
+
children: /* @__PURE__ */ f(j, {
|
|
824
1030
|
size: 200,
|
|
825
1031
|
color: "var(--lv5)"
|
|
826
1032
|
})
|
|
827
1033
|
});
|
|
828
|
-
let
|
|
829
|
-
return
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
1034
|
+
let N = y ?? g;
|
|
1035
|
+
return N ? /* @__PURE__ */ f(Y, {
|
|
1036
|
+
error: (y ? b : _) ?? {
|
|
1037
|
+
kind: "unknown",
|
|
1038
|
+
message: N,
|
|
1039
|
+
technical: N,
|
|
1040
|
+
retryable: !1
|
|
1041
|
+
},
|
|
1042
|
+
onRetry: x
|
|
833
1043
|
}) : a || i === null ? /* @__PURE__ */ f("div", {
|
|
834
|
-
className:
|
|
835
|
-
children: /* @__PURE__ */ f(
|
|
1044
|
+
className: ae.placeholder,
|
|
1045
|
+
children: /* @__PURE__ */ f(j, {
|
|
836
1046
|
size: 200,
|
|
837
1047
|
color: "var(--lv5)"
|
|
838
1048
|
})
|
|
839
|
-
}) : i.length === 0 ? /* @__PURE__ */ f("div", {
|
|
840
|
-
className: z.invalid,
|
|
841
|
-
children: /* @__PURE__ */ f("p", { children: "No results found." })
|
|
842
|
-
}) : /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("div", { children: (i ?? []).slice(0, C).map((t, i) => {
|
|
1049
|
+
}) : i.length === 0 ? null : /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("div", { children: (i ?? []).slice(0, E).map((t, i) => {
|
|
843
1050
|
let a = t.document, o = t.score, c;
|
|
844
1051
|
try {
|
|
845
1052
|
c = typeof a == "string" ? JSON.parse(a) : a;
|
|
846
1053
|
} catch {
|
|
847
1054
|
return /* @__PURE__ */ f("div", {
|
|
848
|
-
className:
|
|
1055
|
+
className: ae.invalid,
|
|
849
1056
|
children: /* @__PURE__ */ f("p", { children: "Invalid JSON" })
|
|
850
1057
|
}, i);
|
|
851
1058
|
}
|
|
@@ -857,20 +1064,20 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
857
1064
|
if (n) for (let e in l) {
|
|
858
1065
|
let t = l[e];
|
|
859
1066
|
if (typeof t == "string") {
|
|
860
|
-
let n =
|
|
1067
|
+
let n = fe(t);
|
|
861
1068
|
n && (l[e] = n);
|
|
862
1069
|
}
|
|
863
1070
|
}
|
|
864
|
-
return /* @__PURE__ */ f(
|
|
1071
|
+
return /* @__PURE__ */ f(se, {
|
|
865
1072
|
index: i,
|
|
866
1073
|
score: o,
|
|
867
1074
|
showScore: s.showScore,
|
|
868
1075
|
children: r(l, {
|
|
869
1076
|
result: t,
|
|
870
|
-
select: () =>
|
|
1077
|
+
select: () => w?.(t) ?? Promise.resolve()
|
|
871
1078
|
})
|
|
872
1079
|
}, i);
|
|
873
|
-
}) }),
|
|
1080
|
+
}) }), A && /* @__PURE__ */ f("div", {
|
|
874
1081
|
style: {
|
|
875
1082
|
textAlign: "center",
|
|
876
1083
|
marginTop: "20px"
|
|
@@ -878,17 +1085,17 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
878
1085
|
children: /* @__PURE__ */ f(m, {
|
|
879
1086
|
variant: "secondary",
|
|
880
1087
|
size: "micro",
|
|
881
|
-
onClick:
|
|
882
|
-
children: h.trim() === "" ? "Load more" : u !== -1 && u !== void 0 && u > 0 ? `Load results ${
|
|
1088
|
+
onClick: M,
|
|
1089
|
+
children: h.trim() === "" ? "Load more" : u !== -1 && u !== void 0 && u > 0 ? `Load results ${E + 1}-${Math.min(E + T, i.length, u)} of ${u}` : "Load more"
|
|
883
1090
|
})
|
|
884
1091
|
})] });
|
|
885
|
-
},
|
|
1092
|
+
}, me = {
|
|
886
1093
|
row: "_row_ujwhc_1",
|
|
887
1094
|
title: "_title_ujwhc_8"
|
|
888
|
-
},
|
|
889
|
-
className: [
|
|
1095
|
+
}, he = ({ variant: e = "default", children: t }) => /* @__PURE__ */ f("div", {
|
|
1096
|
+
className: [me.row, e === "title" ? me.title : ""].filter(Boolean).join(" "),
|
|
890
1097
|
children: t
|
|
891
|
-
}),
|
|
1098
|
+
}), ge = {
|
|
892
1099
|
bar: "_bar_4nxla_12",
|
|
893
1100
|
skeletonAppear: "_skeletonAppear_4nxla_1",
|
|
894
1101
|
fade: "_fade_4nxla_1",
|
|
@@ -898,7 +1105,7 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
898
1105
|
inputRow: "_inputRow_4nxla_40",
|
|
899
1106
|
inputBar: "_inputBar_4nxla_45",
|
|
900
1107
|
histogramRow: "_histogramRow_4nxla_55"
|
|
901
|
-
},
|
|
1108
|
+
}, _e = [
|
|
902
1109
|
65,
|
|
903
1110
|
80,
|
|
904
1111
|
55,
|
|
@@ -907,37 +1114,37 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
907
1114
|
75,
|
|
908
1115
|
50,
|
|
909
1116
|
68
|
|
910
|
-
],
|
|
1117
|
+
], ve = ({ title: e, rows: t = 5, variant: n = "list", withHistogram: r = !1, collapsible: i = !0, startCollapsed: a = !1 }) => /* @__PURE__ */ f(_, {
|
|
911
1118
|
title: e,
|
|
912
1119
|
collapsible: i,
|
|
913
1120
|
collapsed: a,
|
|
914
1121
|
children: n === "slider" ? /* @__PURE__ */ p("div", {
|
|
915
|
-
className:
|
|
1122
|
+
className: ge.sliderArea,
|
|
916
1123
|
children: [
|
|
917
|
-
r && /* @__PURE__ */ f("div", { className:
|
|
918
|
-
/* @__PURE__ */ f("div", { className:
|
|
1124
|
+
r && /* @__PURE__ */ f("div", { className: ge.histogramRow }),
|
|
1125
|
+
/* @__PURE__ */ f("div", { className: ge.sliderTrack }),
|
|
919
1126
|
/* @__PURE__ */ p("div", {
|
|
920
|
-
className:
|
|
1127
|
+
className: ge.inputRow,
|
|
921
1128
|
children: [/* @__PURE__ */ f("div", {
|
|
922
|
-
className:
|
|
1129
|
+
className: ge.inputBar,
|
|
923
1130
|
style: { animationDelay: "0.1s" }
|
|
924
1131
|
}), /* @__PURE__ */ f("div", {
|
|
925
|
-
className:
|
|
1132
|
+
className: ge.inputBar,
|
|
926
1133
|
style: { animationDelay: "0.15s" }
|
|
927
1134
|
})]
|
|
928
1135
|
})
|
|
929
1136
|
]
|
|
930
1137
|
}) : /* @__PURE__ */ f("div", {
|
|
931
|
-
className:
|
|
1138
|
+
className: ge.listRows,
|
|
932
1139
|
children: Array.from({ length: t }).map((e, t) => /* @__PURE__ */ f("div", {
|
|
933
|
-
className:
|
|
1140
|
+
className: ge.bar,
|
|
934
1141
|
style: {
|
|
935
|
-
width: `${
|
|
1142
|
+
width: `${_e[t % _e.length]}%`,
|
|
936
1143
|
animationDelay: `${t * .05}s`
|
|
937
1144
|
}
|
|
938
1145
|
}, t))
|
|
939
1146
|
})
|
|
940
|
-
}),
|
|
1147
|
+
}), X = {
|
|
941
1148
|
list: "_list_18vbb_2",
|
|
942
1149
|
count: "_count_18vbb_7",
|
|
943
1150
|
countValue: "_countValue_18vbb_17",
|
|
@@ -945,8 +1152,30 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
945
1152
|
chipLabel: "_chipLabel_18vbb_32",
|
|
946
1153
|
grid: "_grid_18vbb_40",
|
|
947
1154
|
active: "_active_18vbb_54"
|
|
948
|
-
},
|
|
949
|
-
|
|
1155
|
+
}, ye = {
|
|
1156
|
+
notice: "_notice_4sel0_1",
|
|
1157
|
+
technical: "_technical_4sel0_9"
|
|
1158
|
+
}, be = ({ label: e, field: t, missing: n }) => {
|
|
1159
|
+
let r = n.map((e) => e[0].toUpperCase() + e.slice(1)).join(" and ");
|
|
1160
|
+
return o(() => {
|
|
1161
|
+
console.warn(`[intrface] The panel for "${t}" is hidden: the field is not ${r}. Mark it ${r} in the dataset's field configuration (web console → Fields).`);
|
|
1162
|
+
}, [t, r]), /* @__PURE__ */ f(_, {
|
|
1163
|
+
title: e ?? t,
|
|
1164
|
+
collapsible: !1,
|
|
1165
|
+
children: /* @__PURE__ */ p("div", {
|
|
1166
|
+
className: ye.notice,
|
|
1167
|
+
children: [/* @__PURE__ */ f("span", { children: "Not available" }), /* @__PURE__ */ p("code", {
|
|
1168
|
+
className: ye.technical,
|
|
1169
|
+
children: [
|
|
1170
|
+
t,
|
|
1171
|
+
": not ",
|
|
1172
|
+
r
|
|
1173
|
+
]
|
|
1174
|
+
})]
|
|
1175
|
+
})
|
|
1176
|
+
});
|
|
1177
|
+
}, xe = ({ field: e, label: t, preserveBlankFacetState: n = !1, preserveBlankFacetStateOrder: r = !1, sortFacetsBy: i = "histogram", limit: a = 10, collapsible: s = !0, startCollapsed: u = !1, control: d, displayType: g, layout: v = "list", showActivePanel: b = !1, showCount: x = !0, showNull: S = !1, match: w = "all", displayIfEmptyQuery: T = !0, displayCondition: E = (e) => !0 }) => {
|
|
1178
|
+
let { state: { facets: D, filterableFields: O, facetableFields: k, filters: A, query: j }, toggleFilter: M, setValueMatch: N, authError: P, isFetchingInitial: F, allowEmptySearch: I } = q(), L = d ?? g ?? "checkbox", R = L === "radio" ? "any" : w;
|
|
950
1179
|
o(() => {
|
|
951
1180
|
N(e, R);
|
|
952
1181
|
}, [
|
|
@@ -957,11 +1186,11 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
957
1186
|
let z = c(null), [B, V] = l(a);
|
|
958
1187
|
if (o(() => {
|
|
959
1188
|
V(a);
|
|
960
|
-
}, [D?.[e], a]), !
|
|
961
|
-
if (
|
|
1189
|
+
}, [D?.[e], a]), !I && !j || P) return null;
|
|
1190
|
+
if (F || !D) return L === "toggle" ? /* @__PURE__ */ f(ve, {
|
|
962
1191
|
rows: 1,
|
|
963
1192
|
collapsible: !1
|
|
964
|
-
}) : /* @__PURE__ */ f(
|
|
1193
|
+
}) : /* @__PURE__ */ f(ve, {
|
|
965
1194
|
title: t,
|
|
966
1195
|
rows: Math.min(a, 6),
|
|
967
1196
|
collapsible: s,
|
|
@@ -973,25 +1202,14 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
973
1202
|
facets: D
|
|
974
1203
|
}) || !T && !j && Object.keys(A).length < 1) return null;
|
|
975
1204
|
if (!O?.includes(e) || !k?.includes(e)) {
|
|
976
|
-
let
|
|
977
|
-
return O?.includes(e) ||
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
color: "red",
|
|
982
|
-
fontSize: "12px"
|
|
983
|
-
},
|
|
984
|
-
children: [
|
|
985
|
-
"Cannot render filter for \"",
|
|
986
|
-
e,
|
|
987
|
-
"\": missing ",
|
|
988
|
-
t.join(" and "),
|
|
989
|
-
"."
|
|
990
|
-
]
|
|
991
|
-
})
|
|
1205
|
+
let n = [];
|
|
1206
|
+
return O?.includes(e) || n.push("filterable"), k?.includes(e) || n.push("facetable"), /* @__PURE__ */ f(be, {
|
|
1207
|
+
label: t,
|
|
1208
|
+
field: e,
|
|
1209
|
+
missing: n
|
|
992
1210
|
});
|
|
993
1211
|
}
|
|
994
|
-
let H = D?.[e] ?? (
|
|
1212
|
+
let H = D?.[e] ?? (L === "toggle" ? [] : void 0);
|
|
995
1213
|
if (!H || !Array.isArray(H)) return null;
|
|
996
1214
|
let U = A?.[e] ?? [];
|
|
997
1215
|
n && !z.current && H.length > 0 && (z.current = H.reduce((e, t) => (e[t.key] = t.value, e), {}));
|
|
@@ -1005,16 +1223,16 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
1005
1223
|
"true",
|
|
1006
1224
|
"false",
|
|
1007
1225
|
"null"
|
|
1008
|
-
]), G = Array.from(W.keys()), te =
|
|
1226
|
+
]), G = Array.from(W.keys()), te = L === "toggle" && (G.length > 0 && G.every((e) => ee.has(e)) || G.length === 0 && U.length > 0);
|
|
1009
1227
|
if (te && W.has("null")) {
|
|
1010
1228
|
let e = W.get("null") ?? 0, t = W.get("false") ?? 0;
|
|
1011
1229
|
W.set("false", t + e), W.delete("null");
|
|
1012
1230
|
}
|
|
1013
|
-
if (
|
|
1231
|
+
if (L === "toggle" && !te) return /* @__PURE__ */ f(_, {
|
|
1014
1232
|
collapsible: !1,
|
|
1015
1233
|
children: /* @__PURE__ */ f("div", {
|
|
1016
|
-
className:
|
|
1017
|
-
children: /* @__PURE__ */ f(
|
|
1234
|
+
className: X.count,
|
|
1235
|
+
children: /* @__PURE__ */ f(C, {
|
|
1018
1236
|
label: t,
|
|
1019
1237
|
checked: !1,
|
|
1020
1238
|
onChange: () => {},
|
|
@@ -1024,12 +1242,12 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
1024
1242
|
});
|
|
1025
1243
|
if (te) {
|
|
1026
1244
|
let n = W.get("true"), r = typeof n == "number" ? n : null, i = U.includes("true"), a = r === 0 && !i, o = x && (r ?? 0) > 0 ? `${r}` : "";
|
|
1027
|
-
return /* @__PURE__ */ f(
|
|
1245
|
+
return /* @__PURE__ */ f(_, {
|
|
1028
1246
|
collapsible: !1,
|
|
1029
1247
|
children: /* @__PURE__ */ p("div", {
|
|
1030
|
-
className:
|
|
1248
|
+
className: X.count,
|
|
1031
1249
|
children: [
|
|
1032
|
-
/* @__PURE__ */ f(
|
|
1250
|
+
/* @__PURE__ */ f(C, {
|
|
1033
1251
|
label: t,
|
|
1034
1252
|
checked: i,
|
|
1035
1253
|
onChange: () => M(e, "true"),
|
|
@@ -1042,7 +1260,7 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
1042
1260
|
});
|
|
1043
1261
|
}
|
|
1044
1262
|
let K = Array.from(W.entries());
|
|
1045
|
-
if (
|
|
1263
|
+
if (S || (K = K.filter(([e]) => e !== "null")), K.length === 0 && !n) return null;
|
|
1046
1264
|
if (!r) if (i === "alphabetical") {
|
|
1047
1265
|
let e = K.filter(([, e]) => typeof e == "number" && e > 0).sort(([e], [t]) => e.localeCompare(t)), t = K.filter(([, e]) => e === 0 || e === null).sort(([e], [t]) => e.localeCompare(t));
|
|
1048
1266
|
K = [...e, ...t];
|
|
@@ -1056,24 +1274,24 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
1056
1274
|
let e = K.filter(([, e]) => typeof e == "number" && e > 0), t = K.filter(([, e]) => e === 0 || e === null);
|
|
1057
1275
|
K = [...e, ...t];
|
|
1058
1276
|
}
|
|
1059
|
-
let
|
|
1060
|
-
let r = U.includes(t), i = n === 0, a = x && (n ?? 0) > 0 ? ` (${n})` : "", o = x && (n ?? 0) > 0 ? n : "", s = () => M(e, t,
|
|
1061
|
-
switch (
|
|
1062
|
-
case "button": return
|
|
1063
|
-
className:
|
|
1277
|
+
let ne = typeof a == "number" && K.length > a, re = ne ? K.slice(0, B) : K, ie = (t, n) => {
|
|
1278
|
+
let r = U.includes(t), i = n === 0, a = x && (n ?? 0) > 0 ? ` (${n})` : "", o = x && (n ?? 0) > 0 ? n : "", s = () => M(e, t, L === "radio");
|
|
1279
|
+
switch (L) {
|
|
1280
|
+
case "button": return v === "list" ? /* @__PURE__ */ p("div", {
|
|
1281
|
+
className: X.count,
|
|
1064
1282
|
children: [/* @__PURE__ */ f(m, {
|
|
1065
1283
|
variant: r ? "primary" : "secondary",
|
|
1066
1284
|
onClick: s,
|
|
1067
1285
|
disabled: i,
|
|
1068
1286
|
size: "micro",
|
|
1069
|
-
className:
|
|
1287
|
+
className: X.chip,
|
|
1070
1288
|
title: t,
|
|
1071
1289
|
children: /* @__PURE__ */ f("span", {
|
|
1072
|
-
className:
|
|
1290
|
+
className: X.chipLabel,
|
|
1073
1291
|
children: t
|
|
1074
1292
|
})
|
|
1075
1293
|
}), /* @__PURE__ */ f("span", {
|
|
1076
|
-
className:
|
|
1294
|
+
className: X.countValue,
|
|
1077
1295
|
children: o
|
|
1078
1296
|
})]
|
|
1079
1297
|
}) : /* @__PURE__ */ f(m, {
|
|
@@ -1081,39 +1299,39 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
1081
1299
|
onClick: s,
|
|
1082
1300
|
disabled: i,
|
|
1083
1301
|
size: "micro",
|
|
1084
|
-
className:
|
|
1302
|
+
className: X.chip,
|
|
1085
1303
|
title: `${t}${a}`,
|
|
1086
1304
|
children: /* @__PURE__ */ f("span", {
|
|
1087
|
-
className:
|
|
1305
|
+
className: X.chipLabel,
|
|
1088
1306
|
children: `${t}${a}`
|
|
1089
1307
|
})
|
|
1090
1308
|
});
|
|
1091
|
-
case "toggle": return /* @__PURE__ */ f(
|
|
1309
|
+
case "toggle": return /* @__PURE__ */ f(C, {
|
|
1092
1310
|
label: t,
|
|
1093
1311
|
checked: r,
|
|
1094
1312
|
onChange: s,
|
|
1095
1313
|
disabled: i
|
|
1096
1314
|
});
|
|
1097
1315
|
case "radio": {
|
|
1098
|
-
let n = /* @__PURE__ */ f(
|
|
1316
|
+
let n = /* @__PURE__ */ f(y, {
|
|
1099
1317
|
id: `${e}-${t}`,
|
|
1100
1318
|
name: e,
|
|
1101
1319
|
value: t,
|
|
1102
|
-
label:
|
|
1320
|
+
label: v === "grid" ? `${t}${a}` : t,
|
|
1103
1321
|
checked: r,
|
|
1104
1322
|
onChange: s,
|
|
1105
1323
|
disabled: i
|
|
1106
1324
|
});
|
|
1107
|
-
return
|
|
1108
|
-
className:
|
|
1325
|
+
return v === "list" ? /* @__PURE__ */ p("div", {
|
|
1326
|
+
className: X.count,
|
|
1109
1327
|
children: [n, /* @__PURE__ */ f("span", {
|
|
1110
|
-
className:
|
|
1328
|
+
className: X.countValue,
|
|
1111
1329
|
children: o
|
|
1112
1330
|
})]
|
|
1113
1331
|
}) : n;
|
|
1114
1332
|
}
|
|
1115
|
-
default: return
|
|
1116
|
-
className:
|
|
1333
|
+
default: return v === "list" ? /* @__PURE__ */ p("div", {
|
|
1334
|
+
className: X.count,
|
|
1117
1335
|
children: [/* @__PURE__ */ f(h, {
|
|
1118
1336
|
label: t,
|
|
1119
1337
|
score: "",
|
|
@@ -1121,7 +1339,7 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
1121
1339
|
onChange: s,
|
|
1122
1340
|
disabled: i
|
|
1123
1341
|
}), /* @__PURE__ */ f("span", {
|
|
1124
|
-
className:
|
|
1342
|
+
className: X.countValue,
|
|
1125
1343
|
children: o
|
|
1126
1344
|
})]
|
|
1127
1345
|
}) : /* @__PURE__ */ f(h, {
|
|
@@ -1133,22 +1351,22 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
1133
1351
|
});
|
|
1134
1352
|
}
|
|
1135
1353
|
};
|
|
1136
|
-
return /* @__PURE__ */ f(
|
|
1354
|
+
return /* @__PURE__ */ f(_, {
|
|
1137
1355
|
title: t,
|
|
1138
1356
|
collapsible: s,
|
|
1139
1357
|
collapsed: s ? u : !1,
|
|
1140
|
-
className: b && U.length > 0 ?
|
|
1358
|
+
className: b && U.length > 0 ? X.active : void 0,
|
|
1141
1359
|
children: /* @__PURE__ */ p("ul", {
|
|
1142
|
-
className:
|
|
1360
|
+
className: v === "grid" ? X.grid : X.list,
|
|
1143
1361
|
style: {
|
|
1144
1362
|
listStyle: "none",
|
|
1145
1363
|
padding: 0,
|
|
1146
1364
|
margin: 0
|
|
1147
1365
|
},
|
|
1148
|
-
children: [
|
|
1366
|
+
children: [re.map(([e, t]) => /* @__PURE__ */ f("li", { children: ie(e, t) }, e)), ne && B < K.length && (() => {
|
|
1149
1367
|
let e = K.length - B, t = Math.min(50, e);
|
|
1150
1368
|
return /* @__PURE__ */ f("li", {
|
|
1151
|
-
className:
|
|
1369
|
+
className: X.toggleItem,
|
|
1152
1370
|
children: /* @__PURE__ */ f(m, {
|
|
1153
1371
|
variant: "ghost",
|
|
1154
1372
|
size: "micro",
|
|
@@ -1159,7 +1377,7 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
1159
1377
|
})()]
|
|
1160
1378
|
})
|
|
1161
1379
|
});
|
|
1162
|
-
},
|
|
1380
|
+
}, Z = {
|
|
1163
1381
|
disabledMessage: "_disabledMessage_adany_1",
|
|
1164
1382
|
histogram: "_histogram_adany_6",
|
|
1165
1383
|
histogramLayer: "_histogramLayer_adany_14",
|
|
@@ -1173,219 +1391,219 @@ var te = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, children: r
|
|
|
1173
1391
|
};
|
|
1174
1392
|
//#endregion
|
|
1175
1393
|
//#region src/utils/numeric.ts
|
|
1176
|
-
function
|
|
1394
|
+
function Se(e) {
|
|
1177
1395
|
if (!Number.isFinite(e)) return 0;
|
|
1178
1396
|
let t = String(e), n = t.indexOf(".");
|
|
1179
1397
|
return n === -1 ? 0 : Math.min(6, t.length - n - 1);
|
|
1180
1398
|
}
|
|
1181
|
-
function
|
|
1399
|
+
function Ce(e) {
|
|
1182
1400
|
let t = 0;
|
|
1183
|
-
for (let n of e) t = Math.max(t,
|
|
1401
|
+
for (let n of e) t = Math.max(t, Se(n));
|
|
1184
1402
|
return t === 0 ? 1 : Number((10 ** -t).toFixed(t));
|
|
1185
1403
|
}
|
|
1186
|
-
function
|
|
1187
|
-
return Number(e.toFixed(
|
|
1404
|
+
function Q(e, t) {
|
|
1405
|
+
return Number(e.toFixed(Se(t)));
|
|
1188
1406
|
}
|
|
1189
1407
|
//#endregion
|
|
1190
1408
|
//#region src/components/RangeFilterPanel.tsx
|
|
1191
|
-
function
|
|
1409
|
+
function we(e, t, n) {
|
|
1192
1410
|
let r = t + Math.round((e - t) / n) * n;
|
|
1193
|
-
return Number(r.toFixed(
|
|
1411
|
+
return Number(r.toFixed(Se(n)));
|
|
1194
1412
|
}
|
|
1195
|
-
function
|
|
1413
|
+
function Te(e, t, n) {
|
|
1196
1414
|
let r = Math.ceil(Number(((e - t) / n).toFixed(6)));
|
|
1197
|
-
return Number((t + r * n).toFixed(
|
|
1415
|
+
return Number((t + r * n).toFixed(Se(n)));
|
|
1198
1416
|
}
|
|
1199
|
-
var
|
|
1200
|
-
let { state: { rangeFilters:
|
|
1417
|
+
var Ee = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, control: a, displayType: o, showActivePanel: s = !1, collapsible: c = !0, startCollapsed: l = !1, showHistogram: u = !1, resolution: d, step: m, stepMarks: h }) => {
|
|
1418
|
+
let { state: { rangeFilters: g, rangeBounds: y, facetStats: b, facets: x, filterableFields: C, facetableFields: w, query: T, facetDebounceDelayMillis: E }, setRangeFilter: D, resetRangeFilter: O, allowEmptySearch: k, authError: A, isFetchingInitial: j } = q(), M = a ?? o ?? "input", N = y?.[t] !== void 0, P = y?.[t] ?? {
|
|
1201
1419
|
min: r,
|
|
1202
1420
|
max: i
|
|
1203
|
-
},
|
|
1421
|
+
}, F = P.min, I = P.max, L = b?.[t] ?? P, R = Math.max(F, Math.min(I, L.min)), z = Math.max(F, Math.min(I, L.max)), B = e.useMemo(() => {
|
|
1204
1422
|
if (m) return m;
|
|
1205
|
-
let e = Math.max(
|
|
1206
|
-
if (Array.isArray(n)) for (let t of n) e = Math.max(e,
|
|
1423
|
+
let e = Math.max(Se(F), Se(I)), n = x?.[t];
|
|
1424
|
+
if (Array.isArray(n)) for (let t of n) e = Math.max(e, Se(Number(t.key)));
|
|
1207
1425
|
return e === 0 ? 1 : Number((10 ** -e).toFixed(e));
|
|
1208
1426
|
}, [
|
|
1209
1427
|
m,
|
|
1210
|
-
P,
|
|
1211
1428
|
F,
|
|
1212
|
-
|
|
1429
|
+
I,
|
|
1430
|
+
x,
|
|
1213
1431
|
t
|
|
1214
|
-
]), V =
|
|
1215
|
-
let e =
|
|
1216
|
-
return { width: `calc(${Math.max(3,
|
|
1432
|
+
]), V = N && F === I, H = V ? r : F, U = V ? i : I, W = Te(U + B, H, B), ee = (e) => Math.min(W, Math.max(H, e)), G = g?.[t], te = s && G !== void 0 ? Z.active : void 0, K = G ? G.min : F, ne = G ? G.max : I, re = G !== void 0, ie = R !== F || z !== I, [J, Y] = e.useState([K, ne]), [ae, oe] = e.useState(!1), [se, ce] = e.useState(!1), [le, ue] = e.useState(String(K)), [de, fe] = e.useState(String(ne)), pe = e.useMemo(() => {
|
|
1433
|
+
let e = Se(B);
|
|
1434
|
+
return { width: `calc(${Math.max(3, F.toFixed(e).length, I.toFixed(e).length, le.length, de.length) + 1}ch + 20px)` };
|
|
1217
1435
|
}, [
|
|
1218
1436
|
B,
|
|
1219
|
-
P,
|
|
1220
1437
|
F,
|
|
1221
|
-
|
|
1222
|
-
|
|
1438
|
+
I,
|
|
1439
|
+
le,
|
|
1440
|
+
de
|
|
1223
1441
|
]);
|
|
1224
1442
|
e.useEffect(() => {
|
|
1225
|
-
|
|
1443
|
+
ue(String(J[0])), fe(String(J[1]));
|
|
1226
1444
|
}, [J]);
|
|
1227
|
-
let { finalMin:
|
|
1228
|
-
let [e, t] = J, n = Math.max(
|
|
1445
|
+
let { finalMin: me, finalMax: he, isValidMin: ge, isValidMax: _e } = e.useMemo(() => {
|
|
1446
|
+
let [e, t] = J, n = Math.max(F, Math.min(I, e)), r = Math.max(F, Math.min(I, t)), i = Math.min(n, r), a = Math.max(n, r);
|
|
1229
1447
|
return {
|
|
1230
1448
|
finalMin: i,
|
|
1231
1449
|
finalMax: a,
|
|
1232
|
-
isValidMin: i >=
|
|
1233
|
-
isValidMax: a <=
|
|
1450
|
+
isValidMin: i >= F && i <= a,
|
|
1451
|
+
isValidMax: a <= I && a >= i
|
|
1234
1452
|
};
|
|
1235
1453
|
}, [
|
|
1236
1454
|
J,
|
|
1237
|
-
|
|
1238
|
-
|
|
1455
|
+
F,
|
|
1456
|
+
I
|
|
1239
1457
|
]);
|
|
1240
1458
|
e.useEffect(() => {
|
|
1241
1459
|
if (V) return;
|
|
1242
|
-
if (J[0] ===
|
|
1243
|
-
|
|
1460
|
+
if (J[0] === F && J[1] === I) {
|
|
1461
|
+
oe(!1), ce(!1);
|
|
1244
1462
|
return;
|
|
1245
1463
|
}
|
|
1246
1464
|
let e = E ?? 500, n = setTimeout(() => {
|
|
1247
|
-
|
|
1465
|
+
oe(!ge), ce(!_e);
|
|
1248
1466
|
}, 300), r = setTimeout(() => {
|
|
1249
|
-
|
|
1467
|
+
ge && _e && (me === F && he === I ? O(t, !1) : D(t, me, he));
|
|
1250
1468
|
}, e);
|
|
1251
1469
|
return () => {
|
|
1252
1470
|
clearTimeout(n), clearTimeout(r);
|
|
1253
1471
|
};
|
|
1254
1472
|
}, [
|
|
1473
|
+
me,
|
|
1255
1474
|
he,
|
|
1256
1475
|
ge,
|
|
1257
1476
|
_e,
|
|
1258
|
-
ve,
|
|
1259
|
-
P,
|
|
1260
1477
|
F,
|
|
1478
|
+
I,
|
|
1261
1479
|
t,
|
|
1262
1480
|
O,
|
|
1263
1481
|
D,
|
|
1264
1482
|
E,
|
|
1265
1483
|
V
|
|
1266
1484
|
]), e.useEffect(() => {
|
|
1267
|
-
Y([K,
|
|
1485
|
+
Y([K, ne]), oe(!1), ce(!1);
|
|
1268
1486
|
}, [
|
|
1269
1487
|
K,
|
|
1270
|
-
|
|
1488
|
+
ne,
|
|
1271
1489
|
t
|
|
1272
1490
|
]);
|
|
1273
|
-
let
|
|
1274
|
-
let t =
|
|
1275
|
-
return [t,
|
|
1276
|
-
}, [B]),
|
|
1491
|
+
let X = e.useCallback((e) => {
|
|
1492
|
+
let t = Q(Math.min(e[0], e[1] - B), B);
|
|
1493
|
+
return [t, Q(Math.max(e[1] - B, t), B)];
|
|
1494
|
+
}, [B]), ye = e.useCallback((e) => {
|
|
1277
1495
|
if (V) return;
|
|
1278
|
-
let [t, n] =
|
|
1279
|
-
Y([Math.max(
|
|
1496
|
+
let [t, n] = X(e);
|
|
1497
|
+
Y([Math.max(F, Math.min(z, t)), Math.max(R, Math.min(I, n))]);
|
|
1280
1498
|
}, [
|
|
1281
1499
|
V,
|
|
1282
|
-
|
|
1283
|
-
P,
|
|
1500
|
+
X,
|
|
1284
1501
|
F,
|
|
1502
|
+
I,
|
|
1285
1503
|
R,
|
|
1286
1504
|
z
|
|
1287
1505
|
]), xe = e.useCallback((e) => {
|
|
1288
1506
|
if (V) return;
|
|
1289
|
-
let [n, r] =
|
|
1290
|
-
i ===
|
|
1507
|
+
let [n, r] = X(e), i = Math.max(F, Math.min(z, n)), a = Math.max(R, Math.min(I, r));
|
|
1508
|
+
i === F && a === I ? (Y([F, I]), O(t, !0)) : Y([i, a]);
|
|
1291
1509
|
}, [
|
|
1292
1510
|
V,
|
|
1293
|
-
|
|
1294
|
-
P,
|
|
1511
|
+
X,
|
|
1295
1512
|
F,
|
|
1513
|
+
I,
|
|
1296
1514
|
R,
|
|
1297
1515
|
z,
|
|
1298
1516
|
t,
|
|
1299
1517
|
O
|
|
1300
|
-
]),
|
|
1518
|
+
]), Ce = e.useRef(null), Ee = e.useCallback((e, n) => {
|
|
1301
1519
|
if (V) return;
|
|
1302
|
-
let r =
|
|
1520
|
+
let r = Ce.current;
|
|
1303
1521
|
if (G && r && r.start === e && r.last === n) {
|
|
1304
|
-
|
|
1522
|
+
Ce.current = null, Y([F, I]), O(t, !0);
|
|
1305
1523
|
return;
|
|
1306
1524
|
}
|
|
1307
|
-
let i =
|
|
1308
|
-
|
|
1525
|
+
let i = we(Math.max(F, R, e), F, B), a = Math.max(i, we(Math.min(I, z, n), F, B));
|
|
1526
|
+
Ce.current = {
|
|
1309
1527
|
start: e,
|
|
1310
1528
|
last: n
|
|
1311
1529
|
}, Y([i, a]);
|
|
1312
1530
|
}, [
|
|
1313
1531
|
V,
|
|
1314
1532
|
G,
|
|
1315
|
-
P,
|
|
1316
1533
|
F,
|
|
1534
|
+
I,
|
|
1317
1535
|
R,
|
|
1318
1536
|
z,
|
|
1319
1537
|
B,
|
|
1320
1538
|
t,
|
|
1321
1539
|
O
|
|
1322
|
-
]),
|
|
1540
|
+
]), $ = e.useCallback(() => {
|
|
1323
1541
|
if (V) return;
|
|
1324
|
-
let e =
|
|
1542
|
+
let e = le.trim(), t = e === "" ? NaN : Number(e);
|
|
1325
1543
|
if (isNaN(t)) {
|
|
1326
|
-
|
|
1544
|
+
ue(String(J[0]));
|
|
1327
1545
|
return;
|
|
1328
1546
|
}
|
|
1329
|
-
let n = Math.max(
|
|
1330
|
-
n < J[1] ? Y([n, J[1]]) : Y([
|
|
1547
|
+
let n = Math.max(F, Math.min(z, t));
|
|
1548
|
+
n < J[1] ? Y([n, J[1]]) : Y([F, J[1]]), ue(String(n < J[1] ? n : F));
|
|
1331
1549
|
}, [
|
|
1332
1550
|
V,
|
|
1333
|
-
|
|
1551
|
+
le,
|
|
1334
1552
|
J,
|
|
1335
|
-
|
|
1553
|
+
F,
|
|
1336
1554
|
z
|
|
1337
|
-
]),
|
|
1555
|
+
]), De = e.useCallback(() => {
|
|
1338
1556
|
if (V) return;
|
|
1339
|
-
let e =
|
|
1557
|
+
let e = de.trim(), t = e === "" ? NaN : Number(e);
|
|
1340
1558
|
if (isNaN(t)) {
|
|
1341
|
-
|
|
1559
|
+
fe(String(J[1]));
|
|
1342
1560
|
return;
|
|
1343
1561
|
}
|
|
1344
|
-
let n = Math.max(R, Math.min(
|
|
1345
|
-
n > J[0] ? Y([J[0], n]) : Y([J[0],
|
|
1562
|
+
let n = Math.max(R, Math.min(I, t));
|
|
1563
|
+
n > J[0] ? Y([J[0], n]) : Y([J[0], I]), fe(String(n > J[0] ? n : I));
|
|
1346
1564
|
}, [
|
|
1347
1565
|
V,
|
|
1348
|
-
|
|
1566
|
+
de,
|
|
1349
1567
|
J,
|
|
1350
1568
|
R,
|
|
1351
|
-
|
|
1352
|
-
]),
|
|
1569
|
+
I
|
|
1570
|
+
]), Oe = (e) => (t) => {
|
|
1353
1571
|
t.key === "Enter" && e();
|
|
1354
|
-
}, [
|
|
1572
|
+
}, [ke, Ae] = e.useState(null), je = e.useRef(null);
|
|
1355
1573
|
e.useEffect(() => {
|
|
1356
1574
|
if (!u) return;
|
|
1357
|
-
let e = `${
|
|
1358
|
-
if (e ===
|
|
1359
|
-
let n =
|
|
1575
|
+
let e = `${F}:${I}`;
|
|
1576
|
+
if (e === je.current && je.current !== null) return;
|
|
1577
|
+
let n = x?.[t];
|
|
1360
1578
|
if (!Array.isArray(n) || n.length === 0) return;
|
|
1361
1579
|
let r = n.filter((e) => e.value != null && !isNaN(Number(e.key))).map((e) => ({
|
|
1362
1580
|
key: e.key,
|
|
1363
1581
|
value: e.value
|
|
1364
1582
|
}));
|
|
1365
|
-
r.length > 0 && (
|
|
1583
|
+
r.length > 0 && (je.current = e, Ae(r));
|
|
1366
1584
|
}, [
|
|
1367
|
-
P,
|
|
1368
1585
|
F,
|
|
1369
|
-
|
|
1586
|
+
I,
|
|
1587
|
+
x,
|
|
1370
1588
|
t,
|
|
1371
1589
|
u
|
|
1372
1590
|
]);
|
|
1373
|
-
let
|
|
1374
|
-
if (!u || !
|
|
1375
|
-
let e =
|
|
1591
|
+
let Me = e.useMemo(() => {
|
|
1592
|
+
if (!u || !ke || ke.length === 0) return [];
|
|
1593
|
+
let e = I - F;
|
|
1376
1594
|
if (e <= 0) return [];
|
|
1377
|
-
let t = d ?? Math.max(B,
|
|
1595
|
+
let t = d ?? Math.max(B, Q(Math.ceil(e / 20 / B) * B, B)), n = Math.ceil(e / t);
|
|
1378
1596
|
return Array.from({ length: n }, (e, r) => {
|
|
1379
|
-
let i =
|
|
1597
|
+
let i = F + r * t, a = F + (r + 1) * t, o = r === n - 1, s = ke.filter((e) => {
|
|
1380
1598
|
let t = Number(e.key);
|
|
1381
|
-
return t >= i && (t < a || o && t <=
|
|
1382
|
-
}).reduce((e, t) => e + t.value, 0), c = o ?
|
|
1599
|
+
return t >= i && (t < a || o && t <= I);
|
|
1600
|
+
}).reduce((e, t) => e + t.value, 0), c = o ? I : Q(a - B, B);
|
|
1383
1601
|
return {
|
|
1384
1602
|
bucketStart: i,
|
|
1385
1603
|
bucketEnd: a,
|
|
1386
1604
|
count: s,
|
|
1387
1605
|
last: c,
|
|
1388
|
-
barEnd:
|
|
1606
|
+
barEnd: Q(c + B, B)
|
|
1389
1607
|
};
|
|
1390
1608
|
}).map((e, t, n) => ({
|
|
1391
1609
|
...e,
|
|
@@ -1393,92 +1611,92 @@ var le = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1393
1611
|
}));
|
|
1394
1612
|
}, [
|
|
1395
1613
|
u,
|
|
1396
|
-
|
|
1397
|
-
P,
|
|
1614
|
+
ke,
|
|
1398
1615
|
F,
|
|
1616
|
+
I,
|
|
1399
1617
|
d,
|
|
1400
1618
|
B,
|
|
1401
1619
|
W
|
|
1402
|
-
]),
|
|
1403
|
-
return u && !
|
|
1620
|
+
]), Ne = e.useMemo(() => Math.max(...Me.map((e) => e.count), 1), [Me]);
|
|
1621
|
+
return u && !j && !w?.includes(t) && console.warn(`RangeFilterPanel: showHistogram=true but field "${t}" is not facetable. Add .Facetable = true to this field.`), A ? null : j ? /* @__PURE__ */ f(ve, {
|
|
1404
1622
|
title: n,
|
|
1405
1623
|
variant: "slider",
|
|
1406
1624
|
withHistogram: u,
|
|
1407
1625
|
collapsible: c,
|
|
1408
1626
|
startCollapsed: l
|
|
1409
|
-
}) : !k && !T ? null : C?.includes(t) ?
|
|
1627
|
+
}) : !k && !T ? null : C?.includes(t) ? M === "slider" ? /* @__PURE__ */ p(_, {
|
|
1410
1628
|
title: n,
|
|
1411
1629
|
collapsed: l,
|
|
1412
1630
|
collapsible: c,
|
|
1413
1631
|
className: te,
|
|
1414
1632
|
children: [
|
|
1415
1633
|
V && /* @__PURE__ */ p("div", {
|
|
1416
|
-
className:
|
|
1634
|
+
className: Z.disabledMessage,
|
|
1417
1635
|
children: [
|
|
1418
1636
|
"No adjustable range (all results have the same value: ",
|
|
1419
|
-
|
|
1637
|
+
F,
|
|
1420
1638
|
")."
|
|
1421
1639
|
]
|
|
1422
1640
|
}),
|
|
1423
|
-
u &&
|
|
1424
|
-
u &&
|
|
1425
|
-
let [e, t] = z > R && (R >
|
|
1641
|
+
u && Me.length === 0 && /* @__PURE__ */ f("div", { className: Z.histogram }),
|
|
1642
|
+
u && Me.length > 0 && (() => {
|
|
1643
|
+
let [e, t] = z > R && (R > F || z < I) ? [R, z] : [H, U], n = Math.max(me, e), r = Math.min(he, t), i = W, a = i - H || 1, o = (e) => Math.max(0, Math.min(1, (e - H) / a)), s = (e) => e >= U ? 0 : Math.max(0, Math.min(1, (i - (e + B)) / a)), c = o(n), l = r < n ? 1 - c : s(r), u = (e) => `calc(10px + (100% - 20px) * ${e})`, d = `inset(0 ${u(l)} 0 ${u(c)})`, m = `inset(0 ${u(s(t))} 0 ${u(o(e))})`, h = (n) => n.last < e || n.bucketStart > t, g = Me.slice(1).map((e) => u((e.bucketStart - H) / a)), _ = Me.map((e) => ({
|
|
1426
1644
|
...e,
|
|
1427
|
-
height: Math.max(1, Math.ceil(e.count /
|
|
1645
|
+
height: Math.max(1, Math.ceil(e.count / Ne * 20))
|
|
1428
1646
|
}));
|
|
1429
1647
|
return /* @__PURE__ */ p("div", {
|
|
1430
|
-
className:
|
|
1648
|
+
className: Z.histogram,
|
|
1431
1649
|
children: [
|
|
1432
1650
|
/* @__PURE__ */ f("div", {
|
|
1433
|
-
className:
|
|
1651
|
+
className: Z.histogramLayer,
|
|
1434
1652
|
children: _.map((e, t) => /* @__PURE__ */ f("button", {
|
|
1435
1653
|
type: "button",
|
|
1436
|
-
className:
|
|
1654
|
+
className: Z.histogramBar,
|
|
1437
1655
|
style: { flexGrow: e.span },
|
|
1438
1656
|
"data-testid": "histogram-bar",
|
|
1439
1657
|
disabled: V || h(e),
|
|
1440
1658
|
"aria-label": `${e.bucketStart} to ${e.last}: ${e.count}`,
|
|
1441
1659
|
title: `${e.bucketStart} to ${e.last}: ${e.count}`,
|
|
1442
|
-
onClick: () =>
|
|
1660
|
+
onClick: () => Ee(e.bucketStart, e.last),
|
|
1443
1661
|
children: /* @__PURE__ */ f("span", {
|
|
1444
|
-
className:
|
|
1662
|
+
className: Z.histogramFill,
|
|
1445
1663
|
style: { height: `${e.height}px` }
|
|
1446
1664
|
})
|
|
1447
1665
|
}, t))
|
|
1448
1666
|
}),
|
|
1449
1667
|
/* @__PURE__ */ f("div", {
|
|
1450
|
-
className: `${
|
|
1668
|
+
className: `${Z.histogramLayer} ${Z.histogramLive}`,
|
|
1451
1669
|
"aria-hidden": "true",
|
|
1452
1670
|
"data-testid": "histogram-live",
|
|
1453
1671
|
style: { clipPath: m },
|
|
1454
1672
|
children: _.map((e, t) => /* @__PURE__ */ f("span", {
|
|
1455
|
-
className:
|
|
1673
|
+
className: Z.histogramBar,
|
|
1456
1674
|
style: { flexGrow: e.span },
|
|
1457
1675
|
children: /* @__PURE__ */ f("span", {
|
|
1458
|
-
className:
|
|
1676
|
+
className: Z.histogramFill,
|
|
1459
1677
|
style: { height: `${e.height}px` }
|
|
1460
1678
|
})
|
|
1461
1679
|
}, t))
|
|
1462
1680
|
}),
|
|
1463
1681
|
/* @__PURE__ */ f("div", {
|
|
1464
|
-
className: `${
|
|
1682
|
+
className: `${Z.histogramLayer} ${Z.histogramLit}`,
|
|
1465
1683
|
"aria-hidden": "true",
|
|
1466
1684
|
"data-testid": "histogram-lit",
|
|
1467
1685
|
style: { clipPath: d },
|
|
1468
1686
|
children: _.map((e, t) => /* @__PURE__ */ f("span", {
|
|
1469
|
-
className:
|
|
1687
|
+
className: Z.histogramBar,
|
|
1470
1688
|
style: { flexGrow: e.span },
|
|
1471
1689
|
children: /* @__PURE__ */ f("span", {
|
|
1472
|
-
className:
|
|
1690
|
+
className: Z.histogramFill,
|
|
1473
1691
|
style: { height: `${e.height}px` }
|
|
1474
1692
|
})
|
|
1475
1693
|
}, t))
|
|
1476
1694
|
}),
|
|
1477
1695
|
/* @__PURE__ */ f("div", {
|
|
1478
|
-
className:
|
|
1696
|
+
className: Z.histogramSeparators,
|
|
1479
1697
|
"aria-hidden": "true",
|
|
1480
1698
|
children: g.map((e, t) => /* @__PURE__ */ f("span", {
|
|
1481
|
-
className:
|
|
1699
|
+
className: Z.histogramSeparator,
|
|
1482
1700
|
style: { left: e }
|
|
1483
1701
|
}, t))
|
|
1484
1702
|
})
|
|
@@ -1487,20 +1705,20 @@ var le = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1487
1705
|
})(),
|
|
1488
1706
|
/* @__PURE__ */ f("div", {
|
|
1489
1707
|
style: { padding: "10px 10px 20px 10px" },
|
|
1490
|
-
children: /* @__PURE__ */ f(
|
|
1708
|
+
children: /* @__PURE__ */ f(S, {
|
|
1491
1709
|
min: H,
|
|
1492
1710
|
max: W,
|
|
1493
1711
|
step: B,
|
|
1494
1712
|
stepMarks: h,
|
|
1495
|
-
value: V ? [H, W] : [ee(
|
|
1713
|
+
value: V ? [H, W] : [ee(we(me, H, B)), ee(we(he + B, H, B))],
|
|
1496
1714
|
isRange: !0,
|
|
1497
|
-
onChange: (e) =>
|
|
1715
|
+
onChange: (e) => ye(e),
|
|
1498
1716
|
onFinalChange: (e) => xe(e),
|
|
1499
1717
|
disabled: V,
|
|
1500
1718
|
activeMin: R,
|
|
1501
|
-
activeMax: ee(
|
|
1502
|
-
isFaceted:
|
|
1503
|
-
highlightFaceted:
|
|
1719
|
+
activeMax: ee(Q(z + B, B)),
|
|
1720
|
+
isFaceted: ie,
|
|
1721
|
+
highlightFaceted: re,
|
|
1504
1722
|
"aria-label": n || `Filter by ${t}`
|
|
1505
1723
|
})
|
|
1506
1724
|
}),
|
|
@@ -1511,41 +1729,41 @@ var le = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1511
1729
|
alignItems: "flex-start",
|
|
1512
1730
|
justifyContent: "space-between"
|
|
1513
1731
|
},
|
|
1514
|
-
children: [/* @__PURE__ */ f(
|
|
1732
|
+
children: [/* @__PURE__ */ f(v, {
|
|
1515
1733
|
label: "Min:",
|
|
1516
1734
|
type: "number",
|
|
1517
|
-
style:
|
|
1518
|
-
value: V ? String(
|
|
1519
|
-
min:
|
|
1520
|
-
max:
|
|
1521
|
-
onChange: (e) =>
|
|
1522
|
-
onBlur:
|
|
1523
|
-
onKeyDown:
|
|
1735
|
+
style: pe,
|
|
1736
|
+
value: V ? String(F) : le,
|
|
1737
|
+
min: F,
|
|
1738
|
+
max: Q(Math.min(z, J[1] - B), B),
|
|
1739
|
+
onChange: (e) => ue(e.target.value),
|
|
1740
|
+
onBlur: $,
|
|
1741
|
+
onKeyDown: Oe($),
|
|
1524
1742
|
disabled: V,
|
|
1525
|
-
isValid: V || !
|
|
1526
|
-
}), /* @__PURE__ */ f(
|
|
1743
|
+
isValid: V || !ae
|
|
1744
|
+
}), /* @__PURE__ */ f(v, {
|
|
1527
1745
|
label: "Max:",
|
|
1528
1746
|
type: "number",
|
|
1529
|
-
style:
|
|
1530
|
-
value: V ? String(
|
|
1531
|
-
min:
|
|
1532
|
-
max:
|
|
1533
|
-
onChange: (e) =>
|
|
1534
|
-
onBlur:
|
|
1535
|
-
onKeyDown:
|
|
1747
|
+
style: pe,
|
|
1748
|
+
value: V ? String(I) : de,
|
|
1749
|
+
min: Q(Math.max(R, J[0] + B), B),
|
|
1750
|
+
max: I,
|
|
1751
|
+
onChange: (e) => fe(e.target.value),
|
|
1752
|
+
onBlur: De,
|
|
1753
|
+
onKeyDown: Oe(De),
|
|
1536
1754
|
disabled: V,
|
|
1537
|
-
isValid: V || !
|
|
1755
|
+
isValid: V || !se
|
|
1538
1756
|
})]
|
|
1539
1757
|
})
|
|
1540
1758
|
]
|
|
1541
|
-
}) : /* @__PURE__ */ p(
|
|
1759
|
+
}) : /* @__PURE__ */ p(_, {
|
|
1542
1760
|
title: n,
|
|
1543
1761
|
className: te,
|
|
1544
1762
|
children: [V && /* @__PURE__ */ p("div", {
|
|
1545
|
-
className:
|
|
1763
|
+
className: Z.disabledMessage,
|
|
1546
1764
|
children: [
|
|
1547
1765
|
"No adjustable range (all results have the same value: ",
|
|
1548
|
-
|
|
1766
|
+
F,
|
|
1549
1767
|
")."
|
|
1550
1768
|
]
|
|
1551
1769
|
}), /* @__PURE__ */ p("div", {
|
|
@@ -1554,58 +1772,48 @@ var le = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1554
1772
|
gap: "10px",
|
|
1555
1773
|
alignItems: "flex-start"
|
|
1556
1774
|
},
|
|
1557
|
-
children: [/* @__PURE__ */ f(
|
|
1775
|
+
children: [/* @__PURE__ */ f(v, {
|
|
1558
1776
|
label: "Min:",
|
|
1559
1777
|
type: "number",
|
|
1560
|
-
style:
|
|
1561
|
-
value: V ? String(
|
|
1562
|
-
min:
|
|
1563
|
-
max:
|
|
1564
|
-
onChange: (e) =>
|
|
1565
|
-
onBlur:
|
|
1566
|
-
onKeyDown:
|
|
1778
|
+
style: pe,
|
|
1779
|
+
value: V ? String(F) : le,
|
|
1780
|
+
min: F,
|
|
1781
|
+
max: Q(Math.min(z, J[1] - B), B),
|
|
1782
|
+
onChange: (e) => ue(e.target.value),
|
|
1783
|
+
onBlur: $,
|
|
1784
|
+
onKeyDown: Oe($),
|
|
1567
1785
|
disabled: V,
|
|
1568
|
-
isValid: V || !
|
|
1569
|
-
}), /* @__PURE__ */ f(
|
|
1786
|
+
isValid: V || !ae
|
|
1787
|
+
}), /* @__PURE__ */ f(v, {
|
|
1570
1788
|
label: "Max:",
|
|
1571
1789
|
type: "number",
|
|
1572
|
-
style:
|
|
1573
|
-
value: V ? String(
|
|
1574
|
-
min:
|
|
1575
|
-
max:
|
|
1576
|
-
onChange: (e) =>
|
|
1577
|
-
onBlur:
|
|
1578
|
-
onKeyDown:
|
|
1790
|
+
style: pe,
|
|
1791
|
+
value: V ? String(I) : de,
|
|
1792
|
+
min: Q(Math.max(R, J[0] + B), B),
|
|
1793
|
+
max: I,
|
|
1794
|
+
onChange: (e) => fe(e.target.value),
|
|
1795
|
+
onBlur: De,
|
|
1796
|
+
onKeyDown: Oe(De),
|
|
1579
1797
|
disabled: V,
|
|
1580
|
-
isValid: V || !
|
|
1798
|
+
isValid: V || !se
|
|
1581
1799
|
})]
|
|
1582
1800
|
})]
|
|
1583
|
-
}) : /* @__PURE__ */ f(
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
color: "red",
|
|
1588
|
-
fontSize: "12px"
|
|
1589
|
-
},
|
|
1590
|
-
children: [
|
|
1591
|
-
"Cannot render filter for \"",
|
|
1592
|
-
t,
|
|
1593
|
-
"\": missing filterable."
|
|
1594
|
-
]
|
|
1595
|
-
})
|
|
1801
|
+
}) : /* @__PURE__ */ f(be, {
|
|
1802
|
+
label: n,
|
|
1803
|
+
field: t,
|
|
1804
|
+
missing: ["filterable"]
|
|
1596
1805
|
});
|
|
1597
|
-
},
|
|
1598
|
-
list: "
|
|
1599
|
-
grid: "
|
|
1600
|
-
count: "
|
|
1601
|
-
countValue: "
|
|
1602
|
-
chip: "
|
|
1603
|
-
|
|
1604
|
-
active: "_active_apmmi_46"
|
|
1806
|
+
}, $ = {
|
|
1807
|
+
list: "_list_9je85_2",
|
|
1808
|
+
grid: "_grid_9je85_9",
|
|
1809
|
+
count: "_count_9je85_22",
|
|
1810
|
+
countValue: "_countValue_9je85_31",
|
|
1811
|
+
chip: "_chip_9je85_35",
|
|
1812
|
+
active: "_active_9je85_41"
|
|
1605
1813
|
};
|
|
1606
1814
|
//#endregion
|
|
1607
1815
|
//#region src/components/BucketFilterPanel.tsx
|
|
1608
|
-
function
|
|
1816
|
+
function De(e, t) {
|
|
1609
1817
|
if (!t) return null;
|
|
1610
1818
|
let n = 0, r = !1;
|
|
1611
1819
|
for (let i of t) {
|
|
@@ -1617,16 +1825,16 @@ function ue(e, t) {
|
|
|
1617
1825
|
}
|
|
1618
1826
|
return r ? n : 0;
|
|
1619
1827
|
}
|
|
1620
|
-
var
|
|
1621
|
-
let { state: { facets: S, filterableFields: C, facetableFields: w, bucketFilters: T, rangeBounds: E, facetStats: D, query: O }, toggleBucketFilter: k,
|
|
1828
|
+
var Oe = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a, layout: c = "list", showCount: u = !0, showEmpty: d = !1, limit: g, showActivePanel: v = !1, collapsible: b = !0, startCollapsed: x = !1 }) => {
|
|
1829
|
+
let { state: { facets: S, filterableFields: C, facetableFields: w, bucketFilters: T, rangeBounds: E, facetStats: D, query: O }, toggleBucketFilter: k, authError: A, isFetchingInitial: j, allowEmptySearch: M } = q(), N = i ?? a ?? "checkbox", P = S?.[e], F = T[e] ?? [], [I, L] = l(g ?? Infinity);
|
|
1622
1830
|
o(() => {
|
|
1623
|
-
|
|
1624
|
-
}, [
|
|
1831
|
+
L(g ?? Infinity);
|
|
1832
|
+
}, [g, P]);
|
|
1625
1833
|
let R = E?.[e] ?? D?.[e], z = s(() => {
|
|
1626
1834
|
let e = [];
|
|
1627
|
-
if (R && e.push(R.min, R.max), Array.isArray(
|
|
1628
|
-
return
|
|
1629
|
-
}, [R,
|
|
1835
|
+
if (R && e.push(R.min, R.max), Array.isArray(P)) for (let t of P) e.push(Number(t.key));
|
|
1836
|
+
return Ce(e.filter(Number.isFinite));
|
|
1837
|
+
}, [R, P]), B = s(() => {
|
|
1630
1838
|
let e = R?.min ?? -Number.MAX_VALUE, t = R?.max ?? Number.MAX_VALUE, i = (n, r, i) => ({
|
|
1631
1839
|
label: i ?? (n === void 0 ? `up to ${r}` : r === void 0 ? `${n} and up` : `${n}-${r}`),
|
|
1632
1840
|
range: {
|
|
@@ -1638,12 +1846,12 @@ var de = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
1638
1846
|
if (r && r.length > 0) return r.map((e) => i(e.min, e.max, e.label));
|
|
1639
1847
|
if (Array.isArray(n)) {
|
|
1640
1848
|
let e = [...n].sort((e, t) => e - t), t = [];
|
|
1641
|
-
for (let n = 0; n < e.length - 1; n++) t.push(i(e[n],
|
|
1849
|
+
for (let n = 0; n < e.length - 1; n++) t.push(i(e[n], Q(e[n + 1] - z, z)));
|
|
1642
1850
|
return t;
|
|
1643
1851
|
}
|
|
1644
1852
|
if (typeof n == "number" && n > 0 && R) {
|
|
1645
1853
|
let e = [], t = Math.floor(R.min / n) * n;
|
|
1646
|
-
for (let r = t; r <= R.max; r =
|
|
1854
|
+
for (let r = t; r <= R.max; r = Q(r + n, z)) e.push(i(Q(r, z), Q(r + n - z, z)));
|
|
1647
1855
|
return e;
|
|
1648
1856
|
}
|
|
1649
1857
|
return [];
|
|
@@ -1653,33 +1861,28 @@ var de = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
1653
1861
|
R,
|
|
1654
1862
|
z
|
|
1655
1863
|
]);
|
|
1656
|
-
if (A
|
|
1864
|
+
if (A) return null;
|
|
1865
|
+
if (j || !S) return /* @__PURE__ */ f(ve, {
|
|
1657
1866
|
title: t,
|
|
1658
1867
|
rows: Math.max(1, Math.min(B.length || 5, 8)),
|
|
1659
1868
|
collapsible: b,
|
|
1660
1869
|
startCollapsed: x
|
|
1661
1870
|
});
|
|
1662
|
-
if (!
|
|
1663
|
-
if (!C?.includes(e)) return /* @__PURE__ */ f(
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
children: [
|
|
1668
|
-
"Cannot render buckets for \"",
|
|
1669
|
-
e,
|
|
1670
|
-
"\": field is not filterable."
|
|
1671
|
-
]
|
|
1672
|
-
})
|
|
1871
|
+
if (!M && !O) return null;
|
|
1872
|
+
if (!C?.includes(e)) return /* @__PURE__ */ f(be, {
|
|
1873
|
+
label: t,
|
|
1874
|
+
field: e,
|
|
1875
|
+
missing: ["filterable"]
|
|
1673
1876
|
});
|
|
1674
|
-
let V = w?.includes(e) && Array.isArray(
|
|
1877
|
+
let V = w?.includes(e) && Array.isArray(P), H = (e) => F.some((t) => t.min === e.range.min && t.max === e.range.max), U = B.map((e) => ({
|
|
1675
1878
|
bucket: e,
|
|
1676
|
-
count: V ?
|
|
1879
|
+
count: V ? De(e, P) : null
|
|
1677
1880
|
}));
|
|
1678
1881
|
if (d || (U = U.filter((e) => e.count !== 0 || H(e.bucket))), U.length === 0) return null;
|
|
1679
|
-
let W = U.slice(0,
|
|
1680
|
-
let r = H(t), i = n === 0 && !r, a = u && (n ?? 0) > 0 ? `${n}` : "", o = () => k(e, t.range,
|
|
1681
|
-
if (
|
|
1682
|
-
let n = /* @__PURE__ */ f(
|
|
1882
|
+
let W = U.slice(0, I), ee = (t, n) => {
|
|
1883
|
+
let r = H(t), i = n === 0 && !r, a = u && (n ?? 0) > 0 ? `${n}` : "", o = () => k(e, t.range, N === "radio");
|
|
1884
|
+
if (N === "radio") {
|
|
1885
|
+
let n = /* @__PURE__ */ f(y, {
|
|
1683
1886
|
id: `${e}-${t.range.min}-${t.range.max}`,
|
|
1684
1887
|
name: e,
|
|
1685
1888
|
value: t.label,
|
|
@@ -1689,32 +1892,32 @@ var de = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
1689
1892
|
disabled: i
|
|
1690
1893
|
});
|
|
1691
1894
|
return c === "list" ? /* @__PURE__ */ p("div", {
|
|
1692
|
-
className:
|
|
1895
|
+
className: $.count,
|
|
1693
1896
|
children: [n, /* @__PURE__ */ f("span", {
|
|
1694
|
-
className:
|
|
1897
|
+
className: $.countValue,
|
|
1695
1898
|
children: a
|
|
1696
1899
|
})]
|
|
1697
1900
|
}) : n;
|
|
1698
1901
|
}
|
|
1699
|
-
if (
|
|
1902
|
+
if (N === "button") {
|
|
1700
1903
|
let e = /* @__PURE__ */ f(m, {
|
|
1701
1904
|
variant: r ? "primary" : "secondary",
|
|
1702
1905
|
onClick: o,
|
|
1703
1906
|
disabled: i,
|
|
1704
1907
|
size: "micro",
|
|
1705
|
-
className:
|
|
1908
|
+
className: $.chip,
|
|
1706
1909
|
children: c === "grid" && a ? `${t.label} (${a})` : t.label
|
|
1707
1910
|
});
|
|
1708
1911
|
return c === "list" ? /* @__PURE__ */ p("div", {
|
|
1709
|
-
className:
|
|
1912
|
+
className: $.count,
|
|
1710
1913
|
children: [e, /* @__PURE__ */ f("span", {
|
|
1711
|
-
className:
|
|
1914
|
+
className: $.countValue,
|
|
1712
1915
|
children: a
|
|
1713
1916
|
})]
|
|
1714
1917
|
}) : e;
|
|
1715
1918
|
}
|
|
1716
1919
|
return c === "list" ? /* @__PURE__ */ p("div", {
|
|
1717
|
-
className:
|
|
1920
|
+
className: $.count,
|
|
1718
1921
|
children: [/* @__PURE__ */ f(h, {
|
|
1719
1922
|
label: t.label,
|
|
1720
1923
|
score: "",
|
|
@@ -1722,7 +1925,7 @@ var de = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
1722
1925
|
onChange: o,
|
|
1723
1926
|
disabled: i
|
|
1724
1927
|
}), /* @__PURE__ */ f("span", {
|
|
1725
|
-
className:
|
|
1928
|
+
className: $.countValue,
|
|
1726
1929
|
children: a
|
|
1727
1930
|
})]
|
|
1728
1931
|
}) : /* @__PURE__ */ f(h, {
|
|
@@ -1733,13 +1936,13 @@ var de = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
1733
1936
|
disabled: i
|
|
1734
1937
|
});
|
|
1735
1938
|
};
|
|
1736
|
-
return /* @__PURE__ */ f(
|
|
1939
|
+
return /* @__PURE__ */ f(_, {
|
|
1737
1940
|
title: t,
|
|
1738
1941
|
collapsible: b,
|
|
1739
1942
|
collapsed: b ? x : !1,
|
|
1740
|
-
className:
|
|
1943
|
+
className: v && F.length > 0 ? $.active : void 0,
|
|
1741
1944
|
children: /* @__PURE__ */ p("ul", {
|
|
1742
|
-
className: c === "grid" ?
|
|
1945
|
+
className: c === "grid" ? $.grid : $.list,
|
|
1743
1946
|
style: {
|
|
1744
1947
|
listStyle: "none",
|
|
1745
1948
|
padding: 0,
|
|
@@ -1748,39 +1951,39 @@ var de = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
1748
1951
|
children: [W.map(({ bucket: e, count: t }) => /* @__PURE__ */ f("li", { children: ee(e, t) }, `${e.range.min}-${e.range.max}`)), W.length < U.length && /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(m, {
|
|
1749
1952
|
variant: "ghost",
|
|
1750
1953
|
size: "micro",
|
|
1751
|
-
onClick: () =>
|
|
1954
|
+
onClick: () => L(U.length),
|
|
1752
1955
|
children: `Show ${U.length - W.length} more of ${U.length} total`
|
|
1753
1956
|
}) })]
|
|
1754
1957
|
})
|
|
1755
1958
|
});
|
|
1756
|
-
},
|
|
1959
|
+
}, ke = {
|
|
1757
1960
|
grid: "_grid_1xjna_2",
|
|
1758
1961
|
chip: "_chip_1xjna_21",
|
|
1759
1962
|
chipLabel: "_chipLabel_1xjna_32"
|
|
1760
|
-
},
|
|
1963
|
+
}, Ae = r(({ field: e, value: t, onReset: n }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(m, {
|
|
1761
1964
|
onClick: n,
|
|
1762
|
-
iconRight: /* @__PURE__ */ f(
|
|
1965
|
+
iconRight: /* @__PURE__ */ f(L, {}),
|
|
1763
1966
|
variant: "primary",
|
|
1764
1967
|
size: "micro",
|
|
1765
|
-
className:
|
|
1968
|
+
className: ke.chip,
|
|
1766
1969
|
title: `${e}: ${t}`,
|
|
1767
1970
|
children: /* @__PURE__ */ p("span", {
|
|
1768
|
-
className:
|
|
1971
|
+
className: ke.chipLabel,
|
|
1769
1972
|
children: [
|
|
1770
1973
|
e,
|
|
1771
1974
|
": ",
|
|
1772
1975
|
t
|
|
1773
1976
|
]
|
|
1774
1977
|
})
|
|
1775
|
-
}) })),
|
|
1978
|
+
}) })), je = r(({ field: e, min: t, max: n, onReset: r }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(m, {
|
|
1776
1979
|
onClick: r,
|
|
1777
|
-
iconRight: /* @__PURE__ */ f(
|
|
1980
|
+
iconRight: /* @__PURE__ */ f(L, {}),
|
|
1778
1981
|
variant: "primary",
|
|
1779
1982
|
size: "micro",
|
|
1780
|
-
className:
|
|
1983
|
+
className: ke.chip,
|
|
1781
1984
|
title: `${e}: ${t} – ${n}`,
|
|
1782
1985
|
children: /* @__PURE__ */ p("span", {
|
|
1783
|
-
className:
|
|
1986
|
+
className: ke.chipLabel,
|
|
1784
1987
|
children: [
|
|
1785
1988
|
e,
|
|
1786
1989
|
": ",
|
|
@@ -1789,15 +1992,15 @@ var de = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
1789
1992
|
n
|
|
1790
1993
|
]
|
|
1791
1994
|
})
|
|
1792
|
-
}) })),
|
|
1995
|
+
}) })), Me = r(({ field: e, label: t, onReset: n }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(m, {
|
|
1793
1996
|
onClick: n,
|
|
1794
|
-
iconRight: /* @__PURE__ */ f(
|
|
1997
|
+
iconRight: /* @__PURE__ */ f(L, {}),
|
|
1795
1998
|
variant: "primary",
|
|
1796
1999
|
size: "micro",
|
|
1797
|
-
className:
|
|
2000
|
+
className: ke.chip,
|
|
1798
2001
|
title: `${e}: ${t}`,
|
|
1799
2002
|
children: /* @__PURE__ */ p("span", {
|
|
1800
|
-
className:
|
|
2003
|
+
className: ke.chipLabel,
|
|
1801
2004
|
children: [
|
|
1802
2005
|
e,
|
|
1803
2006
|
": ",
|
|
@@ -1805,8 +2008,8 @@ var de = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
1805
2008
|
]
|
|
1806
2009
|
})
|
|
1807
2010
|
}) }));
|
|
1808
|
-
function
|
|
1809
|
-
let { state: { filters: e, rangeFilters: t, bucketFilters: n }, resetFilters: r, resetSingleFilter: i, resetRangeFilter: a, resetBucketFilter: o } =
|
|
2011
|
+
function Ne() {
|
|
2012
|
+
let { state: { filters: e, rangeFilters: t, bucketFilters: n }, resetFilters: r, resetSingleFilter: i, resetRangeFilter: a, resetBucketFilter: o } = q(), c = s(() => Object.entries(e).map(([e, t]) => t.map((t) => ({
|
|
1810
2013
|
field: e,
|
|
1811
2014
|
value: t
|
|
1812
2015
|
}))).flat(), [e]), l = s(() => Object.entries(t).map(([e, { min: t, max: n }]) => ({
|
|
@@ -1822,24 +2025,24 @@ function he() {
|
|
|
1822
2025
|
e,
|
|
1823
2026
|
t,
|
|
1824
2027
|
u
|
|
1825
|
-
]) ? /* @__PURE__ */ f(
|
|
2028
|
+
]) ? /* @__PURE__ */ f(_, {
|
|
1826
2029
|
collapsible: !1,
|
|
1827
2030
|
title: "Active filters",
|
|
1828
2031
|
children: /* @__PURE__ */ p("ul", {
|
|
1829
|
-
className:
|
|
2032
|
+
className: ke.grid,
|
|
1830
2033
|
children: [
|
|
1831
|
-
c.map(({ field: e, value: t }) => /* @__PURE__ */ f(
|
|
2034
|
+
c.map(({ field: e, value: t }) => /* @__PURE__ */ f(Ae, {
|
|
1832
2035
|
field: e,
|
|
1833
2036
|
value: t,
|
|
1834
2037
|
onReset: () => i(e, t)
|
|
1835
2038
|
}, `${e}-${t}`)),
|
|
1836
|
-
l.map(({ field: e, min: t, max: n }) => /* @__PURE__ */ f(
|
|
2039
|
+
l.map(({ field: e, min: t, max: n }) => /* @__PURE__ */ f(je, {
|
|
1837
2040
|
field: e,
|
|
1838
2041
|
min: t,
|
|
1839
2042
|
max: n,
|
|
1840
2043
|
onReset: () => a(e)
|
|
1841
2044
|
}, e)),
|
|
1842
|
-
u.map(({ field: e, range: t, label: n }) => /* @__PURE__ */ f(
|
|
2045
|
+
u.map(({ field: e, range: t, label: n }) => /* @__PURE__ */ f(Me, {
|
|
1843
2046
|
field: e,
|
|
1844
2047
|
label: n,
|
|
1845
2048
|
onReset: () => o(e, t)
|
|
@@ -1854,12 +2057,12 @@ function he() {
|
|
|
1854
2057
|
})
|
|
1855
2058
|
}) : null;
|
|
1856
2059
|
}
|
|
1857
|
-
var
|
|
2060
|
+
var Pe = {
|
|
1858
2061
|
select: "_select_nwf7i_1",
|
|
1859
2062
|
radioGroup: "_radioGroup_nwf7i_6"
|
|
1860
|
-
},
|
|
1861
|
-
let o = n ?? (r === "radio" ? "radio" : "select"), { state: { sortableFields: s, sortBy: c, sortAscending: l }, setSort: u, isFetchingInitial: d } =
|
|
1862
|
-
if (d) return /* @__PURE__ */ f(
|
|
2063
|
+
}, Fe = ({ options: e, noneLabel: t = "None", control: n, displayType: r, collapsible: i = !0, startCollapsed: a = !1 }) => {
|
|
2064
|
+
let o = n ?? (r === "radio" ? "radio" : "select"), { state: { sortableFields: s, sortBy: c, sortAscending: l }, setSort: u, isFetchingInitial: d } = q();
|
|
2065
|
+
if (d) return /* @__PURE__ */ f(ve, {
|
|
1863
2066
|
title: "Sort by",
|
|
1864
2067
|
rows: o === "radio" ? 3 : 1,
|
|
1865
2068
|
collapsible: i,
|
|
@@ -1878,36 +2081,36 @@ var ge = {
|
|
|
1878
2081
|
}]), h = t === null ? m : [{
|
|
1879
2082
|
label: t,
|
|
1880
2083
|
value: "none"
|
|
1881
|
-
}, ...m],
|
|
2084
|
+
}, ...m], g = (e) => {
|
|
1882
2085
|
if (e === "none" || e === "") u(null, !0);
|
|
1883
2086
|
else {
|
|
1884
2087
|
let [t, n] = e.split(":");
|
|
1885
2088
|
u(t, n === "asc");
|
|
1886
2089
|
}
|
|
1887
2090
|
};
|
|
1888
|
-
return /* @__PURE__ */ f(
|
|
2091
|
+
return /* @__PURE__ */ f(_, {
|
|
1889
2092
|
title: "Sort by",
|
|
1890
2093
|
collapsible: i,
|
|
1891
2094
|
collapsed: i ? a : !1,
|
|
1892
|
-
children: o === "select" ? /* @__PURE__ */ f(
|
|
2095
|
+
children: o === "select" ? /* @__PURE__ */ f(x, {
|
|
1893
2096
|
value: p,
|
|
1894
|
-
onValueChange:
|
|
2097
|
+
onValueChange: g,
|
|
1895
2098
|
options: h,
|
|
1896
2099
|
placeholder: "Select sort...",
|
|
1897
2100
|
"aria-label": "Sort by"
|
|
1898
2101
|
}) : /* @__PURE__ */ f("div", {
|
|
1899
|
-
className:
|
|
1900
|
-
children: h.map((e) => /* @__PURE__ */ f(
|
|
2102
|
+
className: Pe.radioGroup,
|
|
2103
|
+
children: h.map((e) => /* @__PURE__ */ f(y, {
|
|
1901
2104
|
id: `sort-${e.value}`,
|
|
1902
2105
|
name: "sort-by",
|
|
1903
2106
|
value: e.value,
|
|
1904
2107
|
label: e.label,
|
|
1905
2108
|
checked: p === e.value,
|
|
1906
|
-
onChange: (e) =>
|
|
2109
|
+
onChange: (e) => g(e.target.value)
|
|
1907
2110
|
}, e.value))
|
|
1908
2111
|
})
|
|
1909
2112
|
});
|
|
1910
|
-
},
|
|
2113
|
+
}, Ie = { list: "_list_1y4fk_1" }, Le = {
|
|
1911
2114
|
coverageDepth: 500,
|
|
1912
2115
|
coverWholeQuery: !0,
|
|
1913
2116
|
coverWholeWords: !0,
|
|
@@ -1922,8 +2125,8 @@ var ge = {
|
|
|
1922
2125
|
truncateWordHitTolerance: 0,
|
|
1923
2126
|
truncationScore: 65024
|
|
1924
2127
|
};
|
|
1925
|
-
function
|
|
1926
|
-
let { state: { searchSettings: e }, setSearchSettings: t, url: n, team: r, dataset: i, authenticatedFetch: a } =
|
|
2128
|
+
function Re() {
|
|
2129
|
+
let { state: { searchSettings: e }, setSearchSettings: t, url: n, team: r, dataset: i, authenticatedFetch: a } = q(), [s, c] = l(!1), [u, h] = l(null);
|
|
1927
2130
|
o(() => {
|
|
1928
2131
|
let e = !0;
|
|
1929
2132
|
try {
|
|
@@ -1940,7 +2143,7 @@ function be() {
|
|
|
1940
2143
|
i,
|
|
1941
2144
|
a
|
|
1942
2145
|
]);
|
|
1943
|
-
let
|
|
2146
|
+
let g = e.coverageSetup, y = (e) => g[e] !== void 0 && g[e] !== null, b = (e) => g[e] ?? u?.coverageSetup?.[e] ?? Le[e], x = e.coverageDepth ?? u?.coverageDepth ?? Le.coverageDepth, w = u ? "dataset" : "default", D = (e, t) => t ? e : `${e} (${w})`, O = e.coverageDepth !== void 0 || Object.keys(g).some((e) => y(e)), k = (e, n) => {
|
|
1944
2147
|
let r = parseInt(n, 10);
|
|
1945
2148
|
isNaN(r) || t({ [e]: r });
|
|
1946
2149
|
}, A = (e, n) => {
|
|
@@ -1957,25 +2160,25 @@ function be() {
|
|
|
1957
2160
|
[n]: r
|
|
1958
2161
|
} });
|
|
1959
2162
|
};
|
|
1960
|
-
return /* @__PURE__ */ f(
|
|
2163
|
+
return /* @__PURE__ */ f(_, {
|
|
1961
2164
|
collapsed: !0,
|
|
1962
2165
|
title: "Settings",
|
|
1963
2166
|
children: /* @__PURE__ */ p("ul", {
|
|
1964
|
-
className:
|
|
2167
|
+
className: Ie.list,
|
|
1965
2168
|
children: [
|
|
1966
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2169
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(v, {
|
|
1967
2170
|
label: "Max Results",
|
|
1968
2171
|
type: "number",
|
|
1969
2172
|
value: e.maxNumberOfRecordsToReturn.toString(),
|
|
1970
2173
|
onChange: (e) => k("maxNumberOfRecordsToReturn", e.target.value)
|
|
1971
2174
|
}) }),
|
|
1972
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2175
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(v, {
|
|
1973
2176
|
label: D("Coverage Depth", e.coverageDepth !== void 0),
|
|
1974
2177
|
type: "number",
|
|
1975
|
-
value:
|
|
2178
|
+
value: x.toString(),
|
|
1976
2179
|
onChange: (e) => k("coverageDepth", e.target.value)
|
|
1977
2180
|
}) }),
|
|
1978
|
-
/* @__PURE__ */ p("li", { children: [/* @__PURE__ */ f(
|
|
2181
|
+
/* @__PURE__ */ p("li", { children: [/* @__PURE__ */ f(v, {
|
|
1979
2182
|
label: "Minimum Score (16 bit)",
|
|
1980
2183
|
type: "number",
|
|
1981
2184
|
value: e.minimumScore.toString(),
|
|
@@ -1987,7 +2190,7 @@ function be() {
|
|
|
1987
2190
|
}
|
|
1988
2191
|
}), /* @__PURE__ */ f("div", {
|
|
1989
2192
|
style: { padding: "10px 10px 20px 10px" },
|
|
1990
|
-
children: /* @__PURE__ */ f(
|
|
2193
|
+
children: /* @__PURE__ */ f(S, {
|
|
1991
2194
|
min: 0,
|
|
1992
2195
|
max: 65535,
|
|
1993
2196
|
step: 1,
|
|
@@ -1998,7 +2201,7 @@ function be() {
|
|
|
1998
2201
|
"aria-label": "Minimum score"
|
|
1999
2202
|
})
|
|
2000
2203
|
})] }),
|
|
2001
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2204
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(v, {
|
|
2002
2205
|
label: "Placeholder text",
|
|
2003
2206
|
type: "text",
|
|
2004
2207
|
value: e.placeholderText,
|
|
@@ -2006,17 +2209,17 @@ function be() {
|
|
|
2006
2209
|
t({ placeholderText: e.target.value });
|
|
2007
2210
|
}
|
|
2008
2211
|
}) }),
|
|
2009
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2212
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(C, {
|
|
2010
2213
|
label: "Show score",
|
|
2011
2214
|
checked: e.showScore,
|
|
2012
2215
|
onChange: (e) => A("showScore", e)
|
|
2013
2216
|
}) }),
|
|
2014
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2217
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(C, {
|
|
2015
2218
|
label: "Enable Coverage",
|
|
2016
2219
|
checked: e.enableCoverage,
|
|
2017
2220
|
onChange: (e) => A("enableCoverage", e)
|
|
2018
2221
|
}) }),
|
|
2019
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2222
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(C, {
|
|
2020
2223
|
label: "Remove Duplicates",
|
|
2021
2224
|
checked: e.removeDuplicates,
|
|
2022
2225
|
onChange: (e) => A("removeDuplicates", e)
|
|
@@ -2024,65 +2227,65 @@ function be() {
|
|
|
2024
2227
|
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(m, {
|
|
2025
2228
|
variant: "ghost",
|
|
2026
2229
|
size: "micro",
|
|
2027
|
-
iconRight: f(s ?
|
|
2230
|
+
iconRight: f(s ? T : E, {}),
|
|
2028
2231
|
onClick: () => c((e) => !e),
|
|
2029
2232
|
children: s ? "Hide Coverage Setup" : "Show Coverage Setup"
|
|
2030
2233
|
}) }),
|
|
2031
2234
|
s && /* @__PURE__ */ p(d, { children: [
|
|
2032
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2235
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(C, {
|
|
2033
2236
|
label: D("Cover Whole Query", y("coverWholeQuery")),
|
|
2034
2237
|
checked: b("coverWholeQuery"),
|
|
2035
2238
|
onChange: (e) => M("coverWholeQuery", e)
|
|
2036
2239
|
}) }),
|
|
2037
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2240
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(C, {
|
|
2038
2241
|
label: D("Cover Whole Words", y("coverWholeWords")),
|
|
2039
2242
|
checked: b("coverWholeWords"),
|
|
2040
2243
|
onChange: (e) => M("coverWholeWords", e)
|
|
2041
2244
|
}) }),
|
|
2042
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2245
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(C, {
|
|
2043
2246
|
label: D("Cover Fuzzy Words", y("coverFuzzyWords")),
|
|
2044
2247
|
checked: b("coverFuzzyWords"),
|
|
2045
2248
|
onChange: (e) => M("coverFuzzyWords", e)
|
|
2046
2249
|
}) }),
|
|
2047
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2250
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(C, {
|
|
2048
2251
|
label: D("Cover Joined Words", y("coverJoinedWords")),
|
|
2049
2252
|
checked: b("coverJoinedWords"),
|
|
2050
2253
|
onChange: (e) => M("coverJoinedWords", e)
|
|
2051
2254
|
}) }),
|
|
2052
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2255
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(C, {
|
|
2053
2256
|
label: D("Cover Prefix Suffix", y("coverPrefixSuffix")),
|
|
2054
2257
|
checked: b("coverPrefixSuffix"),
|
|
2055
2258
|
onChange: (e) => M("coverPrefixSuffix", e)
|
|
2056
2259
|
}) }),
|
|
2057
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2260
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(C, {
|
|
2058
2261
|
label: D("Truncate", y("truncate")),
|
|
2059
2262
|
checked: b("truncate"),
|
|
2060
2263
|
onChange: (e) => M("truncate", e)
|
|
2061
2264
|
}) }),
|
|
2062
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2265
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(C, {
|
|
2063
2266
|
label: D("Include Pattern Matches", y("includePatternMatches")),
|
|
2064
2267
|
checked: b("includePatternMatches"),
|
|
2065
2268
|
onChange: (e) => M("includePatternMatches", e)
|
|
2066
2269
|
}) }),
|
|
2067
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2270
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(v, {
|
|
2068
2271
|
label: D("Levenshtein Max Word Size", y("levenshteinMaxWordSize")),
|
|
2069
2272
|
type: "number",
|
|
2070
2273
|
value: b("levenshteinMaxWordSize").toString(),
|
|
2071
2274
|
onChange: (e) => j("levenshteinMaxWordSize", e.target.value)
|
|
2072
2275
|
}) }),
|
|
2073
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2276
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(v, {
|
|
2074
2277
|
label: D("Min Word Size", y("minWordSize")),
|
|
2075
2278
|
type: "number",
|
|
2076
2279
|
value: b("minWordSize").toString(),
|
|
2077
2280
|
onChange: (e) => j("minWordSize", e.target.value)
|
|
2078
2281
|
}) }),
|
|
2079
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2282
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(v, {
|
|
2080
2283
|
label: D("Truncate Word Hit Limit", y("truncateWordHitLimit")),
|
|
2081
2284
|
type: "number",
|
|
2082
2285
|
value: b("truncateWordHitLimit").toString(),
|
|
2083
2286
|
onChange: (e) => j("truncateWordHitLimit", e.target.value)
|
|
2084
2287
|
}) }),
|
|
2085
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2288
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(v, {
|
|
2086
2289
|
label: D("Truncate Word Hit Tolerance", y("truncateWordHitTolerance")),
|
|
2087
2290
|
type: "number",
|
|
2088
2291
|
value: b("truncateWordHitTolerance").toString(),
|
|
@@ -2104,7 +2307,7 @@ function be() {
|
|
|
2104
2307
|
}
|
|
2105
2308
|
//#endregion
|
|
2106
2309
|
//#region src/components/SearchErrorBoundary.tsx
|
|
2107
|
-
var
|
|
2310
|
+
var ze = class extends t {
|
|
2108
2311
|
constructor(e) {
|
|
2109
2312
|
super(e), this.state = {
|
|
2110
2313
|
hasError: !1,
|
|
@@ -2186,8 +2389,8 @@ var xe = class extends t {
|
|
|
2186
2389
|
};
|
|
2187
2390
|
//#endregion
|
|
2188
2391
|
//#region src/hooks/useVectorSearch.ts
|
|
2189
|
-
function
|
|
2190
|
-
let { url: n, team: r, dataset: a, authenticatedFetch: o } =
|
|
2392
|
+
function Be(e, t) {
|
|
2393
|
+
let { url: n, team: r, dataset: a, authenticatedFetch: o } = q(), [s, c] = l(null), [u, d] = l(!1), [f, p] = l(void 0);
|
|
2191
2394
|
return {
|
|
2192
2395
|
results: s,
|
|
2193
2396
|
isLoading: u,
|
|
@@ -2206,7 +2409,7 @@ function Se(e, t) {
|
|
|
2206
2409
|
headers: { "Content-Type": "application/json" },
|
|
2207
2410
|
body: JSON.stringify(l)
|
|
2208
2411
|
});
|
|
2209
|
-
if (!u.ok) throw await
|
|
2412
|
+
if (!u.ok) throw await R.fromResponse("VectorSearch", u);
|
|
2210
2413
|
let d = await u.json();
|
|
2211
2414
|
if (d.length === 0) {
|
|
2212
2415
|
c([]);
|
|
@@ -2217,7 +2420,7 @@ function Se(e, t) {
|
|
|
2217
2420
|
headers: { "Content-Type": "application/json" },
|
|
2218
2421
|
body: JSON.stringify(f)
|
|
2219
2422
|
});
|
|
2220
|
-
if (!p.ok) throw await
|
|
2423
|
+
if (!p.ok) throw await R.fromResponse("GetJson", p);
|
|
2221
2424
|
c((await p.json()).map((e, t) => ({
|
|
2222
2425
|
document: e,
|
|
2223
2426
|
documentKey: f[t],
|
|
@@ -2242,8 +2445,8 @@ function Se(e, t) {
|
|
|
2242
2445
|
}
|
|
2243
2446
|
//#endregion
|
|
2244
2447
|
//#region src/hooks/useHybridSearch.ts
|
|
2245
|
-
function
|
|
2246
|
-
let { url: n, team: r, dataset: a, authenticatedFetch: o } =
|
|
2448
|
+
function Ve(e, t) {
|
|
2449
|
+
let { url: n, team: r, dataset: a, authenticatedFetch: o } = q(), [s, c] = l(null), [u, d] = l(!1), [f, p] = l(void 0);
|
|
2247
2450
|
return {
|
|
2248
2451
|
results: s,
|
|
2249
2452
|
isLoading: u,
|
|
@@ -2264,7 +2467,7 @@ function Ce(e, t) {
|
|
|
2264
2467
|
headers: { "Content-Type": "application/json" },
|
|
2265
2468
|
body: JSON.stringify(l)
|
|
2266
2469
|
});
|
|
2267
|
-
if (!u.ok) throw await
|
|
2470
|
+
if (!u.ok) throw await R.fromResponse("HybridSearch", u);
|
|
2268
2471
|
let d = await u.json();
|
|
2269
2472
|
if (d.length === 0) {
|
|
2270
2473
|
c([]);
|
|
@@ -2275,7 +2478,7 @@ function Ce(e, t) {
|
|
|
2275
2478
|
headers: { "Content-Type": "application/json" },
|
|
2276
2479
|
body: JSON.stringify(f)
|
|
2277
2480
|
});
|
|
2278
|
-
if (!p.ok) throw await
|
|
2481
|
+
if (!p.ok) throw await R.fromResponse("GetJson", p);
|
|
2279
2482
|
c((await p.json()).map((e, t) => ({
|
|
2280
2483
|
document: e,
|
|
2281
2484
|
documentKey: f[t],
|
|
@@ -2301,4 +2504,4 @@ function Ce(e, t) {
|
|
|
2301
2504
|
};
|
|
2302
2505
|
}
|
|
2303
2506
|
//#endregion
|
|
2304
|
-
export {
|
|
2507
|
+
export { Ne as ActiveFiltersPanel, Oe as BucketFilterPanel, ve as FilterPanelSkeleton, R as IndxApiError, Ee as RangeFilterPanel, K as SearchContext, ze as SearchErrorBoundary, re as SearchInput, ne as SearchProvider, se as SearchResult, he as SearchResultRow, pe as SearchResults, Y as SearchResultsMessage, ue as SearchResultsSkeleton, Re as SearchSettingsPanel, z as SearchSetupError, Fe as SortByPanel, xe as ValueFilterPanel, B as describeSearchError, Ve as useHybridSearch, q as useSearch, q as useSearchContext, Be as useVectorSearch };
|