col-browser 2.6.4 → 2.6.6

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