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,EAAI,EAAI,EAAI,EAAI,GAC1C,MAAM,EAAK,EAAK,EAAI,EAAK,EAAK,EAAI,EAAK,EAAK,EAAI,EAAK,EAAK,EAAI,EAAK,EAAK,EAAI,EAAK,EAAK,EAChF,EAAK,EAAK,EAAK,EAAK,EAAI,EAAK,EAAK,EAAK,EAAK,EAAI,EAAK,EAAK,EAAK,EAAK,EAMpE,EAAI,EAAK,EAAK,EACpB,OAAO,GAAM,EAAK,EAAK,EAAK,GAAM,GAAM,EAAK,EAAK,EAAK,GAAM,GAAM,EAAK,EAAK,EAAK,IAAO,MAAQ,EAAI,CACzG,CAGA,SAAS,OAAO,GACZ,OAAO,EAAI,EAAI,GAAK,EAAI,GAAK,CACjC,CAKA,SAAS,cAAc,KAGd,WAAa,UAAU,OAAS,KAAG,UAAY,IAAI,WAAW,MAC9D,IAAM,GAAG,OAAS,KAAG,GAAK,IAAI,WAAW,MACzC,WAAa,UAAU,OAAS,KAAG,UAAY,IAAI,WAAW,IACnE,IAAI,EAAO,EACX,KAAO,EAAW,EAAJ,GAAO,IAAS,IACzB,QAAU,OAAO,OAAS,KAAQ,OAAS,IAAI,WAAW,GAAO,OAAS,IAAI,YAAY,IAC/F,MAAQ,EAAO,CACnB","file":"/npm/earcut@3.2.4/src/earcut.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.48.0.\n * Original file: /npm/earcut@3.2.4/src/earcut.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/**\n * A vertex in a circular doubly linked list representing a polygon ring.\n * `prev`/`next` are always linked (set immediately after {@link createNode}), so they're typed\n * non-null; `prevZ`/`nextZ` are the z-order list links and are null at the ends.\n *\n * @typedef {object} Node\n * @property {number} i vertex index in the coordinates array\n * @property {number} x vertex x coordinate\n * @property {number} y vertex y coordinate\n * @property {Node} prev previous vertex node in the polygon ring\n * @property {Node} next next vertex node in the polygon ring\n * @property {number} z z-order curve value; doubles as the owning block index during eliminateHoles\n * @property {Node | null} prevZ previous node in z-order\n * @property {Node | null} nextZ next node in z-order\n */\n\n// single-vertex holes to preserve through filterPoints (steiner points); kept off the Node\n// shape since they're rare — the empty-set fast path means non-steiner inputs pay nothing\n/** @type {Set<Node>} */\nconst steiners = new Set();\n\n// set by filterPoints whenever it removes at least one node; read by earcutLinked's stall\n// handler to decide whether another clip pass is worth attempting before the costlier stages\nlet filteredOut = false;\n\n/**\n * Triangulate a polygon given as a flat array of vertex coordinates.\n *\n * @param {ArrayLike<number>} data flat array of vertex coordinates\n * @param {ArrayLike<number> | null} [holeIndices] indices (in vertices, not coordinates) where each hole ring starts\n * @param {number} [dim=2] number of coordinates per vertex in `data`\n * @returns {number[]} triangles as triplets of vertex indices into `data`\n * @example earcut([10,0, 0,50, 60,60, 70,10]); // [1,0,3, 3,2,1]\n */\nexport default function earcut(data, holeIndices, dim = 2) {\n\n    const hasHoles = holeIndices && holeIndices.length;\n    const outerLen = hasHoles ? holeIndices[0] * dim : data.length;\n    if (steiners.size) steiners.clear();\n\n    let outerNode = linkedList(data, 0, outerLen, dim, true);\n    /** @type {number[]} */\n    const triangles = [];\n\n    if (!outerNode || outerNode.next === outerNode.prev) return triangles;\n\n    let minX = 0, minY = 0, invSize = 0;\n\n    if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim);\n\n    // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox\n    if (data.length > 80 * dim) {\n        minX = data[0];\n        minY = data[1];\n        let maxX = minX;\n        let maxY = minY;\n\n        for (let i = dim; i < outerLen; i += dim) {\n            const x = data[i];\n            const y = data[i + 1];\n            if (x < minX) minX = x;\n            if (y < minY) minY = y;\n            if (x > maxX) maxX = x;\n            if (y > maxY) maxY = y;\n        }\n\n        // minX, minY and invSize are later used to transform coords into integers for z-order calculation\n        invSize = Math.max(maxX - minX, maxY - minY);\n        invSize = invSize !== 0 ? 32767 / invSize : 0;\n    }\n\n    earcutLinked(outerNode, triangles, minX, minY, invSize);\n\n    return triangles;\n}\n\n// create a circular doubly linked list from polygon points in the specified winding order\n/** @param {ArrayLike<number>} data @param {number} start @param {number} end @param {number} dim @param {boolean} clockwise @returns {Node | null} */\nfunction linkedList(data, start, end, dim, clockwise) {\n    /** @type {Node | null} */\n    let last = null;\n\n    if (clockwise === (signedArea(data, start, end, dim) > 0)) {\n        for (let i = start; i < end; i += dim) last = insertNode(i / dim | 0, data[i], data[i + 1], last);\n    } else {\n        for (let i = end - dim; i >= start; i -= dim) last = insertNode(i / dim | 0, data[i], data[i + 1], last);\n    }\n\n    if (last && equals(last, last.next)) {\n        removeNode(last);\n        last = last.next;\n    }\n\n    return last;\n}\n\n// Remove collinear or coincident points; removability depends only on a node's immediate\n// neighbors, so we sweep forward and re-check the predecessor after each removal. With no `end`\n// we sweep the whole ring, lapping until nothing is removable (the fixpoint the clipper needs).\n// With an explicit `end` we heal only the dirty window around a bridge/diagonal cut, stopping at\n// `end` rather than lapping — O(window) instead of O(ring).\n/** @param {Node} start @param {Node} [end] @returns {Node} */\nfunction filterPoints(start, end = start) {\n    const full = end === start;\n\n    let p = start, again;\n    do {\n        again = false;\n        if (p !== p.next && (steiners.size === 0 || !steiners.has(p)) &&\n            (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {\n            if (full || p === end) end = p.prev; // pull the stop bound back past the removal\n            filteredOut = true;\n            removeNode(p);\n            p = p.prev;         // re-check the predecessor\n            again = true;\n        } else if (full || p !== end) {\n            p = p.next;\n            again = !full;      // local heal: keep looping until the sweep reaches end\n        }\n    } while (again || p !== end);\n\n    return end;\n}\n\n// main ear slicing loop which triangulates a polygon (given as a linked list)\n/** @param {Node} ear @param {number[]} triangles @param {number} minX @param {number} minY @param {number} invSize */\nfunction earcutLinked(ear, triangles, minX, minY, invSize) {\n    // interlink polygon nodes in z-order\n    if (invSize) indexCurve(ear, minX, minY, invSize);\n\n    let stop = ear, cured = false;\n\n    // iterate through ears, slicing them one by one\n    while (ear.prev !== ear.next) {\n        const prev = ear.prev;\n        /** @type {Node} */\n        const next = ear.next;\n\n        if (area(prev, ear, next) < 0 && (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear))) {\n            triangles.push(prev.i, ear.i, next.i); // cut off the triangle\n\n            removeNode(ear);\n            ear = next;\n            stop = next;\n            continue;\n        }\n\n        ear = next;\n\n        // if we looped through the whole remaining polygon and can't find any more ears\n        if (ear === stop) {\n            // try filtering collinear/coincident points and slicing again — repeat as long as\n            // filtering actually removes nodes, since each removal can expose new ears\n            filteredOut = false;\n            ear = filterPoints(ear);\n            if (filteredOut) { stop = ear; continue; }\n\n            // filtering is exhausted: cure small local self-intersections once, then retry\n            if (!cured) {\n                ear = cureLocalIntersections(ear, triangles);\n                stop = ear;\n                cured = true;\n                continue;\n            }\n\n            // as a last resort, try splitting the remaining polygon into two\n            splitEarcut(ear, triangles, minX, minY, invSize);\n            break;\n        }\n    }\n}\n\n// check whether a polygon node forms a valid ear with adjacent nodes\n/** @param {Node} ear @returns {boolean} */\nfunction isEar(ear) {\n    // reflex check (area(a, b, c) >= 0) is hoisted into the earcutLinked caller to avoid non-inlined call here\n    const a = ear.prev, b = ear, c = ear.next,\n        ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y,\n        x0 = Math.min(ax, bx, cx), // triangle bbox\n        y0 = Math.min(ay, by, cy),\n        x1 = Math.max(ax, bx, cx),\n        y1 = Math.max(ay, by, cy);\n\n    // make sure we don't have other points inside the potential ear\n    let p = c.next;\n    while (p !== a) {\n        if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && !(ax === p.x && ay === p.y) &&\n            pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;\n        p = p.next;\n    }\n    return true;\n}\n\n/** @param {Node} ear @param {number} minX @param {number} minY @param {number} invSize @returns {boolean} */\nfunction isEarHashed(ear, minX, minY, invSize) {\n    // reflex check is hoisted into the earcutLinked caller (see isEar)\n    const a = ear.prev, b = ear, c = ear.next,\n        ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y,\n        x0 = Math.min(ax, bx, cx), // triangle bbox\n        y0 = Math.min(ay, by, cy),\n        x1 = Math.max(ax, bx, cx),\n        y1 = Math.max(ay, by, cy),\n        minZ = zOrder(x0, y0, minX, minY, invSize), // z-order range for the current triangle bbox;\n        maxZ = zOrder(x1, y1, minX, minY, invSize);\n\n    let p = ear.prevZ;\n    while (p && p.z >= minZ) { // look for points inside the triangle in decreasing z-order\n        if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== c && !(ax === p.x && ay === p.y) &&\n            pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;\n        p = p.prevZ;\n    }\n    let n = ear.nextZ;\n    while (n && n.z <= maxZ) { // look for points in increasing z-order\n        if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== c && !(ax === n.x && ay === n.y) &&\n            pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;\n        n = n.nextZ;\n    }\n    return true;\n}\n\n// go through all polygon nodes and cure small local self-intersections\n/** @param {Node} start @param {number[]} triangles @returns {Node} */\nfunction cureLocalIntersections(start, triangles) {\n    let p = start;\n    let cured = false;\n    do {\n        const a = p.prev,\n            b = p.next.next;\n\n        if (intersects(a, p, p.next, b, false) && locallyInside(a, b) && locallyInside(b, a)) {\n\n            triangles.push(a.i, p.i, b.i);\n\n            // remove two nodes involved\n            removeNode(p);\n            removeNode(p.next);\n\n            p = start = b;\n            cured = true;\n        }\n        p = p.next;\n    } while (p !== start);\n\n    return cured ? filterPoints(p) : p;\n}\n\n// try splitting polygon into two and triangulate them independently\n/** @param {Node} start @param {number[]} triangles @param {number} minX @param {number} minY @param {number} invSize */\nfunction splitEarcut(start, triangles, minX, minY, invSize) {\n    // look for a valid diagonal that divides the polygon into two\n    let a = start;\n    do {\n        let b = a.next.next;\n        while (b !== a.prev) {\n            if (a.i !== b.i && isValidDiagonal(a, b)) {\n                // split the polygon in two by the diagonal\n                let c = splitPolygon(a, b);\n\n                // filter colinear points around the cuts\n                a = filterPoints(a, a.next);\n                c = filterPoints(c, c.next);\n\n                // run earcut on each half\n                earcutLinked(a, triangles, minX, minY, invSize);\n                earcutLinked(c, triangles, minX, minY, invSize);\n                return;\n            }\n            b = b.next;\n        }\n        a = a.next;\n    } while (a !== start);\n}\n\n// true only while eliminateHoles merges holes, so removeNode keeps the block index live (growBlock)\nlet indexActive = false;\n\n// link every hole into the outer loop, producing a single-ring polygon without holes\n/** @param {ArrayLike<number>} data @param {ArrayLike<number>} holeIndices @param {Node} outerNode @param {number} dim @returns {Node} */\nfunction eliminateHoles(data, holeIndices, outerNode, dim) {\n    const queue = [];\n\n    for (let i = 0, len = holeIndices.length; i < len; i++) {\n        const start = holeIndices[i] * dim;\n        const end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;\n        const list = /** @type {Node} */ (linkedList(data, start, end, dim, false));\n        if (list === list.next) steiners.add(list);\n        queue.push(getLeftmost(list));\n    }\n\n    queue.sort(compareXYSlope);\n\n    // block-bbox index for findHoleBridge, grown append-only as holes merge (see notes\n    // above buildBlockIndex). Seed it with the outer ring, then append each merged hole.\n    buildBlockIndex(data.length / dim, holeIndices.length);\n    indexSegment(outerNode, outerNode);\n\n    // process holes from left to right; indexActive lets removeNode keep block bboxes live as\n    // filterPoints heals edges during merges (see growBlock)\n    indexActive = true;\n    for (let i = 0; i < queue.length; i++) {\n        outerNode = eliminateHole(queue[i], outerNode);\n    }\n    indexActive = false;\n\n    // collapse collinear/coincident points across the whole merged ring once before clipping\n    return filterPoints(outerNode);\n}\n\n/** @param {Node} a @param {Node} b @returns {number} */\nfunction compareXYSlope(a, b) {\n    // when the left-most point of 2 holes meet at a vertex, sort the holes counterclockwise so that when we find\n    // the bridge to the outer shell is always the point that they meet at.\n    return a.x - b.x || a.y - b.y ||\n        (a.next.y - a.y) / (a.next.x - a.x) -\n        (b.next.y - b.y) / (b.next.x - b.x);\n}\n\n// find a bridge between vertices that connects hole with an outer ring and link it\n/** @param {Node} hole @param {Node} outerNode @returns {Node} */\nfunction eliminateHole(hole, outerNode) {\n    const bridge = findHoleBridge(hole, outerNode);\n    if (!bridge) {\n        return outerNode;\n    }\n\n    const bridgeReverse = splitPolygon(bridge, hole);\n\n    // index the merged-in segment before filtering: in ring order the splice runs\n    // bridge -> hole -> bridgeReverse -> bridge2 -> (bridge's old next), covering the\n    // hole's edges and both new slit edges. filterPoints below only drops collinear /\n    // coincident points, so these bboxes stay valid (conservative) supersets.\n    const bridge2 = bridgeReverse.next;\n    indexSegment(bridge, bridge2.next);\n\n    // heal collinear/coincident points around the two new slit edges\n    filterPoints(bridgeReverse, bridgeReverse.next);\n    return filterPoints(bridge, bridge.next);\n}\n\n// Block-bbox index for findHoleBridge (issue #183): one [minX,minY,maxX,maxY] bbox per K\n// consecutive ring edges, in a flat Float64Array, so the leftward-ray scan can skip whole\n// blocks in O(1) instead of walking the entire merged ring. Grown append-only — the outer\n// ring seeds it, then each merged hole appends a segment (head node, stop node, K-blocks\n// over head..stop); independent segments, not a ring tiling, since splices land mid-ring.\n// Buffers are sized once from the input upper bound and reused across calls.\n//\n// filterPoints only drops collinear/coincident points, so a stale bbox stays a conservative\n// superset of its live edges (never a false skip); the scan skips dead nodes (p.prev.next !==\n// p) and lazily advances a dead stop. Blocks are scanned in append (not ring) order, so the\n// chosen bridge can differ from the un-indexed code — a different but equally valid result.\nconst K = 16; // edges per block\n\nlet blockBBox = new Float64Array(0); // [minX,minY,maxX,maxY] per block\nlet numBlocks = 0;\n/** @type {Node[]} */\nconst blockHead = []; // first node of each block's segment\n/** @type {Node[]} */\nconst blockStop = []; // node just past each block's segment (exclusive walk bound)\n\n/** @param {number} maxNodes @param {number} numHoles */\nfunction buildBlockIndex(maxNodes, numHoles) {\n    // upper bound: every input node indexed once, +2 bridge nodes per hole, plus a partial\n    // trailing block per appended segment (outer ring + one per hole)\n    const maxBlocks = Math.ceil((maxNodes + 2 * numHoles) / K) + numHoles + 2;\n    if (blockBBox.length < maxBlocks * 4) blockBBox = new Float64Array(maxBlocks * 4);\n    numBlocks = 0;\n}\n\n// index the ring run head..stop (exclusive) as ceil(len / K) blocks; head === stop means\n// the whole ring. each block's bbox covers both endpoints of every edge it owns.\n/** @param {Node} head @param {Node} stop */\nfunction indexSegment(head, stop) {\n    let p = head;\n    do {\n        const b = numBlocks++;\n        blockHead[b] = p;\n        let minX = p.x, minY = p.y, maxX = p.x, maxY = p.y;\n        let k = 0;\n        do {\n            const c = p.next; // edge p->c; bbox must bound both endpoints\n            p.z = b; // reuse z as the owning block during eliminateHoles (see growBlock)\n            if (c.x < minX) minX = c.x; if (c.x > maxX) maxX = c.x;\n            if (c.y < minY) minY = c.y; if (c.y > maxY) maxY = c.y;\n            p = c;\n        } while (++k < K && p !== stop);\n        blockStop[b] = p;\n        const g = b * 4;\n        blockBBox[g] = minX; blockBBox[g + 1] = minY; blockBBox[g + 2] = maxX; blockBBox[g + 3] = maxY;\n    } while (p !== stop);\n}\n\n// when filterPoints heals an edge head->tail (removing the collinear node between them), the\n// healed edge can extend past head's frozen block bbox if its old far endpoint lived in another\n// block; grow head's block bbox to cover tail so the leftward-ray prune can't false-skip it.\n/** @param {Node} head @param {Node} tail */\nfunction growBlock(head, tail) {\n    const g = head.z * 4;\n    if (tail.x < blockBBox[g]) blockBBox[g] = tail.x;\n    if (tail.y < blockBBox[g + 1]) blockBBox[g + 1] = tail.y;\n    if (tail.x > blockBBox[g + 2]) blockBBox[g + 2] = tail.x;\n    if (tail.y > blockBBox[g + 3]) blockBBox[g + 3] = tail.y;\n}\n\n/** @param {number} b @returns {Node} */\nfunction liveBlockStop(b) {\n    let stop = blockStop[b];\n    while (stop.prev.next !== stop) stop = stop.next;\n    blockStop[b] = stop;\n    return stop;\n}\n\n// the block's head node can be removed by filterPoints during merges; advance it to the next\n// live node so the walk doesn't start on (and immediately terminate at) a dead node. For the\n// single full-ring seed block (head === stop) the same forward advance keeps them equal, so the\n// do-while still laps the whole ring instead of collapsing to an empty walk.\n/** @param {number} b @returns {Node} */\nfunction liveBlockHead(b) {\n    let head = blockHead[b];\n    while (head.prev.next !== head) head = head.next;\n    blockHead[b] = head;\n    return head;\n}\n\n// David Eberly's algorithm for finding a bridge between hole and outer polygon\n/** @param {Node} hole @param {Node} outerNode @returns {Node | null} */\nfunction findHoleBridge(hole, outerNode) {\n    let p = outerNode;\n    const hx = hole.x;\n    const hy = hole.y;\n    let qx = -Infinity;\n    /** @type {Node | undefined} */\n    let m;\n\n    // find a segment intersected by a ray from the hole's leftmost point to the left;\n    // segment's endpoint with lesser x will be potential connection point\n    // unless they intersect at a vertex, then choose the vertex\n    if (equals(hole, p)) return p;\n\n    // scan blocks; skip any whose bbox can't hold a crossing that beats qx and lies left\n    // of hx (the prune Morton order can't express — explicit per-axis [minY,maxY]/[minX,maxX])\n    for (let b = 0, g = 0; b < numBlocks; b++, g += 4) {\n        if (hy < blockBBox[g + 1] || hy > blockBBox[g + 3] || blockBBox[g] > hx || blockBBox[g + 2] <= qx) continue;\n\n        // ensure the walk's exclusive bound is live so we don't overrun into other blocks\n        const stop = liveBlockStop(b);\n\n        p = liveBlockHead(b);\n        do {\n            if (p.prev.next === p) { // skip nodes removed by filterPoints (stale in the index)\n                if (equals(hole, p.next)) return p.next;\n                else if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {\n                    const x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);\n                    if (x <= hx && x > qx) {\n                        qx = x;\n                        m = p.x < p.next.x ? p : p.next;\n                        if (x === hx) return m; // hole touches outer segment; pick leftmost endpoint\n                    }\n                }\n            }\n            p = p.next;\n        } while (p !== stop);\n    }\n\n    if (!m) return null;\n\n    // look for points inside the triangle of hole point, segment intersection and endpoint;\n    // if there are no points found, we have a valid connection;\n    // otherwise choose the point of the minimum angle with the ray as connection point\n\n    const mx = m.x;\n    const my = m.y;\n    const tminY = Math.min(hy, my); // the triangle's y span; x span is [mx, hx]\n    const tmaxY = Math.max(hy, my);\n    let tanMin = Infinity;\n\n    // scan the same blocks; skip any whose bbox can't overlap the triangle's [mx,hx]×[tminY,tmaxY] box\n    for (let b = 0, g = 0; b < numBlocks; b++, g += 4) {\n        if (blockBBox[g + 2] < mx || blockBBox[g] > hx || blockBBox[g + 3] < tminY || blockBBox[g + 1] > tmaxY) continue;\n\n        const stop = liveBlockStop(b);\n\n        p = liveBlockHead(b);\n        do {\n            if (p.prev.next === p && hx >= p.x && p.x >= mx && hx !== p.x && // skip dead nodes\n                    pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {\n\n                const tan = Math.abs(hy - p.y) / (hx - p.x); // tangential\n\n                // if hole point sits on p's horizontal edge (T-junction touch): the bridge runs\n                // along that edge — locallyInside rejects it as collinear, but it's valid\n                if ((locallyInside(p, hole) || (p.y === hy && p.next.y === hy && p.next.x > hx)) &&\n                    (tan < tanMin || (tan === tanMin && (p.x > m.x || (p.x === m.x && sectorContainsSector(m, p)))))) {\n                    m = p;\n                    tanMin = tan;\n                }\n            }\n\n            p = p.next;\n        } while (p !== stop);\n    }\n\n    return m;\n}\n\n// whether sector in vertex m contains sector in vertex p in the same coordinates\n/** @param {Node} m @param {Node} p @returns {boolean} */\nfunction sectorContainsSector(m, p) {\n    return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0;\n}\n\n// scratch buffers reused across calls and grown on demand: two node-ref arrays that\n// ping-pong during the radix passes, plus parallel z-value arrays so the passes read\n// z from contiguous memory instead of dereferencing each node. 256-entry histogram for\n// 8-bit digits; the small histogram keeps per-call setup cheap (most rings are short)\n/** @type {Node[]} */\nconst sortArr = [];\n/** @type {Node[]} */\nlet sortBuf = [];\nlet zArr = new Uint32Array(0);\nlet zBuf = new Uint32Array(0);\nconst counts = new Uint32Array(256);\n\n// interlink polygon nodes in z-order: collect into an array, sort by z, relink\n/** @param {Node} start @param {number} minX @param {number} minY @param {number} invSize */\nfunction indexCurve(start, minX, minY, invSize) {\n    let p = start;\n    let n = 0;\n    do {\n        // always (re)compute: z may still hold a block index left over from eliminateHoles\n        p.z = zOrder(p.x, p.y, minX, minY, invSize);\n        sortArr[n++] = p;\n        p = p.next;\n    } while (p !== start);\n\n    sortNodes(n);\n\n    /** @type {Node | null} */\n    let prev = null;\n    for (let i = 0; i < n; i++) {\n        const node = sortArr[i];\n        node.prevZ = prev;\n        if (prev) prev.nextZ = node;\n        prev = node;\n    }\n    /** @type {Node} */ (prev).nextZ = null;\n\n    // drop the node refs but keep the capacity: setting length to 0 leaves sortBuf unresized\n    // (its growth is gated on zArr), so the radix scatter regrows it out of order every call\n    sortArr.fill(/** @type {Node} */ (/** @type {unknown} */ (null)), 0, n);\n    sortBuf.fill(/** @type {Node} */ (/** @type {unknown} */ (null)), 0, n);\n}\n\n// sort the first n nodes of sortArr by z, in place: insertion sort for small n (cheaper\n// than histogram setup), else LSD radix in four 8-bit passes (covering z's 30 bits)\n/** @param {number} n */\nfunction sortNodes(n) {\n    if (n <= 32) {\n        for (let i = 1; i < n; i++) {\n            const node = sortArr[i], z = node.z;\n            let j = i - 1;\n            while (j >= 0 && sortArr[j].z > z) { sortArr[j + 1] = sortArr[j]; j--; }\n            sortArr[j + 1] = node;\n        }\n        return;\n    }\n\n    if (zArr.length < n) {\n        zArr = new Uint32Array(n);\n        zBuf = new Uint32Array(n);\n        sortBuf = new Array(n);\n    }\n    for (let i = 0; i < n; i++) zArr[i] = sortArr[i].z;\n\n    // even pass count lands the sorted result back in sortArr\n    radixPass(n, sortArr, zArr, sortBuf, zBuf, 0);\n    radixPass(n, sortBuf, zBuf, sortArr, zArr, 8);\n    radixPass(n, sortArr, zArr, sortBuf, zBuf, 16);\n    radixPass(n, sortBuf, zBuf, sortArr, zArr, 24);\n}\n\n// one LSD radix pass: stably scatter the first n nodes (and their z) from src to dst,\n// bucketed by the 8-bit digit of z at the given bit shift\n/** @param {number} n @param {Node[]} src @param {Uint32Array} srcZ @param {Node[]} dst @param {Uint32Array} dstZ @param {number} shift */\nfunction radixPass(n, src, srcZ, dst, dstZ, shift) {\n    counts.fill(0);\n    for (let i = 0; i < n; i++) counts[(srcZ[i] >>> shift) & 0xff]++;\n    // turn per-bucket counts into start offsets (prefix sum)\n    let sum = 0;\n    for (let b = 0; b < 256; b++) { const c = counts[b]; counts[b] = sum; sum += c; }\n    for (let i = 0; i < n; i++) {\n        const z = srcZ[i];\n        const pos = counts[(z >>> shift) & 0xff]++;\n        dst[pos] = src[i];\n        dstZ[pos] = z;\n    }\n}\n\n// z-order of a point given coords and inverse of the longer side of data bbox\n/** @param {number} x @param {number} y @param {number} minX @param {number} minY @param {number} invSize @returns {number} */\nfunction zOrder(x, y, minX, minY, invSize) {\n    // coords are transformed into non-negative 15-bit integer range\n    x = (x - minX) * invSize | 0;\n    y = (y - minY) * invSize | 0;\n\n    x = (x | (x << 8)) & 0x00FF00FF;\n    x = (x | (x << 4)) & 0x0F0F0F0F;\n    x = (x | (x << 2)) & 0x33333333;\n    x = (x | (x << 1)) & 0x55555555;\n\n    y = (y | (y << 8)) & 0x00FF00FF;\n    y = (y | (y << 4)) & 0x0F0F0F0F;\n    y = (y | (y << 2)) & 0x33333333;\n    y = (y | (y << 1)) & 0x55555555;\n\n    return x | (y << 1);\n}\n\n// find the leftmost node of a polygon ring\n/** @param {Node} start @returns {Node} */\nfunction getLeftmost(start) {\n    let p = start,\n        leftmost = start;\n    do {\n        if (p.x < leftmost.x || (p.x === leftmost.x && p.y < leftmost.y)) leftmost = p;\n        p = p.next;\n    } while (p !== start);\n\n    return leftmost;\n}\n\n// check if a point lies within a convex triangle\n/** @param {number} ax @param {number} ay @param {number} bx @param {number} by @param {number} cx @param {number} cy @param {number} px @param {number} py @returns {boolean} */\nfunction pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {\n    return (cx - px) * (ay - py) >= (ax - px) * (cy - py) &&\n           (ax - px) * (by - py) >= (bx - px) * (ay - py) &&\n           (bx - px) * (cy - py) >= (cx - px) * (by - py);\n}\n\n// check if a diagonal between two polygon nodes is valid (lies in polygon interior)\n/** @param {Node} a @param {Node} b @returns {boolean} true when the diagonal is valid */\nfunction isValidDiagonal(a, b) {\n    const zeroLength = equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0; // degenerate case\n    return a.next.i !== b.i && (zeroLength || locallyInside(a, b) && locallyInside(b, a) && // // locally visible\n        (area(a.prev, a, b.prev) !== 0 || area(a, b.prev, b) !== 0)) && // no opposite-facing sectors\n        !intersectsPolygon(a, b) && (zeroLength || middleInside(a, b)); // doesn't intersect other edges, diagonal inside polygon\n}\n\n// signed area of a triangle\n/** @param {Node} p @param {Node} q @param {Node} r @returns {number} */\nfunction area(p, q, r) {\n    return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);\n}\n\n// check if two points are equal\n/** @param {Node} p1 @param {Node} p2 @returns {boolean} */\nfunction equals(p1, p2) {\n    return p1.x === p2.x && p1.y === p2.y;\n}\n\n// check if two segments intersect; by default includes collinear boundary touches\n/** @param {Node} p1 @param {Node} q1 @param {Node} p2 @param {Node} q2 @param {boolean} [includeBoundary] @returns {boolean} */\nfunction intersects(p1, q1, p2, q2, includeBoundary = true) {\n    const o1 = area(p1, q1, p2);\n    const o2 = area(p1, q1, q2);\n    const o3 = area(p2, q2, p1);\n    const o4 = area(p2, q2, q1);\n\n    if (((o1 > 0 && o2 < 0) || (o1 < 0 && o2 > 0)) && ((o3 > 0 && o4 < 0) || (o3 < 0 && o4 > 0))) return true;\n\n    if (!includeBoundary) return false;\n\n    if (o1 === 0 && onSegment(p1, p2, q1)) return true; // p1, q1 and p2 are collinear and p2 lies on p1q1\n    if (o2 === 0 && onSegment(p1, q2, q1)) return true; // p1, q1 and q2 are collinear and q2 lies on p1q1\n    if (o3 === 0 && onSegment(p2, p1, q2)) return true; // p2, q2 and p1 are collinear and p1 lies on p2q2\n    if (o4 === 0 && onSegment(p2, q1, q2)) return true; // p2, q2 and q1 are collinear and q1 lies on p2q2\n\n    return false;\n}\n\n// for collinear points p, q, r, check if point q lies on segment pr\n/** @param {Node} p @param {Node} q @param {Node} r @returns {boolean} */\nfunction onSegment(p, q, r) {\n    return q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y);\n}\n\n// check if a polygon diagonal intersects any polygon segments\n/** @param {Node} a @param {Node} b @returns {boolean} */\nfunction intersectsPolygon(a, b) {\n    // diagonal bbox; an edge whose bbox can't overlap it can't intersect it, so\n    // skip the orientation test for those (the common case — the diagonal is short)\n    const minX = Math.min(a.x, b.x);\n    const maxX = Math.max(a.x, b.x);\n    const minY = Math.min(a.y, b.y);\n    const maxY = Math.max(a.y, b.y);\n\n    let p = a;\n    do {\n        const n = p.next;\n        if ((p.x > maxX && n.x > maxX) || (p.x < minX && n.x < minX) ||\n            (p.y > maxY && n.y > maxY) || (p.y < minY && n.y < minY)) {\n            p = n;\n            continue;\n        }\n        if (p.i !== a.i && n.i !== a.i && p.i !== b.i && n.i !== b.i &&\n                intersects(p, n, a, b)) return true;\n        p = n;\n    } while (p !== a);\n\n    return false;\n}\n\n// check if a polygon diagonal is locally inside the polygon\n/** @param {Node} a @param {Node} b @returns {boolean} */\nfunction locallyInside(a, b) {\n    return area(a.prev, a, a.next) < 0 ?\n        area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 :\n        area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;\n}\n\n// check if the middle point of a polygon diagonal is inside the polygon\n/** @param {Node} a @param {Node} b @returns {boolean} */\nfunction middleInside(a, b) {\n    let p = a;\n    let inside = false;\n    const px = (a.x + b.x) / 2;\n    const py = (a.y + b.y) / 2;\n    do {\n        const n = p.next;\n        if (((p.y > py) !== (n.y > py)) && (px < (n.x - p.x) * (py - p.y) / (n.y - p.y) + p.x))\n            inside = !inside;\n        p = n;\n    } while (p !== a);\n\n    return inside;\n}\n\n// link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two;\n// if one belongs to the outer ring and another to a hole, it merges it into a single ring\n/** @param {Node} a @param {Node} b @returns {Node} */\nfunction splitPolygon(a, b) {\n    const a2 = createNode(a.i, a.x, a.y),\n        b2 = createNode(b.i, b.x, b.y),\n        an = a.next,\n        bp = b.prev;\n\n    a.next = b;\n    b.prev = a;\n\n    a2.next = an;\n    an.prev = a2;\n\n    b2.next = a2;\n    a2.prev = b2;\n\n    bp.next = b2;\n    b2.prev = bp;\n\n    return b2;\n}\n\n// create a node and optionally link it with previous one (in a circular doubly linked list)\n/** @param {number} i @param {number} x @param {number} y @param {Node | null} last @returns {Node} */\nfunction insertNode(i, x, y, last) {\n    const p = createNode(i, x, y);\n\n    if (!last) {\n        p.prev = p;\n        p.next = p;\n\n    } else {\n        p.next = last.next;\n        p.prev = last;\n        last.next.prev = p;\n        last.next = p;\n    }\n    return p;\n}\n\n/** @param {Node} p */\nfunction removeNode(p) {\n    p.next.prev = p.prev;\n    p.prev.next = p.next;\n\n    if (p.prevZ) p.prevZ.nextZ = p.nextZ;\n    if (p.nextZ) p.nextZ.prevZ = p.prevZ;\n\n    // keep the hole-bridge index's block bboxes covering the healed prev->next edge\n    if (indexActive) growBlock(p.prev, p.next);\n}\n\n/** @param {number} i @param {number} x @param {number} y @returns {Node} */\nfunction createNode(i, x, y) {\n    // prev/next are assigned by the caller before any read, so the null init is cast away here\n    return /** @type {Node} */ (/** @type {unknown} */ ({\n        i, // vertex index in coordinates array\n        x, y, // vertex coordinates\n        prev: null, // previous and next vertex nodes in a polygon ring\n        next: null,\n        z: 0, // z-order curve value; doubles as owning block in the hole-bridge index during eliminateHoles\n        prevZ: null, // previous and next nodes in z-order\n        nextZ: null\n    }));\n}\n\n/**\n * Return the relative difference between the polygon area and the area of its triangulation —\n * a value near 0 means a correct triangulation. Useful for verifying output in tests.\n *\n * @param {ArrayLike<number>} data\n * @param {ArrayLike<number> | null} holeIndices\n * @param {number} dim number of coordinates per vertex in `data`\n * @param {ArrayLike<number>} triangles output of {@link earcut}\n * @returns {number}\n * @example deviation(data, holes, dim, earcut(data, holes, dim)); // ~0 if correct\n */\nexport function deviation(data, holeIndices, dim, triangles) {\n    const hasHoles = holeIndices && holeIndices.length;\n    const outerLen = hasHoles ? holeIndices[0] * dim : data.length;\n\n    let polygonArea = Math.abs(signedArea(data, 0, outerLen, dim));\n    if (hasHoles) {\n        for (let i = 0, len = holeIndices.length; i < len; i++) {\n            const start = holeIndices[i] * dim;\n            const end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;\n            polygonArea -= Math.abs(signedArea(data, start, end, dim));\n        }\n    }\n\n    let trianglesArea = 0;\n    for (let i = 0; i < triangles.length; i += 3) {\n        const a = triangles[i] * dim;\n        const b = triangles[i + 1] * dim;\n        const c = triangles[i + 2] * dim;\n        trianglesArea += Math.abs(\n            (data[a] - data[c]) * (data[b + 1] - data[a + 1]) -\n            (data[a] - data[b]) * (data[c + 1] - data[a + 1]));\n    }\n\n    // with no triangles, a polygon area within shoelace roundoff of zero (which scales with the\n    // squared coordinate magnitude) means the input was degenerate rather than mistriangulated\n    if (trianglesArea === 0) {\n        let max = 0;\n        for (let i = 0; i < data.length; i += dim) max = Math.max(max, Math.abs(data[i]), Math.abs(data[i + 1]));\n        return Math.abs(polygonArea) <= data.length * max * max * Number.EPSILON ? 0 : 1;\n    }\n    return Math.abs((trianglesArea - polygonArea) / polygonArea);\n}\n\n/** @param {ArrayLike<number>} data @param {number} start @param {number} end @param {number} dim @returns {number} */\nfunction signedArea(data, start, end, dim) {\n    let sum = 0;\n    for (let i = start, j = end - dim; i < end; i += dim) {\n        sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);\n        j = i;\n    }\n    return sum;\n}\n\n/**\n * Turn a polygon in multi-dimensional array form (e.g. as in GeoJSON) into the flat form Earcut accepts.\n *\n * @param {ReadonlyArray<ReadonlyArray<ArrayLike<number>>>} data array of rings; the first ring is the outer contour, the rest are holes\n * @returns {{vertices: number[], holes: number[], dimensions: number}}\n * @example const {vertices, holes, dimensions} = flatten(geojson.coordinates);\n */\nexport function flatten(data) {\n    const vertices = [];\n    const holes = [];\n    const dimensions = data[0][0].length;\n    let holeIndex = 0;\n    let prevLen = 0;\n\n    for (const ring of data) {\n        for (const p of ring) {\n            for (let d = 0; d < dimensions; d++) vertices.push(p[d]);\n        }\n        if (prevLen) {\n            holeIndex += prevLen;\n            holes.push(holeIndex);\n        }\n        prevLen = ring.length;\n    }\n    return {vertices, holes, dimensions};\n}\n\n// Reusable module-level scratch for refine():\n//   he      = twin half-edge of each edge, or -1 on the polygon boundary\n//   hTable  = open-addressing hash, slot -> half-edge index, valid iff hStamp[slot] === gen\n//   edgeStamp = pending-in-stack flag, cleared when the edge is popped\n/** @type {Int32Array} */ let edgeStack;\n/** @type {Int32Array} */ let he;\n/** @type {Int32Array} */ let hTable;\n/** @type {Uint32Array} */ let hStamp;\n/** @type {Uint8Array} */ let edgeStamp;\nlet hMask = 0, gen = 0;\n\n/**\n * Refine a triangulation toward the constrained Delaunay triangulation by legalizing every\n * interior edge in place with Lawson flips — maximizing the minimum angle and removing most\n * slivers. An optional post-pass for {@link earcut} output, or any manifold triangle-index array\n * indexing into `coords`. Adapted from delaunator's edge legalization.\n *\n * Uses non-robust predicates: float input is fine, and the worst case is a not-quite-Delaunay\n * edge, never an invalid mesh.\n *\n * @param {number[]} triangles triangle indices, as returned by {@link earcut}; mutated in place\n * @param {ArrayLike<number>} coords the flat vertex coordinates passed to {@link earcut}\n * @param {number} [dim=2] number of coordinates per vertex in `coords`\n * @example refine(earcut(data), data);\n */\nexport function refine(triangles, coords, dim = 2) {\n    const t = triangles;\n    const n = t.length;\n    if (n < 6) return;\n    ensureScratch(n);\n    gen++;              // bumping the generation logically empties the hash (no clearing)\n    he.fill(-1, 0, n);\n\n    // Build half-edge twins with an undirected-edge hash; consumed slots mark linked pairs. As each\n    // pair is linked we seed the stack with one representative (s, the earlier-inserted edge) — this\n    // fuses the initial \"push every interior edge\" pass into the build, saving a full O(n) scan.\n    // edgeStamp is all-zero here (balanced push/pop leaves it clean) and each pair links once, so\n    // the seed write needs no dedup guard.\n    let i = 0;\n    for (let e = 0; e < n; e++) {\n        const a = t[e], b = t[nextHE(e)];\n        const lo = a < b ? a : b, hi = a < b ? b : a;\n        let h = (Math.imul(lo, 0x9e3779b1) ^ Math.imul(hi, 0x85ebca6b)) & hMask;\n        while (hStamp[h] === gen) {\n            const s = hTable[h];\n            // s === -1 marks a consumed slot (a pair already linked) — skip past it\n            if (s !== -1) {\n                const sa = t[s], sb = t[nextHE(s)];\n                if ((sa === lo && sb === hi) || (sa === hi && sb === lo)) {\n                    he[e] = s; he[s] = e; hTable[h] = -1; // link, then consume the slot\n                    edgeStamp[s] = 1; edgeStack[i++] = s; // seed the interior edge for the cascade\n                    break;\n                }\n            }\n            h = (h + 1) & hMask;\n        }\n        if (hStamp[h] !== gen) { hTable[h] = e; hStamp[h] = gen; } // first occurrence: insert\n    }\n\n    while (i > 0) {\n        const a = edgeStack[--i];\n        edgeStamp[a] = 0;\n        const b = he[a];\n        if (b === -1) continue;\n\n        const a0 = a - a % 3;\n        const b0 = b - b % 3;\n        const ar = a0 + (a + 2) % 3;\n        const al = a0 + (a + 1) % 3;\n        const bl = b0 + (b + 2) % 3;\n        const br = b0 + (b + 1) % 3;\n        const p0 = t[ar], pr = t[a], pl = t[al], p1 = t[bl];\n\n        const x0 = coords[p0 * dim], y0 = coords[p0 * dim + 1];\n        const xr = coords[pr * dim], yr = coords[pr * dim + 1];\n        const xl = coords[pl * dim], yl = coords[pl * dim + 1];\n        const x1 = coords[p1 * dim], y1 = coords[p1 * dim + 1];\n\n        // Test inCircle first: most interior edges are already Delaunay (inCircle true → no flip),\n        // so this short-circuits before the two convexity orients on the common path. The quad must\n        // also be convex (both new triangles CCW) — flipping a reflex quad would push a triangle\n        // outside the polygon. Boundary/hole edges need no guard — they self-protect via he === -1.\n        if (!inCircle(x0, y0, xr, yr, xl, yl, x1, y1) &&\n            orient(x0, y0, xr, yr, x1, y1) > 0 && orient(x0, y0, x1, y1, xl, yl) > 0) {\n            t[a] = p1; t[b] = p0;\n            const hbl = he[bl], har = he[ar];\n            he[a] = hbl; if (hbl !== -1) he[hbl] = a;\n            he[b] = har; if (har !== -1) he[har] = b;\n            he[ar] = bl; he[bl] = ar;\n\n            // re-check the quad's four outer edges; skip boundary edges (he === -1) and any\n            // already queued (edgeStamp), which also keeps the stack bounded by n.\n            if (hbl    !== -1 && edgeStamp[a]  === 0) { edgeStamp[a]  = 1; edgeStack[i++] = a; }\n            if (har    !== -1 && edgeStamp[b]  === 0) { edgeStamp[b]  = 1; edgeStack[i++] = b; }\n            if (he[al] !== -1 && edgeStamp[al] === 0) { edgeStamp[al] = 1; edgeStack[i++] = al; }\n            if (he[br] !== -1 && edgeStamp[br] === 0) { edgeStamp[br] = 1; edgeStack[i++] = br; }\n        }\n    }\n}\n\n/** @param {number} ax @param {number} ay @param {number} bx @param {number} by @param {number} cx @param {number} cy */\nfunction orient(ax, ay, bx, by, cx, cy) {\n    return (bx - ax) * (cy - ay) - (by - ay) * (cx - ax);\n}\n\n// Whether p is inside or exactly on the circumcircle of triangle (a, b, c). Sign is negated vs the\n// usual predicate to match earcut's CCW winding — the standard sign would build the anti-Delaunay\n// mesh. Cocircular quads are legal ties, so refine only flips when this returns false.\n/** @param {number} ax @param {number} ay @param {number} bx @param {number} by @param {number} cx @param {number} cy @param {number} px @param {number} py */\nfunction inCircle(ax, ay, bx, by, cx, cy, px, py) {\n    const dx = ax - px, dy = ay - py, ex = bx - px, ey = by - py, fx = cx - px, fy = cy - py;\n    const ap = dx * dx + dy * dy, bp = ex * ex + ey * ey, cp = fx * fx + fy * fy;\n    // A near-cocircular quad is a legal Delaunay tie, but roundoff can flag both an edge and its\n    // flip as illegal, cascading into an endless flip loop (#205) — so treat a determinant within\n    // a small margin of zero as a tie. The determinant's worst-case roundoff error is provably\n    // below 9e-16·(ap + bp + cp)² (Shewchuk-style bound), so the margin guarantees every executed\n    // flip is illegal in exact arithmetic, and Lawson flipping always terminates.\n    const s = ap + bp + cp;\n    return dx * (ey * cp - bp * fy) - dy * (ex * cp - bp * fx) + ap * (ex * fy - ey * fx) <= 1e-13 * s * s;\n}\n\n/** @param {number} e */\nfunction nextHE(e) { // next half-edge within the same triangle\n    return e - e % 3 + (e + 1) % 3;\n}\n\n// Grow the scratch arrays on demand (like earcut's z-order arrays). Allocating lazily here rather\n// than at module load lets the whole refine() block tree-shake away for callers who don't use it.\n/** @param {number} n */\nfunction ensureScratch(n) {\n    // edgeStack holds at most one entry per half-edge (edgeStamp dedups), so n is a safe cap —\n    // sizing it up front lets the cascade push without a bounds/grow check.\n    if (!edgeStack || edgeStack.length < n) edgeStack = new Int32Array(n);\n    if (!he || he.length < n) he = new Int32Array(n);\n    if (!edgeStamp || edgeStamp.length < n) edgeStamp = new Uint8Array(n);\n    let size = 1;\n    while (size < n * 4) size <<= 1; // power-of-two table, load factor <= 0.25\n    if (!hTable || hTable.length < size) { hTable = new Int32Array(size); hStamp = new Uint32Array(size); }\n    hMask = size - 1;\n}\n"]}