UNPKG

higlass

Version:

HiGlass Hi-C / genomic / large data viewer

1,292 lines 4.34 MB
(function(global, factory) { typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react"), require("pixi.js"), require("react-dom"), require("react/jsx-runtime")) : typeof define === "function" && define.amd ? define(["exports", "react", "pixi.js", "react-dom", "react/jsx-runtime"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.hglib = {}, global.React, global.PIXI, global.ReactDOM, global.ReactJSXRuntime)); })(this, (function(exports2, React, PIXI, ReactDOM, jsxRuntime) { "use strict"; function _interopNamespaceDefault(e) { const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } }); if (e) { for (const k in e) { if (k !== "default") { const d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, get: () => e[k] }); } } } n.default = e; return Object.freeze(n); } const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React); const PIXI__namespace = /* @__PURE__ */ _interopNamespaceDefault(PIXI); function r$1(e) { var t, f2, n = ""; if ("string" == typeof e || "number" == typeof e) n += e; else if ("object" == typeof e) if (Array.isArray(e)) for (t = 0; t < e.length; t++) e[t] && (f2 = r$1(e[t])) && (n && (n += " "), n += f2); else for (t in e) e[t] && (n && (n += " "), n += t); return n; } function clsx$2() { for (var e, t, f2 = 0, n = ""; f2 < arguments.length; ) (e = arguments[f2++]) && (t = r$1(e)) && (n && (n += " "), n += t); return n; } function getDefaultExportFromCjs(x) { return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x; } function getAugmentedNamespace(n) { if (Object.prototype.hasOwnProperty.call(n, "__esModule")) return n; var f2 = n.default; if (typeof f2 == "function") { var a = function a2() { var isInstance = false; try { isInstance = this instanceof a2; } catch { } if (isInstance) { return Reflect.construct(f2, arguments, this.constructor); } return f2.apply(this, arguments); }; a.prototype = f2.prototype; } else a = {}; Object.defineProperty(a, "__esModule", { value: true }); Object.keys(n).forEach(function(k) { var d = Object.getOwnPropertyDescriptor(n, k); Object.defineProperty(a, k, d.get ? d : { enumerable: true, get: function() { return n[k]; } }); }); return a; } var ResizeSensor$1 = { exports: {} }; var ResizeSensor = ResizeSensor$1.exports; var hasRequiredResizeSensor; function requireResizeSensor() { if (hasRequiredResizeSensor) return ResizeSensor$1.exports; hasRequiredResizeSensor = 1; (function(module2, exports3) { (function(root2, factory) { { module2.exports = factory(); } })(typeof window !== "undefined" ? window : ResizeSensor, function() { if (typeof window === "undefined") { return null; } var globalWindow = typeof window != "undefined" && window.Math == Math ? window : typeof self != "undefined" && self.Math == Math ? self : Function("return this")(); var requestAnimationFrame2 = globalWindow.requestAnimationFrame || globalWindow.mozRequestAnimationFrame || globalWindow.webkitRequestAnimationFrame || function(fn) { return globalWindow.setTimeout(fn, 20); }; var cancelAnimationFrame = globalWindow.cancelAnimationFrame || globalWindow.mozCancelAnimationFrame || globalWindow.webkitCancelAnimationFrame || function(timer2) { globalWindow.clearTimeout(timer2); }; function forEachElement(elements, callback) { var elementsType = Object.prototype.toString.call(elements); var isCollectionTyped = "[object Array]" === elementsType || "[object NodeList]" === elementsType || "[object HTMLCollection]" === elementsType || "[object Object]" === elementsType || "undefined" !== typeof jQuery && elements instanceof jQuery || "undefined" !== typeof Elements && elements instanceof Elements; var i2 = 0, j = elements.length; if (isCollectionTyped) { for (; i2 < j; i2++) { callback(elements[i2]); } } else { callback(elements); } } function getElementSize(element) { if (!element.getBoundingClientRect) { return { width: element.offsetWidth, height: element.offsetHeight }; } var rect2 = element.getBoundingClientRect(); return { width: Math.round(rect2.width), height: Math.round(rect2.height) }; } function setStyle(element, style) { Object.keys(style).forEach(function(key) { element.style[key] = style[key]; }); } var ResizeSensor2 = function(element, callback) { var lastAnimationFrameForInvisibleCheck = 0; function EventQueue() { var q2 = []; this.add = function(ev) { q2.push(ev); }; var i2, j; this.call = function(sizeInfo) { for (i2 = 0, j = q2.length; i2 < j; i2++) { q2[i2].call(this, sizeInfo); } }; this.remove = function(ev) { var newQueue = []; for (i2 = 0, j = q2.length; i2 < j; i2++) { if (q2[i2] !== ev) newQueue.push(q2[i2]); } q2 = newQueue; }; this.length = function() { return q2.length; }; } function attachResizeEvent(element2, resized) { if (!element2) return; if (element2.resizedAttached) { element2.resizedAttached.add(resized); return; } element2.resizedAttached = new EventQueue(); element2.resizedAttached.add(resized); element2.resizeSensor = document.createElement("div"); element2.resizeSensor.dir = "ltr"; element2.resizeSensor.className = "resize-sensor"; var style = { pointerEvents: "none", position: "absolute", left: "0px", top: "0px", right: "0px", bottom: "0px", overflow: "hidden", zIndex: "-1", visibility: "hidden", maxWidth: "100%" }; var styleChild = { position: "absolute", left: "0px", top: "0px", transition: "0s" }; setStyle(element2.resizeSensor, style); var expand = document.createElement("div"); expand.className = "resize-sensor-expand"; setStyle(expand, style); var expandChild = document.createElement("div"); setStyle(expandChild, styleChild); expand.appendChild(expandChild); var shrink = document.createElement("div"); shrink.className = "resize-sensor-shrink"; setStyle(shrink, style); var shrinkChild = document.createElement("div"); setStyle(shrinkChild, styleChild); setStyle(shrinkChild, { width: "200%", height: "200%" }); shrink.appendChild(shrinkChild); element2.resizeSensor.appendChild(expand); element2.resizeSensor.appendChild(shrink); element2.appendChild(element2.resizeSensor); var computedStyle = window.getComputedStyle(element2); var position = computedStyle ? computedStyle.getPropertyValue("position") : null; if ("absolute" !== position && "relative" !== position && "fixed" !== position && "sticky" !== position) { element2.style.position = "relative"; } var dirty = false; var rafId = 0; var size = getElementSize(element2); var lastWidth = 0; var lastHeight = 0; var initialHiddenCheck = true; lastAnimationFrameForInvisibleCheck = 0; var resetExpandShrink = function() { var width = element2.offsetWidth; var height = element2.offsetHeight; expandChild.style.width = width + 10 + "px"; expandChild.style.height = height + 10 + "px"; expand.scrollLeft = width + 10; expand.scrollTop = height + 10; shrink.scrollLeft = width + 10; shrink.scrollTop = height + 10; }; var reset = function() { if (initialHiddenCheck) { var invisible = element2.offsetWidth === 0 && element2.offsetHeight === 0; if (invisible) { if (!lastAnimationFrameForInvisibleCheck) { lastAnimationFrameForInvisibleCheck = requestAnimationFrame2(function() { lastAnimationFrameForInvisibleCheck = 0; reset(); }); } return; } else { initialHiddenCheck = false; } } resetExpandShrink(); }; element2.resizeSensor.resetSensor = reset; var onResized = function() { rafId = 0; if (!dirty) return; lastWidth = size.width; lastHeight = size.height; if (element2.resizedAttached) { element2.resizedAttached.call(size); } }; var onScroll = function() { size = getElementSize(element2); dirty = size.width !== lastWidth || size.height !== lastHeight; if (dirty && !rafId) { rafId = requestAnimationFrame2(onResized); } reset(); }; var addEvent = function(el2, name, cb) { if (el2.attachEvent) { el2.attachEvent("on" + name, cb); } else { el2.addEventListener(name, cb); } }; addEvent(expand, "scroll", onScroll); addEvent(shrink, "scroll", onScroll); lastAnimationFrameForInvisibleCheck = requestAnimationFrame2(function() { lastAnimationFrameForInvisibleCheck = 0; reset(); }); } forEachElement(element, function(elem) { attachResizeEvent(elem, callback); }); this.detach = function(ev) { if (!lastAnimationFrameForInvisibleCheck) { cancelAnimationFrame(lastAnimationFrameForInvisibleCheck); lastAnimationFrameForInvisibleCheck = 0; } ResizeSensor2.detach(element, ev); }; this.reset = function() { element.resizeSensor.resetSensor(); }; }; ResizeSensor2.reset = function(element) { forEachElement(element, function(elem) { elem.resizeSensor.resetSensor(); }); }; ResizeSensor2.detach = function(element, ev) { forEachElement(element, function(elem) { if (!elem) return; if (elem.resizedAttached && typeof ev === "function") { elem.resizedAttached.remove(ev); if (elem.resizedAttached.length()) return; } if (elem.resizeSensor) { if (elem.contains(elem.resizeSensor)) { elem.removeChild(elem.resizeSensor); } delete elem.resizeSensor; delete elem.resizedAttached; } }); }; if (typeof MutationObserver !== "undefined") { var observer = new MutationObserver(function(mutations) { for (var i2 in mutations) { if (mutations.hasOwnProperty(i2)) { var items2 = mutations[i2].addedNodes; for (var j = 0; j < items2.length; j++) { if (items2[j].resizeSensor) { ResizeSensor2.reset(items2[j]); } } } } }); document.addEventListener("DOMContentLoaded", function(event) { observer.observe(document.body, { childList: true, subtree: true }); }); } return ResizeSensor2; }); })(ResizeSensor$1); return ResizeSensor$1.exports; } var ElementQueries$1 = { exports: {} }; var ElementQueries = ElementQueries$1.exports; var hasRequiredElementQueries; function requireElementQueries() { if (hasRequiredElementQueries) return ElementQueries$1.exports; hasRequiredElementQueries = 1; (function(module2, exports3) { (function(root2, factory) { { module2.exports = factory(requireResizeSensor()); } })(typeof window !== "undefined" ? window : ElementQueries, function(ResizeSensor2) { var ElementQueries2 = function() { var cssStyleElement; var allQueries = {}; var idToSelectorMapping = []; function getEmSize(element) { if (!element) { element = document.documentElement; } var fontSize = window.getComputedStyle(element, null).fontSize; return parseFloat(fontSize) || 16; } function getElementSize(element) { if (!element.getBoundingClientRect) { return { width: element.offsetWidth, height: element.offsetHeight }; } var rect2 = element.getBoundingClientRect(); return { width: Math.round(rect2.width), height: Math.round(rect2.height) }; } function convertToPx(element, value) { var numbers2 = value.split(/\d/); var units = numbers2[numbers2.length - 1]; value = parseFloat(value); switch (units) { case "px": return value; case "em": return value * getEmSize(element); case "rem": return value * getEmSize(); // Viewport units! // According to http://quirksmode.org/mobile/tableViewport.html // documentElement.clientWidth/Height gets us the most reliable info case "vw": return value * document.documentElement.clientWidth / 100; case "vh": return value * document.documentElement.clientHeight / 100; case "vmin": case "vmax": var vw = document.documentElement.clientWidth / 100; var vh = document.documentElement.clientHeight / 100; var chooser = Math[units === "vmin" ? "min" : "max"]; return value * chooser(vw, vh); default: return value; } } function SetupInformation(element, id2) { this.element = element; var key, option, elementSize, value, actualValue, attrValues, attrValue, attrName; var attributes2 = ["min-width", "min-height", "max-width", "max-height"]; this.call = function() { elementSize = getElementSize(this.element); attrValues = {}; for (key in allQueries[id2]) { if (!allQueries[id2].hasOwnProperty(key)) { continue; } option = allQueries[id2][key]; value = convertToPx(this.element, option.value); actualValue = option.property === "width" ? elementSize.width : elementSize.height; attrName = option.mode + "-" + option.property; attrValue = ""; if (option.mode === "min" && actualValue >= value) { attrValue += option.value; } if (option.mode === "max" && actualValue <= value) { attrValue += option.value; } if (!attrValues[attrName]) attrValues[attrName] = ""; if (attrValue && -1 === (" " + attrValues[attrName] + " ").indexOf(" " + attrValue + " ")) { attrValues[attrName] += " " + attrValue; } } for (var k in attributes2) { if (!attributes2.hasOwnProperty(k)) continue; if (attrValues[attributes2[k]]) { this.element.setAttribute(attributes2[k], attrValues[attributes2[k]].substr(1)); } else { this.element.removeAttribute(attributes2[k]); } } }; } function setupElement(element, id2) { if (!element.elementQueriesSetupInformation) { element.elementQueriesSetupInformation = new SetupInformation(element, id2); } if (!element.elementQueriesSensor) { element.elementQueriesSensor = new ResizeSensor2(element, function() { element.elementQueriesSetupInformation.call(); }); } } function queueQuery(selector2, mode, property2, value) { if (typeof allQueries[selector2] === "undefined") { allQueries[selector2] = []; var id2 = idToSelectorMapping.length; cssStyleElement.innerHTML += "\n" + selector2 + " {animation: 0.1s element-queries;}"; cssStyleElement.innerHTML += "\n" + selector2 + " > .resize-sensor {min-width: " + id2 + "px;}"; idToSelectorMapping.push(selector2); } allQueries[selector2].push({ mode, property: property2, value }); } function getQuery(container) { var query; if (document.querySelectorAll) query = container ? container.querySelectorAll.bind(container) : document.querySelectorAll.bind(document); if (!query && "undefined" !== typeof $$) query = $$; if (!query && "undefined" !== typeof jQuery) query = jQuery; if (!query) { throw "No document.querySelectorAll, jQuery or Mootools's $$ found."; } return query; } function findElementQueriesElements(container) { var query = getQuery(container); for (var selector2 in allQueries) if (allQueries.hasOwnProperty(selector2)) { var elements = query(selector2, container); for (var i2 = 0, j = elements.length; i2 < j; i2++) { setupElement(elements[i2], selector2); } } } function attachResponsiveImage(element) { var children2 = []; var rules2 = []; var sources = []; var defaultImageId = 0; var lastActiveImage = -1; var loadedImages = []; for (var i2 in element.children) { if (!element.children.hasOwnProperty(i2)) continue; if (element.children[i2].tagName && element.children[i2].tagName.toLowerCase() === "img") { children2.push(element.children[i2]); var minWidth = element.children[i2].getAttribute("min-width") || element.children[i2].getAttribute("data-min-width"); var src2 = element.children[i2].getAttribute("data-src") || element.children[i2].getAttribute("url"); sources.push(src2); var rule = { minWidth }; rules2.push(rule); if (!minWidth) { defaultImageId = children2.length - 1; element.children[i2].style.display = "block"; } else { element.children[i2].style.display = "none"; } } } lastActiveImage = defaultImageId; function check2() { var imageToDisplay = false, i3; for (i3 in children2) { if (!children2.hasOwnProperty(i3)) continue; if (rules2[i3].minWidth) { if (element.offsetWidth > rules2[i3].minWidth) { imageToDisplay = i3; } } } if (!imageToDisplay) { imageToDisplay = defaultImageId; } if (lastActiveImage !== imageToDisplay) { if (!loadedImages[imageToDisplay]) { var image2 = new Image(); image2.onload = function() { children2[imageToDisplay].src = sources[imageToDisplay]; children2[lastActiveImage].style.display = "none"; children2[imageToDisplay].style.display = "block"; loadedImages[imageToDisplay] = true; lastActiveImage = imageToDisplay; }; image2.src = sources[imageToDisplay]; } else { children2[lastActiveImage].style.display = "none"; children2[imageToDisplay].style.display = "block"; lastActiveImage = imageToDisplay; } } else { children2[imageToDisplay].src = sources[imageToDisplay]; } } element.resizeSensorInstance = new ResizeSensor2(element, check2); check2(); } function findResponsiveImages() { var query = getQuery(); var elements = query("[data-responsive-image],[responsive-image]"); for (var i2 = 0, j = elements.length; i2 < j; i2++) { attachResponsiveImage(elements[i2]); } } var regex = /,?[\s\t]*([^,\n]*?)((?:\[[\s\t]*?(?:min|max)-(?:width|height)[\s\t]*?[~$\^]?=[\s\t]*?"[^"]*?"[\s\t]*?])+)([^,\n\s\{]*)/mgi; var attrRegex = /\[[\s\t]*?(min|max)-(width|height)[\s\t]*?[~$\^]?=[\s\t]*?"([^"]*?)"[\s\t]*?]/mgi; function extractQuery(css2) { var match, smatch, attrs, attrMatch; css2 = css2.replace(/'/g, '"'); while (null !== (match = regex.exec(css2))) { smatch = match[1] + match[3]; attrs = match[2]; while (null !== (attrMatch = attrRegex.exec(attrs))) { queueQuery(smatch, attrMatch[1], attrMatch[2], attrMatch[3]); } } } function readRules(rules2) { var selector2 = ""; if (!rules2) { return; } if ("string" === typeof rules2) { rules2 = rules2.toLowerCase(); if (-1 !== rules2.indexOf("min-width") || -1 !== rules2.indexOf("max-width")) { extractQuery(rules2); } } else { for (var i2 = 0, j = rules2.length; i2 < j; i2++) { if (1 === rules2[i2].type) { selector2 = rules2[i2].selectorText || rules2[i2].cssText; if (-1 !== selector2.indexOf("min-height") || -1 !== selector2.indexOf("max-height")) { extractQuery(selector2); } else if (-1 !== selector2.indexOf("min-width") || -1 !== selector2.indexOf("max-width")) { extractQuery(selector2); } } else if (4 === rules2[i2].type) { readRules(rules2[i2].cssRules || rules2[i2].rules); } else if (3 === rules2[i2].type) { if (rules2[i2].styleSheet.hasOwnProperty("cssRules")) { readRules(rules2[i2].styleSheet.cssRules); } } } } } var defaultCssInjected = false; this.init = function() { var animationStart = "animationstart"; if (typeof document.documentElement.style["webkitAnimationName"] !== "undefined") { animationStart = "webkitAnimationStart"; } else if (typeof document.documentElement.style["MozAnimationName"] !== "undefined") { animationStart = "mozanimationstart"; } else if (typeof document.documentElement.style["OAnimationName"] !== "undefined") { animationStart = "oanimationstart"; } document.body.addEventListener(animationStart, function(e) { var element = e.target; var styles2 = element && window.getComputedStyle(element, null); var animationName = styles2 && styles2.getPropertyValue("animation-name"); var requiresSetup = animationName && -1 !== animationName.indexOf("element-queries"); if (requiresSetup) { element.elementQueriesSensor = new ResizeSensor2(element, function() { if (element.elementQueriesSetupInformation) { element.elementQueriesSetupInformation.call(); } }); var sensorStyles = window.getComputedStyle(element.resizeSensor, null); var id2 = sensorStyles.getPropertyValue("min-width"); id2 = parseInt(id2.replace("px", "")); setupElement(e.target, idToSelectorMapping[id2]); } }); if (!defaultCssInjected) { cssStyleElement = document.createElement("style"); cssStyleElement.type = "text/css"; cssStyleElement.innerHTML = "[responsive-image] > img, [data-responsive-image] {overflow: hidden; padding: 0; } [responsive-image] > img, [data-responsive-image] > img {width: 100%;}"; cssStyleElement.innerHTML += "\n@keyframes element-queries { 0% { visibility: inherit; } }"; document.getElementsByTagName("head")[0].appendChild(cssStyleElement); defaultCssInjected = true; } for (var i2 = 0, j = document.styleSheets.length; i2 < j; i2++) { try { if (document.styleSheets[i2].href && 0 === document.styleSheets[i2].href.indexOf("file://")) { console.warn("CssElementQueries: unable to parse local css files, " + document.styleSheets[i2].href); } readRules(document.styleSheets[i2].cssRules || document.styleSheets[i2].rules || document.styleSheets[i2].cssText); } catch (e) { } } findResponsiveImages(); }; this.findElementQueriesElements = function(container) { findElementQueriesElements(container); }; this.update = function() { this.init(); }; }; ElementQueries2.update = function() { ElementQueries2.instance.update(); }; ElementQueries2.detach = function(element) { if (element.elementQueriesSetupInformation) { element.elementQueriesSensor.detach(); delete element.elementQueriesSetupInformation; delete element.elementQueriesSensor; } else if (element.resizeSensorInstance) { element.resizeSensorInstance.detach(); delete element.resizeSensorInstance; } }; ElementQueries2.init = function() { if (!ElementQueries2.instance) { ElementQueries2.instance = new ElementQueries2(); } ElementQueries2.instance.init(); }; var domLoaded = function(callback) { if (document.addEventListener) { document.addEventListener("DOMContentLoaded", callback, false); } else if (/KHTML|WebKit|iCab/i.test(navigator.userAgent)) { var DOMLoadTimer = setInterval(function() { if (/loaded|complete/i.test(document.readyState)) { callback(); clearInterval(DOMLoadTimer); } }, 10); } else window.onload = callback; }; ElementQueries2.findElementQueriesElements = function(container) { ElementQueries2.instance.findElementQueriesElements(container); }; ElementQueries2.listen = function() { domLoaded(ElementQueries2.init); }; return ElementQueries2; }); })(ElementQueries$1); return ElementQueries$1.exports; } var cssElementQueries; var hasRequiredCssElementQueries; function requireCssElementQueries() { if (hasRequiredCssElementQueries) return cssElementQueries; hasRequiredCssElementQueries = 1; cssElementQueries = { ResizeSensor: requireResizeSensor(), ElementQueries: requireElementQueries() }; return cssElementQueries; } var cssElementQueriesExports = requireCssElementQueries(); function ascending$1(a, b) { return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN; } function bisector(f2) { let delta2 = f2; let compare = f2; if (f2.length === 1) { delta2 = (d, x) => f2(d) - x; compare = ascendingComparator(f2); } function left2(a, x, lo, hi) { if (lo == null) lo = 0; if (hi == null) hi = a.length; while (lo < hi) { const mid2 = lo + hi >>> 1; if (compare(a[mid2], x) < 0) lo = mid2 + 1; else hi = mid2; } return lo; } function right2(a, x, lo, hi) { if (lo == null) lo = 0; if (hi == null) hi = a.length; while (lo < hi) { const mid2 = lo + hi >>> 1; if (compare(a[mid2], x) > 0) hi = mid2; else lo = mid2 + 1; } return lo; } function center2(a, x, lo, hi) { if (lo == null) lo = 0; if (hi == null) hi = a.length; const i2 = left2(a, x, lo, hi - 1); return i2 > lo && delta2(a[i2 - 1], x) > -delta2(a[i2], x) ? i2 - 1 : i2; } return { left: left2, center: center2, right: right2 }; } function ascendingComparator(f2) { return (d, x) => ascending$1(f2(d), x); } function number$3(x) { return x === null ? NaN : +x; } function* numbers(values, valueof) { if (valueof === void 0) { for (let value of values) { if (value != null && (value = +value) >= value) { yield value; } } } else { let index2 = -1; for (let value of values) { if ((value = valueof(value, ++index2, values)) != null && (value = +value) >= value) { yield value; } } } } const ascendingBisect = bisector(ascending$1); const bisectRight = ascendingBisect.right; const bisectLeft = ascendingBisect.left; const bisectCenter = bisector(number$3).center; function count(values, valueof) { let count2 = 0; if (valueof === void 0) { for (let value of values) { if (value != null && (value = +value) >= value) { ++count2; } } } else { let index2 = -1; for (let value of values) { if ((value = valueof(value, ++index2, values)) != null && (value = +value) >= value) { ++count2; } } } return count2; } function length$2(array2) { return array2.length | 0; } function empty$3(length2) { return !(length2 > 0); } function arrayify(values) { return typeof values !== "object" || "length" in values ? values : Array.from(values); } function reducer$1(reduce2) { return (values) => reduce2(...values); } function cross$2(...values) { const reduce2 = typeof values[values.length - 1] === "function" && reducer$1(values.pop()); values = values.map(arrayify); const lengths = values.map(length$2); const j = values.length - 1; const index2 = new Array(j + 1).fill(0); const product = []; if (j < 0 || lengths.some(empty$3)) return product; while (true) { product.push(index2.map((j2, i3) => values[i3][j2])); let i2 = j; while (++index2[i2] === lengths[i2]) { if (i2 === 0) return reduce2 ? product.map(reduce2) : product; index2[i2--] = 0; } } } function cumsum$1(values, valueof) { var sum2 = 0, index2 = 0; return Float64Array.from(values, valueof === void 0 ? (v) => sum2 += +v || 0 : (v) => sum2 += +valueof(v, index2++, values) || 0); } function descending(a, b) { return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN; } function variance(values, valueof) { let count2 = 0; let delta2; let mean2 = 0; let sum2 = 0; if (valueof === void 0) { for (let value of values) { if (value != null && (value = +value) >= value) { delta2 = value - mean2; mean2 += delta2 / ++count2; sum2 += delta2 * (value - mean2); } } } else { let index2 = -1; for (let value of values) { if ((value = valueof(value, ++index2, values)) != null && (value = +value) >= value) { delta2 = value - mean2; mean2 += delta2 / ++count2; sum2 += delta2 * (value - mean2); } } } if (count2 > 1) return sum2 / (count2 - 1); } function deviation(values, valueof) { const v = variance(values, valueof); return v ? Math.sqrt(v) : v; } function extent$1(values, valueof) { let min2; let max2; if (valueof === void 0) { for (const value of values) { if (value != null) { if (min2 === void 0) { if (value >= value) min2 = max2 = value; } else { if (min2 > value) min2 = value; if (max2 < value) max2 = value; } } } } else { let index2 = -1; for (let value of values) { if ((value = valueof(value, ++index2, values)) != null) { if (min2 === void 0) { if (value >= value) min2 = max2 = value; } else { if (min2 > value) min2 = value; if (max2 < value) max2 = value; } } } } return [min2, max2]; } function _classCallCheck$1E(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } function _defineProperties$1w(e, r2) { for (var t = 0; t < r2.length; t++) { var o = r2[t]; o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey$1w(o.key), o); } } function _createClass$1E(e, r2, t) { return r2 && _defineProperties$1w(e.prototype, r2), Object.defineProperty(e, "prototype", { writable: false }), e; } function _toPropertyKey$1w(t) { var i2 = _toPrimitive$1w(t, "string"); return "symbol" == typeof i2 ? i2 : i2 + ""; } function _toPrimitive$1w(t, r2) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i2 = e.call(t, r2); if ("object" != typeof i2) return i2; throw new TypeError("@@toPrimitive must return a primitive value."); } return String(t); } let Adder = /* @__PURE__ */ (function() { function Adder2() { _classCallCheck$1E(this, Adder2); this._partials = new Float64Array(32); this._n = 0; } return _createClass$1E(Adder2, [{ key: "add", value: function add2(x) { const p = this._partials; let i2 = 0; for (let j = 0; j < this._n && j < 32; j++) { const y = p[j], hi = x + y, lo = Math.abs(x) < Math.abs(y) ? x - (hi - y) : y - (hi - x); if (lo) p[i2++] = lo; x = hi; } p[i2] = x; this._n = i2 + 1; return this; } }, { key: "valueOf", value: function valueOf() { const p = this._partials; let n = this._n, x, y, lo, hi = 0; if (n > 0) { hi = p[--n]; while (n > 0) { x = hi; y = p[--n]; hi = x + y; lo = y - (hi - x); if (lo) break; } if (n > 0 && (lo < 0 && p[n - 1] < 0 || lo > 0 && p[n - 1] > 0)) { y = lo * 2; x = hi + y; if (y == x - hi) hi = x; } } return hi; } }]); })(); function fsum(values, valueof) { const adder = new Adder(); if (valueof === void 0) { for (let value of values) { if (value = +value) { adder.add(value); } } } else { let index2 = -1; for (let value of values) { if (value = +valueof(value, ++index2, values)) { adder.add(value); } } } return +adder; } function fcumsum(values, valueof) { const adder = new Adder(); let index2 = -1; return Float64Array.from(values, valueof === void 0 ? (v) => adder.add(+v || 0) : (v) => adder.add(+valueof(v, ++index2, values) || 0)); } function _classCallCheck$1D(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } function _defineProperties$1v(e, r2) { for (var t = 0; t < r2.length; t++) { var o = r2[t]; o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey$1v(o.key), o); } } function _createClass$1D(e, r2, t) { return r2 && _defineProperties$1v(e.prototype, r2), Object.defineProperty(e, "prototype", { writable: false }), e; } function _toPropertyKey$1v(t) { var i2 = _toPrimitive$1v(t, "string"); return "symbol" == typeof i2 ? i2 : i2 + ""; } function _toPrimitive$1v(t, r2) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i2 = e.call(t, r2); if ("object" != typeof i2) return i2; throw new TypeError("@@toPrimitive must return a primitive value."); } return String(t); } function _callSuper$1h(t, o, e) { return o = _getPrototypeOf$1h(o), _possibleConstructorReturn$1p(t, _isNativeReflectConstruct$1h() ? Reflect.construct(o, [], _getPrototypeOf$1h(t).constructor) : o.apply(t, e)); } function _possibleConstructorReturn$1p(t, e) { if (e && ("object" == typeof e || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized$1h(t); } function _assertThisInitialized$1h(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; } function _superPropGet$F(t, o, e, r2) { var p = _get$F(_getPrototypeOf$1h(t.prototype), o, e); return 2 & r2 && "function" == typeof p ? function(t4) { return p.apply(e, t4); } : p; } function _get$F() { return _get$F = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function(e, t, r2) { var p = _superPropBase$F(e, t); if (p) { var n = Object.getOwnPropertyDescriptor(p, t); return n.get ? n.get.call(arguments.length < 3 ? e : r2) : n.value; } }, _get$F.apply(null, arguments); } function _superPropBase$F(t, o) { for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf$1h(t)); ) ; return t; } function _inherits$1p(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: true, configurable: true } }), Object.defineProperty(t, "prototype", { writable: false }), e && _setPrototypeOf$1h(t, e); } function _wrapNativeSuper$1(t) { var r2 = "function" == typeof Map ? /* @__PURE__ */ new Map() : void 0; return _wrapNativeSuper$1 = function(t4) { if (null === t4 || !_isNativeFunction$1(t4)) return t4; if ("function" != typeof t4) throw new TypeError("Super expression must either be null or a function"); if (void 0 !== r2) { if (r2.has(t4)) return r2.get(t4); r2.set(t4, Wrapper); } function Wrapper() { return _construct$1(t4, arguments, _getPrototypeOf$1h(this).constructor); } return Wrapper.prototype = Object.create(t4.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }), _setPrototypeOf$1h(Wrapper, t4); }, _wrapNativeSuper$1(t); } function _construct$1(t, e, r2) { if (_isNativeReflectConstruct$1h()) return Reflect.construct.apply(null, arguments); var o = [null]; o.push.apply(o, e); var p = new (t.bind.apply(t, o))(); return r2 && _setPrototypeOf$1h(p, r2.prototype), p; } function _isNativeReflectConstruct$1h() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() { })); } catch (t4) { } return (_isNativeReflectConstruct$1h = function() { return !!t; })(); } function _isNativeFunction$1(t) { try { return -1 !== Function.toString.call(t).indexOf("[native code]"); } catch (n) { return "function" == typeof t; } } function _setPrototypeOf$1h(t, e) { return _setPrototypeOf$1h = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(t4, e3) { return t4.__proto__ = e3, t4; }, _setPrototypeOf$1h(t, e); } function _getPrototypeOf$1h(t) { return _getPrototypeOf$1h = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(t4) { return t4.__proto__ || Object.getPrototypeOf(t4); }, _getPrototypeOf$1h(t); } let InternMap = /* @__PURE__ */ (function(_Map) { function InternMap2(entries, key = keyof) { var _this; _classCallCheck$1D(this, InternMap2); _this = _callSuper$1h(this, InternMap2); Object.defineProperties(_this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: key } }); if (entries != null) for (const [key2, value] of entries) _this.set(key2, value); return _this; } _inherits$1p(InternMap2, _Map); return _createClass$1D(InternMap2, [{ key: "get", value: function get2(key) { return _superPropGet$F(InternMap2, "get", this, 3)([intern_get(this, key)]); } }, { key: "has", value: function has(key) { return _superPropGet$F(InternMap2, "has", this, 3)([intern_get(this, key)]); } }, { key: "set", value: function set2(key, value) { return _superPropGet$F(InternMap2, "set", this, 3)([intern_set(this, key), value]); } }, { key: "delete", value: function _delete(key) { return _superPropGet$F(InternMap2, "delete", this, 3)([intern_delete(this, key)]); } }]); })(/* @__PURE__ */ _wrapNativeSuper$1(Map)); let InternSet = /* @__PURE__ */ (function(_Set) { function InternSet2(values, key = keyof) { var _this2; _classCallCheck$1D(this, InternSet2); _this2 = _callSuper$1h(this, InternSet2); Object.defineProperties(_this2, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: key } }); if (values != null) for (const value of values) _this2.add(value); return _this2; } _inherits$1p(InternSet2, _Set); return _createClass$1D(InternSet2, [{ key: "has", value: function has(value) { return _superPropGet$F(InternSet2, "has", this, 3)([intern_get(this, value)]); } }, { key: "add", value: function add2(value) { return _superPropGet$F(InternSet2, "add", this, 3)([intern_set(this, value)]); } }, { key: "delete", value: function _delete(value) { return _superPropGet$F(InternSet2, "delete", this, 3)([intern_delete(this, value)]); } }]); })(/* @__PURE__ */ _wrapNativeSuper$1(Set)); function intern_get({ _intern, _key }, value) { const key = _key(value); return _intern.has(key) ? _intern.get(key) : value; } function intern_set({ _intern, _key }, value) { const key = _key(value); if (_intern.has(key)) return _intern.get(key); _intern.set(key, value); return value; } function intern_delete({ _intern, _key }, value) { const key = _key(value); if (_intern.has(key)) { value = _intern.get(value); _intern.delete(key); } return value; } function keyof(value) { return value !== null && typeof value === "object" ? value.valueOf() : value; } function identity$a(x) { return x; } function group(values, ...keys2) { return nest(values, identity$a, identity$a, keys2); } function groups(values, ...keys2) { return nest(values, Array.from, identity$a, keys2); } function rollup(values, reduce2, ...keys2) { return nest(values, identity$a, reduce2, keys2); } function rollups(values, reduce2, ...keys2) { return nest(values, Array.from, reduce2, keys2); } function index$1(values, ...keys2) { return nest(values, identity$a, unique, keys2); } function indexes(values, ...keys2) { return nest(values, Array.from, unique, keys2); } function unique(values) { if (values.length !== 1) throw new Error("duplicate key"); return values[0]; } function nest(values, map2, reduce2, keys2) { return (function regroup(values2, i2) { if (i2 >= keys2.length) return reduce2(values2); const groups2 = new InternMap(); const keyof2 = keys2[i2++]; let index2 = -1; for (const value of values2) { const key = keyof2(value, ++index2, values2); const group2 = groups2.get(key); if (group2) group2.push(value); else groups2.set(key, [value]); } for (const [key, values3] of groups2) { groups2.set(key, regroup(values3, i2)); } return map2(groups2); })(values, 0); } function permute(source, keys2) { return Array.from(keys2, (key) => source[key]); } function sort$2(values, ...F) { if (typeof values[Symbol.iterator] !== "function") throw new TypeError("values is not iterable"); values = Array.from(values); let [f2 = ascending$1] = F; if (f2.length === 1 || F.length > 1) { const index2 = Uint32Array.from(values, (d, i2) => i2); if (F.length > 1) { F = F.map((f3) => values.map(f3)); index2.sort((i2, j) => { for (const f3 of F) { const c = ascending$1(f3[i2], f3[j]); if (c) return c; } }); } else { f2 = values.map(f2); index2.sort((i2, j) => ascending$1(f2[i2], f2[j])); } return permute(values, index2); } return values.sort(f2); } function groupSort(values, reduce2, key) { return (reduce2.length === 1 ? sort$2(rollup(values, reduce2, key), ([ak, av], [bk, bv]) => ascending$1(av, bv) || ascending$1(ak, bk)) : sort$2(group(values, key), ([ak, av], [bk, bv]) => reduce2(av, bv) || ascending$1(ak, bk))).map(([key2]) => key2); } var array$1 = Array.prototype; var slice$2 = array$1.slice; function constant$7(x) { return function() { return x; }; } var e10 = Math.sqrt(50), e5 = Math.sqrt(10), e2 = Math.sqrt(2); function ticks(start2, stop, count2) { var reverse2, i2 = -1, n, ticks2, step; stop = +stop, start2 = +start2, count2 = +count2; if (start2 === stop && count2 > 0) return [start2]; if (reverse2 = stop < start2) n = start2, start2 = stop, stop = n; if ((step = tickIncrement(start2, stop, count2)) === 0 || !isFinite(step)) return []; if (step > 0) { let r0 = Math.round(start2 / step), r1 = Math.round(stop / step); if (r0 * step < start2) ++r0; if (r1 * step > stop) --r1; ticks2 = new Array(n = r1 - r0 + 1); while (++i2 < n) ticks2[i2] = (r0 + i2) * step; } else { step = -step; let r0 = Math.round(start2 * step), r1 = Math.round(stop * step); if (r0 / step < start2) ++r0; if (r1 / step > stop) --r1; ticks2 = new Array(n = r1 - r0 + 1); while (++i2 < n) ticks2[i2] = (r0 + i2) / step; } if (reverse2) ticks2.reverse(); return ticks2; } function tickIncrement(start2, stop, count2) { var step = (stop - start2) / Math.max(0, count2), power = Math.floor(Math.log(step) / Math.LN10), error = step / Math.pow(10, power); return power >= 0 ? (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1) * Math.pow(10, power) : -Math.pow(10, -power) / (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1); } function tickStep(start2, stop, count2) { var step0 = Math.abs(stop - start2) / Math.max(0, count2), step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10)), error = step0 / step1; if (error >= e10) step1 *= 10; else if (error >= e5) step1 *= 5; else if (error >= e2) step1 *= 2; return stop < start2 ? -step1 : step1; } function nice$1(start2, stop, count2) { let prestep; while (true) { const step = tickIncrement(start2, stop, count2); if (step === prestep || step === 0 || !isFinite(step)) { return [start2, stop]; } else if (step > 0) { start2 = Math.floor(start2 / step) * step; stop = Math.ceil(stop /