col-browser 2.9.0 → 2.10.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.
Files changed (63) hide show
  1. package/README.md +29 -1
  2. package/basemap/style.json +1 -1
  3. package/es/bibtex.js +1 -1
  4. package/es/chunks/{BibTex-Bmiqb90o.js → BibTex-2E8oB2c5.js} +2 -2
  5. package/es/chunks/{BibTex-Bmiqb90o.js.map → BibTex-2E8oB2c5.js.map} +1 -1
  6. package/es/chunks/{DatasetCitation-BtDwIIDX.js → DatasetCitation-CqEmtLlj.js} +3 -3
  7. package/es/chunks/{DatasetCitation-BtDwIIDX.js.map → DatasetCitation-CqEmtLlj.js.map} +1 -1
  8. package/es/chunks/{DatasetlogoWithFallback-CMPmcG2C.js → DatasetlogoWithFallback-DLNEhUlR.js} +2 -2
  9. package/es/chunks/{DatasetlogoWithFallback-CMPmcG2C.js.map → DatasetlogoWithFallback-DLNEhUlR.js.map} +1 -1
  10. package/es/chunks/Distributions-mIlSFgUC.js +230 -0
  11. package/es/chunks/Distributions-mIlSFgUC.js.map +1 -0
  12. package/es/chunks/{ErrorMsg-B-kvpMgH.js → ErrorMsg-Co668fRd.js} +8 -7
  13. package/es/chunks/{ErrorMsg-B-kvpMgH.js.map → ErrorMsg-Co668fRd.js.map} +1 -1
  14. package/es/chunks/{MetricsPresentation-DKCJQOtf.js → MetricsPresentation-D0lWPxCu.js} +2 -2
  15. package/es/chunks/{MetricsPresentation-DKCJQOtf.js.map → MetricsPresentation-D0lWPxCu.js.map} +1 -1
  16. package/es/chunks/{TaxonBreakdown-CILXbINQ.js → TaxonBreakdown-C2tMPpaB.js} +16 -15
  17. package/es/chunks/{TaxonBreakdown-CILXbINQ.js.map → TaxonBreakdown-C2tMPpaB.js.map} +1 -1
  18. package/es/chunks/{XrGutter-CPe8vyRy.js → XrGutter-CQdnOGIa.js} +2 -2
  19. package/es/chunks/{XrGutter-CPe8vyRy.js.map → XrGutter-CQdnOGIa.js.map} +1 -1
  20. package/es/chunks/client-CTn6s1A6.js +57 -0
  21. package/es/chunks/client-CTn6s1A6.js.map +1 -0
  22. package/es/chunks/{config-DFtvmQdF.js → config-9UwXwMRq.js} +2 -2
  23. package/es/chunks/{config-DFtvmQdF.js.map → config-9UwXwMRq.js.map} +1 -1
  24. package/es/chunks/{dataset-BKggpI8E.js → dataset-Dz2EA1A4.js} +3 -3
  25. package/es/chunks/{dataset-BKggpI8E.js.map → dataset-Dz2EA1A4.js.map} +1 -1
  26. package/es/chunks/{enumeration-aHxx2gjA.js → enumeration-DV0R7nXc.js} +3 -3
  27. package/es/chunks/{enumeration-aHxx2gjA.js.map → enumeration-DV0R7nXc.js.map} +1 -1
  28. package/es/chunks/index-CJZY-Eu5.js +1107 -0
  29. package/es/chunks/index-CJZY-Eu5.js.map +1 -0
  30. package/es/chunks/router-2hWSOoof.js +56 -0
  31. package/es/chunks/router-2hWSOoof.js.map +1 -0
  32. package/es/chunks/{sector-DdCBeUzI.js → sector-CRBn67UW.js} +3 -3
  33. package/es/chunks/{sector-DdCBeUzI.js.map → sector-CRBn67UW.js.map} +1 -1
  34. package/es/col-browser.css +1 -1
  35. package/es/config.js +1 -1
  36. package/es/index.js +1 -1
  37. package/es/map.js +30 -0
  38. package/es/map.js.map +1 -0
  39. package/es/search.js +99 -98
  40. package/es/search.js.map +1 -1
  41. package/es/sourceDataset.js +24 -23
  42. package/es/sourceDataset.js.map +1 -1
  43. package/es/sourceDatasetList.js +29 -28
  44. package/es/sourceDatasetList.js.map +1 -1
  45. package/es/taxon.js +52 -51
  46. package/es/taxon.js.map +1 -1
  47. package/es/taxonBreakdown.js +9 -8
  48. package/es/taxonBreakdown.js.map +1 -1
  49. package/es/taxonDistribution.js +18 -17
  50. package/es/taxonDistribution.js.map +1 -1
  51. package/es/tree.js +9 -8
  52. package/es/tree.js.map +1 -1
  53. package/package.json +5 -1
  54. package/types/map.d.ts +99 -0
  55. package/umd/col-browser.js +974 -233
  56. package/umd/col-browser.js.map +1 -1
  57. package/umd/col-browser.min.js +5 -5
  58. package/umd/col-browser.min.js.map +1 -1
  59. package/umd/main.css +2 -23
  60. package/es/chunks/Distributions-D_yRCeZ3.js +0 -1232
  61. package/es/chunks/Distributions-D_yRCeZ3.js.map +0 -1
  62. package/es/chunks/router-CssZk5qZ.js +0 -109
  63. package/es/chunks/router-CssZk5qZ.js.map +0 -1
