UNPKG

ivt

Version:

Ivt Components Library

1,691 lines (1,643 loc) 623 kB
import * as React from 'react'; import React__default, { isValidElement, forwardRef, useContext, createContext, PureComponent, useState, useCallback, useMemo, useRef, useImperativeHandle, useEffect, cloneElement, createElement } from 'react'; import { a as clsx, c as cn } from '../chunks/utils-05LlW3Cl.mjs'; import { createPortal } from 'react-dom'; import { g as getDefaultExportFromCjs } from '../chunks/_commonjsHelpers-9sDwrKIv.mjs'; import { r as requireShim } from '../chunks/index-korrz_kD.mjs'; import '../chunks/bundle-mjs-BYcyWisL.mjs'; var EventKeys = [ 'dangerouslySetInnerHTML', 'onCopy', 'onCopyCapture', 'onCut', 'onCutCapture', 'onPaste', 'onPasteCapture', 'onCompositionEnd', 'onCompositionEndCapture', 'onCompositionStart', 'onCompositionStartCapture', 'onCompositionUpdate', 'onCompositionUpdateCapture', 'onFocus', 'onFocusCapture', 'onBlur', 'onBlurCapture', 'onChange', 'onChangeCapture', 'onBeforeInput', 'onBeforeInputCapture', 'onInput', 'onInputCapture', 'onReset', 'onResetCapture', 'onSubmit', 'onSubmitCapture', 'onInvalid', 'onInvalidCapture', 'onLoad', 'onLoadCapture', 'onError', 'onErrorCapture', 'onKeyDown', 'onKeyDownCapture', 'onKeyPress', 'onKeyPressCapture', 'onKeyUp', 'onKeyUpCapture', 'onAbort', 'onAbortCapture', 'onCanPlay', 'onCanPlayCapture', 'onCanPlayThrough', 'onCanPlayThroughCapture', 'onDurationChange', 'onDurationChangeCapture', 'onEmptied', 'onEmptiedCapture', 'onEncrypted', 'onEncryptedCapture', 'onEnded', 'onEndedCapture', 'onLoadedData', 'onLoadedDataCapture', 'onLoadedMetadata', 'onLoadedMetadataCapture', 'onLoadStart', 'onLoadStartCapture', 'onPause', 'onPauseCapture', 'onPlay', 'onPlayCapture', 'onPlaying', 'onPlayingCapture', 'onProgress', 'onProgressCapture', 'onRateChange', 'onRateChangeCapture', 'onSeeked', 'onSeekedCapture', 'onSeeking', 'onSeekingCapture', 'onStalled', 'onStalledCapture', 'onSuspend', 'onSuspendCapture', 'onTimeUpdate', 'onTimeUpdateCapture', 'onVolumeChange', 'onVolumeChangeCapture', 'onWaiting', 'onWaitingCapture', 'onAuxClick', 'onAuxClickCapture', 'onClick', 'onClickCapture', 'onContextMenu', 'onContextMenuCapture', 'onDoubleClick', 'onDoubleClickCapture', 'onDrag', 'onDragCapture', 'onDragEnd', 'onDragEndCapture', 'onDragEnter', 'onDragEnterCapture', 'onDragExit', 'onDragExitCapture', 'onDragLeave', 'onDragLeaveCapture', 'onDragOver', 'onDragOverCapture', 'onDragStart', 'onDragStartCapture', 'onDrop', 'onDropCapture', 'onMouseDown', 'onMouseDownCapture', 'onMouseEnter', 'onMouseLeave', 'onMouseMove', 'onMouseMoveCapture', 'onMouseOut', 'onMouseOutCapture', 'onMouseOver', 'onMouseOverCapture', 'onMouseUp', 'onMouseUpCapture', 'onSelect', 'onSelectCapture', 'onTouchCancel', 'onTouchCancelCapture', 'onTouchEnd', 'onTouchEndCapture', 'onTouchMove', 'onTouchMoveCapture', 'onTouchStart', 'onTouchStartCapture', 'onPointerDown', 'onPointerDownCapture', 'onPointerMove', 'onPointerMoveCapture', 'onPointerUp', 'onPointerUpCapture', 'onPointerCancel', 'onPointerCancelCapture', 'onPointerEnter', 'onPointerEnterCapture', 'onPointerLeave', 'onPointerLeaveCapture', 'onPointerOver', 'onPointerOverCapture', 'onPointerOut', 'onPointerOutCapture', 'onGotPointerCapture', 'onGotPointerCaptureCapture', 'onLostPointerCapture', 'onLostPointerCaptureCapture', 'onScroll', 'onScrollCapture', 'onWheel', 'onWheelCapture', 'onAnimationStart', 'onAnimationStartCapture', 'onAnimationEnd', 'onAnimationEndCapture', 'onAnimationIteration', 'onAnimationIterationCapture', 'onTransitionEnd', 'onTransitionEndCapture' ]; function isEventKey(key) { if (typeof key !== 'string') { return false; } var allowedEventKeys = EventKeys; return allowedEventKeys.includes(key); } var SVGElementPropKeys = [ 'aria-activedescendant', 'aria-atomic', 'aria-autocomplete', 'aria-busy', 'aria-checked', 'aria-colcount', 'aria-colindex', 'aria-colspan', 'aria-controls', 'aria-current', 'aria-describedby', 'aria-details', 'aria-disabled', 'aria-errormessage', 'aria-expanded', 'aria-flowto', 'aria-haspopup', 'aria-hidden', 'aria-invalid', 'aria-keyshortcuts', 'aria-label', 'aria-labelledby', 'aria-level', 'aria-live', 'aria-modal', 'aria-multiline', 'aria-multiselectable', 'aria-orientation', 'aria-owns', 'aria-placeholder', 'aria-posinset', 'aria-pressed', 'aria-readonly', 'aria-relevant', 'aria-required', 'aria-roledescription', 'aria-rowcount', 'aria-rowindex', 'aria-rowspan', 'aria-selected', 'aria-setsize', 'aria-sort', 'aria-valuemax', 'aria-valuemin', 'aria-valuenow', 'aria-valuetext', 'className', 'color', 'height', 'id', 'lang', 'max', 'media', 'method', 'min', 'name', 'style', /* * removed 'type' SVGElementPropKey because we do not currently use any SVG elements * that can use it, and it conflicts with the recharts prop 'type' * https://github.com/recharts/recharts/pull/3327 * https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/type */ // 'type', 'target', 'width', 'role', 'tabIndex', 'accentHeight', 'accumulate', 'additive', 'alignmentBaseline', 'allowReorder', 'alphabetic', 'amplitude', 'arabicForm', 'ascent', 'attributeName', 'attributeType', 'autoReverse', 'azimuth', 'baseFrequency', 'baselineShift', 'baseProfile', 'bbox', 'begin', 'bias', 'by', 'calcMode', 'capHeight', 'clip', 'clipPath', 'clipPathUnits', 'clipRule', 'colorInterpolation', 'colorInterpolationFilters', 'colorProfile', 'colorRendering', 'contentScriptType', 'contentStyleType', 'cursor', 'cx', 'cy', 'd', 'decelerate', 'descent', 'diffuseConstant', 'direction', 'display', 'divisor', 'dominantBaseline', 'dur', 'dx', 'dy', 'edgeMode', 'elevation', 'enableBackground', 'end', 'exponent', 'externalResourcesRequired', 'fill', 'fillOpacity', 'fillRule', 'filter', 'filterRes', 'filterUnits', 'floodColor', 'floodOpacity', 'focusable', 'fontFamily', 'fontSize', 'fontSizeAdjust', 'fontStretch', 'fontStyle', 'fontVariant', 'fontWeight', 'format', 'from', 'fx', 'fy', 'g1', 'g2', 'glyphName', 'glyphOrientationHorizontal', 'glyphOrientationVertical', 'glyphRef', 'gradientTransform', 'gradientUnits', 'hanging', 'horizAdvX', 'horizOriginX', 'href', 'ideographic', 'imageRendering', 'in2', 'in', 'intercept', 'k1', 'k2', 'k3', 'k4', 'k', 'kernelMatrix', 'kernelUnitLength', 'kerning', 'keyPoints', 'keySplines', 'keyTimes', 'lengthAdjust', 'letterSpacing', 'lightingColor', 'limitingConeAngle', 'local', 'markerEnd', 'markerHeight', 'markerMid', 'markerStart', 'markerUnits', 'markerWidth', 'mask', 'maskContentUnits', 'maskUnits', 'mathematical', 'mode', 'numOctaves', 'offset', 'opacity', 'operator', 'order', 'orient', 'orientation', 'origin', 'overflow', 'overlinePosition', 'overlineThickness', 'paintOrder', 'panose1', 'pathLength', 'patternContentUnits', 'patternTransform', 'patternUnits', 'pointerEvents', 'pointsAtX', 'pointsAtY', 'pointsAtZ', 'preserveAlpha', 'preserveAspectRatio', 'primitiveUnits', 'r', 'radius', 'refX', 'refY', 'renderingIntent', 'repeatCount', 'repeatDur', 'requiredExtensions', 'requiredFeatures', 'restart', 'result', 'rotate', 'rx', 'ry', 'seed', 'shapeRendering', 'slope', 'spacing', 'specularConstant', 'specularExponent', 'speed', 'spreadMethod', 'startOffset', 'stdDeviation', 'stemh', 'stemv', 'stitchTiles', 'stopColor', 'stopOpacity', 'strikethroughPosition', 'strikethroughThickness', 'string', 'stroke', 'strokeDasharray', 'strokeDashoffset', 'strokeLinecap', 'strokeLinejoin', 'strokeMiterlimit', 'strokeOpacity', 'strokeWidth', 'surfaceScale', 'systemLanguage', 'tableValues', 'targetX', 'targetY', 'textAnchor', 'textDecoration', 'textLength', 'textRendering', 'to', 'transform', 'u1', 'u2', 'underlinePosition', 'underlineThickness', 'unicode', 'unicodeBidi', 'unicodeRange', 'unitsPerEm', 'vAlphabetic', 'values', 'vectorEffect', 'version', 'vertAdvY', 'vertOriginX', 'vertOriginY', 'vHanging', 'vIdeographic', 'viewTarget', 'visibility', 'vMathematical', 'widths', 'wordSpacing', 'writingMode', 'x1', 'x2', 'x', 'xChannelSelector', 'xHeight', 'xlinkActuate', 'xlinkArcrole', 'xlinkHref', 'xlinkRole', 'xlinkShow', 'xlinkTitle', 'xlinkType', 'xmlBase', 'xmlLang', 'xmlns', 'xmlnsXlink', 'xmlSpace', 'y1', 'y2', 'y', 'yChannelSelector', 'z', 'zoomAndPan', 'ref', 'key', 'angle' ]; function isSvgElementPropKey(key) { if (typeof key !== 'string') { return false; } var allowedSvgKeys = SVGElementPropKeys; return allowedSvgKeys.includes(key); } /** * Checks if the property is a data attribute. * @param key The property key. * @returns True if the key starts with 'data-', false otherwise. */ function isDataAttribute(key) { return typeof key === 'string' && key.startsWith('data-'); } /** * Filters an object to only include SVG properties. Removes all event handlers too. * @param obj - The object to filter * @returns A new object containing only valid SVG properties, excluding event handlers. */ function svgPropertiesNoEvents(obj) { var filteredEntries = Object.entries(obj).filter((_ref)=>{ var [key] = _ref; return isSvgElementPropKey(key) || isDataAttribute(key); }); return Object.fromEntries(filteredEntries); } /** * Function to filter SVG properties from various input types. * The input types can be: * - A record of string keys to any values, in which case it returns a record of only SVG properties * - A React element, in which case it returns the props of the element filtered to only SVG properties * - Anything else, in which case it returns null * * This function has a wide-open return type, because it will read and filter the props of an arbitrary React element. * This can be SVG, HTML, whatnot, with arbitrary values, so we can't type it more specifically. * * If you wish to have a type-safe version, use svgPropertiesNoEvents directly with a typed object. * * @param input - The input to filter, which can be a record, a React element, or other types. * @returns A record of SVG properties if the input is a record or React element, otherwise null. */ function svgPropertiesNoEventsFromUnknown(input) { if (input == null) { return null; } if (/*#__PURE__*/ isValidElement(input) && typeof input.props === 'object' && input.props !== null) { var p = input.props; return svgPropertiesNoEvents(p); } if (typeof input === 'object' && !Array.isArray(input)) { return svgPropertiesNoEvents(input); } return null; } /** * Filters an object to only include SVG properties, data attributes, and event handlers. * @param obj - The object to filter. * @returns A new object containing only valid SVG properties, data attributes, and event handlers. */ function svgPropertiesAndEvents(obj) { var filteredEntries = Object.entries(obj).filter((_ref)=>{ var [key] = _ref; return isSvgElementPropKey(key) || isDataAttribute(key) || isEventKey(key); }); return Object.fromEntries(filteredEntries); } var _excluded$4 = [ "children", "width", "height", "viewBox", "className", "style", "title", "desc" ]; function _extends$a() { return _extends$a = Object.assign ? Object.assign.bind() : function(n) { for(var e = 1; e < arguments.length; e++){ var t = arguments[e]; for(var r in t)({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$a.apply(null, arguments); } function _objectWithoutProperties$4(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose$4(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; } function _objectWithoutPropertiesLoose$4(r, e) { if (null == r) return {}; var t = {}; for(var n in r)if (({}).hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; } var Surface = /*#__PURE__*/ forwardRef((props, ref)=>{ var { children, width, height, viewBox, className, style, title, desc } = props, others = _objectWithoutProperties$4(props, _excluded$4); var svgView = viewBox || { width, height, x: 0, y: 0 }; var layerClass = clsx('recharts-surface', className); return /*#__PURE__*/ React.createElement("svg", _extends$a({}, svgPropertiesAndEvents(others), { className: layerClass, width: width, height: height, style: style, viewBox: "".concat(svgView.x, " ").concat(svgView.y, " ").concat(svgView.width, " ").concat(svgView.height), ref: ref }), /*#__PURE__*/ React.createElement("title", null, title), /*#__PURE__*/ React.createElement("desc", null, desc), children); }); var LegendPortalContext = /*#__PURE__*/ createContext(null); var useLegendPortal = ()=>useContext(LegendPortalContext); function constant$1(x) { return function constant() { return x; }; } const cos = Math.cos; const sin = Math.sin; const sqrt$1 = Math.sqrt; const pi$1 = Math.PI; const tau$1 = 2 * pi$1; const pi = Math.PI, tau = 2 * pi, epsilon = 1e-6, tauEpsilon = tau - epsilon; function append(strings) { this._ += strings[0]; for(let i = 1, n = strings.length; i < n; ++i){ this._ += arguments[i] + strings[i]; } } function appendRound(digits) { let d = Math.floor(digits); if (!(d >= 0)) throw new Error(`invalid digits: ${digits}`); if (d > 15) return append; const k = 10 ** d; return function(strings) { this._ += strings[0]; for(let i = 1, n = strings.length; i < n; ++i){ this._ += Math.round(arguments[i] * k) / k + strings[i]; } }; } class Path { moveTo(x, y) { this._append`M${this._x0 = this._x1 = +x},${this._y0 = this._y1 = +y}`; } closePath() { if (this._x1 !== null) { this._x1 = this._x0, this._y1 = this._y0; this._append`Z`; } } lineTo(x, y) { this._append`L${this._x1 = +x},${this._y1 = +y}`; } quadraticCurveTo(x1, y1, x, y) { this._append`Q${+x1},${+y1},${this._x1 = +x},${this._y1 = +y}`; } bezierCurveTo(x1, y1, x2, y2, x, y) { this._append`C${+x1},${+y1},${+x2},${+y2},${this._x1 = +x},${this._y1 = +y}`; } arcTo(x1, y1, x2, y2, r) { x1 = +x1, y1 = +y1, x2 = +x2, y2 = +y2, r = +r; // Is the radius negative? Error. if (r < 0) throw new Error(`negative radius: ${r}`); let x0 = this._x1, y0 = this._y1, x21 = x2 - x1, y21 = y2 - y1, x01 = x0 - x1, y01 = y0 - y1, l01_2 = x01 * x01 + y01 * y01; // Is this path empty? Move to (x1,y1). if (this._x1 === null) { this._append`M${this._x1 = x1},${this._y1 = y1}`; } else if (!(l01_2 > epsilon)) ; else if (!(Math.abs(y01 * x21 - y21 * x01) > epsilon) || !r) { this._append`L${this._x1 = x1},${this._y1 = y1}`; } else { let x20 = x2 - x0, y20 = y2 - y0, l21_2 = x21 * x21 + y21 * y21, l20_2 = x20 * x20 + y20 * y20, l21 = Math.sqrt(l21_2), l01 = Math.sqrt(l01_2), l = r * Math.tan((pi - Math.acos((l21_2 + l01_2 - l20_2) / (2 * l21 * l01))) / 2), t01 = l / l01, t21 = l / l21; // If the start tangent is not coincident with (x0,y0), line to. if (Math.abs(t01 - 1) > epsilon) { this._append`L${x1 + t01 * x01},${y1 + t01 * y01}`; } this._append`A${r},${r},0,0,${+(y01 * x20 > x01 * y20)},${this._x1 = x1 + t21 * x21},${this._y1 = y1 + t21 * y21}`; } } arc(x, y, r, a0, a1, ccw) { x = +x, y = +y, r = +r, ccw = !!ccw; // Is the radius negative? Error. if (r < 0) throw new Error(`negative radius: ${r}`); let dx = r * Math.cos(a0), dy = r * Math.sin(a0), x0 = x + dx, y0 = y + dy, cw = 1 ^ ccw, da = ccw ? a0 - a1 : a1 - a0; // Is this path empty? Move to (x0,y0). if (this._x1 === null) { this._append`M${x0},${y0}`; } else if (Math.abs(this._x1 - x0) > epsilon || Math.abs(this._y1 - y0) > epsilon) { this._append`L${x0},${y0}`; } // Is this arc empty? We’re done. if (!r) return; // Does the angle go the wrong way? Flip the direction. if (da < 0) da = da % tau + tau; // Is this a complete circle? Draw two arcs to complete the circle. if (da > tauEpsilon) { this._append`A${r},${r},0,1,${cw},${x - dx},${y - dy}A${r},${r},0,1,${cw},${this._x1 = x0},${this._y1 = y0}`; } else if (da > epsilon) { this._append`A${r},${r},0,${+(da >= pi)},${cw},${this._x1 = x + r * Math.cos(a1)},${this._y1 = y + r * Math.sin(a1)}`; } } rect(x, y, w, h) { this._append`M${this._x0 = this._x1 = +x},${this._y0 = this._y1 = +y}h${w = +w}v${+h}h${-w}Z`; } toString() { return this._; } constructor(digits){ this._x0 = this._y0 = this._x1 = this._y1 = null; // end of current subpath this._ = ""; this._append = digits == null ? append : appendRound(digits); } } function withPath(shape) { let digits = 3; shape.digits = function(_) { if (!arguments.length) return digits; if (_ == null) { digits = null; } else { const d = Math.floor(_); if (!(d >= 0)) throw new RangeError(`invalid digits: ${_}`); digits = d; } return shape; }; return ()=>new Path(digits); } function array(x) { return typeof x === "object" && "length" in x ? x // Array, TypedArray, NodeList, array-like : Array.from(x); // Map, Set, iterable, string, or anything else } function Linear(context) { this._context = context; } Linear.prototype = { areaStart: function() { this._line = 0; }, areaEnd: function() { this._line = NaN; }, lineStart: function() { this._point = 0; }, lineEnd: function() { if (this._line || this._line !== 0 && this._point === 1) this._context.closePath(); this._line = 1 - this._line; }, point: function(x, y) { x = +x, y = +y; switch(this._point){ case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; case 1: this._point = 2; // falls through default: this._context.lineTo(x, y); break; } } }; function curveLinear(context) { return new Linear(context); } function x(p) { return p[0]; } function y(p) { return p[1]; } function shapeLine(x$1, y$1) { var defined = constant$1(true), context = null, curve = curveLinear, output = null, path = withPath(line); x$1 = typeof x$1 === "function" ? x$1 : x$1 === undefined ? x : constant$1(x$1); y$1 = typeof y$1 === "function" ? y$1 : y$1 === undefined ? y : constant$1(y$1); function line(data) { var i, n = (data = array(data)).length, d, defined0 = false, buffer; if (context == null) output = curve(buffer = path()); for(i = 0; i <= n; ++i){ if (!(i < n && defined(d = data[i], i, data)) === defined0) { if (defined0 = !defined0) output.lineStart(); else output.lineEnd(); } if (defined0) output.point(+x$1(d, i, data), +y$1(d, i, data)); } if (buffer) return output = null, buffer + "" || null; } line.x = function(_) { return arguments.length ? (x$1 = typeof _ === "function" ? _ : constant$1(+_), line) : x$1; }; line.y = function(_) { return arguments.length ? (y$1 = typeof _ === "function" ? _ : constant$1(+_), line) : y$1; }; line.defined = function(_) { return arguments.length ? (defined = typeof _ === "function" ? _ : constant$1(!!_), line) : defined; }; line.curve = function(_) { return arguments.length ? (curve = _, context != null && (output = curve(context)), line) : curve; }; line.context = function(_) { return arguments.length ? (_ == null ? context = output = null : output = curve(context = _), line) : context; }; return line; } function shapeArea(x0, y0, y1) { var x1 = null, defined = constant$1(true), context = null, curve = curveLinear, output = null, path = withPath(area); x0 = typeof x0 === "function" ? x0 : x0 === undefined ? x : constant$1(+x0); y0 = typeof y0 === "function" ? y0 : y0 === undefined ? constant$1(0) : constant$1(+y0); y1 = typeof y1 === "function" ? y1 : y1 === undefined ? y : constant$1(+y1); function area(data) { var i, j, k, n = (data = array(data)).length, d, defined0 = false, buffer, x0z = new Array(n), y0z = new Array(n); if (context == null) output = curve(buffer = path()); for(i = 0; i <= n; ++i){ if (!(i < n && defined(d = data[i], i, data)) === defined0) { if (defined0 = !defined0) { j = i; output.areaStart(); output.lineStart(); } else { output.lineEnd(); output.lineStart(); for(k = i - 1; k >= j; --k){ output.point(x0z[k], y0z[k]); } output.lineEnd(); output.areaEnd(); } } if (defined0) { x0z[i] = +x0(d, i, data), y0z[i] = +y0(d, i, data); output.point(x1 ? +x1(d, i, data) : x0z[i], y1 ? +y1(d, i, data) : y0z[i]); } } if (buffer) return output = null, buffer + "" || null; } function arealine() { return shapeLine().defined(defined).curve(curve).context(context); } area.x = function(_) { return arguments.length ? (x0 = typeof _ === "function" ? _ : constant$1(+_), x1 = null, area) : x0; }; area.x0 = function(_) { return arguments.length ? (x0 = typeof _ === "function" ? _ : constant$1(+_), area) : x0; }; area.x1 = function(_) { return arguments.length ? (x1 = _ == null ? null : typeof _ === "function" ? _ : constant$1(+_), area) : x1; }; area.y = function(_) { return arguments.length ? (y0 = typeof _ === "function" ? _ : constant$1(+_), y1 = null, area) : y0; }; area.y0 = function(_) { return arguments.length ? (y0 = typeof _ === "function" ? _ : constant$1(+_), area) : y0; }; area.y1 = function(_) { return arguments.length ? (y1 = _ == null ? null : typeof _ === "function" ? _ : constant$1(+_), area) : y1; }; area.lineX0 = area.lineY0 = function() { return arealine().x(x0).y(y0); }; area.lineY1 = function() { return arealine().x(x0).y(y1); }; area.lineX1 = function() { return arealine().x(x1).y(y0); }; area.defined = function(_) { return arguments.length ? (defined = typeof _ === "function" ? _ : constant$1(!!_), area) : defined; }; area.curve = function(_) { return arguments.length ? (curve = _, context != null && (output = curve(context)), area) : curve; }; area.context = function(_) { return arguments.length ? (_ == null ? context = output = null : output = curve(context = _), area) : context; }; return area; } class Bump { areaStart() { this._line = 0; } areaEnd() { this._line = NaN; } lineStart() { this._point = 0; } lineEnd() { if (this._line || this._line !== 0 && this._point === 1) this._context.closePath(); this._line = 1 - this._line; } point(x, y) { x = +x, y = +y; switch(this._point){ case 0: { this._point = 1; if (this._line) this._context.lineTo(x, y); else this._context.moveTo(x, y); break; } case 1: this._point = 2; // falls through default: { if (this._x) this._context.bezierCurveTo(this._x0 = (this._x0 + x) / 2, this._y0, this._x0, y, x, y); else this._context.bezierCurveTo(this._x0, this._y0 = (this._y0 + y) / 2, x, this._y0, x, y); break; } } this._x0 = x, this._y0 = y; } constructor(context, x){ this._context = context; this._x = x; } } function bumpX(context) { return new Bump(context, true); } function bumpY(context) { return new Bump(context, false); } var symbolCircle = { draw (context, size) { const r = sqrt$1(size / pi$1); context.moveTo(r, 0); context.arc(0, 0, r, 0, tau$1); } }; var symbolCross = { draw (context, size) { const r = sqrt$1(size / 5) / 2; context.moveTo(-3 * r, -r); context.lineTo(-r, -r); context.lineTo(-r, -3 * r); context.lineTo(r, -3 * r); context.lineTo(r, -r); context.lineTo(3 * r, -r); context.lineTo(3 * r, r); context.lineTo(r, r); context.lineTo(r, 3 * r); context.lineTo(-r, 3 * r); context.lineTo(-r, r); context.lineTo(-3 * r, r); context.closePath(); } }; const tan30 = sqrt$1(1 / 3); const tan30_2 = tan30 * 2; var symbolDiamond = { draw (context, size) { const y = sqrt$1(size / tan30_2); const x = y * tan30; context.moveTo(0, -y); context.lineTo(x, 0); context.lineTo(0, y); context.lineTo(-x, 0); context.closePath(); } }; var symbolSquare = { draw (context, size) { const w = sqrt$1(size); const x = -w / 2; context.rect(x, x, w, w); } }; const ka = 0.89081309152928522810; const kr = sin(pi$1 / 10) / sin(7 * pi$1 / 10); const kx = sin(tau$1 / 10) * kr; const ky = -cos(tau$1 / 10) * kr; var symbolStar = { draw (context, size) { const r = sqrt$1(size * ka); const x = kx * r; const y = ky * r; context.moveTo(0, -r); context.lineTo(x, y); for(let i = 1; i < 5; ++i){ const a = tau$1 * i / 5; const c = cos(a); const s = sin(a); context.lineTo(s * r, -c * r); context.lineTo(c * x - s * y, s * x + c * y); } context.closePath(); } }; const sqrt3 = sqrt$1(3); var symbolTriangle = { draw (context, size) { const y = -sqrt$1(size / (sqrt3 * 3)); context.moveTo(0, y * 2); context.lineTo(-sqrt3 * y, -y); context.lineTo(sqrt3 * y, -y); context.closePath(); } }; const c = -0.5; const s = sqrt$1(3) / 2; const k = 1 / sqrt$1(12); const a = (k / 2 + 1) * 3; var symbolWye = { draw (context, size) { const r = sqrt$1(size / a); const x0 = r / 2, y0 = r * k; const x1 = x0, y1 = r * k + r; const x2 = -x1, y2 = y1; context.moveTo(x0, y0); context.lineTo(x1, y1); context.lineTo(x2, y2); context.lineTo(c * x0 - s * y0, s * x0 + c * y0); context.lineTo(c * x1 - s * y1, s * x1 + c * y1); context.lineTo(c * x2 - s * y2, s * x2 + c * y2); context.lineTo(c * x0 + s * y0, c * y0 - s * x0); context.lineTo(c * x1 + s * y1, c * y1 - s * x1); context.lineTo(c * x2 + s * y2, c * y2 - s * x2); context.closePath(); } }; function Symbol$1(type, size) { let context = null, path = withPath(symbol); type = typeof type === "function" ? type : constant$1(type || symbolCircle); size = typeof size === "function" ? size : constant$1(size === undefined ? 64 : +size); function symbol() { let buffer; if (!context) context = buffer = path(); type.apply(this, arguments).draw(context, +size.apply(this, arguments)); if (buffer) return context = null, buffer + "" || null; } symbol.type = function(_) { return arguments.length ? (type = typeof _ === "function" ? _ : constant$1(_), symbol) : type; }; symbol.size = function(_) { return arguments.length ? (size = typeof _ === "function" ? _ : constant$1(+_), symbol) : size; }; symbol.context = function(_) { return arguments.length ? (context = _ == null ? null : _, symbol) : context; }; return symbol; } function noop$3() {} function point$2(that, x, y) { that._context.bezierCurveTo((2 * that._x0 + that._x1) / 3, (2 * that._y0 + that._y1) / 3, (that._x0 + 2 * that._x1) / 3, (that._y0 + 2 * that._y1) / 3, (that._x0 + 4 * that._x1 + x) / 6, (that._y0 + 4 * that._y1 + y) / 6); } function Basis(context) { this._context = context; } Basis.prototype = { areaStart: function() { this._line = 0; }, areaEnd: function() { this._line = NaN; }, lineStart: function() { this._x0 = this._x1 = this._y0 = this._y1 = NaN; this._point = 0; }, lineEnd: function() { switch(this._point){ case 3: point$2(this, this._x1, this._y1); // falls through case 2: this._context.lineTo(this._x1, this._y1); break; } if (this._line || this._line !== 0 && this._point === 1) this._context.closePath(); this._line = 1 - this._line; }, point: function(x, y) { x = +x, y = +y; switch(this._point){ case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; case 1: this._point = 2; break; case 2: this._point = 3; this._context.lineTo((5 * this._x0 + this._x1) / 6, (5 * this._y0 + this._y1) / 6); // falls through default: point$2(this, x, y); break; } this._x0 = this._x1, this._x1 = x; this._y0 = this._y1, this._y1 = y; } }; function curveBasis(context) { return new Basis(context); } function BasisClosed(context) { this._context = context; } BasisClosed.prototype = { areaStart: noop$3, areaEnd: noop$3, lineStart: function() { this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = NaN; this._point = 0; }, lineEnd: function() { switch(this._point){ case 1: { this._context.moveTo(this._x2, this._y2); this._context.closePath(); break; } case 2: { this._context.moveTo((this._x2 + 2 * this._x3) / 3, (this._y2 + 2 * this._y3) / 3); this._context.lineTo((this._x3 + 2 * this._x2) / 3, (this._y3 + 2 * this._y2) / 3); this._context.closePath(); break; } case 3: { this.point(this._x2, this._y2); this.point(this._x3, this._y3); this.point(this._x4, this._y4); break; } } }, point: function(x, y) { x = +x, y = +y; switch(this._point){ case 0: this._point = 1; this._x2 = x, this._y2 = y; break; case 1: this._point = 2; this._x3 = x, this._y3 = y; break; case 2: this._point = 3; this._x4 = x, this._y4 = y; this._context.moveTo((this._x0 + 4 * this._x1 + x) / 6, (this._y0 + 4 * this._y1 + y) / 6); break; default: point$2(this, x, y); break; } this._x0 = this._x1, this._x1 = x; this._y0 = this._y1, this._y1 = y; } }; function curveBasisClosed(context) { return new BasisClosed(context); } function BasisOpen(context) { this._context = context; } BasisOpen.prototype = { areaStart: function() { this._line = 0; }, areaEnd: function() { this._line = NaN; }, lineStart: function() { this._x0 = this._x1 = this._y0 = this._y1 = NaN; this._point = 0; }, lineEnd: function() { if (this._line || this._line !== 0 && this._point === 3) this._context.closePath(); this._line = 1 - this._line; }, point: function(x, y) { x = +x, y = +y; switch(this._point){ case 0: this._point = 1; break; case 1: this._point = 2; break; case 2: this._point = 3; var x0 = (this._x0 + 4 * this._x1 + x) / 6, y0 = (this._y0 + 4 * this._y1 + y) / 6; this._line ? this._context.lineTo(x0, y0) : this._context.moveTo(x0, y0); break; case 3: this._point = 4; // falls through default: point$2(this, x, y); break; } this._x0 = this._x1, this._x1 = x; this._y0 = this._y1, this._y1 = y; } }; function curveBasisOpen(context) { return new BasisOpen(context); } function LinearClosed(context) { this._context = context; } LinearClosed.prototype = { areaStart: noop$3, areaEnd: noop$3, lineStart: function() { this._point = 0; }, lineEnd: function() { if (this._point) this._context.closePath(); }, point: function(x, y) { x = +x, y = +y; if (this._point) this._context.lineTo(x, y); else this._point = 1, this._context.moveTo(x, y); } }; function curveLinearClosed(context) { return new LinearClosed(context); } function sign(x) { return x < 0 ? -1 : 1; } // Calculate the slopes of the tangents (Hermite-type interpolation) based on // the following paper: Steffen, M. 1990. A Simple Method for Monotonic // Interpolation in One Dimension. Astronomy and Astrophysics, Vol. 239, NO. // NOV(II), P. 443, 1990. function slope3(that, x2, y2) { var h0 = that._x1 - that._x0, h1 = x2 - that._x1, s0 = (that._y1 - that._y0) / (h0 || h1 < 0 && -0), s1 = (y2 - that._y1) / (h1 || h0 < 0 && -0), p = (s0 * h1 + s1 * h0) / (h0 + h1); return (sign(s0) + sign(s1)) * Math.min(Math.abs(s0), Math.abs(s1), 0.5 * Math.abs(p)) || 0; } // Calculate a one-sided slope. function slope2(that, t) { var h = that._x1 - that._x0; return h ? (3 * (that._y1 - that._y0) / h - t) / 2 : t; } // According to https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Representations // "you can express cubic Hermite interpolation in terms of cubic Bézier curves // with respect to the four values p0, p0 + m0 / 3, p1 - m1 / 3, p1". function point$1(that, t0, t1) { var x0 = that._x0, y0 = that._y0, x1 = that._x1, y1 = that._y1, dx = (x1 - x0) / 3; that._context.bezierCurveTo(x0 + dx, y0 + dx * t0, x1 - dx, y1 - dx * t1, x1, y1); } function MonotoneX(context) { this._context = context; } MonotoneX.prototype = { areaStart: function() { this._line = 0; }, areaEnd: function() { this._line = NaN; }, lineStart: function() { this._x0 = this._x1 = this._y0 = this._y1 = this._t0 = NaN; this._point = 0; }, lineEnd: function() { switch(this._point){ case 2: this._context.lineTo(this._x1, this._y1); break; case 3: point$1(this, this._t0, slope2(this, this._t0)); break; } if (this._line || this._line !== 0 && this._point === 1) this._context.closePath(); this._line = 1 - this._line; }, point: function(x, y) { var t1 = NaN; x = +x, y = +y; if (x === this._x1 && y === this._y1) return; // Ignore coincident points. switch(this._point){ case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; case 1: this._point = 2; break; case 2: this._point = 3; point$1(this, slope2(this, t1 = slope3(this, x, y)), t1); break; default: point$1(this, this._t0, t1 = slope3(this, x, y)); break; } this._x0 = this._x1, this._x1 = x; this._y0 = this._y1, this._y1 = y; this._t0 = t1; } }; function MonotoneY(context) { this._context = new ReflectContext(context); } (MonotoneY.prototype = Object.create(MonotoneX.prototype)).point = function(x, y) { MonotoneX.prototype.point.call(this, y, x); }; function ReflectContext(context) { this._context = context; } ReflectContext.prototype = { moveTo: function(x, y) { this._context.moveTo(y, x); }, closePath: function() { this._context.closePath(); }, lineTo: function(x, y) { this._context.lineTo(y, x); }, bezierCurveTo: function(x1, y1, x2, y2, x, y) { this._context.bezierCurveTo(y1, x1, y2, x2, y, x); } }; function monotoneX(context) { return new MonotoneX(context); } function monotoneY(context) { return new MonotoneY(context); } function Natural(context) { this._context = context; } Natural.prototype = { areaStart: function() { this._line = 0; }, areaEnd: function() { this._line = NaN; }, lineStart: function() { this._x = []; this._y = []; }, lineEnd: function() { var x = this._x, y = this._y, n = x.length; if (n) { this._line ? this._context.lineTo(x[0], y[0]) : this._context.moveTo(x[0], y[0]); if (n === 2) { this._context.lineTo(x[1], y[1]); } else { var px = controlPoints(x), py = controlPoints(y); for(var i0 = 0, i1 = 1; i1 < n; ++i0, ++i1){ this._context.bezierCurveTo(px[0][i0], py[0][i0], px[1][i0], py[1][i0], x[i1], y[i1]); } } } if (this._line || this._line !== 0 && n === 1) this._context.closePath(); this._line = 1 - this._line; this._x = this._y = null; }, point: function(x, y) { this._x.push(+x); this._y.push(+y); } }; // See https://www.particleincell.com/2012/bezier-splines/ for derivation. function controlPoints(x) { var i, n = x.length - 1, m, a = new Array(n), b = new Array(n), r = new Array(n); a[0] = 0, b[0] = 2, r[0] = x[0] + 2 * x[1]; for(i = 1; i < n - 1; ++i)a[i] = 1, b[i] = 4, r[i] = 4 * x[i] + 2 * x[i + 1]; a[n - 1] = 2, b[n - 1] = 7, r[n - 1] = 8 * x[n - 1] + x[n]; for(i = 1; i < n; ++i)m = a[i] / b[i - 1], b[i] -= m, r[i] -= m * r[i - 1]; a[n - 1] = r[n - 1] / b[n - 1]; for(i = n - 2; i >= 0; --i)a[i] = (r[i] - a[i + 1]) / b[i]; b[n - 1] = (x[n] + a[n - 1]) / 2; for(i = 0; i < n - 1; ++i)b[i] = 2 * x[i + 1] - a[i + 1]; return [ a, b ]; } function curveNatural(context) { return new Natural(context); } function Step(context, t) { this._context = context; this._t = t; } Step.prototype = { areaStart: function() { this._line = 0; }, areaEnd: function() { this._line = NaN; }, lineStart: function() { this._x = this._y = NaN; this._point = 0; }, lineEnd: function() { if (0 < this._t && this._t < 1 && this._point === 2) this._context.lineTo(this._x, this._y); if (this._line || this._line !== 0 && this._point === 1) this._context.closePath(); if (this._line >= 0) this._t = 1 - this._t, this._line = 1 - this._line; }, point: function(x, y) { x = +x, y = +y; switch(this._point){ case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; case 1: this._point = 2; // falls through default: { if (this._t <= 0) { this._context.lineTo(this._x, y); this._context.lineTo(x, y); } else { var x1 = this._x * (1 - this._t) + x * this._t; this._context.lineTo(x1, this._y); this._context.lineTo(x1, y); } break; } } this._x = x, this._y = y; } }; function curveStep(context) { return new Step(context, 0.5); } function stepBefore(context) { return new Step(context, 0); } function stepAfter(context) { return new Step(context, 1); } function stackOffsetNone(series, order) { if (!((n = series.length) > 1)) return; for(var i = 1, j, s0, s1 = series[order[0]], n, m = s1.length; i < n; ++i){ s0 = s1, s1 = series[order[i]]; for(j = 0; j < m; ++j){ s1[j][1] += s1[j][0] = isNaN(s0[j][1]) ? s0[j][0] : s0[j][1]; } } } function stackOrderNone(series) { var n = series.length, o = new Array(n); while(--n >= 0)o[n] = n; return o; } function stackValue(d, key) { return d[key]; } function stackSeries(key) { const series = []; series.key = key; return series; } function shapeStack() { var keys = constant$1([]), order = stackOrderNone, offset = stackOffsetNone, value = stackValue; function stack(data) { var sz = Array.from(keys.apply(this, arguments), stackSeries), i, n = sz.length, j = -1, oz; for (const d of data){ for(i = 0, ++j; i < n; ++i){ (sz[i][j] = [ 0, +value(d, sz[i].key, j, data) ]).data = d; } } for(i = 0, oz = array(order(sz)); i < n; ++i){ sz[oz[i]].index = i; } offset(sz, oz); return sz; } stack.keys = function(_) { return arguments.length ? (keys = typeof _ === "function" ? _ : constant$1(Array.from(_)), stack) : keys; }; stack.value = function(_) { return arguments.length ? (value = typeof _ === "function" ? _ : constant$1(+_), stack) : value; }; stack.order = function(_) { return arguments.length ? (order = _ == null ? stackOrderNone : typeof _ === "function" ? _ : constant$1(Array.from(_)), stack) : order; }; stack.offset = function(_) { return arguments.length ? (offset = _ == null ? stackOffsetNone : _, stack) : offset; }; return stack; } function stackOffsetExpand(series, order) { if (!((n = series.length) > 0)) return; for(var i, n, j = 0, m = series[0].length, y; j < m; ++j){ for(y = i = 0; i < n; ++i)y += series[i][j][1] || 0; if (y) for(i = 0; i < n; ++i)series[i][j][1] /= y; } stackOffsetNone(series, order); } function stackOffsetSilhouette(series, order) { if (!((n = series.length) > 0)) return; for(var j = 0, s0 = series[order[0]], n, m = s0.length; j < m; ++j){ for(var i = 0, y = 0; i < n; ++i)y += series[i][j][1] || 0; s0[j][1] += s0[j][0] = -y / 2; } stackOffsetNone(series, order); } function stackOffsetWiggle(series, order) { if (!((n = series.length) > 0) || !((m = (s0 = series[order[0]]).length) > 0)) return; for(var y = 0, j = 1, s0, m, n; j < m; ++j){ for(var i = 0, s1 = 0, s2 = 0; i < n; ++i){ var si = series[order[i]], sij0 = si[j][1] || 0, sij1 = si[j - 1][1] || 0, s3 = (sij0 - sij1) / 2; for(var k = 0; k < i; ++k){ var sk = series[order[k]], skj0 = sk[j][1] || 0, skj1 = sk[j - 1][1] || 0; s3 += skj0 - skj1; } s1 += sij0, s2 += s3 * sij0; } s0[j - 1][1] += s0[j - 1][0] = y; if (s1) y -= s2 / s1; } s0[j - 1][1] += s0[j - 1][0] = y; stackOffsetNone(series, order); } var get$2 = {}; var isUnsafeProperty = {}; var hasRequiredIsUnsafeProperty; function requireIsUnsafeProperty() { if (hasRequiredIsUnsafeProperty) return isUnsafeProperty; hasRequiredIsUnsafeProperty = 1; (function(exports) { Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); function isUnsafeProperty(key) { return key === '__proto__'; } exports.isUnsafeProperty = isUnsafeProperty; })(isUnsafeProperty); return isUnsafeProperty; } var isDeepKey = {}; var hasRequiredIsDeepKey; function requireIsDeepKey() { if (hasRequiredIsDeepKey) return isDeepKey; hasRequiredIsDeepKey = 1; (function(exports) { Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); function isDeepKey(key) { switch(typeof key){ case 'number': case 'symbol': { return false; } case 'string': { return key.includes('.') || key.includes('[') || key.includes(']'); } } } exports.isDeepKey = isDeepKey; })(isDeepKey); return isDeepKey; } var toKey = {}; var hasRequiredToKey; function requireToKey() { if (hasRequiredToKey) return toKey; hasRequiredToKey = 1; (function(exports) { Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); function toKey(value) { if (typeof value === 'string' || typeof value === 'symbol') { return value; } if (Object.is(value?.valueOf?.(), -0)) { return '-0'; } return String(value); } exports.toKey = toKey; })(toKey); return toKey; } var toPath = {}; var toString$1 = {}; var hasRequiredToString; function requireToString() { if (hasRequiredToString) return toString$1; hasRequiredToString = 1; (function(exports) { Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); function toString(value) { if (value == null) { return ''; } if (typeof value === 'string') { return value; } if (Array.isArray(value)) { return value.map(toString).join(','); } const result = String(value); if (result === '0' && Object.is(Number(value), -0)) { return '-0'; } return result; } exports.toString = toString; })(toString$1); return toString$1; } var hasRequiredToPath; function requireToPath() { if (hasRequiredToPath) return toPath; hasRequiredToPath = 1; (function(exports) { Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const toString = /*@__PURE__*/ requireToString(); const toKey = /*@__PURE__*/ requireToKey(); function toPath(deepKey) { if (Array.isArray(deepKey)) { return deepKey.map(toKey.toKey); } if (typeof deepKey === 'symbol') { return [ deepKey ]; } deepKey = toString.toString(deepKey); const result = []; const length = deepKey.length; if (length === 0) { return result; } let index = 0; let key = ''; let quoteChar = ''; let bracket = false; if (deepKey.charCodeAt(0) === 46) { re