chrono-phylo-tree 1.1.9 → 1.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/App.d.ts +2 -0
  2. package/dist/chrono-phylo-tree.es.js +1122 -0
  3. package/dist/chrono-phylo-tree.umd.js +15 -0
  4. package/dist/classes/Species.d.ts +34 -0
  5. package/dist/components/HoverDescription.d.ts +14 -0
  6. package/dist/components/LanguageSelector.d.ts +8 -0
  7. package/dist/components/Menu.d.ts +14 -0
  8. package/dist/components/NavBar.d.ts +32 -0
  9. package/dist/components/PhTree.d.ts +30 -0
  10. package/dist/index.d.ts +5 -0
  11. package/dist/logo.png +0 -0
  12. package/dist/main.d.ts +0 -0
  13. package/dist/translate.csv +37 -0
  14. package/dist/utils/between.d.ts +1 -0
  15. package/dist/utils/example.d.ts +2 -0
  16. package/dist/utils/hexToRGBA.d.ts +1 -0
  17. package/dist/utils/scientificNotation.d.ts +1 -0
  18. package/dist/utils/setFromJson.d.ts +2 -0
  19. package/dist/utils/translate.d.ts +3 -0
  20. package/dist/utils/updateSpecies.d.ts +6 -0
  21. package/dist/vite.svg +1 -0
  22. package/package.json +13 -3
  23. package/src/App.css +0 -131
  24. package/src/App.tsx +0 -149
  25. package/src/assets/react.svg +0 -1
  26. package/src/classes/Species.tsx +0 -267
  27. package/src/components/HoverDescription.tsx +0 -27
  28. package/src/components/LanguageSelector.tsx +0 -29
  29. package/src/components/Menu.tsx +0 -348
  30. package/src/components/NavBar.tsx +0 -234
  31. package/src/components/PhTree.tsx +0 -362
  32. package/src/index.css +0 -68
  33. package/src/index.ts +0 -4
  34. package/src/main.tsx +0 -10
  35. package/src/types.d.ts +0 -9
  36. package/src/utils/between.tsx +0 -3
  37. package/src/utils/example.tsx +0 -73
  38. package/src/utils/hexToRGBA.tsx +0 -12
  39. package/src/utils/scientificNotation.tsx +0 -20
  40. package/src/utils/setFromJson.tsx +0 -40
  41. package/src/utils/translate.tsx +0 -68
  42. package/src/utils/updateSpecies.tsx +0 -129
  43. package/src/vite-env.d.ts +0 -1
