UNPKG

@linkurious/ogma-annotations-react

Version:

A react component to add ogma annotations with react

1,069 lines 96.9 kB
import Wr, { createContext as Ye, useContext as Ur, useReducer as Xr, useState as Et, useEffect as he } from "react"; import { useOgma as Gr } from "@linkurious/ogma-react"; var Vr = Object.defineProperty, Zr = (l, t, i) => t in l ? Vr(l, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : l[t] = i, m = (l, t, i) => Zr(l, typeof t != "symbol" ? t + "" : t, i); let Jt = (l = 21) => crypto.getRandomValues(new Uint8Array(l)).reduce((t, i) => (i &= 63, i < 36 ? t += i.toString(36) : i < 62 ? t += (i - 26).toString(36).toUpperCase() : i > 62 ? t += "-" : t += "_", t), ""); const Pt = { strokeType: "plain", strokeColor: "#202020", strokeWidth: 1, head: "none", tail: "none" }, $e = { id: 0, type: "Feature", properties: { type: "arrow", style: { ...Pt } }, geometry: { type: "LineString", coordinates: [ [0, 0], [100, 100] ] } // type: 'arrow', // stroke: { // type: 'plain', // color: 'black', // width: 1 // }, // head: 'none', // tail: 'arrow-plain', // start: { x: 0, y: 0 }, // end: { x: 100, y: 100 } }, Yr = (l = 0, t = 0, i = 0, r = 0, a = { ...Pt }) => ({ id: Jt(), type: "Feature", properties: { type: "arrow", style: { ...Pt, ...a } }, geometry: { type: "LineString", coordinates: [ [l, t], [i, r] ] } }), Jr = "http://www.w3.org/2000/svg"; function wt(l) { return document.createElementNS(Jr, l); } function Je(l) { return l.geometry.bbox || Kr(l), l.geometry.bbox; } function ft(l) { const t = Je(l); return { width: t[2] - t[0], height: t[3] - t[1] }; } function dt(l) { const t = Je(l); return { x: t[0], y: t[1] }; } function Kr(l) { const [t, i] = l.geometry.coordinates[0][0], [r, a] = l.geometry.coordinates[0][2]; l.geometry.bbox = [t, i, r, a]; } function Qr(l, t, i, r, a) { l.geometry.bbox = [t, i, t + r, i + a], l.geometry.coordinates = [ [ [t, i], [t + r, i], [t + r, i + a], [t, i + a], [t, i] ] ]; } function zt(l) { const [t, i] = l.geometry.coordinates[0]; return { x: t, y: i }; } function Rt(l, t) { const [i, r] = l.geometry.coordinates[t === "start" ? 0 : 1]; return { x: i, y: r }; } function Xt(l) { const [t, i] = l.geometry.coordinates[1]; return { x: t, y: i }; } function Ke(l, t, i) { l.geometry.coordinates[0] = [t, i]; } function Qe(l, t, i) { l.geometry.coordinates[1] = [t, i]; } function Gt(l) { return { start: zt(l), end: Xt(l) }; } function St(l, t, i, r) { t === "start" ? Ke(l, i, r) : Qe(l, i, r); } const tr = (l) => parseInt(l.getAttribute("data-handle-id") || "-1"); function tn(l) { return Array.isArray(l) && l.length === 2 && l.every(isFinite); } function en(l, t, i, r) { for (let a = 0; a < l.coordinates.length; a++) { const h = l.coordinates[a]; if (tn(h)) h[0] = i + (h[0] - i) * t, h[1] = r + (h[1] - r) * t; else for (let c = 0; c < h.length; c++) { const d = h[c]; d[0] = i + (d[0] - i) * t, d[1] = r + (d[1] - r) * t; } } return l; } function Wt(l, t, i) { const r = Math.atan2(l.y - t.y, l.x - t.x); return { x: t.x + i * Math.cos(r), y: t.y + i * Math.sin(r) }; } function Vt(l, t) { if (!t) return { x: l.clientX, y: l.clientY }; const i = t.getBoundingClientRect(); return { x: l.clientX - i.left - t.clientLeft, y: l.clientY - i.top - t.clientTop }; } const xt = (l, t) => ({ x: l.x - t.x, y: l.y - t.y }), _t = (l) => Math.sqrt(l.x * l.x + l.y * l.y), er = (l) => ({ x: -l.x, y: -l.y }), rr = (l) => { const t = _t(l); return t === 0 ? { x: 0, y: 0 } : { x: l.x / t, y: l.y / t }; }, Ct = (l, t) => ({ x: l.x + t.x, y: l.y + t.y }), nr = (l, t) => ({ x: l.x * t, y: l.y * t }), Ut = (l, t) => ({ x: l.x * t.x, y: l.y * t.y }), nt = (l, t) => { const i = Math.sin(t), r = Math.cos(t); return { x: l.x * r - l.y * i, y: l.x * i + l.y * r }; }, rn = (l, t) => ({ x: l.x / t, y: l.y / t }), Ie = (l, t) => l.x * t.x + l.y * t.y, nn = 0.5; function ir(l, t = 5, i = 30) { var r; const { start: a, end: h } = Gt(l), c = xt(h, a), d = l.properties.style && l.properties.style.strokeWidth ? (r = l.properties.style) == null ? void 0 : r.strokeWidth : 0; return Math.min(i, Math.max(3 * d, _t(c) * 0.01, t)); } function Me(l, t, i, r) { const a = nr(er(rr(t)), r); if (!i || i !== "arrow" && i !== "arrow-plain") return ""; const h = Ct(l, nt(a, Math.PI / 10)), c = Ct(l, nt(a, -Math.PI / 10)), d = `${l.x} ${l.y}`; return `M ${h.x} ${h.y} L ${d} ${c.x} ${c.y} ${i === "arrow" ? "" : `${h.x} ${h.y}`}`; } function sn(l, t, i, r, a) { const { start: h, end: c } = Gt(l), { tail: d, head: f, strokeColor: g, strokeWidth: p = 0 } = l.properties.style || i, w = xt(c, h), b = ir(l, r, a), A = wt("g"), E = wt("path"); A.setAttribute("data-annotation", `${l.id}`), A.setAttribute("data-annotation-type", "arrow"); const k = f === "arrow-plain" || d === "arrow", L = g || "none"; E.setAttribute("stroke", L), E.setAttribute("stroke-width", `${p}`), E.setAttribute("fill", k ? g || "" : "none"), E.setAttribute("stroke-linecap", "round"), E.setAttribute("stroke-linejoin", "round"); const M = Me(h, er(w), d, b), C = Me(c, w, f, b), N = M + `M ${h.x} ${h.y} ${c.x} ${c.y}` + C; E.setAttribute("d", N), A.appendChild(E), Oe(A, h, L, d, p), Oe(A, c, L, f, p), t.appendChild(A); } function Oe(l, t, i, r, a) { r === "halo-dot" && ze( l, t, on(i), nn, a * 4 ), (r === "dot" || r === "halo-dot") && ze(l, t, i, 1, a * 2); } function on(l) { return l === "none" ? "none" : l; } function ze(l, t, i, r, a) { const h = wt("circle"); h.setAttribute("cx", `${t.x}`), h.setAttribute("cy", `${t.y}`), h.setAttribute("r", `${a}`), h.setAttribute("fill-opacity", `${r}`), h.setAttribute("fill", i), l.appendChild(h); } const U = -1, Zt = "dragging", Yt = "dragstart", Lt = "dragend", fe = "select", ge = "unselect", an = "hover", ln = "unhover", pe = "remove", ye = "add", hn = "cancelDrawing", me = "update", un = "link"; function sr(l) { return l && l.__esModule && Object.prototype.hasOwnProperty.call(l, "default") ? l.default : l; } var Pe = { exports: {} }, Fe; function cn() { return Fe || (Fe = 1, function(l) { var t = Object.prototype.hasOwnProperty, i = "~"; function r() { } Object.create && (r.prototype = /* @__PURE__ */ Object.create(null), new r().__proto__ || (i = !1)); function a(f, g, p) { this.fn = f, this.context = g, this.once = p || !1; } function h(f, g, p, w, b) { if (typeof p != "function") throw new TypeError("The listener must be a function"); var A = new a(p, w || f, b), E = i ? i + g : g; return f._events[E] ? f._events[E].fn ? f._events[E] = [f._events[E], A] : f._events[E].push(A) : (f._events[E] = A, f._eventsCount++), f; } function c(f, g) { --f._eventsCount === 0 ? f._events = new r() : delete f._events[g]; } function d() { this._events = new r(), this._eventsCount = 0; } d.prototype.eventNames = function() { var f = [], g, p; if (this._eventsCount === 0) return f; for (p in g = this._events) t.call(g, p) && f.push(i ? p.slice(1) : p); return Object.getOwnPropertySymbols ? f.concat(Object.getOwnPropertySymbols(g)) : f; }, d.prototype.listeners = function(f) { var g = i ? i + f : f, p = this._events[g]; if (!p) return []; if (p.fn) return [p.fn]; for (var w = 0, b = p.length, A = new Array(b); w < b; w++) A[w] = p[w].fn; return A; }, d.prototype.listenerCount = function(f) { var g = i ? i + f : f, p = this._events[g]; return p ? p.fn ? 1 : p.length : 0; }, d.prototype.emit = function(f, g, p, w, b, A) { var E = i ? i + f : f; if (!this._events[E]) return !1; var k = this._events[E], L = arguments.length, M, C; if (k.fn) { switch (k.once && this.removeListener(f, k.fn, void 0, !0), L) { case 1: return k.fn.call(k.context), !0; case 2: return k.fn.call(k.context, g), !0; case 3: return k.fn.call(k.context, g, p), !0; case 4: return k.fn.call(k.context, g, p, w), !0; case 5: return k.fn.call(k.context, g, p, w, b), !0; case 6: return k.fn.call(k.context, g, p, w, b, A), !0; } for (C = 1, M = new Array(L - 1); C < L; C++) M[C - 1] = arguments[C]; k.fn.apply(k.context, M); } else { var N = k.length, P; for (C = 0; C < N; C++) switch (k[C].once && this.removeListener(f, k[C].fn, void 0, !0), L) { case 1: k[C].fn.call(k[C].context); break; case 2: k[C].fn.call(k[C].context, g); break; case 3: k[C].fn.call(k[C].context, g, p); break; case 4: k[C].fn.call(k[C].context, g, p, w); break; default: if (!M) for (P = 1, M = new Array(L - 1); P < L; P++) M[P - 1] = arguments[P]; k[C].fn.apply(k[C].context, M); } } return !0; }, d.prototype.on = function(f, g, p) { return h(this, f, g, p, !1); }, d.prototype.once = function(f, g, p) { return h(this, f, g, p, !0); }, d.prototype.removeListener = function(f, g, p, w) { var b = i ? i + f : f; if (!this._events[b]) return this; if (!g) return c(this, b), this; var A = this._events[b]; if (A.fn) A.fn === g && (!w || A.once) && (!p || A.context === p) && c(this, b); else { for (var E = 0, k = [], L = A.length; E < L; E++) (A[E].fn !== g || w && !A[E].once || p && A[E].context !== p) && k.push(A[E]); k.length ? this._events[b] = k.length === 1 ? k[0] : k : c(this, b); } return this; }, d.prototype.removeAllListeners = function(f) { var g; return f ? (g = i ? i + f : f, this._events[g] && c(this, g)) : (this._events = new r(), this._eventsCount = 0), this; }, d.prototype.off = d.prototype.removeListener, d.prototype.addListener = d.prototype.on, d.prefixed = i, d.EventEmitter = d, l.exports = d; }(Pe)), Pe.exports; } var dn = cn(); const or = /* @__PURE__ */ sr(dn); class ar extends or { constructor(t, i) { super(), m(this, "ogma"), m(this, "elements"), m(this, "layer"), m(this, "editor"), m(this, "selectedId", U), m(this, "hoveredId", U), m(this, "ogmaOptions"), m(this, "shouldDetect"), m(this, "isDragging"), m(this, "showeditorOnHover"), m(this, "_onKeyUp", (r) => { r.code === 27 && this.selectedId !== U ? this.unselect() : (r.code === 46 || r.code === 8) && this.selectedId !== U && this._canRemove() && this.remove(this.selectedId); }), m(this, "_onClickMouseMove", (r) => { if (!r.domEvent || this.isDragging || !this.shouldDetect || r.domEvent.type !== "mousemove" && r.domEvent.target && r.domEvent.target.tagName === "a") return; const a = this.ogma.view.screenToGraphCoordinates(r), h = this.shouldDetect || !this.shouldDetect && +this.selectedId > -1 ? this.detect(a, 0) : void 0; r.domEvent.type === "mousemove" ? h ? this.hover(h.id) : this.hoveredId !== U && this.unhover() : h ? this.select(h.id) : this.selectedId !== U && this.unselect(); }), this.ogma = t, this.elements = [], this.shouldDetect = !0, this.isDragging = !1, this.showeditorOnHover = !0, this.ogmaOptions = t.getOptions(), t.events.on(["click", "mousemove"], this._onClickMouseMove).on("keyup", this._onKeyUp).on("frame", () => { this.refreshEditor(), this.refreshDrawing(); }), this.layer = t.layers.addSVGLayer({ draw: (r) => this.draw(r) }), this.layer.moveToTop(), this.editor = t.layers.addLayer(i), this.editor.hide(); } _canRemove() { return !0; } /** * @method add * @param options Params for the annotation (merged with default) * @returns the added annotation */ add(t) { const i = this.getDefaultOptions(), r = Object.assign(t, { id: t.id === void 0 ? Jt() : t.id, type: t.type, properties: { ...i.properties, ...t.properties || {}, // styles need to be merged style: { ...i.properties.style, ...t.properties.style || {} } }, geometry: { ...i.geometry, ...t.geometry } }); return this.elements.push(r), this.layer.refresh(), this.emit(ye, r), r; } updateStyle(t, i) { this.updateAnnotation(t, { properties: { style: i } }); } updateGeometry(t, i) { this.updateAnnotation(t, { geometry: i }); } scale(t, i, r, a) { this.updateGeometry( t, en(t.geometry, i, r, a) ); } /** * @method update * Updates an annotation (position, color etc) * @param id Id of the annotation to update * @param element params of the annotation */ update(t, i) { const r = this.getById(t); this.updateAnnotation(r, i); } updateAnnotation(t, i) { if (!t) return; const r = t.id; Object.keys(i).forEach((a) => { if (a !== "id") if (a === "properties") { const h = i.properties || { style: {} }; t.properties = { ...t.properties || {}, ...h || {}, style: { ...t.properties.style || {}, ...h.style || {} } }; } else a === "geometry" ? t.geometry = { ...t.geometry, ...i.geometry } : t[a] = i[a]; }), r === this.selectedId && this.refreshEditor(), this.layer.refresh(); } getById(t) { const i = Number(t); for (let r = 0; r < this.elements.length; r++) { const a = this.elements[r]; if (!(a.id !== t && a.id !== i)) return a; } } /** * @method select * @param id id of the element to select * Select element, show editor, disable Ogma dragging and fire event */ select(t) { const i = this.getById(t); i && (this.editor.show(), this.selectedId = t, this.refreshEditor(), this.layer.refresh(), this.emit(fe, i)); } hover(t) { const i = this.getById(t); i && (this.showeditorOnHover && this.editor.show(), this.hoveredId = t, this.refreshEditor(), this.layer.refresh(), this.emit(an, i)); } getSelectedFeature() { return this.selectedId === U ? null : this.getById(this.selectedId); } unselect() { const t = this.getById(this.selectedId); return t && this.emit(ge, t), this.selectedId = U, this.hoveredId === U && this.editor.hide(), this.layer.refresh(), this; } unhover() { const t = this.getById(this.hoveredId); return this.emit(ln, t), this.hoveredId = U, this.selectedId === U && this.editor.hide(), this.layer.refresh(), this; } /** * @method remove * @param id Id of the annotation to remove * Removes annotation with the given id */ remove(t) { const i = this.getById(t); t === this.hoveredId && this.unhover(), t === this.selectedId && this.unselect(), this.elements = this.elements.filter((r) => r.id !== t), i && this.emit(pe, i), this.layer.refresh(); } /** * @method disableDragging * Prevents Ogma from dragging elements or moving the view while dragging an annotation */ disableDragging() { this.ogma.setOptions({ interactions: { drag: { enabled: !1 }, pan: { enabled: !1 } }, detect: { nodes: !1, edges: !1, nodeTexts: !1, edgeTexts: !1 } }); } /** * @method restoreDragging * restore ogma options as they were before we start dragging an annotation */ restoreDragging() { this.ogma.setOptions(this.ogmaOptions); } enableDetection() { this.shouldDetect = !0; } /** * @method disableDetection * Disables the hover behaviour, used by controller to avoid hovering * arrows while dragging texts and vice versa */ disableDetection() { this.shouldDetect = !1; } refreshLayer() { this.layer.refresh(); } refreshDrawing() { } getElements() { return [...this.elements]; } destroy() { this.ogma.events.off(this._onClickMouseMove).off(this._onKeyUp), this.layer.destroy(); } } const He = "handle-line", Ne = "handle-start", je = "handle-end"; class fn extends ar { constructor(t, i = {}) { super( t, ` <div class="arrow-handle"> <div id="${He}" data-handle-id="0" class="handle line"></div> <div id="${Ne}" data-handle-id="1" class="handle point"></div> <div id="${je}" data-handle-id="2" class="handle point"></div> </div> ` ), m(this, "draggedHandle", U), m(this, "start", { x: 0, y: 0 }), m(this, "end", { x: 0, y: 0 }), m(this, "arrow", { ...$e }), m(this, "startX", 0), m(this, "startY", 0), m(this, "minArrowHeight", 0), m(this, "maxArrowHeight", 0), m(this, "handles", []), m(this, "onHandleMouseDown", (r) => { const a = this.getById(this.selectedId) || this.getById(this.hoveredId); if (!a) return; const { x: h, y: c } = Vt(r, this.ogma.getContainer()); this.startDragging(a, h, c), this.draggedHandle = tr(r.target); }), m(this, "onMouseUp", () => { this.draggedHandle !== -1 && (this.restoreDragging(), this.isDragging = !1, this.draggedHandle = U, this.emit(Lt, this.arrow)); }), m(this, "onMouseMove", (r) => { if (!this.isDragging || this.draggedHandle === U) return; const { x: a, y: h } = Vt(r, this.ogma.getContainer()), c = this.handles[this.draggedHandle], d = this.ogma.view.getAngle(), { x: f, y: g } = nt( rn( { x: a - this.startX, y: h - this.startY }, this.ogma.view.getZoom() ), d ), p = c.id === He, w = c.id === Ne, b = c.id === je; (p || w) && Ke(this.arrow, this.start.x + f, this.start.y + g), (p || b) && Qe(this.arrow, this.end.x + f, this.end.y + g), this.emit( Zt, this.arrow, p ? "line" : w ? "start" : "end" ), this.refreshEditor(), this.layer.refresh(); }), this.minArrowHeight = i.minArrowHeight || 0, this.maxArrowHeight = i.maxArrowHeight || 1e6, this.handles = Array.prototype.slice.call( this.editor.element.querySelectorAll(".arrow-handle>.handle") ), this.handles.forEach( (r) => r.addEventListener("mousedown", this.onHandleMouseDown) ), document.addEventListener("mousemove", this.onMouseMove, !0), document.addEventListener("mouseup", this.onMouseUp); } /** * Start drawing a new arrow, it will also be added as a new annotation * @param x * @param y * @param arrow */ startDrawing(t, i, r = Yr(t, i, t, i, Pt)) { var a; this.disableDragging(), this.add(r), this.hoveredId = r.id; const h = this.ogma.view.graphToScreenCoordinates({ x: t, y: i }), c = ((a = this.ogma.getContainer()) == null ? void 0 : a.getBoundingClientRect()) || { left: 0, top: 0 }; this.startDragging( this.getById(r.id), h.x + (c == null ? void 0 : c.left), h.y + c.top ), this.draggedHandle = 2; } cancelDrawing() { this.isDragging && (this.remove(this.arrow.id), this.emit(Lt, this.arrow), this.restoreDragging(), this.isDragging = !1, this.draggedHandle = U); } startDragging(t, i, r) { this.selectedId !== t.id && this.select(this.hoveredId), this.arrow = t, this.startX = i, this.startY = r, this.start = zt(this.arrow), this.end = Xt(this.arrow), this.disableDragging(), this.emit(Yt, this.arrow), this.isDragging = !0; } detect(t, i = 0) { return this.elements.find((r) => { const { start: a, end: h } = Gt(r), c = xt(t, { x: (a.x + h.x) / 2, y: (a.y + h.y) / 2 }), d = xt(h, a), f = _t(d), g = rr(d), p = ir(r); return Math.abs(Ie(g, c)) < f / 2 + i && Math.abs(Ie(nt(g, Math.PI / 2), c)) < p / 2 + i; }); } refreshEditor() { if (+this.selectedId < 0 && +this.hoveredId < 0) return; const t = this.selectedId !== U ? this.getById(this.selectedId) : this.getById(this.hoveredId), i = Gt(t), r = this.ogma.view.graphToScreenCoordinates(i.start), a = this.ogma.view.graphToScreenCoordinates(i.end), [h, c, d] = Array.prototype.slice.call( this.editor.element.querySelectorAll(".handle") ); c.style.transform = `translate(${r.x}px, ${r.y}px) translate(-50%, -50%)`, d.style.transform = `translate(${a.x}px, ${a.y}px) translate(-50%, -50%)`; const f = { x: (a.x + r.x) / 2, y: (a.y + r.y) / 2 }, g = xt(a, r), p = nr(g, 1 / _t(g)), w = Math.atan2(p.y, p.x); h.style.width = `${_t(g)}px`, h.style.left = `${f.x}px`, h.style.top = `${f.y}px`, h.style.transform = `translate(-50%, -50%) rotate(${w}rad)`; } getDefaultOptions() { return $e; } draw(t) { t.innerHTML = ""; const i = wt("g"), r = this.ogma.view.getAngle(); r !== 0 && i.setAttribute("transform", `rotate(${-r * (180 / Math.PI)})`), this.elements.forEach( (a) => sn(a, i, Pt, this.minArrowHeight, this.maxArrowHeight) ), t.appendChild(i); } refreshDrawing() { const t = this.ogma.view.getAngle(); this.layer.element !== null && t !== 0 && this.layer.element.children[0].setAttribute( "transform", `rotate(${-t * (180 / Math.PI)})` ); } destroy() { super.destroy(), document.removeEventListener("mousemove", this.onMouseMove, !0), document.removeEventListener("mouseup", this.onMouseUp); } } const Dt = { font: "sans-serif", fontSize: 18, color: "#505050", background: "#f5f5f5", strokeWidth: 0, borderRadius: 8, padding: 16, strokeType: "plain" }, ue = { id: 0, type: "Feature", properties: { type: "text", content: "", style: { ...Dt } }, geometry: { type: "Polygon", coordinates: [ [ [0, 0], [100, 0], [100, 50], [0, 50], [0, 0] ] ] } // position: { x: 0, y: 0 }, // size: { width: 100, height: 50 } }, Be = { handleSize: 3.5, placeholder: "Your text..." }, gn = (l = 0, t = 0, i = 100, r = 50, a = "", h = { ...Dt }) => ({ id: Jt(), type: "Feature", properties: { type: "text", content: a, style: { ...Dt, ...h } }, geometry: { type: "Polygon", coordinates: [ [ [l, t], [l + i, t], [l + i, t + r], [l, t + r], [l, t] ] ] } }); var ve = { exports: {} }, pn = ve.exports, qe; function yn() { return qe || (qe = 1, function(l, t) { (function(i, r) { l.exports = r(); })(pn, () => (() => { var i = { d: (e, n) => { for (var o in n) i.o(n, o) && !i.o(e, o) && Object.defineProperty(e, o, { enumerable: !0, get: n[o] }); }, o: (e, n) => Object.prototype.hasOwnProperty.call(e, n) }, r = {}; function a(e) { return a = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) { return typeof n; } : function(n) { return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n; }, a(e); } i.d(r, { default: () => qr }); var h = /^((?:[a-z\d-]+\s+)*)([\d.]+(%|em|px)|(?:x+-)?large|(?:x+-)?small|medium)(?:\s*\/\s*(normal|[\d.]+(%|px|em)?))?(\s.+)?$/, c = /\bsmall-caps\b/, d = /\b(?:italic|oblique)\b/, f = /\bbold(?:er)?\b/, g = 13.3333333, p = { "xx-small": 9, "x-small": 10, smaller: 13.3333, small: 13, medium: 16, large: 18, larger: 19.2, "x-large": 24, "xx-large": 32 }; function w(e) { var n = "", o = this; return o.style && o.style !== "normal" && (n += o.style), o.variant && o.variant !== "normal" && (n += (n ? " " : "") + o.variant), o.weight && o.weight !== "normal" && (n += (n ? " " : "") + o.weight), o.size && (n += (n ? " " : "") + o.size + "px", o.height !== o.size && (n += "/" + o.height + "px")), o.family && (n += (n ? " " : "") + o.family), e && (n += "::" + o.baseline), e && (n += "::" + o.color), n; } var b = { id: "", family: "sans-serif", height: 14, size: 12, variant: "", style: "", weight: "", baseline: "", color: null, toString: w, valueOf: w }; function A(e) { var n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, o = h.exec(e); n.family = (o[6] || "").trim(); var s = p[o[2]] || parseFloat(o[2]); o[3] === "%" ? s *= 0.16 : o[3] === "em" ? s *= 16 : o[3] === "pt" && (s *= g), n.size = s; var u = parseFloat(o[4]); if (u !== "normal" && u !== "inherit" && u ? o[5] && o[5] !== "em" ? o[5] === "pt" ? n.height = u * g : o[5] === "%" ? n.height = 0.01 * s : n.height = u : n.height = u * s : n.height = Math.round(s * (7 / 6)), c.test(o[1]) && (n.variant = "small-caps"), d.test(o[1]) && (n.style = "italic"), f.test(o[1])) n.weight = "bold"; else { var y = parseInt(/\b(\d+)\b/.exec(o[1]), 10); y >= 100 && y !== 400 && (n.weight = y); } return n; } function E() { var e, n, o, s = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "12px/14px sans-serif", u = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, y = 14, x = 12, v = null, S = null, _ = ""; if (s && s.nodeType) { var $ = s && (s.ownerDocument && s.ownerDocument.defaultView || s.document && s || s.defaultView), I = $.getComputedStyle(s, null); e = I.getPropertyValue("font-family") || "", x = parseFloat(I.getPropertyValue("font-size")), y = I.getPropertyValue("line-height"), v = I.getPropertyValue("font-weight"), S = I.getPropertyValue("font-style"), _ = I.getPropertyValue("font-variant") || ""; } else if (typeof s == "string") { var D = A(s); e = D.family, x = D.size, y = D.height, _ = D.variant, S = D.style, v = D.weight; } else a(s) === "object" && (e = s.family, x = s.size, y = s.height, _ = s.variant, v = s.weight, S = s.style, n = s.baseline, o = s.color); u.size && u.size < 3 && (x *= u.size), y = y !== "normal" && y ? parseFloat(y) : x * (7 / 6), u.height && u.height < 3 && (y *= u.height); var O = Object.create(b); return O.family = u.family || e || "sans-serif", O.height = y ?? 14, O.size = x ?? 12, O.variant = u.variant || _ || "", O.style = u.style || S || "", O.weight = u.weight || v || "", O.baseline = n || 0, u.baseline != null && (O.baseline = u.baseline), O.color = u.color || o || "", O.id = w.call(O, !0), O; } const k = { "\n": 0.28, "\r": 0.28, " ": 0.28, " ": 0.28, " ": 0.28, "᠎": 0, " ": 0.5, " ": 1, " ": 0.5, " ": 1, " ": 0.33, " ": 0.25, " ": 0.16, " ": 0.56, " ": 0.28, " ": 0.2, " ": 0.15, "​": 0, " ": 0.16, " ": 0.22, " ": 1, "\uFEFF": 0 }; var L, M = function(e) { var n = typeof OffscreenCanvas < "u" && new OffscreenCanvas(100, 100) || e && e.createElement("canvas"); if (n && n.getContext) { var o = n.getContext("2d"); if (o && typeof o.measureText == "function") return function(s, u) { return o.font = String(u), o.measureText(s).width; }; } }(typeof document < "u" ? document : null) || (L = {}, function(e, n) { if (!L[n]) { var o = E(n); L[n] = o, /\bmonospace\b/.test(o.family) ? o.size *= 0.6 : (o.size *= 0.45, o.weight && (o.size *= 1.18)); } return e.length * L[n].size; }), C = {}, N = { trim: !0, collapse: !0 }; function P(e, n, o) { var s = Object.assign({}, N, o), u = String(e); if (!u) return 0; if (u in k) { var y = n.id + "/" + u; return y in C || (C[y] = M("_".concat(u, "_"), n) - M("__", n)), C[y]; } return s.trim && s.collapse ? s.trim ? u = u.trim() : s.collapse && (u = u.replace(/\s+/g, " ")) : u = u.replace(/\n/g, " "), M(u, n) + n.size * (e.tracking || 0); } function tt(e) { return tt = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) { return typeof n; } : function(n) { return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n; }, tt(e); } function it(e, n) { if (typeof n != "function" && n !== null) throw new TypeError("Super expression must either be null or a function"); e.prototype = Object.create(n && n.prototype, { constructor: { value: e, writable: !0, configurable: !0 } }), Object.defineProperty(e, "prototype", { writable: !1 }), n && Kt(e, n); } function Kt(e, n) { return Kt = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(o, s) { return o.__proto__ = s, o; }, Kt(e, n); } function Qt(e) { var n = function() { if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1; if (typeof Proxy == "function") return !0; try { return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() { })), !0; } catch { return !1; } }(); return function() { var o, s = Ft(e); if (n) { var u = Ft(this).constructor; o = Reflect.construct(s, arguments, u); } else o = s.apply(this, arguments); return ur(this, o); }; } function ur(e, n) { if (n && (tt(n) === "object" || typeof n == "function")) return n; if (n !== void 0) throw new TypeError("Derived constructors may only return object or undefined"); return function(o) { if (o === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return o; }(e); } function Ft(e) { return Ft = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(n) { return n.__proto__ || Object.getPrototypeOf(n); }, Ft(e); } function Ht(e, n) { if (!(e instanceof n)) throw new TypeError("Cannot call a class as a function"); } function cr(e, n) { for (var o = 0; o < n.length; o++) { var s = n[o]; s.enumerable = s.enumerable || !1, s.configurable = !0, "value" in s && (s.writable = !0), Object.defineProperty(e, (u = function(y, x) { if (tt(y) !== "object" || y === null) return y; var v = y[Symbol.toPrimitive]; if (v !== void 0) { var S = v.call(y, x); if (tt(S) !== "object") return S; throw new TypeError("@@toPrimitive must return a primitive value."); } return String(y); }(s.key, "string"), tt(u) === "symbol" ? u : String(u)), s); } var u; } function Nt(e, n, o) { return n && cr(e.prototype, n), Object.defineProperty(e, "prototype", { writable: !1 }), e; } var j = function() { function e() { var n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : ""; Ht(this, e), this.value = n, this.weight = null, this.style = null, this.font = null, this.href = null, this.sub = !1, this.sup = !1; } return Nt(e, [{ key: "clone", value: function() { var n = new e(this.value); return n.value = this.value, n.weight = this.weight, n.style = this.style, n.font = this.font, n.href = this.href, n.sub = this.sub, n.sup = this.sup, n; } }, { key: "valueOf", value: function() { return this.value; } }, { key: "toString", value: function() { return this.value; } }]), e; }(), Tt = function(e) { it(o, e); var n = Qt(o); function o() { return Ht(this, o), n.apply(this, arguments); } return Nt(o); }(j), et = function(e) { it(o, e); var n = Qt(o); function o() { return Ht(this, o), n.apply(this, arguments); } return Nt(o); }(j), yt = function(e) { it(o, e); var n = Qt(o); function o() { return Ht(this, o), n.apply(this, arguments); } return Nt(o); }(j), te = /^[\n\r\t\x20\xA0\u2000-\u200B\u205F\u3000]/, dr = /^[^\n\r\t\u0020\u2000-\u200B\u205F\u3000]{2,}/, we = /^[\xA0\u2011\u202F\u2060\uFEFF]/, fr = /^(?:[;\xAD%?…]|,(?!\d))/, gr = /^[´±°¢£¤$¥\u2212]/; function jt(e, n) { n !== !1 && (e = e.trim()); for (var o, s, u = [], y = e.charAt(0), x = 0, v = 1, S = e.length; v < S; v++) { o = e.charAt(v), s = e.charAt(v + 1); var _ = te.test(y), $ = te.test(o), I = $ || _, D = void 0; if ((gr.test(o) && !we.test(y) || fr.test(y + s) && !we.test(o)) && (I = !0), y !== "-" && y !== "‐" && y !== "–" && y !== "—" || ((D = te.test(e.charAt(v - 2))) && !$ && (I = !1), !D && dr.test(o + s) && (I = !0)), I) { var O = e.slice(x, v); /\u00AD$/.test(O) ? (u.push(new j(O.slice(0, -1))), u.push(new yt())) : (u.push(new j(O)), u.push(new Tt())), x = v; } y = o; } return u.push(new j(e.slice(x))), u; } const xe = { nbsp: " ", iexcl: "¡", cent: "¢", pound: "£", curren: "¤", yen: "¥", brvbar: "¦", sect: "§", uml: "¨", copy: "©", ordf: "ª", laquo: "«", not: "¬", shy: "­", reg: "®", macr: "¯", deg: "°", plusmn: "±", sup2: "²", sup3: "³", acute: "´", micro: "µ", para: "¶", middot: "·", cedil: "¸", sup1: "¹", ordm: "º", raquo: "»", frac14: "¼", frac12: "½", frac34: "¾", iquest: "¿", Agrave: "À", Aacute: "Á", Acirc: "Â", Atilde: "Ã", Auml: "Ä", Aring: "Å", AElig: "Æ", Ccedil: "Ç", Egrave: "È", Eacute: "É", Ecirc: "Ê", Euml: "Ë", Igrave: "Ì", Iacute: "Í", Icirc: "Î", Iuml: "Ï", ETH: "Ð", Ntilde: "Ñ", Ograve: "Ò", Oacute: "Ó", Ocirc: "Ô", Otilde: "Õ", Ouml: "Ö", times: "×", Oslash: "Ø", Ugrave: "Ù", Uacute: "Ú", Ucirc: "Û", Uuml: "Ü", Yacute: "Ý", THORN: "Þ", szlig: "ß", agrave: "à", aacute: "á", acirc: "â", atilde: "ã", auml: "ä", aring: "å", aelig: "æ", ccedil: "ç", egrave: "è", eacute: "é", ecirc: "ê", euml: "ë", igrave: "ì", iacute: "í", icirc: "î", iuml: "ï", eth: "ð", ntilde: "ñ", ograve: "ò", oacute: "ó", ocirc: "ô", otilde: "õ", ouml: "ö", divide: "÷", oslash: "ø", ugrave: "ù", uacute: "ú", ucirc: "û", uuml: "ü", yacute: "ý", thorn: "þ", yuml: "ÿ", fnof: "ƒ", Alpha: "Α", Beta: "Β", Gamma: "Γ", Delta: "Δ", Epsilon: "Ε", Zeta: "Ζ", Eta: "Η", Theta: "Θ", Iota: "Ι", Kappa: "Κ", Lambda: "Λ", Mu: "Μ", Nu: "Ν", Xi: "Ξ", Omicron: "Ο", Pi: "Π", Rho: "Ρ", Sigma: "Σ", Tau: "Τ", Upsilon: "Υ", Phi: "Φ", Chi: "Χ", Psi: "Ψ", Omega: "Ω", alpha: "α", beta: "β", gamma: "γ", delta: "δ", epsilon: "ε", zeta: "ζ", eta: "η", theta: "θ", iota: "ι", kappa: "κ", lambda: "λ", mu: "μ", nu: "ν", xi: "ξ", omicron: "ο", pi: "π", rho: "ρ", sigmaf: "ς", sigma: "σ", tau: "τ", upsilon: "υ", phi: "φ", chi: "χ", psi: "ψ", omega: "ω", thetasym: "ϑ", upsih: "ϒ", piv: "ϖ", bull: "•", hellip: "…", prime: "′", Prime: "″", oline: "‾", frasl: "⁄", weierp: "℘", image: "ℑ", real: "ℜ", trade: "™", alefsym: "ℵ", larr: "←", uarr: "↑", rarr: "→", darr: "↓", harr: "↔", crarr: "↵", lArr: "⇐", uArr: "⇑", rArr: "⇒", dArr: "⇓", hArr: "⇔", forall: "∀", part: "∂", exist: "∃", empty: "∅", nabla: "∇", isin: "∈", notin: "∉", ni: "∋", prod: "∏", sum: "∑", minus: "−", lowast: "∗", radic: "√", prop: "∝", infin: "∞", ang: "∠", and: "⊥", or: "⊦", cap: "∩", cup: "∪", int: "∫", there4: "∴", sim: "∼", cong: "≅", asymp: "≈", ne: "≠", equiv: "≡", le: "≤", ge: "≥", sub: "⊂", sup: "⊃", nsub: "⊄", sube: "⊆", supe: "⊇", oplus: "⊕", otimes: "⊗", perp: "⊥", sdot: "⋅", lceil: "⌈", rceil: "⌉", lfloor: "⌊", rfloor: "⌋", lang: "〈", rang: "〉", loz: "◊", spades: "♠", clubs: "♣", hearts: "♥", diams: "♦", quot: '"', amp: "&", lt: "<", gt: ">", OElig: "Œ", oelig: "œ", Scaron: "Š", scaron: "š", Yuml: "Ÿ", circ: "ˆ", tilde: "˜", ensp: " ", emsp: " ", thinsp: " ", zwnj: "‌", zwj: "‍", lrm: "‎", rlm: "‏", ndash: "–", mdash: "—", lsquo: "‘", rsquo: "’", sbquo: "‚", ldquo: "“", rdquo: "”", bdquo: "„", dagger: "†", Dagger: "‡", permil: "‰", lsaquo: "‹", rsaquo: "›" }; var pr = /^[\n\r\x20\u2000-\u200B\u205F\u3000]/, yr = /^<\/([a-zA-Z0-9]+)([^>]*)>/, mr = /^<([a-zA-Z0-9]+)((?:\s[^=\s/]+(?:\s*=\s*(?:"[^"]+"|'[^']+'|[^>\\s]+))?)+)?\s*(\/?)>(\n*)/, vr = /^<!--(.+?)-->/, wr = /&(?:#(\d\d{2,})|#x([\da-fA-F]{2,})|([a-zA-Z][a-zA-Z1-4]{1,8}));/g, be = { b: function(e) { e.weight = "bold"; }, strong: function(e) { e.weight = "bold"; }, i: function(e) { e.style = "italic"; }, em: function(e) { e.style = "italic"; }, dfn: function(e) { e.style = "italic"; }, cite: function(e) { e.style = "italic"; }, code: function(e) { e.family = "monospace"; }, kbd: function(e) { e.family = "monospace"; }, samp: function(e) { e.family = "monospace"; }, var: function(e) { e.family = "monospace"; }, tt: function(e) { e.family = "monospace"; }, sub: function(e) { e.sub = !0; }, sup: function(e) { e.sup = !0; } }, xr = { div: 1, li: 1, blockquote: 2, h1: 2, h2: 2, h3: 2, h4: 2, h5: 2, h6: 2, ul: 2, ol: 2, hr: 2, p: 2 }; function Ae(e) { return e.replace(wr, function(n, o, s, u) { if (o || s) { var y = o ? 10 : 16; return String.fromCharCode(parseInt(o || s, y)); } return u in xe ? xe[u] : n; }); } function br(e) { return e && e.length > 1 && (e[0] === '"' && e[e.length - 1] === '"' || e[0] === "'" && e[e.length - 1] === "'") ? e.slice(1, -1) : e; } var Ar = /^\s*([^=\s&]+)(?:\s*=\s*("[^"]+"|'[^']+'|[^>\s]+))?/; function kr(e) { var n, o = {}; if (e) { do if (n = Ar.exec(e)) { var s = Ae(br(n[2] || "")).replace(/[ \r\n\t]+/g, " ").trim(); if (o[n[1]] = s, (e = e.slice(n[0].length)).length && /^\S/.test(e[0])) throw new Error("Attribute error"); } while (n && e.length); if (/\S/.test(e)) throw new Error("Attribute error"); } return o; } const ke = { copyright: "©", textcopyright: "©", dag: "†", textdagger: "†", ddag: "‡", textdaggerdbl: "‡", guillemotleft: "«", guillemotright: "»", guilsinglleft: "‹", guilsinglright: "›", ldots: "…", dots: "…", textellipsis: "…", lq: "‘", P: "¶", textparagraph: "¶", pounds: "£", textsterling: "£", quotedblbase: "„", quotesinglbase: "‚", rq: "’", S: "§", sim: "~", textasciicircum: "^", textasciitilde: "˜", texttildelow: "~", textasteriskcentered: "*", textbackslash: "'", textbar: "|", textbardbl: "╎", textbigcircle: "◯", textbraceleft: "{", textbraceright: "}", textbullet: "•", textdollar: "$", textemdash: "—", textendash: "—", texteuro: "€", eurosym: "€", euro: "€", textexclamdown: "¡", textgreater: ">", textless: "<", textordfeminine: "ª", textordmasculine: "º", textperiodcentered: "·", cdot: "·", textquestiondown: "¿", textquotedblleft: "“", textquotedblright: "”", textquoteleft: "‘", textquoteright: "’", textquotestraightbase: "‚", textquotestraightdblbase: "„", textregistered: "®", textthreequartersemdash: "-", texttrademark: "™", texttwelveudash: "-", textunderscore: "_", textvisiblespace: "␣", gets: "←", textleftarrow: "←", to: "→", textrightarrow: "→", textdegree: "°", infty: "∞", triangle: "△", triangledown: "▽", blacktriangle: "▲", blacktriangledown: "▼", angle: "∠", sphericalangle: "∢", aleph: "ℵ", hbar: "ħ", imath: "𝚤", jmath: "𝚥", ell: "ℓ", wp: "℘", Re: "ℜ", Im: "ℑ", mho: "℧", prime: "′", emptyset: "∅", nabla: "∇", surd: "√", partial: "∂", top: "⟙", bot: "⟂", vdash: "⟝", dashv: "⟞", forall: "∀", exists: "∃", nexists: "∄", neg: "¬", lnot: "¬", flat: "♭", natural: "♮", sharp: "♯", backslash: "\\", Box: "□", Diamond: "♢", clubsuit: "♣", diamondsuit: "♦", heartsuit: "♥", spadesuit: "♠", Join: "⨝", blacksquare: "■", bigstar: "★", diagdown: "╲", diagup: "╱", blacklozenge: "⧫", rfloor: "⌋", lfloor: "⌊", rceil: "⌉", lceil: "⌈", rangle: "⟩", langle: "⟨", sum: "∑", int: "∫", oint: "∮", prod: "∏", coprod: "∏", bigcap: "∩", bigcup: "∪", bigsqcup: "⊔", bigvee: "∨", bigwedge: "∧", bigodot: "⊙", bigotimes: "⊗", bigoplus: "⊕", biguplus: "⊎", alpha: "α", beta: "β", chi: "χ", delta: "δ", epsilon: "ε", eta: "η", gamma: "γ", iota: "ι", kappa: "κ", lambda: "λ", mu: "μ", nu: "ν", omega: "ω", phi: "φ", pi: "π", psi: "ψ", rho: "ρ", sigma: "σ", tau: "τ", theta: "θ", upsilon: "υ", xi: "ξ", zeta: "ζ", Alpha: "Α", Beta: "Β", Chi: "Χ", Delta: "Δ", Epsilon: "Ε", Eta: "Η", Gamma: "Γ", Iota: "Ι", Kappa: "Κ", Lambda: "Λ", Mu: "Μ", Nu: "Ν", Omega: "Ω", Phi: "Φ", Pi: "Π", Psi: "Ψ", Rho: "Ρ", Sigma: "Σ", Tau: "Τ", Theta: "Θ", Upsilon: "Υ", Xi: "Ξ", Zeta: "Ζ", aa: "å", AA: "Å", ae: "æ", AE: "Æ", dh: "ð", DH: "Ð", dj: "đ", DJ: "Đ", ij: "ij", IJ: "IJ", l: "ł", L: "Ł", ng: "ŋ", NG: "Ŋ", o: "ø", O: "Ø", oe: "œ", OE: "Œ", ss: "ß", SS: "SS", th: "þ", TH: "Þ" }; var Er = /^(\^|_|\\[^#$%&~_^\\{}()\s]+)(\{)?/, Sr = /^%[^\n]+(?:\n|$)/, Cr = /^[^#$%&~_^\\{}]+/, _r = /^\\([&{}$%#_])/, Dr = /(?:\\[\\@,!:;-]|-{2,3}|[!?]`|``?|,,|''?|~|<<|>>)/g, Lr = { "---": "—", "--": "–", "!`": "¡", "?`": "¿", "``": "“", ",,": "„", "''": "”", "`": "‘", "'": "’", "<<": "«", ">>": "»", "~": " ", "\\-": "­", "\\,": " ", "\\;": " ", "\\:": " ", "\\!": " ", "\\@": "\uFEFF", "\\\\": "\\newline{}" }, X = { bf: function(e) { e.weight = "bold"; }, it: function(e) { e.style = "italic"; }, sl: function(e) { e.style = "italic"; }, color: function(e, n) { e.color = n; }, href: function(e, n) { e.href = n; }, "^": function(e) { e.sup = !0; }, _: function(e) { e.sub = !0; }, par: function(e) { this.tokens.push(new et(), new et()); }, newline: function(e) { this.tokens.push(new et()); }, url: function(e, n) { this.open_context().href = n, this.add_token(new j(n)), this.close_context(); } }; X.textsuperscript = X["^"], X.textsubscript = X._, X.textsl = X.sl, X.mathbf = X.bf, X.mathit = X.it, X.textbf = X.bf, X.textit = X.it, X.textcolor = X.color; var Tr = /[\r\n\xA0]+/g; function $r(e, n) { e.sup && (e.baseline = 0.45, e.size = 0.7), e.sub && (e.baseline = -0.3, e.size = 0.7); var o = n; return (e.style || e.weight || e.baseline || e.color || e.size || e.family) && (o = E(n, e)), o; } function Ee(e, n, o) { for (var s, u, y = e.width; y + o.width > n && e.length; ) u = (s = e[e.length - 1]).width, s.width > o.width ? (s.value = s.value.slice(0, -1), s.width = P(s, s.font), y += s.width) : e.pop(), y -= u; e[e.length - 1] instanceof yt && e.pop(), s = e[e.length - 1] || s || {}, o.font = E(o.font, s.bold, s.italic, ""), o.href = e.length ? s.href : null, o.rel = e.length ? s.rel : null, o.target = e.length ? s.target : null, e.push(o); } function bt(e) { return Math.round(1e6 * e) / 1e6; } function Se(e) { return function(n) { if (Array.isArray(n)) return ee(n); }(e) || function(n) { if (typeof Symbol < "u" && n[Symbol.iterator] != null || n["@@iterator"] != null) return Array.from(n); }(e) || function(n, o) { if (n) { if (typeof n == "string") return ee(n, o); var s = Object.prototype.toString.call(n).slice(8, -1); return s === "Object" && n.constructor && (s = n.constructor.name), s === "Map" || s === "Set" ? Array.from(n) : s === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s) ? ee(n, o) : void 0; } }(e) || function() { throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`); }(); } function ee(e, n) { (n == null || n > e.length) && (n = e.length); for (var o = 0, s = new Array(n); o < n; o++) s[o] = e[o]; return s; } var Ir = { center: "middle", right: "end" }, Mr = { middle: 0.5, center: 0.5, bottom: 1, end: 1 }, re = function(e, n) { return !e && !n || e === n; }; function Or(e, n) { var o = [], s = n.font(), u = s.size, y = s.family, x = n.align(), v = n.createElement(); if (e.length) { var S = s.height, _ = n.valign(), $ = n.height()(), I = n.width()(0), D = !isFinite(I) && e.length === 1, O = D ? null : n.x(), B = bt(S / u), J = D ? null : bt(S / (1.15 * u + (S - u) / 2)); if (Mr[_] && isFinite($)) { var F = _ === "bottom" ? 1 : 0.5; J += ($ * F - S * e.length * F) / u; } var z = x === "justify", q = 0; x === "right" ? q = I : x === "center" && (q = I / 2); for (var H = [], K = "tspan", G = null, R = "", T = function() { if (R) { var mt = v(K, G, R); H.push(mt); } K = "tspan", G = null, R = ""; }, rt = 0, Q = e.length; rt < Q; rt++) { var lt = "", gt = "", at = 0, ht = e[rt]; if (ht.length) { H = []; for (var At = 0, Mt = 0, ut = void 0, V = 0, Bt = ht.length; V < Bt; V++) { var W = ht[V], Z = W.font; W.whitespace && At++, Mt += W.width, V && !W.tracking && !at && re(Z.id, lt) && re(W.class, gt) && re(ut, W.href) ? R += W.value : (T(), R = W.value, G = { fontFamily: Z.family !== y ? Z.family : null, fontSize: Z.size !== u ? Z.size : null, fontWeight: Z.weight || null, fontStyle: Z.style || null, fontVariant: Z.variant !== "normal" && Z.variant || null, fill: Z.color || null, baselineShift: Z.baseline ? 100 * Z.baseline + "%" : null, className: W.class || null }, at && (G.dx = bt(at), at = 0), W.tracking && (at = Z.size * W.tracking), W.href && !ut ? (ut = W.href, K = "a", G.href = ut, G.rel = W.rel, G.target = W.target) : ut = null, lt = Z.id, gt = W.class); } if (T(), D) o.push.apply(o, Se(H)); else { var qt = null, Ot = rt === Q - 1 || ht[ht.length - 1] instanceof et; z && ht.length > 1 && !Ot && (qt = bt((I - Mt) / At)), o.push(v.apply(void 0, ["tspan", { wordSpacing: qt, x: O(rt) + q, dy: bt(rt ? B : J) + "em" }].concat(Se(H)))); } } else o.push(v("tspan", { x: O(rt), dy: bt(rt ? B : J) + "em" }, " ")); } } return v.apply(void 0, ["text", { fontFamily: y, fontSize: u, textAnchor: Ir[x] || "start" }].concat(o)); } var zr = { middle: 0.5, center: 0.5, bottom: 1, end: 1 }; function Pr(e, n, o) { if (e.length) { o.textBaseline = "middle"; var s = n.font(), u = s.height, y = s.size, x = n.valign(), v = n.height()(), S = n.width()(0), _ = n.align(), $ = _ === "justify", I = 0.5 * u, D = zr[x]; if (D && isFinite(v)) { var O = e.length * u; I += v * D - O * D; } e.forEach(function(B, J) { var F = n.x()(J), z = J * u + I, q = 0, H = 0; B.forEach(function(R) { R.whitespace && q++, H += R.width; }); var K = 0, G = J === e.length - 1 || B[B.length - 1] instanceof et; $ && B.length > 1 && !G && (K = (S - H) / q), B.forEach(function(R) { o.font = R.font; var T = R.font, rt = T.baseline ? y * -T.baseline + 0.15 * y : 0; o.fillStyle = function(gt, at) { return gt.color ? gt.color : at.href ? "#00C" : "#000"; }(T, R); var Q = 0; if (_ === "right" ? Q += S - H : _ === "center" ? Q += S / 2 - H / 2 : _ === "justify" && (R.whitespace || R instanceof et) && (F += K), o.fillText(R.value, F + Q, z + rt), R.href) { o.beginPath(), o.strokeStyle = o.fillStyle; var lt = Math.floor(z + 0.45 * y) + 0.5; o.moveTo(F + Q, lt), o.lineTo(F + Q + R.width, lt), o.stroke(); } F += R.width; }); }); } } function ne(e) { return ne = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) { return typeof n; } : function(n) { return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n; }, ne(e); } function Ce(e) { for (var n = {}, o = 0; o < e.length; o++) { var s = e[o]; typeof s != "number" && s != null && (typeof s == "string" ? n.text = s : typeof s == "function" ? n.fn = s : ne(s) === "object" && s._groups ? n.d3 = s : s && s.nodeType && s.getContext ? n.ctx = s.getContext("2d") : s && s.fillText && s.beginPath ? n.ctx = s : s && (n.text = s)); } return n; } function $t(e) { return $t = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) { return typeof n; } : function(n) { return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n; }, $t(e); } function Fr(e, n) { for (var o = 0; o < n.length; o++) { var s = n[o]; s.enumerable = s.enumerable || !1, s.configurable = !0, "value" in s && (s.writable = !0), Object.defineProperty(e, (u = function(y, x) { if ($t(y) !== "object" || y === null) return y; var v = y[Symbol.toPrimitive]; if (v !== void 0) { var S = v.call(y, x); if ($t(S) !== "object") return S; throw new TypeError(