@@ -0,0 +1,1107 @@
1
+ import { j as o } from "./jsx-runtime-BzflLqGi.js";
2
+ import { useState as I, useEffect as F, useRef as k, useMemo as q } from "react";
3
+ import * as H from "maplibre-gl";
4
+ import "maplibre-gl/dist/maplibre-gl.css";
5
+ import { c as M } from "./config-9UwXwMRq.js";
6
+ import { c as wt } from "./client-CTn6s1A6.js";
7
+ import { r as Lt, w as Ct } from "./storage-BgdCo9fV.js";
8
+ import { Segmented as kt, Tooltip as It } from "antd";
9
+ const ae = [
10
+ "subspecies",
11
+ "variety",
12
+ "subvariety",
13
+ "form",
14
+ "subform",
15
+ "infraspecific name"
16
+ ], We = (e, n) => {
17
+ const i = n.indexOf(e);
18
+ return i === -1 ? [] : ae.filter((s) => n.indexOf(s) > i);
19
+ }, jt = 16, Et = (e) => {
20
+ var n, i;
21
+ return ((n = e == null ? void 0 : e.area) == null ? void 0 : n.gazetteer) !== "text" && !!((i = e == null ? void 0 : e.area) != null && i.globalId);
22
+ }, Rt = async (e, n, i) => {
23
+ const s = new Array(e.length);
24
+ let c = 0;
25
+ const d = Array.from({ length: Math.min(i, e.length) }, async () => {
26
+ for (; ; ) {
27
+ const g = c++;
28
+ if (g >= e.length) return;
29
+ s[g] = await n(e[g], g);
30
+ }
31
+ });
32
+ return await Promise.all(d), s;
33
+ }, Ft = (e) => wt(e).then((n) => n == null ? void 0 : n.data), Gt = async (e, n, i, s) => {
34
+ var u;
35
+ if (s.length === 0) return [];
36
+ const c = new URLSearchParams();
37
+ c.append("TAXON_ID", i), s.forEach((l) => c.append("rank", l)), ["accepted", "provisionally accepted"].forEach(
38
+ (l) => c.append("status", l)
39
+ ), c.append("limit", "1000");
40
+ const d = `${M.dataApi}dataset/${n}/nameusage/search?${c}`;
41
+ return (((u = await e(d)) == null ? void 0 : u.result) || []).filter((l) => {
42
+ var p;
43
+ return (p = l == null ? void 0 : l.usage) == null ? void 0 : p.id;
44
+ }).map((l) => {
45
+ var p, f, v, C, N, m;
46
+ return {
47
+ id: l.usage.id,
48
+ scientificName: ((f = (p = l.usage) == null ? void 0 : p.name) == null ? void 0 : f.scientificName) || ((v = l.usage) == null ? void 0 : v.label) || l.usage.id,
49
+ rank: (N = (C = l.usage) == null ? void 0 : C.name) == null ? void 0 : N.rank,
50
+ parentId: (m = l.usage) == null ? void 0 : m.parentId
51
+ };
52
+ });
53
+ }, Mt = async (e, n, i) => {
54
+ const s = `${M.dataApi}dataset/${n}/taxon/${encodeURIComponent(i)}/distribution`;
55
+ try {
56
+ const c = await e(s);
57
+ return Array.isArray(c) ? c : [];
58
+ } catch {
59
+ return [];
60
+ }
61
+ }, Nt = async ({
62
+ datasetKey: e,
63
+ focalTaxon: n,
64
+ rankOrder: i,
65
+ fetchJson: s = Ft
66
+ }) => {
67
+ var p;
68
+ const c = We((p = n == null ? void 0 : n.name) == null ? void 0 : p.rank, i);
69
+ let d = !1, g = [];
70
+ try {
71
+ g = await Gt(s, e, n.id, c);
72
+ } catch {
73
+ return d = !0, { taxa: [], descendantsFailed: d };
74
+ }
75
+ const u = await Rt(
76
+ g,
77
+ (f) => Mt(s, e, f.id),
78
+ jt
79
+ );
80
+ return { taxa: g.map((f, v) => {
81
+ const C = u[v] || [];
82
+ return { ...f, distributions: C, mappable: C.filter(Et) };
83
+ }), descendantsFailed: d };
84
+ }, Ae = [
85
+ "#E58606",
86
+ "#5D69B1",
87
+ "#52BCA3",
88
+ "#99C945",
89
+ "#CC61B0",
90
+ "#24796C",
91
+ "#DAA51B",
92
+ "#2F8AC4",
93
+ "#764E9F",
94
+ "#ED645A",
95
+ "#CC3A8E",
96
+ "#A5AA99"
97
+ ], Pe = (e, n) => {
98
+ const i = n.indexOf(e);
99
+ return i === -1 ? n.length : i;
100
+ }, _t = (e, n) => {
101
+ const i = [...e].sort((c, d) => {
102
+ const g = Pe(c.rank, n), u = Pe(d.rank, n);
103
+ return g !== u ? g - u : c.scientificName.localeCompare(d.scientificName);
104
+ }), s = {};
105
+ return i.forEach((c, d) => {
106
+ s[c.id] = Ae[d % Ae.length];
107
+ }), s;
108
+ }, $t = (e) => e ?? M.basemapStyle, At = /(^|\.)cartocdn\.com$/i, Pt = (e = M.cartoKey) => {
109
+ if (e)
110
+ return (n) => {
111
+ let i;
112
+ try {
113
+ i = new URL(n);
114
+ } catch {
115
+ return { url: n };
116
+ }
117
+ return !At.test(i.hostname) || i.searchParams.has("key") ? { url: n } : (i.searchParams.set("key", e), { url: i.toString() });
118
+ };
119
+ }, yn = "7ddf754f-d193-4cc9-b351-99906754a03b", Te = "hasCoordinate=true&hasGeospatialIssue=false&occurrenceStatus=PRESENT", Ke = (e, n) => `checklistKey=${encodeURIComponent(e)}&taxonKey=${encodeURIComponent(n)}`, Bt = (e, n) => `${M.gbifApi}/v2/map/occurrence/density/{z}/{x}/{y}@1x.png?srs=EPSG%3A3857&style=iNaturalist.poly&bin=hex&hexPerTile=64&${Te}&${Ke(e, n)}`, zt = (e, n) => `${M.gbifPortal}/occurrence/search?checklist_key=${encodeURIComponent(
120
+ e
121
+ )}&taxon_key=${encodeURIComponent(
122
+ n
123
+ )}&has_coordinate=true&has_geospatial_issue=false&occurrence_status=present`, Ot = async (e, n) => {
124
+ var i;
125
+ try {
126
+ const s = await fetch(
127
+ `${M.gbifApi}/v1/occurrence/search?${Ke(e, n)}&${Te}&limit=0`
128
+ );
129
+ return s.ok ? ((i = await s.json()) == null ? void 0 : i.count) ?? 0 : null;
130
+ } catch {
131
+ return null;
132
+ }
133
+ }, bn = (e, n) => {
134
+ const [i, s] = I(null);
135
+ return F(() => {
136
+ if (s(null), !e || !n) return;
137
+ let c = !1;
138
+ return Ot(e, n).then((d) => {
139
+ c || s(d);
140
+ }), () => {
141
+ c = !0;
142
+ };
143
+ }, [e, n]), i;
144
+ }, Ze = ({ style: e }) => /* @__PURE__ */ o.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 6, ...e }, children: [
145
+ /* @__PURE__ */ o.jsx("svg", { width: "12", height: "12", viewBox: "0 0 12 12", "aria-hidden": "true", children: /* @__PURE__ */ o.jsx(
146
+ "polygon",
147
+ {
148
+ points: "3,1 9,1 11,6 9,11 3,11 1,6",
149
+ fill: "#de1e6e",
150
+ stroke: "rgba(0,0,0,0.25)",
151
+ strokeWidth: "0.75"
152
+ }
153
+ ) }),
154
+ /* @__PURE__ */ o.jsx("span", { children: "GBIF occurrences" })
155
+ ] }), Dt = {
156
+ position: "absolute",
157
+ bottom: 8,
158
+ left: 8,
159
+ zIndex: 1e3,
160
+ background: "#fff",
161
+ borderRadius: 4,
162
+ boxShadow: "0 1px 4px rgba(0,0,0,0.2)",
163
+ padding: "6px 8px",
164
+ fontSize: 12,
165
+ lineHeight: 1.5,
166
+ maxWidth: 260
167
+ }, Ht = {
168
+ maxHeight: 240,
169
+ overflowY: "auto"
170
+ }, qe = {
171
+ fontWeight: 600,
172
+ marginTop: 4
173
+ }, Ut = {
174
+ ...qe,
175
+ marginTop: 0
176
+ }, Be = {
177
+ display: "flex",
178
+ alignItems: "center",
179
+ gap: 6,
180
+ paddingLeft: 4
181
+ }, Vt = (e) => ({
182
+ display: "inline-block",
183
+ width: 12,
184
+ height: 12,
185
+ background: e,
186
+ border: "1px solid rgba(0,0,0,0.15)",
187
+ borderRadius: 2,
188
+ flex: "0 0 auto"
189
+ }), Wt = {
190
+ marginTop: 6,
191
+ cursor: "pointer",
192
+ color: "#1890ff",
193
+ fontSize: 11
194
+ }, Tt = {
195
+ marginTop: 4,
196
+ borderTop: "1px solid #eee",
197
+ paddingTop: 4,
198
+ color: "#666"
199
+ }, Ye = {
200
+ fontWeight: 600,
201
+ marginTop: 4
202
+ }, Kt = {
203
+ ...Ye,
204
+ marginTop: 0
205
+ }, Zt = {
206
+ fontStyle: "italic",
207
+ paddingLeft: 4
208
+ }, ze = (e) => e.reduce((n, i) => n + i.taxa.length, 0), qt = ({ visibleGroups: e, unmappableGroups: n, showGbif: i }) => {
209
+ const [s, c] = I(!1), d = ze(e), g = ze(n);
210
+ return d === 0 && g === 0 && !i ? null : /* @__PURE__ */ o.jsxs("div", { style: Dt, children: [
211
+ /* @__PURE__ */ o.jsxs("div", { style: Ht, children: [
212
+ e.map((u, l) => /* @__PURE__ */ o.jsxs("div", { children: [
213
+ /* @__PURE__ */ o.jsx("div", { style: l === 0 ? Ut : qe, children: u.label }),
214
+ u.taxa.map((p) => /* @__PURE__ */ o.jsxs("div", { style: Be, children: [
215
+ /* @__PURE__ */ o.jsx("span", { style: Vt(p.color) }),
216
+ /* @__PURE__ */ o.jsx("span", { style: { fontStyle: "italic" }, children: p.displayName || p.scientificName })
217
+ ] }, p.id))
218
+ ] }, u.rank)),
219
+ i && /* @__PURE__ */ o.jsx(Ze, { style: Be })
220
+ ] }),
221
+ g > 0 && /* @__PURE__ */ o.jsxs(o.Fragment, { children: [
222
+ /* @__PURE__ */ o.jsxs(
223
+ "div",
224
+ {
225
+ style: Wt,
226
+ onClick: () => c((u) => !u),
227
+ children: [
228
+ s ? "− Hide" : "+",
229
+ " ",
230
+ g,
231
+ " without map data"
232
+ ]
233
+ }
234
+ ),
235
+ s && /* @__PURE__ */ o.jsx("div", { style: Tt, children: n.map((u, l) => /* @__PURE__ */ o.jsxs("div", { children: [
236
+ /* @__PURE__ */ o.jsx(
237
+ "div",
238
+ {
239
+ style: l === 0 ? Kt : Ye,
240
+ children: u.label
241
+ }
242
+ ),
243
+ u.taxa.map((p) => /* @__PURE__ */ o.jsx("div", { style: Zt, children: p.displayName || p.scientificName }, p.id))
244
+ ] }, u.rank)) })
245
+ ] })
246
+ ] });
247
+ };
248
+ let fe = null;
249
+ const Yt = () => {
250
+ var e, n;
251
+ if (typeof window > "u" || !window.WebGL2RenderingContext)
252
+ return !1;
253
+ try {
254
+ const s = document.createElement("canvas").getContext("webgl2");
255
+ return !s || typeof s.getParameter != "function" ? !1 : ((n = (e = s.getExtension) == null ? void 0 : e.call(s, "WEBGL_lose_context")) == null || n.loseContext(), !0);
256
+ } catch {
257
+ return !1;
258
+ }
259
+ }, Oe = () => (fe === null && (fe = Yt()), fe), Je = (e) => {
260
+ var g;
261
+ let n = 1 / 0, i = 1 / 0, s = -1 / 0, c = -1 / 0;
262
+ const d = (u) => {
263
+ if (typeof u[0] == "number") {
264
+ const [l, p] = u;
265
+ l < n && (n = l), l > s && (s = l), p < i && (i = p), p > c && (c = p);
266
+ } else
267
+ for (let l = 0; l < u.length; l++) d(u[l]);
268
+ };
269
+ for (let u = 0; u < e.length; u++) {
270
+ const l = (g = e[u]) == null ? void 0 : g.geometry;
271
+ l != null && l.coordinates && d(l.coordinates);
272
+ }
273
+ return n === 1 / 0 ? null : [
274
+ [n, i],
275
+ [s, c]
276
+ ];
277
+ }, De = (e) => e ? e.type === "FeatureCollection" ? e.features || [] : [e] : [], Qe = (e) => {
278
+ switch (e == null ? void 0 : e.type) {
279
+ case "Polygon":
280
+ return [e.coordinates];
281
+ case "MultiPolygon":
282
+ return e.coordinates;
283
+ case "MultiLineString":
284
+ case "LineString":
285
+ case "MultiPoint":
286
+ case "Point":
287
+ return [e.coordinates];
288
+ case "GeometryCollection":
289
+ return (e.geometries || []).flatMap(Qe);
290
+ default:
291
+ return [];
292
+ }
293
+ }, xn = (e) => {
294
+ const n = e.flatMap((f) => Qe(f == null ? void 0 : f.geometry)).map((f) => Je([{ geometry: { coordinates: f } }])).filter(Boolean);
295
+ if (n.length === 0) return null;
296
+ const i = Math.min(...n.map(([f]) => f[1])), s = Math.max(...n.map(([, f]) => f[1])), c = n.map(([f, v]) => [f[0], v[0]]).sort((f, v) => f[0] - v[0]);
297
+ let d = Math.max(...c.map(([, f]) => f)), g = c[0][0] + 360 - d, u = c[0][0], l = d, p = c[0][1];
298
+ for (let f = 1; f < c.length; f++) {
299
+ const v = c[f][0] - p;
300
+ v > g && (g = v, u = c[f][0], l = p + 360), p = Math.max(p, c[f][1]);
301
+ }
302
+ return [
303
+ [u, i],
304
+ [l, s]
305
+ ];
306
+ }, Xe = [
307
+ { key: "nativeendemic", label: "Native endemic", color: "#0F8554" },
308
+ { key: "native", label: "Native", color: "#87C55F" },
309
+ { key: "nativereintroduced", label: "Native reintroduced", color: "#C9DB74" },
310
+ { key: "introduced", label: "Introduced", color: "#FE88B1" },
311
+ {
312
+ key: "introducedassistedcolonisation",
313
+ label: "Introduced assisted colonisation",
314
+ color: "#DCB0F2"
315
+ },
316
+ { key: "vagrant", label: "Vagrant", color: "#F6CF71" },
317
+ { key: "uncertain", label: "Uncertain", color: "#8BE0A4" }
318
+ ], et = Object.fromEntries(Xe.map((e) => [e.key, e.color])), oe = "#66C5CC", tt = (e) => {
319
+ if (e == null || e === "") return null;
320
+ const n = String(e).toLowerCase().replace(/[^a-z]/g, "");
321
+ return et[n] ? n : "uncertain";
322
+ }, Jt = (e) => {
323
+ const n = tt(e);
324
+ return n == null ? oe : et[n];
325
+ }, ie = "land", be = "eez", ye = (e) => (e == null ? void 0 : e.gazetteer) === "iso" && /^[A-Z]{2}$/i.test((e == null ? void 0 : e.id) || ""), Qt = (e, n = ie) => `${M.dataApi}vocab/area/${e.gazetteer}:${encodeURIComponent(
326
+ e.id
327
+ )}.geojson${n === be && ye(e) ? "?variant=eez" : ""}`, Xt = (e) => Array.isArray(e) && e.some((n) => String(n).toLowerCase() === "marine"), en = (e) => Xt(e) ? be : ie, he = /* @__PURE__ */ new Map(), He = (e, n = ie) => {
328
+ const i = Qt(e, n);
329
+ return he.has(i) || he.set(
330
+ i,
331
+ fetch(i).then((s) => s.ok ? s.json() : null).catch(() => null)
332
+ ), he.get(i);
333
+ }, tn = [
334
+ { label: "Land", value: ie },
335
+ {
336
+ label: /* @__PURE__ */ o.jsx(It, { title: "Countries with their exclusive economic zone, as GBIF uses them", children: "EEZ" }),
337
+ value: be
338
+ }
339
+ ], nn = ({ value: e, onChange: n, style: i }) => /* @__PURE__ */ o.jsx(
340
+ kt,
341
+ {
342
+ size: "small",
343
+ options: tn,
344
+ value: e,
345
+ onChange: n,
346
+ style: i
347
+ }
348
+ ), sn = [
349
+ "establishmentMeans",
350
+ "degreeOfEstablishment",
351
+ "pathway",
352
+ "threatStatus",
353
+ "year",
354
+ "lifeStage"
355
+ ], rn = (e) => Jt(e == null ? void 0 : e.establishmentMeans), nt = "gbif-visible", an = (e) => Lt(nt, e), Ue = (e) => Ct(nt, e), Y = "col-focal-distributions", U = "col-focal-fill", ge = "col-focal-line", re = "col-gbif-occurrences", G = "col-gbif-occurrences", me = (e) => `col-descendant-${e}`, J = (e) => `col-descendant-fill-${e}`, Q = (e) => `col-descendant-line-${e}`, X = (e) => String(e).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;"), st = (e) => {
356
+ var s, c;
357
+ const n = ((s = e == null ? void 0 : e.area) == null ? void 0 : s.name) || ((c = e == null ? void 0 : e.area) == null ? void 0 : c.globalId) || "", i = sn.map((d) => [d, e == null ? void 0 : e[d]]).filter(([, d]) => d != null && d !== "").map(
358
+ ([d, g]) => `<div><strong>${X(d)}:</strong> ${X(g)}</div>`
359
+ ).join("");
360
+ return `<div style="min-width:180px"><div style="font-weight:600;margin-bottom:4px">${X(
361
+ n
362
+ )}</div>${i}</div>`;
363
+ }, on = (e, n) => `<div style="font-weight:600;font-style:italic;margin-bottom:4px">${X(
364
+ e.scientificName
365
+ )}</div><div style="color:#888;margin-bottom:4px">${X(e.rank || "")}</div>` + st(n), cn = {
366
+ subspecies: "subspecies",
367
+ variety: "varieties",
368
+ subvariety: "subvarieties",
369
+ form: "forms",
370
+ subform: "subforms",
371
+ "infraspecific name": "infraspecific names"
372
+ }, Ve = (e) => cn[e] || e, rt = (e) => {
373
+ if (!e) return "";
374
+ const n = e.trim().split(/\s+/);
375
+ return n[n.length - 1];
376
+ }, vn = ({
377
+ records: e,
378
+ onUnmappable: n,
379
+ datasetKey: i,
380
+ focalTaxon: s,
381
+ rankOrder: c,
382
+ // GBIF checklist the occurrence layer uses; without one there is no layer.
383
+ gbifChecklistKey: d,
384
+ // The taxon key in that checklist. Defaults to the focal taxon's id, which
385
+ // fits datasets keyed by the same ids as the checklist, e.g. COL releases.
386
+ gbifTaxonKey: g,
387
+ // true | null → show GBIF layer; false → GBIF API returned 0 occurrences,
388
+ // grey out the toggle and skip loading tiles. Defaults to true so the
389
+ // component works without the count check.
390
+ gbifAvailable: u = !0,
391
+ // MapLibre style URL or inline style object; falls back to the global
392
+ // `configure({ basemapStyle })` value. Changing it rebuilds the map.
393
+ basemapStyle: l,
394
+ // Called from the no-WebGL notice to switch the host to its list view.
395
+ onShowList: p,
396
+ showListLabel: f = "Show distributions as a list",
397
+ // `fetchJson(url)` loads the descendants and their distributions. Defaults
398
+ // to the library's client; a host can pass its own to send its credentials.
399
+ fetchJson: v
400
+ }) => {
401
+ var $e;
402
+ const C = k(null), N = k(null), m = k(null), j = k(null), ee = k(/* @__PURE__ */ new Map()), te = k(/* @__PURE__ */ new Map()), E = k(/* @__PURE__ */ new Map()), $ = k(!1), A = k(!1), x = k(/* @__PURE__ */ new Set()), ce = k(null), [at, ot] = I(!1), [P, xe] = I(null), [ve, Se] = I(!1), [S, V] = I({
403
+ status: "idle",
404
+ // idle | loading | ready | empty | error
405
+ taxa: []
406
+ }), [le, it] = I(!0), [we, ct] = I(!1), ne = g ?? (s == null ? void 0 : s.id), B = !!d && !!ne, lt = B && (!e || e.length === 0), [ut, Le] = I(null);
407
+ F(() => Le(null), [s == null ? void 0 : s.id]);
408
+ const W = ut ?? en(s == null ? void 0 : s.environments), dt = q(
409
+ () => (e || []).some((t) => ye(t.area)) || S.taxa.some(
410
+ (t) => t.mappable.some((r) => ye(r.area))
411
+ ),
412
+ [e, S]
413
+ ), [_, Ce] = I(
414
+ () => an(!0)
415
+ ), [z, ke] = I(/* @__PURE__ */ new Set()), [pt, Ie] = I(!1), ue = k(!1), ft = () => {
416
+ Ce((t) => {
417
+ const r = !t;
418
+ return Ue(r), r;
419
+ });
420
+ }, je = () => {
421
+ Ce(!0), Ue(!0);
422
+ }, Ee = q(() => {
423
+ if (!(e != null && e.length)) return [];
424
+ const t = /* @__PURE__ */ new Set();
425
+ return e.forEach((r) => {
426
+ const a = tt(r == null ? void 0 : r.establishmentMeans);
427
+ a != null && t.add(a);
428
+ }), Xe.filter((r) => t.has(r.key));
429
+ }, [e]), T = q(() => S.status !== "ready" ? {} : _t(
430
+ S.taxa.filter((t) => t.mappable.length > 0),
431
+ c || []
432
+ ), [S, c]), de = q(() => {
433
+ if (S.status !== "ready")
434
+ return { visibleGroups: [], unmappableGroups: [] };
435
+ const t = (h) => ({
436
+ ...h,
437
+ color: T[h.id],
438
+ displayName: rt(h.scientificName)
439
+ }), r = (h) => {
440
+ const w = {};
441
+ return h.forEach((b) => {
442
+ (w[b.rank] = w[b.rank] || []).push(t(b));
443
+ }), ae.filter((b) => w[b]).map((b) => ({
444
+ rank: b,
445
+ label: Ve(b),
446
+ taxa: w[b]
447
+ }));
448
+ }, a = r(
449
+ S.taxa.filter(
450
+ (h) => h.mappable.length > 0 && z.has(h.id)
451
+ )
452
+ ), y = r(
453
+ S.taxa.filter((h) => h.mappable.length === 0)
454
+ );
455
+ return { visibleGroups: a, unmappableGroups: y };
456
+ }, [S, T, z]), Re = de.visibleGroups.length > 0, se = $t(l), Fe = M.cartoKey, ht = `${typeof se == "string" ? se : JSON.stringify(se)}|${Fe || ""}`;
457
+ F(() => {
458
+ if (!C.current || m.current || !Oe()) return;
459
+ let t;
460
+ try {
461
+ t = new H.Map({
462
+ container: C.current,
463
+ style: se,
464
+ transformRequest: Pt(Fe),
465
+ center: [0, 20],
466
+ zoom: 1,
467
+ minZoom: 0,
468
+ attributionControl: !1,
469
+ renderWorldCopies: !0
470
+ });
471
+ } catch (a) {
472
+ console.warn("Distribution map disabled:", a), ot(!0);
473
+ return;
474
+ }
475
+ t.addControl(
476
+ new H.AttributionControl({ compact: !0 }),
477
+ "bottom-right"
478
+ ), t.addControl(
479
+ new H.NavigationControl({ showCompass: !1 }),
480
+ "top-left"
481
+ ), t.addControl(
482
+ new H.FullscreenControl({ container: N.current }),
483
+ "top-right"
484
+ ), m.current = t, t.on("load", () => {
485
+ xe(t);
486
+ const a = t.getContainer().querySelector(".maplibregl-ctrl-attrib");
487
+ a && a.classList.remove("maplibregl-compact-show");
488
+ });
489
+ const r = typeof ResizeObserver < "u" ? new ResizeObserver(() => t.resize()) : null;
490
+ return r && r.observe(C.current), () => {
491
+ r && r.disconnect(), j.current && (j.current.remove(), j.current = null), t.remove(), m.current = null, $.current = !1, A.current = !1, x.current = /* @__PURE__ */ new Set(), ce.current = null, xe(null);
492
+ };
493
+ }, [ht]), F(() => {
494
+ const t = () => {
495
+ const r = document.fullscreenElement || document.webkitFullscreenElement;
496
+ ct(!!r && r === N.current);
497
+ };
498
+ return document.addEventListener("fullscreenchange", t), document.addEventListener("webkitfullscreenchange", t), () => {
499
+ document.removeEventListener("fullscreenchange", t), document.removeEventListener("webkitfullscreenchange", t);
500
+ };
501
+ }, []), F(() => {
502
+ const t = P;
503
+ if (!t || !(e != null && e.length)) return;
504
+ let r = !1;
505
+ return Se(!1), Promise.allSettled(
506
+ e.map(
507
+ (a) => He(a.area, W).then((y) => ({
508
+ record: a,
509
+ geojson: y
510
+ }))
511
+ )
512
+ ).then((a) => {
513
+ if (r || m.current !== t) return;
514
+ const y = [], h = /* @__PURE__ */ new Map();
515
+ let w = 0;
516
+ a.forEach((L, R) => {
517
+ if (L.status !== "fulfilled" || !L.value.geojson) {
518
+ w += 1;
519
+ return;
520
+ }
521
+ const { record: O, geojson: D } = L.value, pe = rn(O), K = `focal-${R}`;
522
+ h.set(K, O), De(D).forEach((Z) => {
523
+ y.push({
524
+ ...Z,
525
+ properties: {
526
+ ...Z.properties || {},
527
+ _recordKey: K,
528
+ _color: pe
529
+ }
530
+ });
531
+ });
532
+ }), ee.current = h;
533
+ const b = { type: "FeatureCollection", features: y };
534
+ if (t.getSource(Y))
535
+ t.getSource(Y).setData(b);
536
+ else {
537
+ const L = t.getLayer(G) ? G : void 0;
538
+ t.addSource(Y, { type: "geojson", data: b }), t.addLayer(
539
+ {
540
+ id: U,
541
+ type: "fill",
542
+ source: Y,
543
+ paint: {
544
+ "fill-color": ["coalesce", ["get", "_color"], oe],
545
+ "fill-opacity": 0.65
546
+ }
547
+ },
548
+ L
549
+ ), t.addLayer(
550
+ {
551
+ id: ge,
552
+ type: "line",
553
+ source: Y,
554
+ paint: {
555
+ "line-color": ["coalesce", ["get", "_color"], oe],
556
+ "line-width": 1
557
+ }
558
+ },
559
+ L
560
+ ), t.on("click", U, gt), t.on("mouseenter", U, Ge), t.on("mouseleave", U, Me), $.current = !0;
561
+ }
562
+ if (y.length > 0 && ce.current !== e) {
563
+ ce.current = e;
564
+ const L = Je(y);
565
+ L && t.fitBounds(L, { padding: 20, animate: !1 });
566
+ }
567
+ typeof n == "function" && n(w), Se(!0);
568
+ }), () => {
569
+ r = !0;
570
+ };
571
+ }, [P, e, W]);
572
+ const gt = (t) => {
573
+ var w, b;
574
+ const r = m.current;
575
+ if (!r) return;
576
+ const a = (w = t.features) == null ? void 0 : w[0], y = (b = a == null ? void 0 : a.properties) == null ? void 0 : b._recordKey, h = y ? ee.current.get(y) : null;
577
+ h && (j.current && j.current.remove(), j.current = new H.Popup({ closeButton: !0, maxWidth: "320px" }).setLngLat(t.lngLat).setHTML(st(h)).addTo(r));
578
+ }, Ge = () => {
579
+ const t = m.current;
580
+ t && (t.getCanvas().style.cursor = "pointer");
581
+ }, Me = () => {
582
+ const t = m.current;
583
+ t && (t.getCanvas().style.cursor = "");
584
+ };
585
+ F(() => {
586
+ const t = m.current;
587
+ if (!t || !$.current) return;
588
+ const r = le ? "visible" : "none";
589
+ t.getLayer(U) && t.setLayoutProperty(U, "visibility", r), t.getLayer(ge) && t.setLayoutProperty(ge, "visibility", r);
590
+ }, [le, ve]), F(() => {
591
+ const t = P;
592
+ if (!t || ((() => {
593
+ t.getLayer(G) && t.removeLayer(G), t.getSource(re) && t.removeSource(re), A.current = !1;
594
+ })(), !B) || u === !1) return;
595
+ const a = zt(d, ne);
596
+ t.addSource(re, {
597
+ type: "raster",
598
+ tiles: [Bt(d, ne)],
599
+ tileSize: 256,
600
+ attribution: '<a href="' + a + '" target="_blank" rel="noopener">GBIF</a> occurrence data'
601
+ }), t.addLayer({
602
+ id: G,
603
+ type: "raster",
604
+ source: re,
605
+ paint: { "raster-opacity": 0.9 },
606
+ layout: { visibility: _ ? "visible" : "none" }
607
+ }), A.current = !0;
608
+ }, [P, d, ne, u]), F(() => {
609
+ const t = m.current;
610
+ if (!t || !A.current) return;
611
+ const r = _ ? "visible" : "none";
612
+ t.getLayer(G) && t.setLayoutProperty(G, "visibility", r);
613
+ }, [_]);
614
+ const Ne = (t) => z.has(t) ? "visible" : "none";
615
+ F(() => {
616
+ const t = P;
617
+ if (!t || (x.current.forEach((a) => {
618
+ t.getLayer(J(a)) && t.removeLayer(J(a)), t.getLayer(Q(a)) && t.removeLayer(Q(a)), t.getSource(me(a)) && t.removeSource(me(a));
619
+ }), x.current = /* @__PURE__ */ new Set(), te.current = /* @__PURE__ */ new Map(), E.current = /* @__PURE__ */ new Map(), S.status !== "ready")) return;
620
+ const r = T;
621
+ S.taxa.forEach((a) => {
622
+ a.mappable.length !== 0 && (te.current.set(a.id, a), Promise.allSettled(
623
+ a.mappable.map(
624
+ (y) => He(y.area, W).then((h) => ({
625
+ record: y,
626
+ geojson: h
627
+ }))
628
+ )
629
+ ).then((y) => {
630
+ if (m.current !== t) return;
631
+ const h = [];
632
+ y.forEach((R, O) => {
633
+ if (R.status !== "fulfilled" || !R.value.geojson) return;
634
+ const { record: D, geojson: pe } = R.value, K = `desc-${a.id}-${O}`;
635
+ E.current.set(K, { taxon: a, record: D }), De(pe).forEach((Z) => {
636
+ h.push({
637
+ ...Z,
638
+ properties: {
639
+ ...Z.properties || {},
640
+ _recordKey: K
641
+ }
642
+ });
643
+ });
644
+ });
645
+ const w = r[a.id] || oe, b = { type: "FeatureCollection", features: h }, L = me(a.id);
646
+ if (m.current.getSource(L))
647
+ m.current.getSource(L).setData(b);
648
+ else {
649
+ m.current.addSource(L, { type: "geojson", data: b });
650
+ const R = J(a.id), O = Q(a.id), D = m.current.getLayer(G) ? G : void 0;
651
+ m.current.addLayer(
652
+ {
653
+ id: R,
654
+ type: "fill",
655
+ source: L,
656
+ paint: { "fill-color": w, "fill-opacity": 0.55 },
657
+ layout: { visibility: Ne(a.id) }
658
+ },
659
+ D
660
+ ), m.current.addLayer(
661
+ {
662
+ id: O,
663
+ type: "line",
664
+ source: L,
665
+ paint: { "line-color": w, "line-width": 2 },
666
+ layout: { visibility: Ne(a.id) }
667
+ },
668
+ D
669
+ ), m.current.on("click", R, mt), m.current.on("mouseenter", R, Ge), m.current.on("mouseleave", R, Me), x.current.add(a.id);
670
+ }
671
+ }));
672
+ });
673
+ }, [P, S, T, W]);
674
+ const mt = (t) => {
675
+ var w, b;
676
+ const r = m.current;
677
+ if (!r) return;
678
+ const a = (w = t.features) == null ? void 0 : w[0], y = (b = a == null ? void 0 : a.properties) == null ? void 0 : b._recordKey, h = y ? E.current.get(y) : null;
679
+ h && (j.current && j.current.remove(), j.current = new H.Popup({ closeButton: !0, maxWidth: "320px" }).setLngLat(t.lngLat).setHTML(on(h.taxon, h.record)).addTo(r));
680
+ };
681
+ F(() => {
682
+ const t = m.current;
683
+ t && x.current.forEach((r) => {
684
+ const a = z.has(r) ? "visible" : "none";
685
+ t.getLayer(J(r)) && t.setLayoutProperty(J(r), "visibility", a), t.getLayer(Q(r)) && t.setLayoutProperty(Q(r), "visibility", a);
686
+ });
687
+ }, [z, S]);
688
+ const _e = () => {
689
+ var a;
690
+ if (ue.current || !i || !s || !c) return;
691
+ const t = (a = s == null ? void 0 : s.name) == null ? void 0 : a.rank;
692
+ !t || t !== "species" && !ae.includes(t) || We(t, c).length === 0 || (ue.current = !0, V({ status: "loading", taxa: [] }), Nt({ datasetKey: i, focalTaxon: s, rankOrder: c, fetchJson: v }).then(
693
+ ({ taxa: y, descendantsFailed: h }) => {
694
+ if (h) {
695
+ V({ status: "error", taxa: [] });
696
+ return;
697
+ }
698
+ if (y.length === 0) {
699
+ V({ status: "empty", taxa: [] });
700
+ return;
701
+ }
702
+ V({ status: "ready", taxa: y });
703
+ }
704
+ ));
705
+ }, yt = () => {
706
+ Ie(!0), _e();
707
+ }, bt = q(() => {
708
+ if (S.status !== "ready") return [];
709
+ const t = {};
710
+ return S.taxa.filter((r) => r.mappable.length > 0).forEach((r) => {
711
+ (t[r.rank] = t[r.rank] || []).push(r);
712
+ }), ae.filter((r) => t[r]).map((r) => ({
713
+ rank: r,
714
+ label: Ve(r),
715
+ taxa: t[r].slice().sort(
716
+ (a, y) => a.scientificName.localeCompare(y.scientificName)
717
+ )
718
+ }));
719
+ }, [S]), xt = (t) => {
720
+ ke((r) => {
721
+ const a = new Set(r);
722
+ return a.has(t) ? a.delete(t) : a.add(t), a;
723
+ });
724
+ }, vt = (t) => {
725
+ ke((r) => {
726
+ const a = new Set(r), y = t.every((h) => r.has(h.id));
727
+ return t.forEach((h) => {
728
+ y ? a.delete(h.id) : a.add(h.id);
729
+ }), a;
730
+ });
731
+ };
732
+ if (at || !Oe())
733
+ return /* @__PURE__ */ o.jsxs(
734
+ "div",
735
+ {
736
+ style: {
737
+ padding: 12,
738
+ background: "#fafafa",
739
+ border: "1px solid #eee",
740
+ borderRadius: 4,
741
+ color: "#666",
742
+ fontSize: 12
743
+ },
744
+ children: [
745
+ /* @__PURE__ */ o.jsx("strong", { children: "The distribution map can't be shown because WebGL is not available in your browser." }),
746
+ " ",
747
+ "This usually means hardware acceleration is turned off or the graphics drivers aren't set up for WebGL.",
748
+ typeof p == "function" && /* @__PURE__ */ o.jsxs(o.Fragment, { children: [
749
+ " ",
750
+ /* @__PURE__ */ o.jsx("a", { onClick: p, style: { cursor: "pointer" }, children: f })
751
+ ] })
752
+ ]
753
+ }
754
+ );
755
+ if (lt && !_)
756
+ return /* @__PURE__ */ o.jsxs(
757
+ "div",
758
+ {
759
+ className: "col-distributions-map col-distributions-map--collapsed",
760
+ style: {
761
+ display: "flex",
762
+ alignItems: "center",
763
+ gap: 6,
764
+ padding: "8px 12px",
765
+ background: "#fafafa",
766
+ border: "1px solid #eee",
767
+ borderRadius: 4,
768
+ color: "#666",
769
+ fontSize: 12
770
+ },
771
+ children: [
772
+ /* @__PURE__ */ o.jsx("span", { children: "No curated distribution data." }),
773
+ /* @__PURE__ */ o.jsx(
774
+ "a",
775
+ {
776
+ role: "button",
777
+ tabIndex: 0,
778
+ style: { cursor: "pointer" },
779
+ onClick: je,
780
+ onKeyDown: (t) => {
781
+ (t.key === "Enter" || t.key === " ") && (t.preventDefault(), je());
782
+ },
783
+ children: "Show GBIF occurrences"
784
+ }
785
+ )
786
+ ]
787
+ }
788
+ );
789
+ const St = (($e = s == null ? void 0 : s.name) == null ? void 0 : $e.scientificName) || "This taxon";
790
+ return /* @__PURE__ */ o.jsxs(
791
+ "div",
792
+ {
793
+ className: "col-distributions-map",
794
+ ref: N,
795
+ style: we ? { position: "relative", width: "100%", height: "100%", background: "#fff" } : { position: "relative" },
796
+ children: [
797
+ /* @__PURE__ */ o.jsx(
798
+ "div",
799
+ {
800
+ ref: C,
801
+ className: "col-distributions-map__canvas",
802
+ style: {
803
+ height: we ? "100%" : 360,
804
+ width: "100%",
805
+ background: "#f5f5f5"
806
+ }
807
+ }
808
+ ),
809
+ dt && /* @__PURE__ */ o.jsx(
810
+ nn,
811
+ {
812
+ value: W,
813
+ onChange: Le,
814
+ style: {
815
+ position: "absolute",
816
+ // Left of the fullscreen control, top right.
817
+ top: 10,
818
+ right: 50,
819
+ zIndex: 2,
820
+ boxShadow: "0 1px 4px rgba(0,0,0,0.2)"
821
+ }
822
+ }
823
+ ),
824
+ /* @__PURE__ */ o.jsx(
825
+ ln,
826
+ {
827
+ open: pt,
828
+ onOpen: yt,
829
+ onClose: () => Ie(!1),
830
+ focalName: St,
831
+ focalReady: ve,
832
+ focalVisible: le,
833
+ onToggleFocal: () => it((t) => !t),
834
+ gbifEnabled: B,
835
+ gbifVisible: _,
836
+ gbifAvailable: u,
837
+ onToggleGbif: ft,
838
+ descendantStatus: S.status,
839
+ descendantsByRank: bt,
840
+ descendantColors: T,
841
+ visibleTaxonIds: z,
842
+ onToggleTaxon: xt,
843
+ onToggleRankGroup: vt,
844
+ onRetry: () => {
845
+ ue.current = !1, V({ status: "idle", taxa: [] }), _e();
846
+ }
847
+ }
848
+ ),
849
+ !Re && (Ee.length > 0 || B && u !== !1 && _) && /* @__PURE__ */ o.jsxs(
850
+ "div",
851
+ {
852
+ style: {
853
+ position: "absolute",
854
+ bottom: 8,
855
+ left: 8,
856
+ zIndex: 1,
857
+ background: "#fff",
858
+ borderRadius: 4,
859
+ boxShadow: "0 1px 4px rgba(0,0,0,0.2)",
860
+ padding: "6px 8px",
861
+ fontSize: 12,
862
+ lineHeight: 1.5
863
+ },
864
+ children: [
865
+ Ee.map((t) => /* @__PURE__ */ o.jsxs(
866
+ "div",
867
+ {
868
+ style: { display: "flex", alignItems: "center", gap: 6 },
869
+ children: [
870
+ /* @__PURE__ */ o.jsx(
871
+ "span",
872
+ {
873
+ style: {
874
+ display: "inline-block",
875
+ width: 12,
876
+ height: 12,
877
+ background: t.color,
878
+ border: "1px solid rgba(0,0,0,0.15)",
879
+ borderRadius: 2
880
+ }
881
+ }
882
+ ),
883
+ /* @__PURE__ */ o.jsx("span", { children: t.label })
884
+ ]
885
+ },
886
+ t.key
887
+ )),
888
+ B && u !== !1 && _ && /* @__PURE__ */ o.jsx(Ze, {})
889
+ ]
890
+ }
891
+ ),
892
+ Re && /* @__PURE__ */ o.jsx(
893
+ qt,
894
+ {
895
+ visibleGroups: de.visibleGroups,
896
+ unmappableGroups: de.unmappableGroups,
897
+ showGbif: B && u !== !1 && _
898
+ }
899
+ )
900
+ ]
901
+ }
902
+ );
903
+ }, ln = ({
904
+ open: e,
905
+ onOpen: n,
906
+ onClose: i,
907
+ focalName: s,
908
+ focalReady: c,
909
+ focalVisible: d,
910
+ onToggleFocal: g,
911
+ gbifEnabled: u,
912
+ gbifVisible: l,
913
+ gbifAvailable: p,
914
+ onToggleGbif: f,
915
+ descendantStatus: v,
916
+ descendantsByRank: C,
917
+ descendantColors: N,
918
+ visibleTaxonIds: m,
919
+ onToggleTaxon: j,
920
+ onToggleRankGroup: ee,
921
+ onRetry: te
922
+ }) => e ? /* @__PURE__ */ o.jsxs(
923
+ "div",
924
+ {
925
+ style: {
926
+ position: "absolute",
927
+ // Aligns with the collapsed "+" button, below the fullscreen control.
928
+ top: 48,
929
+ right: 10,
930
+ zIndex: 2,
931
+ background: "#fff",
932
+ borderRadius: 4,
933
+ boxShadow: "0 1px 4px rgba(0,0,0,0.2)",
934
+ padding: "6px 10px",
935
+ fontSize: 12,
936
+ lineHeight: 1.5,
937
+ maxHeight: 320,
938
+ overflowY: "auto",
939
+ minWidth: 160
940
+ },
941
+ onMouseLeave: i,
942
+ children: [
943
+ /* @__PURE__ */ o.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
944
+ /* @__PURE__ */ o.jsx(
945
+ "input",
946
+ {
947
+ type: "checkbox",
948
+ checked: d,
949
+ disabled: !c,
950
+ onChange: g
951
+ }
952
+ ),
953
+ /* @__PURE__ */ o.jsx("span", { style: { fontStyle: "italic" }, children: s })
954
+ ] }),
955
+ u && /* @__PURE__ */ o.jsxs(
956
+ "div",
957
+ {
958
+ style: {
959
+ display: "flex",
960
+ alignItems: "center",
961
+ gap: 6,
962
+ opacity: p === !1 ? 0.5 : 1
963
+ },
964
+ title: p === !1 ? "GBIF has no occurrence records for this taxon." : void 0,
965
+ children: [
966
+ /* @__PURE__ */ o.jsx(
967
+ "input",
968
+ {
969
+ type: "checkbox",
970
+ checked: p === !1 ? !1 : l,
971
+ disabled: p === !1,
972
+ onChange: f
973
+ }
974
+ ),
975
+ /* @__PURE__ */ o.jsx("span", { children: "GBIF occurrences" })
976
+ ]
977
+ }
978
+ ),
979
+ v === "loading" && /* @__PURE__ */ o.jsx("div", { style: { marginTop: 6, color: "#888" }, children: "Loading descendants…" }),
980
+ v === "error" && /* @__PURE__ */ o.jsxs("div", { style: { marginTop: 6, color: "#888" }, children: [
981
+ "Couldn't load descendants.",
982
+ " ",
983
+ /* @__PURE__ */ o.jsx("a", { onClick: te, style: { cursor: "pointer" }, children: "Retry" })
984
+ ] }),
985
+ v === "ready" && C.map((E) => {
986
+ const $ = E.taxa.every((x) => m.has(x.id)), A = E.taxa.some((x) => m.has(x.id));
987
+ return /* @__PURE__ */ o.jsxs("div", { style: { marginTop: 6 }, children: [
988
+ /* @__PURE__ */ o.jsxs(
989
+ "label",
990
+ {
991
+ style: {
992
+ display: "flex",
993
+ alignItems: "center",
994
+ gap: 6,
995
+ fontWeight: 600
996
+ },
997
+ children: [
998
+ /* @__PURE__ */ o.jsx(
999
+ "input",
1000
+ {
1001
+ type: "checkbox",
1002
+ checked: $,
1003
+ ref: (x) => {
1004
+ x && (x.indeterminate = !$ && A);
1005
+ },
1006
+ onChange: () => ee(E.taxa)
1007
+ }
1008
+ ),
1009
+ E.label
1010
+ ]
1011
+ }
1012
+ ),
1013
+ /* @__PURE__ */ o.jsx("div", { style: { paddingLeft: 18 }, children: E.taxa.map((x) => /* @__PURE__ */ o.jsxs(
1014
+ "label",
1015
+ {
1016
+ style: {
1017
+ display: "flex",
1018
+ alignItems: "center",
1019
+ gap: 6
1020
+ },
1021
+ children: [
1022
+ /* @__PURE__ */ o.jsx(
1023
+ "input",
1024
+ {
1025
+ type: "checkbox",
1026
+ checked: m.has(x.id),
1027
+ onChange: () => j(x.id)
1028
+ }
1029
+ ),
1030
+ /* @__PURE__ */ o.jsx(
1031
+ "span",
1032
+ {
1033
+ style: {
1034
+ display: "inline-block",
1035
+ width: 10,
1036
+ height: 10,
1037
+ background: N[x.id],
1038
+ border: "1px solid rgba(0,0,0,0.15)",
1039
+ borderRadius: 2
1040
+ }
1041
+ }
1042
+ ),
1043
+ /* @__PURE__ */ o.jsx("span", { style: { fontStyle: "italic" }, children: rt(x.scientificName) })
1044
+ ]
1045
+ },
1046
+ x.id
1047
+ )) })
1048
+ ] }, E.rank);
1049
+ })
1050
+ ]
1051
+ }
1052
+ ) : /* @__PURE__ */ o.jsx(
1053
+ "button",
1054
+ {
1055
+ type: "button",
1056
+ onClick: n,
1057
+ onMouseEnter: n,
1058
+ title: "Layers",
1059
+ style: {
1060
+ position: "absolute",
1061
+ // Sits just below the maplibre fullscreen control (top-right).
1062
+ top: 48,
1063
+ right: 10,
1064
+ zIndex: 2,
1065
+ width: 30,
1066
+ height: 30,
1067
+ background: "#fff",
1068
+ border: "1px solid rgba(0,0,0,0.2)",
1069
+ borderRadius: 4,
1070
+ cursor: "pointer",
1071
+ fontSize: 18,
1072
+ lineHeight: "26px",
1073
+ padding: 0,
1074
+ boxShadow: "0 1px 4px rgba(0,0,0,0.2)"
1075
+ },
1076
+ children: "+"
1077
+ }
1078
+ );
1079
+ export {
1080
+ nn as A,
1081
+ vn as D,
1082
+ be as E,
1083
+ yn as G,
1084
+ ie as L,
1085
+ oe as M,
1086
+ Ae as V,
1087
+ Xe as a,
1088
+ Ze as b,
1089
+ Je as c,
1090
+ xn as d,
1091
+ en as e,
1092
+ Ot as f,
1093
+ He as g,
1094
+ De as h,
1095
+ zt as i,
1096
+ Bt as j,
1097
+ ye as k,
1098
+ Et as l,
1099
+ Xt as m,
1100
+ Oe as n,
1101
+ Jt as o,
1102
+ tt as p,
1103
+ $t as r,
1104
+ Qt as s,
1105
+ bn as u
1106
+ };
1107
+ //# sourceMappingURL=index-CJZY-Eu5.js.map