@@ -0,0 +1,1122 @@
1
+ var Mt = Object.defineProperty;
2
+ var Lt = (r, n, s) => n in r ? Mt(r, n, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[n] = s;
3
+ var ft = (r, n, s) => Lt(r, typeof n != "symbol" ? n + "" : n, s);
4
+ import { jsxs as X, Fragment as wt, jsx as g } from "react/jsx-runtime";
5
+ import { useState as P, useEffect as Et } from "react";
6
+ const Tt = (r, ...n) => r.sort(
7
+ (s, a) => {
8
+ for (const u of n) {
9
+ const [c, l] = [s, a].map((m) => u(m));
10
+ if (c !== l) return c - l;
11
+ }
12
+ return 0;
13
+ }
14
+ );
15
+ class gt {
16
+ constructor(n = "", s = 0, a = 0, u = void 0, c = [], l = void 0, m = void 0) {
17
+ ft(this, "name", "");
18
+ ft(this, "apparition", 0);
19
+ ft(this, "duration", 0);
20
+ ft(this, "ancestor");
21
+ ft(this, "descendants", []);
22
+ ft(this, "description");
23
+ ft(this, "display", !0);
24
+ ft(this, "image");
25
+ if (a <= 0)
26
+ throw new Error("The duration of the species must be greater than 0");
27
+ this.name = n, this.apparition = s, this.duration = a, this.ancestor = u, this.descendants = c, this.description = l === "" ? void 0 : l, this.image = m === "" ? void 0 : m;
28
+ }
29
+ onPosition(n = !0) {
30
+ return n && this.firstAncestor().stepsUntil(this) % 2 === 0;
31
+ }
32
+ copy() {
33
+ const n = this.firstAncestor(), s = n.allDescendants(!1).indexOf(this);
34
+ return gt.fromJSON(n.toJSON()).allDescendants(!1)[s];
35
+ }
36
+ unlinkAncestor() {
37
+ if (!this.ancestor)
38
+ return;
39
+ this.ancestor.descendants = this.ancestor.descendants.filter((s) => s !== this);
40
+ const n = this.ancestor;
41
+ return this.ancestor = void 0, [n.firstAncestor(), this];
42
+ }
43
+ unlinkDescendant(n) {
44
+ if (this.descendants.includes(n))
45
+ return this.descendants = this.descendants.filter((s) => s !== n), n.ancestor = void 0, [this.firstAncestor(), n];
46
+ }
47
+ linkAncestor(n) {
48
+ if (!(this.ancestor === n && n.descendants.includes(this))) {
49
+ if (n.apparition > this.apparition)
50
+ throw new Error(`The ancestor's apparition (${n.apparition}) must be before or equal the descendant's apparition (${this.apparition})`);
51
+ if (n.extinction() < this.apparition)
52
+ throw new Error(`The ancestor's extinction (${n.extinction()}) must be after or equal the descendant's apparition (${this.apparition})`);
53
+ this.ancestor !== n && this.unlinkAncestor(), this.ancestor = n, n.descendants.push(this);
54
+ }
55
+ }
56
+ linkDescendant(n) {
57
+ if (!(n.ancestor === this && this.descendants.includes(n))) {
58
+ if (n.apparition < this.apparition)
59
+ throw new Error(`The descendant's apparition (${n.apparition}) must be after or equal the ancestor's apparition (${this.apparition})`);
60
+ if (n.extinction() > this.extinction())
61
+ throw new Error(`The descendant's extinction (${n.extinction()}) must be before or equal the ancestor's extinction (${this.extinction()})`);
62
+ this.descendants.includes(n) || (n.ancestor && n.unlinkAncestor(), this.descendants.push(n), n.ancestor = this);
63
+ }
64
+ }
65
+ linkDescendants(n) {
66
+ for (const s of n)
67
+ try {
68
+ this.linkDescendant(s);
69
+ } catch (a) {
70
+ console.error(`Error linking descendant ${s.name} to ancestor ${this.name}:`, a);
71
+ }
72
+ }
73
+ addDescendant(n = "", s = 0, a = 0, u = void 0, c = void 0, l = !1) {
74
+ if (s < 0 || s > this.duration)
75
+ throw new Error(`The apparition of the descendant must be between the apparition (${this.apparition}) and the extinction (${this.extinction()}) of the ancestor`);
76
+ const m = l ? this.copy() : this, v = new gt(
77
+ n,
78
+ m.apparition + Math.max(s, 0),
79
+ Math.max(a, 0),
80
+ void 0,
81
+ [],
82
+ u,
83
+ c
84
+ );
85
+ return v.linkAncestor(m), l ? m : v;
86
+ }
87
+ removeDescendant(n) {
88
+ this.descendants = this.descendants.filter((s) => s !== n);
89
+ }
90
+ addAncestor(n = "", s = 0, a = 0, u = void 0, c = void 0, l = !0, m = !1) {
91
+ if (s < 0)
92
+ throw new Error(`The apparition of the ancestor must be before or equal the apparition (${this.apparition}) of the descendant`);
93
+ if (a < s)
94
+ throw new Error(`The extiction of the ancestor must be after or equal the apparition (${this.apparition}) of the descendant`);
95
+ const v = m ? this.copy() : this, o = new gt(
96
+ n,
97
+ v.apparition - Math.max(s, 0),
98
+ a,
99
+ void 0,
100
+ [],
101
+ u,
102
+ c
103
+ );
104
+ return o.display = l, v.linkAncestor(o), m ? v : o;
105
+ }
106
+ extinction() {
107
+ return this.apparition + this.duration;
108
+ }
109
+ absoluteExtinction() {
110
+ return this.descendants.length > 0 ? Math.max(...this.allDescendants(!1).map((n) => n.extinction())) : this.extinction();
111
+ }
112
+ absoluteDuration() {
113
+ return this.absoluteExtinction() - this.apparition;
114
+ }
115
+ firstAncestor(n = !1) {
116
+ return this.ancestor ? this.ancestor.display || n ? this.ancestor.firstAncestor() : this : this;
117
+ }
118
+ cousinsExtinction() {
119
+ return this.firstAncestor().absoluteExtinction();
120
+ }
121
+ allDescendants(n = !0) {
122
+ const s = n ? Tt(this.descendants, (o) => -o.apparition, (o) => -o.absoluteExtinction()) : this.descendants;
123
+ if (s.length === 0)
124
+ return [this];
125
+ const a = s.filter((o) => o.apparition >= this.extinction()), u = s.filter((o) => a.indexOf(o) === -1), l = (this.onPosition(n) ? Math.ceil : Math.floor)(a.length / 2), m = a.slice(0, l), v = a.slice(l);
126
+ return m.flatMap((o) => o.allDescendants(n)).concat([this]).concat(v.flatMap((o) => o.allDescendants(n))).concat(u.flatMap((o) => o.allDescendants(n)));
127
+ }
128
+ stepsChain(n, s = !1) {
129
+ var a;
130
+ return this.allDescendants(!1).includes(n) ? [this].concat(((a = this.descendants.find((u) => u.allDescendants(!1).includes(n))) == null ? void 0 : a.stepsChain(n)) ?? []).filter((u) => u.display || s) : [];
131
+ }
132
+ stepsUntil(n, s = !1) {
133
+ if (this.allDescendants(!1).includes(n))
134
+ return this.stepsChain(n, s).length - 1;
135
+ }
136
+ stepsUntilLastDescendant(n = !1) {
137
+ return this.descendants.length === 0 ? 0 : Math.max(...this.allDescendants(!1).filter((s) => s.descendants.length === 0).map((s) => this.stepsUntil(s, n) ?? 0));
138
+ }
139
+ toJSON() {
140
+ return {
141
+ name: this.name,
142
+ apparition: this.ancestor ? void 0 : this.apparition,
143
+ afterApparition: this.ancestor ? this.apparition - this.ancestor.apparition : void 0,
144
+ description: this.description,
145
+ duration: this.duration,
146
+ descendants: this.descendants.length > 0 ? this.descendants.map((n) => n.toJSON()) : void 0,
147
+ image: this.image
148
+ };
149
+ }
150
+ async saveJSON(n = void 0) {
151
+ try {
152
+ const s = JSON.stringify(this.toJSON(), null, 2), a = new Blob([s], { type: "application/json" }), u = URL.createObjectURL(a), c = document.createElement("a");
153
+ c.href = u, c.download = n ?? `${this.name}.json`, c.click(), URL.revokeObjectURL(u);
154
+ } catch (s) {
155
+ console.error("Error saving file:", s);
156
+ }
157
+ }
158
+ static fromJSON(n, s) {
159
+ const a = n.afterApparition ?? 0, u = s ? s.apparition : n.apparition ?? 0, c = new gt(n.name ?? "", u + a, n.duration ?? 0, s, [], n.description, n.image);
160
+ if (n.descendants)
161
+ for (const l of n.descendants)
162
+ c.descendants.push(gt.fromJSON(l, c));
163
+ return c;
164
+ }
165
+ }
166
+ const Xt = ({
167
+ speciesList: r,
168
+ width: n = 1e3,
169
+ height: s = 50,
170
+ padding: a = 0,
171
+ stroke: u = "grey",
172
+ format: c = (E) => E.toString(),
173
+ chronoScale: l = !0,
174
+ showImages: m = !0,
175
+ presentTime: v,
176
+ handleMouseMove: o,
177
+ children: b
178
+ }) => {
179
+ const E = r.map((N) => N.copy()), A = Math.min(...E.map((N) => N.apparition)), L = Math.max(...E.map((N) => N.apparition - A)), C = new gt(
180
+ "",
181
+ A,
182
+ L,
183
+ void 0,
184
+ []
185
+ );
186
+ return C.display = !1, C.linkDescendants(E), /* @__PURE__ */ g(
187
+ It,
188
+ {
189
+ commonAncestor: C,
190
+ width: n,
191
+ height: s,
192
+ padding: a,
193
+ stroke: u,
194
+ format: c,
195
+ chronoScale: l,
196
+ showImages: m,
197
+ presentTime: v,
198
+ handleMouseMove: o,
199
+ children: (N, T, B, V) => b == null ? void 0 : b(N, T, B, V)
200
+ }
201
+ );
202
+ }, It = ({
203
+ commonAncestor: r,
204
+ width: n = 1e3,
205
+ height: s = 50,
206
+ padding: a = 0,
207
+ stroke: u = "grey",
208
+ format: c = (E) => E.toString(),
209
+ chronoScale: l = !0,
210
+ showImages: m = !0,
211
+ presentTime: v,
212
+ handleMouseMove: o,
213
+ children: b
214
+ }) => {
215
+ const [E, A] = P(!1), [L, C] = P(void 0), [N, T] = P(void 0), [B, V] = P(r.allDescendants().reduce((t, e) => t.set(e, !0), /* @__PURE__ */ new Map()));
216
+ Et(() => {
217
+ V(r.allDescendants().reduce((t, e) => t.set(e, !0), /* @__PURE__ */ new Map()));
218
+ }, [r]);
219
+ const Z = (t) => {
220
+ C(E ? void 0 : t), A(!E);
221
+ }, rt = (t) => {
222
+ const e = new Map(B);
223
+ e.set(t, !B.get(t)), V(e);
224
+ }, et = (t) => {
225
+ T(t);
226
+ }, K = v !== void 0 && l, p = (t) => m ? t.map((e) => e.image ? 2 : 1).reduce((e, i) => e + i) : t.length;
227
+ return /* @__PURE__ */ X(wt, { children: [
228
+ /* @__PURE__ */ g(
229
+ "svg",
230
+ {
231
+ width: n * (K ? (Math.min(v, r.absoluteExtinction()) - r.apparition) / r.absoluteDuration() : 1),
232
+ height: s * p(K ? r.allDescendants().filter((t) => t.apparition < v) : r.allDescendants()),
233
+ onMouseMove: (t) => {
234
+ o == null || o(t.clientX, t.clientY);
235
+ },
236
+ children: /* @__PURE__ */ g(
237
+ At,
238
+ {
239
+ commonAncestor: r,
240
+ species: r,
241
+ y: -1,
242
+ scaleX: n / (l ? r.absoluteDuration() : Math.max(0, r.stepsUntilLastDescendant()) + 1),
243
+ scaleY: s,
244
+ padding: a,
245
+ stroke: u,
246
+ format: c,
247
+ chronoScale: l,
248
+ showImages: m,
249
+ presentTime: v,
250
+ toggleShowMenu: Z,
251
+ hoverShowMenu: et,
252
+ showDesc: B,
253
+ changeShowDesc: rt
254
+ }
255
+ )
256
+ }
257
+ ),
258
+ b == null ? void 0 : b(L, E, Z, N)
259
+ ] });
260
+ }, At = ({
261
+ commonAncestor: r,
262
+ species: n,
263
+ y: s,
264
+ scaleX: a,
265
+ scaleY: u,
266
+ padding: c = 0,
267
+ stroke: l = "grey",
268
+ format: m = (N) => N.toString(),
269
+ chronoScale: v = !0,
270
+ showImages: o = !0,
271
+ presentTime: b = void 0,
272
+ toggleShowMenu: E,
273
+ hoverShowMenu: A,
274
+ showDesc: L,
275
+ changeShowDesc: C
276
+ }) => {
277
+ const N = b !== void 0 && v, T = r.allDescendants().filter((p) => N ? p.apparition < b : !0), B = T.indexOf(n), V = (v ? n.apparition - r.apparition : r.stepsUntil(n) ?? 0) * a, Z = V + (v ? Math.min(L.get(n) ? n.duration : n.absoluteDuration(), N ? b - n.apparition : n.absoluteDuration()) : 1) * a, rt = o && B > 0 ? [...Array(B).keys()].map((p) => T[p]).map((p) => (p.image ? 2 : 1) * u).reduce((p, t) => p + t) : B * u, et = n.descendants.filter((p) => N ? p.apparition < b : !0), K = et.length > 0 ? V + (Math.min(...et.map((p) => p.apparition)) - n.apparition) * a : Z;
278
+ return /* @__PURE__ */ X("g", { children: [
279
+ s >= 0 && /* @__PURE__ */ g(
280
+ "line",
281
+ {
282
+ x1: V,
283
+ y1: s,
284
+ x2: V,
285
+ y2: rt,
286
+ stroke: l
287
+ }
288
+ ),
289
+ n.display && /* @__PURE__ */ g(
290
+ Ft,
291
+ {
292
+ commonAncestor: r,
293
+ species: n,
294
+ height: u,
295
+ x1: V,
296
+ x2: Z,
297
+ x0: K,
298
+ y: rt,
299
+ stroke: l,
300
+ changeShowDesc: () => C(n),
301
+ showDesc: L.get(n),
302
+ padding: c,
303
+ format: m,
304
+ chronoScale: v,
305
+ showImages: o,
306
+ presentTime: b,
307
+ toggleShowMenu: E,
308
+ hoverShowMenu: A
309
+ }
310
+ ),
311
+ n.descendants.map((p, t) => /* @__PURE__ */ g("g", { className: L.get(n) && et.includes(p) ? "block" : "hidden", children: /* @__PURE__ */ g(
312
+ At,
313
+ {
314
+ commonAncestor: r,
315
+ species: p,
316
+ y: p.display ? rt : -1,
317
+ scaleX: a,
318
+ scaleY: u,
319
+ padding: c,
320
+ stroke: l,
321
+ format: m,
322
+ chronoScale: v,
323
+ showImages: o,
324
+ presentTime: b,
325
+ toggleShowMenu: E,
326
+ showDesc: L,
327
+ changeShowDesc: C,
328
+ hoverShowMenu: A
329
+ }
330
+ ) }, T.length + t))
331
+ ] }, B);
332
+ }, Ft = ({
333
+ commonAncestor: r,
334
+ species: n,
335
+ height: s,
336
+ x1: a,
337
+ x2: u,
338
+ x0: c,
339
+ y: l,
340
+ stroke: m,
341
+ showDesc: v = !0,
342
+ changeShowDesc: o = () => {
343
+ },
344
+ padding: b = 0,
345
+ format: E = (Z) => Z.toString(),
346
+ chronoScale: A = !0,
347
+ showImages: L = !0,
348
+ presentTime: C,
349
+ toggleShowMenu: N,
350
+ hoverShowMenu: T,
351
+ className: B,
352
+ buttonClassName: V
353
+ }) => {
354
+ const Z = C !== void 0, rt = r.allDescendants().filter((i) => Z ? i.apparition < C : !0), et = (i) => rt.indexOf(i), K = n.ancestor && et(n) > et(n.ancestor) ? -3 : 1, p = n.descendants.filter((i) => Z ? i.apparition < C : !0), t = p.filter((i) => i.apparition === n.extinction()).length === 0, e = E(Math.min(v ? n.extinction() : n.absoluteExtinction(), Z ? C : n.absoluteExtinction()));
355
+ return /* @__PURE__ */ X("g", { children: [
356
+ /* @__PURE__ */ g(
357
+ "line",
358
+ {
359
+ x1: a,
360
+ y1: l,
361
+ x2: u,
362
+ y2: l,
363
+ stroke: m
364
+ }
365
+ ),
366
+ /* @__PURE__ */ g(
367
+ "foreignObject",
368
+ {
369
+ x: a + b,
370
+ y: l + b * K,
371
+ width: (A ? c ?? u : u) - a - 2 * b,
372
+ height: s + (L && n.image ? s : 0),
373
+ children: /* @__PURE__ */ X("div", { className: `flex flex-row justify-between w-full ${B ?? ""}`, children: [
374
+ /* @__PURE__ */ g("div", { children: A ? E(n.apparition) : "" }),
375
+ /* @__PURE__ */ X(
376
+ "button",
377
+ {
378
+ className: `p-0.625 justify-center flex flex-col items-center ${V ?? ""}`,
379
+ onClick: () => N(n),
380
+ onMouseEnter: () => T(n),
381
+ onMouseLeave: () => T(void 0),
382
+ children: [
383
+ n.name,
384
+ n.image && L && /* @__PURE__ */ g(
385
+ "img",
386
+ {
387
+ src: n.image,
388
+ alt: n.name,
389
+ style: { height: s }
390
+ }
391
+ )
392
+ ]
393
+ }
394
+ ),
395
+ p.length > 0 ? /* @__PURE__ */ g("button", { onClick: o, className: "h-1", style: { maxWidth: 4 }, children: (t || !v) && (!c || c === u) ? e : "" }) : /* @__PURE__ */ g("div", { children: A ? e : "" })
396
+ ] })
397
+ }
398
+ ),
399
+ A && c && c < u && /* @__PURE__ */ g(
400
+ "foreignObject",
401
+ {
402
+ x: c + b,
403
+ y: l + b * K,
404
+ width: u - c - 2 * b,
405
+ height: s,
406
+ children: /* @__PURE__ */ g("div", { className: "flex flex-row justify-end w-full", children: (t || !v) && A ? e : "" })
407
+ }
408
+ )
409
+ ] });
410
+ }, Nt = (r, n, s) => r < n ? n : r > s ? s : r;
411
+ function jt(r) {
412
+ return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
413
+ }
414
+ var vt = { exports: {} };
415
+ /* @license
416
+ Papa Parse
417
+ v5.5.2
418
+ https://github.com/mholt/PapaParse
419
+ License: MIT
420
+ */
421
+ var Pt = vt.exports, St;
422
+ function Ut() {
423
+ return St || (St = 1, function(r, n) {
424
+ ((s, a) => {
425
+ r.exports = a();
426
+ })(Pt, function s() {
427
+ var a = typeof self < "u" ? self : typeof window < "u" ? window : a !== void 0 ? a : {}, u, c = !a.document && !!a.postMessage, l = a.IS_PAPA_WORKER || !1, m = {}, v = 0, o = {};
428
+ function b(t) {
429
+ this._handle = null, this._finished = !1, this._completed = !1, this._halted = !1, this._input = null, this._baseIndex = 0, this._partialLine = "", this._rowCount = 0, this._start = 0, this._nextChunk = null, this.isFirstChunk = !0, this._completeResults = { data: [], errors: [], meta: {} }, (function(e) {
430
+ var i = et(e);
431
+ i.chunkSize = parseInt(i.chunkSize), e.step || e.chunk || (i.chunkSize = null), this._handle = new N(i), (this._handle.streamer = this)._config = i;
432
+ }).call(this, t), this.parseChunk = function(e, i) {
433
+ var h = parseInt(this._config.skipFirstNLines) || 0;
434
+ if (this.isFirstChunk && 0 < h) {
435
+ let x = this._config.newline;
436
+ x || (d = this._config.quoteChar || '"', x = this._handle.guessLineEndings(e, d)), e = [...e.split(x).slice(h)].join(x);
437
+ }
438
+ this.isFirstChunk && p(this._config.beforeFirstChunk) && (d = this._config.beforeFirstChunk(e)) !== void 0 && (e = d), this.isFirstChunk = !1, this._halted = !1;
439
+ var h = this._partialLine + e, d = (this._partialLine = "", this._handle.parse(h, this._baseIndex, !this._finished));
440
+ if (!this._handle.paused() && !this._handle.aborted()) {
441
+ if (e = d.meta.cursor, h = (this._finished || (this._partialLine = h.substring(e - this._baseIndex), this._baseIndex = e), d && d.data && (this._rowCount += d.data.length), this._finished || this._config.preview && this._rowCount >= this._config.preview), l) a.postMessage({ results: d, workerId: o.WORKER_ID, finished: h });
442
+ else if (p(this._config.chunk) && !i) {
443
+ if (this._config.chunk(d, this._handle), this._handle.paused() || this._handle.aborted()) return void (this._halted = !0);
444
+ this._completeResults = d = void 0;
445
+ }
446
+ return this._config.step || this._config.chunk || (this._completeResults.data = this._completeResults.data.concat(d.data), this._completeResults.errors = this._completeResults.errors.concat(d.errors), this._completeResults.meta = d.meta), this._completed || !h || !p(this._config.complete) || d && d.meta.aborted || (this._config.complete(this._completeResults, this._input), this._completed = !0), h || d && d.meta.paused || this._nextChunk(), d;
447
+ }
448
+ this._halted = !0;
449
+ }, this._sendError = function(e) {
450
+ p(this._config.error) ? this._config.error(e) : l && this._config.error && a.postMessage({ workerId: o.WORKER_ID, error: e, finished: !1 });
451
+ };
452
+ }
453
+ function E(t) {
454
+ var e;
455
+ (t = t || {}).chunkSize || (t.chunkSize = o.RemoteChunkSize), b.call(this, t), this._nextChunk = c ? function() {
456
+ this._readChunk(), this._chunkLoaded();
457
+ } : function() {
458
+ this._readChunk();
459
+ }, this.stream = function(i) {
460
+ this._input = i, this._nextChunk();
461
+ }, this._readChunk = function() {
462
+ if (this._finished) this._chunkLoaded();
463
+ else {
464
+ if (e = new XMLHttpRequest(), this._config.withCredentials && (e.withCredentials = this._config.withCredentials), c || (e.onload = K(this._chunkLoaded, this), e.onerror = K(this._chunkError, this)), e.open(this._config.downloadRequestBody ? "POST" : "GET", this._input, !c), this._config.downloadRequestHeaders) {
465
+ var i, h = this._config.downloadRequestHeaders;
466
+ for (i in h) e.setRequestHeader(i, h[i]);
467
+ }
468
+ var d;
469
+ this._config.chunkSize && (d = this._start + this._config.chunkSize - 1, e.setRequestHeader("Range", "bytes=" + this._start + "-" + d));
470
+ try {
471
+ e.send(this._config.downloadRequestBody);
472
+ } catch (x) {
473
+ this._chunkError(x.message);
474
+ }
475
+ c && e.status === 0 && this._chunkError();
476
+ }
477
+ }, this._chunkLoaded = function() {
478
+ e.readyState === 4 && (e.status < 200 || 400 <= e.status ? this._chunkError() : (this._start += this._config.chunkSize || e.responseText.length, this._finished = !this._config.chunkSize || this._start >= ((i) => (i = i.getResponseHeader("Content-Range")) !== null ? parseInt(i.substring(i.lastIndexOf("/") + 1)) : -1)(e), this.parseChunk(e.responseText)));
479
+ }, this._chunkError = function(i) {
480
+ i = e.statusText || i, this._sendError(new Error(i));
481
+ };
482
+ }
483
+ function A(t) {
484
+ (t = t || {}).chunkSize || (t.chunkSize = o.LocalChunkSize), b.call(this, t);
485
+ var e, i, h = typeof FileReader < "u";
486
+ this.stream = function(d) {
487
+ this._input = d, i = d.slice || d.webkitSlice || d.mozSlice, h ? ((e = new FileReader()).onload = K(this._chunkLoaded, this), e.onerror = K(this._chunkError, this)) : e = new FileReaderSync(), this._nextChunk();
488
+ }, this._nextChunk = function() {
489
+ this._finished || this._config.preview && !(this._rowCount < this._config.preview) || this._readChunk();
490
+ }, this._readChunk = function() {
491
+ var d = this._input, x = (this._config.chunkSize && (x = Math.min(this._start + this._config.chunkSize, this._input.size), d = i.call(d, this._start, x)), e.readAsText(d, this._config.encoding));
492
+ h || this._chunkLoaded({ target: { result: x } });
493
+ }, this._chunkLoaded = function(d) {
494
+ this._start += this._config.chunkSize, this._finished = !this._config.chunkSize || this._start >= this._input.size, this.parseChunk(d.target.result);
495
+ }, this._chunkError = function() {
496
+ this._sendError(e.error);
497
+ };
498
+ }
499
+ function L(t) {
500
+ var e;
501
+ b.call(this, t = t || {}), this.stream = function(i) {
502
+ return e = i, this._nextChunk();
503
+ }, this._nextChunk = function() {
504
+ var i, h;
505
+ if (!this._finished) return i = this._config.chunkSize, e = i ? (h = e.substring(0, i), e.substring(i)) : (h = e, ""), this._finished = !e, this.parseChunk(h);
506
+ };
507
+ }
508
+ function C(t) {
509
+ b.call(this, t = t || {});
510
+ var e = [], i = !0, h = !1;
511
+ this.pause = function() {
512
+ b.prototype.pause.apply(this, arguments), this._input.pause();
513
+ }, this.resume = function() {
514
+ b.prototype.resume.apply(this, arguments), this._input.resume();
515
+ }, this.stream = function(d) {
516
+ this._input = d, this._input.on("data", this._streamData), this._input.on("end", this._streamEnd), this._input.on("error", this._streamError);
517
+ }, this._checkIsFinished = function() {
518
+ h && e.length === 1 && (this._finished = !0);
519
+ }, this._nextChunk = function() {
520
+ this._checkIsFinished(), e.length ? this.parseChunk(e.shift()) : i = !0;
521
+ }, this._streamData = K(function(d) {
522
+ try {
523
+ e.push(typeof d == "string" ? d : d.toString(this._config.encoding)), i && (i = !1, this._checkIsFinished(), this.parseChunk(e.shift()));
524
+ } catch (x) {
525
+ this._streamError(x);
526
+ }
527
+ }, this), this._streamError = K(function(d) {
528
+ this._streamCleanUp(), this._sendError(d);
529
+ }, this), this._streamEnd = K(function() {
530
+ this._streamCleanUp(), h = !0, this._streamData("");
531
+ }, this), this._streamCleanUp = K(function() {
532
+ this._input.removeListener("data", this._streamData), this._input.removeListener("end", this._streamEnd), this._input.removeListener("error", this._streamError);
533
+ }, this);
534
+ }
535
+ function N(t) {
536
+ var e, i, h, d, x = Math.pow(2, 53), H = -x, at = /^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/, st = /^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/, D = this, U = 0, _ = 0, Y = !1, w = !1, O = [], f = { data: [], errors: [], meta: {} };
537
+ function J(R) {
538
+ return t.skipEmptyLines === "greedy" ? R.join("").trim() === "" : R.length === 1 && R[0].length === 0;
539
+ }
540
+ function $() {
541
+ if (f && h && (ot("Delimiter", "UndetectableDelimiter", "Unable to auto-detect delimiting character; defaulted to '" + o.DefaultDelimiter + "'"), h = !1), t.skipEmptyLines && (f.data = f.data.filter(function(y) {
542
+ return !J(y);
543
+ })), G()) {
544
+ let y = function(z, W) {
545
+ p(t.transformHeader) && (z = t.transformHeader(z, W)), O.push(z);
546
+ };
547
+ if (f) if (Array.isArray(f.data[0])) {
548
+ for (var R = 0; G() && R < f.data.length; R++) f.data[R].forEach(y);
549
+ f.data.splice(0, 1);
550
+ } else f.data.forEach(y);
551
+ }
552
+ function M(y, z) {
553
+ for (var W = t.header ? {} : [], I = 0; I < y.length; I++) {
554
+ var F = I, S = y[I], S = ((ht, k) => ((j) => (t.dynamicTypingFunction && t.dynamicTyping[j] === void 0 && (t.dynamicTyping[j] = t.dynamicTypingFunction(j)), (t.dynamicTyping[j] || t.dynamicTyping) === !0))(ht) ? k === "true" || k === "TRUE" || k !== "false" && k !== "FALSE" && (((j) => {
555
+ if (at.test(j) && (j = parseFloat(j), H < j && j < x))
556
+ return 1;
557
+ })(k) ? parseFloat(k) : st.test(k) ? new Date(k) : k === "" ? null : k) : k)(F = t.header ? I >= O.length ? "__parsed_extra" : O[I] : F, S = t.transform ? t.transform(S, F) : S);
558
+ F === "__parsed_extra" ? (W[F] = W[F] || [], W[F].push(S)) : W[F] = S;
559
+ }
560
+ return t.header && (I > O.length ? ot("FieldMismatch", "TooManyFields", "Too many fields: expected " + O.length + " fields but parsed " + I, _ + z) : I < O.length && ot("FieldMismatch", "TooFewFields", "Too few fields: expected " + O.length + " fields but parsed " + I, _ + z)), W;
561
+ }
562
+ var q;
563
+ f && (t.header || t.dynamicTyping || t.transform) && (q = 1, !f.data.length || Array.isArray(f.data[0]) ? (f.data = f.data.map(M), q = f.data.length) : f.data = M(f.data, 0), t.header && f.meta && (f.meta.fields = O), _ += q);
564
+ }
565
+ function G() {
566
+ return t.header && O.length === 0;
567
+ }
568
+ function ot(R, M, q, y) {
569
+ R = { type: R, code: M, message: q }, y !== void 0 && (R.row = y), f.errors.push(R);
570
+ }
571
+ p(t.step) && (d = t.step, t.step = function(R) {
572
+ f = R, G() ? $() : ($(), f.data.length !== 0 && (U += R.data.length, t.preview && U > t.preview ? i.abort() : (f.data = f.data[0], d(f, D))));
573
+ }), this.parse = function(R, M, q) {
574
+ var y = t.quoteChar || '"', y = (t.newline || (t.newline = this.guessLineEndings(R, y)), h = !1, t.delimiter ? p(t.delimiter) && (t.delimiter = t.delimiter(R), f.meta.delimiter = t.delimiter) : ((y = ((z, W, I, F, S) => {
575
+ var ht, k, j, pt;
576
+ S = S || [",", " ", "|", ";", o.RECORD_SEP, o.UNIT_SEP];
577
+ for (var mt = 0; mt < S.length; mt++) {
578
+ for (var dt, yt = S[mt], tt = 0, ut = 0, Q = 0, nt = (j = void 0, new B({ comments: F, delimiter: yt, newline: W, preview: 10 }).parse(z)), ct = 0; ct < nt.data.length; ct++) I && J(nt.data[ct]) ? Q++ : (dt = nt.data[ct].length, ut += dt, j === void 0 ? j = dt : 0 < dt && (tt += Math.abs(dt - j), j = dt));
579
+ 0 < nt.data.length && (ut /= nt.data.length - Q), (k === void 0 || tt <= k) && (pt === void 0 || pt < ut) && 1.99 < ut && (k = tt, ht = yt, pt = ut);
580
+ }
581
+ return { successful: !!(t.delimiter = ht), bestDelimiter: ht };
582
+ })(R, t.newline, t.skipEmptyLines, t.comments, t.delimitersToGuess)).successful ? t.delimiter = y.bestDelimiter : (h = !0, t.delimiter = o.DefaultDelimiter), f.meta.delimiter = t.delimiter), et(t));
583
+ return t.preview && t.header && y.preview++, e = R, i = new B(y), f = i.parse(e, M, q), $(), Y ? { meta: { paused: !0 } } : f || { meta: { paused: !1 } };
584
+ }, this.paused = function() {
585
+ return Y;
586
+ }, this.pause = function() {
587
+ Y = !0, i.abort(), e = p(t.chunk) ? "" : e.substring(i.getCharIndex());
588
+ }, this.resume = function() {
589
+ D.streamer._halted ? (Y = !1, D.streamer.parseChunk(e, !0)) : setTimeout(D.resume, 3);
590
+ }, this.aborted = function() {
591
+ return w;
592
+ }, this.abort = function() {
593
+ w = !0, i.abort(), f.meta.aborted = !0, p(t.complete) && t.complete(f), e = "";
594
+ }, this.guessLineEndings = function(z, y) {
595
+ z = z.substring(0, 1048576);
596
+ var y = new RegExp(T(y) + "([^]*?)" + T(y), "gm"), q = (z = z.replace(y, "")).split("\r"), y = z.split(`
597
+ `), z = 1 < y.length && y[0].length < q[0].length;
598
+ if (q.length === 1 || z) return `
599
+ `;
600
+ for (var W = 0, I = 0; I < q.length; I++) q[I][0] === `
601
+ ` && W++;
602
+ return W >= q.length / 2 ? `\r
603
+ ` : "\r";
604
+ };
605
+ }
606
+ function T(t) {
607
+ return t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
608
+ }
609
+ function B(t) {
610
+ var e = (t = t || {}).delimiter, i = t.newline, h = t.comments, d = t.step, x = t.preview, H = t.fastMode, at = null, st = !1, D = t.quoteChar == null ? '"' : t.quoteChar, U = D;
611
+ if (t.escapeChar !== void 0 && (U = t.escapeChar), (typeof e != "string" || -1 < o.BAD_DELIMITERS.indexOf(e)) && (e = ","), h === e) throw new Error("Comment character same as delimiter");
612
+ h === !0 ? h = "#" : (typeof h != "string" || -1 < o.BAD_DELIMITERS.indexOf(h)) && (h = !1), i !== `
613
+ ` && i !== "\r" && i !== `\r
614
+ ` && (i = `
615
+ `);
616
+ var _ = 0, Y = !1;
617
+ this.parse = function(w, O, f) {
618
+ if (typeof w != "string") throw new Error("Input must be a string");
619
+ var J = w.length, $ = e.length, G = i.length, ot = h.length, R = p(d), M = [], q = [], y = [], z = _ = 0;
620
+ if (!w) return tt();
621
+ if (H || H !== !1 && w.indexOf(D) === -1) {
622
+ for (var W = w.split(i), I = 0; I < W.length; I++) {
623
+ if (y = W[I], _ += y.length, I !== W.length - 1) _ += i.length;
624
+ else if (f) return tt();
625
+ if (!h || y.substring(0, ot) !== h) {
626
+ if (R) {
627
+ if (M = [], pt(y.split(e)), ut(), Y) return tt();
628
+ } else pt(y.split(e));
629
+ if (x && x <= I) return M = M.slice(0, x), tt(!0);
630
+ }
631
+ }
632
+ return tt();
633
+ }
634
+ for (var F = w.indexOf(e, _), S = w.indexOf(i, _), ht = new RegExp(T(U) + T(D), "g"), k = w.indexOf(D, _); ; ) if (w[_] === D) for (k = _, _++; ; ) {
635
+ if ((k = w.indexOf(D, k + 1)) === -1) return f || q.push({ type: "Quotes", code: "MissingQuotes", message: "Quoted field unterminated", row: M.length, index: _ }), dt();
636
+ if (k === J - 1) return dt(w.substring(_, k).replace(ht, D));
637
+ if (D === U && w[k + 1] === U) k++;
638
+ else if (D === U || k === 0 || w[k - 1] !== U) {
639
+ F !== -1 && F < k + 1 && (F = w.indexOf(e, k + 1));
640
+ var j = mt((S = S !== -1 && S < k + 1 ? w.indexOf(i, k + 1) : S) === -1 ? F : Math.min(F, S));
641
+ if (w.substr(k + 1 + j, $) === e) {
642
+ y.push(w.substring(_, k).replace(ht, D)), w[_ = k + 1 + j + $] !== D && (k = w.indexOf(D, _)), F = w.indexOf(e, _), S = w.indexOf(i, _);
643
+ break;
644
+ }
645
+ if (j = mt(S), w.substring(k + 1 + j, k + 1 + j + G) === i) {
646
+ if (y.push(w.substring(_, k).replace(ht, D)), yt(k + 1 + j + G), F = w.indexOf(e, _), k = w.indexOf(D, _), R && (ut(), Y)) return tt();
647
+ if (x && M.length >= x) return tt(!0);
648
+ break;
649
+ }
650
+ q.push({ type: "Quotes", code: "InvalidQuotes", message: "Trailing quote on quoted field is malformed", row: M.length, index: _ }), k++;
651
+ }
652
+ }
653
+ else if (h && y.length === 0 && w.substring(_, _ + ot) === h) {
654
+ if (S === -1) return tt();
655
+ _ = S + G, S = w.indexOf(i, _), F = w.indexOf(e, _);
656
+ } else if (F !== -1 && (F < S || S === -1)) y.push(w.substring(_, F)), _ = F + $, F = w.indexOf(e, _);
657
+ else {
658
+ if (S === -1) break;
659
+ if (y.push(w.substring(_, S)), yt(S + G), R && (ut(), Y)) return tt();
660
+ if (x && M.length >= x) return tt(!0);
661
+ }
662
+ return dt();
663
+ function pt(Q) {
664
+ M.push(Q), z = _;
665
+ }
666
+ function mt(Q) {
667
+ var nt = 0;
668
+ return nt = Q !== -1 && (Q = w.substring(k + 1, Q)) && Q.trim() === "" ? Q.length : nt;
669
+ }
670
+ function dt(Q) {
671
+ return f || (Q === void 0 && (Q = w.substring(_)), y.push(Q), _ = J, pt(y), R && ut()), tt();
672
+ }
673
+ function yt(Q) {
674
+ _ = Q, pt(y), y = [], S = w.indexOf(i, _);
675
+ }
676
+ function tt(Q) {
677
+ if (t.header && !O && M.length && !st) {
678
+ var nt = M[0], ct = {}, xt = new Set(nt);
679
+ let Ot = !1;
680
+ for (let _t = 0; _t < nt.length; _t++) {
681
+ let lt = nt[_t];
682
+ if (ct[lt = p(t.transformHeader) ? t.transformHeader(lt, _t) : lt]) {
683
+ let bt, Rt = ct[lt];
684
+ for (; bt = lt + "_" + Rt, Rt++, xt.has(bt); ) ;
685
+ xt.add(bt), nt[_t] = bt, ct[lt]++, Ot = !0, (at = at === null ? {} : at)[bt] = lt;
686
+ } else ct[lt] = 1, nt[_t] = lt;
687
+ xt.add(lt);
688
+ }
689
+ Ot && console.warn("Duplicate headers found and renamed."), st = !0;
690
+ }
691
+ return { data: M, errors: q, meta: { delimiter: e, linebreak: i, aborted: Y, truncated: !!Q, cursor: z + (O || 0), renamedHeaders: at } };
692
+ }
693
+ function ut() {
694
+ d(tt()), M = [], q = [];
695
+ }
696
+ }, this.abort = function() {
697
+ Y = !0;
698
+ }, this.getCharIndex = function() {
699
+ return _;
700
+ };
701
+ }
702
+ function V(t) {
703
+ var e = t.data, i = m[e.workerId], h = !1;
704
+ if (e.error) i.userError(e.error, e.file);
705
+ else if (e.results && e.results.data) {
706
+ var d = { abort: function() {
707
+ h = !0, Z(e.workerId, { data: [], errors: [], meta: { aborted: !0 } });
708
+ }, pause: rt, resume: rt };
709
+ if (p(i.userStep)) {
710
+ for (var x = 0; x < e.results.data.length && (i.userStep({ data: e.results.data[x], errors: e.results.errors, meta: e.results.meta }, d), !h); x++) ;
711
+ delete e.results;
712
+ } else p(i.userChunk) && (i.userChunk(e.results, d, e.file), delete e.results);
713
+ }
714
+ e.finished && !h && Z(e.workerId, e.results);
715
+ }
716
+ function Z(t, e) {
717
+ var i = m[t];
718
+ p(i.userComplete) && i.userComplete(e), i.terminate(), delete m[t];
719
+ }
720
+ function rt() {
721
+ throw new Error("Not implemented.");
722
+ }
723
+ function et(t) {
724
+ if (typeof t != "object" || t === null) return t;
725
+ var e, i = Array.isArray(t) ? [] : {};
726
+ for (e in t) i[e] = et(t[e]);
727
+ return i;
728
+ }
729
+ function K(t, e) {
730
+ return function() {
731
+ t.apply(e, arguments);
732
+ };
733
+ }
734
+ function p(t) {
735
+ return typeof t == "function";
736
+ }
737
+ return o.parse = function(t, e) {
738
+ var i = (e = e || {}).dynamicTyping || !1;
739
+ if (p(i) && (e.dynamicTypingFunction = i, i = {}), e.dynamicTyping = i, e.transform = !!p(e.transform) && e.transform, !e.worker || !o.WORKERS_SUPPORTED) return i = null, o.NODE_STREAM_INPUT, typeof t == "string" ? (t = ((h) => h.charCodeAt(0) !== 65279 ? h : h.slice(1))(t), i = new (e.download ? E : L)(e)) : t.readable === !0 && p(t.read) && p(t.on) ? i = new C(e) : (a.File && t instanceof File || t instanceof Object) && (i = new A(e)), i.stream(t);
740
+ (i = (() => {
741
+ var h;
742
+ return !!o.WORKERS_SUPPORTED && (h = (() => {
743
+ var d = a.URL || a.webkitURL || null, x = s.toString();
744
+ return o.BLOB_URL || (o.BLOB_URL = d.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ", "(", x, ")();"], { type: "text/javascript" })));
745
+ })(), (h = new a.Worker(h)).onmessage = V, h.id = v++, m[h.id] = h);
746
+ })()).userStep = e.step, i.userChunk = e.chunk, i.userComplete = e.complete, i.userError = e.error, e.step = p(e.step), e.chunk = p(e.chunk), e.complete = p(e.complete), e.error = p(e.error), delete e.worker, i.postMessage({ input: t, config: e, workerId: i.id });
747
+ }, o.unparse = function(t, e) {
748
+ var i = !1, h = !0, d = ",", x = `\r
749
+ `, H = '"', at = H + H, st = !1, D = null, U = !1, _ = ((() => {
750
+ if (typeof e == "object") {
751
+ if (typeof e.delimiter != "string" || o.BAD_DELIMITERS.filter(function(O) {
752
+ return e.delimiter.indexOf(O) !== -1;
753
+ }).length || (d = e.delimiter), typeof e.quotes != "boolean" && typeof e.quotes != "function" && !Array.isArray(e.quotes) || (i = e.quotes), typeof e.skipEmptyLines != "boolean" && typeof e.skipEmptyLines != "string" || (st = e.skipEmptyLines), typeof e.newline == "string" && (x = e.newline), typeof e.quoteChar == "string" && (H = e.quoteChar), typeof e.header == "boolean" && (h = e.header), Array.isArray(e.columns)) {
754
+ if (e.columns.length === 0) throw new Error("Option columns is empty");
755
+ D = e.columns;
756
+ }
757
+ e.escapeChar !== void 0 && (at = e.escapeChar + H), e.escapeFormulae instanceof RegExp ? U = e.escapeFormulae : typeof e.escapeFormulae == "boolean" && e.escapeFormulae && (U = /^[=+\-@\t\r].*$/);
758
+ }
759
+ })(), new RegExp(T(H), "g"));
760
+ if (typeof t == "string" && (t = JSON.parse(t)), Array.isArray(t)) {
761
+ if (!t.length || Array.isArray(t[0])) return Y(null, t, st);
762
+ if (typeof t[0] == "object") return Y(D || Object.keys(t[0]), t, st);
763
+ } else if (typeof t == "object") return typeof t.data == "string" && (t.data = JSON.parse(t.data)), Array.isArray(t.data) && (t.fields || (t.fields = t.meta && t.meta.fields || D), t.fields || (t.fields = Array.isArray(t.data[0]) ? t.fields : typeof t.data[0] == "object" ? Object.keys(t.data[0]) : []), Array.isArray(t.data[0]) || typeof t.data[0] == "object" || (t.data = [t.data])), Y(t.fields || [], t.data || [], st);
764
+ throw new Error("Unable to serialize unrecognized input");
765
+ function Y(O, f, J) {
766
+ var $ = "", G = (typeof O == "string" && (O = JSON.parse(O)), typeof f == "string" && (f = JSON.parse(f)), Array.isArray(O) && 0 < O.length), ot = !Array.isArray(f[0]);
767
+ if (G && h) {
768
+ for (var R = 0; R < O.length; R++) 0 < R && ($ += d), $ += w(O[R], R);
769
+ 0 < f.length && ($ += x);
770
+ }
771
+ for (var M = 0; M < f.length; M++) {
772
+ var q = (G ? O : f[M]).length, y = !1, z = G ? Object.keys(f[M]).length === 0 : f[M].length === 0;
773
+ if (J && !G && (y = J === "greedy" ? f[M].join("").trim() === "" : f[M].length === 1 && f[M][0].length === 0), J === "greedy" && G) {
774
+ for (var W = [], I = 0; I < q; I++) {
775
+ var F = ot ? O[I] : I;
776
+ W.push(f[M][F]);
777
+ }
778
+ y = W.join("").trim() === "";
779
+ }
780
+ if (!y) {
781
+ for (var S = 0; S < q; S++) {
782
+ 0 < S && !z && ($ += d);
783
+ var ht = G && ot ? O[S] : S;
784
+ $ += w(f[M][ht], S);
785
+ }
786
+ M < f.length - 1 && (!J || 0 < q && !z) && ($ += x);
787
+ }
788
+ }
789
+ return $;
790
+ }
791
+ function w(O, f) {
792
+ var J, $;
793
+ return O == null ? "" : O.constructor === Date ? JSON.stringify(O).slice(1, 25) : ($ = !1, U && typeof O == "string" && U.test(O) && (O = "'" + O, $ = !0), J = O.toString().replace(_, at), ($ = $ || i === !0 || typeof i == "function" && i(O, f) || Array.isArray(i) && i[f] || ((G, ot) => {
794
+ for (var R = 0; R < ot.length; R++) if (-1 < G.indexOf(ot[R])) return !0;
795
+ return !1;
796
+ })(J, o.BAD_DELIMITERS) || -1 < J.indexOf(d) || J.charAt(0) === " " || J.charAt(J.length - 1) === " ") ? H + J + H : J);
797
+ }
798
+ }, o.RECORD_SEP = "", o.UNIT_SEP = "", o.BYTE_ORDER_MARK = "\uFEFF", o.BAD_DELIMITERS = ["\r", `
799
+ `, '"', o.BYTE_ORDER_MARK], o.WORKERS_SUPPORTED = !c && !!a.Worker, o.NODE_STREAM_INPUT = 1, o.LocalChunkSize = 10485760, o.RemoteChunkSize = 5242880, o.DefaultDelimiter = ",", o.Parser = B, o.ParserHandle = N, o.NetworkStreamer = E, o.FileStreamer = A, o.StringStreamer = L, o.ReadableStreamStreamer = C, a.jQuery && ((u = a.jQuery).fn.parse = function(t) {
800
+ var e = t.config || {}, i = [];
801
+ return this.each(function(x) {
802
+ if (!(u(this).prop("tagName").toUpperCase() === "INPUT" && u(this).attr("type").toLowerCase() === "file" && a.FileReader) || !this.files || this.files.length === 0) return !0;
803
+ for (var H = 0; H < this.files.length; H++) i.push({ file: this.files[H], inputElem: this, instanceConfig: u.extend({}, e) });
804
+ }), h(), this;
805
+ function h() {
806
+ if (i.length === 0) p(t.complete) && t.complete();
807
+ else {
808
+ var x, H, at, st, D = i[0];
809
+ if (p(t.before)) {
810
+ var U = t.before(D.file, D.inputElem);
811
+ if (typeof U == "object") {
812
+ if (U.action === "abort") return x = "AbortError", H = D.file, at = D.inputElem, st = U.reason, void (p(t.error) && t.error({ name: x }, H, at, st));
813
+ if (U.action === "skip") return void d();
814
+ typeof U.config == "object" && (D.instanceConfig = u.extend(D.instanceConfig, U.config));
815
+ } else if (U === "skip") return void d();
816
+ }
817
+ var _ = D.instanceConfig.complete;
818
+ D.instanceConfig.complete = function(Y) {
819
+ p(_) && _(Y, D.file, D.inputElem), d();
820
+ }, o.parse(D.file, D.instanceConfig);
821
+ }
822
+ }
823
+ function d() {
824
+ i.splice(0, 1), h();
825
+ }
826
+ }), l && (a.onmessage = function(t) {
827
+ t = t.data, o.WORKER_ID === void 0 && t && (o.WORKER_ID = t.workerId), typeof t.input == "string" ? a.postMessage({ workerId: o.WORKER_ID, results: o.parse(t.input, t.config), finished: !0 }) : (a.File && t.input instanceof File || t.input instanceof Object) && (t = o.parse(t.input, t.config)) && a.postMessage({ workerId: o.WORKER_ID, results: t, finished: !0 });
828
+ }), (E.prototype = Object.create(b.prototype)).constructor = E, (A.prototype = Object.create(b.prototype)).constructor = A, (L.prototype = Object.create(L.prototype)).constructor = L, (C.prototype = Object.create(b.prototype)).constructor = C, o;
829
+ });
830
+ }(vt)), vt.exports;
831
+ }
832
+ var qt = Ut();
833
+ const zt = /* @__PURE__ */ jt(qt);
834
+ let Ct = [];
835
+ const kt = async (r) => {
836
+ const a = await (await fetch(r)).body.getReader().read(), c = new TextDecoder("utf-8").decode(a.value), { data: l } = zt.parse(c, {
837
+ header: !0,
838
+ dynamicTyping: !0,
839
+ delimiter: ";"
840
+ });
841
+ return l;
842
+ }, $t = (r = "/translate.csv") => (async (n = "/translate.csv") => {
843
+ Ct = await kt(n);
844
+ })(r), it = (r, n, s = [], a = "/translate.csv") => {
845
+ const [u, c] = P([]);
846
+ Et(() => {
847
+ kt(a).then(c), $t(a);
848
+ }, [n]);
849
+ const l = u.find((m) => m.code === r) ?? Ct.find((m) => m.code === r);
850
+ try {
851
+ const m = l[n];
852
+ return s.reduce((o, b, E) => o.replace(`{${E}}`, b), m);
853
+ } catch {
854
+ return;
855
+ }
856
+ }, Zt = async (r, n, s = [], a = "/translate.csv") => {
857
+ const c = (await kt(a)).find((l) => l.code === r);
858
+ try {
859
+ const l = c[n];
860
+ return s.reduce((m, v, o) => m.replace(`{${o}}`, v), l);
861
+ } catch {
862
+ return "";
863
+ }
864
+ }, Gt = (r = "/translate.csv") => {
865
+ const [n, s] = P(/* @__PURE__ */ new Map());
866
+ return Et(() => {
867
+ (async () => {
868
+ const c = (await kt(r)).find((l) => l.code === "lan");
869
+ if (c) {
870
+ delete c.code;
871
+ const l = new Map(Object.entries(c));
872
+ s(l);
873
+ }
874
+ })();
875
+ }, []), n;
876
+ }, Vt = ({ species: r, language: n, open: s, onClose: a, saveSpecies: u, createDescendant: c, createAncestor: l, deleteAncestor: m, deleteSpecies: v }) => {
877
+ const [o, b] = P(r.name), [E, A] = P(r.apparition), [L, C] = P(r.duration), [N, T] = P(r.description ?? ""), [B, V] = P(!1), [Z, rt] = P(!1), [et, K] = P(r.image ?? ""), p = () => {
878
+ V(!B);
879
+ }, t = () => {
880
+ rt(!Z);
881
+ }, e = (i) => i.ancestor ? i.ancestor.descendants.length === 1 && e(i.ancestor) : !0;
882
+ return /* @__PURE__ */ g(Jt, { open: s, onClose: a, children: /* @__PURE__ */ g("form", { style: { backgroundColor: "grey" }, className: "flex flex-col text-start w-auto fixed p-2.5", children: /* @__PURE__ */ X(
883
+ Dt,
884
+ {
885
+ name: o,
886
+ setName: b,
887
+ apparition: E,
888
+ setApparition: (i) => {
889
+ A(r.ancestor ? Nt(i, r.ancestor.apparition, r.ancestor.extinction()) : i), C(r.descendants.length > 0 ? Math.max(Math.max(...r.descendants.map((h) => h.apparition)) - E, L) : L);
890
+ },
891
+ minApparition: r.ancestor ? r.ancestor.apparition : void 0,
892
+ maxApparition: r.ancestor ? r.ancestor.extinction() : void 0,
893
+ duration: L,
894
+ setDuration: C,
895
+ minDuration: r.descendants.length > 0 ? Math.max(...r.descendants.map((i) => i.apparition)) - E : void 0,
896
+ maxDuration: r.descendants.length > 0 ? Math.max(...r.descendants.map((i) => i.apparition)) - E : void 0,
897
+ description: N,
898
+ setDescription: T,
899
+ image: et,
900
+ setImage: K,
901
+ language: n,
902
+ children: [
903
+ /* @__PURE__ */ g("button", { onClick: async () => {
904
+ try {
905
+ await (u == null ? void 0 : u(r, o, E, L, N, et)), a == null || a();
906
+ } catch (i) {
907
+ console.error(i);
908
+ }
909
+ }, children: it("spbtn00", n ?? "") }),
910
+ /* @__PURE__ */ g("button", { type: "button", onClick: v, children: it("spbtn01", n ?? "") }),
911
+ /* @__PURE__ */ g("button", { type: "button", onClick: p, children: it("spbtn02", n ?? "") }),
912
+ B && /* @__PURE__ */ g(
913
+ Bt,
914
+ {
915
+ species: r,
916
+ language: n,
917
+ onClose: a,
918
+ createDescendant: c
919
+ }
920
+ ),
921
+ r.ancestor ? e(r) && /* @__PURE__ */ g("button", { type: "button", onClick: async () => {
922
+ try {
923
+ await (m == null ? void 0 : m()), a == null || a();
924
+ } catch (i) {
925
+ console.error(i);
926
+ }
927
+ }, children: it("spbtn04" + (r.ancestor.ancestor ? "_0" : ""), n ?? "") }) : /* @__PURE__ */ g("button", { type: "button", onClick: t, children: it("spbtn03", n ?? "") }),
928
+ Z && /* @__PURE__ */ g(
929
+ Ht,
930
+ {
931
+ species: r,
932
+ language: n,
933
+ onClose: a,
934
+ createAncestor: l
935
+ }
936
+ ),
937
+ /* @__PURE__ */ g("button", { type: "button", onClick: a, children: it("spbtn05", n ?? "") })
938
+ ]
939
+ }
940
+ ) }) });
941
+ }, Dt = ({
942
+ name: r,
943
+ setName: n,
944
+ apparition: s,
945
+ setApparition: a,
946
+ minApparition: u,
947
+ maxApparition: c,
948
+ duration: l,
949
+ setDuration: m,
950
+ minDuration: v,
951
+ maxDuration: o,
952
+ description: b,
953
+ setDescription: E,
954
+ language: A,
955
+ image: L,
956
+ setImage: C,
957
+ children: N
958
+ }) => /* @__PURE__ */ X(wt, { children: [
959
+ /* @__PURE__ */ g("table", { children: /* @__PURE__ */ X("tbody", { children: [
960
+ /* @__PURE__ */ X("tr", { children: [
961
+ /* @__PURE__ */ X("td", { children: [
962
+ it("splbl00", A ?? ""),
963
+ ":"
964
+ ] }),
965
+ /* @__PURE__ */ g("td", { children: /* @__PURE__ */ g(
966
+ "input",
967
+ {
968
+ type: "text",
969
+ value: r,
970
+ onChange: (T) => n(T.target.value)
971
+ }
972
+ ) })
973
+ ] }),
974
+ /* @__PURE__ */ X("tr", { children: [
975
+ /* @__PURE__ */ X("td", { children: [
976
+ it("splbl01", A ?? ""),
977
+ ":"
978
+ ] }),
979
+ /* @__PURE__ */ g("td", { children: /* @__PURE__ */ g(
980
+ "input",
981
+ {
982
+ type: "number",
983
+ min: u,
984
+ max: c,
985
+ value: s,
986
+ onChange: (T) => a(Number(T.target.value))
987
+ }
988
+ ) })
989
+ ] }),
990
+ /* @__PURE__ */ X("tr", { children: [
991
+ /* @__PURE__ */ X("td", { children: [
992
+ it("splbl02", A ?? ""),
993
+ ":"
994
+ ] }),
995
+ /* @__PURE__ */ g("td", { children: /* @__PURE__ */ g(
996
+ "input",
997
+ {
998
+ type: "number",
999
+ min: v,
1000
+ max: o,
1001
+ value: l,
1002
+ onChange: (T) => m(Number(T.target.value))
1003
+ }
1004
+ ) })
1005
+ ] }),
1006
+ /* @__PURE__ */ X("tr", { children: [
1007
+ /* @__PURE__ */ X("td", { children: [
1008
+ it("splbl03", A ?? ""),
1009
+ ":"
1010
+ ] }),
1011
+ /* @__PURE__ */ g("td", { children: /* @__PURE__ */ g(
1012
+ "textarea",
1013
+ {
1014
+ value: b,
1015
+ onChange: (T) => E(T.target.value)
1016
+ }
1017
+ ) })
1018
+ ] }),
1019
+ /* @__PURE__ */ X("tr", { children: [
1020
+ /* @__PURE__ */ X("td", { children: [
1021
+ it("splbl04", A ?? ""),
1022
+ ":"
1023
+ ] }),
1024
+ /* @__PURE__ */ g("td", { children: /* @__PURE__ */ g(
1025
+ "input",
1026
+ {
1027
+ type: "text",
1028
+ value: L,
1029
+ onChange: (T) => C(T.target.value)
1030
+ }
1031
+ ) })
1032
+ ] }),
1033
+ /* @__PURE__ */ g("tr", { children: /* @__PURE__ */ g("td", { colSpan: 2, children: /* @__PURE__ */ g(
1034
+ "img",
1035
+ {
1036
+ src: L,
1037
+ style: { height: "100px" }
1038
+ }
1039
+ ) }) })
1040
+ ] }) }),
1041
+ N
1042
+ ] }), Bt = ({ species: r, language: n, onClose: s, createDescendant: a }) => {
1043
+ const [u, c] = P(""), [l, m] = P(r.duration), [v, o] = P(r.duration), [b, E] = P(""), [A, L] = P("");
1044
+ return /* @__PURE__ */ g(wt, { children: /* @__PURE__ */ g(
1045
+ Dt,
1046
+ {
1047
+ name: u,
1048
+ setName: c,
1049
+ apparition: r.apparition + l,
1050
+ setApparition: (C) => m(C - r.apparition),
1051
+ minApparition: r.apparition,
1052
+ maxApparition: r.extinction(),
1053
+ duration: v,
1054
+ setDuration: o,
1055
+ description: b,
1056
+ setDescription: E,
1057
+ image: A,
1058
+ setImage: L,
1059
+ language: n,
1060
+ children: /* @__PURE__ */ g("button", { type: "button", onClick: async () => {
1061
+ try {
1062
+ await (a == null ? void 0 : a(r, u, l, v, b, A)), s == null || s();
1063
+ } catch (C) {
1064
+ console.error(C);
1065
+ }
1066
+ }, children: it("cdbtn00", n ?? "") })
1067
+ }
1068
+ ) });
1069
+ }, Ht = ({ species: r, language: n, onClose: s, createAncestor: a }) => {
1070
+ const [u, c] = P(""), [l, m] = P(r.duration), [v, o] = P(r.duration), [b, E] = P(""), [A, L] = P("");
1071
+ return /* @__PURE__ */ g(wt, { children: /* @__PURE__ */ g(
1072
+ Dt,
1073
+ {
1074
+ name: u,
1075
+ setName: c,
1076
+ apparition: r.apparition - l,
1077
+ setApparition: (C) => {
1078
+ m(r.apparition - C), o(Math.max(r.apparition - C, v));
1079
+ },
1080
+ maxApparition: r.apparition,
1081
+ duration: v,
1082
+ setDuration: o,
1083
+ minDuration: l,
1084
+ description: b,
1085
+ setDescription: E,
1086
+ image: A,
1087
+ setImage: L,
1088
+ language: n,
1089
+ children: /* @__PURE__ */ g("button", { type: "button", onClick: async () => {
1090
+ try {
1091
+ await (a == null ? void 0 : a(r, u, l, v, b, A)), s == null || s();
1092
+ } catch (C) {
1093
+ console.error(C);
1094
+ }
1095
+ }, children: it("cdbtn00", n ?? "") })
1096
+ }
1097
+ ) });
1098
+ }, Jt = ({ open: r, onClose: n, children: s }) => /* @__PURE__ */ g(
1099
+ "div",
1100
+ {
1101
+ style: { backgroundColor: r ? "rgba(0, 0, 0, 0.2)" : "rgba(0, 0, 0, 0)" },
1102
+ className: `flex fixed inset-0 justify-center items-center transition-colors duration-300 ease-in-out ${r ? "visible" : "hidden"}`,
1103
+ onClick: n,
1104
+ children: /* @__PURE__ */ g(
1105
+ "div",
1106
+ {
1107
+ onClick: (a) => a.stopPropagation(),
1108
+ className: "flex justify-center items-center",
1109
+ children: s
1110
+ }
1111
+ )
1112
+ }
1113
+ );
1114
+ export {
1115
+ Vt as Menu,
1116
+ Xt as MultiplePhTrees,
1117
+ It as PhTree,
1118
+ gt as Species,
1119
+ it as codeText,
1120
+ Zt as codeTextAlt,
1121
+ Gt as getLanguageOptions
1122
+ };