UNPKG

@decidables/prospectable-elements

Version:

prospectable-elements: Web Components for visualizing Cumulative Prospect Theory

1,435 lines (1,382 loc) 4.81 MB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.prospectableElements = {})); })(this, (function (exports) { 'use strict'; function _mergeNamespaces(n, m) { m.forEach(function (e) { e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { if (k !== 'default' && !(k in n)) { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, get: function () { return e[k]; } }); } }); }); return Object.freeze(n); } /** * @license * Copyright 2019 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const t$3 = globalThis, e$4 = t$3.ShadowRoot && (undefined === t$3.ShadyCSS || t$3.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, s$3 = Symbol(), o$6 = new WeakMap(); let n$5 = class n { constructor(t, e, o) { if (this._$cssResult$ = true, o !== s$3) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead."); this.cssText = t, this.t = e; } get styleSheet() { let t = this.o; const s = this.t; if (e$4 && undefined === t) { const e = undefined !== s && 1 === s.length; e && (t = o$6.get(s)), undefined === t && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), e && o$6.set(s, t)); } return t; } toString() { return this.cssText; } }; const r$6 = t => new n$5("string" == typeof t ? t : t + "", undefined, s$3), i$7 = (t, ...e) => { const o = 1 === t.length ? t[0] : e.reduce((e, s, o) => e + (t => { if (true === t._$cssResult$) return t.cssText; if ("number" == typeof t) return t; throw Error("Value passed to 'css' function must be a 'css' function result: " + t + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security."); })(s) + t[o + 1], t[0]); return new n$5(o, t, s$3); }, S$2 = (s, o) => { if (e$4) s.adoptedStyleSheets = o.map(t => t instanceof CSSStyleSheet ? t : t.styleSheet);else for (const e of o) { const o = document.createElement("style"), n = t$3.litNonce; undefined !== n && o.setAttribute("nonce", n), o.textContent = e.cssText, s.appendChild(o); } }, c$4 = e$4 ? t => t : t => t instanceof CSSStyleSheet ? (t => { let e = ""; for (const s of t.cssRules) e += s.cssText; return r$6(e); })(t) : t; /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const { is: i$6, defineProperty: e$3, getOwnPropertyDescriptor: r$5, getOwnPropertyNames: h$3, getOwnPropertySymbols: o$5, getPrototypeOf: n$4 } = Object, a$3 = globalThis, c$3 = a$3.trustedTypes, l$2 = c$3 ? c$3.emptyScript : "", p$2 = a$3.reactiveElementPolyfillSupport, d$3 = (t, s) => t, u$2 = { toAttribute(t, s) { switch (s) { case Boolean: t = t ? l$2 : null; break; case Object: case Array: t = null == t ? t : JSON.stringify(t); } return t; }, fromAttribute(t, s) { let i = t; switch (s) { case Boolean: i = null !== t; break; case Number: i = null === t ? null : Number(t); break; case Object: case Array: try { i = JSON.parse(t); } catch (t) { i = null; } } return i; } }, f$4 = (t, s) => !i$6(t, s), y$2 = { attribute: true, type: String, converter: u$2, reflect: false, hasChanged: f$4 }; Symbol.metadata ??= Symbol("metadata"), a$3.litPropertyMetadata ??= new WeakMap(); let b$2 = class b extends HTMLElement { static addInitializer(t) { this._$Ei(), (this.l ??= []).push(t); } static get observedAttributes() { return this.finalize(), this._$Eh && [...this._$Eh.keys()]; } static createProperty(t, s = y$2) { if (s.state && (s.attribute = false), this._$Ei(), this.elementProperties.set(t, s), !s.noAccessor) { const i = Symbol(), r = this.getPropertyDescriptor(t, i, s); undefined !== r && e$3(this.prototype, t, r); } } static getPropertyDescriptor(t, s, i) { const { get: e, set: h } = r$5(this.prototype, t) ?? { get() { return this[s]; }, set(t) { this[s] = t; } }; return { get() { return e?.call(this); }, set(s) { const r = e?.call(this); h.call(this, s), this.requestUpdate(t, r, i); }, configurable: true, enumerable: true }; } static getPropertyOptions(t) { return this.elementProperties.get(t) ?? y$2; } static _$Ei() { if (this.hasOwnProperty(d$3("elementProperties"))) return; const t = n$4(this); t.finalize(), undefined !== t.l && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties); } static finalize() { if (this.hasOwnProperty(d$3("finalized"))) return; if (this.finalized = true, this._$Ei(), this.hasOwnProperty(d$3("properties"))) { const t = this.properties, s = [...h$3(t), ...o$5(t)]; for (const i of s) this.createProperty(i, t[i]); } const t = this[Symbol.metadata]; if (null !== t) { const s = litPropertyMetadata.get(t); if (undefined !== s) for (const [t, i] of s) this.elementProperties.set(t, i); } this._$Eh = new Map(); for (const [t, s] of this.elementProperties) { const i = this._$Eu(t, s); undefined !== i && this._$Eh.set(i, t); } this.elementStyles = this.finalizeStyles(this.styles); } static finalizeStyles(s) { const i = []; if (Array.isArray(s)) { const e = new Set(s.flat(1 / 0).reverse()); for (const s of e) i.unshift(c$4(s)); } else undefined !== s && i.push(c$4(s)); return i; } static _$Eu(t, s) { const i = s.attribute; return false === i ? undefined : "string" == typeof i ? i : "string" == typeof t ? t.toLowerCase() : undefined; } constructor() { super(), this._$Ep = undefined, this.isUpdatePending = false, this.hasUpdated = false, this._$Em = null, this._$Ev(); } _$Ev() { this._$ES = new Promise(t => this.enableUpdating = t), this._$AL = new Map(), this._$E_(), this.requestUpdate(), this.constructor.l?.forEach(t => t(this)); } addController(t) { (this._$EO ??= new Set()).add(t), undefined !== this.renderRoot && this.isConnected && t.hostConnected?.(); } removeController(t) { this._$EO?.delete(t); } _$E_() { const t = new Map(), s = this.constructor.elementProperties; for (const i of s.keys()) this.hasOwnProperty(i) && (t.set(i, this[i]), delete this[i]); t.size > 0 && (this._$Ep = t); } createRenderRoot() { const t = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions); return S$2(t, this.constructor.elementStyles), t; } connectedCallback() { this.renderRoot ??= this.createRenderRoot(), this.enableUpdating(true), this._$EO?.forEach(t => t.hostConnected?.()); } enableUpdating(t) {} disconnectedCallback() { this._$EO?.forEach(t => t.hostDisconnected?.()); } attributeChangedCallback(t, s, i) { this._$AK(t, i); } _$EC(t, s) { const i = this.constructor.elementProperties.get(t), e = this.constructor._$Eu(t, i); if (undefined !== e && true === i.reflect) { const r = (undefined !== i.converter?.toAttribute ? i.converter : u$2).toAttribute(s, i.type); this._$Em = t, null == r ? this.removeAttribute(e) : this.setAttribute(e, r), this._$Em = null; } } _$AK(t, s) { const i = this.constructor, e = i._$Eh.get(t); if (undefined !== e && this._$Em !== e) { const t = i.getPropertyOptions(e), r = "function" == typeof t.converter ? { fromAttribute: t.converter } : undefined !== t.converter?.fromAttribute ? t.converter : u$2; this._$Em = e, this[e] = r.fromAttribute(s, t.type), this._$Em = null; } } requestUpdate(t, s, i) { if (undefined !== t) { if (i ??= this.constructor.getPropertyOptions(t), !(i.hasChanged ?? f$4)(this[t], s)) return; this.P(t, s, i); } false === this.isUpdatePending && (this._$ES = this._$ET()); } P(t, s, i) { this._$AL.has(t) || this._$AL.set(t, s), true === i.reflect && this._$Em !== t && (this._$Ej ??= new Set()).add(t); } async _$ET() { this.isUpdatePending = true; try { await this._$ES; } catch (t) { Promise.reject(t); } const t = this.scheduleUpdate(); return null != t && (await t), !this.isUpdatePending; } scheduleUpdate() { return this.performUpdate(); } performUpdate() { if (!this.isUpdatePending) return; if (!this.hasUpdated) { if (this.renderRoot ??= this.createRenderRoot(), this._$Ep) { for (const [t, s] of this._$Ep) this[t] = s; this._$Ep = undefined; } const t = this.constructor.elementProperties; if (t.size > 0) for (const [s, i] of t) true !== i.wrapped || this._$AL.has(s) || undefined === this[s] || this.P(s, this[s], i); } let t = false; const s = this._$AL; try { t = this.shouldUpdate(s), t ? (this.willUpdate(s), this._$EO?.forEach(t => t.hostUpdate?.()), this.update(s)) : this._$EU(); } catch (s) { throw t = false, this._$EU(), s; } t && this._$AE(s); } willUpdate(t) {} _$AE(t) { this._$EO?.forEach(t => t.hostUpdated?.()), this.hasUpdated || (this.hasUpdated = true, this.firstUpdated(t)), this.updated(t); } _$EU() { this._$AL = new Map(), this.isUpdatePending = false; } get updateComplete() { return this.getUpdateComplete(); } getUpdateComplete() { return this._$ES; } shouldUpdate(t) { return true; } update(t) { this._$Ej &&= this._$Ej.forEach(t => this._$EC(t, this[t])), this._$EU(); } updated(t) {} firstUpdated(t) {} }; b$2.elementStyles = [], b$2.shadowRootOptions = { mode: "open" }, b$2[d$3("elementProperties")] = new Map(), b$2[d$3("finalized")] = new Map(), p$2?.({ ReactiveElement: b$2 }), (a$3.reactiveElementVersions ??= []).push("2.0.4"); /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const t$2 = globalThis, i$5 = t$2.trustedTypes, s$2 = i$5 ? i$5.createPolicy("lit-html", { createHTML: t => t }) : undefined, e$2 = "$lit$", h$2 = `lit$${Math.random().toFixed(9).slice(2)}$`, o$4 = "?" + h$2, n$3 = `<${o$4}>`, r$4 = document, l$1 = () => r$4.createComment(""), c$2 = t => null === t || "object" != typeof t && "function" != typeof t, a$2 = Array.isArray, u$1 = t => a$2(t) || "function" == typeof t?.[Symbol.iterator], d$2 = "[ \t\n\f\r]", f$3 = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, v$2 = /-->/g, _$3 = />/g, m$1 = RegExp(`>|${d$2}(?:([^\\s"'>=/]+)(${d$2}*=${d$2}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`, "g"), p$1 = /'/g, g$2 = /"/g, $$1 = /^(?:script|style|textarea|title)$/i, y$1 = t => (i, ...s) => ({ _$litType$: t, strings: i, values: s }), x$2 = y$1(1), b$1 = y$1(2), T$1 = Symbol.for("lit-noChange"), E$1 = Symbol.for("lit-nothing"), A$2 = new WeakMap(), C$1 = r$4.createTreeWalker(r$4, 129); function P$1(t, i) { if (!a$2(t) || !t.hasOwnProperty("raw")) throw Error("invalid template strings array"); return undefined !== s$2 ? s$2.createHTML(i) : i; } const V$1 = (t, i) => { const s = t.length - 1, o = []; let r, l = 2 === i ? "<svg>" : 3 === i ? "<math>" : "", c = f$3; for (let i = 0; i < s; i++) { const s = t[i]; let a, u, d = -1, y = 0; for (; y < s.length && (c.lastIndex = y, u = c.exec(s), null !== u);) y = c.lastIndex, c === f$3 ? "!--" === u[1] ? c = v$2 : undefined !== u[1] ? c = _$3 : undefined !== u[2] ? ($$1.test(u[2]) && (r = RegExp("</" + u[2], "g")), c = m$1) : undefined !== u[3] && (c = m$1) : c === m$1 ? ">" === u[0] ? (c = r ?? f$3, d = -1) : undefined === u[1] ? d = -2 : (d = c.lastIndex - u[2].length, a = u[1], c = undefined === u[3] ? m$1 : '"' === u[3] ? g$2 : p$1) : c === g$2 || c === p$1 ? c = m$1 : c === v$2 || c === _$3 ? c = f$3 : (c = m$1, r = undefined); const x = c === m$1 && t[i + 1].startsWith("/>") ? " " : ""; l += c === f$3 ? s + n$3 : d >= 0 ? (o.push(a), s.slice(0, d) + e$2 + s.slice(d) + h$2 + x) : s + h$2 + (-2 === d ? i : x); } return [P$1(t, l + (t[s] || "<?>") + (2 === i ? "</svg>" : 3 === i ? "</math>" : "")), o]; }; let N$2 = class N { constructor({ strings: t, _$litType$: s }, n) { let r; this.parts = []; let c = 0, a = 0; const u = t.length - 1, d = this.parts, [f, v] = V$1(t, s); if (this.el = N.createElement(f, n), C$1.currentNode = this.el.content, 2 === s || 3 === s) { const t = this.el.content.firstChild; t.replaceWith(...t.childNodes); } for (; null !== (r = C$1.nextNode()) && d.length < u;) { if (1 === r.nodeType) { if (r.hasAttributes()) for (const t of r.getAttributeNames()) if (t.endsWith(e$2)) { const i = v[a++], s = r.getAttribute(t).split(h$2), e = /([.?@])?(.*)/.exec(i); d.push({ type: 1, index: c, name: e[2], strings: s, ctor: "." === e[1] ? H$1 : "?" === e[1] ? I$1 : "@" === e[1] ? L$1 : k$1 }), r.removeAttribute(t); } else t.startsWith(h$2) && (d.push({ type: 6, index: c }), r.removeAttribute(t)); if ($$1.test(r.tagName)) { const t = r.textContent.split(h$2), s = t.length - 1; if (s > 0) { r.textContent = i$5 ? i$5.emptyScript : ""; for (let i = 0; i < s; i++) r.append(t[i], l$1()), C$1.nextNode(), d.push({ type: 2, index: ++c }); r.append(t[s], l$1()); } } } else if (8 === r.nodeType) if (r.data === o$4) d.push({ type: 2, index: c });else { let t = -1; for (; -1 !== (t = r.data.indexOf(h$2, t + 1));) d.push({ type: 7, index: c }), t += h$2.length - 1; } c++; } } static createElement(t, i) { const s = r$4.createElement("template"); return s.innerHTML = t, s; } }; function S$1(t, i, s = t, e) { if (i === T$1) return i; let h = undefined !== e ? s._$Co?.[e] : s._$Cl; const o = c$2(i) ? undefined : i._$litDirective$; return h?.constructor !== o && (h?._$AO?.(false), undefined === o ? h = undefined : (h = new o(t), h._$AT(t, s, e)), undefined !== e ? (s._$Co ??= [])[e] = h : s._$Cl = h), undefined !== h && (i = S$1(t, h._$AS(t, i.values), h, e)), i; } let M$1 = class M { constructor(t, i) { this._$AV = [], this._$AN = undefined, this._$AD = t, this._$AM = i; } get parentNode() { return this._$AM.parentNode; } get _$AU() { return this._$AM._$AU; } u(t) { const { el: { content: i }, parts: s } = this._$AD, e = (t?.creationScope ?? r$4).importNode(i, true); C$1.currentNode = e; let h = C$1.nextNode(), o = 0, n = 0, l = s[0]; for (; undefined !== l;) { if (o === l.index) { let i; 2 === l.type ? i = new R$2(h, h.nextSibling, this, t) : 1 === l.type ? i = new l.ctor(h, l.name, l.strings, this, t) : 6 === l.type && (i = new z(h, this, t)), this._$AV.push(i), l = s[++n]; } o !== l?.index && (h = C$1.nextNode(), o++); } return C$1.currentNode = r$4, e; } p(t) { let i = 0; for (const s of this._$AV) undefined !== s && (undefined !== s.strings ? (s._$AI(t, s, i), i += s.strings.length - 2) : s._$AI(t[i])), i++; } }; let R$2 = class R { get _$AU() { return this._$AM?._$AU ?? this._$Cv; } constructor(t, i, s, e) { this.type = 2, this._$AH = E$1, this._$AN = undefined, this._$AA = t, this._$AB = i, this._$AM = s, this.options = e, this._$Cv = e?.isConnected ?? true; } get parentNode() { let t = this._$AA.parentNode; const i = this._$AM; return undefined !== i && 11 === t?.nodeType && (t = i.parentNode), t; } get startNode() { return this._$AA; } get endNode() { return this._$AB; } _$AI(t, i = this) { t = S$1(this, t, i), c$2(t) ? t === E$1 || null == t || "" === t ? (this._$AH !== E$1 && this._$AR(), this._$AH = E$1) : t !== this._$AH && t !== T$1 && this._(t) : undefined !== t._$litType$ ? this.$(t) : undefined !== t.nodeType ? this.T(t) : u$1(t) ? this.k(t) : this._(t); } O(t) { return this._$AA.parentNode.insertBefore(t, this._$AB); } T(t) { this._$AH !== t && (this._$AR(), this._$AH = this.O(t)); } _(t) { this._$AH !== E$1 && c$2(this._$AH) ? this._$AA.nextSibling.data = t : this.T(r$4.createTextNode(t)), this._$AH = t; } $(t) { const { values: i, _$litType$: s } = t, e = "number" == typeof s ? this._$AC(t) : (undefined === s.el && (s.el = N$2.createElement(P$1(s.h, s.h[0]), this.options)), s); if (this._$AH?._$AD === e) this._$AH.p(i);else { const t = new M$1(e, this), s = t.u(this.options); t.p(i), this.T(s), this._$AH = t; } } _$AC(t) { let i = A$2.get(t.strings); return undefined === i && A$2.set(t.strings, i = new N$2(t)), i; } k(t) { a$2(this._$AH) || (this._$AH = [], this._$AR()); const i = this._$AH; let s, e = 0; for (const h of t) e === i.length ? i.push(s = new R(this.O(l$1()), this.O(l$1()), this, this.options)) : s = i[e], s._$AI(h), e++; e < i.length && (this._$AR(s && s._$AB.nextSibling, e), i.length = e); } _$AR(t = this._$AA.nextSibling, i) { for (this._$AP?.(false, true, i); t && t !== this._$AB;) { const i = t.nextSibling; t.remove(), t = i; } } setConnected(t) { undefined === this._$AM && (this._$Cv = t, this._$AP?.(t)); } }; let k$1 = class k { get tagName() { return this.element.tagName; } get _$AU() { return this._$AM._$AU; } constructor(t, i, s, e, h) { this.type = 1, this._$AH = E$1, this._$AN = undefined, this.element = t, this.name = i, this._$AM = e, this.options = h, s.length > 2 || "" !== s[0] || "" !== s[1] ? (this._$AH = Array(s.length - 1).fill(new String()), this.strings = s) : this._$AH = E$1; } _$AI(t, i = this, s, e) { const h = this.strings; let o = false; if (undefined === h) t = S$1(this, t, i, 0), o = !c$2(t) || t !== this._$AH && t !== T$1, o && (this._$AH = t);else { const e = t; let n, r; for (t = h[0], n = 0; n < h.length - 1; n++) r = S$1(this, e[s + n], i, n), r === T$1 && (r = this._$AH[n]), o ||= !c$2(r) || r !== this._$AH[n], r === E$1 ? t = E$1 : t !== E$1 && (t += (r ?? "") + h[n + 1]), this._$AH[n] = r; } o && !e && this.j(t); } j(t) { t === E$1 ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? ""); } }; let H$1 = class H extends k$1 { constructor() { super(...arguments), this.type = 3; } j(t) { this.element[this.name] = t === E$1 ? undefined : t; } }; let I$1 = class I extends k$1 { constructor() { super(...arguments), this.type = 4; } j(t) { this.element.toggleAttribute(this.name, !!t && t !== E$1); } }; let L$1 = class L extends k$1 { constructor(t, i, s, e, h) { super(t, i, s, e, h), this.type = 5; } _$AI(t, i = this) { if ((t = S$1(this, t, i, 0) ?? E$1) === T$1) return; const s = this._$AH, e = t === E$1 && s !== E$1 || t.capture !== s.capture || t.once !== s.once || t.passive !== s.passive, h = t !== E$1 && (s === E$1 || e); e && this.element.removeEventListener(this.name, this, s), h && this.element.addEventListener(this.name, this, t), this._$AH = t; } handleEvent(t) { "function" == typeof this._$AH ? this._$AH.call(this.options?.host ?? this.element, t) : this._$AH.handleEvent(t); } }; class z { constructor(t, i, s) { this.element = t, this.type = 6, this._$AN = undefined, this._$AM = i, this.options = s; } get _$AU() { return this._$AM._$AU; } _$AI(t) { S$1(this, t); } } const j$1 = t$2.litHtmlPolyfillSupport; j$1?.(N$2, R$2), (t$2.litHtmlVersions ??= []).push("3.2.1"); const B = (t, i, s) => { const e = s?.renderBefore ?? i; let h = e._$litPart$; if (undefined === h) { const t = s?.renderBefore ?? null; e._$litPart$ = h = new R$2(i.insertBefore(l$1(), t), t, undefined, s ?? {}); } return h._$AI(t), h; }; /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ let r$3 = class r extends b$2 { constructor() { super(...arguments), this.renderOptions = { host: this }, this._$Do = undefined; } createRenderRoot() { const t = super.createRenderRoot(); return this.renderOptions.renderBefore ??= t.firstChild, t; } update(t) { const s = this.render(); this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t), this._$Do = B(s, this.renderRoot, this.renderOptions); } connectedCallback() { super.connectedCallback(), this._$Do?.setConnected(true); } disconnectedCallback() { super.disconnectedCallback(), this._$Do?.setConnected(false); } render() { return T$1; } }; r$3._$litElement$ = true, r$3["finalized"] = true, globalThis.litElementHydrateSupport?.({ LitElement: r$3 }); const i$4 = globalThis.litElementPolyfillSupport; i$4?.({ LitElement: r$3 }); (globalThis.litElementVersions ??= []).push("4.1.1"); function ascending$2(a, b) { return a == null || b == null ? NaN : a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN; } function descending$1(a, b) { return a == null || b == null ? NaN : b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN; } function bisector(f) { let compare1, compare2, delta; // If an accessor is specified, promote it to a comparator. In this case we // can test whether the search value is (self-) comparable. We can’t do this // for a comparator (except for specific, known comparators) because we can’t // tell if the comparator is symmetric, and an asymmetric comparator can’t be // used to test whether a single value is comparable. if (f.length !== 2) { compare1 = ascending$2; compare2 = (d, x) => ascending$2(f(d), x); delta = (d, x) => f(d) - x; } else { compare1 = f === ascending$2 || f === descending$1 ? f : zero$1; compare2 = f; delta = f; } function left(a, x, lo = 0, hi = a.length) { if (lo < hi) { if (compare1(x, x) !== 0) return hi; do { const mid = lo + hi >>> 1; if (compare2(a[mid], x) < 0) lo = mid + 1;else hi = mid; } while (lo < hi); } return lo; } function right(a, x, lo = 0, hi = a.length) { if (lo < hi) { if (compare1(x, x) !== 0) return hi; do { const mid = lo + hi >>> 1; if (compare2(a[mid], x) <= 0) lo = mid + 1;else hi = mid; } while (lo < hi); } return lo; } function center(a, x, lo = 0, hi = a.length) { const i = left(a, x, lo, hi - 1); return i > lo && delta(a[i - 1], x) > -delta(a[i], x) ? i - 1 : i; } return { left, center, right }; } function zero$1() { return 0; } function number$3(x) { return x === null ? NaN : +x; } const ascendingBisect = bisector(ascending$2); const bisectRight = ascendingBisect.right; bisector(number$3).center; const e10 = Math.sqrt(50), e5 = Math.sqrt(10), e2 = Math.sqrt(2); function tickSpec(start, stop, count) { const step = (stop - start) / Math.max(0, count), power = Math.floor(Math.log10(step)), error = step / Math.pow(10, power), factor = error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1; let i1, i2, inc; if (power < 0) { inc = Math.pow(10, -power) / factor; i1 = Math.round(start * inc); i2 = Math.round(stop * inc); if (i1 / inc < start) ++i1; if (i2 / inc > stop) --i2; inc = -inc; } else { inc = Math.pow(10, power) * factor; i1 = Math.round(start / inc); i2 = Math.round(stop / inc); if (i1 * inc < start) ++i1; if (i2 * inc > stop) --i2; } if (i2 < i1 && 0.5 <= count && count < 2) return tickSpec(start, stop, count * 2); return [i1, i2, inc]; } function ticks$1(start, stop, count) { stop = +stop, start = +start, count = +count; if (!(count > 0)) return []; if (start === stop) return [start]; const reverse = stop < start, [i1, i2, inc] = reverse ? tickSpec(stop, start, count) : tickSpec(start, stop, count); if (!(i2 >= i1)) return []; const n = i2 - i1 + 1, ticks = new Array(n); if (reverse) { if (inc < 0) for (let i = 0; i < n; ++i) ticks[i] = (i2 - i) / -inc;else for (let i = 0; i < n; ++i) ticks[i] = (i2 - i) * inc; } else { if (inc < 0) for (let i = 0; i < n; ++i) ticks[i] = (i1 + i) / -inc;else for (let i = 0; i < n; ++i) ticks[i] = (i1 + i) * inc; } return ticks; } function tickIncrement$1(start, stop, count) { stop = +stop, start = +start, count = +count; return tickSpec(start, stop, count)[2]; } function tickStep(start, stop, count) { stop = +stop, start = +start, count = +count; const reverse = stop < start, inc = reverse ? tickIncrement$1(stop, start, count) : tickIncrement$1(start, stop, count); return (reverse ? -1 : 1) * (inc < 0 ? 1 / -inc : inc); } function range(start, stop, step) { start = +start, stop = +stop, step = (n = arguments.length) < 2 ? (stop = start, start = 0, 1) : n < 3 ? 1 : +step; var i = -1, n = Math.max(0, Math.ceil((stop - start) / step)) | 0, range = new Array(n); while (++i < n) { range[i] = start + i * step; } return range; } function identity$9 (x) { return x; } var top = 1, right = 2, bottom = 3, left = 4, epsilon$5 = 1e-6; function translateX(x) { return "translate(" + x + ",0)"; } function translateY(y) { return "translate(0," + y + ")"; } function number$2(scale) { return d => +scale(d); } function center(scale, offset) { offset = Math.max(0, scale.bandwidth() - offset * 2) / 2; if (scale.round()) offset = Math.round(offset); return d => +scale(d) + offset; } function entering() { return !this.__axis; } function axis(orient, scale) { var tickArguments = [], tickValues = null, tickFormat = null, tickSizeInner = 6, tickSizeOuter = 6, tickPadding = 3, offset = typeof window !== "undefined" && window.devicePixelRatio > 1 ? 0 : 0.5, k = orient === top || orient === left ? -1 : 1, x = orient === left || orient === right ? "x" : "y", transform = orient === top || orient === bottom ? translateX : translateY; function axis(context) { var values = tickValues == null ? scale.ticks ? scale.ticks.apply(scale, tickArguments) : scale.domain() : tickValues, format = tickFormat == null ? scale.tickFormat ? scale.tickFormat.apply(scale, tickArguments) : identity$9 : tickFormat, spacing = Math.max(tickSizeInner, 0) + tickPadding, range = scale.range(), range0 = +range[0] + offset, range1 = +range[range.length - 1] + offset, position = (scale.bandwidth ? center : number$2)(scale.copy(), offset), selection = context.selection ? context.selection() : context, path = selection.selectAll(".domain").data([null]), tick = selection.selectAll(".tick").data(values, scale).order(), tickExit = tick.exit(), tickEnter = tick.enter().append("g").attr("class", "tick"), line = tick.select("line"), text = tick.select("text"); path = path.merge(path.enter().insert("path", ".tick").attr("class", "domain").attr("stroke", "currentColor")); tick = tick.merge(tickEnter); line = line.merge(tickEnter.append("line").attr("stroke", "currentColor").attr(x + "2", k * tickSizeInner)); text = text.merge(tickEnter.append("text").attr("fill", "currentColor").attr(x, k * spacing).attr("dy", orient === top ? "0em" : orient === bottom ? "0.71em" : "0.32em")); if (context !== selection) { path = path.transition(context); tick = tick.transition(context); line = line.transition(context); text = text.transition(context); tickExit = tickExit.transition(context).attr("opacity", epsilon$5).attr("transform", function (d) { return isFinite(d = position(d)) ? transform(d + offset) : this.getAttribute("transform"); }); tickEnter.attr("opacity", epsilon$5).attr("transform", function (d) { var p = this.parentNode.__axis; return transform((p && isFinite(p = p(d)) ? p : position(d)) + offset); }); } tickExit.remove(); path.attr("d", orient === left || orient === right ? tickSizeOuter ? "M" + k * tickSizeOuter + "," + range0 + "H" + offset + "V" + range1 + "H" + k * tickSizeOuter : "M" + offset + "," + range0 + "V" + range1 : tickSizeOuter ? "M" + range0 + "," + k * tickSizeOuter + "V" + offset + "H" + range1 + "V" + k * tickSizeOuter : "M" + range0 + "," + offset + "H" + range1); tick.attr("opacity", 1).attr("transform", function (d) { return transform(position(d) + offset); }); line.attr(x + "2", k * tickSizeInner); text.attr(x, k * spacing).text(format); selection.filter(entering).attr("fill", "none").attr("font-size", 10).attr("font-family", "sans-serif").attr("text-anchor", orient === right ? "start" : orient === left ? "end" : "middle"); selection.each(function () { this.__axis = position; }); } axis.scale = function (_) { return arguments.length ? (scale = _, axis) : scale; }; axis.ticks = function () { return tickArguments = Array.from(arguments), axis; }; axis.tickArguments = function (_) { return arguments.length ? (tickArguments = _ == null ? [] : Array.from(_), axis) : tickArguments.slice(); }; axis.tickValues = function (_) { return arguments.length ? (tickValues = _ == null ? null : Array.from(_), axis) : tickValues && tickValues.slice(); }; axis.tickFormat = function (_) { return arguments.length ? (tickFormat = _, axis) : tickFormat; }; axis.tickSize = function (_) { return arguments.length ? (tickSizeInner = tickSizeOuter = +_, axis) : tickSizeInner; }; axis.tickSizeInner = function (_) { return arguments.length ? (tickSizeInner = +_, axis) : tickSizeInner; }; axis.tickSizeOuter = function (_) { return arguments.length ? (tickSizeOuter = +_, axis) : tickSizeOuter; }; axis.tickPadding = function (_) { return arguments.length ? (tickPadding = +_, axis) : tickPadding; }; axis.offset = function (_) { return arguments.length ? (offset = +_, axis) : offset; }; return axis; } function axisBottom(scale) { return axis(bottom, scale); } function axisLeft(scale) { return axis(left, scale); } var noop$2 = { value: () => {} }; function dispatch() { for (var i = 0, n = arguments.length, _ = {}, t; i < n; ++i) { if (!(t = arguments[i] + "") || t in _ || /[\s.]/.test(t)) throw new Error("illegal type: " + t); _[t] = []; } return new Dispatch(_); } function Dispatch(_) { this._ = _; } function parseTypenames$1(typenames, types) { return typenames.trim().split(/^|\s+/).map(function (t) { var name = "", i = t.indexOf("."); if (i >= 0) name = t.slice(i + 1), t = t.slice(0, i); if (t && !types.hasOwnProperty(t)) throw new Error("unknown type: " + t); return { type: t, name: name }; }); } Dispatch.prototype = dispatch.prototype = { constructor: Dispatch, on: function (typename, callback) { var _ = this._, T = parseTypenames$1(typename + "", _), t, i = -1, n = T.length; // If no callback was specified, return the callback of the given type and name. if (arguments.length < 2) { while (++i < n) if ((t = (typename = T[i]).type) && (t = get$1(_[t], typename.name))) return t; return; } // If a type was specified, set the callback for the given type and name. // Otherwise, if a null callback was specified, remove callbacks of the given name. if (callback != null && typeof callback !== "function") throw new Error("invalid callback: " + callback); while (++i < n) { if (t = (typename = T[i]).type) _[t] = set$1(_[t], typename.name, callback);else if (callback == null) for (t in _) _[t] = set$1(_[t], typename.name, null); } return this; }, copy: function () { var copy = {}, _ = this._; for (var t in _) copy[t] = _[t].slice(); return new Dispatch(copy); }, call: function (type, that) { if ((n = arguments.length - 2) > 0) for (var args = new Array(n), i = 0, n, t; i < n; ++i) args[i] = arguments[i + 2]; if (!this._.hasOwnProperty(type)) throw new Error("unknown type: " + type); for (t = this._[type], i = 0, n = t.length; i < n; ++i) t[i].value.apply(that, args); }, apply: function (type, that, args) { if (!this._.hasOwnProperty(type)) throw new Error("unknown type: " + type); for (var t = this._[type], i = 0, n = t.length; i < n; ++i) t[i].value.apply(that, args); } }; function get$1(type, name) { for (var i = 0, n = type.length, c; i < n; ++i) { if ((c = type[i]).name === name) { return c.value; } } } function set$1(type, name, callback) { for (var i = 0, n = type.length; i < n; ++i) { if (type[i].name === name) { type[i] = noop$2, type = type.slice(0, i).concat(type.slice(i + 1)); break; } } if (callback != null) type.push({ name: name, value: callback }); return type; } var xhtml = "http://www.w3.org/1999/xhtml"; var namespaces = { svg: "http://www.w3.org/2000/svg", xhtml: xhtml, xlink: "http://www.w3.org/1999/xlink", xml: "http://www.w3.org/XML/1998/namespace", xmlns: "http://www.w3.org/2000/xmlns/" }; function namespace (name) { var prefix = name += "", i = prefix.indexOf(":"); if (i >= 0 && (prefix = name.slice(0, i)) !== "xmlns") name = name.slice(i + 1); return namespaces.hasOwnProperty(prefix) ? { space: namespaces[prefix], local: name } : name; // eslint-disable-line no-prototype-builtins } function creatorInherit(name) { return function () { var document = this.ownerDocument, uri = this.namespaceURI; return uri === xhtml && document.documentElement.namespaceURI === xhtml ? document.createElement(name) : document.createElementNS(uri, name); }; } function creatorFixed(fullname) { return function () { return this.ownerDocument.createElementNS(fullname.space, fullname.local); }; } function creator (name) { var fullname = namespace(name); return (fullname.local ? creatorFixed : creatorInherit)(fullname); } function none() {} function selector$1 (selector) { return selector == null ? none : function () { return this.querySelector(selector); }; } function selection_select (select) { if (typeof select !== "function") select = selector$1(select); for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) { for (var group = groups[j], n = group.length, subgroup = subgroups[j] = new Array(n), node, subnode, i = 0; i < n; ++i) { if ((node = group[i]) && (subnode = select.call(node, node.__data__, i, group))) { if ("__data__" in node) subnode.__data__ = node.__data__; subgroup[i] = subnode; } } } return new Selection$1(subgroups, this._parents); } // Given something array like (or null), returns something that is strictly an // array. This is used to ensure that array-like objects passed to d3.selectAll // or selection.selectAll are converted into proper arrays when creating a // selection; we don’t ever want to create a selection backed by a live // HTMLCollection or NodeList. However, note that selection.selectAll will use a // static NodeList as a group, since it safely derived from querySelectorAll. function array$2(x) { return x == null ? [] : Array.isArray(x) ? x : Array.from(x); } function empty() { return []; } function selectorAll (selector) { return selector == null ? empty : function () { return this.querySelectorAll(selector); }; } function arrayAll(select) { return function () { return array$2(select.apply(this, arguments)); }; } function selection_selectAll (select) { if (typeof select === "function") select = arrayAll(select);else select = selectorAll(select); for (var groups = this._groups, m = groups.length, subgroups = [], parents = [], j = 0; j < m; ++j) { for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) { if (node = group[i]) { subgroups.push(select.call(node, node.__data__, i, group)); parents.push(node); } } } return new Selection$1(subgroups, parents); } function matcher (selector) { return function () { return this.matches(selector); }; } function childMatcher(selector) { return function (node) { return node.matches(selector); }; } var find = Array.prototype.find; function childFind(match) { return function () { return find.call(this.children, match); }; } function childFirst() { return this.firstElementChild; } function selection_selectChild (match) { return this.select(match == null ? childFirst : childFind(typeof match === "function" ? match : childMatcher(match))); } var filter$2 = Array.prototype.filter; function children() { return Array.from(this.children); } function childrenFilter(match) { return function () { return filter$2.call(this.children, match); }; } function selection_selectChildren (match) { return this.selectAll(match == null ? children : childrenFilter(typeof match === "function" ? match : childMatcher(match))); } function selection_filter (match) { if (typeof match !== "function") match = matcher(match); for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) { for (var group = groups[j], n = group.length, subgroup = subgroups[j] = [], node, i = 0; i < n; ++i) { if ((node = group[i]) && match.call(node, node.__data__, i, group)) { subgroup.push(node); } } } return new Selection$1(subgroups, this._parents); } function sparse (update) { return new Array(update.length); } function selection_enter () { return new Selection$1(this._enter || this._groups.map(sparse), this._parents); } function EnterNode(parent, datum) { this.ownerDocument = parent.ownerDocument; this.namespaceURI = parent.namespaceURI; this._next = null; this._parent = parent; this.__data__ = datum; } EnterNode.prototype = { constructor: EnterNode, appendChild: function (child) { return this._parent.insertBefore(child, this._next); }, insertBefore: function (child, next) { return this._parent.insertBefore(child, next); }, querySelector: function (selector) { return this._parent.querySelector(selector); }, querySelectorAll: function (selector) { return this._parent.querySelectorAll(selector); } }; function constant$3 (x) { return function () { return x; }; } function bindIndex(parent, group, enter, update, exit, data) { var i = 0, node, groupLength = group.length, dataLength = data.length; // Put any non-null nodes that fit into update. // Put any null nodes into enter. // Put any remaining data into enter. for (; i < dataLength; ++i) { if (node = group[i]) { node.__data__ = data[i]; update[i] = node; } else { enter[i] = new EnterNode(parent, data[i]); } } // Put any non-null nodes that don’t fit into exit. for (; i < groupLength; ++i) { if (node = group[i]) { exit[i] = node; } } } function bindKey(parent, group, enter, update, exit, data, key) { var i, node, nodeByKeyValue = new Map(), groupLength = group.length, dataLength = data.length, keyValues = new Array(groupLength), keyValue; // Compute the key for each node. // If multiple nodes have the same key, the duplicates are added to exit. for (i = 0; i < groupLength; ++i) { if (node = group[i]) { keyValues[i] = keyValue = key.call(node, node.__data__, i, group) + ""; if (nodeByKeyValue.has(keyValue)) { exit[i] = node; } else { nodeByKeyValue.set(keyValue, node); } } } // Compute the key for each datum. // If there a node associated with this key, join and add it to update. // If there is not (or the key is a duplicate), add it to enter. for (i = 0; i < dataLength; ++i) { keyValue = key.call(parent, data[i], i, data) + ""; if (node = nodeByKeyValue.get(keyValue)) { update[i] = node; node.__data__ = data[i]; nodeByKeyValue.delete(keyValue); } else { enter[i] = new EnterNode(parent, data[i]); } } // Add any remaining nodes that were not bound to data to exit. for (i = 0; i < groupLength; ++i) { if ((node = group[i]) && nodeByKeyValue.get(keyValues[i]) === node) { exit[i] = node; } } } function datum(node) { return node.__data__; } function selection_data (value, key) { if (!arguments.length) return Array.from(this, datum); var bind = key ? bindKey : bindIndex, parents = this._parents, groups = this._groups; if (typeof value !== "function") value = constant$3(value); for (var m = groups.length, update = new Array(m), enter = new Array(m), exit = new Array(m), j = 0; j < m; ++j) { var parent = parents[j], group = groups[j], groupLength = group.length, data = arraylike(value.call(parent, parent && parent.__data__, j, parents)), dataLength = data.length, enterGroup = enter[j] = new Array(dataLength), updateGroup = update[j] = new Array(dataLength), exitGroup = exit[j] = new Array(groupLength); bind(parent, group, enterGroup, updateGroup, exitGroup, data, key); // Now connect the enter nodes to their following update node, such that // appendChild can insert the materialized enter node before this node, // rather than at the end of the parent node. for (var i0 = 0, i1 = 0, previous, next; i0 < dataLength; ++i0) { if (previous = enterGroup[i0]) { if (i0 >= i1) i1 = i0 + 1; while (!(next = updateGroup[i1]) && ++i1 < dataLength); previous._next = next || null; } } } update = new Selection$1(update, parents); update._enter = enter; update._exit = exit; return update; } // Given some data, this returns an array-like view of it: an object that // exposes a length property and allows numeric indexing. Note that unlike // selectAll, this isn’t worried about “live” collections because the resulting // array will only be used briefly while data is being bound. (It is possible to // cause the data to change while iterating by using a key function, but please // don’t; we’d rather avoid a gratuitous copy.) function arraylike(data) { return typeof data === "object" && "length" in data ? data // Array, TypedArray, NodeList, array-like : Array.from(data); // Map, Set, iterable, string, or anything else } function selection_exit () { return new Selection$1(this._exit || this._groups.map(sparse), this._parents); } function selection_join (onenter, onupdate, onexit) { var enter = this.enter(), update = this, exit = this.exit(); if (typeof onenter === "function") { enter = onenter(enter); if (enter) enter = enter.selection(); } else { enter = enter.append(onenter + ""); } if (onupdate != null) { update = onupdate(update); if (update) update = update.selection(); } if (onexit == null) exit.remove();else onexit(exit); return enter && update ? enter.merge(update).order() : update; } function selection_merge (context) { var selection = context.selection ? context.selection() : context; for (var groups0 = this._groups, groups1 = selection._groups, m0 = groups0.length, m1 = groups1.length, m = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m; ++j) { for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge = merges[j] = new Array(n), node, i = 0; i < n; ++i) { if (node = group0[i] || group1[i]) { merge[i] = node; } } } for (; j < m0; ++j) { merges[j] = groups0[j]; } return new Selection$1(merges, this._parents); } function selection_order () { for (var groups = this._groups, j = -1, m = groups.length; ++j < m;) { for (var group = groups[j], i = group.length - 1, next = group[i], node; --i >= 0;) { if (node = group[i]) { if (next && node.compareDocumentPosition(next) ^ 4) next.parentNode.insertBefore(node, next); next = node; } } } return this; } function selection_sort (compare) { if (!compare) compare = ascending$1; function compareNode(a, b) { return a && b ? compare(a.__data__, b.__data__) : !a - !b; } for (var groups = this._groups, m = groups.length, sortgroups = new Array(m), j = 0; j < m; ++j) { for (var group = groups[j], n = group.length, sortgroup = sortgroups[j] = new Array(n), node, i = 0; i < n; ++i) { if (node = group[i]) { sortgroup[i] = node; } } sortgroup.sort(compareNode); } return new Selection$1(sortgroups, this._parents).order(); } function ascending$1(a, b) { return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN; } function selection_call () { var callback = arguments[0]; arguments[0] = this; callback.apply(null, arguments); return this; } function selection_nodes () { return Array.from(this); } function selection_node () { for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) { for (var group = groups[j], i = 0, n = group.length; i < n; ++i) { var node = group[i]; if (node) return node; } } return null; } function selection_size () { let size = 0; for (const node of this) ++size; // eslint-disable-line no-unused-vars return size; } function selection_empty () { return !this.node(); } function selection_each (callback) { for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) { for (var group = groups[j], i = 0, n = group.length, node; i < n; ++i) { if (node = group[i]) callback.call(node, node.__data__, i, group); } } return this; } function attrRemove$1(name) { return function () { this.removeAttribute(name); }; } function attrRemoveNS$1(fullname) { return function () { this.removeAttributeNS(fullname.space, fullname.local); }; } function attrConstant$1(name, value) { return function () { this.setAttribute(name, value); }; } function attrConstantNS$1(fullname, value) { return function () { this.setAttributeNS(fullname.space, fullname.local, value); }; } function attrFunction$1(name, value) { return function () { var v = value.apply(this, arguments); if (v == null) this