victory-create-container
Version:
Container Helper for Victory
1,382 lines (1,130 loc) • 867 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("react"));
else if(typeof define === 'function' && define.amd)
define(["react"], factory);
else if(typeof exports === 'object')
exports["VictoryCreateContainer"] = factory(require("react"));
else
root["VictoryCreateContainer"] = factory(root["React"]);
})(self, function(__WEBPACK_EXTERNAL_MODULE_react__) {
return /******/ (function() { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ "./create-container.tsx":
/*!******************************!*\
!*** ./create-container.tsx ***!
\******************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "createContainer": function() { return /* binding */ createContainer; },
/* harmony export */ "makeCreateContainerFunction": function() { return /* binding */ makeCreateContainerFunction; }
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var lodash_forOwn__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lodash/forOwn */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/forOwn.js");
/* harmony import */ var lodash_forOwn__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash_forOwn__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var lodash_groupBy__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! lodash/groupBy */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/groupBy.js");
/* harmony import */ var lodash_groupBy__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(lodash_groupBy__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var lodash_isEmpty__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! lodash/isEmpty */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/isEmpty.js");
/* harmony import */ var lodash_isEmpty__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(lodash_isEmpty__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var lodash_toPairs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! lodash/toPairs */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/toPairs.js");
/* harmony import */ var lodash_toPairs__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(lodash_toPairs__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var victory_zoom_container__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! victory-zoom-container */ "../../victory-zoom-container/es/victory-zoom-container.js");
/* harmony import */ var victory_selection_container__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! victory-selection-container */ "../../victory-selection-container/es/victory-selection-container.js");
/* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-container/victory-container.js");
/* harmony import */ var victory_voronoi_container__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! victory-voronoi-container */ "../../victory-voronoi-container/es/victory-voronoi-container.js");
/* harmony import */ var victory_cursor_container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! victory-cursor-container */ "../../victory-cursor-container/es/victory-cursor-container.js");
/* harmony import */ var victory_brush_container__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! victory-brush-container */ "../../victory-brush-container/es/victory-brush-container.js");
function ensureArray(thing) {
if (!thing) {
return [];
} else if (!Array.isArray(thing)) {
return [thing];
}
return thing;
}
const combineEventHandlers = eventHandlersArray => {
// takes an array of event handler objects and produces one eventHandlers object
// creates a custom combinedHandler() for events with multiple conflicting handlers
return eventHandlersArray.reduce((localHandlers, finalHandlers) => {
lodash_forOwn__WEBPACK_IMPORTED_MODULE_1___default()(localHandlers, (localHandler, eventName) => {
const existingHandler = finalHandlers[eventName];
if (existingHandler) {
// create new handler for event that concats the existing handler's mutations with new ones
finalHandlers[eventName] = function combinedHandler() {
// named for debug clarity
// sometimes handlers return undefined; use empty array instead, for concat()
const existingMutations = ensureArray(existingHandler(...arguments));
const localMutations = ensureArray(localHandler(...arguments));
return existingMutations.concat(localMutations);
};
} else {
finalHandlers[eventName] = localHandler;
}
});
return finalHandlers;
});
};
const combineDefaultEvents = defaultEvents => {
// takes a defaultEvents array and returns one equal or lesser length,
// by combining any events that have the same target
const eventsByTarget = lodash_groupBy__WEBPACK_IMPORTED_MODULE_2___default()(defaultEvents, "target");
const events = lodash_toPairs__WEBPACK_IMPORTED_MODULE_4___default()(eventsByTarget).map(_ref => {
let [target, eventsArray] = _ref;
const newEventsArray = eventsArray.filter(Boolean);
return lodash_isEmpty__WEBPACK_IMPORTED_MODULE_3___default()(newEventsArray) ? null : {
target,
eventHandlers: combineEventHandlers(eventsArray.map(event => event.eventHandlers))
// note: does not currently handle eventKey or childName
};
});
return events.filter(Boolean);
};
/**
* Container hooks are used to provide the container logic to the container components through props and a modified children object
* - These hooks contain shared logic for both web and Victory Native containers.
* - In this utility, we call multiple of these hooks with the props returned by the previous to combine the container logic.
*/
const CONTAINER_HOOKS = {
zoom: victory_zoom_container__WEBPACK_IMPORTED_MODULE_5__.useVictoryZoomContainer,
selection: victory_selection_container__WEBPACK_IMPORTED_MODULE_6__.useVictorySelectionContainer,
brush: victory_brush_container__WEBPACK_IMPORTED_MODULE_7__.useVictoryBrushContainer,
cursor: victory_cursor_container__WEBPACK_IMPORTED_MODULE_8__.useVictoryCursorContainer,
voronoi: victory_voronoi_container__WEBPACK_IMPORTED_MODULE_9__.useVictoryVoronoiContainer
};
/**
* Container hooks are wrappers that return a VictoryContainer with the props provided by their respective hooks, and the modified children.
* - These containers are specific to the web. Victory Native has its own container components.
* - For this utility, we only need the container components to extract the defaultEvents.
*/
const CONTAINER_COMPONENTS_WEB = {
zoom: victory_zoom_container__WEBPACK_IMPORTED_MODULE_5__.VictoryZoomContainer,
selection: victory_selection_container__WEBPACK_IMPORTED_MODULE_6__.VictorySelectionContainer,
brush: victory_brush_container__WEBPACK_IMPORTED_MODULE_7__.VictoryBrushContainer,
cursor: victory_cursor_container__WEBPACK_IMPORTED_MODULE_8__.VictoryCursorContainer,
voronoi: victory_voronoi_container__WEBPACK_IMPORTED_MODULE_9__.VictoryVoronoiContainer
};
function makeCreateContainerFunction(containerComponents, VictoryContainerBase) {
// Helper type to support backwards compatibility with old types
return function combineContainers(containerA, containerB) {
const ContainerA = containerComponents[containerA];
const ContainerB = containerComponents[containerB];
const useContainerA = CONTAINER_HOOKS[containerA];
const useContainerB = CONTAINER_HOOKS[containerB];
const CombinedContainer = props => {
const {
children: childrenA,
props: propsA
} = useContainerA(props);
const {
children: combinedChildren,
props: combinedProps
} = useContainerB({
...propsA,
children: childrenA
});
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(VictoryContainerBase, combinedProps, combinedChildren);
};
CombinedContainer.displayName = `Victory${containerA}${containerB}Container`;
CombinedContainer.role = "container";
CombinedContainer.defaultEvents = props => combineDefaultEvents([...ContainerA.defaultEvents(props), ...ContainerB.defaultEvents(props)]);
return CombinedContainer;
};
}
const createContainer = makeCreateContainerFunction(CONTAINER_COMPONENTS_WEB, victory_core__WEBPACK_IMPORTED_MODULE_10__.VictoryContainer);
/***/ }),
/***/ "../../../node_modules/.pnpm/delaunator@4.0.1/node_modules/delaunator/delaunator.js":
/*!******************************************************************************************!*\
!*** ../../../node_modules/.pnpm/delaunator@4.0.1/node_modules/delaunator/delaunator.js ***!
\******************************************************************************************/
/***/ (function(module) {
(function (global, factory) {
true ? module.exports = factory() :
0;
}(this, function () { 'use strict';
var EPSILON = Math.pow(2, -52);
var EDGE_STACK = new Uint32Array(512);
var Delaunator = function Delaunator(coords) {
var n = coords.length >> 1;
if (n > 0 && typeof coords[0] !== 'number') { throw new Error('Expected coords to contain numbers.'); }
this.coords = coords;
// arrays that will store the triangulation graph
var maxTriangles = Math.max(2 * n - 5, 0);
this._triangles = new Uint32Array(maxTriangles * 3);
this._halfedges = new Int32Array(maxTriangles * 3);
// temporary arrays for tracking the edges of the advancing convex hull
this._hashSize = Math.ceil(Math.sqrt(n));
this._hullPrev = new Uint32Array(n); // edge to prev edge
this._hullNext = new Uint32Array(n); // edge to next edge
this._hullTri = new Uint32Array(n); // edge to adjacent triangle
this._hullHash = new Int32Array(this._hashSize).fill(-1); // angular edge hash
// temporary arrays for sorting points
this._ids = new Uint32Array(n);
this._dists = new Float64Array(n);
this.update();
};
Delaunator.from = function from (points, getX, getY) {
if ( getX === void 0 ) getX = defaultGetX;
if ( getY === void 0 ) getY = defaultGetY;
var n = points.length;
var coords = new Float64Array(n * 2);
for (var i = 0; i < n; i++) {
var p = points[i];
coords[2 * i] = getX(p);
coords[2 * i + 1] = getY(p);
}
return new Delaunator(coords);
};
Delaunator.prototype.update = function update () {
var ref = this;
var coords = ref.coords;
var hullPrev = ref._hullPrev;
var hullNext = ref._hullNext;
var hullTri = ref._hullTri;
var hullHash = ref._hullHash;
var n = coords.length >> 1;
// populate an array of point indices; calculate input data bbox
var minX = Infinity;
var minY = Infinity;
var maxX = -Infinity;
var maxY = -Infinity;
for (var i = 0; i < n; i++) {
var x = coords[2 * i];
var y = coords[2 * i + 1];
if (x < minX) { minX = x; }
if (y < minY) { minY = y; }
if (x > maxX) { maxX = x; }
if (y > maxY) { maxY = y; }
this._ids[i] = i;
}
var cx = (minX + maxX) / 2;
var cy = (minY + maxY) / 2;
var minDist = Infinity;
var i0, i1, i2;
// pick a seed point close to the center
for (var i$1 = 0; i$1 < n; i$1++) {
var d = dist(cx, cy, coords[2 * i$1], coords[2 * i$1 + 1]);
if (d < minDist) {
i0 = i$1;
minDist = d;
}
}
var i0x = coords[2 * i0];
var i0y = coords[2 * i0 + 1];
minDist = Infinity;
// find the point closest to the seed
for (var i$2 = 0; i$2 < n; i$2++) {
if (i$2 === i0) { continue; }
var d$1 = dist(i0x, i0y, coords[2 * i$2], coords[2 * i$2 + 1]);
if (d$1 < minDist && d$1 > 0) {
i1 = i$2;
minDist = d$1;
}
}
var i1x = coords[2 * i1];
var i1y = coords[2 * i1 + 1];
var minRadius = Infinity;
// find the third point which forms the smallest circumcircle with the first two
for (var i$3 = 0; i$3 < n; i$3++) {
if (i$3 === i0 || i$3 === i1) { continue; }
var r = circumradius(i0x, i0y, i1x, i1y, coords[2 * i$3], coords[2 * i$3 + 1]);
if (r < minRadius) {
i2 = i$3;
minRadius = r;
}
}
var i2x = coords[2 * i2];
var i2y = coords[2 * i2 + 1];
if (minRadius === Infinity) {
// order collinear points by dx (or dy if all x are identical)
// and return the list as a hull
for (var i$4 = 0; i$4 < n; i$4++) {
this._dists[i$4] = (coords[2 * i$4] - coords[0]) || (coords[2 * i$4 + 1] - coords[1]);
}
quicksort(this._ids, this._dists, 0, n - 1);
var hull = new Uint32Array(n);
var j = 0;
for (var i$5 = 0, d0 = -Infinity; i$5 < n; i$5++) {
var id = this._ids[i$5];
if (this._dists[id] > d0) {
hull[j++] = id;
d0 = this._dists[id];
}
}
this.hull = hull.subarray(0, j);
this.triangles = new Uint32Array(0);
this.halfedges = new Uint32Array(0);
return;
}
// swap the order of the seed points for counter-clockwise orientation
if (orient(i0x, i0y, i1x, i1y, i2x, i2y)) {
var i$6 = i1;
var x$1 = i1x;
var y$1 = i1y;
i1 = i2;
i1x = i2x;
i1y = i2y;
i2 = i$6;
i2x = x$1;
i2y = y$1;
}
var center = circumcenter(i0x, i0y, i1x, i1y, i2x, i2y);
this._cx = center.x;
this._cy = center.y;
for (var i$7 = 0; i$7 < n; i$7++) {
this._dists[i$7] = dist(coords[2 * i$7], coords[2 * i$7 + 1], center.x, center.y);
}
// sort the points by distance from the seed triangle circumcenter
quicksort(this._ids, this._dists, 0, n - 1);
// set up the seed triangle as the starting hull
this._hullStart = i0;
var hullSize = 3;
hullNext[i0] = hullPrev[i2] = i1;
hullNext[i1] = hullPrev[i0] = i2;
hullNext[i2] = hullPrev[i1] = i0;
hullTri[i0] = 0;
hullTri[i1] = 1;
hullTri[i2] = 2;
hullHash.fill(-1);
hullHash[this._hashKey(i0x, i0y)] = i0;
hullHash[this._hashKey(i1x, i1y)] = i1;
hullHash[this._hashKey(i2x, i2y)] = i2;
this.trianglesLen = 0;
this._addTriangle(i0, i1, i2, -1, -1, -1);
for (var k = 0, xp = (void 0), yp = (void 0); k < this._ids.length; k++) {
var i$8 = this._ids[k];
var x$2 = coords[2 * i$8];
var y$2 = coords[2 * i$8 + 1];
// skip near-duplicate points
if (k > 0 && Math.abs(x$2 - xp) <= EPSILON && Math.abs(y$2 - yp) <= EPSILON) { continue; }
xp = x$2;
yp = y$2;
// skip seed triangle points
if (i$8 === i0 || i$8 === i1 || i$8 === i2) { continue; }
// find a visible edge on the convex hull using edge hash
var start = 0;
for (var j$1 = 0, key = this._hashKey(x$2, y$2); j$1 < this._hashSize; j$1++) {
start = hullHash[(key + j$1) % this._hashSize];
if (start !== -1 && start !== hullNext[start]) { break; }
}
start = hullPrev[start];
var e = start, q = (void 0);
while (q = hullNext[e], !orient(x$2, y$2, coords[2 * e], coords[2 * e + 1], coords[2 * q], coords[2 * q + 1])) {
e = q;
if (e === start) {
e = -1;
break;
}
}
if (e === -1) { continue; } // likely a near-duplicate point; skip it
// add the first triangle from the point
var t = this._addTriangle(e, i$8, hullNext[e], -1, -1, hullTri[e]);
// recursively flip triangles from the point until they satisfy the Delaunay condition
hullTri[i$8] = this._legalize(t + 2);
hullTri[e] = t; // keep track of boundary triangles on the hull
hullSize++;
// walk forward through the hull, adding more triangles and flipping recursively
var n$1 = hullNext[e];
while (q = hullNext[n$1], orient(x$2, y$2, coords[2 * n$1], coords[2 * n$1 + 1], coords[2 * q], coords[2 * q + 1])) {
t = this._addTriangle(n$1, i$8, q, hullTri[i$8], -1, hullTri[n$1]);
hullTri[i$8] = this._legalize(t + 2);
hullNext[n$1] = n$1; // mark as removed
hullSize--;
n$1 = q;
}
// walk backward from the other side, adding more triangles and flipping
if (e === start) {
while (q = hullPrev[e], orient(x$2, y$2, coords[2 * q], coords[2 * q + 1], coords[2 * e], coords[2 * e + 1])) {
t = this._addTriangle(q, i$8, e, -1, hullTri[e], hullTri[q]);
this._legalize(t + 2);
hullTri[q] = t;
hullNext[e] = e; // mark as removed
hullSize--;
e = q;
}
}
// update the hull indices
this._hullStart = hullPrev[i$8] = e;
hullNext[e] = hullPrev[n$1] = i$8;
hullNext[i$8] = n$1;
// save the two new edges in the hash table
hullHash[this._hashKey(x$2, y$2)] = i$8;
hullHash[this._hashKey(coords[2 * e], coords[2 * e + 1])] = e;
}
this.hull = new Uint32Array(hullSize);
for (var i$9 = 0, e$1 = this._hullStart; i$9 < hullSize; i$9++) {
this.hull[i$9] = e$1;
e$1 = hullNext[e$1];
}
// trim typed triangle mesh arrays
this.triangles = this._triangles.subarray(0, this.trianglesLen);
this.halfedges = this._halfedges.subarray(0, this.trianglesLen);
};
Delaunator.prototype._hashKey = function _hashKey (x, y) {
return Math.floor(pseudoAngle(x - this._cx, y - this._cy) * this._hashSize) % this._hashSize;
};
Delaunator.prototype._legalize = function _legalize (a) {
var ref = this;
var triangles = ref._triangles;
var halfedges = ref._halfedges;
var coords = ref.coords;
var i = 0;
var ar = 0;
// recursion eliminated with a fixed-size stack
while (true) {
var b = halfedges[a];
/* if the pair of triangles doesn't satisfy the Delaunay condition
* (p1 is inside the circumcircle of [p0, pl, pr]), flip them,
* then do the same check/flip recursively for the new pair of triangles
*
* pl pl
* /||\ / \
* al/ || \bl al/\a
* / || \ / \
* / a||b \flip/___ar___\
* p0\ || /p1 => p0\---bl---/p1
* \ || / \ /
* ar\ || /br b\/br
* \||/ \ /
* pr pr
*/
var a0 = a - a % 3;
ar = a0 + (a + 2) % 3;
if (b === -1) { // convex hull edge
if (i === 0) { break; }
a = EDGE_STACK[--i];
continue;
}
var b0 = b - b % 3;
var al = a0 + (a + 1) % 3;
var bl = b0 + (b + 2) % 3;
var p0 = triangles[ar];
var pr = triangles[a];
var pl = triangles[al];
var p1 = triangles[bl];
var illegal = inCircle(
coords[2 * p0], coords[2 * p0 + 1],
coords[2 * pr], coords[2 * pr + 1],
coords[2 * pl], coords[2 * pl + 1],
coords[2 * p1], coords[2 * p1 + 1]);
if (illegal) {
triangles[a] = p1;
triangles[b] = p0;
var hbl = halfedges[bl];
// edge swapped on the other side of the hull (rare); fix the halfedge reference
if (hbl === -1) {
var e = this._hullStart;
do {
if (this._hullTri[e] === bl) {
this._hullTri[e] = a;
break;
}
e = this._hullPrev[e];
} while (e !== this._hullStart);
}
this._link(a, hbl);
this._link(b, halfedges[ar]);
this._link(ar, bl);
var br = b0 + (b + 1) % 3;
// don't worry about hitting the cap: it can only happen on extremely degenerate input
if (i < EDGE_STACK.length) {
EDGE_STACK[i++] = br;
}
} else {
if (i === 0) { break; }
a = EDGE_STACK[--i];
}
}
return ar;
};
Delaunator.prototype._link = function _link (a, b) {
this._halfedges[a] = b;
if (b !== -1) { this._halfedges[b] = a; }
};
// add a new triangle given vertex indices and adjacent half-edge ids
Delaunator.prototype._addTriangle = function _addTriangle (i0, i1, i2, a, b, c) {
var t = this.trianglesLen;
this._triangles[t] = i0;
this._triangles[t + 1] = i1;
this._triangles[t + 2] = i2;
this._link(t, a);
this._link(t + 1, b);
this._link(t + 2, c);
this.trianglesLen += 3;
return t;
};
// monotonically increases with real angle, but doesn't need expensive trigonometry
function pseudoAngle(dx, dy) {
var p = dx / (Math.abs(dx) + Math.abs(dy));
return (dy > 0 ? 3 - p : 1 + p) / 4; // [0..1]
}
function dist(ax, ay, bx, by) {
var dx = ax - bx;
var dy = ay - by;
return dx * dx + dy * dy;
}
// return 2d orientation sign if we're confident in it through J. Shewchuk's error bound check
function orientIfSure(px, py, rx, ry, qx, qy) {
var l = (ry - py) * (qx - px);
var r = (rx - px) * (qy - py);
return Math.abs(l - r) >= 3.3306690738754716e-16 * Math.abs(l + r) ? l - r : 0;
}
// a more robust orientation test that's stable in a given triangle (to fix robustness issues)
function orient(rx, ry, qx, qy, px, py) {
var sign = orientIfSure(px, py, rx, ry, qx, qy) ||
orientIfSure(rx, ry, qx, qy, px, py) ||
orientIfSure(qx, qy, px, py, rx, ry);
return sign < 0;
}
function inCircle(ax, ay, bx, by, cx, cy, px, py) {
var dx = ax - px;
var dy = ay - py;
var ex = bx - px;
var ey = by - py;
var fx = cx - px;
var fy = cy - py;
var ap = dx * dx + dy * dy;
var bp = ex * ex + ey * ey;
var cp = fx * fx + fy * fy;
return dx * (ey * cp - bp * fy) -
dy * (ex * cp - bp * fx) +
ap * (ex * fy - ey * fx) < 0;
}
function circumradius(ax, ay, bx, by, cx, cy) {
var dx = bx - ax;
var dy = by - ay;
var ex = cx - ax;
var ey = cy - ay;
var bl = dx * dx + dy * dy;
var cl = ex * ex + ey * ey;
var d = 0.5 / (dx * ey - dy * ex);
var x = (ey * bl - dy * cl) * d;
var y = (dx * cl - ex * bl) * d;
return x * x + y * y;
}
function circumcenter(ax, ay, bx, by, cx, cy) {
var dx = bx - ax;
var dy = by - ay;
var ex = cx - ax;
var ey = cy - ay;
var bl = dx * dx + dy * dy;
var cl = ex * ex + ey * ey;
var d = 0.5 / (dx * ey - dy * ex);
var x = ax + (ey * bl - dy * cl) * d;
var y = ay + (dx * cl - ex * bl) * d;
return {x: x, y: y};
}
function quicksort(ids, dists, left, right) {
if (right - left <= 20) {
for (var i = left + 1; i <= right; i++) {
var temp = ids[i];
var tempDist = dists[temp];
var j = i - 1;
while (j >= left && dists[ids[j]] > tempDist) { ids[j + 1] = ids[j--]; }
ids[j + 1] = temp;
}
} else {
var median = (left + right) >> 1;
var i$1 = left + 1;
var j$1 = right;
swap(ids, median, i$1);
if (dists[ids[left]] > dists[ids[right]]) { swap(ids, left, right); }
if (dists[ids[i$1]] > dists[ids[right]]) { swap(ids, i$1, right); }
if (dists[ids[left]] > dists[ids[i$1]]) { swap(ids, left, i$1); }
var temp$1 = ids[i$1];
var tempDist$1 = dists[temp$1];
while (true) {
do { i$1++; } while (dists[ids[i$1]] < tempDist$1);
do { j$1--; } while (dists[ids[j$1]] > tempDist$1);
if (j$1 < i$1) { break; }
swap(ids, i$1, j$1);
}
ids[left + 1] = ids[j$1];
ids[j$1] = temp$1;
if (right - i$1 + 1 >= j$1 - left) {
quicksort(ids, dists, i$1, right);
quicksort(ids, dists, left, j$1 - 1);
} else {
quicksort(ids, dists, left, j$1 - 1);
quicksort(ids, dists, i$1, right);
}
}
}
function swap(arr, i, j) {
var tmp = arr[i];
arr[i] = arr[j];
arr[j] = tmp;
}
function defaultGetX(p) {
return p[0];
}
function defaultGetY(p) {
return p[1];
}
return Delaunator;
}));
/***/ }),
/***/ "../../../node_modules/.pnpm/delaunay-find@0.0.6/node_modules/delaunay-find/lib/index.js":
/*!***********************************************************************************************!*\
!*** ../../../node_modules/.pnpm/delaunay-find@0.0.6/node_modules/delaunay-find/lib/index.js ***!
\***********************************************************************************************/
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports["default"] = void 0;
var _delaunator = _interopRequireDefault(__webpack_require__(/*! delaunator/delaunator.js */ "../../../node_modules/.pnpm/delaunator@4.0.1/node_modules/delaunator/delaunator.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// From https://github.com/d3/d3-delaunay/blob/master/src/delaunay.js
function pointX(p) {
return p[0];
}
function pointY(p) {
return p[1];
} // A triangulation is collinear if all its triangles have a non-null area
function collinear(d) {
var triangles = d.triangles,
coords = d.coords;
for (var i = 0; i < triangles.length; i += 3) {
var a = 2 * triangles[i];
var b = 2 * triangles[i + 1];
var c = 2 * triangles[i + 2];
var cross = (coords[c] - coords[a]) * (coords[b + 1] - coords[a + 1]) - (coords[b] - coords[a]) * (coords[c + 1] - coords[a + 1]); // eslint-disable-next-line no-magic-numbers
if (cross > 1e-10) {
return false;
}
}
return true;
}
function jitter(x, y, r) {
return [x + Math.sin(x + y) * r, y + Math.cos(x - y) * r];
} // eslint-disable-next-line max-params
function flatArray(points, fx, fy, that) {
var n = points.length;
var array = new Float64Array(n * 2);
for (var i = 0; i < n; ++i) {
var p = points[i];
array[i * 2] = fx.call(that, p, i, points);
array[i * 2 + 1] = fy.call(that, p, i, points);
}
return array;
}
var Delaunay =
/*#__PURE__*/
function () {
function Delaunay(points) {
var delaunator = new _delaunator["default"](points);
this.inedges = new Int32Array(points.length / 2);
this._hullIndex = new Int32Array(points.length / 2);
this.points = delaunator.coords;
this._init(delaunator);
} // eslint-disable-next-line max-statements, complexity
var _proto = Delaunay.prototype;
_proto._init = function _init(delaunator) {
var d = delaunator;
var points = this.points; // check for collinear
// eslint-disable-next-line no-magic-numbers
if (d.hull && d.hull.length > 2 && collinear(d)) {
this.collinear = Int32Array.from({
length: points.length / 2
}, function (_, i) {
return i;
}).sort(function (i, j) {
return points[2 * i] - points[2 * j] || points[2 * i + 1] - points[2 * j + 1];
}); // for exact neighbors
var e = this.collinear[0];
var f = this.collinear[this.collinear.length - 1];
var bounds = [points[2 * e], points[2 * e + 1], points[2 * f], points[2 * f + 1]];
var r = 1e-8 * // eslint-disable-line no-magic-numbers
Math.sqrt(Math.pow(bounds[3] - bounds[1], 2) + Math.pow(bounds[2] - bounds[0], 2));
for (var i = 0, n = points.length / 2; i < n; ++i) {
var p = jitter(points[2 * i], points[2 * i + 1], r);
points[2 * i] = p[0];
points[2 * i + 1] = p[1];
}
delaunator = new _delaunator["default"](points);
}
var halfedges = this.halfedges = delaunator.halfedges;
var hull = this.hull = delaunator.hull;
var triangles = this.triangles = delaunator.triangles;
var inedges = this.inedges.fill(-1);
var hullIndex = this._hullIndex.fill(-1); // Compute an index from each point to an (arbitrary) incoming halfedge
// Used to give the first neighbor of each point; for this reason,
// on the hull we give priority to exterior halfedges
for (var _e = 0, _n = halfedges.length; _e < _n; ++_e) {
var _p = triangles[_e % 3 === 2 ? _e - 2 : _e + 1];
if (halfedges[_e] === -1 || inedges[_p] === -1) inedges[_p] = _e;
}
for (var _i = 0, _n2 = hull.length; _i < _n2; ++_i) {
hullIndex[hull[_i]] = _i;
} // degenerate case: 1 or 2 (distinct) points
if (hull.length <= 2 && hull.length > 0) {
this.triangles = new Int32Array(3).fill(-1);
this.halfedges = new Int32Array(3).fill(-1);
this.triangles[0] = hull[0];
this.triangles[1] = hull[1];
this.triangles[2] = hull[1];
inedges[hull[0]] = 1;
if (hull.length === 2) inedges[hull[1]] = 0;
}
} // eslint-disable-next-line max-statements
;
_proto.neighbors = function neighbors(i) {
var results = [];
var inedges = this.inedges,
hull = this.hull,
_hullIndex = this._hullIndex,
halfedges = this.halfedges,
triangles = this.triangles;
var e0 = inedges[i];
if (e0 === -1) return results; // coincident point
var e = e0;
var p0 = -1;
do {
p0 = triangles[e];
results.push(p0);
e = e % 3 === 2 ? e - 2 : e + 1;
if (triangles[e] !== i) break; // bad triangulation
e = halfedges[e];
if (e === -1) {
var p = hull[(_hullIndex[i] + 1) % hull.length];
if (p !== p0) results.push(p);
break;
}
} while (e !== e0);
return results;
};
_proto.find = function find(x, y, i) {
if (i === void 0) {
i = 0;
}
// eslint-disable-next-line no-self-compare
if ((x = +x, x !== x) || (y = +y, y !== y)) return -1;
var i0 = i;
var c;
while ((c = this._step(i, x, y)) >= 0 && c !== i && c !== i0) {
i = c;
}
return c;
};
_proto._step = function _step(i, x, y) {
var inedges = this.inedges,
points = this.points;
if (inedges[i] === -1 || !points.length) return (i + 1) % (points.length >> 1);
var c = i;
var dc = Math.pow(x - points[i * 2], 2) + Math.pow(y - points[i * 2 + 1], 2);
for (var _iterator = this.neighbors(i), _isArray = Array.isArray(_iterator), _i2 = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;
if (_isArray) {
if (_i2 >= _iterator.length) break;
_ref = _iterator[_i2++];
} else {
_i2 = _iterator.next();
if (_i2.done) break;
_ref = _i2.value;
}
var t = _ref;
var dt = Math.pow(x - points[t * 2], 2) + Math.pow(y - points[t * 2 + 1], 2);
if (dt < dc) {
dc = dt;
c = t;
}
}
return c;
};
return Delaunay;
}(); // eslint-disable-next-line max-params
exports["default"] = Delaunay;
Delaunay.from = function (points, fx, fy, that) {
if (fx === void 0) {
fx = pointX;
}
if (fy === void 0) {
fy = pointY;
}
return new Delaunay(flatArray(points, fx, fy, that));
}; // only public methods will be .from and .find
/***/ }),
/***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_MapCache.js":
/*!***********************************************************************************!*\
!*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_MapCache.js ***!
\***********************************************************************************/
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
var listCacheClear = __webpack_require__(/*! ./_listCacheClear */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheClear.js"),
listCacheDelete = __webpack_require__(/*! ./_listCacheDelete */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheDelete.js"),
listCacheGet = __webpack_require__(/*! ./_listCacheGet */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheGet.js"),
listCacheHas = __webpack_require__(/*! ./_listCacheHas */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheHas.js"),
listCacheSet = __webpack_require__(/*! ./_listCacheSet */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheSet.js");
/**
* Creates an list cache object.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function ListCache(entries) {
var index = -1,
length = entries == null ? 0 : entries.length;
this.clear();
while (++index < length) {
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
// Add methods to `ListCache`.
ListCache.prototype.clear = listCacheClear;
ListCache.prototype['delete'] = listCacheDelete;
ListCache.prototype.get = listCacheGet;
ListCache.prototype.has = listCacheHas;
ListCache.prototype.set = listCacheSet;
module.exports = ListCache;
/***/ }),
/***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_SetCache.js":
/*!***********************************************************************************!*\
!*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_SetCache.js ***!
\***********************************************************************************/
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
var isArray = __webpack_require__(/*! ./isArray */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/isArray.js");
/**
* Casts `value` as an array if it's not one.
*
* @static
* @memberOf _
* @since 4.4.0
* @category Lang
* @param {*} value The value to inspect.
* @returns {Array} Returns the cast array.
* @example
*
* _.castArray(1);
* // => [1]
*
* _.castArray({ 'a': 1 });
* // => [{ 'a': 1 }]
*
* _.castArray('abc');
* // => ['abc']
*
* _.castArray(null);
* // => [null]
*
* _.castArray(undefined);
* // => [undefined]
*
* _.castArray();
* // => []
*
* var array = [1, 2, 3];
* console.log(_.castArray(array) === array);
* // => true
*/
function castArray() {
if (!arguments.length) {
return [];
}
var value = arguments[0];
return isArray(value) ? value : [value];
}
module.exports = castArray;
/***/ }),
/***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_Stack.js":
/*!********************************************************************************!*\
!*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_Stack.js ***!
\********************************************************************************/
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
var listCacheClear = __webpack_require__(/*! ./_listCacheClear */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheClear.js"),
listCacheDelete = __webpack_require__(/*! ./_listCacheDelete */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheDelete.js"),
listCacheGet = __webpack_require__(/*! ./_listCacheGet */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheGet.js"),
listCacheHas = __webpack_require__(/*! ./_listCacheHas */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheHas.js"),
listCacheSet = __webpack_require__(/*! ./_listCacheSet */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheSet.js");
/**
* Creates an list cache object.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function ListCache(entries) {
var index = -1,
length = entries == null ? 0 : entries.length;
this.clear();
while (++index < length) {
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
// Add methods to `ListCache`.
ListCache.prototype.clear = listCacheClear;
ListCache.prototype['delete'] = listCacheDelete;
ListCache.prototype.get = listCacheGet;
ListCache.prototype.has = listCacheHas;
ListCache.prototype.set = listCacheSet;
module.exports = ListCache;
/***/ }),
/***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_Symbol.js":
/*!*********************************************************************************!*\
!*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_Symbol.js ***!
\*********************************************************************************/
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
var root = __webpack_require__(/*! ./_root */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_root.js");
/** Built-in value references. */
var Symbol = root.Symbol;
module.exports = Symbol;
/***/ }),
/***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_apply.js":
/*!********************************************************************************!*\
!*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_apply.js ***!
\********************************************************************************/
/***/ (function(module) {
/**
* A faster alternative to `Function#apply`, this function invokes `func`
* with the `this` binding of `thisArg` and the arguments of `args`.
*
* @private
* @param {Function} func The function to invoke.
* @param {*} thisArg The `this` binding of `func`.
* @param {Array} args The arguments to invoke `func` with.
* @returns {*} Returns the result of `func`.
*/
function apply(func, thisArg, args) {
switch (args.length) {
case 0: return func.call(thisArg);
case 1: return func.call(thisArg, args[0]);
case 2: return func.call(thisArg, args[0], args[1]);
case 3: return func.call(thisArg, args[0], args[1], args[2]);
}
return func.apply(thisArg, args);
}
module.exports = apply;
/***/ }),
/***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arrayAggregator.js":
/*!******************************************************************************************!*\
!*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arrayAggregator.js ***!
\******************************************************************************************/
/***/ (function(module) {
/**
* A specialized version of `baseAggregator` for arrays.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} setter The function to set `accumulator` values.
* @param {Function} iteratee The iteratee to transform keys.
* @param {Object} accumulator The initial aggregated object.
* @returns {Function} Returns `accumulator`.
*/
function arrayAggregator(array, setter, iteratee, accumulator) {
var index = -1,
length = array == null ? 0 : array.length;
while (++index < length) {
var value = array[index];
setter(accumulator, value, iteratee(value), array);
}
return accumulator;
}
module.exports = arrayAggregator;
/***/ }),
/***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arrayIncludes.js":
/*!****************************************************************************************!*\
!*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arrayIncludes.js ***!
\****************************************************************************************/
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
var baseIndexOf = __webpack_require__(/*! ./_baseIndexOf */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseIndexOf.js");
/**
* A specialized version of `_.includes` for arrays without support for
* specifying an index to search from.
*
* @private
* @param {Array} [array] The array to inspect.
* @param {*} target The value to search for.
* @returns {boolean} Returns `true` if `target` is found, else `false`.
*/
function arrayIncludes(array, value) {
var length = array == null ? 0 : array.length;
return !!length && baseIndexOf(array, value, 0) > -1;
}
module.exports = arrayIncludes;
/***/ }),
/***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arrayIncludesWith.js":
/*!********************************************************************************************!*\
!*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arrayIncludesWith.js ***!
\********************************************************************************************/
/***/ (function(module) {
/**
* This function is like `arrayIncludes` except that it accepts a comparator.
*
* @private
* @param {Array} [array] The array to inspect.
* @param {*} target The value to search for.
* @param {Function} comparator The comparator invoked per element.
* @returns {boolean} Returns `true` if `target` is found, else `false`.
*/
function arrayIncludesWith(array, value, comparator) {
var index = -1,
length = array == null ? 0 : array.length;
while (++index < length) {
if (comparator(value, array[index])) {
return true;
}
}
return false;
}
module.exports = arrayIncludesWith;
/***/ }),
/***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arrayMap.js":
/*!***********************************************************************************!*\
!*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arrayMap.js ***!
\***********************************************************************************/
/***/ (function(module) {
/**
* A specialized version of `_.map` for arrays without support for iteratee
* shorthands.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Array} Returns the new mapped array.
*/
function arrayMap(array, iteratee) {
var index = -1,
length = array == null ? 0 : array.length,
result = Array(length);
while (++index < length) {
result[index] = iteratee(array[index], index, array);
}
return result;
}
module.exports = arrayMap;
/***/ }),
/***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arrayPush.js":
/*!************************************************************************************!*\
!*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arrayPush.js ***!
\************************************************************************************/
/***/ (function(module) {
/**
* Appends the elements of `values` to `array`.
*
* @private
* @param {Array} array The array to modify.
* @param {Array} values The values to append.
* @returns {Array} Returns `array`.
*/
function arrayPush(array, values) {
var index = -1,
length = values.length,
offset = array.length;
while (++index < length) {
array[offset + index] = values[index];
}
return array;
}
module.exports = arrayPush;
/***/ }),
/***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arraySome.js":
/*!************************************************************************************!*\
!*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arraySome.js ***!
\************************************************************************************/
/***/ (function(module) {
/**
* A specialized version of `_.some` for arrays without support for iteratee
* shorthands.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} predicate The function invoked per iteration.
* @returns {boolean} Returns `true` if any element passes the predicate check,
* else `false`.
*/
function arraySome(array, predicate) {
var index = -1,
length = array == null ? 0 : array.length;
while (++index < length) {
if (predicate(array[index], index, array)) {
return true;
}
}
return false;
}
module.exports = arraySome;
/***/ }),
/***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_assignValue.js":
/*!**************************************************************************************!*\
!*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_assignValue.js ***!
\**************************************************************************************/
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
var baseAssignValue = __webpack_require__(/*! ./_baseAssignValue */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseAssignValue.js"),
eq = __webpack_require__(/*! ./eq */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/eq.js");
/** Used for built-in method references. */
var objectProto = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/**
* Assigns `value` to `key` of `object` if the existing value is not equivalent
* using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* for equality comparisons.
*
* @private
* @param {Object} object The object to modify.
* @param {string} key The key of the property to assign.
* @param {*} value The value to assign.
*/
function assignValue(object, key, value) {
var objValue = object[key];
if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
(value === undefined && !(key in object))) {
baseAssignValue(object, key, value);
}
}
module.exports = assignValue;
/***/ }),
/***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_assocIndexOf.js":
/*!***************************************************************************************!*\
!*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_assocIndexOf.js ***!
\***************************************************************************************/
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
var eq = __webpack_require__(/*! ./eq */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/eq.js");
/**
* Gets the index at which the `key` is found in `array` of key-value pairs.
*
* @private
* @param {Array} array The array to inspect.
* @param {*} key The key to search for.
* @returns {number} Returns the index of the matched value, else `-1`.
*/
function assocIndexOf(array, key) {
var length = array.length;
while (length--) {
if (eq(array[length][0], key)) {
return length;
}
}
return -1;
}
module.exports = assocIndexOf;
/***/ }),
/***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseAggregator.js":
/*!*****************************************************************************************!*\
!*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseAggregator.js ***!
\*****************************************************************************************/
/***/ (function(module) {
/**
* A specialized version of `baseAggregator` for arrays.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} setter The function to set `accumulator` values.
* @param {Function} iteratee The iteratee to transform keys.
* @param {Object} accumulator The initial aggregated object.
* @returns {Function} Returns `accumulator`.
*/
function arrayAggregator(array, setter, iteratee, accumulator) {
var index = -1,
length = array == null ? 0 : array.length;
while (++index < length) {
var value = array[index];
setter(accumulator, value, iteratee(value), array);
}
return accumulator;
}
module.exports = arrayAggregator;
/**