col-browser 2.3.9 → 2.3.10

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/tree.js CHANGED
@@ -1,158 +1,158 @@
1
- var J = Object.defineProperty;
2
- var Q = (m, x, e) => x in m ? J(m, x, { enumerable: !0, configurable: !0, writable: !0, value: e }) : m[x] = e;
3
- var p = (m, x, e) => Q(m, typeof x != "symbol" ? x + "" : x, e);
4
- import { a as X } from "./chunks/withDatasetKey-BgMY05XE.js";
5
- import { c as T, w as Y } from "./chunks/config-B2Z9BaEd.js";
6
- import { j as t } from "./chunks/jsx-runtime-BzflLqGi.js";
7
- import j, { createContext as ee } from "react";
8
- import { Popover as te, Divider as se, Spin as R, Tag as ae, Alert as b, Skeleton as oe, Tree as ne, Button as ie, Row as re, Col as v, Checkbox as $ } from "antd";
9
- import { sortBy as N, get as y, isUndefined as I, flatten as le, isArray as A } from "lodash-es";
10
- import { L, c as D, R as U, s as de, b as he } from "./chunks/router-CssZk5qZ.js";
11
- import S from "dataloader";
12
- import { c as W, b as H, g as ce } from "./chunks/dataset-BuF063rn.js";
13
- import { M as pe } from "./chunks/MergedDataBadge-DK4XUXsL.js";
14
- import { E as ue } from "./chunks/ErrorMsg-K8k5PPTp.js";
15
- import { g as fe } from "./chunks/sector-Behb-WCC.js";
16
- import { C as F, N as xe } from "./chunks/DatasetCitation-JpNSTWz-.js";
17
- import { r as O, w as M } from "./chunks/storage-BgdCo9fV.js";
18
- const w = ee({
1
+ var Y = Object.defineProperty;
2
+ var tt = (x, y, t) => y in x ? Y(x, y, { enumerable: !0, configurable: !0, writable: !0, value: t }) : x[y] = t;
3
+ var u = (x, y, t) => tt(x, typeof y != "symbol" ? y + "" : y, t);
4
+ import { a as et } from "./chunks/withDatasetKey-BgMY05XE.js";
5
+ import { c as D, w as st } from "./chunks/config-B2Z9BaEd.js";
6
+ import { j as e } from "./chunks/jsx-runtime-BzflLqGi.js";
7
+ import j, { createContext as at } from "react";
8
+ import { Popover as ot, Divider as it, Spin as q, Tag as nt, Alert as w, Skeleton as rt, Tree as lt, Button as dt, Row as ht, Col as I, Checkbox as N } from "antd";
9
+ import { sortBy as _, get as m, isUndefined as A, flatten as ct, isArray as O } from "lodash-es";
10
+ import { L as P, c as K, R as H, s as ut, b as pt } from "./chunks/router-CssZk5qZ.js";
11
+ import L from "dataloader";
12
+ import { c as V, b as z, g as ft } from "./chunks/dataset-BuF063rn.js";
13
+ import { M as xt } from "./chunks/MergedDataBadge-DK4XUXsL.js";
14
+ import { E as gt } from "./chunks/ErrorMsg-K8k5PPTp.js";
15
+ import { g as yt } from "./chunks/sector-Behb-WCC.js";
16
+ import { C as R, N as mt } from "./chunks/DatasetCitation-JpNSTWz-.js";
17
+ import { r as F, w as M } from "./chunks/storage-BgdCo9fV.js";
18
+ const E = at({
19
19
  datasetLoader: null,
20
20
  publisherLoader: null
21
- }), B = (m) => ({
22
- datasetLoader: new S((x) => H(x, m)),
23
- publisherLoader: new S(
24
- (x) => W(x, m)
21
+ }), B = (x) => ({
22
+ datasetLoader: new L((y) => z(y, x)),
23
+ publisherLoader: new L(
24
+ (y) => V(y, x)
25
25
  )
26
26
  });
27
- class V extends j.Component {
28
- constructor(e) {
29
- super(e);
27
+ class G extends j.Component {
28
+ constructor(t) {
29
+ super(t);
30
30
  // Returns the shared cache from TreeCacheContext if available, or a
31
31
  // throwaway local DataLoader so the popover still works even if context
32
32
  // doesn't reach this instance (which used to leave the spinner stuck
33
33
  // because getData early-returned with no loading state set).
34
- p(this, "getDatasetLoader", () => {
35
- var s;
36
- const { datasetKey: e } = this.props;
37
- return (s = this.context) != null && s.datasetLoader ? this.context.datasetLoader : (this._localDatasetLoader || (this._localDatasetLoader = new S(
38
- (o) => H(o, e)
34
+ u(this, "getDatasetLoader", () => {
35
+ var a;
36
+ const { datasetKey: t } = this.props;
37
+ return (a = this.context) != null && a.datasetLoader ? this.context.datasetLoader : (this._localDatasetLoader || (this._localDatasetLoader = new L(
38
+ (o) => z(o, t)
39
39
  )), this._localDatasetLoader);
40
40
  });
41
- p(this, "getPublisherLoader", () => {
42
- var s;
43
- const { datasetKey: e } = this.props;
44
- return (s = this.context) != null && s.publisherLoader ? this.context.publisherLoader : (this._localPublisherLoader || (this._localPublisherLoader = new S(
45
- (o) => W(o, e)
41
+ u(this, "getPublisherLoader", () => {
42
+ var a;
43
+ const { datasetKey: t } = this.props;
44
+ return (a = this.context) != null && a.publisherLoader ? this.context.publisherLoader : (this._localPublisherLoader || (this._localPublisherLoader = new L(
45
+ (o) => V(o, t)
46
46
  )), this._localPublisherLoader);
47
47
  });
48
- p(this, "componentDidMount", () => {
49
- const { sourceDatasetKeys: e } = this.props;
50
- e && e.length < 4 && this.setState({ showInNode: !0 }, this.getData);
48
+ u(this, "componentDidMount", () => {
49
+ const { sourceDatasetKeys: t } = this.props;
50
+ t && t.length < 4 && this.setState({ showInNode: !0 }, this.getData);
51
51
  });
52
- p(this, "getData", () => {
53
- const { sourceDatasetKeys: e } = this.props;
54
- if (!(e != null && e.length)) return;
52
+ u(this, "getData", () => {
53
+ const { sourceDatasetKeys: t } = this.props;
54
+ if (!(t != null && t.length)) return;
55
55
  this.setState({ loading: !0 });
56
- const s = this.getDatasetLoader();
56
+ const a = this.getDatasetLoader();
57
57
  Promise.all(
58
- e.map((o) => s.load(o).catch(() => null))
58
+ t.map((o) => a.load(o).catch(() => null))
59
59
  ).then((o) => {
60
- this.setState({ data: N(o, ["alias"]), loading: !1 });
60
+ this.setState({ data: _(o, ["alias"]), loading: !1 });
61
61
  }).catch(() => {
62
62
  this.setState({ data: [], loading: !1 });
63
63
  });
64
64
  });
65
- p(this, "getPublisherData", () => {
66
- const { publisherDatasetKeys: e } = this.props;
67
- if (!e) return;
68
- const s = this.getPublisherLoader();
65
+ u(this, "getPublisherData", () => {
66
+ const { publisherDatasetKeys: t } = this.props;
67
+ if (!t) return;
68
+ const a = this.getPublisherLoader();
69
69
  Promise.all(
70
- Object.keys(e).map(
71
- (o) => s.load(o).then((r) => ({
70
+ Object.keys(t).map(
71
+ (o) => a.load(o).then((r) => ({
72
72
  ...r,
73
- datasets: e[o]
73
+ datasets: t[o]
74
74
  })).catch(() => null)
75
75
  )
76
76
  ).then((o) => {
77
- this.setState({ publishers: N(o.filter(Boolean), ["alias"]) });
77
+ this.setState({ publishers: _(o.filter(Boolean), ["alias"]) });
78
78
  }).catch(() => {
79
79
  this.setState({ publishers: [] });
80
80
  });
81
81
  });
82
- p(this, "render", () => {
83
- const { data: e, showInNode: s, popOverVisible: o, loading: r } = this.state, { taxon: h, datasetKey: c } = this.props, n = { color: "orange", fontSize: "11px" }, f = (a) => `${T.clbPortal}/dataset/${c}/publisher/${a}`;
84
- return s ? e.filter((a) => !!a).map((a, l) => /* @__PURE__ */ t.jsx(
85
- L,
82
+ u(this, "render", () => {
83
+ const { data: t, showInNode: a, popOverVisible: o, loading: r } = this.state, { taxon: l, datasetKey: d } = this.props, i = { color: "orange", fontSize: "11px" }, f = (s) => `${D.clbPortal}/dataset/${d}/publisher/${s}`;
84
+ return a ? t.filter((s) => !!s).map((s, n) => /* @__PURE__ */ e.jsx(
85
+ P,
86
86
  {
87
87
  to: "source",
88
- args: a.key,
88
+ args: s.key,
89
89
  className: "col-tree-data-source",
90
- style: n,
91
- children: (l ? ", " : "") + (a.alias || a.key)
90
+ style: i,
91
+ children: (n ? ", " : "") + (s.alias || s.key)
92
92
  },
93
- a.key
94
- )) : /* @__PURE__ */ t.jsx("div", { style: { display: "inline" }, id: `taxon_sources_${h.id}`, children: /* @__PURE__ */ t.jsx(
95
- te,
93
+ s.key
94
+ )) : /* @__PURE__ */ e.jsx("div", { style: { display: "inline" }, id: `taxon_sources_${l.id}`, children: /* @__PURE__ */ e.jsx(
95
+ ot,
96
96
  {
97
- getPopupContainer: () => document.getElementById(`taxon_sources_${h.id}`),
98
- content: r || e.length === 0 ? /* @__PURE__ */ t.jsx(
97
+ getPopupContainer: () => document.getElementById(`taxon_sources_${l.id}`),
98
+ content: r || t.length === 0 ? /* @__PURE__ */ e.jsx(
99
99
  "div",
100
100
  {
101
101
  style: { minWidth: "200px", textAlign: "center", padding: "8px 0" },
102
- children: /* @__PURE__ */ t.jsx(R, { size: "small" })
102
+ children: /* @__PURE__ */ e.jsx(q, { size: "small" })
103
103
  }
104
- ) : /* @__PURE__ */ t.jsxs("div", { style: { maxWidth: "500px" }, children: [
105
- e.length > 0 && /* @__PURE__ */ t.jsx("div", { children: e.filter((a) => !!a).map((a, l) => /* @__PURE__ */ t.jsx(
106
- L,
104
+ ) : /* @__PURE__ */ e.jsxs("div", { style: { maxWidth: "500px" }, children: [
105
+ t.length > 0 && /* @__PURE__ */ e.jsx("div", { children: t.filter((s) => !!s).map((s, n) => /* @__PURE__ */ e.jsx(
106
+ P,
107
107
  {
108
108
  to: "source",
109
- args: a.key,
109
+ args: s.key,
110
110
  className: "col-tree-data-source",
111
- style: n,
112
- children: (l ? ", " : "") + (a.alias || a.key)
111
+ style: i,
112
+ children: (n ? ", " : "") + (s.alias || s.key)
113
113
  },
114
- a.key
114
+ s.key
115
115
  )) }),
116
- this.state.publishers && this.state.publishers.length > 0 && /* @__PURE__ */ t.jsxs("div", { style: { marginTop: "12px" }, children: [
117
- /* @__PURE__ */ t.jsx("strong", { children: "Publishers" }),
118
- /* @__PURE__ */ t.jsx("div", { children: this.state.publishers.filter((a) => !!a).map((a, l) => {
119
- var u;
120
- return /* @__PURE__ */ t.jsxs(
116
+ this.state.publishers && this.state.publishers.length > 0 && /* @__PURE__ */ e.jsxs("div", { style: { marginTop: "12px" }, children: [
117
+ /* @__PURE__ */ e.jsx("strong", { children: "Publishers" }),
118
+ /* @__PURE__ */ e.jsx("div", { children: this.state.publishers.filter((s) => !!s).map((s, n) => {
119
+ var p;
120
+ return /* @__PURE__ */ e.jsxs(
121
121
  "a",
122
122
  {
123
- href: f(a.id),
123
+ href: f(s.id),
124
124
  target: "_blank",
125
125
  rel: "noopener noreferrer",
126
- style: n,
126
+ style: i,
127
127
  children: [
128
- (l ? ", " : "") + (a.alias || a.id),
129
- (u = a.datasets) != null && u.length ? ` (${a.datasets.length.toLocaleString("en-GB")})` : ""
128
+ (n ? ", " : "") + (s.alias || s.id),
129
+ (p = s.datasets) != null && p.length ? ` (${s.datasets.length.toLocaleString("en-GB")})` : ""
130
130
  ]
131
131
  },
132
- a.id
132
+ s.id
133
133
  );
134
134
  }) })
135
135
  ] })
136
136
  ] }),
137
- title: /* @__PURE__ */ t.jsxs("div", { style: { padding: "4px 0" }, children: [
138
- /* @__PURE__ */ t.jsx("span", { style: { fontWeight: 500 }, children: "Sources for " }),
139
- /* @__PURE__ */ t.jsx("em", { children: h == null ? void 0 : h.name }),
140
- /* @__PURE__ */ t.jsx(se, { style: { margin: "8px 0 0" } })
137
+ title: /* @__PURE__ */ e.jsxs("div", { style: { padding: "4px 0" }, children: [
138
+ /* @__PURE__ */ e.jsx("span", { style: { fontWeight: 500 }, children: "Sources for " }),
139
+ /* @__PURE__ */ e.jsx("em", { children: l == null ? void 0 : l.name }),
140
+ /* @__PURE__ */ e.jsx(it, { style: { margin: "8px 0 0" } })
141
141
  ] }),
142
142
  open: o,
143
- onOpenChange: (a) => this.setState({ popOverVisible: a }, () => {
144
- a && this.state.data.length === 0 && this.getData(), a && this.props.publisherDatasetKeys && !this.state.publishers && this.getPublisherData();
143
+ onOpenChange: (s) => this.setState({ popOverVisible: s }, () => {
144
+ s && this.state.data.length === 0 && this.getData(), s && this.props.publisherDatasetKeys && !this.state.publishers && this.getPublisherData();
145
145
  }),
146
146
  trigger: "click",
147
147
  placement: "rightTop",
148
- children: /* @__PURE__ */ t.jsx(
148
+ children: /* @__PURE__ */ e.jsx(
149
149
  "a",
150
150
  {
151
151
  className: "col-tree-data-source",
152
152
  role: "button",
153
153
  tabIndex: 0,
154
154
  style: { cursor: "pointer", color: "orange", fontSize: "11px" },
155
- onClick: (a) => a.preventDefault(),
155
+ onClick: (s) => s.preventDefault(),
156
156
  children: "Multiple sources"
157
157
  }
158
158
  )
@@ -166,44 +166,44 @@ class V extends j.Component {
166
166
  };
167
167
  }
168
168
  }
169
- p(V, "contextType", w);
170
- const z = j.createContext();
169
+ u(G, "contextType", E);
170
+ const X = j.createContext();
171
171
  class k extends j.Component {
172
- constructor(e) {
173
- super(e);
174
- p(this, "rankIsAboveSpecies", (e) => this.props.rank.indexOf(e) < this.props.rank.indexOf("species"));
175
- p(this, "render", () => {
172
+ constructor(t) {
173
+ super(t);
174
+ u(this, "rankIsAboveSpecies", (t) => this.props.rank.indexOf(t) < this.props.rank.indexOf("species"));
175
+ u(this, "render", () => {
176
176
  const {
177
- taxon: e,
178
- taxon: { sector: s, sourceDatasetKeys: o, publisherDatasetKeys: r },
179
- datasetKey: h
180
- } = this.props, c = y(s, "dataset"), n = (o || []).filter((a) => (s == null ? void 0 : s.subjectDatasetKey) !== a).length > 0;
181
- e.estimate && e.estimates && e.estimates.find((a) => a.estimate === e.estimate);
182
- const f = typeof e.id == "string" && e.id.indexOf("incertae-sedis") > -1;
183
- return /* @__PURE__ */ t.jsx(z.Consumer, { children: ({ showInfo: a }) => /* @__PURE__ */ t.jsxs("div", { id: e.id, children: [
184
- /* @__PURE__ */ t.jsxs("span", { children: [
185
- /* @__PURE__ */ t.jsxs("span", { className: "tree-node-rank", children: [
186
- e.rank,
177
+ taxon: t,
178
+ taxon: { sector: a, sourceDatasetKeys: o, publisherDatasetKeys: r },
179
+ datasetKey: l
180
+ } = this.props, d = m(a, "dataset"), i = (o || []).filter((s) => (a == null ? void 0 : a.subjectDatasetKey) !== s).length > 0;
181
+ t.estimate && t.estimates && t.estimates.find((s) => s.estimate === t.estimate);
182
+ const f = typeof t.id == "string" && t.id.indexOf("incertae-sedis") > -1;
183
+ return /* @__PURE__ */ e.jsx(X.Consumer, { children: ({ showInfo: s }) => /* @__PURE__ */ e.jsxs("div", { id: t.id, children: [
184
+ /* @__PURE__ */ e.jsxs("span", { children: [
185
+ /* @__PURE__ */ e.jsxs("span", { className: "tree-node-rank", children: [
186
+ t.rank,
187
187
  ": "
188
188
  ] }),
189
- f ? /* @__PURE__ */ t.jsx("span", { dangerouslySetInnerHTML: { __html: e.labelHtml } }) : /* @__PURE__ */ t.jsx(L, { to: "taxon", args: e.id, children: /* @__PURE__ */ t.jsx("span", { dangerouslySetInnerHTML: { __html: e.labelHtml } }) }),
190
- (e == null ? void 0 : e.merged) && /* @__PURE__ */ t.jsx(pe, { style: { marginLeft: "4px" }, datasetKey: e == null ? void 0 : e.datasetKey, verbatimSourceKey: e == null ? void 0 : e.verbatimSourceKey })
189
+ f ? /* @__PURE__ */ e.jsx("span", { dangerouslySetInnerHTML: { __html: t.labelHtml } }) : /* @__PURE__ */ e.jsx(P, { to: "taxon", args: t.id, children: /* @__PURE__ */ e.jsx("span", { dangerouslySetInnerHTML: { __html: t.labelHtml } }) }),
190
+ (t == null ? void 0 : t.merged) && /* @__PURE__ */ e.jsx(xt, { style: { marginLeft: "4px" }, datasetKey: t == null ? void 0 : t.datasetKey, verbatimSourceKey: t == null ? void 0 : t.verbatimSourceKey })
191
191
  ] }),
192
- a && e.status === "provisionally accepted" && /* @__PURE__ */ t.jsxs(j.Fragment, { children: [
192
+ s && t.status === "provisionally accepted" && /* @__PURE__ */ e.jsxs(j.Fragment, { children: [
193
193
  " • ",
194
- /* @__PURE__ */ t.jsx(ae, { color: "warning", style: { marginRight: 0 }, children: "prov." })
194
+ /* @__PURE__ */ e.jsx(nt, { color: "warning", style: { marginRight: 0 }, children: "prov." })
195
195
  ] }),
196
- !I(e.count) && this.rankIsAboveSpecies(e == null ? void 0 : e.rank) && /* @__PURE__ */ t.jsxs("span", { children: [
196
+ !A(t.count) && this.rankIsAboveSpecies(t == null ? void 0 : t.rank) && /* @__PURE__ */ e.jsxs("span", { children: [
197
197
  " ",
198
198
  "• ",
199
- Number(e.count).toLocaleString(),
199
+ Number(t.count).toLocaleString(),
200
200
  " ",
201
- a && !I(e.speciesEstimate) && /* @__PURE__ */ t.jsxs("span", { children: [
201
+ s && !A(t.speciesEstimate) && /* @__PURE__ */ e.jsxs("span", { children: [
202
202
  " ",
203
203
  "of",
204
204
  " ",
205
205
  Number(
206
- e.speciesEstimate
206
+ t.speciesEstimate
207
207
  ).toLocaleString(),
208
208
  " ",
209
209
  "est.",
@@ -211,31 +211,31 @@ class k extends j.Component {
211
211
  ] }),
212
212
  "spp."
213
213
  ] }),
214
- a && s && /* @__PURE__ */ t.jsxs("span", { children: [
215
- /* @__PURE__ */ t.jsx("span", { children: " • " }),
216
- /* @__PURE__ */ t.jsxs(
217
- L,
214
+ s && a && /* @__PURE__ */ e.jsxs("span", { children: [
215
+ /* @__PURE__ */ e.jsx("span", { children: " • " }),
216
+ /* @__PURE__ */ e.jsxs(
217
+ P,
218
218
  {
219
219
  to: "source",
220
- args: s.subjectDatasetKey,
221
- style: n ? { fontWeight: "bold" } : null,
220
+ args: a.subjectDatasetKey,
221
+ style: i ? { fontWeight: "bold" } : null,
222
222
  className: "col-tree-data-source",
223
223
  children: [
224
- y(c, "alias") || s.subjectDatasetKey,
225
- n && ", "
224
+ m(d, "alias") || a.subjectDatasetKey,
225
+ i && ", "
226
226
  ]
227
227
  }
228
228
  )
229
229
  ] }),
230
- a && n && /* @__PURE__ */ t.jsxs(j.Fragment, { children: [
230
+ s && i && /* @__PURE__ */ e.jsxs(j.Fragment, { children: [
231
231
  " ",
232
- /* @__PURE__ */ t.jsx(
233
- V,
232
+ /* @__PURE__ */ e.jsx(
233
+ G,
234
234
  {
235
235
  sourceDatasetKeys: o,
236
236
  publisherDatasetKeys: r,
237
- taxon: e,
238
- datasetKey: h
237
+ taxon: t,
238
+ datasetKey: l
239
239
  }
240
240
  )
241
241
  ] })
@@ -248,46 +248,46 @@ class k extends j.Component {
248
248
  };
249
249
  }
250
250
  }
251
- const K = 1e3;
252
- class ge extends j.Component {
253
- constructor(e) {
254
- super(e);
255
- p(this, "onClick", () => {
251
+ const b = 1e3, Z = "__loadMoreBTN__", W = (x) => `${Z}${x}`, U = (x) => typeof x == "string" && x.startsWith(Z);
252
+ class Ct extends j.Component {
253
+ constructor(t) {
254
+ super(t);
255
+ u(this, "onClick", () => {
256
256
  this.setState(
257
257
  { loading: !0 },
258
258
  () => this.props.onClick().then(() => this.setState({ loading: !1 }))
259
259
  );
260
260
  });
261
- p(this, "render", () => {
262
- const { loading: e } = this.state;
263
- return /* @__PURE__ */ t.jsxs(j.Fragment, { children: [
264
- e && /* @__PURE__ */ t.jsx(R, {}),
265
- !e && /* @__PURE__ */ t.jsx("a", { onClick: this.onClick, children: /* @__PURE__ */ t.jsx("strong", { children: "Load more..." }) })
261
+ u(this, "render", () => {
262
+ const { loading: t } = this.state;
263
+ return /* @__PURE__ */ e.jsxs(j.Fragment, { children: [
264
+ t && /* @__PURE__ */ e.jsx(q, {}),
265
+ !t && /* @__PURE__ */ e.jsx("a", { onClick: this.onClick, children: /* @__PURE__ */ e.jsx("strong", { children: "Load more..." }) })
266
266
  ] });
267
267
  });
268
268
  this.state = { loading: !1 };
269
269
  }
270
270
  }
271
- class G extends j.Component {
272
- constructor(e) {
273
- super(e);
274
- p(this, "componentDidMount", () => {
275
- const { datasetKey: e } = this.props;
276
- this.loadRoot(), this.sectorLoader = new S(
277
- (o) => fe(o, e)
271
+ class J extends j.Component {
272
+ constructor(t) {
273
+ super(t);
274
+ u(this, "componentDidMount", () => {
275
+ const { datasetKey: t } = this.props;
276
+ this.loadRoot(), this.sectorLoader = new L(
277
+ (o) => yt(o, t)
278
278
  ), this.getRank();
279
- const { treeRef: s } = this.props;
280
- s(this);
279
+ const { treeRef: a } = this.props;
280
+ a(this);
281
281
  });
282
- p(this, "componentDidUpdate", (e) => {
283
- (e.defaultExpandKey !== this.props.defaultExpandKey || e.hideExtinct !== this.props.hideExtinct || e.insertPlaceholder !== this.props.insertPlaceholder) && this.reloadRoot();
282
+ u(this, "componentDidUpdate", (t) => {
283
+ (t.defaultExpandKey !== this.props.defaultExpandKey || t.hideExtinct !== this.props.hideExtinct || t.insertPlaceholder !== this.props.insertPlaceholder) && this.reloadRoot();
284
284
  });
285
- p(this, "getRank", () => {
286
- D(`${T.dataApi}vocab/rank`).then(
287
- (e) => this.setState({ rank: e.data.map((s) => s.name) })
285
+ u(this, "getRank", () => {
286
+ K(`${D.dataApi}vocab/rank`).then(
287
+ (t) => this.setState({ rank: t.data.map((a) => a.name) })
288
288
  );
289
289
  });
290
- p(this, "reloadRoot", () => this.setState(
290
+ u(this, "reloadRoot", () => this.setState(
291
291
  {
292
292
  rootLoading: !0,
293
293
  treeData: [],
@@ -298,245 +298,255 @@ class G extends j.Component {
298
298
  },
299
299
  this.loadRoot
300
300
  ));
301
- p(this, "loadRoot", async () => {
301
+ // `append` is only set by the "Load more" button, which pages in the next
302
+ // batch of root taxa; every other caller loads page one from scratch.
303
+ // Each call takes a request id and a response is merged only while its id is
304
+ // still the current one. Without that, two overlapping loads — React
305
+ // StrictMode's double mount in dev, or a prop change while a load is in
306
+ // flight — both merged their page into treeData, so every root appeared
307
+ // twice and antd warned "Same 'key' exist in the Tree" (issue #59).
308
+ u(this, "loadRoot", async (t = !1) => {
302
309
  const {
303
- showSourceTaxon: e,
304
- datasetKey: s,
305
- hideExtinct: o,
306
- insertPlaceholder: r,
307
- type: h,
308
- expandedTaxonKey: c
309
- } = this.props, n = c, { defaultTaxonKey: f } = this.props;
310
- return this.setState({ rootLoading: !0, treeData: [] }), D(
311
- `${T.dataApi}dataset/${s}/tree?projectKey=${s}${h ? "&type=" + h : ""}&limit=${K}&offset=${this.state.treeData.length}${o ? "&extinct=false&extinct=" : ""}${r ? "&insertPlaceholder=true" : ""}`
312
- ).then(this.decorateWithSectorsAndDataset).then((a) => {
313
- const l = a.data.result || [], u = a.data.total, g = l.map((d) => {
314
- let i = {
315
- taxon: d,
316
- key: d.id,
317
- datasetKey: s,
318
- childCount: d.childCount,
319
- isLeaf: d.childCount === 0,
310
+ showSourceTaxon: a,
311
+ datasetKey: o,
312
+ hideExtinct: r,
313
+ insertPlaceholder: l,
314
+ type: d,
315
+ expandedTaxonKey: i
316
+ } = this.props, f = i, { defaultTaxonKey: s } = this.props, n = ++this.rootRequestId, p = t ? this.state.treeData.length : 0;
317
+ return this.setState(
318
+ t ? { rootLoading: !0 } : { rootLoading: !0, treeData: [] }
319
+ ), K(
320
+ `${D.dataApi}dataset/${o}/tree?projectKey=${o}${d ? "&type=" + d : ""}&limit=${b}&offset=${p}${r ? "&extinct=false&extinct=" : ""}${l ? "&insertPlaceholder=true" : ""}`
321
+ ).then(this.decorateWithSectorsAndDataset).then((C) => {
322
+ if (n !== this.rootRequestId) return;
323
+ const c = C.data.result || [], h = C.data.total, g = c.map((S) => {
324
+ let T = {
325
+ taxon: S,
326
+ key: S.id,
327
+ datasetKey: o,
328
+ childCount: S.childCount,
329
+ isLeaf: S.childCount === 0,
320
330
  childOffset: 0
321
331
  };
322
- return i.title = /* @__PURE__ */ t.jsx(
332
+ return T.title = /* @__PURE__ */ e.jsx(
323
333
  k,
324
334
  {
325
- taxon: d,
326
- datasetKey: s,
327
- showSourceTaxon: e,
328
- reloadChildren: () => this.fetchChildPage(i, !0),
335
+ taxon: S,
336
+ datasetKey: o,
337
+ showSourceTaxon: a,
338
+ reloadChildren: () => this.fetchChildPage(T, !0),
329
339
  rank: this.state.rank
330
340
  }
331
- ), i.ref = i, i;
341
+ ), T.ref = T, T;
332
342
  });
333
343
  this.setState(
334
- {
335
- rootTotal: u,
344
+ (S) => ({
345
+ rootTotal: h,
336
346
  rootLoading: !1,
337
- treeData: [...this.state.treeData, ...g],
347
+ treeData: t ? [...S.treeData, ...g] : g,
338
348
  // Nothing is auto-expanded by default. Consumers open a specific root
339
349
  // (or deep taxon) by passing `defaultTaxonKey`/`expandedTaxonKey` —
340
350
  // e.g. defaultTaxonKey="CS5HF" opens Eukaryota in current COL releases.
341
351
  expandedKeys: [],
342
352
  error: null
343
- },
353
+ }),
344
354
  () => {
345
- if (n)
346
- return this.expandToTaxon(n);
347
355
  if (f)
348
356
  return this.expandToTaxon(f);
357
+ if (s)
358
+ return this.expandToTaxon(s);
349
359
  }
350
360
  ), g.length === 1 && this.fetchChildPage(g[g.length - 1]);
351
- }).catch((a) => {
352
- this.setState({
361
+ }).catch((C) => {
362
+ n === this.rootRequestId && this.setState({
353
363
  treeData: [],
354
364
  rootLoading: !1,
355
365
  expandedKeys: [],
356
- error: a
366
+ error: C
357
367
  });
358
368
  });
359
369
  });
360
- p(this, "expandToTaxon", async (e) => {
370
+ u(this, "expandToTaxon", async (t) => {
361
371
  const {
362
- showSourceTaxon: s,
372
+ showSourceTaxon: a,
363
373
  datasetKey: o,
364
374
  hideExtinct: r,
365
- type: h
375
+ type: l
366
376
  } = this.props;
367
377
  this.setState({
368
378
  rootLoading: !0
369
379
  /* , treeData: [] */
370
380
  });
371
- const { data: c } = await D(
372
- `${T.dataApi}dataset/${o}/tree/${e}?projectKey=${o}&insertPlaceholder=true${h ? "&type=" + h : ""}${r ? "&extinct=false" : ""}`
381
+ const { data: d } = await K(
382
+ `${D.dataApi}dataset/${o}/tree/${t}?projectKey=${o}&insertPlaceholder=true${l ? "&type=" + l : ""}${r ? "&extinct=false" : ""}`
373
383
  ).then(
374
- (d) => this.decorateWithSectorsAndDataset({
375
- data: { result: d.data }
376
- }).then(() => d)
384
+ (c) => this.decorateWithSectorsAndDataset({
385
+ data: { result: c.data }
386
+ }).then(() => c)
377
387
  );
378
- if (c.length === 0)
388
+ if (d.length === 0)
379
389
  return this.setState(
380
390
  {
381
391
  error: {
382
- message: `No classification found for Taxon ID: ${e}`
392
+ message: `No classification found for Taxon ID: ${t}`
383
393
  }
384
394
  },
385
395
  this.loadRoot
386
396
  );
387
- const n = c[c.length - 1];
397
+ const i = d[d.length - 1];
388
398
  let f = {
389
- taxon: n,
390
- key: n.id,
399
+ taxon: i,
400
+ key: i.id,
391
401
  datasetKey: o,
392
- childCount: n.childCount,
393
- isLeaf: n.childCount === 0,
402
+ childCount: i.childCount,
403
+ isLeaf: i.childCount === 0,
394
404
  childOffset: 0
395
405
  };
396
- f.title = /* @__PURE__ */ t.jsx(
406
+ f.title = /* @__PURE__ */ e.jsx(
397
407
  k,
398
408
  {
399
- taxon: n,
409
+ taxon: i,
400
410
  datasetKey: o,
401
- showSourceTaxon: s,
411
+ showSourceTaxon: a,
402
412
  rank: this.state.rank,
403
413
  reloadChildren: () => this.fetchChildPage(f, !0)
404
414
  }
405
415
  ), f.ref = f;
406
- const a = f;
407
- for (let d = c.length - 2; d >= 0; d--) {
408
- const i = c[d], C = {
409
- taxon: i,
410
- key: i.id,
416
+ const s = f;
417
+ for (let c = d.length - 2; c >= 0; c--) {
418
+ const h = d[c], g = {
419
+ taxon: h,
420
+ key: h.id,
411
421
  datasetKey: o,
412
- childCount: i.childCount,
413
- isLeaf: i.childCount === 0,
422
+ childCount: h.childCount,
423
+ isLeaf: h.childCount === 0,
414
424
  childOffset: 0
415
425
  };
416
- C.ref = C, C.title = /* @__PURE__ */ t.jsx(
426
+ g.ref = g, g.title = /* @__PURE__ */ e.jsx(
417
427
  k,
418
428
  {
419
- taxon: i,
429
+ taxon: h,
420
430
  datasetKey: o,
421
- showSourceTaxon: s,
431
+ showSourceTaxon: a,
422
432
  rank: this.state.rank,
423
- reloadChildren: () => this.fetchChildPage(C, !0)
433
+ reloadChildren: () => this.fetchChildPage(g, !0)
424
434
  }
425
- ), f.children = [C], f = C;
435
+ ), f.children = [g], f = g;
426
436
  }
427
- const { treeData: l } = this.state;
428
- var u = l.findIndex((d) => d.key == a.key);
429
- l[u] = a;
430
- const g = [...c.map((d) => d.id).reverse()];
437
+ const { treeData: n } = this.state;
438
+ var p = n.findIndex((c) => c.key == s.key);
439
+ n[p] = s;
440
+ const C = [...d.map((c) => c.id).reverse()];
431
441
  this.setState(
432
- { treeData: l },
433
- () => this.reloadLoadedKeys(g, e)
442
+ { treeData: n },
443
+ () => this.reloadLoadedKeys(C, t)
434
444
  );
435
445
  });
436
- p(this, "fetchChildPage", async (e, s, o) => {
446
+ u(this, "fetchChildPage", async (t, a, o) => {
437
447
  const {
438
448
  showSourceTaxon: r,
439
- datasetKey: h,
440
- hideExtinct: c,
441
- insertPlaceholder: n,
449
+ datasetKey: l,
450
+ hideExtinct: d,
451
+ insertPlaceholder: i,
442
452
  type: f
443
453
  } = this.props;
444
- y(e, "childCount");
445
- const a = K, l = y(e, "childOffset"), u = await D(
446
- `${T.dataApi}dataset/${h}/tree/${e.taxon.id}/children?limit=${a}&offset=${l}&projectKey=${h}${f ? "&type=" + f : ""}${c ? "&extinct=false" : ""}${n ? "&insertPlaceholder=true" : ""}`
454
+ m(t, "childCount");
455
+ const s = b, n = m(t, "childOffset"), p = await K(
456
+ `${D.dataApi}dataset/${l}/tree/${t.taxon.id}/children?limit=${s}&offset=${n}&projectKey=${l}${f ? "&type=" + f : ""}${d ? "&extinct=false" : ""}${i ? "&insertPlaceholder=true" : ""}`
447
457
  );
448
- await this.decorateWithSectorsAndDataset(u);
449
- const g = u.data.result ? u.data.result.map((d) => {
450
- let i = {
451
- taxon: d,
452
- key: d.id,
453
- datasetKey: h,
454
- childCount: d.childCount,
455
- isLeaf: d.childCount === 0,
458
+ await this.decorateWithSectorsAndDataset(p);
459
+ const C = p.data.result ? p.data.result.map((c) => {
460
+ let h = {
461
+ taxon: c,
462
+ key: c.id,
463
+ datasetKey: l,
464
+ childCount: c.childCount,
465
+ isLeaf: c.childCount === 0,
456
466
  childOffset: 0,
457
- parent: e,
458
- name: d.name
467
+ parent: t,
468
+ name: c.name
459
469
  };
460
- return i.title = /* @__PURE__ */ t.jsx(
470
+ return h.title = /* @__PURE__ */ e.jsx(
461
471
  k,
462
472
  {
463
- taxon: d,
464
- datasetKey: h,
473
+ taxon: c,
474
+ datasetKey: l,
465
475
  showSourceTaxon: r,
466
476
  rank: this.state.rank,
467
- reloadChildren: () => this.fetchChildPage(i, !0)
477
+ reloadChildren: () => this.fetchChildPage(h, !0)
468
478
  }
469
- ), i.ref = i, i;
479
+ ), h.ref = h, h;
470
480
  }) : [];
471
- if (e.children = e.children && l !== 0 && !s ? [...e.children, ...g] : g, u.data.last && e.childCount > e.children.length && (e.childCount = e.children.length), !u.data.last) {
472
- const d = () => (e.childOffset += K, e.children[e.children.length - 1].key === "__loadMoreBTN__" && (e.children = e.children.slice(0, -1)), this.fetchChildPage(e, !1));
473
- e.children = [
474
- ...e.children,
481
+ if (t.children = t.children && n !== 0 && !a ? [...t.children, ...C] : C, p.data.last && t.childCount > t.children.length && (t.childCount = t.children.length), !p.data.last) {
482
+ const c = () => (t.childOffset += b, U(m(t.children[t.children.length - 1], "key")) && (t.children = t.children.slice(0, -1)), this.fetchChildPage(t, !1));
483
+ t.children = [
484
+ ...t.children,
475
485
  {
476
- title: /* @__PURE__ */ t.jsx(
477
- ge,
486
+ title: /* @__PURE__ */ e.jsx(
487
+ Ct,
478
488
  {
479
- onClick: d
489
+ onClick: c
480
490
  },
481
- "__loadMoreBTN__"
491
+ W(t.key)
482
492
  ),
483
- key: "__loadMoreBTN__",
493
+ key: W(t.key),
484
494
  childCount: 0,
485
495
  isLeaf: !0
486
496
  }
487
497
  ];
488
498
  }
489
- o || this.setState((d) => ({
490
- treeData: [...d.treeData],
491
- loadedKeys: [.../* @__PURE__ */ new Set([...d.loadedKeys, e.key])]
499
+ o || this.setState((c) => ({
500
+ treeData: [...c.treeData],
501
+ loadedKeys: [.../* @__PURE__ */ new Set([...c.loadedKeys, t.key])]
492
502
  }));
493
503
  });
494
- p(this, "decorateWithSectorsAndDataset", (e) => e.data.result ? Promise.all(
495
- e.data.result.filter((s) => !!s.sectorDatasetKey).map(
496
- (s) => this.datasetLoader.load(s.sectorDatasetKey).then(
497
- (o) => s.sector = {
498
- id: s.sectorKey,
499
- subjectDatasetKey: s.sectorDatasetKey,
504
+ u(this, "decorateWithSectorsAndDataset", (t) => t.data.result ? Promise.all(
505
+ t.data.result.filter((a) => !!a.sectorDatasetKey).map(
506
+ (a) => this.datasetLoader.load(a.sectorDatasetKey).then(
507
+ (o) => a.sector = {
508
+ id: a.sectorKey,
509
+ subjectDatasetKey: a.sectorDatasetKey,
500
510
  dataset: o
501
511
  }
502
512
  )
503
513
  )
504
- ).then(() => e) : e);
505
- p(this, "onLoadData", (e, s = !1) => (s && (e.childOffset = 0), this.fetchChildPage(e.ref, s)));
506
- p(this, "findNode", (e, s) => {
514
+ ).then(() => t) : t);
515
+ u(this, "onLoadData", (t, a = !1) => (a && (t.childOffset = 0), this.fetchChildPage(t.ref, a)));
516
+ u(this, "findNode", (t, a) => {
507
517
  let o = null;
508
- if (o = s.find((r) => y(r, "taxon.id") === e), o)
518
+ if (o = a.find((r) => m(r, "taxon.id") === t), o)
509
519
  return o;
510
520
  {
511
- const r = s.map((c) => y(c, "children") || []), h = le(r);
512
- return h.length === 0 ? null : this.findNode(e, h);
521
+ const r = a.map((d) => m(d, "children") || []), l = ct(r);
522
+ return l.length === 0 ? null : this.findNode(t, l);
513
523
  }
514
524
  });
515
- p(this, "pageThroughChildrenUntilTaxonFound", async (e, s) => {
525
+ u(this, "pageThroughChildrenUntilTaxonFound", async (t, a) => {
516
526
  let o;
517
- for (; !o && e.children.length < e.childCount; )
518
- e.childOffset += K, e.children[e.children.length - 1].key === "__loadMoreBTN__" && (e.children = e.children.slice(0, -1)), await this.fetchChildPage(e, !1, !0), o = this.findNode(s, e.children);
519
- return o || (o = e.children.find(
520
- (r) => y(r, "taxon.id") ? r.taxon.id.indexOf("incertae-sedis") > -1 : !1
527
+ for (; !o && t.children.length < t.childCount; )
528
+ t.childOffset += b, U(m(t.children[t.children.length - 1], "key")) && (t.children = t.children.slice(0, -1)), await this.fetchChildPage(t, !1, !0), o = this.findNode(a, t.children);
529
+ return o || (o = t.children.find(
530
+ (r) => m(r, "taxon.id") ? r.taxon.id.indexOf("incertae-sedis") > -1 : !1
521
531
  )), o;
522
532
  });
523
- p(this, "reloadLoadedKeys", async (e, s, o = !0) => {
533
+ u(this, "reloadLoadedKeys", async (t, a, o = !0) => {
524
534
  this.setState({ rootLoading: !0 });
525
535
  const { loadedKeys: r } = this.state;
526
- let { treeData: h } = this.state;
527
- const c = s ? this.findNode(s, h) : null, n = e ? [...e] : [...r];
528
- for (let a = 0; a < n.length; a++) {
529
- let l = this.findNode(n[a], h);
530
- if (!l && c && n[a - 1]) {
531
- const u = this.findNode(n[a - 1], h);
532
- u && A(y(u, "children")) && u.children.length > 0 && (l = await this.pageThroughChildrenUntilTaxonFound(
533
- u,
534
- n[a]
535
- ), l ? n.splice(a, 0, l.taxon.id) : this.setState(
536
+ let { treeData: l } = this.state;
537
+ const d = a ? this.findNode(a, l) : null, i = t ? [...t] : [...r];
538
+ for (let s = 0; s < i.length; s++) {
539
+ let n = this.findNode(i[s], l);
540
+ if (!n && d && i[s - 1]) {
541
+ const p = this.findNode(i[s - 1], l);
542
+ p && O(m(p, "children")) && p.children.length > 0 && (n = await this.pageThroughChildrenUntilTaxonFound(
543
+ p,
544
+ i[s]
545
+ ), n ? i.splice(s, 0, n.taxon.id) : this.setState(
536
546
  {
537
- nodeNotFoundErr: /* @__PURE__ */ t.jsxs("span", { children: [
547
+ nodeNotFoundErr: /* @__PURE__ */ e.jsxs("span", { children: [
538
548
  "Cannot find taxon ",
539
- s,
549
+ a,
540
550
  " in tree 😥"
541
551
  ] }),
542
552
  rootLoading: !1
@@ -552,37 +562,37 @@ class G extends j.Component {
552
562
  } */
553
563
  ));
554
564
  }
555
- if (l) {
556
- await this.fetchChildPage(l, !0, !0);
557
- let u = l.children.find(
558
- (g) => y(g, "taxon.id") === y(c, "taxon.id")
565
+ if (n) {
566
+ await this.fetchChildPage(n, !0, !0);
567
+ let p = n.children.find(
568
+ (C) => m(C, "taxon.id") === m(d, "taxon.id")
559
569
  );
560
- c && a === n.length - 2 && y(l, "taxon.id") !== y(c, "taxon.id") && A(l.children) && !u && l.children.length < l.childCount && (u = await this.pageThroughChildrenUntilTaxonFound(
561
- l,
562
- y(c, "taxon.id")
563
- ), u ? this.setState({ treeData: [...this.state.treeData] }, () => {
570
+ d && s === i.length - 2 && m(n, "taxon.id") !== m(d, "taxon.id") && O(n.children) && !p && n.children.length < n.childCount && (p = await this.pageThroughChildrenUntilTaxonFound(
571
+ n,
572
+ m(d, "taxon.id")
573
+ ), p ? this.setState({ treeData: [...this.state.treeData] }, () => {
564
574
  setTimeout(() => {
565
- document.getElementById(s).scrollIntoView({ behavior: "smooth", block: "center" });
575
+ document.getElementById(a).scrollIntoView({ behavior: "smooth", block: "center" });
566
576
  }, 100);
567
577
  }) : this.setState(
568
578
  {
569
- nodeNotFoundErr: /* @__PURE__ */ t.jsxs("span", { children: [
579
+ nodeNotFoundErr: /* @__PURE__ */ e.jsxs("span", { children: [
570
580
  "Cannot find taxon ",
571
- s,
581
+ a,
572
582
  " in tree 😥"
573
583
  ] }),
574
584
  rootLoading: !1
575
585
  },
576
586
  () => {
577
- this.props.treeType === "CATALOGUE" && typeof this.props.addMissingTargetKey == "function" && this.props.addMissingTargetKey(s);
587
+ this.props.treeType === "CATALOGUE" && typeof this.props.addMissingTargetKey == "function" && this.props.addMissingTargetKey(a);
578
588
  }
579
589
  ));
580
590
  }
581
591
  }
582
- const f = { loadedKeys: n, rootLoading: !1 };
583
- o && (f.expandedKeys = n), this.setState(f, () => {
584
- s && setTimeout(() => {
585
- document.getElementById(s).scrollIntoView({ behavior: "smooth", block: "center" });
592
+ const f = { loadedKeys: i, rootLoading: !1 };
593
+ o && (f.expandedKeys = i), this.setState(f, () => {
594
+ a && setTimeout(() => {
595
+ document.getElementById(a).scrollIntoView({ behavior: "smooth", block: "center" });
586
596
  }, 100);
587
597
  });
588
598
  });
@@ -595,7 +605,7 @@ class G extends j.Component {
595
605
  error: null,
596
606
  nodeNotFoundErr: null,
597
607
  rank: []
598
- }, this.treeRef = j.createRef();
608
+ }, this.treeRef = j.createRef(), this.rootRequestId = 0;
599
609
  }
600
610
  // datasetLoader comes from the shared TreeCacheContext so multiple tree
601
611
  // nodes (and TaxonSources instances) share one in-memory cache instead
@@ -605,222 +615,222 @@ class G extends j.Component {
605
615
  }
606
616
  render() {
607
617
  const {
608
- error: e,
609
- rootTotal: s,
618
+ error: t,
619
+ rootTotal: a,
610
620
  rootLoading: o,
611
621
  treeData: r,
612
- defaultExpandAll: h,
613
- nodeNotFoundErr: c,
614
- loadedKeys: n,
622
+ defaultExpandAll: l,
623
+ nodeNotFoundErr: d,
624
+ loadedKeys: i,
615
625
  expandedKeys: f
616
- } = this.state, { treeType: a, dataset: l, height: u, expandedTaxonKey: g } = this.props, d = g;
617
- return /* @__PURE__ */ t.jsxs("div", { children: [
618
- e && /* @__PURE__ */ t.jsx(j.Fragment, { children: y(e, "response.data.code") !== 404 ? /* @__PURE__ */ t.jsx(
619
- b,
626
+ } = this.state, { treeType: s, dataset: n, height: p, expandedTaxonKey: C } = this.props, c = C;
627
+ return /* @__PURE__ */ e.jsxs("div", { children: [
628
+ t && /* @__PURE__ */ e.jsx(j.Fragment, { children: m(t, "response.data.code") !== 404 ? /* @__PURE__ */ e.jsx(
629
+ w,
620
630
  {
621
631
  closable: !0,
622
632
  onClose: () => this.setState({ error: null }),
623
633
  style: { marginTop: "8px" },
624
- message: /* @__PURE__ */ t.jsx(ue, { error: e }),
634
+ message: /* @__PURE__ */ e.jsx(gt, { error: t }),
625
635
  type: "error"
626
636
  }
627
- ) : /* @__PURE__ */ t.jsx(
628
- b,
637
+ ) : /* @__PURE__ */ e.jsx(
638
+ w,
629
639
  {
630
640
  closable: !0,
631
641
  onClose: () => this.setState({ error: null }),
632
642
  style: { marginTop: "8px" },
633
- message: /* @__PURE__ */ t.jsx(
643
+ message: /* @__PURE__ */ e.jsx(
634
644
  Custom404,
635
645
  {
636
- error: e,
637
- treeType: a,
638
- dataset: l,
646
+ error: t,
647
+ treeType: s,
648
+ dataset: n,
639
649
  loadRoot: this.loadRoot
640
650
  }
641
651
  ),
642
652
  type: "warning"
643
653
  }
644
654
  ) }),
645
- c && /* @__PURE__ */ t.jsx(
646
- b,
655
+ d && /* @__PURE__ */ e.jsx(
656
+ w,
647
657
  {
648
658
  closable: !0,
649
659
  onClose: () => this.setState({ nodeNotFoundErr: null }),
650
660
  style: { marginTop: "8px" },
651
- message: c,
661
+ message: d,
652
662
  type: "warning"
653
663
  }
654
664
  ),
655
- o && /* @__PURE__ */ t.jsx(oe, { paragraph: { rows: 10 }, active: !0 }),
656
- !o && r.length > 0 && /* @__PURE__ */ t.jsx(
657
- ne,
665
+ o && /* @__PURE__ */ e.jsx(rt, { paragraph: { rows: 10 }, active: !0 }),
666
+ !o && r.length > 0 && /* @__PURE__ */ e.jsx(
667
+ lt,
658
668
  {
659
669
  ref: this.treeRef,
660
- defaultExpandAll: h,
670
+ defaultExpandAll: l,
661
671
  loadData: this.onLoadData,
662
- onLoad: (i) => this.setState({ loadedKeys: i }),
663
- loadedKeys: n,
672
+ onLoad: (h) => this.setState({ loadedKeys: h }),
673
+ loadedKeys: i,
664
674
  expandedKeys: f,
665
675
  treeData: r,
666
- filterTreeNode: (i) => i.key === d,
667
- onExpand: (i, C) => {
668
- this.setState({ expandedKeys: i }), this.props.onExpandedTaxonKeyChange && this.props.onExpandedTaxonKeyChange(
669
- C.expanded ? C.node.key : null
676
+ filterTreeNode: (h) => h.key === c,
677
+ onExpand: (h, g) => {
678
+ this.setState({ expandedKeys: h }), this.props.onExpandedTaxonKeyChange && this.props.onExpandedTaxonKeyChange(
679
+ g.expanded ? g.node.key : null
670
680
  );
671
681
  }
672
682
  }
673
683
  ),
674
- !e && r.length < s && /* @__PURE__ */ t.jsxs(ie, { loading: o, onClick: this.loadRoot, children: [
684
+ !t && r.length < a && /* @__PURE__ */ e.jsxs(dt, { loading: o, onClick: () => this.loadRoot(!0), children: [
675
685
  "Load more",
676
686
  " "
677
687
  ] })
678
688
  ] });
679
689
  }
680
690
  }
681
- p(G, "contextType", w);
682
- const ye = [
691
+ u(J, "contextType", E);
692
+ const jt = [
683
693
  "infraspecific name",
684
694
  "species",
685
695
  "variety",
686
696
  "form"
687
697
  ];
688
- class Z extends j.Component {
689
- constructor(e) {
690
- super(e);
691
- p(this, "componentDidMount", async () => {
692
- const { datasetKey: e, citation: s } = this.props;
693
- if (s)
698
+ class Q extends j.Component {
699
+ constructor(t) {
700
+ super(t);
701
+ u(this, "componentDidMount", async () => {
702
+ const { datasetKey: t, citation: a } = this.props;
703
+ if (a)
694
704
  try {
695
- const { data: o } = await ce(e);
705
+ const { data: o } = await ft(t);
696
706
  this.setState({ dataset: o });
697
707
  } catch {
698
708
  }
699
709
  });
700
- p(this, "render", () => {
710
+ u(this, "render", () => {
701
711
  const {
702
- datasetKey: e,
703
- defaultTaxonKey: s,
712
+ datasetKey: t,
713
+ defaultTaxonKey: a,
704
714
  expandedTaxonKey: o,
705
715
  onExpandedTaxonKeyChange: r,
706
- showTreeOptions: h,
707
- linkToSpeciesPage: c,
708
- citation: n,
716
+ showTreeOptions: l,
717
+ linkToSpeciesPage: d,
718
+ citation: i,
709
719
  type: f,
710
- insertPlaceholder: a = !0
711
- } = this.props, { hideExtinct: l, dataset: u } = this.state, g = (i) => {
712
- var P, _;
713
- const C = y(i, "key");
714
- if (!C) return;
715
- const q = y(i, "rank");
716
- if (c && ye.includes(q)) {
717
- const E = (_ = (P = this.context) == null ? void 0 : P.taxon) == null ? void 0 : _.onNavigate;
718
- E && E(C);
719
- } else r && (r(C), this.treeRef && this.treeRef.reloadRoot && this.treeRef.reloadRoot());
720
- }, d = () => {
720
+ insertPlaceholder: s = !0
721
+ } = this.props, { hideExtinct: n, dataset: p } = this.state, C = (h) => {
722
+ var T, $;
723
+ const g = m(h, "key");
724
+ if (!g) return;
725
+ const S = m(h, "rank");
726
+ if (d && jt.includes(S)) {
727
+ const v = ($ = (T = this.context) == null ? void 0 : T.taxon) == null ? void 0 : $.onNavigate;
728
+ v && v(g);
729
+ } else r && (r(g), this.treeRef && this.treeRef.reloadRoot && this.treeRef.reloadRoot());
730
+ }, c = () => {
721
731
  r && r(null);
722
732
  };
723
- return /* @__PURE__ */ t.jsxs("div", { className: "catalogue-of-life", children: [
724
- n === "top" && u && /* @__PURE__ */ t.jsx(F, { dataset: u }),
725
- /* @__PURE__ */ t.jsx(w.Provider, { value: this.cache, children: /* @__PURE__ */ t.jsxs(z.Provider, { value: this.state, children: [
726
- /* @__PURE__ */ t.jsxs(re, { children: [
727
- /* @__PURE__ */ t.jsx(v, { flex: "auto", children: /* @__PURE__ */ t.jsx(
728
- xe,
733
+ return /* @__PURE__ */ e.jsxs("div", { className: "catalogue-of-life", children: [
734
+ i === "top" && p && /* @__PURE__ */ e.jsx(R, { dataset: p }),
735
+ /* @__PURE__ */ e.jsx(E.Provider, { value: this.cache, children: /* @__PURE__ */ e.jsxs(X.Provider, { value: this.state, children: [
736
+ /* @__PURE__ */ e.jsxs(ht, { children: [
737
+ /* @__PURE__ */ e.jsx(I, { flex: "auto", children: /* @__PURE__ */ e.jsx(
738
+ mt,
729
739
  {
730
- hideExtinct: l,
731
- datasetKey: e,
740
+ hideExtinct: n,
741
+ datasetKey: t,
732
742
  style: {
733
743
  width: "100%",
734
744
  paddingTop: "5px",
735
745
  paddingBottom: "5px"
736
746
  },
737
747
  defaultTaxonKey: o || null,
738
- onSelectName: g,
739
- onResetSearch: d
748
+ onSelectName: C,
749
+ onResetSearch: c
740
750
  }
741
751
  ) }),
742
- h && /* @__PURE__ */ t.jsxs(v, { style: { paddingLeft: "8px" }, children: [
743
- /* @__PURE__ */ t.jsx(
744
- $,
752
+ l && /* @__PURE__ */ e.jsxs(I, { style: { paddingLeft: "8px" }, children: [
753
+ /* @__PURE__ */ e.jsx(
754
+ N,
745
755
  {
746
756
  defaultChecked: this.state.showInfo,
747
- onChange: ({ target: { checked: i } }) => {
748
- this.setState({ showInfo: i }), M("tree-show-source", i);
757
+ onChange: ({ target: { checked: h } }) => {
758
+ this.setState({ showInfo: h }), M("tree-show-source", h);
749
759
  },
750
760
  children: "Source"
751
761
  }
752
762
  ),
753
- /* @__PURE__ */ t.jsx(
754
- $,
763
+ /* @__PURE__ */ e.jsx(
764
+ N,
755
765
  {
756
766
  defaultChecked: this.state.hideExtinct,
757
- onChange: ({ target: { checked: i } }) => {
758
- this.setState({ hideExtinct: i }), M("tree-extant-only", i);
767
+ onChange: ({ target: { checked: h } }) => {
768
+ this.setState({ hideExtinct: h }), M("tree-extant-only", h);
759
769
  },
760
770
  children: "Extant only"
761
771
  }
762
772
  )
763
773
  ] })
764
774
  ] }),
765
- /* @__PURE__ */ t.jsx(
766
- G,
775
+ /* @__PURE__ */ e.jsx(
776
+ J,
767
777
  {
768
- insertPlaceholder: a,
769
- hideExtinct: l,
770
- datasetKey: e,
771
- defaultTaxonKey: s,
778
+ insertPlaceholder: s,
779
+ hideExtinct: n,
780
+ datasetKey: t,
781
+ defaultTaxonKey: a,
772
782
  expandedTaxonKey: o,
773
783
  onExpandedTaxonKeyChange: r,
774
- treeRef: (i) => this.treeRef = i,
784
+ treeRef: (h) => this.treeRef = h,
775
785
  type: f
776
786
  }
777
787
  )
778
788
  ] }) }),
779
- n === "bottom" && u && /* @__PURE__ */ t.jsx(F, { dataset: u })
789
+ i === "bottom" && p && /* @__PURE__ */ e.jsx(R, { dataset: p })
780
790
  ] });
781
791
  });
782
- de(this.props.auth), this.state = {
783
- hideExtinct: O("tree-extant-only", !1),
784
- showInfo: O("tree-show-source", !1),
792
+ ut(this.props.auth), this.state = {
793
+ hideExtinct: F("tree-extant-only", !1),
794
+ showInfo: F("tree-show-source", !1),
785
795
  dataset: null
786
796
  }, this.cache = B(this.props.datasetKey);
787
797
  }
788
- componentDidUpdate(e) {
789
- e.datasetKey !== this.props.datasetKey && (this.cache = B(this.props.datasetKey));
798
+ componentDidUpdate(t) {
799
+ t.datasetKey !== this.props.datasetKey && (this.cache = B(this.props.datasetKey));
790
800
  }
791
801
  }
792
- p(Z, "contextType", U);
793
- function me({
794
- datasetKey: m,
795
- defaultTaxonKey: x,
796
- expandedTaxonKey: e,
797
- onExpandedTaxonKeyChange: s,
802
+ u(Q, "contextType", H);
803
+ function St({
804
+ datasetKey: x,
805
+ defaultTaxonKey: y,
806
+ expandedTaxonKey: t,
807
+ onExpandedTaxonKeyChange: a,
798
808
  showTreeOptions: o,
799
809
  linkToSpeciesPage: r,
800
- citation: h,
801
- type: c,
802
- insertPlaceholder: n,
810
+ citation: l,
811
+ type: d,
812
+ insertPlaceholder: i,
803
813
  auth: f,
804
- ...a
814
+ ...s
805
815
  }) {
806
- return /* @__PURE__ */ t.jsx(U.Provider, { value: he(a), children: /* @__PURE__ */ t.jsx(
807
- Z,
816
+ return /* @__PURE__ */ e.jsx(H.Provider, { value: pt(s), children: /* @__PURE__ */ e.jsx(
817
+ Q,
808
818
  {
809
- datasetKey: m,
810
- defaultTaxonKey: x,
811
- expandedTaxonKey: e,
812
- onExpandedTaxonKeyChange: s,
819
+ datasetKey: x,
820
+ defaultTaxonKey: y,
821
+ expandedTaxonKey: t,
822
+ onExpandedTaxonKeyChange: a,
813
823
  showTreeOptions: o,
814
824
  linkToSpeciesPage: r,
815
- citation: h,
816
- type: c,
817
- insertPlaceholder: n,
825
+ citation: l,
826
+ type: d,
827
+ insertPlaceholder: i,
818
828
  auth: f
819
829
  }
820
830
  ) });
821
831
  }
822
- const Ne = Y(X(me));
832
+ const Ot = st(et(St));
823
833
  export {
824
- Ne as Tree
834
+ Ot as Tree
825
835
  };
826
836
  //# sourceMappingURL=tree.js.map