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